@devalok/shilp-sutra 0.33.2 → 0.34.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/dist/_chunks/badge-group.js +306 -246
  2. package/dist/_chunks/chat.js +513 -0
  3. package/dist/_chunks/date-picker.js +748 -0
  4. package/dist/_chunks/document-preview.js +109 -90
  5. package/dist/_chunks/file-preview.js +492 -504
  6. package/dist/_chunks/framer.js +5564 -5613
  7. package/dist/_chunks/image-preview.js +127 -88
  8. package/dist/_chunks/keybinding.js +12 -14
  9. package/dist/_chunks/link-context.js +19 -16
  10. package/dist/_chunks/mention-suggestion.js +353 -350
  11. package/dist/_chunks/motion-provider.js +26 -20
  12. package/dist/_chunks/popover.js +127 -0
  13. package/dist/_chunks/primitives.js +7584 -6425
  14. package/dist/_chunks/rich-chat-input.js +2070 -0
  15. package/dist/_chunks/rolldown-runtime.js +21 -0
  16. package/dist/_chunks/shared.js +126 -0
  17. package/dist/_chunks/sonner.js +605 -734
  18. package/dist/_chunks/stat-row.js +418 -440
  19. package/dist/_chunks/tiptap.js +15850 -19964
  20. package/dist/_chunks/tree-view.js +231 -290
  21. package/dist/_chunks/use-calendar.js +161 -208
  22. package/dist/_chunks/vendor-client.js +314 -2199
  23. package/dist/_chunks/vendor-utils.js +1721 -2978
  24. package/dist/ai/ai-command-provider.js +23 -17
  25. package/dist/ai/block-renderer.js +68 -51
  26. package/dist/ai/blocks/index.js +2 -12
  27. package/dist/ai/command-bar.js +470 -519
  28. package/dist/ai/conversation.js +241 -227
  29. package/dist/ai/index.js +181 -167
  30. package/dist/ai/types.js +0 -1
  31. package/dist/composed/activity-feed.js +232 -202
  32. package/dist/composed/avatar-group.js +164 -222
  33. package/dist/composed/bulk-action-bar.js +174 -165
  34. package/dist/composed/command-palette.js +290 -308
  35. package/dist/composed/confirm-dialog.js +28 -48
  36. package/dist/composed/content-card.js +69 -108
  37. package/dist/composed/date-picker/index.js +3 -13
  38. package/dist/composed/deadline-indicator.js +68 -74
  39. package/dist/composed/emoji-picker.js +83 -110
  40. package/dist/composed/empty-state.js +64 -103
  41. package/dist/composed/error-boundary.js +129 -127
  42. package/dist/composed/file-preview.js +2 -12
  43. package/dist/composed/filter-bar.js +98 -130
  44. package/dist/composed/form-section.js +61 -45
  45. package/dist/composed/global-loading.js +34 -47
  46. package/dist/composed/index.js +34 -92
  47. package/dist/composed/inline-edit.js +92 -107
  48. package/dist/composed/lib/string-utils.js +8 -8
  49. package/dist/composed/loading-skeleton.js +103 -171
  50. package/dist/composed/markdown-viewer.js +187 -139
  51. package/dist/composed/master-detail.js +147 -156
  52. package/dist/composed/member-picker.js +46 -49
  53. package/dist/composed/multi-select-popover.js +181 -179
  54. package/dist/composed/page-header.js +54 -76
  55. package/dist/composed/page-skeletons.js +143 -127
  56. package/dist/composed/priority-indicator.js +105 -111
  57. package/dist/composed/responsive-overlay.js +36 -41
  58. package/dist/composed/rich-chat-input.js +2 -1860
  59. package/dist/composed/rich-text-editor.js +561 -424
  60. package/dist/composed/schedule-view.js +134 -185
  61. package/dist/composed/simple-tooltip.js +21 -21
  62. package/dist/composed/status-badge.js +133 -137
  63. package/dist/hooks/index.js +7 -12
  64. package/dist/hooks/use-color-mode.js +28 -25
  65. package/dist/hooks/use-mobile.js +13 -13
  66. package/dist/hooks/use-toast.js +2 -4
  67. package/dist/hooks/use-touch-device.js +9 -11
  68. package/dist/hooks/use-viewport-height.js +14 -14
  69. package/dist/motion/index.js +3 -11
  70. package/dist/motion/primitives-index.js +226 -186
  71. package/dist/shell/app-command-palette.js +203 -234
  72. package/dist/shell/bottom-navbar.js +150 -190
  73. package/dist/shell/command-registry.js +13 -14
  74. package/dist/shell/index.js +10 -20
  75. package/dist/shell/link-context.js +2 -5
  76. package/dist/shell/notification-center.js +238 -259
  77. package/dist/shell/notification-preferences.js +241 -184
  78. package/dist/shell/sidebar.js +251 -281
  79. package/dist/shell/top-bar.js +203 -237
  80. package/dist/tailwind/index.cjs +426 -451
  81. package/dist/tailwind/index.js +2 -4
  82. package/dist/tailwind/preset.d.ts.map +1 -1
  83. package/dist/tailwind/preset.js +443 -468
  84. package/dist/ui/accordion.js +52 -60
  85. package/dist/ui/alert-dialog.js +111 -156
  86. package/dist/ui/alert.js +177 -99
  87. package/dist/ui/aspect-ratio.js +13 -16
  88. package/dist/ui/autocomplete.js +112 -148
  89. package/dist/ui/avatar.js +196 -169
  90. package/dist/ui/badge-group.js +2 -7
  91. package/dist/ui/badge-indicator.js +42 -51
  92. package/dist/ui/badge.js +2 -15
  93. package/dist/ui/banner.js +76 -68
  94. package/dist/ui/breadcrumb.js +65 -84
  95. package/dist/ui/button-group.js +109 -102
  96. package/dist/ui/button-processing.js +69 -73
  97. package/dist/ui/button.js +393 -279
  98. package/dist/ui/card.js +151 -157
  99. package/dist/ui/charts/index.js +1002 -1319
  100. package/dist/ui/chat/index.js +2 -11
  101. package/dist/ui/checkbox.js +77 -100
  102. package/dist/ui/code.js +18 -32
  103. package/dist/ui/collapsible.js +21 -29
  104. package/dist/ui/color-input.js +453 -372
  105. package/dist/ui/color-swatch.js +60 -90
  106. package/dist/ui/combobox.js +244 -293
  107. package/dist/ui/container.js +18 -24
  108. package/dist/ui/context-menu.js +154 -203
  109. package/dist/ui/data-table-body.js +116 -213
  110. package/dist/ui/data-table-bulk-actions.js +43 -59
  111. package/dist/ui/data-table-card.js +84 -71
  112. package/dist/ui/data-table-context.js +39 -42
  113. package/dist/ui/data-table-header.js +98 -139
  114. package/dist/ui/data-table-pagination.js +69 -82
  115. package/dist/ui/data-table-toolbar.js +104 -130
  116. package/dist/ui/data-table.js +278 -354
  117. package/dist/ui/devalok-grain.js +77 -66
  118. package/dist/ui/dialog.js +122 -151
  119. package/dist/ui/dropdown-menu.js +152 -203
  120. package/dist/ui/file-upload.js +242 -266
  121. package/dist/ui/form.js +60 -56
  122. package/dist/ui/hover-card.js +54 -54
  123. package/dist/ui/icon-button.js +21 -26
  124. package/dist/ui/icon-context.js +17 -17
  125. package/dist/ui/icon-group.js +22 -29
  126. package/dist/ui/icon.js +201 -121
  127. package/dist/ui/index.js +74 -350
  128. package/dist/ui/input-otp.d.ts.map +1 -1
  129. package/dist/ui/input-otp.js +44 -48
  130. package/dist/ui/input.js +92 -169
  131. package/dist/ui/label.js +17 -22
  132. package/dist/ui/lib/date-utils.js +14 -11
  133. package/dist/ui/lib/motion.js +77 -36
  134. package/dist/ui/lib/utils.js +39 -16
  135. package/dist/ui/link.js +13 -24
  136. package/dist/ui/menubar.js +132 -210
  137. package/dist/ui/navigation-menu.js +164 -194
  138. package/dist/ui/number-input.js +72 -95
  139. package/dist/ui/pagination.js +122 -159
  140. package/dist/ui/popover.js +2 -131
  141. package/dist/ui/progress-ring.js +133 -143
  142. package/dist/ui/progress.js +51 -95
  143. package/dist/ui/radio.js +41 -50
  144. package/dist/ui/search-input.js +51 -53
  145. package/dist/ui/segmented-control.js +93 -114
  146. package/dist/ui/select.js +131 -157
  147. package/dist/ui/separator.js +15 -25
  148. package/dist/ui/sheet.js +135 -163
  149. package/dist/ui/sidebar.js +357 -600
  150. package/dist/ui/skeleton.js +179 -231
  151. package/dist/ui/slider.js +24 -34
  152. package/dist/ui/spinner.js +226 -205
  153. package/dist/ui/split-button.js +227 -276
  154. package/dist/ui/stack.js +56 -70
  155. package/dist/ui/stat-card.js +259 -251
  156. package/dist/ui/status-dot.js +67 -63
  157. package/dist/ui/stepper.js +119 -168
  158. package/dist/ui/switch.js +51 -54
  159. package/dist/ui/table.js +57 -90
  160. package/dist/ui/tabs.js +139 -156
  161. package/dist/ui/text.js +52 -59
  162. package/dist/ui/textarea.js +40 -57
  163. package/dist/ui/toast-types.js +0 -1
  164. package/dist/ui/toast.js +554 -536
  165. package/dist/ui/toaster.js +23 -33
  166. package/dist/ui/toggle-group.js +37 -41
  167. package/dist/ui/toggle.js +36 -40
  168. package/dist/ui/tooltip.js +80 -65
  169. package/dist/ui/tree-view/index.js +2 -6
  170. package/dist/ui/visually-hidden.js +12 -10
  171. package/llms-full.txt +1 -1
  172. package/llms.txt +12 -0
  173. package/package.json +3 -3
  174. package/dist/_chunks/date-time-picker.js +0 -851
  175. package/dist/_chunks/typing-indicator.js +0 -565
