@yuhuanowo/yunui 0.2.14 → 0.2.16

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.
@@ -209,6 +209,26 @@ interface PageHeaderProps {
209
209
  }
210
210
  declare function PageHeader({ title, description, actions, className }: PageHeaderProps): React$1.JSX.Element;
211
211
 
212
+ interface PageLayoutProps {
213
+ /** Page content, rendered inside `<main>`. */
214
+ children: ReactNode;
215
+ /** Top navigation slot — typically `<Navbar/>`. Rendered above `<main>`. */
216
+ navbar?: ReactNode;
217
+ /** Bottom slot — typically `<Footer/>`. Hidden when `hideFooter`. */
218
+ footer?: ReactNode;
219
+ /** Drop the footer (e.g. focused/app pages). */
220
+ hideFooter?: boolean;
221
+ /** Skip the default `bg-background` so a page can paint its own backdrop. */
222
+ transparentBg?: boolean;
223
+ /** Override the `<main>` classes — defaults to `flex-1 pt-28` (clears the
224
+ * fixed navbar). Pass your own offset for a taller/shorter bar. */
225
+ mainClassName?: string;
226
+ /** Extra classes on the outer wrapper. */
227
+ className?: string;
228
+ }
229
+ /** Full-height page shell: navbar slot · offset `<main>` · footer slot. */
230
+ declare function PageLayout({ children, navbar, footer, hideFooter, transparentBg, mainClassName, className, }: PageLayoutProps): React$1.JSX.Element;
231
+
212
232
  interface PageLoadingStateProps {
213
233
  /** Optional text shown beside the spinner. */
214
234
  message?: string;
@@ -453,6 +473,92 @@ interface MetricBarProps {
453
473
  }
454
474
  declare function MetricBar({ icon, label, value, percentage, color, className }: MetricBarProps): React$1.JSX.Element;
455
475
 
476
+ /** Localized accessible labels for the audio controls. */
477
+ interface AudioPlayerLabels {
478
+ play?: string;
479
+ pause?: string;
480
+ seek?: string;
481
+ download?: string;
482
+ }
483
+ interface AudioPlayerProps {
484
+ /** Audio source URL or object URL. */
485
+ src: string;
486
+ /** Optional title shown above the controls. */
487
+ title?: string;
488
+ /** Show a download button linking to `src`; the value is the download filename. */
489
+ downloadName?: string;
490
+ /** Begin playing as soon as the source is ready. */
491
+ autoPlay?: boolean;
492
+ /** Localized `aria-label`s for the controls (defaults are English). */
493
+ labels?: AudioPlayerLabels;
494
+ className?: string;
495
+ }
496
+ /**
497
+ * A styled wrapper over `<audio>`: play/pause, a seekable progress bar, time
498
+ * readout, and an optional download button. Presentation only — no fetching.
499
+ */
500
+ declare function AudioPlayer({ src, title, downloadName, autoPlay, labels, className }: AudioPlayerProps): React$1.JSX.Element;
501
+
502
+ type MediaStatus = "pending" | "processing" | "completed" | "failed";
503
+ interface MediaResult {
504
+ /** Stable id (used as React key and passed back to callbacks). */
505
+ id: string;
506
+ /** Source URL of the finished media (may be a signed URL that can expire). */
507
+ url: string;
508
+ /** How to render the media. Defaults to `"image"`. */
509
+ kind?: "image" | "video" | "audio";
510
+ /** Prompt / caption shown under the media (clamped to 2 lines). */
511
+ prompt?: ReactNode;
512
+ /** Model id — the last path segment is shown in the meta row. */
513
+ model?: string;
514
+ /** Extra meta node appended to the caption row (e.g. size, duration, seed). */
515
+ meta?: ReactNode;
516
+ /** Generation lifecycle. Absent is treated as `"completed"`. */
517
+ status?: MediaStatus;
518
+ /** 0–100 progress while `pending`/`processing`. */
519
+ progress?: number;
520
+ /** Failure message shown in the error state. */
521
+ error?: string;
522
+ }
523
+ /** Copy overrides so hosts can localize the built-in status/aria strings. */
524
+ interface MediaGalleryLabels {
525
+ starting?: string;
526
+ processing?: string;
527
+ failed?: string;
528
+ expired?: string;
529
+ download?: string;
530
+ delete?: string;
531
+ gridView?: string;
532
+ listView?: string;
533
+ }
534
+ interface MediaGalleryProps {
535
+ /** The results to display, newest-first is conventional. */
536
+ items: MediaResult[];
537
+ /** Controlled view mode. Omit for uncontrolled (defaults to grid). */
538
+ viewMode?: "grid" | "list";
539
+ /** Called when the built-in grid/list toggle is used (renders the toggle). */
540
+ onViewModeChange?: (mode: "grid" | "list") => void;
541
+ /** Show a download control per completed item. */
542
+ onDownload?: (item: MediaResult) => void;
543
+ /** Show a delete control per item. */
544
+ onDelete?: (item: MediaResult) => void;
545
+ /** Make completed items clickable (e.g. open a lightbox). */
546
+ onPreview?: (item: MediaResult) => void;
547
+ /** Optional heading rendered above the gallery. */
548
+ title?: ReactNode;
549
+ /** Rendered in place of the grid when `items` is empty. */
550
+ empty?: ReactNode;
551
+ /** Localized copy for status/aria strings. */
552
+ labels?: MediaGalleryLabels;
553
+ className?: string;
554
+ }
555
+ /**
556
+ * A unified grid/list of generated media results (image · video · audio) with
557
+ * status, progress, expiry handling, and download/delete/preview controls.
558
+ * Shared across generation pages so every modality renders results identically.
559
+ */
560
+ declare function MediaGallery({ items, viewMode, onViewModeChange, onDownload, onDelete, onPreview, title, empty, labels, className, }: MediaGalleryProps): React$1.JSX.Element;
561
+
456
562
  type BannerTone = "info" | "warning" | "critical" | "success" | "neutral";
457
563
  interface BannerProps {
458
564
  /** Tone — drives the gradient, border, text and icon color. */
@@ -594,4 +700,4 @@ interface AvatarUploaderProps {
594
700
  }
595
701
  declare function AvatarUploader({ src, fallback, size, uploading, onSelectFile, label, className, }: AvatarUploaderProps): React$1.JSX.Element;
596
702
 
597
- export { AccountLockedCard, type AccountLockedCardProps, ActiveBadge, AvatarUploader, type AvatarUploaderProps, BackgroundEffects, Banner, type BannerProps, type BannerTone, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, type ConnectedAccountRowProps, DeprecatedBadge, ErrorBoundary, type ErrorBoundaryLabels, FAQ, type FAQItem, type FAQProps, FeatureLockedState, type FeatureLockedStateProps, FellowBadge, FellowsBanner, type FellowsBannerProps, LLMCopyButton, LinkRow, type LinkRowProps, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, MetricBar, type MetricBarProps, NotificationBell, type NotificationBellProps, NotificationItem, type NotificationItemProps, NotificationPanel, type NotificationPanelProps, PageEmptyState, PageErrorState, PageHeader, PageLoadingState, SessionItem, type SessionItemProps, SettingRow, type SettingRowProps, Sidebar, type SidebarNavItem, type SidebarProps, type SidebarSection, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
703
+ export { AccountLockedCard, type AccountLockedCardProps, ActiveBadge, AudioPlayer, type AudioPlayerProps, AvatarUploader, type AvatarUploaderProps, BackgroundEffects, Banner, type BannerProps, type BannerTone, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, type ConnectedAccountRowProps, DeprecatedBadge, ErrorBoundary, type ErrorBoundaryLabels, FAQ, type FAQItem, type FAQProps, FeatureLockedState, type FeatureLockedStateProps, FellowBadge, FellowsBanner, type FellowsBannerProps, LLMCopyButton, LinkRow, type LinkRowProps, MediaEmptyState, MediaErrorState, MediaGallery, type MediaGalleryLabels, type MediaGalleryProps, MediaLoadingState, MediaPageHeader, type MediaResult, type MediaStatus, MetricBar, type MetricBarProps, NotificationBell, type NotificationBellProps, NotificationItem, type NotificationItemProps, NotificationPanel, type NotificationPanelProps, PageEmptyState, PageErrorState, PageHeader, PageLayout, type PageLayoutProps, PageLoadingState, SessionItem, type SessionItemProps, SettingRow, type SettingRowProps, Sidebar, type SidebarNavItem, type SidebarProps, type SidebarSection, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
package/dist/patterns.js CHANGED
@@ -1,12 +1,15 @@
1
1
  "use client";
2
- import { Button, Card, Badge, Avatar, AvatarImage, AvatarFallback, IconButton, Spinner } from './chunk-VXFEANVX.js';
3
- import { copyToClipboard } from './chunk-N53PNMPJ.js';
4
- export { Footer } from './chunk-N53PNMPJ.js';
5
- import { cn } from './chunk-GHO4RCDR.js';
6
- import { useYunUI } from './chunk-U2LNRVMI.js';
2
+ import './chunk-5E3O6ANF.js';
3
+ import { copyToClipboard } from './chunk-UYYG4XDW.js';
4
+ export { Footer } from './chunk-UYYG4XDW.js';
5
+ import './chunk-GSPJ5YI6.js';
6
+ import { ImageLightbox } from './chunk-QEIBYOG2.js';
7
+ import { Button, Card, Badge, Avatar, AvatarImage, AvatarFallback, IconButton, Spinner } from './chunk-5TOGZTAO.js';
8
+ import { cn } from './chunk-AV5TGEJS.js';
9
+ import { useYunUI } from './chunk-3RT24MSH.js';
7
10
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
8
- import React, { useState, useEffect, useCallback, useRef } from 'react';
9
- import { AlertCircle, RefreshCw, Check, Copy, Plus, FileText, ExternalLink, Calendar, Clock, User, ChevronLeft, ChevronRight, PanelLeftClose, X, ArrowUpRight, ArrowDownRight, GraduationCap, ArrowRight, Award, Waves, SlidersHorizontal, Layers, Fingerprint, Ban, Image, Brain, Eye, Code, MessageSquare, XCircle, Zap, CheckCircle, FileCode, EyeOff, Sparkles, Globe, Loader2, LogOut, Bell, Trash2, Camera, Info, CheckCircle2, AlertTriangle } from 'lucide-react';
11
+ import React, { useState, useEffect, useCallback, useRef, useMemo } from 'react';
12
+ import { AlertCircle, RefreshCw, Check, Copy, Plus, FileText, ExternalLink, Calendar, Clock, User, ChevronLeft, ChevronRight, PanelLeftClose, X, ArrowUpRight, ArrowDownRight, GraduationCap, ArrowRight, Award, Waves, SlidersHorizontal, Layers, Fingerprint, Ban, Image, Brain, Eye, Code, MessageSquare, XCircle, Zap, CheckCircle, FileCode, EyeOff, Sparkles, Globe, Loader2, LogOut, Pause, Play, Download, Grid, List, Bell, Trash2, Camera, Info, CheckCircle2, AlertTriangle } from 'lucide-react';
10
13
 
11
14
  function BackgroundEffects() {
12
15
  return /* @__PURE__ */ jsx("div", { className: "absolute inset-0 -z-10 h-full w-full pointer-events-none select-none overflow-hidden bg-(--bg-base)", children: /* @__PURE__ */ jsx(
@@ -734,6 +737,21 @@ function PageHeader({ title, description, actions, className }) {
734
737
  actions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 shrink-0", children: actions })
735
738
  ] });
736
739
  }
740
+ function PageLayout({
741
+ children,
742
+ navbar,
743
+ footer,
744
+ hideFooter = false,
745
+ transparentBg = false,
746
+ mainClassName,
747
+ className
748
+ }) {
749
+ return /* @__PURE__ */ jsxs("div", { className: cn("min-h-dvh flex flex-col relative", !transparentBg && "bg-background", className), children: [
750
+ navbar,
751
+ /* @__PURE__ */ jsx("main", { className: cn("flex-1 pt-28", mainClassName), children }),
752
+ !hideFooter && footer
753
+ ] });
754
+ }
737
755
  function PageLoadingState({ message }) {
738
756
  return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-16", children: [
739
757
  /* @__PURE__ */ jsx(Spinner, { size: "lg" }),
@@ -1095,7 +1113,7 @@ function SessionItem({
1095
1113
  current && /* @__PURE__ */ jsx("span", { className: "text-[10px] px-1.5 py-0.5 rounded-full badge-success shrink-0", children: currentLabel }),
1096
1114
  inactive && /* @__PURE__ */ jsx("span", { className: "text-[10px] px-1.5 py-0.5 rounded-full badge-neutral shrink-0", children: inactiveLabel })
1097
1115
  ] }),
1098
- detail && /* @__PURE__ */ jsx("div", { className: "text-[10px] text-(--text-tertiary) mt-0.5", children: detail }),
1116
+ detail && /* @__PURE__ */ jsx("div", { className: "text-[10px] text-(--text-tertiary) mt-0.5 truncate", children: detail }),
1099
1117
  (ip != null || time != null) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 mt-1 text-[10px] text-(--text-tertiary)", children: [
1100
1118
  ip != null && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-0.5", children: [
1101
1119
  /* @__PURE__ */ jsx(Globe, { size: 8 }),
@@ -1143,6 +1161,441 @@ function MetricBar({ icon, label, value, percentage, color, className }) {
1143
1161
  ] })
1144
1162
  ] });
