@pluno/product-agent-web 0.1.280 → 0.1.281

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.280", ai = {
40
+ const Gp = "0.1.281", 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) {
@@ -661,10 +661,10 @@ function gn(t, e, n) {
661
661
  let S = b ? "submitting" : w ? "awaiting_execution" : d?.phase ?? "idle";
662
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 _ = ["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, E = I?.userMessageIds.filter((C) => !["completed", "failed"].includes(o?.executionByUserMessage[C]?.phase ?? "")) ?? [], q = E.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 || 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.
667
+ }), x = d?.user_message_ids ?? [], M = b || w ? f?.userMessageId ?? null : x[x.length - 1] ?? null, P = u.find((C) => C.userMessageId === M), z = _ ? [...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.
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,
@@ -682,9 +682,9 @@ function gn(t, e, n) {
682
682
  removedItems: o?.removedItems ?? {},
683
683
  streamStates: c,
684
684
  preparation: o?.preparation ?? null,
685
- stop: I ? { ...I, userMessageIds: x, pending: E } : null,
686
- segments: u.map((C, U) => ({ ...C, collapsed: _ ? C.userMessageId !== L : U < u.length - 1 || C.activityIds.length > 0 })),
687
- activity: { phase: S, activeItemId: z, userMessageId: L, executionKey: JSON.stringify([...Tt(d)].sort()) },
685
+ stop: I ? { ...I, userMessageIds: E, pending: q } : null,
686
+ segments: u.map((C, U) => ({ ...C, collapsed: _ ? C.userMessageId !== M : U < u.length - 1 || C.activityIds.length > 0 })),
687
+ activity: { phase: S, activeItemId: z, userMessageId: M, 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.
690
690
  receipts: i.filter((C) => !C.cancelled && e.clients[C.clientScopeId] === n).map((C) => ({ viewId: C.viewId, userMessageId: C.userMessageId, acceptedRendererRevision: C.rendererRevision, durable: t.durableSubmissionIds.includes(C.userMessageId) || C.delivery === "accepted" }))
@@ -1189,13 +1189,13 @@ function Yr(t, e, n) {
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
1191
  const l = (m, _) => {
1192
- const I = { ...i.features.contextObservers }, x = I[m];
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 };
1192
+ const I = { ...i.features.contextObservers }, E = I[m];
1193
+ if (_ === null ? delete I[m] : I[m] = ft(r, { kind: "originContext", clientScopeId: m, origin: _, pageUrl: "" }), o({ contextObservers: I }), !E || Object.values(I).includes(E)) return;
1194
+ const q = { ...i.features.queries }, x = { ...i.features.polls }, M = { ...i.features.contextReads }, P = { ...i.features.originContextQueries }, z = { ...i.features.pending }, B = P[E]?.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 M[x];
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: M, contextRunOrigins: C, pending: z });
1196
+ delete q[E], delete x[E], delete M[E], delete P[E];
1197
+ for (const [U, X] of Object.entries(z)) X.mode === "query" && X.key === E && delete z[U];
1198
+ o({ queries: q, polls: x, contextReads: M, originContextQueries: P, contextRunOrigins: C, pending: z });
1199
1199
  };
1200
1200
  if (e.type === "stage7.account_fallback") return { state: { ...i, account: {
1201
1201
  ...i.account,
@@ -1214,32 +1214,32 @@ function Yr(t, e, n) {
1214
1214
  return { state: _.state, effects: [...m.effects, ..._.effects] };
1215
1215
  }
1216
1216
  const u = (m, _, I) => {
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 && (_ === "check" || L.action !== "check"))) return;
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: _ } } }), s.push({ kind: "stage7.device", id: E, input: { authority: r, requestId: I, feature: m, action: _, now: i.features.now } });
1217
+ const E = m === "notifications" ? "canRequestNotificationPermission" : "canGroupSessionTabs";
1218
+ if (!Ke(r.profile, E) || ji(i, m) !== !0 || i.features.desiredPreferences[m] === !1 || Object.values(i.interactions.devicePending).some((M) => M.feature === m && (_ === "check" || M.action !== "check"))) return;
1219
+ const q = Pn(r, "device", I), x = { ...i.interactions.deviceErrors };
1220
+ delete x[m], a({ deviceErrors: x, devicePending: { ...i.interactions.devicePending, [q]: { feature: m, requestId: I, generation: r.generation, desired: !0, action: _ } } }), s.push({ kind: "stage7.device", id: q, input: { authority: r, requestId: I, feature: m, action: _, now: i.features.now } });
1221
1221
  }, d = (m, _) => {
1222
- const I = _ ? i.interactions.promptActions[_.replace(/:ack$/, "")] : void 0, x = { ...i.interactions.openings };
1223
- for (const [E, A] of Object.entries(x)) {
1224
- if (I?.scope === E && I.openingGeneration === A.generation && ["enable", "allow"].includes(I.action)) continue;
1225
- const L = { ...A.shown };
1226
- delete L[m], x[E] = {
1227
- ...A,
1228
- shown: L,
1229
- turns: Object.fromEntries(Object.entries(A.turns).map(([M, z]) => [M, { ...z, [m]: !1, [`${m}Suppressed`]: !0 }]))
1222
+ const I = _ ? i.interactions.promptActions[_.replace(/:ack$/, "")] : void 0, E = { ...i.interactions.openings };
1223
+ for (const [q, x] of Object.entries(E)) {
1224
+ if (I?.scope === q && I.openingGeneration === x.generation && ["enable", "allow"].includes(I.action)) continue;
1225
+ const M = { ...x.shown };
1226
+ delete M[m], E[q] = {
1227
+ ...x,
1228
+ shown: M,
1229
+ turns: Object.fromEntries(Object.entries(x.turns).map(([P, z]) => [P, { ...z, [m]: !1, [`${m}Suppressed`]: !0 }]))
1230
1230
  };
1231
1231
  }
1232
- a({ openings: x });
1232
+ a({ openings: E });
1233
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
- const x = I === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled";
1237
- m.value[x] !== i.account.preferences[x] && d(I, _);
1236
+ const E = I === "notifications" ? "taskNotificationsEnabled" : "tabGroupingEnabled";
1237
+ m.value[E] !== i.account.preferences[E] && d(I, _);
1238
1238
  }
1239
1239
  if (m.kind === "preferencePrompts" || m.kind === "preferencePrompt")
1240
1240
  for (const I of ["notifications", "tab_grouping"]) {
1241
- const x = m.kind === "preferencePrompts" ? m.value[I] : m.feature === I ? m.value : null;
1242
- x && x.revision > i.interactions.preferencePrompts[I].revision && d(I, x.requestId);
1241
+ const E = m.kind === "preferencePrompts" ? m.value[I] : m.feature === I ? m.value : null;
1242
+ E && E.revision > i.interactions.preferencePrompts[I].revision && d(I, E.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
1245
  }, g = (m, _) => {
@@ -1247,43 +1247,43 @@ function Yr(t, e, n) {
1247
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
1248
  }, y = (m, _, I = !1) => {
1249
1249
  $n(r, m);
1250
- const x = ft(r, m), E = Pn(r, "query", _);
1250
+ const E = ft(r, m), q = Pn(r, "query", _);
1251
1251
  if (m.kind === "originContext") {
1252
- const z = i.features.queries[x], B = i.features.contextReads[x];
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;
1254
- }
1255
- const A = i.features.pending[E];
1256
- if (A && A.fingerprint !== JSON.stringify(m)) throw new Error("Query request ID changed payload.");
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), M = ti(L, { key: x, requestId: Et(_), mode: "replace" });
1259
- o({ queries: { ...i.features.queries, [x]: M }, pending: { ...i.features.pending, [E]: {
1252
+ const z = i.features.queries[E], B = i.features.contextReads[E];
1253
+ if (o({ originContextQueries: { ...i.features.originContextQueries, [E]: 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;
1254
+ }
1255
+ const x = i.features.pending[q];
1256
+ if (x && x.fingerprint !== JSON.stringify(m)) throw new Error("Query request ID changed payload.");
1257
+ if (x?.status === "pending" || Object.values(i.features.pending).some((z) => z.mode === "query" && z.key === E && z.status === "pending")) return;
1258
+ const M = i.features.queries[E] ?? Xt(E), P = ti(M, { key: E, requestId: Et(_), mode: "replace" });
1259
+ o({ queries: { ...i.features.queries, [E]: P }, pending: { ...i.features.pending, [q]: {
1260
1260
  requestId: _,
1261
- effectId: E,
1261
+ effectId: q,
1262
1262
  fingerprint: JSON.stringify(m),
1263
- key: x,
1263
+ key: E,
1264
1264
  generation: r.generation,
1265
1265
  operation: m,
1266
1266
  mode: "query",
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(_), mode: "replace" }) } }), s.push({ kind: "stage7.query", id: E, input: { authority: r, requestId: _, query: m } });
1270
+ } } }), m.kind === "account" && (i = { ...i, account: { ...i.account, query: ti(i.account.query, { key: E, requestId: Et(_), mode: "replace" }) } }), s.push({ kind: "stage7.query", id: q, input: { authority: r, requestId: _, query: m } });
1271
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", _), E = JSON.stringify(m), A = i.features.pending[x];
1274
- if (A) {
1275
- if (A.fingerprint !== E) throw new Error("Request ID was reused with a different payload.");
1276
- if (!I || A.status !== "error") return;
1273
+ const E = Pn(r, "mutate", _), q = JSON.stringify(m), x = i.features.pending[E];
1274
+ if (x) {
1275
+ if (x.fingerprint !== q) throw new Error("Request ID was reused with a different payload.");
1276
+ if (!I || x.status !== "error") return;
1277
1277
  if (!["decision", "preferenceSnooze", "preferenceAcknowledge"].includes(m.kind)) throw new Error("This operation cannot be replayed automatically.");
1278
- if (["conflict", "409"].includes(A.error?.code ?? "")) throw new Error("Refresh the conflicting decision before making another choice.");
1279
- }
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
- const L = i.features.queuedPreferences[m.feature];
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
- requestId: L.requestId,
1286
- effectId: M,
1278
+ if (["conflict", "409"].includes(x.error?.code ?? "")) throw new Error("Refresh the conflicting decision before making another choice.");
1279
+ }
1280
+ if (m.kind === "preference" && (o({ desiredPreferences: { ...i.features.desiredPreferences, [m.feature]: m.enabled } }), Object.values(i.features.pending).some((M) => M.status === "pending" && M.operation.kind === "preference" && M.operation.feature === m.feature))) {
1281
+ const M = i.features.queuedPreferences[m.feature];
1282
+ if (M && M.requestId !== _) {
1283
+ const P = Pn(r, "mutate", M.requestId), z = { kind: "preference", feature: m.feature, enabled: M.enabled };
1284
+ o({ pending: { ...i.features.pending, [P]: {
1285
+ requestId: M.requestId,
1286
+ effectId: P,
1287
1287
  fingerprint: JSON.stringify(z),
1288
1288
  key: al(z),
1289
1289
  generation: r.generation,
@@ -1298,10 +1298,10 @@ function Yr(t, e, n) {
1298
1298
  return;
1299
1299
  }
1300
1300
  if (m.kind === "generatePrompts") {
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" }) } });
1301
+ const M = { kind: "starterPrompts", ...m.page, includeUserSuggestions: m.includeUserSuggestions ?? !1 }, P = ft(r, M), z = i.features.queries[P] ?? Xt(P);
1302
+ o({ queries: { ...i.features.queries, [P]: ti(z, { key: P, requestId: Et(_), mode: "replace" }) } });
1303
1303
  }
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 } });
1304
+ o({ pending: { ...i.features.pending, [E]: { requestId: _, effectId: E, fingerprint: q, key: al(m), generation: r.generation, operation: m, mode: "mutation", status: "pending", error: null, result: null } } }), s.push({ kind: "stage7.mutate", id: E, input: { authority: r, requestId: _, mutation: m } });
1305
1305
  }, b = (m) => {
1306
1306
  if (!(!Ke(r.profile, "canManagePreferences") || i.features.refreshBatch)) {
1307
1307
  for (const _ of Object.values(i.features.pending))
@@ -1313,13 +1313,13 @@ function Yr(t, e, n) {
1313
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 || _;
1317
- if (x.length) o({ refreshBatch: { pending: x, failed: E } });
1316
+ const E = I.pending.filter((x) => x !== m), q = I.failed || _;
1317
+ if (E.length) o({ refreshBatch: { pending: E, failed: q } });
1318
1318
  else {
1319
- const A = E ? i.features.failures + 1 : 0;
1320
- o({ refreshBatch: null, failures: A, refreshAt: i.features.now + Math.min(6e4 * 2 ** A, 9e5) });
1321
- const L = i.features.refreshQueuedRequestId;
1322
- L && (o({ refreshQueuedRequestId: null }), b(L));
1319
+ const x = q ? i.features.failures + 1 : 0;
1320
+ o({ refreshBatch: null, failures: x, refreshAt: i.features.now + Math.min(6e4 * 2 ** x, 9e5) });
1321
+ const M = i.features.refreshQueuedRequestId;
1322
+ M && (o({ refreshQueuedRequestId: null }), b(M));
1323
1323
  }
1324
1324
  }
1325
1325
  };
@@ -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 _ = { ...i.features.queries }, I = { ...i.features.pending }, x = [];
1331
- for (const [E, A] of Object.entries(I)) {
1332
- if (A.operation.kind !== "account" || A.status === "done" || A.status === "error") continue;
1333
- const L = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
1334
- I[E] = { ...A, status: "error", error: L }, x.push(E);
1335
- const M = _[A.key];
1336
- M && (_[A.key] = bs(M, { key: A.key, requestId: Et(A.requestId), error: L }));
1330
+ const _ = { ...i.features.queries }, I = { ...i.features.pending }, E = [];
1331
+ for (const [q, x] of Object.entries(I)) {
1332
+ if (x.operation.kind !== "account" || x.status === "done" || x.status === "error") continue;
1333
+ const M = { code: e.code, message: "The backend refused account access. Refresh account status before retrying.", retryable: !0 };
1334
+ I[q] = { ...x, status: "error", error: M }, E.push(q);
1335
+ const P = _[x.key];
1336
+ P && (_[x.key] = bs(P, { key: x.key, requestId: Et(x.requestId), error: M }));
1337
1337
  }
1338
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) w(E, !0);
1343
+ for (const q of E) w(q, !0);
1344
1344
  break;
1345
1345
  }
1346
1346
  case "stage7.context_observe":
@@ -1384,7 +1384,7 @@ 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)), _ = Object.fromEntries(Object.entries(e.checkpoint.openings).filter(([I, x]) => m.has(I) && n.directory.selections[I]?.sessionId === x.sessionId));
1387
+ const m = new Set(Object.values(n.directory.clients)), _ = Object.fromEntries(Object.entries(e.checkpoint.openings).filter(([I, E]) => m.has(I) && n.directory.selections[I]?.sessionId === E.sessionId));
1388
1388
  a({ ...e.checkpoint, openings: _, openingGeneration: Math.max(i.interactions.openingGeneration, e.checkpoint.openingGeneration) });
1389
1389
  break;
1390
1390
  }
@@ -1406,8 +1406,8 @@ function Yr(t, e, n) {
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
1408
  for (const [_, I] of Object.entries(m)) {
1409
- const x = I.turns[e.userMessageId];
1410
- I.sessionId === e.sessionId && x && !x.tab_groupingSuppressed && (m[_] = { ...I, turns: { ...I.turns, [e.userMessageId]: { ...x, tab_grouping: !0 } } });
1409
+ const E = I.turns[e.userMessageId];
1410
+ I.sessionId === e.sessionId && E && !E.tab_groupingSuppressed && (m[_] = { ...I, turns: { ...I.turns, [e.userMessageId]: { ...E, tab_grouping: !0 } } });
1411
1411
  }
1412
1412
  a({ openings: m });
1413
1413
  break;
@@ -1444,13 +1444,13 @@ function Yr(t, e, n) {
1444
1444
  const m = { ...i.interactions.sources };
1445
1445
  for (const _ of e.sources) {
1446
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.");
1447
+ const I = JSON.stringify([_.conversation_id, _.id]), E = m[I];
1448
+ if (!(E && E.version >= _.version)) {
1449
+ if (E && E.payload.kind !== _.payload.kind) throw new Error("Interaction source changed category.");
1450
1450
  m[I] = {
1451
1451
  ..._,
1452
- lifecycle: x?.lifecycle === "completed" ? "completed" : _.lifecycle,
1453
- payload: x?.payload.kind === "sharing" && _.payload.kind === "sharing" ? { ..._.payload, variant: x.payload.variant } : _.payload
1452
+ lifecycle: E?.lifecycle === "completed" ? "completed" : _.lifecycle,
1453
+ payload: E?.payload.kind === "sharing" && _.payload.kind === "sharing" ? { ..._.payload, variant: E.payload.variant } : _.payload
1454
1454
  };
1455
1455
  }
1456
1456
  }
@@ -1488,11 +1488,11 @@ function Yr(t, e, n) {
1488
1488
  if (e.effectId !== i.features.timerId) break;
1489
1489
  if (o({ timerId: null, timerDeadline: null, schedulerError: e.type === "effect.failed" ? e.error : null }), e.type === "effect.completed") {
1490
1490
  o({ now: e.output.now }), i = Xo(i, n.conversation, n.directory, e.output.now);
1491
- for (const [I, x] of Object.entries(i.features.polls)) {
1492
- if (x.deadline > e.output.now) continue;
1493
- Object.values(i.features.pending).some((A) => A.mode === "query" && A.key === I && A.status === "pending") || y(x.query.kind === "originContext" ? { ...x.query, trigger: "poll" } : x.query, `poll:${I}:${e.output.now}`, !0);
1494
- const E = { ...i.features.polls };
1495
- delete E[I], o({ polls: E });
1491
+ for (const [I, E] of Object.entries(i.features.polls)) {
1492
+ if (E.deadline > e.output.now) continue;
1493
+ Object.values(i.features.pending).some((x) => x.mode === "query" && x.key === I && x.status === "pending") || y(E.query.kind === "originContext" ? { ...E.query, trigger: "poll" } : E.query, `poll:${I}:${e.output.now}`, !0);
1494
+ const q = { ...i.features.polls };
1495
+ delete q[I], o({ polls: q });
1496
1496
  }
1497
1497
  i.features.refreshAt !== null && e.output.now >= i.features.refreshAt && b(`timer:${e.output.now}`);
1498
1498
  }
@@ -1501,15 +1501,15 @@ function Yr(t, e, n) {
1501
1501
  if (e.effectKind === "stage7.device") {
1502
1502
  const I = i.interactions.devicePending[e.effectId];
1503
1503
  if (!I) break;
1504
- const x = { ...i.interactions.devicePending };
1505
- if (delete x[e.effectId], a({ devicePending: x }), e.type === "effect.completed") {
1504
+ const E = { ...i.interactions.devicePending };
1505
+ if (delete E[e.effectId], a({ devicePending: E }), 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
- const E = i.interactions.promptActions[I.requestId];
1508
- d(E.feature, I.requestId), f({
1507
+ const q = i.interactions.promptActions[I.requestId];
1508
+ d(q.feature, I.requestId), f({
1509
1509
  kind: "preferenceAcknowledge",
1510
- feature: E.feature,
1511
- action: E.action,
1512
- expectedRevision: E.expectedRevision
1510
+ feature: q.feature,
1511
+ action: q.action,
1512
+ expectedRevision: q.expectedRevision
1513
1513
  }, `${I.requestId}:ack`);
1514
1514
  }
1515
1515
  g(I.feature, e.output.fact);
@@ -1522,20 +1522,20 @@ function Yr(t, e, n) {
1522
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
- const x = i.features.queries[m.key];
1526
- if (!x || x.requestId !== m.requestId) break;
1525
+ const E = i.features.queries[m.key];
1526
+ if (!E || E.requestId !== m.requestId) break;
1527
1527
  if (["originContext", "userContext", "contextRun"].includes(m.operation.kind)) {
1528
- const E = { ...i.features.polls };
1529
- delete E[m.key], o({ polls: E, contextReads: { ...i.features.contextReads, [m.key]: {
1528
+ const q = { ...i.features.polls };
1529
+ delete q[m.key], o({ polls: q, contextReads: { ...i.features.contextReads, [m.key]: {
1530
1530
  settledAt: _ ? i.features.now : e.output.completedAt,
1531
1531
  failures: _ ? (i.features.contextReads[m.key]?.failures ?? 0) + 1 : 0
1532
1532
  } } });
1533
1533
  }
1534
1534
  if (_)
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 }) } });
1535
+ o({ queries: { ...i.features.queries, [m.key]: bs(E, { 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
- 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 }) } });
1538
+ o({ now: e.output.completedAt, queries: { ...i.features.queries, [m.key]: Zo(E, { 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
1540
  } else if (!_)
1541
1541
  o({ now: e.output.completedAt }), p(e.output.data, m.requestId);
@@ -1545,8 +1545,8 @@ function Yr(t, e, n) {
1545
1545
  }
1546
1546
  if (m.mode === "mutation" && m.operation.kind === "decision") {
1547
1547
  const I = { ...i.interactions.actions };
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: _ ? "error" : "done", error: _ ? e.error : null });
1548
+ for (const [E, q] of Object.entries(I))
1549
+ q.step === "persist" && m.requestId === `sharing:${E}` && (q.operation.kind === "copy" || q.operation.kind === "share") && (I[E] = { ...q, status: _ ? "error" : "done", error: _ ? e.error : null });
1550
1550
  a({ actions: I });
1551
1551
  }
1552
1552
  if (!_ && m.mode === "mutation" && m.operation.kind === "preference" && i.interactions.promptActions[m.requestId]) {
@@ -1559,85 +1559,85 @@ function Yr(t, e, n) {
1559
1559
  }, `${m.requestId}:ack`);
1560
1560
  }
1561
1561
  if (w(e.effectId, _), m.operation.kind === "generatePrompts") {
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]: _ ? 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 }) } });
1562
+ const I = { kind: "starterPrompts", ...m.operation.page, includeUserSuggestions: m.operation.includeUserSuggestions ?? !1 }, E = ft(r, I), q = i.features.queries[E];
1563
+ q?.requestId === m.requestId && o({ queries: { ...i.features.queries, [E]: _ ? bs(q, { key: E, requestId: Et(m.requestId), error: e.error }) : Zo(q, { key: E, requestId: Et(m.requestId), data: e.output.data, cursor: null, updatedAt: e.output.completedAt }) } });
1564
1564
  }
1565
1565
  if (!_ && e.output.data.kind === "originContext") {
1566
- const I = e.output.data, x = m.operation.kind === "originContext" || m.operation.kind === "refreshContext" ? m.operation.origin : null;
1567
- if (x) {
1566
+ const I = e.output.data, E = m.operation.kind === "originContext" || m.operation.kind === "refreshContext" ? m.operation.origin : null;
1567
+ if (E) {
1568
1568
  if (I.value.runId && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status))
1569
- o({ contextRunOrigins: { ...i.features.contextRunOrigins, [I.value.runId]: x } });
1569
+ o({ contextRunOrigins: { ...i.features.contextRunOrigins, [I.value.runId]: E } });
1570
1570
  else {
1571
- const E = { ...i.features.contextRunOrigins };
1572
- for (const [A, L] of Object.entries(E)) L === x && delete E[A];
1573
- o({ contextRunOrigins: E });
1571
+ const q = { ...i.features.contextRunOrigins };
1572
+ for (const [x, M] of Object.entries(q)) M === E && delete q[x];
1573
+ o({ contextRunOrigins: q });
1574
1574
  }
1575
1575
  if (m.mode === "mutation") {
1576
- const E = { ...i.features.queries }, A = { ...i.features.pending }, L = { ...i.features.contextReads }, M = { ...i.features.polls };
1576
+ const q = { ...i.features.queries }, x = { ...i.features.pending }, M = { ...i.features.contextReads }, P = { ...i.features.polls };
1577
1577
  for (const [z, B] of Object.entries(i.features.originContextQueries))
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 M[z];
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) && (M[z] = { query: { ...B, kind: "originContext", trigger: "poll" }, deadline: i.features.now + 5e3 });
1578
+ if (B.origin === E) {
1579
+ q[z] = { ...q[z], data: I, status: "ready", error: null, requestId: null, updatedAt: e.output.completedAt }, M[z] = { settledAt: e.output.completedAt, failures: 0 }, delete P[z];
1580
+ for (const [C, U] of Object.entries(x)) U.mode === "query" && U.key === z && delete x[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 });
1582
1582
  }
1583
- o({ queries: E, pending: A, contextReads: L, polls: M });
1583
+ o({ queries: q, pending: x, contextReads: M, polls: P });
1584
1584
  }
1585
1585
  }
1586
1586
  }
1587
1587
  if (!_ && e.output.data.kind === "contextRun" && !["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(e.output.data.value.status)) {
1588
- const I = e.output.data.value.runId, x = I ? i.features.contextRunOrigins[I] : null;
1589
- if (x && I) {
1590
- const E = { ...i.features.contextRunOrigins };
1591
- delete E[I], o({ contextRunOrigins: E });
1592
- for (const [A, L] of Object.entries(i.features.originContextQueries)) {
1593
- if (L.origin !== x) continue;
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);
1588
+ const I = e.output.data.value.runId, E = I ? i.features.contextRunOrigins[I] : null;
1589
+ if (E && I) {
1590
+ const q = { ...i.features.contextRunOrigins };
1591
+ delete q[I], o({ contextRunOrigins: q });
1592
+ for (const [x, M] of Object.entries(i.features.originContextQueries)) {
1593
+ if (M.origin !== E) continue;
1594
+ const P = { ...i.features.pending };
1595
+ for (const [z, B] of Object.entries(P)) B.mode === "query" && B.key === x && delete P[z];
1596
+ o({ pending: P }), y({ ...M, kind: "originContext" }, `context-final:${m.requestId}:${x}`, !0);
1597
1597
  }
1598
1598
  }
1599
1599
  }
1600
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
- 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;
1604
- if (x && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status)) {
1605
- const E = ft(r, x);
1606
- o({ polls: { ...i.features.polls, [E]: { query: x, deadline: i.features.now + 5e3 } } });
1603
+ const E = 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;
1604
+ if (E && ["queued", "pending", "running", "in_progress", "stopping", "cancel_requested"].includes(I.value.status)) {
1605
+ const q = ft(r, E);
1606
+ o({ polls: { ...i.features.polls, [q]: { query: E, deadline: i.features.now + 5e3 } } });
1607
1607
  }
1608
1608
  }
1609
1609
  }
1610
1610
  if (!_ && m.operation.kind === "stopContext")
1611
- for (const [I, x] of Object.entries(i.features.originContextQueries)) {
1612
- const E = i.features.queries[I]?.data;
1613
- if (E?.kind === "originContext" && E.value.runId === m.operation.runId) {
1614
- const A = { ...i.features.pending };
1615
- for (const [L, M] of Object.entries(A)) M.mode === "query" && M.key === I && delete A[L];
1616
- o({ pending: A }), y({ ...x, kind: "originContext" }, `context-stop:${m.requestId}:${I}`, !0);
1611
+ for (const [I, E] of Object.entries(i.features.originContextQueries)) {
1612
+ const q = i.features.queries[I]?.data;
1613
+ if (q?.kind === "originContext" && q.value.runId === m.operation.runId) {
1614
+ const x = { ...i.features.pending };
1615
+ for (const [M, P] of Object.entries(x)) P.mode === "query" && P.key === I && delete x[M];
1616
+ o({ pending: x }), y({ ...E, kind: "originContext" }, `context-stop:${m.requestId}:${I}`, !0);
1617
1617
  }
1618
1618
  }
1619
1619
  if (_ && m.mode === "query" && ["originContext", "userContext", "contextRun"].includes(m.operation.kind) && e.error.retryable && (i.features.contextReads[m.key]?.failures ?? 0) <= 3) {
1620
- const I = m.operation, x = ft(r, I);
1621
- o({ polls: { ...i.features.polls, [x]: { query: I, deadline: i.features.now + 5e3 * (i.features.contextReads[m.key]?.failures ?? 1) } } });
1620
+ const I = m.operation, E = ft(r, I);
1621
+ o({ polls: { ...i.features.polls, [E]: { 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 = _ ? i.features.suggestionReadFailures + 1 : 0, x = { ...i.features.polls };
1625
- delete x[m.key];
1626
- const E = _ && (e.error.retryable || ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.error.code));
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 });
1624
+ const I = _ ? i.features.suggestionReadFailures + 1 : 0, E = { ...i.features.polls };
1625
+ delete E[m.key];
1626
+ const q = _ && (e.error.retryable || ["connection_interrupted", "request_timed_out", "408", "425", "429", "500", "502", "503", "504"].includes(e.error.code));
1627
+ q && I <= 3 && (E[m.key] = { query: m.operation, deadline: i.features.now + 1e3 * 2 ** (I - 1) }), o({ suggestionReadFailures: I, suggestionRetryAfter: q && I > 3 ? i.features.now + 3e4 : null, polls: E });
1628
1628
  }
1629
1629
  if (m.operation.kind === "preference") {
1630
- const I = m.operation.feature, x = i.features.queuedPreferences[I];
1631
- if (x) {
1632
- const E = { ...i.features.queuedPreferences };
1633
- delete E[I], o({ queuedPreferences: E }), f({ kind: "preference", feature: I, enabled: x.enabled }, x.requestId);
1630
+ const I = m.operation.feature, E = i.features.queuedPreferences[I];
1631
+ if (E) {
1632
+ const q = { ...i.features.queuedPreferences };
1633
+ delete q[I], o({ queuedPreferences: q }), f({ kind: "preference", feature: I, enabled: E.enabled }, E.requestId);
1634
1634
  } else {
1635
- const E = { ...i.features.desiredPreferences };
1636
- delete E[I], o({ desiredPreferences: E });
1635
+ const q = { ...i.features.desiredPreferences };
1636
+ delete q[I], o({ desiredPreferences: q });
1637
1637
  }
1638
1638
  }
1639
1639
  if (!_ && e.output.data.kind === "preferences") for (const I of ["notifications", "tab_grouping"]) u(I, "check", `preference:${m.requestId}:${I}`);
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 });
1640
+ i.features.refreshRequired && !i.features.refreshBatch && !i.features.refreshQueuedRequestId && ["account", "preferences", "preferencePrompts", "decisions"].every((I) => Object.values(i.features.queries).some((E) => E.data?.kind === I && E.status === "ready")) && o({ refreshRequired: !1 });
1641
1641
  break;
1642
1642
  }
1643
1643
  }
@@ -2460,7 +2460,7 @@ function Lh(t, e, n, i) {
2460
2460
  if (n.clients[e.clientScopeId] !== e.conversationScopeId) throw new Error("Submission selection has changed.");
2461
2461
  const { type: r, authorityId: l, generation: c, prepareContext: u, reconcileAcceptance: d, waitForAuthentication: p, ...g } = e, y = t.submissions[e.userMessageId];
2462
2462
  if (y) {
2463
- const { contextPreparation: m, requestedModel: _, sessionId: I, delivery: x, cancelled: E, cancellationReason: A, error: L, executionVersion: M, ...z } = y;
2463
+ const { contextPreparation: m, requestedModel: _, sessionId: I, delivery: E, cancelled: q, cancellationReason: x, error: M, executionVersion: P, ...z } = y;
2464
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
  }
@@ -2876,18 +2876,18 @@ function Uh(t, e, n, i) {
2876
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
2877
2877
  }])),
2878
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");
2879
+ const E = y.deliveries[m], q = _.contextPreparation === null && !E?.handoffRecovery, x = _.delivery === "accepted" ? "accepted" : E?.acceptance ?? (E && (E.step === "send" || E.step === "receipt") ? "uncertain" : "unissued");
2880
2880
  return [m, {
2881
2881
  ...ll(_, I),
2882
- ...x,
2883
- acceptance: A,
2884
- allocation: _.sessionId !== null ? "resolved" : x?.allocation ?? (x?.step === "upload" ? "uncertain" : "unissued"),
2882
+ ...E,
2883
+ acceptance: x,
2884
+ allocation: _.sessionId !== null ? "resolved" : E?.allocation ?? (E?.step === "upload" ? "uncertain" : "unissued"),
2885
2885
  effectId: null,
2886
2886
  // Readiness is authority-local and must be re-established after restart. Captured input stays immutable.
2887
- step: A === "uncertain" && (x?.step === "send" || x?.handoffRecovery) && x.phase !== "done" ? "receipt" : x?.step ?? null,
2888
- prepared: A === "accepted",
2889
- queuePosition: x?.queuePosition ?? I,
2890
- phase: A === "accepted" ? "done" : E || !x ? "failed" : ["running", "waiting"].includes(x.phase) ? "uncertain" : x.phase
2887
+ step: x === "uncertain" && (E?.step === "send" || E?.handoffRecovery) && E.phase !== "done" ? "receipt" : E?.step ?? null,
2888
+ prepared: x === "accepted",
2889
+ queuePosition: E?.queuePosition ?? I,
2890
+ phase: x === "accepted" ? "done" : q || !E ? "failed" : ["running", "waiting"].includes(E.phase) ? "uncertain" : E.phase
2891
2891
  }];
2892
2892
  })),
2893
2893
  operations: Object.fromEntries(Object.entries(y.operations).map(([m, _]) => [m, {
@@ -4050,33 +4050,33 @@ function ug(t, e, n, i) {
4050
4050
  }
4051
4051
  function ar(t, e, n, i) {
4052
4052
  const s = /* @__PURE__ */ new Map();
4053
- for (const E of t.segments)
4054
- for (const A of [...E.activityIds, ...E.outcomeIds]) s.set(A, E.userMessageId);
4055
- const o = t.items.map((E) => ug(
4056
- E,
4057
- s.get(E.id) ?? null,
4058
- t.streamStates[E.id],
4053
+ for (const x of t.segments)
4054
+ for (const M of [...x.activityIds, ...x.outcomeIds]) s.set(M, x.userMessageId);
4055
+ const o = t.items.map((x) => ug(
4056
+ x,
4057
+ s.get(x.id) ?? null,
4058
+ t.streamStates[x.id],
4059
4059
  n
4060
4060
  ));
4061
- for (const E of t.optimistic) o.push({
4062
- id: E.userMessageId,
4061
+ for (const x of t.optimistic) o.push({
4062
+ id: x.userMessageId,
4063
4063
  role: "user",
4064
- content: E.content,
4064
+ content: x.content,
4065
4065
  // There is no canonical timestamp before acceptance. Keep identity stable without fabricating one.
4066
4066
  createdAt: "",
4067
- retryable: E.delivery === "failed" && !["unauthorized", "401", "auth_reconnecting"].includes(E.error?.code ?? "") && ["delivery", "preparation"].includes(jd(t, E.userMessageId)?.type ?? ""),
4068
- attachments: E.attachments.map((A) => ({
4069
- id: A.sourceId,
4070
- name: A.name,
4071
- mimeType: A.mimeType,
4072
- sizeBytes: A.sizeBytes
4067
+ retryable: x.delivery === "failed" && !["unauthorized", "401", "auth_reconnecting"].includes(x.error?.code ?? "") && ["delivery", "preparation"].includes(jd(t, x.userMessageId)?.type ?? ""),
4068
+ attachments: x.attachments.map((M) => ({
4069
+ id: M.sourceId,
4070
+ name: M.name,
4071
+ mimeType: M.mimeType,
4072
+ sizeBytes: M.sizeBytes
4073
4073
  }))
4074
4074
  });
4075
- const a = t.segments.flatMap((E) => o.filter((A) => A.id === E.userMessageId || E.activityIds.includes(A.id) || E.outcomeIds.includes(A.id))), r = { ...t.removedItems };
4076
- for (const E of t.segments) {
4077
- if (!E.userMessageId) continue;
4078
- const A = o.find((L) => E.outcomeIds.includes(L.id) && !L.loading && (L.dataType === "run_status" || L.dataType === "run_error" || L.role === "assistant" && L.phase === "final_answer" && L.streamState === "finished"));
4079
- A && (r[`local-interrupted:${E.userMessageId}`] = A.id);
4075
+ const a = o, r = { ...t.removedItems };
4076
+ for (const x of t.segments) {
4077
+ if (!x.userMessageId) continue;
4078
+ const M = o.find((P) => x.outcomeIds.includes(P.id) && !P.loading && (P.dataType === "run_status" || P.dataType === "run_error" || P.role === "assistant" && P.phase === "final_answer" && P.streamState === "finished"));
4079
+ M && (r[`local-interrupted:${x.userMessageId}`] = M.id);
4080
4080
  }
4081
4081
  t.proactiveQuestion && a.push({
4082
4082
  id: t.proactiveQuestion.id,
@@ -4086,23 +4086,24 @@ function ar(t, e, n, i) {
4086
4086
  createdAt: "",
4087
4087
  loading: !1
4088
4088
  });
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) => {
4090
- const A = E.role === "user" ? y.get(E.id) : void 0;
4091
- return A?.error ? [E, {
4092
- id: `submission-error:${A.userMessageId}`,
4089
+ const l = t.activity.phase, c = t.submissions.filter((x) => !x.cancelled && !["accepted", "failed"].includes(x.delivery)), u = t.submissions[t.submissions.length - 1], d = [...t.items].reverse().find((x) => x.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((x) => (x !== u || g) && !x.cancelled && x.delivery === "failed" && x.error).map((x) => [x.userMessageId, x])), f = a.flatMap((x) => {
4090
+ const M = x.role === "user" ? y.get(x.id) : void 0;
4091
+ return M?.error ? [x, {
4092
+ id: `submission-error:${M.userMessageId}`,
4093
4093
  role: "system",
4094
4094
  dataType: "run_error",
4095
- respondsToUserMessageId: A.userMessageId,
4096
- content: A.error.message,
4095
+ respondsToUserMessageId: M.userMessageId,
4096
+ content: M.error.message,
4097
4097
  createdAt: "",
4098
4098
  loading: !1,
4099
- ...typeof A.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: A.error.details.securitySettingsUrl } : {}
4100
- }] : [E];
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 ? {
4099
+ ...typeof M.error.details?.securitySettingsUrl == "string" ? { securitySettingsUrl: M.error.details.securitySettingsUrl } : {}
4100
+ }] : [x];
4101
+ }), b = e?.error != null && t.historyRefreshFailure != null && t.historyRefreshFailure.consecutiveFailures < 4, w = b ? null : e?.error ?? null, S = [...t.submissions].reverse().find((x) => t.pendingDurabilityIds?.includes(x.userMessageId)), k = S ? {
4102
4102
  code: "submission_checkpoint_pending",
4103
4103
  message: uh,
4104
4104
  details: { requestId: S.requestId }
4105
- } : null, m = u?.delivery === "failed" && !u.cancelled && !g ? u.error : w ?? k, _ = {
4105
+ } : null, m = u?.delivery === "failed" && !u.cancelled && !g ? u.error : w ?? k;
4106
+ let I = {
4106
4107
  isRetrying: t.isRetrying ?? !1,
4107
4108
  historyRefreshFailure: m === e?.error ? t.historyRefreshFailure ?? null : null,
4108
4109
  conversationDiagnostics: {
@@ -4126,7 +4127,7 @@ function ar(t, e, n, i) {
4126
4127
  segments: t.segments,
4127
4128
  activity: t.activity,
4128
4129
  receipts: t.receipts,
4129
- activeScheduledFollowUps: t.followUps.map((E) => ({ taskId: E.task_id, dueAt: E.due_at })),
4130
+ activeScheduledFollowUps: t.followUps.map((x) => ({ taskId: x.task_id, dueAt: x.due_at })),
4130
4131
  // A selected, not-yet-requested conversation must not paint the empty new-chat welcome state.
4131
4132
  isLoadingSession: !!t.preparation || !t.isDraftSession && t.sessionId !== null && (!e || e.status === "not_requested" || (e.status === "loading" || b && a.length === 0) && e.data === null),
4132
4133
  // Streams are already canonical items. A second draft field would render the same text twice.
@@ -4135,7 +4136,7 @@ function ar(t, e, n, i) {
4135
4136
  assistantDraftPhase: null,
4136
4137
  assistantDraftRespondsToUserMessageId: null,
4137
4138
  assistantDraftRunId: null,
4138
- pendingMessageStatus: c.length ? c.some((E) => E.delivery === "uncertain") ? "reconnecting" : "sending" : null,
4139
+ pendingMessageStatus: c.length ? c.some((x) => x.delivery === "uncertain") ? "reconnecting" : "sending" : null,
4139
4140
  turnPhase: l === "submitting" ? "sending" : ["queued", "awaiting_execution"].includes(l) ? "starting" : ["thinking", "steering"].includes(l) ? "thinking" : null,
4140
4141
  isThinking: p,
4141
4142
  taskStatus: l === "completed" ? "completed" : l === "failed" ? "failed" : l === "stopped" || l === "stopping" ? "stopped" : p || l === "submitting" ? "working" : null,
@@ -4143,20 +4144,22 @@ function ar(t, e, n, i) {
4143
4144
  lastErrorCode: m?.code ?? null,
4144
4145
  lastErrorSecuritySettingsUrl: typeof m?.details?.securitySettingsUrl == "string" ? m.details.securitySettingsUrl : null
4145
4146
  };
4146
- let I = _;
4147
- for (const E of t.optimistic.filter((A) => A.cancelled && !t.stop?.userMessageIds.includes(A.userMessageId))) {
4148
- const A = gl(I, "", "stopped", [E.userMessageId], ml(E.cancellationReason));
4149
- I = { ...I, messages: A.messages, segments: A.segments };
4150
- }
4151
- if (!t.stop) return I;
4152
- const x = gl(
4153
- I,
4154
- "",
4155
- t.stop.pending ? "stopping" : "stopped",
4156
- t.stop.userMessageIds,
4157
- ml(t.stop.reason ?? "user_requested")
4158
- );
4159
- return { ..._, messages: x.messages, segments: x.segments };
4147
+ for (const x of t.optimistic.filter((M) => M.cancelled && !t.stop?.userMessageIds.includes(M.userMessageId))) {
4148
+ const M = gl(I, "", "stopped", [x.userMessageId], ml(x.cancellationReason));
4149
+ I = { ...I, messages: M.messages, segments: M.segments };
4150
+ }
4151
+ if (t.stop) {
4152
+ const x = gl(
4153
+ I,
4154
+ "",
4155
+ t.stop.pending ? "stopping" : "stopped",
4156
+ t.stop.userMessageIds,
4157
+ ml(t.stop.reason ?? "user_requested")
4158
+ );
4159
+ I = { ...I, messages: x.messages, segments: x.segments };
4160
+ }
4161
+ const E = new Map(I.segments.flatMap((x, M) => [x.userMessageId, ...x.activityIds, ...x.outcomeIds].filter((P) => P !== null).map((P) => [P, M]))), q = (x) => E.get(x.id) ?? E.get(x.respondsToUserMessageId ?? "") ?? 1 / 0;
4162
+ return { ...I, messages: [...I.messages].sort((x, M) => q(x) - q(M)) };
4160
4163
  }
4161
4164
  function ml(t) {
4162
4165
  switch (t) {
@@ -6915,55 +6918,55 @@ class pu {
6915
6918
  }
6916
6919
  async requestOnce(e, n, i, s, o, a, r, l = 1) {
6917
6920
  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 };
6918
- for (const [M, z] of Object.entries({ ...d, ...n }))
6919
- z != null && u.searchParams.set(M, String(z));
6921
+ for (const [P, z] of Object.entries({ ...d, ...n }))
6922
+ z != null && u.searchParams.set(P, String(z));
6920
6923
  this.requests.signal.throwIfAborted(), a?.throwIfAborted();
6921
- const p = new AbortController(), g = { trigger: null }, y = (M) => {
6922
- p.signal.aborted || (g.trigger = M, p.abort());
6924
+ const p = new AbortController(), g = { trigger: null }, y = (P) => {
6925
+ p.signal.aborted || (g.trigger = P, p.abort());
6923
6926
  }, f = () => y("transport_disposed"), b = () => y(["owner_disposed", "authority_retired", "observation_released", "request_replaced"].includes(a?.reason) ? a.reason : "caller_cancelled");
6924
6927
  this.requests.signal.addEventListener("abort", f, { once: !0 }), a?.addEventListener("abort", b, { once: !0 });
6925
6928
  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();
6926
- let I = null, x = !1, E = null, A = null, L = null;
6929
+ let I = null, E = !1, q = null, x = null, M = null;
6927
6930
  try {
6928
- const M = await Promise.resolve(fetch(u, {
6931
+ const P = await Promise.resolve(fetch(u, {
6929
6932
  method: s ?? (i === void 0 ? "GET" : "POST"),
6930
6933
  cache: "no-store",
6931
6934
  signal: p.signal,
6932
6935
  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 } : {} },
6933
6936
  ...i === void 0 ? {} : { body: JSON.stringify(i) }
6934
6937
  })).catch((z) => {
6935
- throw x = !0, z;
6938
+ throw E = !0, z;
6936
6939
  });
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))
6940
+ if (I = Date.now(), q = P.status, x = Sl(P.headers.get("x-request-id")), M = Sl(P.headers.get("x-cloud-trace-context")), !P.ok) {
6941
+ const z = P.status === 401 ? "unauthorized" : P.status === 426 ? "update_required" : String(P.status), B = (await P.json().catch(() => null))?.detail;
6942
+ 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))
6940
6943
  throw new N("Conversation unavailable", "conversation_access_denied");
6941
- if (o === "conversations" && e.endsWith("/snapshot") && M.status === 409 && B === "Display projection is not enabled")
6944
+ if (o === "conversations" && e.endsWith("/snapshot") && P.status === 409 && B === "Display projection is not enabled")
6942
6945
  throw new N("Conversation history is unavailable. Try loading this chat again after the service is ready.", "display_projection_disabled");
6943
- if (o === "conversations" && e === "/commands" && M.status === 409 && (B === "embedded_submission_conflict" || B === "embedded_submission_snapshot_unavailable"))
6946
+ if (o === "conversations" && e === "/commands" && P.status === 409 && (B === "embedded_submission_conflict" || B === "embedded_submission_snapshot_unavailable"))
6944
6947
  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);
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"))
6948
+ 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"))
6946
6949
  throw new N("Reconnecting the browser before continuing.", "executor_not_ready");
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")
6950
+ 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")
6948
6951
  throw new N(B.message, B.code, !1, {
6949
6952
  ...typeof B.blockedOrigin == "string" ? { blockedOrigin: B.blockedOrigin } : {},
6950
6953
  ...typeof B.securitySettingsUrl == "string" ? { securitySettingsUrl: B.securitySettingsUrl } : {}
6951
6954
  }, o === "conversations" && e === "/commands");
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);
6955
+ 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;
6956
+ 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);
6954
6957
  }
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 = {
6958
+ return await P.json();
6959
+ } catch (P) {
6960
+ const z = g.trigger ?? ((P instanceof Error || P instanceof DOMException) && P.name === "AbortError" ? "unexpected_abort" : null), B = {
6958
6961
  requestId: m,
6959
6962
  method: s ?? (i === void 0 ? "GET" : "POST"),
6960
6963
  route: w ? "/api/product-agent/conversations/:sessionId/snapshot" : e === "/commands" ? "/api/product-agent/:namespace/commands" : "/api/product-agent/:namespace/:operation",
6961
- status: E,
6964
+ status: q,
6962
6965
  abortTrigger: z,
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",
6966
+ category: z === "deadline" ? "request_timed_out" : z === "unexpected_abort" ? "connection_interrupted" : z ? "request_cancelled" : P instanceof N ? P.code : E ? "connection_interrupted" : "invalid_response",
6964
6967
  responseHeadersMs: I === null ? null : Math.max(0, I - _),
6965
6968
  responseBodyMs: I === null ? null : Math.max(0, Date.now() - I),
6966
- owner: z === "deadline" ? "http_deadline" : z === "transport_disposed" ? "http_transport" : z && z !== "unexpected_abort" ? "conversation_query" : E === null ? "browser" : "http_response",
6969
+ owner: z === "deadline" ? "http_deadline" : z === "transport_disposed" ? "http_transport" : z && z !== "unexpected_abort" ? "conversation_query" : q === null ? "browser" : "http_response",
6967
6970
  elapsedMs: Math.max(0, Date.now() - _),
6968
6971
  attempt: l,
6969
6972
  queryRequestId: me(r?.queryRequestId),
@@ -6971,8 +6974,8 @@ class pu {
6971
6974
  authorityGeneration: r?.authorityGeneration ?? null,
6972
6975
  sessionId: me(r?.sessionId),
6973
6976
  release: this.auth.extension_version ? `extension-${this.auth.extension_version}` : `sdk-${ai.version}`,
6974
- upstreamRequestId: A,
6975
- upstreamTraceId: L
6977
+ upstreamRequestId: x,
6978
+ upstreamTraceId: M
6976
6979
  };
6977
6980
  wn(B) && Promise.resolve().then(() => this.options.onRequestFailure ? this.options.onRequestFailure(B) : console.warn("Product Agent HTTP request failed", B)).catch(() => {
6978
6981
  });
@@ -6986,12 +6989,12 @@ class pu {
6986
6989
  C
6987
6990
  );
6988
6991
  }
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.",
6992
+ throw P instanceof N && C ? new N(P.message, P.code, P.outcomeUnknown, { ...P.detail, ...C }, P.backendRefusal) : C ? new N(
6993
+ E ? "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.",
6991
6994
  "connection_interrupted",
6992
6995
  !0,
6993
6996
  C
6994
- ) : M;
6997
+ ) : P;
6995
6998
  } finally {
6996
6999
  clearTimeout(k), this.requests.signal.removeEventListener("abort", f), a?.removeEventListener("abort", b);
6997
7000
  }
@@ -9565,12 +9568,12 @@ class Ka {
9565
9568
  setTimeout(I, 0);
9566
9569
  return;
9567
9570
  }
9568
- const x = () => {
9569
- cancelAnimationFrame(A), document.removeEventListener("visibilitychange", E), setTimeout(I, 0);
9570
- }, E = () => {
9571
- document.visibilityState !== "visible" && x();
9572
- }, A = requestAnimationFrame(x);
9573
- document.addEventListener("visibilitychange", E);
9571
+ const E = () => {
9572
+ cancelAnimationFrame(x), document.removeEventListener("visibilitychange", q), setTimeout(I, 0);
9573
+ }, q = () => {
9574
+ document.visibilityState !== "visible" && E();
9575
+ }, x = requestAnimationFrame(E);
9576
+ document.addEventListener("visibilitychange", q);
9574
9577
  }));
9575
9578
  const _ = f.context.page;
9576
9579
  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 });
@@ -9704,9 +9707,9 @@ class Ka {
9704
9707
  if (!k.startsWith(`background:${this.modelClientScopeId}:`)) continue;
9705
9708
  const _ = gn(f.conversation, f.directory, m), I = _.sessionId ? f.conversation.sessions[_.sessionId] : void 0;
9706
9709
  if (this.firstResponseTimersByClientMessageId.size && (u(ar(_, I?.queries.current, this.options.backendUrl).messages, _.sessionId), ["failed", "stopped"].includes(_.activity.phase)))
9707
- for (const E of Tt(I?.execution)) this.clearFirstResponseTimer(E);
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);
9710
+ for (const q of Tt(I?.execution)) this.clearFirstResponseTimer(q);
9711
+ const E = _.activity.phase === "completed" && Tt(I?.execution).some((q) => this.firstResponseTimersByClientMessageId.has(q));
9712
+ (w && _.sessionId === this.getState().sessionId || !E && ["completed", "failed", "stopped"].includes(_.activity.phase)) && this.directoryScope.detach(k);
9710
9713
  }
9711
9714
  const S = this.getState();
9712
9715
  u(S.messages, S.sessionId);
@@ -12028,12 +12031,12 @@ function by(t, e) {
12028
12031
  const m = k.getAttribute("data-testid") || k.getAttribute("data-test") || k.getAttribute("data-qa") || k.getAttribute("data-cy") || "";
12029
12032
  return `${k.tagName.toLowerCase()}|${y(k)}|${m}`;
12030
12033
  }, b = (k, m, _) => {
12031
- const I = (x, E) => {
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")
12034
+ const I = (E, q) => {
12035
+ const x = E.tagName.toLowerCase(), M = window.getComputedStyle(E), P = u.has(E);
12036
+ if (g >= 1e3 && !P || _.has(E) || o.has(x) || E.matches(".pluno-pa-widget-host, [data-pluno-product-agent-widget]") || M.display === "none" || M.visibility === "hidden")
12034
12037
  return { lines: [], hasUsefulContent: !1, textPreview: "", containsTextElement: !1 };
12035
12038
  g += 1;
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();
12039
+ const z = y(E), B = xu(E), C = r.has(z) || ["button", "input", "textarea", "select", "iframe", "canvas"].includes(x) || x === "a" && E.hasAttribute("href"), U = Array.from(E.children).filter((H) => H instanceof HTMLElement), X = /* @__PURE__ */ new Map();
12037
12040
  for (const H of U) {
12038
12041
  const ee = f(H);
12039
12042
  X.set(ee, (X.get(ee) ?? 0) + 1);
@@ -12050,19 +12053,19 @@ function by(t, e) {
12050
12053
  qe.has(ee) || (Ae.push([`… ${Z.get(ee) ?? 0} similar siblings omitted`]), qe.add(ee));
12051
12054
  continue;
12052
12055
  }
12053
- const Re = I(H, E);
12056
+ const Re = I(H, q);
12054
12057
  F.push(Re), Ae.push(Re.lines);
12055
12058
  }
12056
12059
  const Q = [];
12057
- if (x.shadowRoot)
12058
- for (const H of Array.from(x.shadowRoot.children))
12059
- H instanceof HTMLElement && Q.push(I(H, E + 1));
12060
+ if (E.shadowRoot)
12061
+ for (const H of Array.from(E.shadowRoot.children))
12062
+ H instanceof HTMLElement && Q.push(I(H, q + 1));
12060
12063
  const et = [...F, ...Q], Ve = B.length > 0 || C || et.some((H) => H.hasUsefulContent), pe = ri(
12061
12064
  [B, ...et.map((H) => H.textPreview)].filter(Boolean).join(" ")
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 = [];
12065
+ ).slice(0, 180), ve = E.hasAttribute("contenteditable") && (B.length > 0 || !E.querySelector("[contenteditable]")), Ie = c.some((H) => E.hasAttribute(H)) || !!z || ve, tt = (E.getClientRects().length > 0 || M.display === "contents") && (n.has(x) || Ie || P) && (Ve || P) && (!s.has(x) || Ve || Ie || P), W = tt ? 1 : 0, he = [];
12063
12066
  if (tt) {
12064
- const H = et.some((be) => be.containsTextElement), ee = i.has(A) && !H ? pe : B;
12065
- he.push(ku(x, l, a, ee.slice(0, 180)));
12067
+ const H = et.some((be) => be.containsTextElement), ee = i.has(x) && !H ? pe : B;
12068
+ he.push(ku(E, l, a, ee.slice(0, 180)));
12066
12069
  }
12067
12070
  for (const H of Ae)
12068
12071
  he.push(...xs(H, W));
@@ -12070,9 +12073,9 @@ function by(t, e) {
12070
12073
  if (re.length > 0) {
12071
12074
  const H = re.slice(0, 20);
12072
12075
  re.length > H.length && H.push("… shadow DOM omitted");
12073
- const ee = A.includes("tooltip") || A.includes("popper") || A.includes("loader");
12074
- if (E < 2 && !ee) {
12075
- const be = tt ? "#shadow-root" : `${A} #shadow-root`;
12076
+ const ee = x.includes("tooltip") || x.includes("popper") || x.includes("loader");
12077
+ if (q < 2 && !ee) {
12078
+ const be = tt ? "#shadow-root" : `${x} #shadow-root`;
12076
12079
  he.push(...xs([be, ...xs(H, 1)], W));
12077
12080
  } else
12078
12081
  he.push(...xs(H, W));
@@ -12081,7 +12084,7 @@ function by(t, e) {
12081
12084
  lines: he,
12082
12085
  hasUsefulContent: Ve,
12083
12086
  textPreview: pe,
12084
- containsTextElement: i.has(A) || et.some((H) => H.containsTextElement)
12087
+ containsTextElement: i.has(x) || et.some((H) => H.containsTextElement)
12085
12088
  };
12086
12089
  };
12087
12090
  return [`--- ${m} ---`, ...I(k, 0).lines].join(`
@@ -13221,8 +13224,8 @@ function Nb(t, e, n, i) {
13221
13224
  let p = d.user?.id, g = null, y = "", f = "", b = "";
13222
13225
  const w = e.ownerDocument.defaultView;
13223
13226
  let S, k, m = /* @__PURE__ */ new Map(), _ = d.sessionId, I = d.selectionKey;
13224
- const x = /* @__PURE__ */ new Set(), E = /* @__PURE__ */ new Map();
13225
- let A = null, L = null, M = null, z = 0, B = null, C = null, U = null;
13227
+ const E = /* @__PURE__ */ new Set(), q = /* @__PURE__ */ new Map();
13228
+ let x = null, M = null, P = null, z = 0, B = null, C = null, U = null;
13226
13229
  const X = () => JSON.stringify([
13227
13230
  d.sessionId,
13228
13231
  d.assistantDraftRespondsToUserMessageId,
@@ -13233,10 +13236,10 @@ function Nb(t, e, n, i) {
13233
13236
  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]");
13234
13237
  };
13235
13238
  function Me() {
13236
- L !== null && w.clearTimeout(L), L = null, M = null;
13239
+ M !== null && w.clearTimeout(M), M = null, P = null;
13237
13240
  }
13238
13241
  function _e(W = !1) {
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();
13242
+ Me(), C = null, U !== null && w.clearTimeout(U), U = null, S = void 0, k = void 0, m.clear(), q.clear(), x !== null && w.clearTimeout(x), x = null, W && E.clear();
13240
13243
  }
13241
13244
  function qe() {
13242
13245
  if (Ks(e) !== "none") {
@@ -13248,15 +13251,15 @@ function Nb(t, e, n, i) {
13248
13251
  _e();
13249
13252
  return;
13250
13253
  }
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 = [];
13252
- for (const O of Array.from(e.querySelectorAll(`${H}, [data-message-role="user"]`))) {
13253
- const $ = w.getComputedStyle(O);
13254
- !O.getClientRects().length || $.visibility === "hidden" || $.opacity === "0" || O.parentElement?.closest(H) || ee.push(O.dataset.messageRole === "user" ? "user" : "thinking");
13254
+ const re = (D, $) => Array.from(e.querySelectorAll(D)).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 = [];
13255
+ for (const D of Array.from(e.querySelectorAll(`${H}, [data-message-role="user"]`))) {
13256
+ const $ = w.getComputedStyle(D);
13257
+ !D.getClientRects().length || $.visibility === "hidden" || $.opacity === "0" || D.parentElement?.closest(H) || ee.push(D.dataset.messageRole === "user" ? "user" : "thinking");
13255
13258
  }
13256
13259
  let be = 0;
13257
13260
  if (ee.includes("thinking")) {
13258
- const O = Array.from(e.querySelectorAll('[data-message-role="user"]')), $ = O[O.length - 1], Y = $?.dataset.messageKey ?? $?.dataset.entryKey ?? null;
13259
- Y !== B && x.delete("thinking-without-progress"), B = Y;
13261
+ const D = Array.from(e.querySelectorAll('[data-message-role="user"]')), $ = D[D.length - 1], Y = $?.dataset.messageKey ?? $?.dataset.entryKey ?? null;
13262
+ Y !== B && E.delete("thinking-without-progress"), B = Y;
13260
13263
  let K = 2166136261;
13261
13264
  for (const ne of Array.from(e.querySelectorAll(
13262
13265
  "[data-message-key], [data-entry-key][data-message-role], [data-tool-call-key], [data-event-type]"
@@ -13267,15 +13270,15 @@ function Nb(t, e, n, i) {
13267
13270
  K = Math.imul(K ^ ke.charCodeAt(Ge), 16777619) >>> 0;
13268
13271
  }
13269
13272
  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;
13273
+ K !== P && (P = K, z = ue), be = ue - z, M !== null && w.clearTimeout(M), M = be < 3e5 ? w.setTimeout(qe, 3e5 - be) : null;
13271
13274
  } else
13272
- Me(), x.delete("thinking-without-progress");
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;
13275
+ Me(), E.delete("thinking-without-progress");
13276
+ const G = Array.from(e.querySelectorAll(".pluno-pa-widget__thinking-marker, .thinking-marker, [data-thinking-status]")).some((D) => D.getClientRects().length > 0 && w.getComputedStyle(D).visibility !== "hidden" && w.getComputedStyle(D).opacity !== "0"), Re = d.isThinking || d.turnPhase != null || d.pendingMessageStatus != null || G;
13274
13277
  (!Re || C && C.responseKey !== X()) && (C = null);
13275
13278
  const Oe = {
13276
13279
  executionKey: d.activity?.executionKey,
13277
13280
  inProgress: Re,
13278
- hasComposerText: Array.from(e.querySelectorAll(".pluno-pa-widget__input, .composer textarea")).some((O) => !!O.value.trim()),
13281
+ hasComposerText: Array.from(e.querySelectorAll(".pluno-pa-widget__input, .composer textarea")).some((D) => !!D.value.trim()),
13279
13282
  hasComposerAttachment: !!e.querySelector(".pluno-pa-widget__attachments .pluno-pa-widget__attachment, .composer-attachments .composer-attachment"),
13280
13283
  enabledStopControlCount: Array.from(e.querySelectorAll(
13281
13284
  'button[aria-label="Stop"], button[aria-label="Stop generating"]'
@@ -13283,7 +13286,7 @@ function Nb(t, e, n, i) {
13283
13286
  stopPendingMs: C ? w.performance.now() - C.at : 0,
13284
13287
  thinkingSequence: ee,
13285
13288
  thinkingIdleMs: be,
13286
- messageKeys: Array.from(e.querySelectorAll("[data-message-key], [data-entry-key][data-message-role]")).flatMap((O) => O.dataset.messageKey ?? O.dataset.entryKey ?? []),
13289
+ messageKeys: Array.from(e.querySelectorAll("[data-message-key], [data-entry-key][data-message-role]")).flatMap((D) => D.dataset.messageKey ?? D.dataset.entryKey ?? []),
13287
13290
  canonicalItemKeys: re("[data-canonical-item-key]", "data-canonical-item-key"),
13288
13291
  toolCallKeys: re("[data-tool-call-key]", "data-tool-call-key"),
13289
13292
  attachmentKeys: re("[data-attachment-key]", "data-attachment-key"),
@@ -13293,22 +13296,22 @@ function Nb(t, e, n, i) {
13293
13296
  visibleSessionIds: re("[data-session-id]", "data-session-id"),
13294
13297
  welcome: !!e.querySelector(".pluno-pa-widget__empty-state--starter:not(.pluno-pa-widget__empty-state--morning-report), .empty-state--starter"),
13295
13298
  runtimeItemCount: d.messages.filter(
13296
- (O) => (O.role === "user" || O.role === "assistant") && O.phase !== "commentary" && !O.scheduledCheckInAt && !O.id.startsWith("local-") && !O.id.startsWith("optimistic-user-message:")
13299
+ (D) => (D.role === "user" || D.role === "assistant") && D.phase !== "commentary" && !D.scheduledCheckInAt && !D.id.startsWith("local-") && !D.id.startsWith("optimistic-user-message:")
13297
13300
  ).length
13298
- }, Fe = e.matches("[data-selected-session-id]") ? e : e.querySelector("[data-selected-session-id]"), q = !Fe || (Fe.dataset.selectedSessionId || null) === d.sessionId, D = q && S ? {
13301
+ }, Fe = e.matches("[data-selected-session-id]") ? e : e.querySelector("[data-selected-session-id]"), T = !Fe || (Fe.dataset.selectedSessionId || null) === d.sessionId, L = T && S ? {
13299
13302
  ...S,
13300
- terminalResponseKeys: S.terminalResponseKeys.filter((O) => {
13301
- const $ = m.get(O), Y = $ ? d.removedItems?.[$] : void 0;
13303
+ terminalResponseKeys: S.terminalResponseKeys.filter((D) => {
13304
+ const $ = m.get(D), Y = $ ? d.removedItems?.[$] : void 0;
13302
13305
  return !Y || Oe.canonicalItemKeys.includes($) || !Oe.canonicalItemKeys.includes(Y);
13303
13306
  })
13304
- } : void 0, le = Im(Oe, D), V = new Set(le.map((O) => O.code));
13305
- for (const O of E.keys()) V.has(O) || E.delete(O);
13307
+ } : void 0, le = Im(Oe, L), V = new Set(le.map((D) => D.code));
13308
+ for (const D of q.keys()) V.has(D) || q.delete(D);
13306
13309
  const te = w.performance.now();
13307
- for (const { code: O } of le) {
13308
- if (x.has(O)) continue;
13309
- const $ = E.get(O) ?? { monotonicMs: te, occurredAt: Date.now() };
13310
+ for (const { code: D } of le) {
13311
+ if (E.has(D)) continue;
13312
+ const $ = q.get(D) ?? { monotonicMs: te, occurredAt: Date.now() };
13310
13313
  if (te - $.monotonicMs >= 250) {
13311
- x.add(O), E.delete(O);
13314
+ E.add(D), q.delete(D);
13312
13315
  const Y = Xp(Oe, S, e);
13313
13316
  Y.before && (Y.before.context = k);
13314
13317
  const K = Math.floor(te - $.monotonicMs);
@@ -13316,13 +13319,13 @@ function Nb(t, e, n, i) {
13316
13319
  ...Fr(e, d, { renderSource: "observer" }),
13317
13320
  firstObservedAt: $.occurredAt,
13318
13321
  confirmationMs: K
13319
- }, i.reportInvalidStateTransition?.(`ui_invariant:${O}`, void 0, Y);
13322
+ }, i.reportInvalidStateTransition?.(`ui_invariant:${D}`, void 0, Y);
13320
13323
  } else
13321
- E.set(O, $);
13324
+ q.set(D, $);
13322
13325
  }
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(() => {
13324
- A = null, qe();
13325
- }, Math.max(1, 250 - (te - Math.min(...Array.from(E.values(), (O) => O.monotonicMs))))) : null;
13326
+ le.length === 0 && T && (S = Oe, k = Fr(e, d, { renderSource: "observer" }), m = new Map(Array.from(e.querySelectorAll("[data-terminal-response-key][data-canonical-item-key]")).map((D) => [D.dataset.terminalResponseKey, D.dataset.canonicalItemKey]))), x !== null && w.clearTimeout(x), x = q.size ? w.setTimeout(() => {
13327
+ x = null, qe();
13328
+ }, Math.max(1, 250 - (te - Math.min(...Array.from(q.values(), (D) => D.monotonicMs))))) : null;
13326
13329
  }
13327
13330
  function Ae(W, he = null) {
13328
13331
  const re = W !== "runtime", H = re ? e.querySelectorAll("[data-message-key], [data-entry-key][data-message-role]") : null, ee = H?.length ?? d.messages.length, be = [];
@@ -13350,11 +13353,11 @@ function Nb(t, e, n, i) {
13350
13353
  const V = e.querySelector(".pluno-pa-widget__panel") ?? e, te = (ke) => {
13351
13354
  const Ge = w.getComputedStyle(ke);
13352
13355
  return ke.getClientRects().length > 0 && Ge.visibility !== "hidden" && Ge.display !== "none" && Ge.opacity !== "0";
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 = {
13356
+ }, D = 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 = D && $ && !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 = D && $ && !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 = {
13354
13357
  sessionId: d.sessionId,
13355
13358
  responseItemId: ue ? d.assistantDraftItemId : K?.id ?? null,
13356
13359
  respondsToUserMessageId: ue ? d.assistantDraftRespondsToUserMessageId : K?.respondsToUserMessageId ?? null,
13357
- panelVisible: O,
13360
+ panelVisible: D,
13358
13361
  documentVisible: $,
13359
13362
  loading: d.isLoadingSession
13360
13363
  }, zt = JSON.stringify(ne);
@@ -13371,8 +13374,8 @@ function Nb(t, e, n, i) {
13371
13374
  clientMessageId: Re.id,
13372
13375
  sessionId: d.sessionId
13373
13376
  }), seen: /* @__PURE__ */ new Set() }), s.size > 20 && s.delete(s.keys().next().value));
13374
- const O = s.get(te), $ = (Y) => {
13375
- !O || O.seen.has(Y) || (O.seen.add(Y), O.timer.mark(Y));
13377
+ const D = s.get(te), $ = (Y) => {
13378
+ !D || D.seen.has(Y) || (D.seen.add(Y), D.timer.mark(Y));
13376
13379
  };
13377
13380
  if (W === "runtime" && $(Fe ? "runtime_stopping" : d.activity?.phase === "stopped" ? "runtime_stopped" : Oe ? "runtime_reading" : "runtime_progress"), W === "paint" && !e.ownerDocument.hidden && G.visible && !G.loading && Array.from(e.querySelectorAll('[data-message-role="user"]')).some((K) => (K.dataset.canonicalItemKey === Re.id || K.dataset.entryKey === Re.id || K.dataset.messageKey === `user:${Re.id}`) && K.getClientRects().length > 0)) {
13378
13381
  $("message_painted");
@@ -13380,18 +13383,18 @@ function Nb(t, e, n, i) {
13380
13383
  Fe && K.includes("Stopping") ? $("stopping_painted") : d.activity?.phase === "stopped" && K.includes("Stopped") ? $("stopped_painted") : Oe && K.includes("Reading your message") ? $("reading_painted") : !Oe && !Fe && d.activity?.phase !== "stopped" && !K.includes("Reading your message") && $("progress_painted");
13381
13384
  }
13382
13385
  }
13383
- const q = JSON.stringify(G);
13384
- if (W === "runtime" && q === y || W === "paint" && q === f) return;
13385
- W === "runtime" && (y = q), W === "paint" && (f = q);
13386
- const D = {
13386
+ const T = JSON.stringify(G);
13387
+ if (W === "runtime" && T === y || W === "paint" && T === f) return;
13388
+ W === "runtime" && (y = T), W === "paint" && (f = T);
13389
+ const L = {
13387
13390
  sequence: ++c,
13388
13391
  occurred_at: (/* @__PURE__ */ new Date()).toISOString(),
13389
13392
  monotonic_ms: Math.round(w.performance.now()),
13390
13393
  kind: W,
13391
13394
  action: he,
13392
13395
  ...G
13393
- }, le = new TextEncoder().encode(JSON.stringify(D)).length;
13394
- for (o.push(D), a.push(le), r += le; o.length > Db || r > Lb; )
13396
+ }, le = new TextEncoder().encode(JSON.stringify(L)).length;
13397
+ for (o.push(L), a.push(le), r += le; o.length > Db || r > Lb; )
13395
13398
  o.shift(), r -= a.shift(), l += 1;
13396
13399
  }
13397
13400
  function F() {
@@ -13624,13 +13627,13 @@ async function mw(t = {}) {
13624
13627
  ".pluno-pa-widget__launcher-drag-handle"
13625
13628
  ), I = c.querySelector(
13626
13629
  ".pluno-pa-widget__launcher-input"
13627
- ), x = c.querySelector(
13628
- ".pluno-pa-widget__status--launcher"
13629
13630
  ), E = c.querySelector(
13631
+ ".pluno-pa-widget__status--launcher"
13632
+ ), q = c.querySelector(
13630
13633
  ".pluno-pa-widget__launcher-minimize"
13631
- ), A = c.querySelector(".pluno-pa-widget__panel"), L = c.querySelector(
13634
+ ), x = c.querySelector(".pluno-pa-widget__panel"), M = c.querySelector(
13632
13635
  ".pluno-pa-widget__panel-drag-handle"
13633
- ), M = c.querySelector(
13636
+ ), P = c.querySelector(
13634
13637
  ".pluno-pa-widget__scribble-spirals--panel"
13635
13638
  ), z = Array.from(
13636
13639
  c.querySelectorAll(".pluno-pa-widget__resize-handle")
@@ -13700,9 +13703,9 @@ async function mw(t = {}) {
13700
13703
  ), c.querySelector(
13701
13704
  ".pluno-pa-widget__tab-groups-suggestion-dismiss"
13702
13705
  );
13703
- const q = c.querySelector(
13706
+ const T = c.querySelector(
13704
13707
  ".pluno-pa-widget__proactive-suggestion"
13705
- ), D = c.querySelector(
13708
+ ), L = c.querySelector(
13706
13709
  ".pluno-pa-widget__proactive-suggestion-query"
13707
13710
  ), le = c.querySelector(
13708
13711
  ".pluno-pa-widget__proactive-suggestion-run"
@@ -13710,7 +13713,7 @@ async function mw(t = {}) {
13710
13713
  ".pluno-pa-widget__proactive-suggestion-edit"
13711
13714
  ), te = c.querySelector(
13712
13715
  ".pluno-pa-widget__proactive-suggestion-dismiss"
13713
- ), O = c.querySelector(
13716
+ ), D = c.querySelector(
13714
13717
  ".pluno-pa-widget__proactive-suggestion-close"
13715
13718
  ), $ = c.querySelector(
13716
13719
  ".pluno-pa-widget__proactive-suggestion-never-show"
@@ -13725,15 +13728,15 @@ async function mw(t = {}) {
13725
13728
  ), zt = c.querySelector(
13726
13729
  ".pluno-pa-widget__proactive-suggestion-feedback-status"
13727
13730
  );
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)
13731
+ if (!m || !I || !x || !B || !C || !U || !X || !_e || !qe || !Ae || !F || !Q || !et || !pe || !ve || !Ie || !tt || !W || !he || !re || !H || !ee || !be || !G || !Re)
13729
13732
  throw new Error("Failed to mount Pluno widget");
13730
13733
  if (e.movableLauncher && !_)
13731
13734
  throw new Error("Failed to mount Pluno widget drag handle");
13732
- if (e.movableLauncher && !L)
13735
+ if (e.movableLauncher && !M)
13733
13736
  throw new Error("Failed to mount Pluno widget panel drag handle");
13734
13737
  let ke = !1, Ge = null, Wn = !1, Zi = null, nt = "idle";
13735
13738
  const es = () => {
13736
- if (!(q !== null && !q.hidden && !c.classList.contains("pluno-pa-widget--proactive-suggestion-in-panel") && e.layout === "floating")) {
13739
+ if (!(T !== null && !T.hidden && !c.classList.contains("pluno-pa-widget--proactive-suggestion-in-panel") && e.layout === "floating")) {
13737
13740
  c.classList.remove("pluno-pa-widget--proactive-suggestion-below");
13738
13741
  return;
13739
13742
  }
@@ -13741,19 +13744,19 @@ async function mw(t = {}) {
13741
13744
  "pluno-pa-widget--proactive-suggestion-below",
13742
13745
  Ew(
13743
13746
  m.getBoundingClientRect(),
13744
- q.getBoundingClientRect().height
13747
+ T.getBoundingClientRect().height
13745
13748
  )
13746
13749
  );
13747
13750
  }, ct = () => {
13748
- if (!q || !D || !Y || !K || !ue || !ne || !zt)
13751
+ if (!T || !L || !Y || !K || !ue || !ne || !zt)
13749
13752
  return;
13750
- const h = e.proactiveSuggestion ?? Ge, v = P.getState(), R = h !== null && !Wn && !v.sessionId && !v.isThinking && !v.pendingMessageStatus, T = A.querySelector(
13753
+ const h = e.proactiveSuggestion ?? Ge, v = O.getState(), A = h !== null && !Wn && !v.sessionId && !v.isThinking && !v.pendingMessageStatus, R = x.querySelector(
13751
13754
  ".pluno-pa-widget__proactive-suggestion-slot"
13752
- ), j = !A.hidden && !c.classList.contains("pluno-pa-widget--closing"), ie = R && j && T !== null;
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(
13755
+ ), j = !x.hidden && !c.classList.contains("pluno-pa-widget--closing"), ie = A && j && R !== null;
13756
+ ie ? T.parentElement !== R && R.appendChild(T) : T.parentElement !== c && c.insertBefore(T, B), T.hidden = !A, c.classList.toggle("pluno-pa-widget--proactive-suggestion", A), c.classList.toggle(
13754
13757
  "pluno-pa-widget--proactive-suggestion-in-panel",
13755
13758
  ie
13756
- ), D.textContent = h?.question ?? "", te && (te.textContent = "Not now"), V && (V.textContent = "Edit", V.setAttribute("aria-label", "Edit")), Y.hidden = e.proactiveSuggestion === null || Wn, K.hidden = Ge === null;
13759
+ ), L.textContent = h?.question ?? "", te && (te.textContent = "Not now"), V && (V.textContent = "Edit", V.setAttribute("aria-label", "Edit")), Y.hidden = e.proactiveSuggestion === null || Wn, K.hidden = Ge === null;
13757
13760
  const se = nt === "success";
13758
13761
  ue.hidden = se, ne.hidden = se, ne.disabled = nt === "submitting" || ue.value.trim().length === 0, ne.textContent = nt === "submitting" ? "Sending…" : "Send feedback", zt.textContent = nt === "success" ? "Thanks — this helps improve your suggestions." : nt === "error" ? "Couldn’t send feedback. Please try again." : "Tell Pluno what made this suggestion miss the mark.", zt.classList.toggle(
13759
13762
  "pluno-pa-widget__proactive-suggestion-feedback-status--success",
@@ -13787,9 +13790,9 @@ async function mw(t = {}) {
13787
13790
  let vt = 0, Zt = 0, rc = 0;
13788
13791
  const qt = /* @__PURE__ */ new Map();
13789
13792
  let en = null, Bt = null;
13790
- const wo = (h) => h === F ? "widget_composer" : h === I ? "widget_launcher" : h && l.contains(h) ? "widget_control" : h === k.body ? "body" : h === k.documentElement ? "document" : h ? "host_page" : "none", _n = (h, v, R = {}) => {
13791
- const T = Cs(k), j = R.skipIfAlreadyFocused === !0 && T === h;
13792
- j || (R.preventScroll ? h.focus({ preventScroll: !0 }) : h.focus());
13793
+ const wo = (h) => h === F ? "widget_composer" : h === I ? "widget_launcher" : h && l.contains(h) ? "widget_control" : h === k.body ? "body" : h === k.documentElement ? "document" : h ? "host_page" : "none", _n = (h, v, A = {}) => {
13794
+ const R = Cs(k), j = A.skipIfAlreadyFocused === !0 && R === h;
13795
+ j || (A.preventScroll ? h.focus({ preventScroll: !0 }) : h.focus());
13793
13796
  const ie = Cs(k);
13794
13797
  return ot(
13795
13798
  "web-sdk.widget.focus",
@@ -13798,8 +13801,8 @@ async function mw(t = {}) {
13798
13801
  reason: v,
13799
13802
  mountId: o,
13800
13803
  widgetAgeMs: Date.now() - a,
13801
- scheduledDelayMs: R.scheduledAt === void 0 ? null : Date.now() - R.scheduledAt,
13802
- previousFocus: wo(T),
13804
+ scheduledDelayMs: A.scheduledAt === void 0 ? null : Date.now() - A.scheduledAt,
13805
+ previousFocus: wo(R),
13803
13806
  requestedFocus: wo(h),
13804
13807
  resultingFocus: wo(ie),
13805
13808
  focusSkipped: j,
@@ -13808,8 +13811,8 @@ async function mw(t = {}) {
13808
13811
  panelOpen: c.classList.contains("pluno-pa-widget--open"),
13809
13812
  displayState: c.classList.contains("pluno-pa-widget--minimized") ? "minimized" : c.classList.contains("pluno-pa-widget--open") ? "open" : "collapsed",
13810
13813
  sdkPreview: e.extensionRuntime !== void 0,
13811
- hasSession: !!P.getState().sessionId,
13812
- isThinking: P.getState().isThinking
13814
+ hasSession: !!O.getState().sessionId,
13815
+ isThinking: O.getState().isThinking
13813
13816
  }
13814
13817
  ), !j && ie === h;
13815
13818
  }, 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, {
@@ -13821,8 +13824,8 @@ async function mw(t = {}) {
13821
13824
  lt,
13822
13825
  (h) => {
13823
13826
  Zt++, lt = lt.filter(
13824
- (v, R) => R !== h
13825
- ), di(), xe(P.getState()), De(), tn("remove_attachment");
13827
+ (v, A) => A !== h
13828
+ ), di(), xe(O.getState()), De(), tn("remove_attachment");
13826
13829
  }
13827
13830
  );
13828
13831
  }, ac = e.loginRequired || e.token || e.webSocketFactory ? void 0 : e.tokenProvider ?? (e.tokenEndpoint ? async (h) => Y_(
@@ -13832,10 +13835,10 @@ async function mw(t = {}) {
13832
13835
  if (!e.loginRequired && !e.signupRequired && !e.token && !ac && !e.webSocketFactory && !e.runtimeClient)
13833
13836
  throw new Error("Pluno widget requires token or tokenEndpoint");
13834
13837
  const cc = e.runtimeClient === void 0, _o = cc ? W_(e.clientId) : null;
13835
- let P;
13838
+ let O;
13836
13839
  try {
13837
13840
  if (e.runtimeClient)
13838
- P = e.runtimeClient;
13841
+ O = e.runtimeClient;
13839
13842
  else {
13840
13843
  const h = {
13841
13844
  token: e.token,
@@ -13845,7 +13848,7 @@ async function mw(t = {}) {
13845
13848
  model: e.model,
13846
13849
  metadata: () => ({
13847
13850
  ...typeof e.metadata == "function" ? e.metadata() : e.metadata ?? {},
13848
- ...!P.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
13851
+ ...!O.getState().sessionId && e.scribbleStyle ? { scribbleStyleStarted: !0 } : {}
13849
13852
  }),
13850
13853
  entrySurface: e.entrySurface ?? (e.extensionRuntime ? "extension_widget" : "embedded_widget"),
13851
13854
  initialStarterPrompts: e.initialStarterPrompts,
@@ -13864,22 +13867,22 @@ async function mw(t = {}) {
13864
13867
  initialAccount: e.billingStatus,
13865
13868
  runtimeAdapters: { ...e.runtimeAdapters, interactionEffect: async (v) => {
13866
13869
  if (e.runtimeAdapters?.interactionEffect) return await e.runtimeAdapters.interactionEffect(v);
13867
- const R = v.operation;
13868
- if (R.kind === "copy") {
13869
- const T = R.variant === "referral" ? await e.referralLinkLoader?.() : "I just used @pluno_ai to get work done directly inside my tools. https://pluno.ai/browser";
13870
- if (!T) throw Object.assign(new Error("The sharing link is unavailable."), { code: "interaction_not_started" });
13871
- await jp(T);
13872
- } else if (R.kind === "share") {
13873
- const T = dp().find((j) => j.id === (R.platform ?? "linkedin"));
13874
- window.open(T.href, "_blank", "noopener,noreferrer");
13875
- } else if (R.kind === "run") {
13876
- const T = P.getInteractions().find((ie) => ie.id === R.interactionId)?.kind === "proactive_suggestion";
13877
- if (!await P.sendMessage(T ? "Yes" : R.text, {
13878
- clientMessageId: R.submissionId,
13879
- ...T ? { proactiveSuggestionQuestion: R.text } : {}
13870
+ const A = v.operation;
13871
+ if (A.kind === "copy") {
13872
+ const R = A.variant === "referral" ? await e.referralLinkLoader?.() : "I just used @pluno_ai to get work done directly inside my tools. https://pluno.ai/browser";
13873
+ if (!R) throw Object.assign(new Error("The sharing link is unavailable."), { code: "interaction_not_started" });
13874
+ await jp(R);
13875
+ } else if (A.kind === "share") {
13876
+ const R = dp().find((j) => j.id === (A.platform ?? "linkedin"));
13877
+ window.open(R.href, "_blank", "noopener,noreferrer");
13878
+ } else if (A.kind === "run") {
13879
+ const R = O.getInteractions().find((ie) => ie.id === A.interactionId)?.kind === "proactive_suggestion";
13880
+ if (!await O.sendMessage(R ? "Yes" : A.text, {
13881
+ clientMessageId: A.submissionId,
13882
+ ...R ? { proactiveSuggestionQuestion: A.text } : {}
13880
13883
  })) throw Object.assign(new Error("The task was not submitted."), { code: "interaction_not_started" });
13881
- } else if (R.kind === "edit")
13882
- Zi = e.proactiveSuggestion, Wn = !0, P.stageProactiveSuggestionQuestion(R.text), Mt("Yes, but ", !0, !0, !0, "proactive_suggestion");
13884
+ } else if (A.kind === "edit")
13885
+ Zi = e.proactiveSuggestion, Wn = !0, O.stageProactiveSuggestionQuestion(A.text), Mt("Yes, but ", !0, !0, !0, "proactive_suggestion");
13883
13886
  else throw new Error("The requested platform action is unavailable.");
13884
13887
  } },
13885
13888
  activeUsersLoader: e.activeUsersLoader,
@@ -13891,25 +13894,25 @@ async function mw(t = {}) {
13891
13894
  // cross-tab collision timer because a host-page startup long task can stretch that timer into seconds.
13892
13895
  skipStoredTransportIdentityCollisionCheck: e.extensionRuntime !== void 0
13893
13896
  };
13894
- P = await yb.init(h);
13897
+ O = await yb.init(h);
13895
13898
  }
13896
13899
  } catch (h) {
13897
13900
  throw _o?.release(), r.remove(), h;
13898
13901
  }
13899
- let ui = P.getState().sessionId, pi = P.getState().selectionKey, hi = P.getState().user?.id ?? null, Pt = Fs.find(
13902
+ let ui = O.getState().sessionId, pi = O.getState().selectionKey, hi = O.getState().user?.id ?? null, Pt = Fs.find(
13900
13903
  (h) => h.value === e.model
13901
13904
  )?.value ?? Zs[0].value, gi = !1;
13902
13905
  const lc = e.productVariant === "personal" && e.onModelChange !== void 0;
13903
13906
  Q.hidden = !lc;
13904
13907
  const Vn = () => {
13905
- const h = Fs.find((R) => R.value === Pt), v = gi;
13908
+ const h = Fs.find((A) => A.value === Pt), v = gi;
13906
13909
  et.textContent = h?.label ?? Pt, Q.dataset.loading = String(v), Q.setAttribute("aria-disabled", String(v));
13907
- for (const R of Ve) {
13908
- const T = R.dataset.model === Pt;
13909
- R.classList.toggle("is-selected", T), R.setAttribute("aria-selected", String(T)), R.disabled = v;
13910
+ for (const A of Ve) {
13911
+ const R = A.dataset.model === Pt;
13912
+ A.classList.toggle("is-selected", R), A.setAttribute("aria-selected", String(R)), A.disabled = v;
13910
13913
  }
13911
13914
  }, bp = (h) => {
13912
- Pt = h, P.setModel(h), Vn();
13915
+ Pt = h, O.setModel(h), Vn();
13913
13916
  };
13914
13917
  Vn(), Q.addEventListener("toggle", () => {
13915
13918
  Q.open && gi && (Q.open = !1), Q.open || Q.querySelector(".pluno-pa-widget__model-more")?.removeAttribute("open");
@@ -13920,14 +13923,14 @@ async function mw(t = {}) {
13920
13923
  k.addEventListener("pointerdown", dc, !0);
13921
13924
  for (const h of Ve)
13922
13925
  h.addEventListener("click", () => {
13923
- const v = Fs.find((T) => T.value === h.dataset.model);
13924
- if (!v || v.value === Pt && P.getModel() === v.value || gi) {
13926
+ const v = Fs.find((R) => R.value === h.dataset.model);
13927
+ if (!v || v.value === Pt && O.getModel() === v.value || gi) {
13925
13928
  Q.open = !1;
13926
13929
  return;
13927
13930
  }
13928
- const R = Pt;
13931
+ const A = Pt;
13929
13932
  Pt = v.value, gi = !0, Q.open = !1, Q.title = "", Vn(), Promise.resolve(e.onModelChange?.(v.value)).then(() => bp(v.value)).catch(() => {
13930
- Pt = R, Q.title = "Could not change model";
13933
+ Pt = A, Q.title = "Could not change model";
13931
13934
  }).finally(() => {
13932
13935
  gi = !1, Vn();
13933
13936
  });
@@ -13955,21 +13958,21 @@ async function mw(t = {}) {
13955
13958
  guardCreatedAt: we?.createdAt ?? null,
13956
13959
  selectionFencePending: pc(h)
13957
13960
  }), is = /* @__PURE__ */ new Set();
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) => {
13961
+ let mi = "", $e = !1, dt = null, gc = location.origin, fc = O.getState().sessionId, mc = O.getState().user?.id ?? null, So = O.getState().status, Ft = () => {
13962
+ }, ko = "", Je = O.getSessionHistoryState();
13963
+ const wp = O.subscribeSessionHistory((h) => {
13961
13964
  Je = h, Ne || Ft();
13962
13965
  }), ut = (h, v) => {
13963
13966
  jt = { enabled: h, reason: v };
13964
13967
  }, St = () => {
13965
13968
  ee.hidden = !0;
13966
- }, xo = (h, v, R) => {
13967
- const T = `${h}:${v ?? "current-view"}`;
13968
- is.has(T) || (is.add(T), P.reportInvalidStateTransition?.(h, v, R));
13969
+ }, xo = (h, v, A) => {
13970
+ const R = `${h}:${v ?? "current-view"}`;
13971
+ is.has(R) || (is.add(R), O.reportInvalidStateTransition?.(h, v, A));
13969
13972
  }, _p = () => {
13970
13973
  Wh(fi, xo), ee.hidden = !1;
13971
13974
  }, yc = () => {
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, {
13975
+ we?.observedConversation && G.querySelector(".pluno-pa-widget__empty-state--starter:not(.pluno-pa-widget__empty-state--morning-report)") && (we.observedWelcome ??= hc(O.getState())), we?.observedWelcome && !we.pendingSubmission && (xo("submitted_turn_returned_to_welcome_without_new_chat", we.clientMessageId, {
13973
13976
  before: we.observedConversation,
13974
13977
  current: we.observedWelcome
13975
13978
  }), we = null);
@@ -13986,47 +13989,47 @@ async function mw(t = {}) {
13986
13989
  ko = "";
13987
13990
  return;
13988
13991
  }
13989
- const R = JSON.stringify([
13992
+ const A = JSON.stringify([
13990
13993
  Je.status,
13991
13994
  h,
13992
- P.getState().sessionId,
13993
- h.map((T) => md(T.lastActiveAt, Date.now()))
13995
+ O.getState().sessionId,
13996
+ h.map((R) => md(R.lastActiveAt, Date.now()))
13994
13997
  ]);
13995
- if (R !== ko) {
13996
- if (ko = R, W.classList.toggle(
13998
+ if (A !== ko) {
13999
+ if (ko = A, W.classList.toggle(
13997
14000
  "pluno-pa-widget__history-list--center",
13998
14001
  v && h.length === 0
13999
14002
  ), W.replaceChildren(), v && h.length === 0) {
14000
- const T = document.createElement("p");
14001
- T.className = "pluno-pa-widget__history-loading", T.textContent = "Loading...", W.appendChild(T);
14003
+ const R = document.createElement("p");
14004
+ R.className = "pluno-pa-widget__history-loading", R.textContent = "Loading...", W.appendChild(R);
14002
14005
  }
14003
- for (const T of h) {
14006
+ for (const R of h) {
14004
14007
  const j = document.createElement("button");
14005
14008
  j.type = "button", j.className = "pluno-pa-widget__history-item";
14006
- const ie = T.id === P.getState().sessionId;
14009
+ const ie = R.id === O.getState().sessionId;
14007
14010
  j.disabled = ie, ie && j.setAttribute("aria-current", "page");
14008
14011
  const se = document.createElement("span");
14009
- se.className = "pluno-pa-widget__history-item-title", se.textContent = fd(T), j.setAttribute("aria-label", fd(T));
14012
+ se.className = "pluno-pa-widget__history-item-title", se.textContent = fd(R), j.setAttribute("aria-label", fd(R));
14010
14013
  const ge = document.createElement("time");
14011
- ge.className = "pluno-pa-widget__history-time", ge.dateTime = T.lastActiveAt, ge.textContent = md(
14012
- T.lastActiveAt,
14014
+ ge.className = "pluno-pa-widget__history-time", ge.dateTime = R.lastActiveAt, ge.textContent = md(
14015
+ R.lastActiveAt,
14013
14016
  Date.now()
14014
14017
  );
14015
14018
  const xt = document.createElement("small");
14016
- xt.className = "pluno-pa-widget__history-path", xt.textContent = Dw(T), j.append(se, ge, xt), j.addEventListener("click", () => {
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");
14019
+ xt.className = "pluno-pa-widget__history-path", xt.textContent = Dw(R), j.append(se, ge, xt), j.addEventListener("click", () => {
14020
+ $e = !1, Ft(), we = null, fi = !1, is.clear(), ut(!0, "newSession"), St(), O.loadSession(R.id), vi = null, xe(O.getState()), tn("history_session_selected");
14018
14021
  }), W.appendChild(j);
14019
14022
  }
14020
14023
  if (v && h.length > 0) {
14021
- const T = document.createElement("p");
14022
- T.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", T.textContent = "Loading...", W.appendChild(T);
14024
+ const R = document.createElement("p");
14025
+ R.className = "pluno-pa-widget__history-loading pluno-pa-widget__history-loading--inline", R.textContent = "Loading...", W.appendChild(R);
14023
14026
  }
14024
14027
  re.textContent = (Je.status === "error" ? Zb : null) ?? (!v && h.length === 0 ? "No recent chats for this page yet." : ""), re.hidden = re.textContent.length === 0, re.classList.toggle("pluno-pa-widget__history-error", Je.status === "error"), H.hidden = Je.status !== "error", H.disabled = v;
14025
14028
  }
14026
14029
  };
14027
14030
  const Eo = (h = !1) => {
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(() => {
14031
+ if (dt !== null && (window.clearTimeout(dt), dt = null), !(e.layout === "page" || e.loginRequired || e.signupRequired || ke || !h && O.getState().status !== "connected"))
14032
+ return ke = !0, O.refreshSessionHistory().catch(() => {
14030
14033
  }).finally(() => {
14031
14034
  ke = !1;
14032
14035
  });
@@ -14042,7 +14045,7 @@ async function mw(t = {}) {
14042
14045
  }, 0));
14043
14046
  }, Ip = () => {
14044
14047
  const h = Je.data?.nextCursor ?? null;
14045
- Je.status === "loading_more" || !h || W.scrollHeight - W.scrollTop - W.clientHeight <= 24 && P.loadMoreSessionHistory();
14048
+ Je.status === "loading_more" || !h || W.scrollHeight - W.scrollTop - W.clientHeight <= 24 && O.loadMoreSessionHistory();
14046
14049
  }, bc = () => {
14047
14050
  Ne || typeof document > "u" || (Ed(l, e.accentColor), r.isConnected || (e.mountTarget?.isConnected ? e.mountTarget.appendChild(r) : e.mountTarget || k.body?.appendChild(r)));
14048
14051
  }, wc = new MutationObserver(bc);
@@ -14071,20 +14074,20 @@ async function mw(t = {}) {
14071
14074
  });
14072
14075
  }, os = (h, v) => {
14073
14076
  e.onDisplayStateChange?.(h, v);
14074
- }, bi = (h, v = !0, R = "external_request") => {
14075
- const T = c.classList.contains("pluno-pa-widget--minimized");
14077
+ }, bi = (h, v = !0, A = "external_request") => {
14078
+ const R = c.classList.contains("pluno-pa-widget--minimized");
14076
14079
  if (Cd(e, h), h === "shown") {
14077
- c.classList.remove("pluno-pa-widget--minimized"), m.removeAttribute("tabindex"), m.removeAttribute("role"), m.removeAttribute("aria-label"), !c.classList.contains("pluno-pa-widget--open") && !c.classList.contains("pluno-pa-widget--closing") && wi(!1), v && os("shown", R);
14080
+ c.classList.remove("pluno-pa-widget--minimized"), m.removeAttribute("tabindex"), m.removeAttribute("role"), m.removeAttribute("aria-label"), !c.classList.contains("pluno-pa-widget--open") && !c.classList.contains("pluno-pa-widget--closing") && wi(!1), v && os("shown", A);
14078
14081
  return;
14079
14082
  }
14080
- It !== null && (window.clearTimeout(It), It = null), c.classList.remove("pluno-pa-widget--open"), c.classList.remove("pluno-pa-widget--closing"), c.classList.add("pluno-pa-widget--minimized"), m.hidden = !1, m.setAttribute("role", "button"), m.setAttribute("aria-label", "Open Pluno"), A.hidden = !0, B.hidden = !0, m.tabIndex = 0, F.value = "", ct(), pn(
14083
+ It !== null && (window.clearTimeout(It), It = null), c.classList.remove("pluno-pa-widget--open"), c.classList.remove("pluno-pa-widget--closing"), c.classList.add("pluno-pa-widget--minimized"), m.hidden = !1, m.setAttribute("role", "button"), m.setAttribute("aria-label", "Open Pluno"), x.hidden = !0, B.hidden = !0, m.tabIndex = 0, F.value = "", ct(), pn(
14081
14084
  c,
14082
14085
  Pr(
14083
14086
  c,
14084
14087
  g,
14085
14088
  e.position
14086
14089
  )
14087
- ), hd(c), Qe(), !T && e.layout === "floating" && P.recordWidgetLifecycle("minimized", R), v && os("minimized", R);
14090
+ ), hd(c), Qe(), !R && e.layout === "floating" && O.recordWidgetLifecycle("minimized", A), v && os("minimized", A);
14088
14091
  }, Sn = (h, v = {}) => {
14089
14092
  qw(h, {
14090
14093
  debugVersion: hw,
@@ -14098,17 +14101,17 @@ async function mw(t = {}) {
14098
14101
  },
14099
14102
  rootRect: Dr(c),
14100
14103
  launcherRect: Dr(m),
14101
- panelRect: Dr(A),
14104
+ panelRect: Dr(x),
14102
14105
  viewport: Ze(),
14103
- panelHidden: A.hidden,
14106
+ panelHidden: x.hidden,
14104
14107
  closeHidden: B.hidden,
14105
14108
  ...v
14106
14109
  });
14107
14110
  }, wi = (h = !0) => {
14108
14111
  if (!g) {
14109
14112
  pn(c, null);
14110
- const R = yi(h);
14111
- return es(), R;
14113
+ const A = yi(h);
14114
+ return es(), A;
14112
14115
  }
14113
14116
  const v = yi(h);
14114
14117
  return pn(c, v), es(), Sn("Applied stored closed launcher position", {
@@ -14125,7 +14128,7 @@ async function mw(t = {}) {
14125
14128
  });
14126
14129
  }, Ao = () => {
14127
14130
  const h = Nn(f).width;
14128
- return A.getBoundingClientRect().width || h;
14131
+ return x.getBoundingClientRect().width || h;
14129
14132
  }, _c = () => {
14130
14133
  if (c.classList.contains("pluno-pa-widget--minimized")) {
14131
14134
  pn(
@@ -14143,10 +14146,10 @@ async function mw(t = {}) {
14143
14146
  qr(c, f);
14144
14147
  const v = Nn(f);
14145
14148
  Lr(
14146
- M,
14149
+ P,
14147
14150
  Ao()
14148
14151
  );
14149
- const R = Ki(
14152
+ const A = Ki(
14150
14153
  b ? Hs(b, v) : Or(
14151
14154
  c,
14152
14155
  h,
@@ -14155,9 +14158,9 @@ async function mw(t = {}) {
14155
14158
  ),
14156
14159
  v
14157
14160
  );
14158
- rs(R, h), Sn(
14161
+ rs(A, h), Sn(
14159
14162
  "Applied open panel position after viewport resize",
14160
- { openPanelPosition: R }
14163
+ { openPanelPosition: A }
14161
14164
  );
14162
14165
  } else g && Sn(
14163
14166
  "Applied visible launcher position after viewport resize",
@@ -14172,15 +14175,15 @@ async function mw(t = {}) {
14172
14175
  launcherDragHandle: _,
14173
14176
  getPosition: () => yi(),
14174
14177
  setPosition: (h) => {
14175
- const v = h, R = Ji(c), T = $s(
14178
+ const v = h, A = Ji(c), R = $s(
14176
14179
  c,
14177
14180
  h,
14178
- R
14181
+ A
14179
14182
  );
14180
14183
  g = Mr(
14181
- T,
14182
- R
14183
- ), b = null, pn(c, T), es(), Sn("Dragging closed launcher", {
14184
+ R,
14185
+ A
14186
+ ), b = null, pn(c, R), es(), Sn("Dragging closed launcher", {
14184
14187
  requestedPosition: v
14185
14188
  });
14186
14189
  },
@@ -14204,7 +14207,7 @@ async function mw(t = {}) {
14204
14207
  };
14205
14208
  }, Sp = (h) => {
14206
14209
  f = go(h.size), qr(c, f), Lr(
14207
- M,
14210
+ P,
14208
14211
  Ao()
14209
14212
  );
14210
14213
  const v = Ki(
@@ -14215,29 +14218,29 @@ async function mw(t = {}) {
14215
14218
  v,
14216
14219
  Nn(f)
14217
14220
  );
14218
- const R = yi();
14219
- rs(v, R);
14221
+ const A = yi();
14222
+ rs(v, A);
14220
14223
  }, kp = (h) => {
14221
- const v = Nn(f), R = Ki(
14224
+ const v = Nn(f), A = Ki(
14222
14225
  h,
14223
14226
  v
14224
- ), T = Ji(c), j = $s(
14227
+ ), R = Ji(c), j = $s(
14225
14228
  c,
14226
14229
  Rw(
14227
- R,
14230
+ A,
14228
14231
  v,
14229
- T,
14232
+ R,
14230
14233
  e.position
14231
14234
  ),
14232
- T
14235
+ R
14233
14236
  );
14234
14237
  g = Mr(
14235
14238
  j,
14236
- T
14237
- ), y = !0, b = null, pn(c, j), rs(R, j);
14238
- }, xp = e.movableLauncher && L ? vw({
14239
+ R
14240
+ ), y = !0, b = null, pn(c, j), rs(A, j);
14241
+ }, xp = e.movableLauncher && M ? vw({
14239
14242
  root: c,
14240
- handle: L,
14243
+ handle: M,
14241
14244
  getPosition: () => Ic().position,
14242
14245
  setPosition: kp,
14243
14246
  persist: Qe
@@ -14259,13 +14262,13 @@ async function mw(t = {}) {
14259
14262
  xn.append(Sc, kc), _i.append("Pluno could not load your account. Try again.", xn), Me.after(kn);
14260
14263
  let Ro = !1, En = !1;
14261
14264
  const To = () => {
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";
14265
+ const h = O.getState().status === "error" && ["unauthorized", "invalid_token", "update_required"].includes(O.getState().lastErrorCode ?? ""), v = !!e.billingStatus && e.billingStatus?.submissionGate?.reason !== "connection_required";
14266
+ kn.hidden = h || O.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";
14264
14267
  }, qo = async () => {
14265
14268
  if (!(En || Ne)) {
14266
14269
  En = !0, To();
14267
14270
  try {
14268
- await P.refreshAccount(), Ro = !1;
14271
+ await O.refreshAccount(), Ro = !1;
14269
14272
  } catch (h) {
14270
14273
  Ro = !0, ot(
14271
14274
  "web-sdk.widget",
@@ -14284,18 +14287,18 @@ async function mw(t = {}) {
14284
14287
  const xc = (h) => {
14285
14288
  if (i())
14286
14289
  return;
14287
- const v = Date.now(), R = window.location.href;
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) => {
14290
+ const v = Date.now(), A = window.location.href;
14291
+ h === "composer_input" && vi?.scope === A && v - vi.requestedAt < Ub || (h === "composer_input" && (vi = { scope: A, requestedAt: v }), Promise.resolve(O.warmup(h)).catch((R) => {
14289
14292
  ot(
14290
14293
  "web-sdk.widget",
14291
14294
  "Failed to warm Product Agent sandbox",
14292
- Dn(T)
14295
+ Dn(R)
14293
14296
  );
14294
14297
  }));
14295
- }, Mt = (h = "", v = !0, R = !0, T = !0, j = "external_request") => {
14296
- const ie = c.classList.contains("pluno-pa-widget--open") || !A.hidden && !c.classList.contains("pluno-pa-widget--closing");
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(
14298
- M,
14298
+ }, Mt = (h = "", v = !0, A = !0, R = !0, j = "external_request") => {
14299
+ const ie = c.classList.contains("pluno-pa-widget--open") || !x.hidden && !c.classList.contains("pluno-pa-widget--closing");
14300
+ !ie && R && 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), x.hidden = !1, B.hidden = !1, Lr(
14301
+ P,
14299
14302
  Ao()
14300
14303
  ), c.classList.remove("pluno-pa-widget--closing"), ct();
14301
14304
  const se = wi(), ge = Or(
@@ -14307,22 +14310,22 @@ async function mw(t = {}) {
14307
14310
  if (rs(ge, se), Sn("Opening launcher at clamped open panel position", {
14308
14311
  openPanelPosition: ge,
14309
14312
  visibleLauncherPosition: se
14310
- }), ut(!0, "open"), St(), !ie && e.layout === "floating" && P.recordWidgetLifecycle("opened", j), !v) {
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);
14313
+ }), ut(!0, "open"), St(), !ie && e.layout === "floating" && O.recordWidgetLifecycle("opened", j), !v) {
14314
+ 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, A && (_n(F, "panel_open_immediate"), F.setSelectionRange(F.value.length, F.value.length)), Qe(), os("shown", j), e.onPanelOpenChange?.(!0, j);
14312
14315
  return;
14313
14316
  }
14314
14317
  const xt = Date.now();
14315
14318
  window.requestAnimationFrame(() => {
14316
- c.classList.add("pluno-pa-widget--open"), ie || Co(), h && (F.value = h, Bi(F)), Zn(G, () => jt.enabled), on = G.scrollTop, R && (_n(F, "panel_open_animation", {
14319
+ c.classList.add("pluno-pa-widget--open"), ie || Co(), h && (F.value = h, Bi(F)), Zn(G, () => jt.enabled), on = G.scrollTop, A && (_n(F, "panel_open_animation", {
14317
14320
  scheduledAt: xt
14318
14321
  }), F.setSelectionRange(F.value.length, F.value.length)), Qe(), os("shown", j), e.onPanelOpenChange?.(!0, j), It = window.setTimeout(() => {
14319
14322
  m.hidden = !0, Zn(G, () => jt.enabled), on = G.scrollTop;
14320
14323
  }, 220);
14321
14324
  });
14322
14325
  }, Po = (h = "external_request") => {
14323
- const v = c.classList.contains("pluno-pa-widget--open") || !A.hidden && !c.classList.contains("pluno-pa-widget--closing");
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(() => {
14325
- A.hidden = !0, B.hidden = !0, b = null, c.classList.remove("pluno-pa-widget--closing");
14326
+ const v = c.classList.contains("pluno-pa-widget--open") || !x.hidden && !c.classList.contains("pluno-pa-widget--closing");
14327
+ 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" && O.recordWidgetLifecycle("closed", h), e.onPanelOpenChange?.(!1, h), It = window.setTimeout(() => {
14328
+ x.hidden = !0, B.hidden = !0, b = null, c.classList.remove("pluno-pa-widget--closing");
14326
14329
  }, 220);
14327
14330
  };
14328
14331
  m.addEventListener("submit", (h) => {
@@ -14355,12 +14358,12 @@ async function mw(t = {}) {
14355
14358
  return null;
14356
14359
  let v = h;
14357
14360
  for (; v; ) {
14358
- const R = v.closest(id);
14359
- if (R)
14360
- return R;
14361
- const T = Cp(v);
14362
- if (T) {
14363
- v = T;
14361
+ const A = v.closest(id);
14362
+ if (A)
14363
+ return A;
14364
+ const R = Cp(v);
14365
+ if (R) {
14366
+ v = R;
14364
14367
  continue;
14365
14368
  }
14366
14369
  const j = v.getRootNode();
@@ -14382,11 +14385,11 @@ async function mw(t = {}) {
14382
14385
  if (!v)
14383
14386
  return;
14384
14387
  Ot !== null && window.clearTimeout(Ot);
14385
- const R = Date.now();
14388
+ const A = Date.now();
14386
14389
  Ot = window.setTimeout(() => {
14387
14390
  Ot = null, $t === h && v.isConnected && _n(v, "host_modal_recovery", {
14388
14391
  preventScroll: !0,
14389
- scheduledAt: R
14392
+ scheduledAt: A
14390
14393
  });
14391
14394
  }, 0);
14392
14395
  }, Si = (h, v = null) => {
@@ -14395,12 +14398,12 @@ async function mw(t = {}) {
14395
14398
  return;
14396
14399
  }
14397
14400
  $t = h, h !== null ? (Do(h, v), Cn = window.setInterval(() => {
14398
- const R = $t;
14399
- if (!R || !Ap(R)) {
14401
+ const A = $t;
14402
+ if (!A || !Ap(A)) {
14400
14403
  Si(null);
14401
14404
  return;
14402
14405
  }
14403
- Do(R, null);
14406
+ Do(A, null);
14404
14407
  }, Xb)) : (Cn !== null && (window.clearInterval(Cn), Cn = null), Ot !== null && (window.clearTimeout(Ot), Ot = null), as = null);
14405
14408
  }, Rp = () => {
14406
14409
  Cn !== null && (window.clearInterval(Cn), Cn = null), Ot !== null && (window.clearTimeout(Ot), Ot = null), Ue !== null && (window.clearTimeout(Ue), Ue = null);
@@ -14408,11 +14411,11 @@ async function mw(t = {}) {
14408
14411
  const v = Cc(h);
14409
14412
  if (!v)
14410
14413
  return;
14411
- const R = Date.now();
14412
- rn = R, Ii = R, Ue !== null && window.clearTimeout(Ue);
14413
- const T = $t ?? Mo(Oo());
14414
- T && (Si(T, v), h.stopImmediatePropagation()), Ue = window.setTimeout(() => {
14415
- if (Ue = null, rn !== R)
14414
+ const A = Date.now();
14415
+ rn = A, Ii = A, Ue !== null && window.clearTimeout(Ue);
14416
+ const R = $t ?? Mo(Oo());
14417
+ R && (Si(R, v), h.stopImmediatePropagation()), Ue = window.setTimeout(() => {
14418
+ if (Ue = null, rn !== A)
14416
14419
  return;
14417
14420
  const j = Oo();
14418
14421
  if (j === v) {
@@ -14448,25 +14451,25 @@ async function mw(t = {}) {
14448
14451
  const v = Ii;
14449
14452
  if (Ii = null, v === null || Date.now() - v > sd)
14450
14453
  return;
14451
- const R = h.target, T = rn !== null && Date.now() - rn <= sd;
14454
+ const A = h.target, R = rn !== null && Date.now() - rn <= sd;
14452
14455
  rn = null, Ue !== null && (window.clearTimeout(Ue), Ue = null);
14453
14456
  const j = (ie) => {
14454
14457
  const se = Mo(ie);
14455
14458
  if (!se)
14456
14459
  return !1;
14457
- if (T)
14458
- return Si(se, R), !0;
14460
+ if (R)
14461
+ return Si(se, A), !0;
14459
14462
  const ge = Date.now();
14460
- return as !== null && ge - as <= Yb ? (Si(se, R), !0) : (as = ge, !0);
14463
+ return as !== null && ge - as <= Yb ? (Si(se, A), !0) : (as = ge, !0);
14461
14464
  };
14462
14465
  j(h.relatedTarget) || window.setTimeout(() => {
14463
- $t === null && R.isConnected && j(Oo());
14466
+ $t === null && A.isConnected && j(Oo());
14464
14467
  }, 0);
14465
14468
  }), m.addEventListener("keydown", (h) => {
14466
14469
  !c.classList.contains("pluno-pa-widget--minimized") || h.key !== "Enter" && h.key !== " " || (h.preventDefault(), Mt("", !0, !0, !0, "minimized_launcher"));
14467
- }), E?.addEventListener("pointerdown", (h) => {
14470
+ }), q?.addEventListener("pointerdown", (h) => {
14468
14471
  h.stopPropagation();
14469
- }), E?.addEventListener("click", (h) => {
14472
+ }), q?.addEventListener("click", (h) => {
14470
14473
  h.preventDefault(), h.stopPropagation(), bi("minimized", !0, "minimize_button");
14471
14474
  }), B.addEventListener("click", () => Po("close_button")), G.addEventListener("wheel", (h) => {
14472
14475
  ss(h.deltaY < 0 ? "up" : null);
@@ -14502,22 +14505,22 @@ async function mw(t = {}) {
14502
14505
  G.style.paddingBottom = `${h > 0 ? h + 24 : 12}px`, jt.enabled && Zn(G, () => jt.enabled);
14503
14506
  });
14504
14507
  qc?.observe(Tc);
14505
- let $t = null, ki = !1, ds = P.getState().status === "connected";
14508
+ let $t = null, ki = !1, ds = O.getState().status === "connected";
14506
14509
  const xi = () => {
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 = () => {
14510
+ const h = O.getState().status;
14511
+ return !ds && O.getState().lastErrorCode !== "connection_failed" && (h === "idle" || h === "connecting" || h === "reconnecting");
14512
+ }, Pc = () => O.getState().status !== "connected", An = () => {
14510
14513
  if (e.productVariant !== "personal") return Pc();
14511
14514
  const h = e.billingStatus?.auth;
14512
14515
  return !h?.user || !h.workspace || i();
14513
14516
  }, Lo = () => {
14514
- const h = P.getState().status;
14517
+ const h = O.getState().status;
14515
14518
  return xi() ? !1 : h !== "connected" && !(ds && h === "reconnecting");
14516
14519
  }, Gn = () => {
14517
- const h = i(), v = P.getState(), R = !v.isThinking && !v.pendingMessageStatus && !!v.lastError;
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;
14520
+ const h = i(), v = O.getState(), A = !v.isThinking && !v.pendingMessageStatus && !!v.lastError;
14521
+ I.readOnly = !1, F.readOnly = !1, I.placeholder = h ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : A ? "Needs attention" : ki ? "New update" : e.launcherLabel, F.placeholder = h ? e.signupRequired ? e.signupButtonLabel : e.loginButtonLabel : Wt.launcherLabel, C.hidden = h;
14519
14522
  }, us = () => [...qt.values()].some((h) => h.revision === Zt && h.generation === vt), Mc = () => {
14520
- const h = P.getState(), v = e.billingStatus;
14523
+ const h = O.getState(), v = e.billingStatus;
14521
14524
  return {
14522
14525
  submissionAllowed: v?.submissionGate?.allowed === !0,
14523
14526
  isAuthenticated: !!v?.auth?.user,
@@ -14530,7 +14533,7 @@ async function mw(t = {}) {
14530
14533
  hasPendingMessage: !1
14531
14534
  };
14532
14535
  }, Rn = () => e.productVariant === "personal" ? xi() && !i() && !us() && e.billingStatus?.submissionGate?.allowed === !0 || tl(Mc()) : !Lo() && !Yn(e.billingStatus) && !us(), Oc = () => {
14533
- const h = P.getState(), v = !xi() && [...qt.values()].some((R) => R.revision === Zt && R.generation === vt);
14536
+ const h = O.getState(), v = !xi() && [...qt.values()].some((A) => A.revision === Zt && A.generation === vt);
14534
14537
  return oh({
14535
14538
  hasRunningAssistantTurn: v || h.isThinking || h.turnPhase !== null || h.pendingMessageStatus !== null,
14536
14539
  // Retained text already submitted by this revision must not hide Stop behind a disabled Send.
@@ -14546,16 +14549,16 @@ async function mw(t = {}) {
14546
14549
  };
14547
14550
  Gn();
14548
14551
  const No = () => {
14549
- const h = P.getState(), v = h.isThinking, R = h.turnPhase !== null, T = h.turnPhase === "sending", j = x?.lastElementChild;
14550
- j && (j.textContent = "Working..."), c.classList.toggle("pluno-pa-widget--thinking", v), c.classList.toggle("pluno-pa-widget--sending", T), c.classList.toggle(
14552
+ const h = O.getState(), v = h.isThinking, A = h.turnPhase !== null, R = h.turnPhase === "sending", j = E?.lastElementChild;
14553
+ j && (j.textContent = "Working..."), c.classList.toggle("pluno-pa-widget--thinking", v), c.classList.toggle("pluno-pa-widget--sending", R), c.classList.toggle(
14551
14554
  "pluno-pa-widget--unread",
14552
- !R && (ki || !!h.lastError)
14555
+ !A && (ki || !!h.lastError)
14553
14556
  ), Gn();
14554
14557
  };
14555
14558
  No();
14556
14559
  const Uo = () => {
14557
14560
  if (!(i() || Ne))
14558
- return Gn(), De(), P.connect().then(
14561
+ return Gn(), De(), O.connect().then(
14559
14562
  () => {
14560
14563
  Ne || (Gn(), De());
14561
14564
  },
@@ -14574,60 +14577,60 @@ async function mw(t = {}) {
14574
14577
  U.textContent = "", U.hidden = !0, Bt = null;
14575
14578
  }, 3e3);
14576
14579
  }, zo = (h, v) => {
14577
- const R = qt.get(h);
14578
- if (!R || v !== void 0 && R.submittedAt !== v || (qt.delete(h), R.generation !== vt || R.revision !== Zt)) return;
14579
- const T = new Set(R.attachments);
14580
- lt = lt.filter((j) => !T.has(j)), F.value = "", F.dispatchEvent(new Event("input", { bubbles: !0 })), di(), De();
14580
+ const A = qt.get(h);
14581
+ if (!A || v !== void 0 && A.submittedAt !== v || (qt.delete(h), A.generation !== vt || A.revision !== Zt)) return;
14582
+ const R = new Set(A.attachments);
14583
+ lt = lt.filter((j) => !R.has(j)), F.value = "", F.dispatchEvent(new Event("input", { bubbles: !0 })), di(), De();
14581
14584
  }, Dc = (h) => {
14582
- const v = vt, R = Wn ? Zi : null;
14585
+ const v = vt, A = Wn ? Zi : null;
14583
14586
  Pw(
14584
- P,
14587
+ O,
14585
14588
  h.value,
14586
14589
  h.attachments,
14587
- R?.question,
14590
+ A?.question,
14588
14591
  // The proactive question is a separate canonical item; its answer needs its own receipt identity.
14589
14592
  h.clientMessageId,
14590
14593
  h.submittedAt
14591
- ).then((T) => {
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()));
14593
- }).catch((T) => {
14594
+ ).then((R) => {
14595
+ v === vt && (O.getState().receipts === void 0 && zo(h.clientMessageId), we?.clientMessageId === h.clientMessageId && (we.pendingSubmission = !1, R && (we.clientMessageId = R), yc()), A && (Wn = !1, Zi = null, e.proactiveSuggestion = null, ct()));
14596
+ }).catch((R) => {
14594
14597
  if (v !== vt) return;
14595
14598
  we?.clientMessageId === h.clientMessageId && (we = null), qt.delete(h.clientMessageId), di();
14596
- const j = T instanceof Error ? T.message : "Failed to upload attachment";
14597
- P.getState().lastError !== j && ps(j);
14599
+ const j = R instanceof Error ? R.message : "Failed to upload attachment";
14600
+ O.getState().lastError !== j && ps(j);
14598
14601
  }).finally(() => {
14599
14602
  v === vt && De();
14600
14603
  });
14601
14604
  }, Lc = () => {
14602
- if (Ne || !en || e.productVariant === "personal" && !tl({ ...Mc(), isSubmitting: !1 }) || P.getState().status !== "connected" || i() || Yn(e.billingStatus))
14605
+ if (Ne || !en || e.productVariant === "personal" && !tl({ ...Mc(), isSubmitting: !1 }) || O.getState().status !== "connected" || i() || Yn(e.billingStatus))
14603
14606
  return;
14604
14607
  const h = en;
14605
14608
  en = null, Dc(h);
14606
14609
  }, Bo = () => {
14607
- const h = F.value, v = h.trim(), R = [...lt];
14608
- if (en !== null || us() || e.productVariant === "personal" && !Rn() || !v && R.length === 0)
14610
+ const h = F.value, v = h.trim(), A = [...lt];
14611
+ if (en !== null || us() || e.productVariant === "personal" && !Rn() || !v && A.length === 0)
14609
14612
  return;
14610
- for (const j of R)
14613
+ for (const j of A)
14611
14614
  j.id && j.previewUrl && li.set(j.id, j.previewUrl);
14612
14615
  if ([...qt.values()].some((j) => j.revision === Zt && j.generation === vt)) return;
14613
- const T = {
14616
+ const R = {
14614
14617
  inputValue: h,
14615
14618
  value: v,
14616
- attachments: R,
14619
+ attachments: A,
14617
14620
  clientMessageId: crypto.randomUUID(),
14618
14621
  submittedAt: Math.max(Date.now(), rc + 1)
14619
14622
  };
14620
- if (rc = T.submittedAt, qt.set(T.clientMessageId, { ...T, revision: Zt, generation: vt }), De(), we = {
14623
+ if (rc = R.submittedAt, qt.set(R.clientMessageId, { ...R, revision: Zt, generation: vt }), De(), we = {
14621
14624
  createdAt: Date.now(),
14622
- clientMessageId: T.clientMessageId,
14625
+ clientMessageId: R.clientMessageId,
14623
14626
  observedConversation: null,
14624
14627
  observedWelcome: null,
14625
14628
  pendingSubmission: !0
14626
14629
  }, xi()) {
14627
- en = T;
14630
+ en = R;
14628
14631
  return;
14629
14632
  }
14630
- Dc(T);
14633
+ Dc(R);
14631
14634
  };
14632
14635
  C.addEventListener("submit", (h) => {
14633
14636
  if (h.preventDefault(), e.loginRequired) {
@@ -14649,11 +14652,11 @@ async function mw(t = {}) {
14649
14652
  if (!e.attachmentsEnabled || h.length === 0 || e.productVariant === "personal" && An())
14650
14653
  return;
14651
14654
  const v = a_(
14652
- P,
14655
+ O,
14653
14656
  h,
14654
14657
  e.productVariant === "customer_embedded"
14655
14658
  );
14656
- if (Zt++, lt = [...lt, ...v], di(), Tp(), De(), xe(P.getState()), !c.classList.contains("pluno-pa-widget--open")) {
14659
+ if (Zt++, lt = [...lt, ...v], di(), Tp(), De(), xe(O.getState()), !c.classList.contains("pluno-pa-widget--open")) {
14657
14660
  Mt("", !0, !0, !0, "attachment_drop");
14658
14661
  return;
14659
14662
  }
@@ -14689,21 +14692,21 @@ async function mw(t = {}) {
14689
14692
  !0
14690
14693
  ), k.addEventListener("drop", an, !0), k.addEventListener("dragend", an, !0), k.defaultView?.addEventListener("blur", an), c.addEventListener("drop", (h) => {
14691
14694
  const v = h.dataTransfer;
14692
- !e.attachmentsEnabled || !As(v) || e.loginRequired || An() || (h.preventDefault(), h.stopPropagation(), an(), jo(v.files).catch((R) => {
14695
+ !e.attachmentsEnabled || !As(v) || e.loginRequired || An() || (h.preventDefault(), h.stopPropagation(), an(), jo(v.files).catch((A) => {
14693
14696
  ps(
14694
- R instanceof Error ? R.message : "Failed to attach file"
14697
+ A instanceof Error ? A.message : "Failed to attach file"
14695
14698
  ), ot("web-sdk.widget", "Attachment failed", {
14696
- ...Dn(R)
14699
+ ...Dn(A)
14697
14700
  });
14698
14701
  }));
14699
14702
  }), c.addEventListener("paste", (h) => {
14700
14703
  h.stopPropagation();
14701
- const v = h.clipboardData, R = Array.from(v?.files ?? []);
14702
- !e.attachmentsEnabled || R.length === 0 || e.loginRequired || An() || (h.preventDefault(), jo(R).catch((T) => {
14704
+ const v = h.clipboardData, A = Array.from(v?.files ?? []);
14705
+ !e.attachmentsEnabled || A.length === 0 || e.loginRequired || An() || (h.preventDefault(), jo(A).catch((R) => {
14703
14706
  ps(
14704
- T instanceof Error ? T.message : "Failed to attach file"
14707
+ R instanceof Error ? R.message : "Failed to attach file"
14705
14708
  ), ot("web-sdk.widget", "Attachment failed", {
14706
- ...Dn(T)
14709
+ ...Dn(R)
14707
14710
  });
14708
14711
  }));
14709
14712
  }), pe.addEventListener("click", () => {
@@ -14715,11 +14718,11 @@ async function mw(t = {}) {
14715
14718
  if (h.disabled)
14716
14719
  return;
14717
14720
  if (h.action === "stop") {
14718
- qt.clear(), en = null, we = null, P.stop(), De();
14721
+ qt.clear(), en = null, we = null, O.stop(), De();
14719
14722
  return;
14720
14723
  }
14721
14724
  const v = F.value.trim().length > 0 || lt.length > 0;
14722
- sn = !0, ut(!0, "send"), St(), Bo(), xe(P.getState()), De(), v && tn("send_button_submit");
14725
+ sn = !0, ut(!0, "send"), St(), Bo(), xe(O.getState()), De(), v && tn("send_button_submit");
14723
14726
  }), Ie.addEventListener("click", () => {
14724
14727
  $e = !$e, Ft(), $e && (Je.data === null || Je.status === "error") && Je.status !== "loading" && Eo(), $e || tn("history_closed");
14725
14728
  }), he.addEventListener("click", () => {
@@ -14732,31 +14735,31 @@ async function mw(t = {}) {
14732
14735
  e.onLoginClick?.();
14733
14736
  return;
14734
14737
  }
14735
- (e.productVariant === "personal" ? !Rn() : Lo()) || (sn = !0, ut(!0, "send"), St(), Bo(), xe(P.getState()), De());
14738
+ (e.productVariant === "personal" ? !Rn() : Lo()) || (sn = !0, ut(!0, "send"), St(), Bo(), xe(O.getState()), De());
14736
14739
  }
14737
14740
  }), c.addEventListener("click", (h) => {
14738
14741
  const v = h.target instanceof Element ? h.target : null;
14739
14742
  v?.closest("a[href]") && Qe(), $e && Ab(v, tt, Ie) && ($e = !1, Ft());
14740
- const T = window.getSelection(), j = !!(T && !T.isCollapsed && T.anchorNode && c.contains(T.anchorNode));
14743
+ const R = window.getSelection(), j = !!(R && !R.isCollapsed && R.anchorNode && c.contains(R.anchorNode));
14741
14744
  Eb(h.target, h.detail, j) && tn("passive_surface_click");
14742
14745
  });
14743
14746
  let Uc = !1;
14744
14747
  const zc = (h) => {
14745
14748
  Uc = h.composedPath().includes(r);
14746
14749
  }, Bc = (h) => {
14747
- if (!Uc || A.hidden || c.classList.contains("pluno-pa-widget--closing"))
14750
+ if (!Uc || x.hidden || c.classList.contains("pluno-pa-widget--closing"))
14748
14751
  return;
14749
- const v = l.activeElement ?? k.activeElement, R = Tb(h, v);
14750
- if (!R || F.disabled || F.readOnly)
14752
+ const v = l.activeElement ?? k.activeElement, A = Tb(h, v);
14753
+ if (!A || F.disabled || F.readOnly)
14751
14754
  return;
14752
14755
  h.preventDefault();
14753
- const T = qb(
14756
+ const R = qb(
14754
14757
  F.value,
14755
14758
  F.selectionStart,
14756
14759
  F.selectionEnd,
14757
- R
14760
+ A
14758
14761
  );
14759
- F.value = T.value, F.dispatchEvent(new Event("input", { bubbles: !0 })), Rb(F), F.setSelectionRange(T.caret, T.caret);
14762
+ F.value = R.value, F.dispatchEvent(new Event("input", { bubbles: !0 })), Rb(F), F.setSelectionRange(R.caret, R.caret);
14760
14763
  };
14761
14764
  k.addEventListener(
14762
14765
  "pointerdown",
@@ -14792,20 +14795,20 @@ async function mw(t = {}) {
14792
14795
  h.key !== "Escape" || !$e || ($e = !1, Ft(), tn("history_escape"));
14793
14796
  }), 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");
14794
14797
  const Ci = () => u;
14795
- let Fo = P.getState().appearance !== null, hs = P.getInteractions();
14798
+ let Fo = O.getState().appearance !== null, hs = O.getInteractions();
14796
14799
  const it = (h) => hs.find(
14797
14800
  (v) => v.kind === h && v.eligible
14798
14801
  ), $o = () => {
14799
14802
  for (const [h, v] of [[Oe, it("task_notifications")], [Fe, it("tab_group_permission")]]) {
14800
14803
  if (!h || (h.hidden = !v, !v)) continue;
14801
- const R = v.payload.openingGeneration;
14802
- if (R && c.classList.contains("pluno-pa-widget--open")) {
14803
- const se = `${v.id}:${R}`;
14804
- h.dataset.presentedOpening !== se && (h.dataset.presentedOpening = se, P.recordPromptPresented?.(v.kind === "task_notifications" ? "notifications" : "tab_grouping", R));
14804
+ const A = v.payload.openingGeneration;
14805
+ if (A && c.classList.contains("pluno-pa-widget--open")) {
14806
+ const se = `${v.id}:${A}`;
14807
+ h.dataset.presentedOpening !== se && (h.dataset.presentedOpening = se, O.recordPromptPresented?.(v.kind === "task_notifications" ? "notifications" : "tab_grouping", A));
14805
14808
  }
14806
14809
  h.replaceChildren();
14807
- const T = document.createElement("span");
14808
- T.className = "pluno-pa-widget__notify-suggestion-label", T.textContent = v.presentation.body;
14810
+ const R = document.createElement("span");
14811
+ R.className = "pluno-pa-widget__notify-suggestion-label", R.textContent = v.presentation.body;
14809
14812
  const j = document.createElement("div");
14810
14813
  j.className = "pluno-pa-widget__notify-suggestion-actions";
14811
14814
  for (const se of v.allowedActions) {
@@ -14815,20 +14818,20 @@ async function mw(t = {}) {
14815
14818
  });
14816
14819
  }, j.append(ge);
14817
14820
  }
14818
- h.append(T, j);
14821
+ h.append(R, j);
14819
14822
  const ie = v.payload.error;
14820
14823
  if (ie) {
14821
14824
  const se = document.createElement("span");
14822
14825
  se.setAttribute("role", "alert"), se.textContent = ie, h.append(se);
14823
14826
  }
14824
14827
  }
14825
- }, cn = (h, v, R) => h ? P.actOnInteraction(
14828
+ }, cn = (h, v, A) => h ? O.actOnInteraction(
14826
14829
  h.id,
14827
14830
  v,
14828
14831
  h.revision,
14829
- { ...R, expectedSourceVersion: h.sourceVersion }
14832
+ { ...A, expectedSourceVersion: h.sourceVersion }
14830
14833
  ) : Promise.resolve();
14831
- let Ho = P.getState().isThinking;
14834
+ let Ho = O.getState().isThinking;
14832
14835
  const Pp = async () => {
14833
14836
  $o();
14834
14837
  };
@@ -14837,29 +14840,29 @@ async function mw(t = {}) {
14837
14840
  const Ai = /* @__PURE__ */ new Map(), gs = /* @__PURE__ */ new Map(), fs = /* @__PURE__ */ new Map(), Mp = () => F.value.trim().length > 0 || lt.length > 0, jc = (h) => {
14838
14841
  if (!g_(h, Mp())) return !1;
14839
14842
  if (e.entrySurface === "extension_widget") {
14840
- const v = e.billingStatus?.auth, R = v ? !!v.user : !!(h.user && !e.loginRequired), T = v ? !!v.workspace : !e.signupRequired;
14841
- return R && T && Tn !== null && Tn > 0;
14843
+ const v = e.billingStatus?.auth, A = v ? !!v.user : !!(h.user && !e.loginRequired), R = v ? !!v.workspace : !e.signupRequired;
14844
+ return A && R && Tn !== null && Tn > 0;
14842
14845
  }
14843
14846
  return Tn !== null;
14844
14847
  }, Fc = () => {
14845
- const h = jc(P.getState());
14848
+ const h = jc(O.getState());
14846
14849
  be.hidden = !h, h && Tn !== null && ep(be, Tn);
14847
- }, ms = /* @__PURE__ */ new Map(), Op = async (h, v, R) => {
14848
- const T = ms.get(h) ?? /* @__PURE__ */ new Set();
14849
- if (!T.has(v)) {
14850
- ms.set(h, T), T.add(v), xe(P.getState());
14850
+ }, ms = /* @__PURE__ */ new Map(), Op = async (h, v, A) => {
14851
+ const R = ms.get(h) ?? /* @__PURE__ */ new Set();
14852
+ if (!R.has(v)) {
14853
+ ms.set(h, R), R.add(v), xe(O.getState());
14851
14854
  try {
14852
- await R();
14855
+ await A();
14853
14856
  } finally {
14854
- T.delete(v), T.size || ms.delete(h), Ne || xe(P.getState());
14857
+ R.delete(v), R.size || ms.delete(h), Ne || xe(O.getState());
14855
14858
  }
14856
14859
  }
14857
14860
  };
14858
14861
  let Jn = null;
14859
14862
  const Ko = (h = {}) => {
14860
14863
  vt++, qt.clear(), oc(), en = null, we = null, fi = !1, is.clear(), sn = !0, ut(!0, "newSession"), St(), $e = !1, Ft();
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;
14864
+ const v = Promise.resolve(O.startNewSession(h));
14865
+ return vi = null, vo.clear(), F.value = "", lt = [], di(), Bi(F), Qe(), De(), _n(F, "new_chat"), xe(O.getState()), v;
14863
14866
  };
14864
14867
  le?.addEventListener("click", () => {
14865
14868
  cn(it("proactive_suggestion"), "run").catch(() => {
@@ -14873,7 +14876,7 @@ async function mw(t = {}) {
14873
14876
  cn(it("proactive_suggestion"), "not_now").catch(() => {
14874
14877
  });
14875
14878
  };
14876
- te?.addEventListener("click", $c), O?.addEventListener("click", $c), V?.addEventListener("click", () => {
14879
+ te?.addEventListener("click", $c), D?.addEventListener("click", $c), V?.addEventListener("click", () => {
14877
14880
  cn(it("proactive_suggestion"), "edit").catch(() => {
14878
14881
  });
14879
14882
  }), $?.addEventListener("click", async () => {
@@ -14886,7 +14889,7 @@ async function mw(t = {}) {
14886
14889
  if (!(!h || !v || nt === "submitting")) {
14887
14890
  nt = "submitting", ct();
14888
14891
  try {
14889
- await P.actOnInteraction(h.interactionId ?? h.id, "feedback", 0, { feedback: v }), nt = "success";
14892
+ await O.actOnInteraction(h.interactionId ?? h.id, "feedback", 0, { feedback: v }), nt = "success";
14890
14893
  } catch {
14891
14894
  nt = "error";
14892
14895
  }
@@ -14917,7 +14920,7 @@ async function mw(t = {}) {
14917
14920
  let Wc = "", dn = !1;
14918
14921
  const Dp = async () => {
14919
14922
  if (dn) return;
14920
- dn = !0, xe(P.getState());
14923
+ dn = !0, xe(O.getState());
14921
14924
  let h;
14922
14925
  try {
14923
14926
  await Promise.race([
@@ -14927,7 +14930,7 @@ async function mw(t = {}) {
14927
14930
  })
14928
14931
  ]);
14929
14932
  } finally {
14930
- clearTimeout(h), dn = !1, Ne || xe(P.getState());
14933
+ clearTimeout(h), dn = !1, Ne || xe(O.getState());
14931
14934
  }
14932
14935
  };
14933
14936
  kt.addEventListener("click", () => {
@@ -14936,10 +14939,10 @@ async function mw(t = {}) {
14936
14939
  let qn = !1, Ti = null, ys = 0, Vo = 0;
14937
14940
  const xe = (h, v = {}) => {
14938
14941
  pc(h) && (we = null), uc = v.renderSource ?? "local";
14939
- const R = n();
14940
- c.dataset.conversationGate = e.loginRequired || R ? "authentication" : e.signupRequired ? "signup" : "none", To(), c.classList.toggle(
14942
+ const A = n();
14943
+ c.dataset.conversationGate = e.loginRequired || A ? "authentication" : e.signupRequired ? "signup" : "none", To(), c.classList.toggle(
14941
14944
  "pluno-pa-widget--logged-out",
14942
- (e.loginRequired || R) && e.entrySurface === "extension_widget"
14945
+ (e.loginRequired || A) && e.entrySurface === "extension_widget"
14943
14946
  ), Z.classList.remove("pluno-pa-widget__access-notice--login-only"), h = { ...h, messages: h.messages.map((oe) => {
14944
14947
  if (!oe.attachments?.some((Te) => Te.id && !Te.fileUrl && li.has(Te.id))) return oe;
14945
14948
  const pt = oe.attachments.map((Te) => {
@@ -14951,19 +14954,19 @@ async function mw(t = {}) {
14951
14954
  attachments: { value: pt, enumerable: !0, configurable: !0 }
14952
14955
  });
14953
14956
  }) }, Vn(), nn !== null && (window.clearTimeout(nn), nn = null), Ft(), ct(), bo(), Z.hidden = !i(), Z.hidden && Z.replaceChildren();
14954
- const T = JSON.stringify([
14957
+ const R = JSON.stringify([
14955
14958
  i(),
14956
14959
  h.lastError,
14957
14960
  h.lastErrorCode,
14958
14961
  h.lastErrorSecuritySettingsUrl,
14959
14962
  dn
14960
14963
  ]);
14961
- if (Wc !== T) {
14962
- Wc = T, Me.hidden = i() || !h.lastError || Wi(h.lastErrorCode) !== "bottom_notice";
14964
+ if (Wc !== R) {
14965
+ Wc = R, Me.hidden = i() || !h.lastError || Wi(h.lastErrorCode) !== "bottom_notice";
14963
14966
  const oe = Me.hidden ? "" : h.lastError ?? "";
14964
14967
  Wo.data !== oe && (Wo.data = oe), Me.hidden ? Ht.remove() : Ht.parentElement !== Me && Me.appendChild(Ht), h.lastErrorSecuritySettingsUrl ? (ln.href = h.lastErrorSecuritySettingsUrl, ln.parentElement !== Ht && Ht.insertBefore(ln, kt.parentElement ? kt : null)) : ln.remove(), h.lastErrorCode === "connection_failed" || h.lastErrorCode === "auth_reconnecting" || h.lastErrorCode === "submission_checkpoint_pending" ? (kt.disabled = dn, kt.setAttribute("aria-busy", String(dn)), Hc.hidden = !dn, Kc.data = dn ? "Trying" : "Try again", kt.parentElement !== Ht && Ht.appendChild(kt)) : kt.remove();
14965
14968
  }
14966
- if (R) {
14969
+ if (A) {
14967
14970
  mi = "", Ai.clear(), gs.clear(), fs.clear(), G.replaceChildren(), Rs(
14968
14971
  Z,
14969
14972
  pe,
@@ -14996,10 +14999,10 @@ async function mw(t = {}) {
14996
14999
  const Te = Z.querySelector(".pluno-pa-widget__login");
14997
15000
  Te.disabled = qn, Te.setAttribute("aria-busy", String(qn)), qn && Te.prepend(bn()), Te.addEventListener("click", () => {
14998
15001
  const qi = ++ys, Fp = Vo;
14999
- qn = !0, Ti = null, xe(P.getState()), pt().catch((Xc) => {
15002
+ qn = !0, Ti = null, xe(O.getState()), pt().catch((Xc) => {
15000
15003
  qi !== ys || Fp !== Vo || (Ti = Xc instanceof Error ? Xc.message : "Close and reopen Pluno to try again.");
15001
15004
  }).finally(() => {
15002
- qi === ys && (qn = !1, Ne || xe(P.getState()));
15005
+ qi === ys && (qn = !1, Ne || xe(O.getState()));
15003
15006
  });
15004
15007
  });
15005
15008
  return;
@@ -15063,17 +15066,17 @@ async function mw(t = {}) {
15063
15066
  sn = !0, ut(!0, "send"), St();
15064
15067
  const Te = it("morning_report");
15065
15068
  Te ? cn(Te, "run", { taskIndex: pt }).catch(() => {
15066
- }) : P.sendMessage(oe);
15069
+ }) : O.sendMessage(oe);
15067
15070
  },
15068
- (oe) => (sn = !0, ut(!0, "send"), St(), P.retryLastMessage(oe)),
15071
+ (oe) => (sn = !0, ut(!0, "send"), St(), O.retryLastMessage(oe)),
15069
15072
  e.morningReport,
15070
15073
  () => {
15071
15074
  const oe = it("morning_report");
15072
15075
  oe && cn(oe, "snooze").then(() => {
15073
- Po("morning_report_snooze"), xe(P.getState());
15074
- }).catch(() => xe(P.getState()));
15076
+ Po("morning_report_snooze"), xe(O.getState());
15077
+ }).catch(() => xe(O.getState()));
15075
15078
  },
15076
- () => h.sessionId ? P.loadSession(h.sessionId) : void 0,
15079
+ () => h.sessionId ? O.loadSession(h.sessionId) : void 0,
15077
15080
  () => Ko(),
15078
15081
  ms.get(h.selectionKey ?? h.sessionId ?? "draft"),
15079
15082
  (oe, pt) => {
@@ -15097,12 +15100,12 @@ async function mw(t = {}) {
15097
15100
  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;
15098
15101
  Yc !== null && (nn = window.setTimeout(
15099
15102
  () => {
15100
- nn = null, Ne || xe(P.getState());
15103
+ nn = null, Ne || xe(O.getState());
15101
15104
  },
15102
15105
  Math.min(Yc, 2147483647)
15103
15106
  )), se ? (on = G.scrollTop, St()) : ie && gd(h) && _p();
15104
15107
  }, Vc = () => {
15105
- k.getSelection()?.isCollapsed !== !1 && S_(Ai) && xe(P.getState());
15108
+ k.getSelection()?.isCollapsed !== !1 && S_(Ai) && xe(O.getState());
15106
15109
  };
15107
15110
  k.addEventListener(
15108
15111
  "selectionchange",
@@ -15111,35 +15114,35 @@ async function mw(t = {}) {
15111
15114
  const Go = (h) => {
15112
15115
  Tn = e.entrySurface === "extension_widget" || h.user && !e.loginRequired ? h.activeUsersCount ?? null : null, Fc();
15113
15116
  };
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) => {
15117
+ Go(O.getState());
15118
+ const Lp = O.subscribeInteractions((h) => {
15119
+ hs = h, $o(), e.morningReport = it("morning_report")?.payload ?? null, e.proactiveSuggestion = it("proactive_suggestion")?.payload.suggestion ?? null, Ne || xe(O.getState(), { skipUnchangedTimeline: !0, renderSource: "interactions" });
15120
+ }), Np = O.subscribeAccount((h) => {
15118
15121
  if (!h && !ds) return;
15119
15122
  const v = h?.auth;
15120
15123
  (v?.status !== "error" || v.errorCode !== "browser_session_unavailable" && v.errorCode !== "backend_auth_pending") && (ys += 1, Ti = null, qn = !1);
15121
- const R = i();
15122
- e.billingStatus = h, s(h), Go(P.getState()), Gn(), xe(P.getState(), { skipUnchangedTimeline: !0, renderSource: "account" }), bo(), De(), queueMicrotask(Lc), R && !i() && Uo();
15124
+ const A = i();
15125
+ e.billingStatus = h, s(h), Go(O.getState()), Gn(), xe(O.getState(), { skipUnchangedTimeline: !0, renderSource: "account" }), bo(), De(), queueMicrotask(Lc), A && !i() && Uo();
15123
15126
  });
15124
15127
  let Jo = !1, Qo = null;
15125
15128
  const Gc = (h) => {
15126
15129
  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());
15127
15130
  };
15128
- P.on("state", (h) => {
15131
+ O.on("state", (h) => {
15129
15132
  const v = h.user?.id ?? null;
15130
15133
  (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;
15131
15134
  for (const ge of h.messages)
15132
15135
  ge.role === "user" && zo(ge.id);
15133
15136
  for (const ge of h.receipts ?? []) zo(ge.userMessageId, ge.acceptedRendererRevision);
15134
15137
  if (e.extensionRuntime && (Vo += 1, Ti = null), Go(h), lc) {
15135
- const ge = P.getModel(), xt = bb(ge) ? ge : Zs[0].value;
15138
+ const ge = O.getModel(), xt = bb(ge) ? ge : Zs[0].value;
15136
15139
  xt !== Pt && (Pt = xt, Vn());
15137
15140
  }
15138
15141
  Gc(h), h.status === "connected" && (ds = !0, en && queueMicrotask(() => {
15139
15142
  Lc();
15140
15143
  })), Pp();
15141
- const R = Ho && !h.isThinking, T = gc !== location.origin || fc !== h.sessionId || mc !== (h.user?.id ?? null), j = Ho !== h.isThinking, ie = So !== "connected" && h.status === "connected", se = So === "connected" && h.status !== "connected";
15142
- gc = location.origin, fc = h.sessionId, mc = h.user?.id ?? null, So = h.status, Ho = h.isThinking, se && dt !== null && (window.clearTimeout(dt), dt = null), c.classList.contains("pluno-pa-widget--open") && h.status === "connected" && (T || j || ie) && Co(), Oe && (Oe.hidden = it("task_notifications") === void 0), Fe && (Fe.hidden = it("tab_group_permission") === void 0), R && !c.classList.contains("pluno-pa-widget--open") && (ki = !0), No(), h.appearance ? (Fo = !0, ot(
15144
+ const A = Ho && !h.isThinking, R = gc !== location.origin || fc !== h.sessionId || mc !== (h.user?.id ?? null), j = Ho !== h.isThinking, ie = So !== "connected" && h.status === "connected", se = So === "connected" && h.status !== "connected";
15145
+ gc = location.origin, fc = h.sessionId, mc = h.user?.id ?? null, So = h.status, Ho = h.isThinking, se && dt !== null && (window.clearTimeout(dt), dt = null), c.classList.contains("pluno-pa-widget--open") && h.status === "connected" && (R || j || ie) && Co(), Oe && (Oe.hidden = it("task_notifications") === void 0), Fe && (Fe.hidden = it("tab_group_permission") === void 0), A && !c.classList.contains("pluno-pa-widget--open") && (ki = !0), No(), h.appearance ? (Fo = !0, ot(
15143
15146
  "web-sdk.widget",
15144
15147
  "Agent state supplied appearance",
15145
15148
  {
@@ -15153,29 +15156,29 @@ async function mw(t = {}) {
15153
15156
  fallbackColorScheme: e.colorScheme,
15154
15157
  fallbackFontFamily: e.fontFamily
15155
15158
  }
15156
- ), Yo({}, "agent.state.appearance-cleared")), xe(h, { skipUnchangedTimeline: !0, renderSource: "state" }), De(), R && qo();
15159
+ ), Yo({}, "agent.state.appearance-cleared")), xe(h, { skipUnchangedTimeline: !0, renderSource: "state" }), De(), A && qo();
15157
15160
  });
15158
- const Jc = P.getState();
15161
+ const Jc = O.getState();
15159
15162
  Gc(Jc), xe(Jc), De(), Uo();
15160
- const Up = Vh(c, (h, v, R, T, j) => {
15161
- const ie = Yp(P.getState(), T);
15162
- P.reportDisplayedError?.(h, v, R, ie ?? void 0, j);
15163
+ const Up = Vh(c, (h, v, A, R, j) => {
15164
+ const ie = Yp(O.getState(), R);
15165
+ O.reportDisplayedError?.(h, v, A, ie ?? void 0, j);
15163
15166
  }), zp = Nb(
15164
15167
  r,
15165
15168
  c,
15166
15169
  e.extensionRuntime ? "extension_widget" : e.entrySurface === "main_web_chat" ? "main_web_chat" : "embedded_widget",
15167
- P
15170
+ O
15168
15171
  ), Bp = Gh(c, xo);
15169
15172
  return {
15170
- agent: P,
15173
+ agent: O,
15171
15174
  startNewChat: Ko,
15172
15175
  host: r,
15173
15176
  updateAppearance: (h) => {
15174
15177
  h.scribbleStyle !== void 0 && (e.scribbleStyle = h.scribbleStyle), Yo(h, "widgetHandle.updateAppearance");
15175
15178
  },
15176
15179
  openPanel: (h) => {
15177
- const v = typeof h == "string" ? h : F.value, R = typeof h == "object" ? h.focusComposer !== !1 : !0, T = typeof h == "object" ? h.trigger ?? "external_request" : "external_request";
15178
- T === "proactive_suggestion" && e.proactiveSuggestion && (Zi = e.proactiveSuggestion, Wn = !0, ct()), Mt(T === "proactive_suggestion" ? "Yes, but " : v, !1, R, !0, T);
15180
+ const v = typeof h == "string" ? h : F.value, A = typeof h == "object" ? h.focusComposer !== !1 : !0, R = typeof h == "object" ? h.trigger ?? "external_request" : "external_request";
15181
+ R === "proactive_suggestion" && e.proactiveSuggestion && (Zi = e.proactiveSuggestion, Wn = !0, ct()), Mt(R === "proactive_suggestion" ? "Yes, but " : v, !1, A, !0, R);
15179
15182
  },
15180
15183
  closePanel: Po,
15181
15184
  updateDisplayState: (h) => {
@@ -15215,7 +15218,7 @@ async function mw(t = {}) {
15215
15218
  ), k.removeEventListener("drop", an, !0), k.removeEventListener("dragend", an, !0), k.defaultView?.removeEventListener(
15216
15219
  "blur",
15217
15220
  an
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());
15221
+ ), 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 && O.destroy(), _o?.release(), r.remove());
15219
15222
  }
15220
15223
  };
15221
15224
  async function jp(h) {
@@ -15225,32 +15228,32 @@ async function mw(t = {}) {
15225
15228
  return;
15226
15229
  } catch {
15227
15230
  }
15228
- const v = Cs(k), R = v instanceof HTMLElement ? v : null, T = document.createElement("textarea");
15229
- T.value = h, T.readOnly = !0, T.setAttribute("aria-hidden", "true"), T.style.position = "fixed", T.style.left = "-9999px", T.style.opacity = "0", document.body.appendChild(T);
15231
+ const v = Cs(k), A = v instanceof HTMLElement ? v : null, R = document.createElement("textarea");
15232
+ R.value = h, R.readOnly = !0, R.setAttribute("aria-hidden", "true"), R.style.position = "fixed", R.style.left = "-9999px", R.style.opacity = "0", document.body.appendChild(R);
15230
15233
  try {
15231
- if (T.select(), T.setSelectionRange(0, h.length), !document.execCommand("copy"))
15234
+ if (R.select(), R.setSelectionRange(0, h.length), !document.execCommand("copy"))
15232
15235
  throw new Error("Could not copy referral link.");
15233
15236
  } finally {
15234
- T.remove(), R?.isConnected && _n(R, "referral_copy_restore", {
15237
+ R.remove(), A?.isConnected && _n(A, "referral_copy_restore", {
15235
15238
  preventScroll: !0
15236
15239
  });
15237
15240
  }
15238
15241
  }
15239
15242
  function Yo(h, v) {
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]);
15243
+ const A = h.accentColor ?? e.accentColor, R = h.colorScheme ?? e.colorScheme, j = h.fontFamily ?? e.fontFamily, ie = h.scribbleStyle ?? e.scribbleStyle, se = JSON.stringify([A, R, j, ie]);
15241
15244
  se !== w && (w = se, u = cd(
15242
- R,
15245
+ A,
15243
15246
  ie
15244
15247
  ), ld(c, u, {
15245
- accentColor: R,
15246
- colorScheme: T,
15248
+ accentColor: A,
15249
+ colorScheme: R,
15247
15250
  fontFamily: j,
15248
15251
  scribbleStyle: ie
15249
15252
  }), ot("web-sdk.widget", "Updated widget appearance", {
15250
15253
  source: v,
15251
15254
  inputAppearance: h,
15252
- appliedAccentColor: R,
15253
- appliedColorScheme: T,
15255
+ appliedAccentColor: A,
15256
+ appliedColorScheme: R,
15254
15257
  appliedFontFamily: j,
15255
15258
  appliedScribbleStyle: ie,
15256
15259
  cssAccent: c.style.getPropertyValue("--pluno-pa-accent")
@@ -17034,68 +17037,68 @@ function Id(t, e) {
17034
17037
  const i = n[1], s = e ? "Finding example tasks..." : " ";
17035
17038
  i.textContent !== s && (i.textContent = s), i.classList.toggle("pluno-pa-widget__starter-placeholder--loading", e), i.parentElement.setAttribute("aria-hidden", String(!e));
17036
17039
  }
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();
17040
+ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I, E, q, x) {
17041
+ const M = ah(o), P = C_(o), z = Array.isArray(o.activeScheduledFollowUps) ? o.activeScheduledFollowUps : null, B = /* @__PURE__ */ new Map();
17039
17042
  if (z !== null)
17040
- for (const q of z) {
17041
- const D = oi(q.dueAt);
17042
- D && B.set(q.taskId, { dueAt: q.dueAt, label: D });
17043
+ for (const T of z) {
17044
+ const L = oi(T.dueAt);
17045
+ L && B.set(T.taskId, { dueAt: T.dueAt, label: L });
17043
17046
  }
17044
17047
  else
17045
- for (const q of M) {
17046
- const D = q.scheduledCheckInAt ? oi(q.scheduledCheckInAt) : null;
17047
- if (!D || !q.scheduledCheckInAt)
17048
+ for (const T of P) {
17049
+ const L = T.scheduledCheckInAt ? oi(T.scheduledCheckInAt) : null;
17050
+ if (!L || !T.scheduledCheckInAt)
17048
17051
  continue;
17049
- const le = q.scheduledCheckInId ?? q.id;
17052
+ const le = T.scheduledCheckInId ?? T.id;
17050
17053
  B.set(le, {
17051
- dueAt: q.scheduledCheckInAt,
17052
- label: D
17054
+ dueAt: T.scheduledCheckInAt,
17055
+ label: L
17053
17056
  });
17054
17057
  }
17055
- const C = [...B.values()].sort((q, D) => Date.parse(q.dueAt) - Date.parse(D.dueAt)), U = A_(
17056
- M.filter(
17057
- (q) => !up(q) && !q.scheduledCheckInAt
17058
+ const C = [...B.values()].sort((T, L) => Date.parse(T.dueAt) - Date.parse(L.dueAt)), U = A_(
17059
+ P.filter(
17060
+ (T) => !up(T) && !T.scheduledCheckInAt
17058
17061
  ),
17059
17062
  o.segments
17060
- ), X = new Map((o.segments ?? []).flatMap((q) => q.activityIds.map((D) => [D, q])));
17063
+ ), X = new Map((o.segments ?? []).flatMap((T) => T.activityIds.map((L) => [L, T])));
17061
17064
  t.dataset.selectedSessionId = o.sessionId ?? "", t.dataset.removedItems = JSON.stringify(o.removedItems ?? {}), t.dataset.loadingSession = String(o.isLoadingSession);
17062
17065
  const Z = o.activeResponseUserMessageId;
17063
- if (L.showProgress && o.turnPhase && !o.assistantDraft && Z) {
17064
- const q = U.findIndex(
17066
+ if (M.showProgress && o.turnPhase && !o.assistantDraft && Z) {
17067
+ const T = U.findIndex(
17065
17068
  (le) => le.role === "user" && le.id === Z
17066
- ), D = U.some(
17069
+ ), L = U.some(
17067
17070
  (le) => le.role !== "user" && le.respondsToUserMessageId === Z
17068
17071
  );
17069
- q !== -1 && !D && U.splice(q + 1, 0, {
17072
+ T !== -1 && !L && U.splice(T + 1, 0, {
17070
17073
  id: `turn-status:${Z}`,
17071
17074
  role: "system",
17072
17075
  content: "",
17073
- createdAt: U[q].createdAt,
17076
+ createdAt: U[T].createdAt,
17074
17077
  respondsToUserMessageId: Z,
17075
17078
  dataType: "run_status",
17076
17079
  loading: !0
17077
17080
  });
17078
17081
  }
17079
- const Me = t.scrollTop, _e = [], qe = /* @__PURE__ */ new Set(), Ae = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Set(), Q = (q) => {
17080
- q === e && _e.push(t.querySelector('slot[name="conversation-notices"]') ?? Xu("conversation-notices")), q.dataset.sessionId = o.sessionId ?? "", _e.push(q);
17082
+ const Me = t.scrollTop, _e = [], qe = /* @__PURE__ */ new Set(), Ae = /* @__PURE__ */ new Set(), F = /* @__PURE__ */ new Set(), Q = (T) => {
17083
+ T === e && _e.push(t.querySelector('slot[name="conversation-notices"]') ?? Xu("conversation-notices")), T.dataset.sessionId = o.sessionId ?? "", _e.push(T);
17081
17084
  };
17082
17085
  nc(n, o.isThinking), n.disabled = !1, s.hidden = !r, r && a !== null && ep(s, a);
17083
- const et = !!A?.cards.length, Ve = et || U.length > 0 || C.length > 0 || !!o.assistantDraft || o.pendingMessageStatus !== null || o.isThinking;
17086
+ const et = !!x?.cards.length, Ve = et || U.length > 0 || C.length > 0 || !!o.assistantDraft || o.pendingMessageStatus !== null || o.isThinking;
17084
17087
  if (i(Ve || !!o.historyPreparation), o.historyPreparation && Ve) {
17085
- const q = document.createElement("div");
17086
- q.className = "pluno-pa-widget__transcript-loading", q.setAttribute("role", "status"), q.append(bn(), document.createTextNode("Preparing this conversation…")), Q(q);
17088
+ const T = document.createElement("div");
17089
+ T.className = "pluno-pa-widget__transcript-loading", T.setAttribute("role", "status"), T.append(bn(), document.createTextNode("Preparing this conversation…")), Q(T);
17087
17090
  }
17088
17091
  if (o.isLoadingSession && !Ve) {
17089
- const q = document.createElement("div");
17090
- q.className = "pluno-pa-widget__transcript-loading", q.setAttribute("role", "status");
17091
- const D = document.createElement("span");
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);
17092
+ const T = document.createElement("div");
17093
+ T.className = "pluno-pa-widget__transcript-loading", T.setAttribute("role", "status");
17094
+ const L = document.createElement("span");
17095
+ L.textContent = o.historyPreparation ? "Preparing this conversation…" : "Loading chat...", T.append(bn(), L), d.clear(), p.clear(), g.clear(), Q(T), Q(e), Lt(t, _e);
17093
17096
  return;
17094
17097
  }
17095
17098
  if (!Ve && o.sessionId && !o.isDraftSession) {
17096
17099
  if (!o.lastError) {
17097
- const q = document.createElement("div");
17098
- q.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--conversation", q.textContent = rh, Q(q);
17100
+ const T = document.createElement("div");
17101
+ T.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--conversation", T.textContent = rh, Q(T);
17099
17102
  }
17100
17103
  if (!o.lastError || Wi(o.lastErrorCode) === "bottom_notice") {
17101
17104
  Q(e), Lt(t, _e);
@@ -17103,15 +17106,15 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I,
17103
17106
  }
17104
17107
  }
17105
17108
  if (U.length === 0 && !et && C.length === 0 && !o.assistantDraft && (!o.lastError || Wi(o.lastErrorCode) === "bottom_notice") && !o.pendingMessageStatus && !o.isThinking) {
17106
- const q = A?.morning, D = JSON.stringify([
17109
+ const T = x?.morning, L = JSON.stringify([
17107
17110
  o.sessionId,
17108
17111
  o.user?.id,
17109
17112
  S,
17110
- q,
17113
+ T,
17111
17114
  o.starterPrompts,
17112
17115
  f()
17113
17116
  ]), le = d.get("welcome");
17114
- if (le?.renderSignature === D) {
17117
+ if (le?.renderSignature === L) {
17115
17118
  Id(le.node, o.starterPromptsLoading), Q(le.node), Q(e), Lt(t, _e);
17116
17119
  return;
17117
17120
  }
@@ -17119,11 +17122,11 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I,
17119
17122
  V.className = "pluno-pa-widget__empty-state pluno-pa-widget__empty-state--starter" + (S ? " pluno-pa-widget__empty-state--morning-report" : "");
17120
17123
  const te = document.createElement("div");
17121
17124
  te.className = "pluno-pa-widget__empty-hero";
17122
- const O = Ut(
17125
+ const D = Ut(
17123
17126
  "pluno-pa-widget__character--empty",
17124
17127
  f()
17125
17128
  );
17126
- if (te.appendChild(O), V.appendChild(te), S) {
17129
+ if (te.appendChild(D), V.appendChild(te), S) {
17127
17130
  const K = document.createElement("h2");
17128
17131
  K.className = "pluno-pa-widget__empty pluno-pa-widget__morning-report-title", K.textContent = S.opening, V.appendChild(K);
17129
17132
  } else
@@ -17132,7 +17135,7 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I,
17132
17135
  if (Y.className = $.length > 0 ? "pluno-pa-widget__starter-prompts" : "pluno-pa-widget__starter-prompts pluno-pa-widget__starter-prompts--empty", $.length === 0 && !o.starterPromptsLoading && Y.setAttribute("aria-hidden", "true"), $.length > 0)
17133
17136
  for (const [K, ue] of $.entries()) {
17134
17137
  const ne = document.createElement("button");
17135
- ne.type = "button", ne.className = "pluno-pa-widget__starter-prompt", ne.textContent = ue, ne.disabled = q?.status === "pending", ne.addEventListener("click", () => {
17138
+ ne.type = "button", ne.className = "pluno-pa-widget__starter-prompt", ne.textContent = ue, ne.disabled = T?.status === "pending", ne.addEventListener("click", () => {
17136
17139
  b(ue, K);
17137
17140
  }), Y.appendChild(ne);
17138
17141
  }
@@ -17143,27 +17146,27 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I,
17143
17146
  }
17144
17147
  if (V.appendChild(Y), Id(V, o.starterPromptsLoading), S) {
17145
17148
  const K = document.createElement("button");
17146
- if (K.type = "button", K.className = "pluno-pa-widget__morning-report-snooze", K.textContent = "Snooze morning report", K.disabled = q?.status === "pending", K.addEventListener("click", k), V.appendChild(K), q && "error" in q.payload && q.payload.error) {
17149
+ if (K.type = "button", K.className = "pluno-pa-widget__morning-report-snooze", K.textContent = "Snooze morning report", K.disabled = T?.status === "pending", K.addEventListener("click", k), V.appendChild(K), T && "error" in T.payload && T.payload.error) {
17147
17150
  const ue = document.createElement("p");
17148
- ue.setAttribute("role", "alert"), ue.textContent = String(q.payload.error), V.appendChild(ue);
17151
+ ue.setAttribute("role", "alert"), ue.textContent = String(T.payload.error), V.appendChild(ue);
17149
17152
  }
17150
17153
  }
17151
- d.clear(), p.clear(), g.clear(), Q(V), d.set("welcome", { node: V, renderSignature: D }), Q(e), Lt(t, _e);
17154
+ d.clear(), p.clear(), g.clear(), Q(V), d.set("welcome", { node: V, renderSignature: L }), Q(e), Lt(t, _e);
17152
17155
  return;
17153
17156
  }
17154
17157
  let pe = null, ve = null, Ie = [];
17155
17158
  const tt = U.some(Ca), W = U.some(
17156
- (q) => q.role === "tool" && q.id === o.activity?.activeItemId
17159
+ (T) => T.role === "tool" && T.id === o.activity?.activeItemId
17157
17160
  ), he = o.turnPhase ? Mb(o.turnPhase) : "Thinking...";
17158
17161
  let re = !1;
17159
17162
  const H = () => {
17160
17163
  if (Ie.length === 0)
17161
17164
  return re = !1, !1;
17162
- const q = L.showProgress && Ie.some(
17165
+ const T = M.showProgress && Ie.some(
17163
17166
  (le) => le.id === o.activity?.activeItemId
17164
- ), D = O_(
17167
+ ), L = O_(
17165
17168
  Ie,
17166
- q,
17169
+ T,
17167
17170
  u,
17168
17171
  p,
17169
17172
  Ae,
@@ -17171,57 +17174,57 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I,
17171
17174
  f(),
17172
17175
  X.get(Ie[0].id)?.collapsed ?? !0
17173
17176
  );
17174
- return Q(D), pe = null, ve = D, Ie = [], re = q, !0;
17175
- }, ee = (q) => {
17176
- const D = (te, O) => A.act(q, te, O), le = q.payload.error ?? null;
17177
+ return Q(L), pe = null, ve = L, Ie = [], re = T, !0;
17178
+ }, ee = (T) => {
17179
+ const L = (te, D) => x.act(T, te, D), le = T.payload.error ?? null;
17177
17180
  let V;
17178
- if (q.kind === "social_share") V = P_(q.payload.candidate, {
17179
- isActing: q.status === "pending",
17181
+ if (T.kind === "social_share") V = P_(T.payload.candidate, {
17182
+ isActing: T.status === "pending",
17180
17183
  error: le,
17181
17184
  characterIconOptions: f(),
17182
- presentation: q.presentation,
17183
- socialPostRewardsUrl: A?.socialPostRewardsUrl,
17184
- onReferralCopy: () => D("copy"),
17185
- onSocialShare: (te, O) => D("share", O),
17186
- onDismiss: () => D("dismiss")
17185
+ presentation: T.presentation,
17186
+ socialPostRewardsUrl: x?.socialPostRewardsUrl,
17187
+ onReferralCopy: () => L("copy"),
17188
+ onSocialShare: (te, D) => L("share", D),
17189
+ onDismiss: () => L("dismiss")
17187
17190
  });
17188
- else if (q.kind === "integration_connection") V = m_(
17189
- q.payload.request,
17190
- { status: q.status === "pending" ? "connecting" : q.payload.status, error: le ?? void 0 },
17191
- () => D("connect"),
17192
- q.presentation
17191
+ else if (T.kind === "integration_connection") V = m_(
17192
+ T.payload.request,
17193
+ { status: T.status === "pending" ? "connecting" : T.payload.status, error: le ?? void 0 },
17194
+ () => L("connect"),
17195
+ T.presentation
17193
17196
  );
17194
- else if (q.kind === "personal_channel_connection") V = y_(
17195
- q.payload.request,
17196
- () => D("pair"),
17197
- q.presentation,
17198
- q.status === "pending" ? "connect" : null
17197
+ else if (T.kind === "personal_channel_connection") V = y_(
17198
+ T.payload.request,
17199
+ () => L("pair"),
17200
+ T.presentation,
17201
+ T.status === "pending" ? "connect" : null
17199
17202
  );
17200
17203
  else return;
17201
- V.dataset.interactionId = q.id, V.dataset.interactionUserMessageId = q.userMessageId ?? "", Q(V), pe = null, ve = V;
17202
- }, be = new Set(U.filter((q) => q.role === "user").map((q) => q.id));
17203
- for (const q of A?.cards ?? []) be.has(q.userMessageId ?? "") || ee(q);
17204
+ V.dataset.interactionId = T.id, V.dataset.interactionUserMessageId = T.userMessageId ?? "", Q(V), pe = null, ve = V;
17205
+ }, be = new Set(U.filter((T) => T.role === "user").map((T) => T.id));
17206
+ for (const T of x?.cards ?? []) be.has(T.userMessageId ?? "") || ee(T);
17204
17207
  let G = null;
17205
17208
  const Re = () => {
17206
- for (const q of A?.cards ?? []) G && q.userMessageId === G && ee(q);
17209
+ for (const T of x?.cards ?? []) G && T.userMessageId === G && ee(T);
17207
17210
  };
17208
- for (let q = 0; q < U.length; q += 1) {
17209
- const D = U[q];
17210
- if (D.role === "user" && (H(), Re(), G = D.id), D.role === "tool") {
17211
- Ie.length > 0 && X.get(Ie[0].id)?.id !== X.get(D.id)?.id && H(), Ie.push(D);
17211
+ for (let T = 0; T < U.length; T += 1) {
17212
+ const L = U[T];
17213
+ if (L.role === "user" && (H(), Re(), G = L.id), L.role === "tool") {
17214
+ Ie.length > 0 && X.get(Ie[0].id)?.id !== X.get(L.id)?.id && H(), Ie.push(L);
17212
17215
  continue;
17213
17216
  }
17214
- if (D.role === "system" && D.dataType === "run_status" && D.steered === !0) {
17217
+ if (L.role === "system" && L.dataType === "run_status" && L.steered === !0) {
17215
17218
  if (!H()) {
17216
17219
  const Y = N_(f());
17217
17220
  Q(Y), pe = null, ve = Y;
17218
17221
  }
17219
17222
  continue;
17220
17223
  }
17221
- if (Ca(D)) {
17222
- if (!L.showProgress)
17224
+ if (Ca(L)) {
17225
+ if (!M.showProgress)
17223
17226
  continue;
17224
- const $ = H(), Y = lp(D);
17227
+ const $ = H(), Y = lp(L);
17225
17228
  if ($) {
17226
17229
  if (!re) {
17227
17230
  const K = xd(
@@ -17244,96 +17247,96 @@ function f_(t, e, n, i, s, o, a, r, l, c, u, d, p, g, y, f, b, w, S, k, m, _, I,
17244
17247
  }
17245
17248
  continue;
17246
17249
  }
17247
- if (D.role === "system") {
17248
- if (D.dataType === "run_error" || D.dataType === "run_status") {
17250
+ if (L.role === "system") {
17251
+ if (L.dataType === "run_error" || L.dataType === "run_status") {
17249
17252
  const $ = H(), Y = U.some(
17250
- (ne) => ne.role === "tool" && so(ne, D)
17253
+ (ne) => ne.role === "tool" && so(ne, L)
17251
17254
  );
17252
17255
  if (!$ && !Y) {
17253
17256
  const ne = Qi(f());
17254
17257
  ne.classList.add("pluno-pa-widget__terminal-marker"), Q(ne);
17255
17258
  }
17256
- const K = document.createElement("div"), ue = D.dataType === "run_error";
17257
- if (K.className = ue ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", K.dataset.messageKey = tc(D), K.dataset.canonicalItemKey = D.id, K.dataset.messageRole = "system", D.provisional || (K.dataset.terminalResponseKey = D.id), D.runId && (K.dataset.runId = D.runId), K.textContent = oo(
17258
- D.content
17259
- ), ue && D.securitySettingsUrl) {
17259
+ const K = document.createElement("div"), ue = L.dataType === "run_error";
17260
+ if (K.className = ue ? "pluno-pa-widget__error" : "pluno-pa-widget__status pluno-pa-widget__run-status", K.dataset.messageKey = tc(L), K.dataset.canonicalItemKey = L.id, K.dataset.messageRole = "system", L.provisional || (K.dataset.terminalResponseKey = L.id), L.runId && (K.dataset.runId = L.runId), K.textContent = oo(
17261
+ L.content
17262
+ ), ue && L.securitySettingsUrl) {
17260
17263
  const ne = document.createElement("a");
17261
- ne.className = "pluno-pa-widget__error-retry", ne.href = D.securitySettingsUrl, ne.target = "_blank", ne.rel = "noreferrer", ne.textContent = "Security settings", K.appendChild(ne);
17264
+ ne.className = "pluno-pa-widget__error-retry", ne.href = L.securitySettingsUrl, ne.target = "_blank", ne.rel = "noreferrer", ne.textContent = "Security settings", K.appendChild(ne);
17262
17265
  }
17263
17266
  Q(K), pe = ue ? K : null, ve = ue ? null : K;
17264
17267
  }
17265
17268
  continue;
17266
17269
  }
17267
- D.role;
17268
- const le = H(), V = oo(D.content), te = D.role === "assistant" && U.some(
17269
- ($) => $.role === "tool" && so($, D)
17270
+ L.role;
17271
+ const le = H(), V = oo(L.content), te = L.role === "assistant" && U.some(
17272
+ ($) => $.role === "tool" && so($, L)
17270
17273
  );
17271
- if (D.role === "assistant" && !le && !te) {
17274
+ if (L.role === "assistant" && !le && !te) {
17272
17275
  const $ = Qi(f());
17273
17276
  Q($), pe = null, ve = $;
17274
17277
  }
17275
- const O = b_(
17276
- D,
17278
+ const D = b_(
17279
+ L,
17277
17280
  V,
17278
17281
  d,
17279
17282
  qe,
17280
- E
17283
+ q
17281
17284
  );
17282
- if (O.querySelector("[data-submission-retry]")?.remove(), D.role === "user" && D.retryable) {
17285
+ if (D.querySelector("[data-submission-retry]")?.remove(), L.role === "user" && L.retryable) {
17283
17286
  const $ = document.createElement("button");
17284
- $.type = "button", $.className = "pluno-pa-widget__error-retry", $.dataset.submissionRetry = D.id, $.textContent = "Retry this message", $.addEventListener("click", () => w(D.id)), O.appendChild($);
17287
+ $.type = "button", $.className = "pluno-pa-widget__error-retry", $.dataset.submissionRetry = L.id, $.textContent = "Retry this message", $.addEventListener("click", () => w(L.id)), D.appendChild($);
17285
17288
  }
17286
- Q(O), pe = O, ve = null, D.role;
17289
+ Q(D), pe = D, ve = null, L.role;
17287
17290
  }
17288
17291
  const Oe = H(), Fe = U[U.length - 1]?.role === "assistant";
17289
- if (L.showProgress && o.turnPhase && !o.assistantDraft && !W && !Fe && !tt) {
17290
- const q = o.activeResponseUserMessageId ? `response:${o.activeResponseUserMessageId}` : `session:${o.sessionId ?? "pending"}`;
17292
+ if (M.showProgress && o.turnPhase && !o.assistantDraft && !W && !Fe && !tt) {
17293
+ const T = o.activeResponseUserMessageId ? `response:${o.activeResponseUserMessageId}` : `session:${o.sessionId ?? "pending"}`;
17291
17294
  if (Oe) {
17292
17295
  if (!re) {
17293
- const D = xd(
17296
+ const L = xd(
17294
17297
  g,
17295
17298
  F,
17296
- q,
17299
+ T,
17297
17300
  he
17298
17301
  );
17299
- Q(D), pe = null, ve = D;
17302
+ Q(L), pe = null, ve = L;
17300
17303
  }
17301
17304
  } else {
17302
- const D = kd(
17305
+ const L = kd(
17303
17306
  g,
17304
17307
  F,
17305
- q,
17308
+ T,
17306
17309
  f(),
17307
17310
  he
17308
17311
  );
17309
- Q(D), pe = null, ve = D;
17312
+ Q(L), pe = null, ve = L;
17310
17313
  }
17311
17314
  }
17312
17315
  if (o.lastError && Wi(o.lastErrorCode) === "conversation") {
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());
17316
+ const le = U.slice(U.map((D) => D.role).lastIndexOf("user") + 1).some((D) => D.role === "assistant" || D.role === "tool") ? document.createElement("article") : Qi(f());
17314
17317
  le.classList.add("pluno-pa-widget__terminal-marker");
17315
17318
  const V = document.createElement("div");
17316
17319
  V.className = "pluno-pa-widget__error", o.historyRefreshFailure && (V.dataset.historyRefreshFailure = JSON.stringify(o.historyRefreshFailure));
17317
17320
  const te = document.createElement("span");
17318
17321
  if (te.textContent = o.lastError, V.appendChild(te), o.lastErrorSecuritySettingsUrl) {
17319
- const O = document.createElement("a");
17320
- O.className = "pluno-pa-widget__error-retry", O.href = o.lastErrorSecuritySettingsUrl, O.target = "_blank", O.rel = "noreferrer", O.textContent = "Security settings", V.appendChild(O);
17322
+ const D = document.createElement("a");
17323
+ D.className = "pluno-pa-widget__error-retry", D.href = o.lastErrorSecuritySettingsUrl, D.target = "_blank", D.rel = "noreferrer", D.textContent = "Security settings", V.appendChild(D);
17321
17324
  }
17322
- for (const O of L.actions) {
17325
+ for (const D of M.actions) {
17323
17326
  const $ = document.createElement("button");
17324
17327
  $.type = "button", $.className = "pluno-pa-widget__error-retry";
17325
- const Y = I?.has(O) === !0 || O === "retry_history" && o.conversationDiagnostics?.queryRequestId != null || O === "retry_message" && o.isRetrying;
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($);
17328
+ const Y = I?.has(D) === !0 || D === "retry_history" && o.conversationDiagnostics?.queryRequestId != null || D === "retry_message" && o.isRetrying;
17329
+ $.disabled = Y, $.setAttribute("aria-busy", String(Y)), $.textContent = D === "new_chat" ? Y ? "Starting new chat" : "Start new chat" : Y ? "Trying" : "Try again", Y && $.prepend(bn()), $.addEventListener("click", () => E(D, D === "retry_history" ? m : D === "retry_message" ? w : _)), V.appendChild($);
17327
17330
  }
17328
17331
  le.appendChild(V), Q(le), pe = null, ve = le;
17329
17332
  }
17330
17333
  Re();
17331
- for (const q of C) {
17332
- const D = document.createElement("div");
17333
- D.className = "pluno-pa-widget__next-check-in", D.append(
17334
- Yw(q.dueAt),
17335
- document.createTextNode(q.label)
17336
- ), Q(D), pe = null, ve = D;
17334
+ for (const T of C) {
17335
+ const L = document.createElement("div");
17336
+ L.className = "pluno-pa-widget__next-check-in", L.append(
17337
+ Yw(T.dueAt),
17338
+ document.createTextNode(T.label)
17339
+ ), Q(L), pe = null, ve = L;
17337
17340
  }
17338
17341
  pe?.classList.add(
17339
17342
  "pluno-pa-widget__message--bottom-reserve"
@@ -17718,27 +17721,27 @@ function O_(t, e, n, i, s, o, a, r = !0) {
17718
17721
  const m = document.createElement("article"), _ = Ut(
17719
17722
  "pluno-pa-widget__character--tool-group",
17720
17723
  a
17721
- ), I = JSON.stringify(a), x = document.createElement("div");
17722
- x.className = "pluno-pa-widget__tool-active-content";
17723
- const E = mo(), A = document.createElement("details"), L = document.createElement("summary");
17724
- L.className = "pluno-pa-widget__tool-summary";
17725
- const M = document.createElement("div");
17726
- M.className = "pluno-pa-widget__tool-summary-title", L.appendChild(M), L.addEventListener("click", () => {
17724
+ ), I = JSON.stringify(a), E = document.createElement("div");
17725
+ E.className = "pluno-pa-widget__tool-active-content";
17726
+ const q = mo(), x = document.createElement("details"), M = document.createElement("summary");
17727
+ M.className = "pluno-pa-widget__tool-summary";
17728
+ const P = document.createElement("div");
17729
+ P.className = "pluno-pa-widget__tool-summary-title", M.appendChild(P), M.addEventListener("click", () => {
17727
17730
  const B = m.dataset.responseGroupKey ?? c;
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";
17729
- }), A.appendChild(L);
17731
+ x.open ? (n.delete(B), n.add(`closed:${B}`)) : (n.add(B), n.delete(`closed:${B}`)), o(), P.textContent = x.open ? m.dataset.collapsedActivityTitle ?? "Activities" : "Activities";
17732
+ }), x.appendChild(M);
17730
17733
  const z = document.createElement("div");
17731
- z.className = "pluno-pa-widget__tool-lines", A.addEventListener("toggle", () => {
17732
- m.dataset.responseGroupKey, m.classList.toggle("pluno-pa-widget__tool-group--open", A.open), M.textContent = A.open ? "Activities" : m.dataset.collapsedActivityTitle ?? "Activities";
17734
+ z.className = "pluno-pa-widget__tool-lines", x.addEventListener("toggle", () => {
17735
+ m.dataset.responseGroupKey, m.classList.toggle("pluno-pa-widget__tool-group--open", x.open), P.textContent = x.open ? "Activities" : m.dataset.collapsedActivityTitle ?? "Activities";
17733
17736
  }), u = {
17734
17737
  node: m,
17735
17738
  character: _,
17736
17739
  characterSignature: I,
17737
- activeContent: x,
17738
- thinkingStatus: E,
17739
- details: A,
17740
- summary: L,
17741
- summaryTitle: M,
17740
+ activeContent: E,
17741
+ thinkingStatus: q,
17742
+ details: x,
17743
+ summary: M,
17744
+ summaryTitle: P,
17742
17745
  lines: z,
17743
17746
  lineNodes: /* @__PURE__ */ new Map()
17744
17747
  }, i.set(c, u);