@pluno/product-agent-web 0.1.24 → 0.1.25
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/product-agent-widget.js +748 -729
- package/package.json +1 -1
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { PlunoProductAgent as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
const
|
|
1
|
+
import { PlunoProductAgent as zt } from "./product-agent-sdk.js";
|
|
2
|
+
const Gt = "#7c3aed";
|
|
3
|
+
function Ut(e) {
|
|
4
|
+
const t = qt(e);
|
|
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">
|
|
8
|
-
<stop offset="0" stop-color="${
|
|
9
|
-
<stop offset="0.36" stop-color="${
|
|
10
|
-
<stop offset="0.72" stop-color="${
|
|
11
|
-
<stop offset="1" stop-color="${
|
|
8
|
+
<stop offset="0" stop-color="${t.top}"/>
|
|
9
|
+
<stop offset="0.36" stop-color="${t.middle}"/>
|
|
10
|
+
<stop offset="0.72" stop-color="${t.bottom}"/>
|
|
11
|
+
<stop offset="1" stop-color="${t.bottom}"/>
|
|
12
12
|
</linearGradient>
|
|
13
13
|
<linearGradient id="boltEdge" x1="470" y1="145" x2="900" y2="980" gradientUnits="userSpaceOnUse">
|
|
14
|
-
<stop offset="0" stop-color="${
|
|
15
|
-
<stop offset="0.32" stop-color="${
|
|
16
|
-
<stop offset="0.78" stop-color="${
|
|
17
|
-
<stop offset="1" stop-color="${
|
|
14
|
+
<stop offset="0" stop-color="${t.edgeStart}"/>
|
|
15
|
+
<stop offset="0.32" stop-color="${t.edgeMiddle}"/>
|
|
16
|
+
<stop offset="0.78" stop-color="${t.edgeEnd}"/>
|
|
17
|
+
<stop offset="1" stop-color="${t.edgeEnd}"/>
|
|
18
18
|
</linearGradient>
|
|
19
19
|
<radialGradient id="boltGlow" cx="50%" cy="22%" r="82%">
|
|
20
|
-
<stop offset="0" stop-color="${
|
|
21
|
-
<stop offset="0.5" stop-color="${
|
|
22
|
-
<stop offset="1" stop-color="${
|
|
20
|
+
<stop offset="0" stop-color="${t.glow}" stop-opacity="0.72"/>
|
|
21
|
+
<stop offset="0.5" stop-color="${t.middle}" stop-opacity="0.44"/>
|
|
22
|
+
<stop offset="1" stop-color="${t.bottom}" stop-opacity="0"/>
|
|
23
23
|
</radialGradient>
|
|
24
24
|
<radialGradient id="eyeWhite" cx="35%" cy="25%" r="70%">
|
|
25
25
|
<stop offset="0" stop-color="#ffffff"/>
|
|
@@ -32,7 +32,7 @@ function Ft(t) {
|
|
|
32
32
|
<stop offset="1" stop-color="#000000"/>
|
|
33
33
|
</radialGradient>
|
|
34
34
|
<filter id="softDropShadow" x="-18%" y="-12%" width="136%" height="136%" color-interpolation-filters="sRGB">
|
|
35
|
-
<feDropShadow dx="0" dy="12" stdDeviation="18" flood-color="${
|
|
35
|
+
<feDropShadow dx="0" dy="12" stdDeviation="18" flood-color="${t.shadow}" flood-opacity="0.24"/>
|
|
36
36
|
</filter>
|
|
37
37
|
<filter id="innerDepth" x="-8%" y="-8%" width="116%" height="116%" color-interpolation-filters="sRGB">
|
|
38
38
|
<feGaussianBlur in="SourceAlpha" stdDeviation="8" result="blur"/>
|
|
@@ -42,7 +42,7 @@ function Ft(t) {
|
|
|
42
42
|
<feBlend in="SourceGraphic" in2="innerLight" mode="screen"/>
|
|
43
43
|
</filter>
|
|
44
44
|
<filter id="eyeShadow" x="-24%" y="-20%" width="148%" height="148%" color-interpolation-filters="sRGB">
|
|
45
|
-
<feDropShadow dx="0" dy="8" stdDeviation="5" flood-color="${
|
|
45
|
+
<feDropShadow dx="0" dy="8" stdDeviation="5" flood-color="${t.shadow}" flood-opacity="0.3"/>
|
|
46
46
|
</filter>
|
|
47
47
|
<filter id="pupilGloss" x="-15%" y="-15%" width="130%" height="130%" color-interpolation-filters="sRGB">
|
|
48
48
|
<feDropShadow dx="0" dy="3" stdDeviation="3" flood-color="#000000" flood-opacity="0.22"/>
|
|
@@ -56,9 +56,9 @@ function Ft(t) {
|
|
|
56
56
|
<path d="M546 166 C522 166 505 180 499 204 L397 606 C390 630 406 646 432 646 L526 646 C568 646 590 672 581 712 L512 1001 C510 1010 518 1014 524 1006 L875 475 C886 458 878 449 855 449 L814 449 C764 449 745 415 769 374 L884 200 C894 181 883 161 858 161 Z" fill="url(#boltFill)" filter="url(#innerDepth)"/>
|
|
57
57
|
<path d="M546 166 C522 166 505 180 499 204 L397 606 C390 630 406 646 432 646 L526 646 C568 646 590 672 581 712 L512 1001 C510 1010 518 1014 524 1006 L875 475 C886 458 878 449 855 449 L814 449 C764 449 745 415 769 374 L884 200 C894 181 883 161 858 161 Z" fill="url(#boltGlow)" opacity="0.74"/>
|
|
58
58
|
<g clip-path="url(#boltClip)" opacity="0.42">
|
|
59
|
-
<path d="M523 181 C505 189 496 206 489 232 L400 594 C397 606 400 619 411 626" fill="none" stroke="${
|
|
60
|
-
<path d="M556 685 L501 994" fill="none" stroke="${
|
|
61
|
-
<path d="M858 160 C882 166 893 181 883 204" fill="none" stroke="${
|
|
59
|
+
<path d="M523 181 C505 189 496 206 489 232 L400 594 C397 606 400 619 411 626" fill="none" stroke="${t.highlight}" stroke-width="22" stroke-linecap="round" opacity="0.65"/>
|
|
60
|
+
<path d="M556 685 L501 994" fill="none" stroke="${t.highlight}" stroke-width="20" stroke-linecap="round" opacity="0.55"/>
|
|
61
|
+
<path d="M858 160 C882 166 893 181 883 204" fill="none" stroke="${t.inner}" stroke-width="18" stroke-linecap="round" opacity="0.48"/>
|
|
62
62
|
</g>
|
|
63
63
|
</g>
|
|
64
64
|
<g filter="url(#eyeShadow)">
|
|
@@ -75,23 +75,23 @@ function Ft(t) {
|
|
|
75
75
|
</g>
|
|
76
76
|
</svg>`;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
78
|
+
function $t(e) {
|
|
79
|
+
return `data:image/svg+xml,${encodeURIComponent(Ut(e))}`;
|
|
80
80
|
}
|
|
81
|
-
const j = "#2c2a1e", $e = [253, 250, 241],
|
|
82
|
-
function dt(
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
85
|
-
return
|
|
86
|
-
let o = te(
|
|
81
|
+
const j = "#2c2a1e", $e = [253, 250, 241], We = 3.5;
|
|
82
|
+
function dt(e) {
|
|
83
|
+
const t = ct(e);
|
|
84
|
+
if (He(te(t), $e) >= We)
|
|
85
|
+
return t;
|
|
86
|
+
let o = te(t);
|
|
87
87
|
const a = te(j);
|
|
88
88
|
for (let i = 0; i < 6; i += 1)
|
|
89
|
-
if (o =
|
|
89
|
+
if (o = jt(o, a, 0.22), He(o, $e) >= We)
|
|
90
90
|
return Ce(o);
|
|
91
91
|
return Ce(o);
|
|
92
92
|
}
|
|
93
|
-
function
|
|
94
|
-
const
|
|
93
|
+
function Wt(e) {
|
|
94
|
+
const t = dt(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";
|
|
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">
|
|
@@ -104,7 +104,7 @@ function Gt(t) {
|
|
|
104
104
|
</defs>
|
|
105
105
|
<g filter="url(#scribbleBoltWobble)">
|
|
106
106
|
<g clip-path="url(#scribbleBoltClip)">
|
|
107
|
-
<path d="${
|
|
107
|
+
<path d="${Vt()}" fill="none" stroke="${t}" stroke-width="56" stroke-linecap="round" stroke-linejoin="round" opacity="0.9" transform="rotate(-14 627 600)"/>
|
|
108
108
|
</g>
|
|
109
109
|
<path d="${n}" fill="none" stroke="${j}" stroke-width="18" stroke-linejoin="round"/>
|
|
110
110
|
<g transform="rotate(-2 528 463)">
|
|
@@ -120,10 +120,10 @@ function Gt(t) {
|
|
|
120
120
|
</g>
|
|
121
121
|
</svg>`;
|
|
122
122
|
}
|
|
123
|
-
function
|
|
124
|
-
return `data:image/svg+xml,${encodeURIComponent(
|
|
123
|
+
function Ht(e) {
|
|
124
|
+
return `data:image/svg+xml,${encodeURIComponent(Wt(e))}`;
|
|
125
125
|
}
|
|
126
|
-
function
|
|
126
|
+
function Vt() {
|
|
127
127
|
let n = "M 280 120", o = !1, a = 0;
|
|
128
128
|
for (let i = 150; i <= 1170; i += 62) {
|
|
129
129
|
const l = (a % 3 - 1) * 18, p = o ? 280 - l : 1020 + l;
|
|
@@ -131,8 +131,8 @@ function $t() {
|
|
|
131
131
|
}
|
|
132
132
|
return n;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
135
|
-
const
|
|
134
|
+
function qt(e) {
|
|
135
|
+
const t = ct(e), n = Ee(te(t));
|
|
136
136
|
return n > 0.86 ? {
|
|
137
137
|
top: "#ffffff",
|
|
138
138
|
middle: "#f6f6f6",
|
|
@@ -156,90 +156,90 @@ function Ht(t) {
|
|
|
156
156
|
inner: "#4b4b4b",
|
|
157
157
|
shadow: "#000000"
|
|
158
158
|
} : {
|
|
159
|
-
top: I(
|
|
160
|
-
middle: I(
|
|
161
|
-
bottom: I(
|
|
162
|
-
edgeStart: I(
|
|
163
|
-
edgeMiddle: I(
|
|
164
|
-
edgeEnd: I(
|
|
165
|
-
glow: I(
|
|
166
|
-
highlight: I(
|
|
167
|
-
inner: I(
|
|
168
|
-
shadow: I(
|
|
159
|
+
top: I(t, 0.28, -0.03),
|
|
160
|
+
middle: I(t, 0.08, 0.04),
|
|
161
|
+
bottom: I(t, -0.1, 0.02),
|
|
162
|
+
edgeStart: I(t, 0.08, 0.08),
|
|
163
|
+
edgeMiddle: I(t, -0.08, 0.08),
|
|
164
|
+
edgeEnd: I(t, -0.18, 0.05),
|
|
165
|
+
glow: I(t, 0.32, -0.12),
|
|
166
|
+
highlight: I(t, 0.38, -0.18),
|
|
167
|
+
inner: I(t, 0.24, -0.1),
|
|
168
|
+
shadow: I(t, -0.25, -0.08)
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
|
-
function ct(
|
|
172
|
-
const
|
|
173
|
-
return /^#[0-9a-f]{6}$/i.test(
|
|
171
|
+
function ct(e) {
|
|
172
|
+
const t = e.trim();
|
|
173
|
+
return /^#[0-9a-f]{6}$/i.test(t) ? t.toLowerCase() : /^#[0-9a-f]{3}$/i.test(t) ? `#${t.slice(1).split("").map((n) => n + n).join("").toLowerCase()}` : Gt;
|
|
174
174
|
}
|
|
175
|
-
function te(
|
|
175
|
+
function te(e) {
|
|
176
176
|
return [
|
|
177
|
-
Number.parseInt(
|
|
178
|
-
Number.parseInt(
|
|
179
|
-
Number.parseInt(
|
|
177
|
+
Number.parseInt(e.slice(1, 3), 16),
|
|
178
|
+
Number.parseInt(e.slice(3, 5), 16),
|
|
179
|
+
Number.parseInt(e.slice(5, 7), 16)
|
|
180
180
|
];
|
|
181
181
|
}
|
|
182
|
-
function Ce([
|
|
182
|
+
function Ce([e, t, n]) {
|
|
183
183
|
const o = (a) => Math.max(0, Math.min(255, Math.round(a))).toString(16).padStart(2, "0");
|
|
184
|
-
return `#${o(
|
|
184
|
+
return `#${o(e)}${o(t)}${o(n)}`;
|
|
185
185
|
}
|
|
186
|
-
function Ee([
|
|
186
|
+
function Ee([e, t, n]) {
|
|
187
187
|
const o = (a) => {
|
|
188
188
|
const i = a / 255;
|
|
189
189
|
return i <= 0.04045 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
|
|
190
190
|
};
|
|
191
|
-
return 0.2126 * o(
|
|
191
|
+
return 0.2126 * o(e) + 0.7152 * o(t) + 0.0722 * o(n);
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
const n = Ee(
|
|
193
|
+
function He(e, t) {
|
|
194
|
+
const n = Ee(e), o = Ee(t), [a, i] = n > o ? [n, o] : [o, n];
|
|
195
195
|
return (a + 0.05) / (i + 0.05);
|
|
196
196
|
}
|
|
197
|
-
function
|
|
197
|
+
function jt(e, t, n) {
|
|
198
198
|
const o = ke(n);
|
|
199
199
|
return [
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
200
|
+
e[0] + (t[0] - e[0]) * o,
|
|
201
|
+
e[1] + (t[1] - e[1]) * o,
|
|
202
|
+
e[2] + (t[2] - e[2]) * o
|
|
203
203
|
];
|
|
204
204
|
}
|
|
205
|
-
function I(
|
|
206
|
-
const [o, a, i] =
|
|
207
|
-
return Ce(
|
|
205
|
+
function I(e, t, n) {
|
|
206
|
+
const [o, a, i] = Yt(te(e));
|
|
207
|
+
return Ce(Kt(o, ke(a + n), ke(i + t)));
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
const o =
|
|
209
|
+
function Yt([e, t, n]) {
|
|
210
|
+
const o = e / 255, a = t / 255, i = n / 255, l = Math.max(o, a, i), p = Math.min(o, a, i), s = (l + p) / 2;
|
|
211
211
|
if (l === p)
|
|
212
212
|
return [0, 0, s];
|
|
213
213
|
const g = l - p, u = s > 0.5 ? g / (2 - l - p) : g / (l + p);
|
|
214
214
|
return [(l === o ? (a - i) / g + (a < i ? 6 : 0) : l === a ? (i - o) / g + 2 : (o - a) / g + 4) / 6, u, s];
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
if (
|
|
216
|
+
function Kt(e, t, n) {
|
|
217
|
+
if (t === 0)
|
|
218
218
|
return [n * 255, n * 255, n * 255];
|
|
219
|
-
const o = n < 0.5 ? n * (1 +
|
|
219
|
+
const o = n < 0.5 ? n * (1 + t) : n + t - n * t, a = 2 * n - o;
|
|
220
220
|
return [
|
|
221
|
-
we(a, o,
|
|
222
|
-
we(a, o,
|
|
223
|
-
we(a, o,
|
|
221
|
+
we(a, o, e + 1 / 3) * 255,
|
|
222
|
+
we(a, o, e) * 255,
|
|
223
|
+
we(a, o, e - 1 / 3) * 255
|
|
224
224
|
];
|
|
225
225
|
}
|
|
226
|
-
function we(
|
|
226
|
+
function we(e, t, n) {
|
|
227
227
|
let o = n;
|
|
228
|
-
return o < 0 && (o += 1), o > 1 && (o -= 1), o < 1 / 6 ?
|
|
228
|
+
return o < 0 && (o += 1), o > 1 && (o -= 1), o < 1 / 6 ? e + (t - e) * 6 * o : o < 1 / 2 ? t : o < 2 / 3 ? e + (t - e) * (2 / 3 - o) * 6 : e;
|
|
229
229
|
}
|
|
230
|
-
function ke(
|
|
231
|
-
return Math.max(0, Math.min(1,
|
|
230
|
+
function ke(e) {
|
|
231
|
+
return Math.max(0, Math.min(1, e));
|
|
232
232
|
}
|
|
233
233
|
const ut = "suggest_share_on_socials";
|
|
234
|
-
function
|
|
235
|
-
for (let
|
|
236
|
-
const n = t
|
|
234
|
+
function Xt(e) {
|
|
235
|
+
for (let t = e.length - 1; t >= 0; t -= 1) {
|
|
236
|
+
const n = e[t];
|
|
237
237
|
if (n.role !== "tool" || n.toolName !== ut)
|
|
238
238
|
continue;
|
|
239
|
-
const o = Ve(
|
|
239
|
+
const o = Ve(e, t, "assistant");
|
|
240
240
|
if (!o)
|
|
241
241
|
return null;
|
|
242
|
-
const a = Ve(
|
|
242
|
+
const a = Ve(e, o.index, "user");
|
|
243
243
|
return a ? {
|
|
244
244
|
id: `share:${n.callId ?? n.id}`,
|
|
245
245
|
userPrompt: a.content,
|
|
@@ -248,24 +248,24 @@ function jt(t) {
|
|
|
248
248
|
}
|
|
249
249
|
return null;
|
|
250
250
|
}
|
|
251
|
-
async function
|
|
252
|
-
const
|
|
251
|
+
async function Zt(e) {
|
|
252
|
+
const t = await Jt(e);
|
|
253
253
|
if (!navigator.clipboard || typeof ClipboardItem > "u")
|
|
254
254
|
throw new Error("Image copy is not supported in this browser. Download the screenshot instead.");
|
|
255
|
-
await navigator.clipboard.write([new ClipboardItem({ [
|
|
255
|
+
await navigator.clipboard.write([new ClipboardItem({ [t.type || "image/png"]: t })]);
|
|
256
256
|
}
|
|
257
|
-
function Ve(
|
|
258
|
-
for (let o =
|
|
259
|
-
const a =
|
|
257
|
+
function Ve(e, t, n) {
|
|
258
|
+
for (let o = t - 1; o >= 0; o -= 1) {
|
|
259
|
+
const a = e[o];
|
|
260
260
|
if (a.role === n && a.content.trim())
|
|
261
261
|
return { index: o, content: a.content.trim() };
|
|
262
262
|
}
|
|
263
263
|
return null;
|
|
264
264
|
}
|
|
265
|
-
async function
|
|
266
|
-
return await (await fetch(
|
|
265
|
+
async function Jt(e) {
|
|
266
|
+
return await (await fetch(e)).blob();
|
|
267
267
|
}
|
|
268
|
-
const gt = 100,
|
|
268
|
+
const gt = 100, Qt = "product-agent:sdk-preview-socket-connect", en = "product-agent:sdk-preview-socket-send", tn = "product-agent:sdk-preview-socket-close", nn = "product-agent:sdk-preview-socket-open", on = "product-agent:sdk-preview-socket-message", an = "product-agent:sdk-preview-socket-error", rn = "product-agent:sdk-preview-socket-closed", qe = "product-agent:sdk-preview-socket-id", ln = "product-agent:preview-diagnostic", ht = "pluno.productAgent.sharePromptsDisabled", de = 10, pn = 10 * 1024 * 1024, sn = /* @__PURE__ */ new Set(["image/png", "image/jpeg", "image/webp", "image/gif", "application/pdf"]), R = {
|
|
269
269
|
launcherLabel: "Ask for anything...",
|
|
270
270
|
accentColor: "#7c3aed",
|
|
271
271
|
colorScheme: "light",
|
|
@@ -273,83 +273,83 @@ const gt = 100, Xt = "product-agent:sdk-preview-socket-connect", Zt = "product-a
|
|
|
273
273
|
scribbleStyle: !1,
|
|
274
274
|
position: "bottom-right",
|
|
275
275
|
movableLauncher: !1
|
|
276
|
-
}, je = '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>',
|
|
277
|
-
function
|
|
278
|
-
return (
|
|
279
|
-
}
|
|
280
|
-
async function
|
|
281
|
-
const
|
|
282
|
-
launcherLabel:
|
|
283
|
-
accentColor:
|
|
284
|
-
colorScheme:
|
|
285
|
-
fontFamily:
|
|
286
|
-
scribbleStyle:
|
|
287
|
-
position:
|
|
288
|
-
movableLauncher:
|
|
289
|
-
token:
|
|
290
|
-
tokenProvider:
|
|
291
|
-
tokenEndpoint:
|
|
292
|
-
backendUrl:
|
|
293
|
-
metadata:
|
|
294
|
-
initialStarterPrompts:
|
|
295
|
-
clientId:
|
|
296
|
-
restorePersistedState:
|
|
297
|
-
expectedPersistedSessionId:
|
|
298
|
-
webSocketFactory:
|
|
299
|
-
loginRequired:
|
|
300
|
-
loginButtonLabel:
|
|
301
|
-
onLoginClick:
|
|
302
|
-
socialPostDraftHandler:
|
|
303
|
-
billingStatus:
|
|
304
|
-
billingStatusLoader:
|
|
305
|
-
socialPostRewardsUrl:
|
|
306
|
-
loadSharePromptsDisabled:
|
|
307
|
-
persistSharePromptsDisabled:
|
|
276
|
+
}, je = '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>', dn = '"Architects Daughter", "Bradley Hand", "Chalkboard SE", "Comic Sans MS", "Comic Sans", "Segoe Print", cursive', Ye = "pluno-pa-scribble-font", mt = 190, ft = 41, cn = 48, un = 420, gn = 520, hn = 0.24, mn = 680, fn = 800, bn = 0.76, A = 8, Se = 50, wn = "http://www.w3.org/2000/svg", _n = 11, xn = 13, yn = 4, vn = 10, Cn = 40, En = "movable-launcher-position-v2", bt = "pluno-pa-widget-styles", wt = "data-pluno-pa-widget-styles";
|
|
277
|
+
function kn(e) {
|
|
278
|
+
return (t) => new O(t, e);
|
|
279
|
+
}
|
|
280
|
+
async function Sn(e = {}) {
|
|
281
|
+
const t = {
|
|
282
|
+
launcherLabel: e.launcherLabel ?? R.launcherLabel,
|
|
283
|
+
accentColor: e.accentColor ?? R.accentColor,
|
|
284
|
+
colorScheme: e.colorScheme ?? R.colorScheme,
|
|
285
|
+
fontFamily: e.fontFamily ?? R.fontFamily,
|
|
286
|
+
scribbleStyle: e.scribbleStyle ?? R.scribbleStyle,
|
|
287
|
+
position: e.position ?? R.position,
|
|
288
|
+
movableLauncher: e.movableLauncher ?? R.movableLauncher,
|
|
289
|
+
token: e.token,
|
|
290
|
+
tokenProvider: e.tokenProvider,
|
|
291
|
+
tokenEndpoint: e.tokenEndpoint,
|
|
292
|
+
backendUrl: e.backendUrl,
|
|
293
|
+
metadata: e.metadata,
|
|
294
|
+
initialStarterPrompts: e.initialStarterPrompts,
|
|
295
|
+
clientId: e.clientId,
|
|
296
|
+
restorePersistedState: e.restorePersistedState,
|
|
297
|
+
expectedPersistedSessionId: e.expectedPersistedSessionId,
|
|
298
|
+
webSocketFactory: e.webSocketFactory,
|
|
299
|
+
loginRequired: e.loginRequired === !0,
|
|
300
|
+
loginButtonLabel: e.loginButtonLabel ?? "Log in to Pluno",
|
|
301
|
+
onLoginClick: e.onLoginClick,
|
|
302
|
+
socialPostDraftHandler: e.socialPostDraftHandler,
|
|
303
|
+
billingStatus: e.billingStatus ?? null,
|
|
304
|
+
billingStatusLoader: e.billingStatusLoader,
|
|
305
|
+
socialPostRewardsUrl: e.socialPostRewardsUrl,
|
|
306
|
+
loadSharePromptsDisabled: e.loadSharePromptsDisabled,
|
|
307
|
+
persistSharePromptsDisabled: e.persistSharePromptsDisabled
|
|
308
308
|
};
|
|
309
309
|
U("web-sdk.widget", "Mounting widget with merged options", {
|
|
310
|
-
accentColor:
|
|
311
|
-
colorScheme:
|
|
312
|
-
fontFamily:
|
|
313
|
-
backendUrl:
|
|
314
|
-
hasToken: !!
|
|
315
|
-
hasTokenProvider: !!
|
|
316
|
-
hasTokenEndpoint: !!
|
|
317
|
-
hasWebSocketFactory: !!
|
|
318
|
-
initialStarterPromptCount:
|
|
310
|
+
accentColor: t.accentColor,
|
|
311
|
+
colorScheme: t.colorScheme,
|
|
312
|
+
fontFamily: t.fontFamily,
|
|
313
|
+
backendUrl: t.backendUrl,
|
|
314
|
+
hasToken: !!t.token,
|
|
315
|
+
hasTokenProvider: !!t.tokenProvider,
|
|
316
|
+
hasTokenEndpoint: !!t.tokenEndpoint,
|
|
317
|
+
hasWebSocketFactory: !!t.webSocketFactory,
|
|
318
|
+
initialStarterPromptCount: t.initialStarterPrompts?.length ?? 0
|
|
319
319
|
});
|
|
320
320
|
const n = document.createElement("div");
|
|
321
321
|
n.className = "pluno-pa-widget-host", n.setAttribute("data-pluno-product-agent-ui", "widget");
|
|
322
322
|
const o = n.attachShadow({ mode: "open" }), a = document.createElement("div");
|
|
323
|
-
a.className = `pluno-pa-widget pluno-pa-widget--${
|
|
324
|
-
let i =
|
|
325
|
-
|
|
326
|
-
const l = await
|
|
327
|
-
l.appendChild(n), a.classList.add(`pluno-pa-widget--${
|
|
328
|
-
accentColor:
|
|
329
|
-
colorScheme:
|
|
330
|
-
fontFamily:
|
|
331
|
-
scribbleStyle:
|
|
323
|
+
a.className = `pluno-pa-widget pluno-pa-widget--${t.position}`, a.setAttribute("data-pluno-product-agent-ui-root", "widget");
|
|
324
|
+
let i = Ke(t.accentColor, t.scribbleStyle);
|
|
325
|
+
Rn(a, t.launcherLabel, i, t.movableLauncher), o.appendChild(a);
|
|
326
|
+
const l = await ko(), p = l.ownerDocument;
|
|
327
|
+
l.appendChild(n), a.classList.add(`pluno-pa-widget--${t.colorScheme}`), rt(o, t.accentColor), Xe(a, i, {
|
|
328
|
+
accentColor: t.accentColor,
|
|
329
|
+
colorScheme: t.colorScheme,
|
|
330
|
+
fontFamily: t.fontFamily,
|
|
331
|
+
scribbleStyle: t.scribbleStyle
|
|
332
332
|
}), U("web-sdk.widget", "Applied initial widget appearance", {
|
|
333
|
-
accentColor:
|
|
334
|
-
colorScheme:
|
|
335
|
-
fontFamily:
|
|
333
|
+
accentColor: t.accentColor,
|
|
334
|
+
colorScheme: t.colorScheme,
|
|
335
|
+
fontFamily: t.fontFamily,
|
|
336
336
|
cssAccent: a.style.getPropertyValue("--pluno-pa-accent")
|
|
337
337
|
});
|
|
338
338
|
const s = a.querySelector(".pluno-pa-widget__launcher"), g = a.querySelector(".pluno-pa-widget__launcher-drag-handle"), u = a.querySelector(".pluno-pa-widget__launcher-input"), b = a.querySelector(".pluno-pa-widget__panel"), w = a.querySelector(".pluno-pa-widget__close"), x = a.querySelector(".pluno-pa-widget__composer"), C = a.querySelector(".pluno-pa-widget__attachment-error"), m = a.querySelector(".pluno-pa-widget__billing-status"), f = a.querySelector(".pluno-pa-widget__attachments"), d = a.querySelector(".pluno-pa-widget__input"), h = a.querySelector(".pluno-pa-widget__send"), _ = a.querySelector(".pluno-pa-widget__new-chat"), k = a.querySelector(".pluno-pa-widget__timeline");
|
|
339
339
|
if (!s || !u || !b || !w || !x || !C || !m || !f || !d || !h || !_ || !k)
|
|
340
340
|
throw new Error("Failed to mount Pluno widget");
|
|
341
|
-
if (
|
|
341
|
+
if (t.movableLauncher && !g)
|
|
342
342
|
throw new Error("Failed to mount Pluno widget drag handle");
|
|
343
343
|
Qe(u), Qe(d);
|
|
344
|
-
let
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
344
|
+
let y = [], v = null;
|
|
345
|
+
const D = () => {
|
|
346
|
+
qn(f, y, (r) => {
|
|
347
|
+
y = y.filter((c, L) => L !== r), D(), T();
|
|
348
348
|
});
|
|
349
|
-
}, ne =
|
|
350
|
-
if (!
|
|
349
|
+
}, ne = t.loginRequired || t.token || t.webSocketFactory ? void 0 : t.tokenProvider ?? (async () => {
|
|
350
|
+
if (!t.tokenEndpoint)
|
|
351
351
|
throw new Error("Pluno widget requires token or tokenEndpoint");
|
|
352
|
-
const r = await fetch(
|
|
352
|
+
const r = await fetch(t.tokenEndpoint, {
|
|
353
353
|
method: "POST",
|
|
354
354
|
credentials: "include",
|
|
355
355
|
headers: { "content-type": "application/json" },
|
|
@@ -363,47 +363,47 @@ async function Cn(t = {}) {
|
|
|
363
363
|
return c.token;
|
|
364
364
|
});
|
|
365
365
|
let E;
|
|
366
|
-
E = await
|
|
367
|
-
token:
|
|
366
|
+
E = await zt.init({
|
|
367
|
+
token: t.token,
|
|
368
368
|
tokenProvider: ne,
|
|
369
|
-
backendUrl:
|
|
369
|
+
backendUrl: t.backendUrl,
|
|
370
370
|
metadata: () => ({
|
|
371
|
-
...
|
|
372
|
-
...!E.getState().sessionId &&
|
|
371
|
+
...t.metadata ?? {},
|
|
372
|
+
...!E.getState().sessionId && t.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
|
|
373
373
|
}),
|
|
374
|
-
initialStarterPrompts:
|
|
375
|
-
clientId:
|
|
376
|
-
restorePersistedState:
|
|
377
|
-
expectedPersistedSessionId:
|
|
378
|
-
webSocketFactory:
|
|
379
|
-
autoConnect:
|
|
374
|
+
initialStarterPrompts: t.initialStarterPrompts,
|
|
375
|
+
clientId: t.clientId,
|
|
376
|
+
restorePersistedState: t.restorePersistedState,
|
|
377
|
+
expectedPersistedSessionId: t.expectedPersistedSessionId,
|
|
378
|
+
webSocketFactory: t.webSocketFactory,
|
|
379
|
+
autoConnect: t.loginRequired ? !1 : void 0
|
|
380
380
|
});
|
|
381
|
-
const z =
|
|
382
|
-
let ue = z.sharePromptsDisabled || await
|
|
383
|
-
const
|
|
384
|
-
Ie || typeof document > "u" || (rt(o,
|
|
385
|
-
},
|
|
386
|
-
|
|
381
|
+
const z = So(t), ce = new Set(z.openToolGroupKeys), $ = new Set(z.seenShareCandidateIds), oe = new Set($);
|
|
382
|
+
let ue = z.sharePromptsDisabled || await Lo(t), M = t.movableLauncher ? z.launcherPosition : null, De = M !== null, B = null, Ie = !1;
|
|
383
|
+
const Tt = () => {
|
|
384
|
+
Ie || typeof document > "u" || (rt(o, t.accentColor), n.isConnected || p.body?.appendChild(n));
|
|
385
|
+
}, Me = new MutationObserver(Tt);
|
|
386
|
+
Me.observe(p.documentElement, { childList: !0, subtree: !0 });
|
|
387
387
|
const ge = (r = !0) => {
|
|
388
388
|
const c = Le(a, r);
|
|
389
389
|
return Ze(
|
|
390
390
|
a,
|
|
391
|
-
|
|
391
|
+
M ?? An(a, t.position, c),
|
|
392
392
|
c
|
|
393
393
|
);
|
|
394
394
|
}, N = () => {
|
|
395
|
-
|
|
395
|
+
Ao(t, {
|
|
396
396
|
isOpen: a.classList.contains("pluno-pa-widget--open"),
|
|
397
397
|
composerValue: d.value,
|
|
398
398
|
openToolGroupKeys: [...ce],
|
|
399
|
-
launcherPosition:
|
|
399
|
+
launcherPosition: De ? M : null,
|
|
400
400
|
seenShareCandidateIds: [...$].slice(-gt),
|
|
401
401
|
sharePromptsDisabled: ue
|
|
402
402
|
});
|
|
403
403
|
}, G = (r, c = {}) => {
|
|
404
|
-
|
|
405
|
-
debugVersion:
|
|
406
|
-
launcherPosition:
|
|
404
|
+
Mn(r, {
|
|
405
|
+
debugVersion: En,
|
|
406
|
+
launcherPosition: M,
|
|
407
407
|
rootClasses: a.className,
|
|
408
408
|
rootStyle: {
|
|
409
409
|
left: a.style.left,
|
|
@@ -414,61 +414,61 @@ async function Cn(t = {}) {
|
|
|
414
414
|
rootRect: _e(a),
|
|
415
415
|
launcherRect: _e(s),
|
|
416
416
|
panelRect: _e(b),
|
|
417
|
-
viewport:
|
|
417
|
+
viewport: K(),
|
|
418
418
|
panelHidden: b.hidden,
|
|
419
419
|
closeHidden: w.hidden,
|
|
420
420
|
...c
|
|
421
421
|
});
|
|
422
422
|
}, ae = (r = !0) => {
|
|
423
|
-
if (!
|
|
423
|
+
if (!M)
|
|
424
424
|
return re(a, null), ge(r);
|
|
425
425
|
const c = ge(r);
|
|
426
426
|
return re(a, c), G("Applied stored closed launcher position", { visibleLauncherPosition: c }), c;
|
|
427
|
-
},
|
|
427
|
+
}, Re = (r, c) => {
|
|
428
428
|
if (!r || !c) {
|
|
429
|
-
|
|
429
|
+
In(a);
|
|
430
430
|
return;
|
|
431
431
|
}
|
|
432
|
-
|
|
432
|
+
Dn(a, {
|
|
433
433
|
x: r.x - c.x,
|
|
434
434
|
y: r.y - c.y
|
|
435
435
|
});
|
|
436
436
|
}, Oe = () => {
|
|
437
437
|
const r = ae();
|
|
438
438
|
if (a.classList.contains("pluno-pa-widget--open") || a.classList.contains("pluno-pa-widget--closing")) {
|
|
439
|
-
const c = Je(a, r,
|
|
440
|
-
|
|
441
|
-
} else
|
|
439
|
+
const c = Je(a, r, t.position);
|
|
440
|
+
Re(c, r), G("Applied open panel position after viewport resize", { openPanelPosition: c });
|
|
441
|
+
} else M && G("Applied visible launcher position after viewport resize", { visibleLauncherPosition: r });
|
|
442
442
|
};
|
|
443
443
|
let Be = () => {
|
|
444
444
|
};
|
|
445
|
-
window.addEventListener("resize", Oe),
|
|
445
|
+
window.addEventListener("resize", Oe), t.movableLauncher && g ? (ae(), Be = Pn({
|
|
446
446
|
root: a,
|
|
447
447
|
launcherDragHandle: g,
|
|
448
448
|
getPosition: () => ge(),
|
|
449
449
|
setPosition: (r) => {
|
|
450
450
|
const c = r;
|
|
451
|
-
|
|
451
|
+
M = Ze(a, r, Le(a)), re(a, M), G("Dragging closed launcher", { requestedPosition: c });
|
|
452
452
|
},
|
|
453
453
|
persist: () => {
|
|
454
|
-
|
|
454
|
+
De = !0, N(), G("Persisted closed launcher drag position");
|
|
455
455
|
}
|
|
456
456
|
})) : re(a, null);
|
|
457
457
|
let he = !1;
|
|
458
458
|
const Fe = async () => {
|
|
459
|
-
if (!(!
|
|
459
|
+
if (!(!t.billingStatusLoader || he)) {
|
|
460
460
|
he = !0;
|
|
461
461
|
try {
|
|
462
|
-
const r = await
|
|
463
|
-
tt(
|
|
462
|
+
const r = await t.billingStatusLoader();
|
|
463
|
+
tt(t.billingStatus, r, E.getState().lastErrorCode) && (t.billingStatus = r, ve(m, t.billingStatus, E.getState().lastErrorCode), T());
|
|
464
464
|
} finally {
|
|
465
465
|
he = !1;
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
},
|
|
468
|
+
}, W = (r = "", c = !0) => {
|
|
469
469
|
Fe(), B !== null && (window.clearTimeout(B), B = null), b.hidden = !1, w.hidden = !1, a.classList.remove("pluno-pa-widget--closing");
|
|
470
|
-
const L = ae(), Q = Je(a, L,
|
|
471
|
-
if (
|
|
470
|
+
const L = ae(), Q = Je(a, L, t.position);
|
|
471
|
+
if (Re(Q, L), G("Opening launcher at clamped open panel position", { openPanelPosition: Q, visibleLauncherPosition: L }), !c) {
|
|
472
472
|
a.classList.add("pluno-pa-widget--open"), s.hidden = !0, r && (d.value = r, ee(d)), k.scrollTop = k.scrollHeight, d.focus(), d.setSelectionRange(d.value.length, d.value.length), N();
|
|
473
473
|
return;
|
|
474
474
|
}
|
|
@@ -477,99 +477,99 @@ async function Cn(t = {}) {
|
|
|
477
477
|
s.hidden = !0, k.scrollTop = k.scrollHeight;
|
|
478
478
|
}, 220);
|
|
479
479
|
});
|
|
480
|
-
},
|
|
481
|
-
B !== null && (window.clearTimeout(B), B = null), s.hidden = !1,
|
|
480
|
+
}, Dt = () => {
|
|
481
|
+
B !== null && (window.clearTimeout(B), B = null), s.hidden = !1, M && (ae(!1), G("Closing launcher at stored position")), a.classList.remove("pluno-pa-widget--open"), a.classList.add("pluno-pa-widget--closing"), N(), B = window.setTimeout(() => {
|
|
482
482
|
b.hidden = !0, w.hidden = !0, a.classList.remove("pluno-pa-widget--closing");
|
|
483
483
|
}, 220);
|
|
484
484
|
};
|
|
485
485
|
s.addEventListener("submit", (r) => {
|
|
486
|
-
r.preventDefault(),
|
|
486
|
+
r.preventDefault(), W(u.value), u.value = "";
|
|
487
487
|
}), g?.addEventListener("click", (r) => {
|
|
488
488
|
r.preventDefault(), r.stopPropagation();
|
|
489
489
|
}), s.addEventListener("click", (r) => {
|
|
490
|
-
r.target !== u && (
|
|
490
|
+
r.target !== u && (W(u.value), u.value = "");
|
|
491
491
|
}), u.addEventListener("focus", () => {
|
|
492
|
-
|
|
492
|
+
W(u.value), u.value = "";
|
|
493
493
|
}), u.addEventListener("input", () => {
|
|
494
494
|
if (!u.value)
|
|
495
495
|
return;
|
|
496
496
|
const r = u.value;
|
|
497
|
-
|
|
498
|
-
}), w.addEventListener("click",
|
|
499
|
-
const
|
|
500
|
-
h.disabled = F(
|
|
497
|
+
W(r), u.value = "";
|
|
498
|
+
}), w.addEventListener("click", Dt);
|
|
499
|
+
const T = () => {
|
|
500
|
+
h.disabled = F(t.billingStatus) || !E.getState().isThinking && d.value.trim().length === 0 && y.length === 0;
|
|
501
501
|
};
|
|
502
|
-
|
|
503
|
-
if (r.preventDefault(),
|
|
504
|
-
|
|
502
|
+
t.loginRequired && (u.readOnly = !0, u.placeholder = t.loginButtonLabel, d.placeholder = t.loginButtonLabel, x.hidden = !0), x.addEventListener("submit", (r) => {
|
|
503
|
+
if (r.preventDefault(), t.loginRequired) {
|
|
504
|
+
t.onLoginClick?.();
|
|
505
505
|
return;
|
|
506
506
|
}
|
|
507
|
-
F(
|
|
507
|
+
F(t.billingStatus) || (y = xe(E, d, y), D(), T());
|
|
508
508
|
});
|
|
509
509
|
let Z = 0;
|
|
510
|
-
const
|
|
510
|
+
const It = () => {
|
|
511
511
|
Z = 0, a.classList.remove("pluno-pa-widget--drag-over");
|
|
512
|
-
},
|
|
513
|
-
|
|
514
|
-
C.textContent = "", C.hidden = !0,
|
|
512
|
+
}, Mt = (r) => {
|
|
513
|
+
v !== null && window.clearTimeout(v), C.textContent = r, C.hidden = !1, v = window.setTimeout(() => {
|
|
514
|
+
C.textContent = "", C.hidden = !0, v = null;
|
|
515
515
|
}, 3e3);
|
|
516
|
-
},
|
|
517
|
-
|
|
518
|
-
},
|
|
516
|
+
}, Rt = () => {
|
|
517
|
+
v !== null && (window.clearTimeout(v), v = null), C.textContent = "", C.hidden = !0;
|
|
518
|
+
}, Ot = async (r) => {
|
|
519
519
|
if (r.length === 0)
|
|
520
520
|
return;
|
|
521
|
-
const c = await
|
|
522
|
-
if (
|
|
521
|
+
const c = await Xn(r);
|
|
522
|
+
if (y.length + c.length > de)
|
|
523
523
|
throw new Error(`Attach up to ${de} files per message.`);
|
|
524
|
-
|
|
524
|
+
y = [...y, ...c], D(), Rt(), T();
|
|
525
525
|
};
|
|
526
526
|
a.addEventListener("dragenter", (r) => {
|
|
527
|
-
!le(r.dataTransfer) ||
|
|
527
|
+
!le(r.dataTransfer) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), Z += 1, a.classList.add("pluno-pa-widget--drag-over"));
|
|
528
528
|
}), a.addEventListener("dragover", (r) => {
|
|
529
529
|
const c = r.dataTransfer;
|
|
530
|
-
!le(c) ||
|
|
530
|
+
!le(c) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), c.dropEffect = "copy");
|
|
531
531
|
}), a.addEventListener("dragleave", (r) => {
|
|
532
532
|
le(r.dataTransfer) && (r.stopPropagation(), Z = Math.max(0, Z - 1), Z === 0 && a.classList.remove("pluno-pa-widget--drag-over"));
|
|
533
533
|
}), a.addEventListener("drop", (r) => {
|
|
534
534
|
const c = r.dataTransfer;
|
|
535
|
-
!le(c) ||
|
|
536
|
-
|
|
535
|
+
!le(c) || t.loginRequired || (r.preventDefault(), r.stopPropagation(), It(), Ot(c.files).catch((L) => {
|
|
536
|
+
Mt(L instanceof Error ? L.message : "Failed to attach file"), U("web-sdk.widget", "Attachment failed", {
|
|
537
537
|
message: L instanceof Error ? L.message : String(L)
|
|
538
538
|
});
|
|
539
539
|
}));
|
|
540
540
|
}), h.addEventListener("click", () => {
|
|
541
|
-
if (
|
|
542
|
-
|
|
541
|
+
if (t.loginRequired) {
|
|
542
|
+
t.onLoginClick?.();
|
|
543
543
|
return;
|
|
544
544
|
}
|
|
545
545
|
if (E.getState().isThinking) {
|
|
546
546
|
E.stop();
|
|
547
547
|
return;
|
|
548
548
|
}
|
|
549
|
-
|
|
549
|
+
y = xe(E, d, y), D(), T();
|
|
550
550
|
}), _.addEventListener("click", () => {
|
|
551
|
-
E.startNewSession(), ce.clear(), d.value = "",
|
|
551
|
+
E.startNewSession(), ce.clear(), d.value = "", y = [], D(), ee(d), N(), T(), d.focus();
|
|
552
552
|
}), d.addEventListener("input", () => {
|
|
553
|
-
ee(d), N(),
|
|
553
|
+
ee(d), N(), T();
|
|
554
554
|
}), d.addEventListener("keydown", (r) => {
|
|
555
555
|
if (!(r.key !== "Enter" || r.shiftKey)) {
|
|
556
|
-
if (r.preventDefault(),
|
|
557
|
-
|
|
556
|
+
if (r.preventDefault(), t.loginRequired) {
|
|
557
|
+
t.onLoginClick?.();
|
|
558
558
|
return;
|
|
559
559
|
}
|
|
560
|
-
|
|
560
|
+
y = xe(E, d, y), D(), T();
|
|
561
561
|
}
|
|
562
562
|
}), a.addEventListener("click", (r) => {
|
|
563
563
|
(r.target instanceof Element ? r.target : null)?.closest("a[href]") && N();
|
|
564
|
-
}), z.composerValue && (d.value = z.composerValue, ee(d)), z.isOpen &&
|
|
564
|
+
}), z.composerValue && (d.value = z.composerValue, ee(d)), z.isOpen && W(d.value, !1);
|
|
565
565
|
const ze = () => i;
|
|
566
|
-
let me = E.getState().appearance !== null, ie = null, J = null,
|
|
567
|
-
const
|
|
568
|
-
if (
|
|
569
|
-
|
|
566
|
+
let me = E.getState().appearance !== null, ie = null, J = null, H = null, Ge = E.getState().isThinking, V = null;
|
|
567
|
+
const Bt = !!t.socialPostDraftHandler, q = (r) => {
|
|
568
|
+
if (Te(r.lastErrorCode) ? V = r.lastErrorCode : t.billingStatus?.creditsUsed !== null && !F(t.billingStatus) && (V = null), ve(m, t.billingStatus, V), t.loginRequired) {
|
|
569
|
+
so(k, h, _, ze, t.loginButtonLabel, t.onLoginClick);
|
|
570
570
|
return;
|
|
571
571
|
}
|
|
572
|
-
|
|
572
|
+
po(
|
|
573
573
|
k,
|
|
574
574
|
h,
|
|
575
575
|
_,
|
|
@@ -580,7 +580,7 @@ async function Cn(t = {}) {
|
|
|
580
580
|
(c) => {
|
|
581
581
|
E.sendMessage(c);
|
|
582
582
|
},
|
|
583
|
-
|
|
583
|
+
Bt && !ue ? {
|
|
584
584
|
dismissedCandidateIds: oe,
|
|
585
585
|
draftingCandidateId: ie,
|
|
586
586
|
error: J,
|
|
@@ -588,13 +588,13 @@ async function Cn(t = {}) {
|
|
|
588
588
|
$.add(c.id), N();
|
|
589
589
|
},
|
|
590
590
|
onDraft: (c) => {
|
|
591
|
-
|
|
591
|
+
Ft(c);
|
|
592
592
|
},
|
|
593
593
|
onDismiss: (c) => {
|
|
594
594
|
$.add(c.id), oe.add(c.id), N(), J = null, q(E.getState());
|
|
595
595
|
},
|
|
596
596
|
onDisable: (c) => {
|
|
597
|
-
ue = !0, $.add(c.id), oe.add(c.id), N(),
|
|
597
|
+
ue = !0, $.add(c.id), oe.add(c.id), N(), Po(t, !0), J = null, q(E.getState());
|
|
598
598
|
}
|
|
599
599
|
} : void 0
|
|
600
600
|
);
|
|
@@ -604,45 +604,45 @@ async function Cn(t = {}) {
|
|
|
604
604
|
Ge = r.isThinking, r.appearance ? (me = !0, U("web-sdk.widget", "Agent state supplied appearance", {
|
|
605
605
|
appearance: r.appearance
|
|
606
606
|
}), fe(r.appearance, "agent.state.appearance")) : me && (me = !1, U("web-sdk.widget", "Agent state cleared appearance; reverting to configured widget options", {
|
|
607
|
-
fallbackAccentColor:
|
|
608
|
-
fallbackColorScheme:
|
|
609
|
-
fallbackFontFamily:
|
|
610
|
-
}), fe({}, "agent.state.appearance-cleared")), q(r),
|
|
611
|
-
}), q(E.getState()),
|
|
607
|
+
fallbackAccentColor: t.accentColor,
|
|
608
|
+
fallbackColorScheme: t.colorScheme,
|
|
609
|
+
fallbackFontFamily: t.fontFamily
|
|
610
|
+
}), fe({}, "agent.state.appearance-cleared")), q(r), T(), c && Fe();
|
|
611
|
+
}), q(E.getState()), T(), {
|
|
612
612
|
agent: E,
|
|
613
613
|
updateAppearance: (r) => {
|
|
614
|
-
r.scribbleStyle !== void 0 && (
|
|
614
|
+
r.scribbleStyle !== void 0 && (t.scribbleStyle = r.scribbleStyle), fe(r, "widgetHandle.updateAppearance");
|
|
615
615
|
},
|
|
616
616
|
updateBillingStatus: (r) => {
|
|
617
617
|
const c = r ?? null;
|
|
618
|
-
tt(
|
|
618
|
+
tt(t.billingStatus, c, V) && (t.billingStatus = c, t.billingStatus?.creditsUsed !== null && !F(t.billingStatus) && (V = null), ve(
|
|
619
619
|
a.querySelector(".pluno-pa-widget__billing-status"),
|
|
620
|
-
|
|
620
|
+
t.billingStatus,
|
|
621
621
|
V
|
|
622
|
-
),
|
|
622
|
+
), T());
|
|
623
623
|
},
|
|
624
624
|
openPanel: () => {
|
|
625
|
-
|
|
625
|
+
W(d.value, !1);
|
|
626
626
|
},
|
|
627
627
|
destroy: () => {
|
|
628
|
-
Ie = !0,
|
|
628
|
+
Ie = !0, Me.disconnect(), window.removeEventListener("resize", Oe), Be(), v !== null && window.clearTimeout(v), H?.remove(), E.destroy(), n.remove();
|
|
629
629
|
}
|
|
630
630
|
};
|
|
631
|
-
async function
|
|
631
|
+
async function Ft(r) {
|
|
632
632
|
if (!ie) {
|
|
633
633
|
ie = r.id, J = null, q(E.getState());
|
|
634
634
|
try {
|
|
635
|
-
if (!
|
|
635
|
+
if (!t.socialPostDraftHandler)
|
|
636
636
|
throw new Error("Social post drafting is not available here.");
|
|
637
|
-
const c = await
|
|
637
|
+
const c = await t.socialPostDraftHandler(r);
|
|
638
638
|
if (!c.linkedinPost || !c.xPost)
|
|
639
639
|
throw new Error("Pluno did not return a complete social post draft.");
|
|
640
|
-
$.add(r.id), oe.add(r.id), N(),
|
|
641
|
-
socialPostRewardsUrl:
|
|
640
|
+
$.add(r.id), oe.add(r.id), N(), H?.remove(), H = go(c, {
|
|
641
|
+
socialPostRewardsUrl: t.socialPostRewardsUrl,
|
|
642
642
|
onClose: () => {
|
|
643
|
-
|
|
643
|
+
H?.remove(), H = null;
|
|
644
644
|
}
|
|
645
|
-
}), a.appendChild(
|
|
645
|
+
}), a.appendChild(H);
|
|
646
646
|
} catch (c) {
|
|
647
647
|
J = c instanceof Error ? c.message : "Could not draft social post.";
|
|
648
648
|
} finally {
|
|
@@ -651,8 +651,8 @@ async function Cn(t = {}) {
|
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
653
|
function fe(r, c) {
|
|
654
|
-
const L = r.accentColor ??
|
|
655
|
-
i =
|
|
654
|
+
const L = r.accentColor ?? t.accentColor, Q = r.colorScheme ?? t.colorScheme, Ue = r.fontFamily ?? t.fontFamily, be = r.scribbleStyle ?? t.scribbleStyle;
|
|
655
|
+
i = Ke(L, be), Xe(a, i, {
|
|
656
656
|
accentColor: L,
|
|
657
657
|
colorScheme: Q,
|
|
658
658
|
fontFamily: Ue,
|
|
@@ -668,254 +668,254 @@ async function Cn(t = {}) {
|
|
|
668
668
|
});
|
|
669
669
|
}
|
|
670
670
|
}
|
|
671
|
-
function
|
|
672
|
-
return
|
|
671
|
+
function Ke(e, t) {
|
|
672
|
+
return t ? Ht(e) : $t(e);
|
|
673
673
|
}
|
|
674
|
-
function Xe(
|
|
675
|
-
|
|
674
|
+
function Xe(e, t, n) {
|
|
675
|
+
e.classList.toggle("pluno-pa-widget--dark", n.colorScheme === "dark"), e.classList.toggle("pluno-pa-widget--light", n.colorScheme !== "dark"), e.classList.toggle("pluno-pa-widget--scribble", n.scribbleStyle);
|
|
676
676
|
const o = n.scribbleStyle ? dt(n.accentColor) : n.accentColor;
|
|
677
|
-
|
|
678
|
-
const a = Array.from(
|
|
677
|
+
e.style.setProperty("--pluno-pa-accent", o), e.style.fontFamily = n.scribbleStyle ? dn : n.fontFamily, n.scribbleStyle && Ln(e.ownerDocument);
|
|
678
|
+
const a = Array.from(e.querySelectorAll(".pluno-pa-widget__character"));
|
|
679
679
|
for (const i of a)
|
|
680
|
-
i.src =
|
|
680
|
+
i.src = t;
|
|
681
681
|
}
|
|
682
|
-
function
|
|
683
|
-
if (
|
|
682
|
+
function Ln(e) {
|
|
683
|
+
if (e.getElementById(Ye))
|
|
684
684
|
return;
|
|
685
|
-
const
|
|
686
|
-
|
|
685
|
+
const t = e.createElement("style");
|
|
686
|
+
t.id = Ye, t.textContent = `@font-face {
|
|
687
687
|
font-family: "Architects Daughter";
|
|
688
688
|
font-style: normal;
|
|
689
689
|
font-weight: 400;
|
|
690
690
|
font-display: swap;
|
|
691
691
|
src: url("https://fonts.gstatic.com/s/architectsdaughter/v20/KtkxAKiDZI_td1Lkx62xHZHDtgO_Y-bvTYlg4-7jA-U.woff2") format("woff2");
|
|
692
|
-
}`,
|
|
692
|
+
}`, e.head.appendChild(t), e.fonts?.load('16px "Architects Daughter"');
|
|
693
693
|
}
|
|
694
|
-
function
|
|
695
|
-
root:
|
|
696
|
-
launcherDragHandle:
|
|
694
|
+
function Pn({
|
|
695
|
+
root: e,
|
|
696
|
+
launcherDragHandle: t,
|
|
697
697
|
getPosition: n,
|
|
698
698
|
setPosition: o,
|
|
699
699
|
persist: a
|
|
700
700
|
}) {
|
|
701
701
|
let i = null, l = null, p = null, s = !1;
|
|
702
702
|
const g = () => {
|
|
703
|
-
i = null, l = null, p = null, s = !1,
|
|
703
|
+
i = null, l = null, p = null, s = !1, e.classList.remove("pluno-pa-widget--dragging");
|
|
704
704
|
}, u = (m) => {
|
|
705
|
-
|
|
705
|
+
e.classList.contains("pluno-pa-widget--open") || e.classList.contains("pluno-pa-widget--closing") || (m.preventDefault(), m.stopPropagation(), i = m.pointerId, l = { x: m.clientX, y: m.clientY }, p = n(), s = !1, t.setPointerCapture?.(m.pointerId));
|
|
706
706
|
}, b = (m) => {
|
|
707
707
|
if (i !== m.pointerId || !l || !p)
|
|
708
708
|
return;
|
|
709
709
|
m.preventDefault();
|
|
710
710
|
const f = m.clientX - l.x, d = m.clientY - l.y;
|
|
711
|
-
!s && Math.hypot(f, d) <
|
|
711
|
+
!s && Math.hypot(f, d) < yn || (s = !0, e.classList.add("pluno-pa-widget--dragging"), o({ x: p.x + f, y: p.y + d }));
|
|
712
712
|
}, w = (m) => {
|
|
713
713
|
i === m.pointerId && (m.preventDefault(), m.stopPropagation(), s && a(), g());
|
|
714
714
|
}, x = (m) => {
|
|
715
715
|
i === m.pointerId && (m.preventDefault(), g());
|
|
716
716
|
}, C = (m) => {
|
|
717
|
-
if (
|
|
717
|
+
if (e.classList.contains("pluno-pa-widget--open") || e.classList.contains("pluno-pa-widget--closing"))
|
|
718
718
|
return;
|
|
719
|
-
const f = m.shiftKey ?
|
|
719
|
+
const f = m.shiftKey ? Cn : vn, d = n();
|
|
720
720
|
let h = null;
|
|
721
721
|
m.key === "ArrowUp" ? h = { x: d.x, y: d.y - f } : m.key === "ArrowDown" ? h = { x: d.x, y: d.y + f } : m.key === "ArrowLeft" ? h = { x: d.x - f, y: d.y } : m.key === "ArrowRight" && (h = { x: d.x + f, y: d.y }), h && (m.preventDefault(), m.stopPropagation(), o(h), a());
|
|
722
722
|
};
|
|
723
|
-
return
|
|
724
|
-
|
|
723
|
+
return t.addEventListener("pointerdown", u), t.addEventListener("pointermove", b), t.addEventListener("pointerup", w), t.addEventListener("pointercancel", x), t.addEventListener("keydown", C), () => {
|
|
724
|
+
t.removeEventListener("pointerdown", u), t.removeEventListener("pointermove", b), t.removeEventListener("pointerup", w), t.removeEventListener("pointercancel", x), t.removeEventListener("keydown", C);
|
|
725
725
|
};
|
|
726
726
|
}
|
|
727
|
-
function Le(
|
|
728
|
-
const n =
|
|
727
|
+
function Le(e, t = !0) {
|
|
728
|
+
const n = K(), o = e.getBoundingClientRect(), a = !e.classList.contains("pluno-pa-widget--open") && !e.classList.contains("pluno-pa-widget--closing");
|
|
729
729
|
return {
|
|
730
|
-
width:
|
|
731
|
-
height:
|
|
730
|
+
width: t && a && o.width > 0 ? o.width : Math.min(mt, n.width - 36),
|
|
731
|
+
height: t && a && o.height > 0 ? o.height : e.classList.contains("pluno-pa-widget--scribble") ? cn : ft
|
|
732
732
|
};
|
|
733
733
|
}
|
|
734
|
-
function
|
|
735
|
-
const
|
|
734
|
+
function _t() {
|
|
735
|
+
const e = K();
|
|
736
736
|
return {
|
|
737
737
|
width: Math.min(
|
|
738
|
-
|
|
739
|
-
|
|
738
|
+
Y(e.width * hn, un, gn),
|
|
739
|
+
e.width - A * 2
|
|
740
740
|
),
|
|
741
741
|
height: Math.min(
|
|
742
|
-
|
|
743
|
-
|
|
742
|
+
Y(e.height * bn, mn, fn),
|
|
743
|
+
e.height - Se - A
|
|
744
744
|
)
|
|
745
745
|
};
|
|
746
746
|
}
|
|
747
|
-
function
|
|
748
|
-
const o = Number.parseFloat(
|
|
747
|
+
function An(e, t, n) {
|
|
748
|
+
const o = Number.parseFloat(e.style.left), a = Number.parseFloat(e.style.top);
|
|
749
749
|
if (Number.isFinite(o) && Number.isFinite(a))
|
|
750
750
|
return { x: o, y: a };
|
|
751
|
-
const i =
|
|
751
|
+
const i = e.getBoundingClientRect();
|
|
752
752
|
if (i.width > 0 || i.height > 0)
|
|
753
753
|
return { x: i.left, y: i.top };
|
|
754
|
-
const l =
|
|
754
|
+
const l = K();
|
|
755
755
|
return {
|
|
756
|
-
x:
|
|
756
|
+
x: t === "bottom-left" ? 26 : l.width - 26 - n.width,
|
|
757
757
|
y: l.height - 24 - n.height
|
|
758
758
|
};
|
|
759
759
|
}
|
|
760
|
-
function Ze(
|
|
761
|
-
const o =
|
|
760
|
+
function Ze(e, t, n) {
|
|
761
|
+
const o = K(), a = A + Nn(e);
|
|
762
762
|
return {
|
|
763
|
-
x:
|
|
764
|
-
y:
|
|
763
|
+
x: Y(t.x, A, Math.max(A, o.width - n.width - A)),
|
|
764
|
+
y: Y(t.y, a, Math.max(a, o.height - n.height - A))
|
|
765
765
|
};
|
|
766
766
|
}
|
|
767
|
-
function
|
|
768
|
-
return
|
|
767
|
+
function Nn(e) {
|
|
768
|
+
return e.classList.contains("pluno-pa-widget--scribble") ? xn : _n;
|
|
769
769
|
}
|
|
770
|
-
function Je(
|
|
771
|
-
const o = Le(
|
|
772
|
-
x: n === "bottom-left" ?
|
|
773
|
-
y:
|
|
770
|
+
function Je(e, t, n) {
|
|
771
|
+
const o = Le(e), a = _t(), i = {
|
|
772
|
+
x: n === "bottom-left" ? t.x : t.x + o.width - a.width,
|
|
773
|
+
y: t.y + o.height - a.height
|
|
774
774
|
};
|
|
775
|
-
return
|
|
775
|
+
return Tn(i);
|
|
776
776
|
}
|
|
777
|
-
function
|
|
778
|
-
const
|
|
777
|
+
function Tn(e) {
|
|
778
|
+
const t = K(), n = _t();
|
|
779
779
|
return {
|
|
780
|
-
x:
|
|
781
|
-
y:
|
|
782
|
-
|
|
780
|
+
x: Y(e.x, A, Math.max(A, t.width - n.width - A)),
|
|
781
|
+
y: Y(
|
|
782
|
+
e.y,
|
|
783
783
|
Se,
|
|
784
|
-
Math.max(Se,
|
|
784
|
+
Math.max(Se, t.height - n.height - A)
|
|
785
785
|
)
|
|
786
786
|
};
|
|
787
787
|
}
|
|
788
|
-
function re(
|
|
789
|
-
if (
|
|
790
|
-
|
|
788
|
+
function re(e, t) {
|
|
789
|
+
if (e.classList.toggle("pluno-pa-widget--custom-position", t !== null), !t) {
|
|
790
|
+
e.style.removeProperty("left"), e.style.removeProperty("top"), e.style.removeProperty("right"), e.style.removeProperty("bottom");
|
|
791
791
|
return;
|
|
792
792
|
}
|
|
793
|
-
|
|
793
|
+
e.style.left = `${t.x}px`, e.style.top = `${t.y}px`, e.style.right = "auto", e.style.bottom = "auto";
|
|
794
794
|
}
|
|
795
|
-
function
|
|
796
|
-
|
|
795
|
+
function Dn(e, t) {
|
|
796
|
+
e.style.setProperty("--pluno-pa-panel-offset-x", `${t.x}px`), e.style.setProperty("--pluno-pa-panel-offset-y", `${t.y}px`);
|
|
797
797
|
}
|
|
798
|
-
function
|
|
799
|
-
|
|
798
|
+
function In(e) {
|
|
799
|
+
e.style.removeProperty("--pluno-pa-panel-offset-x"), e.style.removeProperty("--pluno-pa-panel-offset-y");
|
|
800
800
|
}
|
|
801
|
-
function
|
|
801
|
+
function K() {
|
|
802
802
|
return {
|
|
803
803
|
width: window.innerWidth || document.documentElement.clientWidth || mt + A * 2,
|
|
804
804
|
height: window.innerHeight || document.documentElement.clientHeight || ft + A * 2
|
|
805
805
|
};
|
|
806
806
|
}
|
|
807
|
-
function _e(
|
|
808
|
-
const
|
|
807
|
+
function _e(e) {
|
|
808
|
+
const t = e.getBoundingClientRect();
|
|
809
809
|
return {
|
|
810
|
-
x: Math.round(
|
|
811
|
-
y: Math.round(
|
|
812
|
-
width: Math.round(
|
|
813
|
-
height: Math.round(
|
|
810
|
+
x: Math.round(t.x),
|
|
811
|
+
y: Math.round(t.y),
|
|
812
|
+
width: Math.round(t.width),
|
|
813
|
+
height: Math.round(t.height)
|
|
814
814
|
};
|
|
815
815
|
}
|
|
816
|
-
function
|
|
817
|
-
return Math.min(Math.max(
|
|
816
|
+
function Y(e, t, n) {
|
|
817
|
+
return Math.min(Math.max(e, t), n);
|
|
818
818
|
}
|
|
819
|
-
function U(
|
|
819
|
+
function U(e, t, n) {
|
|
820
820
|
if (typeof window > "u")
|
|
821
821
|
return;
|
|
822
822
|
const o = window, a = {
|
|
823
823
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
824
|
-
source:
|
|
825
|
-
message:
|
|
824
|
+
source: e,
|
|
825
|
+
message: t,
|
|
826
826
|
details: n
|
|
827
827
|
}, i = o.__plunoProductAgentDiagnostics__ ?? [];
|
|
828
|
-
i.push(a), i.length > 120 && i.splice(0, i.length - 120), o.__plunoProductAgentDiagnostics__ = i, o.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent(
|
|
828
|
+
i.push(a), i.length > 120 && i.splice(0, i.length - 120), o.__plunoProductAgentDiagnostics__ = i, o.__PLUNO_PRODUCT_AGENT_DIAGNOSTICS__ = () => [...i], window.dispatchEvent(new CustomEvent(ln, { detail: a }));
|
|
829
829
|
}
|
|
830
|
-
function
|
|
831
|
-
U("web-sdk.widget.position",
|
|
830
|
+
function Mn(e, t) {
|
|
831
|
+
U("web-sdk.widget.position", e, t);
|
|
832
832
|
}
|
|
833
|
-
function xe(
|
|
834
|
-
const o =
|
|
835
|
-
return !o && n.length === 0 ? n : (
|
|
833
|
+
function xe(e, t, n) {
|
|
834
|
+
const o = t.value.trim();
|
|
835
|
+
return !o && n.length === 0 ? n : (t.value = "", t.style.height = "22px", t.style.overflowY = "hidden", e.sendMessage(o, { attachments: n.length > 0 ? n : void 0 }), t.dispatchEvent(new Event("input", { bubbles: !0 })), []);
|
|
836
836
|
}
|
|
837
|
-
function ee(
|
|
838
|
-
|
|
839
|
-
const
|
|
840
|
-
|
|
837
|
+
function ee(e) {
|
|
838
|
+
e.style.height = "0px";
|
|
839
|
+
const t = Math.max(22, Math.min(e.scrollHeight, 140));
|
|
840
|
+
e.style.height = `${t}px`, e.style.overflowY = e.scrollHeight > 140 ? "auto" : "hidden";
|
|
841
841
|
}
|
|
842
|
-
function
|
|
843
|
-
|
|
842
|
+
function Rn(e, t, n, o) {
|
|
843
|
+
e.appendChild(Gn()), e.appendChild(On(t, n, o)), e.appendChild(vt("pluno-pa-widget__close", "Close", Un(16), !0)), e.appendChild(Bn(n));
|
|
844
844
|
}
|
|
845
|
-
function
|
|
845
|
+
function On(e, t, n) {
|
|
846
846
|
const o = document.createElement("form");
|
|
847
847
|
if (o.className = "pluno-pa-widget__launcher", n) {
|
|
848
848
|
const i = document.createElement("button");
|
|
849
849
|
i.type = "button", i.className = "pluno-pa-widget__launcher-drag-handle", i.setAttribute("aria-label", "Move Pluno launcher"), i.title = "Move Pluno launcher", o.appendChild(i);
|
|
850
850
|
}
|
|
851
|
-
o.appendChild(
|
|
851
|
+
o.appendChild(yt("pluno-pa-widget__character--launcher", t));
|
|
852
852
|
const a = document.createElement("input");
|
|
853
|
-
return a.className = "pluno-pa-widget__launcher-input", a.type = "text", a.placeholder =
|
|
853
|
+
return a.className = "pluno-pa-widget__launcher-input", a.type = "text", a.placeholder = e, a.setAttribute("aria-label", e), o.appendChild(a), o;
|
|
854
854
|
}
|
|
855
|
-
function
|
|
856
|
-
const
|
|
857
|
-
|
|
855
|
+
function Bn(e) {
|
|
856
|
+
const t = document.createElement("section");
|
|
857
|
+
t.className = "pluno-pa-widget__panel", t.hidden = !0;
|
|
858
858
|
const n = document.createElement("div");
|
|
859
859
|
n.className = "pluno-pa-widget__timeline-wrap";
|
|
860
860
|
const o = document.createElement("main");
|
|
861
|
-
return o.className = "pluno-pa-widget__timeline", o.appendChild(
|
|
861
|
+
return o.className = "pluno-pa-widget__timeline", o.appendChild(zn(e)), n.appendChild(o), n.appendChild(vt("pluno-pa-widget__new-chat", "New chat", $n(), !0)), t.appendChild(n), t.appendChild(Fn()), t;
|
|
862
862
|
}
|
|
863
|
-
function
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
const
|
|
867
|
-
|
|
863
|
+
function Fn() {
|
|
864
|
+
const e = document.createElement("form");
|
|
865
|
+
e.className = "pluno-pa-widget__composer";
|
|
866
|
+
const t = document.createElement("div");
|
|
867
|
+
t.className = "pluno-pa-widget__billing-status", t.hidden = !0, e.appendChild(t);
|
|
868
868
|
const n = document.createElement("div");
|
|
869
|
-
n.className = "pluno-pa-widget__attachment-error", n.hidden = !0,
|
|
869
|
+
n.className = "pluno-pa-widget__attachment-error", n.hidden = !0, e.appendChild(n);
|
|
870
870
|
const o = document.createElement("div");
|
|
871
|
-
o.className = "pluno-pa-widget__attachments", o.hidden = !0,
|
|
871
|
+
o.className = "pluno-pa-widget__attachments", o.hidden = !0, e.appendChild(o);
|
|
872
872
|
const a = document.createElement("div");
|
|
873
873
|
a.className = "pluno-pa-widget__composer-inner";
|
|
874
874
|
const i = document.createElement("textarea");
|
|
875
875
|
i.className = "pluno-pa-widget__input", i.rows = 1, i.placeholder = "Ask for anything...", a.appendChild(i);
|
|
876
876
|
const l = document.createElement("button");
|
|
877
|
-
l.type = "button", l.className = "pluno-pa-widget__send", l.setAttribute("aria-label", "Send"), l.appendChild(
|
|
877
|
+
l.type = "button", l.className = "pluno-pa-widget__send", l.setAttribute("aria-label", "Send"), l.appendChild(Ct()), a.appendChild(l), e.appendChild(a);
|
|
878
878
|
const p = document.createElement("div");
|
|
879
879
|
p.className = "pluno-pa-widget__composer-meta";
|
|
880
880
|
const s = document.createElement("a");
|
|
881
881
|
s.className = "pluno-pa-widget__powered-by", s.href = "https://pluno.ai", s.target = "_blank", s.rel = "noopener noreferrer", s.textContent = "Powered by Pluno.ai.", p.appendChild(s);
|
|
882
882
|
const g = document.createElement("span");
|
|
883
|
-
return g.className = "pluno-pa-widget__ai-disclaimer", g.textContent = "AI can make mistakes. Verify outputs.", p.appendChild(g),
|
|
883
|
+
return g.className = "pluno-pa-widget__ai-disclaimer", g.textContent = "AI can make mistakes. Verify outputs.", p.appendChild(g), e.appendChild(p), e;
|
|
884
884
|
}
|
|
885
|
-
function
|
|
886
|
-
const e = document.createElement("div");
|
|
887
|
-
return e.className = "pluno-pa-widget__empty-state", e.appendChild(_t("pluno-pa-widget__character--empty", t)), e.appendChild(wt()), e;
|
|
888
|
-
}
|
|
889
|
-
function wt() {
|
|
885
|
+
function zn(e) {
|
|
890
886
|
const t = document.createElement("div");
|
|
891
|
-
return t.className = "pluno-pa-widget__empty", t.appendChild(
|
|
887
|
+
return t.className = "pluno-pa-widget__empty-state", t.appendChild(yt("pluno-pa-widget__character--empty", e)), t.appendChild(xt()), t;
|
|
892
888
|
}
|
|
893
|
-
function
|
|
889
|
+
function xt() {
|
|
890
|
+
const e = document.createElement("div");
|
|
891
|
+
return e.className = "pluno-pa-widget__empty", e.appendChild(document.createTextNode("Hey there, I'm Pluno 👋")), e.appendChild(document.createElement("br")), e.appendChild(document.createTextNode("What do you want to do today?")), e;
|
|
892
|
+
}
|
|
893
|
+
function yt(e, t) {
|
|
894
894
|
const n = document.createElement("img");
|
|
895
|
-
return n.className = `pluno-pa-widget__character ${
|
|
895
|
+
return n.className = `pluno-pa-widget__character ${e}`, n.src = t, n.alt = "", n.setAttribute("aria-hidden", "true"), n;
|
|
896
896
|
}
|
|
897
|
-
function
|
|
897
|
+
function vt(e, t, n, o) {
|
|
898
898
|
const a = document.createElement("button");
|
|
899
|
-
return a.type = "button", a.className =
|
|
899
|
+
return a.type = "button", a.className = e, a.setAttribute("aria-label", t), a.title = t, a.hidden = o, a.appendChild(n), a;
|
|
900
900
|
}
|
|
901
|
-
function
|
|
902
|
-
const
|
|
901
|
+
function Gn() {
|
|
902
|
+
const e = S("svg", {
|
|
903
903
|
class: "pluno-pa-widget__scribble-defs",
|
|
904
904
|
"aria-hidden": "true",
|
|
905
905
|
focusable: "false",
|
|
906
906
|
width: "0",
|
|
907
907
|
height: "0"
|
|
908
|
-
}),
|
|
909
|
-
return
|
|
908
|
+
}), t = S("defs");
|
|
909
|
+
return t.appendChild(ye("pluno-pa-scribble-wobble", "2", "12")), t.appendChild(ye("pluno-pa-scribble-wobble-2", "5", "15")), t.appendChild(ye("pluno-pa-scribble-wobble-3", "9", "19")), e.appendChild(t), e;
|
|
910
910
|
}
|
|
911
|
-
function
|
|
912
|
-
const o = S("filter", { id:
|
|
911
|
+
function ye(e, t, n) {
|
|
912
|
+
const o = S("filter", { id: e, x: "-8%", y: "-8%", width: "116%", height: "116%" });
|
|
913
913
|
return o.appendChild(
|
|
914
914
|
S("feTurbulence", {
|
|
915
915
|
type: "fractalNoise",
|
|
916
916
|
baseFrequency: "0.012 0.028",
|
|
917
917
|
numOctaves: "3",
|
|
918
|
-
seed:
|
|
918
|
+
seed: t,
|
|
919
919
|
result: "stroke-noise"
|
|
920
920
|
})
|
|
921
921
|
), o.appendChild(
|
|
@@ -945,282 +945,282 @@ function ve(t, e, n) {
|
|
|
945
945
|
})
|
|
946
946
|
), o;
|
|
947
947
|
}
|
|
948
|
-
function
|
|
949
|
-
const
|
|
950
|
-
return
|
|
948
|
+
function Un(e) {
|
|
949
|
+
const t = X("0 0 24 24", e, e, "none", "currentColor", "2.25");
|
|
950
|
+
return t.appendChild(S("path", { d: "m6 9 6 6 6-6" })), t;
|
|
951
951
|
}
|
|
952
|
-
function
|
|
953
|
-
const
|
|
954
|
-
return
|
|
952
|
+
function $n() {
|
|
953
|
+
const e = X("0 0 24 24", 17, 17, "none", "currentColor", "2.25");
|
|
954
|
+
return e.appendChild(S("path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" })), e.appendChild(S("path", { d: "M18.4 2.6a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4Z" })), e;
|
|
955
955
|
}
|
|
956
|
-
function
|
|
957
|
-
const
|
|
958
|
-
return
|
|
956
|
+
function Ct() {
|
|
957
|
+
const e = X("0 0 24 24", 14, 14, "none", "currentColor", "2.75");
|
|
958
|
+
return e.appendChild(S("line", { x1: "12", y1: "19", x2: "12", y2: "5" })), e.appendChild(S("polyline", { points: "5 12 12 5 19 12" })), e;
|
|
959
959
|
}
|
|
960
|
-
function
|
|
961
|
-
const
|
|
962
|
-
return
|
|
960
|
+
function Wn() {
|
|
961
|
+
const e = X("0 0 24 24", 18, 18, "currentColor");
|
|
962
|
+
return e.appendChild(S("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" })), e;
|
|
963
963
|
}
|
|
964
|
-
function
|
|
965
|
-
const
|
|
966
|
-
return
|
|
964
|
+
function Hn() {
|
|
965
|
+
const e = X("0 0 24 24", 12, 12, "none", "currentColor", "2.4");
|
|
966
|
+
return e.appendChild(S("path", { d: "M18 6 6 18" })), e.appendChild(S("path", { d: "m6 6 12 12" })), e;
|
|
967
967
|
}
|
|
968
|
-
function
|
|
969
|
-
const
|
|
970
|
-
return
|
|
968
|
+
function Vn() {
|
|
969
|
+
const e = X("0 0 24 24", 13, 13, "none", "currentColor", "2.25");
|
|
970
|
+
return e.appendChild(S("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" })), e.appendChild(S("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })), e;
|
|
971
971
|
}
|
|
972
|
-
function X(
|
|
972
|
+
function X(e, t, n, o, a, i) {
|
|
973
973
|
const l = {
|
|
974
|
-
viewBox:
|
|
975
|
-
width: String(
|
|
974
|
+
viewBox: e,
|
|
975
|
+
width: String(t),
|
|
976
976
|
height: String(n),
|
|
977
977
|
fill: o,
|
|
978
978
|
"aria-hidden": "true"
|
|
979
979
|
};
|
|
980
980
|
return a && (l.stroke = a, l["stroke-linecap"] = "round", l["stroke-linejoin"] = "round"), i && (l["stroke-width"] = i), S("svg", l);
|
|
981
981
|
}
|
|
982
|
-
function S(
|
|
983
|
-
const n = document.createElementNS(
|
|
984
|
-
for (const [o, a] of Object.entries(
|
|
982
|
+
function S(e, t = {}) {
|
|
983
|
+
const n = document.createElementNS(wn, e);
|
|
984
|
+
for (const [o, a] of Object.entries(t))
|
|
985
985
|
n.setAttribute(o, a);
|
|
986
986
|
return n;
|
|
987
987
|
}
|
|
988
|
-
function Qe(
|
|
989
|
-
for (const
|
|
990
|
-
|
|
988
|
+
function Qe(e) {
|
|
989
|
+
for (const t of ["keydown", "keypress", "keyup"])
|
|
990
|
+
e.addEventListener(t, (n) => {
|
|
991
991
|
n.stopPropagation();
|
|
992
992
|
});
|
|
993
993
|
}
|
|
994
|
-
function
|
|
995
|
-
|
|
996
|
-
for (const [o, a] of
|
|
994
|
+
function qn(e, t, n) {
|
|
995
|
+
e.replaceChildren(), e.hidden = t.length === 0;
|
|
996
|
+
for (const [o, a] of t.entries()) {
|
|
997
997
|
const i = document.createElement("div");
|
|
998
|
-
i.className = "pluno-pa-widget__attachment", i.appendChild(
|
|
998
|
+
i.className = "pluno-pa-widget__attachment", i.appendChild(jn(a));
|
|
999
999
|
const l = document.createElement("span");
|
|
1000
1000
|
l.textContent = a.name, i.appendChild(l);
|
|
1001
1001
|
const p = document.createElement("button");
|
|
1002
|
-
p.type = "button", p.setAttribute("aria-label", `Remove ${a.name}`), p.appendChild(
|
|
1002
|
+
p.type = "button", p.setAttribute("aria-label", `Remove ${a.name}`), p.appendChild(Hn()), p.addEventListener("click", () => n(o)), i.appendChild(p), e.appendChild(i);
|
|
1003
1003
|
}
|
|
1004
1004
|
}
|
|
1005
|
-
function
|
|
1006
|
-
if (
|
|
1005
|
+
function jn(e) {
|
|
1006
|
+
if (Et(e)) {
|
|
1007
1007
|
const n = document.createElement("img");
|
|
1008
|
-
return n.src =
|
|
1008
|
+
return n.src = e.dataUrl, n.alt = "", n.setAttribute("aria-hidden", "true"), n;
|
|
1009
1009
|
}
|
|
1010
|
-
const
|
|
1011
|
-
return
|
|
1010
|
+
const t = document.createElement("span");
|
|
1011
|
+
return t.className = "pluno-pa-widget__attachment-file", t.textContent = "PDF", t;
|
|
1012
1012
|
}
|
|
1013
|
-
function
|
|
1014
|
-
if (
|
|
1013
|
+
function Yn(e) {
|
|
1014
|
+
if (Et(e)) {
|
|
1015
1015
|
const a = document.createElement("img");
|
|
1016
|
-
return a.src =
|
|
1016
|
+
return a.src = e.dataUrl, a.alt = e.name, a;
|
|
1017
1017
|
}
|
|
1018
|
-
const
|
|
1019
|
-
|
|
1018
|
+
const t = document.createElement("div");
|
|
1019
|
+
t.className = "pluno-pa-widget__message-attachment-file";
|
|
1020
1020
|
const n = document.createElement("span");
|
|
1021
1021
|
n.textContent = "PDF";
|
|
1022
1022
|
const o = document.createElement("strong");
|
|
1023
|
-
return o.textContent =
|
|
1023
|
+
return o.textContent = e.name, t.append(n, o), t;
|
|
1024
1024
|
}
|
|
1025
|
-
function
|
|
1026
|
-
return
|
|
1025
|
+
function Et(e) {
|
|
1026
|
+
return e.mimeType.startsWith("image/");
|
|
1027
1027
|
}
|
|
1028
|
-
function
|
|
1029
|
-
return
|
|
1028
|
+
function Kn(e) {
|
|
1029
|
+
return e === "application/pdf" ? "document.pdf" : "image";
|
|
1030
1030
|
}
|
|
1031
|
-
async function
|
|
1032
|
-
if (!
|
|
1031
|
+
async function Xn(e) {
|
|
1032
|
+
if (!e)
|
|
1033
1033
|
return [];
|
|
1034
|
-
const
|
|
1035
|
-
if (
|
|
1034
|
+
const t = Array.from(e);
|
|
1035
|
+
if (t.length > de)
|
|
1036
1036
|
throw new Error(`Attach up to ${de} files per message.`);
|
|
1037
1037
|
return Promise.all(
|
|
1038
|
-
|
|
1039
|
-
const o =
|
|
1038
|
+
t.map(async (n) => {
|
|
1039
|
+
const o = Zn(n);
|
|
1040
1040
|
if (!o)
|
|
1041
1041
|
throw new Error("Pluno supports PNG, JPEG, WebP, non-animated GIF, and PDF files.");
|
|
1042
|
-
if (n.size >
|
|
1042
|
+
if (n.size > pn)
|
|
1043
1043
|
throw new Error("Each Pluno attachment can be up to 10 MB.");
|
|
1044
1044
|
if (o === "image/gif") {
|
|
1045
|
-
const a = new Uint8Array(await
|
|
1046
|
-
if (
|
|
1045
|
+
const a = new Uint8Array(await ro(n));
|
|
1046
|
+
if (Qn(a))
|
|
1047
1047
|
throw new Error("Pluno supports non-animated GIF images.");
|
|
1048
1048
|
}
|
|
1049
1049
|
return {
|
|
1050
|
-
name: n.name ||
|
|
1050
|
+
name: n.name || Kn(o),
|
|
1051
1051
|
mimeType: o,
|
|
1052
1052
|
sizeBytes: n.size,
|
|
1053
|
-
dataUrl:
|
|
1053
|
+
dataUrl: Jn(await lo(n), o)
|
|
1054
1054
|
};
|
|
1055
1055
|
})
|
|
1056
1056
|
);
|
|
1057
1057
|
}
|
|
1058
|
-
function
|
|
1059
|
-
if (
|
|
1060
|
-
return
|
|
1061
|
-
const
|
|
1062
|
-
return
|
|
1058
|
+
function Zn(e) {
|
|
1059
|
+
if (sn.has(e.type))
|
|
1060
|
+
return e.type;
|
|
1061
|
+
const t = e.name.toLowerCase();
|
|
1062
|
+
return t.endsWith(".png") ? "image/png" : t.endsWith(".jpg") || t.endsWith(".jpeg") ? "image/jpeg" : t.endsWith(".webp") ? "image/webp" : t.endsWith(".gif") ? "image/gif" : t.endsWith(".pdf") ? "application/pdf" : null;
|
|
1063
1063
|
}
|
|
1064
|
-
function
|
|
1065
|
-
const n = `data:${
|
|
1066
|
-
return
|
|
1064
|
+
function Jn(e, t) {
|
|
1065
|
+
const n = `data:${t};base64,`;
|
|
1066
|
+
return e.startsWith(n) ? e : e.replace(/^data:[^;]*;base64,/, n);
|
|
1067
1067
|
}
|
|
1068
|
-
function
|
|
1069
|
-
if (
|
|
1068
|
+
function Qn(e) {
|
|
1069
|
+
if (e.length < 14 || !eo(e))
|
|
1070
1070
|
return !1;
|
|
1071
|
-
const
|
|
1071
|
+
const t = e[10];
|
|
1072
1072
|
let n = 13;
|
|
1073
|
-
|
|
1073
|
+
t & 128 && (n += 3 * 2 ** ((t & 7) + 1));
|
|
1074
1074
|
let o = 0;
|
|
1075
|
-
for (; n <
|
|
1076
|
-
const a =
|
|
1075
|
+
for (; n < e.length; ) {
|
|
1076
|
+
const a = e[n];
|
|
1077
1077
|
if (n += 1, a === 59)
|
|
1078
1078
|
return !1;
|
|
1079
1079
|
if (a === 33) {
|
|
1080
|
-
n += 1, n = et(
|
|
1080
|
+
n += 1, n = et(e, n);
|
|
1081
1081
|
continue;
|
|
1082
1082
|
}
|
|
1083
1083
|
if (a !== 44)
|
|
1084
1084
|
return !1;
|
|
1085
1085
|
if (o += 1, o > 1)
|
|
1086
1086
|
return !0;
|
|
1087
|
-
if (n + 9 >=
|
|
1087
|
+
if (n + 9 >= e.length)
|
|
1088
1088
|
return !1;
|
|
1089
|
-
const i =
|
|
1090
|
-
if (n += 9, i & 128 && (n += 3 * 2 ** ((i & 7) + 1)), n >=
|
|
1089
|
+
const i = e[n + 8];
|
|
1090
|
+
if (n += 9, i & 128 && (n += 3 * 2 ** ((i & 7) + 1)), n >= e.length)
|
|
1091
1091
|
return !1;
|
|
1092
|
-
n += 1, n = et(
|
|
1092
|
+
n += 1, n = et(e, n);
|
|
1093
1093
|
}
|
|
1094
1094
|
return !1;
|
|
1095
1095
|
}
|
|
1096
|
-
function
|
|
1097
|
-
return
|
|
1096
|
+
function eo(e) {
|
|
1097
|
+
return e[0] === 71 && e[1] === 73 && e[2] === 70 && e[3] === 56 && (e[4] === 55 || e[4] === 57) && e[5] === 97;
|
|
1098
1098
|
}
|
|
1099
|
-
function et(
|
|
1100
|
-
for (;
|
|
1101
|
-
const n = t
|
|
1102
|
-
if (
|
|
1103
|
-
return
|
|
1104
|
-
|
|
1099
|
+
function et(e, t) {
|
|
1100
|
+
for (; t < e.length; ) {
|
|
1101
|
+
const n = e[t];
|
|
1102
|
+
if (t += 1, n === 0)
|
|
1103
|
+
return t;
|
|
1104
|
+
t += n;
|
|
1105
1105
|
}
|
|
1106
|
-
return
|
|
1106
|
+
return t;
|
|
1107
1107
|
}
|
|
1108
|
-
function le(
|
|
1109
|
-
return !!(
|
|
1108
|
+
function le(e) {
|
|
1109
|
+
return !!(e && Array.from(e.types).includes("Files"));
|
|
1110
1110
|
}
|
|
1111
|
-
function
|
|
1112
|
-
if (!
|
|
1113
|
-
|
|
1111
|
+
function ve(e, t, n = null) {
|
|
1112
|
+
if (!e || !Pe(t, n)) {
|
|
1113
|
+
e && (e.hidden = !0, e.replaceChildren());
|
|
1114
1114
|
return;
|
|
1115
1115
|
}
|
|
1116
|
-
|
|
1116
|
+
e.hidden = !1, e.replaceChildren(), e.className = "pluno-pa-widget__billing-status", F(t) || Te(n) ? e.appendChild(to(t, n)) : kt(t) && e.appendChild(no(t));
|
|
1117
1117
|
}
|
|
1118
|
-
function
|
|
1118
|
+
function to(e, t) {
|
|
1119
1119
|
const n = document.createElement("div");
|
|
1120
1120
|
n.className = "pluno-pa-widget__billing-action-card";
|
|
1121
|
-
const o =
|
|
1121
|
+
const o = e.limitExceeded || t === "limit_exceeded", a = document.createElement("strong");
|
|
1122
1122
|
a.textContent = o ? "Credits used up" : "Billing needs attention", n.appendChild(a);
|
|
1123
1123
|
const i = document.createElement("span");
|
|
1124
|
-
return i.textContent = o ? "Earn bonus credits or upgrade to keep using Pluno on this product." :
|
|
1124
|
+
return i.textContent = o ? "Earn bonus credits or upgrade to keep using Pluno on this product." : e.paymentIssue ?? "Open billing to keep using Pluno.", n.appendChild(i), n.appendChild(St(e, "Upgrade plan", "pluno-pa-widget__billing-action-card-actions")), n;
|
|
1125
1125
|
}
|
|
1126
|
-
function
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1126
|
+
function no(e) {
|
|
1127
|
+
const t = document.createElement("div");
|
|
1128
|
+
t.className = "pluno-pa-widget__billing-action-card pluno-pa-widget__billing-action-card--low";
|
|
1129
1129
|
const n = document.createElement("strong");
|
|
1130
|
-
n.textContent = "Credits running low",
|
|
1130
|
+
n.textContent = "Credits running low", t.appendChild(n);
|
|
1131
1131
|
const o = document.createElement("span");
|
|
1132
|
-
return o.textContent =
|
|
1132
|
+
return o.textContent = ao(e) ?? "Credits are running low for this period.", t.appendChild(o), t.appendChild(St(e, "Upgrade", "pluno-pa-widget__billing-action-card-actions")), t;
|
|
1133
1133
|
}
|
|
1134
|
-
function Pe(
|
|
1135
|
-
return
|
|
1134
|
+
function Pe(e, t) {
|
|
1135
|
+
return e !== null && (F(e) || kt(e) || Te(t));
|
|
1136
1136
|
}
|
|
1137
|
-
function tt(
|
|
1138
|
-
return Pe(
|
|
1137
|
+
function tt(e, t, n) {
|
|
1138
|
+
return Pe(t, n) || oo(t) ? !0 : !Pe(e, n);
|
|
1139
1139
|
}
|
|
1140
|
-
function
|
|
1141
|
-
return
|
|
1140
|
+
function oo(e) {
|
|
1141
|
+
return e != null && (e.creditsUsed !== null || e.creditLimit !== null || e.creditsRemaining !== null || F(e));
|
|
1142
1142
|
}
|
|
1143
|
-
function F(
|
|
1144
|
-
return
|
|
1143
|
+
function F(e) {
|
|
1144
|
+
return e?.limitExceeded === !0 || !!e?.paymentIssue;
|
|
1145
1145
|
}
|
|
1146
|
-
function
|
|
1147
|
-
return
|
|
1146
|
+
function Te(e) {
|
|
1147
|
+
return e === "limit_exceeded" || e === "subscription_required" || e === "subscription_inactive" || e === "payment_issue" || e === "subscription_invalid" || e === "payment_required";
|
|
1148
1148
|
}
|
|
1149
|
-
function
|
|
1150
|
-
return !F(
|
|
1149
|
+
function kt(e) {
|
|
1150
|
+
return !F(e) && e.creditLimit !== null && e.creditLimit > 0 && e.creditsRemaining !== null && e.creditsRemaining > 0 && e.creditsRemaining / e.creditLimit <= 0.2;
|
|
1151
1151
|
}
|
|
1152
|
-
function
|
|
1153
|
-
return
|
|
1152
|
+
function ao(e) {
|
|
1153
|
+
return e.creditsRemaining === null ? null : `${io(e.creditsRemaining)} credits left`;
|
|
1154
1154
|
}
|
|
1155
|
-
function
|
|
1155
|
+
function io(e) {
|
|
1156
1156
|
return new Intl.NumberFormat("en-US", {
|
|
1157
1157
|
maximumFractionDigits: 0
|
|
1158
|
-
}).format(Math.ceil(
|
|
1158
|
+
}).format(Math.ceil(e));
|
|
1159
1159
|
}
|
|
1160
|
-
function
|
|
1160
|
+
function St(e, t, n) {
|
|
1161
1161
|
const o = document.createElement("div");
|
|
1162
|
-
return o.className = n, o.appendChild(nt(
|
|
1162
|
+
return o.className = n, o.appendChild(nt(t, e.pricingUrl)), o.appendChild(nt("Earn credits", e.earnCreditsUrl)), o;
|
|
1163
1163
|
}
|
|
1164
|
-
function nt(
|
|
1164
|
+
function nt(e, t) {
|
|
1165
1165
|
const n = document.createElement("button");
|
|
1166
|
-
return n.type = "button", n.textContent =
|
|
1167
|
-
|
|
1166
|
+
return n.type = "button", n.textContent = e, n.disabled = t.trim().length === 0, n.addEventListener("click", () => {
|
|
1167
|
+
t.trim().length !== 0 && window.open(t, "_blank", "noopener,noreferrer");
|
|
1168
1168
|
}), n;
|
|
1169
1169
|
}
|
|
1170
|
-
function
|
|
1171
|
-
return new Promise((
|
|
1170
|
+
function ro(e) {
|
|
1171
|
+
return new Promise((t, n) => {
|
|
1172
1172
|
const o = new FileReader();
|
|
1173
1173
|
o.addEventListener("load", () => {
|
|
1174
1174
|
if (o.result instanceof ArrayBuffer) {
|
|
1175
|
-
|
|
1175
|
+
t(o.result);
|
|
1176
1176
|
return;
|
|
1177
1177
|
}
|
|
1178
1178
|
n(new Error("Failed to read file"));
|
|
1179
1179
|
}), o.addEventListener("error", () => {
|
|
1180
1180
|
n(o.error ?? new Error("Failed to read file"));
|
|
1181
|
-
}), o.readAsArrayBuffer(
|
|
1181
|
+
}), o.readAsArrayBuffer(e);
|
|
1182
1182
|
});
|
|
1183
1183
|
}
|
|
1184
|
-
function
|
|
1185
|
-
return new Promise((
|
|
1184
|
+
function lo(e) {
|
|
1185
|
+
return new Promise((t, n) => {
|
|
1186
1186
|
const o = new FileReader();
|
|
1187
1187
|
o.addEventListener("load", () => {
|
|
1188
1188
|
if (typeof o.result == "string") {
|
|
1189
|
-
|
|
1189
|
+
t(o.result);
|
|
1190
1190
|
return;
|
|
1191
1191
|
}
|
|
1192
1192
|
n(new Error("Failed to read file"));
|
|
1193
1193
|
}), o.addEventListener("error", () => {
|
|
1194
1194
|
n(o.error ?? new Error("Failed to read file"));
|
|
1195
|
-
}), o.readAsDataURL(
|
|
1195
|
+
}), o.readAsDataURL(e);
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
1198
|
-
function
|
|
1199
|
-
const g = [...o.messages], u = g.filter((h) => !
|
|
1200
|
-
|
|
1198
|
+
function po(e, t, n, o, a, i, l, p, s) {
|
|
1199
|
+
const g = [...o.messages], u = g.filter((h) => !wo(h));
|
|
1200
|
+
e.replaceChildren(), Pt(t, o.isThinking);
|
|
1201
1201
|
const b = u.length > 0 || !!o.assistantDraft || o.isThinking;
|
|
1202
1202
|
if (n.hidden = !b, u.length === 0 && !o.assistantDraft && !o.lastError && !o.isThinking) {
|
|
1203
1203
|
const h = document.createElement("div");
|
|
1204
1204
|
h.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
1205
1205
|
const _ = document.createElement("img");
|
|
1206
|
-
_.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", _.src = l(), _.alt = "", _.setAttribute("aria-hidden", "true"), h.appendChild(_), h.appendChild(
|
|
1206
|
+
_.className = "pluno-pa-widget__character pluno-pa-widget__character--empty", _.src = l(), _.alt = "", _.setAttribute("aria-hidden", "true"), h.appendChild(_), h.appendChild(xt());
|
|
1207
1207
|
const k = document.createElement("div");
|
|
1208
1208
|
k.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 && k.setAttribute("aria-hidden", "true");
|
|
1209
|
-
for (const
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1212
|
-
p(
|
|
1213
|
-
}), k.appendChild(
|
|
1209
|
+
for (const y of o.starterPrompts) {
|
|
1210
|
+
const v = document.createElement("button");
|
|
1211
|
+
v.type = "button", v.className = "pluno-pa-widget__starter-prompt", v.textContent = `"${y}"`, v.addEventListener("click", () => {
|
|
1212
|
+
p(y);
|
|
1213
|
+
}), k.appendChild(v);
|
|
1214
1214
|
}
|
|
1215
|
-
h.appendChild(k),
|
|
1215
|
+
h.appendChild(k), e.appendChild(h);
|
|
1216
1216
|
return;
|
|
1217
1217
|
}
|
|
1218
1218
|
let w = null, x = null, C = [];
|
|
1219
1219
|
const m = () => {
|
|
1220
1220
|
if (C.length === 0)
|
|
1221
1221
|
return !1;
|
|
1222
|
-
const h =
|
|
1223
|
-
return
|
|
1222
|
+
const h = _o(C, a, i, l());
|
|
1223
|
+
return e.appendChild(h), w = null, x = h, C = [], !0;
|
|
1224
1224
|
};
|
|
1225
1225
|
for (let h = 0; h < u.length; h += 1) {
|
|
1226
1226
|
const _ = u[h];
|
|
@@ -1230,54 +1230,54 @@ function io(t, e, n, o, a, i, l, p, s) {
|
|
|
1230
1230
|
}
|
|
1231
1231
|
if (_.role === "system")
|
|
1232
1232
|
continue;
|
|
1233
|
-
const k = m(),
|
|
1233
|
+
const k = m(), y = at(_.content);
|
|
1234
1234
|
if (_.role === "assistant" && !k) {
|
|
1235
1235
|
const ne = Ae(l());
|
|
1236
|
-
|
|
1236
|
+
e.appendChild(ne), w = null, x = ne;
|
|
1237
1237
|
}
|
|
1238
|
-
const
|
|
1239
|
-
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1238
|
+
const v = document.createElement("div");
|
|
1239
|
+
v.className = `pluno-pa-widget__message pluno-pa-widget__message--${_.role}`, _.role === "assistant" ? it(v, y) : v.textContent = y, _.role === "user" && _.attachments?.length && v.appendChild(co(_.attachments));
|
|
1240
|
+
const D = document.createElement("div");
|
|
1241
|
+
D.className = "pluno-pa-widget__message-actions", D.appendChild(ot(y)), v.appendChild(D), e.appendChild(v), w = v, x = null;
|
|
1242
1242
|
}
|
|
1243
1243
|
const f = m();
|
|
1244
1244
|
if (o.assistantDraft) {
|
|
1245
1245
|
if (!f) {
|
|
1246
|
-
const
|
|
1247
|
-
|
|
1246
|
+
const y = Ae(l());
|
|
1247
|
+
e.appendChild(y), w = null, x = y;
|
|
1248
1248
|
}
|
|
1249
1249
|
const h = at(o.assistantDraft), _ = document.createElement("div");
|
|
1250
1250
|
_.className = "pluno-pa-widget__message pluno-pa-widget__message--assistant", it(_, h);
|
|
1251
1251
|
const k = document.createElement("div");
|
|
1252
|
-
k.className = "pluno-pa-widget__message-actions", k.appendChild(ot(h)), _.appendChild(k),
|
|
1252
|
+
k.className = "pluno-pa-widget__message-actions", k.appendChild(ot(h)), _.appendChild(k), e.appendChild(_), w = _, x = null;
|
|
1253
1253
|
}
|
|
1254
1254
|
if (o.isThinking && !o.assistantDraft)
|
|
1255
1255
|
if (f) {
|
|
1256
|
-
const h =
|
|
1257
|
-
|
|
1256
|
+
const h = Lt();
|
|
1257
|
+
e.appendChild(h), w = null, x = h;
|
|
1258
1258
|
} else {
|
|
1259
|
-
const h =
|
|
1260
|
-
|
|
1259
|
+
const h = xo(l());
|
|
1260
|
+
e.appendChild(h), w = null, x = h;
|
|
1261
1261
|
}
|
|
1262
1262
|
if (o.lastError) {
|
|
1263
1263
|
const h = document.createElement("div");
|
|
1264
|
-
h.className = "pluno-pa-widget__error", h.textContent = o.lastError,
|
|
1264
|
+
h.className = "pluno-pa-widget__error", h.textContent = o.lastError, e.appendChild(h), w = h, x = null;
|
|
1265
1265
|
}
|
|
1266
|
-
const d = s && !o.isThinking ?
|
|
1266
|
+
const d = s && !o.isThinking ? Xt(g) : null;
|
|
1267
1267
|
if (s && d && !s.dismissedCandidateIds.has(d.id)) {
|
|
1268
|
-
const h =
|
|
1268
|
+
const h = uo(d, {
|
|
1269
1269
|
isDrafting: s.draftingCandidateId === d.id,
|
|
1270
1270
|
error: s.error,
|
|
1271
1271
|
onDraft: s.onDraft,
|
|
1272
1272
|
onDismiss: s.onDismiss,
|
|
1273
1273
|
onDisable: s.onDisable
|
|
1274
1274
|
});
|
|
1275
|
-
|
|
1275
|
+
e.appendChild(h), s.onSeen(d), w = null, x = h;
|
|
1276
1276
|
}
|
|
1277
|
-
w?.classList.add("pluno-pa-widget__message--bottom-reserve"), x?.classList.add("pluno-pa-widget__bottom-reserve-compact"),
|
|
1277
|
+
w?.classList.add("pluno-pa-widget__message--bottom-reserve"), x?.classList.add("pluno-pa-widget__bottom-reserve-compact"), e.scrollTop = e.scrollHeight;
|
|
1278
1278
|
}
|
|
1279
|
-
function
|
|
1280
|
-
|
|
1279
|
+
function so(e, t, n, o, a, i) {
|
|
1280
|
+
e.replaceChildren(), Pt(t, !1), t.disabled = !0, n.hidden = !0;
|
|
1281
1281
|
const l = document.createElement("div");
|
|
1282
1282
|
l.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter";
|
|
1283
1283
|
const p = document.createElement("img");
|
|
@@ -1285,22 +1285,22 @@ function ro(t, e, n, o, a, i) {
|
|
|
1285
1285
|
const s = document.createElement("div");
|
|
1286
1286
|
s.className = "pluno-pa-widget__empty", s.textContent = "Log in to use Pluno on this page.", l.appendChild(s);
|
|
1287
1287
|
const g = document.createElement("button");
|
|
1288
|
-
g.type = "button", g.className = "pluno-pa-widget__login", g.textContent = a, g.addEventListener("click", () => i?.()), l.appendChild(g),
|
|
1288
|
+
g.type = "button", g.className = "pluno-pa-widget__login", g.textContent = a, g.addEventListener("click", () => i?.()), l.appendChild(g), e.appendChild(l);
|
|
1289
1289
|
}
|
|
1290
|
-
function
|
|
1291
|
-
const
|
|
1292
|
-
|
|
1293
|
-
for (const n of
|
|
1294
|
-
|
|
1295
|
-
return
|
|
1296
|
-
}
|
|
1297
|
-
function ot(
|
|
1298
|
-
const
|
|
1299
|
-
return
|
|
1300
|
-
n.preventDefault(), n.stopPropagation(), navigator.clipboard.writeText(
|
|
1301
|
-
}),
|
|
1302
|
-
}
|
|
1303
|
-
function
|
|
1290
|
+
function co(e) {
|
|
1291
|
+
const t = document.createElement("div");
|
|
1292
|
+
t.className = "pluno-pa-widget__message-attachments";
|
|
1293
|
+
for (const n of e)
|
|
1294
|
+
t.appendChild(Yn(n));
|
|
1295
|
+
return t;
|
|
1296
|
+
}
|
|
1297
|
+
function ot(e) {
|
|
1298
|
+
const t = document.createElement("button");
|
|
1299
|
+
return t.type = "button", t.className = "pluno-pa-widget__message-copy", t.setAttribute("aria-label", "Copy message"), t.title = "Copy message", t.appendChild(Vn()), t.addEventListener("click", (n) => {
|
|
1300
|
+
n.preventDefault(), n.stopPropagation(), navigator.clipboard.writeText(e);
|
|
1301
|
+
}), t;
|
|
1302
|
+
}
|
|
1303
|
+
function uo(e, t) {
|
|
1304
1304
|
const n = document.createElement("article");
|
|
1305
1305
|
n.className = "pluno-pa-widget__share-prompt";
|
|
1306
1306
|
const o = document.createElement("div");
|
|
@@ -1310,9 +1310,9 @@ function po(t, e) {
|
|
|
1310
1310
|
const i = document.createElement("strong");
|
|
1311
1311
|
i.textContent = "Share this win?", a.appendChild(i);
|
|
1312
1312
|
const l = document.createElement("span");
|
|
1313
|
-
if (l.textContent =
|
|
1313
|
+
if (l.textContent = t.isDrafting ? "Drafting social post..." : "Create a screenshot and generate a draft for a social post.", a.appendChild(l), t.error) {
|
|
1314
1314
|
const u = document.createElement("span");
|
|
1315
|
-
u.className = "pluno-pa-widget__share-prompt-error", u.textContent =
|
|
1315
|
+
u.className = "pluno-pa-widget__share-prompt-error", u.textContent = t.error, a.appendChild(u);
|
|
1316
1316
|
}
|
|
1317
1317
|
o.appendChild(a);
|
|
1318
1318
|
const p = document.createElement("div");
|
|
@@ -1320,33 +1320,33 @@ function po(t, e) {
|
|
|
1320
1320
|
const s = document.createElement("div");
|
|
1321
1321
|
s.className = "pluno-pa-widget__share-prompt-primary-actions";
|
|
1322
1322
|
const g = document.createElement("button");
|
|
1323
|
-
if (g.type = "button", g.disabled =
|
|
1324
|
-
|
|
1325
|
-
}),
|
|
1323
|
+
if (g.type = "button", g.disabled = t.isDrafting, g.addEventListener("click", () => {
|
|
1324
|
+
t.onDraft(e);
|
|
1325
|
+
}), t.isDrafting ? (g.appendChild(Ne()), g.appendChild(document.createTextNode("Drafting..."))) : g.textContent = "Draft a social post", s.appendChild(g), t.isDrafting)
|
|
1326
1326
|
p.appendChild(s);
|
|
1327
1327
|
else {
|
|
1328
1328
|
const u = document.createElement("button");
|
|
1329
1329
|
u.type = "button", u.className = "pluno-pa-widget__share-prompt-dismiss", u.setAttribute("aria-label", "Dismiss share prompt"), u.title = "Dismiss", u.textContent = "Dismiss", u.addEventListener("click", () => {
|
|
1330
|
-
|
|
1330
|
+
t.onDismiss(e);
|
|
1331
1331
|
}), s.appendChild(u), p.appendChild(s);
|
|
1332
1332
|
const b = document.createElement("button");
|
|
1333
1333
|
b.type = "button", b.className = "pluno-pa-widget__share-prompt-disable", b.textContent = "Don't ask again", b.addEventListener("click", () => {
|
|
1334
|
-
|
|
1334
|
+
t.onDisable(e);
|
|
1335
1335
|
}), p.appendChild(b);
|
|
1336
1336
|
}
|
|
1337
1337
|
return o.appendChild(p), n.appendChild(o), n;
|
|
1338
1338
|
}
|
|
1339
|
-
function
|
|
1339
|
+
function go(e, t) {
|
|
1340
1340
|
const n = document.createElement("div");
|
|
1341
1341
|
n.className = "pluno-pa-widget__share-dialog-backdrop", n.addEventListener("click", (f) => {
|
|
1342
|
-
f.target === n &&
|
|
1342
|
+
f.target === n && t.onClose();
|
|
1343
1343
|
});
|
|
1344
1344
|
const o = document.createElement("section");
|
|
1345
1345
|
o.className = "pluno-pa-widget__share-dialog", o.setAttribute("role", "dialog"), o.setAttribute("aria-modal", "true"), o.setAttribute("aria-label", "Draft a social post");
|
|
1346
1346
|
const a = document.createElement("header"), i = document.createElement("strong");
|
|
1347
1347
|
i.textContent = "Share this win", a.appendChild(i);
|
|
1348
1348
|
const l = document.createElement("button");
|
|
1349
|
-
l.type = "button", l.setAttribute("aria-label", "Close"), l.textContent = "×", l.addEventListener("click",
|
|
1349
|
+
l.type = "button", l.setAttribute("aria-label", "Close"), l.textContent = "×", l.addEventListener("click", t.onClose), a.appendChild(l), o.appendChild(a);
|
|
1350
1350
|
const p = document.createElement("p");
|
|
1351
1351
|
p.className = "pluno-pa-widget__share-dialog-status", p.hidden = !0;
|
|
1352
1352
|
const s = document.createElement("div");
|
|
@@ -1355,18 +1355,18 @@ function so(t, e) {
|
|
|
1355
1355
|
g.className = "pluno-pa-widget__share-dialog-step-header";
|
|
1356
1356
|
const u = document.createElement("strong");
|
|
1357
1357
|
u.textContent = "1) Copy Screenshot", g.appendChild(u);
|
|
1358
|
-
const b =
|
|
1358
|
+
const b = ho("Copy Screenshot", async () => {
|
|
1359
1359
|
try {
|
|
1360
|
-
return await
|
|
1360
|
+
return await Zt(e.screenshotDataUrl ?? ""), p.textContent = "", p.hidden = !0, !0;
|
|
1361
1361
|
} catch {
|
|
1362
1362
|
return p.textContent = "Could not copy screenshot.", p.hidden = !1, !1;
|
|
1363
1363
|
}
|
|
1364
1364
|
});
|
|
1365
|
-
if (g.appendChild(b), s.appendChild(g),
|
|
1365
|
+
if (g.appendChild(b), s.appendChild(g), e.screenshotDataUrl) {
|
|
1366
1366
|
const f = document.createElement("div");
|
|
1367
1367
|
f.className = "pluno-pa-widget__share-dialog-screenshot";
|
|
1368
1368
|
const d = document.createElement("img");
|
|
1369
|
-
d.src =
|
|
1369
|
+
d.src = e.screenshotDataUrl, d.alt = "Product page with Pluno open", f.appendChild(d), s.appendChild(f);
|
|
1370
1370
|
}
|
|
1371
1371
|
o.appendChild(s), o.appendChild(p);
|
|
1372
1372
|
const w = document.createElement("div");
|
|
@@ -1377,33 +1377,33 @@ function so(t, e) {
|
|
|
1377
1377
|
C.className = "pluno-pa-widget__share-dialog-hint", C.textContent = "Post draft opens prefilled on supported platforms.", w.appendChild(C);
|
|
1378
1378
|
const m = document.createElement("footer");
|
|
1379
1379
|
m.className = "pluno-pa-widget__share-dialog-platforms";
|
|
1380
|
-
for (const f of
|
|
1380
|
+
for (const f of mo(e)) {
|
|
1381
1381
|
const d = document.createElement("a");
|
|
1382
|
-
d.href = f.href, d.target = "_blank", d.rel = "noopener noreferrer", d.title = f.label, d.setAttribute("aria-label", `Open ${f.label}`), d.appendChild(
|
|
1382
|
+
d.href = f.href, d.target = "_blank", d.rel = "noopener noreferrer", d.title = f.label, d.setAttribute("aria-label", `Open ${f.label}`), d.appendChild(fo(f.id)), m.appendChild(d);
|
|
1383
1383
|
}
|
|
1384
|
-
if (w.appendChild(m), o.appendChild(w),
|
|
1384
|
+
if (w.appendChild(m), o.appendChild(w), t.socialPostRewardsUrl) {
|
|
1385
1385
|
const f = document.createElement("div");
|
|
1386
1386
|
f.className = "pluno-pa-widget__share-dialog-step";
|
|
1387
1387
|
const d = document.createElement("strong");
|
|
1388
1388
|
d.className = "pluno-pa-widget__share-dialog-step-title", d.textContent = "3) Submit post to get 2000 free credits!", f.appendChild(d);
|
|
1389
1389
|
const h = document.createElement("a");
|
|
1390
|
-
h.className = "pluno-pa-widget__share-dialog-reward-link", h.href =
|
|
1390
|
+
h.className = "pluno-pa-widget__share-dialog-reward-link", h.href = t.socialPostRewardsUrl, h.target = "_blank", h.rel = "noopener noreferrer", h.appendChild(document.createTextNode("Submit post URL")), h.appendChild(bo()), f.appendChild(h), o.appendChild(f);
|
|
1391
1391
|
}
|
|
1392
1392
|
return n.appendChild(o), n;
|
|
1393
1393
|
}
|
|
1394
|
-
function
|
|
1394
|
+
function ho(e, t) {
|
|
1395
1395
|
const n = document.createElement("button");
|
|
1396
|
-
return n.type = "button", n.className = "pluno-pa-widget__share-dialog-copy", n.textContent =
|
|
1397
|
-
o.preventDefault(), o.stopPropagation(), await
|
|
1396
|
+
return n.type = "button", n.className = "pluno-pa-widget__share-dialog-copy", n.textContent = e, n.addEventListener("click", async (o) => {
|
|
1397
|
+
o.preventDefault(), o.stopPropagation(), await t() && (n.textContent = "Copied ✓");
|
|
1398
1398
|
}), n;
|
|
1399
1399
|
}
|
|
1400
|
-
function
|
|
1401
|
-
const
|
|
1400
|
+
function mo(e) {
|
|
1401
|
+
const t = e.linkedinPost.trim(), n = e.xPost.trim();
|
|
1402
1402
|
return [
|
|
1403
1403
|
{
|
|
1404
1404
|
id: "linkedin",
|
|
1405
1405
|
label: "LinkedIn",
|
|
1406
|
-
href: `https://www.linkedin.com/feed/?shareActive=true&text=${encodeURIComponent(
|
|
1406
|
+
href: `https://www.linkedin.com/feed/?shareActive=true&text=${encodeURIComponent(t)}`
|
|
1407
1407
|
},
|
|
1408
1408
|
{
|
|
1409
1409
|
id: "x",
|
|
@@ -1417,40 +1417,40 @@ function uo(t) {
|
|
|
1417
1417
|
}
|
|
1418
1418
|
];
|
|
1419
1419
|
}
|
|
1420
|
-
function
|
|
1421
|
-
const
|
|
1422
|
-
return
|
|
1420
|
+
function fo(e) {
|
|
1421
|
+
const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1422
|
+
return t.setAttribute("class", "pluno-pa-widget__share-dialog-platform-logo"), t.setAttribute("viewBox", "0 0 32 32"), t.setAttribute("aria-hidden", "true"), e === "linkedin" ? (P(t, "M6.7 13.2c.4 4.1.2 8.1.1 12.3"), P(t, "M6.4 6.9c.6-.5 1.6-.5 2.1.1.7.7.5 1.8-.2 2.3-.8.5-1.9.2-2.3-.6-.2-.6 0-1.3.4-1.8Z"), P(t, "M14.4 13.3c.1 3.8.1 7.8 0 11.9"), P(t, "M14.8 16.2c1.2-2 3-3.1 5.1-2.9 3.4.3 4.8 2.7 4.8 6.2 0 1.9-.1 3.8-.1 5.8"), P(t, "M20 18c.1 2.2.1 4.7 0 7.2"), t) : e === "x" ? (P(t, "M7.2 7.4c5.6 6.4 10.9 12.2 17.7 17.2"), P(t, "M24.4 7.2c-5.1 6.3-10.6 11.8-17 17.8"), P(t, "M9.1 8.2c5.1 5.6 9.7 10.8 15 15.5", "0.55"), t) : (P(t, "M10.2 6.4c3.8-.3 8-.3 11.6.1 2.5.3 3.8 1.8 4 4 .4 3.3.4 7.4 0 10.9-.3 2.4-1.7 3.8-4 4.1-3.8.4-8.2.4-11.8 0-2.3-.3-3.7-1.8-4-4.1-.4-3.5-.3-7.8.1-11.1.2-2.2 1.8-3.6 4.1-3.9Z"), P(t, "M11 7.3c3.4-.4 7.1-.4 10.2.1 2 .3 3.1 1.4 3.4 3.2.4 3 .4 6.6.1 9.9-.3 2.2-1.3 3.3-3.3 3.7-3.2.5-7.2.5-10.5.1", "0.48"), P(t, "M12.1 16.1c.1-2.4 1.8-4.1 4-4.2 2.4-.1 4.2 1.6 4.3 4 .1 2.3-1.6 4.1-3.9 4.2-2.6.2-4.3-1.5-4.4-4Z"), P(t, "M22 10.7c.3-.1.7 0 .9.3.2.4.1.8-.2 1-.4.2-.8.1-1-.2-.2-.4-.1-.8.3-1.1Z"), t);
|
|
1423
1423
|
}
|
|
1424
|
-
function P(
|
|
1424
|
+
function P(e, t, n) {
|
|
1425
1425
|
const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1426
|
-
o.setAttribute("d",
|
|
1426
|
+
o.setAttribute("d", t), n && o.setAttribute("opacity", n), e.appendChild(o);
|
|
1427
1427
|
}
|
|
1428
|
-
function
|
|
1429
|
-
const
|
|
1430
|
-
return
|
|
1428
|
+
function bo() {
|
|
1429
|
+
const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
1430
|
+
return e.setAttribute("class", "pluno-pa-widget__share-dialog-external-icon"), e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("aria-hidden", "true"), P(e, "M14 5h5v5"), P(e, "M19 5l-8 8"), P(e, "M18 13v5a1 1 0 0 1-1 1H7a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1h5"), e;
|
|
1431
1431
|
}
|
|
1432
|
-
function
|
|
1433
|
-
return
|
|
1432
|
+
function wo(e) {
|
|
1433
|
+
return e.role === "tool" && e.toolName === ut;
|
|
1434
1434
|
}
|
|
1435
|
-
function at(
|
|
1436
|
-
return
|
|
1435
|
+
function at(e) {
|
|
1436
|
+
return e.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
|
|
1437
1437
|
}
|
|
1438
|
-
function
|
|
1438
|
+
function _o(e, t, n, o) {
|
|
1439
1439
|
const a = document.createElement("article");
|
|
1440
|
-
a.className = "pluno-pa-widget__tool-group", a.title = new Date(
|
|
1440
|
+
a.className = "pluno-pa-widget__tool-group", a.title = new Date(e[e.length - 1].createdAt).toLocaleString();
|
|
1441
1441
|
const i = document.createElement("img");
|
|
1442
1442
|
i.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", i.src = o, i.alt = "", i.setAttribute("aria-hidden", "true"), a.appendChild(i);
|
|
1443
|
-
const l = document.createElement("details"), p =
|
|
1444
|
-
l.open =
|
|
1445
|
-
l.open ?
|
|
1443
|
+
const l = document.createElement("details"), p = yo(e);
|
|
1444
|
+
l.open = t.has(p), l.addEventListener("toggle", () => {
|
|
1445
|
+
l.open ? t.add(p) : t.delete(p), n();
|
|
1446
1446
|
});
|
|
1447
1447
|
const s = document.createElement("summary");
|
|
1448
|
-
s.className = "pluno-pa-widget__tool-summary",
|
|
1448
|
+
s.className = "pluno-pa-widget__tool-summary", e.some((b) => b.loading) && s.appendChild(Ne());
|
|
1449
1449
|
const u = document.createElement("span");
|
|
1450
|
-
if (u.className = "pluno-pa-widget__tool-summary-title", u.textContent =
|
|
1450
|
+
if (u.className = "pluno-pa-widget__tool-summary-title", u.textContent = e[e.length - 1].content || "Run tool", s.appendChild(u), l.appendChild(s), e.length > 0) {
|
|
1451
1451
|
const b = document.createElement("div");
|
|
1452
1452
|
b.className = "pluno-pa-widget__tool-lines";
|
|
1453
|
-
for (const w of
|
|
1453
|
+
for (const w of e) {
|
|
1454
1454
|
const x = document.createElement("div");
|
|
1455
1455
|
x.className = "pluno-pa-widget__tool-line", w.loading && x.appendChild(Ne());
|
|
1456
1456
|
const C = document.createElement("span");
|
|
@@ -1460,36 +1460,36 @@ function fo(t, e, n, o) {
|
|
|
1460
1460
|
}
|
|
1461
1461
|
return a.appendChild(l), a;
|
|
1462
1462
|
}
|
|
1463
|
-
function Ae(
|
|
1464
|
-
const
|
|
1465
|
-
|
|
1463
|
+
function Ae(e) {
|
|
1464
|
+
const t = document.createElement("article");
|
|
1465
|
+
t.className = "pluno-pa-widget__tool-group pluno-pa-widget__assistant-marker";
|
|
1466
1466
|
const n = document.createElement("img");
|
|
1467
|
-
return n.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", n.src =
|
|
1467
|
+
return n.className = "pluno-pa-widget__character pluno-pa-widget__character--tool-group", n.src = e, n.alt = "", n.setAttribute("aria-hidden", "true"), t.appendChild(n), t;
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1470
|
-
const
|
|
1471
|
-
return
|
|
1469
|
+
function xo(e) {
|
|
1470
|
+
const t = Ae(e);
|
|
1471
|
+
return t.classList.add("pluno-pa-widget__thinking-marker"), t.appendChild(Lt()), t;
|
|
1472
1472
|
}
|
|
1473
|
-
function
|
|
1474
|
-
const
|
|
1475
|
-
|
|
1476
|
-
const
|
|
1477
|
-
|
|
1473
|
+
function Lt() {
|
|
1474
|
+
const e = document.createElement("div");
|
|
1475
|
+
e.className = "pluno-pa-widget__status";
|
|
1476
|
+
const t = document.createElement("span");
|
|
1477
|
+
t.className = "pluno-pa-widget__thinking-dot", t.setAttribute("aria-hidden", "true"), e.appendChild(t);
|
|
1478
1478
|
const n = document.createElement("span");
|
|
1479
|
-
return n.textContent = "Thinking...",
|
|
1479
|
+
return n.textContent = "Thinking...", e.appendChild(n), e;
|
|
1480
1480
|
}
|
|
1481
|
-
function
|
|
1482
|
-
return `tools:${
|
|
1481
|
+
function yo(e) {
|
|
1482
|
+
return `tools:${e.map((t) => t.id).join("|")}`;
|
|
1483
1483
|
}
|
|
1484
1484
|
function Ne() {
|
|
1485
|
-
const
|
|
1486
|
-
return
|
|
1485
|
+
const e = document.createElement("span");
|
|
1486
|
+
return e.className = "pluno-pa-widget__spinner", e.setAttribute("aria-hidden", "true"), e;
|
|
1487
1487
|
}
|
|
1488
|
-
function
|
|
1489
|
-
|
|
1488
|
+
function Pt(e, t) {
|
|
1489
|
+
e.setAttribute("aria-label", t ? "Stop" : "Send"), e.classList.toggle("pluno-pa-widget__send--stop", t), e.replaceChildren(t ? Wn() : Ct());
|
|
1490
1490
|
}
|
|
1491
|
-
function it(
|
|
1492
|
-
const n =
|
|
1491
|
+
function it(e, t) {
|
|
1492
|
+
const n = t.replace(/\r\n/g, `
|
|
1493
1493
|
`).split(`
|
|
1494
1494
|
`);
|
|
1495
1495
|
let o = 0;
|
|
@@ -1506,13 +1506,13 @@ function it(t, e) {
|
|
|
1506
1506
|
o += o < n.length ? 1 : 0;
|
|
1507
1507
|
const u = document.createElement("pre"), b = document.createElement("code");
|
|
1508
1508
|
b.textContent = g.join(`
|
|
1509
|
-
`), u.appendChild(b),
|
|
1509
|
+
`), u.appendChild(b), e.appendChild(u);
|
|
1510
1510
|
continue;
|
|
1511
1511
|
}
|
|
1512
1512
|
const l = a.match(/^(#{1,3})\s+(.+)$/);
|
|
1513
1513
|
if (l) {
|
|
1514
1514
|
const g = document.createElement(`h${l[1].length + 2}`);
|
|
1515
|
-
pe(g, l[2]),
|
|
1515
|
+
pe(g, l[2]), e.appendChild(g), o += 1;
|
|
1516
1516
|
continue;
|
|
1517
1517
|
}
|
|
1518
1518
|
if (/^\s*[-*+]\s+/.test(a)) {
|
|
@@ -1521,7 +1521,7 @@ function it(t, e) {
|
|
|
1521
1521
|
const u = document.createElement("li");
|
|
1522
1522
|
pe(u, n[o].replace(/^\s*[-*+]\s+/, "")), g.appendChild(u), o += 1;
|
|
1523
1523
|
}
|
|
1524
|
-
|
|
1524
|
+
e.appendChild(g);
|
|
1525
1525
|
continue;
|
|
1526
1526
|
}
|
|
1527
1527
|
if (/^\s*\d+\.\s+/.test(a)) {
|
|
@@ -1530,7 +1530,7 @@ function it(t, e) {
|
|
|
1530
1530
|
const u = document.createElement("li");
|
|
1531
1531
|
pe(u, n[o].replace(/^\s*\d+\.\s+/, "")), g.appendChild(u), o += 1;
|
|
1532
1532
|
}
|
|
1533
|
-
|
|
1533
|
+
e.appendChild(g);
|
|
1534
1534
|
continue;
|
|
1535
1535
|
}
|
|
1536
1536
|
const p = [a];
|
|
@@ -1539,52 +1539,51 @@ function it(t, e) {
|
|
|
1539
1539
|
const s = document.createElement("p");
|
|
1540
1540
|
p.forEach((g, u) => {
|
|
1541
1541
|
u > 0 && s.appendChild(document.createElement("br")), pe(s, g);
|
|
1542
|
-
}),
|
|
1542
|
+
}), e.appendChild(s);
|
|
1543
1543
|
}
|
|
1544
1544
|
}
|
|
1545
|
-
function pe(
|
|
1545
|
+
function pe(e, t) {
|
|
1546
1546
|
const n = /(`[^`]+`|\*\*[^*]+\*\*|\*[^*]+\*|\[[^\]]+\]\(([^)\s]+)\))/g;
|
|
1547
1547
|
let o = 0;
|
|
1548
|
-
for (const a of
|
|
1548
|
+
for (const a of t.matchAll(n)) {
|
|
1549
1549
|
const i = a.index ?? 0;
|
|
1550
|
-
i > o &&
|
|
1550
|
+
i > o && e.appendChild(document.createTextNode(t.slice(o, i)));
|
|
1551
1551
|
const l = a[0];
|
|
1552
1552
|
if (l.startsWith("`")) {
|
|
1553
1553
|
const p = document.createElement("code");
|
|
1554
|
-
p.textContent = l.slice(1, -1),
|
|
1554
|
+
p.textContent = l.slice(1, -1), e.appendChild(p);
|
|
1555
1555
|
} else if (l.startsWith("**")) {
|
|
1556
1556
|
const p = document.createElement("strong");
|
|
1557
|
-
p.textContent = l.slice(2, -2),
|
|
1557
|
+
p.textContent = l.slice(2, -2), e.appendChild(p);
|
|
1558
1558
|
} else if (l.startsWith("*")) {
|
|
1559
1559
|
const p = document.createElement("em");
|
|
1560
|
-
p.textContent = l.slice(1, -1),
|
|
1560
|
+
p.textContent = l.slice(1, -1), e.appendChild(p);
|
|
1561
1561
|
} else {
|
|
1562
1562
|
const p = l.match(/^\[([^\]]+)\]\(([^)\s]+)\)$/);
|
|
1563
|
-
if (p &&
|
|
1563
|
+
if (p && vo(p[2])) {
|
|
1564
1564
|
const s = document.createElement("a");
|
|
1565
|
-
s.href = p[2], s.target = "_top", s.rel = "noreferrer", s.textContent = p[1],
|
|
1565
|
+
s.href = p[2], s.target = "_top", s.rel = "noreferrer", s.textContent = p[1], e.appendChild(s);
|
|
1566
1566
|
} else
|
|
1567
|
-
|
|
1567
|
+
e.appendChild(document.createTextNode(l));
|
|
1568
1568
|
}
|
|
1569
1569
|
o = i + l.length;
|
|
1570
1570
|
}
|
|
1571
|
-
o <
|
|
1571
|
+
o < t.length && e.appendChild(document.createTextNode(t.slice(o)));
|
|
1572
1572
|
}
|
|
1573
|
-
function
|
|
1574
|
-
if (
|
|
1573
|
+
function vo(e) {
|
|
1574
|
+
if (e.startsWith("/") || e.startsWith("#"))
|
|
1575
1575
|
return !0;
|
|
1576
1576
|
try {
|
|
1577
|
-
const
|
|
1578
|
-
return ["http:", "https:", "mailto:"].includes(
|
|
1577
|
+
const t = new URL(e);
|
|
1578
|
+
return ["http:", "https:", "mailto:"].includes(t.protocol);
|
|
1579
1579
|
} catch {
|
|
1580
1580
|
return !1;
|
|
1581
1581
|
}
|
|
1582
1582
|
}
|
|
1583
|
-
function rt(
|
|
1584
|
-
if (
|
|
1583
|
+
function rt(e, t) {
|
|
1584
|
+
if (Co(e))
|
|
1585
1585
|
return;
|
|
1586
|
-
const n =
|
|
1587
|
-
n.id = "pluno-pa-widget-styles", n.textContent = `
|
|
1586
|
+
const n = `
|
|
1588
1587
|
:host {
|
|
1589
1588
|
all: initial;
|
|
1590
1589
|
color-scheme: light;
|
|
@@ -1616,7 +1615,7 @@ function rt(t, e) {
|
|
|
1616
1615
|
flex: 0 0 auto;
|
|
1617
1616
|
}
|
|
1618
1617
|
.pluno-pa-widget {
|
|
1619
|
-
--pluno-pa-accent: ${
|
|
1618
|
+
--pluno-pa-accent: ${t};
|
|
1620
1619
|
--pluno-pa-bg: #fafaf9;
|
|
1621
1620
|
--pluno-pa-surface: #f4f4f2;
|
|
1622
1621
|
--pluno-pa-bubble: #eeeded;
|
|
@@ -1635,7 +1634,7 @@ function rt(t, e) {
|
|
|
1635
1634
|
--pluno-pa-accent-contrast: #fafafa;
|
|
1636
1635
|
position: fixed;
|
|
1637
1636
|
z-index: 2147483645;
|
|
1638
|
-
font-family: ${
|
|
1637
|
+
font-family: ${R.fontFamily};
|
|
1639
1638
|
font-size: 14px;
|
|
1640
1639
|
color: var(--pluno-pa-text);
|
|
1641
1640
|
width: var(--pluno-pa-launcher-width);
|
|
@@ -2337,7 +2336,7 @@ function rt(t, e) {
|
|
|
2337
2336
|
place-items: center;
|
|
2338
2337
|
padding: 18px;
|
|
2339
2338
|
background: rgba(24, 24, 27, 0.28);
|
|
2340
|
-
font-family: var(--pluno-pa-font, ${
|
|
2339
|
+
font-family: var(--pluno-pa-font, ${R.fontFamily});
|
|
2341
2340
|
color: var(--pluno-pa-text);
|
|
2342
2341
|
}
|
|
2343
2342
|
.pluno-pa-widget__share-dialog {
|
|
@@ -3232,30 +3231,50 @@ function rt(t, e) {
|
|
|
3232
3231
|
.pluno-pa-widget--scribble .pluno-pa-widget__close svg {
|
|
3233
3232
|
filter: url(#pluno-pa-scribble-wobble-2);
|
|
3234
3233
|
}
|
|
3235
|
-
|
|
3234
|
+
`;
|
|
3235
|
+
if (Eo(e, n))
|
|
3236
|
+
return;
|
|
3237
|
+
const o = e.ownerDocument.createElement("style");
|
|
3238
|
+
o.id = bt, o.textContent = n, e.appendChild(o), At(e);
|
|
3239
|
+
}
|
|
3240
|
+
function Co(e) {
|
|
3241
|
+
return e.getElementById(bt) !== null || e.host instanceof HTMLElement && e.host.getAttribute(wt) === "true";
|
|
3236
3242
|
}
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3243
|
+
function At(e) {
|
|
3244
|
+
e.host instanceof HTMLElement && e.host.setAttribute(wt, "true");
|
|
3245
|
+
}
|
|
3246
|
+
function Eo(e, t) {
|
|
3247
|
+
if (typeof CSSStyleSheet > "u" || typeof CSSStyleSheet.prototype.replaceSync != "function" || !("adoptedStyleSheets" in e))
|
|
3248
|
+
return !1;
|
|
3249
|
+
try {
|
|
3250
|
+
const n = new CSSStyleSheet();
|
|
3251
|
+
return n.replaceSync(t), e.adoptedStyleSheets = [...e.adoptedStyleSheets, n], At(e), !0;
|
|
3252
|
+
} catch {
|
|
3253
|
+
return !1;
|
|
3254
|
+
}
|
|
3255
|
+
}
|
|
3256
|
+
async function ko() {
|
|
3257
|
+
return document.body ? document.body : await new Promise((e) => {
|
|
3258
|
+
const t = new MutationObserver(() => {
|
|
3259
|
+
document.body && (t.disconnect(), e(document.body));
|
|
3241
3260
|
});
|
|
3242
|
-
|
|
3261
|
+
t.observe(document.documentElement, { childList: !0 });
|
|
3243
3262
|
});
|
|
3244
3263
|
}
|
|
3245
|
-
function
|
|
3246
|
-
return `pluno.productAgent.widgetState.${location.origin}.${
|
|
3264
|
+
function Nt(e) {
|
|
3265
|
+
return `pluno.productAgent.widgetState.${location.origin}.${e.backendUrl ?? ""}.${e.tokenEndpoint ?? ""}.${e.position ?? ""}`;
|
|
3247
3266
|
}
|
|
3248
|
-
function
|
|
3267
|
+
function So(e) {
|
|
3249
3268
|
try {
|
|
3250
|
-
const
|
|
3251
|
-
if (!
|
|
3269
|
+
const t = window.localStorage.getItem(Nt(e));
|
|
3270
|
+
if (!t)
|
|
3252
3271
|
return lt();
|
|
3253
|
-
const n = JSON.parse(
|
|
3272
|
+
const n = JSON.parse(t);
|
|
3254
3273
|
return {
|
|
3255
3274
|
isOpen: n.isOpen === !0,
|
|
3256
3275
|
composerValue: typeof n.composerValue == "string" ? n.composerValue : "",
|
|
3257
3276
|
openToolGroupKeys: Array.isArray(n.openToolGroupKeys) ? n.openToolGroupKeys.filter((o) => typeof o == "string") : [],
|
|
3258
|
-
launcherPosition:
|
|
3277
|
+
launcherPosition: No(n.launcherPosition) ? n.launcherPosition : null,
|
|
3259
3278
|
seenShareCandidateIds: Array.isArray(n.seenShareCandidateIds) ? n.seenShareCandidateIds.filter((o) => typeof o == "string").slice(-gt) : [],
|
|
3260
3279
|
sharePromptsDisabled: n.sharePromptsDisabled === !0
|
|
3261
3280
|
};
|
|
@@ -3263,23 +3282,23 @@ function vo(t) {
|
|
|
3263
3282
|
return lt();
|
|
3264
3283
|
}
|
|
3265
3284
|
}
|
|
3266
|
-
async function
|
|
3267
|
-
if (
|
|
3268
|
-
return
|
|
3285
|
+
async function Lo(e) {
|
|
3286
|
+
if (e.loadSharePromptsDisabled)
|
|
3287
|
+
return e.loadSharePromptsDisabled();
|
|
3269
3288
|
try {
|
|
3270
3289
|
return window.localStorage.getItem(ht) === "true";
|
|
3271
3290
|
} catch {
|
|
3272
3291
|
return !1;
|
|
3273
3292
|
}
|
|
3274
3293
|
}
|
|
3275
|
-
function
|
|
3276
|
-
if (
|
|
3277
|
-
Promise.resolve(
|
|
3294
|
+
function Po(e, t) {
|
|
3295
|
+
if (e.persistSharePromptsDisabled) {
|
|
3296
|
+
Promise.resolve(e.persistSharePromptsDisabled(t)).catch(() => {
|
|
3278
3297
|
});
|
|
3279
3298
|
return;
|
|
3280
3299
|
}
|
|
3281
3300
|
try {
|
|
3282
|
-
|
|
3301
|
+
t && window.localStorage.setItem(ht, "true");
|
|
3283
3302
|
} catch {
|
|
3284
3303
|
return;
|
|
3285
3304
|
}
|
|
@@ -3294,41 +3313,41 @@ function lt() {
|
|
|
3294
3313
|
sharePromptsDisabled: !1
|
|
3295
3314
|
};
|
|
3296
3315
|
}
|
|
3297
|
-
function
|
|
3316
|
+
function Ao(e, t) {
|
|
3298
3317
|
try {
|
|
3299
|
-
window.localStorage.setItem(
|
|
3318
|
+
window.localStorage.setItem(Nt(e), JSON.stringify(t));
|
|
3300
3319
|
} catch {
|
|
3301
3320
|
return;
|
|
3302
3321
|
}
|
|
3303
3322
|
}
|
|
3304
|
-
function
|
|
3305
|
-
if (!
|
|
3323
|
+
function No(e) {
|
|
3324
|
+
if (!e || typeof e != "object")
|
|
3306
3325
|
return !1;
|
|
3307
|
-
const
|
|
3308
|
-
return Number.isFinite(
|
|
3326
|
+
const t = e;
|
|
3327
|
+
return Number.isFinite(t.x) && Number.isFinite(t.y);
|
|
3309
3328
|
}
|
|
3310
3329
|
const pt = /* @__PURE__ */ new WeakSet();
|
|
3311
|
-
function
|
|
3312
|
-
return Object.keys(
|
|
3330
|
+
function To(e) {
|
|
3331
|
+
return Object.keys(e.dataset).some((t) => t.startsWith("pluno"));
|
|
3313
3332
|
}
|
|
3314
|
-
function st(
|
|
3315
|
-
const
|
|
3316
|
-
return
|
|
3333
|
+
function st(e) {
|
|
3334
|
+
const t = e.pathname.split("/");
|
|
3335
|
+
return t[t.length - 1] ?? "";
|
|
3317
3336
|
}
|
|
3318
|
-
function
|
|
3319
|
-
const n = new URL(
|
|
3320
|
-
return n.href ===
|
|
3337
|
+
function Do(e, t) {
|
|
3338
|
+
const n = new URL(e.src, document.baseURI);
|
|
3339
|
+
return n.href === t.href || n.pathname === t.pathname ? !0 : st(n) === st(t);
|
|
3321
3340
|
}
|
|
3322
3341
|
class O extends EventTarget {
|
|
3323
|
-
constructor(
|
|
3324
|
-
super(), this.channelId = n, this.url =
|
|
3342
|
+
constructor(t, n) {
|
|
3343
|
+
super(), this.channelId = n, this.url = t, this.addPreviewListener(nn, () => {
|
|
3325
3344
|
this.readyState = O.OPEN, this.dispatchEvent(new Event("open"));
|
|
3326
|
-
}), this.addPreviewListener(
|
|
3345
|
+
}), this.addPreviewListener(on, (o) => {
|
|
3327
3346
|
const a = o;
|
|
3328
3347
|
this.dispatchEvent(new MessageEvent("message", { data: a.detail?.data ?? "" }));
|
|
3329
|
-
}), this.addPreviewListener(
|
|
3348
|
+
}), this.addPreviewListener(an, () => {
|
|
3330
3349
|
this.readyState = O.CLOSED, this.dispatchEvent(new Event("error")), this.cleanup();
|
|
3331
|
-
}), this.addPreviewListener(
|
|
3350
|
+
}), this.addPreviewListener(rn, (o) => {
|
|
3332
3351
|
const a = o;
|
|
3333
3352
|
this.readyState = O.CLOSED, this.dispatchEvent(
|
|
3334
3353
|
new CloseEvent("close", {
|
|
@@ -3338,8 +3357,8 @@ class O extends EventTarget {
|
|
|
3338
3357
|
})
|
|
3339
3358
|
), this.cleanup();
|
|
3340
3359
|
}), window.dispatchEvent(
|
|
3341
|
-
new CustomEvent(se(
|
|
3342
|
-
detail: { socketId: this.socketId, url:
|
|
3360
|
+
new CustomEvent(se(Qt, this.channelId), {
|
|
3361
|
+
detail: { socketId: this.socketId, url: t }
|
|
3343
3362
|
})
|
|
3344
3363
|
);
|
|
3345
3364
|
}
|
|
@@ -3354,79 +3373,79 @@ class O extends EventTarget {
|
|
|
3354
3373
|
binaryType = "blob";
|
|
3355
3374
|
bufferedAmount = 0;
|
|
3356
3375
|
readyState = O.CONNECTING;
|
|
3357
|
-
socketId =
|
|
3376
|
+
socketId = Io();
|
|
3358
3377
|
listeners = /* @__PURE__ */ new Map();
|
|
3359
|
-
send(
|
|
3378
|
+
send(t) {
|
|
3360
3379
|
if (this.readyState !== O.OPEN)
|
|
3361
3380
|
throw new DOMException("Pluno preview websocket is not open", "InvalidStateError");
|
|
3362
3381
|
window.dispatchEvent(
|
|
3363
|
-
new CustomEvent(se(
|
|
3364
|
-
detail: { socketId: this.socketId, data: typeof
|
|
3382
|
+
new CustomEvent(se(en, this.channelId), {
|
|
3383
|
+
detail: { socketId: this.socketId, data: typeof t == "string" ? t : String(t) }
|
|
3365
3384
|
})
|
|
3366
3385
|
);
|
|
3367
3386
|
}
|
|
3368
|
-
close(
|
|
3387
|
+
close(t, n) {
|
|
3369
3388
|
this.readyState !== O.CLOSED && (this.readyState = O.CLOSING, window.dispatchEvent(
|
|
3370
|
-
new CustomEvent(se(
|
|
3371
|
-
detail: { socketId: this.socketId, code:
|
|
3389
|
+
new CustomEvent(se(tn, this.channelId), {
|
|
3390
|
+
detail: { socketId: this.socketId, code: t, reason: n }
|
|
3372
3391
|
})
|
|
3373
3392
|
), this.cleanup());
|
|
3374
3393
|
}
|
|
3375
|
-
addPreviewListener(
|
|
3376
|
-
const o = se(
|
|
3394
|
+
addPreviewListener(t, n) {
|
|
3395
|
+
const o = se(t, this.channelId), a = (i) => {
|
|
3377
3396
|
i.detail?.socketId === this.socketId && n(i);
|
|
3378
3397
|
};
|
|
3379
3398
|
this.listeners.set(o, a), window.addEventListener(o, a);
|
|
3380
3399
|
}
|
|
3381
3400
|
cleanup() {
|
|
3382
|
-
for (const [
|
|
3383
|
-
window.removeEventListener(
|
|
3401
|
+
for (const [t, n] of this.listeners.entries())
|
|
3402
|
+
window.removeEventListener(t, n);
|
|
3384
3403
|
this.listeners.clear();
|
|
3385
3404
|
}
|
|
3386
3405
|
}
|
|
3387
|
-
function
|
|
3388
|
-
const
|
|
3389
|
-
if (
|
|
3390
|
-
return
|
|
3391
|
-
const
|
|
3392
|
-
return window.sessionStorage.setItem(qe,
|
|
3406
|
+
function Io() {
|
|
3407
|
+
const e = window.sessionStorage.getItem(qe);
|
|
3408
|
+
if (e)
|
|
3409
|
+
return e;
|
|
3410
|
+
const t = crypto.randomUUID();
|
|
3411
|
+
return window.sessionStorage.setItem(qe, t), t;
|
|
3393
3412
|
}
|
|
3394
|
-
function se(
|
|
3395
|
-
return `${
|
|
3413
|
+
function se(e, t) {
|
|
3414
|
+
return `${e}:${t}`;
|
|
3396
3415
|
}
|
|
3397
|
-
function
|
|
3398
|
-
const
|
|
3399
|
-
if (
|
|
3400
|
-
return [
|
|
3401
|
-
const n = new URL(
|
|
3416
|
+
function Mo(e) {
|
|
3417
|
+
const t = document.currentScript;
|
|
3418
|
+
if (t instanceof HTMLScriptElement)
|
|
3419
|
+
return [t];
|
|
3420
|
+
const n = new URL(e, document.baseURI).href, o = new URL(n);
|
|
3402
3421
|
return Array.from(document.querySelectorAll("script[type='module'][src]")).filter(
|
|
3403
|
-
(a) => a instanceof HTMLScriptElement &&
|
|
3422
|
+
(a) => a instanceof HTMLScriptElement && To(a) && Do(a, o)
|
|
3404
3423
|
);
|
|
3405
3424
|
}
|
|
3406
|
-
function
|
|
3407
|
-
for (const
|
|
3408
|
-
if (pt.has(
|
|
3425
|
+
function Ro(e) {
|
|
3426
|
+
for (const t of Mo(e)) {
|
|
3427
|
+
if (pt.has(t) || t.dataset.plunoAutoMount === "false")
|
|
3409
3428
|
continue;
|
|
3410
|
-
pt.add(
|
|
3411
|
-
const n =
|
|
3412
|
-
|
|
3413
|
-
token:
|
|
3414
|
-
tokenEndpoint:
|
|
3415
|
-
backendUrl:
|
|
3416
|
-
webSocketFactory: n ?
|
|
3417
|
-
launcherLabel:
|
|
3418
|
-
accentColor:
|
|
3419
|
-
colorScheme:
|
|
3420
|
-
fontFamily:
|
|
3421
|
-
scribbleStyle:
|
|
3422
|
-
position:
|
|
3429
|
+
pt.add(t);
|
|
3430
|
+
const n = t.dataset.plunoPreviewChannel;
|
|
3431
|
+
Sn({
|
|
3432
|
+
token: t.dataset.plunoToken,
|
|
3433
|
+
tokenEndpoint: t.dataset.plunoTokenEndpoint,
|
|
3434
|
+
backendUrl: t.dataset.plunoBackendUrl,
|
|
3435
|
+
webSocketFactory: n ? kn(n) : void 0,
|
|
3436
|
+
launcherLabel: t.dataset.plunoLauncherLabel,
|
|
3437
|
+
accentColor: t.dataset.plunoAccentColor,
|
|
3438
|
+
colorScheme: t.dataset.plunoColorScheme === "dark" ? "dark" : "light",
|
|
3439
|
+
fontFamily: t.dataset.plunoFontFamily,
|
|
3440
|
+
scribbleStyle: t.dataset.plunoScribbleStyle === "true",
|
|
3441
|
+
position: t.dataset.plunoPosition === "bottom-left" ? "bottom-left" : "bottom-right"
|
|
3423
3442
|
}).catch((o) => {
|
|
3424
3443
|
console.error("Failed to mount Pluno widget", o);
|
|
3425
3444
|
});
|
|
3426
3445
|
}
|
|
3427
3446
|
}
|
|
3428
|
-
|
|
3447
|
+
Ro(import.meta.url);
|
|
3429
3448
|
export {
|
|
3430
|
-
|
|
3431
|
-
|
|
3449
|
+
kn as createProductAgentPreviewBridgeWebSocketFactory,
|
|
3450
|
+
Sn as mountPlunoProductAgentWidget
|
|
3432
3451
|
};
|