@zuude-ui/video 0.1.35 → 0.1.42

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.
@@ -0,0 +1,84 @@
1
+ import { V as VideoRef } from '../types-DejCaLAg.cjs';
2
+ import { RefObject } from 'react';
3
+
4
+ declare const useAutoplayByForce: (videoRef: VideoRef, enabled: boolean, setError?: (error: string | null) => void) => void;
5
+
6
+ declare const useAutoplayOnVisible: (videoRef: VideoRef, threshold: number | undefined, enabled?: boolean) => void;
7
+
8
+ declare const useFullscreen: (videoRef: VideoRef) => {
9
+ isFullscreen: boolean;
10
+ toggleFullscreen: () => void;
11
+ };
12
+
13
+ declare const useGetDuration: (videoRef: VideoRef) => {
14
+ duration: number | null;
15
+ isLoading: boolean;
16
+ };
17
+
18
+ declare const useHotKeys: (key: string, func: (event: KeyboardEvent) => void, enabled?: boolean) => void;
19
+
20
+ declare const useMuteUnmute: (videoRef: VideoRef) => {
21
+ toggleMute: () => void;
22
+ isMuted: boolean;
23
+ mute: () => void;
24
+ unmute: () => void;
25
+ };
26
+
27
+ declare const usePictureInPicture: (videoRef: VideoRef) => {
28
+ togglePictureInPicture: () => Promise<void>;
29
+ requestPictureInPicture: () => Promise<void>;
30
+ exitPictureInPicture: () => Promise<void>;
31
+ };
32
+
33
+ declare const usePlayPause: (videoRef: VideoRef) => {
34
+ togglePlay: () => void;
35
+ isPlaying: boolean;
36
+ play: () => void;
37
+ pause: () => void;
38
+ };
39
+
40
+ declare const useSeek: (videoRef: VideoRef, value?: number) => {
41
+ seekForward: () => void;
42
+ seekBackward: () => void;
43
+ };
44
+
45
+ declare const useSpeed: (videoRef: VideoRef) => {
46
+ speed: number;
47
+ onChangeSpeed: (speed: number) => void;
48
+ };
49
+
50
+ declare const useStartAt: (videoRef: VideoRef, startAt: number) => void;
51
+
52
+ declare const useCurrentTime: (videoRef: VideoRef, interval?: number) => {
53
+ currentTime: number;
54
+ onTimeUpdate: (time: number) => void;
55
+ };
56
+
57
+ declare const useVideoState: (videoRef: RefObject<HTMLVideoElement | null>) => {
58
+ isPlaying: boolean;
59
+ isMuted: boolean;
60
+ isFullscreen: boolean;
61
+ };
62
+
63
+ declare const useVolume: (videoRef: VideoRef, initialVolume?: number) => {
64
+ volume: number;
65
+ onChangeVolume: (volume: number) => void;
66
+ };
67
+
68
+ declare const useBuffer: (videoRef: VideoRef, duration?: number) => {
69
+ buffered: number;
70
+ bufferedPercentage: number;
71
+ };
72
+
73
+ declare const useDownload: (videoRef: VideoRef) => {
74
+ downloadVideo: (filename?: string) => Promise<void>;
75
+ downloadDirect: (filename?: string) => void;
76
+ isDownloading: boolean;
77
+ downloadProgress: number;
78
+ error: string | null;
79
+ resetError: () => void;
80
+ };
81
+
82
+ declare const useRange: (videoRef: VideoRef, range: [number, number]) => void;
83
+
84
+ export { useAutoplayByForce, useAutoplayOnVisible, useBuffer, useCurrentTime, useDownload, useFullscreen, useGetDuration, useHotKeys, useMuteUnmute, usePictureInPicture, usePlayPause, useRange, useSeek, useSpeed, useStartAt, useVideoState, useVolume };
@@ -0,0 +1,84 @@
1
+ import { V as VideoRef } from '../types-DejCaLAg.js';
2
+ import { RefObject } from 'react';
3
+
4
+ declare const useAutoplayByForce: (videoRef: VideoRef, enabled: boolean, setError?: (error: string | null) => void) => void;
5
+
6
+ declare const useAutoplayOnVisible: (videoRef: VideoRef, threshold: number | undefined, enabled?: boolean) => void;
7
+
8
+ declare const useFullscreen: (videoRef: VideoRef) => {
9
+ isFullscreen: boolean;
10
+ toggleFullscreen: () => void;
11
+ };
12
+
13
+ declare const useGetDuration: (videoRef: VideoRef) => {
14
+ duration: number | null;
15
+ isLoading: boolean;
16
+ };
17
+
18
+ declare const useHotKeys: (key: string, func: (event: KeyboardEvent) => void, enabled?: boolean) => void;
19
+
20
+ declare const useMuteUnmute: (videoRef: VideoRef) => {
21
+ toggleMute: () => void;
22
+ isMuted: boolean;
23
+ mute: () => void;
24
+ unmute: () => void;
25
+ };
26
+
27
+ declare const usePictureInPicture: (videoRef: VideoRef) => {
28
+ togglePictureInPicture: () => Promise<void>;
29
+ requestPictureInPicture: () => Promise<void>;
30
+ exitPictureInPicture: () => Promise<void>;
31
+ };
32
+
33
+ declare const usePlayPause: (videoRef: VideoRef) => {
34
+ togglePlay: () => void;
35
+ isPlaying: boolean;
36
+ play: () => void;
37
+ pause: () => void;
38
+ };
39
+
40
+ declare const useSeek: (videoRef: VideoRef, value?: number) => {
41
+ seekForward: () => void;
42
+ seekBackward: () => void;
43
+ };
44
+
45
+ declare const useSpeed: (videoRef: VideoRef) => {
46
+ speed: number;
47
+ onChangeSpeed: (speed: number) => void;
48
+ };
49
+
50
+ declare const useStartAt: (videoRef: VideoRef, startAt: number) => void;
51
+
52
+ declare const useCurrentTime: (videoRef: VideoRef, interval?: number) => {
53
+ currentTime: number;
54
+ onTimeUpdate: (time: number) => void;
55
+ };
56
+
57
+ declare const useVideoState: (videoRef: RefObject<HTMLVideoElement | null>) => {
58
+ isPlaying: boolean;
59
+ isMuted: boolean;
60
+ isFullscreen: boolean;
61
+ };
62
+
63
+ declare const useVolume: (videoRef: VideoRef, initialVolume?: number) => {
64
+ volume: number;
65
+ onChangeVolume: (volume: number) => void;
66
+ };
67
+
68
+ declare const useBuffer: (videoRef: VideoRef, duration?: number) => {
69
+ buffered: number;
70
+ bufferedPercentage: number;
71
+ };
72
+
73
+ declare const useDownload: (videoRef: VideoRef) => {
74
+ downloadVideo: (filename?: string) => Promise<void>;
75
+ downloadDirect: (filename?: string) => void;
76
+ isDownloading: boolean;
77
+ downloadProgress: number;
78
+ error: string | null;
79
+ resetError: () => void;
80
+ };
81
+
82
+ declare const useRange: (videoRef: VideoRef, range: [number, number]) => void;
83
+
84
+ export { useAutoplayByForce, useAutoplayOnVisible, useBuffer, useCurrentTime, useDownload, useFullscreen, useGetDuration, useHotKeys, useMuteUnmute, usePictureInPicture, usePlayPause, useRange, useSeek, useSpeed, useStartAt, useVideoState, useVolume };
@@ -0,0 +1,2 @@
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"../chunk-XV6ODTKT.js";export{a as useAutoplayByForce,h as useAutoplayOnVisible,o as useBuffer,l as useCurrentTime,p as useDownload,f as useFullscreen,i as useGetDuration,b as useHotKeys,e as useMuteUnmute,g as usePictureInPicture,d as usePlayPause,q as useRange,c as useSeek,j as useSpeed,k as useStartAt,m as useVideoState,n as useVolume};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.cjs CHANGED
@@ -1,3 +1,2 @@
1
- "use strict";"use client";var pe=Object.create;var C=Object.defineProperty;var ye=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ee=Object.getPrototypeOf,ve=Object.prototype.hasOwnProperty;var Pe=(e,n)=>{for(var r in n)C(e,r,{get:n[r],enumerable:!0})},O=(e,n,r,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let u of Ve(n))!ve.call(e,u)&&u!==r&&C(e,u,{get:()=>n[u],enumerable:!(t=ye(n,u))||t.enumerable});return e};var d=(e,n,r)=>(r=e!=null?pe(Ee(e)):{},O(n||!e||!e.__esModule?C(r,"default",{value:e,enumerable:!0}):r,e)),he=e=>O(C({},"__esModule",{value:!0}),e);var xe={};Pe(xe,{Video:()=>ne,formatTime:()=>ie,useAutoplayByForce:()=>T,useFullscreen:()=>S,useGetDuration:()=>se,useMuteUnmute:()=>M,usePlayPause:()=>V,useStartAt:()=>w,useTimeline:()=>ue,useVideo:()=>l,useVolume:()=>oe});module.exports=he(xe);function N(e,{insertAt:n}={}){if(!e||typeof document=="undefined")return;let r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",n==="top"&&r.firstChild?r.insertBefore(t,r.firstChild):r.appendChild(t),t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}N(`.reset-styles{box-sizing:border-box;padding:0;margin:0}[data-zuude-video-wrapper]{position:relative}[data-zuude-video-wrapper] [data-zuude-video]{width:100%;height:100%;object-fit:cover}
2
- `);var E=d(require("react"),1);var g=d(require("react"),1),$=require("react/jsx-runtime"),z=g.default.createContext(void 0),l=()=>{let e=g.default.useContext(z);if(!e)throw new Error("useVideo must be used within a VideoProvider");return e},q=({children:e,videoRef:n,duration:r,showHidingElement:t,setShowHidingElement:u})=>{let[s,o]=g.default.useState(!1);return(0,$.jsx)(z.Provider,{value:{videoRef:n,duration:r,isFullscreen:s,setIsFullscreen:o,showHidingElement:t,setShowHidingElement:u},children:e})};var B=d(require("react"),1),T=(e,n,r)=>{B.default.useEffect(()=>{if(!(e!=null&&e.current)||!n)return;(async()=>{var u;try{await((u=e.current)==null?void 0:u.play())}catch(s){if(s instanceof Error&&s.name==="NotAllowedError"){if(r==null||r("NotAllowedError"),console.error("NotAllowedError"),e!=null&&e.current){e.current.muted=!0;try{await e.current.play()}catch(o){console.error(o)}}}else console.error(s)}})()},[n,e==null?void 0:e.current])};var D=d(require("react"),1),w=(e,n)=>{D.default.useEffect(()=>{if(!(e!=null&&e.current)||!n)return;let r=e==null?void 0:e.current;r&&n&&(r.currentTime=n)},[n,e==null?void 0:e.current])};var U=d(require("react"),1),j=(e,n,r)=>{U.default.useEffect(()=>{if(!r||!(e!=null&&e.current))return;let t=new IntersectionObserver(u=>{u.forEach(s=>{var o;e!=null&&e.current&&(s.isIntersecting?e.current.play().catch(a=>{e.current&&(e.current.pause(),e.current.muted=!0,e.current.play(),console.error(a))}):(o=e.current)==null||o.pause())})},{threshold:n!=null?n:.5});return t.observe(e==null?void 0:e.current),()=>{t.disconnect()}},[r,e==null?void 0:e.current])};var L=d(require("react"),1),V=(e,n)=>{let[r,t]=L.default.useState(!1),u=L.default.useCallback(()=>{console.log(e==null?void 0:e.current),e!=null&&e.current&&(e.current.paused?e.current.play():e.current.pause())},[e==null?void 0:e.current]);return L.default.useEffect(()=>{if(!n||!(e!=null&&e.current))return;let s=()=>{t(!0)},o=()=>{t(!1)};if(t(!(e!=null&&e.current.paused)),e!=null&&e.current)return e.current.addEventListener("play",s),e.current.addEventListener("pause",o),()=>{var a,m;(a=e.current)==null||a.removeEventListener("play",s),(m=e.current)==null||m.removeEventListener("pause",o)}},[e==null?void 0:e.current,n]),{togglePlay:u,isPlaying:r}};var W=require("react/jsx-runtime"),G=()=>{let{videoRef:e}=l(),{togglePlay:n}=V(e,!0);return(0,W.jsx)("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},onClick:n})};var Y=d(require("react"),1);var F=d(require("react"),1),M=(e,n)=>{let[r,t]=F.default.useState(!1),u=F.default.useCallback(()=>{e!=null&&e.current&&(e.current.muted=!e.current.muted)},[e==null?void 0:e.current]);return F.default.useEffect(()=>{if(!n||!(e!=null&&e.current))return;t(e.current.muted);let s=()=>{e.current&&t(e.current.muted)};return e.current.addEventListener("volumechange",s),()=>{var o;(o=e.current)==null||o.removeEventListener("volumechange",s)}},[e==null?void 0:e.current,n]),{toggleMute:u,isMuted:r}};var J=d(require("react"),1);var S=()=>{let{videoRef:e,isFullscreen:n,setIsFullscreen:r}=l();J.default.useEffect(()=>{let u=()=>{r==null||r(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",u),()=>document.removeEventListener("fullscreenchange",u)},[]);let t=()=>{var a;let u=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),s=e==null?void 0:e.current;if(s&&u){if(s.webkitEnterFullscreen){s.webkitEnterFullscreen();return}else if(s.requestFullscreen){s.requestFullscreen();return}}let o=(a=e==null?void 0:e.current)==null?void 0:a.closest("[data-zuude-video-wrapper]");o&&(n?document.exitFullscreen():o.requestFullscreen())};return{isFullscreen:n!=null?n:!1,toggleFullscreen:t}};var K=d(require("react"),1);var Q=()=>{let{videoRef:e,isPictureInPicture:n,setIsPictureInPicture:r}=l();K.default.useEffect(()=>{let u=()=>{r==null||r(!!document.pictureInPictureElement)};return document.addEventListener("pictureinpicturechange",u),()=>document.removeEventListener("pictureinpicturechange",u)},[]);let t=async()=>{let u=e==null?void 0:e.current;if(u)try{document.pictureInPictureElement?await document.exitPictureInPicture():await u.requestPictureInPicture()}catch(s){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))u.webkitEnterFullscreen?u.webkitEnterFullscreen():u.requestFullscreen&&u.requestFullscreen();else{let a=u.closest("[data-zuude-video-wrapper]");a&&(document.fullscreenElement?await document.exitFullscreen():await a.requestFullscreen())}}};return{isPictureInPicture:n!=null?n:!1,togglePictureInPicture:t}};var I=d(require("react"),1),X=(e,n)=>{let[r,t]=I.default.useState(1),u=s=>{t(s)};return I.default.useEffect(()=>{e!=null&&e.current&&t(e.current.playbackRate)},[e==null?void 0:e.current]),I.default.useEffect(()=>{!n||!(e!=null&&e.current)||(e.current.playbackRate=r)},[r,n,e==null?void 0:e.current]),{speed:r,onChangeSpeed:u}};var Z=Y.default.forwardRef(({children:e},n)=>{let{duration:r,showHidingElement:t}=l(),{togglePlay:u,isPlaying:s}=V(n,typeof e=="function"),{speed:o,onChangeSpeed:a}=X(n,typeof e=="function"),{toggleMute:m,isMuted:p}=M(n,typeof e=="function"),{isFullscreen:P,toggleFullscreen:A}=S(),{isPictureInPicture:R,togglePictureInPicture:i}=Q();return typeof e!="function"?null:e({isPlaying:s,togglePlay:u,isMuted:p,toggleMute:m,speed:o,onChangeSpeed:a,isFullscreen:P,toggleFullscreen:A,isPictureInPicture:R,togglePictureInPicture:i,duration:r,showHidingElement:t!=null?t:!1})});var _=d(require("react"),1);var te=require("react/jsx-runtime"),ee=_.default.forwardRef(({children:e,className:n,...r})=>{let{videoRef:t}=l(),{isPlaying:u}=V(t,!0),{showHidingElement:s,setShowHidingElement:o}=l();return(0,te.jsx)("div",{"data-zuude-hiding-element":!0,"data-show":!u||s,className:n,onMouseEnter:()=>{o==null||o(!0)},onMouseLeave:()=>{o==null||o(!1)},...r,children:e})});var x=require("react/jsx-runtime"),re=E.default.forwardRef(({children:e,autoPlay:n,className:r,config:t,ratio:u,controls:s,pause:o,...a},m)=>{let[p,P]=E.default.useState(null),[A,R]=E.default.useState(null),i=m||E.default.useRef(null),[ae,b]=E.default.useState(!1),v=E.default.useRef(null),ce=()=>{var c;(c=i.current)!=null&&c.paused||(b(!0),v.current&&clearTimeout(v.current))},le=()=>{var c;(c=i.current)!=null&&c.paused||(b(!1),v.current&&clearTimeout(v.current))},de=()=>{var c;(c=i.current)!=null&&c.paused||(b(!0),v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{b(!1)},3e3))};return E.default.useEffect(()=>{var c,y;o!==void 0&&(o?(c=i.current)==null||c.pause():(y=i.current)==null||y.play())},[o,i.current]),T(i,n==="force"&&a.muted===void 0&&!(t!=null&&t.autoplayOnVisible),R),w(i,t==null?void 0:t.startAt),j(i,typeof(t==null?void 0:t.autoplayOnVisible)=="number"?t.autoplayOnVisible:void 0,t==null?void 0:t.autoplayOnVisible),(0,x.jsx)(q,{videoRef:i,duration:p,showHidingElement:ae,setShowHidingElement:b,children:(0,x.jsxs)("div",{"data-zuude-video-wrapper":!0,className:r,style:{aspectRatio:u},children:[(0,x.jsx)("video",{"data-zuude-video":!0,ref:i,autoPlay:t!=null&&t.autoplayOnVisible?!1:n==="force"?!0:n,playsInline:!0,onMouseEnter:ce,onMouseLeave:le,onMouseMove:de,onClick:()=>{var c,y,h;t!=null&&t.clickToPlay&&((c=i.current)!=null&&c.paused?(y=i.current)==null||y.play():(h=i.current)==null||h.pause())},onLoadedMetadata:c=>{console.log("loaded metadata"),P(c.target.duration)},onTimeUpdate:c=>{var y;if(t!=null&&t.range){let[h,me]=t.range;if(!(i!=null&&i.current))return;((y=i==null?void 0:i.current)==null?void 0:y.currentTime)<h&&(i.current.currentTime=h),i.current.currentTime>me&&(i.current.currentTime=h)}},className:r,style:{aspectRatio:u},...a}),typeof e=="function"?(0,x.jsx)(Z,{ref:i,children:e}):e,A==="NotAllowedError"&&typeof(t==null?void 0:t.muteFallback)=="function"&&t.muteFallback(()=>{i.current&&(i.current.muted=!i.current.muted),R(null)})]})})});re.displayName="Video";var ne=Object.assign(re,{PlayPauseOnVideo:G,HidingElement:ee});var H=d(require("react"),1);var oe=()=>{let[e,n]=H.default.useState(100),{videoRef:r}=l(),t=u=>{n(u)};return H.default.useEffect(()=>{r!=null&&r.current&&n(r.current.volume*100)},[r==null?void 0:r.current]),H.default.useEffect(()=>{r!=null&&r.current&&(r.current.volume=e/100)},[e,r==null?void 0:r.current]),{volume:e,onChangeVolume:t}};var f=d(require("react"),1);var ue=()=>{let[e,n]=f.default.useState(!1),[r,t]=f.default.useState(0),[u,s]=f.default.useState(0),{videoRef:o,duration:a}=l();return f.default.useEffect(()=>{if(o!=null&&o.current&&e){let m=setInterval(()=>{var p,P;t(((p=o.current)==null?void 0:p.currentTime)||0),(P=o.current)!=null&&P.buffered.length&&s(o.current.buffered.end(o.current.buffered.length-1))},10);return()=>clearInterval(m)}},[o==null?void 0:o.current,e]),f.default.useEffect(()=>{if(o!=null&&o.current)return o.current.addEventListener("play",()=>n(!0)),o.current.addEventListener("pause",()=>n(!1)),()=>{var m,p;(m=o.current)==null||m.removeEventListener("play",()=>n(!0)),(p=o.current)==null||p.removeEventListener("pause",()=>n(!1))}},[]),{currentTime:r,duration:a,buffered:u,setCurrentTime:t}};var k=d(require("react"),1),se=e=>{let[n,r]=k.default.useState(!1),[t,u]=k.default.useState(null);return k.default.useEffect(()=>{if(e!=null&&e.current)return r(!0),e.current.addEventListener("loadedmetadata",()=>{var s,o;u((o=(s=e.current)==null?void 0:s.duration)!=null?o:null),r(!1)}),e.current.addEventListener("error",()=>{r(!1)}),()=>{var s,o;(s=e.current)==null||s.removeEventListener("loadedmetadata",()=>{}),(o=e.current)==null||o.removeEventListener("error",()=>{})}},[e==null?void 0:e.current]),{duration:t,isLoading:n}};function ie(e,n="mm:ss"){let r=Math.floor(e/60),t=Math.floor(e%60);return n==="h:mm:ss"?`${Math.floor(r/60)}:${r}:${t<10?"0":""}${t}`:`${r}:${t<10?"0":""}${t}`}0&&(module.exports={Video,formatTime,useAutoplayByForce,useFullscreen,useGetDuration,useMuteUnmute,usePlayPause,useStartAt,useTimeline,useVideo,useVolume});
1
+ "use strict";"use client";var mt=Object.create;var z=Object.defineProperty;var it=Object.getOwnPropertyDescriptor;var pt=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty;var Et=(t,n)=>{for(var r in n)z(t,r,{get:n[r],enumerable:!0})},Z=(t,n,r,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let s of pt(n))!yt.call(t,s)&&s!==r&&z(t,s,{get:()=>n[s],enumerable:!(e=it(n,s))||e.enumerable});return t};var P=(t,n,r)=>(r=t!=null?mt(dt(t)):{},Z(n||!t||!t.__esModule?z(r,"default",{value:t,enumerable:!0}):r,t)),ht=t=>Z(z({},"__esModule",{value:!0}),t);var Nt={};Et(Nt,{Controls:()=>wt,Download:()=>jt,ExitFullscreen:()=>At,Fullscreen:()=>Mt,Loading:()=>Dt,Mute:()=>Ct,Pause:()=>Tt,PictureInPicture:()=>Ht,Play:()=>xt,SeekBackward:()=>It,SeekForward:()=>St,Shadow:()=>Ot,Speed:()=>Ft,Unmute:()=>kt,Video:()=>X,VideoProvider:()=>R,useVideo:()=>y});module.exports=ht(Nt);var L=P(require("react"),1),J=require("react/jsx-runtime"),v=(0,L.createContext)(null),R=L.default.memo(({children:t,config:n,onError:r,...e})=>{let[s,o]=(0,L.useState)({current:null}),[u,c]=(0,L.useState)(null),[d,a]=(0,L.useState)(!1),E=(0,L.useRef)(null);return(0,L.useEffect)(()=>{r==null||r(u)},[u]),(0,L.useEffect)(()=>{let m=E.current;if(m){let l=m.querySelectorAll("[data-zuude-hide-elements]"),i=m.querySelector("[data-zuude-video]");if(l){let f=null,H=3e3,w=!1,x=()=>{f&&(clearTimeout(f),f=null),f=setTimeout(()=>{w&&i&&!i.paused&&l.forEach(T=>{T.setAttribute("data-hidden","true")}),f=null},H)},h=()=>{w=!0,l.forEach(T=>{T.removeAttribute("data-hidden")}),x()},M=()=>{w=!1,f&&(clearTimeout(f),f=null),i&&!i.paused&&l.forEach(T=>{T.setAttribute("data-hidden","true")})},C=()=>{w&&(l.forEach(T=>{T.hasAttribute("data-hidden")&&T.removeAttribute("data-hidden")}),x())},k=()=>{w||l.forEach(T=>{T.setAttribute("data-hidden","true")})};return m.addEventListener("mouseenter",h),m.addEventListener("mouseleave",M),m.addEventListener("mousemove",C),i.addEventListener("pause",h),i.addEventListener("play",k),()=>{f&&clearTimeout(f),m.removeEventListener("mouseenter",h),m.removeEventListener("mouseleave",M),m.removeEventListener("mousemove",C),i.removeEventListener("pause",h),i.removeEventListener("play",k)}}}},[]),(0,L.useEffect)(()=>{if(d){let m=l=>{var i;(i=E.current)!=null&&i.contains(l.target)||a(!1)};return document.addEventListener("click",m),()=>{document.removeEventListener("click",m)}}},[d]),(0,J.jsx)(v.Provider,{value:{videoRef:s,setVideoRef:o,config:{clickToPlay:!0,...n},error:u,setError:c,isFocused:d,setIsFocused:a},children:(0,J.jsx)("div",{ref:E,"data-zuude-video-wrapper":!0,onClick:()=>a(!0),...e,children:t})})}),y=()=>{let t=(0,L.useContext)(v);if(!t)throw new Error("useVideo must be used within a VideoProvider");return t};var I=require("react");var tt=P(require("react"),1),et=(t,n,r)=>{tt.default.useEffect(()=>{if(!(t!=null&&t.current)||!n)return;(async()=>{var s;try{await((s=t.current)==null?void 0:s.play())}catch(o){if(o instanceof Error&&o.name==="NotAllowedError"){if(r==null||r("NotAllowedError"),console.error("NotAllowedError"),t!=null&&t.current){t.current.muted=!0;try{await t.current.play()}catch(u){console.error(u)}}}else console.error(o)}})()},[n,t==null?void 0:t.current])};var rt=require("react"),j=(t,n,r=!0)=>{let e=s=>{s.key===t&&(s.preventDefault(),n(s))};(0,rt.useEffect)(()=>{if(r)return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[t,n,r])};var Q=P(require("react"),1),q=(t,n=10)=>{let r=Q.default.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime+=n)},[t==null?void 0:t.current]),e=Q.default.useCallback(()=>{t!=null&&t.current&&(t.current.currentTime-=n)},[t==null?void 0:t.current]);return{seekForward:r,seekBackward:e}};var O=P(require("react"),1),U=t=>{let[n,r]=O.default.useState(!1),e=O.default.useCallback(()=>{t!=null&&t.current&&(t.current.paused?t.current.play():t.current.pause())},[t==null?void 0:t.current]),s=O.default.useCallback(()=>{t!=null&&t.current&&t.current.play()},[t==null?void 0:t.current]),o=O.default.useCallback(()=>{t!=null&&t.current&&t.current.pause()},[t==null?void 0:t.current]);return O.default.useEffect(()=>{if(!(t!=null&&t.current))return;let u=()=>{r(!0)},c=()=>{r(!1)};if(r(!(t!=null&&t.current.paused)),t!=null&&t.current)return t.current.addEventListener("play",u),t.current.addEventListener("pause",c),()=>{var d,a;(d=t.current)==null||d.removeEventListener("play",u),(a=t.current)==null||a.removeEventListener("pause",c)}},[t==null?void 0:t.current]),{togglePlay:e,isPlaying:n,play:s,pause:o}};var N=P(require("react"),1),B=t=>{let[n,r]=N.default.useState(!1),e=N.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!t.current.muted)},[t==null?void 0:t.current]),s=N.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!0)},[t==null?void 0:t.current]),o=N.default.useCallback(()=>{t!=null&&t.current&&(t.current.muted=!1)},[t==null?void 0:t.current]);return N.default.useEffect(()=>{if(!(t!=null&&t.current))return;r(t.current.muted);let u=()=>{t.current&&r(t.current.muted)};return t.current.addEventListener("volumechange",u),()=>{var c;(c=t.current)==null||c.removeEventListener("volumechange",u)}},[t==null?void 0:t.current]),{toggleMute:e,isMuted:n,mute:s,unmute:o}};var K=P(require("react"),1),W=t=>{let[n,r]=K.default.useState(!1),e=K.default.useRef(null);K.default.useEffect(()=>{let o=()=>{let u=!!document.fullscreenElement;r(u);let c=t==null?void 0:t.current;c&&(u?(e.current={objectFit:c.style.objectFit||"cover",borderRadius:c.style.borderRadius||"",width:c.style.width||"",height:c.style.height||"",maxWidth:c.style.maxWidth||"",maxHeight:c.style.maxHeight||"",margin:c.style.margin||""},c.style.objectFit="contain",c.style.borderRadius="0",c.style.width="100%",c.style.height="100%",c.style.maxWidth="none",c.style.maxHeight="none",c.style.margin="0"):e.current&&(c.style.objectFit=e.current.objectFit,c.style.borderRadius=e.current.borderRadius,c.style.width=e.current.width,c.style.height=e.current.height,c.style.maxWidth=e.current.maxWidth,c.style.maxHeight=e.current.maxHeight,c.style.margin=e.current.margin,e.current=null))};return document.addEventListener("fullscreenchange",o),()=>document.removeEventListener("fullscreenchange",o)},[t]);let s=()=>{let o=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),u=t==null?void 0:t.current;if(u&&o){if(u.webkitEnterFullscreen){u.webkitEnterFullscreen();return}else if(u.requestFullscreen){u.requestFullscreen();return}}let c=u==null?void 0:u.closest("[data-zuude-video-wrapper]");c&&(n?document.exitFullscreen():c.requestFullscreen())};return{isFullscreen:n!=null?n:!1,toggleFullscreen:s}};var $=t=>({togglePictureInPicture:async()=>{let s=t==null?void 0:t.current;if(s)try{document.pictureInPictureElement?await document.exitPictureInPicture():await s.requestPictureInPicture()}catch(o){if(/^((?!chrome|android).)*safari/i.test(navigator.userAgent))s.webkitEnterFullscreen?s.webkitEnterFullscreen():s.requestFullscreen&&s.requestFullscreen();else{let c=s.closest("[data-zuude-video-wrapper]");c&&(document.fullscreenElement?await document.exitFullscreen():await c.requestFullscreen())}}},requestPictureInPicture:async()=>{let s=t==null?void 0:t.current;s&&await s.requestPictureInPicture()},exitPictureInPicture:async()=>{t!=null&&t.current&&await document.exitPictureInPicture()}});var nt=()=>{let{videoRef:t}=y(),{seekForward:n,seekBackward:r}=q(t),{togglePlay:e}=U(t),{toggleMute:s}=B(t),{toggleFullscreen:o}=W(t),{togglePictureInPicture:u}=$(t);return j("ArrowRight",()=>{n()}),j("ArrowLeft",()=>{r()}),j(" ",()=>{e()}),j("m",()=>{s()}),j("f",()=>{o()}),j("p",()=>{u()}),null};var st=P(require("react"),1),ut=(t,n,r=!0)=>{st.default.useEffect(()=>{if(!(t!=null&&t.current)||!r)return;let e=new IntersectionObserver(s=>{s.forEach(o=>{var u;t!=null&&t.current&&(o.isIntersecting?t.current.play().catch(c=>{t.current&&(t.current.pause(),t.current.muted=!0,t.current.play(),console.error(c))}):(u=t.current)==null||u.pause())})},{threshold:n!=null?n:.5});return e.observe(t==null?void 0:t.current),()=>{e.disconnect()}},[t==null?void 0:t.current])};var gt=P(require("react"),1);var G=P(require("react"),1),ct=t=>{let[n,r]=G.default.useState(1),e=s=>{r(s)};return G.default.useEffect(()=>{t!=null&&t.current&&r(t.current.playbackRate)},[t==null?void 0:t.current]),G.default.useEffect(()=>{t!=null&&t.current&&(t.current.playbackRate=n)},[n,t==null?void 0:t.current]),{speed:n,onChangeSpeed:e}};var bt=P(require("react"),1);var Pt=P(require("react"),1);var ot=require("react");var Lt=P(require("react"),1);var Vt=P(require("react"),1);var A=require("react"),at=t=>{let[n,r]=(0,A.useState)(!1),[e,s]=(0,A.useState)(0),[o,u]=(0,A.useState)(null),c=(0,A.useCallback)(async a=>{var l;if(!(t!=null&&t.current)){u("Video element not found");return}let E=t.current,m=E.src||E.currentSrc;if(!m){u("No video source found");return}try{r(!0),u(null),s(0);let i=await fetch(m);if(!i.ok)throw new Error(`Failed to fetch video: ${i.statusText}`);let f=i.headers.get("content-length"),H=f?parseInt(f,10):0,w=(l=i.body)==null?void 0:l.getReader();if(!w)throw new Error("Failed to create download stream");let x=[],h=0;for(;;){let{done:g,value:p}=await w.read();if(g)break;if(x.push(p),h+=p.length,H>0){let F=h/H*100;s(Math.round(F))}}let M=new Blob(x,{type:i.headers.get("content-type")||"video/mp4"}),C=URL.createObjectURL(M),k=document.createElement("a");k.href=C;let T=a||`video-${Date.now()}.mp4`;k.download=T,document.body.appendChild(k),k.click(),document.body.removeChild(k),URL.revokeObjectURL(C),s(100),r(!1)}catch(i){u(i instanceof Error?i.message:"Download failed"),r(!1),s(0)}},[t]),d=(0,A.useCallback)(a=>{if(!(t!=null&&t.current)){u("Video element not found");return}let E=t.current,m=E.src||E.currentSrc;if(!m){u("No video source found");return}try{r(!0),u(null),s(0);let l=document.createElement("a");l.href=m,l.download=a||`video-${Date.now()}.mp4`,l.target="_blank",document.body.appendChild(l),l.click(),document.body.removeChild(l),r(!1),s(100)}catch(l){u(l instanceof Error?l.message:"Download failed"),r(!1),s(0)}},[t]);return(0,A.useEffect)(()=>()=>{r(!1),s(0),u(null)},[]),{downloadVideo:c,downloadDirect:d,isDownloading:n,downloadProgress:e,error:o,resetError:()=>u(null)}};var ft=P(require("react"),1);var D=require("react/jsx-runtime"),X=(0,I.forwardRef)(({src:t,autoPlay:n,muteFallback:r,controls:e,preload:s="metadata",autoPlayOnVisible:o,ranges:u,...c},d)=>{let{videoRef:a,setVideoRef:E,config:m,setError:l,error:i,isFocused:f}=y(),H=(0,I.useRef)(null),w=(0,I.useRef)(!1),x=(0,I.useRef)(null),h=(0,I.useRef)(null),M=u&&u.length>=2&&typeof u[0]=="number"&&typeof u[1]=="number"&&u[0]>=0&&u[1]>u[0]&&isFinite(u[0])&&isFinite(u[1]),C=M?u[0]:void 0,k=M?u[1]:void 0;(0,I.useEffect)(()=>{let g=H.current,p=d;return p?E(p):g&&E({current:g}),()=>{w.current=!1,x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),h.current!==null&&(clearTimeout(h.current),h.current=null)}},[t,d,E]),(0,I.useEffect)(()=>()=>{x.current!==null&&(cancelAnimationFrame(x.current),x.current=null),h.current!==null&&(clearTimeout(h.current),h.current=null)},[]),et(a,n==="force"&&c.muted===void 0,l),ut(a,typeof o=="number"?o:o?void 0:.5,!!o);let T=(0,I.useCallback)(()=>{var g,p,F;(g=a==null?void 0:a.current)!=null&&g.paused?(p=a.current)==null||p.play():(F=a==null?void 0:a.current)==null||F.pause()},[a]);return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)("video",{ref:d||H,"data-zuude-video":!0,src:t,onClick:m!=null&&m.clickToPlay?T:void 0,autoPlay:n==="force"?!0:n,preload:s,playsInline:!0,onLoadedMetadata:g=>{var F;let p=g.currentTarget;M&&C!==void 0&&k!==void 0&&p.currentTime<.1&&(p.currentTime=C),(F=c.onLoadedMetadata)==null||F.call(c,g)},onCanPlay:g=>{var F;let p=g.currentTarget;if(M&&C!==void 0&&k!==void 0&&!p.seeking){let _=p.currentTime;_<.1&&_<C&&(p.currentTime=C)}(F=c.onCanPlay)==null||F.call(c,g)},onSeeked:g=>{var p;w.current=!1,(p=c.onSeeked)==null||p.call(c,g)},onTimeUpdate:g=>{var F;let p=g.currentTarget;M&&C!==void 0&&k!==void 0&&!w.current&&!p.paused&&!p.seeking&&p.readyState>=2&&p.currentTime>=k&&(w.current=!0,p.currentTime=C,h.current!==null&&clearTimeout(h.current),x.current=requestAnimationFrame(()=>{h.current=setTimeout(()=>{w.current&&(w.current=!1),h.current=null},100),x.current=null})),(F=c.onTimeUpdate)==null||F.call(c,g)},...c}),e&&f&&(0,D.jsx)(nt,{}),i==="NotAllowedError"&&typeof r=="function"&&r(()=>{a!=null&&a.current&&(a.current.muted=!a.current.muted),l(null)})]})});X.displayName="Video";var b=P(require("react"),1),S=require("@radix-ui/react-slot");var Y=P(require("react"),1),lt=t=>{let[n,r]=Y.default.useState(!1);return Y.default.useEffect(()=>{if(!(t!=null&&t.current))return;let e=t.current,s=()=>{r(!0)},o=()=>{},u=()=>{},c=()=>{r(!1)},d=()=>{r(!1)},a=()=>{r(!0)},E=()=>{r(!1)},m=()=>{r(!1)},l=()=>{r(!1)},i=()=>{};return e.addEventListener("loadstart",s),e.addEventListener("loadedmetadata",o),e.addEventListener("loadeddata",u),e.addEventListener("canplay",c),e.addEventListener("canplaythrough",d),e.addEventListener("waiting",a),e.addEventListener("playing",E),e.addEventListener("error",m),e.addEventListener("abort",l),e.addEventListener("suspend",i),e.readyState>=2&&r(!1),()=>{e.removeEventListener("loadstart",s),e.removeEventListener("loadedmetadata",o),e.removeEventListener("loadeddata",u),e.removeEventListener("canplay",c),e.removeEventListener("canplaythrough",d),e.removeEventListener("waiting",a),e.removeEventListener("playing",E),e.removeEventListener("error",m),e.removeEventListener("abort",l),e.removeEventListener("suspend",i)}},[t]),{isLoading:n}};var V=require("react/jsx-runtime"),wt=b.default.memo(({children:t,asChild:n,...r})=>(0,V.jsx)("div",{"data-zuude-hide-elements":!0,...r,children:t})),xt=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{play:o}=U(s);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),Tt=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{pause:o}=U(s);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),Ct=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{mute:o}=B(s);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),kt=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{unmute:o}=B(s);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),Ft=b.default.memo(({children:t,asChild:n,value:r,onClick:e,...s})=>{let o=n?S.Slot:"button",{videoRef:u}=y(),{speed:c,onChangeSpeed:d}=ct(u);return(0,V.jsx)(o,{...s,value:r,onClick:()=>{d(r),e==null||e()},children:t})}),St=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{seekForward:o}=q(s,10);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),It=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{seekBackward:o}=q(s,10);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),Mt=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{toggleFullscreen:o}=W(s);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),At=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{toggleFullscreen:o}=W(s);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),Ht=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{togglePictureInPicture:o}=$(s);return(0,V.jsx)(e,{...r,onClick:o,children:t})}),jt=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"button",{videoRef:s}=y(),{downloadDirect:o}=at(s);return(0,V.jsx)(e,{...r,onClick:()=>o(),children:t})}),Dt=b.default.memo(({children:t,asChild:n,...r})=>{let e=n?S.Slot:"div",{videoRef:s}=y(),{isLoading:o}=lt(s);return(0,V.jsx)(e,{...r,style:{...r.style,pointerEvents:"none"},"data-loading":o,children:t})}),Ot=({...t})=>{let{videoRef:n}=y(),r=(0,b.useRef)(null);return b.default.useEffect(()=>{let e=n==null?void 0:n.current;if(r.current&&e){let s=0,o=!1,u=null,c=()=>{u&&clearInterval(u),u=setInterval(()=>{s=e.currentTime,r.current&&(r.current.currentTime=s)},100)},d=()=>{u&&(clearInterval(u),u=null)},a=()=>{o=!0,c()},E=()=>{o=!1,d()};return e.addEventListener("play",a),e.addEventListener("pause",E),()=>{d(),e.removeEventListener("play",a),e.removeEventListener("pause",E)}}},[n==null?void 0:n.current]),n!=null&&n.current?(0,V.jsx)("div",{...t,style:{...t.style,position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:(0,V.jsx)("video",{ref:r,src:n.current.src,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"cover"}})}):null};0&&(module.exports={Controls,Download,ExitFullscreen,Fullscreen,Loading,Mute,Pause,PictureInPicture,Play,SeekBackward,SeekForward,Shadow,Speed,Unmute,Video,VideoProvider,useVideo});
3
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","#style-inject:#style-inject","../src/styles.css","../src/video.tsx","../src/context.tsx","../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-play-pause.tsx","../src/components/play-pause-on-video.tsx","../src/function-children.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/hooks/use-speed.tsx","../src/components/hiding-element.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-timeline.tsx","../src/hooks/use-get-duration.tsx","../src/utils.ts"],"sourcesContent":["\"use client\";\n\nimport \"./styles.css\";\n\nexport { Video } from \"./video\";\n\n// Types\nexport type { VideoProps, VideoContextType } from \"./types\";\n\n// Context\nexport { useVideo } from \"./context\";\n\n// Hooks\nexport { useVolume } from \"./hooks/use-volume\";\nexport { useTimeline } from \"./hooks/use-timeline\";\nexport { useGetDuration } from \"./hooks/use-get-duration\";\nexport { usePlayPause } from \"./hooks/use-play-pause\";\nexport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nexport { useStartAt } from \"./hooks/use-start-at\";\nexport { useFullscreen } from \"./hooks/use-fullscreen\";\nexport { useAutoplayByForce } from \"./hooks/use-autoplay-by-force\";\n\n// Utils\nexport { formatTime } from \"./utils\";\n","\n export default function styleInject(css, { insertAt } = {}) {\n if (!css || typeof document === 'undefined') return\n \n const head = document.head || document.getElementsByTagName('head')[0]\n const style = document.createElement('style')\n style.type = 'text/css'\n \n if (insertAt === 'top') {\n if (head.firstChild) {\n head.insertBefore(style, head.firstChild)\n } else {\n head.appendChild(style)\n }\n } else {\n head.appendChild(style)\n }\n \n if (style.styleSheet) {\n style.styleSheet.cssText = css\n } else {\n style.appendChild(document.createTextNode(css))\n }\n }\n ","import styleInject from '#style-inject';styleInject(\".reset-styles{box-sizing:border-box;padding:0;margin:0}[data-zuude-video-wrapper]{position:relative}[data-zuude-video-wrapper] [data-zuude-video]{width:100%;height:100%;object-fit:cover}\\n\")","import React from \"react\";\n\n// 📦 Types\nimport type { VideoProps, VideoRef } from \"./types\";\n\n// 🔍 Context\nimport { VideoProvider } from \"./context\";\n\n// 🔗 Hooks\nimport { useAutoplayByForce } from \"./hooks/use-autoplay-by-force\";\nimport { useStartAt } from \"./hooks/use-start-at\";\nimport { useAutoplayOnVisible } from \"./hooks/use-autoplay-on-visible\";\n\n// 🔧 Components\nimport { PlayPauseOnVideo } from \"./components/play-pause-on-video\";\nimport { FunctionChildren } from \"./function-children\";\nimport { HidingElement, HidingElementProps } from \"./components/hiding-element\";\n\n/**\n * Main Video component structure\n * @param {VideoProps} props - Video component props\n */\n\nconst VideoComponent = React.forwardRef<\n HTMLVideoElement,\n VideoProps & { pause?: boolean }\n>(\n (\n { children, autoPlay, className, config, ratio, controls, pause, ...props },\n ref\n ) => {\n const [duration, setDuration] = React.useState<number | null>(null);\n const [error, setError] = React.useState<string | null>(null);\n\n const videoRef = (ref as VideoRef) || React.useRef<VideoRef>(null);\n\n const [showHidingElement, setShowHidingElement] = React.useState(false);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout>>(null);\n const handleMouseEnter = () => {\n if (videoRef.current?.paused) return;\n\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseLeave = () => {\n if (videoRef.current?.paused) return;\n\n setShowHidingElement(false);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n const handleMouseMove = () => {\n if (videoRef.current?.paused) return;\n\n setShowHidingElement(true);\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n timeoutRef.current = setTimeout(() => {\n setShowHidingElement(false);\n }, 3000);\n };\n\n React.useEffect(() => {\n if (pause !== undefined) {\n if (pause) {\n videoRef.current?.pause();\n } else {\n videoRef.current?.play();\n }\n }\n }, [pause, videoRef.current]);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" &&\n props.muted === undefined &&\n !config?.autoplayOnVisible,\n setError\n );\n useStartAt(videoRef, config?.startAt);\n useAutoplayOnVisible(\n videoRef,\n typeof config?.autoplayOnVisible === \"number\"\n ? config.autoplayOnVisible\n : undefined,\n config?.autoplayOnVisible\n );\n\n return (\n <VideoProvider\n videoRef={videoRef}\n duration={duration}\n showHidingElement={showHidingElement}\n setShowHidingElement={setShowHidingElement}\n >\n <div\n data-zuude-video-wrapper\n className={className}\n style={{ aspectRatio: ratio }}\n >\n <video\n data-zuude-video\n // @ts-ignore\n ref={videoRef}\n autoPlay={\n config?.autoplayOnVisible\n ? false\n : autoPlay === \"force\"\n ? true\n : autoPlay\n }\n playsInline\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onMouseMove={handleMouseMove}\n onClick={() => {\n if (config?.clickToPlay) {\n if (videoRef.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef.current?.pause();\n }\n }\n }}\n onLoadedMetadata={(e) => {\n console.log(\"loaded metadata\");\n setDuration((e.target as HTMLVideoElement).duration);\n }}\n onTimeUpdate={(e) => {\n /**\n * If the current time is less than the start time, set the current time to the start time\n * If the current time is greater than the end time, set the current time to the start time\n */\n if (config?.range) {\n const [start, end] = config.range;\n\n if (!videoRef?.current) return;\n\n if (videoRef?.current?.currentTime < start) {\n videoRef.current.currentTime = start;\n }\n\n if (videoRef.current.currentTime > end) {\n videoRef.current.currentTime = start;\n }\n }\n }}\n className={className}\n style={{ aspectRatio: ratio }}\n {...props}\n />\n {typeof children === \"function\" ? (\n <FunctionChildren ref={videoRef} children={children} />\n ) : (\n children\n )}\n {error === \"NotAllowedError\" &&\n typeof config?.muteFallback === \"function\" &&\n config.muteFallback(() => {\n if (videoRef.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </div>\n </VideoProvider>\n );\n }\n);\n\nVideoComponent.displayName = \"Video\";\n\n/**\n * Using compound components pattern\n */\nexport const Video = Object.assign(VideoComponent, {\n PlayPauseOnVideo,\n HidingElement: HidingElement as React.ComponentType<HidingElementProps>,\n});\n","import React from \"react\";\nimport type { VideoContextType } from \"./types.js\";\n\nconst VideoContext = React.createContext<VideoContextType | undefined>(\n undefined\n);\n\nconst useVideo = () => {\n const context = React.useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n\ninterface VideoProviderProps extends VideoContextType {\n children: React.ReactNode;\n}\n\nconst VideoProvider = ({\n children,\n videoRef,\n duration,\n showHidingElement,\n setShowHidingElement,\n}: VideoProviderProps) => {\n const [fullscreen, setFullscreen] = React.useState(false);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n duration,\n isFullscreen: fullscreen,\n setIsFullscreen: setFullscreen,\n showHidingElement,\n setShowHidingElement,\n }}\n >\n {children}\n </VideoContext.Provider>\n );\n};\n\nexport { useVideo, VideoProvider };\n","import React from \"react\";\nimport { VideoRef } from \"../types.js\";\n\nexport const useAutoplayByForce = (\n ref: VideoRef | null,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!ref?.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await ref.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (ref?.current) {\n ref.current.muted = true;\n try {\n await ref.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, ref?.current]);\n};\n","import React from \"react\";\nimport type { VideoConfig, VideoRef } from \"../types\";\n\nexport const useStartAt = (ref: VideoRef, startAt?: VideoConfig[\"startAt\"]) => {\n React.useEffect(() => {\n if (!ref?.current || !startAt) return;\n\n const video = ref?.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt, ref?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n ref: VideoRef,\n threshold: number | undefined,\n enabled: boolean | number | null | undefined\n) => {\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!ref?.current) return;\n\n if (entry.isIntersecting) {\n ref.current.play().catch((error) => {\n if (!ref.current) return;\n\n ref.current.pause();\n ref.current.muted = true;\n ref.current.play();\n console.error(error);\n });\n } else {\n ref.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(ref?.current);\n\n return () => {\n observer.disconnect();\n };\n }, [enabled, ref?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (ref: VideoRef, enabled: boolean) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n console.log(ref?.current);\n if (ref?.current) {\n ref.current.paused ? ref.current.play() : ref.current.pause();\n }\n }, [ref?.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!ref?.current.paused);\n\n if (ref?.current) {\n ref.current.addEventListener(\"play\", handlePlay);\n ref.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n ref.current?.removeEventListener(\"play\", handlePlay);\n ref.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [ref?.current, enabled]);\n\n return { togglePlay, isPlaying };\n};\n","import { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport const PlayPauseOnVideo = () => {\n const { videoRef } = useVideo();\n\n const { togglePlay } = usePlayPause(videoRef, true);\n\n return (\n <div\n style={{\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n display: \"flex\",\n justifyContent: \"center\",\n alignItems: \"center\",\n }}\n onClick={togglePlay}\n ></div>\n );\n};\n","import React from \"react\";\n\nimport type { VideoChildren, VideoRef } from \"./types\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { useVideo } from \"./context\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\nimport { useSpeed } from \"./hooks/use-speed\";\n\nexport const FunctionChildren = React.forwardRef<\n any,\n {\n children: VideoChildren;\n }\n>(({ children }, ref) => {\n const { duration, showHidingElement } = useVideo();\n\n /**\n * Only use these hooks if the children is a function\n */\n const { togglePlay, isPlaying } = usePlayPause(\n ref as VideoRef,\n typeof children === \"function\"\n );\n const { speed, onChangeSpeed } = useSpeed(\n ref as VideoRef,\n typeof children === \"function\"\n );\n const { toggleMute, isMuted } = useMuteUnmute(\n ref as VideoRef,\n typeof children === \"function\"\n );\n const { isFullscreen, toggleFullscreen } = useFullscreen();\n const { isPictureInPicture, togglePictureInPicture } = usePictureInPicture();\n\n if (typeof children !== \"function\") return null;\n\n return children({\n isPlaying,\n togglePlay,\n isMuted,\n toggleMute,\n speed,\n onChangeSpeed,\n isFullscreen,\n toggleFullscreen,\n isPictureInPicture,\n togglePictureInPicture,\n duration,\n showHidingElement: showHidingElement ?? false,\n });\n});\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (ref: VideoRef, enabled: boolean) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (ref?.current) {\n ref.current.muted = !ref.current.muted;\n }\n }, [ref?.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n // Set the initial state\n setIsMuted(ref.current.muted);\n\n const handleVolumeChange = () => {\n if (ref.current) {\n setIsMuted(ref.current.muted);\n }\n };\n\n ref.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n ref.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [ref?.current, enabled]);\n\n return { toggleMute, isMuted };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useFullscreen = () => {\n const { videoRef, isFullscreen, setIsFullscreen } = useVideo();\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n setIsFullscreen?.(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, []);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef?.current;\n\n if (video && isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n return;\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n return;\n }\n }\n\n const videoContainer = videoRef?.current?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n videoContainer.requestFullscreen();\n } else {\n document.exitFullscreen();\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const usePictureInPicture = () => {\n const { videoRef, isPictureInPicture, setIsPictureInPicture } = useVideo();\n\n React.useEffect(() => {\n const handlePictureInPictureChange = () => {\n setIsPictureInPicture?.(!!document.pictureInPictureElement);\n };\n\n document.addEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n return () =>\n document.removeEventListener(\n \"pictureinpicturechange\",\n handlePictureInPictureChange\n );\n }, []);\n\n const togglePictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n\n try {\n if (document.pictureInPictureElement) {\n await document.exitPictureInPicture();\n } else {\n await video.requestPictureInPicture();\n }\n } catch (error) {\n // Fallback for browsers that don't support PiP\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n\n if (isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n }\n } else {\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n if (videoContainer) {\n if (!document.fullscreenElement) {\n await videoContainer.requestFullscreen();\n } else {\n await document.exitFullscreen();\n }\n }\n }\n }\n };\n\n return {\n isPictureInPicture: isPictureInPicture ?? false,\n togglePictureInPicture,\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (ref: VideoRef, enabled: boolean) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n // Get the speed from the video element\n React.useEffect(() => {\n if (!ref?.current) return;\n setSpeed(ref.current.playbackRate);\n }, [ref?.current]);\n\n React.useEffect(() => {\n if (!enabled || !ref?.current) return;\n\n ref.current.playbackRate = speed;\n }, [speed, enabled, ref?.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\nimport { usePlayPause } from \"../hooks/use-play-pause\";\n\nexport interface HidingElementProps\n extends React.ComponentPropsWithoutRef<\"div\"> {\n children: React.ReactNode;\n className?: string;\n}\n\nexport const HidingElement = React.forwardRef<\n HTMLDivElement,\n HidingElementProps\n>(({ children, className, ...props }: HidingElementProps) => {\n const { videoRef } = useVideo();\n const { isPlaying } = usePlayPause(videoRef, true);\n const { showHidingElement, setShowHidingElement } = useVideo();\n\n return (\n <div\n data-zuude-hiding-element\n data-show={!isPlaying || showHidingElement}\n className={className}\n onMouseEnter={() => {\n setShowHidingElement?.(true);\n }}\n onMouseLeave={() => {\n setShowHidingElement?.(false);\n }}\n {...props}\n >\n {children}\n </div>\n );\n});\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useVolume = () => {\n const [volume, setVolume] = React.useState(100);\n const { videoRef } = useVideo();\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n // Get the volume from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setVolume(videoRef.current.volume * 100);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.volume = volume / 100;\n }, [volume, videoRef?.current]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport { useVideo } from \"../context\";\n\nexport const useTimeline = () => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n const [buffered, setBuffered] = React.useState(0);\n\n const { videoRef, duration } = useVideo();\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(videoRef.current?.currentTime || 0);\n\n if (videoRef.current?.buffered.length) {\n setBuffered(\n videoRef.current.buffered.end(videoRef.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.addEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n currentTime,\n duration,\n buffered,\n setCurrentTime,\n };\n};\n","import React from \"react\";\nimport { VideoRef } from \"../types.js\";\n\nexport const useGetDuration = (ref: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!ref?.current) return;\n setIsLoading(true);\n\n ref.current.addEventListener(\"loadedmetadata\", () => {\n setDuration(ref.current?.duration ?? null);\n setIsLoading(false);\n });\n\n ref.current.addEventListener(\"error\", () => {\n setIsLoading(false);\n });\n\n return () => {\n ref.current?.removeEventListener(\"loadedmetadata\", () => {});\n ref.current?.removeEventListener(\"error\", () => {});\n };\n }, [ref?.current]);\n\n return { duration, isLoading };\n};\n","function formatTime(time: number, type: \"h:mm:ss\" | \"mm:ss\" = \"mm:ss\"): string {\n const minutes = Math.floor(time / 60);\n const seconds = Math.floor(time % 60);\n if (type === \"h:mm:ss\") {\n const hours = Math.floor(minutes / 60);\n return `${hours}:${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n }\n return `${minutes}:${seconds < 10 ? \"0\" : \"\"}${seconds}`;\n}\n\nexport { formatTime };\n"],"mappings":"mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,WAAAE,GAAA,eAAAC,GAAA,uBAAAC,EAAA,kBAAAC,EAAA,mBAAAC,GAAA,kBAAAC,EAAA,iBAAAC,EAAA,eAAAC,EAAA,gBAAAC,GAAA,aAAAC,EAAA,cAAAC,KAAA,eAAAC,GAAAb,ICCyB,SAARc,EAA6BC,EAAK,CAAE,SAAAC,CAAS,EAAI,CAAC,EAAG,CAC1D,GAAI,CAACD,GAAO,OAAO,UAAa,YAAa,OAE7C,IAAME,EAAO,SAAS,MAAQ,SAAS,qBAAqB,MAAM,EAAE,CAAC,EAC/DC,EAAQ,SAAS,cAAc,OAAO,EAC5CA,EAAM,KAAO,WAETF,IAAa,OACXC,EAAK,WACPA,EAAK,aAAaC,EAAOD,EAAK,UAAU,EAK1CA,EAAK,YAAYC,CAAK,EAGpBA,EAAM,WACRA,EAAM,WAAW,QAAUH,EAE3BG,EAAM,YAAY,SAAS,eAAeH,CAAG,CAAC,CAElD,CCvB8BI,EAAY;AAAA,CAA8L,ECAlP,IAAAC,EAAkB,sBCAlB,IAAAC,EAAkB,sBA6BdC,EAAA,6BA1BEC,EAAe,EAAAC,QAAM,cACzB,MACF,EAEMC,EAAW,IAAM,CACrB,IAAMC,EAAU,EAAAF,QAAM,WAAWD,CAAY,EAC7C,GAAI,CAACG,EACH,MAAM,IAAI,MAAM,8CAA8C,EAEhE,OAAOA,CACT,EAMMC,EAAgB,CAAC,CACrB,SAAAC,EACA,SAAAC,EACA,SAAAC,EACA,kBAAAC,EACA,qBAAAC,CACF,IAA0B,CACxB,GAAM,CAACC,EAAYC,CAAa,EAAI,EAAAV,QAAM,SAAS,EAAK,EAExD,SACE,OAACD,EAAa,SAAb,CACC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AAA,YAAAA,EAAK,OAAO,CAAC,EAEV,CAAE,SAAAI,EAAU,UAAAH,CAAU,CAC/B,EC3BA,SAASO,GAAWC,EAAcC,EAA4B,QAAiB,CAC7E,IAAMC,EAAU,KAAK,MAAMF,EAAO,EAAE,EAC9BG,EAAU,KAAK,MAAMH,EAAO,EAAE,EACpC,OAAIC,IAAS,UAEJ,GADO,KAAK,MAAMC,EAAU,EAAE,CACtB,IAAIA,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,GAE1D,GAAGD,CAAO,IAAIC,EAAU,GAAK,IAAM,EAAE,GAAGA,CAAO,EACxD","names":["index_exports","__export","Video","formatTime","useAutoplayByForce","useFullscreen","useGetDuration","useMuteUnmute","usePlayPause","useStartAt","useTimeline","useVideo","useVolume","__toCommonJS","styleInject","css","insertAt","head","style","styleInject","import_react","import_react","import_jsx_runtime","VideoContext","React","useVideo","context","VideoProvider","children","videoRef","duration","showHidingElement","setShowHidingElement","fullscreen","setFullscreen","import_react","useAutoplayByForce","ref","enabled","setError","React","_a","error","retryError","import_react","useStartAt","ref","startAt","React","video","import_react","useAutoplayOnVisible","ref","threshold","enabled","React","observer","entries","entry","_a","error","import_react","usePlayPause","ref","enabled","isPlaying","setIsPlaying","React","togglePlay","handlePlay","handlePause","_a","_b","import_jsx_runtime","PlayPauseOnVideo","videoRef","useVideo","togglePlay","usePlayPause","import_react","import_react","useMuteUnmute","ref","enabled","isMuted","setIsMuted","React","toggleMute","handleVolumeChange","_a","import_react","useFullscreen","videoRef","isFullscreen","setIsFullscreen","useVideo","React","handleFullscreenChange","toggleFullscreen","_a","isSafari","video","videoContainer","import_react","usePictureInPicture","videoRef","isPictureInPicture","setIsPictureInPicture","useVideo","React","handlePictureInPictureChange","togglePictureInPicture","video","error","videoContainer","import_react","useSpeed","ref","enabled","speed","setSpeed","React","onChangeSpeed","FunctionChildren","React","children","ref","duration","showHidingElement","useVideo","togglePlay","isPlaying","usePlayPause","speed","onChangeSpeed","useSpeed","toggleMute","isMuted","useMuteUnmute","isFullscreen","toggleFullscreen","useFullscreen","isPictureInPicture","togglePictureInPicture","usePictureInPicture","import_react","import_jsx_runtime","HidingElement","React","children","className","props","videoRef","useVideo","isPlaying","usePlayPause","showHidingElement","setShowHidingElement","import_jsx_runtime","VideoComponent","React","children","autoPlay","className","config","ratio","controls","pause","props","ref","duration","setDuration","error","setError","videoRef","showHidingElement","setShowHidingElement","timeoutRef","handleMouseEnter","_a","handleMouseLeave","handleMouseMove","_b","useAutoplayByForce","useStartAt","useAutoplayOnVisible","VideoProvider","_c","e","start","end","FunctionChildren","Video","PlayPauseOnVideo","HidingElement","import_react","useVolume","volume","setVolume","React","videoRef","useVideo","onChangeVolume","import_react","useTimeline","isPlaying","setIsPlaying","React","currentTime","setCurrentTime","buffered","setBuffered","videoRef","duration","useVideo","intervalId","_a","_b","import_react","useGetDuration","ref","isLoading","setIsLoading","React","duration","setDuration","_a","_b","formatTime","time","type","minutes","seconds"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/wrapper.tsx","../src/video.tsx","../src/hooks/use-autoplay-by-force.tsx","../src/hooks/use-hot-keys.tsx","../src/hooks/use-seek.tsx","../src/hooks/use-play-pause.tsx","../src/hooks/use-mute-unmute.tsx","../src/hooks/use-fullscreen.tsx","../src/hooks/use-picture-in-picture.tsx","../src/keyboard.tsx","../src/hooks/use-autoplay-on-visible.tsx","../src/hooks/use-get-duration.tsx","../src/hooks/use-speed.tsx","../src/hooks/use-start-at.tsx","../src/hooks/use-current-time.tsx","../src/hooks/use-video-state.tsx","../src/hooks/use-volume.tsx","../src/hooks/use-buffer.tsx","../src/hooks/use-download.tsx","../src/hooks/use-range.tsx","../src/components.tsx","../src/hooks/use-loading.tsx"],"sourcesContent":["\"use client\";\n\nexport { VideoProvider, useVideo } from \"./wrapper\";\nexport { Video } from \"./video\";\nexport * from \"./components\";\nexport * from \"./types\";\n","import React, {\n createContext,\n useContext,\n useEffect,\n useRef,\n useState,\n} from \"react\";\nimport type { VideoRef } from \"./types\";\n\ninterface VideoConfig {\n config?: Partial<{\n clickToPlay: boolean;\n }>;\n}\n\ninterface VideoContextType extends VideoConfig {\n videoRef: VideoRef;\n setVideoRef: (video: VideoRef) => void;\n error: string | null;\n setError: (error: string | null) => void;\n isFocused: boolean;\n setIsFocused: (isFocused: boolean) => void;\n}\n\nexport const VideoContext = createContext<VideoContextType | null>(null);\n\ntype VideoProviderProps = Omit<React.ComponentProps<\"div\">, \"onError\"> &\n VideoConfig & {\n children: React.ReactNode;\n onError?: (error: string | null) => void;\n };\n\nexport const VideoProvider = React.memo(\n ({ children, config, onError, ...props }: VideoProviderProps) => {\n const [videoRef, setVideoRef] = useState<VideoRef>({ current: null });\n const [error, setError] = useState<string | null>(null);\n const [isFocused, setIsFocused] = useState(false);\n\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n\n // Sending error to user if it exists\n useEffect(() => {\n onError?.(error);\n }, [error]);\n\n useEffect(() => {\n const videoWrapper = videoWrapperRef.current;\n if (videoWrapper) {\n const controls = videoWrapper.querySelectorAll(\n \"[data-zuude-hide-elements]\"\n );\n const video = videoWrapper.querySelector(\n \"[data-zuude-video]\"\n ) as HTMLVideoElement;\n\n if (controls) {\n let hideTimeout: ReturnType<typeof setTimeout> | null = null;\n const hideDelay = 3000; // 3 seconds delay\n let isMouseOver = false;\n\n const resetTimer = () => {\n // Clear any pending hide timeout\n if (hideTimeout) {\n clearTimeout(hideTimeout);\n hideTimeout = null;\n }\n\n // Start new timer to hide controls after delay\n hideTimeout = setTimeout(() => {\n if (isMouseOver) {\n // Check if video is paused - don't hide controls if paused\n if (video && !video.paused) {\n controls.forEach((control) => {\n control.setAttribute(\"data-hidden\", \"true\");\n });\n }\n }\n hideTimeout = null;\n }, hideDelay);\n };\n\n const showControls = () => {\n isMouseOver = true;\n controls.forEach((control) => {\n control.removeAttribute(\"data-hidden\");\n });\n resetTimer();\n };\n\n const hideControls = () => {\n isMouseOver = false;\n // Clear any pending hide timeout\n if (hideTimeout) {\n clearTimeout(hideTimeout);\n hideTimeout = null;\n }\n // Hide controls immediately when mouse leaves\n if (video && !video.paused) {\n controls.forEach((control) => {\n control.setAttribute(\"data-hidden\", \"true\");\n });\n }\n };\n\n const handleMouseMove = () => {\n if (isMouseOver) {\n // If controls are hidden, show them\n controls.forEach((control) => {\n if (control.hasAttribute(\"data-hidden\")) {\n control.removeAttribute(\"data-hidden\");\n }\n });\n resetTimer();\n }\n };\n\n const handlePlay = () => {\n // Hide controls when video starts playing (autoplay)\n if (!isMouseOver) {\n controls.forEach((control) => {\n control.setAttribute(\"data-hidden\", \"true\");\n });\n }\n };\n\n videoWrapper.addEventListener(\"mouseenter\", showControls);\n videoWrapper.addEventListener(\"mouseleave\", hideControls);\n videoWrapper.addEventListener(\"mousemove\", handleMouseMove);\n video.addEventListener(\"pause\", showControls);\n video.addEventListener(\"play\", handlePlay);\n\n // Cleanup function\n return () => {\n if (hideTimeout) {\n clearTimeout(hideTimeout);\n }\n videoWrapper.removeEventListener(\"mouseenter\", showControls);\n videoWrapper.removeEventListener(\"mouseleave\", hideControls);\n videoWrapper.removeEventListener(\"mousemove\", handleMouseMove);\n video.removeEventListener(\"pause\", showControls);\n video.removeEventListener(\"play\", handlePlay);\n };\n }\n }\n }, []);\n\n useEffect(() => {\n if (isFocused) {\n const handleClick = (event: MouseEvent) => {\n if (!videoWrapperRef.current?.contains(event.target as Node)) {\n setIsFocused(false);\n }\n };\n document.addEventListener(\"click\", handleClick);\n\n return () => {\n document.removeEventListener(\"click\", handleClick);\n };\n }\n }, [isFocused]);\n\n return (\n <VideoContext.Provider\n value={{\n videoRef,\n setVideoRef,\n config: { clickToPlay: true, ...config },\n error,\n setError,\n isFocused,\n setIsFocused,\n }}\n >\n <div\n ref={videoWrapperRef}\n data-zuude-video-wrapper\n onClick={() => setIsFocused(true)}\n {...props}\n >\n {children}\n </div>\n </VideoContext.Provider>\n );\n }\n);\n\nexport const useVideo = () => {\n const context = useContext(VideoContext);\n if (!context) {\n throw new Error(\"useVideo must be used within a VideoProvider\");\n }\n return context;\n};\n","import React, {\n forwardRef,\n RefObject,\n useCallback,\n useEffect,\n useRef,\n} from \"react\";\nimport { useVideo } from \"./wrapper\";\nimport { VideoAutoplay } from \"./types\";\nimport { useAutoplayByForce } from \"./hooks/use-autoplay-by-force\";\nimport { Keyboards } from \"./keyboard\";\nimport { useAutoplayOnVisible } from \"./hooks\";\n\ninterface Props\n extends Omit<React.ComponentProps<\"video\">, \"autoPlay\" | \"preload\"> {\n src: string;\n autoPlay?: VideoAutoplay;\n controls?: boolean;\n preload?: \"none\" | \"metadata\" | \"auto\";\n muteFallback?: (onMute: () => void) => React.ReactNode;\n autoPlayOnVisible?: boolean | number;\n ranges?: number[];\n}\n\nexport const Video = forwardRef<HTMLVideoElement, Props>(\n (\n {\n src,\n autoPlay,\n muteFallback,\n controls,\n preload = \"metadata\",\n autoPlayOnVisible,\n ranges,\n ...props\n },\n ref\n ) => {\n const { videoRef, setVideoRef, config, setError, error, isFocused } =\n useVideo();\n\n const refVideo = useRef<HTMLVideoElement>(null);\n const isAdjustingRef = useRef(false);\n const rafIdRef = useRef<number | null>(null);\n const timeoutIdRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n // Validate ranges: ensure they're valid and start < end\n const isValidRange =\n ranges &&\n ranges.length >= 2 &&\n typeof ranges[0] === \"number\" &&\n typeof ranges[1] === \"number\" &&\n ranges[0] >= 0 &&\n ranges[1] > ranges[0] &&\n isFinite(ranges[0]) &&\n isFinite(ranges[1]);\n\n // Safely get range values (only use when isValidRange is true)\n const rangeStart = isValidRange ? ranges[0] : undefined;\n const rangeEnd = isValidRange ? ranges[1] : undefined;\n\n useEffect(() => {\n const video = refVideo.current;\n const thirdPartyRef = ref;\n\n if (thirdPartyRef) {\n setVideoRef(thirdPartyRef as RefObject<HTMLVideoElement>);\n } else {\n if (video) {\n setVideoRef({ current: video });\n }\n }\n\n // Safari: Reset adjustment flags when src changes to prevent stale state\n return () => {\n isAdjustingRef.current = false;\n if (rafIdRef.current !== null) {\n cancelAnimationFrame(rafIdRef.current);\n rafIdRef.current = null;\n }\n if (timeoutIdRef.current !== null) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n };\n }, [src, ref, setVideoRef]);\n\n // Cleanup requestAnimationFrame and setTimeout on unmount (critical for Safari)\n useEffect(() => {\n return () => {\n if (rafIdRef.current !== null) {\n cancelAnimationFrame(rafIdRef.current);\n rafIdRef.current = null;\n }\n if (timeoutIdRef.current !== null) {\n clearTimeout(timeoutIdRef.current);\n timeoutIdRef.current = null;\n }\n };\n }, []);\n\n useAutoplayByForce(\n videoRef,\n autoPlay === \"force\" && props.muted === undefined,\n setError\n );\n\n useAutoplayOnVisible(\n videoRef,\n typeof autoPlayOnVisible === \"number\"\n ? autoPlayOnVisible\n : !autoPlayOnVisible\n ? 0.5\n : undefined,\n !!autoPlayOnVisible\n );\n\n const onPlay = useCallback(() => {\n if (videoRef?.current?.paused) {\n videoRef.current?.play();\n } else {\n videoRef?.current?.pause();\n }\n }, [videoRef]);\n\n return (\n <>\n <video\n ref={ref || refVideo}\n data-zuude-video\n src={src}\n onClick={config?.clickToPlay ? onPlay : undefined}\n autoPlay={autoPlay === \"force\" ? true : autoPlay}\n preload={preload}\n playsInline\n onLoadedMetadata={(e) => {\n // Set initial position as early as possible when metadata loads\n // This ensures video starts at rangeStart even with autoplay\n // Only set if video is at the beginning (not if user has already seeked)\n const video = e.currentTarget;\n if (\n isValidRange &&\n rangeStart !== undefined &&\n rangeEnd !== undefined &&\n video.currentTime < 0.1\n ) {\n // Only set to rangeStart on initial load (when currentTime is near 0)\n video.currentTime = rangeStart;\n }\n props.onLoadedMetadata?.(e);\n }}\n onCanPlay={(e) => {\n // Only set initial position when video first loads (not during seeking)\n const video = e.currentTarget;\n if (\n isValidRange &&\n rangeStart !== undefined &&\n rangeEnd !== undefined &&\n !video.seeking\n ) {\n const currentTime = video.currentTime;\n // Only adjust on initial load (when currentTime is 0 or very close to it)\n // Don't adjust if user has manually seeked to a different position\n if (currentTime < 0.1 && currentTime < rangeStart) {\n video.currentTime = rangeStart;\n }\n }\n props.onCanPlay?.(e);\n }}\n onSeeked={(e) => {\n // Don't enforce ranges on seek - allow free seeking for trimming\n // Ranges are only enforced during playback (in onTimeUpdate)\n isAdjustingRef.current = false;\n props.onSeeked?.(e);\n }}\n onTimeUpdate={(e) => {\n const video = e.currentTarget;\n\n // Only enforce ranges during active playback\n // Completely skip range enforcement when paused (allows free seeking for trimming)\n if (\n isValidRange &&\n rangeStart !== undefined &&\n rangeEnd !== undefined &&\n !isAdjustingRef.current &&\n !video.paused &&\n !video.seeking &&\n video.readyState >= 2 // Ensure video has loaded enough data\n ) {\n const currentTime = video.currentTime;\n\n // During playback: loop back when reaching or exceeding the end boundary\n if (currentTime >= rangeEnd) {\n isAdjustingRef.current = true;\n video.currentTime = rangeStart;\n // Reset flag after seek completes (onSeeked will handle this)\n // But add a fallback timeout in case onSeeked doesn't fire\n // Cleanup existing timeout before setting new one (Safari memory safety)\n if (timeoutIdRef.current !== null) {\n clearTimeout(timeoutIdRef.current);\n }\n rafIdRef.current = requestAnimationFrame(() => {\n timeoutIdRef.current = setTimeout(() => {\n if (isAdjustingRef.current) {\n isAdjustingRef.current = false;\n }\n timeoutIdRef.current = null;\n }, 100);\n rafIdRef.current = null;\n });\n }\n }\n\n props.onTimeUpdate?.(e);\n }}\n {...props}\n />\n\n {controls && isFocused && <Keyboards />}\n\n {error === \"NotAllowedError\" &&\n typeof muteFallback === \"function\" &&\n muteFallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n setError(null);\n })}\n </>\n );\n }\n);\n\nVideo.displayName = \"Video\";\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayByForce = (\n videoRef: VideoRef,\n enabled: boolean,\n setError?: (error: string | null) => void\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const playVideo = async () => {\n try {\n await videoRef.current?.play();\n } catch (error) {\n // If autoplay fails, try muting and playing again\n if (error instanceof Error && error.name === \"NotAllowedError\") {\n setError?.(\"NotAllowedError\");\n console.error(\"NotAllowedError\");\n if (videoRef?.current) {\n videoRef.current.muted = true;\n try {\n await videoRef.current.play();\n } catch (retryError) {\n console.error(retryError);\n }\n }\n } else {\n console.error(error);\n }\n }\n };\n\n playVideo();\n }, [enabled, videoRef?.current]);\n};\n","import { useEffect } from \"react\";\n\nexport const useHotKeys = (\n key: string,\n func: (event: KeyboardEvent) => void,\n enabled = true\n) => {\n const handleKeyDown = (event: KeyboardEvent) => {\n if (event.key === key) {\n event.preventDefault();\n func(event);\n }\n };\n\n useEffect(() => {\n if (!enabled) return;\n\n document.addEventListener(\"keydown\", handleKeyDown);\n\n return () => {\n document.removeEventListener(\"keydown\", handleKeyDown);\n };\n }, [key, func, enabled]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSeek = (videoRef: VideoRef, value = 10) => {\n const seekForward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime += value;\n }\n }, [videoRef?.current]);\n\n const seekBackward = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.currentTime -= value;\n }\n }, [videoRef?.current]);\n\n return { seekForward, seekBackward };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const usePlayPause = (videoRef: VideoRef) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n\n const togglePlay = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.paused\n ? videoRef.current.play()\n : videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n const play = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.play();\n }\n }, [videoRef?.current]);\n\n const pause = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.pause();\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const handlePlay = () => {\n setIsPlaying(true);\n };\n const handlePause = () => {\n setIsPlaying(false);\n };\n\n setIsPlaying(!videoRef?.current.paused);\n\n if (videoRef?.current) {\n videoRef.current.addEventListener(\"play\", handlePlay);\n videoRef.current.addEventListener(\"pause\", handlePause);\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", handlePlay);\n videoRef.current?.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [videoRef?.current]);\n\n return { togglePlay, isPlaying, play, pause };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useMuteUnmute = (videoRef: VideoRef) => {\n const [isMuted, setIsMuted] = React.useState(false);\n\n const toggleMute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = !videoRef.current.muted;\n }\n }, [videoRef?.current]);\n\n const mute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = true;\n }\n }, [videoRef?.current]);\n\n const unmute = React.useCallback(() => {\n if (videoRef?.current) {\n videoRef.current.muted = false;\n }\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef?.current]);\n\n return { toggleMute, isMuted, mute, unmute };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nconst useFullscreen = (videoRef: VideoRef) => {\n const [isFullscreen, setIsFullscreen] = React.useState(false);\n const previousStylesRef = React.useRef<{\n objectFit: string;\n borderRadius: string;\n width: string;\n height: string;\n maxWidth: string;\n maxHeight: string;\n margin: string;\n } | null>(null);\n\n React.useEffect(() => {\n const handleFullscreenChange = () => {\n const isCurrentlyFullscreen = !!document.fullscreenElement;\n setIsFullscreen(isCurrentlyFullscreen);\n\n // Apply styles based on fullscreen state\n const video = videoRef?.current;\n if (video) {\n if (isCurrentlyFullscreen) {\n // Store previous styles before entering fullscreen\n previousStylesRef.current = {\n objectFit: video.style.objectFit || \"cover\",\n borderRadius: video.style.borderRadius || \"\",\n width: video.style.width || \"\",\n height: video.style.height || \"\",\n maxWidth: video.style.maxWidth || \"\",\n maxHeight: video.style.maxHeight || \"\",\n margin: video.style.margin || \"\",\n };\n // Apply fullscreen styles\n video.style.objectFit = \"contain\";\n video.style.borderRadius = \"0\";\n video.style.width = \"100%\";\n video.style.height = \"100%\";\n video.style.maxWidth = \"none\";\n video.style.maxHeight = \"none\";\n video.style.margin = \"0\";\n } else {\n // Restore previous styles when exiting fullscreen\n if (previousStylesRef.current) {\n video.style.objectFit = previousStylesRef.current.objectFit;\n video.style.borderRadius = previousStylesRef.current.borderRadius;\n video.style.width = previousStylesRef.current.width;\n video.style.height = previousStylesRef.current.height;\n video.style.maxWidth = previousStylesRef.current.maxWidth;\n video.style.maxHeight = previousStylesRef.current.maxHeight;\n video.style.margin = previousStylesRef.current.margin;\n previousStylesRef.current = null;\n }\n }\n }\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n const toggleFullscreen = () => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n const video = videoRef?.current;\n\n if (video && isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n return;\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n return;\n }\n }\n\n const videoContainer = video?.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n\n if (videoContainer) {\n if (!isFullscreen) {\n videoContainer.requestFullscreen();\n } else {\n document.exitFullscreen();\n }\n }\n };\n\n return { isFullscreen: isFullscreen ?? false, toggleFullscreen };\n};\n\nexport { useFullscreen };\n","import type { VideoRef } from \"../types\";\n\nexport const usePictureInPicture = (videoRef: VideoRef) => {\n const togglePictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n\n try {\n if (document.pictureInPictureElement) {\n await document.exitPictureInPicture();\n } else {\n await video.requestPictureInPicture();\n }\n } catch (error) {\n // Fallback for browsers that don't support PiP\n const isSafari = /^((?!chrome|android).)*safari/i.test(\n navigator.userAgent\n );\n\n if (isSafari) {\n if ((video as any).webkitEnterFullscreen) {\n (video as any).webkitEnterFullscreen();\n } else if (video.requestFullscreen) {\n video.requestFullscreen();\n }\n } else {\n const videoContainer = video.closest(\n \"[data-zuude-video-wrapper]\"\n ) as HTMLElement;\n if (videoContainer) {\n if (!document.fullscreenElement) {\n await videoContainer.requestFullscreen();\n } else {\n await document.exitFullscreen();\n }\n }\n }\n }\n };\n\n const requestPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await video.requestPictureInPicture();\n };\n\n const exitPictureInPicture = async () => {\n const video = videoRef?.current;\n if (!video) return;\n await document.exitPictureInPicture();\n };\n\n return {\n togglePictureInPicture,\n requestPictureInPicture,\n exitPictureInPicture,\n };\n};\n","import { useVideo } from \"./wrapper\";\nimport { useHotKeys } from \"./hooks/use-hot-keys\";\nimport { useSeek } from \"./hooks/use-seek\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\n\nexport const Keyboards = () => {\n const { videoRef } = useVideo();\n\n const { seekForward, seekBackward } = useSeek(videoRef);\n const { togglePlay } = usePlayPause(videoRef);\n const { toggleMute } = useMuteUnmute(videoRef);\n const { toggleFullscreen } = useFullscreen(videoRef);\n const { togglePictureInPicture } = usePictureInPicture(videoRef);\n\n useHotKeys(\"ArrowRight\", () => {\n seekForward();\n });\n useHotKeys(\"ArrowLeft\", () => {\n seekBackward();\n });\n useHotKeys(\" \", () => {\n togglePlay();\n });\n useHotKeys(\"m\", () => {\n toggleMute();\n });\n useHotKeys(\"f\", () => {\n toggleFullscreen();\n });\n useHotKeys(\"p\", () => {\n togglePictureInPicture();\n });\n\n return null;\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useAutoplayOnVisible = (\n videoRef: VideoRef,\n threshold: number | undefined,\n enabled = true\n) => {\n React.useEffect(() => {\n if (!videoRef?.current || !enabled) return;\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (!videoRef?.current) return;\n\n if (entry.isIntersecting) {\n videoRef.current.play().catch((error) => {\n if (!videoRef.current) return;\n\n videoRef.current.pause();\n videoRef.current.muted = true;\n videoRef.current.play();\n console.error(error);\n });\n } else {\n videoRef.current?.pause();\n }\n });\n },\n { threshold: threshold ?? 0.5 }\n );\n\n observer.observe(videoRef?.current);\n\n return () => {\n observer.disconnect();\n };\n }, [videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useGetDuration = (videoRef: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n const [duration, setDuration] = React.useState<number | null>(null);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n setIsLoading(true);\n\n const getDuration = () => {\n setDuration(videoRef.current?.duration ?? null);\n setIsLoading(false);\n };\n\n const handleError = () => {\n setIsLoading(false);\n };\n\n const video = videoRef.current;\n\n // Check if duration is already available\n if (video.duration && !isNaN(video.duration)) {\n setDuration(video.duration);\n setIsLoading(false);\n } else {\n // Add event listeners\n video.addEventListener(\"loadedmetadata\", getDuration);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"loadeddata\", getDuration);\n\n return () => {\n video.removeEventListener(\"loadedmetadata\", getDuration);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"loadeddata\", getDuration);\n };\n }\n }, [videoRef]);\n\n return { duration, isLoading };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useSpeed = (videoRef: VideoRef) => {\n const [speed, setSpeed] = React.useState(1);\n\n const onChangeSpeed = (speed: number) => {\n setSpeed(speed);\n };\n\n // Get the speed from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setSpeed(videoRef.current.playbackRate);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.playbackRate = speed;\n }, [speed, videoRef?.current]);\n\n return { speed, onChangeSpeed };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useStartAt = (videoRef: VideoRef, startAt: number) => {\n React.useEffect(() => {\n if (!videoRef?.current || !startAt) return;\n\n const video = videoRef?.current;\n if (video && startAt) {\n video.currentTime = startAt;\n }\n }, [startAt, videoRef?.current]);\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useCurrentTime = (videoRef: VideoRef, interval = 10) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [currentTime, setCurrentTime] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n setCurrentTime(videoRef.current?.currentTime || 0);\n }, interval);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const video = videoRef.current;\n\n // Store handlers in variables for proper cleanup (critical for Safari memory safety)\n const handlePlay = () => setIsPlaying(true);\n const handlePause = () => setIsPlaying(false);\n\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n\n return () => {\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n };\n }, [videoRef?.current]);\n\n const onTimeUpdate = (time: number) => {\n if (videoRef?.current) {\n setCurrentTime(time);\n videoRef.current.currentTime = time;\n }\n };\n\n return {\n currentTime,\n onTimeUpdate,\n };\n};\n","import { RefObject, useEffect, useState } from \"react\";\n\nconst useVideoState = (videoRef: RefObject<HTMLVideoElement | null>) => {\n const [isPlaying, setIsPlaying] = useState(false);\n const [isMuted, setIsMuted] = useState(false);\n const [isFullscreen, setIsFullscreen] = useState(false);\n\n useEffect(() => {\n const video = videoRef.current;\n\n if (video) {\n video.addEventListener(\"play\", () => setIsPlaying(true));\n video.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n video.removeEventListener(\"play\", () => setIsPlaying(true));\n video.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n // Set the initial state\n setIsMuted(videoRef.current.muted);\n\n const handleVolumeChange = () => {\n if (videoRef.current) {\n setIsMuted(videoRef.current.muted);\n }\n };\n\n videoRef.current.addEventListener(\"volumechange\", handleVolumeChange);\n\n return () => {\n videoRef.current?.removeEventListener(\"volumechange\", handleVolumeChange);\n };\n }, [videoRef]);\n\n useEffect(() => {\n if (!videoRef?.current) return;\n\n const handleFullscreenChange = () => {\n setIsFullscreen(!!document.fullscreenElement);\n };\n\n document.addEventListener(\"fullscreenchange\", handleFullscreenChange);\n return () =>\n document.removeEventListener(\"fullscreenchange\", handleFullscreenChange);\n }, [videoRef]);\n\n return { isPlaying, isMuted, isFullscreen };\n};\n\nexport { useVideoState };\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useVolume = (videoRef: VideoRef, initialVolume = 100) => {\n const [volume, setVolume] = React.useState(initialVolume);\n\n const onChangeVolume = (volume: number) => {\n setVolume(volume);\n };\n\n // Get the volume from the video element\n React.useEffect(() => {\n if (!videoRef?.current) return;\n setVolume(videoRef.current.volume * 100);\n }, [videoRef?.current]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.volume = volume / 100;\n }, [volume, videoRef?.current]);\n\n return { volume, onChangeVolume };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types.js\";\n\nexport const useBuffer = (videoRef: VideoRef, duration?: number) => {\n const [isPlaying, setIsPlaying] = React.useState(false);\n const [buffered, setBuffered] = React.useState(0);\n\n React.useEffect(() => {\n if (videoRef?.current && isPlaying) {\n const intervalId = setInterval(() => {\n if (videoRef.current?.buffered.length) {\n setBuffered(\n videoRef.current.buffered.end(videoRef.current.buffered.length - 1)\n );\n }\n }, 10);\n\n return () => clearInterval(intervalId);\n }\n }, [videoRef?.current, isPlaying]);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n videoRef.current.addEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current.addEventListener(\"pause\", () => setIsPlaying(false));\n\n return () => {\n videoRef.current?.removeEventListener(\"play\", () => setIsPlaying(true));\n videoRef.current?.removeEventListener(\"pause\", () => setIsPlaying(false));\n };\n }, []);\n\n return {\n buffered,\n bufferedPercentage: (buffered / (duration || 0)) * 100 || 0,\n };\n};\n","import { useEffect, useState, useCallback } from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useDownload = (videoRef: VideoRef) => {\n const [isDownloading, setIsDownloading] = useState(false);\n const [downloadProgress, setDownloadProgress] = useState(0);\n const [error, setError] = useState<string | null>(null);\n\n const downloadVideo = useCallback(\n async (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n // Fetch the video file\n const response = await fetch(videoSrc);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch video: ${response.statusText}`);\n }\n\n // Get the content length for progress tracking\n const contentLength = response.headers.get(\"content-length\");\n const total = contentLength ? parseInt(contentLength, 10) : 0;\n\n // Create a readable stream to track progress\n const reader = response.body?.getReader();\n if (!reader) {\n throw new Error(\"Failed to create download stream\");\n }\n\n const chunks: BlobPart[] = [];\n let receivedLength = 0;\n\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n chunks.push(value);\n receivedLength += value.length;\n\n if (total > 0) {\n const progress = (receivedLength / total) * 100;\n setDownloadProgress(Math.round(progress));\n }\n }\n\n // Combine chunks into a single blob\n const blob = new Blob(chunks, {\n type: response.headers.get(\"content-type\") || \"video/mp4\",\n });\n\n // Create download link\n const url = URL.createObjectURL(blob);\n const link = document.createElement(\"a\");\n link.href = url;\n\n // Generate filename if not provided\n const defaultFilename = filename || `video-${Date.now()}.mp4`;\n link.download = defaultFilename;\n\n // Trigger download\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n // Clean up\n URL.revokeObjectURL(url);\n\n setDownloadProgress(100);\n setIsDownloading(false);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Alternative simple download method for direct video URLs\n const downloadDirect = useCallback(\n (filename?: string) => {\n if (!videoRef?.current) {\n setError(\"Video element not found\");\n return;\n }\n\n const video = videoRef.current;\n const videoSrc = video.src || video.currentSrc;\n\n if (!videoSrc) {\n setError(\"No video source found\");\n return;\n }\n\n try {\n setIsDownloading(true);\n setError(null);\n setDownloadProgress(0);\n\n const link = document.createElement(\"a\");\n link.href = videoSrc;\n link.download = filename || `video-${Date.now()}.mp4`;\n link.target = \"_blank\";\n\n document.body.appendChild(link);\n link.click();\n document.body.removeChild(link);\n\n setIsDownloading(false);\n setDownloadProgress(100);\n } catch (err) {\n setError(err instanceof Error ? err.message : \"Download failed\");\n setIsDownloading(false);\n setDownloadProgress(0);\n }\n },\n [videoRef]\n );\n\n // Cleanup on unmount\n useEffect(() => {\n return () => {\n setIsDownloading(false);\n setDownloadProgress(0);\n setError(null);\n };\n }, []);\n\n return {\n downloadVideo,\n downloadDirect,\n isDownloading,\n downloadProgress,\n error,\n resetError: () => setError(null),\n };\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useRange = (videoRef: VideoRef, range: [number, number]) => {\n React.useEffect(() => {\n if (!videoRef?.current || !range) return;\n\n const video = videoRef.current;\n\n if (video) {\n const handleTimeUpdate = () => {\n if (video.currentTime >= range[1]) {\n video.currentTime = range[0];\n } else if (video.currentTime <= range[0]) {\n video.currentTime = range[0];\n }\n };\n\n video.addEventListener(\"timeupdate\", handleTimeUpdate);\n\n return () => {\n video.removeEventListener(\"timeupdate\", handleTimeUpdate);\n };\n }\n }, [range, videoRef?.current]);\n};\n","import React, { RefObject, useRef } from \"react\";\n\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { useVideo } from \"./wrapper\";\nimport { useFullscreen } from \"./hooks/use-fullscreen\";\nimport { useSeek } from \"./hooks/use-seek\";\nimport { useMuteUnmute } from \"./hooks/use-mute-unmute\";\nimport { usePlayPause } from \"./hooks/use-play-pause\";\nimport { useCurrentTime } from \"./hooks/use-current-time\";\nimport { usePictureInPicture } from \"./hooks/use-picture-in-picture\";\nimport { useDownload } from \"./hooks/use-download\";\nimport { useSpeed } from \"./hooks\";\nimport { useLoading } from \"./hooks/use-loading\";\n\ninterface ControlsProps extends React.ComponentProps<\"div\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Controls = React.memo(\n ({ children, asChild, ...props }: ControlsProps) => {\n return (\n <div data-zuude-hide-elements {...props}>\n {children}\n </div>\n );\n }\n);\n\ninterface Props extends React.ComponentProps<\"button\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Play = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { play } = usePlayPause(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={play}>\n {children}\n </Element>\n );\n});\n\nconst Pause = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { pause } = usePlayPause(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={pause}>\n {children}\n </Element>\n );\n});\n\nconst Mute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { mute } = useMuteUnmute(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={mute}>\n {children}\n </Element>\n );\n});\n\nconst Unmute = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { unmute } = useMuteUnmute(videoRef as RefObject<HTMLVideoElement>);\n\n return (\n <Element {...props} onClick={unmute}>\n {children}\n </Element>\n );\n});\n\ninterface SpeedProps extends Props {\n value: number;\n onClick?: () => void;\n}\n\nconst Speed = React.memo(\n ({ children, asChild, value, onClick, ...props }: SpeedProps) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { speed, onChangeSpeed } = useSpeed(\n videoRef as RefObject<HTMLVideoElement>\n );\n\n return (\n <Element\n {...props}\n value={value}\n onClick={() => {\n onChangeSpeed(value);\n onClick?.();\n }}\n >\n {children}\n </Element>\n );\n }\n);\n\nconst SeekForward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { seekForward } = useSeek(videoRef as RefObject<HTMLVideoElement>, 10);\n\n return (\n <Element {...props} onClick={seekForward}>\n {children}\n </Element>\n );\n});\n\nconst SeekBackward = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { seekBackward } = useSeek(videoRef as RefObject<HTMLVideoElement>, 10);\n\n return (\n <Element {...props} onClick={seekBackward}>\n {children}\n </Element>\n );\n});\n\nconst Fullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(videoRef);\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst ExitFullscreen = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { toggleFullscreen } = useFullscreen(videoRef);\n\n return (\n <Element {...props} onClick={toggleFullscreen}>\n {children}\n </Element>\n );\n});\n\nconst PictureInPicture = React.memo(\n ({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { togglePictureInPicture } = usePictureInPicture(videoRef);\n\n return (\n <Element {...props} onClick={togglePictureInPicture}>\n {children}\n </Element>\n );\n }\n);\n\nconst Download = React.memo(({ children, asChild, ...props }: Props) => {\n const Element = asChild ? Slot : \"button\";\n const { videoRef } = useVideo();\n\n const { downloadDirect } = useDownload(videoRef);\n\n return (\n <Element {...props} onClick={() => downloadDirect()}>\n {children}\n </Element>\n );\n});\n\ninterface LoadingProps extends React.ComponentProps<\"div\"> {\n children: React.ReactNode;\n asChild?: boolean;\n}\n\nconst Loading = React.memo(({ children, asChild, ...props }: LoadingProps) => {\n const Element = asChild ? Slot : \"div\";\n const { videoRef } = useVideo();\n\n const { isLoading } = useLoading(videoRef);\n\n return (\n <Element\n {...props}\n style={{ ...props.style, pointerEvents: \"none\" }}\n data-loading={isLoading}\n >\n {children}\n </Element>\n );\n});\n\ninterface ShadowProps extends React.ComponentProps<\"div\"> {}\n\nconst Shadow = ({ ...props }: ShadowProps) => {\n const { videoRef } = useVideo();\n\n const shadowVideoRef = useRef<HTMLVideoElement>(null);\n\n React.useEffect(() => {\n const video = videoRef?.current;\n if (shadowVideoRef.current && video) {\n let currentTime = 0;\n let isPlaying = false;\n let interval: ReturnType<typeof setInterval> | null = null;\n\n const startInterval = () => {\n if (interval) clearInterval(interval);\n interval = setInterval(() => {\n currentTime = video.currentTime;\n if (shadowVideoRef.current) {\n shadowVideoRef.current.currentTime = currentTime;\n }\n }, 100);\n };\n\n const stopInterval = () => {\n if (interval) {\n clearInterval(interval);\n interval = null;\n }\n };\n\n const handlePlay = () => {\n isPlaying = true;\n startInterval();\n };\n\n const handlePause = () => {\n isPlaying = false;\n stopInterval();\n };\n\n video.addEventListener(\"play\", handlePlay);\n video.addEventListener(\"pause\", handlePause);\n\n return () => {\n stopInterval();\n video.removeEventListener(\"play\", handlePlay);\n video.removeEventListener(\"pause\", handlePause);\n };\n }\n }, [videoRef?.current]);\n\n if (!videoRef?.current) return null;\n\n return (\n <div\n {...props}\n style={{\n ...props.style,\n position: \"absolute\",\n top: 0,\n left: 0,\n width: \"100%\",\n height: \"100%\",\n pointerEvents: \"none\",\n }}\n >\n <video\n ref={shadowVideoRef}\n src={videoRef.current.src}\n muted\n playsInline\n style={{\n width: \"100%\",\n height: \"100%\",\n objectFit: \"cover\",\n }}\n />\n </div>\n );\n};\n\nexport {\n Controls,\n Play,\n Pause,\n Mute,\n Unmute,\n Speed,\n SeekForward,\n SeekBackward,\n Fullscreen,\n ExitFullscreen,\n PictureInPicture,\n Download,\n Loading,\n Shadow,\n};\n","import React from \"react\";\nimport type { VideoRef } from \"../types\";\n\nexport const useLoading = (videoRef: VideoRef) => {\n const [isLoading, setIsLoading] = React.useState(false);\n\n React.useEffect(() => {\n if (!videoRef?.current) return;\n\n const video = videoRef.current;\n\n const handleLoadStart = () => {\n setIsLoading(true);\n };\n\n const handleLoadedMetadata = () => {\n // Metadata loaded but video might not be ready to play yet\n // Keep loading true until canplay\n };\n\n const handleLoadedData = () => {\n // First frame loaded, but might still be buffering\n // Keep loading true until canplay\n };\n\n const handleCanPlay = () => {\n setIsLoading(false);\n };\n\n const handleCanPlayThrough = () => {\n setIsLoading(false);\n };\n\n const handleWaiting = () => {\n // Video is waiting for data (buffering)\n setIsLoading(true);\n };\n\n const handlePlaying = () => {\n // Video is playing, so it's not loading anymore\n setIsLoading(false);\n };\n\n const handleError = () => {\n setIsLoading(false);\n };\n\n const handleAbort = () => {\n setIsLoading(false);\n };\n\n const handleSuspend = () => {\n // Loading suspended (e.g., user paused)\n // Don't change loading state here\n };\n\n // Add event listeners\n video.addEventListener(\"loadstart\", handleLoadStart);\n video.addEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.addEventListener(\"loadeddata\", handleLoadedData);\n video.addEventListener(\"canplay\", handleCanPlay);\n video.addEventListener(\"canplaythrough\", handleCanPlayThrough);\n video.addEventListener(\"waiting\", handleWaiting);\n video.addEventListener(\"playing\", handlePlaying);\n video.addEventListener(\"error\", handleError);\n video.addEventListener(\"abort\", handleAbort);\n video.addEventListener(\"suspend\", handleSuspend);\n\n // Check initial state\n if (video.readyState >= 2) {\n setIsLoading(false);\n }\n\n return () => {\n // Remove event listeners\n video.removeEventListener(\"loadstart\", handleLoadStart);\n video.removeEventListener(\"loadedmetadata\", handleLoadedMetadata);\n video.removeEventListener(\"loadeddata\", handleLoadedData);\n video.removeEventListener(\"canplay\", handleCanPlay);\n video.removeEventListener(\"canplaythrough\", handleCanPlayThrough);\n video.removeEventListener(\"waiting\", handleWaiting);\n video.removeEventListener(\"playing\", handlePlaying);\n video.removeEventListener(\"error\", handleError);\n video.removeEventListener(\"abort\", handleAbort);\n video.removeEventListener(\"suspend\", handleSuspend);\n };\n }, [videoRef]);\n\n return { isLoading };\n};\n"],"mappings":"mlBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,cAAAE,GAAA,aAAAC,GAAA,mBAAAC,GAAA,eAAAC,GAAA,YAAAC,GAAA,SAAAC,GAAA,UAAAC,GAAA,qBAAAC,GAAA,SAAAC,GAAA,iBAAAC,GAAA,gBAAAC,GAAA,WAAAC,GAAA,UAAAC,GAAA,WAAAC,GAAA,UAAAC,EAAA,kBAAAC,EAAA,aAAAC,IAAA,eAAAC,GAAAnB,ICAA,IAAAoB,EAMO,sBAuKCC,EAAA,6BArJKC,KAAe,iBAAuC,IAAI,EAQ1DC,EAAgB,EAAAC,QAAM,KACjC,CAAC,CAAE,SAAAC,EAAU,OAAAC,EAAQ,QAAAC,EAAS,GAAGC,CAAM,IAA0B,CAC/D,GAAM,CAACC,EAAUC,CAAW,KAAI,YAAmB,CAAE,QAAS,IAAK,CAAC,EAC9D,CAACC,EAAOC,CAAQ,KAAI,YAAwB,IAAI,EAChD,CAACC,EAAWC,CAAY,KAAI,YAAS,EAAK,EAE1CC,KAA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SACC,IAAKuC,EACL,IAAKpC,EAAS,QAAQ,IACtB,MAAK,GACL,YAAW,GACX,MAAO,CACL,MAAO,OACP,OAAQ,OACR,UAAW,OACb,EACF,EACF,EA1B6B,IA4BjC","names":["index_exports","__export","Controls","Download","ExitFullscreen","Fullscreen","Loading","Mute","Pause","PictureInPicture","Play","SeekBackward","SeekForward","Shadow","Speed","Unmute","Video","VideoProvider","useVideo","__toCommonJS","import_react","import_jsx_runtime","VideoContext","VideoProvider","React","children","config","onError","props","videoRef","setVideoRef","error","setError","isFocused","setIsFocused","videoWrapperRef","videoWrapper","controls","video","hideTimeout","hideDelay","isMouseOver","resetTimer","control","showControls","hideControls","handleMouseMove","handlePlay","handleClick","event","_a","useVideo","context","import_react","import_react","useAutoplayByForce","videoRef","enabled","setError","React","_a","error","retryError","import_react","useHotKeys","key","func","enabled","handleKeyDown","event","import_react","useSeek","videoRef","value","seekForward","React","seekBackward","import_react","usePlayPause","videoRef","isPlaying","setIsPlaying","React","togglePlay","play","pause","handlePlay","handlePause","_a","_b","import_react","useMuteUnmute","videoRef","isMuted","setIsMuted","React","toggleMute","mute","unmute","handleVolumeChange","_a","import_react","useFullscreen","videoRef","isFullscreen","setIsFullscreen","React","previousStylesRef","handleFullscreenChange","isCurrentlyFullscreen","video","toggleFullscreen","isSafari","videoContainer","usePictureInPicture","videoRef","video","error","videoContainer","Keyboards","videoRef","useVideo","seekForward","seekBackward","useSeek","togglePlay","usePlayPause","toggleMute","useMuteUnmute","toggleFullscreen","useFullscreen","togglePictureInPicture","usePictureInPicture","useHotKeys","import_react","useAutoplayOnVisible","videoRef","threshold","enabled","React","observer","entries","entry","_a","error","import_react","import_react","useSpeed","videoRef","speed","setSpeed","React","onChangeSpeed","import_react","import_react","import_react","import_react","import_react","import_react","useDownload","videoRef","isDownloading","setIsDownloading","downloadProgress","setDownloadProgress","error","setError","downloadVideo","filename","_a","video","videoSrc","response","contentLength","total","reader","chunks","receivedLength","done","value","progress","blob","url","link","defaultFilename","err","downloadDirect","import_react","import_jsx_runtime","Video","src","autoPlay","muteFallback","controls","preload","autoPlayOnVisible","ranges","props","ref","videoRef","setVideoRef","config","setError","error","isFocused","useVideo","refVideo","isAdjustingRef","rafIdRef","timeoutIdRef","isValidRange","rangeStart","rangeEnd","video","thirdPartyRef","useAutoplayByForce","useAutoplayOnVisible","onPlay","_a","_b","_c","e","currentTime","Keyboards","import_react","import_react_slot","import_react","useLoading","videoRef","isLoading","setIsLoading","React","video","handleLoadStart","handleLoadedMetadata","handleLoadedData","handleCanPlay","handleCanPlayThrough","handleWaiting","handlePlaying","handleError","handleAbort","handleSuspend","import_jsx_runtime","Controls","React","children","asChild","props","Play","Element","videoRef","useVideo","play","usePlayPause","Pause","pause","Mute","mute","useMuteUnmute","Unmute","unmute","Speed","value","onClick","speed","onChangeSpeed","useSpeed","SeekForward","seekForward","useSeek","SeekBackward","seekBackward","Fullscreen","toggleFullscreen","useFullscreen","ExitFullscreen","PictureInPicture","togglePictureInPicture","usePictureInPicture","Download","downloadDirect","useDownload","Loading","isLoading","useLoading","Shadow","shadowVideoRef","video","currentTime","isPlaying","interval","startInterval","stopInterval","handlePlay","handlePause"]}