@pluno/product-agent-web 0.1.277 → 0.1.279

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.
@@ -37,7 +37,7 @@ function Wp(t, e, n, i) {
37
37
  function Vp(t) {
38
38
  return zr(t) > 0.5 ? [24, 24, 27] : [250, 250, 249];
39
39
  }
40
- const Gp = "0.1.277", ai = {
40
+ const Gp = "0.1.279", ai = {
41
41
  version: Gp
42
42
  }, me = (t) => typeof t == "string" && /^[a-zA-Z0-9:_.-]{1,160}$/.test(t) ? t : null;
43
43
  function qd(t) {
@@ -351,20 +351,20 @@ function Xo(t, e, n, i) {
351
351
  if (!r) continue;
352
352
  const l = r.sessionId ? e.sessions[r.sessionId] : void 0, c = l?.execution?.user_message_ids ?? [], u = ["queued", "thinking", "steering"].includes(l?.execution?.phase ?? "idle"), d = t.interactions.openings[a], p = d && (d.sessionId === r.sessionId || d.sessionId === null) ? { ...d, sessionId: r.sessionId } : { sessionId: r.sessionId, generation: ++o, openedAt: i, awaitingBaseline: r.sessionId !== null && !l?.execution, ignoredTurns: c, turns: {}, shown: {} };
353
353
  if (p.awaitingBaseline && l?.execution) {
354
- const y = c.filter((g) => {
355
- const b = e.submissions[g];
354
+ const y = c.filter((f) => {
355
+ const b = e.submissions[f];
356
356
  return b?.conversationScopeId === a && b.submittedAt >= p.openedAt;
357
357
  });
358
- p.awaitingBaseline = !1, p.ignoredTurns = c.filter((g) => !y.includes(g));
358
+ p.awaitingBaseline = !1, p.ignoredTurns = c.filter((f) => !y.includes(f));
359
359
  }
360
- const f = {};
361
- for (const [y, g] of Object.entries(p.turns)) {
362
- const b = u && c.includes(y), _ = b && !g.active ? i : g.startedAt;
363
- f[y] = { ...g, startedAt: _, active: b, notifications: !g.notificationsSuppressed && (g.notifications || b && i - _ >= 1e4) };
360
+ const g = {};
361
+ for (const [y, f] of Object.entries(p.turns)) {
362
+ const b = u && c.includes(y), w = b && !f.active ? i : f.startedAt;
363
+ g[y] = { ...f, startedAt: w, active: b, notifications: !f.notificationsSuppressed && (f.notifications || b && i - w >= 1e4) };
364
364
  }
365
365
  if (u)
366
- for (const y of c) !p.ignoredTurns.includes(y) && !f[y] && (f[y] = { startedAt: i, active: !0, notifications: !1, tab_grouping: (t.interactions.crossTabTurns[r.sessionId] ?? []).includes(y) });
367
- s[a] = { ...p, turns: f };
366
+ for (const y of c) !p.ignoredTurns.includes(y) && !g[y] && (g[y] = { startedAt: i, active: !0, notifications: !1, tab_grouping: (t.interactions.crossTabTurns[r.sessionId] ?? []).includes(y) });
367
+ s[a] = { ...p, turns: g };
368
368
  }
369
369
  return { ...t, interactions: { ...t.interactions, openings: s, openingGeneration: o } };
370
370
  }
@@ -657,14 +657,14 @@ function gn(t, e, n) {
657
657
  collapsed: !1
658
658
  });
659
659
  }
660
- const d = o?.execution, p = a.filter((C) => !C.cancelled && C.delivery !== "failed"), f = p.filter((C) => C.delivery !== "accepted" && C.executionVersion === null), y = p.filter((C) => C.delivery === "accepted" && C.executionVersion === null), g = p[p.length - 1], b = f.length > 0, _ = g !== void 0 && y.includes(g);
661
- let S = b ? "submitting" : _ ? "awaiting_execution" : d?.phase ?? "idle";
662
- const k = Object.entries(t.stops).filter(([C]) => C === n || s !== null && e.selections[C]?.sessionId === s).map(([, C]) => C).find((C) => (!a.length || C.userMessageIds.includes(a[a.length - 1].userMessageId) || !b && !_ && Tt(d).some((U) => C.userMessageIds.includes(U))) && (!d || d.version <= C.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((U) => U.cancelled && U.executionVersion === null && C.userMessageIds.includes(U.userMessageId)))), m = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((C) => C.delivery === "accepted" && C.executionVersion === null && k?.userMessageIds.includes(C.userMessageId));
660
+ const d = o?.execution, p = a.filter((C) => !C.cancelled && C.delivery !== "failed"), g = p.filter((C) => C.delivery !== "accepted" && C.executionVersion === null), y = p.filter((C) => C.delivery === "accepted" && C.executionVersion === null), f = p[p.length - 1], b = g.length > 0, w = f !== void 0 && y.includes(f);
661
+ let S = b ? "submitting" : w ? "awaiting_execution" : d?.phase ?? "idle";
662
+ const k = Object.entries(t.stops).filter(([C]) => C === n || s !== null && e.selections[C]?.sessionId === s).map(([, C]) => C).find((C) => (!a.length || C.userMessageIds.includes(a[a.length - 1].userMessageId) || !b && !w && Tt(d).some((U) => C.userMessageIds.includes(U))) && (!d || d.version <= C.executionVersion || ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((U) => U.cancelled && U.executionVersion === null && C.userMessageIds.includes(U.userMessageId)))), m = d && ["thinking", "steering", "queued", "stopping"].includes(d.phase) || a.some((C) => C.delivery === "accepted" && C.executionVersion === null && k?.userMessageIds.includes(C.userMessageId));
663
663
  k && m && !b && (!d || !["thinking", "steering", "queued", "stopping"].includes(d.phase) || Tt(d).every((C) => k.userMessageIds.includes(C))) && (S = "stopping"), k && !m && !b && a.some((C) => C.cancelled && C.executionVersion === null && k.userMessageIds.includes(C.userMessageId)) && (S = a.some((C) => k.userMessageIds.includes(C.userMessageId) && ["sending", "uncertain"].includes(C.delivery)) ? "stopping" : "stopped");
664
- const w = ["thinking", "steering", "queued"].includes(S), I = t.stops[n] ?? k, x = I?.userMessageIds.filter((C) => !["completed", "failed"].includes(o?.executionByUserMessage[C]?.phase ?? "")) ?? [], E = x.some((C) => {
664
+ const _ = ["thinking", "steering", "queued"].includes(S), I = t.stops[n] ?? k, x = I?.userMessageIds.filter((C) => !["completed", "failed"].includes(o?.executionByUserMessage[C]?.phase ?? "")) ?? [], E = x.some((C) => {
665
665
  const U = a.find((Z) => Z.userMessageId === C);
666
666
  return !Object.values(t.operations).some((Z) => Z.command.type === "run.stop" && Z.command.payload.expectedUserMessageId === C && Z.phase === "done") && (U?.executionVersion === null && ["sending", "uncertain", "accepted"].includes(U.delivery) || !!(d && Tt(d).includes(C) && ["thinking", "steering", "queued", "stopping"].includes(d.phase)));
667
- }), A = d?.user_message_ids ?? [], L = b || _ ? g?.userMessageId ?? null : A[A.length - 1] ?? null, P = u.find((C) => C.userMessageId === L), z = w ? [...P?.activityIds ?? []].reverse().find((C) => c[C] === "open") ?? null : null, B = s !== null && !!e.selections[n]?.provisionalId && r.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
667
+ }), A = d?.user_message_ids ?? [], L = b || w ? f?.userMessageId ?? null : A[A.length - 1] ?? null, M = u.find((C) => C.userMessageId === L), z = _ ? [...M?.activityIds ?? []].reverse().find((C) => c[C] === "open") ?? null : null, B = s !== null && !!e.selections[n]?.provisionalId && r.length === 0 && a.length === 0 && // The first persisted idle snapshot already has a positive synchronization version.
668
668
  (!o?.execution || o.execution.phase === "idle" && o.execution.user_message_ids.length === 0) && Object.values(t.operations).some((C) => C.conversationScopeId === n && C.phase === "done" && ["runtime.warmup", "attachment.prepare"].includes(C.command.type) && !C.command.payload.sessionId && C.result?.sessionId === s);
669
669
  return We({
670
670
  historyRefreshFailure: o?.historyRefreshFailure ?? null,
@@ -683,7 +683,7 @@ function gn(t, e, n) {
683
683
  streamStates: c,
684
684
  preparation: o?.preparation ?? null,
685
685
  stop: I ? { ...I, userMessageIds: x, pending: E } : null,
686
- segments: u.map((C, U) => ({ ...C, collapsed: w ? C.userMessageId !== L : U < u.length - 1 || C.activityIds.length > 0 })),
686
+ segments: u.map((C, U) => ({ ...C, collapsed: _ ? C.userMessageId !== L : U < u.length - 1 || C.activityIds.length > 0 })),
687
687
  activity: { phase: S, activeItemId: z, userMessageId: L, executionKey: JSON.stringify([...Tt(d)].sort()) },
688
688
  // Staging transfers the immutable input to the core. Waiting for backend acceptance leaves
689
689
  // the same submitted text in the optimistic transcript and composer during delivery.
@@ -699,7 +699,7 @@ function jd(t, e) {
699
699
  return { type: "preparation", submission: o };
700
700
  if (o && !o.cancelled && (o.delivery === "uncertain" || o.delivery === "failed" && !["attachment_source_unavailable", "context_preparation_interrupted"].includes(o.error?.code ?? "") || t.deliveries[o.userMessageId]?.phase === "paused"))
701
701
  return { type: "delivery", userMessageId: o.userMessageId };
702
- if (e && o?.delivery !== "accepted") return null;
702
+ if (e && (o ? o.delivery !== "accepted" : !n.has(e))) return null;
703
703
  const a = e ?? [...t.items].reverse().find((r) => r.type === "user_message")?.id ?? [...t.submissions].reverse().find((r) => !r.cancelled && r.delivery === "accepted")?.userMessageId;
704
704
  return t.sessionId && a ? { type: "execution", userMessageId: a, sessionId: t.sessionId } : null;
705
705
  }
@@ -750,7 +750,7 @@ function fh(t, e, n) {
750
750
  const i = t.account.authority;
751
751
  if (!i) return [];
752
752
  const s = Ke(i.profile, "canShowPersonalFeatures"), o = [], a = t.features.now, r = (l) => {
753
- const c = Object.values(t.features.pending).filter((f) => f.mode === "mutation" && l.includes(f.key)), u = c.some((f) => f.status === "pending"), d = c[c.length - 1], p = d?.status === "error" ? d.error : null;
753
+ const c = Object.values(t.features.pending).filter((g) => g.mode === "mutation" && l.includes(g.key)), u = c.some((g) => g.status === "pending"), d = c[c.length - 1], p = d?.status === "error" ? d.error : null;
754
754
  return { status: u ? "pending" : p ? "error" : "presentable", error: p };
755
755
  };
756
756
  if (i.profile === "main_web_chat") for (const [l, c] of Object.entries(t.interactions.deviceHints)) {
@@ -778,23 +778,23 @@ function fh(t, e, n) {
778
778
  if (!Ke(i.profile, c)) continue;
779
779
  const u = n.conversationScopeId ? t.interactions.openings[n.conversationScopeId] : void 0;
780
780
  if (!n.sessionId || !u || u.sessionId !== n.sessionId || !Ld(t, n.conversationScopeId, l) || t.features.refreshRequired && !u.shown[l] || i.profile === "main_web_chat" && !t.interactions.bridgeReady && !u.shown[l]) continue;
781
- const d = ji(t, l), p = t.interactions.preferencePrompts[l], f = t.interactions.deviceFacts[l], y = `preference:${l}`, g = d === null;
782
- if (d === !1 || t.features.desiredPreferences[l] === !1 || g && p.snoozedUntil && Date.parse(p.snoozedUntil) > a || !g && (f.permission !== "missing" || f.snoozedUntil && Date.parse(f.snoozedUntil) > a)) continue;
783
- const b = Object.values(t.interactions.devicePending).some((k) => k.feature === l), _ = r([y, `preferenceSnooze:${l}`, `preferenceAcknowledge:${l}`]), S = _.error ?? t.interactions.deviceErrors[l] ?? (u.shown[l] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
781
+ const d = ji(t, l), p = t.interactions.preferencePrompts[l], g = t.interactions.deviceFacts[l], y = `preference:${l}`, f = d === null;
782
+ if (d === !1 || t.features.desiredPreferences[l] === !1 || f && p.snoozedUntil && Date.parse(p.snoozedUntil) > a || !f && (g.permission !== "missing" || g.snoozedUntil && Date.parse(g.snoozedUntil) > a)) continue;
783
+ const b = Object.values(t.interactions.devicePending).some((k) => k.feature === l), w = r([y, `preferenceSnooze:${l}`, `preferenceAcknowledge:${l}`]), S = w.error ?? t.interactions.deviceErrors[l] ?? (u.shown[l] && t.interactions.bridgeError ? { code: "connection_interrupted", message: t.interactions.bridgeError, retryable: !0 } : null);
784
784
  o.push({
785
785
  id: y,
786
- category: g ? "preference" : "permission",
786
+ category: f ? "preference" : "permission",
787
787
  placement: "bottom_overlay",
788
788
  sourceId: null,
789
789
  conversationId: null,
790
790
  userMessageId: null,
791
791
  sourceVersion: u.generation,
792
792
  decisionRevision: p.revision,
793
- actions: g ? ["enable", "not_now", "dont_enable"] : ["allow", "not_now"],
794
- status: b ? "pending" : S ? "error" : _.status,
793
+ actions: f ? ["enable", "not_now", "dont_enable"] : ["allow", "not_now"],
794
+ status: b ? "pending" : S ? "error" : w.status,
795
795
  error: S,
796
796
  payload: { feature: l, openingGeneration: u.generation },
797
- nextEligibleAt: g ? p.snoozedUntil : f.snoozedUntil
797
+ nextEligibleAt: f ? p.snoozedUntil : g.snoozedUntil
798
798
  });
799
799
  }
800
800
  for (const l of Object.values(t.interactions.sources)) {
@@ -807,7 +807,7 @@ function fh(t, e, n) {
807
807
  if (c.wait_for_terminal && (!y || !gh(y, l.user_message_id)) || (i.profile.startsWith("extension_") ? t.interactions.localSharing[l.id]?.resolved : rl(t.interactions.decisions[`prompt:social_share:${l.id}`], a))) continue;
808
808
  }
809
809
  if (c.kind === "integration_auth" && !Ke(i.profile, "canManageIntegrationAuth") || c.kind === "personal_channel" && !s) continue;
810
- const u = c.kind === "integration_auth" && l.lifecycle === "pending" && Date.parse(c.expires_at) <= a ? "expired" : l.lifecycle, d = t.interactions.decisions[`prompt:social_share:${l.id}`], p = t.interactions.localSharing[l.id], f = Object.values(t.interactions.actions).filter((y) => y.interactionId === l.id && y.sourceVersion === l.version && (y.operation.kind !== "connect" || y.operation.source.conversation_id === l.conversation_id)).slice(-1)[0];
810
+ const u = c.kind === "integration_auth" && l.lifecycle === "pending" && Date.parse(c.expires_at) <= a ? "expired" : l.lifecycle, d = t.interactions.decisions[`prompt:social_share:${l.id}`], p = t.interactions.localSharing[l.id], g = Object.values(t.interactions.actions).filter((y) => y.interactionId === l.id && y.sourceVersion === l.version && (y.operation.kind !== "connect" || y.operation.source.conversation_id === l.conversation_id)).slice(-1)[0];
811
811
  o.push({
812
812
  id: l.id,
813
813
  category: c.kind,
@@ -818,9 +818,9 @@ function fh(t, e, n) {
818
818
  sourceVersion: l.version,
819
819
  decisionRevision: i.profile.startsWith("extension_") ? p?.revision ?? 0 : d?.revision ?? 0,
820
820
  actions: c.kind === "sharing" ? ["copy", "share", "dismiss"] : c.kind === "integration_auth" ? ["connect"] : ["pair"],
821
- ...c.kind === "integration_auth" ? { actionLabels: { connect: f?.status === "error" ? "Try again" : u === "pending" ? "Connect" : "Reconnect" } } : {},
821
+ ...c.kind === "integration_auth" ? { actionLabels: { connect: g?.status === "error" ? "Try again" : u === "pending" ? "Connect" : "Reconnect" } } : {},
822
822
  ...r([`prompt:social_share:${l.id}`]),
823
- ...f?.status === "pending" || f?.status === "error" ? { status: f.status, error: f.error } : {},
823
+ ...g?.status === "pending" || g?.status === "error" ? { status: g.status, error: g.error } : {},
824
824
  payload: c.kind === "integration_auth" ? { ...c, lifecycle: u } : c,
825
825
  nextEligibleAt: null
826
826
  });
@@ -829,7 +829,7 @@ function fh(t, e, n) {
829
829
  for (const l of Object.values(t.interactions.welcome)) {
830
830
  const c = l.category === "morning_report" ? "canManageMorningReport" : "canManageProactiveSuggestions", u = l.category === "morning_report" ? "category:morning_report" : `prompt:proactive_suggestion:${l.sourceSuggestionId ?? l.id}`;
831
831
  if (l.clientScopeId && l.clientScopeId !== n.clientScopeId || !l.eligible || l.expiresAt !== void 0 && l.expiresAt <= a || !Ke(i.profile, c) || rl(t.interactions.decisions[u], a)) continue;
832
- const d = r([u]), p = $d(t, l.id, n), f = d.status === "pending" || p?.status === "pending" ? "pending" : d.error || p?.status === "error" ? "error" : "presentable";
832
+ const d = r([u]), p = $d(t, l.id, n), g = d.status === "pending" || p?.status === "pending" ? "pending" : d.error || p?.status === "error" ? "error" : "presentable";
833
833
  o.push({
834
834
  id: l.id,
835
835
  category: l.category,
@@ -840,7 +840,7 @@ function fh(t, e, n) {
840
840
  sourceVersion: null,
841
841
  decisionRevision: t.interactions.decisions[u]?.revision ?? 0,
842
842
  actions: l.category === "morning_report" ? ["run", "snooze"] : ["run", "edit", "not_now", "never", "feedback"],
843
- status: f,
843
+ status: g,
844
844
  error: d.error ?? (p?.status === "error" ? p.error : null),
845
845
  payload: { text: l.text, tasks: l.tasks, sourceSuggestionId: l.sourceSuggestionId ?? l.id },
846
846
  nextEligibleAt: t.interactions.decisions[u]?.nextEligibleAt ?? null
@@ -864,13 +864,13 @@ function mh(t, e, n, i) {
864
864
  if (e.type === "stage7.act") {
865
865
  const u = s.interactions.actions[e.requestId];
866
866
  if (u) {
867
- const g = s.interactions.welcome[e.interactionId], b = g?.category === "morning_report" ? g.tasks[e.taskIndex ?? 0] : g?.text;
867
+ const f = s.interactions.welcome[e.interactionId], b = f?.category === "morning_report" ? f.tasks[e.taskIndex ?? 0] : f?.text;
868
868
  if (u.interactionId !== e.interactionId || u.action !== e.action || u.expectedRevision !== e.expectedRevision || u.sourceVersion !== (e.sourceVersion ?? null) || u.clientScopeId !== e.clientScopeId || u.taskIndex !== (e.taskIndex ?? null) || (u.operation.kind === "run" || u.operation.kind === "edit") && u.operation.text !== b) throw new Error("Action request changed.");
869
869
  return { state: s, effects: o, command: null };
870
870
  }
871
871
  if (e.action === "feedback") {
872
- const g = s.interactions.welcome[e.interactionId];
873
- if (!g || g.category !== "proactive_suggestion" || !e.feedback || g.clientScopeId && g.clientScopeId !== e.clientScopeId) throw new Error("Missing proactive feedback.");
872
+ const f = s.interactions.welcome[e.interactionId];
873
+ if (!f || f.category !== "proactive_suggestion" || !e.feedback || f.clientScopeId && f.clientScopeId !== e.clientScopeId) throw new Error("Missing proactive feedback.");
874
874
  return { state: s, effects: o, command: {
875
875
  type: "stage7.mutate",
876
876
  authority: a,
@@ -878,30 +878,30 @@ function mh(t, e, n, i) {
878
878
  requestId: e.requestId,
879
879
  mutation: {
880
880
  kind: "proactiveFeedback",
881
- suggestionId: g.sourceSuggestionId ?? g.id,
882
- suggestedQuery: g.text,
881
+ suggestionId: f.sourceSuggestionId ?? f.id,
882
+ suggestedQuery: f.text,
883
883
  message: e.feedback.message,
884
884
  context: e.feedback.context
885
885
  }
886
886
  } };
887
887
  }
888
- const d = Hd(s, n, i, e.clientScopeId).find((g) => g.id === e.interactionId);
888
+ const d = Hd(s, n, i, e.clientScopeId).find((f) => f.id === e.interactionId);
889
889
  if (!d || !d.actions.includes(e.action) || d.decisionRevision !== e.expectedRevision || d.sourceVersion !== e.sourceVersion || d.status === "pending") throw new Error("Interaction changed or action is unavailable.");
890
890
  if (d.category === "preference" || d.category === "permission") {
891
- const g = d.payload.feature;
892
- if (g !== "notifications" && g !== "tab_grouping") throw new Error("Missing preference feature.");
893
- if (s = { ...s, interactions: { ...s.interactions, promptActions: { ...s.interactions.promptActions, [e.requestId]: { scope: i.clients[e.clientScopeId], openingGeneration: d.sourceVersion, expectedRevision: e.expectedRevision, feature: g, action: e.action } } } }, d.category === "permission") return { state: s, effects: o, command: { type: "stage7.permission", authority: a, now: e.now, requestId: e.requestId, feature: g, action: e.action, settings: !1 } };
894
- const b = e.action === "not_now" ? { kind: "preferenceSnooze", feature: g, expectedRevision: e.expectedRevision } : { kind: "preference", feature: g, enabled: e.action === "enable" };
891
+ const f = d.payload.feature;
892
+ if (f !== "notifications" && f !== "tab_grouping") throw new Error("Missing preference feature.");
893
+ if (s = { ...s, interactions: { ...s.interactions, promptActions: { ...s.interactions.promptActions, [e.requestId]: { scope: i.clients[e.clientScopeId], openingGeneration: d.sourceVersion, expectedRevision: e.expectedRevision, feature: f, action: e.action } } } }, d.category === "permission") return { state: s, effects: o, command: { type: "stage7.permission", authority: a, now: e.now, requestId: e.requestId, feature: f, action: e.action, settings: !1 } };
894
+ const b = e.action === "not_now" ? { kind: "preferenceSnooze", feature: f, expectedRevision: e.expectedRevision } : { kind: "preference", feature: f, enabled: e.action === "enable" };
895
895
  return { state: s, effects: o, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: b } };
896
896
  }
897
897
  if (["not_now", "never", "snooze"].includes(e.action)) {
898
- const g = d.category === "morning_report" ? { kind: "decision", category: "morning_report", action: "snooze", promptKey: d.id, expectedRevision: e.expectedRevision } : { kind: "decision", category: "proactive_suggestion", action: e.action, promptKey: s.interactions.welcome[d.id].sourceSuggestionId ?? d.id, expectedRevision: e.expectedRevision };
899
- return { state: s, effects: o, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: g } };
898
+ const f = d.category === "morning_report" ? { kind: "decision", category: "morning_report", action: "snooze", promptKey: d.id, expectedRevision: e.expectedRevision } : { kind: "decision", category: "proactive_suggestion", action: e.action, promptKey: s.interactions.welcome[d.id].sourceSuggestionId ?? d.id, expectedRevision: e.expectedRevision };
899
+ return { state: s, effects: o, command: { type: "stage7.mutate", authority: a, now: e.now, requestId: e.requestId, mutation: f } };
900
900
  }
901
- const p = Object.values(s.interactions.sources).find((g) => g.id === d.sourceId && g.conversation_id === d.conversationId);
902
- let f;
901
+ const p = Object.values(s.interactions.sources).find((f) => f.id === d.sourceId && f.conversation_id === d.conversationId);
902
+ let g;
903
903
  if (d.category === "device_hint")
904
- f = { kind: "saveHint", interactionId: d.id };
904
+ g = { kind: "saveHint", interactionId: d.id };
905
905
  else if (e.action === "dismiss") {
906
906
  if (!a.profile.startsWith("extension_")) return { state: s, effects: o, command: {
907
907
  type: "stage7.mutate",
@@ -910,38 +910,38 @@ function mh(t, e, n, i) {
910
910
  requestId: e.requestId,
911
911
  mutation: { kind: "decision", category: "social_share", promptKey: d.id, action: "dismiss", expectedRevision: e.expectedRevision }
912
912
  } };
913
- f = { kind: "saveSharing", interactionId: d.id, expectedRevision: e.expectedRevision };
913
+ g = { kind: "saveSharing", interactionId: d.id, expectedRevision: e.expectedRevision };
914
914
  } else if (e.action === "copy" || e.action === "share") {
915
915
  if (p?.payload.kind !== "sharing") throw new Error("Missing sharing source.");
916
- const g = Object.values(s.interactions.actions).find((b) => b.interactionId === d.id && b.step === "perform" && b.status === "error" && (b.operation.kind === "copy" || b.operation.kind === "share"));
917
- if (g && g.error?.code !== "interaction_not_started") throw new Error("The previous sharing action has an uncertain outcome.");
918
- f = { kind: e.action, interactionId: d.id, variant: p.payload.variant, ...e.sharePlatform ? { platform: e.sharePlatform } : {} };
916
+ const f = Object.values(s.interactions.actions).find((b) => b.interactionId === d.id && b.step === "perform" && b.status === "error" && (b.operation.kind === "copy" || b.operation.kind === "share"));
917
+ if (f && f.error?.code !== "interaction_not_started") throw new Error("The previous sharing action has an uncertain outcome.");
918
+ g = { kind: e.action, interactionId: d.id, variant: p.payload.variant, ...e.sharePlatform ? { platform: e.sharePlatform } : {} };
919
919
  } else if (e.action === "connect") {
920
920
  if (p?.payload.kind !== "integration_auth") throw new Error("Missing integration request.");
921
- f = { kind: "connect", interactionId: d.id, authRequestId: p.payload.request_id, source: p };
921
+ g = { kind: "connect", interactionId: d.id, authRequestId: p.payload.request_id, source: p };
922
922
  } else if (e.action === "pair") {
923
923
  if (p?.payload.kind !== "personal_channel") throw new Error("Missing channel request.");
924
- f = { kind: "pair", interactionId: d.id, requestId: p.payload.request_id, managementUrl: p.payload.management_url };
924
+ g = { kind: "pair", interactionId: d.id, requestId: p.payload.request_id, managementUrl: p.payload.management_url };
925
925
  } else {
926
- const g = $d(s, d.id, { clientScopeId: e.clientScopeId, conversationScopeId: i.clients[e.clientScopeId] });
927
- if (g?.status === "error" && g.error?.code !== "interaction_not_started") throw new Error("Reconcile the previous action before trying again.");
926
+ const f = $d(s, d.id, { clientScopeId: e.clientScopeId, conversationScopeId: i.clients[e.clientScopeId] });
927
+ if (f?.status === "error" && f.error?.code !== "interaction_not_started") throw new Error("Reconcile the previous action before trying again.");
928
928
  if (e.action !== "edit") {
929
929
  if (a.profile.startsWith("extension_") && !e.origin) throw new Error("Task submission requires the current page origin.");
930
930
  const S = Ud(s.account, "send_message", e.origin ?? null);
931
931
  if (!S.allowed) throw new Error(`Task submission unavailable: ${S.reason}.`);
932
932
  }
933
- const b = s.interactions.welcome[d.id], _ = b.category === "morning_report" ? b.tasks[e.taskIndex ?? 0] : b.text;
934
- if (!_) throw new Error("Missing selected task.");
935
- f = {
933
+ const b = s.interactions.welcome[d.id], w = b.category === "morning_report" ? b.tasks[e.taskIndex ?? 0] : b.text;
934
+ if (!w) throw new Error("Missing selected task.");
935
+ g = {
936
936
  kind: e.action === "edit" ? "edit" : "run",
937
937
  interactionId: d.id,
938
- text: _,
938
+ text: w,
939
939
  clientScopeId: e.clientScopeId,
940
940
  conversationScopeId: i.clients[e.clientScopeId],
941
941
  submissionId: e.requestId
942
942
  };
943
943
  }
944
- const y = f.kind === "saveSharing" || f.kind === "saveHint" ? "persist" : "perform";
944
+ const y = g.kind === "saveSharing" || g.kind === "saveHint" ? "persist" : "perform";
945
945
  l(e.requestId, {
946
946
  interactionId: d.id,
947
947
  clientScopeId: e.clientScopeId,
@@ -950,11 +950,11 @@ function mh(t, e, n, i) {
950
950
  action: e.action,
951
951
  expectedRevision: e.expectedRevision,
952
952
  sourceVersion: e.sourceVersion ?? null,
953
- operation: f,
953
+ operation: g,
954
954
  step: y,
955
955
  status: "pending",
956
956
  error: null
957
- }), c(e.requestId, f, y);
957
+ }), c(e.requestId, g, y);
958
958
  } else if (e.type === "stage7.retry_action") {
959
959
  const u = s.interactions.actions[e.requestId];
960
960
  if (!u || u.step !== "persist" || u.status !== "error") throw new Error("An uncertain browser action cannot be replayed.");
@@ -962,7 +962,7 @@ function mh(t, e, n, i) {
962
962
  return { state: s, effects: o, command: { type: "stage7.retry", authority: a, now: e.now, requestId: `sharing:${e.requestId}` } };
963
963
  c(e.requestId, u.operation, "persist");
964
964
  } else {
965
- const u = Object.entries(s.interactions.actions).find(([f, y]) => r(f, y.step) === e.effectId && y.status === "pending");
965
+ const u = Object.entries(s.interactions.actions).find(([g, y]) => r(g, y.step) === e.effectId && y.status === "pending");
966
966
  if (!u) return { state: s, effects: o, command: null };
967
967
  const [d, p] = u;
968
968
  if (e.type === "effect.failed") l(d, { ...p, status: "error", error: e.error });
@@ -975,8 +975,8 @@ function mh(t, e, n, i) {
975
975
  requestId: `sharing:${d}`,
976
976
  mutation: { kind: "decision", category: "social_share", promptKey: p.interactionId, action: "shared", expectedRevision: p.expectedRevision }
977
977
  } };
978
- const f = { kind: "saveSharing", interactionId: p.interactionId, expectedRevision: p.expectedRevision };
979
- l(d, { ...p, operation: f, step: "persist" }), c(d, f, "persist");
978
+ const g = { kind: "saveSharing", interactionId: p.interactionId, expectedRevision: p.expectedRevision };
979
+ l(d, { ...p, operation: g, step: "persist" }), c(d, g, "persist");
980
980
  } else
981
981
  l(d, { ...p, status: "done" }), p.operation.kind === "saveHint" && (s = { ...s, interactions: { ...s.interactions, deviceHints: { ...s.interactions.deviceHints, [p.interactionId]: !0 } } }), p.operation.kind === "saveSharing" && (s = { ...s, interactions: { ...s.interactions, localSharing: {
982
982
  ...s.interactions.localSharing,
@@ -993,21 +993,21 @@ function yh(t, e, n, i) {
993
993
  let s = t;
994
994
  const o = [], a = (d) => {
995
995
  s = { ...s, ...d };
996
- }, r = (d, p, f) => JSON.stringify(["stage7", e.authorityId, e.generation, d, p, ...f === void 0 ? [] : [f]]), l = (d, p) => Kd(d) && "origin" in d && d.origin === p, c = (d) => Object.values(s.pending).some((p) => p.mode === "mutation" && ["pending", "queued"].includes(p.status) && l(p.operation, d)), u = (d) => {
996
+ }, r = (d, p, g) => JSON.stringify(["stage7", e.authorityId, e.generation, d, p, ...g === void 0 ? [] : [g]]), l = (d, p) => Kd(d) && "origin" in d && d.origin === p, c = (d) => Object.values(s.pending).some((p) => p.mode === "mutation" && ["pending", "queued"].includes(p.status) && l(p.operation, d)), u = (d) => {
997
997
  const p = s.pending[d];
998
998
  a({ pending: { ...s.pending, [d]: { ...p, status: "pending" } } }), o.push({ kind: "stage7.query", id: d, input: { authority: e, requestId: p.requestId, query: p.operation } });
999
999
  };
1000
1000
  if (n.type === "stage7.query" && n.query.kind === "appearance") {
1001
1001
  const d = { ...n.query, kind: "appearance" }, p = i(d);
1002
- if (Object.values(s.pending).some((g) => g.mode === "query" && g.key === p)) return { state: s, effects: o };
1003
- const f = r("query", n.requestId, s.appearanceEpochs[d.origin] ?? 0), y = s.pending[f];
1002
+ if (Object.values(s.pending).some((f) => f.mode === "query" && f.key === p)) return { state: s, effects: o };
1003
+ const g = r("query", n.requestId, s.appearanceEpochs[d.origin] ?? 0), y = s.pending[g];
1004
1004
  if (y && y.fingerprint !== JSON.stringify(d)) throw new Error("Query request ID changed payload.");
1005
1005
  a({
1006
1006
  appearanceQueries: { ...s.appearanceQueries, [p]: d },
1007
1007
  queries: { ...s.queries, [p]: ti(s.queries[p] ?? Xt(p), { key: p, requestId: Et(n.requestId), mode: "replace" }) },
1008
- pending: { ...s.pending, [f]: {
1008
+ pending: { ...s.pending, [g]: {
1009
1009
  requestId: n.requestId,
1010
- effectId: f,
1010
+ effectId: g,
1011
1011
  fingerprint: JSON.stringify(d),
1012
1012
  key: p,
1013
1013
  generation: e.generation,
@@ -1017,24 +1017,24 @@ function yh(t, e, n, i) {
1017
1017
  error: null,
1018
1018
  result: null
1019
1019
  } }
1020
- }), c(d.origin) || u(f);
1020
+ }), c(d.origin) || u(g);
1021
1021
  } else if (n.type === "stage7.mutate" && (n.mutation.kind === "sampleStyle" || n.mutation.kind === "saveStyle" || n.mutation.kind === "scribble" || n.mutation.kind === "deleteStyle")) {
1022
- const d = n.mutation, p = d.origin, f = r("mutate", n.requestId), y = s.pending[f], g = JSON.stringify(d);
1022
+ const d = n.mutation, p = d.origin, g = r("mutate", n.requestId), y = s.pending[g], f = JSON.stringify(d);
1023
1023
  if (y) {
1024
- if (y.fingerprint !== g) throw new Error("Request ID was reused with a different payload.");
1024
+ if (y.fingerprint !== f) throw new Error("Request ID was reused with a different payload.");
1025
1025
  return { state: s, effects: o };
1026
1026
  }
1027
- const b = c(p), _ = (s.appearanceEpochs[p] ?? 0) + 1, S = { ...s.pending };
1027
+ const b = c(p), w = (s.appearanceEpochs[p] ?? 0) + 1, S = { ...s.pending };
1028
1028
  for (const [k, m] of Object.entries(S)) {
1029
1029
  if (m.mode !== "query" || !l(m.operation, p)) continue;
1030
1030
  delete S[k];
1031
- const w = r("query", m.requestId, _);
1032
- S[w] = { ...m, effectId: w, status: "queued" };
1031
+ const _ = r("query", m.requestId, w);
1032
+ S[_] = { ...m, effectId: _, status: "queued" };
1033
1033
  }
1034
- S[f] = {
1034
+ S[g] = {
1035
1035
  requestId: n.requestId,
1036
- effectId: f,
1037
- fingerprint: g,
1036
+ effectId: g,
1037
+ fingerprint: f,
1038
1038
  key: `appearance:${p}`,
1039
1039
  generation: e.generation,
1040
1040
  operation: d,
@@ -1043,30 +1043,30 @@ function yh(t, e, n, i) {
1043
1043
  status: b ? "queued" : "pending",
1044
1044
  error: null,
1045
1045
  result: null
1046
- }, a({ pending: S, appearanceEpochs: { ...s.appearanceEpochs, [p]: _ } }), b || o.push({ kind: "stage7.mutate", id: f, input: { authority: e, requestId: n.requestId, mutation: d } });
1046
+ }, a({ pending: S, appearanceEpochs: { ...s.appearanceEpochs, [p]: w } }), b || o.push({ kind: "stage7.mutate", id: g, input: { authority: e, requestId: n.requestId, mutation: d } });
1047
1047
  } else if (n.type === "effect.completed" || n.type === "effect.failed") {
1048
1048
  const d = s.pending[n.effectId];
1049
1049
  if (!d || d.status !== "pending" || !("origin" in d.operation)) return { state: s, effects: o };
1050
1050
  const p = d.operation.origin;
1051
1051
  if (n.effectKind !== "stage7.query" && n.effectKind !== "stage7.mutate") return { state: s, effects: o };
1052
- const f = n.type === "effect.completed" ? n.output.data : null;
1053
- if (f && (f.kind !== "appearance" || f.origin !== p)) throw new Error("Appearance response does not match its origin.");
1054
- const y = { ...s.pending }, g = { ...s.queries };
1052
+ const g = n.type === "effect.completed" ? n.output.data : null;
1053
+ if (g && (g.kind !== "appearance" || g.origin !== p)) throw new Error("Appearance response does not match its origin.");
1054
+ const y = { ...s.pending }, f = { ...s.queries };
1055
1055
  if (d.mode === "query") {
1056
1056
  delete y[n.effectId];
1057
- const b = g[d.key];
1058
- b?.requestId === d.requestId && (g[d.key] = n.type === "effect.failed" ? { ...b, status: "error", error: n.error, requestId: null } : { ...b, status: "ready", data: f, error: null, requestId: null, updatedAt: n.output.completedAt });
1059
- } else if (y[n.effectId] = { ...d, status: f ? "done" : "error", result: f, error: n.type === "effect.failed" ? n.error : null }, f && n.type === "effect.completed") {
1060
- for (const [b, _] of Object.entries(s.appearanceQueries))
1061
- _.origin === p && (g[b] = { ...g[b], status: "ready", data: f, requestId: null, error: null, updatedAt: n.output.completedAt });
1062
- for (const [b, _] of Object.entries(y)) _.mode === "query" && l(_.operation, p) && delete y[b];
1057
+ const b = f[d.key];
1058
+ b?.requestId === d.requestId && (f[d.key] = n.type === "effect.failed" ? { ...b, status: "error", error: n.error, requestId: null } : { ...b, status: "ready", data: g, error: null, requestId: null, updatedAt: n.output.completedAt });
1059
+ } else if (y[n.effectId] = { ...d, status: g ? "done" : "error", result: g, error: n.type === "effect.failed" ? n.error : null }, g && n.type === "effect.completed") {
1060
+ for (const [b, w] of Object.entries(s.appearanceQueries))
1061
+ w.origin === p && (f[b] = { ...f[b], status: "ready", data: g, requestId: null, error: null, updatedAt: n.output.completedAt });
1062
+ for (const [b, w] of Object.entries(y)) w.mode === "query" && l(w.operation, p) && delete y[b];
1063
1063
  } else if (n.type === "effect.failed")
1064
- for (const [b, _] of Object.entries(y)) _.mode === "mutation" && _.status === "queued" && l(_.operation, p) && (y[b] = { ..._, status: "error", error: { code: "appearance_write_cancelled", message: "Refresh appearance before saving again.", retryable: !1 } });
1065
- if (a({ pending: y, queries: g }), d.mode === "mutation") {
1066
- const b = Object.values(s.pending).find((_) => _.mode === "mutation" && _.status === "queued" && l(_.operation, p));
1064
+ for (const [b, w] of Object.entries(y)) w.mode === "mutation" && w.status === "queued" && l(w.operation, p) && (y[b] = { ...w, status: "error", error: { code: "appearance_write_cancelled", message: "Refresh appearance before saving again.", retryable: !1 } });
1065
+ if (a({ pending: y, queries: f }), d.mode === "mutation") {
1066
+ const b = Object.values(s.pending).find((w) => w.mode === "mutation" && w.status === "queued" && l(w.operation, p));
1067
1067
  if (b && (b.operation.kind === "sampleStyle" || b.operation.kind === "saveStyle" || b.operation.kind === "scribble" || b.operation.kind === "deleteStyle"))
1068
1068
  a({ pending: { ...s.pending, [b.effectId]: { ...b, status: "pending" } } }), o.push({ kind: "stage7.mutate", id: b.effectId, input: { authority: e, requestId: b.requestId, mutation: b.operation } });
1069
- else for (const [_, S] of Object.entries(s.pending)) S.mode === "query" && S.status === "queued" && l(S.operation, p) && u(_);
1069
+ else for (const [w, S] of Object.entries(s.pending)) S.mode === "query" && S.status === "queued" && l(S.operation, p) && u(w);
1070
1070
  }
1071
1071
  }
1072
1072
  return { state: s, effects: o };
@@ -1188,14 +1188,14 @@ function Yr(t, e, n) {
1188
1188
  if ("authority" in e && JSON.stringify(e.authority) !== JSON.stringify(r)) return { state: i, effects: s };
1189
1189
  if (e.type === "stage7.retire") return { state: { account: Gr(), features: Qr(e.now), interactions: Jr() }, effects: s };
1190
1190
  "now" in e && o({ now: e.now });
1191
- const l = (m, w) => {
1191
+ const l = (m, _) => {
1192
1192
  const I = { ...i.features.contextObservers }, x = I[m];
1193
- if (w === null ? delete I[m] : I[m] = ft(r, { kind: "originContext", clientScopeId: m, origin: w, pageUrl: "" }), o({ contextObservers: I }), !x || Object.values(I).includes(x)) return;
1194
- const E = { ...i.features.queries }, A = { ...i.features.polls }, L = { ...i.features.contextReads }, P = { ...i.features.originContextQueries }, z = { ...i.features.pending }, B = P[x]?.origin, C = { ...i.features.contextRunOrigins };
1193
+ if (_ === null ? delete I[m] : I[m] = ft(r, { kind: "originContext", clientScopeId: m, origin: _, pageUrl: "" }), o({ contextObservers: I }), !x || Object.values(I).includes(x)) return;
1194
+ const E = { ...i.features.queries }, A = { ...i.features.polls }, L = { ...i.features.contextReads }, M = { ...i.features.originContextQueries }, z = { ...i.features.pending }, B = M[x]?.origin, C = { ...i.features.contextRunOrigins };
1195
1195
  for (const [U, X] of Object.entries(C)) X === B && delete C[U];
1196
- delete E[x], delete A[x], delete L[x], delete P[x];
1196
+ delete E[x], delete A[x], delete L[x], delete M[x];
1197
1197
  for (const [U, X] of Object.entries(z)) X.mode === "query" && X.key === x && delete z[U];
1198
- o({ queries: E, polls: A, contextReads: L, originContextQueries: P, contextRunOrigins: C, pending: z });
1198
+ o({ queries: E, polls: A, contextReads: L, originContextQueries: M, contextRunOrigins: C, pending: z });
1199
1199
  };
1200
1200
  if (e.type === "stage7.account_fallback") return { state: { ...i, account: {
1201
1201
  ...i.account,
@@ -1204,37 +1204,37 @@ function Yr(t, e, n) {
1204
1204
  const c = e.type === "stage7.query" ? e.query : e.type === "stage7.mutate" ? e.mutation : e.type === "effect.completed" || e.type === "effect.failed" ? i.features.pending[e.effectId]?.operation : null;
1205
1205
  if (c && Kd(c)) {
1206
1206
  $n(r, c);
1207
- const m = yh(i.features, r, e, (w) => ft(r, w));
1207
+ const m = yh(i.features, r, e, (_) => ft(r, _));
1208
1208
  return { state: { ...i, features: m.state }, effects: m.effects };
1209
1209
  }
1210
1210
  if (e.type === "stage7.act" || e.type === "stage7.retry_action" || (e.type === "effect.completed" || e.type === "effect.failed") && e.effectKind === "stage7.platform") {
1211
1211
  const m = mh(i, e, n.conversation, n.directory);
1212
1212
  if (!m.command) return { state: m.state, effects: m.effects };
1213
- const w = Yr(m.state, m.command, n);
1214
- return { state: w.state, effects: [...m.effects, ...w.effects] };
1213
+ const _ = Yr(m.state, m.command, n);
1214
+ return { state: _.state, effects: [...m.effects, ..._.effects] };
1215
1215
  }
1216
- const u = (m, w, I) => {
1216
+ const u = (m, _, I) => {
1217
1217
  const x = m === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
1218
- if (!Ke(r.profile, x) || ji(i, m) !== !0 || i.features.desiredPreferences[m] === !1 || Object.values(i.interactions.devicePending).some((L) => L.feature === m && (w === "check" || L.action !== "check"))) return;
1218
+ if (!Ke(r.profile, x) || ji(i, m) !== !0 || i.features.desiredPreferences[m] === !1 || Object.values(i.interactions.devicePending).some((L) => L.feature === m && (_ === "check" || L.action !== "check"))) return;
1219
1219
  const E = Pn(r, "device", I), A = { ...i.interactions.deviceErrors };
1220
- delete A[m], a({ deviceErrors: A, devicePending: { ...i.interactions.devicePending, [E]: { feature: m, requestId: I, generation: r.generation, desired: !0, action: w } } }), s.push({ kind: "stage7.device", id: E, input: { authority: r, requestId: I, feature: m, action: w, now: i.features.now } });
1221
- }, d = (m, w) => {
1222
- const I = w ? i.interactions.promptActions[w.replace(/:ack$/, "")] : void 0, x = { ...i.interactions.openings };
1220
+ delete A[m], a({ deviceErrors: A, devicePending: { ...i.interactions.devicePending, [E]: { feature: m, requestId: I, generation: r.generation, desired: !0, action: _ } } }), s.push({ kind: "stage7.device", id: E, input: { authority: r, requestId: I, feature: m, action: _, now: i.features.now } });
1221
+ }, d = (m, _) => {
1222
+ const I = _ ? i.interactions.promptActions[_.replace(/:ack$/, "")] : void 0, x = { ...i.interactions.openings };
1223
1223
  for (const [E, A] of Object.entries(x)) {
1224
1224
  if (I?.scope === E && I.openingGeneration === A.generation && ["enable", "allow"].includes(I.action)) continue;
1225
1225
  const L = { ...A.shown };
1226
1226
  delete L[m], x[E] = {
1227
1227
  ...A,
1228
1228
  shown: L,
1229
- turns: Object.fromEntries(Object.entries(A.turns).map(([P, z]) => [P, { ...z, [m]: !1, [`${m}Suppressed`]: !0 }]))
1229
+ turns: Object.fromEntries(Object.entries(A.turns).map(([M, z]) => [M, { ...z, [m]: !1, [`${m}Suppressed`]: !0 }]))
1230
1230
  };
1231
1231
  }
1232
1232
  a({ openings: x });
1233
- }, p = (m, w = null) => {
1233
+ }, p = (m, _ = null) => {
1234
1234
  if (m.kind === "preferences" && i.account.preferences && m.value.preferencesVersion > i.account.preferences.preferencesVersion)
1235
1235
  for (const I of ["notifications", "tab_grouping"]) {
1236
1236
  const x = I === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled";
1237
- m.value[x] !== i.account.preferences[x] && d(I, w);
1237
+ m.value[x] !== i.account.preferences[x] && d(I, _);
1238
1238
  }
1239
1239
  if (m.kind === "preferencePrompts" || m.kind === "preferencePrompt")
1240
1240
  for (const I of ["notifications", "tab_grouping"]) {
@@ -1242,12 +1242,12 @@ function Yr(t, e, n) {
1242
1242
  x && x.revision > i.interactions.preferencePrompts[I].revision && d(I, x.requestId);
1243
1243
  }
1244
1244
  m.kind === "preferences" && (i = { ...i, account: bh(i.account, m.value) }), m.kind === "preferencePrompts" && (i = { ...i, interactions: ol(i.interactions, m.value) }), m.kind === "preferencePrompt" && (i = { ...i, interactions: ol(i.interactions, { ...i.interactions.preferencePrompts, [m.feature]: m.value }) }), m.kind === "decisions" && (i = { ...i, interactions: er(i.interactions, m.decisions) }), m.kind === "decision" && (i = { ...i, interactions: er(i.interactions, [m.value]) });
1245
- }, f = (m, w) => {
1245
+ }, g = (m, _) => {
1246
1246
  const I = i.interactions.deviceFacts[m];
1247
- w.revision <= I.revision || (ji(i, m) === !0 && (w.permission === "granted" && I.permission !== "granted" || w.snoozedUntil && w.snoozedUntil !== I.snoozedUntil) && d(m, null), a({ deviceFacts: { ...i.interactions.deviceFacts, [m]: w } }));
1248
- }, y = (m, w, I = !1) => {
1247
+ _.revision <= I.revision || (ji(i, m) === !0 && (_.permission === "granted" && I.permission !== "granted" || _.snoozedUntil && _.snoozedUntil !== I.snoozedUntil) && d(m, null), a({ deviceFacts: { ...i.interactions.deviceFacts, [m]: _ } }));
1248
+ }, y = (m, _, I = !1) => {
1249
1249
  $n(r, m);
1250
- const x = ft(r, m), E = Pn(r, "query", w);
1250
+ const x = ft(r, m), E = Pn(r, "query", _);
1251
1251
  if (m.kind === "originContext") {
1252
1252
  const z = i.features.queries[x], B = i.features.contextReads[x];
1253
1253
  if (o({ originContextQueries: { ...i.features.originContextQueries, [x]: m } }), !I && (z?.status === "ready" || z?.status === "error") && B && (i.features.now - B.settledAt < 3e4 || z.error && !z.error.retryable && z.error.code !== "runtime_error")) return;
@@ -1255,9 +1255,9 @@ function Yr(t, e, n) {
1255
1255
  const A = i.features.pending[E];
1256
1256
  if (A && A.fingerprint !== JSON.stringify(m)) throw new Error("Query request ID changed payload.");
1257
1257
  if (A?.status === "pending" || Object.values(i.features.pending).some((z) => z.mode === "query" && z.key === x && z.status === "pending")) return;
1258
- const L = i.features.queries[x] ?? Xt(x), P = ti(L, { key: x, requestId: Et(w), mode: "replace" });
1259
- o({ queries: { ...i.features.queries, [x]: P }, pending: { ...i.features.pending, [E]: {
1260
- requestId: w,
1258
+ const L = i.features.queries[x] ?? Xt(x), M = ti(L, { key: x, requestId: Et(_), mode: "replace" });
1259
+ o({ queries: { ...i.features.queries, [x]: M }, pending: { ...i.features.pending, [E]: {
1260
+ requestId: _,
1261
1261
  effectId: E,
1262
1262
  fingerprint: JSON.stringify(m),
1263
1263
  key: x,
@@ -1267,10 +1267,10 @@ function Yr(t, e, n) {
1267
1267
  status: "pending",
1268
1268
  error: null,
1269
1269
  result: null
1270
- } } }), m.kind === "account" && (i = { ...i, account: { ...i.account, query: ti(i.account.query, { key: x, requestId: Et(w), mode: "replace" }) } }), s.push({ kind: "stage7.query", id: E, input: { authority: r, requestId: w, query: m } });
1271
- }, g = (m, w, I = !1) => {
1270
+ } } }), m.kind === "account" && (i = { ...i, account: { ...i.account, query: ti(i.account.query, { key: x, requestId: Et(_), mode: "replace" }) } }), s.push({ kind: "stage7.query", id: E, input: { authority: r, requestId: _, query: m } });
1271
+ }, f = (m, _, I = !1) => {
1272
1272
  if ($n(r, m), m.kind === "report" && !i.account.query.data?.user?.isSuperuser) throw new Error("Chat reporting requires superuser access.");
1273
- const x = Pn(r, "mutate", w), E = JSON.stringify(m), A = i.features.pending[x];
1273
+ const x = Pn(r, "mutate", _), E = JSON.stringify(m), A = i.features.pending[x];
1274
1274
  if (A) {
1275
1275
  if (A.fingerprint !== E) throw new Error("Request ID was reused with a different payload.");
1276
1276
  if (!I || A.status !== "error") return;
@@ -1279,11 +1279,11 @@ function Yr(t, e, n) {
1279
1279
  }
1280
1280
  if (m.kind === "preference" && (o({ desiredPreferences: { ...i.features.desiredPreferences, [m.feature]: m.enabled } }), Object.values(i.features.pending).some((L) => L.status === "pending" && L.operation.kind === "preference" && L.operation.feature === m.feature))) {
1281
1281
  const L = i.features.queuedPreferences[m.feature];
1282
- if (L && L.requestId !== w) {
1283
- const P = Pn(r, "mutate", L.requestId), z = { kind: "preference", feature: m.feature, enabled: L.enabled };
1284
- o({ pending: { ...i.features.pending, [P]: {
1282
+ if (L && L.requestId !== _) {
1283
+ const M = Pn(r, "mutate", L.requestId), z = { kind: "preference", feature: m.feature, enabled: L.enabled };
1284
+ o({ pending: { ...i.features.pending, [M]: {
1285
1285
  requestId: L.requestId,
1286
- effectId: P,
1286
+ effectId: M,
1287
1287
  fingerprint: JSON.stringify(z),
1288
1288
  key: al(z),
1289
1289
  generation: r.generation,
@@ -1294,26 +1294,26 @@ function Yr(t, e, n) {
1294
1294
  error: { code: "preference_superseded", message: "A newer preference choice replaced this request.", retryable: !1 }
1295
1295
  } } });
1296
1296
  }
1297
- o({ queuedPreferences: { ...i.features.queuedPreferences, [m.feature]: { requestId: w, enabled: m.enabled } } });
1297
+ o({ queuedPreferences: { ...i.features.queuedPreferences, [m.feature]: { requestId: _, enabled: m.enabled } } });
1298
1298
  return;
1299
1299
  }
1300
1300
  if (m.kind === "generatePrompts") {
1301
- const L = { kind: "starterPrompts", ...m.page, includeUserSuggestions: m.includeUserSuggestions ?? !1 }, P = ft(r, L), z = i.features.queries[P] ?? Xt(P);
1302
- o({ queries: { ...i.features.queries, [P]: ti(z, { key: P, requestId: Et(w), mode: "replace" }) } });
1301
+ const L = { kind: "starterPrompts", ...m.page, includeUserSuggestions: m.includeUserSuggestions ?? !1 }, M = ft(r, L), z = i.features.queries[M] ?? Xt(M);
1302
+ o({ queries: { ...i.features.queries, [M]: ti(z, { key: M, requestId: Et(_), mode: "replace" }) } });
1303
1303
  }
1304
- o({ pending: { ...i.features.pending, [x]: { requestId: w, effectId: x, fingerprint: E, key: al(m), generation: r.generation, operation: m, mode: "mutation", status: "pending", error: null, result: null } } }), s.push({ kind: "stage7.mutate", id: x, input: { authority: r, requestId: w, mutation: m } });
1304
+ o({ pending: { ...i.features.pending, [x]: { requestId: _, effectId: x, fingerprint: E, key: al(m), generation: r.generation, operation: m, mode: "mutation", status: "pending", error: null, result: null } } }), s.push({ kind: "stage7.mutate", id: x, input: { authority: r, requestId: _, mutation: m } });
1305
1305
  }, b = (m) => {
1306
1306
  if (!(!Ke(r.profile, "canManagePreferences") || i.features.refreshBatch)) {
1307
- for (const w of Object.values(i.features.pending))
1308
- w.mode === "mutation" && w.operation.kind === "preferenceAcknowledge" && w.status === "error" && !["conflict", "409"].includes(w.error?.code ?? "") && g(w.operation, w.requestId, !0);
1309
- for (const w of ["account", "preferences", "preferencePrompts", "decisions"])
1310
- Object.values(i.features.pending).some((I) => I.mode === "query" && I.status === "pending" && I.operation.kind === w) || y({ kind: w }, `${m}:${w}`);
1311
- o({ refreshAt: null, refreshBatch: { pending: Object.values(i.features.pending).filter((w) => w.mode === "query" && w.status === "pending" && ["account", "preferences", "preferencePrompts", "decisions"].includes(w.operation.kind)).map((w) => w.effectId), failed: !1 } });
1307
+ for (const _ of Object.values(i.features.pending))
1308
+ _.mode === "mutation" && _.operation.kind === "preferenceAcknowledge" && _.status === "error" && !["conflict", "409"].includes(_.error?.code ?? "") && f(_.operation, _.requestId, !0);
1309
+ for (const _ of ["account", "preferences", "preferencePrompts", "decisions"])
1310
+ Object.values(i.features.pending).some((I) => I.mode === "query" && I.status === "pending" && I.operation.kind === _) || y({ kind: _ }, `${m}:${_}`);
1311
+ o({ refreshAt: null, refreshBatch: { pending: Object.values(i.features.pending).filter((_) => _.mode === "query" && _.status === "pending" && ["account", "preferences", "preferencePrompts", "decisions"].includes(_.operation.kind)).map((_) => _.effectId), failed: !1 } });
1312
1312
  }
1313
- }, _ = (m, w) => {
1313
+ }, w = (m, _) => {
1314
1314
  const I = i.features.refreshBatch;
1315
1315
  if (I?.pending.includes(m)) {
1316
- const x = I.pending.filter((A) => A !== m), E = I.failed || w;
1316
+ const x = I.pending.filter((A) => A !== m), E = I.failed || _;
1317
1317
  if (x.length) o({ refreshBatch: { pending: x, failed: E } });
1318
1318
  else {
1319
1319
  const A = E ? i.features.failures + 1 : 0;
@@ -1327,20 +1327,20 @@ function Yr(t, e, n) {
1327
1327
  case "stage7.account_refusal": {
1328
1328
  const m = Yi(void 0, e.code);
1329
1329
  if (m.allowed) return { state: i, effects: s };
1330
- const w = { ...i.features.queries }, I = { ...i.features.pending }, x = [];
1330
+ const _ = { ...i.features.queries }, I = { ...i.features.pending }, x = [];
1331
1331
  for (const [E, A] of Object.entries(I)) {
1332
1332
  if (A.operation.kind !== "account" || A.status === "done" || A.status === "error") continue;
1333
1333
  const L = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
1334
1334
  I[E] = { ...A, status: "error", error: L }, x.push(E);
1335
- const P = w[A.key];
1336
- P && (w[A.key] = bs(P, { key: A.key, requestId: Et(A.requestId), error: L }));
1335
+ const M = _[A.key];
1336
+ M && (_[A.key] = bs(M, { key: A.key, requestId: Et(A.requestId), error: L }));
1337
1337
  }
1338
- i = { ...i, features: { ...i.features, pending: I, queries: w }, account: {
1338
+ i = { ...i, features: { ...i.features, pending: I, queries: _ }, account: {
1339
1339
  ...i.account,
1340
1340
  refusal: m,
1341
1341
  query: { ...i.account.query, requestId: null, status: i.account.query.data ? "ready" : "not_requested" }
1342
1342
  } };
1343
- for (const E of x) _(E, !0);
1343
+ for (const E of x) w(E, !0);
1344
1344
  break;
1345
1345
  }
1346
1346
  case "stage7.context_observe":
@@ -1348,29 +1348,29 @@ function Yr(t, e, n) {
1348
1348
  break;
1349
1349
  case "stage7.query":
1350
1350
  if (e.query.kind === "userSuggestedTasks") {
1351
- const m = ft(r, e.query), w = i.features.queries[m]?.status === "error";
1352
- if (!e.force && (i.features.polls[m] || w && (i.features.suggestionRetryAfter === null || e.now < i.features.suggestionRetryAfter))) break;
1353
- (e.force || w) && o({ suggestionReadFailures: 0, suggestionRetryAfter: null });
1351
+ const m = ft(r, e.query), _ = i.features.queries[m]?.status === "error";
1352
+ if (!e.force && (i.features.polls[m] || _ && (i.features.suggestionRetryAfter === null || e.now < i.features.suggestionRetryAfter))) break;
1353
+ (e.force || _) && o({ suggestionReadFailures: 0, suggestionRetryAfter: null });
1354
1354
  }
1355
1355
  if (e.query.kind === "originContext" && (l(e.query.clientScopeId, e.query.origin), e.force)) {
1356
- const m = ft(r, e.query), w = { ...i.features.contextReads };
1357
- delete w[m], o({ contextReads: w });
1356
+ const m = ft(r, e.query), _ = { ...i.features.contextReads };
1357
+ delete _[m], o({ contextReads: _ });
1358
1358
  }
1359
1359
  y(e.query, e.requestId, e.force);
1360
1360
  break;
1361
1361
  case "stage7.mutate":
1362
- g(e.mutation, e.requestId);
1362
+ f(e.mutation, e.requestId);
1363
1363
  break;
1364
1364
  case "stage7.retry": {
1365
1365
  const m = i.features.pending[Pn(r, "mutate", e.requestId)];
1366
1366
  if (!m || m.mode !== "mutation") throw new Error("Unknown mutation request.");
1367
- g(m.operation, e.requestId, !0);
1367
+ f(m.operation, e.requestId, !0);
1368
1368
  break;
1369
1369
  }
1370
1370
  case "stage7.reconcile":
1371
1371
  if (o({ schedulerError: null }), e.reason !== "periodic" || i.features.refreshAt === null || e.now >= i.features.refreshAt) {
1372
1372
  if (e.reason === "startup" && o({ refreshRequired: !0 }), e.reason === "wake" || e.reason === "reconnect") {
1373
- const m = Object.values(i.features.pending).some((w) => w.mode === "query" && w.status === "pending" && ["account", "preferences", "preferencePrompts", "decisions"].includes(w.operation.kind));
1373
+ const m = Object.values(i.features.pending).some((_) => _.mode === "query" && _.status === "pending" && ["account", "preferences", "preferencePrompts", "decisions"].includes(_.operation.kind));
1374
1374
  o({ refreshRequired: !0, refreshQueuedRequestId: m ? `after:${e.requestId}` : i.features.refreshQueuedRequestId });
1375
1375
  }
1376
1376
  b(e.requestId);
@@ -1384,30 +1384,30 @@ function Yr(t, e, n) {
1384
1384
  break;
1385
1385
  case "stage7.restore_prompt_openings": {
1386
1386
  if (!r.profile.startsWith("extension_")) throw new Error("Prompt restoration requires an extension opening checkpoint.");
1387
- const m = new Set(Object.values(n.directory.clients)), w = Object.fromEntries(Object.entries(e.checkpoint.openings).filter(([I, x]) => m.has(I) && n.directory.selections[I]?.sessionId === x.sessionId));
1388
- a({ ...e.checkpoint, openings: w, openingGeneration: Math.max(i.interactions.openingGeneration, e.checkpoint.openingGeneration) });
1387
+ const m = new Set(Object.values(n.directory.clients)), _ = Object.fromEntries(Object.entries(e.checkpoint.openings).filter(([I, x]) => m.has(I) && n.directory.selections[I]?.sessionId === x.sessionId));
1388
+ a({ ...e.checkpoint, openings: _, openingGeneration: Math.max(i.interactions.openingGeneration, e.checkpoint.openingGeneration) });
1389
1389
  break;
1390
1390
  }
1391
1391
  case "stage7.prompt_view": {
1392
1392
  const m = n.directory.clients[e.clientScopeId];
1393
1393
  if (!m) break;
1394
- const w = { ...i.interactions.openings };
1395
- e.open || delete w[m], a({ openings: w, closedScopes: { ...i.interactions.closedScopes, [m]: !e.open } }), i = Xo(i, n.conversation, n.directory, e.now);
1394
+ const _ = { ...i.interactions.openings };
1395
+ e.open || delete _[m], a({ openings: _, closedScopes: { ...i.interactions.closedScopes, [m]: !e.open } }), i = Xo(i, n.conversation, n.directory, e.now);
1396
1396
  break;
1397
1397
  }
1398
1398
  case "stage7.prompt_shown": {
1399
- const m = n.directory.clients[e.clientScopeId], w = i.interactions.openings[m];
1400
- if (!w || w.generation !== e.openingGeneration) break;
1399
+ const m = n.directory.clients[e.clientScopeId], _ = i.interactions.openings[m];
1400
+ if (!_ || _.generation !== e.openingGeneration) break;
1401
1401
  const I = Ld(i, m, e.feature);
1402
- I && a({ openings: { ...i.interactions.openings, [m]: { ...w, shown: { ...w.shown, [e.feature]: I } } } });
1402
+ I && a({ openings: { ...i.interactions.openings, [m]: { ..._, shown: { ..._.shown, [e.feature]: I } } } });
1403
1403
  break;
1404
1404
  }
1405
1405
  case "stage7.cross_tab": {
1406
1406
  a({ crossTabTurns: { ...i.interactions.crossTabTurns, [e.sessionId]: [.../* @__PURE__ */ new Set([...i.interactions.crossTabTurns[e.sessionId] ?? [], e.userMessageId])] } });
1407
1407
  const m = { ...i.interactions.openings };
1408
- for (const [w, I] of Object.entries(m)) {
1408
+ for (const [_, I] of Object.entries(m)) {
1409
1409
  const x = I.turns[e.userMessageId];
1410
- I.sessionId === e.sessionId && x && !x.tab_groupingSuppressed && (m[w] = { ...I, turns: { ...I.turns, [e.userMessageId]: { ...x, tab_grouping: !0 } } });
1410
+ I.sessionId === e.sessionId && x && !x.tab_groupingSuppressed && (m[_] = { ...I, turns: { ...I.turns, [e.userMessageId]: { ...x, tab_grouping: !0 } } });
1411
1411
  }
1412
1412
  a({ openings: m });
1413
1413
  break;
@@ -1420,7 +1420,7 @@ function Yr(t, e, n) {
1420
1420
  break;
1421
1421
  }
1422
1422
  case "stage7.device_fact":
1423
- f(e.feature, e.fact);
1423
+ g(e.feature, e.fact);
1424
1424
  break;
1425
1425
  case "stage7.import_legacy_decisions":
1426
1426
  if (!r.profile.startsWith("extension_") || e.decisions.some((m) => m.revision !== 0)) throw new Error("Invalid legacy decision import.");
@@ -1429,28 +1429,28 @@ function Yr(t, e, n) {
1429
1429
  case "stage7.device_hints": {
1430
1430
  if (r.profile !== "main_web_chat") throw new Error("Main-web hints unavailable.");
1431
1431
  const m = { ...i.interactions.deviceHints };
1432
- for (const [w, I] of Object.entries(e.hints)) m[w] = m[w] === !0 || I;
1432
+ for (const [_, I] of Object.entries(e.hints)) m[_] = m[_] === !0 || I;
1433
1433
  a({ deviceHints: m });
1434
1434
  break;
1435
1435
  }
1436
1436
  case "stage7.local_sharing": {
1437
1437
  const m = { ...i.interactions.localSharing };
1438
- for (const [w, I] of Object.entries(e.decisions))
1439
- (!m[w] || I.revision > m[w].revision) && (m[w] = I);
1438
+ for (const [_, I] of Object.entries(e.decisions))
1439
+ (!m[_] || I.revision > m[_].revision) && (m[_] = I);
1440
1440
  a({ localSharing: m, localSharingReady: !0 });
1441
1441
  break;
1442
1442
  }
1443
1443
  case "stage7.sources": {
1444
1444
  const m = { ...i.interactions.sources };
1445
- for (const w of e.sources) {
1446
- if (!Number.isSafeInteger(w.version) || w.version < 0) throw new Error("Invalid source version.");
1447
- const I = JSON.stringify([w.conversation_id, w.id]), x = m[I];
1448
- if (!(x && x.version >= w.version)) {
1449
- if (x && x.payload.kind !== w.payload.kind) throw new Error("Interaction source changed category.");
1445
+ for (const _ of e.sources) {
1446
+ if (!Number.isSafeInteger(_.version) || _.version < 0) throw new Error("Invalid source version.");
1447
+ const I = JSON.stringify([_.conversation_id, _.id]), x = m[I];
1448
+ if (!(x && x.version >= _.version)) {
1449
+ if (x && x.payload.kind !== _.payload.kind) throw new Error("Interaction source changed category.");
1450
1450
  m[I] = {
1451
- ...w,
1452
- lifecycle: x?.lifecycle === "completed" ? "completed" : w.lifecycle,
1453
- payload: x?.payload.kind === "sharing" && w.payload.kind === "sharing" ? { ...w.payload, variant: x.payload.variant } : w.payload
1451
+ ..._,
1452
+ lifecycle: x?.lifecycle === "completed" ? "completed" : _.lifecycle,
1453
+ payload: x?.payload.kind === "sharing" && _.payload.kind === "sharing" ? { ..._.payload, variant: x.payload.variant } : _.payload
1454
1454
  };
1455
1455
  }
1456
1456
  }
@@ -1467,8 +1467,8 @@ function Yr(t, e, n) {
1467
1467
  delete I[e.id], a({ welcome: I });
1468
1468
  break;
1469
1469
  }
1470
- const m = e.signupAgeDays, w = e.retained === !0 || e.localHour >= 5 && e.lastShownDate !== e.localDate && (m === 1 || m === 3 || m === 5 || m >= 7 && m % 7 === 0);
1471
- a({ welcome: { ...i.interactions.welcome, [e.id]: { id: e.id, text: e.text, tasks: e.tasks, category: "morning_report", eligible: w } } });
1470
+ const m = e.signupAgeDays, _ = e.retained === !0 || e.localHour >= 5 && e.lastShownDate !== e.localDate && (m === 1 || m === 3 || m === 5 || m >= 7 && m % 7 === 0);
1471
+ a({ welcome: { ...i.interactions.welcome, [e.id]: { id: e.id, text: e.text, tasks: e.tasks, category: "morning_report", eligible: _ } } });
1472
1472
  break;
1473
1473
  }
1474
1474
  case "stage7.welcome":
@@ -1478,8 +1478,8 @@ function Yr(t, e, n) {
1478
1478
  if (!Ke(r.profile, "canStartDeepFlow")) throw new Error("Deep flow unavailable.");
1479
1479
  const m = i.features.deepFlows[e.clientScopeId];
1480
1480
  if ((m?.id ?? null) !== e.expectedId || m && e.flow && e.flow.id !== m.id || e.flow && m && m.status !== "running") break;
1481
- const w = { ...i.features.deepFlows };
1482
- e.flow ? w[e.clientScopeId] = e.flow : delete w[e.clientScopeId], o({ deepFlows: w });
1481
+ const _ = { ...i.features.deepFlows };
1482
+ e.flow ? _[e.clientScopeId] = e.flow : delete _[e.clientScopeId], o({ deepFlows: _ });
1483
1483
  break;
1484
1484
  }
1485
1485
  case "effect.completed":
@@ -1505,21 +1505,21 @@ function Yr(t, e, n) {
1505
1505
  if (delete x[e.effectId], a({ devicePending: x }), e.type === "effect.completed") {
1506
1506
  if (I.action !== "check" && i.interactions.promptActions[I.requestId] && !i.features.pending[Pn(r, "mutate", `${I.requestId}:ack`)]) {
1507
1507
  const E = i.interactions.promptActions[I.requestId];
1508
- d(E.feature, I.requestId), g({
1508
+ d(E.feature, I.requestId), f({
1509
1509
  kind: "preferenceAcknowledge",
1510
1510
  feature: E.feature,
1511
1511
  action: E.action,
1512
1512
  expectedRevision: E.expectedRevision
1513
1513
  }, `${I.requestId}:ack`);
1514
1514
  }
1515
- f(I.feature, e.output.fact);
1515
+ g(I.feature, e.output.fact);
1516
1516
  } else ji(i, I.feature) === !0 && i.features.desiredPreferences[I.feature] !== !1 && a({ deviceErrors: { ...i.interactions.deviceErrors, [I.feature]: e.error } });
1517
1517
  break;
1518
1518
  }
1519
1519
  const m = i.features.pending[e.effectId];
1520
1520
  if (!m || m.status !== "pending" || m.generation !== r.generation) break;
1521
- const w = e.type === "effect.failed";
1522
- if (o({ pending: { ...i.features.pending, [e.effectId]: { ...m, status: w ? "error" : "done", error: w ? e.error : null, result: w ? null : e.output.data } } }), m.mode === "query") {
1521
+ const _ = e.type === "effect.failed";
1522
+ if (o({ pending: { ...i.features.pending, [e.effectId]: { ...m, status: _ ? "error" : "done", error: _ ? e.error : null, result: _ ? null : e.output.data } } }), m.mode === "query") {
1523
1523
  const I = { ...i.features.pending };
1524
1524
  delete I[e.effectId], o({ pending: I });
1525
1525
  const x = i.features.queries[m.key];
@@ -1527,17 +1527,17 @@ function Yr(t, e, n) {
1527
1527
  if (["originContext", "userContext", "contextRun"].includes(m.operation.kind)) {
1528
1528
  const E = { ...i.features.polls };
1529
1529
  delete E[m.key], o({ polls: E, contextReads: { ...i.features.contextReads, [m.key]: {
1530
- settledAt: w ? i.features.now : e.output.completedAt,
1531
- failures: w ? (i.features.contextReads[m.key]?.failures ?? 0) + 1 : 0
1530
+ settledAt: _ ? i.features.now : e.output.completedAt,
1531
+ failures: _ ? (i.features.contextReads[m.key]?.failures ?? 0) + 1 : 0
1532
1532
  } } });
1533
1533
  }
1534
- if (w)
1534
+ if (_)
1535
1535
  o({ queries: { ...i.features.queries, [m.key]: bs(x, { key: m.key, requestId: Et(m.requestId), error: e.error }) } }), m.operation.kind === "account" && (i = { ...i, account: { ...i.account, query: bs(i.account.query, { key: m.key, requestId: Et(m.requestId), error: e.error }) } });
1536
1536
  else {
1537
1537
  if (e.output.data.kind !== m.operation.kind) throw new Error("Feature response kind does not match the query.");
1538
1538
  o({ now: e.output.completedAt, queries: { ...i.features.queries, [m.key]: Zo(x, { key: m.key, requestId: Et(m.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } }), p(e.output.data, m.requestId), e.output.data.kind === "account" && (i = { ...i, account: { ...i.account, refusal: null, query: Zo(i.account.query, { key: m.key, requestId: Et(m.requestId), data: e.output.data.value, cursor: null, updatedAt: e.output.completedAt }) } });
1539
1539
  }
1540
- } else if (!w)
1540
+ } else if (!_)
1541
1541
  o({ now: e.output.completedAt }), p(e.output.data, m.requestId);
1542
1542
  else if (["conflict", "409"].includes(e.error.code)) {
1543
1543
  const I = m.operation.kind === "decision" ? "decisions" : m.operation.kind === "preferenceSnooze" || m.operation.kind === "preferenceAcknowledge" ? "preferencePrompts" : "preferences";
@@ -1546,23 +1546,23 @@ function Yr(t, e, n) {
1546
1546
  if (m.mode === "mutation" && m.operation.kind === "decision") {
1547
1547
  const I = { ...i.interactions.actions };
1548
1548
  for (const [x, E] of Object.entries(I))
1549
- E.step === "persist" && m.requestId === `sharing:${x}` && (E.operation.kind === "copy" || E.operation.kind === "share") && (I[x] = { ...E, status: w ? "error" : "done", error: w ? e.error : null });
1549
+ E.step === "persist" && m.requestId === `sharing:${x}` && (E.operation.kind === "copy" || E.operation.kind === "share") && (I[x] = { ...E, status: _ ? "error" : "done", error: _ ? e.error : null });
1550
1550
  a({ actions: I });
1551
1551
  }
1552
- if (!w && m.mode === "mutation" && m.operation.kind === "preference" && i.interactions.promptActions[m.requestId]) {
1552
+ if (!_ && m.mode === "mutation" && m.operation.kind === "preference" && i.interactions.promptActions[m.requestId]) {
1553
1553
  const I = i.interactions.promptActions[m.requestId];
1554
- d(I.feature, m.requestId), g({
1554
+ d(I.feature, m.requestId), f({
1555
1555
  kind: "preferenceAcknowledge",
1556
1556
  feature: I.feature,
1557
1557
  action: I.action,
1558
1558
  expectedRevision: I.expectedRevision
1559
1559
  }, `${m.requestId}:ack`);
1560
1560
  }
1561
- if (_(e.effectId, w), m.operation.kind === "generatePrompts") {
1561
+ if (w(e.effectId, _), m.operation.kind === "generatePrompts") {
1562
1562
  const I = { kind: "starterPrompts", ...m.operation.page, includeUserSuggestions: m.operation.includeUserSuggestions ?? !1 }, x = ft(r, I), E = i.features.queries[x];
1563
- E?.requestId === m.requestId && o({ queries: { ...i.features.queries, [x]: w ? bs(E, { key: x, requestId: Et(m.requestId), error: e.error }) : Zo(E, { key: x, requestId: Et(m.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } });
1563
+ E?.requestId === m.requestId && o({ queries: { ...i.features.queries, [x]: _ ? bs(E, { key: x, requestId: Et(m.requestId), error: e.error }) : Zo(E, { key: x, requestId: Et(m.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } });
1564
1564
  }
1565
- if (!w && e.output.data.kind === "originContext") {
1565
+ if (!_ && e.output.data.kind === "originContext") {
1566
1566
  const I = e.output.data, x = m.operation.kind === "originContext" || m.operation.kind === "refreshContext" ? m.operation.origin : null;
1567
1567
  if (x) {
1568
1568
  if (I.value.runId && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status))
@@ -1573,31 +1573,31 @@ function Yr(t, e, n) {
1573
1573
  o({ contextRunOrigins: E });
1574
1574
  }
1575
1575
  if (m.mode === "mutation") {
1576
- const E = { ...i.features.queries }, A = { ...i.features.pending }, L = { ...i.features.contextReads }, P = { ...i.features.polls };
1576
+ const E = { ...i.features.queries }, A = { ...i.features.pending }, L = { ...i.features.contextReads }, M = { ...i.features.polls };
1577
1577
  for (const [z, B] of Object.entries(i.features.originContextQueries))
1578
1578
  if (B.origin === x) {
1579
- E[z] = { ...E[z], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, L[z] = { settledAt: e.output.completedAt, failures: 0 }, delete P[z];
1579
+ E[z] = { ...E[z], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, L[z] = { settledAt: e.output.completedAt, failures: 0 }, delete M[z];
1580
1580
  for (const [C, U] of Object.entries(A)) U.mode === "query" && U.key === z && delete A[C];
1581
- ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (P[z] = { query: { ...B, kind: "originContext", trigger: "poll" }, deadline: i.features.now + 5e3 });
1581
+ ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status) && (M[z] = { query: { ...B, kind: "originContext", trigger: "poll" }, deadline: i.features.now + 5e3 });
1582
1582
  }
1583
- o({ queries: E, pending: A, contextReads: L, polls: P });
1583
+ o({ queries: E, pending: A, contextReads: L, polls: M });
1584
1584
  }
1585
1585
  }
1586
1586
  }
1587
- if (!w && e.output.data.kind === "contextRun" && !["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(e.output.data.value.status)) {
1587
+ if (!_ && e.output.data.kind === "contextRun" && !["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(e.output.data.value.status)) {
1588
1588
  const I = e.output.data.value.runId, x = I ? i.features.contextRunOrigins[I] : null;
1589
1589
  if (x && I) {
1590
1590
  const E = { ...i.features.contextRunOrigins };
1591
1591
  delete E[I], o({ contextRunOrigins: E });
1592
1592
  for (const [A, L] of Object.entries(i.features.originContextQueries)) {
1593
1593
  if (L.origin !== x) continue;
1594
- const P = { ...i.features.pending };
1595
- for (const [z, B] of Object.entries(P)) B.mode === "query" && B.key === A && delete P[z];
1596
- o({ pending: P }), y({ ...L, kind: "originContext" }, `context-final:${m.requestId}:${A}`, !0);
1594
+ const M = { ...i.features.pending };
1595
+ for (const [z, B] of Object.entries(M)) B.mode === "query" && B.key === A && delete M[z];
1596
+ o({ pending: M }), y({ ...L, kind: "originContext" }, `context-final:${m.requestId}:${A}`, !0);
1597
1597
  }
1598
1598
  }
1599
1599
  }
1600
- if (!w && ["originContext", "userContext", "contextRun"].includes(e.output.data.kind)) {
1600
+ if (!_ && ["originContext", "userContext", "contextRun"].includes(e.output.data.kind)) {
1601
1601
  const I = e.output.data;
1602
1602
  if (I.kind === "originContext" || I.kind === "userContext" || I.kind === "contextRun") {
1603
1603
  const x = I.kind === "originContext" ? m.mode === "query" && m.operation.kind === "originContext" && Object.values(i.features.contextObservers).includes(m.key) ? m.operation : null : I.kind === "userContext" ? { kind: "userContext" } : I.value.runId ? { kind: "contextRun", runId: I.value.runId } : null;
@@ -1607,43 +1607,43 @@ function Yr(t, e, n) {
1607
1607
  }
1608
1608
  }
1609
1609
  }
1610
- if (!w && m.operation.kind === "stopContext")
1610
+ if (!_ && m.operation.kind === "stopContext")
1611
1611
  for (const [I, x] of Object.entries(i.features.originContextQueries)) {
1612
1612
  const E = i.features.queries[I]?.data;
1613
1613
  if (E?.kind === "originContext" && E.value.runId === m.operation.runId) {
1614
1614
  const A = { ...i.features.pending };
1615
- for (const [L, P] of Object.entries(A)) P.mode === "query" && P.key === I && delete A[L];
1615
+ for (const [L, M] of Object.entries(A)) M.mode === "query" && M.key === I && delete A[L];
1616
1616
  o({ pending: A }), y({ ...x, kind: "originContext" }, `context-stop:${m.requestId}:${I}`, !0);
1617
1617
  }
1618
1618
  }
1619
- if (w && m.mode === "query" && ["originContext", "userContext", "contextRun"].includes(m.operation.kind) && e.error.retryable && (i.features.contextReads[m.key]?.failures ?? 0) <= 3) {
1619
+ if (_ && m.mode === "query" && ["originContext", "userContext", "contextRun"].includes(m.operation.kind) && e.error.retryable && (i.features.contextReads[m.key]?.failures ?? 0) <= 3) {
1620
1620
  const I = m.operation, x = ft(r, I);
1621
1621
  o({ polls: { ...i.features.polls, [x]: { query: I, deadline: i.features.now + 5e3 * (i.features.contextReads[m.key]?.failures ?? 1) } } });
1622
1622
  }
1623
1623
  if (m.mode === "query" && m.operation.kind === "userSuggestedTasks") {
1624
- const I = w ? i.features.suggestionReadFailures + 1 : 0, x = { ...i.features.polls };
1624
+ const I = _ ? i.features.suggestionReadFailures + 1 : 0, x = { ...i.features.polls };
1625
1625
  delete x[m.key];
1626
- const E = w && (e.error.retryable || ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.error.code));
1626
+ const E = _ && (e.error.retryable || ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.error.code));
1627
1627
  E && I <= 3 && (x[m.key] = { query: m.operation, deadline: i.features.now + 1e3 * 2 ** (I - 1) }), o({ suggestionReadFailures: I, suggestionRetryAfter: E && I > 3 ? i.features.now + 3e4 : null, polls: x });
1628
1628
  }
1629
1629
  if (m.operation.kind === "preference") {
1630
1630
  const I = m.operation.feature, x = i.features.queuedPreferences[I];
1631
1631
  if (x) {
1632
1632
  const E = { ...i.features.queuedPreferences };
1633
- delete E[I], o({ queuedPreferences: E }), g({ kind: "preference", feature: I, enabled: x.enabled }, x.requestId);
1633
+ delete E[I], o({ queuedPreferences: E }), f({ kind: "preference", feature: I, enabled: x.enabled }, x.requestId);
1634
1634
  } else {
1635
1635
  const E = { ...i.features.desiredPreferences };
1636
1636
  delete E[I], o({ desiredPreferences: E });
1637
1637
  }
1638
1638
  }
1639
- if (!w && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"]) u(I, "check", `preference:${m.requestId}:${I}`);
1639
+ if (!_ && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"]) u(I, "check", `preference:${m.requestId}:${I}`);
1640
1640
  i.features.refreshRequired && !i.features.refreshBatch && !i.features.refreshQueuedRequestId && ["account", "preferences", "preferencePrompts", "decisions"].every((I) => Object.values(i.features.queries).some((x) => x.data?.kind === I && x.status === "ready")) && o({ refreshRequired: !1 });
1641
1641
  break;
1642
1642
  }
1643
1643
  }
1644
1644
  const S = [
1645
1645
  i.features.refreshAt,
1646
- ...Object.values(i.interactions.openings).flatMap((m) => Object.values(m.turns).filter((w) => w.active && !w.notifications && !w.notificationsSuppressed).map((w) => w.startedAt + 1e4)),
1646
+ ...Object.values(i.interactions.openings).flatMap((m) => Object.values(m.turns).filter((_) => _.active && !_.notifications && !_.notificationsSuppressed).map((_) => _.startedAt + 1e4)),
1647
1647
  ...Object.values(i.interactions.welcome).map((m) => m.eligible ? m.expiresAt ?? null : null),
1648
1648
  ...Object.values(i.interactions.sources).map((m) => m.lifecycle === "pending" && m.payload.kind === "integration_auth" ? Date.parse(m.payload.expires_at) : null),
1649
1649
  ...Object.values(i.features.polls).map((m) => m.deadline),
@@ -1652,8 +1652,8 @@ function Yr(t, e, n) {
1652
1652
  ...Object.values(i.interactions.deviceFacts).map((m) => m.snoozedUntil ? Date.parse(m.snoozedUntil) : null)
1653
1653
  ].filter((m) => m !== null && m > i.features.now), k = S.length ? Math.min(...S) : null;
1654
1654
  if (k !== i.features.timerDeadline && !i.features.schedulerError) {
1655
- const m = i.features.timerRevision + 1, w = k === null ? null : Pn(r, "wait", `${m}:${k}`);
1656
- o({ timerId: w, timerDeadline: k, timerRevision: m }), k !== null && w && s.push({ kind: "stage7.wait", id: w, input: { authority: r, deadline: k } });
1655
+ const m = i.features.timerRevision + 1, _ = k === null ? null : Pn(r, "wait", `${m}:${k}`);
1656
+ o({ timerId: _, timerDeadline: k, timerRevision: m }), k !== null && _ && s.push({ kind: "stage7.wait", id: _, input: { authority: r, deadline: k } });
1657
1657
  }
1658
1658
  return { state: i, effects: s };
1659
1659
  }
@@ -1691,8 +1691,8 @@ function Ih(t, e, n, i) {
1691
1691
  if (!p) return;
1692
1692
  await t["stage7.mutate"]({ authority: c, requestId: `local-preferences:${i()}`, mutation: p }), await r(async () => {
1693
1693
  a(c);
1694
- const f = await e.load(c.userId);
1695
- f && await e.save(c.userId, { ...f, pending: f.pending.slice(1) });
1694
+ const g = await e.load(c.userId);
1695
+ g && await e.save(c.userId, { ...g, pending: g.pending.slice(1) });
1696
1696
  });
1697
1697
  }
1698
1698
  };
@@ -1711,22 +1711,22 @@ function Ih(t, e, n, i) {
1711
1711
  if (!d || u) {
1712
1712
  const p = await t["stage7.query"](c);
1713
1713
  if (p.data.kind !== "preferences") throw new Error("Invalid preference result.");
1714
- const f = p.data.value;
1714
+ const g = p.data.value;
1715
1715
  d = await r(async () => {
1716
1716
  a(c.authority);
1717
1717
  const y = await e.load(c.authority.userId);
1718
1718
  if (y) {
1719
- if (!u || (f.securityPolicyVersion ?? 1) < (y.value.securityPolicyVersion ?? 1)) return y;
1719
+ if (!u || (g.securityPolicyVersion ?? 1) < (y.value.securityPolicyVersion ?? 1)) return y;
1720
1720
  const b = { ...y, value: {
1721
1721
  ...y.value,
1722
- blockedOrigins: f.blockedOrigins,
1723
- securityPolicyVersion: f.securityPolicyVersion,
1724
- preferencesVersion: Math.max(y.value.preferencesVersion, f.preferencesVersion) + 1
1722
+ blockedOrigins: g.blockedOrigins,
1723
+ securityPolicyVersion: g.securityPolicyVersion,
1724
+ preferencesVersion: Math.max(y.value.preferencesVersion, g.preferencesVersion) + 1
1725
1725
  } };
1726
1726
  return await e.save(c.authority.userId, b), b;
1727
1727
  }
1728
- const g = { value: f, pending: [] };
1729
- return await e.save(c.authority.userId, g), g;
1728
+ const f = { value: g, pending: [] };
1729
+ return await e.save(c.authority.userId, f), f;
1730
1730
  });
1731
1731
  }
1732
1732
  return a(c.authority), l(c.authority), { data: { kind: "preferences", value: d.value }, completedAt: i() };
@@ -1735,28 +1735,28 @@ function Ih(t, e, n, i) {
1735
1735
  a(c.authority), $n(c.authority, c.mutation);
1736
1736
  const u = c.mutation;
1737
1737
  if (u.kind === "blockedOrigins" || u.kind === "personalInstructions") {
1738
- const p = async (f) => {
1739
- if (f.data.kind !== "preferences") throw new Error("Invalid preference result.");
1740
- const y = f.data.value;
1738
+ const p = async (g) => {
1739
+ if (g.data.kind !== "preferences") throw new Error("Invalid preference result.");
1740
+ const y = g.data.value;
1741
1741
  return { data: { kind: "preferences", value: await r(async () => {
1742
1742
  a(c.authority);
1743
- const b = await e.load(c.authority.userId), _ = {
1743
+ const b = await e.load(c.authority.userId), w = {
1744
1744
  ...b?.value ?? y,
1745
1745
  ...u.kind === "personalInstructions" ? { personalInstructions: y.personalInstructions } : { blockedOrigins: y.blockedOrigins, securityPolicyVersion: y.securityPolicyVersion },
1746
1746
  preferencesVersion: Math.max(b?.value.preferencesVersion ?? 0, y.preferencesVersion) + 1
1747
1747
  };
1748
- return await e.save(c.authority.userId, { value: _, pending: b?.pending ?? [] }), _;
1748
+ return await e.save(c.authority.userId, { value: w, pending: b?.pending ?? [] }), w;
1749
1749
  }) }, completedAt: i() };
1750
1750
  };
1751
- return t["stage7.mutate"](c).then(p, async (f) => {
1752
- throw u.kind === "personalInstructions" || await p(await t["stage7.query"]({ authority: c.authority, requestId: c.requestId, query: { kind: "preferences" } })), f;
1751
+ return t["stage7.mutate"](c).then(p, async (g) => {
1752
+ throw u.kind === "personalInstructions" || await p(await t["stage7.query"]({ authority: c.authority, requestId: c.requestId, query: { kind: "preferences" } })), g;
1753
1753
  });
1754
1754
  }
1755
1755
  if (u.kind !== "preference" && u.kind !== "scribblePreference") return t["stage7.mutate"](c);
1756
1756
  const d = await r(async () => {
1757
1757
  a(c.authority);
1758
- const p = await e.load(c.authority.userId), f = p?.value ?? vh, y = u.kind === "preference" ? { [u.feature === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"]: u.enabled } : { scribbleStyleEnabled: u.enabled }, g = { ...f, ...y, preferencesVersion: f.preferencesVersion + 1 };
1759
- return await e.save(c.authority.userId, { value: g, pending: [...p?.pending ?? [], u] }), g;
1758
+ const p = await e.load(c.authority.userId), g = p?.value ?? vh, y = u.kind === "preference" ? { [u.feature === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled"]: u.enabled } : { scribbleStyleEnabled: u.enabled }, f = { ...g, ...y, preferencesVersion: g.preferencesVersion + 1 };
1759
+ return await e.save(c.authority.userId, { value: f, pending: [...p?.pending ?? [], u] }), f;
1760
1760
  });
1761
1761
  return a(c.authority), l(c.authority), { data: { kind: "preferences", value: d }, completedAt: i() };
1762
1762
  }
@@ -2109,9 +2109,9 @@ function Wd(t, e, n) {
2109
2109
  let l = !1, c = !1, u = () => {
2110
2110
  }, d = () => {
2111
2111
  };
2112
- const p = (y, g) => {
2113
- c || (c = !0, u(), d(), y ? r(y) : a(g));
2114
- }, f = () => {
2112
+ const p = (y, f) => {
2113
+ c || (c = !0, u(), d(), y ? r(y) : a(f));
2114
+ }, g = () => {
2115
2115
  if (!l) return;
2116
2116
  const y = t.engine.getState().slices;
2117
2117
  if (JSON.stringify(y.account.authority) !== JSON.stringify(i)) {
@@ -2122,15 +2122,15 @@ function Wd(t, e, n) {
2122
2122
  p(Object.assign(new Error("Context observation retired."), { code: "observation_released", retryable: !1 }));
2123
2123
  return;
2124
2124
  }
2125
- const g = Object.values(y.features.pending).find((b) => b.requestId === o);
2126
- if (!g && e.type === "stage7.query") {
2125
+ const f = Object.values(y.features.pending).find((b) => b.requestId === o);
2126
+ if (!f && e.type === "stage7.query") {
2127
2127
  const b = Vs(y, e.query);
2128
2128
  b?.status === "error" ? p(b.error) : b?.status === "ready" && b.data && p(null, b.data);
2129
2129
  }
2130
- g?.status === "error" ? p(g.error) : g?.status === "done" && p(null, g.result);
2130
+ f?.status === "error" ? p(f.error) : f?.status === "done" && p(null, f.result);
2131
2131
  };
2132
- u = t.engine.subscribe(f), d = t.onDispose(() => p(new Error("Feature runtime disposed."))), t.engine.dispatch({ ...e, authority: i, requestId: o, now: Date.now() }).then(() => {
2133
- l = !0, f();
2132
+ u = t.engine.subscribe(g), d = t.onDispose(() => p(new Error("Feature runtime disposed."))), t.engine.dispatch({ ...e, authority: i, requestId: o, now: Date.now() }).then(() => {
2133
+ l = !0, g();
2134
2134
  }, (y) => p(y));
2135
2135
  });
2136
2136
  }
@@ -2142,36 +2142,36 @@ async function Th(t, e, n = crypto.randomUUID()) {
2142
2142
  let l = !1, c = !1, u = () => {
2143
2143
  }, d = () => {
2144
2144
  };
2145
- const p = (g) => {
2146
- c || (c = !0, u(), d(), g ? r(g) : a());
2147
- }, f = () => {
2145
+ const p = (f) => {
2146
+ c || (c = !0, u(), d(), f ? r(f) : a());
2147
+ }, g = () => {
2148
2148
  if (!l) return;
2149
- const g = t.engine.getState().slices;
2150
- if (JSON.stringify(g.account.authority) !== JSON.stringify(i)) return p(new Error("Feature authority retired."));
2151
- const b = g.interactions.actions[o];
2149
+ const f = t.engine.getState().slices;
2150
+ if (JSON.stringify(f.account.authority) !== JSON.stringify(i)) return p(new Error("Feature authority retired."));
2151
+ const b = f.interactions.actions[o];
2152
2152
  if (b) {
2153
2153
  b.status === "error" ? p(b.error) : b.status === "done" && p();
2154
2154
  return;
2155
2155
  }
2156
- const _ = Object.values(g.features.pending).find((k) => k.requestId === o);
2157
- if (_) {
2158
- _.status === "error" ? p(_.error) : _.status === "done" && p();
2156
+ const w = Object.values(f.features.pending).find((k) => k.requestId === o);
2157
+ if (w) {
2158
+ w.status === "error" ? p(w.error) : w.status === "done" && p();
2159
2159
  return;
2160
2160
  }
2161
- if (Object.values(g.interactions.devicePending).some((k) => k.requestId === o)) return;
2161
+ if (Object.values(f.interactions.devicePending).some((k) => k.requestId === o)) return;
2162
2162
  const S = e.interactionId === "preference:notifications" ? "notifications" : e.interactionId === "preference:tab_grouping" ? "tab_grouping" : null;
2163
- p(S ? g.interactions.deviceErrors[S] : void 0);
2163
+ p(S ? f.interactions.deviceErrors[S] : void 0);
2164
2164
  };
2165
- u = t.engine.subscribe(f), d = t.onDispose(() => p(new Error("Feature runtime disposed.")));
2165
+ u = t.engine.subscribe(g), d = t.onDispose(() => p(new Error("Feature runtime disposed.")));
2166
2166
  const y = s ? { type: "stage7.retry_action", authority: i, now: Date.now(), requestId: o } : { type: "stage7.act", authority: i, now: Date.now(), requestId: o, ...e, sourceVersion: e.expectedSourceVersion ?? null };
2167
2167
  t.engine.dispatch(y).then(() => {
2168
- l = !0, f();
2168
+ l = !0, g();
2169
2169
  }, p);
2170
2170
  });
2171
2171
  }
2172
2172
  function qh(t, e, n, i) {
2173
2173
  return Hd(t, e, n, i).map((s) => {
2174
- const o = s.sourceId ? Object.values(t.interactions.sources).find((y) => y.id === s.sourceId && y.conversation_id === s.conversationId) : null, a = o?.payload, r = s.payload.feature, l = s.category === "permission", c = s.category === "sharing" ? "social_share" : s.category === "integration_auth" ? "integration_connection" : s.category === "personal_channel" ? "personal_channel_connection" : r === "notifications" ? "task_notifications" : r === "tab_grouping" ? "tab_group_permission" : s.category, u = c === "integration_connection" && a?.kind === "integration_auth" ? `Connect ${a.app_name}` : c === "personal_channel_connection" ? "Connect WhatsApp" : null, d = r === "notifications" ? l ? "Allow notifications in this browser?" : "Get notified when Pluno finishes a task?" : r === "tab_grouping" ? l ? "Allow Pluno to group tabs in this browser?" : "Group tabs used by Pluno?" : s.category === "sharing" ? "Share what Pluno helped you accomplish." : String(s.payload.text ?? u ?? ""), p = Object.fromEntries(s.actions.map((y) => [y, s.actionLabels?.[y] ?? { enable: "Enable", not_now: "Not now", dont_enable: "Don't ask again", allow: "Allow", run: s.category === "proactive_suggestion" ? "Yes" : "Start", edit: "Edit", never: "Never", snooze: "Snooze morning report", pair: "Pair WhatsApp", dismiss: "Dismiss", copy: "Copy", share: "Share", feedback: "Send feedback" }[y] ?? y])), f = a?.kind === "integration_auth" ? { type: "pipedream_auth_required", authRequestId: a.request_id, appSlug: a.app_slug, appName: a.app_name, appLogo: a.app_logo, expiresAt: a.expires_at } : a?.kind === "personal_channel" ? { type: "personal_channel_connection_required", requestId: a.request_id, channel: a.channel, managementUrl: a.management_url } : null;
2174
+ const o = s.sourceId ? Object.values(t.interactions.sources).find((y) => y.id === s.sourceId && y.conversation_id === s.conversationId) : null, a = o?.payload, r = s.payload.feature, l = s.category === "permission", c = s.category === "sharing" ? "social_share" : s.category === "integration_auth" ? "integration_connection" : s.category === "personal_channel" ? "personal_channel_connection" : r === "notifications" ? "task_notifications" : r === "tab_grouping" ? "tab_group_permission" : s.category, u = c === "integration_connection" && a?.kind === "integration_auth" ? `Connect ${a.app_name}` : c === "personal_channel_connection" ? "Connect WhatsApp" : null, d = r === "notifications" ? l ? "Allow notifications in this browser?" : "Get notified when Pluno finishes a task?" : r === "tab_grouping" ? l ? "Allow Pluno to group tabs in this browser?" : "Group tabs used by Pluno?" : s.category === "sharing" ? "Share what Pluno helped you accomplish." : String(s.payload.text ?? u ?? ""), p = Object.fromEntries(s.actions.map((y) => [y, s.actionLabels?.[y] ?? { enable: "Enable", not_now: "Not now", dont_enable: "Don't ask again", allow: "Allow", run: s.category === "proactive_suggestion" ? "Yes" : "Start", edit: "Edit", never: "Never", snooze: "Snooze morning report", pair: "Pair WhatsApp", dismiss: "Dismiss", copy: "Copy", share: "Share", feedback: "Send feedback" }[y] ?? y])), g = a?.kind === "integration_auth" ? { type: "pipedream_auth_required", authRequestId: a.request_id, appSlug: a.app_slug, appName: a.app_name, appLogo: a.app_logo, expiresAt: a.expires_at } : a?.kind === "personal_channel" ? { type: "personal_channel_connection_required", requestId: a.request_id, channel: a.channel, managementUrl: a.management_url } : null;
2175
2175
  return {
2176
2176
  id: s.id,
2177
2177
  kind: c,
@@ -2180,7 +2180,7 @@ function qh(t, e, n, i) {
2180
2180
  payload: {
2181
2181
  ...s.payload,
2182
2182
  error: s.error?.message ?? null,
2183
- ...f ? { request: f, status: s.payload.lifecycle ?? o?.lifecycle, error: s.error?.message ?? null } : {},
2183
+ ...g ? { request: g, status: s.payload.lifecycle ?? o?.lifecycle, error: s.error?.message ?? null } : {},
2184
2184
  ...s.category === "sharing" ? { candidate: { id: s.id, variant: a?.kind === "sharing" ? a.variant : "social" } } : {},
2185
2185
  ...s.category === "proactive_suggestion" ? { suggestion: { id: String(s.payload.sourceSuggestionId ?? s.id), interactionId: s.id, genericQuestion: String(s.payload.text ?? ""), question: String(s.payload.text ?? "") } } : {},
2186
2186
  ...s.category === "morning_report" ? { opening: s.payload.text, prompts: s.payload.tasks } : {}
@@ -2375,7 +2375,7 @@ function Lh(t, e, n, i) {
2375
2375
  } : null });
2376
2376
  const p = { ...t.requests };
2377
2377
  delete p[e.effectId];
2378
- let f = t.submissions;
2378
+ let g = t.submissions;
2379
2379
  if (e.type === "effect.completed" && e.output.snapshot.conversation_id !== r.sessionId) throw new Error("Snapshot belongs to another conversation.");
2380
2380
  if (e.type === "effect.completed" && !e.output.snapshot.projection_ready && (e.output.snapshot.preparation === "pending" || e.output.snapshot.preparation === "busy")) {
2381
2381
  for (const y of e.output.snapshot.items) y.type === "user_message" && (l = Xr(l, y));
@@ -2394,23 +2394,23 @@ function Lh(t, e, n, i) {
2394
2394
  else {
2395
2395
  const y = at(e.output.snapshot);
2396
2396
  r.lane === "current" && (l = { ...l, preparation: null });
2397
- const g = l.queries.history, b = r.lane === "current" && (g.status === "not_requested" || y.next_cursor !== null && !l.items[y.next_cursor]);
2397
+ const f = l.queries.history, b = r.lane === "current" && (f.status === "not_requested" || y.next_cursor !== null && !l.items[y.next_cursor]);
2398
2398
  if (y.conversation_id !== r.sessionId) throw new Error("Snapshot belongs to another conversation.");
2399
- for (const _ of y.removed_items) l = or(l, _);
2400
- for (const _ of y.items) l = Xr(l, _);
2401
- for (const _ of y.streams) l = Vd(l, _);
2399
+ for (const w of y.removed_items) l = or(l, w);
2400
+ for (const w of y.items) l = Xr(l, w);
2401
+ for (const w of y.streams) l = Vd(l, w);
2402
2402
  if (l = Zr(l, y.execution), l = or(l, {
2403
2403
  type: "conversation.follow_ups.updated",
2404
2404
  conversation_id: y.conversation_id,
2405
2405
  version: y.follow_ups_version,
2406
2406
  follow_ups: y.follow_ups
2407
- }), y.interactions.some((_) => _.conversation_id !== y.conversation_id)) throw new Error("Interaction belongs to another conversation.");
2407
+ }), y.interactions.some((w) => w.conversation_id !== y.conversation_id)) throw new Error("Interaction belongs to another conversation.");
2408
2408
  if (a = { authorityId: t.authorityId, generation: t.generation, sessionId: r.sessionId, sources: y.interactions }, y.execution.version === l.execution?.version)
2409
- for (const _ of r.acceptedUserMessageIds) {
2410
- const S = f[_];
2411
- S.executionVersion === null && (f = {
2412
- ...f,
2413
- [_]: { ...S, executionVersion: y.execution.version }
2409
+ for (const w of r.acceptedUserMessageIds) {
2410
+ const S = g[w];
2411
+ S.executionVersion === null && (g = {
2412
+ ...g,
2413
+ [w]: { ...S, executionVersion: y.execution.version }
2414
2414
  });
2415
2415
  }
2416
2416
  if (l = { ...l, queries: { ...l.queries, [r.lane]: {
@@ -2422,12 +2422,12 @@ function Lh(t, e, n, i) {
2422
2422
  cursor: y.next_cursor,
2423
2423
  updatedAt: e.output.updatedAt
2424
2424
  } } }, b) {
2425
- for (const [_, S] of Object.entries(p))
2426
- S.sessionId === r.sessionId && S.lane === "history" && delete p[_];
2427
- l = { ...l, queries: { ...l.queries, history: { ...l.queries.current, key: g.key } } };
2425
+ for (const [w, S] of Object.entries(p))
2426
+ S.sessionId === r.sessionId && S.lane === "history" && delete p[w];
2427
+ l = { ...l, queries: { ...l.queries, history: { ...l.queries.current, key: f.key } } };
2428
2428
  }
2429
2429
  }
2430
- s = { ...t, requests: p, submissions: f, sessions: { ...t.sessions, [l.sessionId]: l } };
2430
+ s = { ...t, requests: p, submissions: g, sessions: { ...t.sessions, [l.sessionId]: l } };
2431
2431
  } else {
2432
2432
  if (e.authorityId !== t.authorityId || e.generation !== t.generation || !n.authorityId && !["conversation.submission_stage", "conversation.submission_delivery", "conversation.stop"].includes(e.type)) return { state: t, effects: o };
2433
2433
  switch (e.type) {
@@ -2458,24 +2458,24 @@ function Lh(t, e, n, i) {
2458
2458
  }
2459
2459
  case "conversation.submission_stage": {
2460
2460
  if (n.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
2461
- const { type: r, authorityId: l, generation: c, prepareContext: u, waitForAuthentication: d, ...p } = e, f = t.submissions[e.userMessageId];
2462
- if (f) {
2463
- const { contextPreparation: k, requestedModel: m, sessionId: w, delivery: I, cancelled: x, cancellationReason: E, error: A, executionVersion: L, ...P } = f;
2464
- if (vs(P) !== vs(p)) throw new Error("User-message identity cannot be reused with different input.");
2461
+ const { type: r, authorityId: l, generation: c, prepareContext: u, reconcileAcceptance: d, waitForAuthentication: p, ...g } = e, y = t.submissions[e.userMessageId];
2462
+ if (y) {
2463
+ const { contextPreparation: m, requestedModel: _, sessionId: I, delivery: x, cancelled: E, cancellationReason: A, error: L, executionVersion: M, ...z } = y;
2464
+ if (vs(z) !== vs(g)) throw new Error("User-message identity cannot be reused with different input.");
2465
2465
  return { state: t, effects: o };
2466
2466
  }
2467
- const y = n.selections[e.conversationScopeId], g = Object.values(t.submissions).find((k) => k.conversationScopeId === e.conversationScopeId && !k.cancelled && k.sessionId !== null), b = i.scopes[e.clientScopeId], _ = {
2468
- ...at(p),
2467
+ const f = n.selections[e.conversationScopeId], b = Object.values(t.submissions).find((m) => m.conversationScopeId === e.conversationScopeId && !m.cancelled && m.sessionId !== null), w = i.scopes[e.clientScopeId], S = {
2468
+ ...at(g),
2469
2469
  ...u ? { contextPreparation: null } : {},
2470
2470
  // Extension staging can await page context after the picker has already changed.
2471
- requestedModel: b?.submissions[e.userMessageId] ? b.submissions[e.userMessageId].requestedModel ?? null : b ? Ta(b) ?? null : null,
2472
- sessionId: y.sessionId ?? g?.sessionId ?? null,
2473
- delivery: d ? "failed" : "staged",
2471
+ requestedModel: w?.submissions[e.userMessageId] ? w.submissions[e.userMessageId].requestedModel ?? null : w ? Ta(w) ?? null : null,
2472
+ sessionId: f.sessionId ?? b?.sessionId ?? null,
2473
+ delivery: p ? "failed" : "staged",
2474
2474
  cancelled: !1,
2475
- error: d ? { code: d, message: d === "unauthorized" ? "Open the Pluno login link, then return to Pluno." : "Pluno is reconnecting. Try again in a moment.", retryable: !1 } : null,
2475
+ error: p ? { code: p, message: p === "unauthorized" ? "Open the Pluno login link, then return to Pluno." : "Pluno is reconnecting. Try again in a moment.", retryable: !1 } : null,
2476
2476
  executionVersion: null
2477
- }, S = { ...t.proactiveQuestions };
2478
- delete S[e.conversationScopeId], s = { ...t, proactiveQuestions: S, submissions: { ...t.submissions, [e.userMessageId]: _ }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
2477
+ }, k = { ...t.proactiveQuestions };
2478
+ delete k[e.conversationScopeId], s = { ...t, proactiveQuestions: k, submissions: { ...t.submissions, [e.userMessageId]: S }, submissionOrder: [...t.submissionOrder, e.userMessageId] };
2479
2479
  break;
2480
2480
  }
2481
2481
  case "conversation.submission_accepted": {
@@ -2492,14 +2492,14 @@ function Lh(t, e, n, i) {
2492
2492
  }
2493
2493
  case "conversation.stop": {
2494
2494
  if (n.clients[e.clientScopeId] !== e.conversationScopeId) return { state: t, effects: o };
2495
- const r = n.selections[e.conversationScopeId].sessionId, l = r ? t.sessions[r]?.execution : null, c = Object.values(t.submissions).filter((g) => (r ? g.sessionId === r : g.conversationScopeId === e.conversationScopeId) && (!e.userMessageIds || e.userMessageIds.includes(g.userMessageId))), u = c.filter((g) => !g.cancelled && (g.delivery !== "failed" || t.deliveries[g.userMessageId]?.phase === "paused" || e.userMessageIds?.includes(g.userMessageId) && t.deliveries[g.userMessageId]?.acceptance === "unissued") && (g.delivery !== "accepted" || g.executionVersion === null)), d = u.length > 0, p = l && ["queued", "thinking", "steering", "stopping"].includes(l.phase) && (!e.userMessageIds || Tt(l).some((g) => e.userMessageIds.includes(g)));
2495
+ const r = n.selections[e.conversationScopeId].sessionId, l = r ? t.sessions[r]?.execution : null, c = Object.values(t.submissions).filter((f) => (r ? f.sessionId === r : f.conversationScopeId === e.conversationScopeId) && (!e.userMessageIds || e.userMessageIds.includes(f.userMessageId))), u = c.filter((f) => !f.cancelled && (f.delivery !== "failed" || t.deliveries[f.userMessageId]?.phase === "paused" || e.userMessageIds?.includes(f.userMessageId) && t.deliveries[f.userMessageId]?.acceptance === "unissued") && (f.delivery !== "accepted" || f.executionVersion === null)), d = u.length > 0, p = l && ["queued", "thinking", "steering", "stopping"].includes(l.phase) && (!e.userMessageIds || Tt(l).some((f) => e.userMessageIds.includes(f)));
2496
2496
  if (!d && !p && (l || !e.userMessageIds?.length)) return { state: t, effects: o };
2497
- const f = Array.from(new Set(e.userMessageIds ?? [...u.map((g) => g.userMessageId), ...p ? Tt(l) : []])), y = { ...t.submissions };
2498
- for (const g of c)
2499
- f.includes(g.userMessageId) && g.delivery !== "accepted" && (y[g.userMessageId] = { ...g, cancelled: !0, cancellationReason: e.reason ?? "user_requested" });
2497
+ const g = Array.from(new Set(e.userMessageIds ?? [...u.map((f) => f.userMessageId), ...p ? Tt(l) : []])), y = { ...t.submissions };
2498
+ for (const f of c)
2499
+ g.includes(f.userMessageId) && f.delivery !== "accepted" && (y[f.userMessageId] = { ...f, cancelled: !0, cancellationReason: e.reason ?? "user_requested" });
2500
2500
  s = { ...t, submissions: y, stops: { ...t.stops, [e.conversationScopeId]: {
2501
2501
  requestId: e.requestId,
2502
- userMessageIds: f,
2502
+ userMessageIds: g,
2503
2503
  executionVersion: l?.version ?? -1,
2504
2504
  reason: e.reason ?? "user_requested"
2505
2505
  } } };
@@ -2544,7 +2544,7 @@ function Lh(t, e, n, i) {
2544
2544
  before: e.lane === "history" ? l.cursor : null,
2545
2545
  refreshItemIds: Dh(r),
2546
2546
  retryPreparation: l.error?.code === "history_preparation_failed"
2547
- }, u = Object.values(t.submissions).filter((f) => f.sessionId === e.sessionId && f.delivery === "accepted" && f.executionVersion === null).map((f) => f.userMessageId), d = t.requestSequence + 1, p = `conversation:${t.generation}:${d}`;
2547
+ }, u = Object.values(t.submissions).filter((g) => g.sessionId === e.sessionId && g.delivery === "accepted" && g.executionVersion === null).map((g) => g.userMessageId), d = t.requestSequence + 1, p = `conversation:${t.generation}:${d}`;
2548
2548
  s = {
2549
2549
  ...t,
2550
2550
  requestSequence: d,
@@ -2583,15 +2583,15 @@ function qa(t, e) {
2583
2583
  if (d.cancelled && n.has(d.conversationScopeId) && t.stops[d.conversationScopeId]?.userMessageIds.includes(u) && !p?.items[u] && !p?.removedItems[u]) return !0;
2584
2584
  if (d.delivery === "accepted") {
2585
2585
  if (d.cancelled) return !s(u);
2586
- const f = d.sessionId ? t.sessions[d.sessionId] : void 0;
2587
- return d.executionVersion === null || !(f?.items[u] || f?.removedItems[u]);
2586
+ const g = d.sessionId ? t.sessions[d.sessionId] : void 0;
2587
+ return d.executionVersion === null || !(g?.items[u] || g?.removedItems[u]);
2588
2588
  }
2589
2589
  return !d.cancelled || mn(t, u) || t.deliveries[u]?.phase === "running";
2590
2590
  }).map(([u, d]) => [u, d.delivery === "accepted" || d.cancelled ? { ...d, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } } : d])), a = Object.fromEntries(Object.entries(t.deliveries).filter(([u]) => u in o).map(([u, d]) => [u, o[u].delivery === "accepted" ? { ...d, phase: "done", effectId: null, command: null, uploads: [], completedUploads: 0 } : o[u].cancelled ? { ...d, command: null } : d])), r = Object.fromEntries(Object.entries(t.stops).filter(([u, d]) => d.userMessageIds.some((p) => {
2591
2591
  if (o[p]) return !0;
2592
2592
  if (!s(p)) return i.some((y) => y.command.payload.expectedUserMessageId === p && y.phase !== "done");
2593
- const f = Object.values(t.sessions).find((y) => y.executionByUserMessage[p])?.executionByUserMessage[p];
2594
- return n.has(u) && (!f || f.version <= d.executionVersion || !["completed", "failed", "stopped"].includes(f.phase));
2593
+ const g = Object.values(t.sessions).find((y) => y.executionByUserMessage[p])?.executionByUserMessage[p];
2594
+ return n.has(u) && (!g || g.version <= d.executionVersion || !["completed", "failed", "stopped"].includes(g.phase));
2595
2595
  }))), l = new Set(Object.values(r).flatMap((u) => u.userMessageIds)), c = Object.fromEntries(Object.entries(t.operations).filter(([, u]) => {
2596
2596
  if (!["done", "failed"].includes(u.phase)) return !0;
2597
2597
  if (u.command.type === "run.stop") return l.has(String(u.command.payload.expectedUserMessageId)) || Object.values(o).some((p) => p.cancelled && p.userMessageId === u.command.payload.expectedUserMessageId);
@@ -2599,7 +2599,7 @@ function qa(t, e) {
2599
2599
  if (u.command.type === "runtime.warmup") return e.selections[u.conversationScopeId]?.sessionId !== u.result?.sessionId;
2600
2600
  if (u.command.type !== "attachment.prepare") return !1;
2601
2601
  const d = u.command.payload.source;
2602
- return !Object.values(t.submissions).some((p) => p.conversationScopeId === u.conversationScopeId && p.delivery === "accepted" && p.attachments.some((f) => f.sourceId === d.sourceId));
2602
+ return !Object.values(t.submissions).some((p) => p.conversationScopeId === u.conversationScopeId && p.delivery === "accepted" && p.attachments.some((g) => g.sourceId === d.sourceId));
2603
2603
  }));
2604
2604
  return We({
2605
2605
  schema: 1,
@@ -2649,27 +2649,32 @@ function oa(t) {
2649
2649
  const l = e.submissions[r];
2650
2650
  let c = e.deliveries[r];
2651
2651
  if (t.pendingRestoration[l.clientScopeId] === l.conversationScopeId || !c || c.phase !== "waiting" || !mn(e, r) || l.delivery === "accepted") continue;
2652
+ if (c.handoffRecovery && c.step === "receipt") {
2653
+ const g = s();
2654
+ e = { ...e, deliveries: { ...e.deliveries, [r]: { ...c, phase: "running", effectId: g, prepared: l.cancelled } } }, n.push({ id: g, kind: "conversation.receipt", input: { ...i, userMessageId: r, sessionId: l.sessionId } });
2655
+ continue;
2656
+ }
2652
2657
  if (!c.prepared && !l.cancelled) {
2653
- const f = s();
2654
- e = { ...e, deliveries: { ...e.deliveries, [r]: { ...c, phase: "running", effectId: f } } }, n.push({ id: f, kind: "conversation.prepare", input: { ...i, submission: l, sources: l.attachments.slice(c.uploads.length) } });
2658
+ const g = s();
2659
+ e = { ...e, deliveries: { ...e.deliveries, [r]: { ...c, phase: "running", effectId: g } } }, n.push({ id: g, kind: "conversation.prepare", input: { ...i, submission: l, sources: l.attachments.slice(c.uploads.length) } });
2655
2660
  continue;
2656
2661
  }
2657
- if (l.contextPreparation === null && !l.cancelled || l.sessionId === null && Object.values(e.operations).some((f) => ["runtime.warmup", "attachment.prepare"].includes(f.command.type) && f.conversationScopeId === l.conversationScopeId && (["waiting", "running", "uncertain"].includes(f.phase) || f.phase === "done" && !!f.result?.sessionId)) || l.sessionId === null && o.some((f) => f !== r && o.indexOf(f) < o.indexOf(r) && e.submissions[f].conversationScopeId === l.conversationScopeId && e.deliveries[f] && !e.submissions[f].cancelled && (e.submissions[f].delivery !== "failed" || e.deliveries[f].acceptance === "uncertain" || e.deliveries[f].allocation === "uncertain"))) continue;
2662
+ if (l.contextPreparation === null && !l.cancelled || l.sessionId === null && Object.values(e.operations).some((g) => ["runtime.warmup", "attachment.prepare"].includes(g.command.type) && g.conversationScopeId === l.conversationScopeId && (["waiting", "running", "uncertain"].includes(g.phase) || g.phase === "done" && !!g.result?.sessionId)) || l.sessionId === null && o.some((g) => g !== r && o.indexOf(g) < o.indexOf(r) && e.submissions[g].conversationScopeId === l.conversationScopeId && e.deliveries[g] && !e.submissions[g].cancelled && (e.submissions[g].delivery !== "failed" || e.deliveries[g].acceptance === "uncertain" || e.deliveries[g].allocation === "uncertain"))) continue;
2658
2663
  for (; c.uploads.length < l.attachments.length; ) {
2659
- const f = l.attachments[c.uploads.length];
2660
- if (f.uploaded) {
2661
- c = { ...c, uploads: [...c.uploads, f.uploaded] };
2664
+ const g = l.attachments[c.uploads.length];
2665
+ if (g.uploaded) {
2666
+ c = { ...c, uploads: [...c.uploads, g.uploaded] };
2662
2667
  continue;
2663
2668
  }
2664
- const y = Object.values(e.operations).find((g) => g.command.type === "attachment.prepare" && g.conversationScopeId === l.conversationScopeId && g.phase === "done" && g.command.payload.source.sourceId === f.sourceId && g.result?.sessionId === l.sessionId);
2669
+ const y = Object.values(e.operations).find((f) => f.command.type === "attachment.prepare" && f.conversationScopeId === l.conversationScopeId && f.phase === "done" && f.command.payload.source.sourceId === g.sourceId && f.result?.sessionId === l.sessionId);
2665
2670
  if (!y) break;
2666
2671
  c = { ...c, uploads: [...c.uploads, y.result.attachment] };
2667
2672
  }
2668
2673
  for (; c.completedUploads < c.uploads.length && l.attachments[c.completedUploads].uploaded; )
2669
2674
  c = { ...c, completedUploads: c.completedUploads + 1 };
2670
- if (!l.cancelled && c.uploads.length === l.attachments.length && c.completedUploads === c.uploads.length && o.slice(0, o.indexOf(r)).some((f) => {
2671
- const y = e.submissions[f];
2672
- return (y.conversationScopeId === l.conversationScopeId || l.sessionId !== null && y.sessionId === l.sessionId) && y.delivery !== "accepted" && (y.delivery !== "failed" || e.deliveries[f]?.acceptance === "uncertain") && (!y.cancelled || mn(e, f));
2675
+ if (!l.cancelled && c.uploads.length === l.attachments.length && c.completedUploads === c.uploads.length && o.slice(0, o.indexOf(r)).some((g) => {
2676
+ const y = e.submissions[g];
2677
+ return (y.conversationScopeId === l.conversationScopeId || l.sessionId !== null && y.sessionId === l.sessionId) && y.delivery !== "accepted" && (y.delivery !== "failed" || e.deliveries[g]?.acceptance === "uncertain") && (!y.cancelled || mn(e, g));
2673
2678
  })) continue;
2674
2679
  const u = s();
2675
2680
  let d, p = c.command;
@@ -2707,7 +2712,7 @@ function oa(t) {
2707
2712
  };
2708
2713
  for (const [r, l] of Object.entries(e.stops))
2709
2714
  for (const c of l.userMessageIds) {
2710
- const u = e.submissions[c], d = u?.sessionId ?? Object.values(e.sessions).find((f) => Tt(f.execution).includes(c))?.sessionId, p = u?.delivery === "accepted" || d && Tt(e.sessions[d]?.execution).includes(c);
2715
+ const u = e.submissions[c], d = u?.sessionId ?? Object.values(e.sessions).find((g) => Tt(g.execution).includes(c))?.sessionId, p = u?.delivery === "accepted" || d && Tt(e.sessions[d]?.execution).includes(c);
2711
2716
  d && p && a(`stop:${r}:${l.requestId}:${c}`, d, c, l.reason);
2712
2717
  }
2713
2718
  for (const r of Object.values(e.submissions))
@@ -2719,8 +2724,8 @@ function oa(t) {
2719
2724
  ));
2720
2725
  for (const [r, l] of Object.entries(e.operations)) {
2721
2726
  if (l.phase !== "waiting" || l.conversationScopeId && Object.values(e.pendingRestoration).includes(l.conversationScopeId)) continue;
2722
- const c = Object.values(e.operations).filter((f) => f !== l && f.conversationScopeId === l.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(f.command.type)), u = c.find((f) => f.phase === "done" && f.result?.sessionId)?.result, d = l.command.payload.sessionId ?? u?.sessionId ?? Object.values(e.submissions).find((f) => f.conversationScopeId === l.conversationScopeId && !f.cancelled && f.sessionId)?.sessionId ?? null;
2723
- if (l.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(l.command.type) && !d && (c.some((f) => f.phase === "running" || f.phase === "uncertain") || Object.values(e.submissions).some((f) => f.conversationScopeId === l.conversationScopeId && e.deliveries[f.userMessageId]?.phase === "running"))) continue;
2727
+ const c = Object.values(e.operations).filter((g) => g !== l && g.conversationScopeId === l.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(g.command.type)), u = c.find((g) => g.phase === "done" && g.result?.sessionId)?.result, d = l.command.payload.sessionId ?? u?.sessionId ?? Object.values(e.submissions).find((g) => g.conversationScopeId === l.conversationScopeId && !g.cancelled && g.sessionId)?.sessionId ?? null;
2728
+ if (l.conversationScopeId && ["runtime.warmup", "attachment.prepare"].includes(l.command.type) && !d && (c.some((g) => g.phase === "running" || g.phase === "uncertain") || Object.values(e.submissions).some((g) => g.conversationScopeId === l.conversationScopeId && e.deliveries[g.userMessageId]?.phase === "running"))) continue;
2724
2729
  if (l.command.type === "runtime.warmup" && u && !l.command.payload.sessionId) {
2725
2730
  e = { ...e, operations: { ...e.operations, [r]: { ...l, phase: "done", result: u } } };
2726
2731
  continue;
@@ -2745,46 +2750,54 @@ function oa(t) {
2745
2750
  function Uh(t, e, n, i) {
2746
2751
  let s = t, o = e;
2747
2752
  if (e.type === "effect.completed" || e.type === "effect.failed") {
2748
- e.effectKind === "conversation.checkpoint" && e.effectId === t.checkpointEffectId && (s = { ...s, checkpointEffectId: null, checkpointError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed" && e.effectKind === "conversation.checkpoint" && e.output && e.output.authorityId === t.authorityId && e.output.generation === t.generation && (s = { ...s, durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...e.output.submissionIds])].filter((f) => !!t.submissions[f]) });
2749
- const d = Object.keys(t.deliveries).find((f) => t.deliveries[f].effectId === e.effectId), p = Object.keys(t.operations).find((f) => t.operations[f].effectId === e.effectId);
2753
+ e.effectKind === "conversation.checkpoint" && e.effectId === t.checkpointEffectId && (s = { ...s, checkpointEffectId: null, checkpointError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed" && e.effectKind === "conversation.checkpoint" && e.output && e.output.authorityId === t.authorityId && e.output.generation === t.generation && (s = { ...s, durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...e.output.submissionIds])].filter((g) => !!t.submissions[g]) });
2754
+ const d = Object.keys(t.deliveries).find((g) => t.deliveries[g].effectId === e.effectId), p = Object.keys(t.operations).find((g) => t.operations[g].effectId === e.effectId);
2750
2755
  if (d) {
2751
- const f = t.deliveries[d], y = t.submissions[d];
2752
- let g = { ...f, phase: "waiting", effectId: null };
2756
+ const g = t.deliveries[d], y = t.submissions[d];
2757
+ let f = { ...g, phase: "waiting", effectId: null };
2753
2758
  if (e.type === "effect.failed") {
2754
- const b = e.error.details?.acceptance === "unissued" && f.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : f.acceptance, _ = e.error.details?.allocation === "unissued" ? "unissued" : f.allocation, S = e.effectKind === "conversation.command" && f.step === "send" && b === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", k = e.effectKind === "conversation.prepare" || S ? "failed" : b === "uncertain" || _ === "uncertain" || e.error.retryable ? "uncertain" : "failed";
2755
- g = { ...g, phase: k, acceptance: b, allocation: _ }, !y.cancelled && y.delivery !== "accepted" && (s = { ...s, submissions: {
2759
+ const b = e.error.details?.acceptance === "unissued" && g.acceptance !== "accepted" ? "unissued" : e.error.details?.acceptance === "rejected" ? "rejected" : g.acceptance, w = e.error.details?.allocation === "unissued" ? "unissued" : g.allocation, S = e.effectKind === "conversation.command" && g.step === "send" && b === "unissued" || e.effectKind === "conversation.upload" && e.error.details?.allocation === "unissued", k = e.effectKind === "conversation.prepare" || S ? "failed" : b === "uncertain" || w === "uncertain" || e.error.retryable ? "uncertain" : "failed";
2760
+ f = {
2761
+ ...f,
2762
+ phase: k,
2763
+ acceptance: b,
2764
+ allocation: w,
2765
+ ...g.handoffRecovery && g.step === "send" ? { step: "receipt" } : {}
2766
+ }, !y.cancelled && y.delivery !== "accepted" && (s = { ...s, submissions: {
2756
2767
  ...s.submissions,
2757
2768
  [d]: { ...y, delivery: k, error: e.error }
2758
2769
  } });
2759
2770
  } else if (e.effectKind === "conversation.prepare")
2760
- y.cancelled ? g = { ...g, phase: "failed" } : (g = { ...g, prepared: !0 }, s = { ...s, submissions: { ...s.submissions, [d]: {
2771
+ y.cancelled ? f = { ...f, phase: "failed" } : (f = { ...f, prepared: !0 }, s = { ...s, submissions: { ...s.submissions, [d]: {
2761
2772
  ...y,
2762
2773
  ...y.contextPreparation === null ? { contextPreparation: { pageContent: e.output.pageContent, sessionTabs: e.output.sessionTabs } } : {}
2763
- } } }, f.recoveryDeadline !== null && e.output.now >= f.recoveryDeadline && (g = { ...g, phase: "paused" }, s = { ...s, submissions: { ...s.submissions, [d]: {
2774
+ } } }, g.recoveryDeadline !== null && e.output.now >= g.recoveryDeadline && (f = { ...f, phase: "paused" }, s = { ...s, submissions: { ...s.submissions, [d]: {
2764
2775
  ...s.submissions[d],
2765
2776
  delivery: "failed",
2766
2777
  error: { code: "message_delivery_failed", message: "Pluno could not send this message. Try it again.", retryable: !0 }
2767
2778
  } } }));
2768
2779
  else if (e.effectKind === "conversation.upload") {
2769
- const b = at(e.output), _ = y.attachments[f.uploads.length];
2770
- if (b.attachment.id !== _.sourceId || b.attachment.size_bytes !== _.sizeBytes || y.sessionId !== null && y.sessionId !== b.sessionId)
2780
+ const b = at(e.output), w = y.attachments[g.uploads.length];
2781
+ if (b.attachment.id !== w.sourceId || b.attachment.size_bytes !== w.sizeBytes || y.sessionId !== null && y.sessionId !== b.sessionId)
2771
2782
  throw new Error("Upload does not match the captured attachment or conversation.");
2772
- g = { ...g, allocation: "resolved", uploads: [...f.uploads, b.attachment] };
2783
+ f = { ...f, allocation: "resolved", uploads: [...g.uploads, b.attachment] };
2773
2784
  const S = Object.fromEntries(Object.entries(s.submissions).map(([k, m]) => [
2774
2785
  k,
2775
2786
  m.conversationScopeId === y.conversationScopeId && (k === d || !m.cancelled && !y.cancelled) ? { ...m, sessionId: b.sessionId } : m
2776
2787
  ]));
2777
2788
  s = { ...s, submissions: S };
2778
2789
  } else if (e.effectKind === "conversation.receipt")
2779
- if (e.output === null)
2780
- g = { ...g, phase: y.cancelled ? "uncertain" : "paused" }, y.cancelled || (s = { ...s, submissions: { ...s.submissions, [d]: {
2790
+ if (e.output === null && g.handoffRecovery && !y.cancelled)
2791
+ f = { ...f, phase: "waiting", step: null };
2792
+ else if (e.output === null)
2793
+ f = { ...f, phase: y.cancelled ? "uncertain" : "paused" }, y.cancelled || (s = { ...s, submissions: { ...s.submissions, [d]: {
2781
2794
  ...y,
2782
2795
  delivery: "failed",
2783
2796
  error: { code: "message_acceptance_unconfirmed", message: "Pluno could not confirm whether this message was accepted. Try again.", retryable: !0 }
2784
2797
  } } });
2785
2798
  else {
2786
2799
  const b = dl(e.output, d);
2787
- g = { ...g, phase: "done", acceptance: "accepted" }, o = {
2800
+ f = { ...f, phase: "done", acceptance: "accepted" }, o = {
2788
2801
  type: "conversation.submission_accepted",
2789
2802
  authorityId: t.authorityId,
2790
2803
  generation: t.generation,
@@ -2792,11 +2805,11 @@ function Uh(t, e, n, i) {
2792
2805
  sessionId: b.sessionId
2793
2806
  };
2794
2807
  }
2795
- else if (e.effectKind === "conversation.command" && f.step === "complete")
2796
- g = { ...g, completedUploads: f.completedUploads + 1, command: null };
2797
- else if (e.effectKind === "conversation.command" && f.step === "send") {
2808
+ else if (e.effectKind === "conversation.command" && g.step === "complete")
2809
+ f = { ...f, completedUploads: g.completedUploads + 1, command: null };
2810
+ else if (e.effectKind === "conversation.command" && g.step === "send") {
2798
2811
  const b = dl(e.output, d);
2799
- g = { ...g, phase: "done", acceptance: "accepted" }, o = {
2812
+ f = { ...f, phase: "done", acceptance: "accepted" }, o = {
2800
2813
  type: "conversation.submission_accepted",
2801
2814
  authorityId: t.authorityId,
2802
2815
  generation: t.generation,
@@ -2804,26 +2817,26 @@ function Uh(t, e, n, i) {
2804
2817
  sessionId: b.sessionId
2805
2818
  };
2806
2819
  }
2807
- s = { ...s, deliveries: { ...s.deliveries, [d]: g } };
2820
+ s = { ...s, deliveries: { ...s.deliveries, [d]: f } };
2808
2821
  } else if (p) {
2809
- const f = t.operations[p];
2822
+ const g = t.operations[p];
2810
2823
  if (s = { ...s, operations: { ...s.operations, [p]: {
2811
- ...f,
2824
+ ...g,
2812
2825
  effectId: null,
2813
2826
  phase: e.type === "effect.failed" ? e.error.retryable ? "uncertain" : "failed" : "done",
2814
2827
  error: e.type === "effect.failed" ? e.error : null,
2815
2828
  result: e.type === "effect.completed" ? at(e.output) : null
2816
- } } }, e.type === "effect.completed" && ["runtime.warmup", "attachment.prepare"].includes(f.command.type) && !f.command.payload.sessionId && f.conversationScopeId && !Object.values(n.clients).includes(f.conversationScopeId)) {
2829
+ } } }, e.type === "effect.completed" && ["runtime.warmup", "attachment.prepare"].includes(g.command.type) && !g.command.payload.sessionId && g.conversationScopeId && !Object.values(n.clients).includes(g.conversationScopeId)) {
2817
2830
  const y = e.output;
2818
2831
  y?.sessionId && (s = { ...s, operations: {
2819
2832
  ...s.operations,
2820
2833
  [`cleanup:${p}`]: sa({
2821
- request_id: `cleanup:${f.command.request_id}`,
2834
+ request_id: `cleanup:${g.command.request_id}`,
2822
2835
  type: "session.reset",
2823
2836
  payload: {
2824
2837
  sessionId: y.sessionId,
2825
- ...f.command.payload.warmupId ? { warmupId: f.command.payload.warmupId } : {},
2826
- ...f.command.payload.page ? { page: f.command.payload.page } : {}
2838
+ ...g.command.payload.warmupId ? { warmupId: g.command.payload.warmupId } : {},
2839
+ ...g.command.payload.page ? { page: g.command.payload.page } : {}
2827
2840
  }
2828
2841
  })
2829
2842
  } });
@@ -2837,50 +2850,50 @@ function Uh(t, e, n, i) {
2837
2850
  const d = at(e.checkpoint), p = t.submissionOrder.every((m) => t.deliveries[m]?.acceptance === "unissued" && t.submissions[m].delivery === "failed" && ["unauthorized", "auth_reconnecting"].includes(t.submissions[m].error?.code ?? ""));
2838
2851
  if (d.schema !== 1 || d.authorityId !== t.authorityId || !p || Object.keys(t.operations).length)
2839
2852
  throw new Error("Delivery restoration requires an empty engine with the same authenticated authority.");
2840
- const f = { ...t.submissions, ...d.submissions };
2841
- for (const [m, w] of Object.entries(t.submissions))
2842
- w.cancelled && (f[m] = { ...f[m], cancelled: !0, cancellationReason: w.cancellationReason });
2853
+ const g = { ...t.submissions, ...d.submissions };
2854
+ for (const [m, _] of Object.entries(t.submissions))
2855
+ _.cancelled && (g[m] = { ...g[m], cancelled: !0, cancellationReason: _.cancellationReason });
2843
2856
  const y = {
2844
2857
  ...d,
2845
- submissions: f,
2858
+ submissions: g,
2846
2859
  stops: { ...d.stops, ...t.stops },
2847
2860
  deliveries: { ...t.deliveries, ...d.deliveries },
2848
2861
  submissionOrder: [.../* @__PURE__ */ new Set([...d.submissionOrder, ...t.submissionOrder])]
2849
- }, { schema: g, authorityId: b, ..._ } = y, S = at(e.pendingRestoration ?? {}), k = (m) => !n.clients[m.clientScopeId] && S[m.clientScopeId] === m.conversationScopeId;
2862
+ }, { schema: f, authorityId: b, ...w } = y, S = at(e.pendingRestoration ?? {}), k = (m) => !n.clients[m.clientScopeId] && S[m.clientScopeId] === m.conversationScopeId;
2850
2863
  s = {
2851
2864
  ...t,
2852
- ..._,
2865
+ ...w,
2853
2866
  durableSubmissionIds: [.../* @__PURE__ */ new Set([...t.durableSubmissionIds, ...Object.keys(d.submissions)])],
2854
2867
  pendingRestoration: S,
2855
2868
  requestSequence: Math.max(t.requestSequence, y.requestSequence),
2856
2869
  effectsEnabled: !0,
2857
- submissions: Object.fromEntries(Object.entries(y.submissions).map(([m, w]) => [m, {
2858
- ...w,
2870
+ submissions: Object.fromEntries(Object.entries(y.submissions).map(([m, _]) => [m, {
2871
+ ..._,
2859
2872
  executionVersion: null,
2860
- cancelled: w.cancelled || !k(w) && !ta(w, n),
2861
- ...!w.cancelled && !k(w) && !ta(w, n) ? { cancellationReason: "owner_lost" } : {},
2862
- delivery: (w.contextPreparation === null || !y.deliveries[m]) && !w.cancelled && w.delivery !== "accepted" ? "failed" : w.delivery === "sending" ? "uncertain" : w.delivery,
2863
- error: w.contextPreparation === null && !w.cancelled && !["unauthorized", "auth_reconnecting"].includes(w.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !y.deliveries[m] && w.delivery !== "accepted" && !w.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : w.error
2873
+ cancelled: _.cancelled || !k(_) && !ta(_, n),
2874
+ ...!_.cancelled && !k(_) && !ta(_, n) ? { cancellationReason: "owner_lost" } : {},
2875
+ delivery: (_.contextPreparation === null && !y.deliveries[m]?.handoffRecovery || !y.deliveries[m]) && !_.cancelled && _.delivery !== "accepted" ? "failed" : _.delivery === "sending" ? "uncertain" : _.delivery,
2876
+ error: _.contextPreparation === null && !y.deliveries[m]?.handoffRecovery && !_.cancelled && !["unauthorized", "auth_reconnecting"].includes(_.error?.code ?? "") ? { code: "context_preparation_interrupted", message: "Page context preparation was interrupted. Please send this message again.", retryable: !1 } : !y.deliveries[m] && _.delivery !== "accepted" && !_.cancelled ? { code: "submission_interrupted", message: "Message preparation was interrupted. Retry this message.", retryable: !0 } : _.error
2864
2877
  }])),
2865
- deliveries: Object.fromEntries(Object.entries(y.submissions).map(([m, w], I) => {
2866
- const x = y.deliveries[m], E = w.contextPreparation === null, A = w.delivery === "accepted" ? "accepted" : x?.acceptance ?? (x && (x.step === "send" || x.step === "receipt") ? "uncertain" : "unissued");
2878
+ deliveries: Object.fromEntries(Object.entries(y.submissions).map(([m, _], I) => {
2879
+ const x = y.deliveries[m], E = _.contextPreparation === null && !x?.handoffRecovery, A = _.delivery === "accepted" ? "accepted" : x?.acceptance ?? (x && (x.step === "send" || x.step === "receipt") ? "uncertain" : "unissued");
2867
2880
  return [m, {
2868
- ...ll(w, I),
2881
+ ...ll(_, I),
2869
2882
  ...x,
2870
2883
  acceptance: A,
2871
- allocation: w.sessionId !== null ? "resolved" : x?.allocation ?? (x?.step === "upload" ? "uncertain" : "unissued"),
2884
+ allocation: _.sessionId !== null ? "resolved" : x?.allocation ?? (x?.step === "upload" ? "uncertain" : "unissued"),
2872
2885
  effectId: null,
2873
2886
  // Readiness is authority-local and must be re-established after restart. Captured input stays immutable.
2874
- step: A === "uncertain" && x?.step === "send" && x.phase !== "done" ? "receipt" : x?.step ?? null,
2887
+ step: A === "uncertain" && (x?.step === "send" || x?.handoffRecovery) && x.phase !== "done" ? "receipt" : x?.step ?? null,
2875
2888
  prepared: A === "accepted",
2876
2889
  queuePosition: x?.queuePosition ?? I,
2877
2890
  phase: A === "accepted" ? "done" : E || !x ? "failed" : ["running", "waiting"].includes(x.phase) ? "uncertain" : x.phase
2878
2891
  }];
2879
2892
  })),
2880
- operations: Object.fromEntries(Object.entries(y.operations).map(([m, w]) => [m, {
2881
- ...w,
2893
+ operations: Object.fromEntries(Object.entries(y.operations).map(([m, _]) => [m, {
2894
+ ..._,
2882
2895
  effectId: null,
2883
- phase: ["running", "waiting"].includes(w.phase) ? "uncertain" : w.phase
2896
+ phase: ["running", "waiting"].includes(_.phase) ? "uncertain" : _.phase
2884
2897
  }]))
2885
2898
  };
2886
2899
  }
@@ -2903,7 +2916,7 @@ function Uh(t, e, n, i) {
2903
2916
  if (!d) throw new Error("Stage the immutable submission before sending.");
2904
2917
  const p = t.deliveries[e.userMessageId];
2905
2918
  if (p && !d.cancelled && d.delivery !== "accepted" && (p.phase === "uncertain" || e.manualRetry && ["paused", "failed"].includes(p.phase))) {
2906
- const y = (p.acceptance === "unissued" || p.acceptance === "rejected") && p.allocation !== "uncertain" ? Math.max(t.requestSequence, ...Object.values(t.deliveries).map((g) => g.queuePosition)) + 1 : p.queuePosition;
2919
+ const y = (p.acceptance === "unissued" || p.acceptance === "rejected") && p.allocation !== "uncertain" ? Math.max(t.requestSequence, ...Object.values(t.deliveries).map((f) => f.queuePosition)) + 1 : p.queuePosition;
2907
2920
  s = {
2908
2921
  ...t,
2909
2922
  effectsEnabled: !0,
@@ -2924,11 +2937,11 @@ function Uh(t, e, n, i) {
2924
2937
  }
2925
2938
  if (e.type === "conversation.recover" || e.type === "conversation.submit")
2926
2939
  for (const [d, p] of Object.entries(s.deliveries)) {
2927
- const f = s.submissions[d];
2928
- p.phase !== "waiting" || f.cancelled || p.recoveryDeadline === null || e.now < p.recoveryDeadline || (s = {
2940
+ const g = s.submissions[d];
2941
+ p.phase !== "waiting" || g.cancelled || p.recoveryDeadline === null || e.now < p.recoveryDeadline || (s = {
2929
2942
  ...s,
2930
2943
  deliveries: { ...s.deliveries, [d]: { ...p, phase: "paused" } },
2931
- submissions: { ...s.submissions, [d]: { ...f, delivery: "failed", error: {
2944
+ submissions: { ...s.submissions, [d]: { ...g, delivery: "failed", error: {
2932
2945
  code: "message_delivery_failed",
2933
2946
  message: "Pluno could not send this message. Try it again.",
2934
2947
  retryable: !0
@@ -2943,12 +2956,12 @@ function Uh(t, e, n, i) {
2943
2956
  const p = t.operations[d.request_id];
2944
2957
  if (p && (JSON.stringify(p.command) !== JSON.stringify(d) || p.conversationScopeId !== (e.conversationScopeId ?? null))) throw new Error("Command identity changed.");
2945
2958
  if (!p) {
2946
- const f = d.type === "chat.retry_last_user_message" ? Object.fromEntries(Object.entries(t.stops).flatMap(([y, g]) => {
2947
- if (n.selections[y]?.sessionId !== d.payload.sessionId) return [[y, g]];
2948
- const b = g.userMessageIds.filter((_) => _ !== d.payload.clientMessageId);
2949
- return b.length ? [[y, { ...g, userMessageIds: b }]] : [];
2959
+ const g = d.type === "chat.retry_last_user_message" ? Object.fromEntries(Object.entries(t.stops).flatMap(([y, f]) => {
2960
+ if (n.selections[y]?.sessionId !== d.payload.sessionId) return [[y, f]];
2961
+ const b = f.userMessageIds.filter((w) => w !== d.payload.clientMessageId);
2962
+ return b.length ? [[y, { ...f, userMessageIds: b }]] : [];
2950
2963
  })) : t.stops;
2951
- s = { ...t, stops: f, effectsEnabled: !0, operations: {
2964
+ s = { ...t, stops: g, effectsEnabled: !0, operations: {
2952
2965
  ...t.operations,
2953
2966
  [d.request_id]: sa(d, e.conversationScopeId ?? null)
2954
2967
  } };
@@ -2965,18 +2978,22 @@ function Uh(t, e, n, i) {
2965
2978
  ...r,
2966
2979
  effectsEnabled: !0,
2967
2980
  requestSequence: r.requestSequence + 1,
2968
- deliveries: { ...r.deliveries, [e.userMessageId]: { ...ll(r.submissions[e.userMessageId], r.requestSequence + 1), ...e.waitForAuthentication ? { phase: "failed" } : {} } }
2981
+ deliveries: { ...r.deliveries, [e.userMessageId]: {
2982
+ ...ll(r.submissions[e.userMessageId], r.requestSequence + 1),
2983
+ ...e.reconcileAcceptance !== void 0 ? { handoffRecovery: !0, recoveryDeadline: e.reconcileAcceptance + 18e4, acceptance: "uncertain", step: "receipt" } : {},
2984
+ ...e.waitForAuthentication ? { phase: "failed" } : {}
2985
+ } }
2969
2986
  });
2970
2987
  for (const [d, p] of Object.entries(r.submissions)) {
2971
- const f = r.deliveries[d];
2972
- f && (p.delivery === "accepted" && f.acceptance !== "accepted" ? r = {
2988
+ const g = r.deliveries[d];
2989
+ g && (p.delivery === "accepted" && g.acceptance !== "accepted" ? r = {
2973
2990
  ...r,
2974
- deliveries: { ...r.deliveries, [d]: { ...f, acceptance: "accepted", phase: "done", effectId: null } }
2975
- } : (p.cancelled || p.delivery === "failed") && f.phase === "running" && !f.prepared && (r = {
2991
+ deliveries: { ...r.deliveries, [d]: { ...g, acceptance: "accepted", phase: "done", effectId: null } }
2992
+ } : (p.cancelled || p.delivery === "failed") && g.phase === "running" && !g.prepared && (r = {
2976
2993
  ...r,
2977
2994
  // Stop retires readiness work, but a previously issued message still needs receipt reconciliation.
2978
2995
  deliveries: { ...r.deliveries, [d]: {
2979
- ...f,
2996
+ ...g,
2980
2997
  phase: p.cancelled && mn(r, d) ? "waiting" : "failed",
2981
2998
  prepared: p.cancelled,
2982
2999
  effectId: null
@@ -3143,31 +3160,31 @@ function $h(t) {
3143
3160
  requestId: u?.request_id ?? "cancellation",
3144
3161
  clientMessageId: u ? String(u.payload.expectedUserMessageId) : null,
3145
3162
  sessionId: u ? String(u.payload.sessionId) : null
3146
- }), p = e, f = async () => {
3163
+ }), p = e, g = async () => {
3147
3164
  if (!t.isCurrent() || a.authorityId !== t.authorityId) throw new Error("Cancellation authority was retired.");
3148
3165
  if (!r && n && a.requestSequence <= n.requestSequence) return;
3149
3166
  const y = await s();
3150
3167
  if (y && y.authorityId !== t.authorityId) throw new Error("Cancellation checkpoint authority mismatch.");
3151
- const g = { authorityId: t.authorityId, requestSequence: Math.max(a.requestSequence, y?.requestSequence ?? 0), cancelled: { ...y?.cancelled }, operations: { ...y?.operations }, stops: { ...y?.stops } };
3168
+ const f = { authorityId: t.authorityId, requestSequence: Math.max(a.requestSequence, y?.requestSequence ?? 0), cancelled: { ...y?.cancelled }, operations: { ...y?.operations }, stops: { ...y?.stops } };
3152
3169
  if (r) {
3153
- n = a, a.requestSequence >= (y?.requestSequence ?? 0) && (g.cancelled = {}, g.operations = {}, g.stops = {});
3154
- for (const [b] of c) delete g.cancelled[b];
3155
- for (const [b, _] of Object.entries(a.stops)) g.stops[b]?.requestId === _.requestId && delete g.stops[b];
3156
- for (const [b, _] of l)
3157
- JSON.stringify(g.operations[b]?.command) === JSON.stringify(_.command) && delete g.operations[b];
3170
+ n = a, a.requestSequence >= (y?.requestSequence ?? 0) && (f.cancelled = {}, f.operations = {}, f.stops = {});
3171
+ for (const [b] of c) delete f.cancelled[b];
3172
+ for (const [b, w] of Object.entries(a.stops)) f.stops[b]?.requestId === w.requestId && delete f.stops[b];
3173
+ for (const [b, w] of l)
3174
+ JSON.stringify(f.operations[b]?.command) === JSON.stringify(w.command) && delete f.operations[b];
3158
3175
  } else {
3159
- for (const [b, _] of c) n?.submissions[b]?.cancelled || (g.cancelled[b] = { ..._, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } });
3160
- for (const [b, _] of Object.entries(a.stops)) n?.stops[b]?.requestId !== _.requestId && (g.stops[b] = _);
3161
- for (const [b, _] of l) _.phase !== "done" && _.phase !== "failed" && JSON.stringify(n?.operations[b]?.command) !== JSON.stringify(_.command) && (g.operations[b] = { ..._, effectId: null, phase: "uncertain", result: null, error: null });
3176
+ for (const [b, w] of c) n?.submissions[b]?.cancelled || (f.cancelled[b] = { ...w, context: {}, contextPreparation: { pageContent: "", sessionTabs: [] } });
3177
+ for (const [b, w] of Object.entries(a.stops)) n?.stops[b]?.requestId !== w.requestId && (f.stops[b] = w);
3178
+ for (const [b, w] of l) w.phase !== "done" && w.phase !== "failed" && JSON.stringify(n?.operations[b]?.command) !== JSON.stringify(w.command) && (f.operations[b] = { ...w, effectId: null, phase: "uncertain", result: null, error: null });
3162
3179
  }
3163
- if (!(!y && !Object.keys(g.cancelled).length && !Object.keys(g.operations).length && !Object.keys(g.stops).length) && !(JSON.stringify(y?.cancelled ?? {}) === JSON.stringify(g.cancelled) && JSON.stringify(y?.operations ?? {}) === JSON.stringify(g.operations) && JSON.stringify(y?.stops ?? {}) === JSON.stringify(g.stops))) {
3180
+ if (!(!y && !Object.keys(f.cancelled).length && !Object.keys(f.operations).length && !Object.keys(f.stops).length) && !(JSON.stringify(y?.cancelled ?? {}) === JSON.stringify(f.cancelled) && JSON.stringify(y?.operations ?? {}) === JSON.stringify(f.operations) && JSON.stringify(y?.stops ?? {}) === JSON.stringify(f.stops))) {
3164
3181
  if (!t.isCurrent()) throw new Error("Cancellation authority was retired.");
3165
- await d.measure("cancellation_write", () => t.write(g)), i = Promise.resolve(g);
3182
+ await d.measure("cancellation_write", () => t.write(f)), i = Promise.resolve(f);
3166
3183
  }
3167
3184
  };
3168
3185
  return e = d.measure("cancellation_queue", () => p.then(() => {
3169
3186
  }, () => {
3170
- })).then(f), e;
3187
+ })).then(g), e;
3171
3188
  };
3172
3189
  return {
3173
3190
  save: (a) => o(a, !1),
@@ -3230,10 +3247,10 @@ function Vh(t, e) {
3230
3247
  "button:not(.error__link), a.error__link, a.pluno-pa-widget__error-retry, svg, [hidden], [aria-hidden='true']"
3231
3248
  ).forEach((y) => y.remove());
3232
3249
  const d = Ma(`${a}
3233
- ${u.textContent?.trim()}`), p = l.closest("[data-canonical-item-key]")?.dataset.canonicalItemKey, f = c ? `${d}:${c.sessionId}:${c.episodeId}` : p ? `${d}:${p}` : d;
3234
- if (!i.has(f)) {
3250
+ ${u.textContent?.trim()}`), p = l.closest("[data-canonical-item-key]")?.dataset.canonicalItemKey, g = c ? `${d}:${c.sessionId}:${c.episodeId}` : p ? `${d}:${p}` : d;
3251
+ if (!i.has(g)) {
3235
3252
  if (i.size >= 100) return;
3236
- i.add(f), e(a, d, Fn(u.textContent ?? ""), ...c ? [p, c] : p ? [p] : []);
3253
+ i.add(g), e(a, d, Fn(u.textContent ?? ""), ...c ? [p, c] : p ? [p] : []);
3237
3254
  }
3238
3255
  }
3239
3256
  }, o = new MutationObserver(s);
@@ -3509,16 +3526,16 @@ function ng(t) {
3509
3526
  entrySurface: y.entrySurface
3510
3527
  }) })) : [], d = e, p = Promise.all(u.map(({ timer: y }) => y.measure("checkpoint_queue", () => d.then(() => {
3511
3528
  }, () => {
3512
- })))), f = async () => {
3529
+ })))), g = async () => {
3513
3530
  await p;
3514
3531
  const y = async () => {
3515
- const g = await c;
3516
- if (!g.ok) throw g.error;
3532
+ const f = await c;
3533
+ if (!f.ok) throw f.error;
3517
3534
  };
3518
- await Promise.all(u.length ? u.map(({ timer: g }) => g.measure("checkpoint_prerequisite", y)) : [y()]), st(t, t.authority), await t.saveDelivery(r, u[u.length - 1]?.timer);
3519
- for (const { submission: g, timer: b } of u) b.mark(g.contextPreparation === null ? "checkpoint" : "checkpoint_prepared");
3535
+ await Promise.all(u.length ? u.map(({ timer: f }) => f.measure("checkpoint_prerequisite", y)) : [y()]), st(t, t.authority), await t.saveDelivery(r, u[u.length - 1]?.timer);
3536
+ for (const { submission: f, timer: b } of u) b.mark(f.contextPreparation === null ? "checkpoint" : "checkpoint_prepared");
3520
3537
  };
3521
- return e = e.then(f, f), e;
3538
+ return e = e.then(g, g), e;
3522
3539
  }, i = (r, l) => {
3523
3540
  throw He(t) && !(r instanceof Error && "code" in r && ["executor_not_ready", "request_timed_out"].includes(String(r.code))) && t.onError?.(r, l), Mn(r, l);
3524
3541
  }, s = () => {
@@ -3529,7 +3546,7 @@ function ng(t) {
3529
3546
  throw Object.assign(new Error("Submission was cancelled."), { code: "submission_cancelled", retryable: !1 });
3530
3547
  }, a = (r) => {
3531
3548
  if (!t.onTiming || r.submission.sessionId !== null) return;
3532
- const l = t.runtime(), c = Object.values(l.engine.getState().slices.conversation.operations).find((f) => f.command.type === "runtime.warmup" && f.conversationScopeId === r.submission.conversationScopeId && ["waiting", "running", "uncertain"].includes(f.phase));
3549
+ const l = t.runtime(), c = Object.values(l.engine.getState().slices.conversation.operations).find((g) => g.command.type === "runtime.warmup" && g.conversationScopeId === r.submission.conversationScopeId && ["waiting", "running", "uncertain"].includes(g.phase));
3533
3550
  if (!c) return;
3534
3551
  const u = Xe(t.onTiming, {
3535
3552
  operation: "send",
@@ -3542,12 +3559,12 @@ function ng(t) {
3542
3559
  let d = () => {
3543
3560
  }, p = () => {
3544
3561
  };
3545
- u.measure("warmup_wait", () => new Promise((f, y) => {
3546
- const g = () => {
3547
- const b = l.engine.getState().slices, _ = b.conversation.submissions[r.submission.userMessageId], S = b.conversation.operations[c.command.request_id];
3548
- !He(t) || !_ || _.cancelled || b.directory.clients[_.clientScopeId] !== _.conversationScopeId ? y(new Error("Warmup wait was retired.")) : (_.sessionId !== null || !S || !["waiting", "running", "uncertain"].includes(S.phase)) && f();
3562
+ u.measure("warmup_wait", () => new Promise((g, y) => {
3563
+ const f = () => {
3564
+ const b = l.engine.getState().slices, w = b.conversation.submissions[r.submission.userMessageId], S = b.conversation.operations[c.command.request_id];
3565
+ !He(t) || !w || w.cancelled || b.directory.clients[w.clientScopeId] !== w.conversationScopeId ? y(new Error("Warmup wait was retired.")) : (w.sessionId !== null || !S || !["waiting", "running", "uncertain"].includes(S.phase)) && g();
3549
3566
  };
3550
- d = l.engine.subscribe(g), p = l.onDispose(() => y(new Error("Warmup wait was retired."))), g();
3567
+ d = l.engine.subscribe(f), p = l.onDispose(() => y(new Error("Warmup wait was retired."))), f();
3551
3568
  })).catch(() => {
3552
3569
  }).finally(() => {
3553
3570
  d(), p();
@@ -3570,14 +3587,14 @@ function ng(t) {
3570
3587
  new Error("Message preparation timed out. Retry this message."),
3571
3588
  { code: "submission_preparation_timeout", retryable: !0 }
3572
3589
  ));
3573
- }, 18e4), p = t.runtime(), f = () => {
3574
- const b = p.engine.getState().slices, _ = b.conversation.submissions[r.submission.userMessageId];
3575
- (!He(t) || !_ || _.cancelled || _.requestId !== r.submission.requestId || b.directory.clients[_.clientScopeId] !== _.conversationScopeId) && u(Object.assign(new Error("Submission preparation was retired."), { code: "aborted", retryable: !1 }));
3576
- }, y = p.engine.subscribe(f), g = p.onDispose(() => u(Object.assign(new Error("Submission runtime was disposed."), { code: "aborted" })));
3577
- return f(), qs(l.signal, () => t.prepareSubmission(r, l.signal).then((b) => (l.signal.aborted && c.mark("context_discarded"), b), (b) => {
3590
+ }, 18e4), p = t.runtime(), g = () => {
3591
+ const b = p.engine.getState().slices, w = b.conversation.submissions[r.submission.userMessageId];
3592
+ (!He(t) || !w || w.cancelled || w.requestId !== r.submission.requestId || b.directory.clients[w.clientScopeId] !== w.conversationScopeId) && u(Object.assign(new Error("Submission preparation was retired."), { code: "aborted", retryable: !1 }));
3593
+ }, y = p.engine.subscribe(g), f = p.onDispose(() => u(Object.assign(new Error("Submission runtime was disposed."), { code: "aborted" })));
3594
+ return g(), qs(l.signal, () => t.prepareSubmission(r, l.signal).then((b) => (l.signal.aborted && c.mark("context_discarded"), b), (b) => {
3578
3595
  throw l.signal.aborted && c.mark("context_discarded"), b;
3579
- })).then((b) => (f(), l.signal.throwIfAborted(), a(r), b)).catch((b) => (u(b), i(b, { operation: "conversation.prepare", requestId: r.submission.userMessageId }))).finally(() => {
3580
- clearTimeout(d), y(), g();
3596
+ })).then((b) => (g(), l.signal.throwIfAborted(), a(r), b)).catch((b) => (u(b), i(b, { operation: "conversation.prepare", requestId: r.submission.userMessageId }))).finally(() => {
3597
+ clearTimeout(d), y(), f();
3581
3598
  });
3582
3599
  },
3583
3600
  "conversation.checkpoint": async (r) => (st(t, r), await n(r.checkpoint, t.saveCancellation(r.checkpoint)).catch((l) => i(l, { operation: "conversation.checkpoint" })), st(t, r), { ...t.authority, submissionIds: Object.keys(r.checkpoint.submissions) }),
@@ -3625,14 +3642,14 @@ function ng(t) {
3625
3642
  );
3626
3643
  if (st(t, r), p.request_id !== r.command.request_id || !ii(p.result)) throw Object.assign(new Error("Conversation response identity mismatch."), { code: "acceptance_identity_mismatch" });
3627
3644
  if (r.command.type.startsWith("chat.")) {
3628
- const f = p.result;
3629
- if (typeof f?.sessionId != "string" || !f.sessionId || f.clientMessageId !== r.command.payload.clientMessageId || r.command.payload.sessionId && f.sessionId !== r.command.payload.sessionId) throw Object.assign(new Error("Conversation acceptance identity mismatch."), { code: "acceptance_identity_mismatch" });
3645
+ const g = p.result;
3646
+ 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" });
3630
3647
  Xe(t.onTiming, {
3631
3648
  operation: "send",
3632
3649
  layer: "http",
3633
3650
  requestId: r.command.request_id,
3634
3651
  clientMessageId: String(c.clientMessageId),
3635
- sessionId: f.sessionId
3652
+ sessionId: g.sessionId
3636
3653
  }).mark("acceptance_received");
3637
3654
  }
3638
3655
  return p.result;
@@ -3662,8 +3679,8 @@ function ng(t) {
3662
3679
  }).measure("attachment_upload", () => Promise.resolve().then(async () => {
3663
3680
  const c = () => {
3664
3681
  if (st(t, r), !r.preparationId) return o(r.submission.userMessageId);
3665
- const g = t.runtime().engine.getState().slices.directory;
3666
- if (!Object.values(g.clients).includes(r.submission.conversationScopeId))
3682
+ const f = t.runtime().engine.getState().slices.directory;
3683
+ if (!Object.values(f.clients).includes(r.submission.conversationScopeId))
3667
3684
  throw Object.assign(new Error("Attachment preparation was cancelled."), { code: "submission_cancelled", retryable: !1 });
3668
3685
  };
3669
3686
  c(), await n(), c();
@@ -3688,18 +3705,18 @@ function ng(t) {
3688
3705
  if (c(), !p.sessionId || r.submission.sessionId && p.sessionId !== r.submission.sessionId || p.attachment.id !== r.source.sourceId || p.attachment.mimeType !== r.source.mimeType || p.attachment.sizeBytes !== r.source.sizeBytes)
3689
3706
  throw Object.assign(new Error("Attachment preparation identity mismatch."), { code: "attachment_identity_mismatch", retryable: !1 });
3690
3707
  if ("uploadUrl" in p) {
3691
- const g = await fetch(t.http.resolveUrl(p.uploadUrl), { method: p.uploadMethod, headers: p.uploadHeaders, body: u });
3692
- if (!g.ok) throw Object.assign(new Error("Attachment transfer failed."), { code: String(g.status) });
3708
+ const f = await fetch(t.http.resolveUrl(p.uploadUrl), { method: p.uploadMethod, headers: p.uploadHeaders, body: u });
3709
+ if (!f.ok) throw Object.assign(new Error("Attachment transfer failed."), { code: String(f.status) });
3693
3710
  }
3694
3711
  c();
3695
- const f = p.attachment, y = {
3696
- id: f.id ?? null,
3697
- name: f.name,
3698
- mime_type: f.mimeType,
3699
- size_bytes: f.sizeBytes,
3700
- storage_key: f.storageKey ?? null,
3701
- sandbox_path: f.sandboxPath ?? null,
3702
- file_url: f.fileUrl ?? null
3712
+ const g = p.attachment, y = {
3713
+ id: g.id ?? null,
3714
+ name: g.name,
3715
+ mime_type: g.mimeType,
3716
+ size_bytes: g.sizeBytes,
3717
+ storage_key: g.storageKey ?? null,
3718
+ sandbox_path: g.sandboxPath ?? null,
3719
+ file_url: g.fileUrl ?? null
3703
3720
  };
3704
3721
  return await t.onUploaded?.(r.source.sourceId, p.sessionId, y), c(), { sessionId: p.sessionId, attachment: y };
3705
3722
  }).catch((c) => {
@@ -3713,18 +3730,18 @@ function ng(t) {
3713
3730
  "conversation.snapshot": (r) => Promise.resolve().then(async () => {
3714
3731
  st(t, r);
3715
3732
  const l = t.runtime(), c = new AbortController(), u = () => {
3716
- const f = l.engine.getState().slices;
3717
- He(t) ? f.directory.memberships[r.sessionId]?.members.length ? f.conversation.sessions[r.sessionId]?.queries[r.lane].requestId !== r.requestId && c.abort("request_replaced") : c.abort("observation_released") : c.abort("authority_retired");
3733
+ const g = l.engine.getState().slices;
3734
+ He(t) ? g.directory.memberships[r.sessionId]?.members.length ? g.conversation.sessions[r.sessionId]?.queries[r.lane].requestId !== r.requestId && c.abort("request_replaced") : c.abort("observation_released") : c.abort("authority_retired");
3718
3735
  }, d = l.engine.subscribe(u), p = l.onDispose(() => c.abort("owner_disposed"));
3719
3736
  u();
3720
3737
  try {
3721
- const f = [];
3722
- for (let _ = 0; _ < Math.max(1, r.refreshItemIds.length); _ += 200) {
3738
+ const g = [];
3739
+ for (let w = 0; w < Math.max(1, r.refreshItemIds.length); w += 200) {
3723
3740
  if (st(t, r), !t.runtime().engine.getState().slices.directory.memberships[r.sessionId]?.members.length) throw new Error("Conversation observation was retired.");
3724
3741
  const S = await t.http.request(
3725
3742
  `/${encodeURIComponent(r.sessionId)}/snapshot`,
3726
3743
  {},
3727
- { context: { ...s(), ...t.snapshotContext?.(r.sessionId) }, retry_preparation: r.retryPreparation === !0, limit: 100, before: r.before, refresh_item_ids: r.refreshItemIds.slice(_, _ + 200) },
3744
+ { context: { ...s(), ...t.snapshotContext?.(r.sessionId) }, retry_preparation: r.retryPreparation === !0, limit: 100, before: r.before, refresh_item_ids: r.refreshItemIds.slice(w, w + 200) },
3728
3745
  "POST",
3729
3746
  "conversations",
3730
3747
  { readOnly: !0, signal: c.signal, diagnostic: {
@@ -3734,27 +3751,27 @@ function ng(t) {
3734
3751
  authorityGeneration: r.generation
3735
3752
  } }
3736
3753
  ).catch((k) => {
3737
- if (f.length === 0) throw k;
3754
+ if (g.length === 0) throw k;
3738
3755
  const m = Mn(k);
3739
- throw Object.assign(m, { details: { ...m.details, successfulRequests: f.length } });
3756
+ throw Object.assign(m, { details: { ...m.details, successfulRequests: g.length } });
3740
3757
  });
3741
3758
  if (st(t, r), S.conversation_id !== r.sessionId) throw new Error("Snapshot conversation identity mismatch.");
3742
- if (f.push(S), !S.projection_ready) break;
3759
+ if (g.push(S), !S.projection_ready) break;
3743
3760
  }
3744
- const y = f[0];
3761
+ const y = g[0];
3745
3762
  if (r.before !== null && y.next_cursor === r.before)
3746
3763
  throw Object.assign(new Error("Conversation history cursor did not advance."), { code: "invalid_history_cursor" });
3747
- const g = f.reduce((_, S) => S.execution.version > _.version ? S.execution : _, y.execution), b = f.reduce((_, S) => S.follow_ups_version > _.follow_ups_version ? S : _, y);
3764
+ const f = g.reduce((w, S) => S.execution.version > w.version ? S.execution : w, y.execution), b = g.reduce((w, S) => S.follow_ups_version > w.follow_ups_version ? S : w, y);
3748
3765
  return { snapshot: {
3749
3766
  ...y,
3750
- execution: g,
3751
- items: f.flatMap((_) => _.items),
3752
- streams: f.flatMap((_) => _.streams),
3753
- removed_items: f.flatMap((_) => _.removed_items),
3754
- interactions: f.flatMap((_) => _.interactions),
3767
+ execution: f,
3768
+ items: g.flatMap((w) => w.items),
3769
+ streams: g.flatMap((w) => w.streams),
3770
+ removed_items: g.flatMap((w) => w.removed_items),
3771
+ interactions: g.flatMap((w) => w.interactions),
3755
3772
  follow_ups: b.follow_ups,
3756
3773
  follow_ups_version: b.follow_ups_version,
3757
- projection_ready: f.every((_) => _.projection_ready)
3774
+ projection_ready: g.every((w) => w.projection_ready)
3758
3775
  }, updatedAt: t.now() };
3759
3776
  } finally {
3760
3777
  d(), p();
@@ -4069,7 +4086,7 @@ function ar(t, e, n, i) {
4069
4086
  createdAt: "",
4070
4087
  loading: !1
4071
4088
  });
4072
- const l = t.activity.phase, c = t.submissions.filter((E) => !E.cancelled && !["accepted", "failed"].includes(E.delivery)), u = t.submissions[t.submissions.length - 1], d = [...t.items].reverse().find((E) => E.type === "user_message"), p = ["queued", "thinking", "steering", "awaiting_execution"].includes(l), f = u?.delivery === "failed" && (p && t.activity.userMessageId != null && t.activity.userMessageId !== u.userMessageId || d !== void 0 && d.id !== u.userMessageId && Date.parse(d.created_at) > u.submittedAt), y = new Map(t.submissions.filter((E) => (E !== u || f) && !E.cancelled && E.delivery === "failed" && E.error).map((E) => [E.userMessageId, E])), g = a.flatMap((E) => {
4089
+ const l = t.activity.phase, c = t.submissions.filter((E) => !E.cancelled && !["accepted", "failed"].includes(E.delivery)), u = t.submissions[t.submissions.length - 1], d = [...t.items].reverse().find((E) => E.type === "user_message"), p = ["queued", "thinking", "steering", "awaiting_execution"].includes(l), g = u?.delivery === "failed" && (p && t.activity.userMessageId != null && t.activity.userMessageId !== u.userMessageId || d !== void 0 && d.id !== u.userMessageId && Date.parse(d.created_at) > u.submittedAt), y = new Map(t.submissions.filter((E) => (E !== u || g) && !E.cancelled && E.delivery === "failed" && E.error).map((E) => [E.userMessageId, E])), f = a.flatMap((E) => {
4073
4090
  const A = E.role === "user" ? y.get(E.id) : void 0;
4074
4091
  return A?.error ? [E, {
4075
4092
  id: `submission-error:${A.userMessageId}`,
@@ -4081,16 +4098,16 @@ function ar(t, e, n, i) {
4081
4098
  loading: !1,
4082
4099
  ...typeof A.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: A.error.details.securitySettingsUrl } : {}
4083
4100
  }] : [E];
4084
- }), b = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, _ = b ? null : e?.error ?? null, S = [...t.submissions].reverse().find((E) => t.pendingDurabilityIds?.includes(E.userMessageId)), k = S ? {
4101
+ }), b = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, w = b ? null : e?.error ?? null, S = [...t.submissions].reverse().find((E) => t.pendingDurabilityIds?.includes(E.userMessageId)), k = S ? {
4085
4102
  code: "submission_checkpoint_pending",
4086
4103
  message: uh,
4087
4104
  details: { requestId: S.requestId }
4088
- } : null, m = u?.delivery === "failed" && !u.cancelled && !f ? u.error : _ ?? k, w = {
4105
+ } : null, m = u?.delivery === "failed" && !u.cancelled && !g ? u.error : w ?? k, _ = {
4089
4106
  isRetrying: t.isRetrying ?? !1,
4090
4107
  historyRefreshFailure: m === e?.error ? t.historyRefreshFailure ?? null : null,
4091
4108
  conversationDiagnostics: {
4092
4109
  ...m ? { errorMessageFingerprint: Ma(Fn(m.message)) } : {},
4093
- ...u && m && m === u.error && !f ? { failedClientMessageId: u.userMessageId } : {},
4110
+ ...u && m && m === u.error && !g ? { failedClientMessageId: u.userMessageId } : {},
4094
4111
  ...typeof m?.details?.requestId == "string" ? { errorRequestId: m.details.requestId } : {},
4095
4112
  ...ro(m?.details?.errorNormalization) ? { errorNormalization: m.details.errorNormalization } : {},
4096
4113
  ...i ? { owner: i } : {},
@@ -4103,7 +4120,7 @@ function ar(t, e, n, i) {
4103
4120
  selectionKey: t.selectionKey,
4104
4121
  isDraftSession: t.isDraftSession,
4105
4122
  sessionId: t.sessionId,
4106
- messages: g,
4123
+ messages: f,
4107
4124
  removedItems: r,
4108
4125
  activeResponseUserMessageId: t.activity.userMessageId ?? t.segments[t.segments.length - 1]?.userMessageId ?? u?.userMessageId ?? null,
4109
4126
  segments: t.segments,
@@ -4126,7 +4143,7 @@ function ar(t, e, n, i) {
4126
4143
  lastErrorCode: m?.code ?? null,
4127
4144
  lastErrorSecuritySettingsUrl: typeof m?.details?.securitySettingsUrl == "string" ? m.details.securitySettingsUrl : null
4128
4145
  };
4129
- let I = w;
4146
+ let I = _;
4130
4147
  for (const E of t.optimistic.filter((A) => A.cancelled && !t.stop?.userMessageIds.includes(A.userMessageId))) {
4131
4148
  const A = gl(I, "", "stopped", [E.userMessageId], ml(E.cancellationReason));
4132
4149
  I = { ...I, messages: A.messages, segments: A.segments };
@@ -4139,7 +4156,7 @@ function ar(t, e, n, i) {
4139
4156
  t.stop.userMessageIds,
4140
4157
  ml(t.stop.reason ?? "user_requested")
4141
4158
  );
4142
- return { ...w, messages: x.messages, segments: x.segments };
4159
+ return { ..._, messages: x.messages, segments: x.segments };
4143
4160
  }
4144
4161
  function ml(t) {
4145
4162
  switch (t) {
@@ -6788,7 +6805,7 @@ class lf {
6788
6805
  connection_id: `pa-sio:${this.socket.id}`,
6789
6806
  request_id: s,
6790
6807
  session_id: e.sessionId ?? e.session_id
6791
- }).replace(/[\u007f-\uffff]/g, (f) => `\\u${f.charCodeAt(0).toString(16).padStart(4, "0")}`)
6808
+ }).replace(/[\u007f-\uffff]/g, (g) => `\\u${g.charCodeAt(0).toString(16).padStart(4, "0")}`)
6792
6809
  },
6793
6810
  body: JSON.stringify({ request_id: s, type: "tool.result", payload: e })
6794
6811
  });
@@ -6874,80 +6891,80 @@ class pu {
6874
6891
  }) : this.options.pendingAuthentication?.()), l();
6875
6892
  const p = this.options.authenticationFailure?.();
6876
6893
  if (p) throw p;
6877
- const f = this.auth.token;
6894
+ const g = this.auth.token;
6878
6895
  let y = null;
6879
6896
  try {
6880
- let g = i;
6897
+ let f = i;
6881
6898
  if (o === "conversations" && e === "/commands" && this.auth.role !== "session_surface" && this.options.executorConnection) {
6882
6899
  if (y = this.options.executorConnection(), !y) throw new N("Reconnecting the browser before continuing.", "executor_not_ready");
6883
6900
  const S = i;
6884
- g = { ...S, context: { ...S.context, connection_id: y } };
6901
+ f = { ...S, context: { ...S.context, connection_id: y } };
6885
6902
  }
6886
- const b = () => this.requestOnce(e, n, g, s, o, a.signal, a.diagnostic, ++u), _ = await (a.timing ? a.timing.measure("http_request", b) : b());
6887
- return l(), _;
6888
- } catch (g) {
6889
- if (l(!1), this.requests.signal.aborted || a.signal?.aborted) throw g;
6890
- if (g instanceof N && g.code === "executor_not_ready" && y && d === 0 && this.options.restoreExecutor) {
6903
+ const b = () => this.requestOnce(e, n, f, s, o, a.signal, a.diagnostic, ++u), w = await (a.timing ? a.timing.measure("http_request", b) : b());
6904
+ return l(), w;
6905
+ } catch (f) {
6906
+ if (l(!1), this.requests.signal.aborted || a.signal?.aborted) throw f;
6907
+ if (f instanceof N && f.code === "executor_not_ready" && y && d === 0 && this.options.restoreExecutor) {
6891
6908
  await this.options.restoreExecutor(y), d++, l();
6892
6909
  continue;
6893
6910
  }
6894
- if (!(g instanceof N) || !["unauthorized", "403"].includes(g.code) || !this.options.recoverAuthentication || !c || (await this.options.recoverAuthentication(f, g, c && d === 0), l(), !c || d !== 0)) throw g;
6911
+ if (!(f instanceof N) || !["unauthorized", "403"].includes(f.code) || !this.options.recoverAuthentication || !c || (await this.options.recoverAuthentication(g, f, c && d === 0), l(), !c || d !== 0)) throw f;
6895
6912
  d++;
6896
6913
  }
6897
6914
  }
6898
6915
  }
6899
6916
  async requestOnce(e, n, i, s, o, a, r, l = 1) {
6900
6917
  const c = this.auth.client_kind === "embed", u = new URL(`/api/product-agent/${o ?? (c ? "embed" : "runtime")}${e}`, this.options.backendUrl), d = o === "conversations" ? {} : c ? { client_id: this.auth.client_id, transport_id: this.auth.transport_id } : { community_id: this.auth.community_id, automation_run_id: this.auth.automation_run_id };
6901
- for (const [P, z] of Object.entries({ ...d, ...n }))
6902
- z != null && u.searchParams.set(P, String(z));
6918
+ for (const [M, z] of Object.entries({ ...d, ...n }))
6919
+ z != null && u.searchParams.set(M, String(z));
6903
6920
  this.requests.signal.throwIfAborted(), a?.throwIfAborted();
6904
- const p = new AbortController(), f = { trigger: null }, y = (P) => {
6905
- p.signal.aborted || (f.trigger = P, p.abort());
6906
- }, g = () => y("transport_disposed"), b = () => y(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
6907
- this.requests.signal.addEventListener("abort", g, { once: !0 }), a?.addEventListener("abort", b, { once: !0 });
6908
- const _ = o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && s === "POST", S = /^\/conversations(?:\/[^/]+)?$/.test(e) && (s ?? (i === void 0 ? "GET" : "POST")) === "GET", k = setTimeout(() => y("deadline"), S ? 6e4 : _ ? 3e4 : 15e3), m = df(), w = Date.now();
6921
+ const p = new AbortController(), g = { trigger: null }, y = (M) => {
6922
+ p.signal.aborted || (g.trigger = M, p.abort());
6923
+ }, f = () => y("transport_disposed"), b = () => y(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
6924
+ this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", b, { once: !0 });
6925
+ const w = o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) && s === "POST", S = /^\/conversations(?:\/[^/]+)?$/.test(e) && (s ?? (i === void 0 ? "GET" : "POST")) === "GET", k = setTimeout(() => y("deadline"), S ? 6e4 : w ? 3e4 : 15e3), m = df(), _ = Date.now();
6909
6926
  let I = null, x = !1, E = null, A = null, L = null;
6910
6927
  try {
6911
- const P = await Promise.resolve(fetch(u, {
6928
+ const M = await Promise.resolve(fetch(u, {
6912
6929
  method: s ?? (i === void 0 ? "GET" : "POST"),
6913
6930
  cache: "no-store",
6914
6931
  signal: p.signal,
6915
- headers: { "x-product-agent-auth-request-id": m, authorization: c || o === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ..._ ? { "x-request-id": m } : {} },
6932
+ headers: { "x-product-agent-auth-request-id": m, authorization: c || o === "conversations" ? `Bearer ${this.auth.token}` : this.auth.token, "content-type": "application/json", ...w ? { "x-request-id": m } : {} },
6916
6933
  ...i === void 0 ? {} : { body: JSON.stringify(i) }
6917
6934
  })).catch((z) => {
6918
6935
  throw x = !0, z;
6919
6936
  });
6920
- if (I = Date.now(), E = P.status, A = Sl(P.headers.get("x-request-id")), L = Sl(P.headers.get("x-cloud-trace-context")), !P.ok) {
6921
- const z = P.status === 401 ? "unauthorized" : P.status === 426 ? "update_required" : String(P.status), B = (await P.json().catch(() => null))?.detail;
6922
- if (c && P.status === 403 && (o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) || (!o || o === "embed") && /^\/conversations\/[^/]+$/.test(e)) && ["Conversation unavailable", "Integration mismatch", "Embedded origin mismatch"].includes(B))
6937
+ if (I = Date.now(), E = M.status, A = Sl(M.headers.get("x-request-id")), L = Sl(M.headers.get("x-cloud-trace-context")), !M.ok) {
6938
+ const z = M.status === 401 ? "unauthorized" : M.status === 426 ? "update_required" : String(M.status), B = (await M.json().catch(() => null))?.detail;
6939
+ if (c && M.status === 403 && (o === "conversations" && /^\/[^/]+\/snapshot$/.test(e) || (!o || o === "embed") && /^\/conversations\/[^/]+$/.test(e)) && ["Conversation unavailable", "Integration mismatch", "Embedded origin mismatch"].includes(B))
6923
6940
  throw new N("Conversation unavailable", "conversation_access_denied");
6924
- if (o === "conversations" && e.endsWith("/snapshot") && P.status === 409 && B === "Display projection is not enabled")
6941
+ if (o === "conversations" && e.endsWith("/snapshot") && M.status === 409 && B === "Display projection is not enabled")
6925
6942
  throw new N("Conversation history is unavailable. Try loading this chat again after the service is ready.", "display_projection_disabled");
6926
- if (o === "conversations" && e === "/commands" && P.status === 409 && (B === "embedded_submission_conflict" || B === "embedded_submission_snapshot_unavailable"))
6943
+ if (o === "conversations" && e === "/commands" && M.status === 409 && (B === "embedded_submission_conflict" || B === "embedded_submission_snapshot_unavailable"))
6927
6944
  throw new N(B === "embedded_submission_conflict" ? "This message conflicts with an earlier submission. Review the conversation before retrying." : "This earlier submission cannot be verified. Review the conversation before retrying.", B, !1, void 0, !0);
6928
- if (o === "conversations" && e === "/commands" && (P.status === 409 && B?.code === "executor_not_ready" && B.retryable === !0 || P.status === 403 && B === "Register the executor before commands"))
6945
+ if (o === "conversations" && e === "/commands" && (M.status === 409 && B?.code === "executor_not_ready" && B.retryable === !0 || M.status === 403 && B === "Register the executor before commands"))
6929
6946
  throw new N("Reconnecting the browser before continuing.", "executor_not_ready");
6930
- if (P.status !== 401 && B && typeof B == "object" && (["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(B.code) || !Yi(void 0, B.code).allowed) && typeof B.message == "string")
6947
+ if (M.status !== 401 && B && typeof B == "object" && (["service_origin_not_allowed", "security_control_enforcement_unavailable"].includes(B.code) || !Yi(void 0, B.code).allowed) && typeof B.message == "string")
6931
6948
  throw new N(B.message, B.code, !1, {
6932
6949
  ...typeof B.blockedOrigin == "string" ? { blockedOrigin: B.blockedOrigin } : {},
6933
6950
  ...typeof B.securitySettingsUrl == "string" ? { securitySettingsUrl: B.securitySettingsUrl } : {}
6934
6951
  }, o === "conversations" && e === "/commands");
6935
- const C = B === "Token expired" ? "token_expired" : B === "Invalid token" ? "invalid_token" : B?.reason, U = P.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(C) ? { requestId: m, authTransport: "http", authEndpoint: `${o ?? (c ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: C, retryable: C === "token_expired" && (B === "Token expired" || B.retryable === !0) } : void 0;
6936
- throw new N(P.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : P.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${P.status})`, z, !1, U);
6952
+ const C = B === "Token expired" ? "token_expired" : B === "Invalid token" ? "invalid_token" : B?.reason, U = M.status === 401 && ["missing_token", "token_expired", "invalid_token", "user_not_found"].includes(C) ? { requestId: m, authTransport: "http", authEndpoint: `${o ?? (c ? "embed" : "runtime")}:${["snapshot", "me", "bootstrap", "commands", "activity", "session-history"].includes(e.split("/").pop()) ? e.split("/").pop() : "other"}`, reason: C, retryable: C === "token_expired" && (B === "Token expired" || B.retryable === !0) } : void 0;
6953
+ throw new N(M.status === 401 ? "Your session expired or is invalid. Reconnect to continue." : M.status === 403 ? "You don't have access to this conversation. Check your access and reconnect." : `Product Agent request failed (${M.status})`, z, !1, U);
6937
6954
  }
6938
- return await P.json();
6939
- } catch (P) {
6940
- const z = f.trigger ?? ((P instanceof Error || P instanceof DOMException) && P.name === "AbortError" ? "unexpected_abort" : null), B = {
6955
+ return await M.json();
6956
+ } catch (M) {
6957
+ const z = g.trigger ?? ((M instanceof Error || M instanceof DOMException) && M.name === "AbortError" ? "unexpected_abort" : null), B = {
6941
6958
  requestId: m,
6942
6959
  method: s ?? (i === void 0 ? "GET" : "POST"),
6943
- route: _ ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
6960
+ route: w ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
6944
6961
  status: E,
6945
6962
  abortTrigger: z,
6946
- category: z === "deadline" ? "request_timed_out" : z === "unexpected_abort" ? "connection_interrupted" : z ? "request_cancelled" : P instanceof N ? P.code : x ? "connection_interrupted" : "invalid_response",
6947
- responseHeadersMs: I === null ? null : Math.max(0, I - w),
6963
+ category: z === "deadline" ? "request_timed_out" : z === "unexpected_abort" ? "connection_interrupted" : z ? "request_cancelled" : M instanceof N ? M.code : x ? "connection_interrupted" : "invalid_response",
6964
+ responseHeadersMs: I === null ? null : Math.max(0, I - _),
6948
6965
  responseBodyMs: I === null ? null : Math.max(0, Date.now() - I),
6949
6966
  owner: z === "deadline" ? "http_deadline" : z === "transport_disposed" ? "http_transport" : z && z !== "unexpected_abort" ? "conversation_query" : E === null ? "browser" : "http_response",
6950
- elapsedMs: Math.max(0, Date.now() - w),
6967
+ elapsedMs: Math.max(0, Date.now() - _),
6951
6968
  attempt: l,
6952
6969
  queryRequestId: me(r?.queryRequestId),
6953
6970
  ownerId: me(r?.ownerId),
@@ -6969,14 +6986,14 @@ class pu {
6969
6986
  C
6970
6987
  );
6971
6988
  }
6972
- throw P instanceof N && C ? new N(P.message, P.code, P.outcomeUnknown, { ...P.detail, ...C }, P.backendRefusal) : C ? new N(
6973
- x ? "The connection was interrupted. Please try again." : _ ? "The conversation response could not be read. Please try again." : "The response could not be read. Please try again.",
6989
+ throw M instanceof N && C ? new N(M.message, M.code, M.outcomeUnknown, { ...M.detail, ...C }, M.backendRefusal) : C ? new N(
6990
+ x ? "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.",
6974
6991
  "connection_interrupted",
6975
6992
  !0,
6976
6993
  C
6977
- ) : P;
6994
+ ) : M;
6978
6995
  } finally {
6979
- clearTimeout(k), this.requests.signal.removeEventListener("abort", g), a?.removeEventListener("abort", b);
6996
+ clearTimeout(k), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", b);
6980
6997
  }
6981
6998
  }
6982
6999
  }
@@ -7369,16 +7386,16 @@ class mf {
7369
7386
  if (e !== void 0 && o.some((l) => l.sessionId !== e)) return !1;
7370
7387
  const a = [], r = new Set(o.map((l) => l.sessionId));
7371
7388
  for (const l of r) {
7372
- const c = o.filter((f) => f.sessionId === l), u = l === null ? c[0] : c.find((f) => f.clientScopeId === i.mains[l]) ?? this.choose(c), d = [u, ...c.filter((f) => f !== u)], p = /* @__PURE__ */ new Set();
7373
- for (const f of d) {
7374
- const y = { ...this.options.authority, clientScopeId: f.clientScopeId, conversationScopeId: f.conversationScopeId, replacement: null };
7375
- f.provisionalId !== null && !p.has(f.conversationScopeId) && !n.selections[f.conversationScopeId]?.sessionId ? (a.push({ ...y, type: "directory.provisional", provisionalId: f.provisionalId }), l !== null && (a.push({
7389
+ const c = o.filter((g) => g.sessionId === l), u = l === null ? c[0] : c.find((g) => g.clientScopeId === i.mains[l]) ?? this.choose(c), d = [u, ...c.filter((g) => g !== u)], p = /* @__PURE__ */ new Set();
7390
+ for (const g of d) {
7391
+ const y = { ...this.options.authority, clientScopeId: g.clientScopeId, conversationScopeId: g.conversationScopeId, replacement: null };
7392
+ g.provisionalId !== null && !p.has(g.conversationScopeId) && !n.selections[g.conversationScopeId]?.sessionId ? (a.push({ ...y, type: "directory.provisional", provisionalId: g.provisionalId }), l !== null && (a.push({
7376
7393
  ...this.options.authority,
7377
7394
  type: "directory.accepted",
7378
- conversationScopeId: f.conversationScopeId,
7379
- provisionalId: f.provisionalId,
7395
+ conversationScopeId: g.conversationScopeId,
7396
+ provisionalId: g.provisionalId,
7380
7397
  sessionId: l
7381
- }), p.add(f.conversationScopeId))) : a.push({ ...y, type: "directory.bind", sessionId: l, reason: "user" });
7398
+ }), p.add(g.conversationScopeId))) : a.push({ ...y, type: "directory.bind", sessionId: l, reason: "user" });
7382
7399
  }
7383
7400
  }
7384
7401
  return await Promise.all(a.map((l) => this.options.runtime.engine.dispatch(l))), !0;
@@ -7672,7 +7689,7 @@ class Ee extends EventTarget {
7672
7689
  if (i === "auth.session") {
7673
7690
  if (this.initialized) return;
7674
7691
  this.initialized = !0;
7675
- const p = this.bootstrapRequests.signal, f = this.credentialBootstrap ?? await this.httpTransport.request(
7692
+ const p = this.bootstrapRequests.signal, g = this.credentialBootstrap ?? await this.httpTransport.request(
7676
7693
  o ? "/bootstrap" : "/me",
7677
7694
  o ? r : {},
7678
7695
  void 0,
@@ -7680,8 +7697,8 @@ class Ee extends EventTarget {
7680
7697
  void 0,
7681
7698
  { signal: p }
7682
7699
  );
7683
- if (p.aborted || !this.isCurrent(n) || (this.credentialBootstrap = null, !this.options.auth.community_id && f.user?.runtimeCommunityId && (this.options.auth.community_id = f.user.runtimeCommunityId), this.receive({ type: "auth.ok", ...f }), p.aborted)) return;
7684
- this.options.auth.client_kind === "extension" && this.receive({ type: "executor.registered", userId: f.user.id }), this.bootstrapped = !0;
7700
+ if (p.aborted || !this.isCurrent(n) || (this.credentialBootstrap = null, !this.options.auth.community_id && g.user?.runtimeCommunityId && (this.options.auth.community_id = g.user.runtimeCommunityId), this.receive({ type: "auth.ok", ...g }), p.aborted)) return;
7701
+ this.options.auth.client_kind === "extension" && this.receive({ type: "executor.registered", userId: g.user.id }), this.bootstrapped = !0;
7685
7702
  for (const y of this.beforeBootstrap.splice(0)) this.receive(y);
7686
7703
  this.synchronizeReferences();
7687
7704
  return;
@@ -7691,8 +7708,8 @@ class Ee extends EventTarget {
7691
7708
  return;
7692
7709
  }
7693
7710
  if (i === "starter_prompts.page_url" || i === "starter_prompts.page_context") {
7694
- const p = ++this.promptRevision, f = await this.http("/starter-prompts", r, i === "starter_prompts.page_context" ? { page_url: a, page_title: e.pageTitle ?? "", html_content: e.htmlContent ?? "" } : void 0);
7695
- this.isCurrent(n) && p === this.promptRevision && a === this.options.pageUrl() && this.receive({ type: "starterPrompts.updated", ...f });
7711
+ const p = ++this.promptRevision, g = await this.http("/starter-prompts", r, i === "starter_prompts.page_context" ? { page_url: a, page_title: e.pageTitle ?? "", html_content: e.htmlContent ?? "" } : void 0);
7712
+ this.isCurrent(n) && p === this.promptRevision && a === this.options.pageUrl() && this.receive({ type: "starterPrompts.updated", ...g });
7696
7713
  return;
7697
7714
  }
7698
7715
  if (i === "session.load") {
@@ -8059,17 +8076,17 @@ function Bn(t, e, n) {
8059
8076
  if (e.type === "effect.failed")
8060
8077
  i = { ...i, queries: { ...i.queries, [r]: { ...l, status: "error", error: { ...e.error }, requestId: null, consecutiveFailures: l.consecutiveFailures + 1 } } };
8061
8078
  else if (e.effectKind === "directory.query") {
8062
- for (const g of e.output.entries) i = pr(i, g, !0);
8063
- const c = e.output.entries.map((g) => g.conversation_id), u = { ...i.durableActivityBySessionId }, d = { ...i.activityBySessionId }, p = { ...i.activityRevisionBySessionId };
8064
- for (const g of e.output.entries) {
8065
- if (typeof g.is_active != "boolean") continue;
8066
- u[g.conversation_id] = g.is_active;
8067
- const b = l.startedAtActivityRevisionBySessionId[g.conversation_id];
8068
- b !== void 0 && p[g.conversation_id] === b && (delete d[g.conversation_id], delete p[g.conversation_id]);
8079
+ for (const f of e.output.entries) i = pr(i, f, !0);
8080
+ const c = e.output.entries.map((f) => f.conversation_id), u = { ...i.durableActivityBySessionId }, d = { ...i.activityBySessionId }, p = { ...i.activityRevisionBySessionId };
8081
+ for (const f of e.output.entries) {
8082
+ if (typeof f.is_active != "boolean") continue;
8083
+ u[f.conversation_id] = f.is_active;
8084
+ const b = l.startedAtActivityRevisionBySessionId[f.conversation_id];
8085
+ b !== void 0 && p[f.conversation_id] === b && (delete d[f.conversation_id], delete p[f.conversation_id]);
8069
8086
  }
8070
8087
  i = { ...i, durableActivityBySessionId: u, activityBySessionId: d, activityRevisionBySessionId: p };
8071
- const f = Object.fromEntries(Object.entries(i.optimisticEntries).filter(([, g]) => g.sessionId === null || !c.includes(g.sessionId)));
8072
- i = { ...i, optimisticEntries: f };
8088
+ const g = Object.fromEntries(Object.entries(i.optimisticEntries).filter(([, f]) => f.sessionId === null || !c.includes(f.sessionId)));
8089
+ i = { ...i, optimisticEntries: g };
8073
8090
  const y = [.../* @__PURE__ */ new Set([...l.mode === "append" ? l.data ?? [] : [], ...c])];
8074
8091
  i = { ...i, queries: { ...i.queries, [r]: {
8075
8092
  ...l,
@@ -8503,10 +8520,10 @@ class Uf {
8503
8520
  return { state: c.state === o.slices.activeUsers ? o : Object.freeze({ revision: o.revision + 1, slices: Object.freeze({ ...o.slices, activeUsers: c.state }) }), effects: c.effects };
8504
8521
  }
8505
8522
  if (Of(r)) {
8506
- const c = Bn(o.slices.directory, r, o.slices.conversation), u = oa(na(o.slices.conversation, c.state, r.type === "directory.authority_replace" && r.adoptLocalSubmissions === !0)), d = ia(o.slices.conversation, u.state, c.state, c.state.clients !== o.slices.directory.clients), p = d.state, f = Ml(o.slices.conversation, p, c.state);
8507
- return { state: f === o.slices.directory && p === o.slices.conversation ? o : Object.freeze({
8523
+ const c = Bn(o.slices.directory, r, o.slices.conversation), u = oa(na(o.slices.conversation, c.state, r.type === "directory.authority_replace" && r.adoptLocalSubmissions === !0)), d = ia(o.slices.conversation, u.state, c.state, c.state.clients !== o.slices.directory.clients), p = d.state, g = Ml(o.slices.conversation, p, c.state);
8524
+ return { state: g === o.slices.directory && p === o.slices.conversation ? o : Object.freeze({
8508
8525
  revision: o.revision + 1,
8509
- slices: Object.freeze({ ...o.slices, directory: f, conversation: p })
8526
+ slices: Object.freeze({ ...o.slices, directory: g, conversation: p })
8510
8527
  }), effects: [...d.effects, ...c.effects, ...u.effects] };
8511
8528
  }
8512
8529
  if (Df(r)) {
@@ -8514,13 +8531,13 @@ class Uf {
8514
8531
  let u = o.slices.directory;
8515
8532
  for (const [S, k] of Object.entries(c.state.operations)) {
8516
8533
  if (!["runtime.warmup", "attachment.prepare"].includes(k.command.type) || !k.conversationScopeId || k.phase !== "done" || o.slices.conversation.operations[S]?.phase === "done") continue;
8517
- const m = k.result, w = u.selections[k.conversationScopeId];
8518
- m?.sessionId && w?.provisionalId && w.sessionId === null && Object.values(u.clients).includes(k.conversationScopeId) && (u = Bn(u, {
8534
+ const m = k.result, _ = u.selections[k.conversationScopeId];
8535
+ m?.sessionId && _?.provisionalId && _.sessionId === null && Object.values(u.clients).includes(k.conversationScopeId) && (u = Bn(u, {
8519
8536
  authorityId: c.state.authorityId,
8520
8537
  generation: c.state.generation,
8521
8538
  type: "directory.accepted",
8522
8539
  conversationScopeId: k.conversationScopeId,
8523
- provisionalId: w.provisionalId,
8540
+ provisionalId: _.provisionalId,
8524
8541
  sessionId: m.sessionId
8525
8542
  }).state);
8526
8543
  }
@@ -8537,17 +8554,17 @@ class Uf {
8537
8554
  }).state);
8538
8555
  }
8539
8556
  u = Ml(o.slices.conversation, c.state, u);
8540
- const p = oa(na(c.state, u)), f = ia(c.state, p.state, u);
8557
+ const p = oa(na(c.state, u)), g = ia(c.state, p.state, u);
8541
8558
  let y = o.slices;
8542
- const g = [], b = c.interactionSources, _ = y.account.authority;
8543
- if (b && _ && _.authorityId === b.authorityId && _.generation === b.generation) {
8544
- const S = Yr(y, { type: "stage7.sources", authority: _, now: y.features.now, sources: b.sources }, { conversation: f.state, directory: u });
8545
- y = We(at({ account: S.state.account, features: S.state.features, interactions: S.state.interactions })), g.push(...S.effects);
8559
+ const f = [], b = c.interactionSources, w = y.account.authority;
8560
+ if (b && w && w.authorityId === b.authorityId && w.generation === b.generation) {
8561
+ const S = Yr(y, { type: "stage7.sources", authority: w, now: y.features.now, sources: b.sources }, { conversation: g.state, directory: u });
8562
+ y = We(at({ account: S.state.account, features: S.state.features, interactions: S.state.interactions })), f.push(...S.effects);
8546
8563
  }
8547
- return { state: f.state === o.slices.conversation && u === o.slices.directory && y === o.slices ? o : Object.freeze({
8564
+ return { state: g.state === o.slices.conversation && u === o.slices.directory && y === o.slices ? o : Object.freeze({
8548
8565
  revision: o.revision + 1,
8549
- slices: Object.freeze({ ...o.slices, account: y.account, features: y.features, interactions: y.interactions, directory: u, conversation: f.state })
8550
- }), effects: [...c.effects, ...g, ...f.effects, ...p.effects] };
8566
+ slices: Object.freeze({ ...o.slices, account: y.account, features: y.features, interactions: y.interactions, directory: u, conversation: g.state })
8567
+ }), effects: [...c.effects, ...f, ...g.effects, ...p.effects] };
8551
8568
  }
8552
8569
  const l = Cf(o.slices.modelSelection, r);
8553
8570
  return { state: l === o.slices.modelSelection ? o : Object.freeze({
@@ -9512,8 +9529,8 @@ class Ka {
9512
9529
  const e = ++this.conversationAdapterGeneration;
9513
9530
  this.conversationObservation?.dispose(), this.conversationUnsubscribe?.();
9514
9531
  const n = this.directoryAuthority, i = () => e === this.conversationAdapterGeneration;
9515
- this.operationTimingReporter = Fh((g) => {
9516
- i() && !this.clientRuntime.isDisposed && this.reportHealthSignal("operation_timing", { timings: g.map((b) => ({ ...b, entrySurface: this.options.entrySurface })) });
9532
+ this.operationTimingReporter = Fh((f) => {
9533
+ i() && !this.clientRuntime.isDisposed && this.reportHealthSignal("operation_timing", { timings: f.map((b) => ({ ...b, entrySurface: this.options.entrySurface })) });
9517
9534
  });
9518
9535
  const s = `pa.conversation.delivery:${this.modelClientScopeId}:${n.authorityId}`, o = `${s}:cancellations`;
9519
9536
  this.authenticatedUserId && this.options.restorePersistedState === !1 && sessionStorage.removeItem(o);
@@ -9521,10 +9538,10 @@ class Ka {
9521
9538
  authorityId: n.authorityId,
9522
9539
  isCurrent: i,
9523
9540
  read: async () => a ? JSON.parse(a) : null,
9524
- write: async (g) => {
9525
- this.authenticatedUserId && sessionStorage.setItem(o, JSON.stringify(g));
9541
+ write: async (f) => {
9542
+ this.authenticatedUserId && sessionStorage.setItem(o, JSON.stringify(f));
9526
9543
  },
9527
- onTiming: (g) => this.reportOperationTiming(g)
9544
+ onTiming: (f) => this.reportOperationTiming(f)
9528
9545
  });
9529
9546
  this.clientRuntime.installConversationPorts({
9530
9547
  ...ng({
@@ -9533,16 +9550,16 @@ class Ka {
9533
9550
  isCurrent: i,
9534
9551
  http: this.directoryHttp,
9535
9552
  now: () => Date.now(),
9536
- prepareSubmission: async ({ submission: g, sources: b }, _) => {
9553
+ prepareSubmission: async ({ submission: f, sources: b }, w) => {
9537
9554
  const S = Xe(this.operationTimingReporter, {
9538
9555
  operation: "send",
9539
9556
  layer: "sdk",
9540
- requestId: g.requestId,
9541
- clientMessageId: g.userMessageId,
9542
- sessionId: g.sessionId
9543
- }), k = (w, I) => S.measure(w, () => qs(_, I));
9544
- let m = g.contextPreparation ?? { pageContent: "", sessionTabs: [] };
9545
- if (g.contextPreparation === null) {
9557
+ requestId: f.requestId,
9558
+ clientMessageId: f.userMessageId,
9559
+ sessionId: f.sessionId
9560
+ }), k = (_, I) => S.measure(_, () => qs(w, I));
9561
+ let m = f.contextPreparation ?? { pageContent: "", sessionTabs: [] };
9562
+ if (f.contextPreparation === null) {
9546
9563
  await k("first_frame", () => new Promise((I) => {
9547
9564
  if (document.visibilityState !== "visible") {
9548
9565
  setTimeout(I, 0);
@@ -9555,77 +9572,77 @@ class Ka {
9555
9572
  }, A = requestAnimationFrame(x);
9556
9573
  document.addEventListener("visibilitychange", E);
9557
9574
  }));
9558
- const w = g.context.page;
9559
- if (Ct().url !== w.url) throw Object.assign(new Error("The page changed before preparation completed. Send this message again."), { code: "context_preparation_interrupted", retryable: !1 });
9575
+ const _ = f.context.page;
9576
+ if (Ct().url !== _.url) throw Object.assign(new Error("The page changed before preparation completed. Send this message again."), { code: "context_preparation_interrupted", retryable: !1 });
9560
9577
  m = { pageContent: await k("page_capture", async () => Wa()), sessionTabs: [] };
9561
9578
  }
9562
9579
  if (await k("authentication", () => this.waitForAuthentication()), !i() || n !== this.directoryAuthority || this.clientRuntime.isDisposed) throw new Error("Submission authority was retired.");
9563
- for (const w of b)
9564
- if (!w.uploaded && (await qs(_, () => (this.attachmentPersistence.get(w.sourceId) ?? Promise.resolve()).catch(() => {
9580
+ for (const _ of b)
9581
+ if (!_.uploaded && (await qs(w, () => (this.attachmentPersistence.get(_.sourceId) ?? Promise.resolve()).catch(() => {
9565
9582
  throw Object.assign(new Error("Attachment files could not be stored. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
9566
- })), !await qs(_, () => Ol(w.sourceId))))
9583
+ })), !await qs(w, () => Ol(_.sourceId))))
9567
9584
  throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
9568
- return _.throwIfAborted(), S.mark("context_ready"), { ...m, now: Date.now() };
9585
+ return w.throwIfAborted(), S.mark("context_ready"), { ...m, now: Date.now() };
9569
9586
  },
9570
9587
  connectionId: () => this.socket instanceof Ee ? this.socket.connectionId : null,
9571
- prepareUpload: this.options.prepareAttachmentUpload ?? (this.options.productVariant === "customer_embedded" ? (g) => this.prepareEmbedAttachmentUpload(g, i) : void 0),
9572
- onUploaded: async (g, b, _) => {
9573
- await mu(g, {
9588
+ prepareUpload: this.options.prepareAttachmentUpload ?? (this.options.productVariant === "customer_embedded" ? (f) => this.prepareEmbedAttachmentUpload(f, i) : void 0),
9589
+ onUploaded: async (f, b, w) => {
9590
+ await mu(f, {
9574
9591
  sessionId: b,
9575
- sandboxPath: _.sandbox_path ?? void 0,
9576
- storageKey: _.storage_key ?? void 0,
9577
- fileUrl: _.file_url ? new URL(_.file_url, this.options.backendUrl).toString() : void 0,
9592
+ sandboxPath: w.sandbox_path ?? void 0,
9593
+ storageKey: w.storage_key ?? void 0,
9594
+ fileUrl: w.file_url ? new URL(w.file_url, this.options.backendUrl).toString() : void 0,
9578
9595
  lastUsedAt: Date.now()
9579
9596
  }).catch((S) => ze("web-sdk.attachments", "Failed to update persisted Product Agent attachment", {
9580
- attachmentId: g,
9597
+ attachmentId: f,
9581
9598
  message: S instanceof Error ? S.message : String(S)
9582
9599
  }));
9583
9600
  },
9584
9601
  persistUpload: this.options.persistAttachmentUpload,
9585
- readAttachment: async (g) => {
9586
- const b = (await Ol(g))?.blob;
9602
+ readAttachment: async (f) => {
9603
+ const b = (await Ol(f))?.blob;
9587
9604
  if (!b) throw Object.assign(new Error("Attachment files are unavailable. Attach the files again and send a new message."), { code: "attachment_source_unavailable", retryable: !1 });
9588
9605
  return b;
9589
9606
  },
9590
- saveCancellation: (g) => r.save(g),
9591
- saveDelivery: async (g) => {
9592
- this.authenticatedUserId && (sessionStorage.setItem(s, JSON.stringify(g)), await r.committed(g));
9607
+ saveCancellation: (f) => r.save(f),
9608
+ saveDelivery: async (f) => {
9609
+ this.authenticatedUserId && (sessionStorage.setItem(s, JSON.stringify(f)), await r.committed(f));
9593
9610
  },
9594
9611
  // HTTP now owns command delivery; keep opt-in operational traces at that actual handoff.
9595
- onTiming: (g) => {
9596
- i() && this.reportOperationTiming(g);
9612
+ onTiming: (f) => {
9613
+ i() && this.reportOperationTiming(f);
9597
9614
  },
9598
- onCommand: (g) => Qn("client_event", g.type, wr({ ...g.payload, type: g.type })),
9599
- onError: (g, b) => {
9600
- if (this.options.productVariant === "customer_embedded" && b.operation === "conversation.snapshot" && g instanceof N && g.code === "conversation_access_denied") {
9615
+ onCommand: (f) => Qn("client_event", f.type, wr({ ...f.payload, type: f.type })),
9616
+ onError: (f, b) => {
9617
+ if (this.options.productVariant === "customer_embedded" && b.operation === "conversation.snapshot" && f instanceof N && f.code === "conversation_access_denied") {
9601
9618
  b.sessionId === this.getState().sessionId && this.startNewSession({ notifyTransport: !1 });
9602
9619
  return;
9603
9620
  }
9604
- ze("web-sdk.conversation", "Conversation operation failed", { ...b, ...Dn(g) }), g instanceof N && g.backendRefusal && b.operation.startsWith("chat.") ? this.applyAccountSubmissionError(g.code) : this.handleDirectoryTransportError(g);
9621
+ ze("web-sdk.conversation", "Conversation operation failed", { ...b, ...Dn(f) }), f instanceof N && f.backendRefusal && b.operation.startsWith("chat.") ? this.applyAccountSubmissionError(f.code) : this.handleDirectoryTransportError(f);
9605
9622
  }
9606
9623
  })
9607
9624
  });
9608
9625
  const l = this.clientRuntime.engine.getState().slices.conversation, c = this.options.restorePersistedState === !1 || !this.authenticatedUserId ? null : rr(s);
9609
9626
  if (this.authenticatedUserId && !l.submissionOrder.length && !Object.keys(l.operations).length) {
9610
- const g = this.queuedClientEvents.filter((S) => S.type === "chat.user_message"), b = c ? JSON.parse(c) : g.length ? eg(l, g.map((S) => {
9611
- const { type: k, ...m } = S, w = this.clientRuntime.engine.getState().slices.directory, I = w.clients[this.modelClientScopeId];
9627
+ const f = this.queuedClientEvents.filter((S) => S.type === "chat.user_message"), b = c ? JSON.parse(c) : f.length ? eg(l, f.map((S) => {
9628
+ const { type: k, ...m } = S, _ = this.clientRuntime.engine.getState().slices.directory, I = _.clients[this.modelClientScopeId];
9612
9629
  return {
9613
9630
  command: { type: k, request_id: S.clientMessageId, payload: JSON.parse(JSON.stringify(m)) },
9614
9631
  requestedModel: S.model ?? null,
9615
9632
  clientScopeId: this.modelClientScopeId,
9616
9633
  conversationScopeId: I,
9617
9634
  viewId: `sdk:${this.modelClientScopeId}`,
9618
- sessionId: S.sessionId ?? w.selections[I]?.sessionId ?? null,
9635
+ sessionId: S.sessionId ?? _.selections[I]?.sessionId ?? null,
9619
9636
  entrySurface: this.options.entrySurface,
9620
9637
  submittedAt: Date.now()
9621
9638
  };
9622
- })) : null, _ = this.options.restorePersistedState === !1 || !a ? b : await r.restore(
9639
+ })) : null, w = this.options.restorePersistedState === !1 || !a ? b : await r.restore(
9623
9640
  b ?? qa(l, this.clientRuntime.engine.getState().slices.directory)
9624
9641
  );
9625
9642
  if (!i()) return;
9626
- _ && (b || Object.keys(_.operations).length || Object.keys(_.stops).length) && await this.clientRuntime.engine.dispatch({ ...n, type: "conversation.restore_delivery", checkpoint: _ });
9643
+ w && (b || Object.keys(w.operations).length || Object.keys(w.stops).length) && await this.clientRuntime.engine.dispatch({ ...n, type: "conversation.restore_delivery", checkpoint: w });
9627
9644
  }
9628
- if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((g) => !["chat.user_message", "chat.retry_last_user_message", "run.stop", "runtime.warmup", "session.reset", "attachment.upload_completed"].includes(g.type))), On(this.options.clientId, this.queuedClientEvents), !i()) return;
9645
+ if (this.authenticatedUserId && (this.queuedClientEvents = this.queuedClientEvents.filter((f) => !["chat.user_message", "chat.retry_last_user_message", "run.stop", "runtime.warmup", "session.reset", "attachment.upload_completed"].includes(f.type))), On(this.options.clientId, this.queuedClientEvents), !i()) return;
9629
9646
  this.conversationObservation = new ig({
9630
9647
  authority: n,
9631
9648
  now: () => Date.now(),
@@ -9633,16 +9650,16 @@ class Ka {
9633
9650
  isCurrent: i,
9634
9651
  enabled: () => !!this.token && !this.authenticationFailure && !this.refreshingDefaultCredentials && this.state.status !== "closed",
9635
9652
  socket: {
9636
- retain: async (g, b) => {
9637
- const _ = this.socket;
9638
- _ instanceof Ee && await _.directoryRooms.retain(g, b).catch((S) => {
9639
- if (this.socket === _) throw S;
9653
+ retain: async (f, b) => {
9654
+ const w = this.socket;
9655
+ w instanceof Ee && await w.directoryRooms.retain(f, b).catch((S) => {
9656
+ if (this.socket === w) throw S;
9640
9657
  });
9641
9658
  },
9642
- release: async (g, b) => {
9643
- const _ = this.socket;
9644
- _ instanceof Ee && await _.directoryRooms.release(g, b).catch((S) => {
9645
- if (this.socket === _) throw S;
9659
+ release: async (f, b) => {
9660
+ const w = this.socket;
9661
+ w instanceof Ee && await w.directoryRooms.release(f, b).catch((S) => {
9662
+ if (this.socket === w) throw S;
9646
9663
  });
9647
9664
  }
9648
9665
  },
@@ -9650,46 +9667,46 @@ class Ka {
9650
9667
  wakeup: { start: () => {
9651
9668
  }, stop: () => {
9652
9669
  } },
9653
- onError: (g) => this.handleDirectoryTransportError(g)
9670
+ onError: (f) => this.handleDirectoryTransportError(f)
9654
9671
  });
9655
- const u = (g, b) => {
9672
+ const u = (f, b) => {
9656
9673
  if (this.firstResponseTimersByClientMessageId.size) {
9657
- for (const _ of g)
9658
- (_.dataType === "run_status" || _.dataType === "run_error") && this.clearFirstResponseTimer(_.respondsToUserMessageId ?? null);
9659
- for (const _ of g)
9660
- if (_.content.trim() && (_.role === "assistant" || _.dataType === "commentary_history" || _.dataType === "tool_summary")) {
9674
+ for (const w of f)
9675
+ (w.dataType === "run_status" || w.dataType === "run_error") && this.clearFirstResponseTimer(w.respondsToUserMessageId ?? null);
9676
+ for (const w of f)
9677
+ if (w.content.trim() && (w.role === "assistant" || w.dataType === "commentary_history" || w.dataType === "tool_summary")) {
9661
9678
  const S = b ? this.clientRuntime.engine.getState().slices.conversation.sessions[b] : void 0;
9662
- for (const k of _.respondsToUserMessageId ? ph(S, _.respondsToUserMessageId) : [])
9679
+ for (const k of w.respondsToUserMessageId ? ph(S, w.respondsToUserMessageId) : [])
9663
9680
  this.clearFirstResponseTimer(k, !0, b);
9664
9681
  }
9665
9682
  }
9666
9683
  };
9667
- let d = new Map(this.getState().messages.map((g) => [g.id, g])), p = this.clientRuntime.engine.getState().slices.conversation, f = this.clientRuntime.engine.getState().slices.directory.selections, y = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
9684
+ let d = new Map(this.getState().messages.map((f) => [f.id, f])), p = this.clientRuntime.engine.getState().slices.conversation, g = this.clientRuntime.engine.getState().slices.directory.selections, y = this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId];
9668
9685
  this.conversationUnsubscribe = this.clientRuntime.engine.subscribe(() => {
9669
- const g = this.clientRuntime.engine.getState().slices, b = p;
9670
- p = g.conversation, Hh(b, g.conversation, this.operationTimingReporter, "sdk");
9671
- const _ = y !== g.directory.clients[this.modelClientScopeId];
9672
- y = g.directory.clients[this.modelClientScopeId], f !== g.directory.selections && (f = g.directory.selections, this.directoryScope.persist());
9673
- for (const k of Object.values(g.conversation.submissions)) {
9686
+ const f = this.clientRuntime.engine.getState().slices, b = p;
9687
+ p = f.conversation, Hh(b, f.conversation, this.operationTimingReporter, "sdk");
9688
+ const w = y !== f.directory.clients[this.modelClientScopeId];
9689
+ y = f.directory.clients[this.modelClientScopeId], g !== f.directory.selections && (g = f.directory.selections, this.directoryScope.persist());
9690
+ for (const k of Object.values(f.conversation.submissions)) {
9674
9691
  if (k.delivery === "accepted" && b.submissions[k.userMessageId]?.delivery !== "accepted") {
9675
9692
  const m = this.firstResponseTimersByClientMessageId.get(k.userMessageId);
9676
9693
  m && (m.sessionId = k.sessionId), this.emit("ack", { clientMessageId: k.userMessageId, sessionId: k.sessionId });
9677
- const w = k.sessionId;
9678
- w && this.getState().sessionId === w && this.directoryHttp.request(`/sessions/${encodeURIComponent(w)}/history`, { limit: 200 }).then((I) => {
9679
- i() && this.getState().sessionId === w && this.state.status !== "closed" && br(this.clientRuntime, this.modelClientScopeId, w, I.turns);
9694
+ const _ = k.sessionId;
9695
+ _ && this.getState().sessionId === _ && this.directoryHttp.request(`/sessions/${encodeURIComponent(_)}/history`, { limit: 200 }).then((I) => {
9696
+ i() && this.getState().sessionId === _ && this.state.status !== "closed" && br(this.clientRuntime, this.modelClientScopeId, _, I.turns);
9680
9697
  }).catch((I) => {
9681
- i() && this.getState().sessionId === w && this.handleDirectoryTransportError(I);
9698
+ i() && this.getState().sessionId === _ && this.handleDirectoryTransportError(I);
9682
9699
  });
9683
9700
  }
9684
9701
  (k.cancelled || k.delivery === "failed") && this.clearFirstResponseTimer(k.userMessageId);
9685
9702
  }
9686
- for (const [k, m] of Object.entries(g.directory.clients)) {
9703
+ for (const [k, m] of Object.entries(f.directory.clients)) {
9687
9704
  if (!k.startsWith(`background:${this.modelClientScopeId}:`)) continue;
9688
- const w = gn(g.conversation, g.directory, m), I = w.sessionId ? g.conversation.sessions[w.sessionId] : void 0;
9689
- if (this.firstResponseTimersByClientMessageId.size && (u(ar(w, I?.queries.current, this.options.backendUrl).messages, w.sessionId), ["failed", "stopped"].includes(w.activity.phase)))
9705
+ const _ = gn(f.conversation, f.directory, m), I = _.sessionId ? f.conversation.sessions[_.sessionId] : void 0;
9706
+ if (this.firstResponseTimersByClientMessageId.size && (u(ar(_, I?.queries.current, this.options.backendUrl).messages, _.sessionId), ["failed", "stopped"].includes(_.activity.phase)))
9690
9707
  for (const E of Tt(I?.execution)) this.clearFirstResponseTimer(E);
9691
- const x = w.activity.phase === "completed" && Tt(I?.execution).some((E) => this.firstResponseTimersByClientMessageId.has(E));
9692
- (_ && w.sessionId === this.getState().sessionId || !x && ["completed", "failed", "stopped"].includes(w.activity.phase)) && this.directoryScope.detach(k);
9708
+ const x = _.activity.phase === "completed" && Tt(I?.execution).some((E) => this.firstResponseTimersByClientMessageId.has(E));
9709
+ (w && _.sessionId === this.getState().sessionId || !x && ["completed", "failed", "stopped"].includes(_.activity.phase)) && this.directoryScope.detach(k);
9693
9710
  }
9694
9711
  const S = this.getState();
9695
9712
  u(S.messages, S.sessionId);
@@ -10057,7 +10074,7 @@ class Ka {
10057
10074
  if (this.clientRuntime.isDisposed) return null;
10058
10075
  const i = e.trim(), s = n.attachments ?? [];
10059
10076
  if (!i && !s.length) return null;
10060
- if (this.options.productVariant === "customer_embedded" && (s.forEach(qu), s.reduce((b, _) => b + _.sizeBytes, 0) > vu))
10077
+ if (this.options.productVariant === "customer_embedded" && (s.forEach(qu), s.reduce((b, w) => b + w.sizeBytes, 0) > vu))
10061
10078
  throw new Error("Embedded attachments must total at most 50 MB per message");
10062
10079
  const o = n.clientMessageId ?? Pe(), a = Xe(this.operationTimingReporter, {
10063
10080
  operation: "send",
@@ -10109,16 +10126,16 @@ class Ka {
10109
10126
  entrySurface: this.options.entrySurface,
10110
10127
  submittedAt: n.submittedAt ?? Date.now()
10111
10128
  });
10112
- const g = this.directoryAuthority;
10113
- return this.clientRuntime.isDisposed ? null : new Promise((b, _) => {
10129
+ const f = this.directoryAuthority;
10130
+ return this.clientRuntime.isDisposed ? null : new Promise((b, w) => {
10114
10131
  let S = null, k = null;
10115
10132
  const m = () => {
10116
- const w = this.clientRuntime.engine.getState().slices.conversation.submissions[o];
10117
- if (!(w && !w.cancelled && w.delivery !== "accepted" && w.delivery !== "failed"))
10118
- if (S?.(), k?.(), w?.delivery === "failed" && !w.cancelled) _(new Error(w.error?.message ?? "Message delivery failed."));
10133
+ const _ = this.clientRuntime.engine.getState().slices.conversation.submissions[o];
10134
+ if (!(_ && !_.cancelled && _.delivery !== "accepted" && _.delivery !== "failed"))
10135
+ if (S?.(), k?.(), _?.delivery === "failed" && !_.cancelled) w(new Error(_.error?.message ?? "Message delivery failed."));
10119
10136
  else {
10120
- const I = w?.invocation === "user" && w.contextPreparation?.pageContent ? w.context.page?.url : null;
10121
- w?.delivery === "accepted" && !w.cancelled && typeof I == "string" && l === this.submissionIntentRevision && g === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === y && (this.lastUserMessagePageUrl = I), b(w?.delivery === "accepted" && !w.cancelled ? o : null);
10137
+ const I = _?.invocation === "user" && _.contextPreparation?.pageContent ? _.context.page?.url : null;
10138
+ _?.delivery === "accepted" && !_.cancelled && typeof I == "string" && l === this.submissionIntentRevision && f === this.directoryAuthority && this.clientRuntime.engine.getState().slices.directory.clients[this.modelClientScopeId] === y && (this.lastUserMessagePageUrl = I), b(_?.delivery === "accepted" && !_.cancelled ? o : null);
10122
10139
  }
10123
10140
  };
10124
10141
  S = this.clientRuntime.engine.subscribe(m), k = this.clientRuntime.onDispose(() => {
@@ -10221,14 +10238,14 @@ class Ka {
10221
10238
  } }
10222
10239
  }), new Promise((c, u) => {
10223
10240
  let d, p;
10224
- const f = () => {
10225
- const y = this.clientRuntime.engine.getState().slices, g = y.conversation.operations[l], b = y.directory.authorityId !== a.authorityId || y.directory.clients[this.modelClientScopeId] !== r;
10226
- if (!b && g && !["done", "failed"].includes(g.phase)) return;
10227
- if (d?.(), p?.(), b || !g || g.phase === "failed") {
10228
- u(new Error(g?.error?.message ?? "Attachment preparation was cancelled."));
10241
+ const g = () => {
10242
+ const y = this.clientRuntime.engine.getState().slices, f = y.conversation.operations[l], b = y.directory.authorityId !== a.authorityId || y.directory.clients[this.modelClientScopeId] !== r;
10243
+ if (!b && f && !["done", "failed"].includes(f.phase)) return;
10244
+ if (d?.(), p?.(), b || !f || f.phase === "failed") {
10245
+ u(new Error(f?.error?.message ?? "Attachment preparation was cancelled."));
10229
10246
  return;
10230
10247
  }
10231
- const S = g.result.attachment;
10248
+ const S = f.result.attachment;
10232
10249
  c(Au({
10233
10250
  id: S.id,
10234
10251
  name: S.name,
@@ -10239,9 +10256,9 @@ class Ka {
10239
10256
  fileUrl: S.file_url
10240
10257
  }, this.options.backendUrl));
10241
10258
  };
10242
- d = this.clientRuntime.engine.subscribe(f), p = this.clientRuntime.onDispose(() => {
10259
+ d = this.clientRuntime.engine.subscribe(g), p = this.clientRuntime.onDispose(() => {
10243
10260
  d?.(), u(new Error("Product Agent was disposed."));
10244
- }), f();
10261
+ }), g();
10245
10262
  });
10246
10263
  }
10247
10264
  async prepareEmbedAttachmentUpload(e, n) {
@@ -10510,31 +10527,31 @@ class Ka {
10510
10527
  return;
10511
10528
  }
10512
10529
  n = !0;
10513
- const p = this.getState().sessionId, f = () => !this.clientRuntime.isDisposed && JSON.stringify(this.clientRuntime.engine.getState().slices.account.authority) === JSON.stringify(d) && this.getState().sessionId === p;
10530
+ const p = this.getState().sessionId, g = () => !this.clientRuntime.isDisposed && JSON.stringify(this.clientRuntime.engine.getState().slices.account.authority) === JSON.stringify(d) && this.getState().sessionId === p;
10514
10531
  Promise.all(["notifications", "tab_grouping"].map(async (y) => {
10515
- const g = await u.getState(y, p);
10516
- if (f()) {
10517
- if (!g.bridgeReady) return g;
10532
+ const f = await u.getState(y, p);
10533
+ if (g()) {
10534
+ if (!f.bridgeReady) return f;
10518
10535
  if (await this.clientRuntime.engine.dispatch({
10519
10536
  type: "stage7.device_fact",
10520
10537
  authority: d,
10521
10538
  now: Date.now(),
10522
10539
  feature: y,
10523
- fact: { permission: g.permissionGranted ? "granted" : g.permissionNeeded ? "missing" : "unknown", revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[y].revision + 1), snoozedUntil: g.snoozedUntil ?? null }
10524
- }), y === "tab_grouping" && g.sessionId === p && p) for (const b of g.crossTabUserMessageIds ?? [])
10540
+ fact: { permission: f.permissionGranted ? "granted" : f.permissionNeeded ? "missing" : "unknown", revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[y].revision + 1), snoozedUntil: f.snoozedUntil ?? null }
10541
+ }), y === "tab_grouping" && f.sessionId === p && p) for (const b of f.crossTabUserMessageIds ?? [])
10525
10542
  await this.clientRuntime.engine.dispatch({ type: "stage7.cross_tab", authority: d, now: Date.now(), sessionId: p, userMessageId: b });
10526
- return g;
10543
+ return f;
10527
10544
  }
10528
10545
  })).then(async (y) => {
10529
- f() && await this.clientRuntime.engine.dispatch({
10546
+ g() && await this.clientRuntime.engine.dispatch({
10530
10547
  type: "stage7.bridge_ready",
10531
10548
  authority: d,
10532
10549
  now: Date.now(),
10533
- ready: y.every((g) => g?.bridgeReady),
10534
- error: y.find((g) => g?.error)?.error ?? null
10550
+ ready: y.every((f) => f?.bridgeReady),
10551
+ error: y.find((f) => f?.error)?.error ?? null
10535
10552
  });
10536
10553
  }).catch(async () => {
10537
- f() && await this.clientRuntime.engine.dispatch({ type: "stage7.bridge_ready", authority: d, now: Date.now(), ready: !1, error: "The Pluno extension could not reconnect. Try again." });
10554
+ g() && await this.clientRuntime.engine.dispatch({ type: "stage7.bridge_ready", authority: d, now: Date.now(), ready: !1, error: "The Pluno extension could not reconnect. Try again." });
10538
10555
  }).finally(() => {
10539
10556
  n = !1, i && (i = !1, s());
10540
10557
  });
@@ -10572,16 +10589,16 @@ class Ka {
10572
10589
  ...o,
10573
10590
  "stage7.wait": e.wait,
10574
10591
  "stage7.device": async ({ feature: u, action: d, requestId: p }) => {
10575
- const f = this.options.runtimeAdapters?.featurePermissions;
10576
- if (!f) return { fact: { permission: "unsupported", revision: Date.now(), snoozedUntil: null }, completedAt: Date.now() };
10577
- const y = this.clientRuntime.engine.getState().slices.interactions, g = y.promptActions[p], b = g?.expectedRevision ?? y.preferencePrompts[u].revision;
10578
- d === "allow" && await f.enable(u, { requestId: p, expectedRevision: b, action: g?.action === "enable" ? "enable" : "allow" }), d === "not_now" && await f.dismiss(u, { requestId: p, expectedRevision: b, action: "not_now" });
10579
- const _ = await f.getState(u, this.getState().sessionId);
10580
- if (!_.bridgeReady) throw new Error("The Pluno extension is reconnecting. Try again.");
10592
+ const g = this.options.runtimeAdapters?.featurePermissions;
10593
+ if (!g) return { fact: { permission: "unsupported", revision: Date.now(), snoozedUntil: null }, completedAt: Date.now() };
10594
+ const y = this.clientRuntime.engine.getState().slices.interactions, f = y.promptActions[p], b = f?.expectedRevision ?? y.preferencePrompts[u].revision;
10595
+ d === "allow" && await g.enable(u, { requestId: p, expectedRevision: b, action: f?.action === "enable" ? "enable" : "allow" }), d === "not_now" && await g.dismiss(u, { requestId: p, expectedRevision: b, action: "not_now" });
10596
+ const w = await g.getState(u, this.getState().sessionId);
10597
+ if (!w.bridgeReady) throw new Error("The Pluno extension is reconnecting. Try again.");
10581
10598
  return { fact: {
10582
- permission: _.permissionGranted === !0 ? "granted" : _.permissionNeeded ? "missing" : "unknown",
10599
+ permission: w.permissionGranted === !0 ? "granted" : w.permissionNeeded ? "missing" : "unknown",
10583
10600
  revision: Math.max(Date.now(), this.clientRuntime.engine.getState().slices.interactions.deviceFacts[u].revision + 1),
10584
- snoozedUntil: _.snoozedUntil ?? null
10601
+ snoozedUntil: w.snoozedUntil ?? null
10585
10602
  }, completedAt: Date.now() };
10586
10603
  },
10587
10604
  "stage7.platform": async (u) => {
@@ -10589,15 +10606,15 @@ class Ka {
10589
10606
  if (d.kind === "saveHint")
10590
10607
  ch(localStorage, d.interactionId);
10591
10608
  else if (d.kind === "connect" && p?.payload.kind === "integration_auth") {
10592
- const f = p.payload;
10609
+ const g = p.payload;
10593
10610
  if (!this.options.runtimeAdapters?.integrationAuthHandler) throw new Error("Connection handler unavailable.");
10594
10611
  await this.options.runtimeAdapters.integrationAuthHandler({
10595
10612
  type: "pipedream_auth_required",
10596
- authRequestId: f.request_id,
10597
- appSlug: f.app_slug,
10598
- appName: f.app_name,
10599
- appLogo: f.app_logo,
10600
- expiresAt: f.expires_at
10613
+ authRequestId: g.request_id,
10614
+ appSlug: g.app_slug,
10615
+ appName: g.app_name,
10616
+ appLogo: g.app_logo,
10617
+ expiresAt: g.expires_at
10601
10618
  });
10602
10619
  } else if (d.kind === "pair") {
10603
10620
  if (!this.options.runtimeAdapters?.personalChannelConnectionHandler) throw new Error("Pairing handler unavailable.");
@@ -10615,8 +10632,8 @@ class Ka {
10615
10632
  let a = "";
10616
10633
  const r = this.clientRuntime.engine.subscribe(() => {
10617
10634
  this.rebuildRuntimeInteractions();
10618
- const u = this.clientRuntime.engine.getState().slices, p = u.directory.selections[u.directory.clients[this.modelClientScopeId]]?.sessionId, f = JSON.stringify([p, p ? u.conversation.sessions[p]?.execution : null]);
10619
- f !== a && (a = f, s());
10635
+ const u = this.clientRuntime.engine.getState().slices, p = u.directory.selections[u.directory.clients[this.modelClientScopeId]]?.sessionId, g = JSON.stringify([p, p ? u.conversation.sessions[p]?.execution : null]);
10636
+ g !== a && (a = g, s());
10620
10637
  }), l = this.options.runtimeAdapters?.featurePermissions?.subscribe?.(s);
10621
10638
  this.clientRuntime.onDispose(() => l?.()), Ch(this.clientRuntime, () => Date.now());
10622
10639
  const c = () => {
@@ -10668,9 +10685,9 @@ class Ka {
10668
10685
  reportHealthSignal(e, n = {}) {
10669
10686
  let i = this.getState();
10670
10687
  if (e === "first_response_slow" && n.sessionId && n.sessionId !== i.sessionId) {
10671
- const { conversation: y, directory: g } = this.clientRuntime.engine.getState().slices, b = Object.values(g.clients).find((_) => g.selections[_]?.sessionId === n.sessionId);
10688
+ const { conversation: y, directory: f } = this.clientRuntime.engine.getState().slices, b = Object.values(f.clients).find((w) => f.selections[w]?.sessionId === n.sessionId);
10672
10689
  b && (i = { ...i, ...ar(
10673
- gn(y, g, b),
10690
+ gn(y, f, b),
10674
10691
  y.sessions[n.sessionId]?.queries.current,
10675
10692
  this.options.backendUrl
10676
10693
  ) });
@@ -10704,10 +10721,10 @@ class Ka {
10704
10721
  ...i.sessionId ? { sessionId: i.sessionId } : {},
10705
10722
  ...n,
10706
10723
  ...n.renderedError?.runId ? { runId: n.renderedError.runId } : {}
10707
- }, { errorDiagnostic: a, responseDiagnostics: r, renderedError: l, uiInvariant: c, timings: u, httpRequest: d, historyRefreshFailure: p, ...f } = o;
10724
+ }, { errorDiagnostic: a, responseDiagnostics: r, renderedError: l, uiInvariant: c, timings: u, httpRequest: d, historyRefreshFailure: p, ...g } = o;
10708
10725
  for (const y of u ?? []) Qn("client_event", "operation_timing", { ...y });
10709
10726
  if (Qn("client_event", "runtime.health", {
10710
- ...f,
10727
+ ...g,
10711
10728
  signalName: e,
10712
10729
  ...p ? { historyRefreshConsecutiveFailures: p.consecutiveFailures, historyRefreshEpisodeId: p.episodeId } : {}
10713
10730
  }), this.options.productVariant === "customer_embedded" || !this.socket || this.socket.readyState !== WebSocket.OPEN || this.authenticatedSocket !== this.socket) {
@@ -10957,11 +10974,11 @@ class Ka {
10957
10974
  if (this.clientRuntime.isDisposed || this.directoryAuthority !== u) return;
10958
10975
  let d = !1;
10959
10976
  for (const p of r) {
10960
- const f = this.clientRuntime.engine.getState().slices.directory, y = f.clients[this.modelClientScopeId];
10961
- if (p.type === "run.stop" && f.selections[y]?.sessionId === p.payload.sessionId) {
10977
+ const g = this.clientRuntime.engine.getState().slices.directory, y = g.clients[this.modelClientScopeId];
10978
+ if (p.type === "run.stop" && g.selections[y]?.sessionId === p.payload.sessionId) {
10962
10979
  if (d) continue;
10963
10980
  d = !0;
10964
- const g = r.filter((b) => b.type === "run.stop" && b.payload.sessionId === p.payload.sessionId).map((b) => String(b.payload.expectedUserMessageId));
10981
+ const f = r.filter((b) => b.type === "run.stop" && b.payload.sessionId === p.payload.sessionId).map((b) => String(b.payload.expectedUserMessageId));
10965
10982
  await this.clientRuntime.engine.dispatch({
10966
10983
  ...u,
10967
10984
  type: "conversation.stop",
@@ -10969,7 +10986,7 @@ class Ka {
10969
10986
  conversationScopeId: y,
10970
10987
  requestId: p.request_id,
10971
10988
  reason: p.payload.reason,
10972
- userMessageIds: g
10989
+ userMessageIds: f
10973
10990
  });
10974
10991
  } else (p.type === "run.stop" || p.type === "session.reset") && await this.clientRuntime.engine.dispatch({ ...u, type: "conversation.operation", command: p });
10975
10992
  }
@@ -11448,47 +11465,47 @@ function Gm(t) {
11448
11465
  }
11449
11466
  function Jm() {
11450
11467
  const t = /* @__PURE__ */ new Set(), e = (p) => {
11451
- t.forEach((f) => {
11468
+ t.forEach((g) => {
11452
11469
  try {
11453
- f(p);
11470
+ g(p);
11454
11471
  } catch {
11455
11472
  }
11456
11473
  });
11457
- }, n = window.fetch, i = XMLHttpRequest.prototype.open, s = XMLHttpRequest.prototype.setRequestHeader, o = XMLHttpRequest.prototype.send, a = function(f, y) {
11458
- const g = Date.now();
11474
+ }, n = window.fetch, i = XMLHttpRequest.prototype.open, s = XMLHttpRequest.prototype.setRequestHeader, o = XMLHttpRequest.prototype.send, a = function(g, y) {
11475
+ const f = Date.now();
11459
11476
  let b;
11460
11477
  try {
11461
- b = n.call(this, f, y);
11462
- } catch (_) {
11463
- throw _;
11478
+ b = n.call(this, g, y);
11479
+ } catch (w) {
11480
+ throw w;
11464
11481
  }
11465
11482
  try {
11466
- const _ = f instanceof Request ? f : null, S = Jy(f, _), k = Pu(y?.headers ?? _?.headers);
11483
+ const w = g instanceof Request ? g : null, S = Jy(g, w), k = Pu(y?.headers ?? w?.headers);
11467
11484
  if (!Xn(S, k, y?.body)) {
11468
- const w = {
11485
+ const _ = {
11469
11486
  requestId: Cr("fetch"),
11470
11487
  url: Jt(S, Ir),
11471
- method: (y?.method ?? _?.method ?? "GET").toUpperCase(),
11488
+ method: (y?.method ?? w?.method ?? "GET").toUpperCase(),
11472
11489
  requestHeaders: k,
11473
11490
  requestBody: Jl(y?.body),
11474
11491
  resourceType: "fetch",
11475
- startedAt: new Date(g).toISOString()
11492
+ startedAt: new Date(f).toISOString()
11476
11493
  };
11477
11494
  b.then(
11478
11495
  (I) => {
11479
- Qy(I, w, g, e).catch(() => {
11496
+ Qy(I, _, f, e).catch(() => {
11480
11497
  e({
11481
- ...w,
11498
+ ..._,
11482
11499
  responseStatus: I.status,
11483
- durationMs: Date.now() - g
11500
+ durationMs: Date.now() - f
11484
11501
  });
11485
11502
  });
11486
11503
  },
11487
11504
  (I) => {
11488
11505
  e({
11489
- ...w,
11506
+ ..._,
11490
11507
  errorText: Jt(I instanceof Error ? I.message : String(I)),
11491
- durationMs: Date.now() - g
11508
+ durationMs: Date.now() - f
11492
11509
  });
11493
11510
  }
11494
11511
  );
@@ -11496,29 +11513,29 @@ function Jm() {
11496
11513
  } catch {
11497
11514
  }
11498
11515
  return b;
11499
- }, r = function(f, y, g, b, _) {
11500
- const S = i.call(this, f, y, g ?? !0, b ?? void 0, _ ?? void 0), k = typeof y == "string" ? y : y.toString();
11516
+ }, r = function(g, y, f, b, w) {
11517
+ const S = i.call(this, g, y, f ?? !0, b ?? void 0, w ?? void 0), k = typeof y == "string" ? y : y.toString();
11501
11518
  return xr.set(this, {
11502
11519
  requestId: Cr("xhr"),
11503
- method: String(f ?? "GET").toUpperCase(),
11520
+ method: String(g ?? "GET").toUpperCase(),
11504
11521
  url: Jt(k, Ir),
11505
11522
  requestHeaders: {},
11506
11523
  startedAtMs: Date.now(),
11507
11524
  startedAt: (/* @__PURE__ */ new Date()).toISOString(),
11508
11525
  excluded: Xn(k)
11509
11526
  }), S;
11510
- }, l = function(f, y) {
11511
- const g = s.call(this, f, y), b = xr.get(this);
11512
- return b && Object.keys(b.requestHeaders).length < Ha && (b.requestHeaders[f] = Ga(f, y), b.excluded = b.excluded || Xn(b.url, b.requestHeaders)), g;
11513
- }, c = function(f) {
11527
+ }, l = function(g, y) {
11528
+ const f = s.call(this, g, y), b = xr.get(this);
11529
+ return b && Object.keys(b.requestHeaders).length < Ha && (b.requestHeaders[g] = Ga(g, y), b.excluded = b.excluded || Xn(b.url, b.requestHeaders)), f;
11530
+ }, c = function(g) {
11514
11531
  try {
11515
11532
  const y = xr.get(this);
11516
- y && (y.excluded = y.excluded || Xn(y.url, y.requestHeaders, f), y.requestBody = Jl(f), y.excluded || this.addEventListener(
11533
+ y && (y.excluded = y.excluded || Xn(y.url, y.requestHeaders, g), y.requestBody = Jl(g), y.excluded || this.addEventListener(
11517
11534
  "loadend",
11518
11535
  () => {
11519
11536
  queueMicrotask(() => {
11520
11537
  try {
11521
- const g = nb(this.getAllResponseHeaders());
11538
+ const f = nb(this.getAllResponseHeaders());
11522
11539
  e({
11523
11540
  requestId: y.requestId,
11524
11541
  url: y.url,
@@ -11527,8 +11544,8 @@ function Jm() {
11527
11544
  requestBody: y.requestBody,
11528
11545
  resourceType: "xhr",
11529
11546
  responseStatus: this.status,
11530
- responseHeaders: g,
11531
- responseBody: Xy(this, g),
11547
+ responseHeaders: f,
11548
+ responseBody: Xy(this, f),
11532
11549
  errorText: this.status === 0 ? "XHR request failed or was aborted" : void 0,
11533
11550
  startedAt: y.startedAt,
11534
11551
  durationMs: Date.now() - y.startedAtMs
@@ -11542,7 +11559,7 @@ function Jm() {
11542
11559
  ));
11543
11560
  } catch {
11544
11561
  }
11545
- return o.call(this, f ?? null);
11562
+ return o.call(this, g ?? null);
11546
11563
  };
11547
11564
  try {
11548
11565
  window.fetch = a;
@@ -11563,18 +11580,18 @@ function Jm() {
11563
11580
  let u = null;
11564
11581
  if (typeof PerformanceObserver < "u") {
11565
11582
  u = new PerformanceObserver((p) => {
11566
- for (const f of p.getEntries()) {
11567
- const y = f;
11583
+ for (const g of p.getEntries()) {
11584
+ const y = g;
11568
11585
  if (y.initiatorType === "fetch" || y.initiatorType === "xmlhttprequest" || Xn(y.name))
11569
11586
  continue;
11570
- const g = performance.timeOrigin + y.startTime;
11587
+ const f = performance.timeOrigin + y.startTime;
11571
11588
  e({
11572
11589
  requestId: Cr("resource"),
11573
11590
  url: Jt(y.name, Ir),
11574
11591
  method: "GET",
11575
11592
  resourceType: "resource",
11576
11593
  responseStatus: y.responseStatus,
11577
- startedAt: new Date(g).toISOString(),
11594
+ startedAt: new Date(f).toISOString(),
11578
11595
  durationMs: y.duration
11579
11596
  });
11580
11597
  }
@@ -11875,27 +11892,27 @@ function my() {
11875
11892
  function Wa() {
11876
11893
  if (!document.body)
11877
11894
  return "";
11878
- const t = [], e = [], n = (g, b) => {
11879
- const _ = ri(b);
11880
- !_ || e.includes(_) || (t.push([g, _]), e.push(_));
11895
+ const t = [], e = [], n = (f, b) => {
11896
+ const w = ri(b);
11897
+ !w || e.includes(w) || (t.push([f, w]), e.push(w));
11881
11898
  };
11882
11899
  n("Selected text", window.getSelection()?.toString() ?? "");
11883
11900
  const i = "[role='dialog'], [role='alertdialog'], dialog[open], [aria-modal='true']", s = Array.from(document.querySelectorAll(i)).filter(
11884
- (g) => Su(g) && !g.parentElement?.closest(i)
11901
+ (f) => Su(f) && !f.parentElement?.closest(i)
11885
11902
  );
11886
- for (const g of s.slice(0, 3))
11887
- n("Active overlay", Er(Vi(g), e));
11903
+ for (const f of s.slice(0, 3))
11904
+ n("Active overlay", Er(Vi(f), e));
11888
11905
  const o = yy(), a = o ? Er(Vi(o), e) : "";
11889
11906
  n("Main page content", a), n("Additional visible page text", Er(Vi(document.body), e));
11890
- const r = t.map(([g, b]) => `${g}:
11907
+ const r = t.map(([f, b]) => `${f}:
11891
11908
  ${b}`).join(`
11892
11909
 
11893
11910
  `).trim().slice(0, 12e3), l = by(s, o).trim(), c = `Simplified DOM outline:
11894
11911
  `, u = `
11895
11912
 
11896
11913
  Visible page text:
11897
- `, d = 12e3 - c.length - u.length, p = Math.min(r.length, 7900), f = l.slice(0, d - p), y = r.slice(0, d - f.length);
11898
- return `${c}${f}${u}${y}`;
11914
+ `, d = 12e3 - c.length - u.length, p = Math.min(r.length, 7900), g = l.slice(0, d - p), y = r.slice(0, d - g.length);
11915
+ return `${c}${g}${u}${y}`;
11899
11916
  }
11900
11917
  function Vi(t) {
11901
11918
  return t.innerText ?? t.textContent ?? "";
@@ -12003,32 +12020,32 @@ function by(t, e) {
12003
12020
  "data-cy"
12004
12021
  ], c = ["aria-label", "placeholder", "data-testid", "data-test", "data-qa", "data-cy"], { priorityElements: u, priorityTargets: d } = wy(), p = new Set(t);
12005
12022
  e && p.add(e);
12006
- let f = 0;
12023
+ let g = 0;
12007
12024
  const y = (k) => {
12008
12025
  const m = k.getAttribute("role");
12009
12026
  return m && !a.has(m) ? m : "";
12010
- }, g = (k) => {
12027
+ }, f = (k) => {
12011
12028
  const m = k.getAttribute("data-testid") || k.getAttribute("data-test") || k.getAttribute("data-qa") || k.getAttribute("data-cy") || "";
12012
12029
  return `${k.tagName.toLowerCase()}|${y(k)}|${m}`;
12013
- }, b = (k, m, w) => {
12030
+ }, b = (k, m, _) => {
12014
12031
  const I = (x, E) => {
12015
- const A = x.tagName.toLowerCase(), L = window.getComputedStyle(x), P = u.has(x);
12016
- if (f >= 1e3 && !P || w.has(x) || o.has(A) || x.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || L.display === "none" || L.visibility === "hidden")
12032
+ const A = x.tagName.toLowerCase(), L = window.getComputedStyle(x), M = u.has(x);
12033
+ if (g >= 1e3 && !M || _.has(x) || o.has(A) || x.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || L.display === "none" || L.visibility === "hidden")
12017
12034
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
12018
- f += 1;
12035
+ g += 1;
12019
12036
  const z = y(x), B = xu(x), C = r.has(z) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(A) || A === "a" && x.hasAttribute("href"), U = Array.from(x.children).filter((H) => H instanceof HTMLElement), X = /* @__PURE__ */ new Map();
12020
12037
  for (const H of U) {
12021
- const ee = g(H);
12038
+ const ee = f(H);
12022
12039
  X.set(ee, (X.get(ee) ?? 0) + 1);
12023
12040
  }
12024
12041
  const Z = /* @__PURE__ */ new Map(), Me = /* @__PURE__ */ new Map();
12025
12042
  for (const H of U) {
12026
- const ee = g(H), be = Me.get(ee) ?? 0;
12043
+ const ee = f(H), be = Me.get(ee) ?? 0;
12027
12044
  Me.set(ee, be + 1), (X.get(ee) ?? 0) > 8 && be >= 6 && !u.has(H) && Z.set(ee, (Z.get(ee) ?? 0) + 1);
12028
12045
  }
12029
12046
  const _e = /* @__PURE__ */ new Map(), qe = /* @__PURE__ */ new Set(), Ae = [], F = [];
12030
12047
  for (const H of U) {
12031
- const ee = g(H), be = X.get(ee) ?? 0, G = _e.get(ee) ?? 0;
12048
+ const ee = f(H), be = X.get(ee) ?? 0, G = _e.get(ee) ?? 0;
12032
12049
  if (_e.set(ee, G + 1), be > 8 && G >= 6 && !u.has(H)) {
12033
12050
  qe.has(ee) || (Ae.push([`… ${Z.get(ee) ?? 0} similar siblings omitted`]), qe.add(ee));
12034
12051
  continue;
@@ -12042,7 +12059,7 @@ function by(t, e) {
12042
12059
  H instanceof HTMLElement && Q.push(I(H, E + 1));
12043
12060
  const et = [...F, ...Q], Ve = B.length > 0 || C || et.some((H) => H.hasUsefulContent), pe = ri(
12044
12061
  [B, ...et.map((H) => H.textPreview)].filter(Boolean).join(" ")
12045
- ).slice(0, 180), ve = x.hasAttribute("contenteditable") && (B.length > 0 || !x.querySelector("[contenteditable]")), Ie = c.some((H) => x.hasAttribute(H)) || !!z || ve, tt = (x.getClientRects().length > 0 || L.display === "contents") && (n.has(A) || Ie || P) && (Ve || P) && (!s.has(A) || Ve || Ie || P), W = tt ? 1 : 0, he = [];
12062
+ ).slice(0, 180), ve = x.hasAttribute("contenteditable") && (B.length > 0 || !x.querySelector("[contenteditable]")), Ie = c.some((H) => x.hasAttribute(H)) || !!z || ve, tt = (x.getClientRects().length > 0 || L.display === "contents") && (n.has(A) || Ie || M) && (Ve || M) && (!s.has(A) || Ve || Ie || M), W = tt ? 1 : 0, he = [];
12046
12063
  if (tt) {
12047
12064
  const H = et.some((be) => be.containsTextElement), ee = i.has(A) && !H ? pe : B;
12048
12065
  he.push(ku(x, l, a, ee.slice(0, 180)));
@@ -12069,16 +12086,16 @@ function by(t, e) {
12069
12086
  };
12070
12087
  return [`--- ${m} ---`, ...I(k, 0).lines].join(`
12071
12088
  `);
12072
- }, _ = [], S = ri(window.getSelection()?.toString() ?? "");
12073
- S && _.push(`--- selected text ---
12074
- ${JSON.stringify(S)}`), d.length > 0 && _.push(_y(d, n, l, a));
12089
+ }, w = [], S = ri(window.getSelection()?.toString() ?? "");
12090
+ S && w.push(`--- selected text ---
12091
+ ${JSON.stringify(S)}`), d.length > 0 && w.push(_y(d, n, l, a));
12075
12092
  for (const k of t.slice(0, 3))
12076
- _.push(b(k, "active overlay DOM", /* @__PURE__ */ new Set()));
12077
- if (e && _.push(b(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
12093
+ w.push(b(k, "active overlay DOM", /* @__PURE__ */ new Set()));
12094
+ if (e && w.push(b(e, "main DOM", /* @__PURE__ */ new Set())), document.body) {
12078
12095
  const k = e || t.length ? "other visible DOM" : "visible DOM";
12079
- _.push(b(document.body, k, p));
12096
+ w.push(b(document.body, k, p));
12080
12097
  }
12081
- return _.join(`
12098
+ return w.join(`
12082
12099
 
12083
12100
  `);
12084
12101
  }
@@ -13201,39 +13218,39 @@ function Nb(t, e, n, i) {
13201
13218
  const s = /* @__PURE__ */ new Map(), o = [], a = [];
13202
13219
  let r = 0, l = 0, c = 0, u = crypto.randomUUID(), d = i.getState();
13203
13220
  e.dataset.executionKey = d.activity?.executionKey ?? "";
13204
- let p = d.user?.id, f = null, y = "", g = "", b = "";
13205
- const _ = e.ownerDocument.defaultView;
13206
- let S, k, m = /* @__PURE__ */ new Map(), w = d.sessionId, I = d.selectionKey;
13221
+ let p = d.user?.id, g = null, y = "", f = "", b = "";
13222
+ const w = e.ownerDocument.defaultView;
13223
+ let S, k, m = /* @__PURE__ */ new Map(), _ = d.sessionId, I = d.selectionKey;
13207
13224
  const x = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map();
13208
- let A = null, L = null, P = null, z = 0, B = null, C = null, U = null;
13225
+ let A = null, L = null, M = null, z = 0, B = null, C = null, U = null;
13209
13226
  const X = () => JSON.stringify([
13210
13227
  d.sessionId,
13211
13228
  d.assistantDraftRespondsToUserMessageId,
13212
13229
  Array.from(e.querySelectorAll('[data-message-role="user"]')).slice(-1)[0]?.dataset.messageKey,
13213
13230
  Array.from(e.querySelectorAll('[data-message-role="user"]')).slice(-1)[0]?.dataset.entryKey
13214
13231
  ]), Z = (W) => {
13215
- const he = _.getComputedStyle(W);
13232
+ const he = w.getComputedStyle(W);
13216
13233
  return W.getClientRects().length > 0 && he.visibility !== "hidden" && he.opacity !== "0" && he.pointerEvents !== "none" && !W.matches(":disabled") && W.getAttribute("aria-disabled") !== "true" && !W.closest("[inert]");
13217
13234
  };
13218
13235
  function Me() {
13219
- L !== null && _.clearTimeout(L), L = null, P = null;
13236
+ L !== null && w.clearTimeout(L), L = null, M = null;
13220
13237
  }
13221
13238
  function _e(W = !1) {
13222
- Me(), C = null, U !== null && _.clearTimeout(U), U = null, S = void 0, k = void 0, m.clear(), E.clear(), A !== null && _.clearTimeout(A), A = null, W && x.clear();
13239
+ Me(), C = null, U !== null && w.clearTimeout(U), U = null, S = void 0, k = void 0, m.clear(), E.clear(), A !== null && w.clearTimeout(A), A = null, W && x.clear();
13223
13240
  }
13224
13241
  function qe() {
13225
13242
  if (Ks(e) !== "none") {
13226
13243
  _e(!0);
13227
13244
  return;
13228
13245
  }
13229
- const W = e.querySelector(".pluno-pa-widget__panel") ?? e, he = _.getComputedStyle(W);
13246
+ const W = e.querySelector(".pluno-pa-widget__panel") ?? e, he = w.getComputedStyle(W);
13230
13247
  if (d.isLoadingSession || e.ownerDocument.hidden || !W.getClientRects().length || he.visibility === "hidden" || he.display === "none" || he.opacity === "0") {
13231
13248
  _e();
13232
13249
  return;
13233
13250
  }
13234
13251
  const re = (O, $) => Array.from(e.querySelectorAll(O)).flatMap((Y) => Y.getAttribute($) ? [Y.getAttribute($)] : []), H = ".pluno-pa-widget__tool-group--active, .tool-group--active, .pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]", ee = [];
13235
13252
  for (const O of Array.from(e.querySelectorAll(`${H}, [data-message-role="user"]`))) {
13236
- const $ = _.getComputedStyle(O);
13253
+ const $ = w.getComputedStyle(O);
13237
13254
  !O.getClientRects().length || $.visibility === "hidden" || $.opacity === "0" || O.parentElement?.closest(H) || ee.push(O.dataset.messageRole === "user" ? "user" : "thinking");
13238
13255
  }
13239
13256
  let be = 0;
@@ -13249,11 +13266,11 @@ function Nb(t, e, n, i) {
13249
13266
  for (let Ge = 0; Ge < ke.length; Ge += 1)
13250
13267
  K = Math.imul(K ^ ke.charCodeAt(Ge), 16777619) >>> 0;
13251
13268
  }
13252
- const ue = _.performance.now();
13253
- K !== P && (P = K, z = ue), be = ue - z, L !== null && _.clearTimeout(L), L = be < 3e5 ? _.setTimeout(qe, 3e5 - be) : null;
13269
+ const ue = w.performance.now();
13270
+ K !== M && (M = K, z = ue), be = ue - z, L !== null && w.clearTimeout(L), L = be < 3e5 ? w.setTimeout(qe, 3e5 - be) : null;
13254
13271
  } else
13255
13272
  Me(), x.delete("thinking-without-progress");
13256
- const G = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((O) => O.getClientRects().length > 0 && _.getComputedStyle(O).visibility !== "hidden" && _.getComputedStyle(O).opacity !== "0"), Re = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || G;
13273
+ const G = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((O) => O.getClientRects().length > 0 && w.getComputedStyle(O).visibility !== "hidden" && w.getComputedStyle(O).opacity !== "0"), Re = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || G;
13257
13274
  (!Re || C && C.responseKey !== X()) && (C = null);
13258
13275
  const Oe = {
13259
13276
  executionKey: d.activity?.executionKey,
@@ -13263,7 +13280,7 @@ function Nb(t, e, n, i) {
13263
13280
  enabledStopControlCount: Array.from(e.querySelectorAll(
13264
13281
  'button[aria-label="Stop"], button[aria-label="Stop generating"]'
13265
13282
  )).filter(Z).length,
13266
- stopPendingMs: C ? _.performance.now() - C.at : 0,
13283
+ stopPendingMs: C ? w.performance.now() - C.at : 0,
13267
13284
  thinkingSequence: ee,
13268
13285
  thinkingIdleMs: be,
13269
13286
  messageKeys: Array.from(e.querySelectorAll("[data-message-key], [data-entry-key][data-message-role]")).flatMap((O) => O.dataset.messageKey ?? O.dataset.entryKey ?? []),
@@ -13286,7 +13303,7 @@ function Nb(t, e, n, i) {
13286
13303
  })
13287
13304
  } : void 0, le = Im(Oe, D), V = new Set(le.map((O) => O.code));
13288
13305
  for (const O of E.keys()) V.has(O) || E.delete(O);
13289
- const te = _.performance.now();
13306
+ const te = w.performance.now();
13290
13307
  for (const { code: O } of le) {
13291
13308
  if (x.has(O)) continue;
13292
13309
  const $ = E.get(O) ?? { monotonicMs: te, occurredAt: Date.now() };
@@ -13303,7 +13320,7 @@ function Nb(t, e, n, i) {
13303
13320
  } else
13304
13321
  E.set(O, $);
13305
13322
  }
13306
- le.length === 0 && q && (S = Oe, k = Fr(e, d, { renderSource: "observer" }), m = new Map(Array.from(e.querySelectorAll("[data-terminal-response-key][data-canonical-item-key]")).map((O) => [O.dataset.terminalResponseKey, O.dataset.canonicalItemKey]))), A !== null && _.clearTimeout(A), A = E.size ? _.setTimeout(() => {
13323
+ le.length === 0 && q && (S = Oe, k = Fr(e, d, { renderSource: "observer" }), m = new Map(Array.from(e.querySelectorAll("[data-terminal-response-key][data-canonical-item-key]")).map((O) => [O.dataset.terminalResponseKey, O.dataset.canonicalItemKey]))), A !== null && w.clearTimeout(A), A = E.size ? w.setTimeout(() => {
13307
13324
  A = null, qe();
13308
13325
  }, Math.max(1, 250 - (te - Math.min(...Array.from(E.values(), (O) => O.monotonicMs))))) : null;
13309
13326
  }
@@ -13331,7 +13348,7 @@ function Nb(t, e, n, i) {
13331
13348
  };
13332
13349
  if (W === "paint" && i.reportResponseVisibility) {
13333
13350
  const V = e.querySelector(".pluno-pa-widget__panel") ?? e, te = (ke) => {
13334
- const Ge = _.getComputedStyle(ke);
13351
+ const Ge = w.getComputedStyle(ke);
13335
13352
  return ke.getClientRects().length > 0 && Ge.visibility !== "hidden" && Ge.display !== "none" && Ge.opacity !== "0";
13336
13353
  }, O = te(V) && te(e), $ = !e.ownerDocument.hidden, Y = new Set(Array.from(e.querySelectorAll("[data-canonical-item-key]")).filter(te).map((ke) => ke.dataset.canonicalItemKey)), K = O && $ && !d.isLoadingSession ? [...d.messages].reverse().find((ke) => (ke.role === "assistant" || ke.dataType === "commentary_history" || ke.dataType === "tool_summary") && Y.has(ke.id)) : void 0, ue = O && $ && !d.isLoadingSession && !!d.assistantDraft.trim() && Array.from(e.querySelectorAll("[data-message-key], [data-entry-key]")).some((ke) => te(ke) && (ke.dataset.messageKey === `assistant:${d.assistantDraftItemId}` || ke.dataset.entryKey === d.assistantDraftItemId)), ne = {
13337
13354
  sessionId: d.sessionId,
@@ -13364,12 +13381,12 @@ function Nb(t, e, n, i) {
13364
13381
  }
13365
13382
  }
13366
13383
  const q = JSON.stringify(G);
13367
- if (W === "runtime" && q === y || W === "paint" && q === g) return;
13368
- W === "runtime" && (y = q), W === "paint" && (g = q);
13384
+ if (W === "runtime" && q === y || W === "paint" && q === f) return;
13385
+ W === "runtime" && (y = q), W === "paint" && (f = q);
13369
13386
  const D = {
13370
13387
  sequence: ++c,
13371
13388
  occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
13372
- monotonic_ms: Math.round(_.performance.now()),
13389
+ monotonic_ms: Math.round(w.performance.now()),
13373
13390
  kind: W,
13374
13391
  action: he,
13375
13392
  ...G
@@ -13378,12 +13395,12 @@ function Nb(t, e, n, i) {
13378
13395
  o.shift(), r -= a.shift(), l += 1;
13379
13396
  }
13380
13397
  function F() {
13381
- f === null && (f = _.requestAnimationFrame(() => {
13382
- f = null, Ae("paint"), qe();
13398
+ g === null && (g = w.requestAnimationFrame(() => {
13399
+ g = null, Ae("paint"), qe();
13383
13400
  }));
13384
13401
  }
13385
13402
  const Q = i.on("state", (W) => {
13386
- W.user?.id !== p || W.sessionId !== w || W.selectionKey !== I ? (_e(!0), w = W.sessionId, I = W.selectionKey) : W.isLoadingSession && _e(), W.user?.id !== p && (s.clear(), o.length = 0, a.length = 0, r = 0, l = 0, c = 0, u = crypto.randomUUID(), y = "", g = "", b = "", p = W.user?.id), d = W, e.dataset.executionKey = d.activity?.executionKey ?? "", Ae("runtime"), F();
13403
+ W.user?.id !== p || W.sessionId !== _ || W.selectionKey !== I ? (_e(!0), _ = W.sessionId, I = W.selectionKey) : W.isLoadingSession && _e(), W.user?.id !== p && (s.clear(), o.length = 0, a.length = 0, r = 0, l = 0, c = 0, u = crypto.randomUUID(), y = "", f = "", b = "", p = W.user?.id), d = W, e.dataset.executionKey = d.activity?.executionKey ?? "", Ae("runtime"), F();
13387
13404
  }), et = new MutationObserver(F);
13388
13405
  et.observe(e, {
13389
13406
  subtree: !0,
@@ -13394,7 +13411,7 @@ function Nb(t, e, n, i) {
13394
13411
  });
13395
13412
  const Ve = (W) => {
13396
13413
  const he = W.target?.closest?.("button"), re = he?.getAttribute("aria-label") ?? he?.getAttribute("title"), H = re === "New chat" ? "new_chat" : re === "Send" || re === "Send message" ? "send" : re === "Stop" || re === "Stop generating" ? "stop" : re === "Retry" || re === "Retry message" ? "retry" : null;
13397
- Ae("click", H), H === "stop" && he && Z(he) && (C = { at: _.performance.now(), responseKey: X() }, U !== null && _.clearTimeout(U), U = _.setTimeout(qe, 1e3)), H === "new_chat" && _e(!0);
13414
+ Ae("click", H), H === "stop" && he && Z(he) && (C = { at: w.performance.now(), responseKey: X() }, U !== null && w.clearTimeout(U), U = w.setTimeout(qe, 1e3)), H === "new_chat" && _e(!0);
13398
13415
  }, pe = () => Ae("submit"), ve = () => Ae("focus");
13399
13416
  e.addEventListener("click", Ve, !0), e.addEventListener("submit", pe, !0), e.addEventListener("focusin", ve, !0), e.addEventListener("input", F, !0);
13400
13417
  const Ie = () => {
@@ -13411,7 +13428,7 @@ function Nb(t, e, n, i) {
13411
13428
  records: o.map((W) => ({ ...W, item_keys: [...W.item_keys] }))
13412
13429
  }),
13413
13430
  dispose: () => {
13414
- Q(), et.disconnect(), _e(!0), f !== null && _.cancelAnimationFrame(f), e.removeEventListener("click", Ve, !0), e.removeEventListener("submit", pe, !0), e.removeEventListener("focusin", ve, !0), e.removeEventListener("input", F, !0), e.ownerDocument.removeEventListener("visibilitychange", Ie), t.__plunoUiFlightRecorder === tt && delete t.__plunoUiFlightRecorder;
13431
+ Q(), et.disconnect(), _e(!0), g !== null && w.cancelAnimationFrame(g), e.removeEventListener("click", Ve, !0), e.removeEventListener("submit", pe, !0), e.removeEventListener("focusin", ve, !0), e.removeEventListener("input", F, !0), e.ownerDocument.removeEventListener("visibilitychange", Ie), t.__plunoUiFlightRecorder === tt && delete t.__plunoUiFlightRecorder;
13415
13432
  }
13416
13433
  };
13417
13434
  return t.__plunoUiFlightRecorder = tt, Ae("runtime"), F(), tt;
@@ -13577,7 +13594,7 @@ async function mw(t = {}) {
13577
13594
  ), l.appendChild(c);
13578
13595
  const d = V_(e), p = e.layout === "floating" ? e.initialDisplayState ?? K_(e) : "shown";
13579
13596
  Cd(e, p);
13580
- let f = e.movableLauncher ? d.launcherPosition : null, y = f !== null, g = d.panelSize, b = null;
13597
+ let g = e.movableLauncher ? d.launcherPosition : null, y = g !== null, f = d.panelSize, b = null;
13581
13598
  c.style.setProperty(
13582
13599
  "--pluno-pa-mobile-panel-top-offset",
13583
13600
  `${e.mobilePanelTopOffset}px`
@@ -13585,11 +13602,11 @@ async function mw(t = {}) {
13585
13602
  c,
13586
13603
  Pr(
13587
13604
  c,
13588
- f,
13605
+ g,
13589
13606
  e.position
13590
13607
  )
13591
13608
  )), Ed(l, e.accentColor);
13592
- let _ = JSON.stringify([
13609
+ let w = JSON.stringify([
13593
13610
  e.accentColor,
13594
13611
  e.colorScheme,
13595
13612
  e.fontFamily,
@@ -13603,7 +13620,7 @@ async function mw(t = {}) {
13603
13620
  });
13604
13621
  const S = e.mountTarget ?? await H_(), k = S.ownerDocument, m = c.querySelector(
13605
13622
  ".pluno-pa-widget__launcher"
13606
- ), w = c.querySelector(
13623
+ ), _ = c.querySelector(
13607
13624
  ".pluno-pa-widget__launcher-drag-handle"
13608
13625
  ), I = c.querySelector(
13609
13626
  ".pluno-pa-widget__launcher-input"
@@ -13613,7 +13630,7 @@ async function mw(t = {}) {
13613
13630
  ".pluno-pa-widget__launcher-minimize"
13614
13631
  ), A = c.querySelector(".pluno-pa-widget__panel"), L = c.querySelector(
13615
13632
  ".pluno-pa-widget__panel-drag-handle"
13616
- ), P = c.querySelector(
13633
+ ), M = c.querySelector(
13617
13634
  ".pluno-pa-widget__scribble-spirals--panel"
13618
13635
  ), z = Array.from(
13619
13636
  c.querySelectorAll(".pluno-pa-widget__resize-handle")
@@ -13710,7 +13727,7 @@ async function mw(t = {}) {
13710
13727
  );
13711
13728
  if (!m || !I || !A || !B || !C || !U || !X || !_e || !qe || !Ae || !F || !Q || !et || !pe || !ve || !Ie || !tt || !W || !he || !re || !H || !ee || !be || !G || !Re)
13712
13729
  throw new Error("Failed to mount Pluno widget");
13713
- if (e.movableLauncher && !w)
13730
+ if (e.movableLauncher && !_)
13714
13731
  throw new Error("Failed to mount Pluno widget drag handle");
13715
13732
  if (e.movableLauncher && !L)
13716
13733
  throw new Error("Failed to mount Pluno widget panel drag handle");
@@ -13730,7 +13747,7 @@ async function mw(t = {}) {
13730
13747
  }, ct = () => {
13731
13748
  if (!q || !D || !Y || !K || !ue || !ne || !zt)
13732
13749
  return;
13733
- const h = e.proactiveSuggestion ?? Ge, v = M.getState(), R = h !== null && !Wn && !v.sessionId && !v.isThinking && !v.pendingMessageStatus, T = A.querySelector(
13750
+ const h = e.proactiveSuggestion ?? Ge, v = P.getState(), R = h !== null && !Wn && !v.sessionId && !v.isThinking && !v.pendingMessageStatus, T = A.querySelector(
13734
13751
  ".pluno-pa-widget__proactive-suggestion-slot"
13735
13752
  ), j = !A.hidden && !c.classList.contains("pluno-pa-widget--closing"), ie = R && j && T !== null;
13736
13753
  ie ? q.parentElement !== T && T.appendChild(q) : q.parentElement !== c && c.insertBefore(q, B), q.hidden = !R, c.classList.toggle("pluno-pa-widget--proactive-suggestion", R), c.classList.toggle(
@@ -13791,8 +13808,8 @@ async function mw(t = {}) {
13791
13808
  panelOpen: c.classList.contains("pluno-pa-widget--open"),
13792
13809
  displayState: c.classList.contains("pluno-pa-widget--minimized") ? "minimized" : c.classList.contains("pluno-pa-widget--open") ? "open" : "collapsed",
13793
13810
  sdkPreview: e.extensionRuntime !== void 0,
13794
- hasSession: !!M.getState().sessionId,
13795
- isThinking: M.getState().isThinking
13811
+ hasSession: !!P.getState().sessionId,
13812
+ isThinking: P.getState().isThinking
13796
13813
  }
13797
13814
  ), !j && ie === h;
13798
13815
  }, tn = (h) => !F.isConnected || F.disabled || F.readOnly || !c.classList.contains("pluno-pa-widget--open") || e.loginRequired || e.signupRequired || Yn(e.billingStatus) ? !1 : _n(F, h, {
@@ -13805,7 +13822,7 @@ async function mw(t = {}) {
13805
13822
  (h) => {
13806
13823
  Zt++, lt = lt.filter(
13807
13824
  (v, R) => R !== h
13808
- ), di(), xe(M.getState()), De(), tn("remove_attachment");
13825
+ ), di(), xe(P.getState()), De(), tn("remove_attachment");
13809
13826
  }
13810
13827
  );
13811
13828
  }, ac = e.loginRequired || e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (e.tokenEndpoint ? async (h) => Y_(
@@ -13815,10 +13832,10 @@ async function mw(t = {}) {
13815
13832
  if (!e.loginRequired && !e.signupRequired && !e.token && !ac && !e.webSocketFactory && !e.runtimeClient)
13816
13833
  throw new Error("Pluno widget requires token or tokenEndpoint");
13817
13834
  const cc = e.runtimeClient === void 0, _o = cc ? W_(e.clientId) : null;
13818
- let M;
13835
+ let P;
13819
13836
  try {
13820
13837
  if (e.runtimeClient)
13821
- M = e.runtimeClient;
13838
+ P = e.runtimeClient;
13822
13839
  else {
13823
13840
  const h = {
13824
13841
  token: e.token,
@@ -13828,7 +13845,7 @@ async function mw(t = {}) {
13828
13845
  model: e.model,
13829
13846
  metadata: () => ({
13830
13847
  ...typeof e.metadata == "function" ? e.metadata() : e.metadata ?? {},
13831
- ...!M.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
13848
+ ...!P.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
13832
13849
  }),
13833
13850
  entrySurface: e.entrySurface ?? (e.extensionRuntime ? "extension_widget" : "embedded_widget"),
13834
13851
  initialStarterPrompts: e.initialStarterPrompts,
@@ -13856,13 +13873,13 @@ async function mw(t = {}) {
13856
13873
  const T = dp().find((j) => j.id === (R.platform ?? "linkedin"));
13857
13874
  window.open(T.href, "_blank", "noopener,noreferrer");
13858
13875
  } else if (R.kind === "run") {
13859
- const T = M.getInteractions().find((ie) => ie.id === R.interactionId)?.kind === "proactive_suggestion";
13860
- if (!await M.sendMessage(T ? "Yes" : R.text, {
13876
+ const T = P.getInteractions().find((ie) => ie.id === R.interactionId)?.kind === "proactive_suggestion";
13877
+ if (!await P.sendMessage(T ? "Yes" : R.text, {
13861
13878
  clientMessageId: R.submissionId,
13862
13879
  ...T ? { proactiveSuggestionQuestion: R.text } : {}
13863
13880
  })) throw Object.assign(new Error("The task was not submitted."), { code: "interaction_not_started" });
13864
13881
  } else if (R.kind === "edit")
13865
- Zi = e.proactiveSuggestion, Wn = !0, M.stageProactiveSuggestionQuestion(R.text), Mt("Yes, but ", !0, !0, !0, "proactive_suggestion");
13882
+ Zi = e.proactiveSuggestion, Wn = !0, P.stageProactiveSuggestionQuestion(R.text), Mt("Yes, but ", !0, !0, !0, "proactive_suggestion");
13866
13883
  else throw new Error("The requested platform action is unavailable.");
13867
13884
  } },
13868
13885
  activeUsersLoader: e.activeUsersLoader,
@@ -13874,12 +13891,12 @@ async function mw(t = {}) {
13874
13891
  // cross-tab collision timer because a host-page startup long task can stretch that timer into seconds.
13875
13892
  skipStoredTransportIdentityCollisionCheck: e.extensionRuntime !== void 0
13876
13893
  };
13877
- M = await yb.init(h);
13894
+ P = await yb.init(h);
13878
13895
  }
13879
13896
  } catch (h) {
13880
13897
  throw _o?.release(), r.remove(), h;
13881
13898
  }
13882
- let ui = M.getState().sessionId, pi = M.getState().selectionKey, hi = M.getState().user?.id ?? null, Pt = Fs.find(
13899
+ let ui = P.getState().sessionId, pi = P.getState().selectionKey, hi = P.getState().user?.id ?? null, Pt = Fs.find(
13883
13900
  (h) => h.value === e.model
13884
13901
  )?.value ?? Zs[0].value, gi = !1;
13885
13902
  const lc = e.productVariant === "personal" && e.onModelChange !== void 0;
@@ -13892,7 +13909,7 @@ async function mw(t = {}) {
13892
13909
  R.classList.toggle("is-selected", T), R.setAttribute("aria-selected", String(T)), R.disabled = v;
13893
13910
  }
13894
13911
  }, bp = (h) => {
13895
- Pt = h, M.setModel(h), Vn();
13912
+ Pt = h, P.setModel(h), Vn();
13896
13913
  };
13897
13914
  Vn(), Q.addEventListener("toggle", () => {
13898
13915
  Q.open && gi && (Q.open = !1), Q.open || Q.querySelector(".pluno-pa-widget__model-more")?.removeAttribute("open");
@@ -13904,7 +13921,7 @@ async function mw(t = {}) {
13904
13921
  for (const h of Ve)
13905
13922
  h.addEventListener("click", () => {
13906
13923
  const v = Fs.find((T) => T.value === h.dataset.model);
13907
- if (!v || v.value === Pt && M.getModel() === v.value || gi) {
13924
+ if (!v || v.value === Pt && P.getModel() === v.value || gi) {
13908
13925
  Q.open = !1;
13909
13926
  return;
13910
13927
  }
@@ -13938,9 +13955,9 @@ async function mw(t = {}) {
13938
13955
  guardCreatedAt: we?.createdAt ?? null,
13939
13956
  selectionFencePending: pc(h)
13940
13957
  }), is = /* @__PURE__ */ new Set();
13941
- let mi = "", $e = !1, dt = null, gc = location.origin, fc = M.getState().sessionId, mc = M.getState().user?.id ?? null, So = M.getState().status, Ft = () => {
13942
- }, ko = "", Je = M.getSessionHistoryState();
13943
- const wp = M.subscribeSessionHistory((h) => {
13958
+ let mi = "", $e = !1, dt = null, gc = location.origin, fc = P.getState().sessionId, mc = P.getState().user?.id ?? null, So = P.getState().status, Ft = () => {
13959
+ }, ko = "", Je = P.getSessionHistoryState();
13960
+ const wp = P.subscribeSessionHistory((h) => {
13944
13961
  Je = h, Ne || Ft();
13945
13962
  }), ut = (h, v) => {
13946
13963
  jt = { enabled: h, reason: v };
@@ -13948,11 +13965,11 @@ async function mw(t = {}) {
13948
13965
  ee.hidden = !0;
13949
13966
  }, xo = (h, v, R) => {
13950
13967
  const T = `${h}:${v ?? "current-view"}`;
13951
- is.has(T) || (is.add(T), M.reportInvalidStateTransition?.(h, v, R));
13968
+ is.has(T) || (is.add(T), P.reportInvalidStateTransition?.(h, v, R));
13952
13969
  }, _p = () => {
13953
13970
  Wh(fi, xo), ee.hidden = !1;
13954
13971
  }, yc = () => {
13955
- we?.observedConversation && G.querySelector(".pluno-pa-widget__empty-state--starter:not(.pluno-pa-widget__empty-state--morning-report)") && (we.observedWelcome ??= hc(M.getState())), we?.observedWelcome && !we.pendingSubmission && (xo("submitted_turn_returned_to_welcome_without_new_chat", we.clientMessageId, {
13972
+ we?.observedConversation && G.querySelector(".pluno-pa-widget__empty-state--starter:not(.pluno-pa-widget__empty-state--morning-report)") && (we.observedWelcome ??= hc(P.getState())), we?.observedWelcome && !we.pendingSubmission && (xo("submitted_turn_returned_to_welcome_without_new_chat", we.clientMessageId, {
13956
13973
  before: we.observedConversation,
13957
13974
  current: we.observedWelcome
13958
13975
  }), we = null);
@@ -13972,7 +13989,7 @@ async function mw(t = {}) {
13972
13989
  const R = JSON.stringify([
13973
13990
  Je.status,
13974
13991
  h,
13975
- M.getState().sessionId,
13992
+ P.getState().sessionId,
13976
13993
  h.map((T) => md(T.lastActiveAt, Date.now()))
13977
13994
  ]);
13978
13995
  if (R !== ko) {
@@ -13986,7 +14003,7 @@ async function mw(t = {}) {
13986
14003
  for (const T of h) {
13987
14004
  const j = document.createElement("button");
13988
14005
  j.type = "button", j.className = "pluno-pa-widget__history-item";
13989
- const ie = T.id === M.getState().sessionId;
14006
+ const ie = T.id === P.getState().sessionId;
13990
14007
  j.disabled = ie, ie && j.setAttribute("aria-current", "page");
13991
14008
  const se = document.createElement("span");
13992
14009
  se.className = "pluno-pa-widget__history-item-title", se.textContent = fd(T), j.setAttribute("aria-label", fd(T));
@@ -13997,7 +14014,7 @@ async function mw(t = {}) {
13997
14014
  );
13998
14015
  const xt = document.createElement("small");
13999
14016
  xt.className = "pluno-pa-widget__history-path", xt.textContent = Dw(T), j.append(se, ge, xt), j.addEventListener("click", () => {
14000
- $e = !1, Ft(), we = null, fi = !1, is.clear(), ut(!0, "newSession"), St(), M.loadSession(T.id), vi = null, xe(M.getState()), tn("history_session_selected");
14017
+ $e = !1, Ft(), we = null, fi = !1, is.clear(), ut(!0, "newSession"), St(), P.loadSession(T.id), vi = null, xe(P.getState()), tn("history_session_selected");
14001
14018
  }), W.appendChild(j);
14002
14019
  }
14003
14020
  if (v && h.length > 0) {
@@ -14008,8 +14025,8 @@ async function mw(t = {}) {
14008
14025
  }
14009
14026
  };
14010
14027
  const Eo = (h = !1) => {
14011
- if (dt !== null && (window.clearTimeout(dt), dt = null), !(e.layout === "page" || e.loginRequired || e.signupRequired || ke || !h && M.getState().status !== "connected"))
14012
- return ke = !0, M.refreshSessionHistory().catch(() => {
14028
+ if (dt !== null && (window.clearTimeout(dt), dt = null), !(e.layout === "page" || e.loginRequired || e.signupRequired || ke || !h && P.getState().status !== "connected"))
14029
+ return ke = !0, P.refreshSessionHistory().catch(() => {
14013
14030
  }).finally(() => {
14014
14031
  ke = !1;
14015
14032
  });
@@ -14025,7 +14042,7 @@ async function mw(t = {}) {
14025
14042
  }, 0));
14026
14043
  }, Ip = () => {
14027
14044
  const h = Je.data?.nextCursor ?? null;
14028
- Je.status === "loading_more" || !h || W.scrollHeight - W.scrollTop - W.clientHeight <= 24 && M.loadMoreSessionHistory();
14045
+ Je.status === "loading_more" || !h || W.scrollHeight - W.scrollTop - W.clientHeight <= 24 && P.loadMoreSessionHistory();
14029
14046
  }, bc = () => {
14030
14047
  Ne || typeof document > "u" || (Ed(l, e.accentColor), r.isConnected || (e.mountTarget?.isConnected ? e.mountTarget.appendChild(r) : e.mountTarget || k.body?.appendChild(r)));
14031
14048
  }, wc = new MutationObserver(bc);
@@ -14037,7 +14054,7 @@ async function mw(t = {}) {
14037
14054
  const v = Ji(c, h);
14038
14055
  return $s(
14039
14056
  c,
14040
- f ? Hs(f, v) : kw(
14057
+ g ? Hs(g, v) : kw(
14041
14058
  c,
14042
14059
  e.position,
14043
14060
  v
@@ -14049,8 +14066,8 @@ async function mw(t = {}) {
14049
14066
  isOpen: c.classList.contains("pluno-pa-widget--open"),
14050
14067
  composerValue: F.value,
14051
14068
  openToolGroupKeys: [...vo],
14052
- launcherPosition: y ? f : null,
14053
- panelSize: g
14069
+ launcherPosition: y ? g : null,
14070
+ panelSize: f
14054
14071
  });
14055
14072
  }, os = (h, v) => {
14056
14073
  e.onDisplayStateChange?.(h, v);
@@ -14064,14 +14081,14 @@ async function mw(t = {}) {
14064
14081
  c,
14065
14082
  Pr(
14066
14083
  c,
14067
- f,
14084
+ g,
14068
14085
  e.position
14069
14086
  )
14070
- ), hd(c), Qe(), !T && e.layout === "floating" && M.recordWidgetLifecycle("minimized", R), v && os("minimized", R);
14087
+ ), hd(c), Qe(), !T && e.layout === "floating" && P.recordWidgetLifecycle("minimized", R), v && os("minimized", R);
14071
14088
  }, Sn = (h, v = {}) => {
14072
14089
  qw(h, {
14073
14090
  debugVersion: hw,
14074
- launcherPosition: f,
14091
+ launcherPosition: g,
14075
14092
  rootClasses: c.className,
14076
14093
  rootStyle: {
14077
14094
  left: c.style.left,
@@ -14088,7 +14105,7 @@ async function mw(t = {}) {
14088
14105
  ...v
14089
14106
  });
14090
14107
  }, wi = (h = !0) => {
14091
- if (!f) {
14108
+ if (!g) {
14092
14109
  pn(c, null);
14093
14110
  const R = yi(h);
14094
14111
  return es(), R;
@@ -14107,7 +14124,7 @@ async function mw(t = {}) {
14107
14124
  y: h.y - v.y
14108
14125
  });
14109
14126
  }, Ao = () => {
14110
- const h = Nn(g).width;
14127
+ const h = Nn(f).width;
14111
14128
  return A.getBoundingClientRect().width || h;
14112
14129
  }, _c = () => {
14113
14130
  if (c.classList.contains("pluno-pa-widget--minimized")) {
@@ -14115,7 +14132,7 @@ async function mw(t = {}) {
14115
14132
  c,
14116
14133
  Pr(
14117
14134
  c,
14118
- f,
14135
+ g,
14119
14136
  e.position
14120
14137
  )
14121
14138
  );
@@ -14123,10 +14140,10 @@ async function mw(t = {}) {
14123
14140
  }
14124
14141
  const h = wi();
14125
14142
  if (c.classList.contains("pluno-pa-widget--open") || c.classList.contains("pluno-pa-widget--closing")) {
14126
- qr(c, g);
14127
- const v = Nn(g);
14143
+ qr(c, f);
14144
+ const v = Nn(f);
14128
14145
  Lr(
14129
- P,
14146
+ M,
14130
14147
  Ao()
14131
14148
  );
14132
14149
  const R = Ki(
@@ -14134,7 +14151,7 @@ async function mw(t = {}) {
14134
14151
  c,
14135
14152
  h,
14136
14153
  e.position,
14137
- g
14154
+ f
14138
14155
  ),
14139
14156
  v
14140
14157
  );
@@ -14142,17 +14159,17 @@ async function mw(t = {}) {
14142
14159
  "Applied open panel position after viewport resize",
14143
14160
  { openPanelPosition: R }
14144
14161
  );
14145
- } else f && Sn(
14162
+ } else g && Sn(
14146
14163
  "Applied visible launcher position after viewport resize",
14147
14164
  { visibleLauncherPosition: h }
14148
14165
  );
14149
14166
  };
14150
14167
  let vc = () => {
14151
14168
  };
14152
- window.addEventListener("resize", _c), e.movableLauncher && w ? (wi(), vc = _w({
14169
+ window.addEventListener("resize", _c), e.movableLauncher && _ ? (wi(), vc = _w({
14153
14170
  root: c,
14154
14171
  launcher: m,
14155
- launcherDragHandle: w,
14172
+ launcherDragHandle: _,
14156
14173
  getPosition: () => yi(),
14157
14174
  setPosition: (h) => {
14158
14175
  const v = h, R = Ji(c), T = $s(
@@ -14160,7 +14177,7 @@ async function mw(t = {}) {
14160
14177
  h,
14161
14178
  R
14162
14179
  );
14163
- f = Mr(
14180
+ g = Mr(
14164
14181
  T,
14165
14182
  R
14166
14183
  ), b = null, pn(c, T), es(), Sn("Dragging closed launcher", {
@@ -14170,38 +14187,38 @@ async function mw(t = {}) {
14170
14187
  persist: () => {
14171
14188
  y = !0, Qe(), Sn("Persisted closed launcher drag position");
14172
14189
  }
14173
- })) : pn(c, null), qr(c, g);
14190
+ })) : pn(c, null), qr(c, f);
14174
14191
  const Ic = () => {
14175
- const h = Nn(g), v = yi();
14192
+ const h = Nn(f), v = yi();
14176
14193
  return {
14177
14194
  position: Ki(
14178
14195
  b ? Hs(b, h) : Or(
14179
14196
  c,
14180
14197
  v,
14181
14198
  e.position,
14182
- g
14199
+ f
14183
14200
  ),
14184
14201
  h
14185
14202
  ),
14186
14203
  size: h
14187
14204
  };
14188
14205
  }, Sp = (h) => {
14189
- g = go(h.size), qr(c, g), Lr(
14190
- P,
14206
+ f = go(h.size), qr(c, f), Lr(
14207
+ M,
14191
14208
  Ao()
14192
14209
  );
14193
14210
  const v = Ki(
14194
14211
  h.position,
14195
- Nn(g)
14212
+ Nn(f)
14196
14213
  );
14197
14214
  b = Mr(
14198
14215
  v,
14199
- Nn(g)
14216
+ Nn(f)
14200
14217
  );
14201
14218
  const R = yi();
14202
14219
  rs(v, R);
14203
14220
  }, kp = (h) => {
14204
- const v = Nn(g), R = Ki(
14221
+ const v = Nn(f), R = Ki(
14205
14222
  h,
14206
14223
  v
14207
14224
  ), T = Ji(c), j = $s(
@@ -14214,7 +14231,7 @@ async function mw(t = {}) {
14214
14231
  ),
14215
14232
  T
14216
14233
  );
14217
- f = Mr(
14234
+ g = Mr(
14218
14235
  j,
14219
14236
  T
14220
14237
  ), y = !0, b = null, pn(c, j), rs(R, j);
@@ -14242,13 +14259,13 @@ async function mw(t = {}) {
14242
14259
  xn.append(Sc, kc), _i.append("Pluno could not load your account. Try again.", xn), Me.after(kn);
14243
14260
  let Ro = !1, En = !1;
14244
14261
  const To = () => {
14245
- const h = M.getState().status === "error" && ["unauthorized", "invalid_token", "update_required"].includes(M.getState().lastErrorCode ?? ""), v = !!e.billingStatus && e.billingStatus?.submissionGate?.reason !== "connection_required";
14246
- kn.hidden = h || M.getState().status !== "connected" || !Ro || v || e.productVariant !== "personal" || i(), kn.hidden ? _i.remove() : _i.parentElement !== kn && kn.append(_i), xn.disabled = En, xn.setAttribute("aria-busy", String(En)), Sc.hidden = !En, kc.data = En ? "Trying" : "Try again";
14262
+ const h = P.getState().status === "error" && ["unauthorized", "invalid_token", "update_required"].includes(P.getState().lastErrorCode ?? ""), v = !!e.billingStatus && e.billingStatus?.submissionGate?.reason !== "connection_required";
14263
+ kn.hidden = h || P.getState().status !== "connected" || !Ro || v || e.productVariant !== "personal" || i(), kn.hidden ? _i.remove() : _i.parentElement !== kn && kn.append(_i), xn.disabled = En, xn.setAttribute("aria-busy", String(En)), Sc.hidden = !En, kc.data = En ? "Trying" : "Try again";
14247
14264
  }, qo = async () => {
14248
14265
  if (!(En || Ne)) {
14249
14266
  En = !0, To();
14250
14267
  try {
14251
- await M.refreshAccount(), Ro = !1;
14268
+ await P.refreshAccount(), Ro = !1;
14252
14269
  } catch (h) {
14253
14270
  Ro = !0, ot(
14254
14271
  "web-sdk.widget",
@@ -14268,7 +14285,7 @@ async function mw(t = {}) {
14268
14285
  if (i())
14269
14286
  return;
14270
14287
  const v = Date.now(), R = window.location.href;
14271
- h === "composer_input" && vi?.scope === R && v - vi.requestedAt < Ub || (h === "composer_input" && (vi = { scope: R, requestedAt: v }), Promise.resolve(M.warmup(h)).catch((T) => {
14288
+ h === "composer_input" && vi?.scope === R && v - vi.requestedAt < Ub || (h === "composer_input" && (vi = { scope: R, requestedAt: v }), Promise.resolve(P.warmup(h)).catch((T) => {
14272
14289
  ot(
14273
14290
  "web-sdk.widget",
14274
14291
  "Failed to warm Product Agent sandbox",
@@ -14278,19 +14295,19 @@ async function mw(t = {}) {
14278
14295
  }, Mt = (h = "", v = !0, R = !0, T = !0, j = "external_request") => {
14279
14296
  const ie = c.classList.contains("pluno-pa-widget--open") || !A.hidden && !c.classList.contains("pluno-pa-widget--closing");
14280
14297
  !ie && T && xc("panel_open"), qo(), ki && (ki = !1, No()), c.classList.contains("pluno-pa-widget--open") || (b = null), It !== null && (window.clearTimeout(It), It = null), bi("shown", !1), A.hidden = !1, B.hidden = !1, Lr(
14281
- P,
14298
+ M,
14282
14299
  Ao()
14283
14300
  ), c.classList.remove("pluno-pa-widget--closing"), ct();
14284
14301
  const se = wi(), ge = Or(
14285
14302
  c,
14286
14303
  se,
14287
14304
  e.position,
14288
- g
14305
+ f
14289
14306
  );
14290
14307
  if (rs(ge, se), Sn("Opening launcher at clamped open panel position", {
14291
14308
  openPanelPosition: ge,
14292
14309
  visibleLauncherPosition: se
14293
- }), ut(!0, "open"), St(), !ie && e.layout === "floating" && M.recordWidgetLifecycle("opened", j), !v) {
14310
+ }), ut(!0, "open"), St(), !ie && e.layout === "floating" && P.recordWidgetLifecycle("opened", j), !v) {
14294
14311
  c.classList.add("pluno-pa-widget--open"), ie || Co(), m.hidden = !0, h && (F.value = h, Bi(F)), Zn(G, () => jt.enabled), on = G.scrollTop, R && (_n(F, "panel_open_immediate"), F.setSelectionRange(F.value.length, F.value.length)), Qe(), os("shown", j), e.onPanelOpenChange?.(!0, j);
14295
14312
  return;
14296
14313
  }
@@ -14304,16 +14321,16 @@ async function mw(t = {}) {
14304
14321
  });
14305
14322
  }, Po = (h = "external_request") => {
14306
14323
  const v = c.classList.contains("pluno-pa-widget--open") || !A.hidden && !c.classList.contains("pluno-pa-widget--closing");
14307
- It !== null && (window.clearTimeout(It), It = null), m.hidden = !1, f && (wi(!1), Sn("Closing launcher at stored position")), c.classList.remove("pluno-pa-widget--open"), c.classList.add("pluno-pa-widget--closing"), ct(), Qe(), v && e.layout === "floating" && M.recordWidgetLifecycle("closed", h), e.onPanelOpenChange?.(!1, h), It = window.setTimeout(() => {
14324
+ It !== null && (window.clearTimeout(It), It = null), m.hidden = !1, g && (wi(!1), Sn("Closing launcher at stored position")), c.classList.remove("pluno-pa-widget--open"), c.classList.add("pluno-pa-widget--closing"), ct(), Qe(), v && e.layout === "floating" && P.recordWidgetLifecycle("closed", h), e.onPanelOpenChange?.(!1, h), It = window.setTimeout(() => {
14308
14325
  A.hidden = !0, B.hidden = !0, b = null, c.classList.remove("pluno-pa-widget--closing");
14309
14326
  }, 220);
14310
14327
  };
14311
14328
  m.addEventListener("submit", (h) => {
14312
14329
  h.preventDefault(), Mt(I.value, !0, !0, !0, "launcher_input"), I.value = "";
14313
- }), w?.addEventListener("click", (h) => {
14330
+ }), _?.addEventListener("click", (h) => {
14314
14331
  h.preventDefault(), h.stopPropagation();
14315
14332
  }), m.addEventListener("click", (h) => {
14316
- h.target === I && !w || (Mt(I.value, !0, !0, !0, "launcher_click"), I.value = "");
14333
+ h.target === I && !_ || (Mt(I.value, !0, !0, !0, "launcher_click"), I.value = "");
14317
14334
  });
14318
14335
  const Ec = () => {
14319
14336
  Mt(I.value, !0, !0, !0, "launcher_focus"), I.value = "";
@@ -14485,22 +14502,22 @@ async function mw(t = {}) {
14485
14502
  G.style.paddingBottom = `${h > 0 ? h + 24 : 12}px`, jt.enabled && Zn(G, () => jt.enabled);
14486
14503
  });
14487
14504
  qc?.observe(Tc);
14488
- let $t = null, ki = !1, ds = M.getState().status === "connected";
14505
+ let $t = null, ki = !1, ds = P.getState().status === "connected";
14489
14506
  const xi = () => {
14490
- const h = M.getState().status;
14491
- return !ds && M.getState().lastErrorCode !== "connection_failed" && (h === "idle" || h === "connecting" || h === "reconnecting");
14492
- }, Pc = () => M.getState().status !== "connected", An = () => {
14507
+ const h = P.getState().status;
14508
+ return !ds && P.getState().lastErrorCode !== "connection_failed" && (h === "idle" || h === "connecting" || h === "reconnecting");
14509
+ }, Pc = () => P.getState().status !== "connected", An = () => {
14493
14510
  if (e.productVariant !== "personal") return Pc();
14494
14511
  const h = e.billingStatus?.auth;
14495
14512
  return !h?.user || !h.workspace || i();
14496
14513
  }, Lo = () => {
14497
- const h = M.getState().status;
14514
+ const h = P.getState().status;
14498
14515
  return xi() ? !1 : h !== "connected" && !(ds && h === "reconnecting");
14499
14516
  }, Gn = () => {
14500
- const h = i(), v = M.getState(), R = !v.isThinking && !v.pendingMessageStatus && !!v.lastError;
14517
+ const h = i(), v = P.getState(), R = !v.isThinking && !v.pendingMessageStatus && !!v.lastError;
14501
14518
  I.readOnly = !1, F.readOnly = !1, I.placeholder = h ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : R ? "Needs attention" : ki ? "New update" : e.launcherLabel, F.placeholder = h ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : Wt.launcherLabel, C.hidden = h;
14502
14519
  }, us = () => [...qt.values()].some((h) => h.revision === Zt && h.generation === vt), Mc = () => {
14503
- const h = M.getState(), v = e.billingStatus;
14520
+ const h = P.getState(), v = e.billingStatus;
14504
14521
  return {
14505
14522
  submissionAllowed: v?.submissionGate?.allowed === !0,
14506
14523
  isAuthenticated: !!v?.auth?.user,
@@ -14513,7 +14530,7 @@ async function mw(t = {}) {
14513
14530
  hasPendingMessage: !1
14514
14531
  };
14515
14532
  }, Rn = () => e.productVariant === "personal" ? xi() && !i() && !us() && e.billingStatus?.submissionGate?.allowed === !0 || tl(Mc()) : !Lo() && !Yn(e.billingStatus) && !us(), Oc = () => {
14516
- const h = M.getState(), v = !xi() && [...qt.values()].some((R) => R.revision === Zt && R.generation === vt);
14533
+ const h = P.getState(), v = !xi() && [...qt.values()].some((R) => R.revision === Zt && R.generation === vt);
14517
14534
  return oh({
14518
14535
  hasRunningAssistantTurn: v || h.isThinking || h.turnPhase !== null || h.pendingMessageStatus !== null,
14519
14536
  // Retained text already submitted by this revision must not hide Stop behind a disabled Send.
@@ -14529,7 +14546,7 @@ async function mw(t = {}) {
14529
14546
  };
14530
14547
  Gn();
14531
14548
  const No = () => {
14532
- const h = M.getState(), v = h.isThinking, R = h.turnPhase !== null, T = h.turnPhase === "sending", j = x?.lastElementChild;
14549
+ const h = P.getState(), v = h.isThinking, R = h.turnPhase !== null, T = h.turnPhase === "sending", j = x?.lastElementChild;
14533
14550
  j && (j.textContent = "Working..."), c.classList.toggle("pluno-pa-widget--thinking", v), c.classList.toggle("pluno-pa-widget--sending", T), c.classList.toggle(
14534
14551
  "pluno-pa-widget--unread",
14535
14552
  !R && (ki || !!h.lastError)
@@ -14538,7 +14555,7 @@ async function mw(t = {}) {
14538
14555
  No();
14539
14556
  const Uo = () => {
14540
14557
  if (!(i() || Ne))
14541
- return Gn(), De(), M.connect().then(
14558
+ return Gn(), De(), P.connect().then(
14542
14559
  () => {
14543
14560
  Ne || (Gn(), De());
14544
14561
  },
@@ -14564,7 +14581,7 @@ async function mw(t = {}) {
14564
14581
  }, Dc = (h) => {
14565
14582
  const v = vt, R = Wn ? Zi : null;
14566
14583
  Pw(
14567
- M,
14584
+ P,
14568
14585
  h.value,
14569
14586
  h.attachments,
14570
14587
  R?.question,
@@ -14572,17 +14589,17 @@ async function mw(t = {}) {
14572
14589
  h.clientMessageId,
14573
14590
  h.submittedAt
14574
14591
  ).then((T) => {
14575
- v === vt && (M.getState().receipts === void 0 && zo(h.clientMessageId), we?.clientMessageId === h.clientMessageId && (we.pendingSubmission = !1, T && (we.clientMessageId = T), yc()), R && (Wn = !1, Zi = null, e.proactiveSuggestion = null, ct()));
14592
+ v === vt && (P.getState().receipts === void 0 && zo(h.clientMessageId), we?.clientMessageId === h.clientMessageId && (we.pendingSubmission = !1, T && (we.clientMessageId = T), yc()), R && (Wn = !1, Zi = null, e.proactiveSuggestion = null, ct()));
14576
14593
  }).catch((T) => {
14577
14594
  if (v !== vt) return;
14578
14595
  we?.clientMessageId === h.clientMessageId && (we = null), qt.delete(h.clientMessageId), di();
14579
14596
  const j = T instanceof Error ? T.message : "Failed to upload attachment";
14580
- M.getState().lastError !== j && ps(j);
14597
+ P.getState().lastError !== j && ps(j);
14581
14598
  }).finally(() => {
14582
14599
  v === vt && De();
14583
14600
  });
14584
14601
  }, Lc = () => {
14585
- if (Ne || !en || e.productVariant === "personal" && !tl({ ...Mc(), isSubmitting: !1 }) || M.getState().status !== "connected" || i() || Yn(e.billingStatus))
14602
+ if (Ne || !en || e.productVariant === "personal" && !tl({ ...Mc(), isSubmitting: !1 }) || P.getState().status !== "connected" || i() || Yn(e.billingStatus))
14586
14603
  return;
14587
14604
  const h = en;
14588
14605
  en = null, Dc(h);
@@ -14632,11 +14649,11 @@ async function mw(t = {}) {
14632
14649
  if (!e.attachmentsEnabled || h.length === 0 || e.productVariant === "personal" && An())
14633
14650
  return;
14634
14651
  const v = a_(
14635
- M,
14652
+ P,
14636
14653
  h,
14637
14654
  e.productVariant === "customer_embedded"
14638
14655
  );
14639
- if (Zt++, lt = [...lt, ...v], di(), Tp(), De(), xe(M.getState()), !c.classList.contains("pluno-pa-widget--open")) {
14656
+ if (Zt++, lt = [...lt, ...v], di(), Tp(), De(), xe(P.getState()), !c.classList.contains("pluno-pa-widget--open")) {
14640
14657
  Mt("", !0, !0, !0, "attachment_drop");
14641
14658
  return;
14642
14659
  }
@@ -14698,11 +14715,11 @@ async function mw(t = {}) {
14698
14715
  if (h.disabled)
14699
14716
  return;
14700
14717
  if (h.action === "stop") {
14701
- qt.clear(), en = null, we = null, M.stop(), De();
14718
+ qt.clear(), en = null, we = null, P.stop(), De();
14702
14719
  return;
14703
14720
  }
14704
14721
  const v = F.value.trim().length > 0 || lt.length > 0;
14705
- sn = !0, ut(!0, "send"), St(), Bo(), xe(M.getState()), De(), v && tn("send_button_submit");
14722
+ sn = !0, ut(!0, "send"), St(), Bo(), xe(P.getState()), De(), v && tn("send_button_submit");
14706
14723
  }), Ie.addEventListener("click", () => {
14707
14724
  $e = !$e, Ft(), $e && (Je.data === null || Je.status === "error") && Je.status !== "loading" && Eo(), $e || tn("history_closed");
14708
14725
  }), he.addEventListener("click", () => {
@@ -14715,7 +14732,7 @@ async function mw(t = {}) {
14715
14732
  e.onLoginClick?.();
14716
14733
  return;
14717
14734
  }
14718
- (e.productVariant === "personal" ? !Rn() : Lo()) || (sn = !0, ut(!0, "send"), St(), Bo(), xe(M.getState()), De());
14735
+ (e.productVariant === "personal" ? !Rn() : Lo()) || (sn = !0, ut(!0, "send"), St(), Bo(), xe(P.getState()), De());
14719
14736
  }
14720
14737
  }), c.addEventListener("click", (h) => {
14721
14738
  const v = h.target instanceof Element ? h.target : null;
@@ -14775,7 +14792,7 @@ async function mw(t = {}) {
14775
14792
  h.key !== "Escape" || !$e || ($e = !1, Ft(), tn("history_escape"));
14776
14793
  }), d.composerValue && (F.value = d.composerValue, Bi(F)), e.layout === "page" ? Mt(F.value, !1, !0, !1, "external_request") : p === "minimized" ? bi("minimized", !1) : e.initialDisplayState === void 0 && d.isOpen && Mt(F.value, !1, !1, !1, "restored_state");
14777
14794
  const Ci = () => u;
14778
- let Fo = M.getState().appearance !== null, hs = M.getInteractions();
14795
+ let Fo = P.getState().appearance !== null, hs = P.getInteractions();
14779
14796
  const it = (h) => hs.find(
14780
14797
  (v) => v.kind === h && v.eligible
14781
14798
  ), $o = () => {
@@ -14784,7 +14801,7 @@ async function mw(t = {}) {
14784
14801
  const R = v.payload.openingGeneration;
14785
14802
  if (R && c.classList.contains("pluno-pa-widget--open")) {
14786
14803
  const se = `${v.id}:${R}`;
14787
- h.dataset.presentedOpening !== se && (h.dataset.presentedOpening = se, M.recordPromptPresented?.(v.kind === "task_notifications" ? "notifications" : "tab_grouping", R));
14804
+ h.dataset.presentedOpening !== se && (h.dataset.presentedOpening = se, P.recordPromptPresented?.(v.kind === "task_notifications" ? "notifications" : "tab_grouping", R));
14788
14805
  }
14789
14806
  h.replaceChildren();
14790
14807
  const T = document.createElement("span");
@@ -14805,13 +14822,13 @@ async function mw(t = {}) {
14805
14822
  se.setAttribute("role", "alert"), se.textContent = ie, h.append(se);
14806
14823
  }
14807
14824
  }
14808
- }, cn = (h, v, R) => h ? M.actOnInteraction(
14825
+ }, cn = (h, v, R) => h ? P.actOnInteraction(
14809
14826
  h.id,
14810
14827
  v,
14811
14828
  h.revision,
14812
14829
  { ...R, expectedSourceVersion: h.sourceVersion }
14813
14830
  ) : Promise.resolve();
14814
- let Ho = M.getState().isThinking;
14831
+ let Ho = P.getState().isThinking;
14815
14832
  const Pp = async () => {
14816
14833
  $o();
14817
14834
  };
@@ -14825,24 +14842,24 @@ async function mw(t = {}) {
14825
14842
  }
14826
14843
  return Tn !== null;
14827
14844
  }, Fc = () => {
14828
- const h = jc(M.getState());
14845
+ const h = jc(P.getState());
14829
14846
  be.hidden = !h, h && Tn !== null && ep(be, Tn);
14830
14847
  }, ms = /* @__PURE__ */ new Map(), Op = async (h, v, R) => {
14831
14848
  const T = ms.get(h) ?? /* @__PURE__ */ new Set();
14832
14849
  if (!T.has(v)) {
14833
- ms.set(h, T), T.add(v), xe(M.getState());
14850
+ ms.set(h, T), T.add(v), xe(P.getState());
14834
14851
  try {
14835
14852
  await R();
14836
14853
  } finally {
14837
- T.delete(v), T.size || ms.delete(h), Ne || xe(M.getState());
14854
+ T.delete(v), T.size || ms.delete(h), Ne || xe(P.getState());
14838
14855
  }
14839
14856
  }
14840
14857
  };
14841
14858
  let Jn = null;
14842
14859
  const Ko = (h = {}) => {
14843
14860
  vt++, qt.clear(), oc(), en = null, we = null, fi = !1, is.clear(), sn = !0, ut(!0, "newSession"), St(), $e = !1, Ft();
14844
- const v = Promise.resolve(M.startNewSession(h));
14845
- return vi = null, vo.clear(), F.value = "", lt = [], di(), Bi(F), Qe(), De(), _n(F, "new_chat"), xe(M.getState()), v;
14861
+ const v = Promise.resolve(P.startNewSession(h));
14862
+ return vi = null, vo.clear(), F.value = "", lt = [], di(), Bi(F), Qe(), De(), _n(F, "new_chat"), xe(P.getState()), v;
14846
14863
  };
14847
14864
  le?.addEventListener("click", () => {
14848
14865
  cn(it("proactive_suggestion"), "run").catch(() => {
@@ -14869,7 +14886,7 @@ async function mw(t = {}) {
14869
14886
  if (!(!h || !v || nt === "submitting")) {
14870
14887
  nt = "submitting", ct();
14871
14888
  try {
14872
- await M.actOnInteraction(h.interactionId ?? h.id, "feedback", 0, { feedback: v }), nt = "success";
14889
+ await P.actOnInteraction(h.interactionId ?? h.id, "feedback", 0, { feedback: v }), nt = "success";
14873
14890
  } catch {
14874
14891
  nt = "error";
14875
14892
  }
@@ -14900,7 +14917,7 @@ async function mw(t = {}) {
14900
14917
  let Wc = "", dn = !1;
14901
14918
  const Dp = async () => {
14902
14919
  if (dn) return;
14903
- dn = !0, xe(M.getState());
14920
+ dn = !0, xe(P.getState());
14904
14921
  let h;
14905
14922
  try {
14906
14923
  await Promise.race([
@@ -14910,7 +14927,7 @@ async function mw(t = {}) {
14910
14927
  })
14911
14928
  ]);
14912
14929
  } finally {
14913
- clearTimeout(h), dn = !1, Ne || xe(M.getState());
14930
+ clearTimeout(h), dn = !1, Ne || xe(P.getState());
14914
14931
  }
14915
14932
  };
14916
14933
  kt.addEventListener("click", () => {
@@ -14979,10 +14996,10 @@ async function mw(t = {}) {
14979
14996
  const Te = Z.querySelector(".pluno-pa-widget__login");
14980
14997
  Te.disabled = qn, Te.setAttribute("aria-busy", String(qn)), qn && Te.prepend(bn()), Te.addEventListener("click", () => {
14981
14998
  const qi = ++ys, Fp = Vo;
14982
- qn = !0, Ti = null, xe(M.getState()), pt().catch((Xc) => {
14999
+ qn = !0, Ti = null, xe(P.getState()), pt().catch((Xc) => {
14983
15000
  qi !== ys || Fp !== Vo || (Ti = Xc instanceof Error ? Xc.message : "Close and reopen Pluno to try again.");
14984
15001
  }).finally(() => {
14985
- qi === ys && (qn = !1, Ne || xe(M.getState()));
15002
+ qi === ys && (qn = !1, Ne || xe(P.getState()));
14986
15003
  });
14987
15004
  });
14988
15005
  return;
@@ -15046,17 +15063,17 @@ async function mw(t = {}) {
15046
15063
  sn = !0, ut(!0, "send"), St();
15047
15064
  const Te = it("morning_report");
15048
15065
  Te ? cn(Te, "run", { taskIndex: pt }).catch(() => {
15049
- }) : M.sendMessage(oe);
15066
+ }) : P.sendMessage(oe);
15050
15067
  },
15051
- (oe) => (sn = !0, ut(!0, "send"), St(), M.retryLastMessage(oe)),
15068
+ (oe) => (sn = !0, ut(!0, "send"), St(), P.retryLastMessage(oe)),
15052
15069
  e.morningReport,
15053
15070
  () => {
15054
15071
  const oe = it("morning_report");
15055
15072
  oe && cn(oe, "snooze").then(() => {
15056
- Po("morning_report_snooze"), xe(M.getState());
15057
- }).catch(() => xe(M.getState()));
15073
+ Po("morning_report_snooze"), xe(P.getState());
15074
+ }).catch(() => xe(P.getState()));
15058
15075
  },
15059
- () => h.sessionId ? M.loadSession(h.sessionId) : void 0,
15076
+ () => h.sessionId ? P.loadSession(h.sessionId) : void 0,
15060
15077
  () => Ko(),
15061
15078
  ms.get(h.selectionKey ?? h.sessionId ?? "draft"),
15062
15079
  (oe, pt) => {
@@ -15080,12 +15097,12 @@ async function mw(t = {}) {
15080
15097
  const xt = Array.isArray(h.activeScheduledFollowUps) ? h.activeScheduledFollowUps : null, Qc = (xt !== null ? xt.map((oe) => oe.dueAt) : h.messages.map((oe) => oe.scheduledCheckInAt)).filter((oe) => !!oe).filter((oe) => oi(oe) !== null).sort((oe, pt) => Date.parse(oe) - Date.parse(pt))[0] ?? null, Yc = Qc ? cm(Qc) : null;
15081
15098
  Yc !== null && (nn = window.setTimeout(
15082
15099
  () => {
15083
- nn = null, Ne || xe(M.getState());
15100
+ nn = null, Ne || xe(P.getState());
15084
15101
  },
15085
15102
  Math.min(Yc, 2147483647)
15086
15103
  )), se ? (on = G.scrollTop, St()) : ie && gd(h) && _p();
15087
15104
  }, Vc = () => {
15088
- k.getSelection()?.isCollapsed !== !1 && S_(Ai) && xe(M.getState());
15105
+ k.getSelection()?.isCollapsed !== !1 && S_(Ai) && xe(P.getState());
15089
15106
  };
15090
15107
  k.addEventListener(
15091
15108
  "selectionchange",
@@ -15094,28 +15111,28 @@ async function mw(t = {}) {
15094
15111
  const Go = (h) => {
15095
15112
  Tn = e.entrySurface === "extension_widget" || h.user && !e.loginRequired ? h.activeUsersCount ?? null : null, Fc();
15096
15113
  };
15097
- Go(M.getState());
15098
- const Lp = M.subscribeInteractions((h) => {
15099
- hs = h, $o(), e.morningReport = it("morning_report")?.payload ?? null, e.proactiveSuggestion = it("proactive_suggestion")?.payload.suggestion ?? null, Ne || xe(M.getState(), { skipUnchangedTimeline: !0, renderSource: "interactions" });
15100
- }), Np = M.subscribeAccount((h) => {
15114
+ Go(P.getState());
15115
+ const Lp = P.subscribeInteractions((h) => {
15116
+ hs = h, $o(), e.morningReport = it("morning_report")?.payload ?? null, e.proactiveSuggestion = it("proactive_suggestion")?.payload.suggestion ?? null, Ne || xe(P.getState(), { skipUnchangedTimeline: !0, renderSource: "interactions" });
15117
+ }), Np = P.subscribeAccount((h) => {
15101
15118
  if (!h && !ds) return;
15102
15119
  const v = h?.auth;
15103
15120
  (v?.status !== "error" || v.errorCode !== "browser_session_unavailable" && v.errorCode !== "backend_auth_pending") && (ys += 1, Ti = null, qn = !1);
15104
15121
  const R = i();
15105
- e.billingStatus = h, s(h), Go(M.getState()), Gn(), xe(M.getState(), { skipUnchangedTimeline: !0, renderSource: "account" }), bo(), De(), queueMicrotask(Lc), R && !i() && Uo();
15122
+ e.billingStatus = h, s(h), Go(P.getState()), Gn(), xe(P.getState(), { skipUnchangedTimeline: !0, renderSource: "account" }), bo(), De(), queueMicrotask(Lc), R && !i() && Uo();
15106
15123
  });
15107
15124
  let Jo = !1, Qo = null;
15108
15125
  const Gc = (h) => {
15109
15126
  ts && ((!h.taskStatus || Qo !== null && Qo !== h.sessionId) && (Jo = !1), Qo = h.sessionId, h.taskStatus === "working" && (Jo = !0), Jo && h.taskStatus ? ts.setStatus(h.taskStatus) : ts.clear());
15110
15127
  };
15111
- M.on("state", (h) => {
15128
+ P.on("state", (h) => {
15112
15129
  const v = h.user?.id ?? null;
15113
15130
  (ui !== null && ui !== h.sessionId || hi !== null && hi !== v || pi !== void 0 && pi !== h.selectionKey) && (vt++, qt.clear(), we = null), pi = h.selectionKey, ui = h.sessionId, hi = v;
15114
15131
  for (const ge of h.messages)
15115
15132
  ge.role === "user" && zo(ge.id);
15116
15133
  for (const ge of h.receipts ?? []) zo(ge.userMessageId, ge.acceptedRendererRevision);
15117
15134
  if (e.extensionRuntime && (Vo += 1, Ti = null), Go(h), lc) {
15118
- const ge = M.getModel(), xt = bb(ge) ? ge : Zs[0].value;
15135
+ const ge = P.getModel(), xt = bb(ge) ? ge : Zs[0].value;
15119
15136
  xt !== Pt && (Pt = xt, Vn());
15120
15137
  }
15121
15138
  Gc(h), h.status === "connected" && (ds = !0, en && queueMicrotask(() => {
@@ -15138,19 +15155,19 @@ async function mw(t = {}) {
15138
15155
  }
15139
15156
  ), Yo({}, "agent.state.appearance-cleared")), xe(h, { skipUnchangedTimeline: !0, renderSource: "state" }), De(), R && qo();
15140
15157
  });
15141
- const Jc = M.getState();
15158
+ const Jc = P.getState();
15142
15159
  Gc(Jc), xe(Jc), De(), Uo();
15143
15160
  const Up = Vh(c, (h, v, R, T, j) => {
15144
- const ie = Yp(M.getState(), T);
15145
- M.reportDisplayedError?.(h, v, R, ie ?? void 0, j);
15161
+ const ie = Yp(P.getState(), T);
15162
+ P.reportDisplayedError?.(h, v, R, ie ?? void 0, j);
15146
15163
  }), zp = Nb(
15147
15164
  r,
15148
15165
  c,
15149
15166
  e.extensionRuntime ? "extension_widget" : e.entrySurface === "main_web_chat" ? "main_web_chat" : "embedded_widget",
15150
- M
15167
+ P
15151
15168
  ), Bp = Gh(c, xo);
15152
15169
  return {
15153
- agent: M,
15170
+ agent: P,
15154
15171
  startNewChat: Ko,
15155
15172
  host: r,
15156
15173
  updateAppearance: (h) => {
@@ -15198,7 +15215,7 @@ async function mw(t = {}) {
15198
15215
  ), k.removeEventListener("drop", an, !0), k.removeEventListener("dragend", an, !0), k.defaultView?.removeEventListener(
15199
15216
  "blur",
15200
15217
  an
15201
- ), window.removeEventListener("resize", _c), vc(), xp(), Ep(), Bt !== null && window.clearTimeout(Bt), dt !== null && (window.clearTimeout(dt), dt = null), wp(), vn !== null && (window.clearTimeout(vn), vn = null), nn !== null && (window.clearTimeout(nn), nn = null), ts?.clear(), cc && M.destroy(), _o?.release(), r.remove());
15218
+ ), window.removeEventListener("resize", _c), vc(), xp(), Ep(), Bt !== null && window.clearTimeout(Bt), dt !== null && (window.clearTimeout(dt), dt = null), wp(), vn !== null && (window.clearTimeout(vn), vn = null), nn !== null && (window.clearTimeout(nn), nn = null), ts?.clear(), cc && P.destroy(), _o?.release(), r.remove());
15202
15219
  }
15203
15220
  };
15204
15221
  async function jp(h) {
@@ -15221,7 +15238,7 @@ async function mw(t = {}) {
15221
15238
  }
15222
15239
  function Yo(h, v) {
15223
15240
  const R = h.accentColor ?? e.accentColor, T = h.colorScheme ?? e.colorScheme, j = h.fontFamily ?? e.fontFamily, ie = h.scribbleStyle ?? e.scribbleStyle, se = JSON.stringify([R, T, j, ie]);
15224
- se !== _ && (_ = se, u = cd(
15241
+ se !== w && (w = se, u = cd(
15225
15242
  R,
15226
15243
  ie
15227
15244
  ), ld(c, u, {
@@ -15312,7 +15329,7 @@ function _w({
15312
15329
  a = null, r = null, l = null, c = !1, t.classList.remove("pluno-pa-widget--dragging");
15313
15330
  }, p = (S) => {
15314
15331
  t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing") || (S.preventDefault(), S.stopPropagation(), a = S.pointerId, r = { x: S.clientX, y: S.clientY }, l = i(), c = !1, e.setPointerCapture?.(S.pointerId));
15315
- }, f = (S) => {
15332
+ }, g = (S) => {
15316
15333
  if (a !== S.pointerId || !r || !l)
15317
15334
  return;
15318
15335
  S.preventDefault();
@@ -15320,7 +15337,7 @@ function _w({
15320
15337
  !c && Math.hypot(k, m) < no || (c = !0, t.classList.add("pluno-pa-widget--dragging"), s({ x: l.x + k, y: l.y + m }));
15321
15338
  }, y = (S) => {
15322
15339
  a === S.pointerId && (S.preventDefault(), S.stopPropagation(), c && (u = { x: S.clientX, y: S.clientY }, o()), d());
15323
- }, g = (S) => {
15340
+ }, f = (S) => {
15324
15341
  a === S.pointerId && (S.preventDefault(), d());
15325
15342
  }, b = (S) => {
15326
15343
  if (!u)
@@ -15330,15 +15347,15 @@ function _w({
15330
15347
  S.clientY - u.y
15331
15348
  ) <= no;
15332
15349
  u = null, k && (S.preventDefault(), S.stopPropagation());
15333
- }, _ = (S) => {
15350
+ }, w = (S) => {
15334
15351
  if (t.classList.contains("pluno-pa-widget--open") || t.classList.contains("pluno-pa-widget--closing"))
15335
15352
  return;
15336
15353
  const k = S.shiftKey ? Xa : Ya, m = i();
15337
- let w = null;
15338
- S.key === "ArrowUp" ? w = { x: m.x, y: m.y - k } : S.key === "ArrowDown" ? w = { x: m.x, y: m.y + k } : S.key === "ArrowLeft" ? w = { x: m.x - k, y: m.y } : S.key === "ArrowRight" && (w = { x: m.x + k, y: m.y }), w && (S.preventDefault(), S.stopPropagation(), s(w), o());
15354
+ let _ = null;
15355
+ S.key === "ArrowUp" ? _ = { x: m.x, y: m.y - k } : S.key === "ArrowDown" ? _ = { x: m.x, y: m.y + k } : S.key === "ArrowLeft" ? _ = { x: m.x - k, y: m.y } : S.key === "ArrowRight" && (_ = { x: m.x + k, y: m.y }), _ && (S.preventDefault(), S.stopPropagation(), s(_), o());
15339
15356
  };
15340
- return e.addEventListener("pointerdown", p), e.addEventListener("pointermove", f), e.addEventListener("pointerup", y), e.addEventListener("pointercancel", g), e.addEventListener("click", b, !0), n.addEventListener("keydown", _), () => {
15341
- e.removeEventListener("pointerdown", p), e.removeEventListener("pointermove", f), e.removeEventListener("pointerup", y), e.removeEventListener("pointercancel", g), e.removeEventListener("click", b, !0), n.removeEventListener("keydown", _);
15357
+ return e.addEventListener("pointerdown", p), e.addEventListener("pointermove", g), e.addEventListener("pointerup", y), e.addEventListener("pointercancel", f), e.addEventListener("click", b, !0), n.addEventListener("keydown", w), () => {
15358
+ e.removeEventListener("pointerdown", p), e.removeEventListener("pointermove", g), e.removeEventListener("pointerup", y), e.removeEventListener("pointercancel", f), e.removeEventListener("click", b, !0), n.removeEventListener("keydown", w);
15342
15359
  };
15343
15360
  }
15344
15361
  function vw({
@@ -15351,25 +15368,25 @@ function vw({
15351
15368
  let o = null, a = null, r = null, l = !1;
15352
15369
  const c = () => {
15353
15370
  o = null, a = null, r = null, l = !1, t.classList.remove("pluno-pa-widget--panel-dragging");
15354
- }, u = (g) => {
15355
- t.classList.contains("pluno-pa-widget--open") && (g.preventDefault(), g.stopPropagation(), o = g.pointerId, a = { x: g.clientX, y: g.clientY }, r = n(), l = !1, e.setPointerCapture?.(g.pointerId));
15356
- }, d = (g) => {
15357
- if (o !== g.pointerId || !a || !r)
15371
+ }, u = (f) => {
15372
+ t.classList.contains("pluno-pa-widget--open") && (f.preventDefault(), f.stopPropagation(), o = f.pointerId, a = { x: f.clientX, y: f.clientY }, r = n(), l = !1, e.setPointerCapture?.(f.pointerId));
15373
+ }, d = (f) => {
15374
+ if (o !== f.pointerId || !a || !r)
15358
15375
  return;
15359
- g.preventDefault(), g.stopPropagation();
15360
- const b = g.clientX - a.x, _ = g.clientY - a.y;
15361
- !l && Math.hypot(b, _) < no || (l = !0, t.classList.add("pluno-pa-widget--panel-dragging"), i({ x: r.x + b, y: r.y + _ }));
15362
- }, p = (g) => {
15363
- o === g.pointerId && (g.preventDefault(), g.stopPropagation(), l && s(), c());
15364
- }, f = (g) => {
15365
- o === g.pointerId && (g.preventDefault(), c());
15366
- }, y = (g) => {
15367
- const b = g.shiftKey ? Xa : Ya, _ = n();
15376
+ f.preventDefault(), f.stopPropagation();
15377
+ const b = f.clientX - a.x, w = f.clientY - a.y;
15378
+ !l && Math.hypot(b, w) < no || (l = !0, t.classList.add("pluno-pa-widget--panel-dragging"), i({ x: r.x + b, y: r.y + w }));
15379
+ }, p = (f) => {
15380
+ o === f.pointerId && (f.preventDefault(), f.stopPropagation(), l && s(), c());
15381
+ }, g = (f) => {
15382
+ o === f.pointerId && (f.preventDefault(), c());
15383
+ }, y = (f) => {
15384
+ const b = f.shiftKey ? Xa : Ya, w = n();
15368
15385
  let S = null;
15369
- g.key === "ArrowUp" ? S = { x: _.x, y: _.y - b } : g.key === "ArrowDown" ? S = { x: _.x, y: _.y + b } : g.key === "ArrowLeft" ? S = { x: _.x - b, y: _.y } : g.key === "ArrowRight" && (S = { x: _.x + b, y: _.y }), S && (g.preventDefault(), g.stopPropagation(), i(S), s());
15386
+ f.key === "ArrowUp" ? S = { x: w.x, y: w.y - b } : f.key === "ArrowDown" ? S = { x: w.x, y: w.y + b } : f.key === "ArrowLeft" ? S = { x: w.x - b, y: w.y } : f.key === "ArrowRight" && (S = { x: w.x + b, y: w.y }), S && (f.preventDefault(), f.stopPropagation(), i(S), s());
15370
15387
  };
15371
- return e.addEventListener("pointerdown", u), e.addEventListener("pointermove", d), e.addEventListener("pointerup", p), e.addEventListener("pointercancel", f), e.addEventListener("keydown", y), () => {
15372
- e.removeEventListener("pointerdown", u), e.removeEventListener("pointermove", d), e.removeEventListener("pointerup", p), e.removeEventListener("pointercancel", f), e.removeEventListener("keydown", y);
15388
+ return e.addEventListener("pointerdown", u), e.addEventListener("pointermove", d), e.addEventListener("pointerup", p), e.addEventListener("pointercancel", g), e.addEventListener("keydown", y), () => {
15389
+ e.removeEventListener("pointerdown", u), e.removeEventListener("pointermove", d), e.removeEventListener("pointerup", p), e.removeEventListener("pointercancel", g), e.removeEventListener("keydown", y);
15373
15390
  };
15374
15391
  }
15375
15392
  function Iw({
@@ -15383,30 +15400,30 @@ function Iw({
15383
15400
  const u = () => {
15384
15401
  o = null, a = null, r = null, l = null, c = !1, t.classList.remove("pluno-pa-widget--resizing");
15385
15402
  }, d = (b) => {
15386
- const _ = b.currentTarget, S = _.dataset.resizeDirection;
15387
- !t.classList.contains("pluno-pa-widget--open") || !dd(S) || (b.preventDefault(), b.stopPropagation(), o = b.pointerId, a = S, r = { x: b.clientX, y: b.clientY }, l = n(), c = !1, _.setPointerCapture?.(b.pointerId));
15403
+ const w = b.currentTarget, S = w.dataset.resizeDirection;
15404
+ !t.classList.contains("pluno-pa-widget--open") || !dd(S) || (b.preventDefault(), b.stopPropagation(), o = b.pointerId, a = S, r = { x: b.clientX, y: b.clientY }, l = n(), c = !1, w.setPointerCapture?.(b.pointerId));
15388
15405
  }, p = (b) => {
15389
15406
  if (o !== b.pointerId || !a || !r || !l)
15390
15407
  return;
15391
15408
  b.preventDefault(), b.stopPropagation();
15392
- const _ = b.clientX - r.x, S = b.clientY - r.y;
15393
- !c && Math.hypot(_, S) < no || (c = !0, t.classList.add("pluno-pa-widget--resizing"), i(
15394
- ud(l, a, _, S)
15409
+ const w = b.clientX - r.x, S = b.clientY - r.y;
15410
+ !c && Math.hypot(w, S) < no || (c = !0, t.classList.add("pluno-pa-widget--resizing"), i(
15411
+ ud(l, a, w, S)
15395
15412
  ));
15396
- }, f = (b) => {
15413
+ }, g = (b) => {
15397
15414
  o === b.pointerId && (b.preventDefault(), b.stopPropagation(), c && s(), u());
15398
15415
  }, y = (b) => {
15399
15416
  o === b.pointerId && (b.preventDefault(), u());
15400
- }, g = (b) => {
15417
+ }, f = (b) => {
15401
15418
  const S = b.currentTarget.dataset.resizeDirection, k = b.shiftKey ? Xa : Ya, m = n();
15402
- let w = 0, I = 0;
15403
- dd(S) && (b.key === "ArrowLeft" ? w = -k : b.key === "ArrowRight" ? w = k : b.key === "ArrowUp" ? I = -k : b.key === "ArrowDown" && (I = k), !(w === 0 && I === 0) && (b.preventDefault(), b.stopPropagation(), i(ud(m, S, w, I)), s()));
15419
+ let _ = 0, I = 0;
15420
+ dd(S) && (b.key === "ArrowLeft" ? _ = -k : b.key === "ArrowRight" ? _ = k : b.key === "ArrowUp" ? I = -k : b.key === "ArrowDown" && (I = k), !(_ === 0 && I === 0) && (b.preventDefault(), b.stopPropagation(), i(ud(m, S, _, I)), s()));
15404
15421
  };
15405
15422
  for (const b of e)
15406
- b.addEventListener("pointerdown", d), b.addEventListener("pointermove", p), b.addEventListener("pointerup", f), b.addEventListener("pointercancel", y), b.addEventListener("keydown", g);
15423
+ b.addEventListener("pointerdown", d), b.addEventListener("pointermove", p), b.addEventListener("pointerup", g), b.addEventListener("pointercancel", y), b.addEventListener("keydown", f);
15407
15424
  return () => {
15408
15425
  for (const b of e)
15409
- b.removeEventListener("pointerdown", d), b.removeEventListener("pointermove", p), b.removeEventListener("pointerup", f), b.removeEventListener("pointercancel", y), b.removeEventListener("keydown", g);
15426
+ b.removeEventListener("pointerdown", d), b.removeEventListener("pointermove", p), b.removeEventListener("pointerup", g), b.removeEventListener("pointercancel", y), b.removeEventListener("keydown", f);
15410
15427
  };
15411
15428
  }
15412
15429
  function dd(t) {
@@ -15875,8 +15892,8 @@ function Uw(t, e) {
15875
15892
  );
15876
15893
  const i = document.createElement("div");
15877
15894
  if (i.className = "pluno-pa-widget__drop-overlay", i.setAttribute("aria-hidden", "true"), i.textContent = "Drop files to attach", n.appendChild(i), e) {
15878
- const g = document.createElement("button");
15879
- g.type = "button", g.className = "pluno-pa-widget__panel-drag-handle", g.setAttribute("aria-label", "Move Pluno widget"), g.title = "Move Pluno widget", n.appendChild(g);
15895
+ const f = document.createElement("button");
15896
+ f.type = "button", f.className = "pluno-pa-widget__panel-drag-handle", f.setAttribute("aria-label", "Move Pluno widget"), f.title = "Move Pluno widget", n.appendChild(f);
15880
15897
  }
15881
15898
  const s = document.createElement("div");
15882
15899
  s.className = "pluno-pa-widget__timeline-wrap";
@@ -15896,15 +15913,15 @@ function Uw(t, e) {
15896
15913
  d.className = "pluno-pa-widget__access-notice", d.hidden = !0;
15897
15914
  const p = document.createElement("div");
15898
15915
  p.className = "pluno-pa-widget__connection-notice", p.hidden = !0, c.append(d, u, p), c.append(l, zw(), Bw()), s.appendChild(c);
15899
- const f = document.createElement("div");
15900
- f.className = "pluno-pa-widget__top-actions", f.appendChild(
15916
+ const g = document.createElement("div");
15917
+ g.className = "pluno-pa-widget__top-actions", g.appendChild(
15901
15918
  fo(
15902
15919
  "pluno-pa-widget__history",
15903
15920
  ka(),
15904
15921
  Qw(),
15905
15922
  !0
15906
15923
  )
15907
- ), s.appendChild(f), s.appendChild($w()), n.appendChild(s);
15924
+ ), s.appendChild(g), s.appendChild($w()), n.appendChild(s);
15908
15925
  const y = document.createElement("div");
15909
15926
  return y.className = "pluno-pa-widget__proactive-suggestion-slot", n.appendChild(y), n.appendChild(Fw()), n.appendChild(hn("left", "Resize Pluno from left")), n.appendChild(
15910
15927
  hn("right", "Resize Pluno from right")
@@ -16016,23 +16033,23 @@ function Fw() {
16016
16033
  p.className = "pluno-pa-widget__model-menu";
16017
16034
  for (const m of Zs)
16018
16035
  p.appendChild(yd(m));
16019
- const f = document.createElement("details");
16020
- f.className = "pluno-pa-widget__model-more";
16021
- const y = document.createElement("summary"), g = document.createElement("span");
16022
- g.textContent = "More";
16036
+ const g = document.createElement("details");
16037
+ g.className = "pluno-pa-widget__model-more";
16038
+ const y = document.createElement("summary"), f = document.createElement("span");
16039
+ f.textContent = "More";
16023
16040
  const b = xa(12);
16024
- b.classList.add("pluno-pa-widget__model-more-chevron"), y.append(g, b), f.appendChild(y);
16041
+ b.classList.add("pluno-pa-widget__model-more-chevron"), y.append(f, b), g.appendChild(y);
16025
16042
  for (const m of ju) {
16026
- const w = yd(m);
16027
- w.classList.add("pluno-pa-widget__model-more-option"), f.appendChild(w);
16043
+ const _ = yd(m);
16044
+ _.classList.add("pluno-pa-widget__model-more-option"), g.appendChild(_);
16028
16045
  }
16029
- p.appendChild(f), c.appendChild(p), l.appendChild(c);
16030
- const _ = document.createElement("div");
16031
- _.className = "pluno-pa-widget__composer-meta";
16046
+ p.appendChild(g), c.appendChild(p), l.appendChild(c);
16047
+ const w = document.createElement("div");
16048
+ w.className = "pluno-pa-widget__composer-meta";
16032
16049
  const S = document.createElement("a");
16033
- S.className = "pluno-pa-widget__powered-by", S.href = "https://pluno.ai", S.target = "_blank", S.rel = "noopener noreferrer", S.textContent = "Powered by Pluno.ai.", _.appendChild(S);
16050
+ S.className = "pluno-pa-widget__powered-by", S.href = "https://pluno.ai", S.target = "_blank", S.rel = "noopener noreferrer", S.textContent = "Powered by Pluno.ai.", w.appendChild(S);
16034
16051
  const k = document.createElement("span");
16035
- return k.className = "pluno-pa-widget__ai-disclaimer", k.textContent = "AI can make mistakes. Verify outputs.", _.appendChild(k), l.appendChild(_), t.appendChild(l), t;
16052
+ return k.className = "pluno-pa-widget__ai-disclaimer", k.textContent = "AI can make mistakes. Verify outputs.", w.appendChild(k), l.appendChild(w), t.appendChild(l), t;
16036
16053
  }
16037
16054
  function yd(t) {
16038
16055
  const e = document.createElement("button");
@@ -16199,7 +16216,7 @@ function Kw(t, e) {
16199
16216
  in2: "innerLight",
16200
16217
  mode: "screen"
16201
16218
  });
16202
- const f = J(o, "filter", {
16219
+ const g = J(o, "filter", {
16203
16220
  id: i.eyeShadow,
16204
16221
  x: "-24%",
16205
16222
  y: "-20%",
@@ -16207,7 +16224,7 @@ function Kw(t, e) {
16207
16224
  height: "148%",
16208
16225
  "color-interpolation-filters": "sRGB"
16209
16226
  });
16210
- J(f, "feDropShadow", {
16227
+ J(g, "feDropShadow", {
16211
16228
  dx: "0",
16212
16229
  dy: "8",
16213
16230
  stdDeviation: "5",
@@ -16229,8 +16246,8 @@ function Kw(t, e) {
16229
16246
  "flood-color": "#000000",
16230
16247
  "flood-opacity": "0.22"
16231
16248
  });
16232
- const g = J(o, "clipPath", { id: i.boltClip });
16233
- J(g, "path", { d: eo });
16249
+ const f = J(o, "clipPath", { id: i.boltClip });
16250
+ J(f, "path", { d: eo });
16234
16251
  const b = J(s, "g", {
16235
16252
  filter: mt(i.softDropShadow)
16236
16253
  });
@@ -16238,13 +16255,13 @@ function Kw(t, e) {
16238
16255
  d: eo,
16239
16256
  fill: mt(i.boltEdge)
16240
16257
  });
16241
- const _ = "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";
16258
+ 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";
16242
16259
  J(b, "path", {
16243
- d: _,
16260
+ d: w,
16244
16261
  fill: mt(i.boltFill),
16245
16262
  filter: mt(i.innerDepth)
16246
16263
  }), J(b, "path", {
16247
- d: _,
16264
+ d: w,
16248
16265
  fill: mt(i.boltGlow),
16249
16266
  opacity: "0.74"
16250
16267
  });
@@ -16850,11 +16867,11 @@ function r_(t, e, n, i, s, o) {
16850
16867
  jn(e(), "message")
16851
16868
  );
16852
16869
  }, c = () => {
16853
- const f = io(e());
16854
- if (f && f !== a) {
16855
- a = f, t.addEventListener("error", c, {
16870
+ const g = io(e());
16871
+ if (g && g !== a) {
16872
+ a = g, t.addEventListener("error", c, {
16856
16873
  once: !0
16857
- }), s(f);
16874
+ }), s(g);
16858
16875
  return;
16859
16876
  }
16860
16877
  l();
@@ -16868,27 +16885,27 @@ function r_(t, e, n, i, s, o) {
16868
16885
  let u = 0;
16869
16886
  const d = () => {
16870
16887
  i(e()).then(
16871
- (f) => {
16888
+ (g) => {
16872
16889
  if (t.isConnected) {
16873
- if (!f) {
16890
+ if (!g) {
16874
16891
  p();
16875
16892
  return;
16876
16893
  }
16877
- t.addEventListener("error", p, { once: !0 }), s(f);
16894
+ t.addEventListener("error", p, { once: !0 }), s(g);
16878
16895
  }
16879
16896
  },
16880
16897
  p
16881
16898
  );
16882
16899
  }, p = () => {
16883
16900
  o();
16884
- const f = zb[u];
16885
- if (u += 1, f === void 0) {
16901
+ const g = zb[u];
16902
+ if (u += 1, g === void 0) {
16886
16903
  l();
16887
16904
  return;
16888
16905
  }
16889
16906
  window.setTimeout(() => {
16890
16907
  t.isConnected && d();
16891
- }, f);
16908
+ }, g);
16892
16909
  };
16893
16910
  d();
16894
16911
  }
@@ -17017,15 +17034,15 @@ function Id(t, e) {
17017
17034
  const i = n[1], s = e ? "Finding example tasks..." : " ";
17018
17035
  i.textContent !== s && (i.textContent = s), i.classList.toggle("pluno-pa-widget__starter-placeholder--loading", e), i.parentElement.setAttribute("aria-hidden", String(!e));
17019
17036
  }
17020
- function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I, x, E, A) {
17021
- const L = ah(o), P = C_(o), z = Array.isArray(o.activeScheduledFollowUps) ? o.activeScheduledFollowUps : null, B = /* @__PURE__ */ new Map();
17037
+ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I, x, E, A) {
17038
+ const L = ah(o), M = C_(o), z = Array.isArray(o.activeScheduledFollowUps) ? o.activeScheduledFollowUps : null, B = /* @__PURE__ */ new Map();
17022
17039
  if (z !== null)
17023
17040
  for (const q of z) {
17024
17041
  const D = oi(q.dueAt);
17025
17042
  D && B.set(q.taskId, { dueAt: q.dueAt, label: D });
17026
17043
  }
17027
17044
  else
17028
- for (const q of P) {
17045
+ for (const q of M) {
17029
17046
  const D = q.scheduledCheckInAt ? oi(q.scheduledCheckInAt) : null;
17030
17047
  if (!D || !q.scheduledCheckInAt)
17031
17048
  continue;
@@ -17036,7 +17053,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17036
17053
  });
17037
17054
  }
17038
17055
  const C = [...B.values()].sort((q, D) => Date.parse(q.dueAt) - Date.parse(D.dueAt)), U = A_(
17039
- P.filter(
17056
+ M.filter(
17040
17057
  (q) => !up(q) && !q.scheduledCheckInAt
17041
17058
  ),
17042
17059
  o.segments
@@ -17072,7 +17089,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17072
17089
  const q = document.createElement("div");
17073
17090
  q.className = "pluno-pa-widget__transcript-loading", q.setAttribute("role", "status");
17074
17091
  const D = document.createElement("span");
17075
- D.textContent = o.historyPreparation ? "Preparing this conversation…" : "Loading chat...", q.append(bn(), D), d.clear(), p.clear(), f.clear(), Q(q), Q(e), Lt(t, _e);
17092
+ D.textContent = o.historyPreparation ? "Preparing this conversation…" : "Loading chat...", q.append(bn(), D), d.clear(), p.clear(), g.clear(), Q(q), Q(e), Lt(t, _e);
17076
17093
  return;
17077
17094
  }
17078
17095
  if (!Ve && o.sessionId && !o.isDraftSession) {
@@ -17092,7 +17109,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17092
17109
  S,
17093
17110
  q,
17094
17111
  o.starterPrompts,
17095
- g()
17112
+ f()
17096
17113
  ]), le = d.get("welcome");
17097
17114
  if (le?.renderSignature === D) {
17098
17115
  Id(le.node, o.starterPromptsLoading), Q(le.node), Q(e), Lt(t, _e);
@@ -17104,7 +17121,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17104
17121
  te.className = "pluno-pa-widget__empty-hero";
17105
17122
  const O = Ut(
17106
17123
  "pluno-pa-widget__character--empty",
17107
- g()
17124
+ f()
17108
17125
  );
17109
17126
  if (te.appendChild(O), V.appendChild(te), S) {
17110
17127
  const K = document.createElement("h2");
@@ -17131,7 +17148,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17131
17148
  ue.setAttribute("role", "alert"), ue.textContent = String(q.payload.error), V.appendChild(ue);
17132
17149
  }
17133
17150
  }
17134
- d.clear(), p.clear(), f.clear(), Q(V), d.set("welcome", { node: V, renderSignature: D }), Q(e), Lt(t, _e);
17151
+ d.clear(), p.clear(), g.clear(), Q(V), d.set("welcome", { node: V, renderSignature: D }), Q(e), Lt(t, _e);
17135
17152
  return;
17136
17153
  }
17137
17154
  let pe = null, ve = null, Ie = [];
@@ -17151,7 +17168,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17151
17168
  p,
17152
17169
  Ae,
17153
17170
  y,
17154
- g(),
17171
+ f(),
17155
17172
  X.get(Ie[0].id)?.collapsed ?? !0
17156
17173
  );
17157
17174
  return Q(D), pe = null, ve = D, Ie = [], re = q, !0;
@@ -17161,7 +17178,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17161
17178
  if (q.kind === "social_share") V = P_(q.payload.candidate, {
17162
17179
  isActing: q.status === "pending",
17163
17180
  error: le,
17164
- characterIconOptions: g(),
17181
+ characterIconOptions: f(),
17165
17182
  presentation: q.presentation,
17166
17183
  socialPostRewardsUrl: A?.socialPostRewardsUrl,
17167
17184
  onReferralCopy: () => D("copy"),
@@ -17196,7 +17213,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17196
17213
  }
17197
17214
  if (D.role === "system" && D.dataType === "run_status" && D.steered === !0) {
17198
17215
  if (!H()) {
17199
- const Y = N_(g());
17216
+ const Y = N_(f());
17200
17217
  Q(Y), pe = null, ve = Y;
17201
17218
  }
17202
17219
  continue;
@@ -17208,7 +17225,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17208
17225
  if ($) {
17209
17226
  if (!re) {
17210
17227
  const K = xd(
17211
- f,
17228
+ g,
17212
17229
  F,
17213
17230
  Y,
17214
17231
  he
@@ -17217,10 +17234,10 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17217
17234
  }
17218
17235
  } else {
17219
17236
  const K = kd(
17220
- f,
17237
+ g,
17221
17238
  F,
17222
17239
  Y,
17223
- g(),
17240
+ f(),
17224
17241
  he
17225
17242
  );
17226
17243
  Q(K), pe = null, ve = K;
@@ -17233,7 +17250,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17233
17250
  (ne) => ne.role === "tool" && so(ne, D)
17234
17251
  );
17235
17252
  if (!$ && !Y) {
17236
- const ne = Qi(g());
17253
+ const ne = Qi(f());
17237
17254
  ne.classList.add("pluno-pa-widget__terminal-marker"), Q(ne);
17238
17255
  }
17239
17256
  const K = document.createElement("div"), ue = D.dataType === "run_error";
@@ -17252,7 +17269,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17252
17269
  ($) => $.role === "tool" && so($, D)
17253
17270
  );
17254
17271
  if (D.role === "assistant" && !le && !te) {
17255
- const $ = Qi(g());
17272
+ const $ = Qi(f());
17256
17273
  Q($), pe = null, ve = $;
17257
17274
  }
17258
17275
  const O = b_(
@@ -17264,7 +17281,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17264
17281
  );
17265
17282
  if (O.querySelector("[data-submission-retry]")?.remove(), D.role === "user" && D.retryable) {
17266
17283
  const $ = document.createElement("button");
17267
- $.type = "button", $.className = "pluno-pa-widget__error-retry", $.dataset.submissionRetry = D.id, $.textContent = "Retry this message", $.addEventListener("click", () => _(D.id)), O.appendChild($);
17284
+ $.type = "button", $.className = "pluno-pa-widget__error-retry", $.dataset.submissionRetry = D.id, $.textContent = "Retry this message", $.addEventListener("click", () => w(D.id)), O.appendChild($);
17268
17285
  }
17269
17286
  Q(O), pe = O, ve = null, D.role;
17270
17287
  }
@@ -17274,7 +17291,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17274
17291
  if (Oe) {
17275
17292
  if (!re) {
17276
17293
  const D = xd(
17277
- f,
17294
+ g,
17278
17295
  F,
17279
17296
  q,
17280
17297
  he
@@ -17283,17 +17300,17 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17283
17300
  }
17284
17301
  } else {
17285
17302
  const D = kd(
17286
- f,
17303
+ g,
17287
17304
  F,
17288
17305
  q,
17289
- g(),
17306
+ f(),
17290
17307
  he
17291
17308
  );
17292
17309
  Q(D), pe = null, ve = D;
17293
17310
  }
17294
17311
  }
17295
17312
  if (o.lastError && Wi(o.lastErrorCode) === "conversation") {
17296
- const le = U.slice(U.map((O) => O.role).lastIndexOf("user") + 1).some((O) => O.role === "assistant" || O.role === "tool") ? document.createElement("article") : Qi(g());
17313
+ const le = U.slice(U.map((O) => O.role).lastIndexOf("user") + 1).some((O) => O.role === "assistant" || O.role === "tool") ? document.createElement("article") : Qi(f());
17297
17314
  le.classList.add("pluno-pa-widget__terminal-marker");
17298
17315
  const V = document.createElement("div");
17299
17316
  V.className = "pluno-pa-widget__error", o.historyRefreshFailure && (V.dataset.historyRefreshFailure = JSON.stringify(o.historyRefreshFailure));
@@ -17306,7 +17323,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17306
17323
  const $ = document.createElement("button");
17307
17324
  $.type = "button", $.className = "pluno-pa-widget__error-retry";
17308
17325
  const Y = I?.has(O) === !0 || O === "retry_history" && o.conversationDiagnostics?.queryRequestId != null || O === "retry_message" && o.isRetrying;
17309
- $.disabled = Y, $.setAttribute("aria-busy", String(Y)), $.textContent = O === "new_chat" ? Y ? "Starting new chat" : "Start new chat" : Y ? "Trying" : "Try again", Y && $.prepend(bn()), $.addEventListener("click", () => x(O, O === "retry_history" ? m : O === "retry_message" ? _ : w)), V.appendChild($);
17326
+ $.disabled = Y, $.setAttribute("aria-busy", String(Y)), $.textContent = O === "new_chat" ? Y ? "Starting new chat" : "Start new chat" : Y ? "Trying" : "Try again", Y && $.prepend(bn()), $.addEventListener("click", () => x(O, O === "retry_history" ? m : O === "retry_message" ? w : _)), V.appendChild($);
17310
17327
  }
17311
17328
  le.appendChild(V), Q(le), pe = null, ve = le;
17312
17329
  }
@@ -17329,7 +17346,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, f, y, g, b, _, S, k, m, w, I,
17329
17346
  p,
17330
17347
  Ae
17331
17348
  ), E_(
17332
- f,
17349
+ g,
17333
17350
  F
17334
17351
  ), Lt(t, _e), l ? Zn(t, c) : t.scrollTop = Me;
17335
17352
  }
@@ -17645,8 +17662,8 @@ function P_(t, e) {
17645
17662
  } else
17646
17663
  for (const d of dp()) {
17647
17664
  const p = document.createElement("a");
17648
- p.className = "pluno-pa-widget__share-prompt-social", p.href = d.href, p.target = "_blank", p.rel = "noopener noreferrer", p.setAttribute("aria-label", `Open ${d.label}`), p.title = d.label, p.appendChild(M_(d.id)), p.addEventListener("click", (f) => {
17649
- f.preventDefault(), e.isActing || e.onSocialShare(t, d.id);
17665
+ p.className = "pluno-pa-widget__share-prompt-social", p.href = d.href, p.target = "_blank", p.rel = "noopener noreferrer", p.setAttribute("aria-label", `Open ${d.label}`), p.title = d.label, p.appendChild(M_(d.id)), p.addEventListener("click", (g) => {
17666
+ g.preventDefault(), e.isActing || e.onSocialShare(t, d.id);
17650
17667
  }), c.appendChild(p);
17651
17668
  }
17652
17669
  const u = document.createElement("button");
@@ -17698,30 +17715,30 @@ function O_(t, e, n, i, s, o, a, r = !0) {
17698
17715
  t
17699
17716
  );
17700
17717
  if (!u) {
17701
- const m = document.createElement("article"), w = Ut(
17718
+ const m = document.createElement("article"), _ = Ut(
17702
17719
  "pluno-pa-widget__character--tool-group",
17703
17720
  a
17704
17721
  ), I = JSON.stringify(a), x = document.createElement("div");
17705
17722
  x.className = "pluno-pa-widget__tool-active-content";
17706
17723
  const E = mo(), A = document.createElement("details"), L = document.createElement("summary");
17707
17724
  L.className = "pluno-pa-widget__tool-summary";
17708
- const P = document.createElement("div");
17709
- P.className = "pluno-pa-widget__tool-summary-title", L.appendChild(P), L.addEventListener("click", () => {
17725
+ const M = document.createElement("div");
17726
+ M.className = "pluno-pa-widget__tool-summary-title", L.appendChild(M), L.addEventListener("click", () => {
17710
17727
  const B = m.dataset.responseGroupKey ?? c;
17711
- A.open ? (n.delete(B), n.add(`closed:${B}`)) : (n.add(B), n.delete(`closed:${B}`)), o(), P.textContent = A.open ? m.dataset.collapsedActivityTitle ?? "Activities" : "Activities";
17728
+ A.open ? (n.delete(B), n.add(`closed:${B}`)) : (n.add(B), n.delete(`closed:${B}`)), o(), M.textContent = A.open ? m.dataset.collapsedActivityTitle ?? "Activities" : "Activities";
17712
17729
  }), A.appendChild(L);
17713
17730
  const z = document.createElement("div");
17714
17731
  z.className = "pluno-pa-widget__tool-lines", A.addEventListener("toggle", () => {
17715
- m.dataset.responseGroupKey, m.classList.toggle("pluno-pa-widget__tool-group--open", A.open), P.textContent = A.open ? "Activities" : m.dataset.collapsedActivityTitle ?? "Activities";
17732
+ m.dataset.responseGroupKey, m.classList.toggle("pluno-pa-widget__tool-group--open", A.open), M.textContent = A.open ? "Activities" : m.dataset.collapsedActivityTitle ?? "Activities";
17716
17733
  }), u = {
17717
17734
  node: m,
17718
- character: w,
17735
+ character: _,
17719
17736
  characterSignature: I,
17720
17737
  activeContent: x,
17721
17738
  thinkingStatus: E,
17722
17739
  details: A,
17723
17740
  summary: L,
17724
- summaryTitle: P,
17741
+ summaryTitle: M,
17725
17742
  lines: z,
17726
17743
  lineNodes: /* @__PURE__ */ new Map()
17727
17744
  }, i.set(c, u);
@@ -17731,8 +17748,8 @@ function O_(t, e, n, i, s, o, a, r = !0) {
17731
17748
  "pluno-pa-widget__character--tool-group",
17732
17749
  a
17733
17750
  ), d.characterSignature = p);
17734
- const f = d.node;
17735
- f.className = "pluno-pa-widget__tool-group", f.dataset.responseGroupKey = c, f.classList.toggle("pluno-pa-widget__tool-group--active", e), f.title = new Date(
17751
+ const g = d.node;
17752
+ g.className = "pluno-pa-widget__tool-group", g.dataset.responseGroupKey = c, g.classList.toggle("pluno-pa-widget__tool-group--active", e), g.title = new Date(
17736
17753
  t[t.length - 1].createdAt
17737
17754
  ).toLocaleString();
17738
17755
  const y = D_(
@@ -17746,19 +17763,19 @@ function O_(t, e, n, i, s, o, a, r = !0) {
17746
17763
  return Lt(m, [
17747
17764
  d.thinkingStatus,
17748
17765
  y
17749
- ]), Lt(f, [d.character, m]), f;
17766
+ ]), Lt(g, [d.character, m]), g;
17750
17767
  }
17751
- const g = d.details;
17752
- g.open = n.has(c) || !n.has(`closed:${c}`) && !r, f.classList.toggle("pluno-pa-widget__tool-group--open", g.open);
17753
- const b = t[t.length - 1], _ = oo(
17768
+ const f = d.details;
17769
+ f.open = n.has(c) || !n.has(`closed:${c}`) && !r, g.classList.toggle("pluno-pa-widget__tool-group--open", f.open);
17770
+ const b = t[t.length - 1], w = oo(
17754
17771
  b.content
17755
- ).trim(), S = b.phase === "commentary", k = _ ? S ? _ : hp(_) : l ? "Steered" : "Thinking...";
17756
- return f.dataset.collapsedActivityTitle = k, d.summaryTitle.replaceChildren(), d.summaryTitle.classList.add(
17772
+ ).trim(), S = b.phase === "commentary", k = w ? S ? w : hp(w) : l ? "Steered" : "Thinking...";
17773
+ return g.dataset.collapsedActivityTitle = k, d.summaryTitle.replaceChildren(), d.summaryTitle.classList.add(
17757
17774
  "pluno-pa-widget__tool-summary-markdown"
17758
17775
  ), ic(
17759
17776
  d.summaryTitle,
17760
- g.open ? "Activities" : k
17761
- ), Lt(g, [d.summary, y]), Lt(f, [d.character, g]), f;
17777
+ f.open ? "Activities" : k
17778
+ ), Lt(f, [d.summary, y]), Lt(g, [d.character, f]), g;
17762
17779
  }
17763
17780
  function D_(t, e, n, i) {
17764
17781
  const s = Ob(
@@ -17772,12 +17789,12 @@ function D_(t, e, n, i) {
17772
17789
  i.set(c, u), u.className = "pluno-pa-widget__tool-line", u.dataset.eventType = l.phase === "commentary" ? "commentary" : "tool", l.phase === "commentary" ? delete u.dataset.toolCallKey : u.dataset.toolCallKey = c, u.dataset.canonicalItemKey = l.id, l.runId ? u.dataset.runId = l.runId : delete u.dataset.runId;
17773
17790
  const d = u.querySelector(".pluno-pa-widget__tool-line-text") ?? document.createElement("div");
17774
17791
  d.className = "pluno-pa-widget__tool-line-text";
17775
- const p = oo(l.content) || (l.phase === "commentary" ? "" : "Run tool"), f = l.phase === "commentary" ? p : hp(p);
17776
- s[r] ? (d.classList.add("pluno-pa-widget__tool-line-text--loading"), d.dataset.loadingText = cg(f)) : delete d.dataset.loadingText, d.classList.add("pluno-pa-widget__tool-line-markdown"), d.replaceChildren();
17792
+ const p = oo(l.content) || (l.phase === "commentary" ? "" : "Run tool"), g = l.phase === "commentary" ? p : hp(p);
17793
+ s[r] ? (d.classList.add("pluno-pa-widget__tool-line-text--loading"), d.dataset.loadingText = cg(g)) : delete d.dataset.loadingText, d.classList.add("pluno-pa-widget__tool-line-markdown"), d.replaceChildren();
17777
17794
  const y = document.createElement("div");
17778
- if (y.className = "pluno-pa-widget__tool-line-markdown", ic(y, f), d.append(y), s[r]) {
17779
- const g = y.cloneNode(!0);
17780
- g.classList.add("pluno-pa-widget__tool-loading-overlay"), g.setAttribute("aria-hidden", "true"), g.inert = !0, d.append(g);
17795
+ if (y.className = "pluno-pa-widget__tool-line-markdown", ic(y, g), d.append(y), s[r]) {
17796
+ const f = y.cloneNode(!0);
17797
+ f.classList.add("pluno-pa-widget__tool-loading-overlay"), f.setAttribute("aria-hidden", "true"), f.inert = !0, d.append(f);
17781
17798
  }
17782
17799
  u.replaceChildren(d), o.push(u);
17783
17800
  }
@@ -17912,8 +17929,8 @@ function B_(t, e) {
17912
17929
  o.className = "pluno-pa-widget__table-scroll";
17913
17930
  const a = document.createElement("table"), r = document.createElement("thead"), l = document.createElement("tr");
17914
17931
  n.forEach((d, p) => {
17915
- const f = document.createElement("th"), y = s[p];
17916
- y && f.classList.add(`pluno-pa-widget__table-cell--${y}`), fn(f, d), l.appendChild(f);
17932
+ const g = document.createElement("th"), y = s[p];
17933
+ y && g.classList.add(`pluno-pa-widget__table-cell--${y}`), fn(g, d), l.appendChild(g);
17917
17934
  }), r.appendChild(l), a.appendChild(r);
17918
17935
  const c = document.createElement("tbody");
17919
17936
  let u = e + 2;
@@ -17922,9 +17939,9 @@ function B_(t, e) {
17922
17939
  if (!d)
17923
17940
  break;
17924
17941
  const p = document.createElement("tr");
17925
- n.forEach((f, y) => {
17926
- const g = document.createElement("td"), b = s[y];
17927
- b && g.classList.add(`pluno-pa-widget__table-cell--${b}`), fn(g, d[y] ?? ""), p.appendChild(g);
17942
+ n.forEach((g, y) => {
17943
+ const f = document.createElement("td"), b = s[y];
17944
+ b && f.classList.add(`pluno-pa-widget__table-cell--${b}`), fn(f, d[y] ?? ""), p.appendChild(f);
17928
17945
  }), c.appendChild(p), u += 1;
17929
17946
  }
17930
17947
  return a.appendChild(c), o.appendChild(a), { element: o, nextIndex: u };
@@ -17945,9 +17962,9 @@ function ic(t, e) {
17945
17962
  for (i += 1; i < n.length && !/^```\s*$/.test(n[i]); )
17946
17963
  d.push(n[i]), i += 1;
17947
17964
  i += i < n.length ? 1 : 0;
17948
- const p = document.createElement("pre"), f = document.createElement("code");
17949
- f.textContent = d.join(`
17950
- `), p.appendChild(f), t.appendChild(p);
17965
+ const p = document.createElement("pre"), g = document.createElement("code");
17966
+ g.textContent = d.join(`
17967
+ `), p.appendChild(g), t.appendChild(p);
17951
17968
  continue;
17952
17969
  }
17953
17970
  const a = B_(n, i);