@burdenoff/fe-libs 2026.1028.9 → 2026.1028.11

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.
@@ -5,92 +5,93 @@ import { useAssistantTr as r } from "../../i18n.js";
5
5
  import { useAssistantStore as i } from "../../store.js";
6
6
  import { languageDisplayName as ee } from "../../voice/speechVoices.js";
7
7
  import { resolveAssistantLanguage as te } from "../../voice/languages.js";
8
+ import { attachmentEditorAccessMessage as ne } from "../../attachmentAccessCopy.js";
8
9
  import { getSendableAttachments as a } from "../../attachments.js";
9
10
  import { ATTACHMENT_COMMIT_CODES as o } from "../../attachmentCommit.js";
10
- import { AssistantAttachmentButton as ne } from "./AssistantAttachmentButton.js";
11
- import { AssistantAttachmentChips as re } from "./AssistantAttachmentChips.js";
12
- import { AssistantModeSelector as ie } from "./AssistantModeSelector.js";
13
- import { AssistantVoiceButton as ae, ListeningDot as oe } from "./AssistantVoiceButton.js";
14
- import { AssistantVoiceSessionButton as se } from "../voice/AssistantVoiceSessionButton.js";
15
- import { useAssistantAttachments as ce } from "../../useAssistantAttachments.js";
16
- import { useCallback as s, useEffect as c, useLayoutEffect as le, useMemo as ue, useRef as l, useState as u } from "react";
17
- import { ArrowUp as de, Loader2 as fe } from "lucide-react";
11
+ import { AssistantAttachmentButton as re } from "./AssistantAttachmentButton.js";
12
+ import { AssistantAttachmentChips as ie } from "./AssistantAttachmentChips.js";
13
+ import { AssistantModeSelector as ae } from "./AssistantModeSelector.js";
14
+ import { AssistantVoiceButton as oe, ListeningDot as se } from "./AssistantVoiceButton.js";
15
+ import { AssistantVoiceSessionButton as ce } from "../voice/AssistantVoiceSessionButton.js";
16
+ import { useAssistantAttachments as le } from "../../useAssistantAttachments.js";
17
+ import { useCallback as s, useEffect as c, useLayoutEffect as ue, useMemo as de, useRef as l, useState as u } from "react";
18
+ import { ArrowUp as fe, Loader2 as pe } from "lucide-react";
18
19
  import { jsx as d, jsxs as f } from "react/jsx-runtime";
19
20
  //#region src/shared/assistant/ui/composer/AssistantComposer.tsx