1145
1163
  }
1164
+ var fmtTime = (s) => {
1165
+ if (!Number.isFinite(s) || s < 0) return "0:00";
1166
+ const m = Math.floor(s / 60);
1167
+ const sec = Math.floor(s % 60);
1168
+ return `${m}:${sec.toString().padStart(2, "0")}`;
1169
+ };
1170
+ function AudioPlayer({ src, title, downloadName, autoPlay = false, labels, className }) {
1171
+ const audioRef = useRef(null);
1172
+ const [playing, setPlaying] = useState(false);
1173
+ const [current, setCurrent] = useState(0);
1174
+ const [duration, setDuration] = useState(0);
1175
+ useEffect(() => {
1176
+ setPlaying(false);
1177
+ setCurrent(0);
1178
+ setDuration(0);
1179
+ }, [src]);
1180
+ const toggle = () => {
1181
+ const el = audioRef.current;
1182
+ if (!el) return;
1183
+ if (el.paused) {
1184
+ void el.play();
1185
+ } else {
1186
+ el.pause();
1187
+ }
1188
+ };
1189
+ const seek = (e) => {
1190
+ const el = audioRef.current;
1191
+ if (!el) return;
1192
+ const t = Number(e.target.value);
1193
+ el.currentTime = t;
1194
+ setCurrent(t);
1195
+ };
1196
+ const pct = duration > 0 ? current / duration * 100 : 0;
1197
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-2 rounded-xl border border-border bg-card p-3", className), children: [
1198
+ title && /* @__PURE__ */ jsx("div", { className: "truncate text-sm font-medium", children: title }),
1199
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
1200
+ /* @__PURE__ */ jsx(
1201
+ "button",
1202
+ {
1203
+ type: "button",
1204
+ onClick: toggle,
1205
+ "aria-label": playing ? labels?.pause ?? "Pause" : labels?.play ?? "Play",
1206
+ className: "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-accent text-accent-foreground transition-opacity hover:opacity-90",
1207
+ children: playing ? /* @__PURE__ */ jsx(Pause, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(Play, { className: "h-4 w-4 translate-x-px" })
1208
+ }
1209
+ ),
1210
+ /* @__PURE__ */ jsx(
1211
+ "input",
1212
+ {
1213
+ type: "range",
1214
+ min: 0,
1215
+ max: duration || 0,
1216
+ step: "any",
1217
+ value: current,
1218
+ onChange: seek,
1219
+ "aria-label": labels?.seek ?? "Seek",
1220
+ className: "h-1.5 flex-1 cursor-pointer appearance-none rounded-full bg-muted accent-[var(--color-accent)]",
1221
+ style: {
1222
+ background: `linear-gradient(to right, var(--color-accent) ${pct}%, var(--color-muted) ${pct}%)`
1223
+ }
1224
+ }
1225
+ ),
1226
+ /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: [
1227
+ fmtTime(current),
1228
+ " / ",
1229
+ fmtTime(duration)
1230
+ ] }),
1231
+ downloadName && /* @__PURE__ */ jsx(
1232
+ "a",
1233
+ {
1234
+ href: src,
1235
+ download: downloadName,
1236
+ "aria-label": labels?.download ?? "Download audio",
1237
+ className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
1238
+ children: /* @__PURE__ */ jsx(Download, { className: "h-4 w-4" })
1239
+ }
1240
+ )
1241
+ ] }),
1242
+ /* @__PURE__ */ jsx(
1243
+ "audio",
1244
+ {
1245
+ ref: audioRef,
1246
+ src,
1247
+ autoPlay,
1248
+ onPlay: () => setPlaying(true),
1249
+ onPause: () => setPlaying(false),
1250
+ onTimeUpdate: (e) => setCurrent(e.currentTarget.currentTime),
1251
+ onLoadedMetadata: (e) => setDuration(e.currentTarget.duration),
1252
+ onEnded: () => setPlaying(false),
1253
+ className: "hidden"
1254
+ }
1255
+ )
1256
+ ] });
1257
+ }
1258
+ var DEFAULT_LABELS = {
1259
+ starting: "Starting\u2026",
1260
+ processing: "Processing\u2026",
1261
+ failed: "Generation failed",
1262
+ expired: "Media expired",
1263
+ download: "Download",
1264
+ delete: "Delete",
1265
+ gridView: "Grid view",
1266
+ listView: "List view"
1267
+ };
1268
+ function isUrlExpired(url) {
1269
+ try {
1270
+ const expires = new URL(url).searchParams.get("Expires");
1271
+ if (expires) {
1272
+ const ts = parseInt(expires, 10);
1273
+ return Date.now() / 1e3 > ts - 60;
1274
+ }
1275
+ } catch {
1276
+ return true;
1277
+ }
1278
+ return false;
1279
+ }
1280
+ function MediaBody({
1281
+ item,
1282
+ labels
1283
+ }) {
1284
+ const [loading, setLoading] = useState(true);
1285
+ const [loadFailed, setLoadFailed] = useState(false);
1286
+ const kind = item.kind ?? "image";
1287
+ const status = item.status ?? "completed";
1288
+ const isExpired = useMemo(() => {
1289
+ if (!item.url || item.url.startsWith("data:") || item.url.startsWith("blob:")) return false;
1290
+ return isUrlExpired(item.url);
1291
+ }, [item.url]);
1292
+ const isProcessing = status === "pending" || status === "processing";
1293
+ const showError = isExpired || loadFailed || status === "failed";
1294
+ if (isProcessing) {
1295
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center gap-2 bg-muted", children: [
1296
+ /* @__PURE__ */ jsx(Spinner, { size: "lg" }),
1297
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: status === "pending" ? labels.starting : labels.processing }),
1298
+ item.progress !== void 0 && item.progress > 0 && /* @__PURE__ */ jsx("div", { className: "mt-1 h-1.5 w-24 overflow-hidden rounded-full bg-muted-foreground/20", children: /* @__PURE__ */ jsx(
1299
+ "div",
1300
+ {
1301
+ className: "h-full bg-primary transition-all duration-300",
1302
+ style: { width: `${Math.min(item.progress, 95)}%` }
1303
+ }
1304
+ ) })
1305
+ ] });
1306
+ }
1307
+ if (showError) {
1308
+ return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center gap-1 bg-muted px-3 text-center", children: [
1309
+ /* @__PURE__ */ jsx(AlertCircle, { size: 22, className: "text-error" }),
1310
+ /* @__PURE__ */ jsx("span", { className: "text-xs text-error", children: status === "failed" ? labels.failed : labels.expired }),
1311
+ item.error && /* @__PURE__ */ jsx("span", { className: "mt-0.5 max-w-[85%] truncate text-xs text-error/70", children: item.error })
1312
+ ] });
1313
+ }
1314
+ if (kind === "audio") {
1315
+ return /* @__PURE__ */ jsx("div", { className: "flex h-full w-full items-center bg-muted/40 px-3", children: /* @__PURE__ */ jsx(AudioPlayer, { src: item.url, className: "w-full" }) });
1316
+ }
1317
+ if (kind === "video") {
1318
+ return (
1319
+ // eslint-disable-next-line jsx-a11y/media-has-caption
1320
+ /* @__PURE__ */ jsx(
1321
+ "video",
1322
+ {
1323
+ src: item.url,
1324
+ controls: true,
1325
+ className: "h-full w-full bg-black object-contain",
1326
+ onLoadedData: () => setLoading(false),
1327
+ onError: () => {
1328
+ setLoading(false);
1329
+ setLoadFailed(true);
1330
+ }
1331
+ }
1332
+ )
1333
+ );
1334
+ }
1335
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1336
+ loading && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 animate-pulse bg-muted" }),
1337
+ /* @__PURE__ */ jsx(
1338
+ "img",
1339
+ {
1340
+ src: item.url,
1341
+ alt: typeof item.prompt === "string" ? item.prompt : "",
1342
+ className: cn("h-full w-full object-cover", loading && "opacity-0"),
1343
+ onLoad: () => setLoading(false),
1344
+ onError: () => {
1345
+ setLoading(false);
1346
+ setLoadFailed(true);
1347
+ }
1348
+ }
1349
+ )
1350
+ ] });
1351
+ }
1352
+ function MediaCard({
1353
+ item,
1354
+ index,
1355
+ view,
1356
+ onDownload,
1357
+ onDelete,
1358
+ onPreview,
1359
+ labels
1360
+ }) {
1361
+ const status = item.status ?? "completed";
1362
+ const kind = item.kind ?? "image";
1363
+ const isProcessing = status === "pending" || status === "processing";
1364
+ const isDone = status === "completed";
1365
+ const canPreview = Boolean(onPreview) && isDone && kind === "image";
1366
+ const modelShort = item.model?.split("/").pop();
1367
+ const caption = /* @__PURE__ */ jsxs("div", { className: cn(view === "list" ? "min-w-0 flex-1" : "p-3"), children: [
1368
+ item.prompt !== void 0 && /* @__PURE__ */ jsx("div", { className: "line-clamp-2 text-sm", children: item.prompt }),
1369
+ (modelShort || item.meta) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
1370
+ modelShort && /* @__PURE__ */ jsx("span", { className: "truncate", children: modelShort }),
1371
+ modelShort && item.meta && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "\u2022" }),
1372
+ item.meta
1373
+ ] })
1374
+ ] });
1375
+ const overlayBtn = "flex h-9 w-9 items-center justify-center rounded-full bg-card text-foreground shadow-md ring-1 ring-border backdrop-blur transition hover:scale-105 disabled:pointer-events-none disabled:opacity-40";
1376
+ const actions = (onDownload || onDelete) && (view === "grid" ? /* @__PURE__ */ jsxs("div", { className: "absolute inset-0 flex items-center justify-center gap-2.5 bg-foreground/0 opacity-0 transition-all group-hover:bg-foreground/30 group-hover:opacity-100", children: [
1377
+ onDownload && /* @__PURE__ */ jsx(
1378
+ "button",
1379
+ {
1380
+ type: "button",
1381
+ className: overlayBtn,
1382
+ disabled: !isDone,
1383
+ "aria-label": labels.download,
1384
+ onClick: (e) => {
1385
+ e.stopPropagation();
1386
+ onDownload(item);
1387
+ },
1388
+ children: /* @__PURE__ */ jsx(Download, { size: 18 })
1389
+ }
1390
+ ),
1391
+ onDelete && /* @__PURE__ */ jsx(
1392
+ "button",
1393
+ {
1394
+ type: "button",
1395
+ className: cn(overlayBtn, "text-error"),
1396
+ "aria-label": labels.delete,
1397
+ onClick: (e) => {
1398
+ e.stopPropagation();
1399
+ onDelete(item);
1400
+ },
1401
+ children: /* @__PURE__ */ jsx(Trash2, { size: 18 })
1402
+ }
1403
+ )
1404
+ ] }) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1405
+ onDownload && /* @__PURE__ */ jsx(
1406
+ Button,
1407
+ {
1408
+ size: "icon",
1409
+ variant: "ghost",
1410
+ disabled: !isDone,
1411
+ "aria-label": labels.download,
1412
+ onClick: (e) => {
1413
+ e.stopPropagation();
1414
+ onDownload(item);
1415
+ },
1416
+ children: /* @__PURE__ */ jsx(Download, { size: 16 })
1417
+ }
1418
+ ),
1419
+ onDelete && /* @__PURE__ */ jsx(
1420
+ Button,
1421
+ {
1422
+ size: "icon",
1423
+ variant: "ghost",
1424
+ "aria-label": labels.delete,
1425
+ onClick: (e) => {
1426
+ e.stopPropagation();
1427
+ onDelete(item);
1428
+ },
1429
+ children: /* @__PURE__ */ jsx(Trash2, { size: 16, className: "text-error" })
1430
+ }
1431
+ )
1432
+ ] }));
1433
+ if (kind === "audio") {
1434
+ const showError = status === "failed";
1435
+ return /* @__PURE__ */ jsxs("div", { className: "card space-y-2.5 p-3", children: [
1436
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
1437
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
1438
+ item.prompt !== void 0 && /* @__PURE__ */ jsx("div", { className: "line-clamp-2 text-sm", children: item.prompt }),
1439
+ (modelShort || item.meta) && /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-wrap items-center gap-2 text-xs text-muted-foreground", children: [
1440
+ modelShort && /* @__PURE__ */ jsx("span", { className: "truncate", children: modelShort }),
1441
+ modelShort && item.meta && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/40", children: "\u2022" }),
1442
+ item.meta
1443
+ ] })
1444
+ ] }),
1445
+ (onDownload || onDelete) && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [
1446
+ onDownload && /* @__PURE__ */ jsx(
1447
+ Button,
1448
+ {
1449
+ size: "icon",
1450
+ variant: "ghost",
1451
+ disabled: !isDone,
1452
+ "aria-label": labels.download,
1453
+ onClick: () => onDownload(item),
1454
+ children: /* @__PURE__ */ jsx(Download, { size: 16 })
1455
+ }
1456
+ ),
1457
+ onDelete && /* @__PURE__ */ jsx(
1458
+ Button,
1459
+ {
1460
+ size: "icon",
1461
+ variant: "ghost",
1462
+ "aria-label": labels.delete,
1463
+ onClick: () => onDelete(item),
1464
+ children: /* @__PURE__ */ jsx(Trash2, { size: 16, className: "text-error" })
1465
+ }
1466
+ )
1467
+ ] })
1468
+ ] }),
1469
+ isProcessing ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 py-2 text-xs text-muted-foreground", children: [
1470
+ /* @__PURE__ */ jsx(Spinner, { size: "sm" }),
1471
+ " ",
1472
+ status === "pending" ? labels.starting : labels.processing
1473
+ ] }) : showError ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 py-2 text-xs text-error", children: [
1474
+ /* @__PURE__ */ jsx(AlertCircle, { size: 14 }),
1475
+ " ",
1476
+ labels.failed,
1477
+ item.error ? `: ${item.error}` : ""
1478
+ ] }) : /* @__PURE__ */ jsx(AudioPlayer, { src: item.url, className: "w-full" })
1479
+ ] });
1480
+ }
1481
+ if (view === "list") {
1482
+ return /* @__PURE__ */ jsxs("div", { className: "card flex items-center gap-3 p-3", children: [
1483
+ /* @__PURE__ */ jsx("div", { className: "relative h-16 w-16 shrink-0 overflow-hidden rounded-md bg-muted", children: /* @__PURE__ */ jsx(MediaBody, { item, labels }) }),
1484
+ caption,
1485
+ actions
1486
+ ] });
1487
+ }
1488
+ return /* @__PURE__ */ jsxs(
1489
+ "div",
1490
+ {
1491
+ className: cn(
1492
+ "card group animate-enter overflow-hidden",
1493
+ canPreview && "cursor-pointer"
1494
+ ),
1495
+ style: { animationDelay: `${Math.min(index, 10) * 50}ms` },
1496
+ onClick: () => canPreview && onPreview?.(item),
1497
+ children: [
1498
+ /* @__PURE__ */ jsxs("div", { className: "relative aspect-square", children: [
1499
+ /* @__PURE__ */ jsx(MediaBody, { item, labels }),
1500
+ !isProcessing && actions
1501
+ ] }),
1502
+ caption
1503
+ ]
1504
+ }
1505
+ );
1506
+ }
1507
+ function MediaGallery({
1508
+ items,
1509
+ viewMode,
1510
+ onViewModeChange,
1511
+ onDownload,
1512
+ onDelete,
1513
+ onPreview,
1514
+ title,
1515
+ empty,
1516
+ labels,
1517
+ className
1518
+ }) {
1519
+ const [internalView, setInternalView] = useState("grid");
1520
+ const view = viewMode ?? internalView;
1521
+ const setView = onViewModeChange ?? setInternalView;
1522
+ const showToggle = Boolean(onViewModeChange) || items.length > 0;
1523
+ const l = { ...DEFAULT_LABELS, ...labels };
1524
+ const [lightbox, setLightbox] = useState(null);
1525
+ const handlePreview = (item) => {
1526
+ if (onPreview) onPreview(item);
1527
+ else setLightbox(item);
1528
+ };
1529
+ return /* @__PURE__ */ jsxs("div", { className, children: [
1530
+ /* @__PURE__ */ jsx(
1531
+ ImageLightbox,
1532
+ {
1533
+ src: lightbox?.url,
1534
+ alt: typeof lightbox?.prompt === "string" ? lightbox.prompt : "",
1535
+ isOpen: lightbox !== null,
1536
+ onClose: () => setLightbox(null)
1537
+ }
1538
+ ),
1539
+ (title || showToggle) && /* @__PURE__ */ jsxs("div", { className: "mb-4 flex items-center justify-between gap-3", children: [
1540
+ title ? /* @__PURE__ */ jsx("h2", { className: "heading-md", children: title }) : /* @__PURE__ */ jsx("span", {}),
1541
+ showToggle && /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
1542
+ /* @__PURE__ */ jsx(
1543
+ "button",
1544
+ {
1545
+ type: "button",
1546
+ onClick: () => setView("grid"),
1547
+ "aria-label": l.gridView,
1548
+ "aria-pressed": view === "grid",
1549
+ className: cn(
1550
+ "rounded-lg p-2 transition-colors",
1551
+ view === "grid" ? "bg-muted" : "hover:bg-muted/50"
1552
+ ),
1553
+ children: /* @__PURE__ */ jsx(Grid, { size: 16 })
1554
+ }
1555
+ ),
1556
+ /* @__PURE__ */ jsx(
1557
+ "button",
1558
+ {
1559
+ type: "button",
1560
+ onClick: () => setView("list"),
1561
+ "aria-label": l.listView,
1562
+ "aria-pressed": view === "list",
1563
+ className: cn(
1564
+ "rounded-lg p-2 transition-colors",
1565
+ view === "list" ? "bg-muted" : "hover:bg-muted/50"
1566
+ ),
1567
+ children: /* @__PURE__ */ jsx(List, { size: 16 })
1568
+ }
1569
+ )
1570
+ ] })
1571
+ ] }),
1572
+ items.length === 0 ? empty ?? null : view === "grid" ? /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4", children: items.map((item, i) => /* @__PURE__ */ jsx(
1573
+ MediaCard,
1574
+ {
1575
+ item,
1576
+ index: i,
1577
+ view: "grid",
1578
+ onDownload,
1579
+ onDelete,
1580
+ onPreview: handlePreview,
1581
+ labels: l
1582
+ },
1583
+ item.id
1584
+ )) }) : /* @__PURE__ */ jsx("div", { className: "space-y-2", children: items.map((item, i) => /* @__PURE__ */ jsx(
1585
+ MediaCard,
1586
+ {
1587
+ item,
1588
+ index: i,
1589
+ view: "list",
1590
+ onDownload,
1591
+ onDelete,
1592
+ onPreview: handlePreview,
1593
+ labels: l
1594
+ },
1595
+ item.id
1596
+ )) })
1597
+ ] });
1598
+ }
1146
1599
  var TONES2 = {
1147
1600
  info: {
1148
1601
  bg: "bg-linear-to-r from-blue-500/10 via-blue-500/5 to-blue-500/10",
@@ -1332,7 +1785,7 @@ function LinkRow({ icon, title, description, href, external, className }) {
1332
1785
  const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
1333
1786
  icon != null && /* @__PURE__ */ jsx("span", { className: "text-(--text-tertiary) shrink-0", children: icon }),
1334
1787
  /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
1335
- /* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: title }),
1788
+ /* @__PURE__ */ jsx("div", { className: "text-sm font-medium truncate", children: title }),
1336
1789
  description && /* @__PURE__ */ jsx("div", { className: "text-xs text-(--text-tertiary) truncate", children: description })
1337
1790
  ] }),
