@knkcs/mediahub-ui 0.1.0
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/dist/index.d.ts +1686 -0
- package/dist/index.js +4357 -0
- package/dist/index.js.map +1 -0
- package/dist/testing.d.ts +487 -0
- package/dist/testing.js +413 -0
- package/dist/testing.js.map +1 -0
- package/package.json +71 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4357 @@
|
|
|
1
|
+
import { toaster as B, Text as L, Grid as dt, Skeleton as ut, Flex as P, Box as F, BreadcrumbRoot as On, BreadcrumbList as Qn, BreadcrumbItem as Xe, BreadcrumbLink as zt, BreadcrumbSeparator as Rt, BreadcrumbCurrentLink as Bn, HStack as J, Link as _n, Spinner as be, Badge as Bt, NativeSelect as Se, MenuRoot as st, MenuTrigger as it, MenuContent as rt, MenuItem as de, Checkbox as Wn, SegmentedControl as Dt, Stack as at, Tabs as Ne } from "@knkcs/anker/primitives";
|
|
2
|
+
import { jsx as s, jsxs as c, Fragment as Vn } from "react/jsx-runtime";
|
|
3
|
+
import { createContext as $n, useMemo as W, useContext as jn, useState as D, useRef as Ie, useEffect as le, useCallback as re } from "react";
|
|
4
|
+
import { useStatuses as Gn, StatusBadge as Hn, StatusTransitionControl as Yn } from "@knkcs/statushub-ui";
|
|
5
|
+
import { useQueryClient as z, useMutation as N, useQuery as O } from "@tanstack/react-query";
|
|
6
|
+
import { create as mt } from "zustand";
|
|
7
|
+
import { persist as Jn } from "zustand/middleware";
|
|
8
|
+
import { SelectableCard as ue, BulkActionBar as Pe, ChipPicker as _t, InlineCreatableList as Wt, Modal as Ae, createTreeCollection as Zn, TreeViewRoot as Xn, TreeViewTree as es, TreeViewNode as ts, TreeViewBranchControl as qt, TreeViewBranchIndicator as Nt, TreeViewBranchText as ns, UploadDropZone as Vt, TruncatedTextCell as Oe, DateCell as $t, ActionCell as jt, ContextRail as ie, Toolbar as Le, DataTable as Gt, StatusBadgeCell as ss, DescriptionList as Ce } from "@knkcs/anker/components";
|
|
9
|
+
import { FileText as ft, Music as Ve, Film as ht, Image as pt, Download as Be, Tag as is, FolderOpen as Ht, Trash2 as Yt, Lock as $e, X as rs, Folder as as, ChevronDown as os, ChevronRight as ls, Ellipsis as ot, FolderPlus as cs, Upload as ds, Sparkles as us, ArrowLeft as ms } from "lucide-react";
|
|
10
|
+
import { Button as Y, Persona as Pt, IconButton as _e, TextInput as We, EmptyState as ye } from "@knkcs/anker/atoms";
|
|
11
|
+
import { useConfirmModal as je, UploadToastStack as fs } from "@knkcs/anker/feedback";
|
|
12
|
+
import { InlineEdit as hs, SearchInput as Jt } from "@knkcs/anker/forms";
|
|
13
|
+
import { usePageRail as Zt, IndexPageTemplate as ps, SubNavLayout as Ee, DetailPageTemplate as gs } from "@knkcs/anker/templates";
|
|
14
|
+
import { createColumnHelper as Xt } from "@tanstack/react-table";
|
|
15
|
+
import { zodResolver as ys } from "@hookform/resolvers/zod";
|
|
16
|
+
import { FieldKitProvider as bs, SpecForm as vs } from "@knkcs/fieldkit/renderer";
|
|
17
|
+
import { getDefaultValues as ws, specToZodSchema as Cs, builtInFieldTypes as et } from "@knkcs/fieldkit/schema";
|
|
18
|
+
import { useForm as Ss, FormProvider as Is } from "react-hook-form";
|
|
19
|
+
const en = 7, As = 9, Ts = 14, Et = "mediahub.v1.LeakGuardViolation", ks = "You don't have access", xs = "You don't have permission to do this. The item's Owner or a workspace admin can grant you access.", Fs = "Blocked to prevent a leak", Ls = "This change would expose Restricted material, so it was refused.", zs = {
|
|
20
|
+
LEAK_GUARD_RULE_RESTRICTED_ASSET_INTO_OPEN_COLLECTION: "These assets live in a Restricted folder. An open collection is visible to the whole workspace, so adding them would leak Restricted material.",
|
|
21
|
+
LEAK_GUARD_RULE_ASSET_INTO_RESTRICTED_CHAIN_WHILE_EXPOSED: "An open collection still exposes this asset, so moving it into a Restricted folder would leak Restricted material. Remove it from the collection first.",
|
|
22
|
+
LEAK_GUARD_RULE_FOLDER_INTO_RESTRICTED_CHAIN_WHILE_EXPOSED: "An open collection still exposes assets inside this folder, so moving it under a Restricted folder would leak Restricted material. Remove those assets from their collections first."
|
|
23
|
+
};
|
|
24
|
+
function gt(e) {
|
|
25
|
+
if (typeof e != "object" || e === null) return;
|
|
26
|
+
const t = e.code;
|
|
27
|
+
return typeof t == "number" ? t : void 0;
|
|
28
|
+
}
|
|
29
|
+
function Rs(e) {
|
|
30
|
+
return gt(e) === en;
|
|
31
|
+
}
|
|
32
|
+
function Ds(e) {
|
|
33
|
+
return gt(e) === Ts;
|
|
34
|
+
}
|
|
35
|
+
function Ut(e) {
|
|
36
|
+
return typeof e == "string" && (e === Et || e.endsWith(`/${Et}`));
|
|
37
|
+
}
|
|
38
|
+
function qs(e) {
|
|
39
|
+
const t = e ?? {}, n = (i) => typeof i == "string" ? i : "";
|
|
40
|
+
return {
|
|
41
|
+
assetId: n(t.assetId),
|
|
42
|
+
assetName: n(t.assetName),
|
|
43
|
+
collectionId: n(t.collectionId),
|
|
44
|
+
collectionName: n(t.collectionName)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function Kt(e) {
|
|
48
|
+
if (typeof e != "object" || e === null) return { exposures: [] };
|
|
49
|
+
const t = e, n = Array.isArray(t.exposures) ? t.exposures.map(qs) : [];
|
|
50
|
+
return { rule: typeof t.rule == "string" ? t.rule : void 0, exposures: n };
|
|
51
|
+
}
|
|
52
|
+
function Ns(e) {
|
|
53
|
+
const t = e.details;
|
|
54
|
+
if (Array.isArray(t))
|
|
55
|
+
for (const n of t) {
|
|
56
|
+
if (typeof n != "object" || n === null) continue;
|
|
57
|
+
const i = n;
|
|
58
|
+
if (Ut(i.type))
|
|
59
|
+
return Kt(i.debug);
|
|
60
|
+
if (Ut(i.$typeName))
|
|
61
|
+
return Kt(i);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function he(e, t) {
|
|
65
|
+
const n = gt(e);
|
|
66
|
+
if (n === en)
|
|
67
|
+
return {
|
|
68
|
+
kind: "permission-denied",
|
|
69
|
+
title: ks,
|
|
70
|
+
description: xs
|
|
71
|
+
};
|
|
72
|
+
if (n === As) {
|
|
73
|
+
const i = Ns(e);
|
|
74
|
+
if (i) {
|
|
75
|
+
const r = (i.rule && zs[i.rule]) ?? Ls, o = i.exposures.map((a) => `${a.assetName} — in collection “${a.collectionName}”`).join(" • ");
|
|
76
|
+
return {
|
|
77
|
+
kind: "leak-guard",
|
|
78
|
+
title: Fs,
|
|
79
|
+
description: o ? `${r} Involved: ${o}` : r,
|
|
80
|
+
exposures: i.exposures,
|
|
81
|
+
ruleText: r
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
kind: "other",
|
|
87
|
+
title: t,
|
|
88
|
+
description: e instanceof Error ? e.message : "An unexpected error occurred"
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function M(e, t) {
|
|
92
|
+
const n = he(e, t);
|
|
93
|
+
B.error({ title: n.title, description: n.description });
|
|
94
|
+
}
|
|
95
|
+
const xe = (e) => e ? new Date(Number(e.seconds) * 1e3 + Math.floor(e.nanos / 1e6)) : void 0, Ps = {
|
|
96
|
+
unspecified: 0,
|
|
97
|
+
static: 1,
|
|
98
|
+
smart: 2
|
|
99
|
+
}, Es = ["unspecified", "static", "smart"], Us = (e) => ({
|
|
100
|
+
id: e.id,
|
|
101
|
+
versionNumber: e.versionNumber,
|
|
102
|
+
originalFilename: e.originalFilename,
|
|
103
|
+
storageKey: e.storageKey,
|
|
104
|
+
fileSize: Number(e.fileSize),
|
|
105
|
+
mimeType: e.mimeType,
|
|
106
|
+
createdBy: e.createdBy,
|
|
107
|
+
comment: e.comment,
|
|
108
|
+
createdAt: xe(e.createdAt)
|
|
109
|
+
});
|
|
110
|
+
function Ks(e) {
|
|
111
|
+
if (!e) return {};
|
|
112
|
+
try {
|
|
113
|
+
const t = JSON.parse(e);
|
|
114
|
+
return typeof t == "object" && t !== null && !Array.isArray(t) ? t : {};
|
|
115
|
+
} catch {
|
|
116
|
+
return {};
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const pe = (e) => ({
|
|
120
|
+
id: e.id,
|
|
121
|
+
workspaceId: e.workspaceId,
|
|
122
|
+
name: e.name,
|
|
123
|
+
description: e.description,
|
|
124
|
+
statusSlug: e.statusSlug ?? "",
|
|
125
|
+
currentVersion: e.currentVersion,
|
|
126
|
+
metadata: Ks(e.metadata),
|
|
127
|
+
assetTypeId: e.assetTypeId,
|
|
128
|
+
folderId: e.folderId,
|
|
129
|
+
createdBy: e.createdBy,
|
|
130
|
+
updatedBy: e.updatedBy,
|
|
131
|
+
createdAt: xe(e.createdAt),
|
|
132
|
+
updatedAt: xe(e.updatedAt),
|
|
133
|
+
versions: (e.versions ?? []).map(Us),
|
|
134
|
+
tagIds: e.tagIds ?? [],
|
|
135
|
+
collectionIds: e.collectionIds ?? [],
|
|
136
|
+
analyzeWithAi: e.analyzeWithAi ?? !1
|
|
137
|
+
}), Te = (e) => ({
|
|
138
|
+
id: e.id,
|
|
139
|
+
workspaceId: e.workspaceId,
|
|
140
|
+
name: e.name,
|
|
141
|
+
slug: e.slug,
|
|
142
|
+
parentId: e.parentId,
|
|
143
|
+
restricted: e.restricted ?? !1
|
|
144
|
+
}), ze = (e) => ({
|
|
145
|
+
id: e.id,
|
|
146
|
+
workspaceId: e.workspaceId,
|
|
147
|
+
name: e.name,
|
|
148
|
+
slug: e.slug,
|
|
149
|
+
description: e.description,
|
|
150
|
+
type: Es[e.type] ?? "unspecified",
|
|
151
|
+
rules: e.rules,
|
|
152
|
+
restricted: e.restricted ?? !1
|
|
153
|
+
}), tt = (e) => ({
|
|
154
|
+
id: e.id,
|
|
155
|
+
workspaceId: e.workspaceId,
|
|
156
|
+
name: e.name,
|
|
157
|
+
slug: e.slug
|
|
158
|
+
}), Ue = (e) => ({
|
|
159
|
+
id: e.id,
|
|
160
|
+
workspaceId: e.workspaceId,
|
|
161
|
+
name: e.name,
|
|
162
|
+
slug: e.slug,
|
|
163
|
+
description: e.description,
|
|
164
|
+
allowedMimeTypes: e.allowedMimeTypes ?? [],
|
|
165
|
+
metadataSchema: e.metadataSchema,
|
|
166
|
+
active: e.active
|
|
167
|
+
}), Ke = (e) => ({
|
|
168
|
+
id: e.id,
|
|
169
|
+
workspaceId: e.workspaceId,
|
|
170
|
+
name: e.name,
|
|
171
|
+
provider: e.provider,
|
|
172
|
+
endpoint: e.endpoint ?? "",
|
|
173
|
+
deployment: e.deployment ?? "",
|
|
174
|
+
apiVersion: e.apiVersion ?? "",
|
|
175
|
+
baseUrl: e.baseUrl ?? "",
|
|
176
|
+
model: e.model ?? "",
|
|
177
|
+
description: e.description ?? "",
|
|
178
|
+
active: e.active,
|
|
179
|
+
hasApiKey: e.hasApiKey
|
|
180
|
+
}), Me = (e) => ({
|
|
181
|
+
id: e.id,
|
|
182
|
+
workspaceId: e.workspaceId,
|
|
183
|
+
assetTypeId: e.assetTypeId,
|
|
184
|
+
connectionId: e.connectionId,
|
|
185
|
+
name: e.name,
|
|
186
|
+
prompt: e.prompt,
|
|
187
|
+
outputs: (e.outputs ?? []).map(
|
|
188
|
+
// biome-ignore lint/suspicious/noExplicitAny: structural Connect shape
|
|
189
|
+
(t) => ({
|
|
190
|
+
key: t.key,
|
|
191
|
+
target: t.target,
|
|
192
|
+
metadataAccessor: t.metadataAccessor ?? ""
|
|
193
|
+
})
|
|
194
|
+
),
|
|
195
|
+
position: e.position ?? 0,
|
|
196
|
+
active: e.active
|
|
197
|
+
}), Ms = (e) => ({
|
|
198
|
+
id: e.id,
|
|
199
|
+
aiProcessId: e.aiProcessId,
|
|
200
|
+
processName: e.processName ?? "",
|
|
201
|
+
status: e.status ?? "",
|
|
202
|
+
error: e.error ?? "",
|
|
203
|
+
startedAt: xe(e.startedAt),
|
|
204
|
+
finishedAt: xe(e.finishedAt)
|
|
205
|
+
});
|
|
206
|
+
function Os(e) {
|
|
207
|
+
return {
|
|
208
|
+
async list(t, n) {
|
|
209
|
+
const i = await e.listAssets({
|
|
210
|
+
workspaceId: t,
|
|
211
|
+
folderId: n.folderId ?? "",
|
|
212
|
+
assetTypeId: n.assetTypeId ?? "",
|
|
213
|
+
statusSlug: n.statusSlug ?? "",
|
|
214
|
+
search: n.search ?? "",
|
|
215
|
+
behavior: n.behavior && n.behavior !== "unspecified" ? n.behavior : "",
|
|
216
|
+
tagIds: n.tagIds ?? [],
|
|
217
|
+
collectionIds: n.collectionIds ?? []
|
|
218
|
+
}), r = i.pagination;
|
|
219
|
+
return {
|
|
220
|
+
items: i.assets.map(pe),
|
|
221
|
+
total: (r == null ? void 0 : r.total) ?? i.assets.length,
|
|
222
|
+
page: (r == null ? void 0 : r.page) ?? 1,
|
|
223
|
+
pageSize: (r == null ? void 0 : r.pageSize) ?? i.assets.length,
|
|
224
|
+
totalPages: (r == null ? void 0 : r.totalPages) ?? 1
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
async get(t) {
|
|
228
|
+
return pe((await e.getAsset({ id: t })).asset);
|
|
229
|
+
},
|
|
230
|
+
async create(t, n) {
|
|
231
|
+
return pe(
|
|
232
|
+
(await e.createAsset({
|
|
233
|
+
workspaceId: t,
|
|
234
|
+
name: n.name,
|
|
235
|
+
description: n.description ?? "",
|
|
236
|
+
assetTypeId: n.assetTypeId,
|
|
237
|
+
folderId: n.folderId ?? "",
|
|
238
|
+
metadata: JSON.stringify(n.metadata ?? {}),
|
|
239
|
+
analyzeWithAi: n.analyzeWithAi
|
|
240
|
+
})).asset
|
|
241
|
+
);
|
|
242
|
+
},
|
|
243
|
+
async update(t, n) {
|
|
244
|
+
return pe(
|
|
245
|
+
(await e.updateAsset({
|
|
246
|
+
id: t,
|
|
247
|
+
name: n.name ?? "",
|
|
248
|
+
description: n.description ?? "",
|
|
249
|
+
metadata: JSON.stringify(n.metadata ?? {})
|
|
250
|
+
})).asset
|
|
251
|
+
);
|
|
252
|
+
},
|
|
253
|
+
async delete(t) {
|
|
254
|
+
await e.deleteAsset({ id: t });
|
|
255
|
+
},
|
|
256
|
+
async getUploadUrl(t) {
|
|
257
|
+
const n = await e.getUploadURL({
|
|
258
|
+
assetId: t.assetId,
|
|
259
|
+
filename: t.filename,
|
|
260
|
+
contentType: t.contentType,
|
|
261
|
+
fileSize: BigInt(t.fileSize),
|
|
262
|
+
comment: t.comment ?? ""
|
|
263
|
+
});
|
|
264
|
+
return { uploadUrl: n.uploadUrl, versionId: n.versionId };
|
|
265
|
+
},
|
|
266
|
+
async finalizeUpload(t) {
|
|
267
|
+
return pe((await e.finalizeUpload({ versionId: t })).asset);
|
|
268
|
+
},
|
|
269
|
+
async getDownloadUrl(t, n) {
|
|
270
|
+
return (await e.getDownloadURL({ assetId: t, versionId: n })).downloadUrl;
|
|
271
|
+
},
|
|
272
|
+
async move(t, n) {
|
|
273
|
+
return pe((await e.moveAsset({ id: t, folderId: n })).asset);
|
|
274
|
+
},
|
|
275
|
+
async transitionStatus(t, n, i) {
|
|
276
|
+
return pe(
|
|
277
|
+
(await e.transitionAssetStatus({ id: t, fromStatusSlug: n, toStatusSlug: i })).asset
|
|
278
|
+
);
|
|
279
|
+
},
|
|
280
|
+
async enhanceMetadata(t) {
|
|
281
|
+
return pe((await e.enhanceAssetMetadata({ assetId: t })).asset);
|
|
282
|
+
},
|
|
283
|
+
async listProcessRuns(t) {
|
|
284
|
+
return (await e.listAIProcessRuns({ assetId: t })).runs.map(Ms);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function Qs(e) {
|
|
289
|
+
return {
|
|
290
|
+
async list(t, n) {
|
|
291
|
+
return (await e.listFolders({ workspaceId: t, parentId: n })).folders.map(Te);
|
|
292
|
+
},
|
|
293
|
+
async get(t) {
|
|
294
|
+
return Te((await e.getFolder({ id: t })).folder);
|
|
295
|
+
},
|
|
296
|
+
async create(t) {
|
|
297
|
+
return Te(
|
|
298
|
+
(await e.createFolder({
|
|
299
|
+
workspaceId: t.workspaceId,
|
|
300
|
+
name: t.name,
|
|
301
|
+
slug: t.slug,
|
|
302
|
+
parentId: t.parentId,
|
|
303
|
+
restricted: t.restricted ?? !1
|
|
304
|
+
})).folder
|
|
305
|
+
);
|
|
306
|
+
},
|
|
307
|
+
async update(t, n) {
|
|
308
|
+
return Te((await e.updateFolder({ id: t, name: n })).folder);
|
|
309
|
+
},
|
|
310
|
+
async delete(t) {
|
|
311
|
+
await e.deleteFolder({ id: t });
|
|
312
|
+
},
|
|
313
|
+
async move(t, n) {
|
|
314
|
+
return Te((await e.moveFolder({ id: t, parentId: n })).folder);
|
|
315
|
+
},
|
|
316
|
+
async setRestricted(t, n) {
|
|
317
|
+
const i = n ? e.restrictFolder : e.unrestrictFolder;
|
|
318
|
+
if (typeof i != "function")
|
|
319
|
+
throw new Error(
|
|
320
|
+
"This server can't toggle Restricted yet (RestrictFolder/UnrestrictFolder, guardian#53)."
|
|
321
|
+
);
|
|
322
|
+
return Te((await i({ id: t })).folder);
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
function Bs(e) {
|
|
327
|
+
return {
|
|
328
|
+
async list(t) {
|
|
329
|
+
return (await e.listCollections({ workspaceId: t })).collections.map(ze);
|
|
330
|
+
},
|
|
331
|
+
async get(t) {
|
|
332
|
+
return ze((await e.getCollection({ id: t })).collection);
|
|
333
|
+
},
|
|
334
|
+
async create(t) {
|
|
335
|
+
return ze(
|
|
336
|
+
(await e.createCollection({
|
|
337
|
+
workspaceId: t.workspaceId,
|
|
338
|
+
name: t.name,
|
|
339
|
+
slug: t.slug,
|
|
340
|
+
description: t.description,
|
|
341
|
+
type: Ps[t.type],
|
|
342
|
+
rules: t.rules,
|
|
343
|
+
restricted: t.restricted ?? !1
|
|
344
|
+
})).collection
|
|
345
|
+
);
|
|
346
|
+
},
|
|
347
|
+
async update(t, n) {
|
|
348
|
+
return ze(
|
|
349
|
+
(await e.updateCollection({
|
|
350
|
+
id: t,
|
|
351
|
+
name: n.name ?? "",
|
|
352
|
+
description: n.description ?? "",
|
|
353
|
+
rules: n.rules ?? ""
|
|
354
|
+
})).collection
|
|
355
|
+
);
|
|
356
|
+
},
|
|
357
|
+
async delete(t) {
|
|
358
|
+
await e.deleteCollection({ id: t });
|
|
359
|
+
},
|
|
360
|
+
async addAssets(t, n) {
|
|
361
|
+
await e.addAssets({ collectionId: t, assetIds: n });
|
|
362
|
+
},
|
|
363
|
+
async removeAssets(t, n) {
|
|
364
|
+
await e.removeAssets({ collectionId: t, assetIds: n });
|
|
365
|
+
},
|
|
366
|
+
async setRestricted(t, n) {
|
|
367
|
+
const i = n ? e.restrictCollection : e.unrestrictCollection;
|
|
368
|
+
if (typeof i != "function")
|
|
369
|
+
throw new Error(
|
|
370
|
+
"This server can't toggle Restricted yet (RestrictCollection/UnrestrictCollection, guardian#53)."
|
|
371
|
+
);
|
|
372
|
+
return ze((await i({ id: t })).collection);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function _s(e) {
|
|
377
|
+
return {
|
|
378
|
+
async list(t) {
|
|
379
|
+
return (await e.listTags({ workspaceId: t })).tags.map(tt);
|
|
380
|
+
},
|
|
381
|
+
async create(t) {
|
|
382
|
+
return tt(
|
|
383
|
+
(await e.createTag({
|
|
384
|
+
workspaceId: t.workspaceId,
|
|
385
|
+
name: t.name,
|
|
386
|
+
slug: t.slug
|
|
387
|
+
})).tag
|
|
388
|
+
);
|
|
389
|
+
},
|
|
390
|
+
async update(t, n) {
|
|
391
|
+
return tt((await e.updateTag({ id: t, name: n })).tag);
|
|
392
|
+
},
|
|
393
|
+
async delete(t) {
|
|
394
|
+
await e.deleteTag({ id: t });
|
|
395
|
+
},
|
|
396
|
+
async tagAssets(t, n) {
|
|
397
|
+
await e.tagAssets({ tagId: t, assetIds: n });
|
|
398
|
+
},
|
|
399
|
+
async untagAssets(t, n) {
|
|
400
|
+
await e.untagAssets({ tagId: t, assetIds: n });
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
function Ws(e) {
|
|
405
|
+
return {
|
|
406
|
+
async list(t) {
|
|
407
|
+
return (await e.listAssetTypes({ workspaceId: t })).assetTypes.map(Ue);
|
|
408
|
+
},
|
|
409
|
+
async get(t) {
|
|
410
|
+
return Ue((await e.getAssetType({ id: t })).assetType);
|
|
411
|
+
},
|
|
412
|
+
async create(t) {
|
|
413
|
+
return Ue(
|
|
414
|
+
(await e.createAssetType({
|
|
415
|
+
workspaceId: t.workspaceId,
|
|
416
|
+
name: t.name,
|
|
417
|
+
slug: t.slug,
|
|
418
|
+
description: t.description,
|
|
419
|
+
allowedMimeTypes: t.allowedMimeTypes,
|
|
420
|
+
metadataSchema: t.metadataSchema
|
|
421
|
+
})).assetType
|
|
422
|
+
);
|
|
423
|
+
},
|
|
424
|
+
async update(t, n) {
|
|
425
|
+
return Ue(
|
|
426
|
+
(await e.updateAssetType({
|
|
427
|
+
id: t,
|
|
428
|
+
name: n.name ?? "",
|
|
429
|
+
description: n.description ?? "",
|
|
430
|
+
allowedMimeTypes: n.allowedMimeTypes ?? [],
|
|
431
|
+
metadataSchema: n.metadataSchema ?? "",
|
|
432
|
+
active: n.active ?? !0
|
|
433
|
+
})).assetType
|
|
434
|
+
);
|
|
435
|
+
},
|
|
436
|
+
async delete(t) {
|
|
437
|
+
await e.deleteAssetType({ id: t });
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
function Vs(e) {
|
|
442
|
+
return {
|
|
443
|
+
async resolveUsers(t) {
|
|
444
|
+
return ((await e.resolveUsers({ userIds: t })).users ?? []).map(
|
|
445
|
+
(i) => ({
|
|
446
|
+
id: i.id,
|
|
447
|
+
displayName: i.displayName
|
|
448
|
+
})
|
|
449
|
+
);
|
|
450
|
+
},
|
|
451
|
+
async listWorkspaceMembers(t) {
|
|
452
|
+
return ((await e.listWorkspaceMembers({ workspaceId: t })).members ?? []).map(
|
|
453
|
+
(i) => ({
|
|
454
|
+
id: i.userId,
|
|
455
|
+
displayName: i.displayName
|
|
456
|
+
})
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
const Qe = {
|
|
462
|
+
asset: 1,
|
|
463
|
+
folder: 2,
|
|
464
|
+
collection: 3
|
|
465
|
+
}, $s = {
|
|
466
|
+
1: "viewer",
|
|
467
|
+
2: "editor"
|
|
468
|
+
}, js = {
|
|
469
|
+
viewer: 1,
|
|
470
|
+
editor: 2
|
|
471
|
+
};
|
|
472
|
+
function Gs(e) {
|
|
473
|
+
return {
|
|
474
|
+
async list(t, n) {
|
|
475
|
+
const i = await e.listGrants({
|
|
476
|
+
resourceType: Qe[t],
|
|
477
|
+
resourceId: n
|
|
478
|
+
}), r = [];
|
|
479
|
+
for (const o of i.grants ?? []) {
|
|
480
|
+
const a = $s[o.level];
|
|
481
|
+
a && r.push({ userId: o.userId, level: a });
|
|
482
|
+
}
|
|
483
|
+
return { ownerUserId: i.ownerUserId ?? "", grants: r };
|
|
484
|
+
},
|
|
485
|
+
async grant(t, n, i, r) {
|
|
486
|
+
await e.grantAccess({
|
|
487
|
+
resourceType: Qe[t],
|
|
488
|
+
resourceId: n,
|
|
489
|
+
userId: i,
|
|
490
|
+
level: js[r]
|
|
491
|
+
});
|
|
492
|
+
},
|
|
493
|
+
async revoke(t, n, i) {
|
|
494
|
+
await e.revokeAccess({
|
|
495
|
+
resourceType: Qe[t],
|
|
496
|
+
resourceId: n,
|
|
497
|
+
userId: i
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function Hs(e) {
|
|
503
|
+
return {
|
|
504
|
+
async canManage(t, n) {
|
|
505
|
+
try {
|
|
506
|
+
return await e.listGrants({
|
|
507
|
+
resourceType: Qe[t],
|
|
508
|
+
resourceId: n
|
|
509
|
+
}), !0;
|
|
510
|
+
} catch (i) {
|
|
511
|
+
if (Rs(i)) return !1;
|
|
512
|
+
throw i;
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function Ys(e) {
|
|
518
|
+
return {
|
|
519
|
+
async getWorkspaceStats(t) {
|
|
520
|
+
const n = await e.getWorkspaceStats({ workspaceId: t });
|
|
521
|
+
return {
|
|
522
|
+
totalAssets: Number(n.totalAssets),
|
|
523
|
+
totalStorageBytes: Number(n.totalStorageBytes),
|
|
524
|
+
statusCounts: n.statusCounts.map((i) => ({
|
|
525
|
+
statusSlug: i.statusSlug,
|
|
526
|
+
name: i.name,
|
|
527
|
+
color: i.color,
|
|
528
|
+
behavior: i.behavior,
|
|
529
|
+
count: Number(i.count)
|
|
530
|
+
})),
|
|
531
|
+
recentUploads: n.recentUploads.map((i) => ({
|
|
532
|
+
id: i.id,
|
|
533
|
+
name: i.name,
|
|
534
|
+
assetTypeName: i.assetTypeName,
|
|
535
|
+
statusName: i.statusName,
|
|
536
|
+
statusColor: i.statusColor,
|
|
537
|
+
createdAt: xe(i.createdAt)
|
|
538
|
+
}))
|
|
539
|
+
};
|
|
540
|
+
},
|
|
541
|
+
async getDashboardLayout(t) {
|
|
542
|
+
return (await e.getDashboardLayout({ workspaceId: t })).layoutJson;
|
|
543
|
+
},
|
|
544
|
+
async saveDashboardLayout(t, n) {
|
|
545
|
+
await e.saveDashboardLayout({ workspaceId: t, layoutJson: n });
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function Js(e) {
|
|
550
|
+
return {
|
|
551
|
+
async list(t) {
|
|
552
|
+
return (await e.listAIConnections({
|
|
553
|
+
workspaceId: t,
|
|
554
|
+
pagination: { page: 1, pageSize: 1e3 }
|
|
555
|
+
})).connections.map(Ke);
|
|
556
|
+
},
|
|
557
|
+
async get(t) {
|
|
558
|
+
return Ke((await e.getAIConnection({ id: t })).connection);
|
|
559
|
+
},
|
|
560
|
+
async create(t) {
|
|
561
|
+
return Ke(
|
|
562
|
+
(await e.createAIConnection({ ...t })).connection
|
|
563
|
+
);
|
|
564
|
+
},
|
|
565
|
+
async update(t, n) {
|
|
566
|
+
return Ke(
|
|
567
|
+
(await e.updateAIConnection({
|
|
568
|
+
id: t,
|
|
569
|
+
name: n.name ?? "",
|
|
570
|
+
endpoint: n.endpoint ?? "",
|
|
571
|
+
deployment: n.deployment ?? "",
|
|
572
|
+
apiVersion: n.apiVersion ?? "",
|
|
573
|
+
baseUrl: n.baseUrl ?? "",
|
|
574
|
+
model: n.model ?? "",
|
|
575
|
+
apiKey: n.apiKey ?? "",
|
|
576
|
+
description: n.description ?? "",
|
|
577
|
+
active: n.active ?? !0
|
|
578
|
+
})).connection
|
|
579
|
+
);
|
|
580
|
+
},
|
|
581
|
+
async delete(t) {
|
|
582
|
+
await e.deleteAIConnection({ id: t });
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
function Zs(e) {
|
|
587
|
+
return {
|
|
588
|
+
async list(t) {
|
|
589
|
+
return (await e.listAIProcesses({ assetTypeId: t })).processes.map(
|
|
590
|
+
Me
|
|
591
|
+
);
|
|
592
|
+
},
|
|
593
|
+
async get(t) {
|
|
594
|
+
return Me((await e.getAIProcess({ id: t })).process);
|
|
595
|
+
},
|
|
596
|
+
async create(t) {
|
|
597
|
+
return Me(
|
|
598
|
+
(await e.createAIProcess({
|
|
599
|
+
workspaceId: t.workspaceId,
|
|
600
|
+
assetTypeId: t.assetTypeId,
|
|
601
|
+
connectionId: t.connectionId,
|
|
602
|
+
name: t.name,
|
|
603
|
+
prompt: t.prompt,
|
|
604
|
+
outputs: t.outputs,
|
|
605
|
+
position: t.position
|
|
606
|
+
})).process
|
|
607
|
+
);
|
|
608
|
+
},
|
|
609
|
+
async update(t, n) {
|
|
610
|
+
return Me(
|
|
611
|
+
(await e.updateAIProcess({
|
|
612
|
+
id: t,
|
|
613
|
+
connectionId: n.connectionId ?? "",
|
|
614
|
+
name: n.name ?? "",
|
|
615
|
+
prompt: n.prompt ?? "",
|
|
616
|
+
outputs: n.outputs ?? [],
|
|
617
|
+
position: n.position ?? 0,
|
|
618
|
+
active: n.active ?? !0
|
|
619
|
+
})).process
|
|
620
|
+
);
|
|
621
|
+
},
|
|
622
|
+
async delete(t) {
|
|
623
|
+
await e.deleteAIProcess({ id: t });
|
|
624
|
+
}
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
function fr(e) {
|
|
628
|
+
return {
|
|
629
|
+
assets: Os(e.asset),
|
|
630
|
+
folders: Qs(e.folder),
|
|
631
|
+
collections: Bs(e.collection),
|
|
632
|
+
tags: _s(e.tag),
|
|
633
|
+
assetTypes: Ws(e.assetType),
|
|
634
|
+
directory: Vs(e.user),
|
|
635
|
+
grants: Gs(e.grant),
|
|
636
|
+
dashboard: Ys(e.dashboard),
|
|
637
|
+
aiConnection: Js(e.aiConnection),
|
|
638
|
+
aiProcess: Zs(e.aiProcess),
|
|
639
|
+
authz: Hs(e.grant)
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
const tn = $n(null), Xs = {};
|
|
643
|
+
function ei({
|
|
644
|
+
clients: e,
|
|
645
|
+
workspaceId: t,
|
|
646
|
+
links: n,
|
|
647
|
+
children: i
|
|
648
|
+
}) {
|
|
649
|
+
const r = W(
|
|
650
|
+
() => ({
|
|
651
|
+
clients: e,
|
|
652
|
+
workspaceId: t,
|
|
653
|
+
links: n ?? Xs
|
|
654
|
+
}),
|
|
655
|
+
[e, t, n]
|
|
656
|
+
);
|
|
657
|
+
return /* @__PURE__ */ s(tn.Provider, { value: r, children: i });
|
|
658
|
+
}
|
|
659
|
+
ei.displayName = "MediahubProvider";
|
|
660
|
+
function yt() {
|
|
661
|
+
const e = jn(tn);
|
|
662
|
+
if (!e)
|
|
663
|
+
throw new Error(
|
|
664
|
+
"useMediahubClients/useWorkspaceId must be used within <MediahubProvider>"
|
|
665
|
+
);
|
|
666
|
+
return e;
|
|
667
|
+
}
|
|
668
|
+
function g() {
|
|
669
|
+
return yt().clients;
|
|
670
|
+
}
|
|
671
|
+
function V() {
|
|
672
|
+
return yt().workspaceId;
|
|
673
|
+
}
|
|
674
|
+
function ti() {
|
|
675
|
+
return yt().links;
|
|
676
|
+
}
|
|
677
|
+
const nn = {
|
|
678
|
+
serviceSlug: "mediahub",
|
|
679
|
+
entityTypeSlug: "asset"
|
|
680
|
+
};
|
|
681
|
+
function bt() {
|
|
682
|
+
return Gn(nn);
|
|
683
|
+
}
|
|
684
|
+
function ni(e) {
|
|
685
|
+
const { data: t, isLoading: n } = bt();
|
|
686
|
+
return {
|
|
687
|
+
status: e ? t == null ? void 0 : t.find((i) => i.slug === e) : void 0,
|
|
688
|
+
isLoading: n
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
async function sn(e, t, n, i) {
|
|
692
|
+
return new Promise((r, o) => {
|
|
693
|
+
const a = new XMLHttpRequest();
|
|
694
|
+
a.open("PUT", e), a.setRequestHeader("x-ms-blob-type", "BlockBlob"), a.setRequestHeader("Content-Type", n), a.upload.onprogress = (l) => {
|
|
695
|
+
l.lengthComputable && i(Math.round(l.loaded / l.total * 100));
|
|
696
|
+
}, a.onload = () => {
|
|
697
|
+
a.status >= 200 && a.status < 300 ? r() : o(new Error(`Upload failed: ${a.status} ${a.statusText}`));
|
|
698
|
+
}, a.onerror = () => o(new Error("Network error during upload")), a.send(t);
|
|
699
|
+
});
|
|
700
|
+
}
|
|
701
|
+
function si() {
|
|
702
|
+
const { assets: e } = g(), t = z(), [n, i] = D(0);
|
|
703
|
+
return { ...N({
|
|
704
|
+
mutationFn: async ({ assetId: o, file: a, comment: l }) => {
|
|
705
|
+
i(0);
|
|
706
|
+
const u = a.type || "application/octet-stream", { uploadUrl: y, versionId: h } = await e.getUploadUrl({
|
|
707
|
+
assetId: o,
|
|
708
|
+
filename: a.name,
|
|
709
|
+
contentType: u,
|
|
710
|
+
fileSize: a.size,
|
|
711
|
+
comment: l ?? ""
|
|
712
|
+
});
|
|
713
|
+
if (!y || !h)
|
|
714
|
+
throw new Error("getUploadUrl returned an incomplete response");
|
|
715
|
+
return await sn(y, a, u, i), e.finalizeUpload(h);
|
|
716
|
+
},
|
|
717
|
+
onSuccess: (o, a) => {
|
|
718
|
+
t.invalidateQueries({ queryKey: ["mediahub", "assets"] }), t.invalidateQueries({
|
|
719
|
+
queryKey: ["mediahub", "assets", "detail", a.assetId]
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
}), progress: n };
|
|
723
|
+
}
|
|
724
|
+
function rn(e = {}) {
|
|
725
|
+
const { assets: t } = g(), n = V();
|
|
726
|
+
return O({
|
|
727
|
+
queryKey: ["mediahub", "assets", n, e],
|
|
728
|
+
queryFn: () => t.list(n, e)
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
function ii(e) {
|
|
732
|
+
const { assets: t } = g();
|
|
733
|
+
return O({
|
|
734
|
+
queryKey: ["mediahub", "assets", "detail", e],
|
|
735
|
+
queryFn: () => t.get(e),
|
|
736
|
+
enabled: !!e
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
function hr() {
|
|
740
|
+
const { assets: e } = g(), t = V(), n = z();
|
|
741
|
+
return N({
|
|
742
|
+
mutationFn: (i) => e.create(t, i),
|
|
743
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
function ri() {
|
|
747
|
+
const { assets: e } = g(), t = z();
|
|
748
|
+
return N({
|
|
749
|
+
mutationFn: (n) => e.update(n.id, n.patch),
|
|
750
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
function vt() {
|
|
754
|
+
const { assets: e } = g(), t = z();
|
|
755
|
+
return N({
|
|
756
|
+
mutationFn: (n) => e.delete(n),
|
|
757
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
function ai() {
|
|
761
|
+
const { assets: e } = g(), t = z();
|
|
762
|
+
return N({
|
|
763
|
+
mutationFn: (n) => e.move(n.id, n.folderId),
|
|
764
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
function oi() {
|
|
768
|
+
const { assets: e } = g(), t = z();
|
|
769
|
+
return N({
|
|
770
|
+
mutationFn: (n) => e.transitionStatus(n.id, n.fromStatusSlug, n.toStatusSlug),
|
|
771
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
function li() {
|
|
775
|
+
const { assets: e } = g(), t = z();
|
|
776
|
+
return N({
|
|
777
|
+
mutationFn: (n) => e.enhanceMetadata(n),
|
|
778
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
function Ge(e, t) {
|
|
782
|
+
const { assets: n } = g();
|
|
783
|
+
return O({
|
|
784
|
+
queryKey: ["mediahub", "assets", "preview-url", e, t],
|
|
785
|
+
queryFn: () => n.getDownloadUrl(e, t),
|
|
786
|
+
enabled: !!e && !!t,
|
|
787
|
+
staleTime: 900 * 1e3
|
|
788
|
+
});
|
|
789
|
+
}
|
|
790
|
+
function ci(e, t) {
|
|
791
|
+
const { authz: n } = g();
|
|
792
|
+
return O({
|
|
793
|
+
queryKey: ["mediahub", "can-manage", e, t],
|
|
794
|
+
queryFn: () => n.canManage(e, t),
|
|
795
|
+
enabled: !!t,
|
|
796
|
+
// Authority rarely changes mid-session; don't re-probe on every menu open.
|
|
797
|
+
staleTime: 5 * 6e4
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
function wt(e = "", t) {
|
|
801
|
+
const { folders: n } = g(), i = V();
|
|
802
|
+
return O({
|
|
803
|
+
queryKey: ["mediahub", "folders", i, e],
|
|
804
|
+
queryFn: () => n.list(i, e),
|
|
805
|
+
enabled: (t == null ? void 0 : t.enabled) ?? !0
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
function nt(e) {
|
|
809
|
+
const { folders: t } = g();
|
|
810
|
+
return O({
|
|
811
|
+
queryKey: ["mediahub", "folder", e],
|
|
812
|
+
queryFn: () => t.get(e),
|
|
813
|
+
enabled: !!e
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
function an() {
|
|
817
|
+
const { folders: e } = g(), t = V(), n = z();
|
|
818
|
+
return N({
|
|
819
|
+
mutationFn: (i) => e.create({ workspaceId: t, ...i }),
|
|
820
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["mediahub", "folders"] })
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
function di() {
|
|
824
|
+
const { folders: e } = g(), t = z();
|
|
825
|
+
return N({
|
|
826
|
+
mutationFn: (n) => e.update(n.id, n.name),
|
|
827
|
+
onSuccess: () => {
|
|
828
|
+
t.invalidateQueries({ queryKey: ["mediahub", "folders"] }), t.invalidateQueries({ queryKey: ["mediahub", "folder"] });
|
|
829
|
+
}
|
|
830
|
+
});
|
|
831
|
+
}
|
|
832
|
+
function ui() {
|
|
833
|
+
const { folders: e } = g(), t = z();
|
|
834
|
+
return N({
|
|
835
|
+
mutationFn: (n) => e.delete(n),
|
|
836
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "folders"] })
|
|
837
|
+
});
|
|
838
|
+
}
|
|
839
|
+
function mi() {
|
|
840
|
+
const { folders: e } = g(), t = z();
|
|
841
|
+
return N({
|
|
842
|
+
mutationFn: (n) => e.move(n.id, n.parentId),
|
|
843
|
+
onSuccess: () => {
|
|
844
|
+
t.invalidateQueries({ queryKey: ["mediahub", "folders"] }), t.invalidateQueries({ queryKey: ["mediahub", "folder"] });
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
function fi() {
|
|
849
|
+
const { folders: e } = g(), t = z();
|
|
850
|
+
return N({
|
|
851
|
+
mutationFn: (n) => e.setRestricted(n.id, n.restricted),
|
|
852
|
+
onSuccess: () => {
|
|
853
|
+
t.invalidateQueries({ queryKey: ["mediahub", "folders"] }), t.invalidateQueries({ queryKey: ["mediahub", "folder"] }), t.invalidateQueries({ queryKey: ["mediahub", "assets"] });
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
}
|
|
857
|
+
function hi(e, t, n) {
|
|
858
|
+
const { grants: i } = g();
|
|
859
|
+
return O({
|
|
860
|
+
queryKey: ["mediahub", "grants", e, t],
|
|
861
|
+
queryFn: () => i.list(e, t),
|
|
862
|
+
enabled: (n == null ? void 0 : n.enabled) ?? !0,
|
|
863
|
+
retry: (r, o) => he(o, "").kind !== "permission-denied" && r < 3
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
function pi() {
|
|
867
|
+
const { grants: e } = g(), t = z();
|
|
868
|
+
return N({
|
|
869
|
+
mutationFn: (n) => e.grant(n.resourceType, n.resourceId, n.userId, n.level),
|
|
870
|
+
// Settled, not success: the server's upsert is delete-then-write, so a
|
|
871
|
+
// mid-failure can leave the grantee revoked — the roster must re-assert
|
|
872
|
+
// server truth after a failure too.
|
|
873
|
+
onSettled: (n, i, r) => t.invalidateQueries({
|
|
874
|
+
queryKey: ["mediahub", "grants", r.resourceType, r.resourceId]
|
|
875
|
+
})
|
|
876
|
+
});
|
|
877
|
+
}
|
|
878
|
+
function gi() {
|
|
879
|
+
const { grants: e } = g(), t = z();
|
|
880
|
+
return N({
|
|
881
|
+
mutationFn: (n) => e.revoke(n.resourceType, n.resourceId, n.userId),
|
|
882
|
+
onSettled: (n, i, r) => t.invalidateQueries({
|
|
883
|
+
queryKey: ["mediahub", "grants", r.resourceType, r.resourceId]
|
|
884
|
+
})
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
function Re() {
|
|
888
|
+
const { collections: e } = g(), t = V();
|
|
889
|
+
return O({
|
|
890
|
+
queryKey: ["mediahub", "collections", t],
|
|
891
|
+
queryFn: () => e.list(t)
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
function pr(e) {
|
|
895
|
+
const { collections: t } = g();
|
|
896
|
+
return O({
|
|
897
|
+
queryKey: ["mediahub", "collection", e],
|
|
898
|
+
queryFn: () => t.get(e),
|
|
899
|
+
enabled: !!e
|
|
900
|
+
});
|
|
901
|
+
}
|
|
902
|
+
function on() {
|
|
903
|
+
const { collections: e } = g(), t = V(), n = z();
|
|
904
|
+
return N({
|
|
905
|
+
mutationFn: (i) => e.create({ workspaceId: t, ...i }),
|
|
906
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["mediahub", "collections"] })
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
function gr() {
|
|
910
|
+
const { collections: e } = g(), t = z();
|
|
911
|
+
return N({
|
|
912
|
+
mutationFn: (n) => e.update(n.id, n.patch),
|
|
913
|
+
onSuccess: () => {
|
|
914
|
+
t.invalidateQueries({ queryKey: ["mediahub", "collections"] }), t.invalidateQueries({ queryKey: ["mediahub", "collection"] });
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
function yr() {
|
|
919
|
+
const { collections: e } = g(), t = z();
|
|
920
|
+
return N({
|
|
921
|
+
mutationFn: (n) => e.delete(n),
|
|
922
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "collections"] })
|
|
923
|
+
});
|
|
924
|
+
}
|
|
925
|
+
function ln() {
|
|
926
|
+
const { collections: e } = g(), t = z();
|
|
927
|
+
return N({
|
|
928
|
+
mutationFn: (n) => e.addAssets(n.collectionId, n.assetIds),
|
|
929
|
+
onSuccess: () => {
|
|
930
|
+
t.invalidateQueries({ queryKey: ["mediahub", "collection"] }), t.invalidateQueries({ queryKey: ["mediahub", "assets"] });
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
function br() {
|
|
935
|
+
const { collections: e } = g(), t = z();
|
|
936
|
+
return N({
|
|
937
|
+
mutationFn: (n) => e.setRestricted(n.id, n.restricted),
|
|
938
|
+
onSuccess: () => {
|
|
939
|
+
t.invalidateQueries({ queryKey: ["mediahub", "collections"] }), t.invalidateQueries({ queryKey: ["mediahub", "collection"] }), t.invalidateQueries({ queryKey: ["mediahub", "assets"] });
|
|
940
|
+
}
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
function yi() {
|
|
944
|
+
const { collections: e } = g(), t = z();
|
|
945
|
+
return N({
|
|
946
|
+
mutationFn: (n) => e.removeAssets(n.collectionId, n.assetIds),
|
|
947
|
+
onSuccess: () => {
|
|
948
|
+
t.invalidateQueries({ queryKey: ["mediahub", "collection"] }), t.invalidateQueries({ queryKey: ["mediahub", "assets"] });
|
|
949
|
+
}
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
function Ct() {
|
|
953
|
+
const { tags: e } = g(), t = V();
|
|
954
|
+
return O({
|
|
955
|
+
queryKey: ["mediahub", "tags", t],
|
|
956
|
+
queryFn: () => e.list(t)
|
|
957
|
+
});
|
|
958
|
+
}
|
|
959
|
+
function bi() {
|
|
960
|
+
const { tags: e } = g(), t = V(), n = z();
|
|
961
|
+
return N({
|
|
962
|
+
mutationFn: (i) => e.create({ workspaceId: t, ...i }),
|
|
963
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["mediahub", "tags"] })
|
|
964
|
+
});
|
|
965
|
+
}
|
|
966
|
+
function vr() {
|
|
967
|
+
const { tags: e } = g(), t = z();
|
|
968
|
+
return N({
|
|
969
|
+
mutationFn: (n) => e.update(n.id, n.name),
|
|
970
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "tags"] })
|
|
971
|
+
});
|
|
972
|
+
}
|
|
973
|
+
function wr() {
|
|
974
|
+
const { tags: e } = g(), t = z();
|
|
975
|
+
return N({
|
|
976
|
+
mutationFn: (n) => e.delete(n),
|
|
977
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "tags"] })
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
function cn() {
|
|
981
|
+
const { tags: e } = g(), t = z();
|
|
982
|
+
return N({
|
|
983
|
+
mutationFn: (n) => e.tagAssets(n.tagId, n.assetIds),
|
|
984
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
function vi() {
|
|
988
|
+
const { tags: e } = g(), t = z();
|
|
989
|
+
return N({
|
|
990
|
+
mutationFn: (n) => e.untagAssets(n.tagId, n.assetIds),
|
|
991
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assets"] })
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
function dn() {
|
|
995
|
+
const { assetTypes: e } = g(), t = V();
|
|
996
|
+
return O({
|
|
997
|
+
queryKey: ["mediahub", "assetTypes", t],
|
|
998
|
+
queryFn: () => e.list(t)
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
function un(e) {
|
|
1002
|
+
const { assetTypes: t } = g();
|
|
1003
|
+
return O({
|
|
1004
|
+
queryKey: ["mediahub", "assetType", e],
|
|
1005
|
+
queryFn: () => t.get(e),
|
|
1006
|
+
enabled: !!e
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
function Cr() {
|
|
1010
|
+
const { assetTypes: e } = g(), t = V(), n = z();
|
|
1011
|
+
return N({
|
|
1012
|
+
mutationFn: (i) => e.create({ workspaceId: t, ...i }),
|
|
1013
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["mediahub", "assetTypes"] })
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
function Sr() {
|
|
1017
|
+
const { assetTypes: e } = g(), t = z();
|
|
1018
|
+
return N({
|
|
1019
|
+
mutationFn: (n) => e.update(n.id, n.patch),
|
|
1020
|
+
onSuccess: () => {
|
|
1021
|
+
t.invalidateQueries({ queryKey: ["mediahub", "assetTypes"] }), t.invalidateQueries({ queryKey: ["mediahub", "assetType"] });
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
function Ir() {
|
|
1026
|
+
const { assetTypes: e } = g(), t = z();
|
|
1027
|
+
return N({
|
|
1028
|
+
mutationFn: (n) => e.delete(n),
|
|
1029
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "assetTypes"] })
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
function St(e) {
|
|
1033
|
+
const { directory: t } = g(), n = [...e].filter(Boolean).sort();
|
|
1034
|
+
return O({
|
|
1035
|
+
queryKey: ["mediahub", "users", n],
|
|
1036
|
+
queryFn: () => t.resolveUsers(n),
|
|
1037
|
+
enabled: n.length > 0,
|
|
1038
|
+
staleTime: 1e3 * 60 * 10,
|
|
1039
|
+
select: (i) => Object.fromEntries(i.map((r) => [r.id, r.displayName]))
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
function wi(e) {
|
|
1043
|
+
const { directory: t } = g(), n = V();
|
|
1044
|
+
return O({
|
|
1045
|
+
queryKey: ["mediahub", "members", n],
|
|
1046
|
+
queryFn: () => t.listWorkspaceMembers(n),
|
|
1047
|
+
enabled: (e == null ? void 0 : e.enabled) ?? !0,
|
|
1048
|
+
staleTime: 1e3 * 60 * 5
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
function Ar() {
|
|
1052
|
+
const { dashboard: e } = g(), t = V();
|
|
1053
|
+
return O({
|
|
1054
|
+
queryKey: ["mediahub", "workspace-stats", t],
|
|
1055
|
+
queryFn: () => e.getWorkspaceStats(t),
|
|
1056
|
+
staleTime: 3e4
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
function Tr() {
|
|
1060
|
+
const { dashboard: e } = g(), t = V();
|
|
1061
|
+
return O({
|
|
1062
|
+
queryKey: ["mediahub", "dashboard-layout", t],
|
|
1063
|
+
queryFn: () => e.getDashboardLayout(t)
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
function kr() {
|
|
1067
|
+
const { dashboard: e } = g(), t = V(), n = z();
|
|
1068
|
+
return N({
|
|
1069
|
+
mutationFn: (i) => e.saveDashboardLayout(t, i),
|
|
1070
|
+
onSuccess: () => n.invalidateQueries({
|
|
1071
|
+
queryKey: ["mediahub", "dashboard-layout", t]
|
|
1072
|
+
})
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
function xr() {
|
|
1076
|
+
const { aiConnection: e } = g(), t = V();
|
|
1077
|
+
return O({
|
|
1078
|
+
queryKey: ["mediahub", "ai-connections", t],
|
|
1079
|
+
queryFn: () => e.list(t)
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
function Fr(e) {
|
|
1083
|
+
const { aiConnection: t } = g();
|
|
1084
|
+
return O({
|
|
1085
|
+
queryKey: ["mediahub", "ai-connection", e],
|
|
1086
|
+
queryFn: () => t.get(e),
|
|
1087
|
+
enabled: !!e
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
function Lr() {
|
|
1091
|
+
const { aiConnection: e } = g(), t = V(), n = z();
|
|
1092
|
+
return N({
|
|
1093
|
+
mutationFn: (i) => e.create({ workspaceId: t, ...i }),
|
|
1094
|
+
onSuccess: () => n.invalidateQueries({ queryKey: ["mediahub", "ai-connections"] })
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
function zr() {
|
|
1098
|
+
const { aiConnection: e } = g(), t = z();
|
|
1099
|
+
return N({
|
|
1100
|
+
mutationFn: (n) => e.update(n.id, n.patch),
|
|
1101
|
+
onSuccess: () => {
|
|
1102
|
+
t.invalidateQueries({ queryKey: ["mediahub", "ai-connections"] }), t.invalidateQueries({ queryKey: ["mediahub", "ai-connection"] });
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
function Rr() {
|
|
1107
|
+
const { aiConnection: e } = g(), t = z();
|
|
1108
|
+
return N({
|
|
1109
|
+
mutationFn: (n) => e.delete(n),
|
|
1110
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "ai-connections"] })
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
function Dr(e) {
|
|
1114
|
+
const { aiProcess: t } = g();
|
|
1115
|
+
return O({
|
|
1116
|
+
queryKey: ["mediahub", "ai-processes", e],
|
|
1117
|
+
queryFn: () => t.list(e),
|
|
1118
|
+
enabled: !!e
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
function qr(e) {
|
|
1122
|
+
const { aiProcess: t } = g();
|
|
1123
|
+
return O({
|
|
1124
|
+
queryKey: ["mediahub", "ai-process", e],
|
|
1125
|
+
queryFn: () => t.get(e),
|
|
1126
|
+
enabled: !!e
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
function Nr() {
|
|
1130
|
+
const { aiProcess: e } = g(), t = z();
|
|
1131
|
+
return N({
|
|
1132
|
+
mutationFn: (n) => e.create(n),
|
|
1133
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "ai-processes"] })
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
function Pr() {
|
|
1137
|
+
const { aiProcess: e } = g(), t = z();
|
|
1138
|
+
return N({
|
|
1139
|
+
mutationFn: (n) => e.update(n.id, n.patch),
|
|
1140
|
+
onSuccess: () => {
|
|
1141
|
+
t.invalidateQueries({ queryKey: ["mediahub", "ai-processes"] }), t.invalidateQueries({ queryKey: ["mediahub", "ai-process"] });
|
|
1142
|
+
}
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
function Er() {
|
|
1146
|
+
const { aiProcess: e } = g(), t = z();
|
|
1147
|
+
return N({
|
|
1148
|
+
mutationFn: (n) => e.delete(n),
|
|
1149
|
+
onSuccess: () => t.invalidateQueries({ queryKey: ["mediahub", "ai-processes"] })
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
const Mt = (e) => (e ?? []).some((t) => t.status === "queued" || t.status === "running");
|
|
1153
|
+
function Ci(e) {
|
|
1154
|
+
const { assets: t } = g(), n = z(), i = Ie(!1), r = O({
|
|
1155
|
+
queryKey: ["mediahub", "ai-process-runs", e],
|
|
1156
|
+
queryFn: () => t.listProcessRuns(e),
|
|
1157
|
+
enabled: !!e,
|
|
1158
|
+
refetchInterval: (a) => Mt(a.state.data) ? 2e3 : !1
|
|
1159
|
+
}), o = Ie(e);
|
|
1160
|
+
return le(() => {
|
|
1161
|
+
o.current !== e && (o.current = e, i.current = !1);
|
|
1162
|
+
}, [e]), le(() => {
|
|
1163
|
+
const a = Mt(r.data);
|
|
1164
|
+
i.current && !a && n.invalidateQueries({
|
|
1165
|
+
queryKey: ["mediahub", "assets", "detail", e]
|
|
1166
|
+
}), i.current = a;
|
|
1167
|
+
}, [r.data, e, n]), r;
|
|
1168
|
+
}
|
|
1169
|
+
const oe = mt((e, t) => ({
|
|
1170
|
+
selectedIds: [],
|
|
1171
|
+
lastClickedId: null,
|
|
1172
|
+
toggle: (n) => {
|
|
1173
|
+
e((i) => ({
|
|
1174
|
+
selectedIds: i.selectedIds.includes(n) ? i.selectedIds.filter((o) => o !== n) : [...i.selectedIds, n],
|
|
1175
|
+
lastClickedId: n
|
|
1176
|
+
}));
|
|
1177
|
+
},
|
|
1178
|
+
selectAll: (n) => e({ selectedIds: [...n], lastClickedId: null }),
|
|
1179
|
+
setSelection: (n) => e({ selectedIds: n, lastClickedId: null }),
|
|
1180
|
+
selectRange: (n, i) => {
|
|
1181
|
+
const { lastClickedId: r, selectedIds: o } = t();
|
|
1182
|
+
if (!r) {
|
|
1183
|
+
e({ selectedIds: [n], lastClickedId: n });
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
const a = i.indexOf(r), l = i.indexOf(n);
|
|
1187
|
+
if (a === -1 || l === -1) return;
|
|
1188
|
+
const u = Math.min(a, l), y = Math.max(a, l), h = i.slice(u, y + 1), f = /* @__PURE__ */ new Set([...o, ...h]);
|
|
1189
|
+
e({ selectedIds: [...f], lastClickedId: n });
|
|
1190
|
+
},
|
|
1191
|
+
clearSelection: () => e({ selectedIds: [], lastClickedId: null })
|
|
1192
|
+
})), Ot = mt()(
|
|
1193
|
+
Jn(
|
|
1194
|
+
(e) => ({
|
|
1195
|
+
sidebarCollapsed: !1,
|
|
1196
|
+
viewMode: "list",
|
|
1197
|
+
toggleSidebar: () => e((t) => ({ sidebarCollapsed: !t.sidebarCollapsed })),
|
|
1198
|
+
setViewMode: (t) => e({ viewMode: t })
|
|
1199
|
+
}),
|
|
1200
|
+
{
|
|
1201
|
+
name: "mediahub-preferences"
|
|
1202
|
+
}
|
|
1203
|
+
)
|
|
1204
|
+
);
|
|
1205
|
+
function ge(e, t, n) {
|
|
1206
|
+
return e.map((i) => i.clientId === t ? { ...i, ...n } : i);
|
|
1207
|
+
}
|
|
1208
|
+
const ee = mt((e, t) => ({
|
|
1209
|
+
files: [],
|
|
1210
|
+
visible: !1,
|
|
1211
|
+
expanded: !0,
|
|
1212
|
+
analyzeWithAi: !0,
|
|
1213
|
+
queryClient: null,
|
|
1214
|
+
assetClient: null,
|
|
1215
|
+
addFiles: (n) => {
|
|
1216
|
+
const i = n.map((r) => ({
|
|
1217
|
+
// Client-only tracking ID; KSUID convention applies to server-persisted IDs
|
|
1218
|
+
clientId: crypto.randomUUID(),
|
|
1219
|
+
file: r,
|
|
1220
|
+
assetTypeId: "",
|
|
1221
|
+
status: "pending",
|
|
1222
|
+
progress: 0
|
|
1223
|
+
}));
|
|
1224
|
+
e((r) => ({ files: [...r.files, ...i] }));
|
|
1225
|
+
},
|
|
1226
|
+
setAssetType: (n, i) => {
|
|
1227
|
+
e((r) => ({
|
|
1228
|
+
files: ge(r.files, n, { assetTypeId: i })
|
|
1229
|
+
}));
|
|
1230
|
+
},
|
|
1231
|
+
setBatchAssetType: (n) => {
|
|
1232
|
+
e((i) => ({
|
|
1233
|
+
files: i.files.map(
|
|
1234
|
+
(r) => r.status === "pending" ? { ...r, assetTypeId: n } : r
|
|
1235
|
+
)
|
|
1236
|
+
}));
|
|
1237
|
+
},
|
|
1238
|
+
setAnalyzeWithAi: (n) => e({ analyzeWithAi: n }),
|
|
1239
|
+
startUpload: async (n, i) => {
|
|
1240
|
+
const r = t().assetClient;
|
|
1241
|
+
if (!r) throw new Error("upload-store: assetClient not set");
|
|
1242
|
+
e({ visible: !0, expanded: !0 });
|
|
1243
|
+
const o = t().files.filter((a) => a.status === "pending");
|
|
1244
|
+
for (const a of o) {
|
|
1245
|
+
const { clientId: l, file: u, assetTypeId: y } = a;
|
|
1246
|
+
try {
|
|
1247
|
+
e((A) => ({
|
|
1248
|
+
files: ge(A.files, l, { status: "creating" })
|
|
1249
|
+
}));
|
|
1250
|
+
const f = (await r.create(n, {
|
|
1251
|
+
name: u.name,
|
|
1252
|
+
assetTypeId: y,
|
|
1253
|
+
folderId: i ?? "",
|
|
1254
|
+
metadata: {},
|
|
1255
|
+
analyzeWithAi: t().analyzeWithAi
|
|
1256
|
+
})).id;
|
|
1257
|
+
if (!f) throw new Error("create returned no asset ID");
|
|
1258
|
+
e((A) => ({
|
|
1259
|
+
files: ge(A.files, l, { assetId: f })
|
|
1260
|
+
}));
|
|
1261
|
+
const { uploadUrl: p, versionId: T } = await r.getUploadUrl({
|
|
1262
|
+
assetId: f,
|
|
1263
|
+
filename: u.name,
|
|
1264
|
+
contentType: u.type || "application/octet-stream",
|
|
1265
|
+
fileSize: u.size,
|
|
1266
|
+
comment: ""
|
|
1267
|
+
});
|
|
1268
|
+
if (!p || !T)
|
|
1269
|
+
throw new Error("getUploadUrl returned incomplete response");
|
|
1270
|
+
e((A) => ({
|
|
1271
|
+
files: ge(A.files, l, {
|
|
1272
|
+
versionId: T,
|
|
1273
|
+
status: "uploading"
|
|
1274
|
+
})
|
|
1275
|
+
})), await sn(
|
|
1276
|
+
p,
|
|
1277
|
+
u,
|
|
1278
|
+
u.type || "application/octet-stream",
|
|
1279
|
+
(A) => {
|
|
1280
|
+
e((k) => ({
|
|
1281
|
+
files: ge(k.files, l, { progress: A })
|
|
1282
|
+
}));
|
|
1283
|
+
}
|
|
1284
|
+
), e((A) => ({
|
|
1285
|
+
files: ge(A.files, l, { status: "finalizing" })
|
|
1286
|
+
})), await r.finalizeUpload(T), e((A) => ({
|
|
1287
|
+
files: ge(A.files, l, {
|
|
1288
|
+
status: "done",
|
|
1289
|
+
progress: 100
|
|
1290
|
+
})
|
|
1291
|
+
}));
|
|
1292
|
+
const v = t().queryClient;
|
|
1293
|
+
v && v.invalidateQueries({ queryKey: ["mediahub", "assets"] });
|
|
1294
|
+
} catch (h) {
|
|
1295
|
+
const f = he(h, "Upload failed"), p = f.kind === "other" ? h instanceof Error ? h.message : String(h) : f.description;
|
|
1296
|
+
e((T) => ({
|
|
1297
|
+
files: ge(T.files, l, {
|
|
1298
|
+
status: "error",
|
|
1299
|
+
error: p
|
|
1300
|
+
})
|
|
1301
|
+
}));
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
},
|
|
1305
|
+
setQueryClient: (n) => e({ queryClient: n }),
|
|
1306
|
+
setAssetClient: (n) => e({ assetClient: n }),
|
|
1307
|
+
clearPending: () => e((n) => ({
|
|
1308
|
+
files: n.files.filter((i) => i.status !== "pending")
|
|
1309
|
+
})),
|
|
1310
|
+
dismiss: () => e({ visible: !1, files: [], expanded: !0, analyzeWithAi: !0 }),
|
|
1311
|
+
toggleExpanded: () => e((n) => ({ expanded: !n.expanded }))
|
|
1312
|
+
}));
|
|
1313
|
+
function De({ slug: e }) {
|
|
1314
|
+
const { status: t, isLoading: n } = ni(e);
|
|
1315
|
+
return !e || n ? null : t ? /* @__PURE__ */ s(Hn, { status: t }) : /* @__PURE__ */ s(L, { fontSize: "xs", color: "fg.muted", children: e });
|
|
1316
|
+
}
|
|
1317
|
+
De.displayName = "AssetStatusBadge";
|
|
1318
|
+
function Si(e) {
|
|
1319
|
+
const t = e.versions[e.versions.length - 1];
|
|
1320
|
+
if (!t) return "unknown";
|
|
1321
|
+
const n = t.mimeType;
|
|
1322
|
+
return n.startsWith("image/") ? "image" : n.startsWith("video/") ? "video" : n.startsWith("audio/") ? "audio" : n === "application/pdf" ? "pdf" : "unknown";
|
|
1323
|
+
}
|
|
1324
|
+
function mn({ category: e }) {
|
|
1325
|
+
switch (e) {
|
|
1326
|
+
case "image":
|
|
1327
|
+
return /* @__PURE__ */ s(pt, { size: 32, opacity: 0.3 });
|
|
1328
|
+
case "video":
|
|
1329
|
+
return /* @__PURE__ */ s(ht, { size: 32, opacity: 0.3 });
|
|
1330
|
+
case "audio":
|
|
1331
|
+
return /* @__PURE__ */ s(Ve, { size: 32, opacity: 0.3 });
|
|
1332
|
+
default:
|
|
1333
|
+
return /* @__PURE__ */ s(ft, { size: 32, opacity: 0.3 });
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
mn.displayName = "TypeIcon";
|
|
1337
|
+
const fn = ({ asset: e, onOpen: t }) => {
|
|
1338
|
+
const n = oe((f) => f.selectedIds.includes(e.id)), i = oe((f) => f.selectedIds.length > 0), r = oe((f) => f.toggle), o = Si(e), a = e.versions[e.versions.length - 1], l = Ge(
|
|
1339
|
+
o === "image" && a ? e.id : "",
|
|
1340
|
+
(a == null ? void 0 : a.id) ?? ""
|
|
1341
|
+
), u = l.data, [y, h] = D(!1);
|
|
1342
|
+
return /* @__PURE__ */ c(
|
|
1343
|
+
ue,
|
|
1344
|
+
{
|
|
1345
|
+
selected: n,
|
|
1346
|
+
selectionVisible: i,
|
|
1347
|
+
onSelect: () => r(e.id),
|
|
1348
|
+
onClick: () => t(e),
|
|
1349
|
+
children: [
|
|
1350
|
+
/* @__PURE__ */ s(ue.Thumbnail, { height: "160px", children: o === "image" && u && !y ? /* @__PURE__ */ s(
|
|
1351
|
+
"img",
|
|
1352
|
+
{
|
|
1353
|
+
src: u,
|
|
1354
|
+
alt: e.name || "Asset preview",
|
|
1355
|
+
onError: () => h(!0),
|
|
1356
|
+
style: {
|
|
1357
|
+
width: "100%",
|
|
1358
|
+
height: "100%",
|
|
1359
|
+
objectFit: "cover"
|
|
1360
|
+
}
|
|
1361
|
+
}
|
|
1362
|
+
) : o === "image" && l.isLoading ? /* @__PURE__ */ s(ut, { w: "full", h: "full" }) : /* @__PURE__ */ s(mn, { category: o }) }),
|
|
1363
|
+
/* @__PURE__ */ s(ue.Body, { children: /* @__PURE__ */ s(L, { fontSize: "sm", fontWeight: "medium", truncate: !0, children: e.name }) }),
|
|
1364
|
+
/* @__PURE__ */ c(ue.Footer, { children: [
|
|
1365
|
+
/* @__PURE__ */ s(De, { slug: e.statusSlug }),
|
|
1366
|
+
/* @__PURE__ */ s(L, { fontSize: "xs", color: "fg.muted", children: o.charAt(0).toUpperCase() + o.slice(1) })
|
|
1367
|
+
] })
|
|
1368
|
+
]
|
|
1369
|
+
}
|
|
1370
|
+
);
|
|
1371
|
+
};
|
|
1372
|
+
fn.displayName = "AssetCard";
|
|
1373
|
+
const hn = ({ assets: e, onOpen: t }) => /* @__PURE__ */ s(dt, { templateColumns: "repeat(auto-fill, minmax(200px, 1fr))", gap: 4, children: e.map((n) => /* @__PURE__ */ s(fn, { asset: n, onOpen: t }, n.id)) });
|
|
1374
|
+
hn.displayName = "AssetGrid";
|
|
1375
|
+
function lt({ mimeType: e }) {
|
|
1376
|
+
return e.startsWith("image/") ? /* @__PURE__ */ s(pt, { size: 48, opacity: 0.3 }) : e.startsWith("video/") ? /* @__PURE__ */ s(ht, { size: 48, opacity: 0.3 }) : e.startsWith("audio/") ? /* @__PURE__ */ s(Ve, { size: 48, opacity: 0.3 }) : /* @__PURE__ */ s(ft, { size: 48, opacity: 0.3 });
|
|
1377
|
+
}
|
|
1378
|
+
lt.displayName = "TypeIcon";
|
|
1379
|
+
const pn = ({
|
|
1380
|
+
assetId: e,
|
|
1381
|
+
versionId: t,
|
|
1382
|
+
mimeType: n,
|
|
1383
|
+
fileName: i
|
|
1384
|
+
}) => {
|
|
1385
|
+
const r = Ge(e, t), o = r.data, [a, l] = D(!1);
|
|
1386
|
+
return r.isLoading ? /* @__PURE__ */ s(ut, { w: "full", h: "full", minH: "200px" }) : !o || a ? /* @__PURE__ */ c(
|
|
1387
|
+
P,
|
|
1388
|
+
{
|
|
1389
|
+
direction: "column",
|
|
1390
|
+
align: "center",
|
|
1391
|
+
justify: "center",
|
|
1392
|
+
gap: 3,
|
|
1393
|
+
p: 6,
|
|
1394
|
+
h: "full",
|
|
1395
|
+
minH: "200px",
|
|
1396
|
+
children: [
|
|
1397
|
+
/* @__PURE__ */ s(lt, { mimeType: n }),
|
|
1398
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.muted", children: "Preview not available" }),
|
|
1399
|
+
o && /* @__PURE__ */ s(Y, { asChild: !0, size: "sm", variant: "outline", children: /* @__PURE__ */ c("a", { href: o, download: i, children: [
|
|
1400
|
+
/* @__PURE__ */ s(Be, { size: 14 }),
|
|
1401
|
+
"Download"
|
|
1402
|
+
] }) })
|
|
1403
|
+
]
|
|
1404
|
+
}
|
|
1405
|
+
) : n.startsWith("image/") ? /* @__PURE__ */ s(
|
|
1406
|
+
F,
|
|
1407
|
+
{
|
|
1408
|
+
h: "full",
|
|
1409
|
+
minH: "200px",
|
|
1410
|
+
display: "flex",
|
|
1411
|
+
alignItems: "center",
|
|
1412
|
+
justifyContent: "center",
|
|
1413
|
+
p: 2,
|
|
1414
|
+
children: /* @__PURE__ */ s(
|
|
1415
|
+
"img",
|
|
1416
|
+
{
|
|
1417
|
+
src: o,
|
|
1418
|
+
alt: i,
|
|
1419
|
+
onError: () => l(!0),
|
|
1420
|
+
style: {
|
|
1421
|
+
maxWidth: "100%",
|
|
1422
|
+
maxHeight: "100%",
|
|
1423
|
+
objectFit: "contain"
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
)
|
|
1427
|
+
}
|
|
1428
|
+
) : n.startsWith("video/") ? /* @__PURE__ */ s(F, { h: "full", minH: "200px", p: 2, children: /* @__PURE__ */ s(
|
|
1429
|
+
"video",
|
|
1430
|
+
{
|
|
1431
|
+
src: o,
|
|
1432
|
+
controls: !0,
|
|
1433
|
+
onError: () => l(!0),
|
|
1434
|
+
style: { width: "100%", maxHeight: "100%" },
|
|
1435
|
+
children: /* @__PURE__ */ s("track", { kind: "captions" })
|
|
1436
|
+
}
|
|
1437
|
+
) }) : n.startsWith("audio/") ? /* @__PURE__ */ c(
|
|
1438
|
+
P,
|
|
1439
|
+
{
|
|
1440
|
+
direction: "column",
|
|
1441
|
+
align: "center",
|
|
1442
|
+
justify: "center",
|
|
1443
|
+
gap: 4,
|
|
1444
|
+
p: 6,
|
|
1445
|
+
h: "full",
|
|
1446
|
+
minH: "200px",
|
|
1447
|
+
children: [
|
|
1448
|
+
/* @__PURE__ */ s(Ve, { size: 48, opacity: 0.3 }),
|
|
1449
|
+
/* @__PURE__ */ s(
|
|
1450
|
+
"audio",
|
|
1451
|
+
{
|
|
1452
|
+
src: o,
|
|
1453
|
+
controls: !0,
|
|
1454
|
+
onError: () => l(!0),
|
|
1455
|
+
style: { width: "100%" },
|
|
1456
|
+
children: /* @__PURE__ */ s("track", { kind: "captions" })
|
|
1457
|
+
}
|
|
1458
|
+
)
|
|
1459
|
+
]
|
|
1460
|
+
}
|
|
1461
|
+
) : n === "application/pdf" ? /* @__PURE__ */ s(F, { h: "full", minH: "400px", children: /* @__PURE__ */ s(
|
|
1462
|
+
"iframe",
|
|
1463
|
+
{
|
|
1464
|
+
src: o,
|
|
1465
|
+
title: i,
|
|
1466
|
+
width: "100%",
|
|
1467
|
+
height: "100%",
|
|
1468
|
+
style: { border: "none" }
|
|
1469
|
+
}
|
|
1470
|
+
) }) : /* @__PURE__ */ c(
|
|
1471
|
+
P,
|
|
1472
|
+
{
|
|
1473
|
+
direction: "column",
|
|
1474
|
+
align: "center",
|
|
1475
|
+
justify: "center",
|
|
1476
|
+
gap: 3,
|
|
1477
|
+
p: 6,
|
|
1478
|
+
h: "full",
|
|
1479
|
+
minH: "200px",
|
|
1480
|
+
children: [
|
|
1481
|
+
/* @__PURE__ */ s(lt, { mimeType: n }),
|
|
1482
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.muted", children: "Preview not available" }),
|
|
1483
|
+
/* @__PURE__ */ s(Y, { asChild: !0, size: "sm", variant: "outline", children: /* @__PURE__ */ c("a", { href: o, download: i, children: [
|
|
1484
|
+
/* @__PURE__ */ s(Be, { size: 14 }),
|
|
1485
|
+
"Download"
|
|
1486
|
+
] }) })
|
|
1487
|
+
]
|
|
1488
|
+
}
|
|
1489
|
+
);
|
|
1490
|
+
};
|
|
1491
|
+
pn.displayName = "AssetPreview";
|
|
1492
|
+
function gn({
|
|
1493
|
+
assetId: e,
|
|
1494
|
+
statusSlug: t
|
|
1495
|
+
}) {
|
|
1496
|
+
const n = oi();
|
|
1497
|
+
return /* @__PURE__ */ s(
|
|
1498
|
+
Yn,
|
|
1499
|
+
{
|
|
1500
|
+
...nn,
|
|
1501
|
+
currentStatusSlug: t,
|
|
1502
|
+
quickAdvance: !1,
|
|
1503
|
+
canRevert: !0,
|
|
1504
|
+
onTransition: async (i) => {
|
|
1505
|
+
try {
|
|
1506
|
+
await n.mutateAsync({
|
|
1507
|
+
id: e,
|
|
1508
|
+
fromStatusSlug: t,
|
|
1509
|
+
toStatusSlug: i.slug
|
|
1510
|
+
});
|
|
1511
|
+
} catch (r) {
|
|
1512
|
+
M(r, "Status change failed");
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
);
|
|
1517
|
+
}
|
|
1518
|
+
gn.displayName = "AssetStatusControl";
|
|
1519
|
+
const yn = () => {
|
|
1520
|
+
const e = oe((v) => v.selectedIds), t = oe((v) => v.clearSelection), n = e.length, i = vt(), { confirm: r } = je(), o = cn(), a = ln(), l = Ct(), u = Re(), y = l.data ?? [], h = u.data ?? [];
|
|
1521
|
+
async function f() {
|
|
1522
|
+
if (!await r({
|
|
1523
|
+
title: "Delete Assets",
|
|
1524
|
+
message: `Delete ${n} asset${n > 1 ? "s" : ""}? This cannot be undone.`,
|
|
1525
|
+
confirmLabel: "Delete"
|
|
1526
|
+
})) return;
|
|
1527
|
+
const A = oe.getState().selectedIds, k = A.length;
|
|
1528
|
+
if (k === 0) return;
|
|
1529
|
+
let U = 0, E;
|
|
1530
|
+
for (const q of A)
|
|
1531
|
+
try {
|
|
1532
|
+
await i.mutateAsync(q);
|
|
1533
|
+
} catch (x) {
|
|
1534
|
+
U++, E ?? (E = x);
|
|
1535
|
+
}
|
|
1536
|
+
if (U === 0)
|
|
1537
|
+
B.success({ title: `${k} asset${k > 1 ? "s" : ""} deleted` }), oe.getState().clearSelection();
|
|
1538
|
+
else {
|
|
1539
|
+
const q = he(
|
|
1540
|
+
E,
|
|
1541
|
+
`${k - U} deleted, ${U} failed`
|
|
1542
|
+
);
|
|
1543
|
+
B.error(
|
|
1544
|
+
q.kind === "other" ? { title: `${k - U} deleted, ${U} failed` } : { title: q.title, description: q.description }
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
async function p(v) {
|
|
1549
|
+
try {
|
|
1550
|
+
await o.mutateAsync({ tagId: v, assetIds: [...e] }), B.success({ title: "Tags updated" });
|
|
1551
|
+
} catch (A) {
|
|
1552
|
+
M(A, "Error");
|
|
1553
|
+
}
|
|
1554
|
+
}
|
|
1555
|
+
async function T(v) {
|
|
1556
|
+
try {
|
|
1557
|
+
await a.mutateAsync({
|
|
1558
|
+
collectionId: v,
|
|
1559
|
+
assetIds: [...e]
|
|
1560
|
+
}), B.success({ title: "Added to collection" });
|
|
1561
|
+
} catch (A) {
|
|
1562
|
+
M(A, "Error");
|
|
1563
|
+
}
|
|
1564
|
+
}
|
|
1565
|
+
return /* @__PURE__ */ c(
|
|
1566
|
+
Pe,
|
|
1567
|
+
{
|
|
1568
|
+
selectedCount: n,
|
|
1569
|
+
onClear: t,
|
|
1570
|
+
countLabel: (v) => `${v} selected`,
|
|
1571
|
+
children: [
|
|
1572
|
+
/* @__PURE__ */ s(
|
|
1573
|
+
Pe.PopoverAction,
|
|
1574
|
+
{
|
|
1575
|
+
label: "Add Tags",
|
|
1576
|
+
icon: /* @__PURE__ */ s(is, { size: 14 }),
|
|
1577
|
+
children: /* @__PURE__ */ c(P, { direction: "column", gap: 1, p: 2, children: [
|
|
1578
|
+
y.map((v) => /* @__PURE__ */ s(
|
|
1579
|
+
F,
|
|
1580
|
+
{
|
|
1581
|
+
asChild: !0,
|
|
1582
|
+
px: 2,
|
|
1583
|
+
py: 1,
|
|
1584
|
+
rounded: "md",
|
|
1585
|
+
fontSize: "sm",
|
|
1586
|
+
textAlign: "left",
|
|
1587
|
+
cursor: "pointer",
|
|
1588
|
+
_hover: { bg: "bg.muted" },
|
|
1589
|
+
children: /* @__PURE__ */ s("button", { type: "button", onClick: () => p(v.id), children: v.name })
|
|
1590
|
+
},
|
|
1591
|
+
v.id
|
|
1592
|
+
)),
|
|
1593
|
+
y.length === 0 && /* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.muted", p: 2, children: "No tags available" })
|
|
1594
|
+
] })
|
|
1595
|
+
}
|
|
1596
|
+
),
|
|
1597
|
+
/* @__PURE__ */ s(
|
|
1598
|
+
Pe.PopoverAction,
|
|
1599
|
+
{
|
|
1600
|
+
label: "Add to Collection",
|
|
1601
|
+
icon: /* @__PURE__ */ s(Ht, { size: 14 }),
|
|
1602
|
+
children: /* @__PURE__ */ c(P, { direction: "column", gap: 1, p: 2, children: [
|
|
1603
|
+
h.map((v) => /* @__PURE__ */ s(
|
|
1604
|
+
F,
|
|
1605
|
+
{
|
|
1606
|
+
asChild: !0,
|
|
1607
|
+
px: 2,
|
|
1608
|
+
py: 1,
|
|
1609
|
+
rounded: "md",
|
|
1610
|
+
fontSize: "sm",
|
|
1611
|
+
textAlign: "left",
|
|
1612
|
+
cursor: "pointer",
|
|
1613
|
+
_hover: { bg: "bg.muted" },
|
|
1614
|
+
children: /* @__PURE__ */ s(
|
|
1615
|
+
"button",
|
|
1616
|
+
{
|
|
1617
|
+
type: "button",
|
|
1618
|
+
onClick: () => T(v.id),
|
|
1619
|
+
children: v.name
|
|
1620
|
+
}
|
|
1621
|
+
)
|
|
1622
|
+
},
|
|
1623
|
+
v.id
|
|
1624
|
+
)),
|
|
1625
|
+
h.length === 0 && /* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.muted", p: 2, children: "No collections available" })
|
|
1626
|
+
] })
|
|
1627
|
+
}
|
|
1628
|
+
),
|
|
1629
|
+
/* @__PURE__ */ s(
|
|
1630
|
+
Pe.Action,
|
|
1631
|
+
{
|
|
1632
|
+
label: "Delete",
|
|
1633
|
+
icon: /* @__PURE__ */ s(Yt, { size: 14 }),
|
|
1634
|
+
colorPalette: "red",
|
|
1635
|
+
onClick: f
|
|
1636
|
+
}
|
|
1637
|
+
)
|
|
1638
|
+
]
|
|
1639
|
+
}
|
|
1640
|
+
);
|
|
1641
|
+
};
|
|
1642
|
+
yn.displayName = "BulkActionBar";
|
|
1643
|
+
const bn = ({
|
|
1644
|
+
assetId: e,
|
|
1645
|
+
assignedCollectionIds: t
|
|
1646
|
+
}) => {
|
|
1647
|
+
const n = Re(), i = n.data ?? [], r = ln(), o = yi(), a = z(), l = i.filter(
|
|
1648
|
+
(f) => t.includes(f.id)
|
|
1649
|
+
), u = i.filter(
|
|
1650
|
+
(f) => !t.includes(f.id)
|
|
1651
|
+
);
|
|
1652
|
+
async function y(f) {
|
|
1653
|
+
try {
|
|
1654
|
+
await r.mutateAsync({
|
|
1655
|
+
collectionId: f.id,
|
|
1656
|
+
assetIds: [e]
|
|
1657
|
+
}), a.invalidateQueries({ queryKey: ["mediahub", "collections"] });
|
|
1658
|
+
} catch (p) {
|
|
1659
|
+
M(p, "Error");
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
async function h(f) {
|
|
1663
|
+
try {
|
|
1664
|
+
await o.mutateAsync({
|
|
1665
|
+
collectionId: f.id,
|
|
1666
|
+
assetIds: [e]
|
|
1667
|
+
}), a.invalidateQueries({ queryKey: ["mediahub", "collections"] });
|
|
1668
|
+
} catch (p) {
|
|
1669
|
+
M(p, "Error");
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
return /* @__PURE__ */ s(
|
|
1673
|
+
_t,
|
|
1674
|
+
{
|
|
1675
|
+
assigned: l,
|
|
1676
|
+
available: u,
|
|
1677
|
+
getItemId: (f) => f.id,
|
|
1678
|
+
getItemLabel: (f) => f.name,
|
|
1679
|
+
onAdd: y,
|
|
1680
|
+
onRemove: h,
|
|
1681
|
+
addLabel: "Add to collection",
|
|
1682
|
+
emptyLabel: "No collections",
|
|
1683
|
+
searchable: !0,
|
|
1684
|
+
loading: n.isLoading
|
|
1685
|
+
}
|
|
1686
|
+
);
|
|
1687
|
+
};
|
|
1688
|
+
bn.displayName = "CollectionChipField";
|
|
1689
|
+
const vn = ({
|
|
1690
|
+
activeCollectionId: e,
|
|
1691
|
+
onSelectCollection: t
|
|
1692
|
+
}) => {
|
|
1693
|
+
const i = Re().data ?? [], r = on();
|
|
1694
|
+
async function o(a) {
|
|
1695
|
+
try {
|
|
1696
|
+
await r.mutateAsync({
|
|
1697
|
+
name: a,
|
|
1698
|
+
slug: a.toLowerCase().replace(/\s+/g, "-"),
|
|
1699
|
+
description: "",
|
|
1700
|
+
type: "static",
|
|
1701
|
+
rules: ""
|
|
1702
|
+
}), B.success({ title: "Collection created" });
|
|
1703
|
+
} catch (l) {
|
|
1704
|
+
M(l, "Error");
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
return /* @__PURE__ */ s(
|
|
1708
|
+
Wt,
|
|
1709
|
+
{
|
|
1710
|
+
items: i,
|
|
1711
|
+
activeIds: e ? [e] : [],
|
|
1712
|
+
onToggle: t,
|
|
1713
|
+
onCreate: o,
|
|
1714
|
+
getItemId: (a) => a.id,
|
|
1715
|
+
getItemLabel: (a) => a.name,
|
|
1716
|
+
variant: "list",
|
|
1717
|
+
createPlaceholder: "Collection name",
|
|
1718
|
+
createLabel: "New collection",
|
|
1719
|
+
emptyText: "No collections"
|
|
1720
|
+
}
|
|
1721
|
+
);
|
|
1722
|
+
};
|
|
1723
|
+
vn.displayName = "CollectionPanel";
|
|
1724
|
+
function Ii(e) {
|
|
1725
|
+
const n = nt(e).data, r = nt((n == null ? void 0 : n.parentId) ?? "").data, a = nt((r == null ? void 0 : r.parentId) ?? "").data;
|
|
1726
|
+
return W(() => {
|
|
1727
|
+
const l = [];
|
|
1728
|
+
return a && l.push({ id: a.id, name: a.name }), r && l.push({ id: r.id, name: r.name }), n && l.push({ id: n.id, name: n.name }), l;
|
|
1729
|
+
}, [n, r, a]);
|
|
1730
|
+
}
|
|
1731
|
+
const wn = ({
|
|
1732
|
+
folderId: e,
|
|
1733
|
+
onNavigate: t
|
|
1734
|
+
}) => {
|
|
1735
|
+
const n = Ii(e);
|
|
1736
|
+
return !e || n.length === 0 ? null : /* @__PURE__ */ s(On, { children: /* @__PURE__ */ c(Qn, { children: [
|
|
1737
|
+
/* @__PURE__ */ c(Xe, { children: [
|
|
1738
|
+
/* @__PURE__ */ s(
|
|
1739
|
+
zt,
|
|
1740
|
+
{
|
|
1741
|
+
href: "#",
|
|
1742
|
+
onClick: (i) => {
|
|
1743
|
+
i.preventDefault(), t("");
|
|
1744
|
+
},
|
|
1745
|
+
cursor: "pointer",
|
|
1746
|
+
children: "All Assets"
|
|
1747
|
+
}
|
|
1748
|
+
),
|
|
1749
|
+
/* @__PURE__ */ s(Rt, {})
|
|
1750
|
+
] }),
|
|
1751
|
+
n.slice(0, -1).map((i) => /* @__PURE__ */ c(Xe, { children: [
|
|
1752
|
+
/* @__PURE__ */ s(
|
|
1753
|
+
zt,
|
|
1754
|
+
{
|
|
1755
|
+
href: "#",
|
|
1756
|
+
onClick: (r) => {
|
|
1757
|
+
r.preventDefault(), t(i.id);
|
|
1758
|
+
},
|
|
1759
|
+
cursor: "pointer",
|
|
1760
|
+
children: i.name
|
|
1761
|
+
}
|
|
1762
|
+
),
|
|
1763
|
+
/* @__PURE__ */ s(Rt, {})
|
|
1764
|
+
] }, i.id)),
|
|
1765
|
+
n.length > 0 && /* @__PURE__ */ s(Xe, { children: /* @__PURE__ */ s(Bn, { children: n[n.length - 1].name }) })
|
|
1766
|
+
] }) });
|
|
1767
|
+
};
|
|
1768
|
+
wn.displayName = "FolderBreadcrumbs";
|
|
1769
|
+
function Qt({
|
|
1770
|
+
href: e,
|
|
1771
|
+
children: t
|
|
1772
|
+
}) {
|
|
1773
|
+
return e ? /* @__PURE__ */ s(
|
|
1774
|
+
_n,
|
|
1775
|
+
{
|
|
1776
|
+
href: e,
|
|
1777
|
+
fontWeight: "medium",
|
|
1778
|
+
color: "colorPalette.fg",
|
|
1779
|
+
colorPalette: "primary",
|
|
1780
|
+
textDecoration: "underline",
|
|
1781
|
+
children: t
|
|
1782
|
+
}
|
|
1783
|
+
) : /* @__PURE__ */ s(L, { as: "span", fontWeight: "medium", children: t });
|
|
1784
|
+
}
|
|
1785
|
+
const Cn = ({
|
|
1786
|
+
refusal: e,
|
|
1787
|
+
open: t,
|
|
1788
|
+
onClose: n,
|
|
1789
|
+
closeLabel: i,
|
|
1790
|
+
resolveHint: r
|
|
1791
|
+
}) => {
|
|
1792
|
+
const o = ti();
|
|
1793
|
+
if (!e) return null;
|
|
1794
|
+
const a = e.exposures ?? [];
|
|
1795
|
+
return /* @__PURE__ */ s(
|
|
1796
|
+
Ae,
|
|
1797
|
+
{
|
|
1798
|
+
open: t,
|
|
1799
|
+
lazyMount: !0,
|
|
1800
|
+
unmountOnExit: !0,
|
|
1801
|
+
onClose: n,
|
|
1802
|
+
size: "md",
|
|
1803
|
+
header: e.title,
|
|
1804
|
+
footer: /* @__PURE__ */ s(J, { gap: "2", justify: "flex-end", children: /* @__PURE__ */ s(Y, { variant: "outline", onClick: n, children: i ?? "Close" }) }),
|
|
1805
|
+
children: /* @__PURE__ */ c(P, { direction: "column", gap: 3, children: [
|
|
1806
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", children: e.ruleText ?? e.description }),
|
|
1807
|
+
a.length > 0 && /* @__PURE__ */ s(F, { as: "ul", pl: 4, display: "flex", flexDirection: "column", gap: 1, children: a.map((l) => {
|
|
1808
|
+
var u, y;
|
|
1809
|
+
return /* @__PURE__ */ c(F, { as: "li", fontSize: "sm", children: [
|
|
1810
|
+
/* @__PURE__ */ s(Qt, { href: (u = o.assetHref) == null ? void 0 : u.call(o, l.assetId), children: l.assetName }),
|
|
1811
|
+
/* @__PURE__ */ s(L, { as: "span", color: "fg.muted", children: " — in collection " }),
|
|
1812
|
+
/* @__PURE__ */ s(Qt, { href: (y = o.collectionHref) == null ? void 0 : y.call(o, l.collectionId), children: l.collectionName })
|
|
1813
|
+
] }, `${l.assetId}:${l.collectionId}`);
|
|
1814
|
+
}) }),
|
|
1815
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.muted", children: r ?? "Resolve these exposures, then try again — nothing was changed." })
|
|
1816
|
+
] })
|
|
1817
|
+
}
|
|
1818
|
+
);
|
|
1819
|
+
};
|
|
1820
|
+
Cn.displayName = "LeakGuardRefusalDialog";
|
|
1821
|
+
const Sn = 100;
|
|
1822
|
+
function In(e) {
|
|
1823
|
+
return e.filter((t) => !t.restricted).map((t) => t.id);
|
|
1824
|
+
}
|
|
1825
|
+
function Ai(e, t) {
|
|
1826
|
+
const n = new Set(In(t));
|
|
1827
|
+
return e.collectionIds.some((i) => n.has(i));
|
|
1828
|
+
}
|
|
1829
|
+
async function ct(e, t) {
|
|
1830
|
+
let n = t;
|
|
1831
|
+
for (let i = 0; i < Sn; i++) {
|
|
1832
|
+
if (n.restricted) return !0;
|
|
1833
|
+
if (!n.parentId) return !1;
|
|
1834
|
+
n = await e.get(n.parentId);
|
|
1835
|
+
}
|
|
1836
|
+
return !0;
|
|
1837
|
+
}
|
|
1838
|
+
async function Ti(e, t, n, i) {
|
|
1839
|
+
if (i.length === 0) return !1;
|
|
1840
|
+
let r = [n];
|
|
1841
|
+
for (let o = 0; r.length > 0 && o < Sn; o++) {
|
|
1842
|
+
for (const l of r)
|
|
1843
|
+
if ((await e.assets.list(t, {
|
|
1844
|
+
folderId: l,
|
|
1845
|
+
collectionIds: i
|
|
1846
|
+
})).total > 0) return !0;
|
|
1847
|
+
const a = [];
|
|
1848
|
+
for (const l of r) {
|
|
1849
|
+
const u = await e.folders.list(t, l);
|
|
1850
|
+
a.push(...u.filter((y) => !y.restricted).map((y) => y.id));
|
|
1851
|
+
}
|
|
1852
|
+
r = a;
|
|
1853
|
+
}
|
|
1854
|
+
return !1;
|
|
1855
|
+
}
|
|
1856
|
+
function ki(e) {
|
|
1857
|
+
switch (e.kind) {
|
|
1858
|
+
case "asset":
|
|
1859
|
+
return e.asset.id;
|
|
1860
|
+
case "folder":
|
|
1861
|
+
return e.folder.id;
|
|
1862
|
+
case "collection":
|
|
1863
|
+
return e.collection.id;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
function xi(e) {
|
|
1867
|
+
switch (e.kind) {
|
|
1868
|
+
case "asset":
|
|
1869
|
+
return e.asset.name;
|
|
1870
|
+
case "folder":
|
|
1871
|
+
return e.folder.name;
|
|
1872
|
+
case "collection":
|
|
1873
|
+
return e.collection.name;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
function It(e) {
|
|
1877
|
+
const { open: t, onOpenChange: n, subject: i } = e, r = g(), o = i.kind, a = ki(i), [l, u] = D(""), [y, h] = D("viewer"), f = hi(o, a, { enabled: t }), p = f.data, T = f.isError && he(f.error, "").kind === "permission-denied", v = wi({
|
|
1878
|
+
enabled: t && f.isSuccess
|
|
1879
|
+
}), A = W(() => {
|
|
1880
|
+
if (!p) return [];
|
|
1881
|
+
const I = p.grants.map((d) => d.userId);
|
|
1882
|
+
return p.ownerUserId && I.push(p.ownerUserId), I;
|
|
1883
|
+
}, [p]), k = St(A), U = (I) => {
|
|
1884
|
+
var d;
|
|
1885
|
+
return ((d = k.data) == null ? void 0 : d[I]) ?? I;
|
|
1886
|
+
}, E = O({
|
|
1887
|
+
queryKey: ["mediahub", "access-scope", o, a],
|
|
1888
|
+
enabled: t && i.kind !== "collection" && f.isSuccess,
|
|
1889
|
+
queryFn: async () => {
|
|
1890
|
+
if (i.kind === "folder")
|
|
1891
|
+
return ct(r.folders, i.folder);
|
|
1892
|
+
if (i.kind === "asset") {
|
|
1893
|
+
if (!i.asset.folderId) return !1;
|
|
1894
|
+
const I = await r.folders.get(i.asset.folderId);
|
|
1895
|
+
return ct(r.folders, I);
|
|
1896
|
+
}
|
|
1897
|
+
return !1;
|
|
1898
|
+
}
|
|
1899
|
+
}), q = i.kind === "collection" ? i.collection.restricted : E.isError ? !0 : E.data, x = pi(), Q = gi(), S = x.isPending || Q.isPending;
|
|
1900
|
+
le(() => {
|
|
1901
|
+
t && (u(""), h("viewer"));
|
|
1902
|
+
}, [t]);
|
|
1903
|
+
const G = W(
|
|
1904
|
+
() => new Set(p == null ? void 0 : p.grants.map((I) => I.userId)),
|
|
1905
|
+
[p]
|
|
1906
|
+
), R = W(
|
|
1907
|
+
() => (v.data ?? []).filter(
|
|
1908
|
+
(I) => I.id !== (p == null ? void 0 : p.ownerUserId) && !G.has(I.id)
|
|
1909
|
+
),
|
|
1910
|
+
[v.data, p, G]
|
|
1911
|
+
), $ = k.data, H = W(() => {
|
|
1912
|
+
const I = (d) => ($ == null ? void 0 : $[d]) ?? d;
|
|
1913
|
+
return [...(p == null ? void 0 : p.grants) ?? []].sort(
|
|
1914
|
+
(d, w) => I(d.userId).localeCompare(I(w.userId))
|
|
1915
|
+
);
|
|
1916
|
+
}, [p, $]);
|
|
1917
|
+
async function te() {
|
|
1918
|
+
if (l)
|
|
1919
|
+
try {
|
|
1920
|
+
await x.mutateAsync({
|
|
1921
|
+
resourceType: o,
|
|
1922
|
+
resourceId: a,
|
|
1923
|
+
userId: l,
|
|
1924
|
+
level: y
|
|
1925
|
+
}), u(""), h("viewer"), B.success({ title: "Access granted" });
|
|
1926
|
+
} catch (I) {
|
|
1927
|
+
M(I, "Grant failed");
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
async function me(I, d) {
|
|
1931
|
+
try {
|
|
1932
|
+
await x.mutateAsync({
|
|
1933
|
+
resourceType: o,
|
|
1934
|
+
resourceId: a,
|
|
1935
|
+
userId: I,
|
|
1936
|
+
level: d
|
|
1937
|
+
}), B.success({ title: "Access updated" });
|
|
1938
|
+
} catch (w) {
|
|
1939
|
+
M(w, "Update failed");
|
|
1940
|
+
}
|
|
1941
|
+
}
|
|
1942
|
+
async function Z(I) {
|
|
1943
|
+
try {
|
|
1944
|
+
await Q.mutateAsync({
|
|
1945
|
+
resourceType: o,
|
|
1946
|
+
resourceId: a,
|
|
1947
|
+
userId: I
|
|
1948
|
+
}), B.success({ title: "Access revoked" });
|
|
1949
|
+
} catch (d) {
|
|
1950
|
+
M(d, "Revoke failed");
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
const ae = e.viewerLabel ?? "Viewer", _ = e.editorLabel ?? "Editor";
|
|
1954
|
+
function ne() {
|
|
1955
|
+
if (f.isLoading)
|
|
1956
|
+
return /* @__PURE__ */ s(P, { justify: "center", py: "8", children: /* @__PURE__ */ s(be, {}) });
|
|
1957
|
+
if (T) {
|
|
1958
|
+
const I = he(f.error, "");
|
|
1959
|
+
return /* @__PURE__ */ c(F, { py: "4", children: [
|
|
1960
|
+
/* @__PURE__ */ s(L, { fontWeight: "medium", children: I.title }),
|
|
1961
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.muted", mt: "1", children: I.description })
|
|
1962
|
+
] });
|
|
1963
|
+
}
|
|
1964
|
+
return f.isError ? /* @__PURE__ */ s(F, { py: "4", children: /* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.error", children: he(f.error, "Couldn't load access").description }) }) : p ? /* @__PURE__ */ c(P, { direction: "column", gap: "4", children: [
|
|
1965
|
+
q !== void 0 && /* @__PURE__ */ c(
|
|
1966
|
+
J,
|
|
1967
|
+
{
|
|
1968
|
+
gap: "2",
|
|
1969
|
+
align: "flex-start",
|
|
1970
|
+
px: "3",
|
|
1971
|
+
py: "2",
|
|
1972
|
+
rounded: "md",
|
|
1973
|
+
bg: "bg.muted",
|
|
1974
|
+
children: [
|
|
1975
|
+
q && /* @__PURE__ */ s($e, { size: 14, style: { marginTop: 2 } }),
|
|
1976
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", color: "fg.muted", children: q ? e.restrictedAccessNote ?? `Restricted — only the Owner and people with Grants can access this ${o}.` : e.openAccessNote ?? `All workspace members can view this ${o}. Grants add explicit access on top.` })
|
|
1977
|
+
]
|
|
1978
|
+
}
|
|
1979
|
+
),
|
|
1980
|
+
/* @__PURE__ */ c(P, { direction: "column", gap: "2", children: [
|
|
1981
|
+
p.ownerUserId && /* @__PURE__ */ c(P, { align: "center", gap: "2", children: [
|
|
1982
|
+
/* @__PURE__ */ s(F, { flex: "1", minW: "0", children: /* @__PURE__ */ s(Pt, { size: "sm", name: U(p.ownerUserId) }) }),
|
|
1983
|
+
/* @__PURE__ */ s(Bt, { variant: "subtle", children: e.ownerBadgeLabel ?? "Owner" })
|
|
1984
|
+
] }),
|
|
1985
|
+
H.map((I) => {
|
|
1986
|
+
const d = U(I.userId);
|
|
1987
|
+
return /* @__PURE__ */ c(P, { align: "center", gap: "2", children: [
|
|
1988
|
+
/* @__PURE__ */ s(F, { flex: "1", minW: "0", children: /* @__PURE__ */ s(Pt, { size: "sm", name: d }) }),
|
|
1989
|
+
/* @__PURE__ */ c(
|
|
1990
|
+
Se,
|
|
1991
|
+
{
|
|
1992
|
+
size: "sm",
|
|
1993
|
+
width: "auto",
|
|
1994
|
+
"aria-label": `Access level for ${d}`,
|
|
1995
|
+
value: I.level,
|
|
1996
|
+
disabled: S,
|
|
1997
|
+
onChange: (w) => me(I.userId, w.target.value),
|
|
1998
|
+
children: [
|
|
1999
|
+
/* @__PURE__ */ s("option", { value: "viewer", children: ae }),
|
|
2000
|
+
/* @__PURE__ */ s("option", { value: "editor", children: _ })
|
|
2001
|
+
]
|
|
2002
|
+
}
|
|
2003
|
+
),
|
|
2004
|
+
/* @__PURE__ */ s(
|
|
2005
|
+
_e,
|
|
2006
|
+
{
|
|
2007
|
+
variant: "ghost",
|
|
2008
|
+
size: "sm",
|
|
2009
|
+
"aria-label": `Revoke access for ${d}`,
|
|
2010
|
+
disabled: S,
|
|
2011
|
+
onClick: () => Z(I.userId),
|
|
2012
|
+
children: /* @__PURE__ */ s(rs, { size: 14 })
|
|
2013
|
+
}
|
|
2014
|
+
)
|
|
2015
|
+
] }, I.userId);
|
|
2016
|
+
})
|
|
2017
|
+
] }),
|
|
2018
|
+
/* @__PURE__ */ c(J, { gap: "2", align: "center", children: [
|
|
2019
|
+
/* @__PURE__ */ s(F, { flex: "1", minW: "0", children: /* @__PURE__ */ s(
|
|
2020
|
+
Se,
|
|
2021
|
+
{
|
|
2022
|
+
size: "sm",
|
|
2023
|
+
"aria-label": "Add a person",
|
|
2024
|
+
placeholder: e.addPersonLabel ?? "Add a person…",
|
|
2025
|
+
value: l,
|
|
2026
|
+
disabled: v.isLoading,
|
|
2027
|
+
onChange: (I) => u(I.target.value),
|
|
2028
|
+
children: R.map((I) => /* @__PURE__ */ s("option", { value: I.id, children: I.displayName }, I.id))
|
|
2029
|
+
}
|
|
2030
|
+
) }),
|
|
2031
|
+
/* @__PURE__ */ c(
|
|
2032
|
+
Se,
|
|
2033
|
+
{
|
|
2034
|
+
size: "sm",
|
|
2035
|
+
width: "auto",
|
|
2036
|
+
"aria-label": "Access level",
|
|
2037
|
+
value: y,
|
|
2038
|
+
onChange: (I) => h(I.target.value),
|
|
2039
|
+
children: [
|
|
2040
|
+
/* @__PURE__ */ s("option", { value: "viewer", children: ae }),
|
|
2041
|
+
/* @__PURE__ */ s("option", { value: "editor", children: _ })
|
|
2042
|
+
]
|
|
2043
|
+
}
|
|
2044
|
+
),
|
|
2045
|
+
/* @__PURE__ */ s(
|
|
2046
|
+
Y,
|
|
2047
|
+
{
|
|
2048
|
+
variant: "solid",
|
|
2049
|
+
colorPalette: "primary",
|
|
2050
|
+
disabled: !l,
|
|
2051
|
+
loading: x.isPending,
|
|
2052
|
+
onClick: te,
|
|
2053
|
+
children: e.grantLabel ?? "Grant access"
|
|
2054
|
+
}
|
|
2055
|
+
)
|
|
2056
|
+
] })
|
|
2057
|
+
] }) : null;
|
|
2058
|
+
}
|
|
2059
|
+
return /* @__PURE__ */ s(
|
|
2060
|
+
Ae,
|
|
2061
|
+
{
|
|
2062
|
+
open: t,
|
|
2063
|
+
lazyMount: !0,
|
|
2064
|
+
unmountOnExit: !0,
|
|
2065
|
+
onClose: () => n(!1),
|
|
2066
|
+
size: "md",
|
|
2067
|
+
header: e.headerLabel ?? `Manage access to "${xi(i)}"`,
|
|
2068
|
+
footer: /* @__PURE__ */ s(J, { gap: "2", justify: "flex-end", children: /* @__PURE__ */ s(Y, { variant: "outline", onClick: () => n(!1), children: e.doneLabel ?? "Done" }) }),
|
|
2069
|
+
children: ne()
|
|
2070
|
+
}
|
|
2071
|
+
);
|
|
2072
|
+
}
|
|
2073
|
+
It.displayName = "ManageAccessDialog";
|
|
2074
|
+
function Fi(e) {
|
|
2075
|
+
return e.kind === "folder" ? e.folder.name : e.asset.name;
|
|
2076
|
+
}
|
|
2077
|
+
function An(e) {
|
|
2078
|
+
return e.kind === "folder" ? e.folder.parentId : e.asset.folderId;
|
|
2079
|
+
}
|
|
2080
|
+
function Li(e, t, n) {
|
|
2081
|
+
return e.subject.kind === "folder" && t.id === e.subject.folder.id ? e.selfLocationLabel : t.id === An(e.subject) ? e.currentLocationLabel : e.guardActive && n ? e.blockedLabel : null;
|
|
2082
|
+
}
|
|
2083
|
+
function Tn({
|
|
2084
|
+
name: e,
|
|
2085
|
+
reason: t,
|
|
2086
|
+
selected: n,
|
|
2087
|
+
restricted: i,
|
|
2088
|
+
emphasized: r,
|
|
2089
|
+
onClick: o
|
|
2090
|
+
}) {
|
|
2091
|
+
return /* @__PURE__ */ s(
|
|
2092
|
+
F,
|
|
2093
|
+
{
|
|
2094
|
+
asChild: !0,
|
|
2095
|
+
flex: "1",
|
|
2096
|
+
px: "2",
|
|
2097
|
+
py: "1",
|
|
2098
|
+
rounded: "md",
|
|
2099
|
+
textAlign: "left",
|
|
2100
|
+
cursor: t ? "not-allowed" : "pointer",
|
|
2101
|
+
opacity: t ? 0.5 : 1,
|
|
2102
|
+
bg: n ? "colorPalette.subtle" : "transparent",
|
|
2103
|
+
color: n ? "colorPalette.fg" : "fg.default",
|
|
2104
|
+
colorPalette: "primary",
|
|
2105
|
+
_hover: { bg: n ? "colorPalette.subtle" : "bg.muted" },
|
|
2106
|
+
children: /* @__PURE__ */ c("button", { type: "button", disabled: !!t, onClick: o, children: [
|
|
2107
|
+
/* @__PURE__ */ c(J, { gap: "2", align: "center", children: [
|
|
2108
|
+
i ? /* @__PURE__ */ s($e, { size: 13 }) : /* @__PURE__ */ s(as, { size: 13 }),
|
|
2109
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", fontWeight: r ? "medium" : "normal", children: e })
|
|
2110
|
+
] }),
|
|
2111
|
+
t && /* @__PURE__ */ s(L, { fontSize: "xs", color: "fg.muted", children: t })
|
|
2112
|
+
] })
|
|
2113
|
+
}
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
function kn({
|
|
2117
|
+
ctx: e,
|
|
2118
|
+
folder: t,
|
|
2119
|
+
ancestorRestricted: n,
|
|
2120
|
+
level: i
|
|
2121
|
+
}) {
|
|
2122
|
+
var p;
|
|
2123
|
+
const [r, o] = D(!1), a = wt(t.id, { enabled: r }), l = n || t.restricted, u = Li(e, t, l), y = e.subject.kind === "folder" && t.id === e.subject.folder.id, h = e.selectedId === t.id, { onDeselect: f } = e;
|
|
2124
|
+
return le(() => {
|
|
2125
|
+
h && u && f(t.id);
|
|
2126
|
+
}, [h, u, t.id, f]), /* @__PURE__ */ c(Vn, { children: [
|
|
2127
|
+
/* @__PURE__ */ c(P, { align: "center", gap: "1", pl: i * 4, children: [
|
|
2128
|
+
y ? /* @__PURE__ */ s(F, { w: "6" }) : /* @__PURE__ */ s(
|
|
2129
|
+
_e,
|
|
2130
|
+
{
|
|
2131
|
+
variant: "ghost",
|
|
2132
|
+
size: "xs",
|
|
2133
|
+
"aria-label": r ? `Collapse "${t.name}"` : `Expand "${t.name}"`,
|
|
2134
|
+
onClick: () => o((T) => !T),
|
|
2135
|
+
children: r ? /* @__PURE__ */ s(os, { size: 14 }) : /* @__PURE__ */ s(ls, { size: 14 })
|
|
2136
|
+
}
|
|
2137
|
+
),
|
|
2138
|
+
/* @__PURE__ */ s(
|
|
2139
|
+
Tn,
|
|
2140
|
+
{
|
|
2141
|
+
name: t.name,
|
|
2142
|
+
reason: u,
|
|
2143
|
+
selected: h,
|
|
2144
|
+
restricted: t.restricted,
|
|
2145
|
+
onClick: () => e.onSelect(t.id)
|
|
2146
|
+
}
|
|
2147
|
+
)
|
|
2148
|
+
] }),
|
|
2149
|
+
r && a.isLoading && /* @__PURE__ */ s(P, { justify: "center", py: "1", children: /* @__PURE__ */ s(be, { size: "xs" }) }),
|
|
2150
|
+
r && ((p = a.data) == null ? void 0 : p.map((T) => /* @__PURE__ */ s(
|
|
2151
|
+
kn,
|
|
2152
|
+
{
|
|
2153
|
+
ctx: e,
|
|
2154
|
+
folder: T,
|
|
2155
|
+
ancestorRestricted: l,
|
|
2156
|
+
level: i + 1
|
|
2157
|
+
},
|
|
2158
|
+
T.id
|
|
2159
|
+
)))
|
|
2160
|
+
] });
|
|
2161
|
+
}
|
|
2162
|
+
function At(e) {
|
|
2163
|
+
const { open: t, onOpenChange: n, subject: i, onMoved: r } = e, o = V(), a = g(), [l, u] = D(null), y = wt(""), h = Re(), f = h.data ?? [], p = W(() => In(f), [f]), T = mi(), v = ai(), A = i.kind === "folder" ? i.folder.id : "", k = O({
|
|
2164
|
+
queryKey: ["mediahub", "move-guard", A, p],
|
|
2165
|
+
queryFn: async () => i.kind !== "folder" || await ct(a.folders, i.folder) ? !1 : Ti(
|
|
2166
|
+
{ folders: a.folders, assets: a.assets },
|
|
2167
|
+
o,
|
|
2168
|
+
i.folder.id,
|
|
2169
|
+
p
|
|
2170
|
+
),
|
|
2171
|
+
enabled: t && i.kind === "folder" && h.isSuccess
|
|
2172
|
+
}), U = i.kind === "asset" ? Ai(i.asset, f) : k.data === !0;
|
|
2173
|
+
function E() {
|
|
2174
|
+
u(null);
|
|
2175
|
+
}
|
|
2176
|
+
le(() => {
|
|
2177
|
+
t && E();
|
|
2178
|
+
}, [t]);
|
|
2179
|
+
async function q() {
|
|
2180
|
+
if (l !== null)
|
|
2181
|
+
try {
|
|
2182
|
+
i.kind === "folder" ? await T.mutateAsync({
|
|
2183
|
+
id: i.folder.id,
|
|
2184
|
+
parentId: l
|
|
2185
|
+
}) : await v.mutateAsync({
|
|
2186
|
+
id: i.asset.id,
|
|
2187
|
+
folderId: l
|
|
2188
|
+
}), B.success({
|
|
2189
|
+
title: i.kind === "folder" ? "Folder moved" : "Asset moved"
|
|
2190
|
+
}), r == null || r(l), n(!1);
|
|
2191
|
+
} catch (R) {
|
|
2192
|
+
M(R, "Move failed");
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
const x = re((R) => {
|
|
2196
|
+
u(($) => $ === R ? null : $);
|
|
2197
|
+
}, []), Q = {
|
|
2198
|
+
subject: i,
|
|
2199
|
+
guardActive: U,
|
|
2200
|
+
selectedId: l,
|
|
2201
|
+
onSelect: u,
|
|
2202
|
+
onDeselect: x,
|
|
2203
|
+
currentLocationLabel: e.currentLocationLabel ?? "Current location",
|
|
2204
|
+
selfLocationLabel: e.selfLocationLabel ?? "You can't move a folder into itself",
|
|
2205
|
+
blockedLabel: e.blockedLabel ?? (i.kind === "asset" ? "Blocked: an open collection still exposes this asset" : `Blocked: an open collection still exposes an asset in "${i.folder.name}"`)
|
|
2206
|
+
}, S = An(i) === "" ? Q.currentLocationLabel : null, G = T.isPending || v.isPending;
|
|
2207
|
+
return /* @__PURE__ */ s(
|
|
2208
|
+
Ae,
|
|
2209
|
+
{
|
|
2210
|
+
open: t,
|
|
2211
|
+
lazyMount: !0,
|
|
2212
|
+
unmountOnExit: !0,
|
|
2213
|
+
onExitComplete: E,
|
|
2214
|
+
onClose: () => n(!1),
|
|
2215
|
+
size: "md",
|
|
2216
|
+
header: e.headerLabel ?? `Move "${Fi(i)}"`,
|
|
2217
|
+
footer: /* @__PURE__ */ c(J, { gap: "2", justify: "flex-end", children: [
|
|
2218
|
+
/* @__PURE__ */ s(Y, { variant: "outline", onClick: () => n(!1), children: e.cancelLabel ?? "Cancel" }),
|
|
2219
|
+
/* @__PURE__ */ s(
|
|
2220
|
+
Y,
|
|
2221
|
+
{
|
|
2222
|
+
variant: "solid",
|
|
2223
|
+
colorPalette: "primary",
|
|
2224
|
+
disabled: l === null,
|
|
2225
|
+
loading: G,
|
|
2226
|
+
onClick: q,
|
|
2227
|
+
children: e.confirmLabel ?? "Move here"
|
|
2228
|
+
}
|
|
2229
|
+
)
|
|
2230
|
+
] }),
|
|
2231
|
+
children: /* @__PURE__ */ c(P, { direction: "column", gap: "0.5", minH: "240px", children: [
|
|
2232
|
+
/* @__PURE__ */ c(P, { align: "center", gap: "1", children: [
|
|
2233
|
+
/* @__PURE__ */ s(F, { w: "6" }),
|
|
2234
|
+
/* @__PURE__ */ s(
|
|
2235
|
+
Tn,
|
|
2236
|
+
{
|
|
2237
|
+
name: e.rootLabel ?? "All Assets",
|
|
2238
|
+
reason: S,
|
|
2239
|
+
selected: l === "",
|
|
2240
|
+
emphasized: !0,
|
|
2241
|
+
onClick: () => u("")
|
|
2242
|
+
}
|
|
2243
|
+
)
|
|
2244
|
+
] }),
|
|
2245
|
+
y.isLoading ? /* @__PURE__ */ s(P, { justify: "center", py: "6", children: /* @__PURE__ */ s(be, {}) }) : (y.data ?? []).map((R) => /* @__PURE__ */ s(
|
|
2246
|
+
kn,
|
|
2247
|
+
{
|
|
2248
|
+
ctx: Q,
|
|
2249
|
+
folder: R,
|
|
2250
|
+
ancestorRestricted: !1,
|
|
2251
|
+
level: 0
|
|
2252
|
+
},
|
|
2253
|
+
R.id
|
|
2254
|
+
))
|
|
2255
|
+
] })
|
|
2256
|
+
}
|
|
2257
|
+
);
|
|
2258
|
+
}
|
|
2259
|
+
At.displayName = "MoveDialog";
|
|
2260
|
+
function zi(e) {
|
|
2261
|
+
return `This ${e} starts creator-only — no one else can see it or anything inside it until you grant access.`;
|
|
2262
|
+
}
|
|
2263
|
+
function Ri(e, t) {
|
|
2264
|
+
return `Unrestrict "${t}"? All workspace members will gain view access to this ${e} and ${e === "folder" ? "everything inside it" : "every asset it contains"}.`;
|
|
2265
|
+
}
|
|
2266
|
+
const Tt = ({
|
|
2267
|
+
size: e = 12,
|
|
2268
|
+
ml: t
|
|
2269
|
+
}) => /* @__PURE__ */ s(
|
|
2270
|
+
F,
|
|
2271
|
+
{
|
|
2272
|
+
role: "img",
|
|
2273
|
+
"aria-label": "Restricted",
|
|
2274
|
+
color: "fg.muted",
|
|
2275
|
+
flexShrink: 0,
|
|
2276
|
+
ml: t,
|
|
2277
|
+
children: /* @__PURE__ */ s($e, { size: e })
|
|
2278
|
+
}
|
|
2279
|
+
);
|
|
2280
|
+
Tt.displayName = "RestrictedLockBadge";
|
|
2281
|
+
const xn = ({ kind: e }) => /* @__PURE__ */ c(
|
|
2282
|
+
P,
|
|
2283
|
+
{
|
|
2284
|
+
gap: 2,
|
|
2285
|
+
p: 3,
|
|
2286
|
+
rounded: "md",
|
|
2287
|
+
bg: "bg.muted",
|
|
2288
|
+
color: "fg.muted",
|
|
2289
|
+
fontSize: "sm",
|
|
2290
|
+
align: "flex-start",
|
|
2291
|
+
children: [
|
|
2292
|
+
/* @__PURE__ */ s(F, { flexShrink: 0, mt: 0.5, children: /* @__PURE__ */ s($e, { size: 14 }) }),
|
|
2293
|
+
/* @__PURE__ */ s(L, { children: zi(e) })
|
|
2294
|
+
]
|
|
2295
|
+
}
|
|
2296
|
+
);
|
|
2297
|
+
xn.displayName = "RestrictedWarningNotice";
|
|
2298
|
+
const Fn = ({
|
|
2299
|
+
open: e,
|
|
2300
|
+
onClose: t,
|
|
2301
|
+
parentId: n,
|
|
2302
|
+
onCreated: i
|
|
2303
|
+
}) => {
|
|
2304
|
+
const [r, o] = D(""), a = an();
|
|
2305
|
+
le(() => {
|
|
2306
|
+
e && o("");
|
|
2307
|
+
}, [e]);
|
|
2308
|
+
async function l() {
|
|
2309
|
+
const u = r.trim();
|
|
2310
|
+
if (u)
|
|
2311
|
+
try {
|
|
2312
|
+
await a.mutateAsync({
|
|
2313
|
+
name: u,
|
|
2314
|
+
slug: u.toLowerCase().replace(/\s+/g, "-"),
|
|
2315
|
+
parentId: n,
|
|
2316
|
+
restricted: !0
|
|
2317
|
+
}), B.success({ title: "Restricted folder created" }), i == null || i(), t();
|
|
2318
|
+
} catch (y) {
|
|
2319
|
+
const h = y instanceof Error ? y.message : String(y);
|
|
2320
|
+
B.error({ title: "Create failed", description: h });
|
|
2321
|
+
}
|
|
2322
|
+
}
|
|
2323
|
+
return /* @__PURE__ */ s(
|
|
2324
|
+
Ae,
|
|
2325
|
+
{
|
|
2326
|
+
open: e,
|
|
2327
|
+
lazyMount: !0,
|
|
2328
|
+
unmountOnExit: !0,
|
|
2329
|
+
onClose: t,
|
|
2330
|
+
header: "New Restricted folder",
|
|
2331
|
+
onSave: l,
|
|
2332
|
+
saveLabel: "Create",
|
|
2333
|
+
saveDisabled: !r.trim(),
|
|
2334
|
+
loading: a.isPending,
|
|
2335
|
+
children: /* @__PURE__ */ c(P, { direction: "column", gap: 3, children: [
|
|
2336
|
+
/* @__PURE__ */ s(xn, { kind: "folder" }),
|
|
2337
|
+
/* @__PURE__ */ s(
|
|
2338
|
+
We,
|
|
2339
|
+
{
|
|
2340
|
+
value: r,
|
|
2341
|
+
onChange: (u) => o(u.target.value),
|
|
2342
|
+
onKeyDown: (u) => {
|
|
2343
|
+
u.key === "Enter" && l();
|
|
2344
|
+
},
|
|
2345
|
+
autoFocus: !0,
|
|
2346
|
+
placeholder: "Folder name"
|
|
2347
|
+
}
|
|
2348
|
+
)
|
|
2349
|
+
] })
|
|
2350
|
+
}
|
|
2351
|
+
);
|
|
2352
|
+
};
|
|
2353
|
+
Fn.displayName = "RestrictedFolderDialog";
|
|
2354
|
+
const kt = ({
|
|
2355
|
+
activeFolderId: e,
|
|
2356
|
+
onFolderSelect: t
|
|
2357
|
+
}) => {
|
|
2358
|
+
const n = V(), r = wt("").data ?? [], [o, a] = D(0), [l, u] = D(!1), [y, h] = D(""), [f, p] = D(null), [T, v] = D(""), [A, k] = D(null), [U, E] = D(!1), [q, x] = D(null), [Q, S] = D(!1), [G, R] = D(
|
|
2359
|
+
null
|
|
2360
|
+
), [$, H] = D(""), [te, me] = D(null), [Z, ae] = D(!1), _ = an(), ne = di(), I = ui(), d = fi(), w = ci("folder", $), { confirm: X } = je(), se = Ie(!1), ve = Ie(!1), { folders: Fe } = g(), He = W(() => {
|
|
2361
|
+
const C = r.map((b) => ({
|
|
2362
|
+
id: b.id,
|
|
2363
|
+
name: b.name,
|
|
2364
|
+
restricted: b.restricted,
|
|
2365
|
+
children: [],
|
|
2366
|
+
info: b
|
|
2367
|
+
}));
|
|
2368
|
+
return Zn({
|
|
2369
|
+
rootNode: {
|
|
2370
|
+
id: "root",
|
|
2371
|
+
name: "Root",
|
|
2372
|
+
restricted: !1,
|
|
2373
|
+
children: C
|
|
2374
|
+
},
|
|
2375
|
+
nodeToValue: (b) => b.id,
|
|
2376
|
+
nodeToString: (b) => b.name,
|
|
2377
|
+
// Return 1 for empty children so all folders are treated as branches
|
|
2378
|
+
// (expandable) even before their children are lazy-loaded.
|
|
2379
|
+
nodeToChildrenCount: (b) => b.children.length > 0 ? b.children.length : 1
|
|
2380
|
+
});
|
|
2381
|
+
}, [r]), Ye = re(
|
|
2382
|
+
async ({ node: C }) => (await Fe.list(n, C.id)).map(
|
|
2383
|
+
(j) => ({
|
|
2384
|
+
id: j.id,
|
|
2385
|
+
name: j.name,
|
|
2386
|
+
restricted: j.restricted,
|
|
2387
|
+
children: [],
|
|
2388
|
+
info: j
|
|
2389
|
+
})
|
|
2390
|
+
),
|
|
2391
|
+
[Fe, n]
|
|
2392
|
+
);
|
|
2393
|
+
async function Je(C, b) {
|
|
2394
|
+
if (await X({
|
|
2395
|
+
title: "Delete Folder",
|
|
2396
|
+
message: `Delete "${b}"? This cannot be undone.`,
|
|
2397
|
+
confirmLabel: "Delete"
|
|
2398
|
+
}))
|
|
2399
|
+
try {
|
|
2400
|
+
await I.mutateAsync(C), e === C && t(""), a((m) => m + 1), B.success({ title: "Folder deleted" });
|
|
2401
|
+
} catch (m) {
|
|
2402
|
+
M(m, "Delete failed");
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
async function fe(C) {
|
|
2406
|
+
if (ve.current) return;
|
|
2407
|
+
const b = T.trim();
|
|
2408
|
+
if (!b || b === C.name) {
|
|
2409
|
+
p(null);
|
|
2410
|
+
return;
|
|
2411
|
+
}
|
|
2412
|
+
ve.current = !0;
|
|
2413
|
+
try {
|
|
2414
|
+
await ne.mutateAsync({ id: C.id, name: b }), p(null), a((j) => j + 1), B.success({ title: "Folder renamed" });
|
|
2415
|
+
} catch (j) {
|
|
2416
|
+
M(j, "Rename failed");
|
|
2417
|
+
} finally {
|
|
2418
|
+
ve.current = !1;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
async function Ze(C) {
|
|
2422
|
+
const b = !C.restricted;
|
|
2423
|
+
if (!(!b && !await X({
|
|
2424
|
+
title: "Unrestrict Folder",
|
|
2425
|
+
message: Ri("folder", C.name),
|
|
2426
|
+
confirmLabel: "Unrestrict"
|
|
2427
|
+
})))
|
|
2428
|
+
try {
|
|
2429
|
+
await d.mutateAsync({
|
|
2430
|
+
id: C.id,
|
|
2431
|
+
restricted: b
|
|
2432
|
+
}), a((j) => j + 1), B.success({
|
|
2433
|
+
title: b ? "Folder restricted" : "Folder unrestricted"
|
|
2434
|
+
});
|
|
2435
|
+
} catch (j) {
|
|
2436
|
+
const m = b ? "Restrict failed" : "Unrestrict failed", K = he(j, m);
|
|
2437
|
+
K.kind === "leak-guard" ? (me(K), ae(!0)) : M(j, m);
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
async function qe() {
|
|
2441
|
+
if (se.current) return;
|
|
2442
|
+
const C = y.trim();
|
|
2443
|
+
if (!C) {
|
|
2444
|
+
u(!1);
|
|
2445
|
+
return;
|
|
2446
|
+
}
|
|
2447
|
+
se.current = !0;
|
|
2448
|
+
try {
|
|
2449
|
+
await _.mutateAsync({
|
|
2450
|
+
name: C,
|
|
2451
|
+
slug: C.toLowerCase().replace(/\s+/g, "-"),
|
|
2452
|
+
parentId: e || ""
|
|
2453
|
+
}), h(""), u(!1), a((b) => b + 1), B.success({ title: "Folder created" });
|
|
2454
|
+
} catch (b) {
|
|
2455
|
+
M(b, "Error");
|
|
2456
|
+
} finally {
|
|
2457
|
+
se.current = !1;
|
|
2458
|
+
}
|
|
2459
|
+
}
|
|
2460
|
+
return /* @__PURE__ */ c(P, { direction: "column", flex: 1, gap: 0.5, children: [
|
|
2461
|
+
/* @__PURE__ */ c(
|
|
2462
|
+
P,
|
|
2463
|
+
{
|
|
2464
|
+
align: "center",
|
|
2465
|
+
px: 2,
|
|
2466
|
+
py: 1,
|
|
2467
|
+
rounded: "md",
|
|
2468
|
+
cursor: "pointer",
|
|
2469
|
+
bg: e ? "transparent" : "colorPalette.subtle",
|
|
2470
|
+
color: e ? "fg.default" : "colorPalette.fg",
|
|
2471
|
+
colorPalette: "primary",
|
|
2472
|
+
_hover: {
|
|
2473
|
+
bg: e ? "bg.muted" : "colorPalette.subtle"
|
|
2474
|
+
},
|
|
2475
|
+
onClick: () => t(""),
|
|
2476
|
+
fontSize: "sm",
|
|
2477
|
+
fontWeight: "medium",
|
|
2478
|
+
css: {
|
|
2479
|
+
"& > [data-folder-menu]": { opacity: 0 },
|
|
2480
|
+
"&:hover > [data-folder-menu]": { opacity: 1 }
|
|
2481
|
+
},
|
|
2482
|
+
children: [
|
|
2483
|
+
"All Assets",
|
|
2484
|
+
/* @__PURE__ */ s(F, { "data-folder-menu": "", transition: "opacity 0.1s", ml: "auto", children: /* @__PURE__ */ c(st, { children: [
|
|
2485
|
+
/* @__PURE__ */ s(it, { asChild: !0, children: /* @__PURE__ */ s(
|
|
2486
|
+
F,
|
|
2487
|
+
{
|
|
2488
|
+
asChild: !0,
|
|
2489
|
+
cursor: "pointer",
|
|
2490
|
+
color: "fg.muted",
|
|
2491
|
+
_hover: { color: "fg.default" },
|
|
2492
|
+
children: /* @__PURE__ */ s(
|
|
2493
|
+
"button",
|
|
2494
|
+
{
|
|
2495
|
+
type: "button",
|
|
2496
|
+
"aria-label": "Actions for All Assets",
|
|
2497
|
+
onClick: (C) => C.stopPropagation(),
|
|
2498
|
+
children: /* @__PURE__ */ s(ot, { size: 12 })
|
|
2499
|
+
}
|
|
2500
|
+
)
|
|
2501
|
+
}
|
|
2502
|
+
) }),
|
|
2503
|
+
/* @__PURE__ */ s(rt, { children: /* @__PURE__ */ s(
|
|
2504
|
+
de,
|
|
2505
|
+
{
|
|
2506
|
+
value: "new-restricted",
|
|
2507
|
+
onClick: (C) => {
|
|
2508
|
+
C.stopPropagation(), R("");
|
|
2509
|
+
},
|
|
2510
|
+
children: "New Restricted folder…"
|
|
2511
|
+
}
|
|
2512
|
+
) })
|
|
2513
|
+
] }) })
|
|
2514
|
+
]
|
|
2515
|
+
}
|
|
2516
|
+
),
|
|
2517
|
+
r.length > 0 && /* @__PURE__ */ s(
|
|
2518
|
+
Xn,
|
|
2519
|
+
{
|
|
2520
|
+
collection: He,
|
|
2521
|
+
selectedValue: e ? [e] : [],
|
|
2522
|
+
onSelectionChange: (C) => {
|
|
2523
|
+
const b = C.selectedValue[0];
|
|
2524
|
+
b && t(b);
|
|
2525
|
+
},
|
|
2526
|
+
loadChildren: Ye,
|
|
2527
|
+
size: "sm",
|
|
2528
|
+
children: /* @__PURE__ */ s(es, { children: /* @__PURE__ */ s(
|
|
2529
|
+
ts,
|
|
2530
|
+
{
|
|
2531
|
+
render: ({ node: C }) => f === C.id ? /* @__PURE__ */ c(qt, { children: [
|
|
2532
|
+
/* @__PURE__ */ s(Nt, {}),
|
|
2533
|
+
/* @__PURE__ */ s(
|
|
2534
|
+
F,
|
|
2535
|
+
{
|
|
2536
|
+
flex: "1",
|
|
2537
|
+
onClick: (b) => b.stopPropagation(),
|
|
2538
|
+
onKeyDown: (b) => b.stopPropagation(),
|
|
2539
|
+
children: /* @__PURE__ */ s(
|
|
2540
|
+
We,
|
|
2541
|
+
{
|
|
2542
|
+
value: T,
|
|
2543
|
+
onChange: (b) => v(b.target.value),
|
|
2544
|
+
onKeyDown: (b) => {
|
|
2545
|
+
b.key === "Enter" && fe(C), b.key === "Escape" && p(null);
|
|
2546
|
+
},
|
|
2547
|
+
onBlur: () => fe(C),
|
|
2548
|
+
autoFocus: !0,
|
|
2549
|
+
size: "sm"
|
|
2550
|
+
}
|
|
2551
|
+
)
|
|
2552
|
+
}
|
|
2553
|
+
)
|
|
2554
|
+
] }) : /* @__PURE__ */ c(
|
|
2555
|
+
qt,
|
|
2556
|
+
{
|
|
2557
|
+
css: {
|
|
2558
|
+
"& > [data-folder-menu]": {
|
|
2559
|
+
opacity: 0
|
|
2560
|
+
},
|
|
2561
|
+
"&:hover > [data-folder-menu]": {
|
|
2562
|
+
opacity: 1
|
|
2563
|
+
}
|
|
2564
|
+
},
|
|
2565
|
+
children: [
|
|
2566
|
+
/* @__PURE__ */ s(Nt, {}),
|
|
2567
|
+
/* @__PURE__ */ s(ns, { children: C.name }),
|
|
2568
|
+
C.restricted && /* @__PURE__ */ s(Tt, { ml: 1 }),
|
|
2569
|
+
/* @__PURE__ */ s(
|
|
2570
|
+
F,
|
|
2571
|
+
{
|
|
2572
|
+
"data-folder-menu": "",
|
|
2573
|
+
transition: "opacity 0.1s",
|
|
2574
|
+
ml: "auto",
|
|
2575
|
+
children: /* @__PURE__ */ c(
|
|
2576
|
+
st,
|
|
2577
|
+
{
|
|
2578
|
+
onOpenChange: ({ open: b }) => {
|
|
2579
|
+
b && H(C.id);
|
|
2580
|
+
},
|
|
2581
|
+
children: [
|
|
2582
|
+
/* @__PURE__ */ s(it, { asChild: !0, children: /* @__PURE__ */ s(
|
|
2583
|
+
F,
|
|
2584
|
+
{
|
|
2585
|
+
asChild: !0,
|
|
2586
|
+
cursor: "pointer",
|
|
2587
|
+
color: "fg.muted",
|
|
2588
|
+
_hover: {
|
|
2589
|
+
color: "fg.default"
|
|
2590
|
+
},
|
|
2591
|
+
children: /* @__PURE__ */ s(
|
|
2592
|
+
"button",
|
|
2593
|
+
{
|
|
2594
|
+
type: "button",
|
|
2595
|
+
"aria-label": `Actions for ${C.name}`,
|
|
2596
|
+
onClick: (b) => b.stopPropagation(),
|
|
2597
|
+
children: /* @__PURE__ */ s(ot, { size: 12 })
|
|
2598
|
+
}
|
|
2599
|
+
)
|
|
2600
|
+
}
|
|
2601
|
+
) }),
|
|
2602
|
+
/* @__PURE__ */ c(rt, { children: [
|
|
2603
|
+
/* @__PURE__ */ s(
|
|
2604
|
+
de,
|
|
2605
|
+
{
|
|
2606
|
+
value: "rename",
|
|
2607
|
+
onClick: (b) => {
|
|
2608
|
+
b.stopPropagation(), v(C.name), p(C.id);
|
|
2609
|
+
},
|
|
2610
|
+
children: "Rename"
|
|
2611
|
+
}
|
|
2612
|
+
),
|
|
2613
|
+
/* @__PURE__ */ s(
|
|
2614
|
+
de,
|
|
2615
|
+
{
|
|
2616
|
+
value: "move",
|
|
2617
|
+
onClick: (b) => {
|
|
2618
|
+
b.stopPropagation(), C.info && (k(C.info), E(!0));
|
|
2619
|
+
},
|
|
2620
|
+
children: "Move…"
|
|
2621
|
+
}
|
|
2622
|
+
),
|
|
2623
|
+
/* @__PURE__ */ s(
|
|
2624
|
+
de,
|
|
2625
|
+
{
|
|
2626
|
+
value: "manage-access",
|
|
2627
|
+
onClick: (b) => {
|
|
2628
|
+
b.stopPropagation(), C.info && (x(C.info), S(!0));
|
|
2629
|
+
},
|
|
2630
|
+
children: "Manage access…"
|
|
2631
|
+
}
|
|
2632
|
+
),
|
|
2633
|
+
/* @__PURE__ */ s(
|
|
2634
|
+
de,
|
|
2635
|
+
{
|
|
2636
|
+
value: "new-restricted",
|
|
2637
|
+
onClick: (b) => {
|
|
2638
|
+
b.stopPropagation(), R(C.id);
|
|
2639
|
+
},
|
|
2640
|
+
children: "New Restricted folder…"
|
|
2641
|
+
}
|
|
2642
|
+
),
|
|
2643
|
+
$ === C.id && w.data === !0 && /* @__PURE__ */ s(
|
|
2644
|
+
de,
|
|
2645
|
+
{
|
|
2646
|
+
value: "toggle-restricted",
|
|
2647
|
+
onClick: (b) => {
|
|
2648
|
+
b.stopPropagation(), Ze(C);
|
|
2649
|
+
},
|
|
2650
|
+
children: C.restricted ? "Unrestrict" : "Restrict"
|
|
2651
|
+
}
|
|
2652
|
+
),
|
|
2653
|
+
/* @__PURE__ */ s(
|
|
2654
|
+
de,
|
|
2655
|
+
{
|
|
2656
|
+
value: "delete",
|
|
2657
|
+
color: "fg.error",
|
|
2658
|
+
onClick: (b) => {
|
|
2659
|
+
b.stopPropagation(), Je(C.id, C.name);
|
|
2660
|
+
},
|
|
2661
|
+
children: "Delete"
|
|
2662
|
+
}
|
|
2663
|
+
)
|
|
2664
|
+
] })
|
|
2665
|
+
]
|
|
2666
|
+
}
|
|
2667
|
+
)
|
|
2668
|
+
}
|
|
2669
|
+
)
|
|
2670
|
+
]
|
|
2671
|
+
}
|
|
2672
|
+
)
|
|
2673
|
+
}
|
|
2674
|
+
) })
|
|
2675
|
+
},
|
|
2676
|
+
o
|
|
2677
|
+
),
|
|
2678
|
+
/* @__PURE__ */ s(F, { flex: 1 }),
|
|
2679
|
+
l ? /* @__PURE__ */ s(F, { px: 2, py: 1, children: /* @__PURE__ */ s(
|
|
2680
|
+
We,
|
|
2681
|
+
{
|
|
2682
|
+
value: y,
|
|
2683
|
+
onChange: (C) => h(C.target.value),
|
|
2684
|
+
onKeyDown: (C) => {
|
|
2685
|
+
C.key === "Enter" && qe(), C.key === "Escape" && (u(!1), h(""));
|
|
2686
|
+
},
|
|
2687
|
+
onBlur: qe,
|
|
2688
|
+
autoFocus: !0,
|
|
2689
|
+
placeholder: "Folder name",
|
|
2690
|
+
size: "sm"
|
|
2691
|
+
}
|
|
2692
|
+
) }) : /* @__PURE__ */ c(
|
|
2693
|
+
P,
|
|
2694
|
+
{
|
|
2695
|
+
align: "center",
|
|
2696
|
+
gap: 1,
|
|
2697
|
+
px: 2,
|
|
2698
|
+
py: 1,
|
|
2699
|
+
rounded: "md",
|
|
2700
|
+
cursor: "pointer",
|
|
2701
|
+
color: "fg.muted",
|
|
2702
|
+
_hover: { bg: "bg.muted" },
|
|
2703
|
+
onClick: () => u(!0),
|
|
2704
|
+
fontSize: "sm",
|
|
2705
|
+
children: [
|
|
2706
|
+
/* @__PURE__ */ s(cs, { size: 14 }),
|
|
2707
|
+
/* @__PURE__ */ s(L, { children: "New Folder" })
|
|
2708
|
+
]
|
|
2709
|
+
}
|
|
2710
|
+
),
|
|
2711
|
+
A && /* @__PURE__ */ s(
|
|
2712
|
+
At,
|
|
2713
|
+
{
|
|
2714
|
+
open: U,
|
|
2715
|
+
onOpenChange: E,
|
|
2716
|
+
subject: { kind: "folder", folder: A },
|
|
2717
|
+
onMoved: () => a((C) => C + 1)
|
|
2718
|
+
}
|
|
2719
|
+
),
|
|
2720
|
+
q && /* @__PURE__ */ s(
|
|
2721
|
+
It,
|
|
2722
|
+
{
|
|
2723
|
+
open: Q,
|
|
2724
|
+
onOpenChange: S,
|
|
2725
|
+
subject: { kind: "folder", folder: q }
|
|
2726
|
+
}
|
|
2727
|
+
),
|
|
2728
|
+
/* @__PURE__ */ s(
|
|
2729
|
+
Fn,
|
|
2730
|
+
{
|
|
2731
|
+
open: G !== null,
|
|
2732
|
+
parentId: G ?? "",
|
|
2733
|
+
onClose: () => R(null),
|
|
2734
|
+
onCreated: () => a((C) => C + 1)
|
|
2735
|
+
}
|
|
2736
|
+
),
|
|
2737
|
+
/* @__PURE__ */ s(
|
|
2738
|
+
Cn,
|
|
2739
|
+
{
|
|
2740
|
+
refusal: te,
|
|
2741
|
+
open: Z,
|
|
2742
|
+
onClose: () => ae(!1)
|
|
2743
|
+
}
|
|
2744
|
+
)
|
|
2745
|
+
] });
|
|
2746
|
+
};
|
|
2747
|
+
kt.displayName = "FolderTree";
|
|
2748
|
+
const Di = ({
|
|
2749
|
+
value: e,
|
|
2750
|
+
onSave: t,
|
|
2751
|
+
as: n = "input",
|
|
2752
|
+
placeholder: i
|
|
2753
|
+
}) => {
|
|
2754
|
+
const [r, o] = D(!1);
|
|
2755
|
+
async function a(l) {
|
|
2756
|
+
const u = l.trim();
|
|
2757
|
+
if (u !== e) {
|
|
2758
|
+
o(!0);
|
|
2759
|
+
try {
|
|
2760
|
+
await t(u);
|
|
2761
|
+
} catch {
|
|
2762
|
+
} finally {
|
|
2763
|
+
o(!1);
|
|
2764
|
+
}
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2767
|
+
return /* @__PURE__ */ s(
|
|
2768
|
+
hs,
|
|
2769
|
+
{
|
|
2770
|
+
value: e,
|
|
2771
|
+
onSubmit: a,
|
|
2772
|
+
variant: n,
|
|
2773
|
+
placeholder: i,
|
|
2774
|
+
disabled: r,
|
|
2775
|
+
fontSize: "sm"
|
|
2776
|
+
}
|
|
2777
|
+
);
|
|
2778
|
+
};
|
|
2779
|
+
Di.displayName = "InlineEditField";
|
|
2780
|
+
const Ln = ({
|
|
2781
|
+
assetId: e,
|
|
2782
|
+
assignedTagIds: t
|
|
2783
|
+
}) => {
|
|
2784
|
+
const n = Ct(), i = n.data ?? [], r = cn(), o = vi(), a = i.filter((h) => t.includes(h.id)), l = i.filter((h) => !t.includes(h.id));
|
|
2785
|
+
async function u(h) {
|
|
2786
|
+
try {
|
|
2787
|
+
await r.mutateAsync({ tagId: h.id, assetIds: [e] });
|
|
2788
|
+
} catch (f) {
|
|
2789
|
+
M(f, "Error");
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
async function y(h) {
|
|
2793
|
+
try {
|
|
2794
|
+
await o.mutateAsync({ tagId: h.id, assetIds: [e] });
|
|
2795
|
+
} catch (f) {
|
|
2796
|
+
M(f, "Error");
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
return /* @__PURE__ */ s(
|
|
2800
|
+
_t,
|
|
2801
|
+
{
|
|
2802
|
+
assigned: a,
|
|
2803
|
+
available: l,
|
|
2804
|
+
getItemId: (h) => h.id,
|
|
2805
|
+
getItemLabel: (h) => h.name,
|
|
2806
|
+
onAdd: u,
|
|
2807
|
+
onRemove: y,
|
|
2808
|
+
addLabel: "Add tag",
|
|
2809
|
+
emptyLabel: "No tags",
|
|
2810
|
+
searchable: !0,
|
|
2811
|
+
loading: n.isLoading
|
|
2812
|
+
}
|
|
2813
|
+
);
|
|
2814
|
+
};
|
|
2815
|
+
Ln.displayName = "TagChipField";
|
|
2816
|
+
const zn = ({
|
|
2817
|
+
activeTags: e,
|
|
2818
|
+
onToggleTag: t
|
|
2819
|
+
}) => {
|
|
2820
|
+
const i = Ct().data ?? [], r = bi();
|
|
2821
|
+
async function o(a) {
|
|
2822
|
+
try {
|
|
2823
|
+
await r.mutateAsync({
|
|
2824
|
+
name: a,
|
|
2825
|
+
slug: a.toLowerCase().replace(/\s+/g, "-")
|
|
2826
|
+
}), B.success({ title: "Tag created" });
|
|
2827
|
+
} catch (l) {
|
|
2828
|
+
M(l, "Error");
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
return /* @__PURE__ */ s(
|
|
2832
|
+
Wt,
|
|
2833
|
+
{
|
|
2834
|
+
items: i,
|
|
2835
|
+
activeIds: e,
|
|
2836
|
+
onToggle: t,
|
|
2837
|
+
onCreate: o,
|
|
2838
|
+
getItemId: (a) => a.id,
|
|
2839
|
+
getItemLabel: (a) => a.name,
|
|
2840
|
+
variant: "wrap",
|
|
2841
|
+
createPlaceholder: "Tag name",
|
|
2842
|
+
createLabel: "Add tag",
|
|
2843
|
+
emptyText: "No tags"
|
|
2844
|
+
}
|
|
2845
|
+
);
|
|
2846
|
+
};
|
|
2847
|
+
zn.displayName = "TagPanel";
|
|
2848
|
+
function qi(e) {
|
|
2849
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
|
|
2850
|
+
}
|
|
2851
|
+
const Rn = ({ entry: e, showOverride: t, onToggleOverride: n, assetTypes: i }) => {
|
|
2852
|
+
const r = ee((o) => o.setAssetType);
|
|
2853
|
+
return /* @__PURE__ */ c(
|
|
2854
|
+
P,
|
|
2855
|
+
{
|
|
2856
|
+
py: 2.5,
|
|
2857
|
+
px: 3,
|
|
2858
|
+
align: "center",
|
|
2859
|
+
borderBottomWidth: "1px",
|
|
2860
|
+
borderColor: "border",
|
|
2861
|
+
_last: { borderBottomWidth: 0 },
|
|
2862
|
+
gap: 3,
|
|
2863
|
+
children: [
|
|
2864
|
+
/* @__PURE__ */ c(F, { flex: 1, minW: 0, children: [
|
|
2865
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", truncate: !0, children: e.file.name }),
|
|
2866
|
+
/* @__PURE__ */ s(L, { fontSize: "xs", color: "fg.muted", children: qi(e.file.size) })
|
|
2867
|
+
] }),
|
|
2868
|
+
t ? /* @__PURE__ */ c(
|
|
2869
|
+
Se,
|
|
2870
|
+
{
|
|
2871
|
+
size: "sm",
|
|
2872
|
+
value: e.assetTypeId,
|
|
2873
|
+
onChange: (o) => r(e.clientId, o.target.value),
|
|
2874
|
+
w: "160px",
|
|
2875
|
+
children: [
|
|
2876
|
+
/* @__PURE__ */ s("option", { value: "", children: "Select type..." }),
|
|
2877
|
+
i.map((o) => /* @__PURE__ */ s("option", { value: o.id, children: o.name }, o.id))
|
|
2878
|
+
]
|
|
2879
|
+
}
|
|
2880
|
+
) : /* @__PURE__ */ s(
|
|
2881
|
+
L,
|
|
2882
|
+
{
|
|
2883
|
+
fontSize: "xs",
|
|
2884
|
+
color: "colorPalette.fg",
|
|
2885
|
+
colorPalette: "primary",
|
|
2886
|
+
cursor: "pointer",
|
|
2887
|
+
_hover: { textDecoration: "underline" },
|
|
2888
|
+
onClick: n,
|
|
2889
|
+
children: "Change type"
|
|
2890
|
+
}
|
|
2891
|
+
)
|
|
2892
|
+
]
|
|
2893
|
+
}
|
|
2894
|
+
);
|
|
2895
|
+
};
|
|
2896
|
+
Rn.displayName = "FileRow";
|
|
2897
|
+
const xt = ({
|
|
2898
|
+
open: e,
|
|
2899
|
+
onClose: t,
|
|
2900
|
+
folderId: n
|
|
2901
|
+
}) => {
|
|
2902
|
+
const i = V(), r = ee((S) => S.files), o = ee((S) => S.setBatchAssetType), a = ee((S) => S.startUpload), l = ee((S) => S.clearPending), u = ee((S) => S.analyzeWithAi), y = ee((S) => S.setAnalyzeWithAi), f = dn().data ?? [], [p, T] = D(""), [v, A] = D(/* @__PURE__ */ new Set()), k = r.filter((S) => S.status === "pending");
|
|
2903
|
+
function U(S) {
|
|
2904
|
+
T(S), o(S);
|
|
2905
|
+
}
|
|
2906
|
+
function E(S) {
|
|
2907
|
+
A((G) => {
|
|
2908
|
+
const R = new Set(G);
|
|
2909
|
+
return R.has(S) ? R.delete(S) : R.add(S), R;
|
|
2910
|
+
});
|
|
2911
|
+
}
|
|
2912
|
+
const q = k.length > 0 && k.every((S) => S.assetTypeId !== "");
|
|
2913
|
+
function x() {
|
|
2914
|
+
a(i, n), t(), T(""), A(/* @__PURE__ */ new Set());
|
|
2915
|
+
}
|
|
2916
|
+
function Q() {
|
|
2917
|
+
l(), t();
|
|
2918
|
+
}
|
|
2919
|
+
return /* @__PURE__ */ c(
|
|
2920
|
+
Ae,
|
|
2921
|
+
{
|
|
2922
|
+
open: e,
|
|
2923
|
+
onClose: Q,
|
|
2924
|
+
header: `Upload ${k.length} file${k.length !== 1 ? "s" : ""}`,
|
|
2925
|
+
saveLabel: "Upload",
|
|
2926
|
+
onSave: x,
|
|
2927
|
+
saveDisabled: !q,
|
|
2928
|
+
children: [
|
|
2929
|
+
/* @__PURE__ */ c(F, { mb: 4, children: [
|
|
2930
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", fontWeight: "medium", mb: 2, children: "Asset Type" }),
|
|
2931
|
+
/* @__PURE__ */ c(
|
|
2932
|
+
Se,
|
|
2933
|
+
{
|
|
2934
|
+
size: "sm",
|
|
2935
|
+
value: p,
|
|
2936
|
+
onChange: (S) => U(S.target.value),
|
|
2937
|
+
children: [
|
|
2938
|
+
/* @__PURE__ */ s("option", { value: "", children: "Select asset type..." }),
|
|
2939
|
+
f.map((S) => /* @__PURE__ */ s("option", { value: S.id, children: S.name }, S.id))
|
|
2940
|
+
]
|
|
2941
|
+
}
|
|
2942
|
+
),
|
|
2943
|
+
/* @__PURE__ */ s(L, { fontSize: "xs", color: "fg.muted", mt: 1, children: "Required. Applies to all files unless overridden." })
|
|
2944
|
+
] }),
|
|
2945
|
+
/* @__PURE__ */ s(F, { mb: 4, children: /* @__PURE__ */ s(
|
|
2946
|
+
Wn,
|
|
2947
|
+
{
|
|
2948
|
+
checked: u,
|
|
2949
|
+
onCheckedChange: (S) => y(!!S.checked),
|
|
2950
|
+
children: "Analyze with AI"
|
|
2951
|
+
}
|
|
2952
|
+
) }),
|
|
2953
|
+
/* @__PURE__ */ s(
|
|
2954
|
+
F,
|
|
2955
|
+
{
|
|
2956
|
+
borderWidth: "1px",
|
|
2957
|
+
borderColor: "border",
|
|
2958
|
+
rounded: "md",
|
|
2959
|
+
maxH: "300px",
|
|
2960
|
+
overflowY: "auto",
|
|
2961
|
+
children: k.map((S) => /* @__PURE__ */ s(
|
|
2962
|
+
Rn,
|
|
2963
|
+
{
|
|
2964
|
+
entry: S,
|
|
2965
|
+
showOverride: v.has(S.clientId),
|
|
2966
|
+
onToggleOverride: () => E(S.clientId),
|
|
2967
|
+
assetTypes: f
|
|
2968
|
+
},
|
|
2969
|
+
S.clientId
|
|
2970
|
+
))
|
|
2971
|
+
}
|
|
2972
|
+
)
|
|
2973
|
+
]
|
|
2974
|
+
}
|
|
2975
|
+
);
|
|
2976
|
+
};
|
|
2977
|
+
xt.displayName = "UploadDialog";
|
|
2978
|
+
const Ft = ({
|
|
2979
|
+
onFilesSelected: e,
|
|
2980
|
+
compact: t
|
|
2981
|
+
}) => /* @__PURE__ */ s(Vt, { onFiles: e, compact: t, multiple: !0 });
|
|
2982
|
+
Ft.displayName = "UploadDropZone";
|
|
2983
|
+
function Ni(e) {
|
|
2984
|
+
switch (e) {
|
|
2985
|
+
case "done":
|
|
2986
|
+
return "done";
|
|
2987
|
+
case "error":
|
|
2988
|
+
return "error";
|
|
2989
|
+
case "uploading":
|
|
2990
|
+
return "uploading";
|
|
2991
|
+
case "creating":
|
|
2992
|
+
case "finalizing":
|
|
2993
|
+
return "processing";
|
|
2994
|
+
default:
|
|
2995
|
+
return "pending";
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
const Pi = () => {
|
|
2999
|
+
const e = ee((r) => r.files), t = ee((r) => r.visible), n = ee((r) => r.dismiss), i = e.map((r) => ({
|
|
3000
|
+
id: r.clientId,
|
|
3001
|
+
filename: r.file.name,
|
|
3002
|
+
status: Ni(r.status),
|
|
3003
|
+
progress: r.progress,
|
|
3004
|
+
error: r.error
|
|
3005
|
+
}));
|
|
3006
|
+
return !t || i.length === 0 ? null : /* @__PURE__ */ s(
|
|
3007
|
+
fs,
|
|
3008
|
+
{
|
|
3009
|
+
files: i,
|
|
3010
|
+
onDismiss: n,
|
|
3011
|
+
autoDismissMs: 5e3,
|
|
3012
|
+
defaultExpanded: !0
|
|
3013
|
+
}
|
|
3014
|
+
);
|
|
3015
|
+
};
|
|
3016
|
+
Pi.displayName = "UploadToastStack";
|
|
3017
|
+
function Ei(e) {
|
|
3018
|
+
return new Map(e.map((t) => [t.id, t.name]));
|
|
3019
|
+
}
|
|
3020
|
+
function Ui(e) {
|
|
3021
|
+
return [...new Set(e.map((t) => t.updatedBy).filter(Boolean))];
|
|
3022
|
+
}
|
|
3023
|
+
const Ki = [
|
|
3024
|
+
{ label: "All", value: "" },
|
|
3025
|
+
{ label: "Active", value: "active" },
|
|
3026
|
+
{ label: "Archived", value: "archived" },
|
|
3027
|
+
{ label: "Inactive", value: "inactive" },
|
|
3028
|
+
{ label: "Deleted", value: "deleted" }
|
|
3029
|
+
], Mi = [
|
|
3030
|
+
{ label: "List", value: "list" },
|
|
3031
|
+
{ label: "Grid", value: "grid" }
|
|
3032
|
+
], Oi = [];
|
|
3033
|
+
function Qi(e) {
|
|
3034
|
+
var b, j;
|
|
3035
|
+
const { onAssetOpen: t, initialFilters: n, onFiltersChange: i } = e, [r, o] = D(n ?? {}), [a, l] = D(!1), u = Ie(null), y = r.statusSlug ?? "", h = r.behavior ?? "", f = r.folderId ?? "", p = r.tagIds ?? Oi, T = ((b = r.collectionIds) == null ? void 0 : b[0]) ?? "", v = re(
|
|
3036
|
+
(m, K) => {
|
|
3037
|
+
o((we) => {
|
|
3038
|
+
const ce = { ...we };
|
|
3039
|
+
return K === void 0 || K === "" || Array.isArray(K) && K.length === 0 ? delete ce[m] : ce[m] = K, i == null || i(ce), ce;
|
|
3040
|
+
});
|
|
3041
|
+
},
|
|
3042
|
+
[i]
|
|
3043
|
+
), [A, k] = D((n == null ? void 0 : n.search) ?? ""), U = Ie(!1);
|
|
3044
|
+
le(() => {
|
|
3045
|
+
if (!U.current) {
|
|
3046
|
+
U.current = !0;
|
|
3047
|
+
return;
|
|
3048
|
+
}
|
|
3049
|
+
const m = setTimeout(
|
|
3050
|
+
() => v("search", A || void 0),
|
|
3051
|
+
300
|
|
3052
|
+
);
|
|
3053
|
+
return () => clearTimeout(m);
|
|
3054
|
+
}, [A]);
|
|
3055
|
+
const E = re(
|
|
3056
|
+
(m) => {
|
|
3057
|
+
const K = p.includes(m) ? p.filter((we) => we !== m) : [...p, m];
|
|
3058
|
+
v("tagIds", K.length > 0 ? K : void 0);
|
|
3059
|
+
},
|
|
3060
|
+
[p, v]
|
|
3061
|
+
), q = re(
|
|
3062
|
+
(m) => {
|
|
3063
|
+
v("collectionIds", m ? [m] : void 0);
|
|
3064
|
+
},
|
|
3065
|
+
[v]
|
|
3066
|
+
);
|
|
3067
|
+
function x(m) {
|
|
3068
|
+
v("statusSlug", m || void 0);
|
|
3069
|
+
}
|
|
3070
|
+
function Q(m) {
|
|
3071
|
+
v(
|
|
3072
|
+
"behavior",
|
|
3073
|
+
m || void 0
|
|
3074
|
+
);
|
|
3075
|
+
}
|
|
3076
|
+
const S = ee((m) => m.addFiles), G = Ot((m) => m.viewMode), R = Ot((m) => m.setViewMode), $ = re(
|
|
3077
|
+
(m) => {
|
|
3078
|
+
S(m), l(!0);
|
|
3079
|
+
},
|
|
3080
|
+
[S]
|
|
3081
|
+
), H = vt(), { confirm: te } = je();
|
|
3082
|
+
async function me(m, K) {
|
|
3083
|
+
if (await te({
|
|
3084
|
+
title: "Delete Asset",
|
|
3085
|
+
message: `Delete "${K}"? This cannot be undone.`,
|
|
3086
|
+
confirmLabel: "Delete"
|
|
3087
|
+
}))
|
|
3088
|
+
try {
|
|
3089
|
+
await H.mutateAsync(m), B.success({ title: "Asset deleted" });
|
|
3090
|
+
} catch (ce) {
|
|
3091
|
+
M(ce, "Delete failed");
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
const Z = rn({
|
|
3095
|
+
folderId: f || void 0,
|
|
3096
|
+
statusSlug: y || void 0,
|
|
3097
|
+
behavior: h || void 0,
|
|
3098
|
+
search: r.search || void 0,
|
|
3099
|
+
tagIds: p.length > 0 ? p : void 0,
|
|
3100
|
+
collectionIds: T ? [T] : void 0
|
|
3101
|
+
}), ae = bt().data ?? [], _ = ((j = Z.data) == null ? void 0 : j.items) ?? [], ne = Z.isError ? Z.error : void 0, I = ne ? Ds(ne) && h ? /* @__PURE__ */ s(
|
|
3102
|
+
ye,
|
|
3103
|
+
{
|
|
3104
|
+
header: "Statuses are unavailable",
|
|
3105
|
+
description: "Mediahub cannot reach the status service, so it cannot tell which statuses count as this group. Your assets are all still here — clear the filter to see them, or try again in a moment.",
|
|
3106
|
+
actions: /* @__PURE__ */ s(Y, { size: "sm", onClick: () => Q(""), children: "Clear status group" })
|
|
3107
|
+
}
|
|
3108
|
+
) : /* @__PURE__ */ s(
|
|
3109
|
+
ye,
|
|
3110
|
+
{
|
|
3111
|
+
header: "Assets could not be loaded",
|
|
3112
|
+
description: he(ne, "Assets could not be loaded").description
|
|
3113
|
+
}
|
|
3114
|
+
) : void 0, d = dn(), w = W(
|
|
3115
|
+
() => Ei(d.data ?? []),
|
|
3116
|
+
[d.data]
|
|
3117
|
+
), X = W(() => Ui(_), [_]), { data: se } = St(X), ve = oe((m) => m.selectedIds), Fe = oe((m) => m.setSelection), He = W(() => {
|
|
3118
|
+
const m = {};
|
|
3119
|
+
for (const K of ve) m[K] = !0;
|
|
3120
|
+
return m;
|
|
3121
|
+
}, [ve]), Ye = re(
|
|
3122
|
+
(m) => {
|
|
3123
|
+
const K = {};
|
|
3124
|
+
for (const ce of oe.getState().selectedIds)
|
|
3125
|
+
K[ce] = !0;
|
|
3126
|
+
const we = typeof m == "function" ? m(K) : m;
|
|
3127
|
+
Fe(Object.keys(we).filter((ce) => we[ce]));
|
|
3128
|
+
},
|
|
3129
|
+
[Fe]
|
|
3130
|
+
), Je = JSON.stringify(r);
|
|
3131
|
+
le(() => {
|
|
3132
|
+
oe.getState().clearSelection();
|
|
3133
|
+
}, [Je]);
|
|
3134
|
+
const fe = Xt(), Ze = W(
|
|
3135
|
+
() => [
|
|
3136
|
+
fe.accessor("name", {
|
|
3137
|
+
header: "Name",
|
|
3138
|
+
cell: (m) => /* @__PURE__ */ s(Oe, { value: m.getValue() })
|
|
3139
|
+
}),
|
|
3140
|
+
fe.accessor("assetTypeId", {
|
|
3141
|
+
header: "Type",
|
|
3142
|
+
cell: (m) => /* @__PURE__ */ s(L, { color: "fg.muted", children: w.get(m.getValue()) ?? m.getValue() })
|
|
3143
|
+
}),
|
|
3144
|
+
fe.accessor("statusSlug", {
|
|
3145
|
+
header: "Status",
|
|
3146
|
+
cell: (m) => /* @__PURE__ */ s(De, { slug: m.getValue() }),
|
|
3147
|
+
enableSorting: !1
|
|
3148
|
+
}),
|
|
3149
|
+
fe.accessor("updatedAt", {
|
|
3150
|
+
header: "Updated",
|
|
3151
|
+
cell: (m) => {
|
|
3152
|
+
const K = m.getValue();
|
|
3153
|
+
return /* @__PURE__ */ s($t, { value: K ?? null, showRelative: !0 });
|
|
3154
|
+
}
|
|
3155
|
+
}),
|
|
3156
|
+
fe.accessor("updatedBy", {
|
|
3157
|
+
header: "Updated By",
|
|
3158
|
+
cell: (m) => /* @__PURE__ */ s(L, { color: "fg.muted", children: (se == null ? void 0 : se[m.getValue()]) ?? m.getValue() })
|
|
3159
|
+
}),
|
|
3160
|
+
fe.display({
|
|
3161
|
+
id: "actions",
|
|
3162
|
+
cell: (m) => {
|
|
3163
|
+
const K = m.row.original;
|
|
3164
|
+
return /* @__PURE__ */ s(
|
|
3165
|
+
jt,
|
|
3166
|
+
{
|
|
3167
|
+
actions: [
|
|
3168
|
+
{
|
|
3169
|
+
icon: Be,
|
|
3170
|
+
label: "Download",
|
|
3171
|
+
onClick: () => {
|
|
3172
|
+
}
|
|
3173
|
+
},
|
|
3174
|
+
{
|
|
3175
|
+
icon: Yt,
|
|
3176
|
+
label: "Delete",
|
|
3177
|
+
onClick: () => me(K.id, K.name),
|
|
3178
|
+
colorPalette: "red"
|
|
3179
|
+
}
|
|
3180
|
+
]
|
|
3181
|
+
}
|
|
3182
|
+
);
|
|
3183
|
+
}
|
|
3184
|
+
})
|
|
3185
|
+
],
|
|
3186
|
+
[w, se]
|
|
3187
|
+
), qe = W(
|
|
3188
|
+
() => /* @__PURE__ */ c(ie, { storageKey: "asset-library-rail", children: [
|
|
3189
|
+
/* @__PURE__ */ s(ie.Section, { id: "upload", label: "Upload", defaultOpen: !0, children: /* @__PURE__ */ s(Ft, { onFilesSelected: $, compact: !0 }) }),
|
|
3190
|
+
/* @__PURE__ */ s(ie.Section, { id: "tags", label: "Tags", defaultOpen: !0, children: /* @__PURE__ */ s(zn, { activeTags: p, onToggleTag: E }) }),
|
|
3191
|
+
/* @__PURE__ */ s(ie.Section, { id: "collections", label: "Collections", defaultOpen: !0, children: /* @__PURE__ */ s(
|
|
3192
|
+
vn,
|
|
3193
|
+
{
|
|
3194
|
+
activeCollectionId: T,
|
|
3195
|
+
onSelectCollection: q
|
|
3196
|
+
}
|
|
3197
|
+
) })
|
|
3198
|
+
] }),
|
|
3199
|
+
[
|
|
3200
|
+
p,
|
|
3201
|
+
T,
|
|
3202
|
+
$,
|
|
3203
|
+
E,
|
|
3204
|
+
q
|
|
3205
|
+
]
|
|
3206
|
+
);
|
|
3207
|
+
Zt(qe);
|
|
3208
|
+
const C = ve.length > 0 ? /* @__PURE__ */ s(yn, {}) : /* @__PURE__ */ c(Le, { children: [
|
|
3209
|
+
/* @__PURE__ */ s(
|
|
3210
|
+
Le.Search,
|
|
3211
|
+
{
|
|
3212
|
+
placeholder: "Search assets…",
|
|
3213
|
+
value: A,
|
|
3214
|
+
onChange: k
|
|
3215
|
+
}
|
|
3216
|
+
),
|
|
3217
|
+
/* @__PURE__ */ c(Le.Filters, { children: [
|
|
3218
|
+
/* @__PURE__ */ c(
|
|
3219
|
+
Se,
|
|
3220
|
+
{
|
|
3221
|
+
size: "sm",
|
|
3222
|
+
value: y,
|
|
3223
|
+
onChange: (m) => x(m.target.value ?? ""),
|
|
3224
|
+
children: [
|
|
3225
|
+
/* @__PURE__ */ s("option", { value: "", children: "All" }),
|
|
3226
|
+
ae.map((m) => /* @__PURE__ */ s("option", { value: m.slug, children: m.name }, m.id))
|
|
3227
|
+
]
|
|
3228
|
+
}
|
|
3229
|
+
),
|
|
3230
|
+
/* @__PURE__ */ s(
|
|
3231
|
+
Dt,
|
|
3232
|
+
{
|
|
3233
|
+
size: "sm",
|
|
3234
|
+
value: h,
|
|
3235
|
+
onValueChange: (m) => Q(m.value ?? ""),
|
|
3236
|
+
items: Ki
|
|
3237
|
+
}
|
|
3238
|
+
)
|
|
3239
|
+
] }),
|
|
3240
|
+
/* @__PURE__ */ c(Le.Right, { children: [
|
|
3241
|
+
/* @__PURE__ */ s(
|
|
3242
|
+
Dt,
|
|
3243
|
+
{
|
|
3244
|
+
size: "sm",
|
|
3245
|
+
value: G,
|
|
3246
|
+
onValueChange: (m) => R(m.value),
|
|
3247
|
+
items: Mi
|
|
3248
|
+
}
|
|
3249
|
+
),
|
|
3250
|
+
ne ? null : /* @__PURE__ */ c(Le.Count, { children: [
|
|
3251
|
+
_.length,
|
|
3252
|
+
" assets"
|
|
3253
|
+
] })
|
|
3254
|
+
] })
|
|
3255
|
+
] });
|
|
3256
|
+
return /* @__PURE__ */ c(
|
|
3257
|
+
ps,
|
|
3258
|
+
{
|
|
3259
|
+
breadcrumbs: [{ label: "Assets" }],
|
|
3260
|
+
title: "Assets",
|
|
3261
|
+
actions: /* @__PURE__ */ c(
|
|
3262
|
+
Y,
|
|
3263
|
+
{
|
|
3264
|
+
variant: "solid",
|
|
3265
|
+
colorPalette: "primary",
|
|
3266
|
+
onClick: () => {
|
|
3267
|
+
var m;
|
|
3268
|
+
return (m = u.current) == null ? void 0 : m.click();
|
|
3269
|
+
},
|
|
3270
|
+
children: [
|
|
3271
|
+
/* @__PURE__ */ s(ds, { size: 14 }),
|
|
3272
|
+
" Upload"
|
|
3273
|
+
]
|
|
3274
|
+
}
|
|
3275
|
+
),
|
|
3276
|
+
toolbar: C,
|
|
3277
|
+
children: [
|
|
3278
|
+
/* @__PURE__ */ c(Ee, { storageKey: "mediahub-assets-subnav", children: [
|
|
3279
|
+
/* @__PURE__ */ s(Ee.Nav, { "aria-label": "Folders", children: /* @__PURE__ */ s(F, { overflow: "hidden", children: /* @__PURE__ */ s(
|
|
3280
|
+
kt,
|
|
3281
|
+
{
|
|
3282
|
+
activeFolderId: f,
|
|
3283
|
+
onFolderSelect: (m) => v("folderId", m || void 0)
|
|
3284
|
+
}
|
|
3285
|
+
) }) }),
|
|
3286
|
+
/* @__PURE__ */ c(Ee.Detail, { children: [
|
|
3287
|
+
/* @__PURE__ */ s(Ee.Toolbar, { children: f ? /* @__PURE__ */ s(
|
|
3288
|
+
wn,
|
|
3289
|
+
{
|
|
3290
|
+
folderId: f,
|
|
3291
|
+
onNavigate: (m) => v("folderId", m || void 0)
|
|
3292
|
+
}
|
|
3293
|
+
) : /* @__PURE__ */ s(L, { fontSize: "sm", fontWeight: "medium", children: "All Assets" }) }),
|
|
3294
|
+
/* @__PURE__ */ c(F, { flex: "1", overflow: "auto", p: 4, children: [
|
|
3295
|
+
I,
|
|
3296
|
+
I && _.length === 0 ? null : G === "grid" ? Z.isLoading ? /* @__PURE__ */ s(P, { justify: "center", py: 10, children: /* @__PURE__ */ s(be, {}) }) : _.length === 0 ? /* @__PURE__ */ s(ye, { header: "No assets found" }) : /* @__PURE__ */ s(
|
|
3297
|
+
hn,
|
|
3298
|
+
{
|
|
3299
|
+
assets: _,
|
|
3300
|
+
onOpen: (m) => t == null ? void 0 : t(m)
|
|
3301
|
+
}
|
|
3302
|
+
) : /* @__PURE__ */ s(
|
|
3303
|
+
Gt,
|
|
3304
|
+
{
|
|
3305
|
+
columns: Ze,
|
|
3306
|
+
data: _,
|
|
3307
|
+
selectable: !0,
|
|
3308
|
+
rowSelection: He,
|
|
3309
|
+
onRowSelectionChange: Ye,
|
|
3310
|
+
getRowId: (m) => m.id,
|
|
3311
|
+
onRowClick: (m) => t == null ? void 0 : t(m),
|
|
3312
|
+
loading: Z.isLoading,
|
|
3313
|
+
emptyState: /* @__PURE__ */ s(ye, { header: "No assets found" }),
|
|
3314
|
+
variant: "line"
|
|
3315
|
+
}
|
|
3316
|
+
)
|
|
3317
|
+
] })
|
|
3318
|
+
] })
|
|
3319
|
+
] }),
|
|
3320
|
+
/* @__PURE__ */ s(
|
|
3321
|
+
"input",
|
|
3322
|
+
{
|
|
3323
|
+
ref: u,
|
|
3324
|
+
type: "file",
|
|
3325
|
+
multiple: !0,
|
|
3326
|
+
hidden: !0,
|
|
3327
|
+
onChange: (m) => {
|
|
3328
|
+
const K = m.target.files;
|
|
3329
|
+
K && K.length > 0 && $(Array.from(K)), m.target.value = "";
|
|
3330
|
+
}
|
|
3331
|
+
}
|
|
3332
|
+
),
|
|
3333
|
+
/* @__PURE__ */ s(
|
|
3334
|
+
xt,
|
|
3335
|
+
{
|
|
3336
|
+
open: a,
|
|
3337
|
+
onClose: () => l(!1),
|
|
3338
|
+
folderId: f || void 0
|
|
3339
|
+
}
|
|
3340
|
+
)
|
|
3341
|
+
]
|
|
3342
|
+
}
|
|
3343
|
+
);
|
|
3344
|
+
}
|
|
3345
|
+
Qi.displayName = "AssetLibrary";
|
|
3346
|
+
const Dn = /* @__PURE__ */ new Set(["section", "card"]);
|
|
3347
|
+
function Bi(e, t, n) {
|
|
3348
|
+
const i = t, r = ws(e, n), o = {};
|
|
3349
|
+
for (const a of e) {
|
|
3350
|
+
if (Dn.has(a.field_type)) continue;
|
|
3351
|
+
const l = a.config.api_accessor, u = a.system ? i[l] : t.metadata[l];
|
|
3352
|
+
u !== void 0 ? o[l] = u : l in r && (o[l] = r[l]);
|
|
3353
|
+
}
|
|
3354
|
+
return o;
|
|
3355
|
+
}
|
|
3356
|
+
function _i(e, t, n) {
|
|
3357
|
+
const i = { ...t.metadata }, r = {};
|
|
3358
|
+
for (const o of e) {
|
|
3359
|
+
if (Dn.has(o.field_type)) continue;
|
|
3360
|
+
const a = o.config.api_accessor;
|
|
3361
|
+
a in n && (o.system ? r[a] = n[a] : i[a] = n[a]);
|
|
3362
|
+
}
|
|
3363
|
+
return {
|
|
3364
|
+
name: String(r.name ?? t.name),
|
|
3365
|
+
description: String(r.description ?? t.description),
|
|
3366
|
+
metadata: i
|
|
3367
|
+
};
|
|
3368
|
+
}
|
|
3369
|
+
function qn(e) {
|
|
3370
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
|
|
3371
|
+
}
|
|
3372
|
+
const ke = Xt();
|
|
3373
|
+
function Wi(e) {
|
|
3374
|
+
switch (e) {
|
|
3375
|
+
case "running":
|
|
3376
|
+
return "blue";
|
|
3377
|
+
case "succeeded":
|
|
3378
|
+
return "green";
|
|
3379
|
+
case "failed":
|
|
3380
|
+
return "red";
|
|
3381
|
+
default:
|
|
3382
|
+
return "gray";
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
function Nn({
|
|
3386
|
+
assetId: e,
|
|
3387
|
+
assetName: t,
|
|
3388
|
+
currentVersionId: n,
|
|
3389
|
+
currentMimeType: i,
|
|
3390
|
+
currentFilename: r,
|
|
3391
|
+
currentFileSize: o,
|
|
3392
|
+
currentVersion: a,
|
|
3393
|
+
assetTypeId: l,
|
|
3394
|
+
createdBy: u,
|
|
3395
|
+
createdByName: y,
|
|
3396
|
+
folderId: h,
|
|
3397
|
+
tagIds: f,
|
|
3398
|
+
collectionIds: p,
|
|
3399
|
+
statusSlug: T
|
|
3400
|
+
}) {
|
|
3401
|
+
var E;
|
|
3402
|
+
const v = si(), A = un(l), U = Ci(e).data ?? [];
|
|
3403
|
+
return /* @__PURE__ */ c(ie, { storageKey: "asset-detail-rail", children: [
|
|
3404
|
+
/* @__PURE__ */ s(ie.Header, { eyebrow: "Asset", title: t }),
|
|
3405
|
+
n && i ? /* @__PURE__ */ s(F, { mx: 4, mt: 3, children: /* @__PURE__ */ s(
|
|
3406
|
+
pn,
|
|
3407
|
+
{
|
|
3408
|
+
assetId: e,
|
|
3409
|
+
versionId: n,
|
|
3410
|
+
mimeType: i,
|
|
3411
|
+
fileName: r ?? t
|
|
3412
|
+
}
|
|
3413
|
+
) }) : null,
|
|
3414
|
+
T ? /* @__PURE__ */ s(ie.Section, { id: "status", label: "Status", defaultOpen: !0, children: /* @__PURE__ */ s(gn, { assetId: e, statusSlug: T }) }) : null,
|
|
3415
|
+
/* @__PURE__ */ c(ie.Section, { id: "new-version", label: "New version", defaultOpen: !0, children: [
|
|
3416
|
+
/* @__PURE__ */ s(
|
|
3417
|
+
Vt,
|
|
3418
|
+
{
|
|
3419
|
+
compact: !0,
|
|
3420
|
+
dropHintText: "Drop a file to add a version",
|
|
3421
|
+
disabled: v.isPending,
|
|
3422
|
+
onFiles: (q) => {
|
|
3423
|
+
const x = q[0];
|
|
3424
|
+
x && v.mutate({ assetId: e, file: x });
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
),
|
|
3428
|
+
v.isPending && /* @__PURE__ */ c(P, { align: "center", gap: 2, mt: 2, children: [
|
|
3429
|
+
/* @__PURE__ */ s(be, { size: "xs" }),
|
|
3430
|
+
/* @__PURE__ */ c(L, { fontSize: "xs", color: "fg.muted", children: [
|
|
3431
|
+
"Uploading… ",
|
|
3432
|
+
v.progress,
|
|
3433
|
+
"%"
|
|
3434
|
+
] })
|
|
3435
|
+
] })
|
|
3436
|
+
] }),
|
|
3437
|
+
/* @__PURE__ */ s(ie.Section, { id: "details", label: "Details", children: /* @__PURE__ */ c(Ce, { orientation: "horizontal", gap: "2", children: [
|
|
3438
|
+
/* @__PURE__ */ s(Ce.Row, { label: "Type", children: ((E = A.data) == null ? void 0 : E.name) ?? l }),
|
|
3439
|
+
/* @__PURE__ */ s(Ce.Row, { label: "Format", children: i ?? "—" }),
|
|
3440
|
+
/* @__PURE__ */ s(Ce.Row, { label: "Size", children: o !== void 0 ? qn(o) : "—" }),
|
|
3441
|
+
/* @__PURE__ */ c(Ce.Row, { label: "Version", children: [
|
|
3442
|
+
"v",
|
|
3443
|
+
a
|
|
3444
|
+
] }),
|
|
3445
|
+
/* @__PURE__ */ s(Ce.Row, { label: "Created by", children: y ?? u }),
|
|
3446
|
+
/* @__PURE__ */ s(Ce.Row, { label: "Folder", children: h || "—" })
|
|
3447
|
+
] }) }),
|
|
3448
|
+
/* @__PURE__ */ s(ie.Section, { id: "tags", label: "Tags", children: /* @__PURE__ */ s(Ln, { assetId: e, assignedTagIds: f }) }),
|
|
3449
|
+
/* @__PURE__ */ s(ie.Section, { id: "collections", label: "Collections", children: /* @__PURE__ */ s(
|
|
3450
|
+
bn,
|
|
3451
|
+
{
|
|
3452
|
+
assetId: e,
|
|
3453
|
+
assignedCollectionIds: p
|
|
3454
|
+
}
|
|
3455
|
+
) }),
|
|
3456
|
+
U.length > 0 ? /* @__PURE__ */ s(
|
|
3457
|
+
ie.Section,
|
|
3458
|
+
{
|
|
3459
|
+
id: "ai-processing",
|
|
3460
|
+
label: "AI Processing",
|
|
3461
|
+
defaultOpen: !0,
|
|
3462
|
+
children: /* @__PURE__ */ s(at, { gap: "2", children: U.map((q) => /* @__PURE__ */ c(at, { gap: "1", children: [
|
|
3463
|
+
/* @__PURE__ */ c(J, { gap: "2", justify: "space-between", children: [
|
|
3464
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", flexShrink: 1, truncate: !0, children: q.processName }),
|
|
3465
|
+
/* @__PURE__ */ s(
|
|
3466
|
+
Bt,
|
|
3467
|
+
{
|
|
3468
|
+
colorPalette: Wi(q.status),
|
|
3469
|
+
variant: "subtle",
|
|
3470
|
+
size: "sm",
|
|
3471
|
+
flexShrink: 0,
|
|
3472
|
+
children: q.status
|
|
3473
|
+
}
|
|
3474
|
+
)
|
|
3475
|
+
] }),
|
|
3476
|
+
q.status === "failed" && q.error ? /* @__PURE__ */ s(L, { fontSize: "xs", color: "fg.error", children: q.error }) : null
|
|
3477
|
+
] }, q.id)) })
|
|
3478
|
+
}
|
|
3479
|
+
) : null
|
|
3480
|
+
] });
|
|
3481
|
+
}
|
|
3482
|
+
Nn.displayName = "AssetDetailRail";
|
|
3483
|
+
function Vi({
|
|
3484
|
+
assetId: e,
|
|
3485
|
+
onBack: t,
|
|
3486
|
+
onDeleted: n
|
|
3487
|
+
}) {
|
|
3488
|
+
var I;
|
|
3489
|
+
const i = ii(e), r = i.data, { assets: o } = g(), a = ri(), l = vt(), u = li(), y = z(), { confirm: h } = je(), f = un((r == null ? void 0 : r.assetTypeId) ?? ""), p = W(() => {
|
|
3490
|
+
var d;
|
|
3491
|
+
try {
|
|
3492
|
+
return JSON.parse(((d = f.data) == null ? void 0 : d.metadataSchema) || "[]");
|
|
3493
|
+
} catch {
|
|
3494
|
+
return [];
|
|
3495
|
+
}
|
|
3496
|
+
}, [(I = f.data) == null ? void 0 : I.metadataSchema]), T = W(
|
|
3497
|
+
() => r ? Bi(p, r, et) : {},
|
|
3498
|
+
[p, r]
|
|
3499
|
+
), v = W(
|
|
3500
|
+
() => Cs(p, et),
|
|
3501
|
+
[p]
|
|
3502
|
+
), A = Ss({
|
|
3503
|
+
resolver: ys(v),
|
|
3504
|
+
values: T,
|
|
3505
|
+
resetOptions: { keepDirtyValues: !0 }
|
|
3506
|
+
});
|
|
3507
|
+
async function k(d) {
|
|
3508
|
+
if (!r) return;
|
|
3509
|
+
const w = _i(p, r, d);
|
|
3510
|
+
try {
|
|
3511
|
+
await a.mutateAsync({ id: r.id, patch: w }), B.success({ title: "Asset saved" }), A.reset(d);
|
|
3512
|
+
} catch (X) {
|
|
3513
|
+
M(X, "Save failed");
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
async function U() {
|
|
3517
|
+
A.formState.isDirty && !await h({
|
|
3518
|
+
title: "Discard changes?",
|
|
3519
|
+
message: "The asset has unsaved changes. Leaving discards them.",
|
|
3520
|
+
confirmLabel: "Discard"
|
|
3521
|
+
}) || t == null || t();
|
|
3522
|
+
}
|
|
3523
|
+
const [E, q] = D(
|
|
3524
|
+
"overview"
|
|
3525
|
+
), [x, Q] = D(!1), [S, G] = D(!1), R = W(() => {
|
|
3526
|
+
if (r)
|
|
3527
|
+
return r.versions.find((d) => d.versionNumber === r.currentVersion) ?? r.versions.at(-1);
|
|
3528
|
+
}, [r]), $ = W(() => {
|
|
3529
|
+
if (!r) return [];
|
|
3530
|
+
const d = /* @__PURE__ */ new Set();
|
|
3531
|
+
r.createdBy && d.add(r.createdBy);
|
|
3532
|
+
for (const w of r.versions)
|
|
3533
|
+
w.createdBy && d.add(w.createdBy);
|
|
3534
|
+
return [...d];
|
|
3535
|
+
}, [r]), { data: H } = St($), te = re(
|
|
3536
|
+
async (d) => {
|
|
3537
|
+
if (r)
|
|
3538
|
+
try {
|
|
3539
|
+
const w = await o.getDownloadUrl(r.id, d);
|
|
3540
|
+
window.open(w, "_blank");
|
|
3541
|
+
} catch (w) {
|
|
3542
|
+
M(w, "Download failed");
|
|
3543
|
+
}
|
|
3544
|
+
},
|
|
3545
|
+
[r, o]
|
|
3546
|
+
), me = W(() => {
|
|
3547
|
+
const d = r ? { [`v${r.currentVersion}`]: "green" } : {};
|
|
3548
|
+
return [
|
|
3549
|
+
ke.accessor("versionNumber", {
|
|
3550
|
+
header: "Version",
|
|
3551
|
+
cell: (w) => /* @__PURE__ */ s(
|
|
3552
|
+
ss,
|
|
3553
|
+
{
|
|
3554
|
+
value: `v${w.getValue()}`,
|
|
3555
|
+
colorMap: d,
|
|
3556
|
+
tooltip: w.getValue() === (r == null ? void 0 : r.currentVersion) ? "Current version" : void 0
|
|
3557
|
+
}
|
|
3558
|
+
)
|
|
3559
|
+
}),
|
|
3560
|
+
ke.accessor("originalFilename", {
|
|
3561
|
+
header: "File",
|
|
3562
|
+
cell: (w) => /* @__PURE__ */ s(
|
|
3563
|
+
Oe,
|
|
3564
|
+
{
|
|
3565
|
+
value: w.getValue(),
|
|
3566
|
+
maxLength: 48,
|
|
3567
|
+
subText: w.row.original.comment || w.row.original.mimeType
|
|
3568
|
+
}
|
|
3569
|
+
)
|
|
3570
|
+
}),
|
|
3571
|
+
ke.accessor("fileSize", {
|
|
3572
|
+
header: "Size",
|
|
3573
|
+
cell: (w) => /* @__PURE__ */ s(Oe, { value: qn(w.getValue()) })
|
|
3574
|
+
}),
|
|
3575
|
+
ke.accessor("createdBy", {
|
|
3576
|
+
header: "Author",
|
|
3577
|
+
cell: (w) => /* @__PURE__ */ s(
|
|
3578
|
+
Oe,
|
|
3579
|
+
{
|
|
3580
|
+
value: (H == null ? void 0 : H[w.getValue()]) ?? w.getValue()
|
|
3581
|
+
}
|
|
3582
|
+
)
|
|
3583
|
+
}),
|
|
3584
|
+
ke.accessor("createdAt", {
|
|
3585
|
+
header: "Date",
|
|
3586
|
+
cell: (w) => /* @__PURE__ */ s($t, { value: w.getValue(), showRelative: !0 })
|
|
3587
|
+
}),
|
|
3588
|
+
ke.display({
|
|
3589
|
+
id: "actions",
|
|
3590
|
+
header: "",
|
|
3591
|
+
cell: (w) => /* @__PURE__ */ s(
|
|
3592
|
+
jt,
|
|
3593
|
+
{
|
|
3594
|
+
actions: [
|
|
3595
|
+
{
|
|
3596
|
+
icon: Be,
|
|
3597
|
+
label: `Download version ${w.row.original.versionNumber}`,
|
|
3598
|
+
onClick: () => {
|
|
3599
|
+
te(w.row.original.id);
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
]
|
|
3603
|
+
}
|
|
3604
|
+
)
|
|
3605
|
+
})
|
|
3606
|
+
];
|
|
3607
|
+
}, [r, te, H]);
|
|
3608
|
+
Zt(
|
|
3609
|
+
r && E === "overview" ? /* @__PURE__ */ s(
|
|
3610
|
+
Nn,
|
|
3611
|
+
{
|
|
3612
|
+
assetId: r.id,
|
|
3613
|
+
assetName: r.name,
|
|
3614
|
+
currentVersionId: R == null ? void 0 : R.id,
|
|
3615
|
+
currentMimeType: R == null ? void 0 : R.mimeType,
|
|
3616
|
+
currentFilename: R == null ? void 0 : R.originalFilename,
|
|
3617
|
+
currentFileSize: R == null ? void 0 : R.fileSize,
|
|
3618
|
+
currentVersion: r.currentVersion,
|
|
3619
|
+
assetTypeId: r.assetTypeId,
|
|
3620
|
+
createdBy: r.createdBy,
|
|
3621
|
+
createdByName: H == null ? void 0 : H[r.createdBy],
|
|
3622
|
+
folderId: r.folderId,
|
|
3623
|
+
tagIds: r.tagIds,
|
|
3624
|
+
collectionIds: r.collectionIds,
|
|
3625
|
+
statusSlug: r.statusSlug
|
|
3626
|
+
}
|
|
3627
|
+
) : null
|
|
3628
|
+
);
|
|
3629
|
+
async function Z() {
|
|
3630
|
+
if (!(!r || !R))
|
|
3631
|
+
try {
|
|
3632
|
+
const d = await o.getDownloadUrl(
|
|
3633
|
+
r.id,
|
|
3634
|
+
R.id
|
|
3635
|
+
);
|
|
3636
|
+
window.open(d, "_blank");
|
|
3637
|
+
} catch (d) {
|
|
3638
|
+
M(d, "Download failed");
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3641
|
+
async function ae() {
|
|
3642
|
+
if (r)
|
|
3643
|
+
try {
|
|
3644
|
+
await u.mutateAsync(r.id), y.invalidateQueries({
|
|
3645
|
+
queryKey: ["mediahub", "ai-process-runs", r.id]
|
|
3646
|
+
}), B.success({ title: "Metadata enhanced with AI" });
|
|
3647
|
+
} catch (d) {
|
|
3648
|
+
M(d, "Enhancement failed");
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
async function _() {
|
|
3652
|
+
if (!(!r || !await h({
|
|
3653
|
+
title: "Delete Asset",
|
|
3654
|
+
message: `Delete "${r.name}"? This cannot be undone.`,
|
|
3655
|
+
confirmLabel: "Delete"
|
|
3656
|
+
})))
|
|
3657
|
+
try {
|
|
3658
|
+
await l.mutateAsync(r.id), B.success({ title: "Asset deleted" }), n == null || n();
|
|
3659
|
+
} catch (w) {
|
|
3660
|
+
M(w, "Delete failed");
|
|
3661
|
+
}
|
|
3662
|
+
}
|
|
3663
|
+
if (i.isLoading)
|
|
3664
|
+
return /* @__PURE__ */ s(P, { justify: "center", align: "center", minH: "400px", children: /* @__PURE__ */ s(be, {}) });
|
|
3665
|
+
if (!r)
|
|
3666
|
+
return /* @__PURE__ */ s(ye, { header: "Asset not found" });
|
|
3667
|
+
const ne = [...r.versions].sort(
|
|
3668
|
+
(d, w) => w.versionNumber - d.versionNumber
|
|
3669
|
+
);
|
|
3670
|
+
return /* @__PURE__ */ s(
|
|
3671
|
+
gs,
|
|
3672
|
+
{
|
|
3673
|
+
breadcrumbs: [{ label: "Assets" }, { label: r.name }],
|
|
3674
|
+
avatar: t ? /* @__PURE__ */ s(
|
|
3675
|
+
_e,
|
|
3676
|
+
{
|
|
3677
|
+
variant: "ghost",
|
|
3678
|
+
size: "sm",
|
|
3679
|
+
"aria-label": "Back to assets",
|
|
3680
|
+
onClick: U,
|
|
3681
|
+
children: /* @__PURE__ */ s(ms, { size: 18 })
|
|
3682
|
+
}
|
|
3683
|
+
) : void 0,
|
|
3684
|
+
title: r.name,
|
|
3685
|
+
badges: r.statusSlug ? /* @__PURE__ */ s(De, { slug: r.statusSlug }) : void 0,
|
|
3686
|
+
meta: /* @__PURE__ */ c(L, { fontSize: "sm", color: "fg.muted", children: [
|
|
3687
|
+
"v",
|
|
3688
|
+
r.currentVersion,
|
|
3689
|
+
r.updatedAt ? ` · ${r.updatedAt.toLocaleDateString()}` : ""
|
|
3690
|
+
] }),
|
|
3691
|
+
actions: /* @__PURE__ */ c(J, { gap: "2", children: [
|
|
3692
|
+
/* @__PURE__ */ c(
|
|
3693
|
+
Y,
|
|
3694
|
+
{
|
|
3695
|
+
variant: "outline",
|
|
3696
|
+
colorPalette: "primary",
|
|
3697
|
+
loading: u.isPending,
|
|
3698
|
+
onClick: ae,
|
|
3699
|
+
children: [
|
|
3700
|
+
/* @__PURE__ */ s(us, { size: 16 }),
|
|
3701
|
+
" Enhance with AI"
|
|
3702
|
+
]
|
|
3703
|
+
}
|
|
3704
|
+
),
|
|
3705
|
+
/* @__PURE__ */ s(
|
|
3706
|
+
Y,
|
|
3707
|
+
{
|
|
3708
|
+
variant: "outline",
|
|
3709
|
+
colorPalette: "primary",
|
|
3710
|
+
onClick: Z,
|
|
3711
|
+
children: "Download"
|
|
3712
|
+
}
|
|
3713
|
+
),
|
|
3714
|
+
/* @__PURE__ */ s(
|
|
3715
|
+
Y,
|
|
3716
|
+
{
|
|
3717
|
+
variant: "outline",
|
|
3718
|
+
disabled: !A.formState.isDirty,
|
|
3719
|
+
onClick: () => (
|
|
3720
|
+
// Override the form's global keepDirtyValues:true (which exists
|
|
3721
|
+
// to protect in-progress edits from background refetches) —
|
|
3722
|
+
// Discard must revert every field, dirty or not.
|
|
3723
|
+
A.reset(T, { keepDirtyValues: !1 })
|
|
3724
|
+
),
|
|
3725
|
+
children: "Discard"
|
|
3726
|
+
}
|
|
3727
|
+
),
|
|
3728
|
+
/* @__PURE__ */ s(
|
|
3729
|
+
Y,
|
|
3730
|
+
{
|
|
3731
|
+
variant: "solid",
|
|
3732
|
+
colorPalette: "primary",
|
|
3733
|
+
disabled: !A.formState.isDirty,
|
|
3734
|
+
loading: a.isPending,
|
|
3735
|
+
onClick: A.handleSubmit(k),
|
|
3736
|
+
children: "Save"
|
|
3737
|
+
}
|
|
3738
|
+
),
|
|
3739
|
+
/* @__PURE__ */ c(st, { children: [
|
|
3740
|
+
/* @__PURE__ */ s(it, { asChild: !0, children: /* @__PURE__ */ s(_e, { variant: "ghost", size: "sm", "aria-label": "More actions", children: /* @__PURE__ */ s(ot, { size: 16 }) }) }),
|
|
3741
|
+
/* @__PURE__ */ c(rt, { children: [
|
|
3742
|
+
/* @__PURE__ */ s(de, { value: "move", onClick: () => Q(!0), children: "Move…" }),
|
|
3743
|
+
/* @__PURE__ */ s(
|
|
3744
|
+
de,
|
|
3745
|
+
{
|
|
3746
|
+
value: "manage-access",
|
|
3747
|
+
onClick: () => G(!0),
|
|
3748
|
+
children: "Manage access…"
|
|
3749
|
+
}
|
|
3750
|
+
),
|
|
3751
|
+
/* @__PURE__ */ s(de, { value: "delete", color: "fg.error", onClick: _, children: "Delete" })
|
|
3752
|
+
] })
|
|
3753
|
+
] })
|
|
3754
|
+
] }),
|
|
3755
|
+
tabs: /* @__PURE__ */ s(
|
|
3756
|
+
Ne.Root,
|
|
3757
|
+
{
|
|
3758
|
+
value: E,
|
|
3759
|
+
onValueChange: (d) => q(d.value),
|
|
3760
|
+
children: /* @__PURE__ */ c(Ne.List, { children: [
|
|
3761
|
+
/* @__PURE__ */ s(Ne.Trigger, { value: "overview", children: "Overview" }),
|
|
3762
|
+
/* @__PURE__ */ s(Ne.Trigger, { value: "versions", children: "Versions" })
|
|
3763
|
+
] })
|
|
3764
|
+
}
|
|
3765
|
+
),
|
|
3766
|
+
children: /* @__PURE__ */ c(at, { gap: "4", px: "8", py: "6", children: [
|
|
3767
|
+
/* @__PURE__ */ s(
|
|
3768
|
+
At,
|
|
3769
|
+
{
|
|
3770
|
+
open: x,
|
|
3771
|
+
onOpenChange: Q,
|
|
3772
|
+
subject: { kind: "asset", asset: r }
|
|
3773
|
+
}
|
|
3774
|
+
),
|
|
3775
|
+
/* @__PURE__ */ s(
|
|
3776
|
+
It,
|
|
3777
|
+
{
|
|
3778
|
+
open: S,
|
|
3779
|
+
onOpenChange: G,
|
|
3780
|
+
subject: { kind: "asset", asset: r }
|
|
3781
|
+
}
|
|
3782
|
+
),
|
|
3783
|
+
E === "overview" ? /* @__PURE__ */ s(bs, { plugins: et, children: /* @__PURE__ */ s(Is, { ...A, children: /* @__PURE__ */ s(vs, { schema: p, loading: f.isLoading }) }) }) : /* @__PURE__ */ s(
|
|
3784
|
+
Gt,
|
|
3785
|
+
{
|
|
3786
|
+
columns: me,
|
|
3787
|
+
data: ne,
|
|
3788
|
+
getRowId: (d) => d.id,
|
|
3789
|
+
emptyState: /* @__PURE__ */ s(ye, { header: "No versions yet" }),
|
|
3790
|
+
variant: "line"
|
|
3791
|
+
}
|
|
3792
|
+
)
|
|
3793
|
+
] })
|
|
3794
|
+
}
|
|
3795
|
+
);
|
|
3796
|
+
}
|
|
3797
|
+
Vi.displayName = "AssetDetail";
|
|
3798
|
+
function Pn(e) {
|
|
3799
|
+
const t = e.versions[e.versions.length - 1];
|
|
3800
|
+
if (!t) return "unknown";
|
|
3801
|
+
const n = t.mimeType;
|
|
3802
|
+
return n.startsWith("image/") ? "image" : n.startsWith("video/") ? "video" : n.startsWith("audio/") ? "audio" : n === "application/pdf" ? "pdf" : "unknown";
|
|
3803
|
+
}
|
|
3804
|
+
function En({ category: e }) {
|
|
3805
|
+
switch (e) {
|
|
3806
|
+
case "image":
|
|
3807
|
+
return /* @__PURE__ */ s(pt, { size: 32, opacity: 0.3 });
|
|
3808
|
+
case "video":
|
|
3809
|
+
return /* @__PURE__ */ s(ht, { size: 32, opacity: 0.3 });
|
|
3810
|
+
case "audio":
|
|
3811
|
+
return /* @__PURE__ */ s(Ve, { size: 32, opacity: 0.3 });
|
|
3812
|
+
default:
|
|
3813
|
+
return /* @__PURE__ */ s(ft, { size: 32, opacity: 0.3 });
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
En.displayName = "TypeIcon";
|
|
3817
|
+
const Un = ({
|
|
3818
|
+
asset: e,
|
|
3819
|
+
selected: t,
|
|
3820
|
+
selectionVisible: n,
|
|
3821
|
+
onToggle: i
|
|
3822
|
+
}) => {
|
|
3823
|
+
const r = Pn(e), o = e.versions[e.versions.length - 1], a = Ge(
|
|
3824
|
+
r === "image" && o ? e.id : "",
|
|
3825
|
+
(o == null ? void 0 : o.id) ?? ""
|
|
3826
|
+
), l = a.data, [u, y] = D(!1);
|
|
3827
|
+
return /* @__PURE__ */ c(
|
|
3828
|
+
ue,
|
|
3829
|
+
{
|
|
3830
|
+
selected: t,
|
|
3831
|
+
selectionVisible: n,
|
|
3832
|
+
onSelect: () => i(e),
|
|
3833
|
+
onClick: () => i(e),
|
|
3834
|
+
children: [
|
|
3835
|
+
/* @__PURE__ */ s(ue.Thumbnail, { height: "120px", children: r === "image" && l && !u ? /* @__PURE__ */ s(
|
|
3836
|
+
"img",
|
|
3837
|
+
{
|
|
3838
|
+
src: l,
|
|
3839
|
+
alt: e.name || "Asset preview",
|
|
3840
|
+
onError: () => y(!0),
|
|
3841
|
+
style: { width: "100%", height: "100%", objectFit: "cover" }
|
|
3842
|
+
}
|
|
3843
|
+
) : r === "image" && a.isLoading ? /* @__PURE__ */ s(ut, { w: "full", h: "full" }) : /* @__PURE__ */ s(En, { category: r }) }),
|
|
3844
|
+
/* @__PURE__ */ s(ue.Body, { children: /* @__PURE__ */ s(L, { fontSize: "sm", fontWeight: "medium", truncate: !0, children: e.name }) }),
|
|
3845
|
+
/* @__PURE__ */ s(ue.Footer, { children: /* @__PURE__ */ s(De, { slug: e.statusSlug }) })
|
|
3846
|
+
]
|
|
3847
|
+
}
|
|
3848
|
+
);
|
|
3849
|
+
};
|
|
3850
|
+
Un.displayName = "PickerAssetCard";
|
|
3851
|
+
const Lt = ({
|
|
3852
|
+
count: e,
|
|
3853
|
+
confirmLabel: t,
|
|
3854
|
+
cancelLabel: n,
|
|
3855
|
+
onConfirm: i,
|
|
3856
|
+
onCancel: r,
|
|
3857
|
+
children: o
|
|
3858
|
+
}) => /* @__PURE__ */ c(P, { align: "center", gap: "3", w: "full", children: [
|
|
3859
|
+
/* @__PURE__ */ c(J, { gap: "2", minW: "0", flex: "1", children: [
|
|
3860
|
+
o,
|
|
3861
|
+
/* @__PURE__ */ c(L, { fontSize: "sm", color: "fg.muted", flexShrink: 0, children: [
|
|
3862
|
+
e,
|
|
3863
|
+
" selected"
|
|
3864
|
+
] })
|
|
3865
|
+
] }),
|
|
3866
|
+
/* @__PURE__ */ s(F, { flexShrink: 0, children: /* @__PURE__ */ c(J, { gap: "2", children: [
|
|
3867
|
+
/* @__PURE__ */ s(Y, { variant: "ghost", onClick: r, children: n }),
|
|
3868
|
+
/* @__PURE__ */ s(
|
|
3869
|
+
Y,
|
|
3870
|
+
{
|
|
3871
|
+
variant: "solid",
|
|
3872
|
+
colorPalette: "primary",
|
|
3873
|
+
disabled: e === 0,
|
|
3874
|
+
onClick: i,
|
|
3875
|
+
children: t
|
|
3876
|
+
}
|
|
3877
|
+
)
|
|
3878
|
+
] }) })
|
|
3879
|
+
] });
|
|
3880
|
+
Lt.displayName = "PickerFooter";
|
|
3881
|
+
function Kn(e) {
|
|
3882
|
+
const [t, n] = D([]), i = re(
|
|
3883
|
+
(l) => {
|
|
3884
|
+
n((u) => {
|
|
3885
|
+
const y = u.some((h) => h.id === l.id);
|
|
3886
|
+
return e === "single" ? y ? [] : [l] : y ? u.filter((h) => h.id !== l.id) : [...u, l];
|
|
3887
|
+
});
|
|
3888
|
+
},
|
|
3889
|
+
[e]
|
|
3890
|
+
), r = re(
|
|
3891
|
+
(l) => n((u) => u.filter((y) => y.id !== l)),
|
|
3892
|
+
[]
|
|
3893
|
+
), o = re(() => n([]), []), a = re(
|
|
3894
|
+
(l) => t.some((u) => u.id === l),
|
|
3895
|
+
[t]
|
|
3896
|
+
);
|
|
3897
|
+
return { items: t, isSelected: a, toggle: i, remove: r, clear: o };
|
|
3898
|
+
}
|
|
3899
|
+
function $i(e, t) {
|
|
3900
|
+
const n = e.versions[e.versions.length - 1];
|
|
3901
|
+
if (!n) return !1;
|
|
3902
|
+
const i = n.mimeType;
|
|
3903
|
+
return t.some(
|
|
3904
|
+
(r) => r.endsWith("/*") ? i.startsWith(r.slice(0, r.indexOf("/") + 1)) : i === r
|
|
3905
|
+
);
|
|
3906
|
+
}
|
|
3907
|
+
function ji(e) {
|
|
3908
|
+
var I;
|
|
3909
|
+
const {
|
|
3910
|
+
open: t,
|
|
3911
|
+
onOpenChange: n,
|
|
3912
|
+
onSelect: i,
|
|
3913
|
+
accept: r,
|
|
3914
|
+
initialFilters: o,
|
|
3915
|
+
headerLabel: a,
|
|
3916
|
+
searchPlaceholder: l,
|
|
3917
|
+
insertLabel: u,
|
|
3918
|
+
cancelLabel: y,
|
|
3919
|
+
emptyLabel: h
|
|
3920
|
+
} = e, f = e.mode ?? "single", [p, T] = D(o ?? {}), v = p.folderId ?? "", A = p.statusSlug ?? "", k = Kn(f);
|
|
3921
|
+
function U(d, w) {
|
|
3922
|
+
T((X) => {
|
|
3923
|
+
const se = { ...X };
|
|
3924
|
+
return w === void 0 || w === "" ? delete se[d] : se[d] = w, se;
|
|
3925
|
+
});
|
|
3926
|
+
}
|
|
3927
|
+
const E = rn(p), q = bt().data ?? [], x = ((I = E.data) == null ? void 0 : I.items) ?? [], Q = W(
|
|
3928
|
+
() => r != null && r.length ? x.filter((d) => $i(d, r)) : x,
|
|
3929
|
+
[x, r]
|
|
3930
|
+
), S = e.allowUpload ?? !1, G = ee((d) => d.addFiles), R = ee((d) => d.files), [$, H] = D(!1), te = Ie(/* @__PURE__ */ new Set());
|
|
3931
|
+
function me(d) {
|
|
3932
|
+
G(d), H(!0);
|
|
3933
|
+
}
|
|
3934
|
+
function Z() {
|
|
3935
|
+
k.clear(), T(o ?? {}), H(!1), te.current.clear();
|
|
3936
|
+
}
|
|
3937
|
+
le(() => {
|
|
3938
|
+
t && Z();
|
|
3939
|
+
}, [t]), le(() => {
|
|
3940
|
+
if (!t) return;
|
|
3941
|
+
const d = new Map(Q.map((w) => [w.id, w]));
|
|
3942
|
+
for (const w of R)
|
|
3943
|
+
if (w.status === "done" && w.assetId && !te.current.has(w.assetId)) {
|
|
3944
|
+
const X = d.get(w.assetId);
|
|
3945
|
+
X && (te.current.add(w.assetId), k.isSelected(X.id) || k.toggle(X));
|
|
3946
|
+
}
|
|
3947
|
+
}, [t, Q, R, k.toggle, k.isSelected]);
|
|
3948
|
+
function ae() {
|
|
3949
|
+
k.items.length !== 0 && (i(
|
|
3950
|
+
f === "single" ? { mode: "single", asset: k.items[0] } : { mode: "multi", assets: k.items }
|
|
3951
|
+
), n(!1));
|
|
3952
|
+
}
|
|
3953
|
+
const _ = k.items.length, ne = u ?? (f === "multi" && _ > 0 ? `Insert ${_}` : "Insert");
|
|
3954
|
+
return /* @__PURE__ */ c(
|
|
3955
|
+
Ae,
|
|
3956
|
+
{
|
|
3957
|
+
open: t,
|
|
3958
|
+
lazyMount: !0,
|
|
3959
|
+
unmountOnExit: !0,
|
|
3960
|
+
onExitComplete: Z,
|
|
3961
|
+
onClose: () => n(!1),
|
|
3962
|
+
size: "cover",
|
|
3963
|
+
header: a ?? (f === "single" ? "Select an asset" : "Select assets"),
|
|
3964
|
+
footer: /* @__PURE__ */ s(
|
|
3965
|
+
Lt,
|
|
3966
|
+
{
|
|
3967
|
+
count: _,
|
|
3968
|
+
confirmLabel: ne,
|
|
3969
|
+
cancelLabel: y ?? "Cancel",
|
|
3970
|
+
onConfirm: ae,
|
|
3971
|
+
onCancel: () => n(!1),
|
|
3972
|
+
children: /* @__PURE__ */ c(J, { gap: "1", minW: "0", children: [
|
|
3973
|
+
k.items.slice(0, 8).map((d) => {
|
|
3974
|
+
const w = d.versions[d.versions.length - 1], X = Pn(d) === "image";
|
|
3975
|
+
return /* @__PURE__ */ s(
|
|
3976
|
+
F,
|
|
3977
|
+
{
|
|
3978
|
+
position: "relative",
|
|
3979
|
+
w: "30px",
|
|
3980
|
+
h: "30px",
|
|
3981
|
+
borderRadius: "md",
|
|
3982
|
+
overflow: "hidden",
|
|
3983
|
+
borderWidth: "1px",
|
|
3984
|
+
borderColor: "border",
|
|
3985
|
+
flexShrink: 0,
|
|
3986
|
+
title: d.name,
|
|
3987
|
+
children: X && w ? /* @__PURE__ */ s(
|
|
3988
|
+
Mn,
|
|
3989
|
+
{
|
|
3990
|
+
assetId: d.id,
|
|
3991
|
+
versionId: w.id,
|
|
3992
|
+
name: d.name
|
|
3993
|
+
}
|
|
3994
|
+
) : /* @__PURE__ */ s(
|
|
3995
|
+
P,
|
|
3996
|
+
{
|
|
3997
|
+
w: "full",
|
|
3998
|
+
h: "full",
|
|
3999
|
+
align: "center",
|
|
4000
|
+
justify: "center",
|
|
4001
|
+
bg: "bg.muted",
|
|
4002
|
+
children: /* @__PURE__ */ s(L, { fontSize: "2xs", color: "fg.muted", children: d.name.slice(0, 2) })
|
|
4003
|
+
}
|
|
4004
|
+
)
|
|
4005
|
+
},
|
|
4006
|
+
d.id
|
|
4007
|
+
);
|
|
4008
|
+
}),
|
|
4009
|
+
_ > 8 && /* @__PURE__ */ c(L, { fontSize: "xs", color: "fg.muted", flexShrink: 0, children: [
|
|
4010
|
+
"+",
|
|
4011
|
+
_ - 8,
|
|
4012
|
+
" more"
|
|
4013
|
+
] })
|
|
4014
|
+
] })
|
|
4015
|
+
}
|
|
4016
|
+
),
|
|
4017
|
+
children: [
|
|
4018
|
+
/* @__PURE__ */ c(P, { h: "full", minH: "0", children: [
|
|
4019
|
+
/* @__PURE__ */ s(
|
|
4020
|
+
F,
|
|
4021
|
+
{
|
|
4022
|
+
w: "188px",
|
|
4023
|
+
flexShrink: 0,
|
|
4024
|
+
borderRightWidth: "1px",
|
|
4025
|
+
borderColor: "border",
|
|
4026
|
+
bg: "bg.subtle",
|
|
4027
|
+
overflowY: "auto",
|
|
4028
|
+
p: "2",
|
|
4029
|
+
children: /* @__PURE__ */ s(
|
|
4030
|
+
kt,
|
|
4031
|
+
{
|
|
4032
|
+
activeFolderId: v,
|
|
4033
|
+
onFolderSelect: (d) => U("folderId", d || void 0)
|
|
4034
|
+
}
|
|
4035
|
+
)
|
|
4036
|
+
}
|
|
4037
|
+
),
|
|
4038
|
+
/* @__PURE__ */ c(P, { direction: "column", flex: "1", minW: "0", children: [
|
|
4039
|
+
/* @__PURE__ */ c(
|
|
4040
|
+
P,
|
|
4041
|
+
{
|
|
4042
|
+
gap: "3",
|
|
4043
|
+
align: "center",
|
|
4044
|
+
px: "4",
|
|
4045
|
+
py: "2",
|
|
4046
|
+
borderBottomWidth: "1px",
|
|
4047
|
+
borderColor: "border",
|
|
4048
|
+
children: [
|
|
4049
|
+
/* @__PURE__ */ s(
|
|
4050
|
+
Jt,
|
|
4051
|
+
{
|
|
4052
|
+
onSearch: (d) => U("search", d || void 0),
|
|
4053
|
+
defaultValue: p.search ?? "",
|
|
4054
|
+
placeholder: l ?? "Search assets...",
|
|
4055
|
+
maxWidth: "260px",
|
|
4056
|
+
size: "sm"
|
|
4057
|
+
}
|
|
4058
|
+
),
|
|
4059
|
+
/* @__PURE__ */ c(J, { gap: "1", children: [
|
|
4060
|
+
/* @__PURE__ */ s(L, { fontSize: "xs", color: "fg.muted", children: "Status:" }),
|
|
4061
|
+
/* @__PURE__ */ c(
|
|
4062
|
+
Se,
|
|
4063
|
+
{
|
|
4064
|
+
size: "sm",
|
|
4065
|
+
value: A,
|
|
4066
|
+
onChange: (d) => U("statusSlug", d.target.value || void 0),
|
|
4067
|
+
children: [
|
|
4068
|
+
/* @__PURE__ */ s("option", { value: "", children: "All" }),
|
|
4069
|
+
q.map((d) => /* @__PURE__ */ s("option", { value: d.slug, children: d.name }, d.id))
|
|
4070
|
+
]
|
|
4071
|
+
}
|
|
4072
|
+
)
|
|
4073
|
+
] })
|
|
4074
|
+
]
|
|
4075
|
+
}
|
|
4076
|
+
),
|
|
4077
|
+
S && /* @__PURE__ */ s(F, { px: "4", py: "2", borderBottomWidth: "1px", borderColor: "border", children: /* @__PURE__ */ s(Ft, { onFilesSelected: me, compact: !0 }) }),
|
|
4078
|
+
/* @__PURE__ */ s(F, { flex: "1", overflow: "auto", p: "4", children: E.isLoading ? /* @__PURE__ */ s(P, { justify: "center", py: "10", children: /* @__PURE__ */ s(be, {}) }) : Q.length === 0 ? /* @__PURE__ */ s(ye, { header: h ?? "No assets found" }) : /* @__PURE__ */ s(
|
|
4079
|
+
dt,
|
|
4080
|
+
{
|
|
4081
|
+
templateColumns: "repeat(auto-fill, minmax(150px, 1fr))",
|
|
4082
|
+
gap: "3",
|
|
4083
|
+
children: Q.map((d) => /* @__PURE__ */ s(
|
|
4084
|
+
Un,
|
|
4085
|
+
{
|
|
4086
|
+
asset: d,
|
|
4087
|
+
selected: k.isSelected(d.id),
|
|
4088
|
+
selectionVisible: _ > 0,
|
|
4089
|
+
onToggle: k.toggle
|
|
4090
|
+
},
|
|
4091
|
+
d.id
|
|
4092
|
+
))
|
|
4093
|
+
}
|
|
4094
|
+
) })
|
|
4095
|
+
] })
|
|
4096
|
+
] }),
|
|
4097
|
+
S && /* @__PURE__ */ s(
|
|
4098
|
+
xt,
|
|
4099
|
+
{
|
|
4100
|
+
open: $,
|
|
4101
|
+
onClose: () => H(!1),
|
|
4102
|
+
folderId: v || void 0
|
|
4103
|
+
}
|
|
4104
|
+
)
|
|
4105
|
+
]
|
|
4106
|
+
}
|
|
4107
|
+
);
|
|
4108
|
+
}
|
|
4109
|
+
ji.displayName = "AssetPicker";
|
|
4110
|
+
function Mn({
|
|
4111
|
+
assetId: e,
|
|
4112
|
+
versionId: t,
|
|
4113
|
+
name: n
|
|
4114
|
+
}) {
|
|
4115
|
+
const { data: i } = Ge(e, t);
|
|
4116
|
+
return i ? /* @__PURE__ */ s(
|
|
4117
|
+
"img",
|
|
4118
|
+
{
|
|
4119
|
+
src: i,
|
|
4120
|
+
alt: n,
|
|
4121
|
+
style: { width: "100%", height: "100%", objectFit: "cover" }
|
|
4122
|
+
}
|
|
4123
|
+
) : /* @__PURE__ */ s(F, { w: "full", h: "full", bg: "bg.muted" });
|
|
4124
|
+
}
|
|
4125
|
+
Mn.displayName = "PickerStripThumb";
|
|
4126
|
+
function Gi(e) {
|
|
4127
|
+
const { open: t, onOpenChange: n, onSelect: i, allowCreate: r } = e, o = e.mode ?? "single", [a, l] = D(""), [u, y] = D(""), h = Kn(o), f = Re(), p = on(), T = f.data ?? [], v = a ? T.filter((x) => x.name.toLowerCase().includes(a.toLowerCase())) : T;
|
|
4128
|
+
function A() {
|
|
4129
|
+
h.clear(), l(""), y("");
|
|
4130
|
+
}
|
|
4131
|
+
le(() => {
|
|
4132
|
+
t && A();
|
|
4133
|
+
}, [t]);
|
|
4134
|
+
function k() {
|
|
4135
|
+
h.items.length !== 0 && (i(
|
|
4136
|
+
o === "single" ? { mode: "single", collection: h.items[0] } : { mode: "multi", collections: h.items }
|
|
4137
|
+
), n(!1));
|
|
4138
|
+
}
|
|
4139
|
+
async function U() {
|
|
4140
|
+
const x = u.trim();
|
|
4141
|
+
if (x)
|
|
4142
|
+
try {
|
|
4143
|
+
await p.mutateAsync({
|
|
4144
|
+
name: x,
|
|
4145
|
+
slug: x.toLowerCase().replace(/\s+/g, "-"),
|
|
4146
|
+
description: "",
|
|
4147
|
+
type: "static",
|
|
4148
|
+
rules: ""
|
|
4149
|
+
}), y(""), B.success({ title: "Collection created" });
|
|
4150
|
+
} catch (Q) {
|
|
4151
|
+
M(Q, "Create failed");
|
|
4152
|
+
}
|
|
4153
|
+
}
|
|
4154
|
+
const E = h.items.length, q = e.confirmLabel ?? (E > 0 ? `Select ${E}` : "Select");
|
|
4155
|
+
return /* @__PURE__ */ s(
|
|
4156
|
+
Ae,
|
|
4157
|
+
{
|
|
4158
|
+
open: t,
|
|
4159
|
+
lazyMount: !0,
|
|
4160
|
+
unmountOnExit: !0,
|
|
4161
|
+
onExitComplete: A,
|
|
4162
|
+
onClose: () => n(!1),
|
|
4163
|
+
size: "lg",
|
|
4164
|
+
header: e.headerLabel ?? (o === "single" ? "Select a collection" : "Select collections"),
|
|
4165
|
+
footer: /* @__PURE__ */ s(
|
|
4166
|
+
Lt,
|
|
4167
|
+
{
|
|
4168
|
+
count: E,
|
|
4169
|
+
confirmLabel: q,
|
|
4170
|
+
cancelLabel: e.cancelLabel ?? "Cancel",
|
|
4171
|
+
onConfirm: k,
|
|
4172
|
+
onCancel: () => n(!1)
|
|
4173
|
+
}
|
|
4174
|
+
),
|
|
4175
|
+
children: /* @__PURE__ */ c(P, { direction: "column", gap: "3", minH: "280px", children: [
|
|
4176
|
+
/* @__PURE__ */ c(P, { gap: "2", align: "center", children: [
|
|
4177
|
+
/* @__PURE__ */ s(
|
|
4178
|
+
Jt,
|
|
4179
|
+
{
|
|
4180
|
+
onSearch: l,
|
|
4181
|
+
placeholder: e.searchPlaceholder ?? "Search collections...",
|
|
4182
|
+
size: "sm",
|
|
4183
|
+
maxWidth: "full"
|
|
4184
|
+
}
|
|
4185
|
+
),
|
|
4186
|
+
r && /* @__PURE__ */ c(J, { gap: "2", flexShrink: 0, children: [
|
|
4187
|
+
/* @__PURE__ */ s(F, { w: "160px", children: /* @__PURE__ */ s(
|
|
4188
|
+
We,
|
|
4189
|
+
{
|
|
4190
|
+
value: u,
|
|
4191
|
+
onChange: (x) => y(x.target.value),
|
|
4192
|
+
placeholder: e.createLabel ?? "New collection name",
|
|
4193
|
+
size: "sm"
|
|
4194
|
+
}
|
|
4195
|
+
) }),
|
|
4196
|
+
/* @__PURE__ */ s(
|
|
4197
|
+
Y,
|
|
4198
|
+
{
|
|
4199
|
+
size: "sm",
|
|
4200
|
+
variant: "outline",
|
|
4201
|
+
onClick: U,
|
|
4202
|
+
loading: p.isPending,
|
|
4203
|
+
disabled: !u.trim(),
|
|
4204
|
+
children: "Create"
|
|
4205
|
+
}
|
|
4206
|
+
)
|
|
4207
|
+
] })
|
|
4208
|
+
] }),
|
|
4209
|
+
f.isLoading ? /* @__PURE__ */ s(P, { justify: "center", py: "10", children: /* @__PURE__ */ s(be, {}) }) : v.length === 0 ? /* @__PURE__ */ s(ye, { header: e.emptyLabel ?? "No collections" }) : /* @__PURE__ */ s(dt, { templateColumns: "repeat(2, 1fr)", gap: "3", children: v.map((x) => /* @__PURE__ */ s(
|
|
4210
|
+
ue,
|
|
4211
|
+
{
|
|
4212
|
+
selected: h.isSelected(x.id),
|
|
4213
|
+
selectionVisible: E > 0,
|
|
4214
|
+
onSelect: () => h.toggle(x),
|
|
4215
|
+
onClick: () => h.toggle(x),
|
|
4216
|
+
children: /* @__PURE__ */ s(ue.Body, { children: /* @__PURE__ */ c(J, { gap: "2", align: "center", children: [
|
|
4217
|
+
/* @__PURE__ */ s(Ht, { size: 16 }),
|
|
4218
|
+
/* @__PURE__ */ c(F, { minW: "0", children: [
|
|
4219
|
+
/* @__PURE__ */ c(J, { gap: "1", align: "center", children: [
|
|
4220
|
+
/* @__PURE__ */ s(L, { fontSize: "sm", fontWeight: "medium", truncate: !0, children: x.name }),
|
|
4221
|
+
x.restricted && /* @__PURE__ */ s(Tt, {})
|
|
4222
|
+
] }),
|
|
4223
|
+
/* @__PURE__ */ s(
|
|
4224
|
+
L,
|
|
4225
|
+
{
|
|
4226
|
+
fontSize: "xs",
|
|
4227
|
+
color: "fg.muted",
|
|
4228
|
+
textTransform: "capitalize",
|
|
4229
|
+
children: x.type
|
|
4230
|
+
}
|
|
4231
|
+
)
|
|
4232
|
+
] })
|
|
4233
|
+
] }) })
|
|
4234
|
+
},
|
|
4235
|
+
x.id
|
|
4236
|
+
)) })
|
|
4237
|
+
] })
|
|
4238
|
+
}
|
|
4239
|
+
);
|
|
4240
|
+
}
|
|
4241
|
+
Gi.displayName = "CollectionPicker";
|
|
4242
|
+
const Ur = "0.1.0";
|
|
4243
|
+
export {
|
|
4244
|
+
nn as ASSET_STATUS_CATALOGUE,
|
|
4245
|
+
Vi as AssetDetail,
|
|
4246
|
+
Nn as AssetDetailRail,
|
|
4247
|
+
hn as AssetGrid,
|
|
4248
|
+
Qi as AssetLibrary,
|
|
4249
|
+
ji as AssetPicker,
|
|
4250
|
+
pn as AssetPreview,
|
|
4251
|
+
De as AssetStatusBadge,
|
|
4252
|
+
gn as AssetStatusControl,
|
|
4253
|
+
yn as BulkActionBar,
|
|
4254
|
+
bn as CollectionChipField,
|
|
4255
|
+
vn as CollectionPanel,
|
|
4256
|
+
Gi as CollectionPicker,
|
|
4257
|
+
wn as FolderBreadcrumbs,
|
|
4258
|
+
kt as FolderTree,
|
|
4259
|
+
Di as InlineEditField,
|
|
4260
|
+
Cn as LeakGuardRefusalDialog,
|
|
4261
|
+
Ur as MEDIAHUB_UI_VERSION,
|
|
4262
|
+
It as ManageAccessDialog,
|
|
4263
|
+
ei as MediahubProvider,
|
|
4264
|
+
At as MoveDialog,
|
|
4265
|
+
Fn as RestrictedFolderDialog,
|
|
4266
|
+
Tt as RestrictedLockBadge,
|
|
4267
|
+
xn as RestrictedWarningNotice,
|
|
4268
|
+
Ln as TagChipField,
|
|
4269
|
+
zn as TagPanel,
|
|
4270
|
+
xt as UploadDialog,
|
|
4271
|
+
Ft as UploadDropZone,
|
|
4272
|
+
Pi as UploadToastStack,
|
|
4273
|
+
Js as createConnectAIConnectionClient,
|
|
4274
|
+
Zs as createConnectAIProcessClient,
|
|
4275
|
+
Os as createConnectAssetClient,
|
|
4276
|
+
Ws as createConnectAssetTypeClient,
|
|
4277
|
+
Hs as createConnectAuthzClient,
|
|
4278
|
+
Bs as createConnectCollectionClient,
|
|
4279
|
+
Ys as createConnectDashboardClient,
|
|
4280
|
+
Vs as createConnectDirectoryClient,
|
|
4281
|
+
Qs as createConnectFolderClient,
|
|
4282
|
+
Gs as createConnectGrantClient,
|
|
4283
|
+
fr as createConnectMediahubClients,
|
|
4284
|
+
_s as createConnectTagClient,
|
|
4285
|
+
he as describeRpcError,
|
|
4286
|
+
Mt as isActive,
|
|
4287
|
+
Rs as isPermissionDenied,
|
|
4288
|
+
Ds as isRetryableUnavailable,
|
|
4289
|
+
zi as restrictedContainerWarning,
|
|
4290
|
+
M as showRpcErrorToast,
|
|
4291
|
+
Ri as unrestrictDisclosure,
|
|
4292
|
+
Fr as useAIConnection,
|
|
4293
|
+
xr as useAIConnections,
|
|
4294
|
+
qr as useAIProcess,
|
|
4295
|
+
Ci as useAIProcessRuns,
|
|
4296
|
+
Dr as useAIProcesses,
|
|
4297
|
+
ln as useAddAssetsToCollection,
|
|
4298
|
+
si as useAddVersion,
|
|
4299
|
+
ii as useAsset,
|
|
4300
|
+
ni as useAssetStatus,
|
|
4301
|
+
bt as useAssetStatuses,
|
|
4302
|
+
un as useAssetType,
|
|
4303
|
+
dn as useAssetTypes,
|
|
4304
|
+
rn as useAssets,
|
|
4305
|
+
ci as useCanManage,
|
|
4306
|
+
pr as useCollection,
|
|
4307
|
+
Re as useCollections,
|
|
4308
|
+
Lr as useCreateAIConnection,
|
|
4309
|
+
Nr as useCreateAIProcess,
|
|
4310
|
+
hr as useCreateAsset,
|
|
4311
|
+
Cr as useCreateAssetType,
|
|
4312
|
+
on as useCreateCollection,
|
|
4313
|
+
an as useCreateFolder,
|
|
4314
|
+
bi as useCreateTag,
|
|
4315
|
+
Rr as useDeleteAIConnection,
|
|
4316
|
+
Er as useDeleteAIProcess,
|
|
4317
|
+
vt as useDeleteAsset,
|
|
4318
|
+
Ir as useDeleteAssetType,
|
|
4319
|
+
yr as useDeleteCollection,
|
|
4320
|
+
ui as useDeleteFolder,
|
|
4321
|
+
wr as useDeleteTag,
|
|
4322
|
+
li as useEnhanceAssetMetadata,
|
|
4323
|
+
nt as useFolder,
|
|
4324
|
+
wt as useFolders,
|
|
4325
|
+
Tr as useGetDashboardLayout,
|
|
4326
|
+
pi as useGrantAccess,
|
|
4327
|
+
hi as useGrants,
|
|
4328
|
+
g as useMediahubClients,
|
|
4329
|
+
ti as useMediahubLinks,
|
|
4330
|
+
ai as useMoveAsset,
|
|
4331
|
+
mi as useMoveFolder,
|
|
4332
|
+
Ot as usePreferencesStore,
|
|
4333
|
+
Ge as usePreviewURL,
|
|
4334
|
+
yi as useRemoveAssetsFromCollection,
|
|
4335
|
+
gi as useRevokeAccess,
|
|
4336
|
+
kr as useSaveDashboardLayout,
|
|
4337
|
+
oe as useSelectionStore,
|
|
4338
|
+
br as useSetCollectionRestricted,
|
|
4339
|
+
fi as useSetFolderRestricted,
|
|
4340
|
+
cn as useTagAssets,
|
|
4341
|
+
Ct as useTags,
|
|
4342
|
+
oi as useTransitionAssetStatus,
|
|
4343
|
+
vi as useUntagAssets,
|
|
4344
|
+
zr as useUpdateAIConnection,
|
|
4345
|
+
Pr as useUpdateAIProcess,
|
|
4346
|
+
ri as useUpdateAsset,
|
|
4347
|
+
Sr as useUpdateAssetType,
|
|
4348
|
+
gr as useUpdateCollection,
|
|
4349
|
+
di as useUpdateFolder,
|
|
4350
|
+
vr as useUpdateTag,
|
|
4351
|
+
ee as useUploadStore,
|
|
4352
|
+
St as useUsers,
|
|
4353
|
+
V as useWorkspaceId,
|
|
4354
|
+
wi as useWorkspaceMembers,
|
|
4355
|
+
Ar as useWorkspaceStats
|
|
4356
|
+
};
|
|
4357
|
+
//# sourceMappingURL=index.js.map
|