20
- var pe = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, readOnly: me = !1, placeholder: he, mode: ge, availableModes: g, attachmentCharsPerFile: _e, onModeChange: ve, auto: ye, onStartVoiceSession: be, onDraftStart: _, onDraftChange: v, suspendDictation: y = !1, onVoiceStateChange: b }) => {
21
- let x = r(), { locale: S } = e(), C = h || me, w = l(null), [T, E] = u(""), [xe, D] = u(!1), [O, k] = u(!1), A = l(!1), [j, M] = u(null), N = l(0), { attachments: P, isBusy: Se, preparingCount: Ce, sendBlocker: F, rejection: I, addFiles: L, remove: we, retry: Te, clear: R, clearRejection: Ee, canAddMore: De, commit: z, cancelCommit: B } = ce({ perFileChars: _e }), V = T.trim() !== "" || P.length > 0, H = l(!1), U = l(!1);
21
+ var me = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, readOnly: he = !1, placeholder: ge, mode: _e, availableModes: ve, attachmentCharsPerFile: ye, onModeChange: be, auto: xe, onStartVoiceSession: g, onDraftStart: _, onDraftChange: v, suspendDictation: y = !1, onVoiceStateChange: b }) => {
22
+ let x = r(), { locale: S } = e(), C = h || he, w = l(null), [T, E] = u(""), [Se, D] = u(!1), [O, Ce] = u(!1), k = l(!1), [A, j] = u(null), M = l(0), { attachments: N, isBusy: we, preparingCount: Te, sendBlocker: P, rejection: F, addFiles: I, remove: Ee, retry: De, clear: L, clearRejection: Oe, canAddMore: ke, commit: R, cancelCommit: z } = le({ perFileChars: ye }), B = T.trim() !== "" || N.length > 0, V = l(!1), H = l(!1);
22
23
  c(() => {
23
- V && !H.current ? (H.current = !0, _?.()) : V || (H.current = !1);
24
- }, [V, _]), c(() => {
25
- V || (U.current = !1), v?.({
24
+ B && !V.current ? (V.current = !0, _?.()) : B || (V.current = !1);
25
+ }, [B, _]), c(() => {
26
+ B || (H.current = !1), v?.({
26
27
  text: T,
27
- hasAttachments: P.length > 0,
28
- dictated: U.current
28
+ hasAttachments: N.length > 0,
29
+ dictated: H.current
29
30
  });
30
31
  }, [
31
32
  T,
32
- P.length,
33
- V,
33
+ N.length,
34
+ B,
34
35
  v
35
36
  ]);
36
- let W = s((e) => {
37
- U.current = !0, E((t) => t ? `${t.replace(/\s+$/, "")} ${e}` : e);
38
- }, []), G = i((e) => e.assistantLanguage), K = n({
39
- onFinalize: W,
40
- language: ue(() => te(G, S), [G, S]).tag
41
- }), q = K.isActive, J = K.interim, Oe = K.stop;
37
+ let U = s((e) => {
38
+ H.current = !0, E((t) => t ? `${t.replace(/\s+$/, "")} ${e}` : e);
39
+ }, []), W = i((e) => e.assistantLanguage), G = n({
40
+ onFinalize: U,
41
+ language: de(() => te(W, S), [W, S]).tag
42
+ }), K = G.isActive, q = G.interim, J = G.stop;
42
43
  c(() => {
43
- !y || !q || (J.trim() !== "" && W(J.trim()), Oe());
44
+ !y || !K || (q.trim() !== "" && U(q.trim()), J());
44
45
  }, [
45
46
  y,
47
+ K,
46
48
  q,
47
49
  J,
48
- Oe,
49
- W
50
+ U
50
51
  ]), c(() => {
51
52
  b?.({
52
53
  committing: O,
53
- dictating: q
54
+ dictating: K
54
55
  });
55
56
  }, [
56
57
  b,
57
58
  O,
58
- q
59
+ K
59
60
  ]);
60
- let ke = he ?? x("composer.placeholder", "Ask me anything…"), Ae = T.trim(), Y = a(P), X = P.filter((e) => e.status === "error"), Z = (Ae.length > 0 || Y.length > 0) && !C && !O && F === null, je = Y.some((e) => !e.fileId && !e.inlineOnly), Me = l(C);
61
- Me.current = C;
61
+ let Ae = ge ?? x("composer.placeholder", "Ask me anything…"), je = T.trim(), Y = a(N), X = N.filter((e) => e.status === "error"), Z = (je.length > 0 || Y.length > 0) && !C && !O && P === null, Me = Y.some((e) => !(e.fileId && e.downloadUrl) && !e.inlineOnly), Ne = l(C);
62
+ Ne.current = C;
62
63
  let Q = l(!0);
63
64
  c(() => (Q.current = !0, () => {
64
65
  Q.current = !1;
65
- }), []), le(() => {
66
+ }), []), ue(() => {
66
67
  let e = w.current;
67
- e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, pe)}px`);
68
+ e && (e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, me)}px`);
68
69
  }, [T]);