@@ -1,511 +1,499 @@
1
1
  "use client";
2
- import { jsxs as u, jsx as e } from "react/jsx-runtime";
3
- import * as a from "react";
4
- import { cn as D } from "../ui/lib/utils.js";
5
- import { Skeleton as X } from "../ui/skeleton.js";
6
- import { Button as V } from "../ui/button.js";
7
- import { Icon as x } from "../ui/icon.js";
8
- import { B as q } from "./badge-group.js";
9
- import { IconAlertTriangle as H, IconDownload as _, IconVolumeOff as O, IconVolume as Y, IconPlayerPlay as F, IconPlayerPause as K, IconMaximize as G } from "@tabler/icons-react";
10
- import { tweens as j, springs as J } from "../ui/lib/motion.js";
11
- import { m as $, A as Q } from "./framer.js";
12
- function U({ message: t, url: o }) {
13
- return /* @__PURE__ */ u("div", { className: "flex flex-col items-center justify-center gap-ds-04 rounded-ds-md border border-surface-border bg-surface-sunken p-ds-08 text-center", children: [
14
- /* @__PURE__ */ e(x, { icon: H, size: "2xl", className: "text-warning-9" }),
15
- /* @__PURE__ */ u("div", { children: [
16
- /* @__PURE__ */ e("p", { className: "text-ds-md font-semibold text-surface-fg", children: "Preview unavailable" }),
17
- /* @__PURE__ */ e("p", { className: "text-ds-sm text-surface-fg-muted mt-ds-01", children: t })
18
- ] }),
19
- /* @__PURE__ */ e(V, { variant: "outline", size: "xs", startIcon: /* @__PURE__ */ e(x, { icon: _ }), asChild: !0, children: /* @__PURE__ */ e("a", { href: o, download: !0, target: "_blank", rel: "noopener noreferrer", children: "Download file" }) })
20
- ] });
2
+ import { a as e, c as t } from "./framer.js";
3
+ import { springs as n, tweens as r } from "../ui/lib/motion.js";
4
+ import { cn as i } from "../ui/lib/utils.js";
5
+ import { Icon as a } from "../ui/icon.js";
6
+ import { n as o } from "./badge-group.js";
7
+ import { Button as s } from "../ui/button.js";
8
+ import { Skeleton as c } from "../ui/skeleton.js";
9
+ import { a as l, i as u, t as d } from "./shared.js";
10
+ import * as f from "react";
11
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
12
+ import { IconDownload as h, IconMaximize as g, IconPlayerPause as _, IconPlayerPlay as v } from "@tabler/icons-react";
13
+ //#region src/composed/file-preview/video-preview.tsx
14
+ var y = [
15
+ .5,
16
+ .75,
17
+ 1,
18
+ 1.25,
19
+ 1.5,
20
+ 2
21
+ ];
22
+ function b({ url: i, onError: o }) {
23
+ let s = f.useRef(null), c = f.useRef(null), [h, b] = f.useState(!1), [x, S] = f.useState(0), [C, w] = f.useState(0), [T, E] = f.useState(0), [D, O] = f.useState(!1), [k, A] = f.useState(!1), [j, M] = f.useState(!0), [N, P] = f.useState(1), F = f.useRef(void 0);
24
+ f.useEffect(() => () => clearTimeout(F.current), []), f.useEffect(() => {
25
+ function e(e) {
26
+ let t = c.current;
27
+ if (!t || !t.contains(document.activeElement) && document.activeElement !== t) return;
28
+ let n = s.current;
29
+ if (n) switch (e.key) {
30
+ case " ":
31
+ case "k":
32
+ e.preventDefault(), b((e) => (e ? n.pause() : n.play(), !e));
33
+ break;
34
+ case "ArrowRight":
35
+ e.preventDefault(), n.currentTime = Math.min(n.duration, n.currentTime + 5);
36
+ break;
37
+ case "ArrowLeft":
38
+ e.preventDefault(), n.currentTime = Math.max(0, n.currentTime - 5);
39
+ break;
40
+ case "j":
41
+ e.preventDefault(), n.currentTime = Math.max(0, n.currentTime - 10);
42
+ break;
43
+ case "l":
44
+ e.preventDefault(), n.currentTime = Math.min(n.duration, n.currentTime + 10);
45
+ break;
46
+ case "m":
47
+ e.preventDefault(), O((e) => (n.muted = !e, !e));
48
+ break;
49
+ case "f":
50
+ e.preventDefault(), n.requestFullscreen?.();
51
+ break;
52
+ case ">":
53
+ e.preventDefault(), I(1);
54
+ break;
55
+ case "<":
56
+ e.preventDefault(), I(-1);
57
+ break;
58
+ }
59
+ }
60
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
61
+ }, []);
62
+ function I(e) {
63
+ let t = y.indexOf(N), n = y[Math.max(0, Math.min(y.length - 1, t + e))];
64
+ P(n), s.current && (s.current.playbackRate = n);
65
+ }
66
+ function L() {
67
+ s.current && (h ? s.current.pause() : s.current.play(), b(!h));
68
+ }
69
+ function R(e) {
70
+ if (!s.current || !C) return;
71
+ let t = e.currentTarget.getBoundingClientRect(), n = (e.clientX - t.left) / t.width;
72
+ s.current.currentTime = n * C;
73
+ }
74
+ function z() {
75
+ M(!0), clearTimeout(F.current), h && (F.current = setTimeout(() => M(!1), 3e3));
76
+ }
77
+ return k ? /* @__PURE__ */ p(d, {
78
+ message: "Could not load video",
79
+ url: i
80
+ }) : /* @__PURE__ */ m("div", {
81
+ ref: c,
82
+ className: "group relative rounded-ds-md bg-black overflow-hidden",
83
+ onMouseMove: z,
84
+ onMouseLeave: () => h && M(!1),
85
+ tabIndex: -1,
86
+ children: [
87
+ /* @__PURE__ */ p("video", {
88
+ ref: s,
89
+ src: i,
90
+ className: "max-h-[70vh] w-full",
91
+ onClick: L,
92
+ muted: D,
93
+ onTimeUpdate: () => {
94
+ s.current && (E(s.current.currentTime), s.current.duration && S(s.current.currentTime / s.current.duration * 100));
95
+ },
96
+ onLoadedMetadata: () => w(s.current?.duration ?? 0),
97
+ onEnded: () => {
98
+ b(!1), M(!0);
99
+ },
100
+ onError: () => {
101
+ A(!0), o?.("Video failed to load");
102
+ },
103
+ playsInline: !0
104
+ }),
105
+ !h && /* @__PURE__ */ p(e.button, {
106
+ initial: {
107
+ opacity: 0,
108
+ scale: .8
109
+ },
110
+ animate: {
111
+ opacity: 1,
112
+ scale: 1
113
+ },
114
+ transition: n.snappy,
115
+ onClick: L,
116
+ className: "absolute inset-0 flex items-center justify-center bg-black/30",
117
+ "aria-label": "Play video",
118
+ children: /* @__PURE__ */ p("div", {
119
+ className: "flex h-14 w-14 items-center justify-center rounded-full bg-white/90 shadow-floating",
120
+ children: /* @__PURE__ */ p(a, {
121
+ icon: v,
122
+ size: "xl",
123
+ className: "text-surface-fg ml-0.5"
124
+ })
125
+ })
126
+ }),
127
+ /* @__PURE__ */ p(t, { children: j && C > 0 && /* @__PURE__ */ m(e.div, {
128
+ initial: {
129
+ opacity: 0,
130
+ y: 10
131
+ },
132
+ animate: {
133
+ opacity: 1,
134
+ y: 0
135
+ },
136
+ exit: {
137
+ opacity: 0,
138
+ y: 10
139
+ },
140
+ transition: r.fade,
141
+ className: "absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/80 to-transparent px-ds-04 pb-ds-04 pt-ds-08",
142
+ children: [/* @__PURE__ */ m("div", {
143
+ className: "relative h-1 w-full cursor-pointer rounded-full bg-white/30 mb-ds-03 group/progress",
144
+ onClick: R,
145
+ role: "slider",
146
+ "aria-label": "Video progress",
147
+ "aria-valuenow": Math.round(x),
148
+ "aria-valuemin": 0,
149
+ "aria-valuemax": 100,
150
+ tabIndex: 0,
151
+ children: [/* @__PURE__ */ p("div", {
152
+ className: "absolute left-0 top-0 h-full rounded-full bg-white transition-[width] duration-75",
153
+ style: { width: `${x}%` }
154
+ }), /* @__PURE__ */ p("div", {
155
+ className: "absolute top-1/2 -translate-y-1/2 h-3 w-3 rounded-full bg-white shadow-raised opacity-0 group-hover/progress:opacity-100 transition-opacity",
156
+ style: {
157
+ left: `${x}%`,
158
+ marginLeft: "-6px"
159
+ }
160
+ })]
161
+ }), /* @__PURE__ */ m("div", {
162
+ className: "flex items-center gap-ds-03",
163
+ children: [
164
+ /* @__PURE__ */ p("button", {
165
+ onClick: L,
166
+ className: "text-white hover:text-white/80",
167
+ "aria-label": h ? "Pause" : "Play",
168
+ title: h ? "Pause" : "Play",
169
+ children: h ? /* @__PURE__ */ p(a, {
170
+ icon: _,
171
+ size: "lg"
172
+ }) : /* @__PURE__ */ p(a, {
173
+ icon: v,
174
+ size: "lg"
175
+ })
176
+ }),
177
+ /* @__PURE__ */ p(u, {
178
+ volume: +!D,
179
+ muted: D,
180
+ onVolumeChange: (e) => {
181
+ s.current && (s.current.volume = e), e > 0 && D && (O(!1), s.current && (s.current.muted = !1));
182
+ },
183
+ onMuteToggle: () => {
184
+ O(!D), s.current && (s.current.muted = !D);
185
+ },
186
+ variant: "dark"
187
+ }),
188
+ /* @__PURE__ */ m("span", {
189
+ className: "text-[11px] font-mono text-white/70 tabular-nums",
190
+ children: [
191
+ l(T),
192
+ " / ",
193
+ l(C)
194
+ ]
195
+ }),
196
+ /* @__PURE__ */ p("div", { className: "flex-1" }),
197
+ /* @__PURE__ */ m("button", {
198
+ onClick: () => I(1),
199
+ className: "text-[11px] font-mono text-white/70 hover:text-white px-1 rounded-ds-sm hover:bg-white/10 transition-colors",
200
+ "aria-label": `Playback speed: ${N}x`,
201
+ children: [N, "x"]
202
+ }),
203
+ /* @__PURE__ */ p("button", {
204
+ onClick: () => s.current?.requestFullscreen?.(),
205
+ className: "text-white hover:text-white/80",
206
+ "aria-label": "Fullscreen (F)",
207
+ title: "Fullscreen",
208
+ children: /* @__PURE__ */ p(a, {
209
+ icon: g,
210
+ size: "sm"
211
+ })
212
+ })
213
+ ]
214
+ })]
215
+ }) })
216
+ ]
217
+ });
21
218
  }
22
- function pe({ children: t, className: o }) {
23
- return /* @__PURE__ */ e(
24
- $.div,
25
- {
26
- initial: { opacity: 0, y: 8 },
27
- animate: { opacity: 1, y: 0 },
28
- transition: j.fade,
29
- className: D(
30
- "flex items-center gap-ds-01 rounded-ds-md border border-surface-border bg-surface-overlay/95 px-ds-02 py-ds-01 shadow-floating backdrop-blur-sm",
31
- o
32
- ),
33
- children: t
34
- }
35
- );
219
+ //#endregion
220
+ //#region src/composed/file-preview/audio-preview.tsx
221
+ function x({ url: e, fileName: t, onError: n }) {
222
+ let r = f.useRef(null), i = f.useRef(null), [o, c] = f.useState(!1), [h, g] = f.useState(0), [y, b] = f.useState(0), [x, S] = f.useState(0), [C, w] = f.useState(1), [T, E] = f.useState(!1), [D, O] = f.useState(!1), [k, A] = f.useState(null);
223
+ f.useEffect(() => {
224
+ function e(e) {
225
+ let t = i.current;
226
+ if (!t || !t.contains(document.activeElement) && document.activeElement !== t) return;
227
+ let n = r.current;
228
+ if (n) switch (e.key) {
229
+ case " ":
230
+ e.preventDefault(), c((e) => (e ? n.pause() : n.play(), !e));
231
+ break;
232
+ case "ArrowRight":
233
+ e.preventDefault(), n.currentTime = Math.min(n.duration || 0, n.currentTime + 5);
234
+ break;
235
+ case "ArrowLeft":
236
+ e.preventDefault(), n.currentTime = Math.max(0, n.currentTime - 5);
237
+ break;
238
+ case "m":
239
+ e.preventDefault(), E((e) => (n.muted = !e, !e));
240
+ break;
241
+ }
242
+ }
243
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
244
+ }, []);
245
+ function j() {
246
+ r.current && (o ? r.current.pause() : r.current.play(), c(!o));
247
+ }
248
+ function M(e) {
249
+ if (!r.current || !y) return;
250
+ let t = e.currentTarget.getBoundingClientRect(), n = Math.max(0, Math.min(1, (e.clientX - t.left) / t.width));
251
+ r.current.currentTime = n * y;
252
+ }
253
+ function N(e) {
254
+ if (!y) return;
255
+ let t = e.currentTarget.getBoundingClientRect();
256
+ A((e.clientX - t.left) / t.width * y);
257
+ }
258
+ function P() {
259
+ if (!r.current) return;
260
+ let e = !T;
261
+ E(e), r.current.muted = e;
262
+ }
263
+ return D ? /* @__PURE__ */ p(d, {
264
+ message: "Could not load audio",
265
+ url: e
266
+ }) : /* @__PURE__ */ m("div", {
267
+ ref: i,
268
+ className: "rounded-ds-lg border border-surface-border bg-surface-raised shadow-raised overflow-hidden",
269
+ tabIndex: -1,
270
+ children: [
271
+ /* @__PURE__ */ p("audio", {
272
+ ref: r,
273
+ src: e,
274
+ onTimeUpdate: () => {
275
+ r.current && (S(r.current.currentTime), r.current.duration && g(r.current.currentTime / r.current.duration * 100));
276
+ },
277
+ onLoadedMetadata: () => b(r.current?.duration ?? 0),
278
+ onEnded: () => c(!1),
279
+ onError: () => {
280
+ O(!0), n?.("Audio failed to load");
281
+ }
282
+ }),
283
+ /* @__PURE__ */ m("div", {
284
+ className: "relative h-1 w-full cursor-pointer bg-surface-sunken group/bar",
285
+ onClick: M,
286
+ onMouseMove: N,
287
+ onMouseLeave: () => A(null),
288
+ role: "slider",
289
+ "aria-label": "Audio progress",
290
+ "aria-valuenow": Math.round(h),
291
+ "aria-valuemin": 0,
292
+ "aria-valuemax": 100,
293
+ tabIndex: 0,
294
+ children: [
295
+ /* @__PURE__ */ p("div", {
296
+ className: "absolute left-0 top-0 h-full bg-accent-9 transition-[width] duration-75",
297
+ style: { width: `${h}%` }
298
+ }),
299
+ k !== null && /* @__PURE__ */ p("div", {
300
+ className: "absolute -top-7 -translate-x-1/2 rounded-ds-sm bg-surface-overlay px-1.5 py-0.5 text-[10px] font-mono text-surface-fg shadow-floating pointer-events-none",
301
+ style: { left: `${k / (y || 1) * 100}%` },
302
+ children: l(k)
303
+ }),
304
+ /* @__PURE__ */ p("div", {
305
+ className: "absolute top-1/2 -translate-y-1/2 h-2.5 w-2.5 rounded-full bg-accent-9 shadow-raised opacity-0 group-hover/bar:opacity-100 transition-opacity",
306
+ style: {
307
+ left: `${h}%`,
308
+ marginLeft: "-5px"
309
+ }
310
+ })
311
+ ]
312
+ }),
313
+ /* @__PURE__ */ m("div", {
314
+ className: "flex items-center gap-ds-04 px-ds-05 py-ds-04",
315
+ children: [
316
+ /* @__PURE__ */ p(s, {
317
+ variant: "solid",
318
+ size: "icon-sm",
319
+ onClick: j,
320
+ "aria-label": o ? "Pause" : "Play",
321
+ title: o ? "Pause" : "Play",
322
+ className: "shrink-0",
323
+ children: o ? /* @__PURE__ */ p(a, {
324
+ icon: _,
325
+ size: "sm"
326
+ }) : /* @__PURE__ */ p(a, {
327
+ icon: v,
328
+ size: "sm",
329
+ className: "ml-0.5"
330
+ })
331
+ }),
332
+ /* @__PURE__ */ m("div", {
333
+ className: "flex-1 min-w-0",
334
+ children: [t && /* @__PURE__ */ p("p", {
335
+ className: "text-ds-sm font-semibold text-surface-fg truncate",
336
+ children: t
337
+ }), /* @__PURE__ */ m("p", {
338
+ className: "text-ds-xs font-mono text-surface-fg-muted tabular-nums",
339
+ children: [
340
+ l(x),
341
+ " / ",
342
+ l(y)
343
+ ]
344
+ })]
345
+ }),
346
+ /* @__PURE__ */ p(u, {
347
+ volume: C,
348
+ muted: T,
349
+ onVolumeChange: (e) => {
350
+ w(e), r.current && (r.current.volume = e), e > 0 && T && (E(!1), r.current && (r.current.muted = !1));
351
+ },
352
+ onMuteToggle: P,
353
+ variant: "light"
354
+ })
355
+ ]
356
+ })
357
+ ]
358
+ });
36
359
  }
37
- function ge() {
38
- return /* @__PURE__ */ e("div", { className: "mx-ds-01 h-4 w-px bg-surface-border-subtle" });
360
+ //#endregion
361
+ //#region src/composed/file-preview/embed-preview.tsx
362
+ function S({ url: t, embedUrl: n, onError: i }) {
363
+ let [a, o] = f.useState(!1), [s, l] = f.useState(!1);
364
+ return f.useEffect(() => {
365
+ let e = setTimeout(() => {
366
+ a || (l(!0), i?.("Embed timed out"));
367
+ }, 15e3);
368
+ return () => clearTimeout(e);
369
+ }, [a, i]), s ? /* @__PURE__ */ p(d, {
370
+ message: "Could not load embed",
371
+ url: t
372
+ }) : /* @__PURE__ */ m("div", {
373
+ className: "relative w-full rounded-ds-md overflow-hidden",
374
+ style: { aspectRatio: "16 / 9" },
375
+ children: [!a && /* @__PURE__ */ p(c, { className: "absolute inset-0" }), /* @__PURE__ */ p(e.iframe, {
376
+ src: n,
377
+ title: "Embedded content",
378
+ onLoad: () => o(!0),
379
+ onError: () => {
380
+ l(!0), i?.("Embed failed to load");
381
+ },
382
+ initial: { opacity: 0 },
383
+ animate: { opacity: +!!a },
384
+ transition: r.fade,
385
+ className: "absolute inset-0 h-full w-full border-none",
386
+ allowFullScreen: !0
387
+ })]
388
+ });
39
389
  }
40
- function W({
41
- volume: t,
42
- muted: o,
43
- onVolumeChange: r,
44
- onMuteToggle: n,
45
- variant: d = "light"
46
- }) {
47
- const l = a.useRef(null), [f, m] = a.useState(!1), v = o ? 0 : t;
48
- function g(p) {
49
- if (!l.current) return t;
50
- const M = l.current.getBoundingClientRect();
51
- return Math.max(0, Math.min(1, (p.clientX - M.left) / M.width));
52
- }
53
- function b(p) {
54
- p.preventDefault(), m(!0);
55
- const M = g(p);
56
- r(M), p.target.setPointerCapture(p.pointerId);
57
- }
58
- function N(p) {
59
- f && r(g(p));
60
- }
61
- function y() {
62
- m(!1);
63
- }
64
- const k = d === "dark", R = k ? "bg-white/30" : "bg-surface-sunken", T = k ? "bg-white" : "bg-accent-9", P = k ? "bg-white" : "bg-accent-9";
65
- return /* @__PURE__ */ u("div", { className: "group/vol flex items-center gap-ds-02 shrink-0", children: [
66
- /* @__PURE__ */ e("button", { onClick: n, className: D("transition-colors", k ? "text-white hover:text-white/80" : "text-surface-fg-muted hover:text-surface-fg"), "aria-label": o ? "Unmute (M)" : "Mute (M)", title: o ? "Unmute" : "Mute", children: o || t === 0 ? /* @__PURE__ */ e(x, { icon: O, size: "sm" }) : /* @__PURE__ */ e(x, { icon: Y, size: "sm" }) }),
67
- /* @__PURE__ */ e("div", { className: "w-0 overflow-hidden group-hover/vol:w-20 transition-[width] duration-200 ease-productive-standard flex items-center", children: /* @__PURE__ */ u(
68
- "div",
69
- {
70
- ref: l,
71
- className: D("relative w-full h-1 rounded-full cursor-pointer", R),
72
- onPointerDown: b,
73
- onPointerMove: N,
74
- onPointerUp: y,
75
- role: "slider",
76
- "aria-label": "Volume",
77
- "aria-valuenow": Math.round(v * 100),
78
- "aria-valuemin": 0,
79
- "aria-valuemax": 100,
80
- tabIndex: 0,
81
- children: [
82
- /* @__PURE__ */ e(
83
- "div",
84
- {
85
- className: D("absolute left-0 top-0 h-full rounded-full transition-[width] duration-75", T),
86
- style: { width: `${v * 100}%` }
87
- }
88
- ),
89
- /* @__PURE__ */ e(
90
- "div",
91
- {
92
- className: D(
93
- "absolute top-1/2 -translate-y-1/2 h-2.5 w-2.5 rounded-full shadow-raised transition-opacity",
94
- P,
95
- f ? "opacity-100 scale-110" : "opacity-0 group-hover/vol:opacity-100"
96
- ),
97
- style: { left: `${v * 100}%`, marginLeft: "-5px" }
98
- }
99
- )
100
- ]
101
- }
102
- ) })
103
- ] });
390
+ //#endregion
391
+ //#region src/composed/file-preview.tsx
392
+ var C = f.lazy(() => import("./image-preview.js")), w = f.lazy(() => import("./document-preview.js"));
393
+ function T(e, t) {
394
+ if (t) {
395
+ if (t.startsWith("image/")) return "image";
396
+ if (t === "application/pdf") return "pdf";
397
+ if (t.startsWith("video/")) return "video";
398
+ if (t.startsWith("audio/")) return "audio";
399
+ }
400
+ let n = e.split("?")[0].split(".").pop()?.toLowerCase();
401
+ return [
402
+ "jpg",
403
+ "jpeg",
404
+ "png",
405
+ "gif",
406
+ "webp",
407
+ "svg",
408
+ "avif",
409
+ "bmp"
410
+ ].includes(n ?? "") ? "image" : n === "pdf" ? "pdf" : [
411
+ "mp4",
412
+ "webm",
413
+ "ogg",
414
+ "mov"
415
+ ].includes(n ?? "") ? "video" : [
416
+ "mp3",
417
+ "wav",
418
+ "ogg",
419
+ "aac",
420
+ "flac"
421
+ ].includes(n ?? "") ? "audio" : e.includes("figma.com") || e.includes("loom.com") || e.includes("youtube.com") || e.includes("youtu.be") || e.includes("vimeo.com") ? "embed" : "image";
104
422
  }
105
- function L(t) {
106
- if (!isFinite(t) || t < 0) return "0:00";
107
- const o = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), n = Math.floor(t % 60);
108
- return o > 0 ? `${o}:${r.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}` : `${r}:${n.toString().padStart(2, "0")}`;
423
+ function E(e) {
424
+ let t = e.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&?]+)/);
425
+ if (t) return `https://www.youtube.com/embed/${t[1]}`;
426
+ let n = e.match(/vimeo\.com\/(\d+)/);
427
+ if (n) return `https://player.vimeo.com/video/${n[1]}`;
428
+ if (e.includes("figma.com")) return `https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(e)}`;
429
+ let r = e.match(/loom\.com\/share\/([^?]+)/);
430
+ return r ? `https://www.loom.com/embed/${r[1]}` : e;
109
431
  }
110
- const B = [0.5, 0.75, 1, 1.25, 1.5, 2];
111
- function Z({ url: t, onError: o }) {
112
- const r = a.useRef(null), n = a.useRef(null), [d, l] = a.useState(!1), [f, m] = a.useState(0), [v, g] = a.useState(0), [b, N] = a.useState(0), [y, k] = a.useState(!1), [R, T] = a.useState(!1), [P, C] = a.useState(!0), [p, M] = a.useState(1), S = a.useRef(void 0);
113
- a.useEffect(() => () => clearTimeout(S.current), []), a.useEffect(() => {
114
- function c(s) {
115
- const h = n.current;
116
- if (!h || !h.contains(document.activeElement) && document.activeElement !== h) return;
117
- const i = r.current;
118
- if (i)
119
- switch (s.key) {
120
- case " ":
121
- case "k":
122
- s.preventDefault(), l((w) => (w ? i.pause() : i.play(), !w));
123
- break;
124
- case "ArrowRight":
125
- s.preventDefault(), i.currentTime = Math.min(i.duration, i.currentTime + 5);
126
- break;
127
- case "ArrowLeft":
128
- s.preventDefault(), i.currentTime = Math.max(0, i.currentTime - 5);
129
- break;
130
- case "j":
131
- s.preventDefault(), i.currentTime = Math.max(0, i.currentTime - 10);
132
- break;
133
- case "l":
134
- s.preventDefault(), i.currentTime = Math.min(i.duration, i.currentTime + 10);
135
- break;
136
- case "m":
137
- s.preventDefault(), k((w) => (i.muted = !w, !w));
138
- break;
139
- case "f":
140
- s.preventDefault(), i.requestFullscreen?.();
141
- break;
142
- case ">":
143
- s.preventDefault(), E(1);
144
- break;
145
- case "<":
146
- s.preventDefault(), E(-1);
147
- break;
148
- }
149
- }
150
- return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
151
- }, []);
152
- function E(c) {
153
- const s = B.indexOf(p), h = Math.max(0, Math.min(B.length - 1, s + c)), i = B[h];
154
- M(i), r.current && (r.current.playbackRate = i);
155
- }
156
- function I() {
157
- r.current && (d ? r.current.pause() : r.current.play(), l(!d));
158
- }
159
- function z(c) {
160
- if (!r.current || !v) return;
161
- const s = c.currentTarget.getBoundingClientRect(), h = (c.clientX - s.left) / s.width;
162
- r.current.currentTime = h * v;
163
- }
164
- function A() {
165
- C(!0), clearTimeout(S.current), d && (S.current = setTimeout(() => C(!1), 3e3));
166
- }
167
- return R ? /* @__PURE__ */ e(U, { message: "Could not load video", url: t }) : /* @__PURE__ */ u(
168
- "div",
169
- {
170
- ref: n,
171
- className: "group relative rounded-ds-md bg-black overflow-hidden",
172
- onMouseMove: A,
173
- onMouseLeave: () => d && C(!1),
174
- tabIndex: -1,
175
- children: [
176
- /* @__PURE__ */ e(
177
- "video",
178
- {
179
- ref: r,
180
- src: t,
181
- className: "max-h-[70vh] w-full",
182
- onClick: I,
183
- muted: y,
184
- onTimeUpdate: () => {
185
- r.current && (N(r.current.currentTime), r.current.duration && m(r.current.currentTime / r.current.duration * 100));
186
- },
187
- onLoadedMetadata: () => g(r.current?.duration ?? 0),
188
- onEnded: () => {
189
- l(!1), C(!0);
190
- },
191
- onError: () => {
192
- T(!0), o?.("Video failed to load");
193
- },
194
- playsInline: !0
195
- }
196
- ),
197
- !d && /* @__PURE__ */ e(
198
- $.button,
199
- {
200
- initial: { opacity: 0, scale: 0.8 },
201
- animate: { opacity: 1, scale: 1 },
202
- transition: J.snappy,
203
- onClick: I,
204
- className: "absolute inset-0 flex items-center justify-center bg-black/30",
205
- "aria-label": "Play video",
206
- children: /* @__PURE__ */ e("div", { className: "flex h-14 w-14 items-center justify-center rounded-full bg-white/90 shadow-floating", children: /* @__PURE__ */ e(x, { icon: F, size: "xl", className: "text-surface-fg ml-0.5" }) })
207
- }
208
- ),
209
- /* @__PURE__ */ e(Q, { children: P && v > 0 && /* @__PURE__ */ u(
210
- $.div,
211
- {
212
- initial: { opacity: 0, y: 10 },
213
- animate: { opacity: 1, y: 0 },
214
- exit: { opacity: 0, y: 10 },
215
- transition: j.fade,
216
- className: "absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/80 to-transparent px-ds-04 pb-ds-04 pt-ds-08",
217
- children: [
218
- /* @__PURE__ */ u(
219
- "div",
220
- {
221
- className: "relative h-1 w-full cursor-pointer rounded-full bg-white/30 mb-ds-03 group/progress",
222
- onClick: z,
223
- role: "slider",
224
- "aria-label": "Video progress",
225
- "aria-valuenow": Math.round(f),
226
- "aria-valuemin": 0,
227
- "aria-valuemax": 100,
228
- tabIndex: 0,
229
- children: [
230
- /* @__PURE__ */ e(
231
- "div",
232
- {
233
- className: "absolute left-0 top-0 h-full rounded-full bg-white transition-[width] duration-75",
234
- style: { width: `${f}%` }
235
- }
236
- ),
237
- /* @__PURE__ */ e(
238
- "div",
239
- {
240
- className: "absolute top-1/2 -translate-y-1/2 h-3 w-3 rounded-full bg-white shadow-raised opacity-0 group-hover/progress:opacity-100 transition-opacity",
241
- style: { left: `${f}%`, marginLeft: "-6px" }
242
- }
243
- )
244
- ]
245
- }
246
- ),
247
- /* @__PURE__ */ u("div", { className: "flex items-center gap-ds-03", children: [
248
- /* @__PURE__ */ e("button", { onClick: I, className: "text-white hover:text-white/80", "aria-label": d ? "Pause" : "Play", title: d ? "Pause" : "Play", children: d ? /* @__PURE__ */ e(x, { icon: K, size: "lg" }) : /* @__PURE__ */ e(x, { icon: F, size: "lg" }) }),
249
- /* @__PURE__ */ e(
250
- W,
251
- {
252
- volume: y ? 0 : 1,
253
- muted: y,
254
- onVolumeChange: (c) => {
255
- r.current && (r.current.volume = c), c > 0 && y && (k(!1), r.current && (r.current.muted = !1));
256
- },
257
- onMuteToggle: () => {
258
- k(!y), r.current && (r.current.muted = !y);
259
- },
260
- variant: "dark"
261
- }
262
- ),
263
- /* @__PURE__ */ u("span", { className: "text-[11px] font-mono text-white/70 tabular-nums", children: [
264
- L(b),
265
- " / ",
266
- L(v)
267
- ] }),
268
- /* @__PURE__ */ e("div", { className: "flex-1" }),
269
- /* @__PURE__ */ u(
270
- "button",
271
- {
272
- onClick: () => E(1),
273
- className: "text-[11px] font-mono text-white/70 hover:text-white px-1 rounded-ds-sm hover:bg-white/10 transition-colors",
274
- "aria-label": `Playback speed: ${p}x`,
275
- children: [
276
- p,
277
- "x"
278
- ]
279
- }
280
- ),
281
- /* @__PURE__ */ e(
282
- "button",
283
- {
284
- onClick: () => r.current?.requestFullscreen?.(),
285
- className: "text-white hover:text-white/80",
286
- "aria-label": "Fullscreen (F)",
287
- title: "Fullscreen",
288
- children: /* @__PURE__ */ e(x, { icon: G, size: "sm" })
289
- }
290
- )
291
- ] })
292
- ]
293
- }
294
- ) })
295
- ]
296
- }
297
- );
432
+ function D({ url: e, type: t, mimeType: n, alt: r, initialPage: l = 1, fileName: u, fileSize: d, onError: g, className: _, ...v }) {
433
+ let y = t ?? T(e, n), D = /* @__PURE__ */ p(c, { className: "h-64 w-full rounded-ds-md" });
434
+ return /* @__PURE__ */ m("div", {
435
+ className: i("flex flex-col gap-ds-03", _),
436
+ ...v,
437
+ children: [
438
+ (u || d) && /* @__PURE__ */ m("div", {
439
+ className: "flex items-center gap-ds-03",
440
+ children: [u && /* @__PURE__ */ p("span", {
441
+ className: "text-ds-sm font-semibold text-surface-fg truncate",
442
+ children: u
443
+ }), d && /* @__PURE__ */ p(o, {
444
+ variant: "subtle",
445
+ size: "xs",
446
+ children: d
447
+ })]
448
+ }),
449
+ y === "image" && /* @__PURE__ */ p(f.Suspense, {
450
+ fallback: D,
451
+ children: /* @__PURE__ */ p(C, {
452
+ url: e,
453
+ alt: r,
454
+ onError: g
455
+ })
456
+ }),
457
+ y === "pdf" && /* @__PURE__ */ p(f.Suspense, {
458
+ fallback: D,
459
+ children: /* @__PURE__ */ p(w, {
460
+ url: e,
461
+ initialPage: l,
462
+ onError: g
463
+ })
464
+ }),
465
+ y === "video" && /* @__PURE__ */ p(b, {
466
+ url: e,
467
+ onError: g
468
+ }),
469
+ y === "audio" && /* @__PURE__ */ p(x, {
470
+ url: e,
471
+ fileName: u,
472
+ onError: g
473
+ }),
474
+ y === "embed" && /* @__PURE__ */ p(S, {
475
+ url: e,
476
+ embedUrl: E(e),
477
+ onError: g
478
+ }),
479
+ y !== "audio" && /* @__PURE__ */ p("div", {
480
+ className: "flex justify-end",
481
+ children: /* @__PURE__ */ p(s, {
482
+ variant: "ghost",
483
+ size: "xs",
484
+ startIcon: /* @__PURE__ */ p(a, { icon: h }),
485
+ asChild: !0,
486
+ children: /* @__PURE__ */ p("a", {
487
+ href: e,
488
+ download: !0,
489
+ target: "_blank",
490
+ rel: "noopener noreferrer",
491
+ children: "Download"
492
+ })
493
+ })
494
+ })
495
+ ]
496
+ });
298
497
  }
299
- function ee({ url: t, fileName: o, onError: r }) {
300
- const n = a.useRef(null), d = a.useRef(null), [l, f] = a.useState(!1), [m, v] = a.useState(0), [g, b] = a.useState(0), [N, y] = a.useState(0), [k, R] = a.useState(1), [T, P] = a.useState(!1), [C, p] = a.useState(!1), [M, S] = a.useState(null);
301
- a.useEffect(() => {
302
- function c(s) {
303
- const h = d.current;
304
- if (!h || !h.contains(document.activeElement) && document.activeElement !== h) return;
305
- const i = n.current;
306
- if (i)
307
- switch (s.key) {
308
- case " ":
309
- s.preventDefault(), f((w) => (w ? i.pause() : i.play(), !w));
310
- break;
311
- case "ArrowRight":
312
- s.preventDefault(), i.currentTime = Math.min(i.duration || 0, i.currentTime + 5);
313
- break;
314
- case "ArrowLeft":
315
- s.preventDefault(), i.currentTime = Math.max(0, i.currentTime - 5);
316
- break;
317
- case "m":
318
- s.preventDefault(), P((w) => (i.muted = !w, !w));
319
- break;
320
- }
321
- }
322
- return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
323
- }, []);
324
- function E() {
325
- n.current && (l ? n.current.pause() : n.current.play(), f(!l));
326
- }
327
- function I(c) {
328
- if (!n.current || !g) return;
329
- const s = c.currentTarget.getBoundingClientRect(), h = Math.max(0, Math.min(1, (c.clientX - s.left) / s.width));
330
- n.current.currentTime = h * g;
331
- }
332
- function z(c) {
333
- if (!g) return;
334
- const s = c.currentTarget.getBoundingClientRect(), h = (c.clientX - s.left) / s.width;
335
- S(h * g);
336
- }
337
- function A() {
338
- if (!n.current) return;
339
- const c = !T;
340
- P(c), n.current.muted = c;
341
- }
342
- return C ? /* @__PURE__ */ e(U, { message: "Could not load audio", url: t }) : /* @__PURE__ */ u("div", { ref: d, className: "rounded-ds-lg border border-surface-border bg-surface-raised shadow-raised overflow-hidden", tabIndex: -1, children: [
343
- /* @__PURE__ */ e(
344
- "audio",
345
- {
346
- ref: n,
347
- src: t,
348
- onTimeUpdate: () => {
349
- n.current && (y(n.current.currentTime), n.current.duration && v(n.current.currentTime / n.current.duration * 100));
350
- },
351
- onLoadedMetadata: () => b(n.current?.duration ?? 0),
352
- onEnded: () => f(!1),
353
- onError: () => {
354
- p(!0), r?.("Audio failed to load");
355
- }
356
- }
357
- ),
358
- /* @__PURE__ */ u(
359
- "div",
360
- {
361
- className: "relative h-1 w-full cursor-pointer bg-surface-sunken group/bar",
362
- onClick: I,
363
- onMouseMove: z,
364
- onMouseLeave: () => S(null),
365
- role: "slider",
366
- "aria-label": "Audio progress",
367
- "aria-valuenow": Math.round(m),
368
- "aria-valuemin": 0,
369
- "aria-valuemax": 100,
370
- tabIndex: 0,
371
- children: [
372
- /* @__PURE__ */ e(
373
- "div",
374
- {
375
- className: "absolute left-0 top-0 h-full bg-accent-9 transition-[width] duration-75",
376
- style: { width: `${m}%` }
377
- }
378
- ),
379
- M !== null && /* @__PURE__ */ e(
380
- "div",
381
- {
382
- className: "absolute -top-7 -translate-x-1/2 rounded-ds-sm bg-surface-overlay px-1.5 py-0.5 text-[10px] font-mono text-surface-fg shadow-floating pointer-events-none",
383
- style: { left: `${M / (g || 1) * 100}%` },
384
- children: L(M)
385
- }
386
- ),
387
- /* @__PURE__ */ e(
388
- "div",
389
- {
390
- className: "absolute top-1/2 -translate-y-1/2 h-2.5 w-2.5 rounded-full bg-accent-9 shadow-raised opacity-0 group-hover/bar:opacity-100 transition-opacity",
391
- style: { left: `${m}%`, marginLeft: "-5px" }
392
- }
393
- )
394
- ]
395
- }
396
- ),
397
- /* @__PURE__ */ u("div", { className: "flex items-center gap-ds-04 px-ds-05 py-ds-04", children: [
398
- /* @__PURE__ */ e(
399
- V,
400
- {
401
- variant: "solid",
402
- size: "icon-sm",
403
- onClick: E,
404
- "aria-label": l ? "Pause" : "Play",
405
- title: l ? "Pause" : "Play",
406
- className: "shrink-0",
407
- children: l ? /* @__PURE__ */ e(x, { icon: K, size: "sm" }) : /* @__PURE__ */ e(x, { icon: F, size: "sm", className: "ml-0.5" })
408
- }
409
- ),
410
- /* @__PURE__ */ u("div", { className: "flex-1 min-w-0", children: [
411
- o && /* @__PURE__ */ e("p", { className: "text-ds-sm font-semibold text-surface-fg truncate", children: o }),
412
- /* @__PURE__ */ u("p", { className: "text-ds-xs font-mono text-surface-fg-muted tabular-nums", children: [
413
- L(N),
414
- " / ",
415
- L(g)
416
- ] })
417
- ] }),
418
- /* @__PURE__ */ e(
419
- W,
420
- {
421
- volume: k,
422
- muted: T,
423
- onVolumeChange: (c) => {
424
- R(c), n.current && (n.current.volume = c), c > 0 && T && (P(!1), n.current && (n.current.muted = !1));
425
- },
426
- onMuteToggle: A,
427
- variant: "light"
428
- }
429
- )
430
- ] })
431
- ] });
432
- }
433
- function te({ url: t, embedUrl: o, onError: r }) {
434
- const [n, d] = a.useState(!1), [l, f] = a.useState(!1);
435
- return a.useEffect(() => {
436
- const m = setTimeout(() => {
437
- n || (f(!0), r?.("Embed timed out"));
438
- }, 15e3);
439
- return () => clearTimeout(m);
440
- }, [n, r]), l ? /* @__PURE__ */ e(U, { message: "Could not load embed", url: t }) : /* @__PURE__ */ u("div", { className: "relative w-full rounded-ds-md overflow-hidden", style: { aspectRatio: "16 / 9" }, children: [
441
- !n && /* @__PURE__ */ e(X, { className: "absolute inset-0" }),
442
- /* @__PURE__ */ e(
443
- $.iframe,
444
- {
445
- src: o,
446
- title: "Embedded content",
447
- onLoad: () => d(!0),
448
- onError: () => {
449
- f(!0), r?.("Embed failed to load");
450
- },
451
- initial: { opacity: 0 },
452
- animate: { opacity: n ? 1 : 0 },
453
- transition: j.fade,
454
- className: "absolute inset-0 h-full w-full border-none",
455
- allowFullScreen: !0
456
- }
457
- )
458
- ] });
459
- }
460
- const re = a.lazy(() => import("./image-preview.js")), ne = a.lazy(() => import("./document-preview.js"));
461
- function ae(t, o) {
462
- if (o) {
463
- if (o.startsWith("image/")) return "image";
464
- if (o === "application/pdf") return "pdf";
465
- if (o.startsWith("video/")) return "video";
466
- if (o.startsWith("audio/")) return "audio";
467
- }
468
- const r = t.split("?")[0].split(".").pop()?.toLowerCase();
469
- return ["jpg", "jpeg", "png", "gif", "webp", "svg", "avif", "bmp"].includes(r ?? "") ? "image" : r === "pdf" ? "pdf" : ["mp4", "webm", "ogg", "mov"].includes(r ?? "") ? "video" : ["mp3", "wav", "ogg", "aac", "flac"].includes(r ?? "") ? "audio" : t.includes("figma.com") || t.includes("loom.com") || t.includes("youtube.com") || t.includes("youtu.be") || t.includes("vimeo.com") ? "embed" : "image";
470
- }
471
- function oe(t) {
472
- const o = t.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&?]+)/);
473
- if (o) return `https://www.youtube.com/embed/${o[1]}`;
474
- const r = t.match(/vimeo\.com\/(\d+)/);
475
- if (r) return `https://player.vimeo.com/video/${r[1]}`;
476
- if (t.includes("figma.com")) return `https://www.figma.com/embed?embed_host=share&url=${encodeURIComponent(t)}`;
477
- const n = t.match(/loom\.com\/share\/([^?]+)/);
478
- return n ? `https://www.loom.com/embed/${n[1]}` : t;
479
- }
480
- function ve({
481
- url: t,
482
- type: o,
483
- mimeType: r,
484
- alt: n,
485
- initialPage: d = 1,
486
- fileName: l,
487
- fileSize: f,
488
- onError: m,
489
- className: v,
490
- ...g
491
- }) {
492
- const b = o ?? ae(t, r), N = /* @__PURE__ */ e(X, { className: "h-64 w-full rounded-ds-md" });
493
- return /* @__PURE__ */ u("div", { className: D("flex flex-col gap-ds-03", v), ...g, children: [
494
- (l || f) && /* @__PURE__ */ u("div", { className: "flex items-center gap-ds-03", children: [
495
- l && /* @__PURE__ */ e("span", { className: "text-ds-sm font-semibold text-surface-fg truncate", children: l }),
496
- f && /* @__PURE__ */ e(q, { variant: "subtle", size: "xs", children: f })
497
- ] }),
498
- b === "image" && /* @__PURE__ */ e(a.Suspense, { fallback: N, children: /* @__PURE__ */ e(re, { url: t, alt: n, onError: m }) }),
499
- b === "pdf" && /* @__PURE__ */ e(a.Suspense, { fallback: N, children: /* @__PURE__ */ e(ne, { url: t, initialPage: d, onError: m }) }),
500
- b === "video" && /* @__PURE__ */ e(Z, { url: t, onError: m }),
501
- b === "audio" && /* @__PURE__ */ e(ee, { url: t, fileName: l, onError: m }),
502
- b === "embed" && /* @__PURE__ */ e(te, { url: t, embedUrl: oe(t), onError: m }),
503
- b !== "audio" && /* @__PURE__ */ e("div", { className: "flex justify-end", children: /* @__PURE__ */ e(V, { variant: "ghost", size: "xs", startIcon: /* @__PURE__ */ e(x, { icon: _ }), asChild: !0, children: /* @__PURE__ */ e("a", { href: t, download: !0, target: "_blank", rel: "noopener noreferrer", children: "Download" }) }) })
504
- ] });
505
- }
506
- export {
507
- U as E,
508
- ve as F,
509
- pe as T,
510
- ge as a
511
- };
498
+ //#endregion
499
+ export { D as t };