@epam/ai-dial-chat-hooks 1.3.0-rc.5 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-chat-hooks",
3
3
  "description": "Framework-level React hooks extracted from AI DIAL Chat for building custom chat interfaces",
4
- "version": "1.3.0-rc.5",
4
+ "version": "1.3.1",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -131,7 +131,7 @@
131
131
  }
132
132
  },
133
133
  "dependencies": {
134
- "@epam/ai-dial-chat-api-client": "1.3.0-rc.5",
134
+ "@epam/ai-dial-chat-api-client": "1.3.1",
135
135
  "dompurify": "3.4.17",
136
136
  "fflate": "^0.8.3",
137
137
  "lru-cache": "^10.4.3",
@@ -140,23 +140,23 @@
140
140
  },
141
141
  "peerDependencies": {
142
142
  "react": "^19.2.8",
143
- "@epam/ai-dial-attachment-canvas": "1.3.0-rc.5",
144
- "@epam/ai-dial-attachment-input": "1.3.0-rc.5",
145
- "@epam/ai-dial-catalog": "1.3.0-rc.5",
146
- "@epam/ai-dial-chat-overlay": "1.3.0-rc.5",
147
- "@epam/ai-dial-chat-shared": "1.3.0-rc.5",
148
- "@epam/ai-dial-conversation-input": "1.3.0-rc.5",
149
- "@epam/ai-dial-mcp-apps": "1.3.0-rc.5",
150
- "@epam/ai-dial-projects": "1.3.0-rc.5",
151
- "@epam/ai-dial-publish-panel": "1.3.0-rc.5",
152
- "@epam/ai-dial-quotations": "1.3.0-rc.5",
143
+ "@epam/ai-dial-attachment-canvas": "1.3.1",
144
+ "@epam/ai-dial-attachment-input": "1.3.1",
145
+ "@epam/ai-dial-catalog": "1.3.1",
146
+ "@epam/ai-dial-chat-overlay": "1.3.1",
147
+ "@epam/ai-dial-chat-shared": "1.3.1",
148
+ "@epam/ai-dial-conversation-input": "1.3.1",
149
+ "@epam/ai-dial-mcp-apps": "1.3.1",
150
+ "@epam/ai-dial-projects": "1.3.1",
151
+ "@epam/ai-dial-publish-panel": "1.3.1",
152
+ "@epam/ai-dial-quotations": "1.3.1",
153
153
  "@epam/ai-dial-react-file-manager": "^0.4.1",
154
- "@epam/ai-dial-scheduled-tasks": "1.3.0-rc.5",
155
- "@epam/ai-dial-share": "1.3.0-rc.5",
156
- "@epam/ai-dial-skill-editor": "1.3.0-rc.5",
157
- "@epam/ai-dial-source-panel": "1.3.0-rc.5",
154
+ "@epam/ai-dial-scheduled-tasks": "1.3.1",
155
+ "@epam/ai-dial-share": "1.3.1",
156
+ "@epam/ai-dial-skill-editor": "1.3.1",
157
+ "@epam/ai-dial-source-panel": "1.3.1",
158
158
  "@epam/ai-dial-ui-kit": "^0.16.0",
159
- "@epam/ai-dial-usage-dashboard": "1.3.0-rc.5",
159
+ "@epam/ai-dial-usage-dashboard": "1.3.1",
160
160
  "@modelcontextprotocol/sdk": "^1.32.2",
161
161
  "@epam/pdf-highlighter-kit": "^0.0.22"
162
162
  },
@@ -8,6 +8,8 @@ export interface PinnedProjectChatsOptions {
8
8
  enabled: boolean;
9
9
  /** The project no longer exists (a watch `DELETE`, or `404` on a read). Called at most once per id. */
10
10
  onProjectDeleted: (projectId: string) => void;
11
+ /** Id of the chat the host has open. When it is not among the newest chats of its project, it takes the last slot of that project's list, so the list never exceeds `PINNED_PROJECT_CHATS_LIMIT`. */
12
+ activeConversationId?: string;
11
13
  }
12
14
  /** A chat listed under a pinned project. */