69
70
  let $ = s(async () => {
70
- if (!Z || A.current) return;
71
- K.isActive && K.stop();
71
+ if (!Z || k.current) return;
72
+ G.isActive && G.stop();
72
73
  let e = T.trim();
73
- if (M(null), !je) {
74
- m(e, Y), E(""), R();
74
+ if (j(null), !Me) {
75
+ m(e, Y), E(""), L();
75
76
  return;
76
77
  }
77
78
  let t = i.getState().activeConversationId;
78
- A.current = !0, k(!0);
79
+ k.current = !0, Ce(!0);
79
80
  try {
80
- let n = await z();
81
+ let n = await R();
81
82
  if (!Q.current) {
82
83
  n.ok && await n.rollback();
83
84
  return;
84
85
  }
85
86
  if (!n.ok) {
86
- n.cancelled || M({
87
+ n.cancelled || j({
87
88
  kind: "failed",
88
89
  failures: n.failures
89
90
  });
90
91
  return;
91
92
  }
92
- if (Me.current) {
93
- await n.rollback(), Q.current && M({
93
+ if (Ne.current) {
94
+ await n.rollback(), Q.current && j({
94
95
  kind: "busy",
95
96
  failures: []
96
97
  });
@@ -98,52 +99,53 @@ var pe = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, rea
98
99
  }
99
100
  let r = i.getState();
100
101
  if (!(r.activeConversationId === t && (t === null || r.conversations.some((e) => e.id === t)))) {
101
- await n.rollback(), Q.current && M({
102
+ await n.rollback(), Q.current && j({
102
103
  kind: "moved",
103
104
  failures: []
104
105
  });
105
106
  return;
106
107
  }
107
- m(e, a(n.attachments)), n.handedOver(), E(""), R();
108
+ m(e, a(n.attachments)), n.handedOver(), E(""), L();
108
109
  } finally {
109
- A.current = !1, Q.current && k(!1);
110
+ k.current = !1, Q.current && Ce(!1);
110
111
  }
111
112
  }, [
112
113
  Z,
113
- je,
114
- z,
114
+ Me,
115
+ R,
115
116
  m,
116
117
  T,
117
118
  Y,
118
- R,
119
- K
120
- ]), Ne = s(() => {
121
- B(), w.current?.focus();
122
- }, [B]);
119
+ L,
120
+ G
121
+ ]), Pe = s(() => {
122
+ z(), w.current?.focus();
123
+ }, [z]);
123
124
  c(() => {
124
- M(null);
125
- }, [P.length]);
126
- let Pe = (e) => {
125
+ j(null);
126
+ }, [N.length]);
127
+ let Fe = (e) => {
127
128
  if (e.kind === "busy") return x("attachments.saveBusy", "The assistant started another reply, so nothing was sent. Your message and files are still here.");
128
129
  if (e.kind === "moved") return x("attachments.saveMoved", "You switched conversations while the files were being saved, so nothing was sent. Your message and files are still here.");
129
130
  let { failures: t } = e;
131
+ if (t.some((e) => e.code === o.editorAccessRequired)) return ne(x, S);
130
132
  if (t.some((e) => e.code === o.quotaExceeded || e.code === o.quotaNotProvisioned)) return `${x("attachments.quotaFull", "File storage is full or not set up for this workspace, so the attachments couldn't be saved. Nothing was sent.")} ${x("attachments.retrySend", "Press Send to try again, or remove the file.")}`;
131
- let n = t[0], r = P.find((e) => e.id === n?.id)?.filename ?? "";
133
+ let n = t[0], r = N.find((e) => e.id === n?.id)?.filename ?? "";
132
134
  return `${t.length <= 1 ? x("attachments.saveFailedOne", "{{name}} couldn't be saved, so nothing was sent.", { name: r }) : x("attachments.saveFailedMany", "{{count}} attachments couldn't be saved, so nothing was sent.", { count: t.length })} ${x("attachments.retrySend", "Press Send to try again, or remove the file.")}`;
133
- }, Fe = s((e) => {
135
+ }, Ie = s((e) => {
134
136
  e.key === "Enter" && !e.shiftKey && (e.preventDefault(), $());
135
- }, [$]), Ie = s((e) => {
137
+ }, [$]), Le = s((e) => {
136
138
  let t = Array.from(e.clipboardData?.files ?? []);
137
- t.length !== 0 && (e.preventDefault(), L(t));
138
- }, [L]), Le = s((e) => {
139
- Array.from(e.dataTransfer?.types ?? []).includes("Files") && (N.current += 1, D(!0));
140
- }, []), Re = s(() => {
141
- N.current = Math.max(0, N.current - 1), N.current === 0 && D(!1);
142
- }, []), ze = s((e) => {
143
- Array.from(e.dataTransfer?.types ?? []).includes("Files") && e.preventDefault();
139
+ t.length !== 0 && (e.preventDefault(), I(t));
140
+ }, [I]), Re = s((e) => {
141
+ Array.from(e.dataTransfer?.types ?? []).includes("Files") && (M.current += 1, D(!0));
142
+ }, []), ze = s(() => {
143
+ M.current = Math.max(0, M.current - 1), M.current === 0 && D(!1);
144
144
  }, []), Be = s((e) => {
145
- e.preventDefault(), N.current = 0, D(!1), L(e.dataTransfer?.files ?? null);
146
- }, [L]), Ve = (e) => {
145
+ Array.from(e.dataTransfer?.types ?? []).includes("Files") && e.preventDefault();
146
+ }, []), Ve = s((e) => {
147
+ e.preventDefault(), M.current = 0, D(!1), I(e.dataTransfer?.files ?? null);
148
+ }, [I]), He = (e) => {
147
149
  switch (e) {
148
150
  case "too-many": return x("attachments.tooMany", "You can attach up to {{max}} files per message.", { max: 5 });
149
151
  case "too-large": return x("attachments.tooLarge", "That file is larger than 10 MB.");
@@ -152,12 +154,12 @@ var pe = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, rea
152
154
  case "unsupported-image": return x("attachments.unsupportedImage", "This device can't read that image format, so it can't be resized to send. Save it as JPEG and try again.");
153
155
  case "too-large-to-save": return x("attachments.tooLargeToSave", "That file is over 5 MB, so it can't be saved to Files, and no text could be read from it.");
154
156
  }
155
- }, He = (() => {
156
- switch (K.error) {
157
+ }, Ue = (() => {
158
+ switch (G.error) {
157
159
  case "not-allowed": return x("voice.denied", "Microphone access is blocked. Allow it in your browser settings to dictate.");
158
160
  case "audio-capture": return x("voice.noMic", "No microphone was found.");
159
161
  case "network": return x("voice.network", "Speech recognition is offline right now.");
160
- case "language-not-supported": return x("voice.languageNotSupported", "This browser cannot recognise spoken {{language}}. Try a different browser, or type instead.", { language: ee(K.language, S) });
162
+ case "language-not-supported": return x("voice.languageNotSupported", "This browser cannot recognise spoken {{language}}. Try a different browser, or type instead.", { language: ee(G.language, S) });
161
163
  case "unknown": return x("voice.failed", "Dictation stopped unexpectedly.");
162
164
  default: return null;
163
165
  }
@@ -166,26 +168,26 @@ var pe = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, rea
166
168
  className: "flex-shrink-0 px-3 pb-3 pt-1.5",
167
169
  children: [
168
170
  /* @__PURE__ */ f("div", {
169
- onDragEnter: Le,
170
- onDragLeave: Re,
171
- onDragOver: ze,
172
- onDrop: Be,
173
- className: `rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${xe ? "border-action-primary-bg border-dashed bg-action-primary-bg/5" : "border-border-default bg-bg-sunken"}`,
171
+ onDragEnter: Re,
172
+ onDragLeave: ze,
173
+ onDragOver: Be,
174
+ onDrop: Ve,
175
+ className: `rounded-2xl border p-2 shadow-sm transition-colors focus-within:border-action-primary-bg focus-within:ring-2 focus-within:ring-action-primary-bg/15 ${Se ? "border-action-primary-bg border-dashed bg-action-primary-bg/5" : "border-border-default bg-bg-sunken"}`,
174
176
  "data-testid": "assistant-composer",
175
177
  children: [
176
- /* @__PURE__ */ d(re, {
177
- attachments: P,
178
- onRemove: we,
179
- onRetry: Te,
178
+ /* @__PURE__ */ d(ie, {
179
+ attachments: N,
180
+ onRemove: Ee,
181
+ onRetry: De,
180
182
  disabled: C || O,
181
- preparingCount: Ce
183
+ preparingCount: Te
182
184
  }),
183
185
  /* @__PURE__ */ f("div", {
184
186
  className: "flex items-end gap-2",
185
187
  children: [
186
- /* @__PURE__ */ d(ne, {
187
- onFiles: L,
188
- canAddMore: De,
188
+ /* @__PURE__ */ d(re, {
189
+ onFiles: I,
190
+ canAddMore: ke,
189
191
  disabled: C || O,
190
192
  showLabel: !0
191
193
  }),
@@ -193,25 +195,25 @@ var pe = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, rea
193
195
  ref: w,
194
196
  value: T,
195
197
  onChange: (e) => E(e.target.value),
196
- onKeyDown: Fe,
197
- onPaste: Ie,
198
+ onKeyDown: Ie,
199
+ onPaste: Le,
198
200
  disabled: C,
199
201
  readOnly: O,
200
202
  "aria-busy": O || void 0,
201
- placeholder: xe ? x("composer.dropHere", "Drop files to attach") : ke,
203
+ placeholder: Se ? x("composer.dropHere", "Drop files to attach") : Ae,
202
204
  rows: 1,
203
205
  className: "min-h-[36px] flex-1 resize-none self-center bg-transparent px-1 py-2 text-[15px] leading-relaxed text-text-primary placeholder:text-text-muted focus:outline-none disabled:opacity-50",
204
206
  "aria-label": x("chatInput.ariaLabel", "Message input"),
205
207
  "data-testid": "assistant-input"
206
208
  }),
207
- K.isSupported && /* @__PURE__ */ d(ae, {
208
- isListening: K.isListening,
209
- isStarting: K.isStarting,
210
- onToggle: K.toggle,
209
+ G.isSupported && /* @__PURE__ */ d(oe, {
210
+ isListening: G.isListening,
211
+ isStarting: G.isStarting,
212
+ onToggle: G.toggle,
211
213
  disabled: C || O
212
214
  }),
213
- be && Ae.length === 0 && P.length === 0 && !K.isActive ? /* @__PURE__ */ d(se, {
214
- onStart: be,
215
+ g && je.length === 0 && N.length === 0 && !G.isActive ? /* @__PURE__ */ d(ce, {
216
+ onStart: g,
215
217
  disabled: C || O
216
218
  }) : /* @__PURE__ */ d("button", {
217
219
  type: "button",
@@ -220,18 +222,18 @@ var pe = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, rea
220
222
  className: `flex size-9 flex-shrink-0 items-center justify-center rounded-full shadow-sm transition-all focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong ${Z ? "bg-action-primary-bg text-action-primary-text hover:scale-105 hover:bg-action-primary-bg-hover" : "bg-bg-elevated text-text-muted"}`,
221
223
  "aria-label": x("chatInput.send", "Send message"),
222
224
  "data-testid": "assistant-send",
223
- children: h || Se || O ? /* @__PURE__ */ d(fe, { className: "size-4 motion-safe:animate-spin" }) : /* @__PURE__ */ d(de, { className: "size-4" })
225
+ children: h || we || O ? /* @__PURE__ */ d(pe, { className: "size-4 motion-safe:animate-spin" }) : /* @__PURE__ */ d(fe, { className: "size-4" })
224
226
  })
225
227
  ]
226
228
  }),
227
- g.length > 1 && /* @__PURE__ */ d("div", {
229
+ ve.length > 1 && /* @__PURE__ */ d("div", {
228
230
  className: "mt-2 px-0.5",
229
- children: /* @__PURE__ */ d(ie, {
230
- mode: ge,
231
- availableModes: g,
232
- onModeChange: ve,
231
+ children: /* @__PURE__ */ d(ae, {
232
+ mode: _e,
233
+ availableModes: ve,
234
+ onModeChange: be,
233
235
  disabled: C || O,
234
- auto: ye
236
+ auto: xe
235
237
  })
236
238
  })
237
239
  ]
@@ -245,49 +247,49 @@ var pe = 200, p = ({ writeAccessDenied: p = !1, onSend: m, disabled: h = !1, rea
245
247
  className: "mt-1.5 px-1 text-center text-[11px]",
246
248
  "aria-live": "polite",
247
249
  children: O ? /* @__PURE__ */ d(t, {
248
- onDismiss: Ne,
250
+ onDismiss: Pe,
249
251
  children: /* @__PURE__ */ f("p", {
250
252
  className: "flex items-center justify-center gap-2 text-text-muted",
251
253
  "data-testid": "assistant-commit-status",
252
254
  children: [
253
- /* @__PURE__ */ d(fe, {
255
+ /* @__PURE__ */ d(pe, {
254
256
  className: "size-3 motion-safe:animate-spin",
255
257
  "aria-hidden": "true"
256
258
  }),
257
259
  /* @__PURE__ */ d("span", { children: x("attachments.saving", "Saving your attachments…") }),
258
260
  /* @__PURE__ */ d("button", {
259
261
  type: "button",
260
- onClick: Ne,
262
+ onClick: Pe,
261
263
  className: "rounded text-text-primary underline underline-offset-2 hover:text-action-primary-bg focus:outline-none focus-visible:ring-2 focus-visible:ring-border-strong",
262
264
  "data-testid": "assistant-commit-cancel",
263
265
  children: x("attachments.cancelSaving", "Cancel")
264
266
  })
265
267
  ]
266
268
  })
267
- }) : j ? /* @__PURE__ */ d("p", {
269
+ }) : A ? /* @__PURE__ */ d("p", {
268
270
  className: "text-status-error-text",
269
271
  role: "alert",
270
272
  "data-testid": "assistant-commit-failed",
271
- children: Pe(j)
272
- }) : K.isStarting && !K.isListening ? /* @__PURE__ */ d("p", {
273
+ children: Fe(A)
274
+ }) : G.isStarting && !G.isListening ? /* @__PURE__ */ d("p", {
273
275
  className: "text-text-muted",
274
276
  "data-testid": "assistant-voice-starting",
275
277
  children: x("voice.starting", "Starting the microphone…")
276
- }) : K.isListening ? /* @__PURE__ */ f("p", {
278
+ }) : G.isListening ? /* @__PURE__ */ f("p", {
277
279
  className: "text-status-error-text",
278
280
  "data-testid": "assistant-voice-status",
279
- children: [/* @__PURE__ */ d(oe, {}), K.interim || x("voice.listening", "Listening… speak now, tap the square to stop")]
280
- }) : He ? /* @__PURE__ */ d("p", {
281
+ children: [/* @__PURE__ */ d(se, {}), G.interim || x("voice.listening", "Listening… speak now, tap the square to stop")]
282
+ }) : Ue ? /* @__PURE__ */ d("p", {
281
283
  className: "text-status-error-text",
282
284
  "data-testid": "assistant-voice-error",
283
- children: He
284
- }) : I ? /* @__PURE__ */ d("button", {
285
+ children: Ue
286
+ }) : F ? /* @__PURE__ */ d("button", {
285
287
  type: "button",
286
- onClick: Ee,
288
+ onClick: Oe,
287
289
  className: "text-status-error-text underline-offset-2 hover:underline",
288
290
  "data-testid": "assistant-attachment-rejection",
289
- children: Ve(I)
290
- }) : F === "failed" ? /* @__PURE__ */ d("p", {
291
+ children: He(F)
292
+ }) : P === "failed" ? /* @__PURE__ */ d("p", {
291
293
  className: "text-status-error-text",
292
294
  "data-testid": "assistant-attachment-blocked",
293
295
  children: X.length === 1 ? x("attachments.blockedOne", "{{name}} didn't upload. Retry or remove it before sending.", { name: X[0].filename }) : x("attachments.blockedMany", "{{count}} attachments didn't upload. Retry or remove them before sending.", { count: X.length })
@@ -151,6 +151,7 @@ function y(e = {}) {
151
151
  status: "ready",
152
152
  error: void 0,
153
153
  saveError: void 0,
154
+ saveErrorCode: void 0,
154
155
  progress: void 0,
155
156
  progressNote: void 0
156
157
  });
@@ -1,41 +1,58 @@
1
- import { useAssistantStorageFolders as e } from "./product.js";
2
- import { FilesPortError as t, createApolloFilesPort as n } from "../../storage/filesPort.js";
3
- import { createAttachmentCommitter as r } from "./attachmentCommit.js";
4
- import { getWorkspaceId as i } from "./context.js";
5
- import { createContext as a, useCallback as o, useContext as s, useMemo as c, useRef as l } from "react";
6
- import { getApolloContext as u } from "@apollo/client/react";
1
+ import { useSafePermissions as e } from "../providers/shell/PermissionProvider.js";
2
+ import { useAssistantStorageFolders as t } from "./product.js";
3
+ import { FilesPortError as n, createApolloFilesPort as r } from "../../storage/filesPort.js";
4
+ import { createAttachmentCommitter as i } from "./attachmentCommit.js";
5
+ import { getActorId as a, getWorkspaceId as o } from "./context.js";
6
+ import { probeAttachmentAccess as s } from "./attachmentAccess.js";
7
+ import { createContext as c, useCallback as l, useContext as u, useEffect as d, useMemo as f, useRef as p } from "react";
8
+ import { getApolloContext as m } from "@apollo/client/react";
7
9
  //#region src/shared/assistant/useAttachmentCommitter.ts
8
- var d = a(null);
9
- function f() {
10
- let e = s(d), { client: t } = s(u());
11
- return c(() => e ?? (t ? n(t, { getWorkspaceId: i }) : null), [e, t]);
10
+ var h = c(null);
11
+ function g() {
12
+ let e = u(h), { client: t } = u(m());
13
+ return f(() => e ?? (t ? r(t, { getWorkspaceId: o }) : null), [e, t]);
12
14
  }
13
- function p() {
14
- let e = f();
15
- return o(async (t) => e ? e.getDownloadUrl(t) : null, [e]);
15
+ function _() {
16
+ let e = g();
17
+ return l(async (t) => e ? e.getDownloadUrl(t) : null, [e]);
16
18
  }
17
- var m = (e) => () => Promise.reject(new t(e, "File storage is not available here.", void 0)), h = {
18
- ensureFolder: m("ensureFolder"),
19
- initiate: m("initiate"),
20
- put: m("put"),
21
- complete: m("complete"),
22
- getSession: m("getSession"),
23
- listSessions: m("listSessions"),
24
- abort: m("abort"),
25
- getDownloadUrl: m("getDownloadUrl"),
26
- deleteFile: m("deleteFile")
19
+ var v = (e) => () => Promise.reject(new n(e, "File storage is not available here.", void 0)), y = {
20
+ ensureFolder: v("ensureFolder"),
21
+ initiate: v("initiate"),
22
+ put: v("put"),
23
+ complete: v("complete"),
24
+ getSession: v("getSession"),
25
+ listSessions: v("listSessions"),
26
+ abort: v("abort"),
27
+ getDownloadUrl: v("getDownloadUrl"),
28
+ deleteFile: v("deleteFile")
27
29
  };
28
- function g(t) {
29
- let n = f(), i = e(), a = l(t);
30
- a.current = t;
31
- let o = l(i.attachments);
32
- return o.current = i.attachments, c(() => r({
33
- port: n ?? h,
30
+ function b() {
31
+ return {
32
+ workspaceId: typeof window < "u" && window.location ? o() : "",
33
+ actorId: a()
34
+ };
35
+ }
36
+ function x(n) {
37
+ let r = g(), a = e()?.isSuperAdmin ?? !1, o = p(a);
38
+ d(() => {
39
+ o.current = a;
40
+ }, [a]);
41
+ let c = t(), l = p(n);
42
+ l.current = n;
43
+ let u = p(c.attachments);
44
+ return u.current = c.attachments, f(() => i({
45
+ port: r ?? y,
46
+ preflightAccess: () => {
47
+ let { workspaceId: e, actorId: t } = b();
48
+ return s(e, t, o.current);
49
+ },
50
+ getScopeKey: () => JSON.stringify(b()),
34
51
  get folderPath() {
35
- return o.current;
52
+ return u.current;
36
53
  },
37
- onChange: (e, t) => a.current(e, t)
38
- }), [n]);
54
+ onChange: (e, t) => l.current(e, t)
55
+ }), [r]);
39
56
  }
40
57
  //#endregion
41
- export { d as AttachmentFilesPortContext, g as useAttachmentCommitter, f as useAttachmentFilesPort, p as useAttachmentUrlResolver };
58
+ export { h as AttachmentFilesPortContext, x as useAttachmentCommitter, g as useAttachmentFilesPort, _ as useAttachmentUrlResolver };