@livo-tv/blocks 1.0.0 → 1.2.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.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
- import * as React3 from 'react';
2
+ import * as React7 from 'react';
3
3
  import { createContext, useContext, useState, useRef, useId, useEffect, useCallback, useLayoutEffect } from 'react';
4
- import { Loader2, AlertTriangle, Inbox, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
4
+ import { Loader2, AlertTriangle, Inbox, Monitor, Sun, Moon, Languages, Upload, Move, ZoomOut, ZoomIn, RotateCcw, RotateCw, Grid3X3, RefreshCw, X, User, Pencil, Check, Play, AlertCircle, VolumeX, Pause, Volume1, Volume2, Settings, Cast, PictureInPicture2, Minimize, Maximize, XIcon } from 'lucide-react';
5
5
  import { clsx } from 'clsx';
6
6
  import { twMerge } from 'tailwind-merge';
7
7
  import { cva } from 'class-variance-authority';
@@ -1196,7 +1196,7 @@ function Slider({
1196
1196
  max = 100,
1197
1197
  ...props
1198
1198
  }) {
1199
- const _values = React3.useMemo(
1199
+ const _values = React7.useMemo(
1200
1200
  () => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
1201
1201
  [value, defaultValue, min, max]
1202
1202
  );
@@ -2232,6 +2232,520 @@ function AvatarEditorDialog({
2232
2232
  ] }) })
2233
2233
  ] });
2234
2234
  }