1338
1791
  /* @__PURE__ */ jsx(ChevronRight, { size: 16, className: "text-(--text-muted) shrink-0" })
@@ -1438,6 +1891,6 @@ function AvatarUploader({
1438
1891
  );
1439
1892
  }
1440
1893
 
1441
- export { AccountLockedCard, ActiveBadge, AvatarUploader, BackgroundEffects, Banner, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, DeprecatedBadge, ErrorBoundary, FAQ, FeatureLockedState, FellowBadge, FellowsBanner, LLMCopyButton, LinkRow, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, MetricBar, NotificationBell, NotificationItem, NotificationPanel, PageEmptyState, PageErrorState, PageHeader, PageLoadingState, SessionItem, SettingRow, Sidebar, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
1894
+ export { AccountLockedCard, ActiveBadge, AudioPlayer, AvatarUploader, BackgroundEffects, Banner, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, DeprecatedBadge, ErrorBoundary, FAQ, FeatureLockedState, FellowBadge, FellowsBanner, LLMCopyButton, LinkRow, MediaEmptyState, MediaErrorState, MediaGallery, MediaLoadingState, MediaPageHeader, MetricBar, NotificationBell, NotificationItem, NotificationPanel, PageEmptyState, PageErrorState, PageHeader, PageLayout, PageLoadingState, SessionItem, SettingRow, Sidebar, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
1442
1895
  //# sourceMappingURL=patterns.js.map
1443
1896
  //# sourceMappingURL=patterns.js.map