@glitchlab/react-video-player 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -99,7 +99,7 @@ No client-component wrapper required.
99
99
  | `className` | `string` | `""` | Extra class added to the outer container (alongside `.gvp-root`). |
100
100
  | `muted` | `boolean` | `true` | Mute the video. Required for autoplay in most browsers. |
101
101
  | `loop` | `boolean` | `false` | Loop playback. |
102
- | `controls` | `boolean \| "custom"` | `false` | `false` — no controls (just the play overlay). `true` — native browser controls. `"custom"` — branded control bar (play/seek/time/speed/captions/volume/PiP/fullscreen) that auto-hides during playback. See [Custom controls](#custom-controls). |
102
+ | `controls` | `boolean \| "custom" \| "native"` | `true` | `true` (default) / `"custom"` — branded control bar (play/seek/time/speed/captions/volume/PiP/fullscreen) that auto-hides during playback. `"native"` — native browser controls. `false` — no controls (just the play overlay). See [Custom controls](#custom-controls). |
103
103
  | `autoPlay` | `boolean` | `false` | Start playback as soon as the source is ready. Works for HLS (after `MANIFEST_PARSED`), native MP4/WebM (after `loadedmetadata`), and YouTube embeds. Browsers block sound-on autoplay, so this only fires when `muted` is also `true` (the default). |
104
104
  | `frameMaxWidth` | `{ desktop?: string; mobile?: string }` | `{ desktop: "960px", mobile: "420px" }` | Max width of the player in each device mode. |
105
105
  | `aspectRatio` | `{ desktop?: AspectRatio; mobile?: AspectRatio }` | `{ desktop: "16/9", mobile: "9/16" }` | Aspect ratio per device mode. `AspectRatio` is `` `${number}/${number}` ``. |
@@ -110,10 +110,20 @@ No client-component wrapper required.
110
110
 
111
111
  ## Custom controls
112
112
 
113
- Set `controls="custom"` for a branded control bar that looks and behaves the same across every browser and OS no more inconsistent native chrome:
113
+ The branded control bar is **on by default** — it looks and behaves the same across every browser and OS, no inconsistent native chrome:
114
114
 
115
115
  ```tsx
116
+ {/* Custom control bar — this is the default, controls={true} */}
117
+ <ReactVideoPlayer src="/videos/movie.m3u8" />
118
+
119
+ {/* Same thing, explicit */}
116
120
  <ReactVideoPlayer src="/videos/movie.m3u8" controls="custom" />
121
+
122
+ {/* Native browser controls instead */}
123
+ <ReactVideoPlayer src="/videos/movie.m3u8" controls="native" />
124
+
125
+ {/* No controls at all */}
126
+ <ReactVideoPlayer src="/videos/movie.m3u8" controls={false} />
117
127
  ```
118
128
 
119
129
  The bar includes, left to right:
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
1
  "use client";
2
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("react"),H=require("hls.js");function z(e){var n,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var u=e.length;for(n=0;n<u;n++)e[n]&&(s=z(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function M(){for(var e,n,s=0,r="",u=arguments.length;s<u;s++)(e=arguments[s])&&(n=z(e))&&(r&&(r+=" "),r+=n);return r}const _="gvp-icon",w=e=>e?`${_} ${e}`:_,de=({className:e})=>t.jsxs("svg",{className:w(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M14 2H10C6.72077 2 5.08116 2 3.91891 2.81382C3.48891 3.1149 3.1149 3.48891 2.81382 3.91891C2 5.08116 2 6.72077 2 10C2 13.2792 2 14.9188 2.81382 16.0811C3.1149 16.5111 3.48891 16.8851 3.91891 17.1862C5.08116 18 6.72077 18 10 18H14C17.2792 18 18.9188 18 20.0811 17.1862C20.5111 16.8851 20.8851 16.5111 21.1862 16.0811C22 14.9188 22 13.2792 22 10C22 6.72077 22 5.08116 21.1862 3.91891C20.8851 3.48891 20.5111 3.1149 20.0811 2.81382C18.9188 2 17.2792 2 14 2Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M11 15H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M14.5 22L14.1845 21.5811C13.4733 20.6369 13.2969 19.1944 13.7468 18M9.5 22L9.8155 21.5811C10.5267 20.6369 10.7031 19.1944 10.2532 18",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M7 22H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),he=({className:e})=>t.jsxs("svg",{className:w(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M5 9C5 5.70017 5 4.05025 6.02513 3.02513C7.05025 2 8.70017 2 12 2C15.2998 2 16.9497 2 17.9749 3.02513C19 4.05025 19 5.70017 19 9V15C19 18.2998 19 19.9497 17.9749 20.9749C16.9497 22 15.2998 22 12 22C8.70017 22 7.05025 22 6.02513 20.9749C5 19.9497 5 18.2998 5 15V9Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),t.jsx("path",{d:"M11 19H13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9 2L9.089 2.53402C9.28188 3.69129 9.37832 4.26993 9.77519 4.62204C10.1892 4.98934 10.7761 5 12 5C13.2239 5 13.8108 4.98934 14.2248 4.62204C14.6217 4.26993 14.7181 3.69129 14.911 2.53402L15 2",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})]}),me=({className:e})=>t.jsx("svg",{className:w(e),width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M6.94994 5.53594L12.1929 0.292938C12.5834 -0.0975275 13.2165 -0.0975279 13.6069 0.292938C13.9974 0.683403 13.9974 1.31647 13.6069 1.70694L8.36394 6.94994L13.6069 12.1929C13.9974 12.5834 13.9974 13.2165 13.6069 13.6069C13.2165 13.9974 12.5834 13.9974 12.1929 13.6069L6.94994 8.36394L1.70694 13.6069C1.31647 13.9974 0.683403 13.9974 0.292938 13.6069C-0.0975279 13.2165 -0.0975277 12.5834 0.292938 12.1929L5.53594 6.94994L0.292938 1.70694C-0.0975279 1.31647 -0.0975279 0.683403 0.292938 0.292938C0.683403 -0.0975279 1.31647 -0.0975277 1.70694 0.292938L6.94994 5.53594Z",fill:"currentColor"})}),pe=({className:e})=>t.jsx("svg",{className:w(e),width:"22",height:"22",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M5.3335 11.45V4.54997C5.3335 4.36108 5.40016 4.20275 5.5335 4.07497C5.66683 3.94719 5.82238 3.8833 6.00016 3.8833C6.05572 3.8833 6.11405 3.89163 6.17516 3.9083C6.23627 3.92497 6.29461 3.94997 6.35016 3.9833L11.7835 7.4333C11.8835 7.49997 11.9585 7.5833 12.0085 7.6833C12.0585 7.7833 12.0835 7.88886 12.0835 7.99997C12.0835 8.11108 12.0585 8.21663 12.0085 8.31663C11.9585 8.41663 11.8835 8.49997 11.7835 8.56663L6.35016 12.0166C6.29461 12.05 6.23627 12.075 6.17516 12.0916C6.11405 12.1083 6.05572 12.1166 6.00016 12.1166C5.82238 12.1166 5.66683 12.0527 5.5335 11.925C5.40016 11.7972 5.3335 11.6389 5.3335 11.45Z",fill:"currentColor"})}),fe=({className:e})=>t.jsxs("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ge=({className:e})=>t.jsx("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M7 5.5V18.5C7 19.2659 7.84856 19.7261 8.4899 19.3071L19.0801 12.4014C19.6644 12.0204 19.6644 11.9796 19.0801 11.5986L8.4899 4.69288C7.84856 4.27388 7 4.73408 7 5.5Z",fill:"currentColor"})}),ve=({className:e})=>t.jsxs("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"}),t.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"})]}),xe=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ke=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),be=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16 9L22 15M22 9L16 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),we=({className:e})=>t.jsx("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M4 9V4H9M15 4H20V9M20 15V20H15M9 20H4V15",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),Ce=({className:e})=>t.jsx("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M9 4V9H4M15 9V4H20M15 20V15H20M9 15H4V20",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),je=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("rect",{x:"12",y:"12",width:"8",height:"5",rx:"1",fill:"currentColor"})]}),Le=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"3",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M7 12H11M13 12H17M7 15H9M11 15H13M15 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ee=({className:e})=>t.jsxs("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2Z",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),ye=({className:e})=>t.jsx("svg",{className:w(e),width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M6 9L12 15L18 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});function q(e){if(!Number.isFinite(e)||e<0)return"--:--";const n=Math.floor(e),s=Math.floor(n/3600),r=Math.floor(n%3600/60),d=(n%60).toString().padStart(2,"0");if(s>0){const c=r.toString().padStart(2,"0");return`${s}:${c}:${d}`}return`${r}:${d}`}const F=(()=>{if(typeof navigator>"u")return!1;const e=navigator.userAgent;return/iPad|iPhone|iPod/.test(e)||e.includes("Mac")&&navigator.maxTouchPoints>1})(),U=typeof navigator>"u"?!1:/iPhone|iPod/.test(navigator.userAgent),Ne=3e3,P={isSupported(){return typeof document>"u"?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)},element(){return typeof document>"u"?null:document.fullscreenElement??document.webkitFullscreenElement??null},request(e){const n=e.requestFullscreen??e.webkitRequestFullscreen;return n?n.call(e):Promise.reject(new Error("Fullscreen not supported"))},exit(){const e=document.exitFullscreen??document.webkitExitFullscreen;return e?e.call(document):Promise.reject(new Error("Fullscreen not supported"))},onChange(e){return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e)}}},Se=({video:e,isPlaying:n,container:s,onTogglePlay:r})=>{const[u,d]=o.useState(!0),c=o.useRef(null),l=o.useCallback(()=>{c.current!==null&&(clearTimeout(c.current),c.current=null)},[]),i=o.useCallback(()=>{l(),n&&(c.current=setTimeout(()=>d(!1),Ne))},[l,n]),f=o.useCallback(()=>{d(!0),i()},[i]);return o.useEffect(()=>{if(!n){l(),d(!0);return}return i(),l},[n,i,l]),o.useEffect(()=>{if(!s)return;const g=()=>f();return s.addEventListener("mousemove",g),s.addEventListener("touchstart",g),s.addEventListener("focusin",g),()=>{s.removeEventListener("mousemove",g),s.removeEventListener("touchstart",g),s.removeEventListener("focusin",g)}},[s,f]),o.useEffect(()=>{if(!s||!e)return;const g=a=>{if(!(!s.contains(document.activeElement)||a.target.tagName==="INPUT"&&a.key!==" "))switch(a.key){case" ":case"k":a.preventDefault(),r(),f();break;case"ArrowLeft":a.preventDefault(),e.currentTime=Math.max(0,e.currentTime-5),f();break;case"ArrowRight":a.preventDefault(),e.currentTime=Math.min(e.duration||0,e.currentTime+5),f();break;case"ArrowUp":a.preventDefault(),e.volume=Math.min(1,e.volume+.1),e.muted&&(e.muted=!1),f();break;case"ArrowDown":a.preventDefault(),e.volume=Math.max(0,e.volume-.1),f();break;case"m":e.muted=!e.muted,f();break;case"f":P.element()===s?P.exit().catch(()=>{}):P.request(s).catch(()=>{}),f();break;case"p":document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):document.pictureInPictureEnabled&&e.requestPictureInPicture().catch(()=>{}),f();break}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s,e,r,f]),t.jsx("div",{role:"toolbar","aria-label":"Video controls",className:M("gvp-controls",!u&&"is-hidden"),onMouseEnter:l,onMouseLeave:i,children:t.jsxs("div",{className:"gvp-controls-row",children:[t.jsx(Me,{isPlaying:n,onToggle:r}),t.jsx(Pe,{video:e}),t.jsx(Te,{video:e}),t.jsx(Ve,{video:e}),t.jsx(Re,{video:e}),t.jsx(Ie,{video:e}),t.jsx(Be,{video:e}),t.jsx(De,{container:s,video:e})]})})},Me=({isPlaying:e,onToggle:n})=>t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":e?"Pause":"Play","aria-pressed":e,onClick:n,children:e?t.jsx(ve,{}):t.jsx(ge,{})}),Pe=({video:e})=>{const[n,s]=o.useState(0),[r,u]=o.useState(0),[d,c]=o.useState(0);o.useEffect(()=>{if(!e)return;const a=()=>s(e.currentTime),p=()=>u(Number.isFinite(e.duration)?e.duration:0),v=()=>{const h=e.buffered;if(!h||h.length===0){c(0);return}let x=h.end(h.length-1);for(let b=0;b<h.length;b++)if(h.start(b)<=e.currentTime&&e.currentTime<=h.end(b)){x=h.end(b);break}c(x)};return a(),p(),v(),e.addEventListener("timeupdate",a),e.addEventListener("durationchange",p),e.addEventListener("loadedmetadata",p),e.addEventListener("progress",v),e.addEventListener("timeupdate",v),()=>{e.removeEventListener("timeupdate",a),e.removeEventListener("durationchange",p),e.removeEventListener("loadedmetadata",p),e.removeEventListener("progress",v),e.removeEventListener("timeupdate",v)}},[e]);const l=r>0,i=l?n/r*100:0,f=l?d/r*100:0,g=a=>{if(!e||!l)return;const p=Number(a.target.value)/100*r;e.currentTime=p,s(p)};return t.jsxs("div",{className:"gvp-seek",children:[t.jsxs("div",{className:"gvp-seek-track",children:[t.jsx("div",{className:"gvp-seek-buffered",style:{width:`${f}%`}}),t.jsx("div",{className:"gvp-seek-progress",style:{width:`${i}%`}})]}),t.jsx("input",{type:"range",className:"gvp-seek-input",min:0,max:100,step:.1,value:i,onChange:g,disabled:!l,"aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(r),"aria-valuenow":Math.floor(n)})]})},Te=({video:e})=>{const[n,s]=o.useState(0),[r,u]=o.useState(0);return o.useEffect(()=>{if(!e)return;const d=()=>s(e.currentTime),c=()=>u(Number.isFinite(e.duration)?e.duration:0);return d(),c(),e.addEventListener("timeupdate",d),e.addEventListener("durationchange",c),e.addEventListener("loadedmetadata",c),()=>{e.removeEventListener("timeupdate",d),e.removeEventListener("durationchange",c),e.removeEventListener("loadedmetadata",c)}},[e]),t.jsxs("span",{className:"gvp-time","aria-live":"off",children:[q(n)," / ",q(r)]})},Ie=({video:e})=>{const[n,s]=o.useState(1),[r,u]=o.useState(!1);o.useEffect(()=>{if(!e)return;const f=()=>{s(e.volume),u(e.muted)};return f(),e.addEventListener("volumechange",f),()=>e.removeEventListener("volumechange",f)},[e]);const d=()=>{e&&(e.muted=!e.muted)},c=f=>{if(!e)return;const g=Number(f.target.value)/100;e.volume=g,g>0&&e.muted&&(e.muted=!1)};let l=xe;r||n===0?l=be:n<.5&&(l=ke);const i=r?0:Math.round(n*100);return t.jsxs("div",{className:M("gvp-volume",!F&&"is-expandable"),children:[t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":r?"Unmute":"Mute","aria-pressed":r,onClick:d,children:t.jsx(l,{})}),!F&&t.jsxs("div",{className:"gvp-volume-slider-wrap",children:[t.jsx("div",{className:"gvp-volume-track",children:t.jsx("div",{className:"gvp-volume-fill",style:{width:`${i}%`}})}),t.jsx("input",{type:"range",className:"gvp-volume-input",min:0,max:100,step:1,value:i,onChange:c,"aria-label":"Volume","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i})]})]})},He=[.5,.75,1,1.25,1.5,2],Ve=({video:e})=>{const[n,s]=o.useState(1),[r,u]=o.useState(!1),d=o.useRef(null);o.useEffect(()=>{if(!e)return;const i=()=>s(e.playbackRate);return i(),e.addEventListener("ratechange",i),()=>e.removeEventListener("ratechange",i)},[e]),o.useEffect(()=>{if(!r)return;const i=g=>{d.current&&!d.current.contains(g.target)&&u(!1)},f=g=>{g.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",i),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",f)}},[r]);const c=i=>{e&&(e.playbackRate=i),s(i),u(!1)},l=n===1?"1×":`${n}×`;return t.jsxs("div",{className:"gvp-speed",ref:d,children:[t.jsxs("button",{type:"button",className:"gvp-ctrl-btn gvp-speed-btn","aria-haspopup":"listbox","aria-expanded":r,"aria-label":`Playback speed: ${l}`,onClick:()=>u(i=>!i),children:[t.jsx(Ee,{}),t.jsx("span",{className:"gvp-speed-label",children:l})]}),r&&t.jsx("ul",{className:"gvp-speed-menu",role:"listbox","aria-label":"Playback speed",children:He.map(i=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":i===n,className:M("gvp-speed-menu-item",i===n&&"is-active"),onClick:()=>c(i),children:i===1?"Normal":`${i}×`})},i))})]})},Re=({video:e})=>{const[n,s]=o.useState([]),[r,u]=o.useState(-1),[d,c]=o.useState(!1),l=o.useRef(null),i=o.useCallback(a=>{const p=[];for(let h=0;h<a.length;h++){const x=a[h];(x.kind==="subtitles"||x.kind==="captions")&&p.push({index:h,label:x.label||x.language||`Track ${h+1}`,language:x.language})}s(p);let v=-1;for(let h=0;h<a.length;h++)if(a[h].mode==="showing"){v=h;break}u(v)},[]);o.useEffect(()=>{if(!e){s([]),u(-1);return}const a=e.textTracks;i(a);const p=()=>i(a);return a.addEventListener("addtrack",p),a.addEventListener("removetrack",p),a.addEventListener("change",p),()=>{a.removeEventListener("addtrack",p),a.removeEventListener("removetrack",p),a.removeEventListener("change",p)}},[e,i]),o.useEffect(()=>{if(!d)return;const a=v=>{l.current&&!l.current.contains(v.target)&&c(!1)},p=v=>{v.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",a),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",p)}},[d]);const f=a=>{if(!e)return;const p=e.textTracks;for(let v=0;v<p.length;v++)p[v].mode=v===a?"showing":"hidden";u(a),c(!1)},g=()=>{if(!e)return;const a=e.textTracks;for(let p=0;p<a.length;p++)a[p].mode="hidden";u(-1),c(!1)};return n.length===0?null:t.jsxs("div",{className:"gvp-captions",ref:l,children:[t.jsx("button",{type:"button",className:M("gvp-ctrl-btn",r>=0&&"is-active"),"aria-haspopup":"listbox","aria-expanded":d,"aria-label":"Captions","aria-pressed":r>=0,onClick:()=>c(a=>!a),children:t.jsx(Le,{})}),d&&t.jsxs("ul",{className:"gvp-captions-menu",role:"listbox","aria-label":"Captions",children:[t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":r===-1,className:M("gvp-captions-menu-item",r===-1&&"is-active"),onClick:g,children:"Off"})}),n.map(a=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":a.index===r,className:M("gvp-captions-menu-item",a.index===r&&"is-active"),onClick:()=>f(a.index),children:a.label})},a.index))]})]})},Be=({video:e})=>{const[n,s]=o.useState(!1);if(o.useEffect(()=>{if(!e)return;const u=()=>s(!0),d=()=>s(!1);return e.addEventListener("enterpictureinpicture",u),e.addEventListener("leavepictureinpicture",d),()=>{e.removeEventListener("enterpictureinpicture",u),e.removeEventListener("leavepictureinpicture",d)}},[e]),!document.pictureInPictureEnabled)return null;const r=()=>{document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):e==null||e.requestPictureInPicture().catch(()=>{})};return t.jsx("button",{type:"button",className:M("gvp-ctrl-btn",n&&"is-active"),"aria-label":n?"Exit picture-in-picture":"Picture-in-picture","aria-pressed":n,onClick:r,children:t.jsx(je,{})})},De=({container:e,video:n})=>{const[s,r]=o.useState(!1);if(o.useEffect(()=>{if(U)return;const i=()=>r(P.element()===e);return i(),P.onChange(i)},[e]),!(P.isSupported()||U&&n!==null&&typeof n.webkitEnterFullscreen=="function"))return null;const d=()=>{var i;if(U){(i=n==null?void 0:n.webkitEnterFullscreen)==null||i.call(n);return}s?P.exit().catch(()=>{}):e&&P.request(e).catch(()=>{})},c=s?Ce:we,l=s?"Exit fullscreen":"Enter fullscreen";return t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":l,"aria-pressed":s,onClick:d,children:t.jsx(c,{})})};function Y(e,n,s){const r=e==null?void 0:e.trim();if(r)return r;if(n){try{const d=new Intl.DisplayNames(void 0,{type:"language"}).of(n);if(d&&d!==n)return d}catch{}return n}return`Audio ${s+1}`}const K=o.forwardRef(({src:e,hlsConfig:n,isHls:s,autoPlay:r,children:u,onAudioTracks:d,audioTrackIndex:c,...l},i)=>{const f=o.useRef(null),g=o.useRef(null),a=o.useRef(d);a.current=d,o.useImperativeHandle(i,()=>f.current);const p=globalThis.window!==void 0&&H.isSupported(),v=!!s||p&&typeof e=="string"&&e.endsWith(".m3u8");return o.useEffect(()=>{var y,V,T;if(!e)return;const h=f.current;if(!h)return;const x=m=>{var C;(C=a.current)==null||C.call(a,m)},b=()=>{r&&h.play().catch(()=>{})};for(g.current&&(g.current.destroy(),g.current=null),h.pause(),h.removeAttribute("src");h.firstChild;)h.firstChild.remove();x([]);let L;if(v){const m=new H(n);g.current=m;const C=()=>{const E=m.audioTracks.map((k,N)=>({index:N,label:Y(k.name,k.lang,N),lang:k.lang||void 0}));x(E)};m.on(H.Events.MANIFEST_PARSED,b),m.on(H.Events.AUDIO_TRACKS_UPDATED,C),m.on(H.Events.AUDIO_TRACK_SWITCHED,C),m.on(H.Events.ERROR,(E,k)=>{k.fatal&&(m.destroy(),g.current=null)}),m.attachMedia(h),m.loadSource(e)}else{h.src=e,h.load(),h.addEventListener("loadedmetadata",b,{once:!0});const m=h.audioTracks;if(m){const C=()=>{const E=[];for(let k=0;k<m.length;k++){const N=m[k];E.push({index:k,label:Y(N.label,N.language,k),lang:N.language||void 0})}x(E)};(y=m.addEventListener)==null||y.call(m,"addtrack",C),(V=m.addEventListener)==null||V.call(m,"removetrack",C),(T=m.addEventListener)==null||T.call(m,"change",C),m.length>0&&C(),L=()=>{var E,k,N;(E=m.removeEventListener)==null||E.call(m,"addtrack",C),(k=m.removeEventListener)==null||k.call(m,"removetrack",C),(N=m.removeEventListener)==null||N.call(m,"change",C)}}}return()=>{for(h.removeEventListener("loadedmetadata",b),L==null||L(),g.current&&(g.current.destroy(),g.current=null),h.pause(),h.removeAttribute("src");h.firstChild;)h.firstChild.remove();h.load(),x([])}},[e,v,n,r]),o.useEffect(()=>{var b;if(c==null||c<0)return;const h=g.current;if(h){h.audioTrack!==c&&(h.audioTrack=c);return}const x=(b=f.current)==null?void 0:b.audioTracks;if(x)for(let L=0;L<x.length;L++)x[L].enabled=L===c},[c]),t.jsx("video",{ref:f,...l,children:u})});K.displayName="HLSPlayer";function J(e){if(!e)return null;if(/^[A-Za-z0-9_-]{11}$/.test(e))return e;let n;try{n=new URL(e)}catch{return null}const s=n.hostname.replace(/^www\./,"");if(s==="youtu.be"){const r=n.pathname.slice(1).split("/")[0];return/^[A-Za-z0-9_-]{11}$/.test(r)?r:null}if(s==="youtube.com"||s==="m.youtube.com"||s==="music.youtube.com"||s==="youtube-nocookie.com"){const r=n.searchParams.get("v");if(r&&/^[A-Za-z0-9_-]{11}$/.test(r))return r;const u=/^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(n.pathname);if(u)return u[1]}return null}function X(e){try{const n=new URL(e),s=n.searchParams.get("t")??n.searchParams.get("start");if(!s)return null;if(/^\d+s?$/.test(s))return Number.parseInt(s,10);const r=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(s);if(r){const u=Number.parseInt(r[1]??"0",10),d=Number.parseInt(r[2]??"0",10),c=Number.parseInt(r[3]??"0",10),l=u*3600+d*60+c;return l>0?l:null}}catch{}return null}function G(e,n={}){const{autoPlay:s=!1,muted:r=!0,loop:u=!1,controls:d=!0,startSeconds:c}=n,l=new URLSearchParams({rel:"0",modestbranding:"1",playsinline:"1",controls:d?"1":"0"});return s?(l.set("autoplay","1"),l.set("mute","1")):r&&l.set("mute","1"),u&&(l.set("loop","1"),l.set("playlist",e)),c&&c>0&&l.set("start",String(c)),`https://www.youtube-nocookie.com/embed/${e}?${l.toString()}`}const Ae=({tracks:e,activeIndex:n,onSelect:s})=>{const[r,u]=o.useState(!1),d=o.useRef(null);o.useEffect(()=>{if(!r)return;const l=f=>{d.current&&!d.current.contains(f.target)&&u(!1)},i=f=>{f.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",i)}},[r]);const c=e.find(l=>l.index===n)??e[0];return t.jsxs("div",{className:"gvp-audio",ref:d,children:[t.jsxs("button",{type:"button",className:"gvp-audio-btn","aria-haspopup":"listbox","aria-expanded":r,"aria-label":"Audio track",onClick:()=>u(l=>!l),children:[t.jsx(fe,{}),t.jsx("span",{className:"gvp-audio-label",children:c==null?void 0:c.label}),t.jsx(ye,{})]}),r&&t.jsx("ul",{className:"gvp-audio-menu",role:"listbox","aria-label":"Audio tracks",children:e.map(l=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":l.index===n,className:M("gvp-audio-menu-item",l.index===n&&"is-active"),onClick:()=>{s(l.index),u(!1)},children:l.label})},l.index))})]})},$e=({src:e,poster:n,showDeviceToggle:s=!0,defaultDevice:r="desktop",hoverPlay:u=!1,tooltipText:d,onClose:c,className:l="",muted:i=!0,loop:f=!1,controls:g=!1,autoPlay:a=!1,frameMaxWidth:p,aspectRatio:v,hlsConfig:h,children:x})=>{const b=o.useRef(null),L=o.useRef(null),[y,V]=o.useState(r),[T,m]=o.useState(!1),[C,E]=o.useState(!1),[k,N]=o.useState([]),[A,Z]=o.useState(-1),[Q,ee]=o.useState(null),[te,ne]=o.useState(null),re=o.useCallback(j=>{b.current=j,ne(j)},[]),I=g==="custom",$=g===!0,R=o.useMemo(()=>J(e),[e]),S=R!==null,se=o.useMemo(()=>y==="mobile"?(v==null?void 0:v.mobile)??"9/16":(v==null?void 0:v.desktop)??"16/9",[y,v]),oe=o.useMemo(()=>y==="mobile"?(p==null?void 0:p.mobile)??"420px":(p==null?void 0:p.desktop)??"960px",[y,p]),ae=o.useMemo(()=>R?G(R,{autoPlay:a,muted:i,loop:f,controls:I?!0:$,startSeconds:X(e)}):null,[R,e,a,i,f,I,$]),le=o.useCallback(j=>{N(j),Z(-1)},[]),B=o.useCallback(async()=>{const j=b.current;if(j){if(L.current)try{await L.current}catch{}j.pause()}},[]),D=o.useCallback(async()=>{const j=b.current;if(j)try{j.readyState<2&&j.load();const O=j.play();L.current=O,await O,m(!0)}catch{m(!1)}finally{L.current=null}},[]),ie=o.useCallback(()=>{!u||S||D()},[u,S,D]),ce=o.useCallback(()=>{!u||S||B().then(()=>m(!1))},[u,S,B]),W=o.useCallback(async()=>{const j=b.current;j&&(j.paused?await D():(await B(),m(!1)))},[D,B]),ue=!S&&k.length>1;return t.jsxs("div",{ref:ee,className:M("gvp-root",l),style:{width:oe,aspectRatio:se},onMouseEnter:()=>{E(!0),ie()},onMouseLeave:()=>{E(!1),ce()},children:[S?t.jsx("iframe",{className:"gvp-video gvp-youtube",src:ae??void 0,title:"YouTube video player",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"}):t.jsx(K,{ref:re,src:e,poster:n,muted:i,loop:f,playsInline:!0,preload:"metadata",controls:$,autoPlay:a,hlsConfig:h,className:"gvp-video",onPlay:()=>m(!0),onPause:()=>m(!1),onAudioTracks:le,audioTrackIndex:A,children:x}),!S&&t.jsx("div",{className:"gvp-vignette"}),s&&t.jsx("div",{className:"gvp-toggle",children:t.jsxs("div",{className:"gvp-toggle-pill",children:[t.jsx("button",{type:"button",onClick:()=>V("desktop"),className:M("gvp-toggle-btn",y==="desktop"&&"is-active"),"aria-label":"Desktop view","aria-pressed":y==="desktop",children:t.jsx(de,{})}),t.jsx("div",{className:"gvp-toggle-divider"}),t.jsx("button",{type:"button",onClick:()=>V("mobile"),className:M("gvp-toggle-btn",y==="mobile"&&"is-active"),"aria-label":"Mobile view","aria-pressed":y==="mobile",children:t.jsx(he,{})})]})}),c&&t.jsx("button",{type:"button",onClick:c,className:"gvp-close","aria-label":"Close",children:t.jsx(me,{})}),ue&&t.jsx(Ae,{tracks:k,activeIndex:A>=0?A:k[0].index,onSelect:Z}),!S&&I&&t.jsx("button",{type:"button",className:"gvp-click-layer",onClick:()=>void W(),"aria-label":T?"Pause":"Play"}),!S&&!I&&!T&&t.jsx("div",{className:"gvp-play-wrap",children:t.jsxs("button",{type:"button",onClick:()=>void W(),onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),className:"gvp-play","aria-label":"Play",children:[t.jsx(pe,{}),d&&C&&t.jsx("span",{className:"gvp-tooltip",role:"tooltip",children:d})]})}),!S&&I&&t.jsx(Se,{video:te,isPlaying:T,container:Q,onTogglePlay:()=>void W()}),!S&&!I&&t.jsx("div",{className:"gvp-bottom-fade"})]})};exports.ReactVideoPlayer=$e;exports.parseYouTubeId=J;exports.parseYouTubeStart=X;exports.youTubeEmbedUrl=G;
2
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),o=require("react"),H=require("hls.js");function z(e){var n,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var u=e.length;for(n=0;n<u;n++)e[n]&&(s=z(e[n]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function M(){for(var e,n,s=0,r="",u=arguments.length;s<u;s++)(e=arguments[s])&&(n=z(e))&&(r&&(r+=" "),r+=n);return r}const _="gvp-icon",w=e=>e?`${_} ${e}`:_,de=({className:e})=>t.jsxs("svg",{className:w(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M14 2H10C6.72077 2 5.08116 2 3.91891 2.81382C3.48891 3.1149 3.1149 3.48891 2.81382 3.91891C2 5.08116 2 6.72077 2 10C2 13.2792 2 14.9188 2.81382 16.0811C3.1149 16.5111 3.48891 16.8851 3.91891 17.1862C5.08116 18 6.72077 18 10 18H14C17.2792 18 18.9188 18 20.0811 17.1862C20.5111 16.8851 20.8851 16.5111 21.1862 16.0811C22 14.9188 22 13.2792 22 10C22 6.72077 22 5.08116 21.1862 3.91891C20.8851 3.48891 20.5111 3.1149 20.0811 2.81382C18.9188 2 17.2792 2 14 2Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M11 15H13",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M14.5 22L14.1845 21.5811C13.4733 20.6369 13.2969 19.1944 13.7468 18M9.5 22L9.8155 21.5811C10.5267 20.6369 10.7031 19.1944 10.2532 18",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),t.jsx("path",{d:"M7 22H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),he=({className:e})=>t.jsxs("svg",{className:w(e),width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M5 9C5 5.70017 5 4.05025 6.02513 3.02513C7.05025 2 8.70017 2 12 2C15.2998 2 16.9497 2 17.9749 3.02513C19 4.05025 19 5.70017 19 9V15C19 18.2998 19 19.9497 17.9749 20.9749C16.9497 22 15.2998 22 12 22C8.70017 22 7.05025 22 6.02513 20.9749C5 19.9497 5 18.2998 5 15V9Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),t.jsx("path",{d:"M11 19H13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M9 2L9.089 2.53402C9.28188 3.69129 9.37832 4.26993 9.77519 4.62204C10.1892 4.98934 10.7761 5 12 5C13.2239 5 13.8108 4.98934 14.2248 4.62204C14.6217 4.26993 14.7181 3.69129 14.911 2.53402L15 2",stroke:"currentColor",strokeWidth:"2",strokeLinejoin:"round"})]}),pe=({className:e})=>t.jsx("svg",{className:w(e),width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M6.94994 5.53594L12.1929 0.292938C12.5834 -0.0975275 13.2165 -0.0975279 13.6069 0.292938C13.9974 0.683403 13.9974 1.31647 13.6069 1.70694L8.36394 6.94994L13.6069 12.1929C13.9974 12.5834 13.9974 13.2165 13.6069 13.6069C13.2165 13.9974 12.5834 13.9974 12.1929 13.6069L6.94994 8.36394L1.70694 13.6069C1.31647 13.9974 0.683403 13.9974 0.292938 13.6069C-0.0975279 13.2165 -0.0975277 12.5834 0.292938 12.1929L5.53594 6.94994L0.292938 1.70694C-0.0975279 1.31647 -0.0975279 0.683403 0.292938 0.292938C0.683403 -0.0975279 1.31647 -0.0975277 1.70694 0.292938L6.94994 5.53594Z",fill:"currentColor"})}),me=({className:e})=>t.jsx("svg",{className:w(e),width:"22",height:"22",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M5.3335 11.45V4.54997C5.3335 4.36108 5.40016 4.20275 5.5335 4.07497C5.66683 3.94719 5.82238 3.8833 6.00016 3.8833C6.05572 3.8833 6.11405 3.89163 6.17516 3.9083C6.23627 3.92497 6.29461 3.94997 6.35016 3.9833L11.7835 7.4333C11.8835 7.49997 11.9585 7.5833 12.0085 7.6833C12.0585 7.7833 12.0835 7.88886 12.0835 7.99997C12.0835 8.11108 12.0585 8.21663 12.0085 8.31663C11.9585 8.41663 11.8835 8.49997 11.7835 8.56663L6.35016 12.0166C6.29461 12.05 6.23627 12.075 6.17516 12.0916C6.11405 12.1083 6.05572 12.1166 6.00016 12.1166C5.82238 12.1166 5.66683 12.0527 5.5335 11.925C5.40016 11.7972 5.3335 11.6389 5.3335 11.45Z",fill:"currentColor"})}),fe=({className:e})=>t.jsxs("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ge=({className:e})=>t.jsx("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M7 5.5V18.5C7 19.2659 7.84856 19.7261 8.4899 19.3071L19.0801 12.4014C19.6644 12.0204 19.6644 11.9796 19.0801 11.5986L8.4899 4.69288C7.84856 4.27388 7 4.73408 7 5.5Z",fill:"currentColor"})}),ve=({className:e})=>t.jsxs("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"6",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"}),t.jsx("rect",{x:"14",y:"5",width:"4",height:"14",rx:"1",fill:"currentColor"})]}),xe=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16M19 5.5C20.5 7 21.5 9.5 21.5 12C21.5 14.5 20.5 17 19 18.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),ke=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16.5 8C17.5 9 18 10.5 18 12C18 13.5 17.5 15 16.5 16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),be=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M3 14V10C3 9.44772 3.44772 9 4 9H6.58579C6.851 9 7.10536 8.89464 7.29289 8.70711L11.2929 4.70711C11.9229 4.07714 13 4.52331 13 5.41421V18.5858C13 19.4767 11.9229 19.9229 11.2929 19.2929L7.29289 15.2929C7.10536 15.1054 6.851 15 6.58579 15H4C3.44772 15 3 14.5523 3 14Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round"}),t.jsx("path",{d:"M16 9L22 15M22 9L16 15",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),we=({className:e})=>t.jsx("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M4 9V4H9M15 4H20V9M20 15V20H15M9 20H4V15",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),Ce=({className:e})=>t.jsx("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M9 4V9H4M15 9V4H20M15 20V15H20M9 15H4V20",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round"})}),je=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("rect",{x:"12",y:"12",width:"8",height:"5",rx:"1",fill:"currentColor"})]}),Le=({className:e})=>t.jsxs("svg",{className:w(e),width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("rect",{x:"2",y:"5",width:"20",height:"14",rx:"3",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M7 12H11M13 12H17M7 15H9M11 15H13M15 15H17",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]}),Ee=({className:e})=>t.jsxs("svg",{className:w(e),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[t.jsx("path",{d:"M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2Z",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M12 8V12L14.5 14.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),ye=({className:e})=>t.jsx("svg",{className:w(e),width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:t.jsx("path",{d:"M6 9L12 15L18 9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})});function q(e){if(!Number.isFinite(e)||e<0)return"--:--";const n=Math.floor(e),s=Math.floor(n/3600),r=Math.floor(n%3600/60),d=(n%60).toString().padStart(2,"0");if(s>0){const c=r.toString().padStart(2,"0");return`${s}:${c}:${d}`}return`${r}:${d}`}const F=(()=>{if(typeof navigator>"u")return!1;const e=navigator.userAgent;return/iPad|iPhone|iPod/.test(e)||e.includes("Mac")&&navigator.maxTouchPoints>1})(),U=typeof navigator>"u"?!1:/iPhone|iPod/.test(navigator.userAgent),Ne=3e3,P={isSupported(){return typeof document>"u"?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)},element(){return typeof document>"u"?null:document.fullscreenElement??document.webkitFullscreenElement??null},request(e){const n=e.requestFullscreen??e.webkitRequestFullscreen;return n?n.call(e):Promise.reject(new Error("Fullscreen not supported"))},exit(){const e=document.exitFullscreen??document.webkitExitFullscreen;return e?e.call(document):Promise.reject(new Error("Fullscreen not supported"))},onChange(e){return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e)}}},Se=({video:e,isPlaying:n,container:s,onTogglePlay:r})=>{const[u,d]=o.useState(!0),c=o.useRef(null),l=o.useCallback(()=>{c.current!==null&&(clearTimeout(c.current),c.current=null)},[]),i=o.useCallback(()=>{l(),n&&(c.current=setTimeout(()=>d(!1),Ne))},[l,n]),f=o.useCallback(()=>{d(!0),i()},[i]);return o.useEffect(()=>{if(!n){l(),d(!0);return}return i(),l},[n,i,l]),o.useEffect(()=>{if(!s)return;const g=()=>f();return s.addEventListener("mousemove",g),s.addEventListener("touchstart",g),s.addEventListener("focusin",g),()=>{s.removeEventListener("mousemove",g),s.removeEventListener("touchstart",g),s.removeEventListener("focusin",g)}},[s,f]),o.useEffect(()=>{if(!s||!e)return;const g=a=>{if(!(!s.contains(document.activeElement)||a.target.tagName==="INPUT"&&a.key!==" "))switch(a.key){case" ":case"k":a.preventDefault(),r(),f();break;case"ArrowLeft":a.preventDefault(),e.currentTime=Math.max(0,e.currentTime-5),f();break;case"ArrowRight":a.preventDefault(),e.currentTime=Math.min(e.duration||0,e.currentTime+5),f();break;case"ArrowUp":a.preventDefault(),e.volume=Math.min(1,e.volume+.1),e.muted&&(e.muted=!1),f();break;case"ArrowDown":a.preventDefault(),e.volume=Math.max(0,e.volume-.1),f();break;case"m":e.muted=!e.muted,f();break;case"f":P.element()===s?P.exit().catch(()=>{}):P.request(s).catch(()=>{}),f();break;case"p":document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):document.pictureInPictureEnabled&&e.requestPictureInPicture().catch(()=>{}),f();break}};return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[s,e,r,f]),t.jsx("div",{role:"toolbar","aria-label":"Video controls",className:M("gvp-controls",!u&&"is-hidden"),onMouseEnter:l,onMouseLeave:i,children:t.jsxs("div",{className:"gvp-controls-row",children:[t.jsx(Me,{isPlaying:n,onToggle:r}),t.jsx(Pe,{video:e}),t.jsx(Te,{video:e}),t.jsx(Ve,{video:e}),t.jsx(Re,{video:e}),t.jsx(Ie,{video:e}),t.jsx(Be,{video:e}),t.jsx(De,{container:s,video:e})]})})},Me=({isPlaying:e,onToggle:n})=>t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":e?"Pause":"Play","aria-pressed":e,onClick:n,children:e?t.jsx(ve,{}):t.jsx(ge,{})}),Pe=({video:e})=>{const[n,s]=o.useState(0),[r,u]=o.useState(0),[d,c]=o.useState(0);o.useEffect(()=>{if(!e)return;const a=()=>s(e.currentTime),m=()=>u(Number.isFinite(e.duration)?e.duration:0),v=()=>{const h=e.buffered;if(!h||h.length===0){c(0);return}let x=h.end(h.length-1);for(let b=0;b<h.length;b++)if(h.start(b)<=e.currentTime&&e.currentTime<=h.end(b)){x=h.end(b);break}c(x)};return a(),m(),v(),e.addEventListener("timeupdate",a),e.addEventListener("durationchange",m),e.addEventListener("loadedmetadata",m),e.addEventListener("progress",v),e.addEventListener("timeupdate",v),()=>{e.removeEventListener("timeupdate",a),e.removeEventListener("durationchange",m),e.removeEventListener("loadedmetadata",m),e.removeEventListener("progress",v),e.removeEventListener("timeupdate",v)}},[e]);const l=r>0,i=l?n/r*100:0,f=l?d/r*100:0,g=a=>{if(!e||!l)return;const m=Number(a.target.value)/100*r;e.currentTime=m,s(m)};return t.jsxs("div",{className:"gvp-seek",children:[t.jsxs("div",{className:"gvp-seek-track",children:[t.jsx("div",{className:"gvp-seek-buffered",style:{width:`${f}%`}}),t.jsx("div",{className:"gvp-seek-progress",style:{width:`${i}%`}})]}),t.jsx("input",{type:"range",className:"gvp-seek-input",min:0,max:100,step:.1,value:i,onChange:g,disabled:!l,"aria-label":"Seek","aria-valuemin":0,"aria-valuemax":Math.floor(r),"aria-valuenow":Math.floor(n)})]})},Te=({video:e})=>{const[n,s]=o.useState(0),[r,u]=o.useState(0);return o.useEffect(()=>{if(!e)return;const d=()=>s(e.currentTime),c=()=>u(Number.isFinite(e.duration)?e.duration:0);return d(),c(),e.addEventListener("timeupdate",d),e.addEventListener("durationchange",c),e.addEventListener("loadedmetadata",c),()=>{e.removeEventListener("timeupdate",d),e.removeEventListener("durationchange",c),e.removeEventListener("loadedmetadata",c)}},[e]),t.jsxs("span",{className:"gvp-time","aria-live":"off",children:[q(n)," / ",q(r)]})},Ie=({video:e})=>{const[n,s]=o.useState(1),[r,u]=o.useState(!1);o.useEffect(()=>{if(!e)return;const f=()=>{s(e.volume),u(e.muted)};return f(),e.addEventListener("volumechange",f),()=>e.removeEventListener("volumechange",f)},[e]);const d=()=>{e&&(e.muted=!e.muted)},c=f=>{if(!e)return;const g=Number(f.target.value)/100;e.volume=g,g>0&&e.muted&&(e.muted=!1)};let l=xe;r||n===0?l=be:n<.5&&(l=ke);const i=r?0:Math.round(n*100);return t.jsxs("div",{className:M("gvp-volume",!F&&"is-expandable"),children:[t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":r?"Unmute":"Mute","aria-pressed":r,onClick:d,children:t.jsx(l,{})}),!F&&t.jsxs("div",{className:"gvp-volume-slider-wrap",children:[t.jsx("div",{className:"gvp-volume-track",children:t.jsx("div",{className:"gvp-volume-fill",style:{width:`${i}%`}})}),t.jsx("input",{type:"range",className:"gvp-volume-input",min:0,max:100,step:1,value:i,onChange:c,"aria-label":"Volume","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":i})]})]})},He=[.5,.75,1,1.25,1.5,2],Ve=({video:e})=>{const[n,s]=o.useState(1),[r,u]=o.useState(!1),d=o.useRef(null);o.useEffect(()=>{if(!e)return;const i=()=>s(e.playbackRate);return i(),e.addEventListener("ratechange",i),()=>e.removeEventListener("ratechange",i)},[e]),o.useEffect(()=>{if(!r)return;const i=g=>{d.current&&!d.current.contains(g.target)&&u(!1)},f=g=>{g.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",i),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",f)}},[r]);const c=i=>{e&&(e.playbackRate=i),s(i),u(!1)},l=n===1?"1×":`${n}×`;return t.jsxs("div",{className:"gvp-speed",ref:d,children:[t.jsxs("button",{type:"button",className:"gvp-ctrl-btn gvp-speed-btn","aria-haspopup":"listbox","aria-expanded":r,"aria-label":`Playback speed: ${l}`,onClick:()=>u(i=>!i),children:[t.jsx(Ee,{}),t.jsx("span",{className:"gvp-speed-label",children:l})]}),r&&t.jsx("ul",{className:"gvp-speed-menu",role:"listbox","aria-label":"Playback speed",children:He.map(i=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":i===n,className:M("gvp-speed-menu-item",i===n&&"is-active"),onClick:()=>c(i),children:i===1?"Normal":`${i}×`})},i))})]})},Re=({video:e})=>{const[n,s]=o.useState([]),[r,u]=o.useState(-1),[d,c]=o.useState(!1),l=o.useRef(null),i=o.useCallback(a=>{const m=[];for(let h=0;h<a.length;h++){const x=a[h];(x.kind==="subtitles"||x.kind==="captions")&&m.push({index:h,label:x.label||x.language||`Track ${h+1}`,language:x.language})}s(m);let v=-1;for(let h=0;h<a.length;h++)if(a[h].mode==="showing"){v=h;break}u(v)},[]);o.useEffect(()=>{if(!e){s([]),u(-1);return}const a=e.textTracks;i(a);const m=()=>i(a);if(typeof a.addEventListener=="function")return a.addEventListener("addtrack",m),a.addEventListener("removetrack",m),a.addEventListener("change",m),()=>{a.removeEventListener("addtrack",m),a.removeEventListener("removetrack",m),a.removeEventListener("change",m)}},[e,i]),o.useEffect(()=>{if(!d)return;const a=v=>{l.current&&!l.current.contains(v.target)&&c(!1)},m=v=>{v.key==="Escape"&&c(!1)};return document.addEventListener("mousedown",a),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",a),document.removeEventListener("keydown",m)}},[d]);const f=a=>{if(!e)return;const m=e.textTracks;for(let v=0;v<m.length;v++)m[v].mode=v===a?"showing":"hidden";u(a),c(!1)},g=()=>{if(!e)return;const a=e.textTracks;for(let m=0;m<a.length;m++)a[m].mode="hidden";u(-1),c(!1)};return n.length===0?null:t.jsxs("div",{className:"gvp-captions",ref:l,children:[t.jsx("button",{type:"button",className:M("gvp-ctrl-btn",r>=0&&"is-active"),"aria-haspopup":"listbox","aria-expanded":d,"aria-label":"Captions","aria-pressed":r>=0,onClick:()=>c(a=>!a),children:t.jsx(Le,{})}),d&&t.jsxs("ul",{className:"gvp-captions-menu",role:"listbox","aria-label":"Captions",children:[t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":r===-1,className:M("gvp-captions-menu-item",r===-1&&"is-active"),onClick:g,children:"Off"})}),n.map(a=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":a.index===r,className:M("gvp-captions-menu-item",a.index===r&&"is-active"),onClick:()=>f(a.index),children:a.label})},a.index))]})]})},Be=({video:e})=>{const[n,s]=o.useState(!1);if(o.useEffect(()=>{if(!e)return;const u=()=>s(!0),d=()=>s(!1);return e.addEventListener("enterpictureinpicture",u),e.addEventListener("leavepictureinpicture",d),()=>{e.removeEventListener("enterpictureinpicture",u),e.removeEventListener("leavepictureinpicture",d)}},[e]),!document.pictureInPictureEnabled)return null;const r=()=>{document.pictureInPictureElement?document.exitPictureInPicture().catch(()=>{}):e==null||e.requestPictureInPicture().catch(()=>{})};return t.jsx("button",{type:"button",className:M("gvp-ctrl-btn",n&&"is-active"),"aria-label":n?"Exit picture-in-picture":"Picture-in-picture","aria-pressed":n,onClick:r,children:t.jsx(je,{})})},De=({container:e,video:n})=>{const[s,r]=o.useState(!1);if(o.useEffect(()=>{if(U)return;const i=()=>r(P.element()===e);return i(),P.onChange(i)},[e]),!(P.isSupported()||U&&n!==null&&typeof n.webkitEnterFullscreen=="function"))return null;const d=()=>{var i;if(U){(i=n==null?void 0:n.webkitEnterFullscreen)==null||i.call(n);return}s?P.exit().catch(()=>{}):e&&P.request(e).catch(()=>{})},c=s?Ce:we,l=s?"Exit fullscreen":"Enter fullscreen";return t.jsx("button",{type:"button",className:"gvp-ctrl-btn","aria-label":l,"aria-pressed":s,onClick:d,children:t.jsx(c,{})})};function Y(e,n,s){const r=e==null?void 0:e.trim();if(r)return r;if(n){try{const d=new Intl.DisplayNames(void 0,{type:"language"}).of(n);if(d&&d!==n)return d}catch{}return n}return`Audio ${s+1}`}const K=o.forwardRef(({src:e,hlsConfig:n,isHls:s,autoPlay:r,children:u,onAudioTracks:d,audioTrackIndex:c,...l},i)=>{const f=o.useRef(null),g=o.useRef(null),a=o.useRef(d);a.current=d,o.useImperativeHandle(i,()=>f.current);const m=globalThis.window!==void 0&&H.isSupported(),v=!!s||m&&typeof e=="string"&&e.endsWith(".m3u8");return o.useEffect(()=>{var y,V,T;if(!e)return;const h=f.current;if(!h)return;const x=p=>{var C;(C=a.current)==null||C.call(a,p)},b=()=>{r&&h.play().catch(()=>{})};for(g.current&&(g.current.destroy(),g.current=null),h.pause(),h.removeAttribute("src");h.firstChild;)h.firstChild.remove();x([]);let L;if(v){const p=new H(n);g.current=p;const C=()=>{const E=p.audioTracks.map((k,N)=>({index:N,label:Y(k.name,k.lang,N),lang:k.lang||void 0}));x(E)};p.on(H.Events.MANIFEST_PARSED,b),p.on(H.Events.AUDIO_TRACKS_UPDATED,C),p.on(H.Events.AUDIO_TRACK_SWITCHED,C),p.on(H.Events.ERROR,(E,k)=>{k.fatal&&(p.destroy(),g.current=null)}),p.attachMedia(h),p.loadSource(e)}else{h.src=e,h.load(),h.addEventListener("loadedmetadata",b,{once:!0});const p=h.audioTracks;if(p){const C=()=>{const E=[];for(let k=0;k<p.length;k++){const N=p[k];E.push({index:k,label:Y(N.label,N.language,k),lang:N.language||void 0})}x(E)};(y=p.addEventListener)==null||y.call(p,"addtrack",C),(V=p.addEventListener)==null||V.call(p,"removetrack",C),(T=p.addEventListener)==null||T.call(p,"change",C),p.length>0&&C(),L=()=>{var E,k,N;(E=p.removeEventListener)==null||E.call(p,"addtrack",C),(k=p.removeEventListener)==null||k.call(p,"removetrack",C),(N=p.removeEventListener)==null||N.call(p,"change",C)}}}return()=>{for(h.removeEventListener("loadedmetadata",b),L==null||L(),g.current&&(g.current.destroy(),g.current=null),h.pause(),h.removeAttribute("src");h.firstChild;)h.firstChild.remove();h.load(),x([])}},[e,v,n,r]),o.useEffect(()=>{var b;if(c==null||c<0)return;const h=g.current;if(h){h.audioTrack!==c&&(h.audioTrack=c);return}const x=(b=f.current)==null?void 0:b.audioTracks;if(x)for(let L=0;L<x.length;L++)x[L].enabled=L===c},[c]),t.jsx("video",{ref:f,...l,children:u})});K.displayName="HLSPlayer";function J(e){if(!e)return null;if(/^[A-Za-z0-9_-]{11}$/.test(e))return e;let n;try{n=new URL(e)}catch{return null}const s=n.hostname.replace(/^www\./,"");if(s==="youtu.be"){const r=n.pathname.slice(1).split("/")[0];return/^[A-Za-z0-9_-]{11}$/.test(r)?r:null}if(s==="youtube.com"||s==="m.youtube.com"||s==="music.youtube.com"||s==="youtube-nocookie.com"){const r=n.searchParams.get("v");if(r&&/^[A-Za-z0-9_-]{11}$/.test(r))return r;const u=/^\/(?:embed|shorts|v|live)\/([A-Za-z0-9_-]{11})/.exec(n.pathname);if(u)return u[1]}return null}function X(e){try{const n=new URL(e),s=n.searchParams.get("t")??n.searchParams.get("start");if(!s)return null;if(/^\d+s?$/.test(s))return Number.parseInt(s,10);const r=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?$/.exec(s);if(r){const u=Number.parseInt(r[1]??"0",10),d=Number.parseInt(r[2]??"0",10),c=Number.parseInt(r[3]??"0",10),l=u*3600+d*60+c;return l>0?l:null}}catch{}return null}function G(e,n={}){const{autoPlay:s=!1,muted:r=!0,loop:u=!1,controls:d=!0,startSeconds:c}=n,l=new URLSearchParams({rel:"0",modestbranding:"1",playsinline:"1",controls:d?"1":"0"});return s?(l.set("autoplay","1"),l.set("mute","1")):r&&l.set("mute","1"),u&&(l.set("loop","1"),l.set("playlist",e)),c&&c>0&&l.set("start",String(c)),`https://www.youtube-nocookie.com/embed/${e}?${l.toString()}`}const Ae=({tracks:e,activeIndex:n,onSelect:s})=>{const[r,u]=o.useState(!1),d=o.useRef(null);o.useEffect(()=>{if(!r)return;const l=f=>{d.current&&!d.current.contains(f.target)&&u(!1)},i=f=>{f.key==="Escape"&&u(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",i)}},[r]);const c=e.find(l=>l.index===n)??e[0];return t.jsxs("div",{className:"gvp-audio",ref:d,children:[t.jsxs("button",{type:"button",className:"gvp-audio-btn","aria-haspopup":"listbox","aria-expanded":r,"aria-label":"Audio track",onClick:()=>u(l=>!l),children:[t.jsx(fe,{}),t.jsx("span",{className:"gvp-audio-label",children:c==null?void 0:c.label}),t.jsx(ye,{})]}),r&&t.jsx("ul",{className:"gvp-audio-menu",role:"listbox","aria-label":"Audio tracks",children:e.map(l=>t.jsx("li",{children:t.jsx("button",{type:"button",role:"option","aria-selected":l.index===n,className:M("gvp-audio-menu-item",l.index===n&&"is-active"),onClick:()=>{s(l.index),u(!1)},children:l.label})},l.index))})]})},$e=({src:e,poster:n,showDeviceToggle:s=!0,defaultDevice:r="desktop",hoverPlay:u=!1,tooltipText:d,onClose:c,className:l="",muted:i=!0,loop:f=!1,controls:g=!0,autoPlay:a=!1,frameMaxWidth:m,aspectRatio:v,hlsConfig:h,children:x})=>{const b=o.useRef(null),L=o.useRef(null),[y,V]=o.useState(r),[T,p]=o.useState(!1),[C,E]=o.useState(!1),[k,N]=o.useState([]),[A,Z]=o.useState(-1),[Q,ee]=o.useState(null),[te,ne]=o.useState(null),re=o.useCallback(j=>{b.current=j,ne(j)},[]),I=g===!0||g==="custom",$=g==="native",R=o.useMemo(()=>J(e),[e]),S=R!==null,se=o.useMemo(()=>y==="mobile"?(v==null?void 0:v.mobile)??"9/16":(v==null?void 0:v.desktop)??"16/9",[y,v]),oe=o.useMemo(()=>y==="mobile"?(m==null?void 0:m.mobile)??"420px":(m==null?void 0:m.desktop)??"960px",[y,m]),ae=o.useMemo(()=>R?G(R,{autoPlay:a,muted:i,loop:f,controls:I?!0:$,startSeconds:X(e)}):null,[R,e,a,i,f,I,$]),le=o.useCallback(j=>{N(j),Z(-1)},[]),B=o.useCallback(async()=>{const j=b.current;if(j){if(L.current)try{await L.current}catch{}j.pause()}},[]),D=o.useCallback(async()=>{const j=b.current;if(j)try{j.readyState<2&&j.load();const O=j.play();L.current=O,await O,p(!0)}catch{p(!1)}finally{L.current=null}},[]),ie=o.useCallback(()=>{!u||S||D()},[u,S,D]),ce=o.useCallback(()=>{!u||S||B().then(()=>p(!1))},[u,S,B]),W=o.useCallback(async()=>{const j=b.current;j&&(j.paused?await D():(await B(),p(!1)))},[D,B]),ue=!S&&k.length>1;return t.jsxs("div",{ref:ee,className:M("gvp-root",l),style:{width:oe,aspectRatio:se},onMouseEnter:()=>{E(!0),ie()},onMouseLeave:()=>{E(!1),ce()},children:[S?t.jsx("iframe",{className:"gvp-video gvp-youtube",src:ae??void 0,title:"YouTube video player",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",allowFullScreen:!0,referrerPolicy:"strict-origin-when-cross-origin"}):t.jsx(K,{ref:re,src:e,poster:n,muted:i,loop:f,playsInline:!0,preload:"metadata",controls:$,autoPlay:a,hlsConfig:h,className:"gvp-video",onPlay:()=>p(!0),onPause:()=>p(!1),onAudioTracks:le,audioTrackIndex:A,children:x}),!S&&t.jsx("div",{className:"gvp-vignette"}),s&&t.jsx("div",{className:"gvp-toggle",children:t.jsxs("div",{className:"gvp-toggle-pill",children:[t.jsx("button",{type:"button",onClick:()=>V("desktop"),className:M("gvp-toggle-btn",y==="desktop"&&"is-active"),"aria-label":"Desktop view","aria-pressed":y==="desktop",children:t.jsx(de,{})}),t.jsx("div",{className:"gvp-toggle-divider"}),t.jsx("button",{type:"button",onClick:()=>V("mobile"),className:M("gvp-toggle-btn",y==="mobile"&&"is-active"),"aria-label":"Mobile view","aria-pressed":y==="mobile",children:t.jsx(he,{})})]})}),c&&t.jsx("button",{type:"button",onClick:c,className:"gvp-close","aria-label":"Close",children:t.jsx(pe,{})}),ue&&t.jsx(Ae,{tracks:k,activeIndex:A>=0?A:k[0].index,onSelect:Z}),!S&&I&&t.jsx("button",{type:"button",className:"gvp-click-layer",onClick:()=>void W(),"aria-label":T?"Pause":"Play"}),!S&&!I&&!T&&t.jsx("div",{className:"gvp-play-wrap",children:t.jsxs("button",{type:"button",onClick:()=>void W(),onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),className:"gvp-play","aria-label":"Play",children:[t.jsx(me,{}),d&&C&&t.jsx("span",{className:"gvp-tooltip",role:"tooltip",children:d})]})}),!S&&I&&t.jsx(Se,{video:te,isPlaying:T,container:Q,onTogglePlay:()=>void W()}),!S&&!I&&t.jsx("div",{className:"gvp-bottom-fade"})]})};exports.ReactVideoPlayer=$e;exports.parseYouTubeId=J;exports.parseYouTubeStart=X;exports.youTubeEmbedUrl=G;
3
3
  //# sourceMappingURL=index.cjs.map