13
15
  export interface PinnedProjectChat {
@@ -22,7 +24,7 @@ export interface PinnedProjectChat {
22
24
  export interface PinnedProjectChats {
23
25
  /** The project's details as last read; `canEdit`, `canManage`, `contentVersion` and `conversationCount` feed the host's actions. */
24
26
  project: ProjectDetailsDto;
25
- /** At most `PINNED_PROJECT_CHATS_LIMIT` chats, newest first. */
27
+ /** At most `PINNED_PROJECT_CHATS_LIMIT` chats, newest first; an open chat past the newest ones replaces the last of them and comes last. */
26
28
  chats: PinnedProjectChat[];
27
29
  /** The project has more chats than `chats` holds. */
28
30
  hasMore: boolean;
@@ -54,5 +56,5 @@ export interface PinnedProjectChatsResult {
54
56
  * @param projectIds - The pinned project ids, in display order.
55
57
  * @param options - Whether the tree is enabled and the delete callback; the callback is read at event time, so a new identity never resubscribes.
56
58
  */
57
- export declare const usePinnedProjectChats: (client: Pick<ProjectsApiClient, "getProject" | "listProjectConversations" | "getProjectConversationTitles" | "watchProjects">, projectIds: string[], { enabled, onProjectDeleted }: PinnedProjectChatsOptions) => PinnedProjectChatsResult;
59
+ export declare const usePinnedProjectChats: (client: Pick<ProjectsApiClient, "getProject" | "listProjectConversations" | "getProjectConversationTitles" | "watchProjects">, projectIds: string[], { enabled, onProjectDeleted, activeConversationId, }: PinnedProjectChatsOptions) => PinnedProjectChatsResult;
58
60
  //# sourceMappingURL=use-pinned-project-chats.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-pinned-project-chats.d.ts","sourceRoot":"","sources":["../../src/project/use-pinned-project-chats.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,kDAAkD;AAClD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAW7C,wEAAwE;AACxE,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,uGAAuG;IACvG,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,oIAAoI;IACpI,OAAO,EAAE,iBAAiB,CAAC;IAC3B,gEAAgE;IAChE,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;IACvC,qGAAqG;IACrG,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,oEAAoE;IACpE,SAAS,EAAE,OAAO,CAAC;IACnB,mGAAmG;IACnG,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,gGAAgG;IAChG,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAiFD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,IAAI,CACV,iBAAiB,EACf,YAAY,GACZ,0BAA0B,GAC1B,8BAA8B,GAC9B,eAAe,CAClB,EACD,YAAY,MAAM,EAAE,EACpB,+BAA+B,yBAAyB,KACvD,wBAqXF,CAAC"}
1
+ {"version":3,"file":"use-pinned-project-chats.d.ts","sourceRoot":"","sources":["../../src/project/use-pinned-project-chats.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,kDAAkD;AAClD,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAW7C,wEAAwE;AACxE,MAAM,WAAW,yBAAyB;IACxC,gEAAgE;IAChE,OAAO,EAAE,OAAO,CAAC;IACjB,uGAAuG;IACvG,gBAAgB,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,qMAAqM;IACrM,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAiB;IAChC,kCAAkC;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC,oIAAoI;IACpI,OAAO,EAAE,iBAAiB,CAAC;IAC3B,4IAA4I;IAC5I,KAAK,EAAE,iBAAiB,EAAE,CAAC;IAC3B,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;IACvC,qGAAqG;IACrG,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,oEAAoE;IACpE,SAAS,EAAE,OAAO,CAAC;IACnB,mGAAmG;IACnG,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,gGAAgG;IAChG,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAiHD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,qBAAqB,GAChC,QAAQ,IAAI,CACV,iBAAiB,EACf,YAAY,GACZ,0BAA0B,GAC1B,8BAA8B,GAC9B,eAAe,CAClB,EACD,YAAY,MAAM,EAAE,EACpB,sDAIG,yBAAyB,KAC3B,wBAwaF,CAAC"}
@@ -14,10 +14,26 @@ var l = 10, u = 1e3, d = [
14
14
  snapshots: /* @__PURE__ */ new Map(),
15
15
  settled: /* @__PURE__ */ new Set(),
16
16
  watchKey: ""
17
- }, m = [], h = (e, { settled: t, snapshots: n }, r) => {
17
+ }, m = [], h = ({ overflow: e, chats: t, ...n }, r) => {
18
+ if (r == null || t.some((e) => e.id === r)) return {
19
+ ...n,
20
+ chats: t
21
+ };
22
+ let i = e.find((e) => e.id === r);
23
+ return i == null ? {
24
+ ...n,
25
+ chats: t
26
+ } : {
27
+ ...n,
28
+ chats: [...t.slice(0, 9), {
29
+ id: i.id,
30
+ title: i.title
31
+ }]
32
+ };
33
+ }, g = (e, { settled: t, snapshots: n }, r) => {
18
34
  let i = [...e].sort();
19
35
  return i.every((e) => t.has(e)) ? i.filter((e) => n.has(e)).slice(0, u).join(f) : r;
20
- }, g = (e, t) => {
36
+ }, _ = (e, t) => {
21
37
  if (!e.snapshots.has(t) && !e.settled.has(t)) return e;
22
38
  let n = new Map(e.snapshots);
23
39
  n.delete(t);
@@ -27,7 +43,7 @@ var l = 10, u = 1e3, d = [
27
43
  snapshots: n,
28
44
  settled: r
29
45
  };
30
- }, _ = (e, t) => {
46
+ }, v = (e, t) => {
31
47
  if (t.length === 0) return e;
32
48
  let n = new Map(t.map((e) => [e.id, e]));
33
49
  return e.map((e) => {
@@ -38,73 +54,75 @@ var l = 10, u = 1e3, d = [
38
54
  isTitlePending: !1
39
55
  } : e;
40
56
  });
41
- }, v = (l, u, { enabled: v, onProjectDeleted: y }) => {
42
- let [b, x] = c(p), S = s(b);
57
+ }, y = (l, u, { enabled: y, onProjectDeleted: b, activeConversationId: x }) => {
58
+ let [S, C] = c(p), w = s(S);
43
59
  a(() => {
44
- S.current = b;
60
+ w.current = S;
45
61
  });
46
- let C = s(y);
62
+ let T = s(b);
47
63
  a(() => {
48
- C.current = y;
64
+ T.current = b;
49
65
  });
50
- let w = s(/* @__PURE__ */ new Set()), T = s(/* @__PURE__ */ new Map()), E = s(/* @__PURE__ */ new Map()), D = s(/* @__PURE__ */ new Set()), O = s(/* @__PURE__ */ new Map()), k = s(/* @__PURE__ */ new Map()), A = s(null), j = o(() => [...new Set(u)].sort().join(f), [u]), M = i(async (e, t) => {
66
+ let E = s(/* @__PURE__ */ new Set()), D = s(/* @__PURE__ */ new Map()), O = s(/* @__PURE__ */ new Map()), k = s(/* @__PURE__ */ new Set()), A = s(/* @__PURE__ */ new Map()), j = s(/* @__PURE__ */ new Map()), M = s(null), N = o(() => [...new Set(u)].sort().join(f), [u]), P = i(async (e, t) => {
51
67
  let [n, r] = await Promise.allSettled([l.getProject(e, t), l.listProjectConversations(e, t)]);
52
68
  if (n.status === "rejected") throw n.reason;
53
69
  let i = r.status === "fulfilled" ? r.value.items : [], a = i.slice(0, 10), o = a.filter((e) => e.isTitlePending).map((e) => e.name);
54
70
  if (o.length > 0) try {
55
71
  let { items: n } = await l.getProjectConversationTitles(e, o, t);
56
- a = _(a, n);
72
+ a = v(a, n);
57
73
  } catch {}
58
74
  return {
59
75
  project: n.value,
60
76
  items: a,
77
+ overflow: i.slice(10),
61
78
  hasMore: i.length > 10
62
79
  };
63
- }, [l]), N = i(({ project: e, items: t, hasMore: r }) => {
64
- for (let { id: e, updatedAt: n } of t) k.current.set(e, n);
80
+ }, [l]), F = i(({ project: e, items: t, overflow: r, hasMore: i }) => {
81
+ for (let { id: e, updatedAt: n } of [...t, ...r]) j.current.set(e, n);
65
82
  return {
66
83
  project: e,
67
- hasMore: r,
84
+ hasMore: i,
85
+ overflow: r,
68
86
  chats: t.map((e) => ({
69
87
  id: e.id,
70
88
  title: e.title,
71
- ...n(O.current, e) ? { isUnread: !0 } : {}
89
+ ...n(A.current, e) ? { isUnread: !0 } : {}
72
90
  }))
73
91
  };
74
- }, []), P = i((e) => {
75
- D.current.has(e) || (D.current.add(e), C.current(e));
76
- }, []), F = i((e) => {
77
- E.current.get(e)?.controller?.abort(), E.current.delete(e);
78
92
  }, []), I = i((e) => {
79
- F(e), x((t) => {
93
+ k.current.has(e) || (k.current.add(e), T.current(e));
94
+ }, []), L = i((e) => {
95
+ O.current.get(e)?.controller?.abort(), O.current.delete(e);
96
+ }, []), R = i((e) => {
97
+ L(e), C((t) => {
80
98
  if (!t.snapshots.has(e)) return t;
81
99
  let n = new Map(t.snapshots);
82
100
  return n.delete(e), {
83
101
  ...t,
84
102
  snapshots: n,
85
- watchKey: h(w.current, {
103
+ watchKey: g(E.current, {
86
104
  settled: t.settled,
87
105
  snapshots: n
88
106
  }, t.watchKey)
89
107
  };
90
108
  });
91
- }, [F]), L = i((t) => {
92
- if (!S.current.snapshots.has(t)) return;
93
- let n = E.current.get(t);
109
+ }, [L]), z = i((t) => {
110
+ if (!w.current.snapshots.has(t)) return;
111
+ let n = O.current.get(t);
94
112
  if (n ?? (n = {
95
113
  isRefreshing: !1,
96
114
  isPending: !1
97
- }, E.current.set(t, n)), n.isRefreshing) {
115
+ }, O.current.set(t, n)), n.isRefreshing) {
98
116
  n.isPending = !0;
99
117
  return;
100
118
  }
101
119
  let r = n, i = new AbortController();
102
120
  r.isRefreshing = !0, r.controller = i, (async () => {
103
121
  try {
104
- let e = await M(t, i.signal);
122
+ let e = await P(t, i.signal);
105
123
  if (i.signal.aborted) return;
106
- let n = N(e);
107
- x((e) => {
124
+ let n = F(e);
125
+ C((e) => {
108
126
  if (!e.snapshots.has(t)) return e;
109
127
  let r = new Map(e.snapshots);
110
128
  return r.set(t, n), {
@@ -114,33 +132,33 @@ var l = 10, u = 1e3, d = [
114
132
  });
115
133
  } catch (n) {
116
134
  if (i.signal.aborted) return;
117
- e(n) === 404 && (I(t), P(t));
135
+ e(n) === 404 && (R(t), I(t));
118
136
  } finally {
119
- r.isRefreshing = !1, r.isPending && !i.signal.aborted && E.current.get(t) === r && (r.isPending = !1, L(t));
137
+ r.isRefreshing = !1, r.isPending && !i.signal.aborted && O.current.get(t) === r && (r.isPending = !1, z(t));
120
138
  }
121
139
  })();
122
140
  }, [
123
- I,
124
- M,
141
+ R,
125
142
  P,
126
- N
127
- ]), R = i((t, n, r = 0) => {
143
+ I,
144
+ F
145
+ ]), B = i((t, n, r = 0) => {
128
146
  let i = () => {
129
- T.current.get(t) === n && T.current.delete(t);
147
+ D.current.get(t) === n && D.current.delete(t);
130
148
  };
131
149
  (async () => {
132
150
  try {
133
- let e = await M(t, n.signal);
151
+ let e = await P(t, n.signal);
134
152
  if (n.signal.aborted) return;
135
- let r = N(e);
136
- x((e) => {
153
+ let r = F(e);
154
+ C((e) => {
137
155
  let n = new Map(e.snapshots);
138
156
  n.set(t, r);
139
157
  let i = new Set(e.settled).add(t);
140
158
  return {
141
159
  snapshots: n,
142
160
  settled: i,
143
- watchKey: h(w.current, {
161
+ watchKey: g(E.current, {
144
162
  settled: i,
145
163
  snapshots: n
146
164
  }, e.watchKey)
@@ -148,13 +166,13 @@ var l = 10, u = 1e3, d = [
148
166
  }), i();
149
167
  } catch (a) {
150
168
  if (n.signal.aborted) return;
151
- x((e) => {
169
+ C((e) => {
152
170
  if (e.settled.has(t)) return e;
153
171
  let n = new Set(e.settled).add(t);
154
172
  return {
155
173
  ...e,
156
174
  settled: n,
157
- watchKey: h(w.current, {
175
+ watchKey: g(E.current, {
158
176
  settled: n,
159
177
  snapshots: e.snapshots
160
178
  }, e.watchKey)
@@ -162,74 +180,74 @@ var l = 10, u = 1e3, d = [
162
180
  });
163
181
  let o = e(a) === 404, s = o ? void 0 : d[r];
164
182
  if (s == null) {
165
- i(), o && P(t);
183
+ i(), o && I(t);
166
184
  return;
167
185
  }
168
- let c = setTimeout(() => R(t, n, r + 1), s);
186
+ let c = setTimeout(() => B(t, n, r + 1), s);
169
187
  n.signal.addEventListener("abort", () => clearTimeout(c), { once: !0 });
170
188
  }
171
189
  })();
172
190
  }, [
173
- M,
174
191
  P,
175
- N
192
+ I,
193
+ F
176
194
  ]);
177
195
  a(() => () => {
178
- for (let e of T.current.values()) e.abort();
179
- T.current.clear();
180
- for (let e of E.current.values()) e.controller?.abort();
181
- E.current.clear(), w.current.clear(), D.current.clear(), O.current.clear(), k.current.clear(), x(p);
182
- }, [l, v]), a(() => {
183
- if (!v) return;
184
- let e = new Set(j === "" ? [] : j.split(f));
185
- for (let t of [...w.current]) e.has(t) || (w.current.delete(t), D.current.delete(t), T.current.get(t)?.abort(), T.current.delete(t), F(t), x((e) => {
186
- let n = g(e, t);
196
+ for (let e of D.current.values()) e.abort();
197
+ D.current.clear();
198
+ for (let e of O.current.values()) e.controller?.abort();
199
+ O.current.clear(), E.current.clear(), k.current.clear(), A.current.clear(), j.current.clear(), C(p);
200
+ }, [l, y]), a(() => {
201
+ if (!y) return;
202
+ let e = new Set(N === "" ? [] : N.split(f));
203
+ for (let t of [...E.current]) e.has(t) || (E.current.delete(t), k.current.delete(t), D.current.get(t)?.abort(), D.current.delete(t), L(t), C((e) => {
204
+ let n = _(e, t);
187
205
  return {
188
206
  ...n,
189
- watchKey: h(w.current, n, e.watchKey)
207
+ watchKey: g(E.current, n, e.watchKey)
190
208
  };
191
209
  }));
192
210
  for (let t of e) {
193
- if (w.current.has(t)) continue;
194
- w.current.add(t);
211
+ if (E.current.has(t)) continue;
212
+ E.current.add(t);
195
213
  let e = new AbortController();
196
- T.current.set(t, e), R(t, e);
214
+ D.current.set(t, e), B(t, e);
197
215
  }
198
216
  }, [
199
- v,
200
- j,
201
- F,
202
- R
217
+ y,
218
+ N,
219
+ L,
220
+ B
203
221
  ]);
204
- let z = v && j !== "" && j.split(f).some((e) => !b.settled.has(e)), B = v ? b.watchKey : "", { watchProjects: V } = l;
222
+ let V = y && N !== "" && N.split(f).some((e) => !S.settled.has(e)), H = y ? S.watchKey : "", { watchProjects: U } = l;
205
223
  a(() => {
206
- if (V == null || B === "" || B === A.current) return;
224
+ if (U == null || H === "" || H === M.current) return;
207
225
  let e = new AbortController();
208
226
  return t({
209
- watchProjects: V,
210
- ids: B.split(f),
227
+ watchProjects: U,
228
+ ids: H.split(f),
211
229
  signal: e.signal,
212
230
  onEvent: (t) => {
213
231
  if (e.signal.aborted) return;
214
- let n = S.current.snapshots.get(t.id);
215
- n != null && (t.action === r.Delete ? (I(t.id), P(t.id)) : (t.etag == null || t.etag !== n.project.etag) && L(t.id));
232
+ let n = w.current.snapshots.get(t.id);
233
+ n != null && (t.action === r.Delete ? (R(t.id), I(t.id)) : (t.etag == null || t.etag !== n.project.etag) && z(t.id));
216
234
  },
217
235
  onReconnected: () => {
218
- for (let e of S.current.snapshots.keys()) L(e);
236
+ for (let e of w.current.snapshots.keys()) z(e);
219
237
  },
220
238
  onUnavailable: () => {
221
- A.current = B;
239
+ M.current = H;
222
240
  }
223
241
  }), () => e.abort();
224
242
  }, [
225
- V,
226
- B,
243
+ U,
244
+ H,
245
+ R,
227
246
  I,
228
- P,
229
- L
247
+ z
230
248
  ]);
231
- let H = i((e) => {
232
- k.current.has(e) && (O.current.set(e, k.current.get(e)), x((t) => {
249
+ let W = i((e) => {
250
+ j.current.has(e) && (A.current.set(e, j.current.get(e)), C((t) => {
233
251
  let n;
234
252
  for (let [r, i] of t.snapshots) i.chats.some((t) => t.id === e && t.isUnread) && (n ??= new Map(t.snapshots), n.set(r, {
235
253
  ...i,
@@ -243,27 +261,65 @@ var l = 10, u = 1e3, d = [
243
261
  snapshots: n
244
262
  } : t;
245
263
  }));
246
- }, []);
247
- return {
248
- projects: o(() => {
249
- if (!v) return m;
250
- let e = /* @__PURE__ */ new Set(), t = [];
251
- for (let n of u) {
252
- if (e.has(n)) continue;
253
- e.add(n);
254
- let r = b.snapshots.get(n);
255
- r && t.push(r);
256
- }
257
- return t;
258
- }, [
259
- v,
260
- u,
261
- b.snapshots
262
- ]),
263
- isLoading: z,
264
- markViewed: H,
265
- refresh: L
264
+ }, []), G = o(() => {
265
+ if (!y) return m;
266
+ let e = /* @__PURE__ */ new Set(), t = [];
267
+ for (let n of u) {
268
+ if (e.has(n)) continue;
269
+ e.add(n);
270
+ let r = S.snapshots.get(n);
271
+ r && t.push(h(r, x));
272
+ }
273
+ return t;
274
+ }, [
275
+ y,
276
+ u,
277
+ S.snapshots,
278
+ x
279
+ ]), K = o(() => {
280
+ if (y && x != null) for (let [e, t] of S.snapshots) {
281
+ let n = t.overflow.find((e) => e.id === x && e.isTitlePending);
282
+ if (n != null) return {
283
+ projectId: e,
284
+ name: n.name
285
+ };
286
+ }
287
+ }, [
288
+ y,
289
+ x,
290
+ S.snapshots
291
+ ]), q = K?.projectId, J = K?.name;
292
+ return a(() => {
293
+ if (q == null || J == null) return;
294
+ let e = new AbortController();
295
+ return (async () => {
296
+ try {
297
+ let { items: t } = await l.getProjectConversationTitles(q, [J], e.signal);
298
+ if (e.signal.aborted) return;
299
+ C((e) => {
300
+ let n = e.snapshots.get(q);
301
+ if (n == null) return e;
302
+ let r = new Map(e.snapshots);
303
+ return r.set(q, {
304
+ ...n,
305
+ overflow: v(n.overflow, t)
306
+ }), {
307
+ ...e,
308
+ snapshots: r
309
+ };
310
+ });
311
+ } catch {}
312
+ })(), () => e.abort();
313
+ }, [
314
+ l,
315
+ q,
316
+ J
317
+ ]), {
318
+ projects: G,
319
+ isLoading: V,
320
+ markViewed: W,
321
+ refresh: z
266
322
  };
267
323
  };
268
324
  //#endregion
269
- export { l as PINNED_PROJECT_CHATS_LIMIT, v as usePinnedProjectChats };
325
+ export { l as PINNED_PROJECT_CHATS_LIMIT, y as usePinnedProjectChats };