2235
+ function usePrefersReducedMotion() {
2236
+ const [reduced, setReduced] = React7.useState(false);
2237
+ React7.useEffect(() => {
2238
+ const media = window.matchMedia("(prefers-reduced-motion: reduce)");
2239
+ const sync = () => setReduced(media.matches);
2240
+ sync();
2241
+ media.addEventListener("change", sync);
2242
+ return () => media.removeEventListener("change", sync);
2243
+ }, []);
2244
+ return reduced;
2245
+ }
2246
+ function CurtainStage({
2247
+ kind,
2248
+ url,
2249
+ alt = "",
2250
+ className,
2251
+ reducedMotion
2252
+ }) {
2253
+ const prefersReduced = usePrefersReducedMotion();
2254
+ const freeze = reducedMotion ?? prefersReduced;
2255
+ if (kind === "video" && !freeze) {
2256
+ return /* @__PURE__ */ jsx(
2257
+ "video",
2258
+ {
2259
+ src: url,
2260
+ className: cn("h-full w-full object-cover", className),
2261
+ autoPlay: true,
2262
+ muted: true,
2263
+ loop: true,
2264
+ playsInline: true,
2265
+ "aria-hidden": alt ? void 0 : true
2266
+ }
2267
+ );
2268
+ }
2269
+ if (kind === "video" && freeze) {
2270
+ return /* @__PURE__ */ jsx(
2271
+ "video",
2272
+ {
2273
+ src: url,
2274
+ className: cn("h-full w-full object-cover", className),
2275
+ muted: true,
2276
+ playsInline: true,
2277
+ preload: "metadata",
2278
+ "aria-hidden": alt ? void 0 : true
2279
+ }
2280
+ );
2281
+ }
2282
+ return /* @__PURE__ */ jsx(
2283
+ "img",
2284
+ {
2285
+ src: url,
2286
+ alt,
2287
+ className: cn("h-full w-full object-cover", className)
2288
+ }
2289
+ );
2290
+ }
2291
+ function useMediaQuery2(query) {
2292
+ const [matches, setMatches] = useState(false);
2293
+ useEffect(() => {
2294
+ if (typeof window === "undefined" || !window.matchMedia) return;
2295
+ const mql = window.matchMedia(query);
2296
+ const onChange = () => setMatches(mql.matches);
2297
+ onChange();
2298
+ mql.addEventListener("change", onChange);
2299
+ return () => mql.removeEventListener("change", onChange);
2300
+ }, [query]);
2301
+ return matches;
2302
+ }
2303
+ function isVideoKind(kind) {
2304
+ return kind === "video";
2305
+ }
2306
+ function useElementInView(enabled) {
2307
+ const [node, setNode] = React7.useState(null);
2308
+ const [inView, setInView] = React7.useState(false);
2309
+ React7.useEffect(() => {
2310
+ if (!enabled || !node || typeof IntersectionObserver === "undefined") {
2311
+ setInView(false);
2312
+ return;
2313
+ }
2314
+ const observer = new IntersectionObserver(
2315
+ (entries) => {
2316
+ const entry = entries[0];
2317
+ setInView(Boolean(entry?.isIntersecting));
2318
+ },
2319
+ { threshold: 0.35, rootMargin: "32px" }
2320
+ );
2321
+ observer.observe(node);
2322
+ return () => observer.disconnect();
2323
+ }, [enabled, node]);
2324
+ return [setNode, inView];
2325
+ }
2326
+ function CurtainPreview({
2327
+ kind,
2328
+ url,
2329
+ alt = "",
2330
+ className,
2331
+ playWhenVisible = true
2332
+ }) {
2333
+ const prefersReduced = useMediaQuery2("(prefers-reduced-motion: reduce)");
2334
+ const video = isVideoKind(kind);
2335
+ const observe = playWhenVisible && video && !prefersReduced;
2336
+ const [setNode, inView] = useElementInView(observe);
2337
+ const shouldPlay = video && !prefersReduced && (!playWhenVisible || inView);
2338
+ if (!url) {
2339
+ return /* @__PURE__ */ jsx(
2340
+ "div",
2341
+ {
2342
+ ref: setNode,
2343
+ className: cn("aspect-video rounded-md bg-skeleton", className),
2344
+ "aria-hidden": "true"
2345
+ }
2346
+ );
2347
+ }
2348
+ const stageKind = video ? "video" : "image";
2349
+ return /* @__PURE__ */ jsx(
2350
+ "div",
2351
+ {
2352
+ ref: setNode,
2353
+ className: cn(
2354
+ "aspect-video overflow-hidden rounded-md bg-black",
2355
+ className
2356
+ ),
2357
+ children: /* @__PURE__ */ jsx(
2358
+ CurtainStage,
2359
+ {
2360
+ kind: stageKind,
2361
+ url,
2362
+ alt,
2363
+ reducedMotion: !shouldPlay,
2364
+ className: "h-full w-full"
2365
+ }
2366
+ )
2367
+ }
2368
+ );
2369
+ }
2370
+ var DEFAULT_CURTAIN_PICKER_LABELS = {
2371
+ select: "Curtain",
2372
+ none: "None",
2373
+ noneDescription: "Use the default curtain",
2374
+ defaultBadge: "Default",
2375
+ makeDefault: "Set as default",
2376
+ delete: "Delete",
2377
+ image: "Image",
2378
+ video: "Video",
2379
+ organization: "Organization",
2380
+ platform: "Catalog",
2381
+ groupOrganization: "Your curtains",
2382
+ groupPlatform: "Catalog",
2383
+ groupOther: "Other",
2384
+ emptyTitle: "No curtains yet",
2385
+ emptyDescription: "Upload an image or a short looping video."
2386
+ };
2387
+ var OWNER_GROUPS = [
2388
+ "organization",
2389
+ "platform",
2390
+ "other"
2391
+ ];
2392
+ function ownerGroup(ownerType) {
2393
+ switch (ownerType) {
2394
+ case "organization":
2395
+ return "organization";
2396
+ case "platform":
2397
+ return "platform";
2398
+ default:
2399
+ return "other";
2400
+ }
2401
+ }
2402
+ function kindLabel(kind, copy) {
2403
+ return kind === "video" ? copy.video : copy.image;
2404
+ }
2405
+ function ownerLabel(ownerType, copy) {
2406
+ if (ownerType === "organization") return copy.organization;
2407
+ if (ownerType === "platform") return copy.platform;
2408
+ return null;
2409
+ }
2410
+ function groupHeading(group, copy) {
2411
+ const headings = {
2412
+ organization: copy.groupOrganization,
2413
+ platform: copy.groupPlatform,
2414
+ other: copy.groupOther
2415
+ };
2416
+ return headings[group];
2417
+ }
2418
+ function gridClass(variant) {
2419
+ return variant === "compact" ? "grid gap-3 sm:grid-cols-2" : "grid gap-4 sm:grid-cols-2 lg:grid-cols-3";
2420
+ }
2421
+ function CurtainPickerSkeleton({
2422
+ count = 6,
2423
+ variant = "default",
2424
+ className
2425
+ }) {
2426
+ return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), "aria-hidden": "true", children: Array.from({ length: count }, (_, index) => /* @__PURE__ */ jsxs("li", { className: "space-y-3 rounded-xl border p-4", children: [
2427
+ /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-skeleton" }),
2428
+ /* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 rounded bg-skeleton" }),
2429
+ /* @__PURE__ */ jsx("div", { className: "h-3 w-1/3 rounded bg-skeleton" })
2430
+ ] }, index)) });
2431
+ }
2432
+ function CurtainPicker({
2433
+ curtains,
2434
+ value = null,
2435
+ onChange,
2436
+ allowNone = false,
2437
+ disabled = false,
2438
+ variant = "default",
2439
+ groupByOwner = false,
2440
+ onMakeDefault,
2441
+ onDelete,
2442
+ canMakeDefault,
2443
+ canDelete,
2444
+ labels,
2445
+ emptyAction,
2446
+ className,
2447
+ actionsPending = false
2448
+ }) {
2449
+ const copy = { ...DEFAULT_CURTAIN_PICKER_LABELS, ...labels };
2450
+ const groupName = React7.useId();
2451
+ const selectable = typeof onChange === "function";
2452
+ const selectedId = value === "" ? null : value ?? null;
2453
+ const ready = curtains.filter((curtain) => curtain.publicUrl);
2454
+ const showEmpty = ready.length === 0 && !allowNone;
2455
+ const grouped = React7.useMemo(() => {
2456
+ if (!groupByOwner) {
2457
+ return [{ group: null, items: ready }];
2458
+ }
2459
+ return OWNER_GROUPS.map((group) => ({
2460
+ group,
2461
+ items: ready.filter((curtain) => ownerGroup(curtain.ownerType) === group)
2462
+ })).filter((section) => section.items.length > 0);
2463
+ }, [groupByOwner, ready]);
2464
+ if (showEmpty) {
2465
+ return /* @__PURE__ */ jsx(
2466
+ EmptyState,
2467
+ {
2468
+ title: copy.emptyTitle,
2469
+ description: copy.emptyDescription,
2470
+ action: emptyAction,
2471
+ className
2472
+ }
2473
+ );
2474
+ }
2475
+ const noneTile = allowNone && selectable ? /* @__PURE__ */ jsx(
2476
+ NoneTile,
2477
+ {
2478
+ name: groupName,
2479
+ checked: selectedId === null,
2480
+ disabled,
2481
+ copy,
2482
+ onSelect: () => onChange(null)
2483
+ }
2484
+ ) : null;
2485
+ if (grouped.length === 0 && noneTile) {
2486
+ return /* @__PURE__ */ jsx("ul", { className: cn(gridClass(variant), className), children: /* @__PURE__ */ jsx("li", { children: noneTile }) });
2487
+ }
2488
+ return /* @__PURE__ */ jsx("div", { className: cn("space-y-6", className), children: grouped.map((section, index) => /* @__PURE__ */ jsxs("section", { className: "space-y-3", children: [
2489
+ section.group ? /* @__PURE__ */ jsx("h3", { className: "text-muted-foreground text-sm font-medium", children: groupHeading(section.group, copy) }) : null,
2490
+ /* @__PURE__ */ jsxs("ul", { className: gridClass(variant), children: [
2491
+ index === 0 && noneTile ? /* @__PURE__ */ jsx("li", { children: noneTile }) : null,
2492
+ section.items.map((item) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
2493
+ CurtainPickerCard,
2494
+ {
2495
+ item,
2496
+ name: groupName,
2497
+ selectable,
2498
+ checked: selectedId === item.id,
2499
+ disabled,
2500
+ actionsPending,
2501
+ copy,
2502
+ onSelect: onChange ? () => onChange(item.id) : void 0,
2503
+ onMakeDefault: onMakeDefault && (canMakeDefault ? canMakeDefault(item) : !item.isDefault) ? () => onMakeDefault(item) : void 0,
2504
+ onDelete: onDelete && (canDelete ? canDelete(item) : true) ? () => onDelete(item) : void 0
2505
+ }
2506
+ ) }, item.id))
2507
+ ] })
2508
+ ] }, section.group ?? "all")) });
2509
+ }
2510
+ function NoneTile({
2511
+ name,
2512
+ checked,
2513
+ disabled,
2514
+ copy,
2515
+ onSelect
2516
+ }) {
2517
+ return /* @__PURE__ */ jsxs(
2518
+ "label",
2519
+ {
2520
+ className: cn(
2521
+ "block cursor-pointer space-y-3 rounded-xl border p-4 transition-shadow",
2522
+ "has-[:checked]:ring-ring has-[:checked]:ring-2",
2523
+ "has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
2524
+ disabled && "pointer-events-none opacity-50"
2525
+ ),
2526
+ children: [
2527
+ /* @__PURE__ */ jsx(
2528
+ "input",
2529
+ {
2530
+ type: "radio",
2531
+ name,
2532
+ value: "",
2533
+ checked,
2534
+ disabled,
2535
+ onChange: onSelect,
2536
+ className: "sr-only"
2537
+ }
2538
+ ),
2539
+ /* @__PURE__ */ jsx("div", { className: "aspect-video rounded-md bg-gradient-to-br from-zinc-900 to-zinc-950" }),
2540
+ /* @__PURE__ */ jsxs("div", { children: [
2541
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: copy.none }),
2542
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: copy.noneDescription })
2543
+ ] })
2544
+ ]
2545
+ }
2546
+ );
2547
+ }
2548
+ function CurtainPickerCard({
2549
+ item,
2550
+ name,
2551
+ selectable,
2552
+ checked,
2553
+ disabled,
2554
+ actionsPending,
2555
+ copy,
2556
+ onSelect,
2557
+ onMakeDefault,
2558
+ onDelete
2559
+ }) {
2560
+ const owner = ownerLabel(item.ownerType, copy);
2561
+ const media = /* @__PURE__ */ jsx(CurtainPreview, { kind: item.kind, url: item.publicUrl, alt: item.title });
2562
+ const meta = /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
2563
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
2564
+ /* @__PURE__ */ jsx("p", { className: "truncate font-medium", children: item.title }),
2565
+ /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-xs", children: [kindLabel(item.kind, copy), owner].filter(Boolean).join(" \xB7 ") })
2566
+ ] }),
2567
+ item.isDefault ? /* @__PURE__ */ jsx("p", { className: "text-muted-foreground shrink-0 text-xs", children: copy.defaultBadge }) : null
2568
+ ] });
2569
+ return /* @__PURE__ */ jsxs(
2570
+ "div",
2571
+ {
2572
+ className: cn(
2573
+ "space-y-3 rounded-xl border p-4",
2574
+ selectable && "has-[:checked]:ring-ring has-[:checked]:ring-2 has-[:focus-visible]:ring-ring has-[:focus-visible]:ring-2",
2575
+ disabled && "opacity-50"
2576
+ ),
2577
+ children: [
2578
+ selectable && onSelect ? /* @__PURE__ */ jsxs(
2579
+ "label",
2580
+ {
2581
+ className: cn(
2582
+ "block space-y-3",
2583
+ disabled ? "pointer-events-none" : "cursor-pointer"
2584
+ ),
2585
+ children: [
2586
+ /* @__PURE__ */ jsx(
2587
+ "input",
2588
+ {
2589
+ type: "radio",
2590
+ name,
2591
+ value: item.id,
2592
+ checked,
2593
+ disabled,
2594
+ onChange: onSelect,
2595
+ className: "sr-only"
2596
+ }
2597
+ ),
2598
+ media,
2599
+ meta
2600
+ ]
2601
+ }
2602
+ ) : /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
2603
+ media,
2604
+ meta
2605
+ ] }),
2606
+ onMakeDefault || onDelete ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
2607
+ onMakeDefault ? /* @__PURE__ */ jsx(
2608
+ Button,
2609
+ {
2610
+ type: "button",
2611
+ size: "sm",
2612
+ variant: "secondary",
2613
+ disabled: disabled || actionsPending,
2614
+ onClick: onMakeDefault,
2615
+ children: copy.makeDefault
2616
+ }
2617
+ ) : null,
2618
+ onDelete ? /* @__PURE__ */ jsx(
2619
+ Button,
2620
+ {
2621
+ type: "button",
2622
+ size: "sm",
2623
+ variant: "destructive",
2624
+ disabled: disabled || actionsPending,
2625
+ onClick: onDelete,
2626
+ children: copy.delete
2627
+ }
2628
+ ) : null
2629
+ ] }) : null
2630
+ ]
2631
+ }
2632
+ );
2633
+ }
2634
+ function formatCountdown(ms) {
2635
+ if (ms <= 0) return "0:00";
2636
+ const total = Math.floor(ms / 1e3);
2637
+ const h = Math.floor(total / 3600);
2638
+ const m = Math.floor(total % 3600 / 60);
2639
+ const s = total % 60;
2640
+ const mm = String(m).padStart(2, "0");
2641
+ const ss = String(s).padStart(2, "0");
2642
+ return h > 0 ? `${h}:${mm}:${ss}` : `${m}:${ss}`;
2643
+ }
2644
+ function WaitingRoom({
2645
+ title,
2646
+ organizationName,
2647
+ organizationImage,
2648
+ startsAt,
2649
+ durationSeconds,
2650
+ curtain,
2651
+ nowMs,
2652
+ labels,
2653
+ className
2654
+ }) {
2655
+ const [now, setNow] = React7.useState(nowMs ?? Date.now());
2656
+ React7.useEffect(() => {
2657
+ if (nowMs != null) {
2658
+ setNow(nowMs);
2659
+ return;
2660
+ }
2661
+ const timer = window.setInterval(() => setNow(Date.now()), 1e3);
2662
+ return () => window.clearInterval(timer);
2663
+ }, [nowMs]);
2664
+ const remaining = startsAt != null ? startsAt - now : null;
2665
+ const durationMinutes = durationSeconds != null ? Math.max(1, Math.round(durationSeconds / 60)) : null;
2666
+ return /* @__PURE__ */ jsxs(
2667
+ "div",
2668
+ {
2669
+ className: cn(
2670
+ "relative flex min-h-[16rem] w-full overflow-hidden rounded-lg bg-zinc-950 text-white",
2671
+ className
2672
+ ),
2673
+ children: [
2674
+ curtain ? /* @__PURE__ */ jsx(
2675
+ CurtainStage,
2676
+ {
2677
+ kind: curtain.kind,
2678
+ url: curtain.url,
2679
+ className: "absolute inset-0"
2680
+ }
2681
+ ) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 bg-gradient-to-br from-zinc-900 to-zinc-950" }),
2682
+ /* @__PURE__ */ jsxs("div", { className: "relative z-10 flex w-full flex-col justify-end gap-3 bg-gradient-to-t from-black/70 via-black/30 to-transparent p-6", children: [
2683
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
2684
+ organizationImage ? /* @__PURE__ */ jsx(
2685
+ "img",
2686
+ {
2687
+ src: organizationImage,
2688
+ alt: "",
2689
+ className: "size-10 rounded-lg object-cover"
2690
+ }
2691
+ ) : /* @__PURE__ */ jsx("div", { className: "flex size-10 items-center justify-center rounded-lg bg-white/15 text-sm font-semibold", children: (organizationName ?? title).slice(0, 1).toUpperCase() }),
2692
+ /* @__PURE__ */ jsxs("div", { children: [
2693
+ /* @__PURE__ */ jsx("p", { className: "text-lg font-semibold tracking-tight", children: title }),
2694
+ organizationName ? /* @__PURE__ */ jsx("p", { className: "text-sm text-white/80", children: organizationName }) : null
2695
+ ] })
2696
+ ] }),
2697
+ remaining != null ? /* @__PURE__ */ jsx("p", { className: "text-sm tabular-nums", children: remaining > 0 ? `${labels?.startsIn ?? "Starts in"} ${formatCountdown(remaining)}` : labels?.started ?? "Starting soon" }) : null,
2698
+ durationMinutes != null ? /* @__PURE__ */ jsx("p", { className: "text-xs text-white/70", children: labels?.duration ? labels.duration(durationMinutes) : `${durationMinutes} min` }) : null
2699
+ ] })
2700
+ ]
2701
+ }
2702
+ );
2703
+ }
2704
+
2705
+ // src/components/video/castHls.ts
2706
+ var CAST_SENDER_SRC = "https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";
2707
+ var DEFAULT_RECEIVER_ID = "CC1AD845";
2708
+ var loadPromise = null;
2709
+ function loadCastSender() {
2710
+ if (typeof window === "undefined") return Promise.resolve();
2711
+ if (window.cast?.framework && window.chrome?.cast) return Promise.resolve();
2712
+ if (loadPromise) return loadPromise;
2713
+ loadPromise = new Promise((resolve, reject) => {
2714
+ window.__onGCastApiAvailable = (available) => {
2715
+ if (available) resolve();
2716
+ else reject(new Error("Cast API unavailable"));
2717
+ };
2718
+ const existing = document.querySelector(`script[src="${CAST_SENDER_SRC}"]`);
2719
+ if (existing) return;
2720
+ const script = document.createElement("script");
2721
+ script.src = CAST_SENDER_SRC;
2722
+ script.async = true;
2723
+ script.onerror = () => reject(new Error("Cast sender failed to load"));
2724
+ document.head.appendChild(script);
2725
+ });
2726
+ return loadPromise;
2727
+ }
2728
+ async function castHlsUrl(hlsUrl) {
2729
+ await loadCastSender();
2730
+ const framework = window.cast?.framework;
2731
+ const chromeCast = window.chrome?.cast;
2732
+ if (!framework || !chromeCast) {
2733
+ throw new Error("Cast API unavailable");
2734
+ }
2735
+ const context = framework.CastContext.getInstance();
2736
+ context.setOptions({
2737
+ receiverApplicationId: chromeCast.media.DEFAULT_MEDIA_RECEIVER_APP_ID || DEFAULT_RECEIVER_ID,
2738
+ autoJoinPolicy: chromeCast.AutoJoinPolicy?.ORIGIN_SCOPED
2739
+ });
2740
+ if (!context.getCurrentSession()) {
2741
+ await context.requestSession();
2742
+ }
2743
+ const session = context.getCurrentSession();
2744
+ if (!session) throw new Error("No Cast session");
2745
+ const media = new chromeCast.media.MediaInfo(hlsUrl, "application/x-mpegURL");
2746
+ const request = new chromeCast.media.LoadRequest(media);
2747
+ await session.loadMedia(request);
2748
+ }
2235
2749
 
