@pluno/product-agent-web 0.1.253 → 0.1.254

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.
@@ -275,6 +275,9 @@ const _p = [
275
275
  "stopping_painted",
276
276
  "progress_painted",
277
277
  "stopped_painted",
278
+ "warmup_checkpoint",
279
+ "warmup_http",
280
+ "warmup_wait",
278
281
  "acceptance_received",
279
282
  "acceptance_applied"
280
283
  ], id = [
@@ -305,7 +308,7 @@ function Zr(t) {
305
308
  const e = t;
306
309
  return Object.keys(e).every((n) => ["entrySurface", "operation", "layer", "stage", "status", "spanId", "requestId", "clientMessageId", "sessionId", "occurredAt", "durationMs", "failureCategory"].includes(n)) && (e.failureCategory === void 0 || e.status === "failed" && id.includes(e.failureCategory)) && (e.entrySurface === void 0 || ["extension_sidepanel", "extension_widget", "main_web_chat", "embedded_widget", "embedded_custom_ui", "automation", "mcp", "whatsapp", "email"].includes(e.entrySurface)) && ["send", "stop"].includes(e.operation) && ["renderer", "sdk", "extension", "http"].includes(e.layer) && _p.includes(e.stage) && ["started", "completed", "failed", "observed"].includes(e.status) && rs(e.spanId) && rs(e.requestId) && (e.clientMessageId === null || rs(e.clientMessageId)) && (e.sessionId === null || rs(e.sessionId)) && typeof e.occurredAt == "string" && e.occurredAt.length <= 40 && Number.isFinite(Date.parse(e.occurredAt)) && Number.isSafeInteger(e.durationMs) && e.durationMs >= 0;
307
310
  }
308
- function Rt(t, e) {
311
+ function St(t, e) {
309
312
  if (!t) return {
310
313
  mark: (s) => {
311
314
  },
@@ -352,7 +355,7 @@ function xp(t) {
352
355
  function kp(t, e, n, i) {
353
356
  if (t !== e)
354
357
  for (const s of Object.values(e.submissions))
355
- s.delivery !== "accepted" || t.submissions[s.userMessageId]?.delivery === "accepted" || Rt(n, {
358
+ s.delivery !== "accepted" || t.submissions[s.userMessageId]?.delivery === "accepted" || St(n, {
356
359
  operation: "send",
357
360
  layer: i,
358
361
  entrySurface: s.entrySurface,
@@ -438,7 +441,7 @@ function ea(t) {
438
441
  e ^= t.charCodeAt(n), e = Math.imul(e, 16777619);
439
442
  return `fnv1a-${(e >>> 0).toString(16).padStart(8, "0")}`;
440
443
  }
441
- const Bs = "0.1.253", od = {
444
+ const Bs = "0.1.254", od = {
442
445
  version: Bs
443
446
  };
444
447
  function Tp(t, e, n, i, s = {}) {
@@ -777,23 +780,23 @@ function zp(t, e, n, i) {
777
780
  else {
778
781
  const m = lt(e.output.snapshot);
779
782
  r.lane === "current" && (c = { ...c, preparation: null });
780
- const f = c.queries.history, w = r.lane === "current" && (f.status === "not_requested" || m.next_cursor !== null && !c.items[m.next_cursor]);
783
+ const f = c.queries.history, b = r.lane === "current" && (f.status === "not_requested" || m.next_cursor !== null && !c.items[m.next_cursor]);
781
784
  if (m.conversation_id !== r.sessionId) throw new Error("Snapshot belongs to another conversation.");
782
- for (const b of m.removed_items) c = No(c, b);
783
- for (const b of m.items) c = vr(c, b);
784
- for (const b of m.streams) c = ld(c, b);
785
+ for (const w of m.removed_items) c = No(c, w);
786
+ for (const w of m.items) c = vr(c, w);
787
+ for (const w of m.streams) c = ld(c, w);
785
788
  if (c = Ir(c, m.execution), c = No(c, {
786
789
  type: "conversation.follow_ups.updated",
787
790
  conversation_id: m.conversation_id,
788
791
  version: m.follow_ups_version,
789
792
  follow_ups: m.follow_ups
790
- }), m.interactions.some((b) => b.conversation_id !== m.conversation_id)) throw new Error("Interaction belongs to another conversation.");
793
+ }), m.interactions.some((w) => w.conversation_id !== m.conversation_id)) throw new Error("Interaction belongs to another conversation.");
791
794
  if (a = { authorityId: t.authorityId, generation: t.generation, sessionId: r.sessionId, sources: m.interactions }, m.execution.version === c.execution?.version)
792
- for (const b of r.acceptedUserMessageIds) {
793
- const _ = g[b];
795
+ for (const w of r.acceptedUserMessageIds) {
796
+ const _ = g[w];
794
797
  _.executionVersion === null && (g = {
795
798
  ...g,
796
- [b]: { ..._, executionVersion: m.execution.version }
799
+ [w]: { ..._, executionVersion: m.execution.version }
797
800
  });
798
801
  }
799
802
  if (c = { ...c, queries: { ...c.queries, [r.lane]: {
@@ -804,9 +807,9 @@ function zp(t, e, n, i) {
804
807
  data: Object.keys(c.items),
805
808
  cursor: m.next_cursor,
806
809
  updatedAt: e.output.updatedAt
807
- } } }, w) {
808
- for (const [b, _] of Object.entries(h))
809
- _.sessionId === r.sessionId && _.lane === "history" && delete h[b];
810
+ } } }, b) {
811
+ for (const [w, _] of Object.entries(h))
812
+ _.sessionId === r.sessionId && _.lane === "history" && delete h[w];
810
813
  c = { ...c, queries: { ...c.queries, history: { ...c.queries.current, key: f.key } } };
811
814
  }
812
815
  }
@@ -837,11 +840,11 @@ function zp(t, e, n, i) {
837
840
  if (n.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
838
841
  const { type: r, authorityId: c, generation: l, prepareContext: p, ...d } = e, h = t.submissions[e.userMessageId];
839
842
  if (h) {
840
- const { contextPreparation: _, requestedModel: v, sessionId: E, delivery: L, cancelled: K, cancellationReason: U, error: he, executionVersion: G, ...oe } = h;
843
+ const { contextPreparation: _, requestedModel: v, sessionId: k, delivery: L, cancelled: K, cancellationReason: U, error: he, executionVersion: G, ...oe } = h;
841
844
  if (as(oe) !== as(d)) throw new Error("User-message identity cannot be reused with different input.");
842
845
  return { state: t, effects: o };
843
846
  }
844
- const g = n.selections[e.conversationScopeId], m = Object.values(t.submissions).find((_) => _.conversationScopeId === e.conversationScopeId && !_.cancelled && _.sessionId !== null), f = i.scopes[e.clientScopeId], w = {
847
+ const g = n.selections[e.conversationScopeId], m = Object.values(t.submissions).find((_) => _.conversationScopeId === e.conversationScopeId && !_.cancelled && _.sessionId !== null), f = i.scopes[e.clientScopeId], b = {
845
848
  ...lt(d),
846
849
  ...p ? { contextPreparation: null } : {},
847
850
  // Extension staging can await page context after the picker has already changed.
@@ -851,8 +854,8 @@ function zp(t, e, n, i) {
851
854
  cancelled: !1,
852
855
  error: null,
853
856
  executionVersion: null
854
- }, b = { ...t.proactiveQuestions };
855
- delete b[e.conversationScopeId], s = { ...t, proactiveQuestions: b, submissions: { ...t.submissions, [e.userMessageId]: w }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
857
+ }, w = { ...t.proactiveQuestions };
858
+ delete w[e.conversationScopeId], s = { ...t, proactiveQuestions: w, submissions: { ...t.submissions, [e.userMessageId]: b }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
856
859
  break;
857
860
  }
858
861
  case "conversation.submission_accepted": {
@@ -1128,8 +1131,8 @@ function $p(t, e, n, i) {
1128
1131
  const h = t.deliveries[p], g = t.submissions[p];
1129
1132
  let m = { ...h, phase: "waiting", effectId: null };
1130
1133
  if (e.type === "effect.failed") {
1131
- const f = e.error.details?.acceptance === "unissued" && h.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : h.acceptance, w = e.error.details?.allocation === "unissued" ? "unissued" : h.allocation, b = e.effectKind === "conversation.command" && h.step === "send" && f === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", _ = e.effectKind === "conversation.prepare" || b ? "failed" : f === "uncertain" || w === "uncertain" || e.error.retryable ? "uncertain" : "failed";
1132
- m = { ...m, phase: _, acceptance: f, allocation: w }, !g.cancelled && g.delivery !== "accepted" && (s = { ...s, submissions: {
1134
+ const f = e.error.details?.acceptance === "unissued" && h.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : h.acceptance, b = e.error.details?.allocation === "unissued" ? "unissued" : h.allocation, w = e.effectKind === "conversation.command" && h.step === "send" && f === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", _ = e.effectKind === "conversation.prepare" || w ? "failed" : f === "uncertain" || b === "uncertain" || e.error.retryable ? "uncertain" : "failed";
1135
+ m = { ...m, phase: _, acceptance: f, allocation: b }, !g.cancelled && g.delivery !== "accepted" && (s = { ...s, submissions: {
1133
1136
  ...s.submissions,
1134
1137
  [p]: { ...g, delivery: _, error: e.error }
1135
1138
  } });
@@ -1143,15 +1146,15 @@ function $p(t, e, n, i) {
1143
1146
  error: { code: "message_delivery_failed", message: "Pluno could not send this message. Try it again.", retryable: !0 }
1144
1147
  } } }));
1145
1148
  else if (e.effectKind === "conversation.upload") {
1146
- const f = lt(e.output), w = g.attachments[h.uploads.length];
1147
- if (f.attachment.id !== w.sourceId || f.attachment.size_bytes !== w.sizeBytes || g.sessionId !== null && g.sessionId !== f.sessionId)
1149
+ const f = lt(e.output), b = g.attachments[h.uploads.length];
1150
+ if (f.attachment.id !== b.sourceId || f.attachment.size_bytes !== b.sizeBytes || g.sessionId !== null && g.sessionId !== f.sessionId)
1148
1151
  throw new Error("Upload does not match the captured attachment or conversation.");
1149
1152
  m = { ...m, allocation: "resolved", uploads: [...h.uploads, f.attachment] };
1150
- const b = Object.fromEntries(Object.entries(s.submissions).map(([_, v]) => [
1153
+ const w = Object.fromEntries(Object.entries(s.submissions).map(([_, v]) => [
1151
1154
  _,
1152
1155
  v.conversationScopeId === g.conversationScopeId && (_ === p || !v.cancelled && !g.cancelled) ? { ...v, sessionId: f.sessionId } : v
1153
1156
  ]));
1154
- s = { ...s, submissions: b };
1157
+ s = { ...s, submissions: w };
1155
1158
  } else if (e.effectKind === "conversation.receipt")
1156
1159
  if (e.output === null)
1157
1160
  m = { ...m, phase: g.cancelled ? "uncertain" : "paused" }, g.cancelled || (s = { ...s, submissions: { ...s.submissions, [p]: {
@@ -1211,40 +1214,40 @@ function $p(t, e, n, i) {
1211
1214
  const p = lt(e.checkpoint);
1212
1215
  if (p.schema !== 1 || p.authorityId !== t.authorityId || t.submissionOrder.length || Object.keys(t.operations).length)
1213
1216
  throw new Error("Delivery restoration requires an empty engine with the same authenticated authority.");
1214
- const { schema: d, authorityId: h, ...g } = p, m = lt(e.pendingRestoration ?? {}), f = (w) => !n.clients[w.clientScopeId] && m[w.clientScopeId] === w.conversationScopeId;
1217
+ const { schema: d, authorityId: h, ...g } = p, m = lt(e.pendingRestoration ?? {}), f = (b) => !n.clients[b.clientScopeId] && m[b.clientScopeId] === b.conversationScopeId;
1215
1218
  s = {
1216
1219
  ...t,
1217
1220
  ...g,
1218
1221
  pendingRestoration: m,
1219
1222
  requestSequence: Math.max(t.requestSequence, p.requestSequence),
1220
1223
  effectsEnabled: !0,
1221
- submissions: Object.fromEntries(Object.entries(p.submissions).map(([w, b]) => [w, {
1222
- ...b,
1224
+ submissions: Object.fromEntries(Object.entries(p.submissions).map(([b, w]) => [b, {
1225
+ ...w,
1223
1226
  executionVersion: null,
1224
- cancelled: b.cancelled || !f(b) && !xr(b, n),
1225
- ...!b.cancelled && !f(b) && !xr(b, n) ? { cancellationReason: "owner_lost" } : {},
1226
- delivery: (b.contextPreparation === null || !p.deliveries[w]) && !b.cancelled && b.delivery !== "accepted" ? "failed" : b.delivery === "sending" ? "uncertain" : b.delivery,
1227
- error: b.contextPreparation === null && !b.cancelled ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !p.deliveries[w] && b.delivery !== "accepted" && !b.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : b.error
1227
+ cancelled: w.cancelled || !f(w) && !xr(w, n),
1228
+ ...!w.cancelled && !f(w) && !xr(w, n) ? { cancellationReason: "owner_lost" } : {},
1229
+ delivery: (w.contextPreparation === null || !p.deliveries[b]) && !w.cancelled && w.delivery !== "accepted" ? "failed" : w.delivery === "sending" ? "uncertain" : w.delivery,
1230
+ error: w.contextPreparation === null && !w.cancelled ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !p.deliveries[b] && w.delivery !== "accepted" && !w.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : w.error
1228
1231
  }])),
1229
- deliveries: Object.fromEntries(Object.entries(p.submissions).map(([w, b], _) => {
1230
- const v = p.deliveries[w], E = b.contextPreparation === null, L = b.delivery === "accepted" ? "accepted" : v?.acceptance ?? (v && (v.step === "send" || v.step === "receipt") ? "uncertain" : "unissued");
1231
- return [w, {
1232
- ...Cc(b, _),
1232
+ deliveries: Object.fromEntries(Object.entries(p.submissions).map(([b, w], _) => {
1233
+ const v = p.deliveries[b], k = w.contextPreparation === null, L = w.delivery === "accepted" ? "accepted" : v?.acceptance ?? (v && (v.step === "send" || v.step === "receipt") ? "uncertain" : "unissued");
1234
+ return [b, {
1235
+ ...Cc(w, _),
1233
1236
  ...v,
1234
1237
  acceptance: L,
1235
- allocation: b.sessionId !== null ? "resolved" : v?.allocation ?? (v?.step === "upload" ? "uncertain" : "unissued"),
1238
+ allocation: w.sessionId !== null ? "resolved" : v?.allocation ?? (v?.step === "upload" ? "uncertain" : "unissued"),
1236
1239
  effectId: null,
1237
1240
  // Readiness is authority-local and must be re-established after restart. Captured input stays immutable.
1238
1241
  step: L === "uncertain" && v?.step === "send" && v.phase !== "done" ? "receipt" : v?.step ?? null,
1239
1242
  prepared: L === "accepted",
1240
1243
  queuePosition: v?.queuePosition ?? _,
1241
- phase: L === "accepted" ? "done" : E || !v ? "failed" : ["running", "waiting"].includes(v.phase) ? "uncertain" : v.phase
1244
+ phase: L === "accepted" ? "done" : k || !v ? "failed" : ["running", "waiting"].includes(v.phase) ? "uncertain" : v.phase
1242
1245
  }];
1243
1246
  })),
1244
- operations: Object.fromEntries(Object.entries(p.operations).map(([w, b]) => [w, {
1245
- ...b,
1247
+ operations: Object.fromEntries(Object.entries(p.operations).map(([b, w]) => [b, {
1248
+ ...w,
1246
1249
  effectId: null,
1247
- phase: ["running", "waiting"].includes(b.phase) ? "uncertain" : b.phase
1250
+ phase: ["running", "waiting"].includes(w.phase) ? "uncertain" : w.phase
1248
1251
  }]))
1249
1252
  };
1250
1253
  }
@@ -1309,7 +1312,7 @@ function $p(t, e, n, i) {
1309
1312
  if (!d) {
1310
1313
  const h = p.type === "chat.retry_last_user_message" ? Object.fromEntries(Object.entries(t.stops).flatMap(([g, m]) => {
1311
1314
  if (n.selections[g]?.sessionId !== p.payload.sessionId) return [[g, m]];
1312
- const f = m.userMessageIds.filter((w) => w !== p.payload.clientMessageId);
1315
+ const f = m.userMessageIds.filter((b) => b !== p.payload.clientMessageId);
1313
1316
  return f.length ? [[g, { ...m, userMessageIds: f }]] : [];
1314
1317
  })) : t.stops;
1315
1318
  s = { ...t, stops: h, effectsEnabled: !0, operations: {
@@ -1412,12 +1415,12 @@ class ms {
1412
1415
  this.schedule(o, e);
1413
1416
  }
1414
1417
  }
1415
- function at(t) {
1418
+ function Ze(t) {
1416
1419
  const e = t.runtime(), n = e.engine.getState().slices.directory;
1417
1420
  return !e.isDisposed && (t.isCurrent?.() ?? !0) && n.authorityId === t.authority.authorityId && n.generation === t.authority.generation;
1418
1421
  }
1419
1422
  function Ye(t, e) {
1420
- if (!at(t) || e.authorityId !== t.authority.authorityId || e.generation !== t.authority.generation)
1423
+ if (!Ze(t) || e.authorityId !== t.authority.authorityId || e.generation !== t.authority.generation)
1421
1424
  throw Object.assign(new Error("Conversation authority was retired."), { code: "authority_retired", retryable: !0 });
1422
1425
  }
1423
1426
  function En(t, e) {
@@ -1440,221 +1443,246 @@ function En(t, e) {
1440
1443
  }
1441
1444
  function Fp(t) {
1442
1445
  let e = Promise.resolve();
1443
- const n = (a = dd(t.runtime().engine.getState().slices.conversation, t.runtime().engine.getState().slices.directory)) => {
1444
- const r = () => (Ye(t, t.authority), t.saveDelivery(a));
1445
- return e = e.then(r, r), e;
1446
- }, i = (a, r) => {
1447
- throw at(t) && !(a instanceof Error && "code" in a && ["executor_not_ready", "request_timed_out"].includes(String(a.code))) && t.onError?.(a, r), En(a, r);
1446
+ const n = (r = dd(t.runtime().engine.getState().slices.conversation, t.runtime().engine.getState().slices.directory)) => {
1447
+ const c = () => (Ye(t, t.authority), t.saveDelivery(r));
1448
+ return e = e.then(c, c), e;
1449
+ }, i = (r, c) => {
1450
+ throw Ze(t) && !(r instanceof Error && "code" in r && ["executor_not_ready", "request_timed_out"].includes(String(r.code))) && t.onError?.(r, c), En(r, c);
1448
1451
  }, s = () => {
1449
- const { token: a, protocol: r, ...c } = t.http.auth;
1450
- return { ...c, ...t.connectionId() ? { connection_id: t.connectionId() } : {} };
1451
- }, o = (a) => {
1452
- if (Ye(t, t.authority), t.runtime().engine.getState().slices.conversation.submissions[a]?.cancelled)
1452
+ const { token: r, protocol: c, ...l } = t.http.auth;
1453
+ return { ...l, ...t.connectionId() ? { connection_id: t.connectionId() } : {} };
1454
+ }, o = (r) => {
1455
+ if (Ye(t, t.authority), t.runtime().engine.getState().slices.conversation.submissions[r]?.cancelled)
1453
1456
  throw Object.assign(new Error("Submission was cancelled."), { code: "submission_cancelled", retryable: !1 });
1457
+ }, a = (r) => {
1458
+ if (!t.onTiming || r.submission.sessionId !== null) return;
1459
+ const c = t.runtime(), l = Object.values(c.engine.getState().slices.conversation.operations).find((g) => g.command.type === "runtime.warmup" && g.conversationScopeId === r.submission.conversationScopeId && ["waiting", "running", "uncertain"].includes(g.phase));
1460
+ if (!l) return;
1461
+ const p = St(t.onTiming, {
1462
+ operation: "send",
1463
+ layer: "http",
1464
+ requestId: l.command.request_id,
1465
+ clientMessageId: r.submission.userMessageId,
1466
+ sessionId: typeof l.command.payload.warmupId == "string" ? l.command.payload.warmupId : null,
1467
+ entrySurface: r.submission.entrySurface
1468
+ });
1469
+ let d = () => {
1470
+ }, h = () => {
1471
+ };
1472
+ p.measure("warmup_wait", () => new Promise((g, m) => {
1473
+ const f = () => {
1474
+ const b = c.engine.getState().slices, w = b.conversation.submissions[r.submission.userMessageId], _ = b.conversation.operations[l.command.request_id];
1475
+ !Ze(t) || !w || w.cancelled || b.directory.clients[w.clientScopeId] !== w.conversationScopeId ? m(new Error("Warmup wait was retired.")) : (w.sessionId !== null || !_ || !["waiting", "running", "uncertain"].includes(_.phase)) && g();
1476
+ };
1477
+ d = c.engine.subscribe(f), h = c.onDispose(() => m(new Error("Warmup wait was retired."))), f();
1478
+ })).catch(() => {
1479
+ }).finally(() => {
1480
+ d(), h();
1481
+ });
1454
1482
  };
1455
1483
  return {
1456
- "conversation.prepare": async (a) => {
1457
- o(a.submission.userMessageId);
1458
- let r;
1459
- const c = new Promise((d, h) => {
1460
- r = setTimeout(() => h(Object.assign(
1484
+ "conversation.prepare": async (r) => {
1485
+ o(r.submission.userMessageId);
1486
+ let c;
1487
+ const l = new Promise((h, g) => {
1488
+ c = setTimeout(() => g(Object.assign(
1461
1489
  new Error("Message preparation timed out. Retry this message."),
1462
1490
  { code: "submission_preparation_timeout", retryable: !0 }
1463
1491
  )), 18e4);
1464
1492
  });
1465
- let l = () => {
1493
+ let p = () => {
1466
1494
  };
1467
- const p = new Promise((d, h) => {
1468
- l = t.runtime().onDispose(() => h(new Error("Submission runtime was disposed.")));
1495
+ const d = new Promise((h, g) => {
1496
+ p = t.runtime().onDispose(() => g(new Error("Submission runtime was disposed.")));
1469
1497
  });
1470
- return Promise.race([t.prepareSubmission(a), c, p]).then((d) => (o(a.submission.userMessageId), d)).catch((d) => i(d, { operation: "conversation.prepare", requestId: a.submission.userMessageId })).finally(() => {
1471
- clearTimeout(r), l();
1498
+ return Promise.race([t.prepareSubmission(r), l, d]).then((h) => (o(r.submission.userMessageId), a(r), h)).catch((h) => i(h, { operation: "conversation.prepare", requestId: r.submission.userMessageId })).finally(() => {
1499
+ clearTimeout(c), p();
1472
1500
  });
1473
1501
  },
1474
- "conversation.checkpoint": async (a) => (Ye(t, a), await n(a.checkpoint).catch((r) => i(r, { operation: "conversation.checkpoint" })), Ye(t, a), null),
1475
- "conversation.receipt": (a) => Rt(t.onTiming, {
1502
+ "conversation.checkpoint": async (r) => (Ye(t, r), await n(r.checkpoint).catch((c) => i(c, { operation: "conversation.checkpoint" })), Ye(t, r), null),
1503
+ "conversation.receipt": (r) => St(t.onTiming, {
1476
1504
  operation: "send",
1477
1505
  layer: "http",
1478
- requestId: a.userMessageId,
1479
- clientMessageId: a.userMessageId,
1480
- sessionId: a.sessionId
1506
+ requestId: r.userMessageId,
1507
+ clientMessageId: r.userMessageId,
1508
+ sessionId: r.sessionId
1481
1509
  }).measure("receipt_http", () => Promise.resolve().then(async () => {
1482
- Ye(t, a);
1483
- const r = await t.http.request("/receipt", {}, {
1510
+ Ye(t, r);
1511
+ const c = await t.http.request("/receipt", {}, {
1484
1512
  context: s(),
1485
- session_id: a.sessionId,
1486
- client_message_id: a.userMessageId
1513
+ session_id: r.sessionId,
1514
+ client_message_id: r.userMessageId
1487
1515
  }, "POST", "conversations", { readOnly: !0 });
1488
- if (Ye(t, a), r !== null && (typeof r.sessionId != "string" || !r.sessionId || r.clientMessageId !== a.userMessageId || a.sessionId !== null && r.sessionId !== a.sessionId)) throw Object.assign(new Error("Conversation receipt identity mismatch."), { code: "acceptance_identity_mismatch" });
1489
- return r !== null && Rt(t.onTiming, {
1516
+ if (Ye(t, r), c !== null && (typeof c.sessionId != "string" || !c.sessionId || c.clientMessageId !== r.userMessageId || r.sessionId !== null && c.sessionId !== r.sessionId)) throw Object.assign(new Error("Conversation receipt identity mismatch."), { code: "acceptance_identity_mismatch" });
1517
+ return c !== null && St(t.onTiming, {
1490
1518
  operation: "send",
1491
1519
  layer: "http",
1492
- requestId: a.userMessageId,
1493
- clientMessageId: a.userMessageId,
1494
- sessionId: r.sessionId
1495
- }).mark("acceptance_received"), r;
1496
- }).catch((r) => i(r, { operation: "conversation.receipt", requestId: a.userMessageId, ...a.sessionId ? { sessionId: a.sessionId } : {} }))),
1497
- "conversation.command": (a) => {
1498
- let r = !1;
1520
+ requestId: r.userMessageId,
1521
+ clientMessageId: r.userMessageId,
1522
+ sessionId: c.sessionId
1523
+ }).mark("acceptance_received"), c;
1524
+ }).catch((c) => i(c, { operation: "conversation.receipt", requestId: r.userMessageId, ...r.sessionId ? { sessionId: r.sessionId } : {} }))),
1525
+ "conversation.command": (r) => {
1526
+ let c = !1;
1499
1527
  return Promise.resolve().then(async () => {
1500
- Ye(t, a), (a.command.type === "chat.user_message" || a.command.type === "attachment.upload_completed") && o(String(a.command.payload.clientMessageId));
1501
- const c = a.command.payload, l = Rt(["chat.user_message", "chat.retry_last_user_message", "run.stop", "attachment.upload_completed"].includes(a.command.type) ? t.onTiming : void 0, {
1502
- operation: a.command.type === "run.stop" ? "stop" : "send",
1528
+ Ye(t, r), (r.command.type === "chat.user_message" || r.command.type === "attachment.upload_completed") && o(String(r.command.payload.clientMessageId));
1529
+ const l = r.command.payload, p = r.command.type === "runtime.warmup", d = St(["runtime.warmup", "chat.user_message", "chat.retry_last_user_message", "run.stop", "attachment.upload_completed"].includes(r.command.type) ? t.onTiming : void 0, {
1530
+ operation: r.command.type === "run.stop" ? "stop" : "send",
1503
1531
  layer: "http",
1504
- requestId: a.command.request_id,
1505
- clientMessageId: String(c.clientMessageId ?? c.expectedUserMessageId ?? a.command.request_id),
1506
- sessionId: typeof c.sessionId == "string" ? c.sessionId : null
1532
+ requestId: r.command.request_id,
1533
+ clientMessageId: p ? null : String(l.clientMessageId ?? l.expectedUserMessageId ?? r.command.request_id),
1534
+ sessionId: typeof l.sessionId == "string" ? l.sessionId : p && typeof l.warmupId == "string" ? l.warmupId : null
1507
1535
  });
1508
- return await l.measure("checkpoint", () => n()), Ye(t, a), (a.command.type === "chat.user_message" || a.command.type === "attachment.upload_completed") && o(String(a.command.payload.clientMessageId)), t.onCommand?.(a.command), r = !0, await l.measure("command_http", async () => {
1509
- const p = await t.http.request(
1536
+ return await d.measure(p ? "warmup_checkpoint" : "checkpoint", () => n()), Ye(t, r), (r.command.type === "chat.user_message" || r.command.type === "attachment.upload_completed") && o(String(r.command.payload.clientMessageId)), t.onCommand?.(r.command), c = !0, await d.measure(p ? "warmup_http" : "command_http", async () => {
1537
+ const h = await t.http.request(
1510
1538
  "/commands",
1511
1539
  {},
1512
- { context: s(), command: a.command },
1540
+ { context: s(), command: r.command },
1513
1541
  "POST",
1514
1542
  "conversations",
1515
- { timing: l }
1543
+ { timing: d }
1516
1544
  );
1517
- if (Ye(t, a), p.request_id !== a.command.request_id || !Li(p.result)) throw Object.assign(new Error("Conversation response identity mismatch."), { code: "acceptance_identity_mismatch" });
1518
- if (a.command.type.startsWith("chat.")) {
1519
- const d = p.result;
1520
- if (typeof d?.sessionId != "string" || !d.sessionId || d.clientMessageId !== a.command.payload.clientMessageId || a.command.payload.sessionId && d.sessionId !== a.command.payload.sessionId) throw Object.assign(new Error("Conversation acceptance identity mismatch."), { code: "acceptance_identity_mismatch" });
1521
- Rt(t.onTiming, {
1545
+ if (Ye(t, r), h.request_id !== r.command.request_id || !Li(h.result)) throw Object.assign(new Error("Conversation response identity mismatch."), { code: "acceptance_identity_mismatch" });
1546
+ if (r.command.type.startsWith("chat.")) {
1547
+ const g = h.result;
1548
+ if (typeof g?.sessionId != "string" || !g.sessionId || g.clientMessageId !== r.command.payload.clientMessageId || r.command.payload.sessionId && g.sessionId !== r.command.payload.sessionId) throw Object.assign(new Error("Conversation acceptance identity mismatch."), { code: "acceptance_identity_mismatch" });
1549
+ St(t.onTiming, {
1522
1550
  operation: "send",
1523
1551
  layer: "http",
1524
- requestId: a.command.request_id,
1525
- clientMessageId: String(c.clientMessageId),
1526
- sessionId: d.sessionId
1552
+ requestId: r.command.request_id,
1553
+ clientMessageId: String(l.clientMessageId),
1554
+ sessionId: g.sessionId
1527
1555
  }).mark("acceptance_received");
1528
1556
  }
1529
- return p.result;
1557
+ return h.result;
1530
1558
  });
1531
- }).catch((c) => {
1532
- if (a.previousAcceptance === "unissued" && c instanceof Error && "backendRefusal" in c && c.backendRefusal === !0) {
1533
- const l = En(c);
1534
- throw Object.assign(l, { details: { ...l.details, acceptance: "rejected" } });
1559
+ }).catch((l) => {
1560
+ if (r.previousAcceptance === "unissued" && l instanceof Error && "backendRefusal" in l && l.backendRefusal === !0) {
1561
+ const p = En(l);
1562
+ throw Object.assign(p, { details: { ...p.details, acceptance: "rejected" } });
1535
1563
  }
1536
- if (!r && a.previousAcceptance === "unissued") {
1537
- const l = En(c);
1538
- throw Object.assign(l, { details: { ...l.details, acceptance: "unissued" } });
1564
+ if (!c && r.previousAcceptance === "unissued") {
1565
+ const p = En(l);
1566
+ throw Object.assign(p, { details: { ...p.details, acceptance: "unissued" } });
1539
1567
  }
1540
- if (c instanceof Error && "code" in c && c.code === "403") throw En(c);
1541
- return i(c, { operation: a.command.type, requestId: a.command.request_id });
1568
+ if (l instanceof Error && "code" in l && l.code === "403") throw En(l);
1569
+ return i(l, { operation: r.command.type, requestId: r.command.request_id });
1542
1570
  });
1543
1571
  },
1544
- "conversation.upload": (a) => {
1545
- let r = !1;
1546
- return Rt(t.onTiming, {
1572
+ "conversation.upload": (r) => {
1573
+ let c = !1;
1574
+ return St(t.onTiming, {
1547
1575
  operation: "send",
1548
1576
  layer: "http",
1549
- requestId: a.submission.userMessageId,
1550
- clientMessageId: a.submission.userMessageId,
1551
- sessionId: a.submission.sessionId
1577
+ requestId: r.submission.userMessageId,
1578
+ clientMessageId: r.submission.userMessageId,
1579
+ sessionId: r.submission.sessionId
1552
1580
  }).measure("attachment_upload", () => Promise.resolve().then(async () => {
1553
- const c = () => {
1554
- if (Ye(t, a), !a.preparationId) return o(a.submission.userMessageId);
1555
- const m = t.runtime().engine.getState().slices.directory;
1556
- if (!Object.values(m.clients).includes(a.submission.conversationScopeId))
1581
+ const l = () => {
1582
+ if (Ye(t, r), !r.preparationId) return o(r.submission.userMessageId);
1583
+ const f = t.runtime().engine.getState().slices.directory;
1584
+ if (!Object.values(f.clients).includes(r.submission.conversationScopeId))
1557
1585
  throw Object.assign(new Error("Attachment preparation was cancelled."), { code: "submission_cancelled", retryable: !1 });
1558
1586
  };
1559
- c(), await n(), c();
1560
- const l = await t.readAttachment(a.source.sourceId);
1561
- if (c(), l.size !== a.source.sizeBytes) throw Object.assign(new Error("Attachment source changed."), { code: "attachment_changed" });
1562
- const p = {
1563
- sessionId: a.submission.sessionId ?? void 0,
1564
- attachmentId: a.source.sourceId,
1587
+ l(), await n(), l();
1588
+ const p = await t.readAttachment(r.source.sourceId);
1589
+ if (l(), p.size !== r.source.sizeBytes) throw Object.assign(new Error("Attachment source changed."), { code: "attachment_changed" });
1590
+ const d = {
1591
+ sessionId: r.submission.sessionId ?? void 0,
1592
+ attachmentId: r.source.sourceId,
1565
1593
  clientId: t.http.auth.client_id,
1566
1594
  transportId: t.http.auth.transport_id ?? t.http.auth.client_id,
1567
1595
  communityId: t.http.auth.community_id,
1568
- name: a.source.name,
1569
- mimeType: a.source.mimeType,
1570
- sizeBytes: a.source.sizeBytes,
1571
- page: a.submission.context.page,
1572
- model: a.submission.requestedModel ?? void 0,
1573
- metadata: a.submission.context.metadata,
1574
- entrySurface: a.submission.entrySurface
1596
+ name: r.source.name,
1597
+ mimeType: r.source.mimeType,
1598
+ sizeBytes: r.source.sizeBytes,
1599
+ page: r.submission.context.page,
1600
+ model: r.submission.requestedModel ?? void 0,
1601
+ metadata: r.submission.context.metadata,
1602
+ entrySurface: r.submission.entrySurface
1575
1603
  };
1576
- r = !0;
1577
- const d = t.persistUpload ? await t.persistUpload(p, new File([l], a.source.name, { type: a.source.mimeType })) : t.prepareUpload ? await t.prepareUpload(p) : await t.http.request("/attachments/upload", {}, p);
1578
- if (c(), !d.sessionId || a.submission.sessionId && d.sessionId !== a.submission.sessionId || d.attachment.id !== a.source.sourceId || d.attachment.mimeType !== a.source.mimeType || d.attachment.sizeBytes !== a.source.sizeBytes)
1604
+ c = !0;
1605
+ const h = t.persistUpload ? await t.persistUpload(d, new File([p], r.source.name, { type: r.source.mimeType })) : t.prepareUpload ? await t.prepareUpload(d) : await t.http.request("/attachments/upload", {}, d);
1606
+ if (l(), !h.sessionId || r.submission.sessionId && h.sessionId !== r.submission.sessionId || h.attachment.id !== r.source.sourceId || h.attachment.mimeType !== r.source.mimeType || h.attachment.sizeBytes !== r.source.sizeBytes)
1579
1607
  throw Object.assign(new Error("Attachment preparation identity mismatch."), { code: "attachment_identity_mismatch", retryable: !1 });
1580
- if ("uploadUrl" in d) {
1581
- const m = await fetch(t.http.resolveUrl(d.uploadUrl), { method: d.uploadMethod, headers: d.uploadHeaders, body: l });
1582
- if (!m.ok) throw Object.assign(new Error("Attachment transfer failed."), { code: String(m.status) });
1608
+ if ("uploadUrl" in h) {
1609
+ const f = await fetch(t.http.resolveUrl(h.uploadUrl), { method: h.uploadMethod, headers: h.uploadHeaders, body: p });
1610
+ if (!f.ok) throw Object.assign(new Error("Attachment transfer failed."), { code: String(f.status) });
1583
1611
  }
1584
- c();
1585
- const h = d.attachment, g = {
1586
- id: h.id ?? null,
1587
- name: h.name,
1588
- mime_type: h.mimeType,
1589
- size_bytes: h.sizeBytes,
1590
- storage_key: h.storageKey ?? null,
1591
- sandbox_path: h.sandboxPath ?? null,
1592
- file_url: h.fileUrl ?? null
1612
+ l();
1613
+ const g = h.attachment, m = {
1614
+ id: g.id ?? null,
1615
+ name: g.name,
1616
+ mime_type: g.mimeType,
1617
+ size_bytes: g.sizeBytes,
1618
+ storage_key: g.storageKey ?? null,
1619
+ sandbox_path: g.sandboxPath ?? null,
1620
+ file_url: g.fileUrl ?? null
1593
1621
  };
1594
- return await t.onUploaded?.(a.source.sourceId, d.sessionId, g), c(), { sessionId: d.sessionId, attachment: g };
1595
- }).catch((c) => {
1596
- if (!r && a.previousAllocation === "unissued") {
1597
- const l = En(c);
1598
- throw Object.assign(l, { details: { ...l.details, allocation: "unissued" } });
1622
+ return await t.onUploaded?.(r.source.sourceId, h.sessionId, m), l(), { sessionId: h.sessionId, attachment: m };
1623
+ }).catch((l) => {
1624
+ if (!c && r.previousAllocation === "unissued") {
1625
+ const p = En(l);
1626
+ throw Object.assign(p, { details: { ...p.details, allocation: "unissued" } });
1599
1627
  }
1600
- return i(c, { operation: "conversation.upload", requestId: a.submission.userMessageId, ...a.submission.sessionId ? { sessionId: a.submission.sessionId } : {} });
1628
+ return i(l, { operation: "conversation.upload", requestId: r.submission.userMessageId, ...r.submission.sessionId ? { sessionId: r.submission.sessionId } : {} });
1601
1629
  }));
1602
1630
  },
1603
- "conversation.snapshot": (a) => Promise.resolve().then(async () => {
1604
- Ye(t, a);
1605
- const r = t.runtime(), c = new AbortController(), l = () => {
1606
- const h = r.engine.getState().slices;
1607
- at(t) ? h.directory.memberships[a.sessionId]?.members.length ? h.conversation.sessions[a.sessionId]?.queries[a.lane].requestId !== a.requestId && c.abort("request_replaced") : c.abort("observation_released") : c.abort("authority_retired");
1608
- }, p = r.engine.subscribe(l), d = r.onDispose(() => c.abort("owner_disposed"));
1609
- l();
1631
+ "conversation.snapshot": (r) => Promise.resolve().then(async () => {
1632
+ Ye(t, r);
1633
+ const c = t.runtime(), l = new AbortController(), p = () => {
1634
+ const g = c.engine.getState().slices;
1635
+ Ze(t) ? g.directory.memberships[r.sessionId]?.members.length ? g.conversation.sessions[r.sessionId]?.queries[r.lane].requestId !== r.requestId && l.abort("request_replaced") : l.abort("observation_released") : l.abort("authority_retired");
1636
+ }, d = c.engine.subscribe(p), h = c.onDispose(() => l.abort("owner_disposed"));
1637
+ p();
1610
1638
  try {
1611
- const h = [];
1612
- for (let w = 0; w < Math.max(1, a.refreshItemIds.length); w += 200) {
1613
- if (Ye(t, a), !t.runtime().engine.getState().slices.directory.memberships[a.sessionId]?.members.length) throw new Error("Conversation observation was retired.");
1614
- const b = await t.http.request(
1615
- `/${encodeURIComponent(a.sessionId)}/snapshot`,
1639
+ const g = [];
1640
+ for (let w = 0; w < Math.max(1, r.refreshItemIds.length); w += 200) {
1641
+ if (Ye(t, r), !t.runtime().engine.getState().slices.directory.memberships[r.sessionId]?.members.length) throw new Error("Conversation observation was retired.");
1642
+ const _ = await t.http.request(
1643
+ `/${encodeURIComponent(r.sessionId)}/snapshot`,
1616
1644
  {},
1617
- { context: s(), retry_preparation: a.retryPreparation === !0, limit: 100, before: a.before, refresh_item_ids: a.refreshItemIds.slice(w, w + 200) },
1645
+ { context: s(), retry_preparation: r.retryPreparation === !0, limit: 100, before: r.before, refresh_item_ids: r.refreshItemIds.slice(w, w + 200) },
1618
1646
  "POST",
1619
1647
  "conversations",
1620
- { readOnly: !0, signal: c.signal, diagnostic: {
1621
- sessionId: a.sessionId,
1622
- queryRequestId: a.requestId,
1623
- ownerId: r.engine.getDiagnostics().ownerId,
1624
- authorityGeneration: a.generation
1648
+ { readOnly: !0, signal: l.signal, diagnostic: {
1649
+ sessionId: r.sessionId,
1650
+ queryRequestId: r.requestId,
1651
+ ownerId: c.engine.getDiagnostics().ownerId,
1652
+ authorityGeneration: r.generation
1625
1653
  } }
1626
- ).catch((_) => {
1627
- if (h.length === 0) throw _;
1628
- const v = En(_);
1629
- throw Object.assign(v, { details: { ...v.details, successfulRequests: h.length } });
1654
+ ).catch((v) => {
1655
+ if (g.length === 0) throw v;
1656
+ const k = En(v);
1657
+ throw Object.assign(k, { details: { ...k.details, successfulRequests: g.length } });
1630
1658
  });
1631
- if (Ye(t, a), b.conversation_id !== a.sessionId) throw new Error("Snapshot conversation identity mismatch.");
1632
- if (h.push(b), !b.projection_ready) break;
1659
+ if (Ye(t, r), _.conversation_id !== r.sessionId) throw new Error("Snapshot conversation identity mismatch.");
1660
+ if (g.push(_), !_.projection_ready) break;
1633
1661
  }
1634
- const g = h[0];
1635
- if (a.before !== null && g.next_cursor === a.before)
1662
+ const m = g[0];
1663
+ if (r.before !== null && m.next_cursor === r.before)
1636
1664
  throw Object.assign(new Error("Conversation history cursor did not advance."), { code: "invalid_history_cursor" });
1637
- const m = h.reduce((w, b) => b.execution.version > w.version ? b.execution : w, g.execution), f = h.reduce((w, b) => b.follow_ups_version > w.follow_ups_version ? b : w, g);
1665
+ const f = g.reduce((w, _) => _.execution.version > w.version ? _.execution : w, m.execution), b = g.reduce((w, _) => _.follow_ups_version > w.follow_ups_version ? _ : w, m);
1638
1666
  return { snapshot: {
1639
- ...g,
1640
- execution: m,
1641
- items: h.flatMap((w) => w.items),
1642
- streams: h.flatMap((w) => w.streams),
1643
- removed_items: h.flatMap((w) => w.removed_items),
1644
- interactions: h.flatMap((w) => w.interactions),
1645
- follow_ups: f.follow_ups,
1646
- follow_ups_version: f.follow_ups_version,
1647
- projection_ready: h.every((w) => w.projection_ready)
1667
+ ...m,
1668
+ execution: f,
1669
+ items: g.flatMap((w) => w.items),
1670
+ streams: g.flatMap((w) => w.streams),
1671
+ removed_items: g.flatMap((w) => w.removed_items),
1672
+ interactions: g.flatMap((w) => w.interactions),
1673
+ follow_ups: b.follow_ups,
1674
+ follow_ups_version: b.follow_ups_version,
1675
+ projection_ready: g.every((w) => w.projection_ready)
1648
1676
  }, updatedAt: t.now() };
1649
1677
  } finally {
1650
- p(), d();
1678
+ d(), h();
1651
1679
  }
1652
- }).catch((r) => {
1653
- const c = En(r, { requestId: a.requestId, sessionId: a.sessionId });
1654
- if (["display_projection_disabled", "409", "connection_interrupted", "request_timed_out", "request_cancelled", "408", "425", "429", "500", "502", "503", "504"].includes(c.code))
1655
- throw Object.assign(c, { code: "history_load_failed", message: "We couldn’t refresh this conversation. Try again.", retryable: !0 });
1656
- if (cd(c.code)) throw Object.assign(c, { retryable: !0 });
1657
- return i(r, { operation: "conversation.snapshot", requestId: a.requestId, sessionId: a.sessionId });
1680
+ }).catch((c) => {
1681
+ const l = En(c, { requestId: r.requestId, sessionId: r.sessionId });
1682
+ if (["display_projection_disabled", "409", "connection_interrupted", "request_timed_out", "request_cancelled", "408", "425", "429", "500", "502", "503", "504"].includes(l.code))
1683
+ throw Object.assign(l, { code: "history_load_failed", message: "We couldn’t refresh this conversation. Try again.", retryable: !0 });
1684
+ if (cd(l.code)) throw Object.assign(l, { retryable: !0 });
1685
+ return i(c, { operation: "conversation.snapshot", requestId: r.requestId, sessionId: r.sessionId });
1658
1686
  })
1659
1687
  };
1660
1688
  }
@@ -1666,7 +1694,7 @@ class jp {
1666
1694
  maxFailureIntervalMs: 3e4,
1667
1695
  isActiveTurn: () => !0,
1668
1696
  poll: async () => {
1669
- if (!(this.disposed || !at(e)) && (await e.runtime().engine.dispatch({ ...e.authority, type: "conversation.recover", now: e.now() }), await this.waitForDelivery(), this.hasUncertainDelivery()))
1697
+ if (!(this.disposed || !Ze(e)) && (await e.runtime().engine.dispatch({ ...e.authority, type: "conversation.recover", now: e.now() }), await this.waitForDelivery(), this.hasUncertainDelivery()))
1670
1698
  throw new Error("Submission receipt recovery is still pending.");
1671
1699
  }
1672
1700
  }), e.runtime().engine.dispatch({ ...e.authority, type: "conversation.enable_effects" }), this.unsubscribe = e.runtime().engine.subscribe(() => this.reconcile()), this.unsubscribeDispose = e.runtime().onDispose(() => this.dispose());
@@ -1680,7 +1708,7 @@ class jp {
1680
1708
  owner;
1681
1709
  deliveryRecovery;
1682
1710
  reconcile() {
1683
- const e = this.options.runtime(), n = !this.disposed && at(this.options) && (this.options.enabled?.() ?? !0), i = e.engine.getProjection().directory.intents;
1711
+ const e = this.options.runtime(), n = !this.disposed && Ze(this.options) && (this.options.enabled?.() ?? !0), i = e.engine.getProjection().directory.intents;
1684
1712
  for (const [o, a] of this.observations)
1685
1713
  n && i[o]?.observe || (a.current.stop(), a.history.stop(), this.observations.delete(o), e.engine.dispatch({ ...this.options.authority, type: "conversation.observation_released", sessionId: o }), a.roomRequested && this.options.socket.release(o, this.owner).catch((r) => this.report(r)));
1686
1714
  if (n) for (const [o, a] of Object.entries(i)) {
@@ -1691,7 +1719,7 @@ class jp {
1691
1719
  maxFailureIntervalMs: 6e4,
1692
1720
  isActiveTurn: () => !1,
1693
1721
  poll: async () => {
1694
- for (; !this.disposed && at(this.options) && this.observations.get(o)?.history === r; ) {
1722
+ for (; !this.disposed && Ze(this.options) && this.observations.get(o)?.history === r; ) {
1695
1723
  const l = e.engine.getState().slices.conversation.sessions[o]?.queries.history;
1696
1724
  if (!l || l.cursor === null || l.error && !l.error.retryable) return;
1697
1725
  const p = l.cursor;
@@ -1727,31 +1755,31 @@ class jp {
1727
1755
  }
1728
1756
  refresh(e, n = "current") {
1729
1757
  const i = this.options.runtime(), s = i.engine.getState().slices.conversation.sessions[e]?.queries[n].requestId;
1730
- if (!at(this.options) || !this.observations.has(e)) return Promise.resolve();
1758
+ if (!Ze(this.options) || !this.observations.has(e)) return Promise.resolve();
1731
1759
  const o = s ?? this.options.nextRequestId();
1732
1760
  return i.engine.dispatch({ ...this.options.authority, type: "conversation.snapshot", sessionId: e, requestId: o, lane: n }).then(() => new Promise((r, c) => {
1733
1761
  let l = null;
1734
1762
  const p = () => {
1735
- const d = i.engine.getState().slices.conversation.sessions[e]?.queries[n], h = !this.disposed && at(this.options) && this.observations.has(e);
1763
+ const d = i.engine.getState().slices.conversation.sessions[e]?.queries[n], h = !this.disposed && Ze(this.options) && this.observations.has(e);
1736
1764
  return h && d?.requestId === o ? !1 : (l?.(), this.waiters.delete(p), h && d?.status === "error" ? c(d.error) : r(), !0);
1737
1765
  };
1738
1766
  p() || (this.waiters.add(p), l = i.engine.subscribe(p));
1739
1767
  }));
1740
1768
  }
1741
1769
  receive(e) {
1742
- if (this.disposed || !at(this.options) || !(this.options.enabled?.() ?? !0)) return;
1770
+ if (this.disposed || !Ze(this.options) || !(this.options.enabled?.() ?? !0)) return;
1743
1771
  const n = e.type === "conversation.item.updated" ? e.item.conversation_id : e.type === "conversation.execution.updated" ? e.execution.conversation_id : e.type === "conversation.interaction.updated" ? e.interaction.conversation_id : e.conversation_id;
1744
1772
  this.observations.has(n) && this.options.runtime().engine.accept({ ...this.options.authority, type: "conversation.display_received", event: e });
1745
1773
  }
1746
1774
  wake() {
1747
- if (!(this.disposed || !at(this.options)) && (this.reconcile(), !!(this.options.enabled?.() ?? !0))) {
1775
+ if (!(this.disposed || !Ze(this.options)) && (this.reconcile(), !!(this.options.enabled?.() ?? !0))) {
1748
1776
  this.deliveryRecovery.refresh();
1749
1777
  for (const [e, n] of this.observations)
1750
1778
  n.roomRequested && this.options.socket.retain(e, this.owner).catch((i) => this.report(i)), n.current.refresh(), n.history.refresh();
1751
1779
  }
1752
1780
  }
1753
1781
  report(e) {
1754
- !this.disposed && at(this.options) && this.options.onError(e);
1782
+ !this.disposed && Ze(this.options) && this.options.onError(e);
1755
1783
  }
1756
1784
  hasUncertainDelivery() {
1757
1785
  const e = this.options.runtime().engine.getState().slices.conversation;
@@ -1764,7 +1792,7 @@ class jp {
1764
1792
  waitForDelivery() {
1765
1793
  return new Promise((e) => {
1766
1794
  let n = null;
1767
- const i = () => !this.disposed && at(this.options) && this.hasRunningDelivery() ? !1 : (n?.(), this.waiters.delete(i), e(), !0);
1795
+ const i = () => !this.disposed && Ze(this.options) && this.hasRunningDelivery() ? !1 : (n?.(), this.waiters.delete(i), e(), !0);
1768
1796
  i() || (this.waiters.add(i), n = this.options.runtime().engine.subscribe(i));
1769
1797
  });
1770
1798
  }
@@ -1808,14 +1836,14 @@ function Vn(t, e, n) {
1808
1836
  collapsed: !1
1809
1837
  });
1810
1838
  }
1811
- const d = o?.execution, h = a.filter((S) => !S.cancelled && S.delivery !== "failed"), g = h.filter((S) => S.delivery !== "accepted" && S.executionVersion === null), m = h.filter((S) => S.delivery === "accepted" && S.executionVersion === null), f = h[h.length - 1], w = g.length > 0, b = f !== void 0 && m.includes(f);
1812
- let _ = w ? "submitting" : b ? "awaiting_execution" : d?.phase ?? "idle";
1813
- const v = Object.entries(t.stops).filter(([S]) => S === n || s !== null && e.selections[S]?.sessionId === s).map(([, S]) => S).find((S) => (!a.length || S.userMessageIds.includes(a[a.length - 1].userMessageId) || !w && !b && Kt(d).some((F) => S.userMessageIds.includes(F))) && (!d || d.version <= S.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((F) => F.cancelled && F.executionVersion === null && S.userMessageIds.includes(F.userMessageId)))), E = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((S) => S.delivery === "accepted" && S.executionVersion === null && v?.userMessageIds.includes(S.userMessageId));
1814
- v && E && !w && (!d || !["thinking", "steering", "queued", "stopping"].includes(d.phase) || Kt(d).every((S) => v.userMessageIds.includes(S))) && (_ = "stopping"), v && !E && !w && a.some((S) => S.cancelled && S.executionVersion === null && v.userMessageIds.includes(S.userMessageId)) && (_ = a.some((S) => v.userMessageIds.includes(S.userMessageId) && ["sending", "uncertain"].includes(S.delivery)) ? "stopping" : "stopped");
1839
+ const d = o?.execution, h = a.filter((S) => !S.cancelled && S.delivery !== "failed"), g = h.filter((S) => S.delivery !== "accepted" && S.executionVersion === null), m = h.filter((S) => S.delivery === "accepted" && S.executionVersion === null), f = h[h.length - 1], b = g.length > 0, w = f !== void 0 && m.includes(f);
1840
+ let _ = b ? "submitting" : w ? "awaiting_execution" : d?.phase ?? "idle";
1841
+ const v = Object.entries(t.stops).filter(([S]) => S === n || s !== null && e.selections[S]?.sessionId === s).map(([, S]) => S).find((S) => (!a.length || S.userMessageIds.includes(a[a.length - 1].userMessageId) || !b && !w && Kt(d).some((F) => S.userMessageIds.includes(F))) && (!d || d.version <= S.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((F) => F.cancelled && F.executionVersion === null && S.userMessageIds.includes(F.userMessageId)))), k = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((S) => S.delivery === "accepted" && S.executionVersion === null && v?.userMessageIds.includes(S.userMessageId));
1842
+ v && k && !b && (!d || !["thinking", "steering", "queued", "stopping"].includes(d.phase) || Kt(d).every((S) => v.userMessageIds.includes(S))) && (_ = "stopping"), v && !k && !b && a.some((S) => S.cancelled && S.executionVersion === null && v.userMessageIds.includes(S.userMessageId)) && (_ = a.some((S) => v.userMessageIds.includes(S.userMessageId) && ["sending", "uncertain"].includes(S.delivery)) ? "stopping" : "stopped");
1815
1843
  const L = ["thinking", "steering", "queued"].includes(_), K = t.stops[n] ?? v, U = K?.userMessageIds.filter((S) => !["completed", "failed"].includes(o?.executionByUserMessage[S]?.phase ?? "")) ?? [], he = U.some((S) => {
1816
1844
  const F = a.find((ce) => ce.userMessageId === S);
1817
1845
  return !Object.values(t.operations).some((ce) => ce.command.type === "run.stop" && ce.command.payload.expectedUserMessageId === S && ce.phase === "done") && (F?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(F.delivery) || !!(d && Kt(d).includes(S) && ["thinking", "steering", "queued", "stopping"].includes(d.phase)));
1818
- }), G = d?.user_message_ids ?? [], oe = w || b ? f?.userMessageId ?? null : G[G.length - 1] ?? null, R = p.find((S) => S.userMessageId === oe), V = L ? [...R?.activityIds ?? []].reverse().find((S) => l[S] === "open") ?? null : null, O = s !== null && !!e.selections[n]?.provisionalId && r.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
1846
+ }), G = d?.user_message_ids ?? [], oe = b || w ? f?.userMessageId ?? null : G[G.length - 1] ?? null, R = p.find((S) => S.userMessageId === oe), V = L ? [...R?.activityIds ?? []].reverse().find((S) => l[S] === "open") ?? null : null, O = s !== null && !!e.selections[n]?.provisionalId && r.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
1819
1847
  (!o?.execution || o.execution.phase === "idle" && o.execution.user_message_ids.length === 0) && Object.values(t.operations).some((S) => S.conversationScopeId === n && S.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(S.command.type) && !S.command.payload.sessionId && S.result?.sessionId === s);
1820
1848
  return qt({
1821
1849
  historyRefreshFailure: o?.historyRefreshFailure ?? null,
@@ -2016,7 +2044,7 @@ function Zp(t, e, n, i) {
2016
2044
  function eh(t, e, n, i) {
2017
2045
  const s = /* @__PURE__ */ new Map();
2018
2046
  for (const v of t.segments)
2019
- for (const E of [...v.activityIds, ...v.outcomeIds]) s.set(E, v.userMessageId);
2047
+ for (const k of [...v.activityIds, ...v.outcomeIds]) s.set(k, v.userMessageId);
2020
2048
  const o = t.items.map((v) => Zp(
2021
2049
  v,
2022
2050
  s.get(v.id) ?? null,
@@ -2030,14 +2058,14 @@ function eh(t, e, n, i) {
2030
2058
  // There is no canonical timestamp before acceptance. Keep identity stable without fabricating one.
2031
2059
  createdAt: "",
2032
2060
  retryable: v.delivery === "failed" && ["delivery", "preparation"].includes(pd(t, v.userMessageId)?.type ?? ""),
2033
- attachments: v.attachments.map((E) => ({
2034
- id: E.sourceId,
2035
- name: E.name,
2036
- mimeType: E.mimeType,
2037
- sizeBytes: E.sizeBytes
2061
+ attachments: v.attachments.map((k) => ({
2062
+ id: k.sourceId,
2063
+ name: k.name,
2064
+ mimeType: k.mimeType,
2065
+ sizeBytes: k.sizeBytes
2038
2066
  }))
2039
2067
  });
2040
- const a = t.segments.flatMap((v) => o.filter((E) => E.id === v.userMessageId || v.activityIds.includes(E.id) || v.outcomeIds.includes(E.id)));
2068
+ const a = t.segments.flatMap((v) => o.filter((k) => k.id === v.userMessageId || v.activityIds.includes(k.id) || v.outcomeIds.includes(k.id)));
2041
2069
  t.proactiveQuestion && a.push({
2042
2070
  id: t.proactiveQuestion.id,
2043
2071
  role: "assistant",
@@ -2047,18 +2075,18 @@ function eh(t, e, n, i) {
2047
2075
  loading: !1
2048
2076
  });
2049
2077
  const r = t.activity.phase, c = t.submissions.filter((v) => !v.cancelled && !["accepted", "failed"].includes(v.delivery)), l = t.submissions[t.submissions.length - 1], p = [...t.items].reverse().find((v) => v.type === "user_message"), d = ["queued", "thinking", "steering", "awaiting_execution"].includes(r), h = l?.delivery === "failed" && (d && t.activity.userMessageId != null && t.activity.userMessageId !== l.userMessageId || p !== void 0 && p.id !== l.userMessageId && Date.parse(p.created_at) > l.submittedAt), g = new Map(t.submissions.filter((v) => (v !== l || h) && !v.cancelled && v.delivery === "failed" && v.error).map((v) => [v.userMessageId, v])), m = a.flatMap((v) => {
2050
- const E = v.role === "user" ? g.get(v.id) : void 0;
2051
- return E?.error ? [v, {
2052
- id: `submission-error:${E.userMessageId}`,
2078
+ const k = v.role === "user" ? g.get(v.id) : void 0;
2079
+ return k?.error ? [v, {
2080
+ id: `submission-error:${k.userMessageId}`,
2053
2081
  role: "system",
2054
2082
  dataType: "run_error",
2055
- respondsToUserMessageId: E.userMessageId,
2056
- content: E.error.message,
2083
+ respondsToUserMessageId: k.userMessageId,
2084
+ content: k.error.message,
2057
2085
  createdAt: "",
2058
2086
  loading: !1,
2059
- ...typeof E.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: E.error.details.securitySettingsUrl } : {}
2087
+ ...typeof k.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: k.error.details.securitySettingsUrl } : {}
2060
2088
  }] : [v];
2061
- }), f = l?.delivery === "failed" && !l.cancelled && !h ? l.error : e?.error ?? null, w = {
2089
+ }), f = l?.delivery === "failed" && !l.cancelled && !h ? l.error : e?.error ?? null, b = {
2062
2090
  isRetrying: t.isRetrying ?? !1,
2063
2091
  historyRefreshFailure: f === e?.error ? t.historyRefreshFailure ?? null : null,
2064
2092
  conversationDiagnostics: {
@@ -2099,20 +2127,20 @@ function eh(t, e, n, i) {
2099
2127
  lastErrorCode: f?.code ?? null,
2100
2128
  lastErrorSecuritySettingsUrl: typeof f?.details?.securitySettingsUrl == "string" ? f.details.securitySettingsUrl : null
2101
2129
  };
2102
- let b = w;
2103
- for (const v of t.optimistic.filter((E) => E.cancelled && !t.stop?.userMessageIds.includes(E.userMessageId))) {
2104
- const E = Pc(b, "", "stopped", [v.userMessageId], qc(v.cancellationReason));
2105
- b = { ...b, messages: E.messages, segments: E.segments };
2130
+ let w = b;
2131
+ for (const v of t.optimistic.filter((k) => k.cancelled && !t.stop?.userMessageIds.includes(k.userMessageId))) {
2132
+ const k = Pc(w, "", "stopped", [v.userMessageId], qc(v.cancellationReason));
2133
+ w = { ...w, messages: k.messages, segments: k.segments };
2106
2134
  }
2107
- if (!t.stop) return b;
2135
+ if (!t.stop) return w;
2108
2136
  const _ = Pc(
2109
- b,
2137
+ w,
2110
2138
  "",
2111
2139
  t.stop.pending ? "stopping" : "stopped",
2112
2140
  t.stop.userMessageIds,
2113
2141
  qc(t.stop.reason ?? "user_requested")
2114
2142
  );
2115
- return { ...w, messages: _.messages, segments: _.segments };
2143
+ return { ...b, messages: _.messages, segments: _.segments };
2116
2144
  }
2117
2145
  function qc(t) {
2118
2146
  switch (t) {
@@ -4838,8 +4866,8 @@ class Cd {
4838
4866
  const _ = i;
4839
4867
  f = { ..._, context: { ..._.context, connection_id: m } };
4840
4868
  }
4841
- const w = () => this.requestOnce(e, n, f, s, o, a.signal, a.diagnostic, ++p), b = await (a.timing ? a.timing.measure("http_request", w) : w());
4842
- return c(), b;
4869
+ const b = () => this.requestOnce(e, n, f, s, o, a.signal, a.diagnostic, ++p), w = await (a.timing ? a.timing.measure("http_request", b) : b());
4870
+ return c(), w;
4843
4871
  } catch (f) {
4844
4872
  if (c(!1), this.requests.signal.aborted || a.signal?.aborted) throw f;
4845
4873
  if (f instanceof T && f.code === "executor_not_ready" && m && d === 0 && this.options.restoreExecutor) {
@@ -4858,16 +4886,16 @@ class Cd {
4858
4886
  this.requests.signal.throwIfAborted(), a?.throwIfAborted();
4859
4887
  const h = new AbortController(), g = { trigger: null }, m = (R) => {
4860
4888
  h.signal.aborted || (g.trigger = R, h.abort());
4861
- }, f = () => m("transport_disposed"), w = () => m(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
4862
- this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", w, { once: !0 });
4863
- const b = o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && s === "POST", _ = /^\/conversations(?:\/[^/]+)?$/.test(e) && (s ?? (i === void 0 ? "GET" : "POST")) === "GET", v = setTimeout(() => m("deadline"), _ ? 6e4 : b ? 3e4 : 15e3), E = Zh(), L = Date.now();
4889
+ }, f = () => m("transport_disposed"), b = () => m(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
4890
+ this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", b, { once: !0 });
4891
+ const w = o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && s === "POST", _ = /^\/conversations(?:\/[^/]+)?$/.test(e) && (s ?? (i === void 0 ? "GET" : "POST")) === "GET", v = setTimeout(() => m("deadline"), _ ? 6e4 : w ? 3e4 : 15e3), k = Zh(), L = Date.now();
4864
4892
  let K = null, U = !1, he = null, G = null, oe = null;
4865
4893
  try {
4866
4894
  const R = await Promise.resolve(fetch(p, {
4867
4895
  method: s ?? (i === void 0 ? "GET" : "POST"),
4868
4896
  cache: "no-store",
4869
4897
  signal: h.signal,
4870
- headers: { "x-product-agent-auth-request-id": E, authorization: l || o === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ...b ? { "x-request-id": E } : {} },
4898
+ headers: { "x-product-agent-auth-request-id": k, authorization: l || o === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ...w ? { "x-request-id": k } : {} },
4871
4899
  ...i === void 0 ? {} : { body: JSON.stringify(i) }
4872
4900
  })).catch((V) => {
4873
4901
  throw U = !0, V;
@@ -4885,15 +4913,15 @@ class Cd {
4885
4913
  ...typeof O.blockedOrigin == "string" ? { blockedOrigin: O.blockedOrigin } : {},
4886
4914
  ...typeof O.securitySettingsUrl == "string" ? { securitySettingsUrl: O.securitySettingsUrl } : {}
4887
4915
  }, o === "conversations" && e === "/commands");
4888
- const S = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, F = R.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(S) ? { requestId: E, authTransport: "http", authEndpoint: `${o ?? (l ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: S, retryable: S === "token_expired" && (O === "Token expired" || O.retryable === !0) } : void 0;
4916
+ const S = O === "Token expired" ? "token_expired" : O === "Invalid token" ? "invalid_token" : O?.reason, F = R.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(S) ? { requestId: k, authTransport: "http", authEndpoint: `${o ?? (l ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: S, retryable: S === "token_expired" && (O === "Token expired" || O.retryable === !0) } : void 0;
4889
4917
  throw new T(R.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : R.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${R.status})`, V, !1, F);
4890
4918
  }
4891
4919
  return await R.json();
4892
4920
  } catch (R) {
4893
4921
  const V = g.trigger ?? ((R instanceof Error || R instanceof DOMException) && R.name === "AbortError" ? "unexpected_abort" : null), O = {
4894
- requestId: E,
4922
+ requestId: k,
4895
4923
  method: s ?? (i === void 0 ? "GET" : "POST"),
4896
- route: b ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
4924
+ route: w ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
4897
4925
  status: he,
4898
4926
  abortTrigger: V,
4899
4927
  category: V === "deadline" ? "request_timed_out" : V === "unexpected_abort" ? "connection_interrupted" : V ? "request_cancelled" : R instanceof T ? R.code : U ? "connection_interrupted" : "invalid_response",
@@ -4923,13 +4951,13 @@ class Cd {
4923
4951
  );
4924
4952
  }
4925
4953
  throw R instanceof T && S ? new T(R.message, R.code, R.outcomeUnknown, { ...R.detail, ...S }, R.backendRefusal) : S ? new T(
4926
- U ? "The connection was interrupted. Please try again." : b ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
4954
+ U ? "The connection was interrupted. Please try again." : w ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
4927
4955
  "connection_interrupted",
4928
4956
  !0,
4929
4957
  S
4930
4958
  ) : R;
4931
4959
  } finally {
4932
- clearTimeout(v), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", w);
4960
+ clearTimeout(v), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", b);
4933
4961
  }
4934
4962
  }
4935
4963
  }
@@ -6454,13 +6482,13 @@ class Cg {
6454
6482
  let l = s.slices.directory;
6455
6483
  for (const [g, m] of Object.entries(c.state.operations)) {
6456
6484
  if (!["runtime.warmup", "attachment.prepare"].includes(m.command.type) || !m.conversationScopeId || m.phase !== "done" || s.slices.conversation.operations[g]?.phase === "done") continue;
6457
- const f = m.result, w = l.selections[m.conversationScopeId];
6458
- f?.sessionId && w?.provisionalId && w.sessionId === null && Object.values(l.clients).includes(m.conversationScopeId) && (l = Mn(l, {
6485
+ const f = m.result, b = l.selections[m.conversationScopeId];
6486
+ f?.sessionId && b?.provisionalId && b.sessionId === null && Object.values(l.clients).includes(m.conversationScopeId) && (l = Mn(l, {
6459
6487
  authorityId: c.state.authorityId,
6460
6488
  generation: c.state.generation,
6461
6489
  type: "directory.accepted",
6462
6490
  conversationScopeId: m.conversationScopeId,
6463
- provisionalId: w.provisionalId,
6491
+ provisionalId: b.provisionalId,
6464
6492
  sessionId: f.sessionId
6465
6493
  }).state);
6466
6494
  }
@@ -7257,7 +7285,7 @@ function gf(t, e) {
7257
7285
  return n;
7258
7286
  }
7259
7287
  const ff = globalThis.fetch.bind(globalThis), nl = '.pluno-pa-widget-host[data-pluno-product-agent-ui="widget"]', mf = '.pluno-pa-widget[data-pluno-product-agent-ui-root="widget"]', yf = ".pluno-pa-widget__panel", wf = ".pluno-pa-widget__timeline", bf = "__plunoExtensionWidgetOwner";
7260
- class Ze extends Error {
7288
+ class et extends Error {
7261
7289
  constructor(e, n, i, s) {
7262
7290
  super(e), this.retryable = n, this.status = i, this.retryAfterMs = s, this.name = "ProductAgentTokenProviderError";
7263
7291
  }
@@ -7379,7 +7407,7 @@ function Bf(t) {
7379
7407
  }
7380
7408
  }
7381
7409
  function er(t) {
7382
- if (t instanceof Ze)
7410
+ if (t instanceof et)
7383
7411
  return t.retryable;
7384
7412
  if (t && typeof t == "object") {
7385
7413
  const e = t instanceof T ? t.code : "", n = /^[45][0-9]{2}$/.test(e) ? Number(e) : t.status;
@@ -7654,7 +7682,7 @@ class pa {
7654
7682
  http: this.directoryHttp,
7655
7683
  now: () => Date.now(),
7656
7684
  prepareSubmission: async ({ submission: d, sources: h }) => {
7657
- const g = Rt(this.operationTimingReporter, {
7685
+ const g = St(this.operationTimingReporter, {
7658
7686
  operation: "send",
7659
7687
  layer: "sdk",
7660
7688
  requestId: d.requestId,
@@ -7663,16 +7691,16 @@ class pa {
7663
7691
  });
7664
7692
  let m = d.contextPreparation ?? { pageContent: "", sessionTabs: [] };
7665
7693
  if (d.contextPreparation === null) {
7666
- await g.measure("first_frame", () => new Promise((w) => {
7694
+ await g.measure("first_frame", () => new Promise((b) => {
7667
7695
  if (document.visibilityState !== "visible") {
7668
- setTimeout(w, 0);
7696
+ setTimeout(b, 0);
7669
7697
  return;
7670
7698
  }
7671
- const b = () => {
7672
- cancelAnimationFrame(v), document.removeEventListener("visibilitychange", _), setTimeout(w, 0);
7699
+ const w = () => {
7700
+ cancelAnimationFrame(v), document.removeEventListener("visibilitychange", _), setTimeout(b, 0);
7673
7701
  }, _ = () => {
7674
- document.visibilityState !== "visible" && b();
7675
- }, v = requestAnimationFrame(b);
7702
+ document.visibilityState !== "visible" && w();
7703
+ }, v = requestAnimationFrame(w);
7676
7704
  document.addEventListener("visibilitychange", _);
7677
7705
  }));
7678
7706
  const f = d.context.page;
@@ -7728,14 +7756,14 @@ class pa {
7728
7756
  const o = this.clientRuntime.engine.getState().slices.conversation, a = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null : Ec(s);
7729
7757
  if (this.authenticatedUserId && !o.submissionOrder.length && !Object.keys(o.operations).length) {
7730
7758
  const d = this.queuedClientEvents.filter((g) => g.type === "chat.user_message"), h = a ? JSON.parse(a) : d.length ? Op(o, d.map((g) => {
7731
- const { type: m, ...f } = g, w = this.clientRuntime.engine.getState().slices.directory, b = w.clients[this.modelClientScopeId];
7759
+ const { type: m, ...f } = g, b = this.clientRuntime.engine.getState().slices.directory, w = b.clients[this.modelClientScopeId];
7732
7760
  return {
7733
7761
  command: { type: m, request_id: g.clientMessageId, payload: JSON.parse(JSON.stringify(f)) },
7734
7762
  requestedModel: g.model ?? null,
7735
7763
  clientScopeId: this.modelClientScopeId,
7736
- conversationScopeId: b,
7764
+ conversationScopeId: w,
7737
7765
  viewId: `sdk:${this.modelClientScopeId}`,
7738
- sessionId: g.sessionId ?? w.selections[b]?.sessionId ?? null,
7766
+ sessionId: g.sessionId ?? b.selections[w]?.sessionId ?? null,
7739
7767
  entrySurface: this.options.entrySurface,
7740
7768
  submittedAt: Date.now()
7741
7769
  };
@@ -7778,26 +7806,26 @@ class pa {
7778
7806
  for (const f of Object.values(d.conversation.submissions)) {
7779
7807
  if (f.delivery === "accepted" && h.submissions[f.userMessageId]?.delivery !== "accepted") {
7780
7808
  this.emit("ack", { clientMessageId: f.userMessageId, sessionId: f.sessionId });
7781
- const w = f.sessionId;
7782
- w && this.getState().sessionId === w && this.directoryHttp.request(`/sessions/${encodeURIComponent(w)}/history`, { limit: 200 }).then((b) => {
7783
- i() && this.getState().sessionId === w && this.state.status !== "closed" && Go(this.clientRuntime, this.modelClientScopeId, w, b.turns);
7784
- }).catch((b) => {
7785
- i() && this.getState().sessionId === w && this.handleDirectoryTransportError(b);
7809
+ const b = f.sessionId;
7810
+ b && this.getState().sessionId === b && this.directoryHttp.request(`/sessions/${encodeURIComponent(b)}/history`, { limit: 200 }).then((w) => {
7811
+ i() && this.getState().sessionId === b && this.state.status !== "closed" && Go(this.clientRuntime, this.modelClientScopeId, b, w.turns);
7812
+ }).catch((w) => {
7813
+ i() && this.getState().sessionId === b && this.handleDirectoryTransportError(w);
7786
7814
  });
7787
7815
  }
7788
7816
  (f.cancelled || f.delivery === "failed") && this.clearFirstResponseTimer(f.userMessageId);
7789
7817
  }
7790
- for (const [f, w] of Object.entries(d.directory.clients)) {
7818
+ for (const [f, b] of Object.entries(d.directory.clients)) {
7791
7819
  if (!f.startsWith(`background:${this.modelClientScopeId}:`)) continue;
7792
- const b = Vn(d.conversation, d.directory, w);
7793
- (g && b.sessionId === this.getState().sessionId || ["completed", "failed", "stopped"].includes(b.activity.phase)) && this.directoryScope.detach(f);
7820
+ const w = Vn(d.conversation, d.directory, b);
7821
+ (g && w.sessionId === this.getState().sessionId || ["completed", "failed", "stopped"].includes(w.activity.phase)) && this.directoryScope.detach(f);
7794
7822
  }
7795
7823
  const m = this.getState();
7796
7824
  for (const f of m.messages) {
7797
- const w = r.get(f.id);
7798
- if ((!w || w.content !== f.content || w.loading !== f.loading) && this.emit("message", f), f.content.trim() && f.content !== w?.content) {
7799
- const b = f.role === "assistant" || f.dataType === "commentary_history";
7800
- b && f.content.startsWith(w?.content ?? "") && this.emit("delta", f.content.slice(w?.content.length ?? 0)), (b || f.dataType === "tool_summary") && this.clearFirstResponseTimer(f.respondsToUserMessageId ?? null, !0);
7825
+ const b = r.get(f.id);
7826
+ if ((!b || b.content !== f.content || b.loading !== f.loading) && this.emit("message", f), f.content.trim() && f.content !== b?.content) {
7827
+ const w = f.role === "assistant" || f.dataType === "commentary_history";
7828
+ w && f.content.startsWith(b?.content ?? "") && this.emit("delta", f.content.slice(b?.content.length ?? 0)), (w || f.dataType === "tool_summary") && this.clearFirstResponseTimer(f.respondsToUserMessageId ?? null, !0);
7801
7829
  }
7802
7830
  }
7803
7831
  r = new Map(m.messages.map((f) => [f.id, f])), this.rebuildRuntimeInteractions(), this.emit("state", m);
@@ -7905,7 +7933,7 @@ class pa {
7905
7933
  let r = null;
7906
7934
  const c = new Promise((l, p) => {
7907
7935
  r = window.setTimeout(() => {
7908
- o.abort(), p(new Ze("Pluno token provider timed out", !0));
7936
+ o.abort(), p(new et("Pluno token provider timed out", !0));
7909
7937
  }, kf);
7910
7938
  });
7911
7939
  try {
@@ -7914,9 +7942,9 @@ class pa {
7914
7942
  c
7915
7943
  ]);
7916
7944
  if (o.signal.aborted || this.tokenAbortController !== o)
7917
- throw new Ze("Pluno token request was cancelled", !0);
7945
+ throw new et("Pluno token request was cancelled", !0);
7918
7946
  if (typeof l != "string" || !l.trim())
7919
- throw new Ze("Chat setup did not return a session. Contact your app administrator, then try again.", !1);
7947
+ throw new et("Chat setup did not return a session. Contact your app administrator, then try again.", !1);
7920
7948
  return this.token = l, this.tokenExpiresAtMs = Bf(l), l;
7921
7949
  } finally {
7922
7950
  r !== null && window.clearTimeout(r);
@@ -7957,7 +7985,7 @@ class pa {
7957
7985
  if (this.lastRecoveryStage = "token_provider", this.token = await this.acquireToken("connect", { forceRefresh: e }), this.token && (this.directoryHttp.auth.token = this.token), n !== this.connectionAttemptId || this.state.status === "closed")
7958
7986
  return;
7959
7987
  if (this.lastRecoveryStage = "socket_admission", !this.token && !this.options.webSocketFactory)
7960
- throw new Ze("Pluno requires a token or tokenProvider", !1);
7988
+ throw new et("Pluno requires a token or tokenProvider", !1);
7961
7989
  if (!this.options.webSocketFactory && this.rejectedTransportToken !== null && this.rejectedTransportToken === this.token) {
7962
7990
  this.clearEmbeddedRecoveryBudget(), this.setState({ status: "error", lastError: i });
7963
7991
  return;
@@ -8053,7 +8081,7 @@ class pa {
8053
8081
  lastError: sl,
8054
8082
  lastErrorCode: "connection_failed"
8055
8083
  }), this.emit("error", o), this.scheduleReconnect(
8056
- s instanceof Ze ? s.retryAfterMs : void 0
8084
+ s instanceof et ? s.retryAfterMs : void 0
8057
8085
  );
8058
8086
  return;
8059
8087
  }
@@ -8135,9 +8163,9 @@ class pa {
8135
8163
  if (this.clientRuntime.isDisposed) return null;
8136
8164
  const i = e.trim(), s = n.attachments ?? [];
8137
8165
  if (!i && !s.length) return null;
8138
- if (this.options.productVariant === "customer_embedded" && (s.forEach(Jd), s.reduce((w, b) => w + b.sizeBytes, 0) > Ud))
8166
+ if (this.options.productVariant === "customer_embedded" && (s.forEach(Jd), s.reduce((b, w) => b + w.sizeBytes, 0) > Ud))
8139
8167
  throw new Error("Embedded attachments must total at most 50 MB per message");
8140
- const o = n.clientMessageId ?? Te(), a = Rt(this.operationTimingReporter, {
8168
+ const o = n.clientMessageId ?? Te(), a = St(this.operationTimingReporter, {
8141
8169
  operation: "send",
8142
8170
  layer: "sdk",
8143
8171
  requestId: o,
@@ -8149,7 +8177,7 @@ class pa {
8149
8177
  if (n.initiatedBy || this.startFirstResponseTimer(o, n.submittedAt), l || await a.measure("authentication", () => this.waitForAuthentication()), this.clientRuntime.isDisposed || c !== this.submissionIntentRevision || l && l !== this.authenticatedUserId) return null;
8150
8178
  Vo(this.clientRuntime, this.modelClientScopeId, o, r ?? null);
8151
8179
  const p = this.clientRuntime.engine.getState().slices.conversation.submissions[o];
8152
- if (p && (p.content !== i || JSON.stringify(p.attachments.map((w) => w.sourceId)) !== JSON.stringify(s.map((w) => w.id ?? w.storageKey ?? w.sandboxPath)))) throw new Error("User-message identity cannot be reused with different input.");
8180
+ if (p && (p.content !== i || JSON.stringify(p.attachments.map((b) => b.sourceId)) !== JSON.stringify(s.map((b) => b.id ?? b.storageKey ?? b.sandboxPath)))) throw new Error("User-message identity cannot be reused with different input.");
8153
8181
  const d = vt(), h = !p && !n.initiatedBy && this.options.capturePageContent !== !1 && this.lastUserMessagePageUrl !== d.url, m = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
8154
8182
  if (!m) throw new Error("Conversation selection is not initialized.");
8155
8183
  p || await this.clientRuntime.engine.dispatch({
@@ -8163,19 +8191,19 @@ class pa {
8163
8191
  viewId: `sdk:${this.modelClientScopeId}`,
8164
8192
  rendererRevision: n.submittedAt ?? ++this.composerRevision,
8165
8193
  content: i,
8166
- attachments: s.map((w) => ({
8167
- sourceId: w.id ?? w.storageKey ?? w.sandboxPath,
8168
- name: w.name,
8169
- mimeType: w.mimeType,
8170
- sizeBytes: w.sizeBytes,
8171
- ...w.storageKey || w.sandboxPath ? { uploaded: {
8172
- id: w.id ?? null,
8173
- name: w.name,
8174
- mime_type: w.mimeType,
8175
- size_bytes: w.sizeBytes,
8176
- storage_key: w.storageKey ?? null,
8177
- sandbox_path: w.sandboxPath ?? null,
8178
- file_url: w.fileUrl ?? null
8194
+ attachments: s.map((b) => ({
8195
+ sourceId: b.id ?? b.storageKey ?? b.sandboxPath,
8196
+ name: b.name,
8197
+ mimeType: b.mimeType,
8198
+ sizeBytes: b.sizeBytes,
8199
+ ...b.storageKey || b.sandboxPath ? { uploaded: {
8200
+ id: b.id ?? null,
8201
+ name: b.name,
8202
+ mime_type: b.mimeType,
8203
+ size_bytes: b.sizeBytes,
8204
+ storage_key: b.storageKey ?? null,
8205
+ sandbox_path: b.sandboxPath ?? null,
8206
+ file_url: b.fileUrl ?? null
8179
8207
  } } : {}
8180
8208
  })),
8181
8209
  context: JSON.parse(JSON.stringify({
@@ -8188,20 +8216,20 @@ class pa {
8188
8216
  submittedAt: n.submittedAt ?? Date.now()
8189
8217
  });
8190
8218
  const f = this.directoryAuthority;
8191
- return this.clientRuntime.isDisposed ? null : new Promise((w, b) => {
8219
+ return this.clientRuntime.isDisposed ? null : new Promise((b, w) => {
8192
8220
  let _ = null, v = null;
8193
- const E = () => {
8221
+ const k = () => {
8194
8222
  const L = this.clientRuntime.engine.getState().slices.conversation.submissions[o];
8195
8223
  if (!(L && !L.cancelled && L.delivery !== "accepted" && L.delivery !== "failed"))
8196
- if (_?.(), v?.(), L?.delivery === "failed" && !L.cancelled) b(new Error(L.error?.message ?? "Message delivery failed."));
8224
+ if (_?.(), v?.(), L?.delivery === "failed" && !L.cancelled) w(new Error(L.error?.message ?? "Message delivery failed."));
8197
8225
  else {
8198
8226
  const K = L?.invocation === "user" && L.contextPreparation?.pageContent ? L.context.page?.url : null;
8199
- L?.delivery === "accepted" && !L.cancelled && typeof K == "string" && c === this.submissionIntentRevision && f === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === m && (this.lastUserMessagePageUrl = K), w(L?.delivery === "accepted" && !L.cancelled ? o : null);
8227
+ L?.delivery === "accepted" && !L.cancelled && typeof K == "string" && c === this.submissionIntentRevision && f === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === m && (this.lastUserMessagePageUrl = K), b(L?.delivery === "accepted" && !L.cancelled ? o : null);
8200
8228
  }
8201
8229
  };
8202
- _ = this.clientRuntime.engine.subscribe(E), v = this.clientRuntime.onDispose(() => {
8203
- _?.(), w(null);
8204
- }), E();
8230
+ _ = this.clientRuntime.engine.subscribe(k), v = this.clientRuntime.onDispose(() => {
8231
+ _?.(), b(null);
8232
+ }), k();
8205
8233
  });
8206
8234
  }
8207
8235
  reportResponseVisibility(e) {
@@ -8300,9 +8328,9 @@ class pa {
8300
8328
  }), new Promise((l, p) => {
8301
8329
  let d, h;
8302
8330
  const g = () => {
8303
- const m = this.clientRuntime.engine.getState().slices, f = m.conversation.operations[c], w = m.directory.authorityId !== a.authorityId || m.directory.clients[this.modelClientScopeId] !== r;
8304
- if (!w && f && !["done", "failed"].includes(f.phase)) return;
8305
- if (d?.(), h?.(), w || !f || f.phase === "failed") {
8331
+ const m = this.clientRuntime.engine.getState().slices, f = m.conversation.operations[c], b = m.directory.authorityId !== a.authorityId || m.directory.clients[this.modelClientScopeId] !== r;
8332
+ if (!b && f && !["done", "failed"].includes(f.phase)) return;
8333
+ if (d?.(), h?.(), b || !f || f.phase === "failed") {
8306
8334
  p(new Error(f?.error?.message ?? "Attachment preparation was cancelled."));
8307
8335
  return;
8308
8336
  }
@@ -8345,7 +8373,7 @@ class pa {
8345
8373
  }
8346
8374
  stop() {
8347
8375
  const e = this.getState();
8348
- Rt((n) => this.reportOperationTiming(n), {
8376
+ St((n) => this.reportOperationTiming(n), {
8349
8377
  operation: "stop",
8350
8378
  layer: "sdk",
8351
8379
  requestId: Te(),
@@ -8725,7 +8753,7 @@ class pa {
8725
8753
  });
8726
8754
  }
8727
8755
  send(e) {
8728
- const n = this.sendNow(rt(e));
8756
+ const n = this.sendNow(at(e));
8729
8757
  return n || (this.queuedClientEvents.push(e), Cn(this.options.clientId, this.queuedClientEvents), this.setState({ status: "reconnecting" }), this.scheduleReconnect()), n;
8730
8758
  }
8731
8759
  sendNow(e) {
@@ -8734,7 +8762,7 @@ class pa {
8734
8762
  const n = this.socket;
8735
8763
  if ((e.type === "tool.result" || e.type === "run.stop") && n instanceof Ae) {
8736
8764
  const i = this.queuedClientEvents.find((s) => "sessionId" in s && s.sessionId === e.sessionId && (e.type === "tool.result" && s.type === "tool.result" && s.callId === e.callId || e.type === "run.stop" && s.type === "run.stop" && s.expectedUserMessageId === e.expectedUserMessageId)) ?? e;
8737
- return this.queuedClientEvents.includes(i) || this.queuedClientEvents.push(i), Cn(this.options.clientId, this.queuedClientEvents), this.pendingRetainedCommandDeliveries.has(i) || (this.pendingRetainedCommandDeliveries.add(i), n.sendRetainedCommand(rt(i)).then((s) => {
8765
+ return this.queuedClientEvents.includes(i) || this.queuedClientEvents.push(i), Cn(this.options.clientId, this.queuedClientEvents), this.pendingRetainedCommandDeliveries.has(i) || (this.pendingRetainedCommandDeliveries.add(i), n.sendRetainedCommand(at(i)).then((s) => {
8738
8766
  this.pendingRetainedCommandDeliveries.delete(i), s && (this.queuedClientEvents = this.queuedClientEvents.filter((o) => o !== i), Cn(this.options.clientId, this.queuedClientEvents));
8739
8767
  })), !0;
8740
8768
  }
@@ -8957,7 +8985,7 @@ class pa {
8957
8985
  this.transientStarterPromptsRequestInFlight = !0, this.transientStarterPromptsRequestAttempted = !0, this.setState({ starterPromptsLoading: !0 });
8958
8986
  const e = am();
8959
8987
  this.sendNow(
8960
- rt({
8988
+ at({
8961
8989
  type: "starter_prompts.page_context",
8962
8990
  pageUrl: e.pageUrl,
8963
8991
  pageTitle: e.pageTitle,
@@ -8987,7 +9015,7 @@ class pa {
8987
9015
  const e = [...this.queuedClientEvents];
8988
9016
  this.queuedClientEvents = this.queuedClientEvents.filter((n) => (n.type === "tool.result" || n.type === "run.stop") && this.socket instanceof Ae), Cn(this.options.clientId, this.queuedClientEvents);
8989
9017
  for (let n = 0; n < e.length; n++)
8990
- if (!this.sendNow(rt(e[n]))) {
9018
+ if (!this.sendNow(at(e[n]))) {
8991
9019
  this.queuedClientEvents.unshift(...e.slice(n).filter((i) => !this.queuedClientEvents.includes(i)));
8992
9020
  break;
8993
9021
  }
@@ -9208,8 +9236,8 @@ class pa {
9208
9236
  callId: i,
9209
9237
  toolName: s,
9210
9238
  summary: o,
9211
- rawInput: rt(a),
9212
- rawOutput: rt({
9239
+ rawInput: at(a),
9240
+ rawOutput: at({
9213
9241
  ok: !1,
9214
9242
  toolName: s,
9215
9243
  error: `Unsupported browser tool: ${s}`
@@ -9224,7 +9252,7 @@ class pa {
9224
9252
  callId: i,
9225
9253
  toolName: s,
9226
9254
  summary: o,
9227
- rawInput: rt(a),
9255
+ rawInput: at(a),
9228
9256
  rawOutput: {
9229
9257
  ok: !1,
9230
9258
  toolName: s,
@@ -9240,7 +9268,7 @@ class pa {
9240
9268
  callId: i,
9241
9269
  toolName: s,
9242
9270
  summary: o,
9243
- rawInput: rt(a),
9271
+ rawInput: at(a),
9244
9272
  rawOutput: null
9245
9273
  },
9246
9274
  startedAtMs: Date.now(),
@@ -9262,8 +9290,8 @@ class pa {
9262
9290
  callId: i,
9263
9291
  toolName: s,
9264
9292
  summary: a.summary,
9265
- rawInput: rt(a),
9266
- rawOutput: rt(_m(d, p))
9293
+ rawInput: at(a),
9294
+ rawOutput: at(_m(d, p))
9267
9295
  }), hl(this.options.clientId, this.activeBrowserToolCalls.values()));
9268
9296
  }
9269
9297
  startPageLifecycleRecovery() {
@@ -9324,7 +9352,7 @@ class pa {
9324
9352
  this.embeddedRecoveryTimer !== null && window.clearTimeout(this.embeddedRecoveryTimer), this.embeddedRecoveryTimer = null;
9325
9353
  }
9326
9354
  connectionFailureDiagnostic(e, n) {
9327
- const i = e instanceof Ze ? e.status : e instanceof T && e.code === "unauthorized" ? 401 : e instanceof T && /^[45][0-9]{2}$/.test(e.code) ? Number(e.code) : void 0, s = i !== void 0 && Number.isInteger(i) && i >= 400 && i <= 599 ? i : void 0, a = !(e instanceof T && ["unauthorized", "403", "update_required", "executor_replaced"].includes(e.code)) && er(e) && s !== 401 && s !== 403;
9355
+ const i = e instanceof et ? e.status : e instanceof T && e.code === "unauthorized" ? 401 : e instanceof T && /^[45][0-9]{2}$/.test(e.code) ? Number(e.code) : void 0, s = i !== void 0 && Number.isInteger(i) && i >= 400 && i <= 599 ? i : void 0, a = !(e instanceof T && ["unauthorized", "403", "update_required", "executor_replaced"].includes(e.code)) && er(e) && s !== 401 && s !== 403;
9328
9356
  return {
9329
9357
  stage: n,
9330
9358
  ...s !== void 0 ? { httpStatus: s } : {},
@@ -9430,13 +9458,13 @@ class pa {
9430
9458
  const c = await this.acquireToken("connect", { forceRefresh: !0 });
9431
9459
  if (this.socket !== e || this.state.status === "closed" || this.clientRuntime.isDisposed)
9432
9460
  throw new T("Conversation authority was retired.", "authority_retired", !0);
9433
- if (!c) throw new Ze("Pluno token provider did not return a token", !1);
9461
+ if (!c) throw new et("Pluno token provider did not return a token", !1);
9434
9462
  if (n && c === s) throw new T("Credential did not change.", "unauthorized", !1);
9435
9463
  this.directoryHttp.auth.token = c, a = "bootstrap", this.lastRecoveryStage = a, await this.replaceDefaultTransportCredentials(e), this.reportTransportDiagnostic("auth_refresh_validated", o);
9436
9464
  })().catch((c) => {
9437
9465
  if (this.socket !== e || this.state.status === "closed") throw c;
9438
9466
  if (this.reportTransportDiagnostic("auth_refresh_failed", { ...o, ...this.connectionFailureDiagnostic(c, a) }), this.credentialRecoveryFailure = Si(c), c instanceof T && ["unauthorized", "403", "update_required"].includes(c.code) || !er(c)) {
9439
- const l = c instanceof T ? c : new T(c instanceof Ze ? c.message : "Your session could not be refreshed. Try again.", this.options.productVariant === "customer_embedded" ? "connection_failed" : "unauthorized", !1);
9467
+ const l = c instanceof T ? c : new T(c instanceof et ? c.message : "Your session could not be refreshed. Try again.", this.options.productVariant === "customer_embedded" ? "connection_failed" : "unauthorized", !1);
9440
9468
  throw this.stopAuthentication(l), l;
9441
9469
  }
9442
9470
  throw this.options.productVariant === "customer_embedded" && this.setState({ status: "reconnecting", lastError: sl, lastErrorCode: "connection_failed" }), this.scheduleReconnect(), c;
@@ -9510,25 +9538,25 @@ function Ff() {
9510
9538
  });
9511
9539
  }, n = window.fetch, i = XMLHttpRequest.prototype.open, s = XMLHttpRequest.prototype.setRequestHeader, o = XMLHttpRequest.prototype.send, a = function(g, m) {
9512
9540
  const f = Date.now();
9513
- let w;
9541
+ let b;
9514
9542
  try {
9515
- w = n.call(this, g, m);
9516
- } catch (b) {
9517
- throw b;
9543
+ b = n.call(this, g, m);
9544
+ } catch (w) {
9545
+ throw w;
9518
9546
  }
9519
9547
  try {
9520
- const b = g instanceof Request ? g : null, _ = Fm(g, b), v = Yd(m?.headers ?? b?.headers);
9548
+ const w = g instanceof Request ? g : null, _ = Fm(g, w), v = Yd(m?.headers ?? w?.headers);
9521
9549
  if (!jn(_, v, m?.body)) {
9522
9550
  const L = {
9523
9551
  requestId: or("fetch"),
9524
9552
  url: Ht(_, Zo),
9525
- method: (m?.method ?? b?.method ?? "GET").toUpperCase(),
9553
+ method: (m?.method ?? w?.method ?? "GET").toUpperCase(),
9526
9554
  requestHeaders: v,
9527
9555
  requestBody: fl(m?.body),
9528
9556
  resourceType: "fetch",
9529
9557
  startedAt: new Date(f).toISOString()
9530
9558
  };
9531
- w.then(
9559
+ b.then(
9532
9560
  (K) => {
9533
9561
  jm(K, L, f, e).catch(() => {
9534
9562
  e({
@@ -9549,9 +9577,9 @@ function Ff() {
9549
9577
  }
9550
9578
  } catch {
9551
9579
  }
9552
- return w;
9553
- }, r = function(g, m, f, w, b) {
9554
- const _ = i.call(this, g, m, f ?? !0, w ?? void 0, b ?? void 0), v = typeof m == "string" ? m : m.toString();
9580
+ return b;
9581
+ }, r = function(g, m, f, b, w) {
9582
+ const _ = i.call(this, g, m, f ?? !0, b ?? void 0, w ?? void 0), v = typeof m == "string" ? m : m.toString();
9555
9583
  return nr.set(this, {
9556
9584
  requestId: or("xhr"),
9557
9585
  method: String(g ?? "GET").toUpperCase(),
@@ -9562,8 +9590,8 @@ function Ff() {
9562
9590
  excluded: jn(v)
9563
9591
  }), _;
9564
9592
  }, c = function(g, m) {
9565
- const f = s.call(this, g, m), w = nr.get(this);
9566
- return w && Object.keys(w.requestHeaders).length < ua && (w.requestHeaders[g] = fa(g, m), w.excluded = w.excluded || jn(w.url, w.requestHeaders)), f;
9593
+ const f = s.call(this, g, m), b = nr.get(this);
9594
+ return b && Object.keys(b.requestHeaders).length < ua && (b.requestHeaders[g] = fa(g, m), b.excluded = b.excluded || jn(b.url, b.requestHeaders)), f;
9567
9595
  }, l = function(g) {
9568
9596
  try {
9569
9597
  const m = nr.get(this);
@@ -9932,9 +9960,9 @@ function dm() {
9932
9960
  function ha() {
9933
9961
  if (!document.body)
9934
9962
  return "";
9935
- const t = [], e = [], n = (f, w) => {
9936
- const b = Yn(w);
9937
- !b || e.includes(b) || (t.push([f, b]), e.push(b));
9963
+ const t = [], e = [], n = (f, b) => {
9964
+ const w = Yn(b);
9965
+ !w || e.includes(w) || (t.push([f, w]), e.push(w));
9938
9966
  };
9939
9967
  n("Selected text", window.getSelection()?.toString() ?? "");
9940
9968
  const i = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", s = Array.from(document.querySelectorAll(i)).filter(
@@ -9944,8 +9972,8 @@ function ha() {
9944
9972
  n("Active overlay", ir(Mi(f), e));
9945
9973
  const o = um(), a = o ? ir(Mi(o), e) : "";
9946
9974
  n("Main page content", a), n("Additional visible page text", ir(Mi(document.body), e));
9947
- const r = t.map(([f, w]) => `${f}:
9948
- ${w}`).join(`
9975
+ const r = t.map(([f, b]) => `${f}:
9976
+ ${b}`).join(`
9949
9977
 
9950
9978
  `).trim().slice(0, 12e3), c = pm(s, o).trim(), l = `Simplified DOM outline:
9951
9979
  `, p = `
@@ -10062,12 +10090,12 @@ function pm(t, e) {
10062
10090
  e && h.add(e);
10063
10091
  let g = 0;
10064
10092
  const m = (v) => {
10065
- const E = v.getAttribute("role");
10066
- return E && !a.has(E) ? E : "";
10093
+ const k = v.getAttribute("role");
10094
+ return k && !a.has(k) ? k : "";
10067
10095
  }, f = (v) => {
10068
- const E = v.getAttribute("data-testid") || v.getAttribute("data-test") || v.getAttribute("data-qa") || v.getAttribute("data-cy") || "";
10069
- return `${v.tagName.toLowerCase()}|${m(v)}|${E}`;
10070
- }, w = (v, E, L) => {
10096
+ const k = v.getAttribute("data-testid") || v.getAttribute("data-test") || v.getAttribute("data-qa") || v.getAttribute("data-cy") || "";
10097
+ return `${v.tagName.toLowerCase()}|${m(v)}|${k}`;
10098
+ }, b = (v, k, L) => {
10071
10099
  const K = (U, he) => {
10072
10100
  const G = U.tagName.toLowerCase(), oe = window.getComputedStyle(U), R = p.has(U);
10073
10101
  if (g >= 1e3 && !R || L.has(U) || o.has(G) || U.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || oe.display === "none" || oe.visibility === "hidden")
@@ -10093,20 +10121,20 @@ function pm(t, e) {
10093
10121
  const ke = K(W, he);
10094
10122
  Oe.push(ke), fe.push(ke.lines);
10095
10123
  }
10096
- const et = [];
10124
+ const tt = [];
10097
10125
  if (U.shadowRoot)
10098
10126
  for (const W of Array.from(U.shadowRoot.children))
10099
- W instanceof HTMLElement && et.push(K(W, he + 1));
10100
- const Ce = [...Oe, ...et], $e = O.length > 0 || S || Ce.some((W) => W.hasUsefulContent), J = Yn(
10127
+ W instanceof HTMLElement && tt.push(K(W, he + 1));
10128
+ const Ce = [...Oe, ...tt], $e = O.length > 0 || S || Ce.some((W) => W.hasUsefulContent), J = Yn(
10101
10129
  [O, ...Ce.map((W) => W.textPreview)].filter(Boolean).join(" ")
10102
- ).slice(0, 180), tt = U.hasAttribute("contenteditable") && (O.length > 0 || !U.querySelector("[contenteditable]")), z = l.some((W) => U.hasAttribute(W)) || !!V || tt, Y = (U.getClientRects().length > 0 || oe.display === "contents") && (n.has(G) || z || R) && ($e || R) && (!s.has(G) || $e || z || R), H = Y ? 1 : 0, ie = [];
10130
+ ).slice(0, 180), nt = U.hasAttribute("contenteditable") && (O.length > 0 || !U.querySelector("[contenteditable]")), z = l.some((W) => U.hasAttribute(W)) || !!V || nt, Y = (U.getClientRects().length > 0 || oe.display === "contents") && (n.has(G) || z || R) && ($e || R) && (!s.has(G) || $e || z || R), H = Y ? 1 : 0, ie = [];
10103
10131
  if (Y) {
10104
10132
  const W = Ce.some((le) => le.containsTextElement), q = i.has(G) && !W ? J : O;
10105
10133
  ie.push($d(U, c, a, q.slice(0, 180)));
10106
10134
  }
10107
10135
  for (const W of fe)
10108
10136
  ie.push(...us(W, H));
10109
- const ve = et.flatMap((W) => W.lines);
10137
+ const ve = tt.flatMap((W) => W.lines);
10110
10138
  if (ve.length > 0) {
10111
10139
  const W = ve.slice(0, 20);
10112
10140
  ve.length > W.length && W.push("… shadow DOM omitted");
@@ -10124,18 +10152,18 @@ function pm(t, e) {
10124
10152
  containsTextElement: i.has(G) || Ce.some((W) => W.containsTextElement)
10125
10153
  };
10126
10154
  };
10127
- return [`--- ${E} ---`, ...K(v, 0).lines].join(`
10155
+ return [`--- ${k} ---`, ...K(v, 0).lines].join(`
10128
10156
  `);
10129
- }, b = [], _ = Yn(window.getSelection()?.toString() ?? "");
10130
- _ && b.push(`--- selected text ---
10131
- ${JSON.stringify(_)}`), d.length > 0 && b.push(gm(d, n, c, a));
10157
+ }, w = [], _ = Yn(window.getSelection()?.toString() ?? "");
10158
+ _ && w.push(`--- selected text ---
10159
+ ${JSON.stringify(_)}`), d.length > 0 && w.push(gm(d, n, c, a));
10132
10160
  for (const v of t.slice(0, 3))
10133
- b.push(w(v, "active overlay DOM", /* @__PURE__ */ new Set()));
10134
- if (e && b.push(w(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
10161
+ w.push(b(v, "active overlay DOM", /* @__PURE__ */ new Set()));
10162
+ if (e && w.push(b(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
10135
10163
  const v = e || t.length ? "other visible DOM" : "visible DOM";
10136
- b.push(w(document.body, v, h));
10164
+ w.push(b(document.body, v, h));
10137
10165
  }
10138
- return b.join(`
10166
+ return w.join(`
10139
10167
 
10140
10168
  `);
10141
10169
  }
@@ -10377,7 +10405,7 @@ function Sm(t, e) {
10377
10405
  ),
10378
10406
  createdAt: typeof n.createdAt == "string" ? n.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
10379
10407
  ...ze(s) !== null ? { displaySequence: ze(s) } : {},
10380
- ...ot(s) !== null ? { causalSequence: ot(s) } : {},
10408
+ ...rt(s) !== null ? { causalSequence: rt(s) } : {},
10381
10409
  respondsToUserMessageId: rn(s) ?? void 0,
10382
10410
  ...Be(s) ? { runId: Be(s) } : {},
10383
10411
  dataType: "assistant_draft",
@@ -10394,7 +10422,7 @@ function Sm(t, e) {
10394
10422
  ),
10395
10423
  createdAt: typeof n.createdAt == "string" ? n.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
10396
10424
  ...ze(s) !== null ? { displaySequence: ze(s) } : {},
10397
- ...ot(s) !== null ? { causalSequence: ot(s) } : {},
10425
+ ...rt(s) !== null ? { causalSequence: rt(s) } : {},
10398
10426
  respondsToUserMessageId: rn(s) ?? void 0,
10399
10427
  ...Be(s) ? { runId: Be(s) } : {},
10400
10428
  attachments: Hd(s.attachments, e),
@@ -10450,7 +10478,7 @@ function Sm(t, e) {
10450
10478
  content: `Connect ${r.appName} to continue`,
10451
10479
  createdAt: typeof n.createdAt == "string" ? n.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
10452
10480
  ...ze(s) !== null ? { displaySequence: ze(s) } : {},
10453
- ...ot(s) !== null ? { causalSequence: ot(s) } : {},
10481
+ ...rt(s) !== null ? { causalSequence: rt(s) } : {},
10454
10482
  respondsToUserMessageId: rn(s) ?? void 0,
10455
10483
  ...Be(s) ? { runId: Be(s) } : {},
10456
10484
  dataType: "function_call_output",
@@ -10463,7 +10491,7 @@ function Sm(t, e) {
10463
10491
  content: "Connect WhatsApp to continue",
10464
10492
  createdAt: typeof n.createdAt == "string" ? n.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
10465
10493
  ...ze(s) !== null ? { displaySequence: ze(s) } : {},
10466
- ...ot(s) !== null ? { causalSequence: ot(s) } : {},
10494
+ ...rt(s) !== null ? { causalSequence: rt(s) } : {},
10467
10495
  respondsToUserMessageId: rn(s) ?? void 0,
10468
10496
  ...Be(s) ? { runId: Be(s) } : {},
10469
10497
  dataType: "function_call_output",
@@ -10478,7 +10506,7 @@ function Sm(t, e) {
10478
10506
  content: s.type === "mcp_call" ? xm(s) : Am(s),
10479
10507
  createdAt: typeof n.createdAt == "string" ? n.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
10480
10508
  ...ze(s) !== null ? { displaySequence: ze(s) } : {},
10481
- ...ot(s) !== null ? { causalSequence: ot(s) } : {},
10509
+ ...rt(s) !== null ? { causalSequence: rt(s) } : {},
10482
10510
  respondsToUserMessageId: rn(s) ?? void 0,
10483
10511
  ...Be(s) ? { runId: Be(s) } : {},
10484
10512
  dataType: String(s.type),
@@ -10492,7 +10520,7 @@ function Sm(t, e) {
10492
10520
  content: Cm(s),
10493
10521
  createdAt: typeof n.createdAt == "string" ? n.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
10494
10522
  ...ze(s) !== null ? { displaySequence: ze(s) } : {},
10495
- ...ot(s) !== null ? { causalSequence: ot(s) } : {},
10523
+ ...rt(s) !== null ? { causalSequence: rt(s) } : {},
10496
10524
  respondsToUserMessageId: rn(s) ?? void 0,
10497
10525
  ...Be(s) ? { runId: Be(s) } : {},
10498
10526
  dataType: String(s.type),
@@ -10576,7 +10604,7 @@ function xi(t) {
10576
10604
  const e = t.callId ?? t.call_id;
10577
10605
  return typeof e == "string" && e ? e : null;
10578
10606
  }
10579
- function ot(t) {
10607
+ function rt(t) {
10580
10608
  return typeof t.causalSequence == "number" && Number.isSafeInteger(t.causalSequence) ? t.causalSequence : null;
10581
10609
  }
10582
10610
  function ze(t) {
@@ -10886,7 +10914,7 @@ function fl(t) {
10886
10914
  return Ht(t);
10887
10915
  }
10888
10916
  function Wm(t) {
10889
- return rt({
10917
+ return at({
10890
10918
  ...t,
10891
10919
  requestBody: ml(t.requestBody),
10892
10920
  responseBody: ml(t.responseBody)
@@ -10899,7 +10927,7 @@ function ml(t) {
10899
10927
  if (!e.startsWith("{") && !e.startsWith("["))
10900
10928
  return Ps(t);
10901
10929
  try {
10902
- return JSON.stringify(rt(JSON.parse(t)));
10930
+ return JSON.stringify(at(JSON.parse(t)));
10903
10931
  } catch {
10904
10932
  return Ps(t);
10905
10933
  }
@@ -10992,7 +11020,7 @@ function ey(t) {
10992
11020
  return t === 401 || t === 403;
10993
11021
  }
10994
11022
  const Vs = "[REDACTED_SECRET]", Wt = "[REDACTED_TOKEN]", ty = "[REDACTED_SIGNED_URL]", ny = 20, iy = /^(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|token|api_key|apiKey|apikey|key|secret|signature|sig|password|passwd|pwd|code|state|session|jwt|csrf|csrfToken|xsrf|xsrfToken)$/i, Zd = /\bBearer\s+[A-Za-z0-9._~+/=-]{12,}/gi, eu = /\bBasic\s+[A-Za-z0-9+/=-]{12,}/gi, tu = /\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g, nu = /\b(access_token|accessToken|refresh_token|refreshToken|id_token|idToken|authToken|api_key|apiKey|apikey|client_secret|clientSecret|password|secret|token|jwt|csrf|csrfToken|xsrf|xsrfToken)\b\s*[:=]\s*["']?[^"',&\s}]+/gi, sy = /\bhttps?:\/\/[^\s"'<>]+(?:X-Amz-Signature|X-Goog-Signature|Signature|sig=)[^\s"'<>]*/gi, oy = /\bhttps?:\/\/[^\s"'<>]+/gi, ry = /[),.;\]]+$/;
10995
- function rt(t) {
11023
+ function at(t) {
10996
11024
  return Ts(t, 0, /* @__PURE__ */ new WeakSet());
10997
11025
  }
10998
11026
  function Ts(t, e, n) {
@@ -11104,16 +11132,16 @@ function fy(t) {
11104
11132
  inner: "#4b4b4b",
11105
11133
  shadow: "#000000"
11106
11134
  } : {
11107
- top: At(e, 0.28, -0.03),
11108
- middle: At(e, 0.08, 0.04),
11109
- bottom: At(e, -0.1, 0.02),
11110
- edgeStart: At(e, 0.08, 0.08),
11111
- edgeMiddle: At(e, -0.08, 0.08),
11112
- edgeEnd: At(e, -0.18, 0.05),
11113
- glow: At(e, 0.32, -0.12),
11114
- highlight: At(e, 0.38, -0.18),
11115
- inner: At(e, 0.24, -0.1),
11116
- shadow: At(e, -0.25, -0.08)
11135
+ top: Rt(e, 0.28, -0.03),
11136
+ middle: Rt(e, 0.08, 0.04),
11137
+ bottom: Rt(e, -0.1, 0.02),
11138
+ edgeStart: Rt(e, 0.08, 0.08),
11139
+ edgeMiddle: Rt(e, -0.08, 0.08),
11140
+ edgeEnd: Rt(e, -0.18, 0.05),
11141
+ glow: Rt(e, 0.32, -0.12),
11142
+ highlight: Rt(e, 0.38, -0.18),
11143
+ inner: Rt(e, 0.24, -0.1),
11144
+ shadow: Rt(e, -0.25, -0.08)
11117
11145
  };
11118
11146
  }
11119
11147
  function au(t) {
@@ -11150,7 +11178,7 @@ function my(t, e, n) {
11150
11178
  t[2] + (e[2] - t[2]) * i
11151
11179
  ];
11152
11180
  }
11153
- function At(t, e, n) {
11181
+ function Rt(t, e, n) {
11154
11182
  const [i, s, o] = yy(qi(t));
11155
11183
  return Br(wy(i, Fr(s + n), Fr(o + e)));
11156
11184
  }
@@ -11273,9 +11301,9 @@ function Ty(t, e, n, i) {
11273
11301
  const s = /* @__PURE__ */ new Map(), o = [], a = [];
11274
11302
  let r = 0, c = 0, l = 0, p = crypto.randomUUID(), d = i.getState();
11275
11303
  e.dataset.executionKey = d.activity?.executionKey ?? "";
11276
- let h = d.user?.id, g = null, m = "", f = "", w = "";
11277
- const b = e.ownerDocument.defaultView;
11278
- let _, v = /* @__PURE__ */ new Map(), E = d.sessionId;
11304
+ let h = d.user?.id, g = null, m = "", f = "", b = "";
11305
+ const w = e.ownerDocument.defaultView;
11306
+ let _, v = /* @__PURE__ */ new Map(), k = d.sessionId;
11279
11307
  const L = /* @__PURE__ */ new Set(), K = /* @__PURE__ */ new Map();
11280
11308
  let U = null, he = null, G = null, oe = 0, R = null, V = null, O = null;
11281
11309
  const S = () => JSON.stringify([
@@ -11284,24 +11312,24 @@ function Ty(t, e, n, i) {
11284
11312
  Array.from(e.querySelectorAll('[data-message-role="user"]')).slice(-1)[0]?.dataset.messageKey,
11285
11313
  Array.from(e.querySelectorAll('[data-message-role="user"]')).slice(-1)[0]?.dataset.entryKey
11286
11314
  ]), F = (z) => {
11287
- const Y = b.getComputedStyle(z);
11315
+ const Y = w.getComputedStyle(z);
11288
11316
  return z.getClientRects().length > 0 && Y.visibility !== "hidden" && Y.opacity !== "0" && Y.pointerEvents !== "none" && !z.matches(":disabled") && z.getAttribute("aria-disabled") !== "true" && !z.closest("[inert]");
11289
11317
  };
11290
11318
  function ee() {
11291
- he !== null && b.clearTimeout(he), he = null, G = null;
11319
+ he !== null && w.clearTimeout(he), he = null, G = null;
11292
11320
  }
11293
11321
  function ce(z = !1) {
11294
- ee(), V = null, O !== null && b.clearTimeout(O), O = null, _ = void 0, v.clear(), K.clear(), U !== null && b.clearTimeout(U), U = null, z && L.clear();
11322
+ ee(), V = null, O !== null && w.clearTimeout(O), O = null, _ = void 0, v.clear(), K.clear(), U !== null && w.clearTimeout(U), U = null, z && L.clear();
11295
11323
  }
11296
11324
  function te() {
11297
- const z = e.querySelector(".pluno-pa-widget__panel") ?? e, Y = b.getComputedStyle(z);
11325
+ const z = e.querySelector(".pluno-pa-widget__panel") ?? e, Y = w.getComputedStyle(z);
11298
11326
  if (d.isLoadingSession || e.ownerDocument.hidden || !z.getClientRects().length || Y.visibility === "hidden" || Y.display === "none" || Y.opacity === "0") {
11299
11327
  ce();
11300
11328
  return;
11301
11329
  }
11302
11330
  const H = (M, Q) => Array.from(e.querySelectorAll(M)).flatMap((de) => de.getAttribute(Q) ? [de.getAttribute(Q)] : []), ie = ".pluno-pa-widget__tool-group--active, .tool-group--active, .pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]", ve = [];
11303
11331
  for (const M of Array.from(e.querySelectorAll(`${ie}, [data-message-role="user"]`))) {
11304
- const Q = b.getComputedStyle(M);
11332
+ const Q = w.getComputedStyle(M);
11305
11333
  !M.getClientRects().length || Q.visibility === "hidden" || Q.opacity === "0" || M.parentElement?.closest(ie) || ve.push(M.dataset.messageRole === "user" ? "user" : "thinking");
11306
11334
  }
11307
11335
  let W = 0;
@@ -11317,11 +11345,11 @@ function Ty(t, e, n, i) {
11317
11345
  for (let X = 0; X < Le.length; X += 1)
11318
11346
  C = Math.imul(C ^ Le.charCodeAt(X), 16777619) >>> 0;
11319
11347
  }
11320
- const k = b.performance.now();
11321
- C !== G && (G = C, oe = k), W = k - oe, he !== null && b.clearTimeout(he), he = W < 3e5 ? b.setTimeout(te, 3e5 - W) : null;
11348
+ const E = w.performance.now();
11349
+ C !== G && (G = C, oe = E), W = E - oe, he !== null && w.clearTimeout(he), he = W < 3e5 ? w.setTimeout(te, 3e5 - W) : null;
11322
11350
  } else
11323
11351
  ee(), L.delete("thinking-without-progress");
11324
- const q = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((M) => M.getClientRects().length > 0 && b.getComputedStyle(M).visibility !== "hidden" && b.getComputedStyle(M).opacity !== "0"), le = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || q;
11352
+ const q = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((M) => M.getClientRects().length > 0 && w.getComputedStyle(M).visibility !== "hidden" && w.getComputedStyle(M).opacity !== "0"), le = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || q;
11325
11353
  (!le || V && V.responseKey !== S()) && (V = null);
11326
11354
  const me = {
11327
11355
  executionKey: d.activity?.executionKey,
@@ -11331,7 +11359,7 @@ function Ty(t, e, n, i) {
11331
11359
  enabledStopControlCount: Array.from(e.querySelectorAll(
11332
11360
  'button[aria-label="Stop"], button[aria-label="Stop generating"]'
11333
11361
  )).filter(F).length,
11334
- stopPendingMs: V ? b.performance.now() - V.at : 0,
11362
+ stopPendingMs: V ? w.performance.now() - V.at : 0,
11335
11363
  thinkingSequence: ve,
11336
11364
  thinkingIdleMs: W,
11337
11365
  messageKeys: Array.from(e.querySelectorAll("[data-message-key], [data-entry-key][data-message-role]")).flatMap((M) => M.dataset.messageKey ?? M.dataset.entryKey ?? []),
@@ -11354,13 +11382,13 @@ function Ty(t, e, n, i) {
11354
11382
  })
11355
11383
  } : void 0, Fe = gf(me, ke), ht = new Set(Fe.map((M) => M.code));
11356
11384
  for (const M of K.keys()) ht.has(M) || K.delete(M);
11357
- const je = b.performance.now();
11385
+ const je = w.performance.now();
11358
11386
  for (const { code: M } of Fe) {
11359
11387
  if (L.has(M)) continue;
11360
11388
  const Q = K.get(M) ?? je;
11361
11389
  je - Q >= 250 ? (L.add(M), K.delete(M), i.reportInvalidStateTransition?.(`ui_invariant:${M}`, void 0, dp(me, _))) : K.set(M, Q);
11362
11390
  }
11363
- Fe.length === 0 && (_ = me, v = new Map(Array.from(e.querySelectorAll("[data-terminal-response-key][data-canonical-item-key]")).map((M) => [M.dataset.terminalResponseKey, M.dataset.canonicalItemKey]))), U !== null && b.clearTimeout(U), U = K.size ? b.setTimeout(() => {
11391
+ Fe.length === 0 && (_ = me, v = new Map(Array.from(e.querySelectorAll("[data-terminal-response-key][data-canonical-item-key]")).map((M) => [M.dataset.terminalResponseKey, M.dataset.canonicalItemKey]))), U !== null && w.clearTimeout(U), U = K.size ? w.setTimeout(() => {
11364
11392
  U = null, te();
11365
11393
  }, Math.max(1, 250 - (je - Math.min(...K.values())))) : null;
11366
11394
  }
@@ -11388,9 +11416,9 @@ function Ty(t, e, n, i) {
11388
11416
  };
11389
11417
  if (z === "paint" && i.reportResponseVisibility) {
11390
11418
  const M = e.querySelector(".pluno-pa-widget__panel") ?? e, Q = (B) => {
11391
- const Z = b.getComputedStyle(B);
11419
+ const Z = w.getComputedStyle(B);
11392
11420
  return B.getClientRects().length > 0 && Z.visibility !== "hidden" && Z.display !== "none" && Z.opacity !== "0";
11393
- }, de = Q(M) && Q(e), C = !e.ownerDocument.hidden, k = new Set(Array.from(e.querySelectorAll("[data-canonical-item-key]")).filter(Q).map((B) => B.dataset.canonicalItemKey)), N = de && C && !d.isLoadingSession ? [...d.messages].reverse().find((B) => (B.role === "assistant" || B.dataType === "commentary_history" || B.dataType === "tool_summary") && k.has(B.id)) : void 0, ye = de && C && !d.isLoadingSession && !!d.assistantDraft.trim() && Array.from(e.querySelectorAll("[data-message-key], [data-entry-key]")).some((B) => Q(B) && (B.dataset.messageKey === `assistant:${d.assistantDraftItemId}` || B.dataset.entryKey === d.assistantDraftItemId)), Le = {
11421
+ }, de = Q(M) && Q(e), C = !e.ownerDocument.hidden, E = new Set(Array.from(e.querySelectorAll("[data-canonical-item-key]")).filter(Q).map((B) => B.dataset.canonicalItemKey)), N = de && C && !d.isLoadingSession ? [...d.messages].reverse().find((B) => (B.role === "assistant" || B.dataType === "commentary_history" || B.dataType === "tool_summary") && E.has(B.id)) : void 0, ye = de && C && !d.isLoadingSession && !!d.assistantDraft.trim() && Array.from(e.querySelectorAll("[data-message-key], [data-entry-key]")).some((B) => Q(B) && (B.dataset.messageKey === `assistant:${d.assistantDraftItemId}` || B.dataset.entryKey === d.assistantDraftItemId)), Le = {
11394
11422
  sessionId: d.sessionId,
11395
11423
  responseItemId: ye ? d.assistantDraftItemId : N?.id ?? null,
11396
11424
  respondsToUserMessageId: ye ? d.assistantDraftRespondsToUserMessageId : N?.respondsToUserMessageId ?? null,
@@ -11398,12 +11426,12 @@ function Ty(t, e, n, i) {
11398
11426
  documentVisible: C,
11399
11427
  loading: d.isLoadingSession
11400
11428
  }, X = JSON.stringify(Le);
11401
- X !== w && (w = X, i.reportResponseVisibility({ ...Le, observedAt: (/* @__PURE__ */ new Date()).toISOString() }));
11429
+ X !== b && (b = X, i.reportResponseVisibility({ ...Le, observedAt: (/* @__PURE__ */ new Date()).toISOString() }));
11402
11430
  }
11403
11431
  const le = [...d.messages].reverse().find((M) => M.role === "user" && (!d.activeResponseUserMessageId || M.id === d.activeResponseUserMessageId)), me = d.activity?.phase === "submitting" || d.turnPhase === "sending" || d.pendingMessageStatus === "sending", ke = d.activity?.phase === "stopping";
11404
11432
  if (le && i.reportOperationTiming) {
11405
11433
  const M = ke || d.activity?.phase === "stopped" ? "stop" : "send", Q = `${M}:${le.id}`;
11406
- (me || ke) && !s.has(Q) && (s.set(Q, { timer: Rt((k) => i.reportOperationTiming?.(k), {
11434
+ (me || ke) && !s.has(Q) && (s.set(Q, { timer: St((E) => i.reportOperationTiming?.(E), {
11407
11435
  operation: M,
11408
11436
  layer: "renderer",
11409
11437
  entrySurface: n,
@@ -11411,8 +11439,8 @@ function Ty(t, e, n, i) {
11411
11439
  clientMessageId: le.id,
11412
11440
  sessionId: d.sessionId
11413
11441
  }), seen: /* @__PURE__ */ new Set() }), s.size > 20 && s.delete(s.keys().next().value));
11414
- const de = s.get(Q), C = (k) => {
11415
- !de || de.seen.has(k) || (de.seen.add(k), de.timer.mark(k));
11442
+ const de = s.get(Q), C = (E) => {
11443
+ !de || de.seen.has(E) || (de.seen.add(E), de.timer.mark(E));
11416
11444
  };
11417
11445
  if (z === "runtime" && C(ke ? "runtime_stopping" : d.activity?.phase === "stopped" ? "runtime_stopped" : me ? "runtime_reading" : "runtime_progress"), z === "paint" && !e.ownerDocument.hidden && q.visible && !q.loading && Array.from(e.querySelectorAll('[data-message-role="user"]')).some((N) => (N.dataset.canonicalItemKey === le.id || N.dataset.entryKey === le.id || N.dataset.messageKey === `user:${le.id}`) && N.getClientRects().length > 0)) {
11418
11446
  C("message_painted");
@@ -11426,7 +11454,7 @@ function Ty(t, e, n, i) {
11426
11454
  const ht = {
11427
11455
  sequence: ++l,
11428
11456
  occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
11429
- monotonic_ms: Math.round(b.performance.now()),
11457
+ monotonic_ms: Math.round(w.performance.now()),
11430
11458
  kind: z,
11431
11459
  action: Y,
11432
11460
  ...q
@@ -11435,12 +11463,12 @@ function Ty(t, e, n, i) {
11435
11463
  o.shift(), r -= a.shift(), c += 1;
11436
11464
  }
11437
11465
  function P() {
11438
- g === null && (g = b.requestAnimationFrame(() => {
11466
+ g === null && (g = w.requestAnimationFrame(() => {
11439
11467
  g = null, Se("paint"), te();
11440
11468
  }));
11441
11469
  }
11442
11470
  const fe = i.on("state", (z) => {
11443
- z.user?.id !== h || z.sessionId !== E ? (ce(!0), E = z.sessionId) : z.isLoadingSession && ce(), z.user?.id !== h && (s.clear(), o.length = 0, a.length = 0, r = 0, c = 0, l = 0, p = crypto.randomUUID(), m = "", f = "", w = "", h = z.user?.id), d = z, e.dataset.executionKey = d.activity?.executionKey ?? "", Se("runtime"), P();
11471
+ z.user?.id !== h || z.sessionId !== k ? (ce(!0), k = z.sessionId) : z.isLoadingSession && ce(), z.user?.id !== h && (s.clear(), o.length = 0, a.length = 0, r = 0, c = 0, l = 0, p = crypto.randomUUID(), m = "", f = "", b = "", h = z.user?.id), d = z, e.dataset.executionKey = d.activity?.executionKey ?? "", Se("runtime"), P();
11444
11472
  }), Oe = new MutationObserver(P);
11445
11473
  Oe.observe(e, {
11446
11474
  subtree: !0,
@@ -11449,16 +11477,16 @@ function Ty(t, e, n, i) {
11449
11477
  attributes: !0,
11450
11478
  attributeFilter: ["disabled", "aria-disabled", "aria-label", "inert", "class", "style", "hidden", "data-loading-text", "data-message-key", "data-entry-key", "data-terminal-response-key", "data-active-response-key", "data-canonical-item-key", "data-tool-call-key", "data-attachment-key", "data-session-id", "data-response-group-key"]
11451
11479
  });
11452
- const et = (z) => {
11480
+ const tt = (z) => {
11453
11481
  const Y = z.target?.closest?.("button"), H = Y?.getAttribute("aria-label") ?? Y?.getAttribute("title"), ie = H === "New chat" ? "new_chat" : H === "Send" || H === "Send message" ? "send" : H === "Stop" || H === "Stop generating" ? "stop" : H === "Retry" || H === "Retry message" ? "retry" : null;
11454
- Se("click", ie), ie === "stop" && Y && F(Y) && (V = { at: b.performance.now(), responseKey: S() }, O !== null && b.clearTimeout(O), O = b.setTimeout(te, 1e3)), ie === "new_chat" && ce(!0);
11482
+ Se("click", ie), ie === "stop" && Y && F(Y) && (V = { at: w.performance.now(), responseKey: S() }, O !== null && w.clearTimeout(O), O = w.setTimeout(te, 1e3)), ie === "new_chat" && ce(!0);
11455
11483
  }, Ce = () => Se("submit"), $e = () => Se("focus");
11456
- e.addEventListener("click", et, !0), e.addEventListener("submit", Ce, !0), e.addEventListener("focusin", $e, !0), e.addEventListener("input", P, !0);
11484
+ e.addEventListener("click", tt, !0), e.addEventListener("submit", Ce, !0), e.addEventListener("focusin", $e, !0), e.addEventListener("input", P, !0);
11457
11485
  const J = () => {
11458
11486
  Se("paint"), P();
11459
11487
  };
11460
11488
  e.ownerDocument.addEventListener("visibilitychange", J);
11461
- const tt = {
11489
+ const nt = {
11462
11490
  snapshot: () => ({
11463
11491
  schema_version: 1,
11464
11492
  surface: n,
@@ -11468,10 +11496,10 @@ function Ty(t, e, n, i) {
11468
11496
  records: o.map((z) => ({ ...z, item_keys: [...z.item_keys] }))
11469
11497
  }),
11470
11498
  dispose: () => {
11471
- fe(), Oe.disconnect(), ce(!0), g !== null && b.cancelAnimationFrame(g), e.removeEventListener("click", et, !0), e.removeEventListener("submit", Ce, !0), e.removeEventListener("focusin", $e, !0), e.removeEventListener("input", P, !0), e.ownerDocument.removeEventListener("visibilitychange", J), t.__plunoUiFlightRecorder === tt && delete t.__plunoUiFlightRecorder;
11499
+ fe(), Oe.disconnect(), ce(!0), g !== null && w.cancelAnimationFrame(g), e.removeEventListener("click", tt, !0), e.removeEventListener("submit", Ce, !0), e.removeEventListener("focusin", $e, !0), e.removeEventListener("input", P, !0), e.ownerDocument.removeEventListener("visibilitychange", J), t.__plunoUiFlightRecorder === nt && delete t.__plunoUiFlightRecorder;
11472
11500
  }
11473
11501
  };
11474
- return t.__plunoUiFlightRecorder = tt, Se("runtime"), P(), tt;
11502
+ return t.__plunoUiFlightRecorder = nt, Se("runtime"), P(), nt;
11475
11503
  }
11476
11504
  const Py = 6e4, My = [100, 500, 1500, 4e3];
11477
11505
  let qy = 0;
@@ -11651,11 +11679,11 @@ async function lw(t = {}) {
11651
11679
  fontFamily: e.fontFamily,
11652
11680
  scribbleStyle: e.scribbleStyle
11653
11681
  });
11654
- const w = e.mountTarget ?? await Ub(), b = w.ownerDocument, _ = r.querySelector(
11682
+ const b = e.mountTarget ?? await Ub(), w = b.ownerDocument, _ = r.querySelector(
11655
11683
  ".pluno-pa-widget__launcher"
11656
11684
  ), v = r.querySelector(
11657
11685
  ".pluno-pa-widget__launcher-drag-handle"
11658
- ), E = r.querySelector(
11686
+ ), k = r.querySelector(
11659
11687
  ".pluno-pa-widget__launcher-input"
11660
11688
  ), L = r.querySelector(
11661
11689
  ".pluno-pa-widget__status--launcher"
@@ -11687,7 +11715,7 @@ async function lw(t = {}) {
11687
11715
  ".pluno-pa-widget__model-picker"
11688
11716
  ), Oe = r.querySelector(
11689
11717
  ".pluno-pa-widget__model-trigger span"
11690
- ), et = Array.from(
11718
+ ), tt = Array.from(
11691
11719
  r.querySelectorAll(".pluno-pa-widget__model-option")
11692
11720
  ), Ce = r.querySelector(
11693
11721
  ".pluno-pa-widget__send"
@@ -11695,7 +11723,7 @@ async function lw(t = {}) {
11695
11723
  ".pluno-pa-widget__top-actions"
11696
11724
  ), J = r.querySelector(
11697
11725
  ".pluno-pa-widget__history"
11698
- ), tt = r.querySelector(
11726
+ ), nt = r.querySelector(
11699
11727
  ".pluno-pa-widget__history-panel"
11700
11728
  ), z = r.querySelector(
11701
11729
  ".pluno-pa-widget__history-list"
@@ -11729,7 +11757,7 @@ async function lw(t = {}) {
11729
11757
  ".pluno-pa-widget__tab-groups-suggestion-enable"
11730
11758
  ), C = r.querySelector(
11731
11759
  ".pluno-pa-widget__tab-groups-suggestion-dismiss"
11732
- ), k = r.querySelector(
11760
+ ), E = r.querySelector(
11733
11761
  ".pluno-pa-widget__proactive-suggestion"
11734
11762
  ), N = r.querySelector(
11735
11763
  ".pluno-pa-widget__proactive-suggestion-query"
@@ -11754,7 +11782,7 @@ async function lw(t = {}) {
11754
11782
  ), zi = r.querySelector(
11755
11783
  ".pluno-pa-widget__proactive-suggestion-feedback-status"
11756
11784
  );
11757
- if (!_ || !E || !U || !R || !V || !O || !S || !ce || !te || !Se || !P || !fe || !Oe || !Ce || !$e || !J || !tt || !z || !Y || !H || !ie || !ve || !W || !q || !le)
11785
+ if (!_ || !k || !U || !R || !V || !O || !S || !ce || !te || !Se || !P || !fe || !Oe || !Ce || !$e || !J || !nt || !z || !Y || !H || !ie || !ve || !W || !q || !le)
11758
11786
  throw new Error("Failed to mount Pluno widget");
11759
11787
  if (e.movableLauncher && !v)
11760
11788
  throw new Error("Failed to mount Pluno widget drag handle");
@@ -11762,7 +11790,7 @@ async function lw(t = {}) {
11762
11790
  throw new Error("Failed to mount Pluno widget panel drag handle");
11763
11791
  let Xs = !1, Vt = null, gn = !1, Nn = null, He = "idle";
11764
11792
  const Bi = () => {
11765
- if (!(k !== null && !k.hidden && !r.classList.contains("pluno-pa-widget--proactive-suggestion-in-panel") && e.layout === "floating")) {
11793
+ if (!(E !== null && !E.hidden && !r.classList.contains("pluno-pa-widget--proactive-suggestion-in-panel") && e.layout === "floating")) {
11766
11794
  r.classList.remove("pluno-pa-widget--proactive-suggestion-below");
11767
11795
  return;
11768
11796
  }
@@ -11770,16 +11798,16 @@ async function lw(t = {}) {
11770
11798
  "pluno-pa-widget--proactive-suggestion-below",
11771
11799
  _w(
11772
11800
  _.getBoundingClientRect(),
11773
- k.getBoundingClientRect().height
11801
+ E.getBoundingClientRect().height
11774
11802
  )
11775
11803
  );
11776
11804
  }, gt = () => {
11777
- if (!k || !N || !ae || !hn || !we || !Qn || !zi)
11805
+ if (!E || !N || !ae || !hn || !we || !Qn || !zi)
11778
11806
  return;
11779
11807
  const u = e.proactiveSuggestion ?? Vt, y = u !== null && !A.getState().isThinking, I = U.querySelector(
11780
11808
  ".pluno-pa-widget__proactive-suggestion-slot"
11781
11809
  ), x = !U.hidden && !r.classList.contains("pluno-pa-widget--closing"), D = y && x && I !== null;
11782
- D ? k.parentElement !== I && I.appendChild(k) : k.parentElement !== r && r.insertBefore(k, R), k.hidden = !y, r.classList.toggle("pluno-pa-widget--proactive-suggestion", y), r.classList.toggle(
11810
+ D ? E.parentElement !== I && I.appendChild(E) : E.parentElement !== r && r.insertBefore(E, R), E.hidden = !y, r.classList.toggle("pluno-pa-widget--proactive-suggestion", y), r.classList.toggle(
11783
11811
  "pluno-pa-widget--proactive-suggestion-in-panel",
11784
11812
  D
11785
11813
  ), N.textContent = u?.question ?? "", ae.hidden = e.proactiveSuggestion === null || gn, hn.hidden = Vt === null;
@@ -11807,19 +11835,19 @@ async function lw(t = {}) {
11807
11835
  }
11808
11836
  );
11809
11837
  };
11810
- Se.hidden = !e.attachmentsEnabled, te.disabled = !e.attachmentsEnabled, te.accept = e.productVariant === "personal" ? "" : Df, $l(E), $l(P);
11811
- let nt = [];
11838
+ Se.hidden = !e.attachmentsEnabled, te.disabled = !e.attachmentsEnabled, te.accept = e.productVariant === "personal" ? "" : Df, $l(k), $l(P);
11839
+ let it = [];
11812
11840
  const Zn = /* @__PURE__ */ new Map(), Ea = () => {
11813
11841
  for (const u of Zn.values()) URL.revokeObjectURL?.(u);
11814
11842
  Zn.clear();
11815
11843
  };
11816
11844
  let ft = 0, Gt = 0, Ca = 0;
11817
- const St = /* @__PURE__ */ new Map();
11845
+ const xt = /* @__PURE__ */ new Map();
11818
11846
  let Jt = null, Dt = null;
11819
- const eo = (u) => u === P ? "widget_composer" : u === E ? "widget_launcher" : u && a.contains(u) ? "widget_control" : u === b.body ? "body" : u === b.documentElement ? "document" : u ? "host_page" : "none", fn = (u, y, I = {}) => {
11820
- const x = ps(b), D = I.skipIfAlreadyFocused === !0 && x === u;
11847
+ const eo = (u) => u === P ? "widget_composer" : u === k ? "widget_launcher" : u && a.contains(u) ? "widget_control" : u === w.body ? "body" : u === w.documentElement ? "document" : u ? "host_page" : "none", fn = (u, y, I = {}) => {
11848
+ const x = ps(w), D = I.skipIfAlreadyFocused === !0 && x === u;
11821
11849
  D || (I.preventScroll ? u.focus({ preventScroll: !0 }) : u.focus());
11822
- const re = ps(b);
11850
+ const re = ps(w);
11823
11851
  return Xe(
11824
11852
  "web-sdk.widget.focus",
11825
11853
  "Programmatic widget focus",
@@ -11847,9 +11875,9 @@ async function lw(t = {}) {
11847
11875
  }), ei = () => {
11848
11876
  Xw(
11849
11877
  ce,
11850
- nt,
11878
+ it,
11851
11879
  (u) => {
11852
- Gt++, nt = nt.filter(
11880
+ Gt++, it = it.filter(
11853
11881
  (y, I) => I !== u
11854
11882
  ), ei(), _e(A.getState()), Me(), Yt("remove_attachment");
11855
11883
  }
@@ -11906,20 +11934,20 @@ async function lw(t = {}) {
11906
11934
  } catch (u) {
11907
11935
  throw to?.release(), o.remove(), u;
11908
11936
  }
11909
- let ti = A.getState().sessionId, ni = A.getState().selectionKey, ii = A.getState().user?.id ?? null, xt = ks.find(
11937
+ let ti = A.getState().sessionId, ni = A.getState().selectionKey, ii = A.getState().user?.id ?? null, kt = ks.find(
11910
11938
  (u) => u.value === e.model
11911
11939
  )?.value ?? Ms[0].value, si = !1;
11912
11940
  const Ta = e.productVariant === "personal" && e.onModelChange !== void 0;
11913
11941
  fe.hidden = !Ta;
11914
11942
  const Un = () => {
11915
- const u = ks.find((I) => I.value === xt), y = si;
11916
- Oe.textContent = u?.label ?? xt, fe.dataset.loading = String(y), fe.setAttribute("aria-disabled", String(y));
11917
- for (const I of et) {
11918
- const x = I.dataset.model === xt;
11943
+ const u = ks.find((I) => I.value === kt), y = si;
11944
+ Oe.textContent = u?.label ?? kt, fe.dataset.loading = String(y), fe.setAttribute("aria-disabled", String(y));
11945
+ for (const I of tt) {
11946
+ const x = I.dataset.model === kt;
11919
11947
  I.classList.toggle("is-selected", x), I.setAttribute("aria-selected", String(x)), I.disabled = y;
11920
11948
  }
11921
11949
  }, Du = (u) => {
11922
- xt = u, A.setModel(u), Un();
11950
+ kt = u, A.setModel(u), Un();
11923
11951
  };
11924
11952
  Un(), fe.addEventListener("toggle", () => {
11925
11953
  fe.open && si && (fe.open = !1), fe.open || fe.querySelector(".pluno-pa-widget__model-more")?.removeAttribute("open");
@@ -11927,24 +11955,24 @@ async function lw(t = {}) {
11927
11955
  const Pa = (u) => {
11928
11956
  fe.open && !u.composedPath().includes(fe) && (fe.open = !1);
11929
11957
  };
11930
- b.addEventListener("pointerdown", Pa, !0);
11931
- for (const u of et)
11958
+ w.addEventListener("pointerdown", Pa, !0);
11959
+ for (const u of tt)
11932
11960
  u.addEventListener("click", () => {
11933
11961
  const y = ks.find((x) => x.value === u.dataset.model);
11934
- if (!y || y.value === xt && A.getModel() === y.value || si) {
11962
+ if (!y || y.value === kt && A.getModel() === y.value || si) {
11935
11963
  fe.open = !1;
11936
11964
  return;
11937
11965
  }
11938
- const I = xt;
11939
- xt = y.value, si = !0, fe.open = !1, fe.title = "", Un(), Promise.resolve(e.onModelChange?.(y.value)).then(() => Du(y.value)).catch(() => {
11940
- xt = I, fe.title = "Could not change model";
11966
+ const I = kt;
11967
+ kt = y.value, si = !0, fe.open = !1, fe.title = "", Un(), Promise.resolve(e.onModelChange?.(y.value)).then(() => Du(y.value)).catch(() => {
11968
+ kt = I, fe.title = "Could not change model";
11941
11969
  }).finally(() => {
11942
11970
  si = !1, Un();
11943
11971
  });
11944
11972
  });
11945
- w.appendChild(o);
11973
+ b.appendChild(o);
11946
11974
  const $i = e.manageTaskPageTitle && e.productVariant === "personal" && e.entrySurface === "main_web_chat" ? new df(
11947
- uf(b)
11975
+ uf(w)
11948
11976
  ) : null;
11949
11977
  Xe(
11950
11978
  "web-sdk.widget",
@@ -11965,11 +11993,11 @@ async function lw(t = {}) {
11965
11993
  guardCreatedAt: be?.createdAt ?? null,
11966
11994
  selectionFencePending: qa(u)
11967
11995
  }), ji = /* @__PURE__ */ new Set();
11968
- let Ki = "", Ke = !1, it = null, Oa = location.origin, La = A.getState().sessionId, Na = A.getState().user?.id ?? null, so = A.getState().status, Lt = () => {
11996
+ let Ki = "", Ke = !1, st = null, Oa = location.origin, La = A.getState().sessionId, Na = A.getState().user?.id ?? null, so = A.getState().status, Lt = () => {
11969
11997
  }, oo = "", We = A.getSessionHistoryState();
11970
11998
  const Ou = A.subscribeSessionHistory((u) => {
11971
11999
  We = u, Pe || Lt();
11972
- }), st = (u, y) => {
12000
+ }), ot = (u, y) => {
11973
12001
  Ot = { enabled: u, reason: y };
11974
12002
  }, yt = () => {
11975
12003
  ve.hidden = !0;
@@ -11984,15 +12012,15 @@ async function lw(t = {}) {
11984
12012
  current: be.observedWelcome
11985
12013
  }), be = null);
11986
12014
  }, Nu = (u = "jump") => {
11987
- st(!0, u), yt(), Kn(q, () => Ot.enabled), Zt = q.scrollTop;
12015
+ ot(!0, u), yt(), Kn(q, () => Ot.enabled), Zt = q.scrollTop;
11988
12016
  }, Wi = (u) => {
11989
- io = u, u === "up" && q.scrollTop < Zt - 1 && (oi = !0, st(!1, "userScroll")), mn !== null && window.clearTimeout(mn), mn = window.setTimeout(() => {
12017
+ io = u, u === "up" && q.scrollTop < Zt - 1 && (oi = !0, ot(!1, "userScroll")), mn !== null && window.clearTimeout(mn), mn = window.setTimeout(() => {
11990
12018
  io = null, mn = null;
11991
12019
  }, 500);
11992
12020
  };
11993
12021
  Lt = () => {
11994
12022
  const u = fp(We.data), y = We.status === "loading" || We.status === "refreshing" || We.status === "loading_more";
11995
- if (J.hidden = e.layout === "page" || e.loginRequired || e.signupRequired, (e.loginRequired || e.signupRequired) && (Ke = !1), tt.hidden = !Ke, J.setAttribute("aria-expanded", String(Ke)), !Ke) {
12023
+ if (J.hidden = e.layout === "page" || e.loginRequired || e.signupRequired, (e.loginRequired || e.signupRequired) && (Ke = !1), nt.hidden = !Ke, J.setAttribute("aria-expanded", String(Ke)), !Ke) {
11996
12024
  oo = "";
11997
12025
  return;
11998
12026
  }
@@ -12024,7 +12052,7 @@ async function lw(t = {}) {
12024
12052
  );
12025
12053
  const _t = document.createElement("small");
12026
12054
  _t.className = "pluno-pa-widget__history-path", _t.textContent = Rw(x), D.append(Re, Ie, _t), D.addEventListener("click", () => {
12027
- Ke = !1, Lt(), be = null, oi = !1, ji.clear(), st(!0, "newSession"), yt(), A.loadSession(x.id), di = null, _e(A.getState()), Yt("history_session_selected");
12055
+ Ke = !1, Lt(), be = null, oi = !1, ji.clear(), ot(!0, "newSession"), yt(), A.loadSession(x.id), di = null, _e(A.getState()), Yt("history_session_selected");
12028
12056
  }), z.appendChild(D);
12029
12057
  }
12030
12058
  if (y && u.length > 0) {
@@ -12035,7 +12063,7 @@ async function lw(t = {}) {
12035
12063
  }
12036
12064
  };
12037
12065
  const ro = (u = !1) => {
12038
- if (it !== null && (window.clearTimeout(it), it = null), !(e.layout === "page" || e.loginRequired || e.signupRequired || Xs || !u && A.getState().status !== "connected"))
12066
+ if (st !== null && (window.clearTimeout(st), st = null), !(e.layout === "page" || e.loginRequired || e.signupRequired || Xs || !u && A.getState().status !== "connected"))
12039
12067
  return Xs = !0, A.refreshSessionHistory().catch(() => {
12040
12068
  }).finally(() => {
12041
12069
  Xs = !1;
@@ -12047,16 +12075,16 @@ async function lw(t = {}) {
12047
12075
  });
12048
12076
  });
12049
12077
  const ao = () => {
12050
- it === null && (it = window.setTimeout(() => {
12051
- it = null, !(Pe || !r.classList.contains("pluno-pa-widget--open")) && ro();
12078
+ st === null && (st = window.setTimeout(() => {
12079
+ st = null, !(Pe || !r.classList.contains("pluno-pa-widget--open")) && ro();
12052
12080
  }, 0));
12053
12081
  }, Uu = () => {
12054
12082
  const u = We.data?.nextCursor ?? null;
12055
12083
  We.status === "loading_more" || !u || z.scrollHeight - z.scrollTop - z.clientHeight <= 24 && A.loadMoreSessionHistory();
12056
12084
  }, za = () => {
12057
- Pe || typeof document > "u" || (Gl(a, e.accentColor), o.isConnected || (e.mountTarget?.isConnected ? e.mountTarget.appendChild(o) : e.mountTarget || b.body?.appendChild(o)));
12085
+ Pe || typeof document > "u" || (Gl(a, e.accentColor), o.isConnected || (e.mountTarget?.isConnected ? e.mountTarget.appendChild(o) : e.mountTarget || w.body?.appendChild(o)));
12058
12086
  }, Ba = new MutationObserver(za);
12059
- Ba.observe(b.documentElement, {
12087
+ Ba.observe(w.documentElement, {
12060
12088
  childList: !0,
12061
12089
  subtree: !0
12062
12090
  }), za();
@@ -12316,7 +12344,7 @@ async function lw(t = {}) {
12316
12344
  if (Gi(Ie, Re), wn("Opening launcher at clamped open panel position", {
12317
12345
  openPanelPosition: Ie,
12318
12346
  visibleLauncherPosition: Re
12319
- }), st(!0, "open"), yt(), !re && e.layout === "floating" && A.recordWidgetLifecycle("opened", D), !y) {
12347
+ }), ot(!0, "open"), yt(), !re && e.layout === "floating" && A.recordWidgetLifecycle("opened", D), !y) {
12320
12348
  r.classList.add("pluno-pa-widget--open"), re || ao(), _.hidden = !0, u && (P.value = u, ki(P)), Kn(q, () => Ot.enabled), Zt = q.scrollTop, I && (fn(P, "panel_open_immediate"), P.setSelectionRange(P.value.length, P.value.length)), Ve(), Vi("shown", D), e.onPanelOpenChange?.(!0, D);
12321
12349
  return;
12322
12350
  }
@@ -12335,23 +12363,23 @@ async function lw(t = {}) {
12335
12363
  }, 220);
12336
12364
  };
12337
12365
  _.addEventListener("submit", (u) => {
12338
- u.preventDefault(), wt(E.value, !0, !0, !0, "launcher_input"), E.value = "";
12366
+ u.preventDefault(), wt(k.value, !0, !0, !0, "launcher_input"), k.value = "";
12339
12367
  }), v?.addEventListener("click", (u) => {
12340
12368
  u.preventDefault(), u.stopPropagation();
12341
12369
  }), _.addEventListener("click", (u) => {
12342
- u.target === E && !v || (wt(E.value, !0, !0, !0, "launcher_click"), E.value = "");
12370
+ u.target === k && !v || (wt(k.value, !0, !0, !0, "launcher_click"), k.value = "");
12343
12371
  });
12344
12372
  const Va = () => {
12345
- wt(E.value, !0, !0, !0, "launcher_focus"), E.value = "";
12373
+ wt(k.value, !0, !0, !0, "launcher_focus"), k.value = "";
12346
12374
  };
12347
- E.addEventListener("focus", Va), E.addEventListener("input", () => {
12348
- if (!E.value)
12375
+ k.addEventListener("focus", Va), k.addEventListener("input", () => {
12376
+ if (!k.value)
12349
12377
  return;
12350
- const u = E.value;
12351
- wt(u, !0, !0, !0, "launcher_input"), E.value = "";
12378
+ const u = k.value;
12379
+ wt(u, !0, !0, !0, "launcher_input"), k.value = "";
12352
12380
  });
12353
- let ui = null, en = null, Ji = null, In = null, kt = null, Ne = null;
12354
- const Yi = (u) => u === E || u === P, Ga = (u) => u.composedPath().find(Yi) ?? null, ju = (u) => {
12381
+ let ui = null, en = null, Ji = null, In = null, Et = null, Ne = null;
12382
+ const Yi = (u) => u === k || u === P, Ga = (u) => u.composedPath().find(Yi) ?? null, ju = (u) => {
12355
12383
  let y = u;
12356
12384
  for (; y; ) {
12357
12385
  if (y.assignedSlot)
@@ -12376,7 +12404,7 @@ async function lw(t = {}) {
12376
12404
  y = D instanceof ShadowRoot ? D.host : null;
12377
12405
  }
12378
12406
  return null;
12379
- }, fo = () => ps(b), Ku = (u) => {
12407
+ }, fo = () => ps(w), Ku = (u) => {
12380
12408
  if (!u.isConnected || !u.matches(xl))
12381
12409
  return !1;
12382
12410
  if (!(u instanceof HTMLElement))
@@ -12390,10 +12418,10 @@ async function lw(t = {}) {
12390
12418
  }, mo = (u, y) => {
12391
12419
  if (!y)
12392
12420
  return;
12393
- kt !== null && window.clearTimeout(kt);
12421
+ Et !== null && window.clearTimeout(Et);
12394
12422
  const I = Date.now();
12395
- kt = window.setTimeout(() => {
12396
- kt = null, Ut === u && y.isConnected && fn(y, "host_modal_recovery", {
12423
+ Et = window.setTimeout(() => {
12424
+ Et = null, Ut === u && y.isConnected && fn(y, "host_modal_recovery", {
12397
12425
  preventScroll: !0,
12398
12426
  scheduledAt: I
12399
12427
  });
@@ -12410,9 +12438,9 @@ async function lw(t = {}) {
12410
12438
  return;
12411
12439
  }
12412
12440
  mo(I, null);
12413
- }, Hy)) : (In !== null && (window.clearInterval(In), In = null), kt !== null && (window.clearTimeout(kt), kt = null), Ji = null);
12441
+ }, Hy)) : (In !== null && (window.clearInterval(In), In = null), Et !== null && (window.clearTimeout(Et), Et = null), Ji = null);
12414
12442
  }, Hu = () => {
12415
- In !== null && (window.clearInterval(In), In = null), kt !== null && (window.clearTimeout(kt), kt = null), Ne !== null && (window.clearTimeout(Ne), Ne = null);
12443
+ In !== null && (window.clearInterval(In), In = null), Et !== null && (window.clearTimeout(Et), Et = null), Ne !== null && (window.clearTimeout(Ne), Ne = null);
12416
12444
  }, Ja = (u) => {
12417
12445
  const y = Ga(u);
12418
12446
  if (!y)
@@ -12433,17 +12461,17 @@ async function lw(t = {}) {
12433
12461
  }, 0);
12434
12462
  }, Xi = (u) => {
12435
12463
  const y = Ga(u);
12436
- y && (ui = Date.now(), Ut !== null && (u.stopImmediatePropagation(), en = null, Ne !== null && (window.clearTimeout(Ne), Ne = null), Ve(), u.type === "focus" && y === E && Va()));
12464
+ y && (ui = Date.now(), Ut !== null && (u.stopImmediatePropagation(), en = null, Ne !== null && (window.clearTimeout(Ne), Ne = null), Ve(), u.type === "focus" && y === k && Va()));
12437
12465
  };
12438
- b.defaultView?.addEventListener(
12466
+ w.defaultView?.addEventListener(
12439
12467
  "pointerdown",
12440
12468
  Ja,
12441
12469
  !0
12442
- ), b.defaultView?.addEventListener(
12470
+ ), w.defaultView?.addEventListener(
12443
12471
  "focus",
12444
12472
  Xi,
12445
12473
  !0
12446
- ), b.defaultView?.addEventListener(
12474
+ ), w.defaultView?.addEventListener(
12447
12475
  "focusin",
12448
12476
  Xi,
12449
12477
  !0
@@ -12495,13 +12523,13 @@ async function lw(t = {}) {
12495
12523
  }), q.addEventListener("keydown", (u) => {
12496
12524
  (u.key === "ArrowUp" || u.key === "PageUp" || u.key === "Home") && Wi("up");
12497
12525
  }), q.addEventListener("scroll", () => {
12498
- q.scrollTop < Zt - 1 && io === "up" && (oi = !0, st(!1, "userScroll")), Zt = q.scrollTop;
12526
+ q.scrollTop < Zt - 1 && io === "up" && (oi = !0, ot(!1, "userScroll")), Zt = q.scrollTop;
12499
12527
  }), ve.addEventListener("click", () => {
12500
12528
  Nu();
12501
12529
  });
12502
12530
  const Ya = typeof IntersectionObserver > "u" ? null : new IntersectionObserver(
12503
12531
  ([u]) => {
12504
- !u?.isIntersecting || q.scrollHeight - q.scrollTop - q.clientHeight > 1 || (st(!0, "bottom"), yt());
12532
+ !u?.isIntersecting || q.scrollHeight - q.scrollTop - q.clientHeight > 1 || (ot(!0, "bottom"), yt());
12505
12533
  },
12506
12534
  { root: q, threshold: 0 }
12507
12535
  );
@@ -12525,8 +12553,8 @@ async function lw(t = {}) {
12525
12553
  return Qi() ? !1 : u !== "connected" && !(yo && u === "reconnecting");
12526
12554
  }, zn = () => {
12527
12555
  const u = Nt(), y = A.getState(), I = !y.isThinking && !y.pendingMessageStatus && !!y.lastError;
12528
- E.readOnly = !1, P.readOnly = !1, E.placeholder = u ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : I ? "Needs attention" : hi ? "New update" : e.launcherLabel, P.placeholder = u ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : $t.launcherLabel, V.hidden = u;
12529
- }, _o = () => [...St.values()].some((u) => u.revision === Gt && u.generation === ft), Za = () => {
12556
+ k.readOnly = !1, P.readOnly = !1, k.placeholder = u ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : I ? "Needs attention" : hi ? "New update" : e.launcherLabel, P.placeholder = u ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : $t.launcherLabel, V.hidden = u;
12557
+ }, _o = () => [...xt.values()].some((u) => u.revision === Gt && u.generation === ft), Za = () => {
12530
12558
  const u = A.getState(), y = e.billingStatus;
12531
12559
  return {
12532
12560
  submissionAllowed: y?.submissionGate?.allowed === !0,
@@ -12540,12 +12568,12 @@ async function lw(t = {}) {
12540
12568
  hasPendingMessage: !1
12541
12569
  };
12542
12570
  }, tn = () => e.productVariant === "personal" ? xc(Za()) : !bo() && !Fn(e.billingStatus) && !_o(), ec = () => {
12543
- const u = A.getState(), y = !Qi() && [...St.values()].some((I) => I.revision === Gt && I.generation === ft);
12571
+ const u = A.getState(), y = !Qi() && [...xt.values()].some((I) => I.revision === Gt && I.generation === ft);
12544
12572
  return yp({
12545
12573
  hasRunningAssistantTurn: y || u.isThinking || u.turnPhase !== null || u.pendingMessageStatus !== null,
12546
12574
  // Retained text already submitted by this revision must not hide Stop behind a disabled Send.
12547
12575
  hasDraftMessage: !y && P.value.trim().length > 0,
12548
- hasPreSubmittedAttachment: nt.length > 0,
12576
+ hasPreSubmittedAttachment: it.length > 0,
12549
12577
  canSubmitMessage: tn()
12550
12578
  });
12551
12579
  }, Me = () => {
@@ -12584,10 +12612,10 @@ async function lw(t = {}) {
12584
12612
  O.textContent = "", O.hidden = !0, Dt = null;
12585
12613
  }, 3e3);
12586
12614
  }, So = (u, y) => {
12587
- const I = St.get(u);
12588
- if (!I || y !== void 0 && I.submittedAt !== y || (St.delete(u), I.generation !== ft || I.revision !== Gt)) return;
12615
+ const I = xt.get(u);
12616
+ if (!I || y !== void 0 && I.submittedAt !== y || (xt.delete(u), I.generation !== ft || I.revision !== Gt)) return;
12589
12617
  const x = new Set(I.attachments);
12590
- nt = nt.filter((D) => !x.has(D)), P.value = "", P.dispatchEvent(new Event("input", { bubbles: !0 })), ei(), Me();
12618
+ it = it.filter((D) => !x.has(D)), P.value = "", P.dispatchEvent(new Event("input", { bubbles: !0 })), ei(), Me();
12591
12619
  }, tc = (u) => {
12592
12620
  const y = ft, I = gn ? Nn : null;
12593
12621
  Ew(
@@ -12602,7 +12630,7 @@ async function lw(t = {}) {
12602
12630
  y === ft && (A.getState().receipts === void 0 && So(u.clientMessageId), be?.clientMessageId === u.clientMessageId && (be.pendingSubmission = !1, x && (be.clientMessageId = x), Ua()), I && (gn = !1, Nn = null, e.proactiveSuggestion = null, gt()));
12603
12631
  }).catch((x) => {
12604
12632
  if (y !== ft) return;
12605
- be?.clientMessageId === u.clientMessageId && (be = null), St.delete(u.clientMessageId), ei();
12633
+ be?.clientMessageId === u.clientMessageId && (be = null), xt.delete(u.clientMessageId), ei();
12606
12634
  const D = x instanceof Error ? x.message : "Failed to upload attachment";
12607
12635
  A.getState().lastError !== D && Zi(D);
12608
12636
  }).finally(() => {
@@ -12614,12 +12642,12 @@ async function lw(t = {}) {
12614
12642
  const u = Jt;
12615
12643
  Jt = null, tc(u);
12616
12644
  }, xo = () => {
12617
- const u = P.value, y = u.trim(), I = [...nt];
12645
+ const u = P.value, y = u.trim(), I = [...it];
12618
12646
  if (Jt !== null || _o() || e.productVariant === "personal" && !tn() || !y && I.length === 0)
12619
12647
  return;
12620
12648
  for (const D of I)
12621
12649
  D.id && D.previewUrl && Zn.set(D.id, D.previewUrl);
12622
- if ([...St.values()].some((D) => D.revision === Gt && D.generation === ft)) return;
12650
+ if ([...xt.values()].some((D) => D.revision === Gt && D.generation === ft)) return;
12623
12651
  const x = {
12624
12652
  inputValue: u,
12625
12653
  value: y,
@@ -12627,7 +12655,7 @@ async function lw(t = {}) {
12627
12655
  clientMessageId: crypto.randomUUID(),
12628
12656
  submittedAt: Math.max(Date.now(), Ca + 1)
12629
12657
  };
12630
- if (Ca = x.submittedAt, St.set(x.clientMessageId, { ...x, revision: Gt, generation: ft }), Me(), be = {
12658
+ if (Ca = x.submittedAt, xt.set(x.clientMessageId, { ...x, revision: Gt, generation: ft }), Me(), be = {
12631
12659
  createdAt: Date.now(),
12632
12660
  clientMessageId: x.clientMessageId,
12633
12661
  observedConversation: null,
@@ -12648,7 +12676,7 @@ async function lw(t = {}) {
12648
12676
  e.onSignupClick?.();
12649
12677
  return;
12650
12678
  }
12651
- (e.productVariant === "personal" ? !tn() : bo() || Fn(e.billingStatus)) || (Qt = !0, st(!0, "send"), yt(), xo());
12679
+ (e.productVariant === "personal" ? !tn() : bo() || Fn(e.billingStatus)) || (Qt = !0, ot(!0, "send"), yt(), xo());
12652
12680
  });
12653
12681
  let gi = 0;
12654
12682
  const nn = () => {
@@ -12663,7 +12691,7 @@ async function lw(t = {}) {
12663
12691
  u,
12664
12692
  e.productVariant === "customer_embedded"
12665
12693
  );
12666
- if (Gt++, nt = [...nt, ...y], ei(), Wu(), Me(), _e(A.getState()), !r.classList.contains("pluno-pa-widget--open")) {
12694
+ if (Gt++, it = [...it, ...y], ei(), Wu(), Me(), _e(A.getState()), !r.classList.contains("pluno-pa-widget--open")) {
12667
12695
  wt("", !0, !0, !0, "attachment_drop");
12668
12696
  return;
12669
12697
  }
@@ -12693,11 +12721,11 @@ async function lw(t = {}) {
12693
12721
  const ic = (u) => {
12694
12722
  r.classList.contains("pluno-pa-widget--drag-over") && !u.composedPath().includes(r) && nn();
12695
12723
  };
12696
- b.addEventListener(
12724
+ w.addEventListener(
12697
12725
  "dragover",
12698
12726
  ic,
12699
12727
  !0
12700
- ), b.addEventListener("drop", nn, !0), b.addEventListener("dragend", nn, !0), b.defaultView?.addEventListener("blur", nn), r.addEventListener("drop", (u) => {
12728
+ ), w.addEventListener("drop", nn, !0), w.addEventListener("dragend", nn, !0), w.defaultView?.addEventListener("blur", nn), r.addEventListener("drop", (u) => {
12701
12729
  const y = u.dataTransfer;
12702
12730
  !e.attachmentsEnabled || !hs(y) || e.loginRequired || Sn() || (u.preventDefault(), u.stopPropagation(), nn(), ko(y.files).catch((I) => {
12703
12731
  Zi(
@@ -12725,11 +12753,11 @@ async function lw(t = {}) {
12725
12753
  if (u.disabled)
12726
12754
  return;
12727
12755
  if (u.action === "stop") {
12728
- St.clear(), Jt = null, be = null, A.stop(), Me();
12756
+ xt.clear(), Jt = null, be = null, A.stop(), Me();
12729
12757
  return;
12730
12758
  }
12731
- const y = P.value.trim().length > 0 || nt.length > 0;
12732
- Qt = !0, st(!0, "send"), yt(), xo(), _e(A.getState()), Me(), y && Yt("send_button_submit");
12759
+ const y = P.value.trim().length > 0 || it.length > 0;
12760
+ Qt = !0, ot(!0, "send"), yt(), xo(), _e(A.getState()), Me(), y && Yt("send_button_submit");
12733
12761
  }), J.addEventListener("click", () => {
12734
12762
  Ke = !Ke, Lt(), Ke && (We.data === null || We.status === "error") && We.status !== "loading" && ro(), Ke || Yt("history_closed");
12735
12763
  }), Y.addEventListener("click", () => {
@@ -12742,11 +12770,11 @@ async function lw(t = {}) {
12742
12770
  e.onLoginClick?.();
12743
12771
  return;
12744
12772
  }
12745
- (e.productVariant === "personal" ? !tn() : bo()) || (Qt = !0, st(!0, "send"), yt(), xo(), _e(A.getState()), Me());
12773
+ (e.productVariant === "personal" ? !tn() : bo()) || (Qt = !0, ot(!0, "send"), yt(), xo(), _e(A.getState()), Me());
12746
12774
  }
12747
12775
  }), r.addEventListener("click", (u) => {
12748
12776
  const y = u.target instanceof Element ? u.target : null;
12749
- y?.closest("a[href]") && Ve(), Ke && vy(y, tt, J) && (Ke = !1, Lt());
12777
+ y?.closest("a[href]") && Ve(), Ke && vy(y, nt, J) && (Ke = !1, Lt());
12750
12778
  const x = window.getSelection(), D = !!(x && !x.isCollapsed && x.anchorNode && r.contains(x.anchorNode));
12751
12779
  by(u.target, u.detail, D) && Yt("passive_surface_click");
12752
12780
  });
@@ -12756,7 +12784,7 @@ async function lw(t = {}) {
12756
12784
  }, rc = (u) => {
12757
12785
  if (!sc || U.hidden || r.classList.contains("pluno-pa-widget--closing"))
12758
12786
  return;
12759
- const y = a.activeElement ?? b.activeElement, I = Sy(u, y);
12787
+ const y = a.activeElement ?? w.activeElement, I = Sy(u, y);
12760
12788
  if (!I || P.disabled || P.readOnly)
12761
12789
  return;
12762
12790
  u.preventDefault();
@@ -12768,11 +12796,11 @@ async function lw(t = {}) {
12768
12796
  );
12769
12797
  P.value = x.value, P.dispatchEvent(new Event("input", { bubbles: !0 })), Iy(P), P.setSelectionRange(x.caret, x.caret);
12770
12798
  };
12771
- b.addEventListener(
12799
+ w.addEventListener(
12772
12800
  "pointerdown",
12773
12801
  oc,
12774
12802
  !0
12775
- ), b.addEventListener(
12803
+ ), w.addEventListener(
12776
12804
  "keydown",
12777
12805
  rc
12778
12806
  ), r.addEventListener("copy", (u) => {
@@ -12802,10 +12830,10 @@ async function lw(t = {}) {
12802
12830
  u.key !== "Escape" || !Ke || (Ke = !1, Lt(), Yt("history_escape"));
12803
12831
  }), l.composerValue && (P.value = l.composerValue, ki(P)), e.layout === "page" ? wt(P.value, !1, !0, !1, "external_request") : p === "minimized" ? ai("minimized", !1) : e.initialDisplayState === void 0 && l.isOpen && wt(P.value, !1, !1, !1, "restored_state");
12804
12832
  const fi = () => c;
12805
- let Eo = A.getState().appearance !== null, es = null, mi = null, Et = A.getInteractions();
12806
- const ue = (u) => Et.find(
12833
+ let Eo = A.getState().appearance !== null, es = null, mi = null, Ct = A.getInteractions();
12834
+ const ue = (u) => Ct.find(
12807
12835
  (y) => y.kind === u && y.eligible && y.status === "presentable"
12808
- ), ac = (u) => Et.find((y) => y.kind === u), cc = () => {
12836
+ ), ac = (u) => Ct.find((y) => y.kind === u), cc = () => {
12809
12837
  const u = ue("task_notifications");
12810
12838
  u && (ke && (ke.textContent = u.presentation.body), Fe && (Fe.textContent = u.presentation.actionLabels.enable ?? "Notify me"), ht && (ht.textContent = u.presentation.actionLabels.later ?? "Later"), je && (je.textContent = u.presentation.actionLabels.never ?? "Never"));
12811
12839
  const y = ue("tab_group_permission");
@@ -12848,7 +12876,7 @@ async function lw(t = {}) {
12848
12876
  });
12849
12877
  }), lc();
12850
12878
  let xn = null;
12851
- const ts = /* @__PURE__ */ new Map(), Ro = /* @__PURE__ */ new Map(), To = /* @__PURE__ */ new Map(), Gu = () => P.value.trim().length > 0 || nt.length > 0, dc = (u) => {
12879
+ const ts = /* @__PURE__ */ new Map(), Ro = /* @__PURE__ */ new Map(), To = /* @__PURE__ */ new Map(), Gu = () => P.value.trim().length > 0 || it.length > 0, dc = (u) => {
12852
12880
  if (e.entrySurface === "extension_widget") {
12853
12881
  const y = e.billingStatus?.auth, I = y ? !!y.user : !!(u.user && !e.loginRequired), x = y ? !!y.workspace : !e.signupRequired;
12854
12882
  return I && x && xn !== null && xn > 0;
@@ -12870,13 +12898,13 @@ async function lw(t = {}) {
12870
12898
  };
12871
12899
  let Bn = null;
12872
12900
  const is = /* @__PURE__ */ new Map();
12873
- for (const u of Et)
12901
+ for (const u of Ct)
12874
12902
  u.kind === "integration_connection" && is.set(u.payload.request.authRequestId, {
12875
12903
  status: u.payload.status,
12876
12904
  error: u.payload.error ?? void 0
12877
12905
  });
12878
12906
  const Yu = async (u) => {
12879
- const y = Et.find(
12907
+ const y = Ct.find(
12880
12908
  (I) => I.kind === "integration_connection" && I.payload.request.authRequestId === u.authRequestId && I.eligible && I.status === "presentable"
12881
12909
  );
12882
12910
  y && await Ue(y, "connect");
@@ -12884,12 +12912,12 @@ async function lw(t = {}) {
12884
12912
  const y = ue("personal_channel_connection");
12885
12913
  y?.payload.request.requestId === u.requestId && await Ue(y, "connect");
12886
12914
  }, yi = (u = {}) => {
12887
- ft++, St.clear(), Ea(), Jt = null, be = null, oi = !1, ji.clear(), Qt = !0, st(!0, "newSession"), yt(), Ke = !1, Lt();
12915
+ ft++, xt.clear(), Ea(), Jt = null, be = null, oi = !1, ji.clear(), Qt = !0, ot(!0, "newSession"), yt(), Ke = !1, Lt();
12888
12916
  const y = Promise.resolve(A.startNewSession(u));
12889
- return di = null, no.clear(), is.clear(), P.value = "", nt = [], ei(), ki(P), Ve(), Me(), fn(P, "new_chat"), _e(A.getState()), y;
12917
+ return di = null, no.clear(), is.clear(), P.value = "", it = [], ei(), ki(P), Ve(), Me(), fn(P, "new_chat"), _e(A.getState()), y;
12890
12918
  }, pc = (u) => {
12891
12919
  window.requestAnimationFrame(() => {
12892
- Pe || U.hidden || b.visibilityState === "hidden" || Array.from(q.querySelectorAll("[data-message-key]")).some(
12920
+ Pe || U.hidden || w.visibilityState === "hidden" || Array.from(q.querySelectorAll("[data-message-key]")).some(
12893
12921
  (y) => u.has(y.dataset.messageKey)
12894
12922
  ) && Hi("proactive_suggestion_previous_chat_visible");
12895
12923
  });
@@ -12945,7 +12973,7 @@ async function lw(t = {}) {
12945
12973
  He = "submitting", gt();
12946
12974
  try {
12947
12975
  await Ue(
12948
- Et.find((I) => I.kind === "proactive_suggestion" && I.payload.suggestion.id === u.id),
12976
+ Ct.find((I) => I.kind === "proactive_suggestion" && I.payload.suggestion.id === u.id),
12949
12977
  "submit_feedback",
12950
12978
  { feedback: y }
12951
12979
  ), He = "success";
@@ -12999,13 +13027,13 @@ async function lw(t = {}) {
12999
13027
  const _e = (u, y = {}) => {
13000
13028
  qa(u) && (be = null), Ma = y.renderSource ?? "local", uo(), r.classList.toggle("pluno-pa-widget--logged-out", e.loginRequired && e.entrySurface === "extension_widget"), F.classList.remove("pluno-pa-widget__access-notice--login-only"), u = { ...u, messages: u.messages.map(($) => {
13001
13029
  if (!$.attachments?.some((Ge) => Ge.id && !Ge.fileUrl && Zn.has(Ge.id))) return $;
13002
- const Ct = $.attachments.map((Ge) => {
13030
+ const At = $.attachments.map((Ge) => {
13003
13031
  const bi = Ge.id ? Zn.get(Ge.id) : void 0;
13004
13032
  return bi && !Ge.fileUrl ? { ...Ge, previewUrl: bi } : Ge;
13005
13033
  });
13006
13034
  return Object.create(Object.getPrototypeOf($), {
13007
13035
  ...Object.getOwnPropertyDescriptors($),
13008
- attachments: { value: Ct, enumerable: !0, configurable: !0 }
13036
+ attachments: { value: At, enumerable: !0, configurable: !0 }
13009
13037
  });
13010
13038
  }) }, Un(), Xt !== null && (window.clearTimeout(Xt), Xt = null), Lt(), gt(), Zs(), F.hidden = !e.loginRequired && !e.signupRequired, F.hidden && F.replaceChildren();
13011
13039
  const I = JSON.stringify([
@@ -13022,8 +13050,8 @@ async function lw(t = {}) {
13022
13050
  }
13023
13051
  if (e.loginRequired) {
13024
13052
  Ki = "", ts.clear(), Ro.clear(), To.clear(), q.replaceChildren();
13025
- const $ = e.billingStatus?.auth, Ct = e.extensionRuntime?.retryAuth;
13026
- if ($?.status === "error" && ($.errorCode === "browser_session_unavailable" || $.errorCode === "backend_auth_pending") && Ct) {
13053
+ const $ = e.billingStatus?.auth, At = e.extensionRuntime?.retryAuth;
13054
+ if ($?.status === "error" && ($.errorCode === "browser_session_unavailable" || $.errorCode === "backend_auth_pending") && At) {
13027
13055
  mr(
13028
13056
  F,
13029
13057
  Ce,
@@ -13039,7 +13067,7 @@ async function lw(t = {}) {
13039
13067
  const Ge = F.querySelector(".pluno-pa-widget__login");
13040
13068
  Ge.disabled = kn, Ge.setAttribute("aria-busy", String(kn)), kn && Ge.prepend(pn()), Ge.addEventListener("click", () => {
13041
13069
  const bi = ++os, rp = Mo;
13042
- kn = !0, wi = null, _e(A.getState()), Ct().catch((Ic) => {
13070
+ kn = !0, wi = null, _e(A.getState()), At().catch((Ic) => {
13043
13071
  bi !== os || rp !== Mo || (wi = Ic instanceof Error ? Ic.message : "Close and reopen Pluno to try again.");
13044
13072
  }).finally(() => {
13045
13073
  bi === os && (kn = !1, Pe || _e(A.getState()));
@@ -13076,7 +13104,7 @@ async function lw(t = {}) {
13076
13104
  }
13077
13105
  const x = JSON.stringify([
13078
13106
  Aw(u),
13079
- Et,
13107
+ Ct,
13080
13108
  u.status,
13081
13109
  u.user,
13082
13110
  Qi()
@@ -13101,9 +13129,9 @@ async function lw(t = {}) {
13101
13129
  Ve,
13102
13130
  fi,
13103
13131
  ($) => {
13104
- (e.productVariant === "personal" ? !tn() : wo()) || (Qt = !0, st(!0, "send"), yt(), A.sendMessage($));
13132
+ (e.productVariant === "personal" ? !tn() : wo()) || (Qt = !0, ot(!0, "send"), yt(), A.sendMessage($));
13105
13133
  },
13106
- ($) => (Qt = !0, st(!0, "send"), yt(), A.retryLastMessage($)),
13134
+ ($) => (Qt = !0, ot(!0, "send"), yt(), A.retryLastMessage($)),
13107
13135
  e.morningReport,
13108
13136
  () => {
13109
13137
  const $ = ue("morning_report");
@@ -13113,16 +13141,16 @@ async function lw(t = {}) {
13113
13141
  () => u.sessionId ? A.loadSession(u.sessionId) : void 0,
13114
13142
  () => yi(),
13115
13143
  ns.get(u.selectionKey ?? u.sessionId ?? "draft"),
13116
- ($, Ct) => {
13117
- Ju(u.selectionKey ?? u.sessionId ?? "draft", $, Ct);
13144
+ ($, At) => {
13145
+ Ju(u.selectionKey ?? u.sessionId ?? "draft", $, At);
13118
13146
  },
13119
13147
  e.attachmentPreviewUrlResolver,
13120
13148
  ac("integration_connection") ? {
13121
- requests: Et.flatMap(($) => $.kind === "integration_connection" ? [$.payload.request] : []),
13149
+ requests: Ct.flatMap(($) => $.kind === "integration_connection" ? [$.payload.request] : []),
13122
13150
  states: is,
13123
13151
  initialStatus: "pending",
13124
13152
  onConnect: ($) => Yu($),
13125
- presentations: new Map(Et.flatMap(
13153
+ presentations: new Map(Ct.flatMap(
13126
13154
  ($) => $.kind === "integration_connection" ? [[$.payload.request.authRequestId, $.presentation]] : []
13127
13155
  ))
13128
13156
  } : void 0,
@@ -13147,8 +13175,8 @@ async function lw(t = {}) {
13147
13175
  sp($);
13148
13176
  },
13149
13177
  onSocialShare: ($) => {
13150
- const Ct = ue("social_share");
13151
- Ue(Ct, "dismiss").catch(() => {
13178
+ const At = ue("social_share");
13179
+ Ue(At, "dismiss").catch(() => {
13152
13180
  });
13153
13181
  },
13154
13182
  onDismiss: () => {
@@ -13167,7 +13195,7 @@ async function lw(t = {}) {
13167
13195
  ".pluno-pa-widget__empty-state--starter:not(.pluno-pa-widget__empty-state--morning-report)"
13168
13196
  );
13169
13197
  be && !be.observedWelcome && !Re && Ol(u) && (be.observedConversation = Da(u)), Ua(), Me(), gt();
13170
- const Ie = Array.isArray(u.activeScheduledFollowUps) ? u.activeScheduledFollowUps : null, _t = (Ie !== null ? Ie.map(($) => $.dueAt) : u.messages.map(($) => $.scheduledCheckInAt)).filter(($) => !!$).filter(($) => Jn($) !== null).sort(($, Ct) => Date.parse($) - Date.parse(Ct))[0] ?? null, vc = _t ? Qg(_t) : null;
13198
+ const Ie = Array.isArray(u.activeScheduledFollowUps) ? u.activeScheduledFollowUps : null, _t = (Ie !== null ? Ie.map(($) => $.dueAt) : u.messages.map(($) => $.scheduledCheckInAt)).filter(($) => !!$).filter(($) => Jn($) !== null).sort(($, At) => Date.parse($) - Date.parse(At))[0] ?? null, vc = _t ? Qg(_t) : null;
13171
13199
  vc !== null && (Xt = window.setTimeout(
13172
13200
  () => {
13173
13201
  Xt = null, Pe || _e(A.getState());
@@ -13175,9 +13203,9 @@ async function lw(t = {}) {
13175
13203
  Math.min(vc, 2147483647)
13176
13204
  )), re ? (Zt = q.scrollTop, yt()) : D && Ol(u) && Lu();
13177
13205
  }, wc = () => {
13178
- b.getSelection()?.isCollapsed !== !1 && mb(ts) && _e(A.getState());
13206
+ w.getSelection()?.isCollapsed !== !1 && mb(ts) && _e(A.getState());
13179
13207
  };
13180
- b.addEventListener(
13208
+ w.addEventListener(
13181
13209
  "selectionchange",
13182
13210
  wc
13183
13211
  );
@@ -13186,8 +13214,8 @@ async function lw(t = {}) {
13186
13214
  };
13187
13215
  qo(A.getState());
13188
13216
  const Zu = A.subscribeInteractions((u) => {
13189
- Et = u, cc(), e.morningReport = ue("morning_report")?.payload ?? null, e.proactiveSuggestion = ue("proactive_suggestion")?.payload.suggestion ?? null;
13190
- for (const y of Et)
13217
+ Ct = u, cc(), e.morningReport = ue("morning_report")?.payload ?? null, e.proactiveSuggestion = ue("proactive_suggestion")?.payload.suggestion ?? null;
13218
+ for (const y of Ct)
13191
13219
  y.kind === "integration_connection" && is.set(y.payload.request.authRequestId, {
13192
13220
  status: y.payload.status,
13193
13221
  error: y.payload.error ?? void 0
@@ -13205,19 +13233,19 @@ async function lw(t = {}) {
13205
13233
  };
13206
13234
  A.on("state", (u) => {
13207
13235
  const y = u.user?.id ?? null;
13208
- (ti !== null && ti !== u.sessionId || ii !== null && ii !== y || ni !== void 0 && ni !== u.selectionKey) && (ft++, St.clear(), be = null), ni = u.selectionKey, ti = u.sessionId, ii = y;
13236
+ (ti !== null && ti !== u.sessionId || ii !== null && ii !== y || ni !== void 0 && ni !== u.selectionKey) && (ft++, xt.clear(), be = null), ni = u.selectionKey, ti = u.sessionId, ii = y;
13209
13237
  for (const Ie of u.messages)
13210
13238
  Ie.role === "user" && So(Ie.id);
13211
13239
  for (const Ie of u.receipts ?? []) So(Ie.userMessageId, Ie.acceptedRendererRevision);
13212
13240
  if (e.extensionRuntime && (Mo += 1, wi = null), qo(u), Ta) {
13213
13241
  const Ie = A.getModel(), _t = uy(Ie) ? Ie : Ms[0].value;
13214
- _t !== xt && (xt = _t, Un());
13242
+ _t !== kt && (kt = _t, Un());
13215
13243
  }
13216
13244
  bc(u), u.status === "connected" && (yo = !0, Jt && queueMicrotask(() => {
13217
13245
  nc();
13218
13246
  })), lc();
13219
13247
  const I = Co && !u.isThinking, x = Oa !== location.origin || La !== u.sessionId || Na !== (u.user?.id ?? null), D = Co !== u.isThinking, re = so !== "connected" && u.status === "connected", Re = so === "connected" && u.status !== "connected";
13220
- Oa = location.origin, La = u.sessionId, Na = u.user?.id ?? null, so = u.status, Co = u.isThinking, Re && it !== null && (window.clearTimeout(it), it = null), r.classList.contains("pluno-pa-widget--open") && u.status === "connected" && (x || D || re) && ao(), me && (me.hidden = ue("task_notifications") === void 0), M && (M.hidden = ue("tab_group_permission") === void 0), I && !r.classList.contains("pluno-pa-widget--open") && (hi = !0), vo(), u.appearance ? (Eo = !0, Xe(
13248
+ Oa = location.origin, La = u.sessionId, Na = u.user?.id ?? null, so = u.status, Co = u.isThinking, Re && st !== null && (window.clearTimeout(st), st = null), r.classList.contains("pluno-pa-widget--open") && u.status === "connected" && (x || D || re) && ao(), me && (me.hidden = ue("task_notifications") === void 0), M && (M.hidden = ue("tab_group_permission") === void 0), I && !r.classList.contains("pluno-pa-widget--open") && (hi = !0), vo(), u.appearance ? (Eo = !0, Xe(
13221
13249
  "web-sdk.widget",
13222
13250
  "Agent state supplied appearance",
13223
13251
  {
@@ -13264,36 +13292,36 @@ async function lw(t = {}) {
13264
13292
  ai("minimized", !1);
13265
13293
  },
13266
13294
  destroy: () => {
13267
- Pe || (tp(), np.dispose(), ip(), Ve(), Pe = !0, Ea(), Zu(), ep(), Ba.disconnect(), b.removeEventListener(
13295
+ Pe || (tp(), np.dispose(), ip(), Ve(), Pe = !0, Ea(), Zu(), ep(), Ba.disconnect(), w.removeEventListener(
13268
13296
  "selectionchange",
13269
13297
  wc
13270
- ), b.removeEventListener("pointerdown", Pa, !0), b.removeEventListener(
13298
+ ), w.removeEventListener("pointerdown", Pa, !0), w.removeEventListener(
13271
13299
  "pointerdown",
13272
13300
  oc,
13273
13301
  !0
13274
- ), b.removeEventListener(
13302
+ ), w.removeEventListener(
13275
13303
  "keydown",
13276
13304
  rc
13277
- ), Ya?.disconnect(), Qa?.disconnect(), Hu(), b.defaultView?.removeEventListener(
13305
+ ), Ya?.disconnect(), Qa?.disconnect(), Hu(), w.defaultView?.removeEventListener(
13278
13306
  "pointerdown",
13279
13307
  Ja,
13280
13308
  !0
13281
- ), b.defaultView?.removeEventListener(
13309
+ ), w.defaultView?.removeEventListener(
13282
13310
  "focus",
13283
13311
  Xi,
13284
13312
  !0
13285
- ), b.defaultView?.removeEventListener(
13313
+ ), w.defaultView?.removeEventListener(
13286
13314
  "focusin",
13287
13315
  Xi,
13288
13316
  !0
13289
- ), b.removeEventListener(
13317
+ ), w.removeEventListener(
13290
13318
  "dragover",
13291
13319
  ic,
13292
13320
  !0
13293
- ), b.removeEventListener("drop", nn, !0), b.removeEventListener("dragend", nn, !0), b.defaultView?.removeEventListener(
13321
+ ), w.removeEventListener("drop", nn, !0), w.removeEventListener("dragend", nn, !0), w.defaultView?.removeEventListener(
13294
13322
  "blur",
13295
13323
  nn
13296
- ), window.removeEventListener("resize", $a), Fa(), $u(), Fu(), Dt !== null && window.clearTimeout(Dt), it !== null && (window.clearTimeout(it), it = null), Ou(), mn !== null && (window.clearTimeout(mn), mn = null), Xt !== null && (window.clearTimeout(Xt), Xt = null), $i?.clear(), Ra && A.destroy(), to?.release(), o.remove());
13324
+ ), window.removeEventListener("resize", $a), Fa(), $u(), Fu(), Dt !== null && window.clearTimeout(Dt), st !== null && (window.clearTimeout(st), st = null), Ou(), mn !== null && (window.clearTimeout(mn), mn = null), Xt !== null && (window.clearTimeout(Xt), Xt = null), $i?.clear(), Ra && A.destroy(), to?.release(), o.remove());
13297
13325
  }
13298
13326
  };
13299
13327
  async function sp(u) {
@@ -13325,7 +13353,7 @@ async function lw(t = {}) {
13325
13353
  return;
13326
13354
  } catch {
13327
13355
  }
13328
- const y = ps(b), I = y instanceof HTMLElement ? y : null, x = document.createElement("textarea");
13356
+ const y = ps(w), I = y instanceof HTMLElement ? y : null, x = document.createElement("textarea");
13329
13357
  x.value = u, x.readOnly = !0, x.setAttribute("aria-hidden", "true"), x.style.position = "fixed", x.style.left = "-9999px", x.style.opacity = "0", document.body.appendChild(x);
13330
13358
  try {
13331
13359
  if (x.select(), x.setSelectionRange(0, u.length), !document.execCommand("copy"))
@@ -13436,13 +13464,13 @@ function gw({
13436
13464
  if (a !== _.pointerId || !r || !c)
13437
13465
  return;
13438
13466
  _.preventDefault();
13439
- const v = _.clientX - r.x, E = _.clientY - r.y;
13440
- !l && Math.hypot(v, E) < Os || (l = !0, t.classList.add("pluno-pa-widget--dragging"), s({ x: c.x + v, y: c.y + E }));
13467
+ const v = _.clientX - r.x, k = _.clientY - r.y;
13468
+ !l && Math.hypot(v, k) < Os || (l = !0, t.classList.add("pluno-pa-widget--dragging"), s({ x: c.x + v, y: c.y + k }));
13441
13469
  }, m = (_) => {
13442
13470
  a === _.pointerId && (_.preventDefault(), _.stopPropagation(), l && (p = { x: _.clientX, y: _.clientY }, o()), d());
13443
13471
  }, f = (_) => {
13444
13472
  a === _.pointerId && (_.preventDefault(), d());
13445
- }, w = (_) => {
13473
+ }, b = (_) => {
13446
13474
  if (!p)
13447
13475
  return;
13448
13476
  const v = Math.hypot(
@@ -13450,15 +13478,15 @@ function gw({
13450
13478
  _.clientY - p.y
13451
13479
  ) <= Os;
13452
13480
  p = null, v && (_.preventDefault(), _.stopPropagation());
13453
- }, b = (_) => {
13481
+ }, w = (_) => {
13454
13482
  if (t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing"))
13455
13483
  return;
13456
- const v = _.shiftKey ? ba : wa, E = i();
13484
+ const v = _.shiftKey ? ba : wa, k = i();
13457
13485
  let L = null;
13458
- _.key === "ArrowUp" ? L = { x: E.x, y: E.y - v } : _.key === "ArrowDown" ? L = { x: E.x, y: E.y + v } : _.key === "ArrowLeft" ? L = { x: E.x - v, y: E.y } : _.key === "ArrowRight" && (L = { x: E.x + v, y: E.y }), L && (_.preventDefault(), _.stopPropagation(), s(L), o());
13486
+ _.key === "ArrowUp" ? L = { x: k.x, y: k.y - v } : _.key === "ArrowDown" ? L = { x: k.x, y: k.y + v } : _.key === "ArrowLeft" ? L = { x: k.x - v, y: k.y } : _.key === "ArrowRight" && (L = { x: k.x + v, y: k.y }), L && (_.preventDefault(), _.stopPropagation(), s(L), o());
13459
13487
  };
13460
- return e.addEventListener("pointerdown", h), e.addEventListener("pointermove", g), e.addEventListener("pointerup", m), e.addEventListener("pointercancel", f), e.addEventListener("click", w, !0), n.addEventListener("keydown", b), () => {
13461
- e.removeEventListener("pointerdown", h), e.removeEventListener("pointermove", g), e.removeEventListener("pointerup", m), e.removeEventListener("pointercancel", f), e.removeEventListener("click", w, !0), n.removeEventListener("keydown", b);
13488
+ return e.addEventListener("pointerdown", h), e.addEventListener("pointermove", g), e.addEventListener("pointerup", m), e.addEventListener("pointercancel", f), e.addEventListener("click", b, !0), n.addEventListener("keydown", w), () => {
13489
+ e.removeEventListener("pointerdown", h), e.removeEventListener("pointermove", g), e.removeEventListener("pointerup", m), e.removeEventListener("pointercancel", f), e.removeEventListener("click", b, !0), n.removeEventListener("keydown", w);
13462
13490
  };
13463
13491
  }
13464
13492
  function fw({
@@ -13477,16 +13505,16 @@ function fw({
13477
13505
  if (o !== f.pointerId || !a || !r)
13478
13506
  return;
13479
13507
  f.preventDefault(), f.stopPropagation();
13480
- const w = f.clientX - a.x, b = f.clientY - a.y;
13481
- !c && Math.hypot(w, b) < Os || (c = !0, t.classList.add("pluno-pa-widget--panel-dragging"), i({ x: r.x + w, y: r.y + b }));
13508
+ const b = f.clientX - a.x, w = f.clientY - a.y;
13509
+ !c && Math.hypot(b, w) < Os || (c = !0, t.classList.add("pluno-pa-widget--panel-dragging"), i({ x: r.x + b, y: r.y + w }));
13482
13510
  }, h = (f) => {
13483
13511
  o === f.pointerId && (f.preventDefault(), f.stopPropagation(), c && s(), l());
13484
13512
  }, g = (f) => {
13485
13513
  o === f.pointerId && (f.preventDefault(), l());
13486
13514
  }, m = (f) => {
13487
- const w = f.shiftKey ? ba : wa, b = n();
13515
+ const b = f.shiftKey ? ba : wa, w = n();
13488
13516
  let _ = null;
13489
- f.key === "ArrowUp" ? _ = { x: b.x, y: b.y - w } : f.key === "ArrowDown" ? _ = { x: b.x, y: b.y + w } : f.key === "ArrowLeft" ? _ = { x: b.x - w, y: b.y } : f.key === "ArrowRight" && (_ = { x: b.x + w, y: b.y }), _ && (f.preventDefault(), f.stopPropagation(), i(_), s());
13517
+ f.key === "ArrowUp" ? _ = { x: w.x, y: w.y - b } : f.key === "ArrowDown" ? _ = { x: w.x, y: w.y + b } : f.key === "ArrowLeft" ? _ = { x: w.x - b, y: w.y } : f.key === "ArrowRight" && (_ = { x: w.x + b, y: w.y }), _ && (f.preventDefault(), f.stopPropagation(), i(_), s());
13490
13518
  };
13491
13519
  return e.addEventListener("pointerdown", p), e.addEventListener("pointermove", d), e.addEventListener("pointerup", h), e.addEventListener("pointercancel", g), e.addEventListener("keydown", m), () => {
13492
13520
  e.removeEventListener("pointerdown", p), e.removeEventListener("pointermove", d), e.removeEventListener("pointerup", h), e.removeEventListener("pointercancel", g), e.removeEventListener("keydown", m);
@@ -13502,31 +13530,31 @@ function mw({
13502
13530
  let o = null, a = null, r = null, c = null, l = !1;
13503
13531
  const p = () => {
13504
13532
  o = null, a = null, r = null, c = null, l = !1, t.classList.remove("pluno-pa-widget--resizing");
13505
- }, d = (w) => {
13506
- const b = w.currentTarget, _ = b.dataset.resizeDirection;
13507
- !t.classList.contains("pluno-pa-widget--open") || !Pl(_) || (w.preventDefault(), w.stopPropagation(), o = w.pointerId, a = _, r = { x: w.clientX, y: w.clientY }, c = n(), l = !1, b.setPointerCapture?.(w.pointerId));
13508
- }, h = (w) => {
13509
- if (o !== w.pointerId || !a || !r || !c)
13533
+ }, d = (b) => {
13534
+ const w = b.currentTarget, _ = w.dataset.resizeDirection;
13535
+ !t.classList.contains("pluno-pa-widget--open") || !Pl(_) || (b.preventDefault(), b.stopPropagation(), o = b.pointerId, a = _, r = { x: b.clientX, y: b.clientY }, c = n(), l = !1, w.setPointerCapture?.(b.pointerId));
13536
+ }, h = (b) => {
13537
+ if (o !== b.pointerId || !a || !r || !c)
13510
13538
  return;
13511
- w.preventDefault(), w.stopPropagation();
13512
- const b = w.clientX - r.x, _ = w.clientY - r.y;
13513
- !l && Math.hypot(b, _) < Os || (l = !0, t.classList.add("pluno-pa-widget--resizing"), i(
13514
- Ml(c, a, b, _)
13539
+ b.preventDefault(), b.stopPropagation();
13540
+ const w = b.clientX - r.x, _ = b.clientY - r.y;
13541
+ !l && Math.hypot(w, _) < Os || (l = !0, t.classList.add("pluno-pa-widget--resizing"), i(
13542
+ Ml(c, a, w, _)
13515
13543
  ));
13516
- }, g = (w) => {
13517
- o === w.pointerId && (w.preventDefault(), w.stopPropagation(), l && s(), p());
13518
- }, m = (w) => {
13519
- o === w.pointerId && (w.preventDefault(), p());
13520
- }, f = (w) => {
13521
- const _ = w.currentTarget.dataset.resizeDirection, v = w.shiftKey ? ba : wa, E = n();
13544
+ }, g = (b) => {
13545
+ o === b.pointerId && (b.preventDefault(), b.stopPropagation(), l && s(), p());
13546
+ }, m = (b) => {
13547
+ o === b.pointerId && (b.preventDefault(), p());
13548
+ }, f = (b) => {
13549
+ const _ = b.currentTarget.dataset.resizeDirection, v = b.shiftKey ? ba : wa, k = n();
13522
13550
  let L = 0, K = 0;
13523
- Pl(_) && (w.key === "ArrowLeft" ? L = -v : w.key === "ArrowRight" ? L = v : w.key === "ArrowUp" ? K = -v : w.key === "ArrowDown" && (K = v), !(L === 0 && K === 0) && (w.preventDefault(), w.stopPropagation(), i(Ml(E, _, L, K)), s()));
13551
+ Pl(_) && (b.key === "ArrowLeft" ? L = -v : b.key === "ArrowRight" ? L = v : b.key === "ArrowUp" ? K = -v : b.key === "ArrowDown" && (K = v), !(L === 0 && K === 0) && (b.preventDefault(), b.stopPropagation(), i(Ml(k, _, L, K)), s()));
13524
13552
  };
13525
- for (const w of e)
13526
- w.addEventListener("pointerdown", d), w.addEventListener("pointermove", h), w.addEventListener("pointerup", g), w.addEventListener("pointercancel", m), w.addEventListener("keydown", f);
13553
+ for (const b of e)
13554
+ b.addEventListener("pointerdown", d), b.addEventListener("pointermove", h), b.addEventListener("pointerup", g), b.addEventListener("pointercancel", m), b.addEventListener("keydown", f);
13527
13555
  return () => {
13528
- for (const w of e)
13529
- w.removeEventListener("pointerdown", d), w.removeEventListener("pointermove", h), w.removeEventListener("pointerup", g), w.removeEventListener("pointercancel", m), w.removeEventListener("keydown", f);
13556
+ for (const b of e)
13557
+ b.removeEventListener("pointerdown", d), b.removeEventListener("pointermove", h), b.removeEventListener("pointerup", g), b.removeEventListener("pointercancel", m), b.removeEventListener("keydown", f);
13530
13558
  };
13531
13559
  }
13532
13560
  function Pl(t) {
@@ -14134,25 +14162,25 @@ function Lw() {
14134
14162
  p.append(d, Gr(12)), l.appendChild(p);
14135
14163
  const h = document.createElement("div");
14136
14164
  h.className = "pluno-pa-widget__model-menu";
14137
- for (const E of Ms)
14138
- h.appendChild(Ul(E));
14165
+ for (const k of Ms)
14166
+ h.appendChild(Ul(k));
14139
14167
  const g = document.createElement("details");
14140
14168
  g.className = "pluno-pa-widget__model-more";
14141
14169
  const m = document.createElement("summary"), f = document.createElement("span");
14142
14170
  f.textContent = "More";
14143
- const w = Gr(12);
14144
- w.classList.add("pluno-pa-widget__model-more-chevron"), m.append(f, w), g.appendChild(m);
14145
- for (const E of ou) {
14146
- const L = Ul(E);
14171
+ const b = Gr(12);
14172
+ b.classList.add("pluno-pa-widget__model-more-chevron"), m.append(f, b), g.appendChild(m);
14173
+ for (const k of ou) {
14174
+ const L = Ul(k);
14147
14175
  L.classList.add("pluno-pa-widget__model-more-option"), g.appendChild(L);
14148
14176
  }
14149
14177
  h.appendChild(g), l.appendChild(h), c.appendChild(l);
14150
- const b = document.createElement("div");
14151
- b.className = "pluno-pa-widget__composer-meta";
14178
+ const w = document.createElement("div");
14179
+ w.className = "pluno-pa-widget__composer-meta";
14152
14180
  const _ = document.createElement("a");
14153
- _.className = "pluno-pa-widget__powered-by", _.href = "https://pluno.ai", _.target = "_blank", _.rel = "noopener noreferrer", _.textContent = "Powered by Pluno.ai.", b.appendChild(_);
14181
+ _.className = "pluno-pa-widget__powered-by", _.href = "https://pluno.ai", _.target = "_blank", _.rel = "noopener noreferrer", _.textContent = "Powered by Pluno.ai.", w.appendChild(_);
14154
14182
  const v = document.createElement("span");
14155
- return v.className = "pluno-pa-widget__ai-disclaimer", v.textContent = "AI can make mistakes. Verify outputs.", b.appendChild(v), c.appendChild(b), t.appendChild(c), t;
14183
+ return v.className = "pluno-pa-widget__ai-disclaimer", v.textContent = "AI can make mistakes. Verify outputs.", w.appendChild(v), c.appendChild(w), t.appendChild(c), t;
14156
14184
  }
14157
14185
  function Ul(t) {
14158
14186
  const e = document.createElement("button");
@@ -14351,24 +14379,24 @@ function zw(t, e) {
14351
14379
  });
14352
14380
  const f = j(o, "clipPath", { id: i.boltClip });
14353
14381
  j(f, "path", { d: qs });
14354
- const w = j(s, "g", {
14382
+ const b = j(s, "g", {
14355
14383
  filter: ct(i.softDropShadow)
14356
14384
  });
14357
- j(w, "path", {
14385
+ j(b, "path", {
14358
14386
  d: qs,
14359
14387
  fill: ct(i.boltEdge)
14360
14388
  });
14361
- const b = "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";
14362
- j(w, "path", {
14363
- d: b,
14389
+ const w = "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";
14390
+ j(b, "path", {
14391
+ d: w,
14364
14392
  fill: ct(i.boltFill),
14365
14393
  filter: ct(i.innerDepth)
14366
- }), j(w, "path", {
14367
- d: b,
14394
+ }), j(b, "path", {
14395
+ d: w,
14368
14396
  fill: ct(i.boltGlow),
14369
14397
  opacity: "0.74"
14370
14398
  });
14371
- const _ = j(w, "g", {
14399
+ const _ = j(b, "g", {
14372
14400
  "clip-path": ct(i.boltClip),
14373
14401
  opacity: "0.42"
14374
14402
  });
@@ -15133,48 +15161,48 @@ function jl(t, e) {
15133
15161
  const i = n[1], s = e ? "Finding example tasks..." : " ";
15134
15162
  i.textContent !== s && (i.textContent = s), i.classList.toggle("pluno-pa-widget__starter-placeholder--loading", e), i.parentElement.setAttribute("aria-hidden", String(!e));
15135
15163
  }
15136
- function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K, U, he, G, oe, R) {
15164
+ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, b, w, _, v, k, L, K, U, he, G, oe, R) {
15137
15165
  const V = (C) => {
15138
- const k = G.states.get(C.authRequestId) ?? { status: G.initialStatus }, N = `integration-retry:${C.authRequestId}`, ye = `integration-connect:${C.authRequestId}`, Le = K?.has(N) ? "retry" : K?.has(ye) ? "connect" : null;
15166
+ const E = G.states.get(C.authRequestId) ?? { status: G.initialStatus }, N = `integration-retry:${C.authRequestId}`, ye = `integration-connect:${C.authRequestId}`, Le = K?.has(N) ? "retry" : K?.has(ye) ? "connect" : null;
15139
15167
  return db(
15140
15168
  C,
15141
- k,
15142
- () => U(k.status === "error" ? N : ye, () => G.onConnect(C)),
15169
+ E,
15170
+ () => U(E.status === "error" ? N : ye, () => G.onConnect(C)),
15143
15171
  G.presentations.get(C.authRequestId),
15144
15172
  Le
15145
15173
  );
15146
15174
  }, O = bp(o), S = _b(o), F = Array.isArray(o.activeScheduledFollowUps) ? o.activeScheduledFollowUps : null, ee = /* @__PURE__ */ new Map();
15147
15175
  if (F !== null)
15148
15176
  for (const C of F) {
15149
- const k = Jn(C.dueAt);
15150
- k && ee.set(C.taskId, { dueAt: C.dueAt, label: k });
15177
+ const E = Jn(C.dueAt);
15178
+ E && ee.set(C.taskId, { dueAt: C.dueAt, label: E });
15151
15179
  }
15152
15180
  else
15153
15181
  for (const C of S) {
15154
- const k = C.scheduledCheckInAt ? Jn(C.scheduledCheckInAt) : null;
15155
- if (!k || !C.scheduledCheckInAt)
15182
+ const E = C.scheduledCheckInAt ? Jn(C.scheduledCheckInAt) : null;
15183
+ if (!E || !C.scheduledCheckInAt)
15156
15184
  continue;
15157
15185
  const N = C.scheduledCheckInId ?? C.id;
15158
15186
  ee.set(N, {
15159
15187
  dueAt: C.scheduledCheckInAt,
15160
- label: k
15188
+ label: E
15161
15189
  });
15162
15190
  }
15163
- const ce = [...ee.values()].sort((C, k) => Date.parse(C.dueAt) - Date.parse(k.dueAt)), te = vb(
15191
+ const ce = [...ee.values()].sort((C, E) => Date.parse(C.dueAt) - Date.parse(E.dueAt)), te = vb(
15164
15192
  S.filter(
15165
15193
  (C) => !Cu(C) && !C.scheduledCheckInAt
15166
15194
  ),
15167
15195
  o.segments
15168
- ), Se = new Map((o.segments ?? []).flatMap((C) => C.activityIds.map((k) => [k, C])));
15196
+ ), Se = new Map((o.segments ?? []).flatMap((C) => C.activityIds.map((E) => [E, C])));
15169
15197
  t.dataset.selectedSessionId = o.sessionId ?? "", t.dataset.loadingSession = String(o.isLoadingSession);
15170
15198
  const P = o.activeResponseUserMessageId;
15171
15199
  if (O.showProgress && o.turnPhase && !o.assistantDraft && P) {
15172
15200
  const C = te.findIndex(
15173
15201
  (N) => N.role === "user" && N.id === P
15174
- ), k = te.some(
15202
+ ), E = te.some(
15175
15203
  (N) => N.role !== "user" && N.respondsToUserMessageId === P
15176
15204
  );
15177
- C !== -1 && !k && te.splice(C + 1, 0, {
15205
+ C !== -1 && !E && te.splice(C + 1, 0, {
15178
15206
  id: `turn-status:${P}`,
15179
15207
  role: "system",
15180
15208
  content: "",
@@ -15184,11 +15212,11 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15184
15212
  loading: !0
15185
15213
  });
15186
15214
  }
15187
- const fe = t.scrollTop, Oe = [], et = /* @__PURE__ */ new Set(), Ce = /* @__PURE__ */ new Set(), $e = /* @__PURE__ */ new Set(), J = (C) => {
15215
+ const fe = t.scrollTop, Oe = [], tt = /* @__PURE__ */ new Set(), Ce = /* @__PURE__ */ new Set(), $e = /* @__PURE__ */ new Set(), J = (C) => {
15188
15216
  C === e && Oe.push(t.querySelector('slot[name="conversation-notices"]') ?? fu("conversation-notices")), C.dataset.sessionId = o.sessionId ?? "", Oe.push(C);
15189
15217
  };
15190
15218
  Sa(n, o.isThinking), n.disabled = !1, s.hidden = !r, r && a !== null && yu(s, a);
15191
- const tt = !!(G?.requests.length || oe || R?.candidate), z = tt || te.length > 0 || ce.length > 0 || !!o.assistantDraft || o.pendingMessageStatus !== null || o.isThinking;
15219
+ const nt = !!(G?.requests.length || oe || R?.candidate), z = nt || te.length > 0 || ce.length > 0 || !!o.assistantDraft || o.pendingMessageStatus !== null || o.isThinking;
15192
15220
  if (i(z || !!o.historyPreparation), o.historyPreparation && z) {
15193
15221
  const C = document.createElement("div");
15194
15222
  C.className = "pluno-pa-widget__transcript-loading", C.setAttribute("role", "status"), C.append(pn(), document.createTextNode("Preparing this conversation…")), J(C);
@@ -15196,8 +15224,8 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15196
15224
  if (o.isLoadingSession && !z) {
15197
15225
  const C = document.createElement("div");
15198
15226
  C.className = "pluno-pa-widget__transcript-loading", C.setAttribute("role", "status");
15199
- const k = document.createElement("span");
15200
- k.textContent = o.historyPreparation ? "Preparing this conversation…" : "Loading chat...", C.append(pn(), k), d.clear(), h.clear(), g.clear(), J(C), J(e), Tt(t, Oe);
15227
+ const E = document.createElement("span");
15228
+ E.textContent = o.historyPreparation ? "Preparing this conversation…" : "Loading chat...", C.append(pn(), E), d.clear(), h.clear(), g.clear(), J(C), J(e), Tt(t, Oe);
15201
15229
  return;
15202
15230
  }
15203
15231
  if (!z && o.sessionId && !o.isDraftSession) {
@@ -15210,16 +15238,16 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15210
15238
  return;
15211
15239
  }
15212
15240
  }
15213
- if (te.length === 0 && !tt && ce.length === 0 && !o.assistantDraft && (!o.lastError || Pi(o.lastErrorCode) === "bottom_notice") && !o.pendingMessageStatus && !o.isThinking) {
15241
+ if (te.length === 0 && !nt && ce.length === 0 && !o.assistantDraft && (!o.lastError || Pi(o.lastErrorCode) === "bottom_notice") && !o.pendingMessageStatus && !o.isThinking) {
15214
15242
  const C = JSON.stringify([
15215
15243
  o.sessionId,
15216
15244
  o.user?.id,
15217
15245
  _,
15218
15246
  o.starterPrompts,
15219
15247
  f()
15220
- ]), k = d.get("welcome");
15221
- if (k?.renderSignature === C) {
15222
- jl(k.node, o.starterPromptsLoading), J(k.node), J(e), Tt(t, Oe);
15248
+ ]), E = d.get("welcome");
15249
+ if (E?.renderSignature === C) {
15250
+ jl(E.node, o.starterPromptsLoading), J(E.node), J(e), Tt(t, Oe);
15223
15251
  return;
15224
15252
  }
15225
15253
  const N = document.createElement("div");
@@ -15240,7 +15268,7 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15240
15268
  for (const Z of X) {
15241
15269
  const ae = document.createElement("button");
15242
15270
  ae.type = "button", ae.className = "pluno-pa-widget__starter-prompt", ae.textContent = Z, ae.addEventListener("click", () => {
15243
- w(Z);
15271
+ b(Z);
15244
15272
  }), B.appendChild(ae);
15245
15273
  }
15246
15274
  else
@@ -15265,7 +15293,7 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15265
15293
  return me = !1, !1;
15266
15294
  const C = O.showProgress && ie.some(
15267
15295
  (N) => N.id === o.activity?.activeItemId
15268
- ), k = Ab(
15296
+ ), E = Ab(
15269
15297
  ie,
15270
15298
  C,
15271
15299
  p,
@@ -15275,7 +15303,7 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15275
15303
  f(),
15276
15304
  Se.get(ie[0].id)?.collapsed ?? !0
15277
15305
  );
15278
- return J(k), Y = null, H = k, ie = [], me = C, !0;
15306
+ return J(E), Y = null, H = E, ie = [], me = C, !0;
15279
15307
  }, Fe = /* @__PURE__ */ new Set();
15280
15308
  let ht = !1;
15281
15309
  const je = () => {
@@ -15284,38 +15312,38 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15284
15312
  ve = [];
15285
15313
  };
15286
15314
  for (let C = 0; C < te.length; C += 1) {
15287
- const k = te[C];
15288
- if (k.role === "tool" && k.integrationAuthRequest && G) {
15289
- Fe.add(k.integrationAuthRequest.authRequestId);
15290
- const B = V(k.integrationAuthRequest);
15315
+ const E = te[C];
15316
+ if (E.role === "tool" && E.integrationAuthRequest && G) {
15317
+ Fe.add(E.integrationAuthRequest.authRequestId);
15318
+ const B = V(E.integrationAuthRequest);
15291
15319
  ve.push(B);
15292
15320
  continue;
15293
15321
  }
15294
- if (k.role === "tool" && k.personalChannelConnectionRequest && oe) {
15322
+ if (E.role === "tool" && E.personalChannelConnectionRequest && oe) {
15295
15323
  ht = !0, ve.push(
15296
15324
  Kl(
15297
- k.personalChannelConnectionRequest,
15325
+ E.personalChannelConnectionRequest,
15298
15326
  oe.onConnect,
15299
15327
  oe.presentation
15300
15328
  )
15301
15329
  );
15302
15330
  continue;
15303
15331
  }
15304
- if (k.role === "tool") {
15305
- ie.length > 0 && Se.get(ie[0].id)?.id !== Se.get(k.id)?.id && ke(), ie.push(k);
15332
+ if (E.role === "tool") {
15333
+ ie.length > 0 && Se.get(ie[0].id)?.id !== Se.get(E.id)?.id && ke(), ie.push(E);
15306
15334
  continue;
15307
15335
  }
15308
- if (k.role === "system" && k.dataType === "run_status" && k.steered === !0) {
15336
+ if (E.role === "system" && E.dataType === "run_status" && E.steered === !0) {
15309
15337
  if (!ke()) {
15310
15338
  const Z = Pb(f());
15311
15339
  J(Z), Y = null, H = Z;
15312
15340
  }
15313
15341
  continue;
15314
15342
  }
15315
- if (Yr(k)) {
15343
+ if (Yr(E)) {
15316
15344
  if (!O.showProgress)
15317
15345
  continue;
15318
- const B = ke(), Z = Eu(k);
15346
+ const B = ke(), Z = Eu(E);
15319
15347
  if (B) {
15320
15348
  if (!me) {
15321
15349
  const ae = Vl(
@@ -15338,69 +15366,69 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15338
15366
  }
15339
15367
  continue;
15340
15368
  }
15341
- if (k.role === "system") {
15342
- if (k.dataType === "run_error" || k.dataType === "run_status") {
15369
+ if (E.role === "system") {
15370
+ if (E.dataType === "run_error" || E.dataType === "run_status") {
15343
15371
  const B = ke(), Z = te.some(
15344
- (we) => we.role === "tool" && Ns(we, k)
15372
+ (we) => we.role === "tool" && Ns(we, E)
15345
15373
  );
15346
15374
  if (!B && !Z) {
15347
15375
  const we = Oi(f());
15348
15376
  we.classList.add("pluno-pa-widget__terminal-marker"), J(we);
15349
15377
  }
15350
- const ae = document.createElement("div"), hn = k.dataType === "run_error";
15351
- if (ae.className = hn ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", ae.dataset.messageKey = Ia(k), ae.dataset.canonicalItemKey = k.id, ae.dataset.messageRole = "system", k.provisional || (ae.dataset.terminalResponseKey = k.id), k.runId && (ae.dataset.runId = k.runId), ae.textContent = Us(
15352
- k.content
15353
- ), hn && k.securitySettingsUrl) {
15378
+ const ae = document.createElement("div"), hn = E.dataType === "run_error";
15379
+ if (ae.className = hn ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", ae.dataset.messageKey = Ia(E), ae.dataset.canonicalItemKey = E.id, ae.dataset.messageRole = "system", E.provisional || (ae.dataset.terminalResponseKey = E.id), E.runId && (ae.dataset.runId = E.runId), ae.textContent = Us(
15380
+ E.content
15381
+ ), hn && E.securitySettingsUrl) {
15354
15382
  const we = document.createElement("a");
15355
- we.className = "pluno-pa-widget__error-retry", we.href = k.securitySettingsUrl, we.target = "_blank", we.rel = "noreferrer", we.textContent = "Security settings", ae.appendChild(we);
15383
+ we.className = "pluno-pa-widget__error-retry", we.href = E.securitySettingsUrl, we.target = "_blank", we.rel = "noreferrer", we.textContent = "Security settings", ae.appendChild(we);
15356
15384
  }
15357
15385
  J(ae), Y = hn ? ae : null, H = hn ? null : ae, je();
15358
15386
  }
15359
15387
  continue;
15360
15388
  }
15361
- k.role === "user" && je();
15362
- const N = ke(), ye = Us(k.content), Le = k.role === "assistant" && te.some(
15363
- (B) => B.role === "tool" && Ns(B, k)
15389
+ E.role === "user" && je();
15390
+ const N = ke(), ye = Us(E.content), Le = E.role === "assistant" && te.some(
15391
+ (B) => B.role === "tool" && Ns(B, E)
15364
15392
  );
15365
- if (k.role === "assistant" && !N && !Le) {
15393
+ if (E.role === "assistant" && !N && !Le) {
15366
15394
  const B = Oi(f());
15367
15395
  J(B), Y = null, H = B;
15368
15396
  }
15369
15397
  const X = ub(
15370
- k,
15398
+ E,
15371
15399
  ye,
15372
15400
  d,
15373
- et,
15401
+ tt,
15374
15402
  he
15375
15403
  );
15376
- if (X.querySelector("[data-submission-retry]")?.remove(), k.role === "user" && k.retryable) {
15404
+ if (X.querySelector("[data-submission-retry]")?.remove(), E.role === "user" && E.retryable) {
15377
15405
  const B = document.createElement("button");
15378
- B.type = "button", B.className = "pluno-pa-widget__error-retry", B.dataset.submissionRetry = k.id, B.textContent = "Retry this message", B.addEventListener("click", () => b(k.id)), X.appendChild(B);
15406
+ B.type = "button", B.className = "pluno-pa-widget__error-retry", B.dataset.submissionRetry = E.id, B.textContent = "Retry this message", B.addEventListener("click", () => w(E.id)), X.appendChild(B);
15379
15407
  }
15380
- J(X), Y = X, H = null, k.role === "assistant" && je();
15408
+ J(X), Y = X, H = null, E.role === "assistant" && je();
15381
15409
  }
15382
15410
  const M = ke(), Q = te[te.length - 1]?.role === "assistant";
15383
15411
  if (O.showProgress && o.turnPhase && !o.assistantDraft && !q && !Q && !W) {
15384
15412
  const C = o.activeResponseUserMessageId ? `response:${o.activeResponseUserMessageId}` : `session:${o.sessionId ?? "pending"}`;
15385
15413
  if (M) {
15386
15414
  if (!me) {
15387
- const k = Vl(
15415
+ const E = Vl(
15388
15416
  g,
15389
15417
  $e,
15390
15418
  C,
15391
15419
  le
15392
15420
  );
15393
- J(k), Y = null, H = k;
15421
+ J(E), Y = null, H = E;
15394
15422
  }
15395
15423
  } else {
15396
- const k = Wl(
15424
+ const E = Wl(
15397
15425
  g,
15398
15426
  $e,
15399
15427
  C,
15400
15428
  f(),
15401
15429
  le
15402
15430
  );
15403
- J(k), Y = null, H = k;
15431
+ J(E), Y = null, H = E;
15404
15432
  }
15405
15433
  }
15406
15434
  if (o.lastError && Pi(o.lastErrorCode) === "conversation") {
@@ -15417,14 +15445,14 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15417
15445
  const B = document.createElement("button");
15418
15446
  B.type = "button", B.className = "pluno-pa-widget__error-retry";
15419
15447
  const Z = K?.has(X) === !0 || X === "retry_history" && o.conversationDiagnostics?.queryRequestId != null || X === "retry_message" && o.isRetrying;
15420
- B.disabled = Z, B.setAttribute("aria-busy", String(Z)), B.textContent = X === "new_chat" ? Z ? "Starting new chat" : "Start new chat" : Z ? "Trying" : "Try again", Z && B.prepend(pn()), B.addEventListener("click", () => U(X, X === "retry_history" ? E : X === "retry_message" ? b : L)), ye.appendChild(B);
15448
+ B.disabled = Z, B.setAttribute("aria-busy", String(Z)), B.textContent = X === "new_chat" ? Z ? "Starting new chat" : "Start new chat" : Z ? "Trying" : "Try again", Z && B.prepend(pn()), B.addEventListener("click", () => U(X, X === "retry_history" ? k : X === "retry_message" ? w : L)), ye.appendChild(B);
15421
15449
  }
15422
15450
  N.appendChild(ye), J(N), Y = null, H = N;
15423
15451
  }
15424
15452
  for (const C of G?.requests ?? []) {
15425
15453
  if (Fe.has(C.authRequestId)) continue;
15426
- const k = V(C);
15427
- J(k), Y = null, H = k;
15454
+ const E = V(C);
15455
+ J(E), Y = null, H = E;
15428
15456
  }
15429
15457
  if (oe && !ht) {
15430
15458
  const C = Kl(
@@ -15451,11 +15479,11 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15451
15479
  }
15452
15480
  je();
15453
15481
  for (const C of ce) {
15454
- const k = document.createElement("div");
15455
- k.className = "pluno-pa-widget__next-check-in", k.append(
15482
+ const E = document.createElement("div");
15483
+ E.className = "pluno-pa-widget__next-check-in", E.append(
15456
15484
  Hw(C.dueAt),
15457
15485
  document.createTextNode(C.label)
15458
- ), J(k), Y = null, H = k;
15486
+ ), J(E), Y = null, H = E;
15459
15487
  }
15460
15488
  Y?.classList.add(
15461
15489
  "pluno-pa-widget__message--bottom-reserve"
@@ -15463,7 +15491,7 @@ function lb(t, e, n, i, s, o, a, r, c, l, p, d, h, g, m, f, w, b, _, v, E, L, K,
15463
15491
  "pluno-pa-widget__bottom-reserve-compact"
15464
15492
  ), J(e), yb(
15465
15493
  d,
15466
- et
15494
+ tt
15467
15495
  ), wb(
15468
15496
  h,
15469
15497
  Ce
@@ -15823,7 +15851,7 @@ function Us(t) {
15823
15851
  return t.replace(/\uE200[^\uE201]*(?:\uE201|$)/g, "");
15824
15852
  }
15825
15853
  function Ab(t, e, n, i, s, o, a, r = !0) {
15826
- const c = t.length > 0 && t.every((E) => E.steered === !0);
15854
+ const c = t.length > 0 && t.every((k) => k.steered === !0);
15827
15855
  e = e && !c;
15828
15856
  const l = Mb(t);
15829
15857
  s.add(l);
@@ -15833,7 +15861,7 @@ function Ab(t, e, n, i, s, o, a, r = !0) {
15833
15861
  t
15834
15862
  );
15835
15863
  if (!p) {
15836
- const E = document.createElement("article"), L = Mt(
15864
+ const k = document.createElement("article"), L = Mt(
15837
15865
  "pluno-pa-widget__character--tool-group",
15838
15866
  a
15839
15867
  ), K = JSON.stringify(a), U = document.createElement("div");
@@ -15842,14 +15870,14 @@ function Ab(t, e, n, i, s, o, a, r = !0) {
15842
15870
  oe.className = "pluno-pa-widget__tool-summary";
15843
15871
  const R = document.createElement("div");
15844
15872
  R.className = "pluno-pa-widget__tool-summary-title", oe.appendChild(R), oe.addEventListener("click", () => {
15845
- const O = E.dataset.responseGroupKey ?? l;
15846
- G.open ? (n.delete(O), n.add(`closed:${O}`)) : (n.add(O), n.delete(`closed:${O}`)), o(), R.textContent = G.open ? E.dataset.collapsedActivityTitle ?? "Activities" : "Activities";
15873
+ const O = k.dataset.responseGroupKey ?? l;
15874
+ G.open ? (n.delete(O), n.add(`closed:${O}`)) : (n.add(O), n.delete(`closed:${O}`)), o(), R.textContent = G.open ? k.dataset.collapsedActivityTitle ?? "Activities" : "Activities";
15847
15875
  }), G.appendChild(oe);
15848
15876
  const V = document.createElement("div");
15849
15877
  V.className = "pluno-pa-widget__tool-lines", G.addEventListener("toggle", () => {
15850
- E.dataset.responseGroupKey, E.classList.toggle("pluno-pa-widget__tool-group--open", G.open), R.textContent = G.open ? "Activities" : E.dataset.collapsedActivityTitle ?? "Activities";
15878
+ k.dataset.responseGroupKey, k.classList.toggle("pluno-pa-widget__tool-group--open", G.open), R.textContent = G.open ? "Activities" : k.dataset.collapsedActivityTitle ?? "Activities";
15851
15879
  }), p = {
15852
- node: E,
15880
+ node: k,
15853
15881
  character: L,
15854
15882
  characterSignature: K,
15855
15883
  activeContent: U,
@@ -15877,17 +15905,17 @@ function Ab(t, e, n, i, s, o, a, r = !0) {
15877
15905
  d.lineNodes
15878
15906
  );
15879
15907
  if (e) {
15880
- const E = d.activeContent;
15881
- return Tt(E, [
15908
+ const k = d.activeContent;
15909
+ return Tt(k, [
15882
15910
  d.thinkingStatus,
15883
15911
  m
15884
- ]), Tt(g, [d.character, E]), g;
15912
+ ]), Tt(g, [d.character, k]), g;
15885
15913
  }
15886
15914
  const f = d.details;
15887
15915
  f.open = n.has(l) || !n.has(`closed:${l}`) && !r, g.classList.toggle("pluno-pa-widget__tool-group--open", f.open);
15888
- const w = t[t.length - 1], b = Us(
15889
- w.content
15890
- ).trim(), _ = w.phase === "commentary", v = b ? _ ? b : Ru(b) : c ? "Steered" : "Thinking...";
15916
+ const b = t[t.length - 1], w = Us(
15917
+ b.content
15918
+ ).trim(), _ = b.phase === "commentary", v = w ? _ ? w : Ru(w) : c ? "Steered" : "Thinking...";
15891
15919
  return g.dataset.collapsedActivityTitle = v, d.summaryTitle.replaceChildren(), d.summaryTitle.classList.add(
15892
15920
  "pluno-pa-widget__tool-summary-markdown"
15893
15921
  ), xa(
@@ -16058,8 +16086,8 @@ function Db(t, e) {
16058
16086
  break;
16059
16087
  const h = document.createElement("tr");
16060
16088
  n.forEach((g, m) => {
16061
- const f = document.createElement("td"), w = s[m];
16062
- w && f.classList.add(`pluno-pa-widget__table-cell--${w}`), ln(f, d[m] ?? ""), h.appendChild(f);
16089
+ const f = document.createElement("td"), b = s[m];
16090
+ b && f.classList.add(`pluno-pa-widget__table-cell--${b}`), ln(f, d[m] ?? ""), h.appendChild(f);
16063
16091
  }), l.appendChild(h), p += 1;
16064
16092
  }
16065
16093
  return a.appendChild(l), o.appendChild(a), { element: o, nextIndex: p };
@@ -19741,9 +19769,9 @@ async function Hb(t, e) {
19741
19769
  if (!n.ok) {
19742
19770
  const s = await n.text(), o = om(s);
19743
19771
  if (o)
19744
- throw console.error(o), new Ze(o, !1, n.status);
19772
+ throw console.error(o), new et(o, !1, n.status);
19745
19773
  const a = n.status === 408 || n.status === 425 || n.status === 429 || n.status >= 500;
19746
- throw new Ze(
19774
+ throw new et(
19747
19775
  n.status === 401 ? "Sign in to your app again, then try connecting to chat." : n.status === 403 ? "Chat access is not configured for this page. Contact your app administrator, then try again." : a ? "Chat is temporarily unavailable. Reconnecting…" : "Chat setup could not be completed. Contact your app administrator, then try again.",
19748
19776
  a,
19749
19777
  n.status,
@@ -19751,13 +19779,13 @@ async function Hb(t, e) {
19751
19779
  );
19752
19780
  }
19753
19781
  const i = await n.json().catch(() => {
19754
- throw new Ze(
19782
+ throw new et(
19755
19783
  "Chat setup did not return a session. Contact your app administrator, then try again.",
19756
19784
  !1
19757
19785
  );
19758
19786
  });
19759
19787
  if (typeof i?.token != "string" || !i.token.trim())
19760
- throw new Ze(
19788
+ throw new et(
19761
19789
  "Chat setup did not return a session. Contact your app administrator, then try again.",
19762
19790
  !1
19763
19791
  );
@@ -19949,7 +19977,7 @@ function Qb(t) {
19949
19977
  }
19950
19978
  Xb(import.meta.url);
19951
19979
  export {
19952
- Ze as ProductAgentTokenProviderError,
19980
+ et as ProductAgentTokenProviderError,
19953
19981
  cw as createProductAgentPreviewBridgeWebSocketFactory,
19954
19982
  lw as mountPlunoProductAgentWidget
19955
19983
  };