@bazza-ui/react 0.1.0-canary.2 → 0.1.0-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/chunk-BGJJC6GX.cjs.map +1 -1
- package/dist/chunk-FWWOE2SW.cjs.map +1 -1
- package/dist/chunk-JSPKF52O.cjs.map +1 -1
- package/dist/chunk-M4G6J7DP.cjs.map +1 -1
- package/dist/combobox/index.cjs.map +1 -1
- package/dist/context-menu/index.cjs.map +1 -1
- package/dist/dropdown-menu/index.cjs.map +1 -1
- package/dist/internal/listbox/index.cjs.map +1 -1
- package/dist/internal/popup-menu/index.cjs.map +1 -1
- package/dist/select/index.cjs.map +1 -1
- package/dist/video-player/index.cjs +3 -0
- package/dist/video-player/index.cjs.map +1 -0
- package/dist/video-player/index.d.cts +1383 -0
- package/dist/video-player/index.d.ts +1383 -0
- package/dist/video-player/index.js +3 -0
- package/dist/video-player/index.js.map +1 -0
- package/package.json +8 -2
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var _chunkM4G6J7DPcjs = require('../chunk-M4G6J7DP.cjs');var _react = require('react'); var Ie = _interopRequireWildcard(_react); var He = _interopRequireWildcard(_react); var nr = _interopRequireWildcard(_react); var Oe = _interopRequireWildcard(_react); var ue = _interopRequireWildcard(_react); var ce = _interopRequireWildcard(_react); var q = _interopRequireWildcard(_react); var J = _interopRequireWildcard(_react); var Qe = _interopRequireWildcard(_react); var de = _interopRequireWildcard(_react); var Z = _interopRequireWildcard(_react); var Ne = _interopRequireWildcard(_react); var Ue = _interopRequireWildcard(_react); var pe = _interopRequireWildcard(_react); var _e = _interopRequireWildcard(_react); var je = _interopRequireWildcard(_react); var fe = _interopRequireWildcard(_react); var d = _interopRequireWildcard(_react); var Ke = _interopRequireWildcard(_react); var k = _interopRequireWildcard(_react); var H = _interopRequireWildcard(_react); var ot = _interopRequireWildcard(_react); var _ = _interopRequireWildcard(_react); var ie = _interopRequireWildcard(_react); var I = _interopRequireWildcard(_react);var lt=Ie.createContext(null);function R(c){let e=Ie.useContext(lt);if(!e)throw new Error(`<VideoPlayer.${c}> must be used within <VideoPlayer.Root>`);return e}function ae(){return R("useVideoPlayer")}var Qr={};_chunkM4G6J7DPcjs.a.call(void 0, Qr,{BufferedIndicator:()=>tr,Captions:()=>or,CaptionsButton:()=>ar,CaptionsDataAttributes:()=>De,CaptionsMenu:()=>ir,CaptionsMenuItem:()=>Fe,Controls:()=>sr,ControlsDataAttributes:()=>We,FullscreenButton:()=>lr,MuteButton:()=>ur,Overlay:()=>cr,OverlayDataAttributes:()=>$e,PictureInPictureButton:()=>dr,PlayButton:()=>pr,PlaybackRateButton:()=>fr,PlaybackRateMenu:()=>mr,PlaybackRateMenuItem:()=>ct,Portal:()=>Pr,Poster:()=>Rr,QualityMenu:()=>yr,QualityMenuItem:()=>pt,Root:()=>br,RootDataAttributes:()=>qe,SeekSlider:()=>Tr,SeekSliderBuffered:()=>Er,SeekSliderControl:()=>xr,SeekSliderCssVars:()=>Ge,SeekSliderDataAttributes:()=>ze,SeekSliderHover:()=>wr,SeekSliderPreviewThumb:()=>Vr,SeekSliderPreviewThumbDataAttributes:()=>Je,SeekSliderPreviewTooltip:()=>me,SeekSliderPreviewTooltipPopup:()=>tt,SeekSliderPreviewTooltipPortal:()=>Ze,SeekSliderPreviewTooltipPositioner:()=>et,SeekSliderProgress:()=>Cr,SeekSliderThumb:()=>Mr,SeekSliderTrack:()=>hr,Thumbnail:()=>Br,ThumbnailDataAttributes:()=>rt,TimeDisplay:()=>Lr,TimeDisplayDataAttributes:()=>nt,Track:()=>Ir,Video:()=>Hr,VolumeSlider:()=>Dr,VolumeSliderControl:()=>Or,VolumeSliderCssVars:()=>at,VolumeSliderDataAttributes:()=>it,VolumeSliderRange:()=>Fr,VolumeSliderThumb:()=>Wr,VolumeSliderTrack:()=>Ar,useTransitionStatus:()=>K,useVideoPlayer:()=>ae});var _jsxruntime = require('react/jsx-runtime');var tr=He.forwardRef(function(e,o){let{render:s,...l}=e,u=R("BufferedIndicator"),r=He.useMemo(()=>{if(!u.buffered||u.buffered.length===0)return 0;for(let n=0;n<u.buffered.length;n++)if(u.buffered.start(n)<=u.currentTime&&u.currentTime<=u.buffered.end(n))return u.buffered.end(n);return u.buffered.end(0)},[u.buffered,u.currentTime]),a=u.duration>0?r/u.duration*100:0,t={buffered:u.buffered,duration:u.duration,bufferedPercentage:a,bufferedEnd:r},i={"--buffered-percentage":`${a}%`,"--buffered-end":r,...l.style},p={ref:o,style:i,"aria-hidden":!0};return s?s(p,t):_jsxruntime.jsx.call(void 0, "div",{ref:o,"aria-hidden":"true",...l,style:i})});var De=(e=>(e.active="data-active",e))(De||{});var or=nr.forwardRef(function(e,o){let{render:s,children:l,...u}=e,a=R("Captions").activeCues,t=a.map(f=>f.text).join(`
|
|
2
|
+
`),i=a.length>0,p={active:i,cueText:t,cues:a},n={ref:o,"aria-live":"polite","aria-atomic":!0,role:"status",style:{pointerEvents:"none"},"data-active":i||void 0};return s?s(n,p):l?_jsxruntime.jsx.call(void 0, "div",{...n,...u,children:l}):_jsxruntime.jsx.call(void 0, "div",{...n,...u,children:t})});var ar=Oe.forwardRef(function(e,o){let{render:s,onClick:l,...u}=e,r=R("CaptionsButton"),a=r.registeredTracks.length>0,t=r.activeTextTrack!==null,i={active:t,available:a,trackCount:r.registeredTracks.length},p=Oe.useCallback(f=>{if(_optionalChain([l, 'optionalCall', _2 => _2(f)]),!f.defaultPrevented){if(t)r.setTextTrack(null);else if(r.registeredTracks.length>0){let S=r.registeredTracks[0];_optionalChain([S, 'optionalAccess', _3 => _3.textTrack])&&r.setTextTrack(S.textTrack)}}},[l,r,t]),n={ref:o,type:"button","aria-label":t?"Disable captions":"Enable captions","aria-pressed":t,disabled:!a,"data-active":t||void 0,"data-available":a||void 0,onClick:p};return s?s(n,i):_jsxruntime.jsx.call(void 0, "button",{...n,...u})});var ir=ue.forwardRef(function(e,o){let{render:s,children:l,...u}=e,r=R("CaptionsMenu"),a={registeredTracks:r.registeredTracks,activeTextTrack:r.activeTextTrack},t={ref:o,role:"menu","aria-label":"Captions","data-active":r.activeTextTrack!==null||void 0};return s?s(t,a):_jsxruntime.jsx.call(void 0, "div",{...t,...u,children:_nullishCoalesce(l, () => (_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Fe,{track:null,children:"Off"}),r.registeredTracks.map(i=>_jsxruntime.jsx.call(void 0, Fe,{track:i.textTrack,children:i.label},i.id))]})))})}),Fe=ue.forwardRef(function(e,o){let{track:s,onClick:l,children:u,...r}=e,a=R("CaptionsMenuItem"),t=a.activeTextTrack===s,i=ue.useCallback(p=>{_optionalChain([l, 'optionalCall', _4 => _4(p)]),p.defaultPrevented||a.setTextTrack(s)},[l,a,s]);return _jsxruntime.jsx.call(void 0, "button",{ref:o,type:"button",role:"menuitemradio","aria-checked":t,"data-active":t||void 0,...r,onClick:i,children:u})});var We=(t=>(t.open="data-open",t.closed="data-closed",t.idle="data-idle",t.playing="data-playing",t.paused="data-paused",t.ended="data-ended",t.startingStyle="data-starting-style",t.endingStyle="data-ending-style",t))(We||{});function Zr(c){let e=[...c.getAnimations(),...Array.from(c.querySelectorAll("*")).flatMap(o=>o.getAnimations())];return e.length===0?Promise.resolve():Promise.all(e.map(o=>o.finished)).then(()=>{}).catch(()=>{})}function K(c){let{open:e,keepMounted:o=!1}=c,[s,l]=q.useState(e||o),[u,r]=q.useState(e?"starting":void 0),a=q.useRef(null),t=q.useRef(!1);return q.useEffect(()=>{if(e){t.current=!1,l(!0),r("starting");let i=requestAnimationFrame(()=>{requestAnimationFrame(()=>{r(void 0)})});return()=>cancelAnimationFrame(i)}},[e]),q.useEffect(()=>{if(!e&&s&&!t.current){r("ending");let i=a.current;if(!i){r(void 0),o||l(!1);return}t.current=!0;let p=requestAnimationFrame(()=>{requestAnimationFrame(()=>{Zr(i).then(()=>{t.current&&(t.current=!1,r(void 0),o||l(!1))})})});return()=>{cancelAnimationFrame(p)}}},[e,s,o]),q.useEffect(()=>{o&&!s&&!e&&l(!0)},[o,s,e]),{mounted:s||o,transitionStatus:u,elementRef:a}}var sr=ce.forwardRef(function(e,o){let{idleTimeout:s,keepMounted:l=!1,render:u,children:r,...a}=e,t=R("Controls"),p=(_nullishCoalesce(s, () => (t.idleTimeout)))===0||!t.idle,{mounted:n,transitionStatus:f,elementRef:S}=K({open:p,keepMounted:l}),y=ce.useCallback(E=>{S.current=E,typeof o=="function"?o(E):o&&(o.current=E)},[o,S]),{onClick:g,...m}=a,h=ce.useCallback(E=>{E.stopPropagation(),_optionalChain([g, 'optionalCall', _5 => _5(E)])},[g]),v={open:p,idle:t.idle,playing:t.playing,paused:t.paused,ended:t.ended},b={ref:y,onClick:h,"data-open":p||void 0,"data-closed":!p||void 0,"data-idle":t.idle||void 0,"data-playing":t.playing||void 0,"data-paused":t.paused||void 0,"data-ended":t.ended||void 0,"data-starting-style":f==="starting"||void 0,"data-ending-style":f==="ending"||void 0};return n?u?u(b,v):_jsxruntime.jsx.call(void 0, "div",{...b,...m,children:r}):null});var lr=J.forwardRef(function(e,o){let{render:s,onClick:l,children:u,...r}=e,a=R("FullscreenButton"),[t,i]=J.useState(!1);J.useEffect(()=>{i("fullscreenEnabled"in document&&document.fullscreenEnabled)},[]);let p=J.useCallback(S=>{_optionalChain([l, 'optionalCall', _6 => _6(S)]),S.defaultPrevented||a.toggleFullscreen()},[l,a]),n={fullscreen:a.fullscreen,supported:t},f={ref:o,type:"button","aria-label":a.fullscreen?"Exit fullscreen":"Enter fullscreen","aria-pressed":a.fullscreen,disabled:!t,"data-fullscreen":a.fullscreen||void 0,"data-supported":t||void 0,onClick:p};return s?s(f,n):_jsxruntime.jsx.call(void 0, "button",{...f,...r,children:u})});var ur=Qe.forwardRef(function(e,o){let{render:s,onClick:l,...u}=e,r=R("MuteButton"),a={muted:r.muted,volume:r.volume},t=Qe.useCallback(m=>{_optionalChain([l, 'optionalCall', _7 => _7(m)]),m.defaultPrevented||r.toggleMute()},[l,r]),i=r.volume,p=r.muted,n=i===0||p,f=i>0&&!p,S=!p&&i>0&&i<.5,y=!p&&i>=.5,g={ref:o,type:"button","aria-label":r.muted?"Unmute":"Mute","aria-pressed":r.muted,"data-muted":p||void 0,"data-volume-off":n||void 0,"data-volume-on":f||void 0,"data-volume-low":S||void 0,"data-volume-high":y||void 0,onClick:t};return s?s(g,a):_jsxruntime.jsx.call(void 0, "button",{...g,...u})});var $e=(n=>(n.open="data-open",n.closed="data-closed",n.playing="data-playing",n.paused="data-paused",n.ended="data-ended",n.waiting="data-waiting",n.seeking="data-seeking",n.fullscreen="data-fullscreen",n.pip="data-pip",n.startingStyle="data-starting-style",n.endingStyle="data-ending-style",n))($e||{});var cr=de.forwardRef(function(e,o){let{idleTimeout:s,keepMounted:l=!1,render:u,onClick:r,children:a,...t}=e,i=R("Overlay"),n=(_nullishCoalesce(s, () => (i.idleTimeout)))===0||!i.idle,{mounted:f,transitionStatus:S,elementRef:y}=K({open:n,keepMounted:l}),g=de.useCallback(b=>{y.current=b,typeof o=="function"?o(b):o&&(o.current=b)},[o,y]),m=de.useCallback(b=>{_optionalChain([r, 'optionalCall', _8 => _8(b)]),b.defaultPrevented||i.toggle()},[r,i]),h={playing:i.playing,paused:i.paused,ended:i.ended,waiting:i.waiting,seeking:i.seeking,fullscreen:i.fullscreen,pictureInPicture:i.pictureInPicture,open:n},v={ref:g,onClick:m,"data-playing":i.playing||void 0,"data-paused":i.paused||void 0,"data-ended":i.ended||void 0,"data-waiting":i.waiting||void 0,"data-seeking":i.seeking||void 0,"data-fullscreen":i.fullscreen||void 0,"data-pip":i.pictureInPicture||void 0,"data-open":n||void 0,"data-closed":!n||void 0,"data-starting-style":S==="starting"||void 0,"data-ending-style":S==="ending"||void 0};return f?u?u(v,h):_jsxruntime.jsx.call(void 0, "div",{...v,...t,children:a}):null});var dr=Z.forwardRef(function(e,o){let{render:s,onClick:l,...u}=e,r=R("PictureInPictureButton"),[a,t]=Z.useState(!1);Z.useEffect(()=>{t("pictureInPictureEnabled"in document&&document.pictureInPictureEnabled)},[]);let i={pictureInPicture:r.pictureInPicture,supported:a},p=Z.useCallback(f=>{_optionalChain([l, 'optionalCall', _9 => _9(f)]),f.defaultPrevented||r.togglePictureInPicture()},[l,r]),n={ref:o,type:"button","aria-label":r.pictureInPicture?"Exit picture-in-picture":"Enter picture-in-picture","aria-pressed":r.pictureInPicture,disabled:!a,"data-pip":r.pictureInPicture||void 0,"data-supported":a||void 0,onClick:p};return s?s(n,i):_jsxruntime.jsx.call(void 0, "button",{...n,...u})});var pr=Ne.forwardRef(function(e,o){let{render:s,onClick:l,children:u,...r}=e,a=R("PlayButton"),t=Ne.useCallback(n=>{_optionalChain([l, 'optionalCall', _10 => _10(n)]),n.defaultPrevented||a.toggle()},[l,a]),i={playing:a.playing,paused:a.paused,ended:a.ended,waiting:a.waiting},p={ref:o,type:"button","aria-label":a.playing?"Pause":"Play","data-playing":a.playing||void 0,"data-paused":a.paused||void 0,"data-ended":a.ended||void 0,"data-waiting":a.waiting||void 0,onClick:t};return s?s(p,i):_jsxruntime.jsx.call(void 0, "button",{...p,...r,children:u})});var sn=[.25,.5,.75,1,1.25,1.5,1.75,2],fr=Ue.forwardRef(function(e,o){let{rates:s=sn,render:l,onClick:u,children:r,...a}=e,t=R("PlaybackRateButton"),i={playbackRate:t.playbackRate,rates:s},p=Ue.useCallback(f=>{if(_optionalChain([u, 'optionalCall', _11 => _11(f)]),!f.defaultPrevented){let y=(s.indexOf(t.playbackRate)+1)%s.length,g=_nullishCoalesce(_nullishCoalesce(s[y], () => (s[0])), () => (t.playbackRate));t.setPlaybackRate(g)}},[u,t,s]),n={ref:o,type:"button","aria-label":`Playback speed: ${t.playbackRate}x`,"data-rate":t.playbackRate,onClick:p};return l?l(n,i):_jsxruntime.jsx.call(void 0, "button",{...n,...a,children:_nullishCoalesce(r, () => (`${t.playbackRate}x`))})});var un=[.25,.5,.75,1,1.25,1.5,1.75,2],mr=pe.forwardRef(function(e,o){let{rates:s=un,render:l,children:u,...r}=e,a=R("PlaybackRateMenu"),t={playbackRate:a.playbackRate,rates:s},i={ref:o,role:"menu","aria-label":"Playback speed","data-rate":a.playbackRate};return l?l(i,t):_jsxruntime.jsx.call(void 0, "div",{...i,...r,children:_nullishCoalesce(u, () => (s.map(p=>_jsxruntime.jsx.call(void 0, ct,{rate:p},p))))})}),ct=pe.forwardRef(function(e,o){let{rate:s,onClick:l,children:u,...r}=e,a=R("PlaybackRateMenuItem"),t=a.playbackRate===s,i=pe.useCallback(p=>{_optionalChain([l, 'optionalCall', _12 => _12(p)]),p.defaultPrevented||a.setPlaybackRate(s)},[l,a,s]);return _jsxruntime.jsx.call(void 0, "button",{ref:o,type:"button",role:"menuitemradio","aria-checked":t,"data-active":t||void 0,...r,onClick:i,children:_nullishCoalesce(u, () => (`${s}x`))})});var _reactdom = require('react-dom'); var gr = _interopRequireWildcard(_reactdom);function Pr(c){let{children:e,container:o}=c,[s,l]=_e.useState(!1);if(_e.useEffect(()=>(l(!0),()=>l(!1)),[]),!s)return null;let u=_nullishCoalesce(o, () => ((typeof document<"u"?document.body:null)));return u?_reactdom.createPortal.call(void 0, e,u):null}var Rr=je.forwardRef(function(e,o){let{keepMounted:s=!1,render:l,children:u,...r}=e,a=R("Poster"),t=!a.canPlay,i=a.canPlay,{mounted:p,transitionStatus:n,elementRef:f}=K({open:t,keepMounted:s}),S=dn(o,f),y={loading:t,loaded:i,transitionStatus:n},g={ref:S,"aria-hidden":!0,"data-loading":t||void 0,"data-loaded":i||void 0,"data-starting-style":n==="starting"||void 0,"data-ending-style":n==="ending"||void 0};return p?l?l(g,y):_jsxruntime.jsx.call(void 0, "div",{...g,...r,children:u}):null});function dn(...c){return je.useCallback(e=>{for(let o of c)typeof o=="function"?o(e):o!=null&&(o.current=e)},c)}var yr=fe.forwardRef(function(e,o){let{render:s,children:l,...u}=e,r=R("QualityMenu"),a={qualities:r.qualities,activeQuality:r.activeQuality},t={ref:o,role:"menu","aria-label":"Video quality","data-quality":_nullishCoalesce(_optionalChain([r, 'access', _13 => _13.activeQuality, 'optionalAccess', _14 => _14.label]), () => (void 0))};return s?s(t,a):_jsxruntime.jsx.call(void 0, "div",{...t,...u,children:_nullishCoalesce(l, () => (r.qualities.map(i=>_jsxruntime.jsx.call(void 0, pt,{quality:i,children:i.label},i.label))))})}),pt=fe.forwardRef(function(e,o){let{quality:s,onClick:l,children:u,...r}=e,a=R("QualityMenuItem"),t=_optionalChain([a, 'access', _15 => _15.activeQuality, 'optionalAccess', _16 => _16.label])===s.label,i=fe.useCallback(p=>{_optionalChain([l, 'optionalCall', _17 => _17(p)]),p.defaultPrevented||a.setQuality(s)},[l,a,s]);return _jsxruntime.jsx.call(void 0, "button",{ref:o,type:"button",role:"menuitemradio","aria-checked":t,"data-active":t||void 0,...r,onClick:i,children:u})});var qe=(i=>(i.playing="data-playing",i.paused="data-paused",i.ended="data-ended",i.waiting="data-waiting",i.seeking="data-seeking",i.fullscreen="data-fullscreen",i.pip="data-pip",i.muted="data-muted",i.idle="data-idle",i))(qe||{});function fn(c,e){return!(c instanceof HTMLElement)||c instanceof HTMLInputElement&&c.type==="range"&&e===" "?!1:c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable}function mn(c){return c==="ArrowRight"||c==="ArrowLeft"}function Sr(c,e){let o=ae(),s=Ke.useRef(o);s.current=o,Ke.useEffect(()=>{if(e==="none")return;let l=a=>{if(fn(a.target,a.key))return;let t=s.current;switch(a.key){case" ":a.preventDefault(),t.toggle();break;case"f":case"F":a.preventDefault(),t.toggleFullscreen();break;case"ArrowUp":a.preventDefault(),t.setVolume(Math.min(t.volume+.1,1));break;case"ArrowDown":a.preventDefault(),t.setVolume(Math.max(t.volume-.1,0));break;case"ArrowRight":a.preventDefault(),t.beginSeekInteraction(),t.seek(Math.min(t.currentTime+5,t.duration));break;case"ArrowLeft":a.preventDefault(),t.beginSeekInteraction(),t.seek(Math.max(t.currentTime-5,0));break;default:return}t.resetIdle()},u=a=>{mn(a.key)&&s.current.endSeekInteraction()};if(e==="global")return window.addEventListener("keydown",l),window.addEventListener("keyup",u),()=>{window.removeEventListener("keydown",l),window.removeEventListener("keyup",u)};let r=c.current;if(r)return r.addEventListener("keydown",l),r.addEventListener("keyup",u),()=>{r.removeEventListener("keydown",l),r.removeEventListener("keyup",u)}},[e,c])}function Xe(c,e,o){let[s,l]=d.useState(e),u=c!==void 0,r=u?c:s,a=d.useCallback(t=>{let i=typeof t=="function"?t(r):t;u||l(i),_optionalChain([o, 'optionalCall', _18 => _18(i)])},[u,r,o]);return[r,a]}function Pn({rootRef:c,videoRef:e,actionsRef:o,defaultPlaying:s=!1,defaultVolume:l=1,defaultMuted:u=!1,defaultPlaybackRate:r=1,playing:a,onPlayingChange:t,volume:i,onVolumeChange:p,muted:n,onMutedChange:f,playbackRate:S,onPlaybackRateChange:y,currentTime:g,onCurrentTimeChange:m,idleTimeout:h=3e3,preventIdleWhenPaused:v=!1,idle:b,onIdleChange:E,onEnded:M,onWaiting:V,onSeeking:O,onSeeked:Y,onFullscreenChange:j,onPictureInPictureChange:T,children:Q}){let A=d.useRef(1),F=d.useRef(!1),G=d.useRef(!1),[w,L]=d.useState("paused"),[N,z]=d.useState(s?"play":"pause");d.useEffect(()=>{a!==void 0&&(z(a?"play":"pause"),w!=="waiting"&&L(a?"playing":"paused"))},[a,w]);let[x,D]=Xe(i,l,p),[U,se]=Xe(n,u,f),[Re,Pt]=Xe(S,r,y),[$r,te]=Xe(b,!0,E),re=d.useRef(null),ye=d.useCallback(()=>{re.current&&(clearTimeout(re.current),re.current=null)},[]),Rt=d.useCallback(()=>{h!==0&&(ye(),re.current=setTimeout(()=>{te(!0)},h))},[h,ye,te]),yt=d.useCallback(()=>{te(!1),Rt()},[te,Rt]),St=d.useCallback(()=>{ye(),te(!0)},[ye,te]);d.useEffect(()=>(h>0&&(re.current=setTimeout(()=>{te(!0)},h)),()=>{re.current&&clearTimeout(re.current)}),[]);let bt=v&&w!=="playing"?!1:$r,[kt,gt]=d.useState(0),[Se,vt]=d.useState(0),[Tt,Nr]=d.useState(null),[be,Ur]=d.useState(null),[xt,ht]=d.useState(!1),[Ct,le]=d.useState(!1),[ke,_r]=d.useState(!1),[ge,Mt]=d.useState(!1),[Et,st]=d.useState([]),[ne,jr]=d.useState(null),[Vt,ve]=d.useState([]),[wt,Ln]=d.useState([]),[Bt,qr]=d.useState(null);d.useEffect(()=>{g!==void 0&&e.current&&(e.current.currentTime=g)},[g,e]),d.useEffect(()=>{let P=()=>{let C=document.fullscreenElement===c.current;_r(C),_optionalChain([j, 'optionalCall', _19 => _19(C)])};return document.addEventListener("fullscreenchange",P),()=>document.removeEventListener("fullscreenchange",P)},[j,c]),d.useEffect(()=>{let P=e.current;if(!P)return;let C=()=>{Mt(!0),_optionalChain([T, 'optionalCall', _20 => _20(!0)])},W=()=>{Mt(!1),_optionalChain([T, 'optionalCall', _21 => _21(!1)])};return P.addEventListener("enterpictureinpicture",C),P.addEventListener("leavepictureinpicture",W),()=>{P.removeEventListener("enterpictureinpicture",C),P.removeEventListener("leavepictureinpicture",W)}},[T,e]);let Te=d.useCallback(async()=>{e.current&&(z("play"),await e.current.play(),L("playing"),_optionalChain([t, 'optionalCall', _22 => _22(!0)]))},[e,t]),xe=d.useCallback(()=>{e.current&&(z("pause"),e.current.pause(),L("paused"),_optionalChain([t, 'optionalCall', _23 => _23(!1)]))},[e,t]),he=d.useCallback(async()=>{w==="playing"?xe():await Te()},[w,Te,xe]),Ce=d.useCallback(P=>{e.current&&(e.current.currentTime=P,gt(P),_optionalChain([m, 'optionalCall', _24 => _24(P)]))},[m,e]),Lt=d.useCallback(()=>{let P=e.current;!P||F.current||(F.current=!0,G.current=N==="play",le(!0),G.current&&!P.paused&&P.pause())},[N,e]),It=d.useCallback(()=>{let P=e.current;if(!P||!F.current)return;let C=G.current&&N==="play";if(F.current=!1,G.current=!1,!C){le(!1);return}P.play().then(()=>{L("playing"),le(!1)}).catch(()=>{L("waiting"),le(!1)})},[N,e]),Me=d.useCallback(P=>{let C=Math.max(0,Math.min(1,P));e.current&&(e.current.volume=C),D(C)},[D,e]),Ht=d.useCallback(()=>{if(!(U||x===0))A.current=x,e.current&&(e.current.muted=!0),se(!0);else{let C=A.current>0?A.current:1;e.current&&(e.current.volume=C,e.current.muted=!1),D(C),se(!1)}},[U,x,se,D,e]),Ee=d.useCallback(async()=>{_optionalChain([c, 'access', _25 => _25.current, 'optionalAccess', _26 => _26.requestFullscreen])&&await c.current.requestFullscreen()},[c]),Ve=d.useCallback(async()=>{document.exitFullscreen&&await document.exitFullscreen()},[]),we=d.useCallback(async()=>{ke?await Ve():await Ee()},[ke,Ee,Ve]),Be=d.useCallback(async()=>{_optionalChain([e, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.requestPictureInPicture])&&await e.current.requestPictureInPicture()},[e]),Le=d.useCallback(async()=>{document.pictureInPictureElement&&await document.exitPictureInPicture()},[]),Dt=d.useCallback(async()=>{ge?await Le():await Be()},[ge,Be,Le]),Ot=d.useCallback(P=>{e.current&&(e.current.playbackRate=P),Pt(P)},[Pt,e]),At=d.useCallback(P=>{if(e.current){for(let C=0;C<e.current.textTracks.length;C++){let W=e.current.textTracks[C];W&&(W.mode="disabled")}P&&(P.mode="hidden")}jr(P),ve([])},[e]),Ft=d.useCallback(P=>{qr(P)},[]),Wt=d.useCallback(P=>{st(C=>C.some(W=>W.id===P.id)?C:[...C,P])},[]),Qt=d.useCallback(P=>{st(C=>C.filter(W=>W.id!==P))},[]),$t=d.useCallback((P,C)=>{st(W=>W.map(oe=>oe.id===P?{...oe,textTrack:C}:oe))},[]);d.useEffect(()=>{if(!ne){ve([]);return}let P=()=>{let C=ne.activeCues;if(!C){ve([]);return}let W=[];for(let oe=0;oe<C.length;oe++){let er=C[oe];er instanceof VTTCue&&W.push(er)}ve(W)};return P(),ne.addEventListener("cuechange",P),()=>{ne.removeEventListener("cuechange",P)}},[ne]),d.useImperativeHandle(o,()=>({toggle:he,seek:Ce,setVolume:Me,toggleFullscreen:we}),[he,Ce,Me,we]);let Nt=d.useCallback(()=>{if(e.current){let P=e.current.currentTime;gt(P),_optionalChain([m, 'optionalCall', _29 => _29(P)])}},[m,e]),Ut=d.useCallback(()=>{e.current&&vt(e.current.duration)},[e]),_t=d.useCallback(()=>{e.current&&Nr(e.current.buffered)},[e]),jt=d.useCallback(()=>{z("play"),L("playing"),_optionalChain([t, 'optionalCall', _30 => _30(!0)])},[t]),qt=d.useCallback(()=>{F.current||w!=="ended"&&(L("paused"),_optionalChain([t, 'optionalCall', _31 => _31(!1)]))},[w,t]),Kt=d.useCallback(()=>{z("pause"),L("ended"),_optionalChain([t, 'optionalCall', _32 => _32(!1)]),_optionalChain([M, 'optionalCall', _33 => _33()])},[t,M]),Xt=d.useCallback(()=>{F.current||(L("waiting"),_optionalChain([V, 'optionalCall', _34 => _34()]))},[V]),Yt=d.useCallback(()=>{if(F.current){ht(!0);return}if(w==="waiting"){let P=N==="play"?"playing":"paused";L(P),_optionalChain([t, 'optionalCall', _35 => _35(P==="playing")])}ht(!0)},[w,N,t]),Gt=d.useCallback(()=>{le(!0),w==="ended"&&L("paused"),_optionalChain([O, 'optionalCall', _36 => _36()])},[w,O]),zt=d.useCallback(()=>{if(le(!1),e.current){let{currentTime:P,duration:C}=e.current;C>0&&C-P<.01&&L("ended")}_optionalChain([Y, 'optionalCall', _37 => _37()])},[Y,e]),Jt=d.useCallback(()=>{e.current&&(D(e.current.volume),se(e.current.muted))},[D,se,e]),Zt=d.useCallback(()=>{e.current&&vt(e.current.duration)},[e]),Kr=d.useMemo(()=>({playbackStatus:w,playbackIntent:N,playing:w==="playing",paused:w==="paused",ended:w==="ended",waiting:w==="waiting",seeking:Ct,canPlay:xt,currentTime:kt,duration:Se,buffered:Tt,hoverTime:be,hoverProgress:be!==null&&Se>0?be/Se*100:null,volume:x,muted:U,fullscreen:ke,pictureInPicture:ge,idle:bt,idleTimeout:h,preventIdleWhenPaused:v,registeredTracks:Et,activeTextTrack:ne,activeCues:Vt,playbackRate:Re,qualities:wt,activeQuality:Bt,videoRef:e,rootRef:c,play:Te,pause:xe,toggle:he,seek:Ce,setVolume:Me,toggleMute:Ht,enterFullscreen:Ee,exitFullscreen:Ve,toggleFullscreen:we,enterPictureInPicture:Be,exitPictureInPicture:Le,togglePictureInPicture:Dt,setPlaybackRate:Ot,setTextTrack:At,setQuality:Ft,registerTrack:Wt,unregisterTrack:Qt,updateTrackRef:$t,resetIdle:yt,setHoverTime:Ur,beginSeekInteraction:Lt,endSeekInteraction:It,_handlers:{onTimeUpdate:Nt,onDurationChange:Ut,onProgress:_t,onPlay:jt,onPause:qt,onEnded:Kt,onWaiting:Xt,onCanPlay:Yt,onSeeking:Gt,onSeeked:zt,onVolumeChange:Jt,onLoadedMetadata:Zt,onRootMouseLeave:St}}),[w,N,Ct,xt,kt,Se,Tt,be,x,U,ke,ge,bt,h,v,Et,ne,Vt,Re,wt,Bt,e,c,Te,xe,he,Ce,Me,Ht,Ee,Ve,we,Be,Le,Dt,Ot,At,Ft,Wt,Qt,$t,yt,Lt,It,Nt,Ut,_t,jt,qt,Kt,Xt,Yt,Gt,zt,Jt,Zt,St]);return _jsxruntime.jsx.call(void 0, lt.Provider,{value:Kr,children:Q})}var br=d.forwardRef(function(e,o){let{actionsRef:s,keyboardShortcuts:l="focused",defaultPlaying:u,defaultVolume:r,defaultMuted:a,defaultPlaybackRate:t,playing:i,onPlayingChange:p,volume:n,onVolumeChange:f,muted:S,onMutedChange:y,playbackRate:g,onPlaybackRateChange:m,currentTime:h,onCurrentTimeChange:v,idleTimeout:b,preventIdleWhenPaused:E,hideCursorWhenIdle:M="fullscreen",idle:V,onIdleChange:O,onEnded:Y,onWaiting:j,onSeeking:T,onSeeked:Q,onFullscreenChange:A,onPictureInPictureChange:F,children:G,...w}=e,L=d.useRef(null),N=d.useRef(null);return _jsxruntime.jsx.call(void 0, Pn,{actionsRef:s,defaultPlaying:u,defaultVolume:r,defaultMuted:a,defaultPlaybackRate:t,playing:i,onPlayingChange:p,volume:n,onVolumeChange:f,muted:S,onMutedChange:y,playbackRate:g,onPlaybackRateChange:m,currentTime:h,onCurrentTimeChange:v,idleTimeout:b,preventIdleWhenPaused:E,idle:V,onIdleChange:O,onEnded:Y,onWaiting:j,onSeeking:T,onSeeked:Q,onFullscreenChange:A,onPictureInPictureChange:F,rootRef:L,videoRef:N,children:_jsxruntime.jsx.call(void 0, Rn,{ref:o,rootRef:L,keyboardShortcuts:l,hideCursorWhenIdle:M,...w,children:G})})}),Rn=d.forwardRef(function({rootRef:e,keyboardShortcuts:o,hideCursorWhenIdle:s,children:l,className:u,style:r,...a},t){let i=ae(),p=yn(t,e),n=d.useRef(null);Sr(e,o);let f=d.useCallback(b=>{let{clientX:E,clientY:M}=b,V=n.current;V&&V.x===E&&V.y===M||(n.current={x:E,y:M},i.resetIdle())},[i]),S=d.useCallback(b=>{let{clientX:E,clientY:M}=b,V=n.current;V&&V.x===E&&V.y===M||(n.current={x:E,y:M},i.resetIdle())},[i]),y=d.useCallback(()=>{i._handlers.onRootMouseLeave()},[i._handlers]),g=d.useCallback(()=>{i.resetIdle()},[i]),m={"data-playing":i.playing||void 0,"data-paused":i.paused||void 0,"data-ended":i.ended||void 0,"data-waiting":i.waiting||void 0,"data-seeking":i.seeking||void 0,"data-fullscreen":i.fullscreen||void 0,"data-pip":i.pictureInPicture||void 0,"data-muted":i.muted||void 0,"data-idle":i.idle||void 0},h=s!==!1&&i.idle&&(s==="always"||s==="fullscreen"&&i.fullscreen),v=d.useId();return _jsxruntime.jsxs.call(void 0, "div",{ref:p,tabIndex:o==="focused"?0:void 0,className:u,style:r,"data-video-player-scope":v,...m,...a,onMouseMove:f,onMouseEnter:S,onMouseLeave:y,onClick:g,children:[h&&_jsxruntime.jsx.call(void 0, "style",{children:`[data-video-player-scope="${v}"], [data-video-player-scope="${v}"] * { cursor: none !important; }`}),l]})});function yn(...c){return d.useCallback(e=>{for(let o of c)typeof o=="function"?o(e):o!=null&&(o.current=e)},c)}var Ge=(r=>(r.progress="--seek-progress",r.buffered="--seek-buffered",r.currentTime="--seek-current-time",r.duration="--seek-duration",r.hoverProgress="--seek-hover-progress",r.hoverTime="--seek-hover-time",r))(Ge||{});var ze=(l=>(l.seeking="data-seeking",l.hovering="data-hovering",l.pressing="data-pressing",l.dragging="data-dragging",l))(ze||{});var _slider = require('@base-ui/react/slider');var _react2 = require('@floating-ui/react');var Je=(l=>(l.open="data-open",l.closed="data-closed",l.startingStyle="data-starting-style",l.endingStyle="data-ending-style",l))(Je||{});var ft=k.createContext(null);function vr(c){let e=k.useContext(ft);if(!e)throw new Error(`${c} must be used within SeekSlider`);return e}function kr(c){return c==="ArrowRight"||c==="ArrowLeft"}var Tr=k.forwardRef(function(e,o){let{render:s,children:l,onPointerMove:u,onPointerLeave:r,onPointerDown:a,onKeyUp:t,onValueCommitted:i,...p}=e,n=R("SeekSlider"),f=k.useRef(null),[S,y]=k.useState(null),[g,m]=k.useState(!1),[h,v]=k.useState(!1),b=k.useRef(!1);k.useEffect(()=>{if(!g)return;let x=()=>{m(!1),v(!1),b.current=!1,n.endSeekInteraction()};return window.addEventListener("pointerup",x),()=>window.removeEventListener("pointerup",x)},[g,n]);let E=n.duration>0?n.currentTime/n.duration*100:0,M=k.useCallback((x,D)=>{let U=typeof x=="number"?x:x[0];U!==void 0&&(D.reason==="keyboard"&&n.beginSeekInteraction(),n.seek(U),n.resetIdle(),b.current&&v(!0))},[n]),V=k.useCallback(x=>{if(_optionalChain([u, 'optionalCall', _38 => _38(x)]),!f.current||n.duration===0)return;let D=f.current.getBoundingClientRect(),U=x.clientX-D.left,Re=Math.max(0,Math.min(1,U/D.width))*n.duration;n.setHoverTime(Re)},[u,n]),O=k.useCallback(x=>{_optionalChain([r, 'optionalCall', _39 => _39(x)]),n.setHoverTime(null)},[r,n]),Y=k.useCallback(x=>{_optionalChain([a, 'optionalCall', _40 => _40(x)]),m(!0),b.current=!0,n.beginSeekInteraction()},[a,n]),j=k.useCallback(x=>{_optionalChain([t, 'optionalCall', _41 => _41(x)]),kr(x.key)&&n.endSeekInteraction()},[t,n]),T=k.useCallback((x,D)=>{let U=typeof x=="number"?x:x[0];U!==void 0&&(_optionalChain([i, 'optionalCall', _42 => _42(U,D)]),m(!1),v(!1),b.current=!1,!(D.reason==="keyboard"&&kr(D.event.key))&&n.endSeekInteraction())},[i,n]),Q=k.useMemo(()=>{if(!n.buffered||n.buffered.length===0)return 0;for(let x=0;x<n.buffered.length;x++)if(n.buffered.start(x)<=n.currentTime&&n.currentTime<=n.buffered.end(x))return n.buffered.end(x);return n.buffered.end(0)},[n.buffered,n.currentTime]),A=n.duration>0?Q/n.duration*100:0;k.useLayoutEffect(()=>{typeof o=="function"?o(f.current):o&&(o.current=f.current)});let F={currentTime:n.currentTime,duration:n.duration,progress:E,seeking:n.seeking,pressing:g,dragging:h,hoverTime:n.hoverTime,hoverProgress:n.hoverProgress},G=n.hoverProgress!==null,w=_nullishCoalesce(n.hoverProgress, () => (0)),L=k.useMemo(()=>({sliderRef:f,previewThumbElement:S,setPreviewThumbElement:y,hoverProgress:w,open:G}),[f,S,y,w,G]),N={position:"relative","--seek-progress":`${E}%`,"--seek-buffered":`${A}%`,"--seek-current-time":n.currentTime,"--seek-duration":n.duration,"--seek-hover-progress":n.hoverProgress!==null?`${n.hoverProgress}%`:void 0,"--seek-hover-time":_nullishCoalesce(n.hoverTime, () => (void 0)),...p.style},z={"data-seeking":n.seeking||void 0,"data-hovering":n.hoverTime!==null||void 0,"data-pressing":g||void 0,"data-dragging":h||void 0,style:N};return s?_jsxruntime.jsx.call(void 0, ft.Provider,{value:L,children:_jsxruntime.jsx.call(void 0, _slider.Slider.Root,{ref:f,min:0,max:n.duration||100,step:.1,value:n.currentTime,onValueChange:M,onValueCommitted:T,onPointerMove:V,onPointerLeave:O,onPointerDown:Y,onKeyUp:j,"aria-label":"Seek",render:x=>s({...x,...z,style:{...x.style,...z.style}},F)})}):_jsxruntime.jsx.call(void 0, ft.Provider,{value:L,children:_jsxruntime.jsx.call(void 0, _slider.Slider.Root,{ref:f,min:0,max:n.duration||100,step:.1,value:n.currentTime,onValueChange:M,onValueCommitted:T,onPointerMove:V,onPointerLeave:O,onPointerDown:Y,onKeyUp:j,"aria-label":"Seek",...z,...p,children:_nullishCoalesce(l, () => (_jsxruntime.jsx.call(void 0, _slider.Slider.Control,{children:_jsxruntime.jsxs.call(void 0, _slider.Slider.Track,{style:{position:"relative"},children:[_jsxruntime.jsx.call(void 0, "div",{style:{position:"absolute",left:0,top:0,height:"100%",width:`${A}%`}}),_jsxruntime.jsx.call(void 0, _slider.Slider.Indicator,{}),_jsxruntime.jsx.call(void 0, _slider.Slider.Thumb,{})]})})))})})}),xr=_slider.Slider.Control,hr=k.forwardRef(function(e,o){let{render:s,children:l,style:u,...r}=e,a={},t={position:"relative",...u},i={ref:o,style:t};return s?_jsxruntime.jsx.call(void 0, _slider.Slider.Track,{render:p=>s({...p,...i},a)}):_jsxruntime.jsx.call(void 0, _slider.Slider.Track,{ref:o,style:t,...r,children:l})}),Cr=k.forwardRef(function(e,o){let{render:s,children:l,style:u,...r}=e,a=R("SeekSliderProgress"),i={progress:a.duration>0?a.currentTime/a.duration*100:0},p={height:"100%",...u},n={ref:o,style:p};return s?_jsxruntime.jsx.call(void 0, _slider.Slider.Indicator,{render:f=>s({...f,...n,style:{...f.style,...p}},i)}):_jsxruntime.jsx.call(void 0, _slider.Slider.Indicator,{ref:o,style:p,...r,children:l})}),Mr=k.forwardRef(function(e,o){let{render:s,children:l,style:u,...r}=e,a={},t={ref:o,style:_nullishCoalesce(u, () => ({}))};return s?_jsxruntime.jsx.call(void 0, _slider.Slider.Thumb,{render:i=>s({...i,...t,style:{...i.style,...u}},a)}):_jsxruntime.jsx.call(void 0, _slider.Slider.Thumb,{ref:o,style:u,...r,children:l})}),Er=k.forwardRef(function(e,o){let{render:s,children:l,...u}=e,r=R("SeekSliderBuffered"),a=k.useMemo(()=>{if(!r.buffered||r.buffered.length===0)return 0;for(let f=0;f<r.buffered.length;f++)if(r.buffered.start(f)<=r.currentTime&&r.currentTime<=r.buffered.end(f))return r.buffered.end(f);return r.buffered.end(0)},[r.buffered,r.currentTime]),t=r.duration>0?a/r.duration*100:0,i={bufferedPercentage:t},p={position:"absolute",left:0,top:0,height:"100%",width:`${t}%`,...u.style},n={ref:o,style:p};return s?s(n,i):_jsxruntime.jsx.call(void 0, "div",{...n,...u,children:l})}),Vr=k.forwardRef(function(e,o){let{keepMounted:s=!1,render:l,children:u,...r}=e,a=R("SeekSliderPreviewThumb"),t=vr("SeekSliderPreviewThumb"),i=a.hoverProgress!==null,p=k.useRef(0);a.hoverProgress!==null&&(p.current=a.hoverProgress);let n=_nullishCoalesce(a.hoverProgress, () => (p.current)),{mounted:f,transitionStatus:S,elementRef:y}=K({open:i,keepMounted:s}),g=k.useCallback(b=>{y.current=b,t.setPreviewThumbElement(b),typeof o=="function"?o(b):o&&(o.current=b)},[o,y,t]),m={open:i,transitionStatus:S,hoverProgress:n},h={position:"absolute",left:`${n}%`,transform:"translateX(-50%)",pointerEvents:"none",...r.style},v={ref:g,style:h,"data-open":i||void 0,"data-closed":!i||void 0,"data-starting-style":S==="starting"||void 0,"data-ending-style":S==="ending"||void 0};return f?l?l(v,m):_jsxruntime.jsx.call(void 0, "span",{...v,...r,children:u}):null}),wr=k.forwardRef(function(e,o){let{render:s,children:l,style:u,...r}=e,a=R("SeekSliderHover"),t=a.hoverProgress!==null,i=_nullishCoalesce(a.hoverProgress, () => (0)),p={hovering:t,hoverProgress:a.hoverProgress,hoverTime:a.hoverTime},n={position:"absolute",left:0,top:0,height:"100%",width:`${i}%`,pointerEvents:"none",...u},f={ref:o,style:n,"data-hovering":t||void 0};return s?s(f,p):_jsxruntime.jsx.call(void 0, "div",{...f,...r,children:l})});function Ze({children:c,container:e}){let o=R("SeekSliderPreviewTooltipPortal"),[s,l]=k.useState(!1);if(k.useEffect(()=>{l(!0)},[]),!s)return null;let u=_nullishCoalesce(_nullishCoalesce(e, () => (o.rootRef.current)), () => (document.body));return gr.createPortal(c,u)}var et=k.forwardRef(function(e,o){let{sideOffset:s=8,collisionPadding:l=0,collisionBoundary:u,keepMounted:r=!1,children:a,style:t,...i}=e,p=vr("SeekSliderPreviewTooltipPositioner"),{previewThumbElement:n,open:f,hoverProgress:S}=p,[y,g]=k.useState(null),{refs:m,floatingStyles:h,update:v}=_react2.useFloating.call(void 0, {placement:"top",middleware:[_react2.offset.call(void 0, s),_react2.shift.call(void 0, {boundary:u,padding:l})]});k.useLayoutEffect(()=>{n&&m.setReference(n)},[n,m]),k.useEffect(()=>{if(f&&n&&y)return _react2.autoUpdate.call(void 0, n,y,v)},[f,n,y,v]),k.useLayoutEffect(()=>{f&&n&&y&&v()},[S,f,n,y,v]);let b=k.useCallback(M=>{m.setFloating(M),g(M),typeof o=="function"?o(M):o&&(o.current=M)},[m,o]);return(r||f)&&!!n?_jsxruntime.jsx.call(void 0, "div",{ref:b,style:{...h,...t},"data-seek-slider-preview-tooltip-positioner":!0,"data-open":f||void 0,"data-closed":!f||void 0,...i,children:a}):null}),tt=k.forwardRef(function(e,o){let{children:s,...l}=e;return _jsxruntime.jsx.call(void 0, "div",{ref:o,"data-seek-slider-preview-tooltip-popup":!0,...l,children:s})});function me({sideOffset:c,collisionPadding:e,collisionBoundary:o,keepMounted:s,container:l,children:u,...r}){return _jsxruntime.jsx.call(void 0, Ze,{container:l,children:_jsxruntime.jsx.call(void 0, et,{sideOffset:c,collisionPadding:e,collisionBoundary:o,keepMounted:s,children:_jsxruntime.jsx.call(void 0, tt,{...r,children:u})})})}me.Portal=Ze;me.Positioner=et;me.Popup=tt;var rt=(s=>(s.loading="data-loading",s.ready="data-ready",s.error="data-error",s))(rt||{});var Br=H.forwardRef(function(e,o){let{time:s,crossOrigin:l="anonymous",render:u,children:r,width:a,height:t,...i}=e,p=R("Thumbnail"),n=H.useRef(null),f=H.useRef(null),S=H.useRef(null),[y,g]=H.useState("idle"),[m,h]=H.useState({width:160,height:90}),v=s!==void 0?s:p.hoverTime,b=H.useMemo(()=>{let T=p.videoRef.current;return T?T.currentSrc||T.src:null},[p.videoRef]);H.useEffect(()=>{if(!b)return;let T=document.createElement("video");T.src=b,T.crossOrigin=l,T.preload="metadata",T.muted=!0,T.playsInline=!0;let Q=()=>{h({width:T.videoWidth,height:T.videoHeight})},A=()=>{g("error")};return T.addEventListener("loadedmetadata",Q),T.addEventListener("error",A),f.current=T,()=>{T.removeEventListener("loadedmetadata",Q),T.removeEventListener("error",A),T.src="",f.current=null}},[b,l]),H.useEffect(()=>{let T=f.current,Q=n.current;if(!T||!Q||v===null||v===void 0||S.current!==null&&Math.abs(S.current-v)<.1)return;g("loading");let A=()=>{let F=Q.getContext("2d");if(F)try{F.drawImage(T,0,0,Q.width,Q.height),S.current=v,g("ready")}catch (e2){g("error")}};return T.addEventListener("seeked",A,{once:!0}),T.currentTime=v,()=>{T.removeEventListener("seeked",A)}},[v]);let E=H.useCallback(T=>{n.current=T,typeof o=="function"?o(T):o&&(o.current=T)},[o]),M=m.width/m.height,V=_nullishCoalesce(a, () => (160)),O=_nullishCoalesce(t, () => (Math.round(V/M)));typeof V=="string"&&(V=160),typeof O=="string"&&(O=90);let Y={loading:y==="loading",ready:y==="ready",error:y==="error",time:v,videoWidth:m.width,videoHeight:m.height},j={ref:E,width:V,height:O,"data-loading":y==="loading"||void 0,"data-ready":y==="ready"||void 0,"data-error":y==="error"||void 0};return u?u(j,Y):_jsxruntime.jsx.call(void 0, "canvas",{...j,...i,children:r})});var nt=(e=>(e.hovering="data-hovering",e))(nt||{});var Lr=ot.forwardRef(function(e,o){let{format:s="current / duration",fixedWidth:l=!0,align:u="left",render:r,...a}=e,t=R("TimeDisplay"),i=ot.useRef(0);t.hoverTime!==null&&(i.current=t.hoverTime);let p=t.duration-t.currentTime,n=Pe(t.currentTime),f=Pe(t.duration),S=Pe(p),y=t.hoverTime!==null?Pe(t.hoverTime):Pe(i.current),g={currentTime:t.currentTime,duration:t.duration,remaining:p,hoverTime:t.hoverTime,hovering:t.hoverTime!==null,formattedCurrent:n,formattedDuration:f,formattedRemaining:S,formattedHover:y},m=()=>{switch(s){case"current":return n;case"duration":return f;case"remaining":return`-${S}`;case"current / duration":return`${n} / ${f}`;case"current / remaining":return`${n} / -${S}`;case"hover":return y;default:return`${n} / ${f}`}},h=()=>{let b=Cn(t.duration);switch(s){case"current":case"duration":case"hover":return b;case"remaining":return`-${b}`;case"current / duration":return`${b} / ${b}`;case"current / remaining":return`${b} / -${b}`;default:return`${b} / ${b}`}},v={ref:o,style:{position:l?"relative":void 0,userSelect:"none",fontVariantNumeric:"tabular-nums",...a.style},"data-hovering":g.hovering||void 0};return r?r(v,g):_jsxruntime.jsx.call(void 0, "span",{ref:o,"data-hovering":g.hovering||void 0,...a,style:{position:l?"relative":void 0,userSelect:"none",fontVariantNumeric:"tabular-nums",...a.style},children:l?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "span",{"aria-hidden":!0,style:{visibility:"hidden"},children:h()}),_jsxruntime.jsx.call(void 0, "span",{style:hn(u),children:m()})]}):m()})});function hn(c){let e={position:"absolute"};switch(c){case"left":return{...e,left:0};case"right":return{...e,right:0};case"center":return{...e,left:"50%",transform:"translateX(-50%)"}}}function Pe(c){if(!Number.isFinite(c)||Number.isNaN(c))return"0:00";let e=Math.floor(c/3600),o=Math.floor(c%3600/60),s=Math.floor(c%60);return e>0?`${e}:${o.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${o}:${s.toString().padStart(2,"0")}`}function Cn(c){if(!Number.isFinite(c)||Number.isNaN(c)||c<=0)return"0:00";let e=Math.floor(c/3600),o=Math.floor(c%3600/60);if(e>0){let l=String(e).length;return`${"0".repeat(l)}:00:00`}let s=String(o).length;return`${"0".repeat(s)}:00`}var Ir=_.forwardRef(function(e,o){let{kind:s="captions",src:l,label:u,srcLang:r,default:a,...t}=e,{registerTrack:i,unregisterTrack:p,updateTrackRef:n,setTextTrack:f}=R("Track"),S=_.useRef(null),y=_.useId(),g=_.useCallback(m=>{typeof o=="function"?o(m):o&&(o.current=m),S.current=m},[o]);return _.useEffect(()=>(i({id:y,kind:s,label:u,srcLang:r,src:l,textTrack:null}),()=>{p(y)}),[y,s,u,r,l,i,p]),_.useEffect(()=>{let m=S.current;if(!m)return;let h=()=>{m.track&&(m.track.mode="disabled",n(y,m.track),a&&f(m.track))};return m.track&&h(),m.addEventListener("load",h),()=>{m.removeEventListener("load",h)}},[y,a,n,f]),_jsxruntime.jsx.call(void 0, "track",{ref:g,kind:s,src:l,label:u,srcLang:r,default:a,...t})});var Hr=ie.forwardRef(function(e,o){let{toggleOnClick:s=!0,onClick:l,...u}=e,r=R("Video"),a=ie.useRef(!1),t=ie.useCallback(n=>{typeof o=="function"?o(n):o&&(o.current=n),r.videoRef.current=n,n&&!a.current&&(a.current=!0,n.readyState>=1&&n.duration&&(r._handlers.onLoadedMetadata(),r._handlers.onDurationChange()),n.readyState>=3&&r._handlers.onCanPlay())},[o,r.videoRef,r._handlers]),i=ie.useCallback(n=>{_optionalChain([l, 'optionalCall', _43 => _43(n)]),!n.defaultPrevented&&s&&r.toggle()},[l,s,r]),p={"data-playing":r.playing||void 0,"data-paused":r.paused||void 0,"data-ended":r.ended||void 0,"data-waiting":r.waiting||void 0,"data-seeking":r.seeking||void 0};return _jsxruntime.jsx.call(void 0, "video",{ref:t,preload:"metadata",...p,...u,onClick:i,onTimeUpdate:r._handlers.onTimeUpdate,onDurationChange:r._handlers.onDurationChange,onProgress:r._handlers.onProgress,onPlay:r._handlers.onPlay,onPause:r._handlers.onPause,onEnded:r._handlers.onEnded,onWaiting:r._handlers.onWaiting,onCanPlay:r._handlers.onCanPlay,onSeeking:r._handlers.onSeeking,onSeeked:r._handlers.onSeeked,onVolumeChange:r._handlers.onVolumeChange,onLoadedMetadata:r._handlers.onLoadedMetadata})});var at=(o=>(o.volume="--volume",o.volumePercentage="--volume-percentage",o))(at||{});var it=(l=>(l.muted="data-muted",l.volume="data-volume",l.pressing="data-pressing",l.dragging="data-dragging",l))(it||{});var Dr=I.forwardRef(function(e,o){let{render:s,children:l,onPointerDown:u,...r}=e,a=R("VolumeSlider"),t=I.useRef(null),[i,p]=I.useState(!1),[n,f]=I.useState(!1),S=I.useRef(!1);I.useEffect(()=>{if(!i)return;let M=()=>{p(!1),f(!1),S.current=!1};return window.addEventListener("pointerup",M),()=>window.removeEventListener("pointerup",M)},[i]),I.useLayoutEffect(()=>{typeof o=="function"?o(t.current):o&&(o.current=t.current)});let y=a.volume*100,g={volume:a.volume,muted:a.muted,percentage:y,pressing:i,dragging:n},m=I.useCallback(M=>{let V=typeof M=="number"?M:M[0];if(V!==void 0){if(a.muted){let O=a.videoRef.current;O&&(O.muted=!1)}a.setVolume(V),a.resetIdle(),S.current&&f(!0)}},[a]),h=I.useCallback(M=>{_optionalChain([u, 'optionalCall', _44 => _44(M)]),p(!0),S.current=!0},[u]),v={"data-muted":a.muted||void 0,"data-volume":a.volume,"data-pressing":i||void 0,"data-dragging":n||void 0},b={position:"relative","--volume":a.volume,"--volume-percentage":`${y}%`,...r.style},E={"data-muted":a.muted||void 0,"data-volume":a.volume,"data-pressing":i||void 0,"data-dragging":n||void 0,style:b};return s?_jsxruntime.jsx.call(void 0, _slider.Slider.Root,{ref:t,min:0,max:1,step:.01,value:a.muted?0:a.volume,onValueChange:m,onPointerDown:h,"aria-label":"Volume",render:M=>s({...M,...E},g)}):_jsxruntime.jsx.call(void 0, _slider.Slider.Root,{ref:t,min:0,max:1,step:.01,value:a.muted?0:a.volume,onValueChange:m,onPointerDown:h,"aria-label":"Volume",...v,...r,style:b,children:_nullishCoalesce(l, () => (_jsxruntime.jsx.call(void 0, _slider.Slider.Control,{children:_jsxruntime.jsxs.call(void 0, _slider.Slider.Track,{children:[_jsxruntime.jsx.call(void 0, _slider.Slider.Indicator,{}),_jsxruntime.jsx.call(void 0, _slider.Slider.Thumb,{})]})})))})}),Or=_slider.Slider.Control,Ar=I.forwardRef(function(e,o){let{style:s,...l}=e,u={position:"relative",...s};return _jsxruntime.jsx.call(void 0, _slider.Slider.Track,{ref:o,style:u,...l})}),Fr=I.forwardRef(function(e,o){return _jsxruntime.jsx.call(void 0, _slider.Slider.Indicator,{ref:o,...e})}),Wr=I.forwardRef(function(e,o){return _jsxruntime.jsx.call(void 0, _slider.Slider.Thumb,{ref:o,...e})});exports.VideoPlayer = Qr; exports.useVideoPlayer = ae;
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/video-player/index.cjs","../../src/video-player/contexts/video-player-context.ts","../../src/video-player/hooks/use-video-player.ts","../../src/video-player/index.parts.ts","../../src/video-player/components/buffered-indicator/buffered-indicator.tsx","../../src/video-player/hooks/use-transition-status.ts"],"names":["VideoPlayerContext","useVideoPlayerContext","component","context","useVideoPlayer","index_parts_exports","__export","BufferedIndicator","Captions","CaptionsButton","CaptionsDataAttributes","CaptionsMenu","CaptionsMenuItem","Controls","ControlsDataAttributes","FullscreenButton","MuteButton","Overlay","OverlayDataAttributes","PictureInPictureButton","PlayButton","PlaybackRateButton","PlaybackRateMenu","PlaybackRateMenuItem","Portal","Poster","QualityMenu","QualityMenuItem","VideoPlayerRoot","RootDataAttributes","SeekSlider","SeekSliderBuffered","SeekSliderControl","SeekSliderCssVars","SeekSliderDataAttributes","SeekSliderHover","SeekSliderPreviewThumb","SeekSliderPreviewThumbDataAttributes","SeekSliderPreviewTooltip","SeekSliderPreviewTooltipPopup","SeekSliderPreviewTooltipPortal","SeekSliderPreviewTooltipPositioner","SeekSliderProgress","SeekSliderThumb","SeekSliderTrack","Thumbnail","ThumbnailDataAttributes","TimeDisplay","TimeDisplayDataAttributes","Track","Video","VolumeSlider","VolumeSliderControl","VolumeSliderCssVars","VolumeSliderDataAttributes","VolumeSliderRange","VolumeSliderThumb","VolumeSliderTrack","useTransitionStatus","props","forwardedRef","render","divProps","bufferedEnd","i","bufferedPercentage","state","style"],"mappings":"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","file":"/Users/kianbazza/repos/bazzalabs/ui/packages/react/dist/video-player/index.cjs","sourcesContent":[null,"'use client'\n\nimport * as React from 'react'\nimport type { VideoPlayerContextValue } from '../types.js'\n\nexport const VideoPlayerContext =\n React.createContext<VideoPlayerContextValue | null>(null)\n\nexport function useVideoPlayerContext(\n component: string,\n): VideoPlayerContextValue {\n const context = React.useContext(VideoPlayerContext)\n if (!context) {\n throw new Error(\n `<VideoPlayer.${component}> must be used within <VideoPlayer.Root>`,\n )\n }\n return context\n}\n","'use client'\n\nimport { useVideoPlayerContext } from '../contexts/video-player-context.js'\nimport type { VideoPlayerContextValue } from '../types.js'\n\n/**\n * Hook to access the VideoPlayer context from custom components.\n *\n * @example\n * ```tsx\n * function CustomControl() {\n * const { playing, toggle, currentTime, duration } = useVideoPlayer()\n *\n * return (\n * <div>\n * {playing ? 'Playing' : 'Paused'} - {currentTime}s / {duration}s\n * <button onClick={toggle}>Toggle</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useVideoPlayer(): VideoPlayerContextValue {\n return useVideoPlayerContext('useVideoPlayer')\n}\n","// ============================================================================\n// VideoPlayer Composable Parts\n// ============================================================================\n//\n// Import like: import * as VideoPlayer from './video-player/index.parts.js'\n//\n// Usage:\n// <VideoPlayer.Root>\n// <VideoPlayer.Video src=\"...\" />\n// <VideoPlayer.Controls>\n// <VideoPlayer.PlayButton />\n// <VideoPlayer.SeekSlider />\n// <VideoPlayer.TimeDisplay />\n// </VideoPlayer.Controls>\n// </VideoPlayer.Root>\n//\n\nexport { BufferedIndicator } from './components/buffered-indicator/buffered-indicator.js'\nexport { CaptionsDataAttributes } from './components/captions/captions.data-attributes.js'\nexport { Captions } from './components/captions/captions.js'\n// Captions\nexport { CaptionsButton } from './components/captions-button/captions-button.js'\nexport {\n CaptionsMenu,\n CaptionsMenuItem,\n} from './components/captions-menu/captions-menu.js'\nexport { ControlsDataAttributes } from './components/controls/controls.data-attributes.js'\nexport { Controls } from './components/controls/controls.js'\n// Display Controls\nexport { FullscreenButton } from './components/fullscreen-button/fullscreen-button.js'\nexport { MuteButton } from './components/mute-button/mute-button.js'\nexport { OverlayDataAttributes } from './components/overlay/overlay.data-attributes.js'\nexport { Overlay } from './components/overlay/overlay.js'\nexport { PictureInPictureButton } from './components/picture-in-picture-button/picture-in-picture-button.js'\n// Playback Controls\nexport { PlayButton } from './components/play-button/play-button.js'\n// Playback Rate\nexport { PlaybackRateButton } from './components/playback-rate-button/playback-rate-button.js'\nexport {\n PlaybackRateMenu,\n PlaybackRateMenuItem,\n} from './components/playback-rate-menu/playback-rate-menu.js'\n// Layout\nexport { Portal } from './components/portal/portal.js'\nexport { Poster } from './components/poster/poster.js'\n// Quality\nexport {\n QualityMenu,\n QualityMenuItem,\n} from './components/quality-menu/quality-menu.js'\n// Data Attributes & CSS Variables\nexport { RootDataAttributes } from './components/root/root.data-attributes.js'\n// Core\nexport { VideoPlayerRoot as Root } from './components/root/root.js'\nexport { SeekSliderCssVars } from './components/seek-slider/seek-slider.css-vars.js'\nexport { SeekSliderDataAttributes } from './components/seek-slider/seek-slider.data-attributes.js'\nexport {\n SeekSlider,\n SeekSliderBuffered,\n SeekSliderControl,\n SeekSliderHover,\n SeekSliderPreviewThumb,\n SeekSliderPreviewTooltip,\n SeekSliderPreviewTooltipPopup,\n SeekSliderPreviewTooltipPortal,\n SeekSliderPreviewTooltipPositioner,\n SeekSliderProgress,\n SeekSliderThumb,\n SeekSliderTrack,\n} from './components/seek-slider/seek-slider.js'\nexport { SeekSliderPreviewThumbDataAttributes } from './components/seek-slider/seek-slider-preview-thumb.data-attributes.js'\nexport { ThumbnailDataAttributes } from './components/thumbnail/thumbnail.data-attributes.js'\nexport { Thumbnail } from './components/thumbnail/thumbnail.js'\nexport { TimeDisplayDataAttributes } from './components/time-display/time-display.data-attributes.js'\nexport { TimeDisplay } from './components/time-display/time-display.js'\nexport { Track } from './components/track/track.js'\nexport { Video } from './components/video/video.js'\nexport { VolumeSliderCssVars } from './components/volume-slider/volume-slider.css-vars.js'\nexport { VolumeSliderDataAttributes } from './components/volume-slider/volume-slider.data-attributes.js'\n// Audio Controls\nexport {\n VolumeSlider,\n VolumeSliderControl,\n VolumeSliderRange,\n VolumeSliderThumb,\n VolumeSliderTrack,\n} from './components/volume-slider/volume-slider.js'\nexport {\n type TransitionStatus,\n type UseTransitionStatusOptions,\n type UseTransitionStatusReturn,\n useTransitionStatus,\n} from './hooks/use-transition-status.js'\n// Hooks\nexport { useVideoPlayer } from './hooks/use-video-player.js'\n// Types\nexport type {\n PlaybackIntent,\n PlaybackStatus,\n RenderProp,\n TrackInfo,\n VideoPlayerActions,\n VideoPlayerContextValue,\n VideoPlayerRootProps,\n VideoPlayerState,\n VideoQuality,\n VideoTextTrack,\n} from './types.js'\n","'use client'\n\nimport * as React from 'react'\nimport { useVideoPlayerContext } from '../../contexts/video-player-context.js'\nimport type { RenderProp } from '../../types.js'\n\n// ============================================================================\n// BufferedIndicator Props\n// ============================================================================\n\nexport interface BufferedIndicatorProps\n extends React.ComponentPropsWithRef<'div'> {\n render?: RenderProp<BufferedIndicatorRenderProps, BufferedIndicatorState>\n}\n\nexport interface BufferedIndicatorRenderProps {\n ref: React.Ref<HTMLElement>\n style: React.CSSProperties\n 'aria-hidden': true\n}\n\nexport interface BufferedIndicatorState {\n buffered: TimeRanges | null\n duration: number\n bufferedPercentage: number\n bufferedEnd: number\n}\n\n// ============================================================================\n// BufferedIndicator Component\n// ============================================================================\n\nexport const BufferedIndicator = React.forwardRef<\n HTMLDivElement,\n BufferedIndicatorProps\n>(function BufferedIndicator(props, forwardedRef) {\n const { render, ...divProps } = props\n const context = useVideoPlayerContext('BufferedIndicator')\n\n // Calculate buffered end position (for progress bar display)\n const bufferedEnd = React.useMemo(() => {\n if (!context.buffered || context.buffered.length === 0) return 0\n\n // Find the buffer range that contains current playback position\n for (let i = 0; i < context.buffered.length; i++) {\n if (\n context.buffered.start(i) <= context.currentTime &&\n context.currentTime <= context.buffered.end(i)\n ) {\n return context.buffered.end(i)\n }\n }\n\n // Fallback to end of first range\n return context.buffered.end(0)\n }, [context.buffered, context.currentTime])\n\n const bufferedPercentage =\n context.duration > 0 ? (bufferedEnd / context.duration) * 100 : 0\n\n const state: BufferedIndicatorState = {\n buffered: context.buffered,\n duration: context.duration,\n bufferedPercentage,\n bufferedEnd,\n }\n\n // CSS custom properties for styling\n const style = {\n '--buffered-percentage': `${bufferedPercentage}%`,\n '--buffered-end': bufferedEnd,\n ...divProps.style,\n } as React.CSSProperties\n\n const renderProps: BufferedIndicatorRenderProps = {\n ref: forwardedRef,\n style,\n 'aria-hidden': true,\n }\n\n if (render) {\n return render(renderProps, state)\n }\n\n return (\n <div ref={forwardedRef} aria-hidden=\"true\" {...divProps} style={style} />\n )\n})\n\n// ============================================================================\n// Namespace\n// ============================================================================\n\nexport namespace BufferedIndicator {\n export type Props = BufferedIndicatorProps\n export type State = BufferedIndicatorState\n}\n","'use client'\n\nimport * as React from 'react'\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport type TransitionStatus = 'starting' | 'ending' | undefined\n\nexport interface UseTransitionStatusOptions {\n /**\n * Whether the element should be visible/open.\n */\n open: boolean\n /**\n * Keep the element always mounted in the DOM, even when closed.\n * Only needed for JavaScript animation libraries (e.g., Framer Motion).\n * CSS transitions and animations work automatically without this.\n * @default false\n */\n keepMounted?: boolean\n}\n\nexport interface UseTransitionStatusReturn {\n /**\n * Whether the element should be rendered in the DOM.\n * Stays true during exit animations.\n */\n mounted: boolean\n /**\n * Current transition status:\n * - 'starting': First frame of enter animation\n * - 'ending': Exit animation in progress\n * - undefined: Idle state\n */\n transitionStatus: TransitionStatus\n /**\n * Ref to attach to the animated element.\n * Used to detect when CSS animations/transitions complete.\n */\n elementRef: React.RefObject<HTMLElement | null>\n}\n\n// ============================================================================\n// Utility: Wait for Animations\n// ============================================================================\n\n/**\n * Returns a promise that resolves when all CSS animations and transitions\n * on the element and its descendants have completed.\n */\nfunction waitForAnimations(element: HTMLElement): Promise<void> {\n // Collect animations from the element and all descendants\n const animations = [\n ...element.getAnimations(),\n ...Array.from(element.querySelectorAll('*')).flatMap((el) =>\n (el as HTMLElement).getAnimations(),\n ),\n ]\n\n if (animations.length === 0) {\n return Promise.resolve()\n }\n return Promise.all(animations.map((a) => a.finished))\n .then(() => {})\n .catch(() => {\n // Animation was cancelled (e.g., element removed or animation interrupted)\n })\n}\n\n// ============================================================================\n// Hook: useTransitionStatus\n// ============================================================================\n\nexport function useTransitionStatus(\n options: UseTransitionStatusOptions,\n): UseTransitionStatusReturn {\n const { open, keepMounted = false } = options\n\n const [mounted, setMounted] = React.useState(open || keepMounted)\n const [transitionStatus, setTransitionStatus] =\n React.useState<TransitionStatus>(open ? 'starting' : undefined)\n\n const elementRef = React.useRef<HTMLElement | null>(null)\n\n // Track if we're currently waiting for animations\n const waitingForAnimationsRef = React.useRef(false)\n\n // Handle open → true (enter)\n React.useEffect(() => {\n if (open) {\n // Cancel any pending exit\n waitingForAnimationsRef.current = false\n\n setMounted(true)\n setTransitionStatus('starting')\n\n // Clear starting style after first paint (double RAF for reliability)\n const raf = requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n setTransitionStatus(undefined)\n })\n })\n\n return () => cancelAnimationFrame(raf)\n }\n }, [open])\n\n // Handle open → false (exit)\n React.useEffect(() => {\n if (!open && mounted && !waitingForAnimationsRef.current) {\n setTransitionStatus('ending')\n\n const element = elementRef.current\n\n if (!element) {\n // No element ref, unmount immediately\n setTransitionStatus(undefined)\n if (!keepMounted) {\n setMounted(false)\n }\n return\n }\n\n waitingForAnimationsRef.current = true\n\n // Wait a frame for the browser to process style changes and start animations\n const raf = requestAnimationFrame(() => {\n // Double RAF for reliability (like enter animation)\n requestAnimationFrame(() => {\n waitForAnimations(element).then(() => {\n // Check if we're still supposed to be unmounting\n // (user might have re-opened during animation)\n if (!waitingForAnimationsRef.current) return\n\n waitingForAnimationsRef.current = false\n setTransitionStatus(undefined)\n\n if (!keepMounted) {\n setMounted(false)\n }\n })\n })\n })\n\n return () => {\n cancelAnimationFrame(raf)\n }\n }\n }, [open, mounted, keepMounted])\n\n // Handle keepMounted change\n React.useEffect(() => {\n if (keepMounted && !mounted && !open) {\n setMounted(true)\n }\n }, [keepMounted, mounted, open])\n\n return {\n mounted: mounted || keepMounted,\n transitionStatus,\n elementRef,\n }\n}\n"]}
|