2236
2750
  // src/components/video/hls-config.ts
2237
2751
  function shouldRetryLiveEdge404(retryConfig, retryCount, _isTimeout, loaderResponse, defaultRetry) {
@@ -2411,27 +2925,27 @@ function useHlsPlayback({
2411
2925
  onError,
2412
2926
  onPlayingChange
2413
2927
  }) {
2414
- const videoRef = React3.useRef(null);
2415
- const hlsRef = React3.useRef(null);
2416
- const [state, setState] = React3.useState("idle");
2417
- const [qualities, setQualities] = React3.useState([]);
2418
- const [activeLevel, setActiveLevel] = React3.useState(-1);
2419
- const [autoplayState, setAutoplayState] = React3.useState("none");
2420
- const [error, setError] = React3.useState(null);
2421
- const [reloadKey, setReloadKey] = React3.useState(0);
2422
- const onErrorRef = React3.useRef(onError);
2423
- const onPlayingChangeRef = React3.useRef(onPlayingChange);
2424
- React3.useEffect(() => {
2928
+ const videoRef = React7.useRef(null);
2929
+ const hlsRef = React7.useRef(null);
2930
+ const [state, setState] = React7.useState("idle");
2931
+ const [qualities, setQualities] = React7.useState([]);
2932
+ const [activeLevel, setActiveLevel] = React7.useState(-1);
2933
+ const [autoplayState, setAutoplayState] = React7.useState("none");
2934
+ const [error, setError] = React7.useState(null);
2935
+ const [reloadKey, setReloadKey] = React7.useState(0);
2936
+ const onErrorRef = React7.useRef(onError);
2937
+ const onPlayingChangeRef = React7.useRef(onPlayingChange);
2938
+ React7.useEffect(() => {
2425
2939
  onErrorRef.current = onError;
2426
2940
  onPlayingChangeRef.current = onPlayingChange;
2427
2941
  }, [onError, onPlayingChange]);
2428
- const retry = React3.useCallback(() => {
2942
+ const retry = React7.useCallback(() => {
2429
2943
  setError(null);
2430
2944
  setState("loading");
2431
2945
  setAutoplayState("none");
2432
2946
  setReloadKey((k) => k + 1);
2433
2947
  }, []);
2434
- React3.useEffect(() => {
2948
+ React7.useEffect(() => {
2435
2949
  const media = videoRef.current;
2436
2950
  if (!media || !src || !active) {
2437
2951
  setState("idle");
@@ -2701,7 +3215,7 @@ function useHlsPlayback({
2701
3215
  destroyHls();
2702
3216
  };
2703
3217
  }, [src, mode, active, autoPlay, muted, reloadKey]);
2704
- const setLevel = React3.useCallback((index) => {
3218
+ const setLevel = React7.useCallback((index) => {
2705
3219
  const hls = hlsRef.current;
2706
3220
  if (!hls) return;
2707
3221
  hls.nextLevel = index;
@@ -2726,6 +3240,7 @@ var DEFAULT_LABELS2 = {
2726
3240
  enterFullscreen: "Fullscreen",
2727
3241
  exitFullscreen: "Exit fullscreen",
2728
3242
  pictureInPicture: "Picture in picture",
3243
+ cast: "Cast",
2729
3244
  settings: "Settings",
2730
3245
  quality: "Quality",
2731
3246
  auto: "Auto",
@@ -2786,12 +3301,12 @@ function VideoPlayer({
2786
3301
  className
2787
3302
  }) {
2788
3303
  const t = { ...DEFAULT_LABELS2, ...labels };
2789
- const containerRef = React3.useRef(null);
2790
- const firstPlayFiredRef = React3.useRef(false);
2791
- const [userStarted, setUserStarted] = React3.useState(false);
3304
+ const containerRef = React7.useRef(null);
3305
+ const firstPlayFiredRef = React7.useRef(false);
3306
+ const [userStarted, setUserStarted] = React7.useState(false);
2792
3307
  const active = autoPlay || !poster || userStarted;
2793
3308
  const autoplayActive = autoPlay || userStarted;
2794
- const handlePlayingChange = React3.useCallback(
3309
+ const handlePlayingChange = React7.useCallback(
2795
3310
  (playing) => {
2796
3311
  setIsPlaying(playing);
2797
3312
  if (playing && !firstPlayFiredRef.current) {
@@ -2820,25 +3335,25 @@ function VideoPlayer({
2820
3335
  onError,
2821
3336
  onPlayingChange: handlePlayingChange
2822
3337
  });
2823
- const [isPlaying, setIsPlaying] = React3.useState(false);
2824
- const [isMuted, setIsMuted] = React3.useState(muted);
2825
- const [volume, setVolume] = React3.useState(1);
2826
- const [currentTime, setCurrentTime] = React3.useState(0);
2827
- const [duration, setDuration] = React3.useState(0);
2828
- const [buffered, setBuffered] = React3.useState(0);
2829
- const [isFullscreen, setIsFullscreen] = React3.useState(false);
2830
- const [pipActive, setPipActive] = React3.useState(false);
2831
- const [controlsVisible, setControlsVisible] = React3.useState(true);
2832
- const [playbackRate, setPlaybackRate] = React3.useState(1);
2833
- const [openMenu, setOpenMenu] = React3.useState(
3338
+ const [isPlaying, setIsPlaying] = React7.useState(false);
3339
+ const [isMuted, setIsMuted] = React7.useState(muted);
3340
+ const [volume, setVolume] = React7.useState(1);
3341
+ const [currentTime, setCurrentTime] = React7.useState(0);
3342
+ const [duration, setDuration] = React7.useState(0);
3343
+ const [buffered, setBuffered] = React7.useState(0);
3344
+ const [isFullscreen, setIsFullscreen] = React7.useState(false);
3345
+ const [pipActive, setPipActive] = React7.useState(false);
3346
+ const [controlsVisible, setControlsVisible] = React7.useState(true);
3347
+ const [playbackRate, setPlaybackRate] = React7.useState(1);
3348
+ const [openMenu, setOpenMenu] = React7.useState(
2834
3349
  null
2835
3350
  );
2836
- const [behindLive, setBehindLive] = React3.useState(false);
2837
- const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React3.useState(false);
2838
- const hideTimerRef = React3.useRef(null);
3351
+ const [behindLive, setBehindLive] = React7.useState(false);
3352
+ const [webkitFullscreenSupported, setWebkitFullscreenSupported] = React7.useState(false);
3353
+ const hideTimerRef = React7.useRef(null);
2839
3354
  const pipSupported = typeof document !== "undefined" && "pictureInPictureEnabled" in document && document.pictureInPictureEnabled;
2840
3355
  const fullscreenSupported = hasStandardFullscreen() || webkitFullscreenSupported;
2841
- React3.useEffect(() => {
3356
+ React7.useEffect(() => {
2842
3357
  const video = videoRef.current;
2843
3358
  if (!video || !active) return;
2844
3359
  const onTimeUpdate = () => {
@@ -2871,20 +3386,21 @@ function VideoPlayer({
2871
3386
  video.removeEventListener("ratechange", onRate);
2872
3387
  };
2873
3388
  }, [videoRef, active, mode]);
2874
- React3.useEffect(() => {
3389
+ React7.useEffect(() => {
2875
3390
  const video = videoRef.current;
2876
3391
  if (!paused || !video || !isPlaying) return;
2877
3392
  video.pause();
2878
3393
  }, [paused, videoRef, isPlaying]);
2879
- React3.useEffect(() => {
3394
+ React7.useEffect(() => {
2880
3395
  setWebkitFullscreenSupported(hasWebkitVideoFullscreen(videoRef.current));
3396
+ videoRef.current?.setAttribute("x-webkit-airplay", "allow");
2881
3397
  }, [videoRef, active]);
2882
- React3.useEffect(() => {
3398
+ React7.useEffect(() => {
2883
3399
  const onFsChange = () => setIsFullscreen(document.fullscreenElement === containerRef.current);
2884
3400
  document.addEventListener("fullscreenchange", onFsChange);
2885
3401
  return () => document.removeEventListener("fullscreenchange", onFsChange);
2886
3402
  }, []);
2887
- React3.useEffect(() => {
3403
+ React7.useEffect(() => {
2888
3404
  const video = asWebkitVideo(videoRef.current);
2889
3405
  if (!video) return;
2890
3406
  const onBegin = () => setIsFullscreen(true);
@@ -2896,7 +3412,7 @@ function VideoPlayer({
2896
3412
  video.removeEventListener("webkitendfullscreen", onEnd);
2897
3413
  };
2898
3414
  }, [videoRef, active]);
2899
- React3.useEffect(() => {
3415
+ React7.useEffect(() => {
2900
3416
  const video = videoRef.current;
2901
3417
  if (!video) return;
2902
3418
  const onEnter = () => setPipActive(true);
@@ -2908,18 +3424,18 @@ function VideoPlayer({
2908
3424
  video.removeEventListener("leavepictureinpicture", onLeave);
2909
3425
  };
2910
3426
  }, [videoRef]);
2911
- const scheduleHide = React3.useCallback(() => {
3427
+ const scheduleHide = React7.useCallback(() => {
2912
3428
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
2913
3429
  hideTimerRef.current = setTimeout(() => {
2914
3430
  setControlsVisible(false);
2915
3431
  setOpenMenu(null);
2916
3432
  }, CONTROLS_HIDE_MS);
2917
3433
  }, []);
2918
- const revealControls = React3.useCallback(() => {
3434
+ const revealControls = React7.useCallback(() => {
2919
3435
  setControlsVisible(true);
2920
3436
  scheduleHide();
2921
3437
  }, [scheduleHide]);
2922
- React3.useEffect(() => {
3438
+ React7.useEffect(() => {
2923
3439
  return () => {
2924
3440
  if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
2925
3441
  };
@@ -3290,6 +3806,16 @@ function VideoPlayer({
3290
3806
  ]
3291
3807
  }
3292
3808
  ),
3809
+ /* @__PURE__ */ jsx(
3810
+ ControlButton,
3811
+ {
3812
+ label: t.cast,
3813
+ onClick: () => {
3814
+ void castHlsUrl(src).catch(() => void 0);
3815
+ },
3816
+ children: /* @__PURE__ */ jsx(Cast, { className: "size-5" })
3817
+ }
3818
+ ),
3293
3819
  pipSupported && /* @__PURE__ */ jsx(ControlButton, { label: t.pictureInPicture, onClick: togglePip, children: /* @__PURE__ */ jsx(
3294
3820
  PictureInPicture2,
3295
3821
  {
@@ -3412,16 +3938,16 @@ function videoInPictureInPicture(container) {
3412
3938
  return container.contains(pip);
3413
3939
  }
3414
3940
  function useFeedExclusivePlayback(playbackId) {
3415
- const containerRef = React3.useRef(null);
3416
- const [forcePaused, setForcePaused] = React3.useState(false);
3417
- const requestPause = React3.useCallback(() => {
3941
+ const containerRef = React7.useRef(null);
3942
+ const [forcePaused, setForcePaused] = React7.useState(false);
3943
+ const requestPause = React7.useCallback(() => {
3418
3944
  if (videoInPictureInPicture(containerRef.current)) return;
3419
3945
  setForcePaused(true);
3420
3946
  }, []);
3421
- React3.useEffect(() => {
3947
+ React7.useEffect(() => {
3422
3948
  return registerFeedPlayer(playbackId, requestPause);
3423
3949
  }, [playbackId, requestPause]);
3424
- React3.useEffect(() => {
3950
+ React7.useEffect(() => {
3425
3951
  const node = containerRef.current;
3426
3952
  if (!node || typeof IntersectionObserver === "undefined") return;
3427
3953
  const observer = new IntersectionObserver(
@@ -3437,14 +3963,14 @@ function useFeedExclusivePlayback(playbackId) {
3437
3963
  observer.observe(node);
3438
3964
  return () => observer.disconnect();
3439
3965
  }, [requestPause]);
3440
- React3.useEffect(() => {
3966
+ React7.useEffect(() => {
3441
3967
  const onVisibility = () => {
3442
3968
  if (document.hidden) requestPause();
3443
3969
  };
3444
3970
  document.addEventListener("visibilitychange", onVisibility);
3445
3971
  return () => document.removeEventListener("visibilitychange", onVisibility);
3446
3972
  }, [requestPause]);
3447
- const onPlayingChange = React3.useCallback(
3973
+ const onPlayingChange = React7.useCallback(
3448
3974
  (playing) => {
3449
3975
  if (!playing) return;
3450
3976
  setForcePaused(false);
@@ -3471,7 +3997,7 @@ function FeedVideoPlayer({
3471
3997
  paused: exclusivePaused,
3472
3998
  onPlayingChange: onExclusivePlayingChange
3473
3999
  } = useFeedExclusivePlayback(playbackId);
3474
- const handlePlayingChange = React3.useCallback(
4000
+ const handlePlayingChange = React7.useCallback(
3475
4001
  (playing) => {
3476
4002
  onExclusivePlayingChange(playing);
3477
4003
  onPlayingChange?.(playing);
@@ -3498,8 +4024,8 @@ function FeedVideoPlayer({
3498
4024
  );
3499
4025
  }
3500
4026
  function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {}) {
3501
- const [stats, setStats] = React3.useState({});
3502
- React3.useEffect(() => {
4027
+ const [stats, setStats] = React7.useState({});
4028
+ React7.useEffect(() => {
3503
4029
  if (!statsUrl || !enabled) return;
3504
4030
  let cancelled = false;
3505
4031
  const controller = new AbortController();
@@ -3528,18 +4054,6 @@ function usePlaybackStats(statsUrl, { intervalMs = 15e3, enabled = true } = {})
3528
4054
  }, [statsUrl, intervalMs, enabled]);
3529
4055
  return stats;
3530
4056
  }
3531
- function useMediaQuery2(query) {
3532
- const [matches, setMatches] = useState(false);
3533
- useEffect(() => {
3534
- if (typeof window === "undefined" || !window.matchMedia) return;
3535
- const mql = window.matchMedia(query);
3536
- const onChange = () => setMatches(mql.matches);
3537
- onChange();
3538
- mql.addEventListener("change", onChange);
3539
- return () => mql.removeEventListener("change", onChange);
3540
- }, [query]);
3541
- return matches;
3542
- }
3543
4057
 
3544
4058
  // src/lib/avatar.ts
3545
4059
  var EMPTY_COLORS = {
@@ -3622,6 +4136,6 @@ function avatarFallbackStyle(name) {
3622
4136
  return getAvatarColors(name);
3623
4137
  }
3624
4138
 
3625
- export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, LanguageContext, LanguageSwitcher, LoadingState, SafeImage, ThemeSwitcher, VideoPlayer, avatarFallbackStyle, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, getAvatarColors, getInitials, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
4139
+ export { AvatarEditor, AvatarEditorDialog, ConfirmDestructiveDialog, CurtainPicker, CurtainPickerSkeleton, CurtainPreview, CurtainStage, DEFAULT_CURTAIN_PICKER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DataList, DataListItem, EditableSection, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyState, EmptyTitle, ErrorState, FeedVideoPlayer, FieldMessage, LanguageContext, LanguageSwitcher, LoadingState, SafeImage, ThemeSwitcher, VideoPlayer, WaitingRoom, avatarFallbackStyle, castHlsUrl, cn, createLiveHlsConfig, createVodHlsConfig, defaultLanguages, describeAvResync, describePlaybackError, getAvatarColors, getInitials, loadCastSender, shouldRetryLiveEdge404, useEditableSection, useFeedExclusivePlayback, useHlsPlayback, useLanguageContext, useMediaQuery2 as useMediaQuery, usePlaybackStats };
3626
4140
  //# sourceMappingURL=index.js.map
3627
4141
  //# sourceMappingURL=index.js.map