@frameset/plex-player 2.0.2 → 2.0.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/index.d.ts +7 -10
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const l=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),l=Math.floor(e%3600/60),s=Math.floor(e%60);return t>0?`${t}:${l.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${l}:${s.toString().padStart(2,"0")}`},s=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),r=(e,t,l)=>Math.min(l,Math.max(t,e)),n=(e,t)=>{let l=!1;return(...s)=>{l||(e(...s),l=!0,setTimeout(()=>l=!1,t))}},a=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,i=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,o=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},c=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},u=e=>{if(0===e.buffered.length)return 0;const t=e.currentTime;for(let l=0;l<e.buffered.length;l++)if(e.buffered.start(l)<=t&&e.buffered.end(l)>=t)return e.buffered.end(l);return e.buffered.end(e.buffered.length-1)},d=({currentTime:n,duration:a,buffered:i,onSeek:o,thumbnailPreview:c,disabled:u=!1})=>{const d=t.useRef(null),[h,m]=t.useState(!1),[v,x]=t.useState(null),[g,y]=t.useState(0),b=s(n,a),f=s(i,a),w=t.useCallback(e=>{if(!d.current)return 0;const t=d.current.getBoundingClientRect();return r((e-t.left)/t.width,0,1)*a},[a]),k=t.useCallback(e=>{if(!d.current)return;const t=d.current.getBoundingClientRect(),l="clientX"in e?e.clientX:0,s=r(l-t.left,0,t.width),n=w(l);y(s),x(n),h&&o(n)},[h,w,o]),j=t.useCallback(e=>{if(u)return;e.preventDefault(),m(!0);const t=w(e.clientX);o(t)},[u,w,o]),C=t.useCallback(()=>{m(!1)},[]),_=t.useCallback(e=>{const t=w(e.clientX);x(t)},[w]),E=t.useCallback(()=>{x(null)},[]);t.useEffect(()=>{if(h){const e=e=>k(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",C)}}},[h,k,C]);const N=t.useCallback(e=>{if(u)return;e.preventDefault();const t=e.touches[0],l=w(t.clientX);m(!0),o(l)},[u,w,o]),P=t.useCallback(e=>{if(!h)return;const t=e.touches[0],l=w(t.clientX);o(l)},[h,w,o]),S=t.useCallback(()=>{m(!1)},[]);return e.jsxs("div",{ref:d,className:"plex-video-player__progress-container",onMouseDown:j,onMouseEnter:_,onMouseLeave:E,onMouseMove:e=>k(e.nativeEvent),onTouchStart:N,onTouchMove:P,onTouchEnd:S,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":a,"aria-valuenow":n,"aria-valuetext":l(n),tabIndex:0,children:[e.jsxs("div",{className:"plex-video-player__progress",children:[e.jsx("div",{className:"plex-video-player__progress-buffered",style:{width:`${f}%`}}),e.jsx("div",{className:"plex-video-player__progress-played",style:{width:`${b}%`}}),e.jsx("div",{className:"plex-video-player__progress-handle",style:{left:`${b}%`}})]}),c?.enabled&&null!==v&&e.jsxs("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${g}px`,width:c.width||160,height:c.height||90},children:[c.sprites&&e.jsx("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${c.sprites})`,backgroundPosition:p(v,a,c.interval||10,c.width||160,c.height||90),backgroundSize:"cover"}}),e.jsx("div",{className:"plex-video-player__thumbnail-time",children:l(v)})]}),null!==v&&!c?.enabled&&e.jsx("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${g}px`,width:"auto",height:"auto",padding:"4px 8px"},children:e.jsx("span",{style:{color:"white",fontSize:"12px"},children:l(v)})})]})},p=(e,t,l,s,r)=>{const n=Math.floor(e/l);return`-${n%10*s}px -${Math.floor(n/10)*r}px`},h=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),m=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),v=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"})}),x=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"})}),g=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 9v6h4l5 5V4l-5 5H7z"})}),y=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"})}),b=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),f=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),w=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"})}),k=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"})}),j=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"})}),C=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),_=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"})}),E=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),N=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),P=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),S=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"})}),z=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"})}),M=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})}),T=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 10h12v2H4zm0-4h12v2H4zm0 8h8v2H4zm10 0v6l5-3z"})}),L=({volume:l,muted:s,onVolumeChange:r,onToggleMute:n})=>{const a=t.useCallback(e=>{const t=parseFloat(e.target.value);r(t)},[r]);return e.jsxs("div",{className:"plex-video-player__volume-container",children:[e.jsx("button",{className:"plex-video-player__btn",onClick:n,"aria-label":s?"Unmute":"Mute",title:s?"Unmute (M)":"Mute (M)",type:"button",children:s||0===l?e.jsx(y,{}):l<.33?e.jsx(g,{}):l<.66?e.jsx(x,{}):e.jsx(v,{})}),e.jsx("div",{className:"plex-video-player__volume-slider-container",children:e.jsx("input",{type:"range",className:"plex-video-player__volume-slider",min:0,max:1,step:.01,value:s?0:l,onChange:a,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(s?0:l)}%, var(--plex-progress-bg) ${100*(s?0:l)}%, var(--plex-progress-bg) 100%)`}})})]})},F=({playbackRate:l,playbackSpeeds:s,onPlaybackRateChange:r,qualityEnabled:n,sources:a,currentQuality:i,onQualityChange:o,captionsEnabled:c,textTracks:u,currentTrack:d,onTrackChange:p})=>{const[h,m]=t.useState(!1),[v,x]=t.useState("main"),g=t.useRef(null);t.useEffect(()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&(m(!1),x("main"))};if(h)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]);const y=t.useCallback(()=>{m(e=>!e),x("main")},[]),b=t.useCallback(e=>{r(e),x("main")},[r]),f=t.useCallback(e=>{o?.(e),x("main")},[o]),w=t.useCallback(e=>{p?.(e),x("main")},[p]);return e.jsxs("div",{className:"plex-video-player__settings-container",ref:g,children:[e.jsx("button",{className:"plex-video-player__btn",onClick:y,"aria-label":"Settings","aria-expanded":h,title:"Settings",type:"button",children:e.jsx(k,{})}),h&&e.jsxs("div",{className:"plex-video-player__settings-menu "+(h?"plex-video-player__settings-menu--open":""),children:["main"===v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"plex-video-player__settings-title",children:"Settings"}),e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("speed"),type:"button",children:[e.jsx("span",{children:"Playback Speed"}),e.jsx("span",{children:1===l?"Normal":`${l}x`})]}),n&&a&&a.length>1&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("quality"),type:"button",children:[e.jsx("span",{children:"Quality"}),e.jsx("span",{children:i||"Auto"})]}),c&&u&&u.length>0&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("captions"),type:"button",children:[e.jsx("span",{children:"Captions"}),e.jsx("span",{children:d||"Off"})]})]}),"speed"===v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>x("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Playback Speed"}),e.jsx("div",{className:"plex-video-player__speed-menu",children:s.map(t=>e.jsx("button",{className:"plex-video-player__speed-btn "+(l===t?"plex-video-player__speed-btn--active":""),onClick:()=>b(t),type:"button",children:1===t?"Normal":`${t}x`},t))})]}),"quality"===v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>x("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Quality"}),e.jsx("div",{className:"plex-video-player__quality-menu",children:a?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(i===t.quality?"plex-video-player__settings-item--active":""),onClick:()=>f(t.quality||t.src),type:"button",children:[e.jsx("span",{children:t.label||t.quality||"Unknown"}),i===t.quality&&e.jsx(E,{size:16})]},t.quality||t.src))})]}),"captions"===v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>x("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Captions"}),e.jsxs("div",{className:"plex-video-player__quality-menu",children:[e.jsxs("button",{className:"plex-video-player__settings-item "+(d?"":"plex-video-player__settings-item--active"),onClick:()=>w(null),type:"button",children:[e.jsx("span",{children:"Off"}),!d&&e.jsx(E,{size:16})]}),u?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(d===t.srclang?"plex-video-player__settings-item--active":""),onClick:()=>w(t.srclang),type:"button",children:[e.jsx("span",{children:t.label}),d===t.srclang&&e.jsx(E,{size:16})]},t.srclang))]})]})]})]})},V=({ad:t,timeRemaining:s,canSkip:r,onSkip:n,onClick:a})=>{const i=r?"Skip Ad":`Skip in ${Math.ceil(s)}s`;return e.jsxs("div",{className:"plex-video-player__ad-overlay",onClick:a,children:[e.jsxs("div",{className:"plex-video-player__ad-info",children:[e.jsx("span",{className:"plex-video-player__ad-badge",children:"Ad"}),e.jsxs("span",{children:[l(s)," remaining"]})]}),t.clickThrough&&e.jsxs("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),a()},type:"button",children:[e.jsx(_,{size:16}),"Learn More"]}),e.jsx("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),r&&n()},disabled:!r,type:"button",children:i})]})},A={1:"The video playback was aborted.",2:"A network error occurred while loading the video.",3:"The video format is not supported or cannot be decoded.",4:"The video source is not supported."},R=({error:t,onRetry:l})=>{const s=t?.code||0,r=A[s]||"An unknown error occurred.";return e.jsxs("div",{className:"plex-video-player__error",children:[e.jsx(C,{className:"plex-video-player__error-icon",size:60}),e.jsx("div",{className:"plex-video-player__error-message",children:r}),s>0&&e.jsxs("div",{className:"plex-video-player__error-code",children:["Error Code: ",s]}),e.jsx("button",{className:"plex-video-player__error-retry",onClick:l,type:"button",children:"Try Again"})]})},I=({visible:t})=>t?e.jsx("div",{className:"plex-video-player__loader",children:e.jsx("div",{className:"plex-video-player__loader-spinner"})}):null,B=({x:l,y:s,isVisible:r,onClose:n,isPlaying:a,isMuted:i,isLoop:o,playbackRate:c,onTogglePlay:u,onToggleMute:d,onToggleLoop:p,onToggleFullscreen:x,onTogglePip:g,onCopyUrl:f,onPlaybackRateChange:k,pipEnabled:C})=>{const _=t.useRef(null);if(t.useEffect(()=>{const e=e=>{_.current&&!_.current.contains(e.target)&&n()},t=e=>{"Escape"===e.key&&n()};return r&&(document.addEventListener("mousedown",e),document.addEventListener("keydown",t)),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",t)}},[r,n]),t.useEffect(()=>{if(r&&_.current){const e=_.current,t=e.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight;let a=l,i=s;l+t.width>r&&(a=r-t.width-10),s+t.height>n&&(i=n-t.height-10),e.style.left=`${a}px`,e.style.top=`${i}px`}},[r,l,s]),!r)return null;const E=[{id:"play",label:a?"Pause":"Play",icon:a?e.jsx(m,{}):e.jsx(h,{}),shortcut:"Space",onClick:()=>{u(),n()}},{id:"mute",label:i?"Unmute":"Mute",icon:i?e.jsx(v,{}):e.jsx(y,{}),shortcut:"M",onClick:()=>{d(),n()}},{id:"divider1",label:"",divider:!0},{id:"loop",label:o?"Disable Loop":"Enable Loop",icon:e.jsx(N,{}),onClick:()=>{p(),n()}},{id:"speed",label:`Speed: ${c}x`,icon:e.jsx(j,{}),onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=(e.indexOf(c)+1)%e.length;k(e[t])}},{id:"divider2",label:"",divider:!0},{id:"pip",label:"Picture in Picture",icon:e.jsx(w,{}),shortcut:"P",disabled:!C,onClick:()=>{g(),n()}},{id:"fullscreen",label:"Fullscreen",icon:e.jsx(b,{}),shortcut:"F",onClick:()=>{x(),n()}},{id:"divider3",label:"",divider:!0},{id:"copy",label:"Copy Video URL",icon:e.jsx(P,{}),onClick:()=>{f(),n()}}];return e.jsxs("div",{ref:_,className:"plex-video-player__context-menu",style:{left:l,top:s},children:[E.map(t=>t.divider?e.jsx("div",{className:"plex-video-player__context-menu-divider"},t.id):e.jsxs("button",{className:"plex-video-player__context-menu-item "+(t.disabled?"plex-video-player__context-menu-item--disabled":""),onClick:t.onClick,disabled:t.disabled,type:"button",children:[e.jsx("span",{className:"plex-video-player__context-menu-icon",children:t.icon}),e.jsx("span",{className:"plex-video-player__context-menu-label",children:t.label}),t.shortcut&&e.jsx("span",{className:"plex-video-player__context-menu-shortcut",children:t.shortcut})]},t.id)),e.jsx("div",{className:"plex-video-player__context-menu-footer",children:"PlexVideo Player © FRAMESET STUDIO"})]})},H=({items:s,currentIndex:r,isPlaying:n,isExpanded:a,onItemSelect:i,onToggleExpand:o,onClose:c,onNext:u,onPrevious:d,loop:p=!1,shuffle:v=!1,onShuffleToggle:x,onLoopToggle:g})=>{const y=t.useRef(null),[b,f]=t.useState(null),[w,k]=t.useState(null);t.useEffect(()=>{if(y.current&&a){const e=y.current.querySelector(`[data-index="${r}"]`);e&&e.scrollIntoView({behavior:"smooth",block:"nearest"})}},[r,a]);const j=t.useCallback((e,t)=>{f(t),e.dataTransfer.effectAllowed="move"},[]),C=t.useCallback((e,t)=>{e.preventDefault(),k(t)},[]),_=t.useCallback(()=>{f(null),k(null)},[]),E=s[r];return e.jsxs("div",{className:"plex-video-player__playlist "+(a?"plex-video-player__playlist--expanded":""),children:[e.jsxs("div",{className:"plex-video-player__playlist-header",children:[e.jsxs("button",{className:"plex-video-player__playlist-toggle",onClick:o,type:"button","aria-label":a?"Collapse playlist":"Expand playlist",children:[a?e.jsx(z,{}):e.jsx(S,{}),e.jsxs("span",{className:"plex-video-player__playlist-title",children:["Playlist (",r+1,"/",s.length,")"]})]}),e.jsxs("div",{className:"plex-video-player__playlist-controls",children:[x&&e.jsx("button",{className:"plex-video-player__playlist-btn "+(v?"plex-video-player__playlist-btn--active":""),onClick:x,type:"button","aria-label":"Shuffle",title:"Shuffle",children:e.jsx(q,{})}),g&&e.jsx("button",{className:"plex-video-player__playlist-btn "+(p?"plex-video-player__playlist-btn--active":""),onClick:g,type:"button","aria-label":"Loop",title:"Loop playlist",children:e.jsx(D,{})}),e.jsx("button",{className:"plex-video-player__playlist-btn",onClick:d,disabled:0===r&&!p,type:"button","aria-label":"Previous",title:"Previous",children:e.jsx($,{})}),e.jsx("button",{className:"plex-video-player__playlist-btn",onClick:u,disabled:r===s.length-1&&!p,type:"button","aria-label":"Next",title:"Next",children:e.jsx(O,{})}),e.jsx("button",{className:"plex-video-player__playlist-btn plex-video-player__playlist-btn--close",onClick:c,type:"button","aria-label":"Close playlist",children:e.jsx(M,{})})]})]}),!a&&E&&e.jsxs("div",{className:"plex-video-player__playlist-current",children:[E.poster&&e.jsx("img",{src:E.poster,alt:E.title,className:"plex-video-player__playlist-current-thumb"}),e.jsxs("div",{className:"plex-video-player__playlist-current-info",children:[e.jsx("div",{className:"plex-video-player__playlist-current-title",children:E.title}),E.artist&&e.jsx("div",{className:"plex-video-player__playlist-current-artist",children:E.artist})]}),n?e.jsx(m,{}):e.jsx(h,{})]}),a&&e.jsx("div",{ref:y,className:"plex-video-player__playlist-items",children:s.map((t,s)=>e.jsxs("div",{"data-index":s,className:`plex-video-player__playlist-item ${s===r?"plex-video-player__playlist-item--active":""} ${b===s?"plex-video-player__playlist-item--dragging":""} ${w===s?"plex-video-player__playlist-item--drag-over":""}`,draggable:!0,onDragStart:e=>j(e,s),onDragOver:e=>C(e,s),onDragEnd:_,onClick:()=>i(s),children:[e.jsx("div",{className:"plex-video-player__playlist-item-number",children:s===r&&n?e.jsxs("div",{className:"plex-video-player__playlist-playing-indicator",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):s+1}),t.poster&&e.jsx("img",{src:t.poster,alt:t.title,className:"plex-video-player__playlist-item-thumb"}),e.jsxs("div",{className:"plex-video-player__playlist-item-info",children:[e.jsx("div",{className:"plex-video-player__playlist-item-title",children:t.title}),t.artist&&e.jsx("div",{className:"plex-video-player__playlist-item-artist",children:t.artist})]}),t.duration&&e.jsx("div",{className:"plex-video-player__playlist-item-duration",children:l(t.duration)})]},t.id))})]})},q=()=>e.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:e.jsx("path",{d:"M10.59 9.17L5.41 4 4 5.41l5.17 5.17 1.42-1.41zM14.5 4l2.04 2.04L4 18.59 5.41 20 17.96 7.46 20 9.5V4h-5.5zm.33 9.41l-1.41 1.41 3.13 3.13L14.5 20H20v-5.5l-2.04 2.04-3.13-3.13z"})}),D=()=>e.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:e.jsx("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),$=()=>e.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:e.jsx("path",{d:"M6 6h2v12H6V6zm3.5 6l8.5 6V6l-8.5 6z"})}),O=()=>e.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",fill:"currentColor",children:e.jsx("path",{d:"M6 18l8.5-6L6 6v12zm2-8.14L11.03 12 8 14.14V9.86zM16 6h2v12h-2V6z"})}),U={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"},Q=({enabled:e,hotkeys:l={},onPlay:s,onMute:r,onFullscreen:n,onPip:a,onSeek:i,onVolume:o,containerRef:c})=>{const u={...U,...l},d=t.useCallback(t=>{if(!e)return;const l=t.target;if("INPUT"===l.tagName||"TEXTAREA"===l.tagName||l.isContentEditable)return;const d=c.current;if(!d||!d.contains(document.activeElement))return;switch(t.key){case u.play:case" ":t.preventDefault(),s();break;case u.mute:case"M":t.preventDefault(),r();break;case u.fullscreen:case"F":t.preventDefault(),n();break;case u.pip:case"P":t.preventDefault(),a();break;case u.seekForward:t.preventDefault(),i(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),i(t.shiftKey?-30:-10);break;case u.volumeUp:t.preventDefault(),o(.1);break;case u.volumeDown:t.preventDefault(),o(-.1);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.preventDefault(),i(-1/0)}},[e,u,s,r,n,a,i,o,c]);t.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[e,d])},X=e=>{const t=(new DOMParser).parseFromString(e,"text/xml");if(t.querySelector("parsererror"))return{ads:[],error:"Failed to parse VAST XML"};const l=[];return t.querySelectorAll("Ad").forEach(e=>{const t=e.querySelector("InLine");if(!t)return;const s=e.getAttribute("id")||"",r=t.querySelector("AdTitle")?.textContent||"",n=t.querySelector("Description")?.textContent||void 0,a=t.querySelectorAll("Creative");let i,o,c=0;const u=[],d=[],p={};a.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const l=t.querySelector("Duration")?.textContent;l&&(c=K(l));const s=t.getAttribute("skipoffset");s&&(i=K(s));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&d.push({url:t,type:e.getAttribute("type")||"video/mp4",width:parseInt(e.getAttribute("width")||"0",10),height:parseInt(e.getAttribute("height")||"0",10),bitrate:parseInt(e.getAttribute("bitrate")||"0",10)||void 0})});const r=t.querySelector("VideoClicks");r&&(o=r.querySelector("ClickThrough")?.textContent?.trim(),r.querySelectorAll("ClickTracking").forEach(e=>{const t=e.textContent?.trim();t&&u.push(t)}));t.querySelectorAll("TrackingEvents Tracking").forEach(e=>{const t=e.getAttribute("event"),l=e.textContent?.trim();t&&l&&(p[t]||(p[t]=[]),p[t].push(l))})});const h=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&h.push(t)}),d.length>0&&l.push({id:s,title:r,description:n,duration:c,skipOffset:i,clickThrough:o,clickTracking:u,impressionUrls:h,mediaFiles:d,trackingEvents:p})}),{ads:l}},K=e=>{if(e.includes("%"))return-1;const t=e.split(":");if(3!==t.length)return 0;return 3600*parseInt(t[0],10)+60*parseInt(t[1],10)+parseFloat(t[2])},G=async e=>{try{const t=await fetch(e.url,{method:"GET",headers:{Accept:"application/xml"}});if(!t.ok)return null;const l=await t.text(),s=X(l);if(s.error||0===s.ads.length)return null;const r=s.ads[0];return void 0!==e.skipDelay&&void 0===r.skipOffset&&(r.skipOffset=e.skipDelay),r}catch(e){return null}},W=e=>{if(0===e.length)return null;const t=document.createElement("video"),l=e.filter(e=>""!==t.canPlayType(e.type));if(0===l.length)return null;l.sort((e,t)=>{const l=e.width*e.height,s=t.width*t.height;return l!==s?s-l:(t.bitrate||0)-(e.bitrate||0)});return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&l.length>1?l[l.length-1]:l[0]},Y=e=>{(new Image).src=e},J=e=>{e.forEach(Y)},Z=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),ee=({vastConfig:e,videoRef:l,onAdStart:s,onAdEnd:r,onAdSkip:n,onAdError:a})=>{const[i,o]=t.useState(!1),[c,u]=t.useState(null),[d,p]=t.useState(0),[h,m]=t.useState(!1),v=t.useRef(null),x=t.useRef(""),g=t.useRef(0),y=t.useRef(new Set),b=t.useRef(null),f=Array.isArray(e)?e:e?[e]:[],w=t.useCallback(async e=>{const t=l.current;if(t&&!i)try{const l=await G(e);if(!l)return void a?.(new Error("Failed to fetch VAST ad"));const r=W(l.mediaFiles);if(!r)return void a?.(new Error("No compatible media file found"));x.current=t.currentSrc,g.current=t.currentTime,J(l.impressionUrls),v.current=l,u(Z(l)),o(!0),p(l.duration),m(void 0===l.skipOffset||0===l.skipOffset),t.src=r.url,t.currentTime=0,await t.play(),l.trackingEvents.start&&J(l.trackingEvents.start),s?.(Z(l)),b.current=window.setInterval(()=>{const e=Math.max(0,l.duration-t.currentTime);p(e),l.skipOffset&&t.currentTime>=l.skipOffset&&m(!0);const s=t.currentTime/l.duration*100;s>=25&&l.trackingEvents.firstQuartile&&J(l.trackingEvents.firstQuartile),s>=50&&l.trackingEvents.midpoint&&J(l.trackingEvents.midpoint),s>=75&&l.trackingEvents.thirdQuartile&&J(l.trackingEvents.thirdQuartile)},250);const n=()=>{l.trackingEvents.complete&&J(l.trackingEvents.complete),k()};t.addEventListener("ended",n,{once:!0})}catch(e){a?.(e instanceof Error?e:new Error("Ad playback failed")),k()}},[l,i,s,a]),k=t.useCallback(()=>{const e=l.current;e&&(b.current&&(clearInterval(b.current),b.current=null),x.current&&(e.src=x.current,e.currentTime=g.current,e.play().catch(()=>{})),o(!1),u(null),p(0),m(!1),v.current=null,r?.())},[l,r]),j=t.useCallback(()=>{if(!h||!v.current)return;const e=v.current;e.trackingEvents.skip&&J(e.trackingEvents.skip),n?.(),k()},[h,k,n]),C=t.useCallback(()=>{if(!v.current)return;const e=v.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&J(e.clickTracking)},[]),_=t.useCallback((e,t)=>{i||0===f.length||f.forEach(l=>{const s=l.position||"preroll",r=`${s}-${l.midrollTime||0}`;if(y.current.has(r))return;let n=!1;switch(s){case"preroll":n=0===e;break;case"midroll":l.midrollTime&&e>=l.midrollTime&&(n=!0);break;case"postroll":n=e>=t-.5}n&&(y.current.add(r),w(l))})},[f,i,w]);return t.useEffect(()=>()=>{b.current&&clearInterval(b.current)},[]),{isAdPlaying:i,currentAd:c,adTimeRemaining:d,canSkip:h,skipAd:j,handleAdClick:C,checkForAd:_}},te=t.forwardRef((s,r)=>{const{src:a,poster:i,autoPlay:o=!1,muted:c=!1,loop:u=!1,controls:p=!0,width:v="100%",className:x="",style:g={},pip:y=!0,fullscreen:k=!0,playbackSpeed:j=!0,playbackSpeeds:C=[.25,.5,.75,1,1.25,1.5,1.75,2],volume:_=!0,initialVolume:E=1,progressBar:N=!0,timeDisplay:P=!0,qualitySelector:S=!0,textTracks:z=[],vast:M,keyboard:A=!0,hotkeys:q,accentColor:D="#f5c518",controlsTimeout:$=3e3,doubleClickFullscreen:O=!0,clickToPlay:U=!0,preload:X="metadata",playlist:K=[],onPlay:G,onPause:W,onEnded:Y,onTimeUpdate:J,onProgress:Z,onVolumeChange:te,onFullscreenChange:le,onPipChange:se,onQualityChange:re,onError:ne,onAdStart:ae,onAdEnd:ie,onAdSkip:oe,onAdError:ce,onReady:ue,onPlaylistItemChange:de}=s,pe=t.useRef(null),he=t.useRef(null),me=t.useRef(null),ve=t.useRef(0),[xe,ge]=t.useState(!1),[ye,be]=t.useState(0),[fe,we]=t.useState(0),[ke,je]=t.useState(0),[Ce,_e]=t.useState(c?0:E),[Ee,Ne]=t.useState(c),[Pe,Se]=t.useState(!1),[ze,Me]=t.useState(!1),[Te,Le]=t.useState(!0),[Fe,Ve]=t.useState(null),[Ae,Re]=t.useState(!0),[Ie,Be]=t.useState(1),[He,qe]=t.useState("auto"),[De,$e]=t.useState(null),[Oe,Ue]=t.useState(u),[Qe,Xe]=t.useState({x:0,y:0,visible:!1}),[Ke,Ge]=t.useState(!1),[We,Ye]=t.useState(!0),[Je,Ze]=t.useState(0),[et,tt]=t.useState(!1),[lt,st]=t.useState(!1),rt=t.useMemo(()=>"string"==typeof a?[{src:a,type:"video/mp4"}]:a,[a]),nt=t.useMemo(()=>K.length>0&&K[Je]?K[Je].src:rt[0]?.src||"",[K,Je,rt]),at=t.useMemo(()=>K.length>0&&K[Je]?.poster?K[Je].poster:i,[K,Je,i]),{currentAd:it,isAdPlaying:ot,adTimeRemaining:ct,canSkip:ut,skipAd:dt,handleAdClick:pt,checkForAd:ht}=ee({vastConfig:M,videoRef:pe,onAdStart:ae,onAdEnd:ie,onAdSkip:oe,onAdError:ce}),mt=t.useCallback(async()=>{const e=pe.current;if(e)try{await e.play()}catch(e){}},[]),vt=t.useCallback(()=>{const e=pe.current;e&&e.pause()},[]),xt=t.useCallback(()=>{const e=pe.current;e&&(e.pause(),e.currentTime=0)},[]),gt=t.useCallback(()=>{const e=pe.current;e&&(e.paused?mt():vt())},[mt,vt]),yt=t.useCallback(e=>{const t=pe.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),bt=t.useCallback(e=>{const t=pe.current;if(!t)return;const l=Math.max(0,Math.min(1,e));t.volume=l,t.muted=0===l,_e(l),Ne(0===l)},[]),ft=t.useCallback(()=>{const e=pe.current;e&&(e.muted=!0,Ne(!0))},[]),wt=t.useCallback(()=>{const e=pe.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,_e(.5)),Ne(!1))},[]),kt=t.useCallback(()=>{const e=pe.current;e&&(e.muted?wt():ft())},[ft,wt]),jt=t.useCallback(()=>{const e=pe.current;e&&(e.loop=!e.loop,Ue(e.loop))},[]),Ct=t.useCallback(async()=>{const e=he.current;if(e)try{await e.requestFullscreen(),Se(!0)}catch(e){}},[]),_t=t.useCallback(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),Se(!1))}catch(e){}},[]),Et=t.useCallback(async()=>{document.fullscreenElement?await _t():await Ct()},[Ct,_t]),Nt=t.useCallback(async()=>{const e=pe.current;if(e&&document.pictureInPictureEnabled)try{await e.requestPictureInPicture(),Me(!0)}catch(e){}},[]),Pt=t.useCallback(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),Me(!1))}catch(e){}},[]),St=t.useCallback(async()=>{document.pictureInPictureElement?await Pt():await Nt()},[Nt,Pt]),zt=t.useCallback(e=>{const t=pe.current;t&&(t.playbackRate=e,Be(e))},[]),Mt=t.useCallback(e=>{const t=rt.find(t=>t.label===e||t.quality===e);if(t&&pe.current){const l=pe.current,s=!l.paused,r=l.currentTime;l.src=t.src,l.currentTime=r,s&&l.play(),qe(e),re?.(e)}},[rt,re]),Tt=t.useCallback(e=>{const t=pe.current;if(t){for(let l=0;l<t.textTracks.length;l++){const s=t.textTracks[l];s.mode=s.label===e?"showing":"hidden"}$e(e)}},[]),Lt=t.useCallback(e=>{e>=0&&e<K.length&&(Ze(e),de?.(e,K[e]),setTimeout(()=>mt(),100))},[K,de,mt]),Ft=t.useCallback(()=>{if(0===K.length)return;let e=Je+1;if(e>=K.length){if(!et)return;e=0}lt&&(e=Math.floor(Math.random()*K.length)),Lt(e)},[Je,K.length,et,lt,Lt]),Vt=t.useCallback(()=>{if(0===K.length)return;let e=Je-1;if(e<0){if(!et)return;e=K.length-1}Lt(e)},[Je,K.length,et,Lt]),At=t.useCallback(e=>{e.preventDefault(),Xe({x:e.clientX,y:e.clientY,visible:!0})},[]),Rt=t.useCallback(()=>{Xe(e=>({...e,visible:!1}))},[]),It=t.useCallback(()=>{navigator.clipboard.writeText(nt)},[nt]),Bt=t.useCallback(()=>{xe&&Re(!1)},[xe]),Ht=t.useCallback(()=>{Re(!0),me.current&&clearTimeout(me.current),xe&&(me.current=setTimeout(Bt,$))},[xe,$,Bt]),qt=t.useMemo(()=>n(Ht,200),[Ht]),Dt=t.useCallback(()=>{if(!U)return;const e=Date.now();O&&e-ve.current<300?Et():gt(),ve.current=e},[U,O,gt,Et]);t.useEffect(()=>{const e=pe.current;if(!e)return;const t=()=>{ge(!0),G?.()},l=()=>{ge(!1),W?.()},s=()=>{ge(!1),Y?.(),K.length>0&&Ft()},r=()=>{be(e.currentTime),J?.(e.currentTime),ht(e.currentTime,e.duration)},n=()=>{we(e.duration)},a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1)/e.duration*100;je(t),Z?.(t)}},i=()=>{_e(e.volume),Ne(e.muted),te?.(e.volume,e.muted)},o=()=>{we(e.duration),Le(!1),ue?.()},c=()=>{Le(!0)},u=()=>{Le(!1)},d=()=>{Le(!1)},p=()=>{Ve(e.error),Le(!1),ne?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",l),e.addEventListener("ended",s),e.addEventListener("timeupdate",r),e.addEventListener("durationchange",n),e.addEventListener("progress",a),e.addEventListener("volumechange",i),e.addEventListener("loadedmetadata",o),e.addEventListener("waiting",c),e.addEventListener("playing",u),e.addEventListener("canplay",d),e.addEventListener("error",p),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",l),e.removeEventListener("ended",s),e.removeEventListener("timeupdate",r),e.removeEventListener("durationchange",n),e.removeEventListener("progress",a),e.removeEventListener("volumechange",i),e.removeEventListener("loadedmetadata",o),e.removeEventListener("waiting",c),e.removeEventListener("playing",u),e.removeEventListener("canplay",d),e.removeEventListener("error",p)}},[G,W,Y,J,Z,te,ue,ne,ht,K.length,Ft]),t.useEffect(()=>{const e=()=>{const e=!!document.fullscreenElement;Se(e),le?.(e)};return document.addEventListener("fullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e)}},[le]),t.useEffect(()=>{const e=pe.current;if(!e)return;const t=()=>{Me(!0),se?.(!0)},l=()=>{Me(!1),se?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",l),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",l)}},[se]),Q({enabled:A,containerRef:he,hotkeys:q,onPlay:gt,onMute:kt,onFullscreen:Et,onPip:St,onSeek:e=>yt(ye+e),onVolume:e=>bt(Ce+e)}),t.useEffect(()=>()=>{me.current&&clearTimeout(me.current)},[]);const $t=t.useCallback(()=>{Ve(null),pe.current?.load()},[]);t.useImperativeHandle(r,()=>({play:mt,pause:vt,stop:xt,seek:yt,setVolume:bt,mute:ft,unmute:wt,toggleMute:kt,enterFullscreen:Ct,exitFullscreen:_t,toggleFullscreen:Et,enterPip:Nt,exitPip:Pt,togglePip:St,setPlaybackRate:zt,setQuality:Mt,getCurrentTime:()=>pe.current?.currentTime||0,getDuration:()=>pe.current?.duration||0,getVolume:()=>pe.current?.volume||0,isMuted:()=>pe.current?.muted??!0,isPlaying:()=>!pe.current?.paused,isFullscreen:()=>Pe,isPip:()=>ze,getVideoElement:()=>pe.current}),[mt,vt,xt,yt,bt,ft,wt,kt,Ct,_t,Et,Nt,Pt,St,zt,Mt,Pe,ze]);const Ot={"--plex-accent-color":D,"--plex-primary":D};return e.jsxs("div",{ref:he,className:`plex-video-player ${Pe?"plex-video-player--fullscreen":""} ${x}`,style:{...Ot,width:v,...g},onMouseMove:qt,onMouseLeave:()=>xe&&Re(!1),onContextMenu:At,tabIndex:0,children:[e.jsxs("video",{ref:pe,className:"plex-video-player__video",src:nt,poster:at,autoPlay:o,muted:c,loop:Oe,preload:X,playsInline:!0,onClick:Dt,children:[rt.slice(1).map((t,l)=>e.jsx("source",{src:t.src,type:t.type},l)),z.map((t,l)=>e.jsx("track",{kind:t.kind,src:t.src,srcLang:t.srclang,label:t.label,default:t.default},l))]}),e.jsx(I,{visible:Te&&!Fe}),Fe&&e.jsx(R,{error:Fe,onRetry:$t}),ot&&it&&e.jsx(V,{ad:it,timeRemaining:ct,canSkip:ut,onSkip:dt,onClick:pt}),e.jsx(B,{x:Qe.x,y:Qe.y,isVisible:Qe.visible,onClose:Rt,isPlaying:xe,isMuted:Ee,isLoop:Oe,playbackRate:Ie,onTogglePlay:gt,onToggleMute:kt,onToggleLoop:jt,onToggleFullscreen:Et,onTogglePip:St,onCopyUrl:It,onPlaybackRateChange:zt,pipEnabled:document.pictureInPictureEnabled,videoUrl:nt}),K.length>0&&Ke&&e.jsx(H,{items:K,currentIndex:Je,isPlaying:xe,isExpanded:We,onItemSelect:Lt,onToggleExpand:()=>Ye(!We),onClose:()=>Ge(!1),onNext:Ft,onPrevious:Vt,loop:et,shuffle:lt,onLoopToggle:()=>tt(!et),onShuffleToggle:()=>st(!lt)}),p&&!ot&&e.jsxs("div",{className:"plex-video-player__controls "+(Ae?"plex-video-player__controls--visible":""),children:[N&&e.jsx(d,{currentTime:ye,duration:fe,buffered:ke,onSeek:yt}),e.jsxs("div",{className:"plex-video-player__controls-bottom",children:[e.jsxs("div",{className:"plex-video-player__controls-left",children:[e.jsx("button",{className:"plex-video-player__btn",onClick:gt,"aria-label":xe?"Pause":"Play",type:"button",children:xe?e.jsx(m,{}):e.jsx(h,{})}),_&&e.jsx(L,{volume:Ce,muted:Ee,onVolumeChange:bt,onToggleMute:kt}),P&&e.jsxs("div",{className:"plex-video-player__time",children:[e.jsx("span",{children:l(ye)}),e.jsx("span",{children:" / "}),e.jsx("span",{children:l(fe)})]})]}),e.jsxs("div",{className:"plex-video-player__controls-right",children:[K.length>0&&e.jsx("button",{className:"plex-video-player__btn "+(Ke?"plex-video-player__btn--active":""),onClick:()=>Ge(!Ke),"aria-label":"Playlist",type:"button",children:e.jsx(T,{})}),j&&e.jsx(F,{playbackRate:Ie,playbackSpeeds:C,onPlaybackRateChange:zt,qualityEnabled:S&&rt.length>1,sources:rt,currentQuality:He,onQualityChange:Mt,captionsEnabled:z.length>0,textTracks:z,currentTrack:De??void 0,onTrackChange:Tt}),y&&document.pictureInPictureEnabled&&e.jsx("button",{className:"plex-video-player__btn",onClick:St,"aria-label":ze?"Exit Picture in Picture":"Picture in Picture",type:"button",children:e.jsx(w,{})}),k&&e.jsx("button",{className:"plex-video-player__btn",onClick:Et,"aria-label":Pe?"Exit Fullscreen":"Fullscreen",type:"button",children:Pe?e.jsx(f,{}):e.jsx(b,{})})]})]})]}),!xe&&!Te&&!Fe&&!ot&&e.jsx("button",{className:"plex-video-player__big-play",onClick:gt,"aria-label":"Play",type:"button",children:e.jsx(h,{})})]})});te.displayName="PlexVideoPlayer";const le={isPlaying:!1,isPaused:!0,isEnded:!1,isBuffering:!1,isSeeking:!1,isFullscreen:!1,isPip:!1,isMuted:!1,isAdPlaying:!1,volume:1,currentTime:0,duration:0,buffered:0,playbackRate:1,currentQuality:null,error:null};exports.AdOverlay=V,exports.CaptionsIcon=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H9.5v-.5h-2v3h2V13H11v1c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1zm7 0h-1.5v-.5h-2v3h2V13H18v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1z"})}),exports.CheckIcon=E,exports.ErrorDisplay=R,exports.ErrorIcon=C,exports.ExternalLinkIcon=_,exports.ForwardIcon=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"})}),exports.FullscreenExitIcon=f,exports.FullscreenIcon=b,exports.Loader=I,exports.PauseIcon=m,exports.PipExitIcon=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14zM5 7h8v6H5z"})}),exports.PipIcon=w,exports.PlayIcon=h,exports.PlexVideoPlayer=te,exports.ProgressBar=d,exports.QualityIcon=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM7.5 13h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2zM7.5 9h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2z"})}),exports.RewindIcon=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"})}),exports.SettingsIcon=k,exports.SettingsMenu=F,exports.SkipNextIcon=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})}),exports.SkipPrevIcon=({className:t,size:l=24})=>e.jsx("svg",{className:t,width:l,height:l,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),exports.SpeedIcon=j,exports.VolumeControl=L,exports.VolumeHighIcon=v,exports.VolumeLowIcon=g,exports.VolumeMediumIcon=x,exports.VolumeMuteIcon=y,exports.canPlayType=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},exports.clamp=r,exports.convertToAdInfo=Z,exports.debounce=(e,t)=>{let l=null;return(...s)=>{l&&clearTimeout(l),l=setTimeout(()=>e(...s),t)}},exports.default=te,exports.detectVideoType=e=>{const t=e.split("?")[0].split(".").pop()?.toLowerCase();return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska"}[t||""]||"video/mp4"},exports.exitFullscreen=c,exports.fetchVastAd=G,exports.fireTrackingPixel=Y,exports.fireTrackingPixels=J,exports.formatTime=l,exports.generateId=()=>`plex-${Math.random().toString(36).substring(2,11)}`,exports.getBufferedEnd=u,exports.getFullscreenElement=i,exports.isFullscreenSupported=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),exports.isHlsNativelySupported=()=>""!==document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),exports.isMobile=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),exports.isPipSupported=a,exports.isTouchDevice=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,exports.parseTime=e=>{const t=e.split(":").map(Number);return 3===t.length?3600*t[0]+60*t[1]+t[2]:2===t.length?60*t[0]+t[1]:t[0]||0},exports.parseVastXml=X,exports.percentage=s,exports.requestFullscreen=o,exports.selectBestMediaFile=W,exports.throttle=n,exports.useKeyboard=Q,exports.usePlayer=(e={})=>{const{autoPlay:l=!1,muted:s=!1,loop:r=!1,volume:n=1,playbackRate:d=1}=e,p=t.useRef(null),h=t.useRef(null),[m,v]=t.useState({...le,volume:n,isMuted:s,playbackRate:d}),x=t.useCallback(e=>{v(t=>({...t,...e}))},[]),g=t.useCallback(async()=>{const e=p.current;if(e)try{await e.play(),x({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[x]),y=t.useCallback(()=>{const e=p.current;e&&(e.pause(),x({isPlaying:!1,isPaused:!0}))},[x]),b=t.useCallback(()=>{m.isPlaying?y():g()},[m.isPlaying,g,y]),f=t.useCallback(e=>{const t=p.current;if(!t)return;const l=Math.max(0,Math.min(e,t.duration||0));t.currentTime=l,x({currentTime:l})},[x]),w=t.useCallback(e=>{const t=p.current;if(!t)return;const l=Math.max(0,Math.min(1,e));t.volume=l,t.muted=0===l,x({volume:l,isMuted:0===l})},[x]),k=t.useCallback(()=>{const e=p.current;e&&(e.muted=!e.muted,x({isMuted:e.muted}))},[x]),j=t.useCallback(e=>{const t=p.current;t&&(t.playbackRate=e,x({playbackRate:e}))},[x]),C=t.useCallback(async()=>{const e=h.current;if(e)try{await o(e),x({isFullscreen:!0})}catch(e){}},[x]),_=t.useCallback(async()=>{try{await c(),x({isFullscreen:!1})}catch(e){}},[x]),E=t.useCallback(async()=>{m.isFullscreen?await _():await C()},[m.isFullscreen,C,_]),N=t.useCallback(async()=>{const e=p.current;if(e&&a())try{await e.requestPictureInPicture(),x({isPip:!0})}catch(e){}},[x]),P=t.useCallback(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),x({isPip:!1})}catch(e){}},[x]),S=t.useCallback(async()=>{m.isPip?await P():await N()},[m.isPip,N,P]);return t.useEffect(()=>{const e=p.current;if(!e)return;e.muted=s,e.volume=n,e.playbackRate=d,e.loop=r;const t={loadedmetadata:()=>{x({duration:e.duration})},timeupdate:()=>{x({currentTime:e.currentTime,buffered:u(e)})},play:()=>{x({isPlaying:!0,isPaused:!1,isEnded:!1})},pause:()=>{x({isPlaying:!1,isPaused:!0})},ended:()=>{x({isPlaying:!1,isPaused:!0,isEnded:!0})},waiting:()=>{x({isBuffering:!0})},canplay:()=>{x({isBuffering:!1})},seeking:()=>{x({isSeeking:!0})},seeked:()=>{x({isSeeking:!1})},volumechange:()=>{x({volume:e.volume,isMuted:e.muted})},ratechange:()=>{x({playbackRate:e.playbackRate})},error:()=>{x({error:e.error})},enterpictureinpicture:()=>{x({isPip:!0})},leavepictureinpicture:()=>{x({isPip:!1})}};return Object.entries(t).forEach(([t,l])=>{e.addEventListener(t,l)}),l&&g(),()=>{Object.entries(t).forEach(([t,l])=>{e.removeEventListener(t,l)})}},[l,s,r,n,d,g,x]),t.useEffect(()=>{const e=()=>{const e=!!i();x({isFullscreen:e})};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}},[x]),{state:m,videoRef:p,containerRef:h,play:g,pause:y,togglePlay:b,seek:f,setVolume:w,toggleMute:k,setPlaybackRate:j,enterFullscreen:C,exitFullscreen:_,toggleFullscreen:E,enterPip:N,exitPip:P,togglePip:S}},exports.useVast=ee;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const r=e=>{const t=(new DOMParser).parseFromString(e,"text/xml");if(t.querySelector("parsererror"))return{ads:[],error:"Failed to parse VAST XML"};const r=[];return t.querySelectorAll("Ad").forEach(e=>{const t=e.querySelector("InLine");if(!t)return;const n=e.getAttribute("id")||"",l=t.querySelector("AdTitle")?.textContent||"",a=t.querySelector("Description")?.textContent||void 0,i=t.querySelectorAll("Creative");let c,o,u=0;const d=[],h=[],p={};i.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const r=t.querySelector("Duration")?.textContent;r&&(u=s(r));const n=t.getAttribute("skipoffset");n&&(c=s(n));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&h.push({url:t,type:e.getAttribute("type")||"video/mp4",width:parseInt(e.getAttribute("width")||"0",10),height:parseInt(e.getAttribute("height")||"0",10),bitrate:parseInt(e.getAttribute("bitrate")||"0",10)||void 0})});const l=t.querySelector("VideoClicks");l&&(o=l.querySelector("ClickThrough")?.textContent?.trim(),l.querySelectorAll("ClickTracking").forEach(e=>{const t=e.textContent?.trim();t&&d.push(t)}));t.querySelectorAll("TrackingEvents Tracking").forEach(e=>{const t=e.getAttribute("event"),r=e.textContent?.trim();t&&r&&(p[t]||(p[t]=[]),p[t].push(r))})});const m=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&m.push(t)}),h.length>0&&r.push({id:n,title:l,description:a,duration:u,skipOffset:c,clickThrough:o,clickTracking:d,impressionUrls:m,mediaFiles:h,trackingEvents:p})}),{ads:r}},s=e=>{if(e.includes("%"))return-1;const t=e.split(":");if(3!==t.length)return 0;return 3600*parseInt(t[0],10)+60*parseInt(t[1],10)+parseFloat(t[2])},n=async e=>{try{const t=await fetch(e.url,{method:"GET",headers:{Accept:"application/xml"}});if(!t.ok)return null;const s=await t.text(),n=r(s);if(n.error||0===n.ads.length)return null;const l=n.ads[0];return void 0!==e.skipDelay&&void 0===l.skipOffset&&(l.skipOffset=e.skipDelay),l}catch(e){return null}},l=e=>{if(0===e.length)return null;const t=document.createElement("video"),r=e.filter(e=>""!==t.canPlayType(e.type));if(0===r.length)return null;r.sort((e,t)=>{const r=e.width*e.height,s=t.width*t.height;return r!==s?s-r:(t.bitrate||0)-(e.bitrate||0)});return/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)&&r.length>1?r[r.length-1]:r[0]},a=e=>{(new Image).src=e},i=e=>{e.forEach(a)},c=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),o=({vastConfig:e,videoRef:r,onAdStart:s,onAdEnd:a,onAdSkip:o,onAdError:u})=>{const[d,h]=t.useState(!1),[p,m]=t.useState(null),[v,x]=t.useState(0),[g,f]=t.useState(!1),w=t.useRef(null),b=t.useRef(""),y=t.useRef(0),k=t.useRef(new Set),j=t.useRef(null),C=Array.isArray(e)?e:e?[e]:[],N=t.useCallback(async e=>{const t=r.current;if(t&&!d)try{const r=await n(e);if(!r)return void u?.(new Error("Failed to fetch VAST ad"));const a=l(r.mediaFiles);if(!a)return void u?.(new Error("No compatible media file found"));b.current=t.currentSrc,y.current=t.currentTime,i(r.impressionUrls),w.current=r,m(c(r)),h(!0),x(r.duration),f(void 0===r.skipOffset||0===r.skipOffset),t.src=a.url,t.currentTime=0,await t.play(),r.trackingEvents.start&&i(r.trackingEvents.start),s?.(c(r)),j.current=window.setInterval(()=>{const e=Math.max(0,r.duration-t.currentTime);x(e),r.skipOffset&&t.currentTime>=r.skipOffset&&f(!0);const s=t.currentTime/r.duration*100;s>=25&&r.trackingEvents.firstQuartile&&i(r.trackingEvents.firstQuartile),s>=50&&r.trackingEvents.midpoint&&i(r.trackingEvents.midpoint),s>=75&&r.trackingEvents.thirdQuartile&&i(r.trackingEvents.thirdQuartile)},250);const o=()=>{r.trackingEvents.complete&&i(r.trackingEvents.complete),E()};t.addEventListener("ended",o,{once:!0})}catch(e){u?.(e instanceof Error?e:new Error("Ad playback failed")),E()}},[r,d,s,u]),E=t.useCallback(()=>{const e=r.current;e&&(j.current&&(clearInterval(j.current),j.current=null),b.current&&(e.src=b.current,e.currentTime=y.current,e.play().catch(()=>{})),h(!1),m(null),x(0),f(!1),w.current=null,a?.())},[r,a]),z=t.useCallback(()=>{if(!g||!w.current)return;const e=w.current;e.trackingEvents.skip&&i(e.trackingEvents.skip),o?.(),E()},[g,E,o]),M=t.useCallback(()=>{if(!w.current)return;const e=w.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&i(e.clickTracking)},[]),P=t.useCallback((e,t)=>{d||0===C.length||C.forEach(r=>{const s=r.position||"preroll",n=`${s}-${r.midrollTime||0}`;if(k.current.has(n))return;let l=!1;switch(s){case"preroll":l=0===e;break;case"midroll":r.midrollTime&&e>=r.midrollTime&&(l=!0);break;case"postroll":l=e>=t-.5}l&&(k.current.add(n),N(r))})},[C,d,N]);return t.useEffect(()=>()=>{j.current&&clearInterval(j.current)},[]),{isAdPlaying:d,currentAd:p,adTimeRemaining:v,canSkip:g,skipAd:z,handleAdClick:M,checkForAd:P}},u=e=>{if(!isFinite(e)||isNaN(e))return"0:00";const t=Math.floor(e/3600),r=Math.floor(e%3600/60),s=Math.floor(e%60);return t>0?`${t}:${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`:`${r}:${s.toString().padStart(2,"0")}`},d=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),h=(e,t,r)=>Math.min(r,Math.max(t,e)),p=(e,t)=>{let r=!1;return(...s)=>{r||(e(...s),r=!0,setTimeout(()=>r=!1,t))}},m=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,v=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,x=async e=>{e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?await e.webkitRequestFullscreen():e.mozRequestFullScreen?await e.mozRequestFullScreen():e.msRequestFullscreen&&await e.msRequestFullscreen()},g=async()=>{document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen?await document.webkitExitFullscreen():document.mozCancelFullScreen?await document.mozCancelFullScreen():document.msExitFullscreen&&await document.msExitFullscreen()},f=e=>{if(0===e.buffered.length)return 0;const t=e.currentTime;for(let r=0;r<e.buffered.length;r++)if(e.buffered.start(r)<=t&&e.buffered.end(r)>=t)return e.buffered.end(r);return e.buffered.end(e.buffered.length-1)},w=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),b=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),y=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"})}),k=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"})}),j=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),C=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),N=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"})}),E=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-5 h-5",children:e.jsx("path",{d:"M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"})}),z=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("path",{d:"M7 7h10v3l4-4-4-4v3H5v6h2V7zm10 10H7v-3l-4 4 4 4v-3h12v-6h-2v4z"})}),M=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),P=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-4 h-4",children:e.jsx("path",{d:"M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"})}),S=t.forwardRef((r,s)=>{const{src:n,poster:l,autoPlay:a=!1,muted:i=!1,loop:c=!1,controls:d=!0,width:h="100%",className:m="",style:v={},pip:x=!0,fullscreen:g=!0,playbackSpeed:f=!0,playbackSpeeds:S=[.5,.75,1,1.25,1.5,2],volume:_=!0,initialVolume:L=1,textTracks:T=[],vast:A,accentColor:V="#f5c518",controlsTimeout:F=3e3,doubleClickFullscreen:R=!0,clickToPlay:I=!0,preload:H="metadata",playlist:B=[],onPlay:q,onPause:D,onEnded:$,onTimeUpdate:O,onProgress:U,onVolumeChange:Q,onFullscreenChange:X,onPipChange:K,onQualityChange:G,onError:Y,onAdStart:J,onAdEnd:W,onAdSkip:Z,onAdError:ee,onReady:te,onPlaylistItemChange:re}=r,se=t.useRef(null),ne=t.useRef(null),le=t.useRef(null),ae=t.useRef(null),ie=t.useRef(0),[ce,oe]=t.useState(!1),[ue,de]=t.useState(0),[he,pe]=t.useState(0),[me,ve]=t.useState(0),[xe,ge]=t.useState(i?0:L),[fe,we]=t.useState(i),[be,ye]=t.useState(!1),[ke,je]=t.useState(!1),[Ce,Ne]=t.useState(!0),[Ee,ze]=t.useState(null),[Me,Pe]=t.useState(!0),[Se,_e]=t.useState(1),[Le,Te]=t.useState(c),[Ae,Ve]=t.useState(!1),[Fe,Re]=t.useState({x:0,y:0,visible:!1}),[Ie,He]=t.useState(0),Be=t.useMemo(()=>"string"==typeof n?[{src:n,type:"video/mp4"}]:n,[n]),qe=t.useMemo(()=>B.length>0&&B[Ie]?B[Ie].src:Be[0]?.src||"",[B,Ie,Be]),De=t.useMemo(()=>B.length>0&&B[Ie]?.poster?B[Ie].poster:l,[B,Ie,l]),{currentAd:$e,isAdPlaying:Oe,adTimeRemaining:Ue,canSkip:Qe,skipAd:Xe,handleAdClick:Ke,checkForAd:Ge}=o({vastConfig:A,videoRef:se,onAdStart:J,onAdEnd:W,onAdSkip:Z,onAdError:ee}),Ye=t.useCallback(async()=>{const e=se.current;if(e)try{await e.play()}catch(e){}},[]),Je=t.useCallback(()=>{se.current?.pause()},[]),We=t.useCallback(()=>{const e=se.current;e&&(e.pause(),e.currentTime=0)},[]),Ze=t.useCallback(()=>{se.current?.paused?Ye():Je()},[Ye,Je]),et=t.useCallback(e=>{const t=se.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),tt=t.useCallback(e=>{const t=se.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,ge(r),we(0===r)},[]),rt=t.useCallback(()=>{se.current&&(se.current.muted=!0,we(!0))},[]),st=t.useCallback(()=>{const e=se.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,ge(.5)),we(!1))},[]),nt=t.useCallback(()=>{se.current?.muted?st():rt()},[rt,st]),lt=t.useCallback(()=>{se.current&&(se.current.loop=!se.current.loop,Te(se.current.loop))},[]),at=t.useCallback(async()=>{try{await(ne.current?.requestFullscreen()),ye(!0)}catch(e){}},[]),it=t.useCallback(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),ye(!1))}catch(e){}},[]),ct=t.useCallback(async()=>{document.fullscreenElement?await it():await at()},[at,it]),ot=t.useCallback(async()=>{try{await(se.current?.requestPictureInPicture()),je(!0)}catch(e){}},[]),ut=t.useCallback(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),je(!1))}catch(e){}},[]),dt=t.useCallback(async()=>{document.pictureInPictureElement?await ut():await ot()},[ot,ut]),ht=t.useCallback(e=>{se.current&&(se.current.playbackRate=e,_e(e),Ve(!1))},[]),pt=t.useCallback(e=>{const t=Be.find(t=>t.label===e||t.quality===e);if(t&&se.current){const r=se.current,s=!r.paused,n=r.currentTime;r.src=t.src,r.currentTime=n,s&&r.play(),G?.(e)}},[Be,G]),mt=t.useCallback(()=>{if(0===B.length)return;const e=(Ie+1)%B.length;He(e),re?.(e,B[e]),setTimeout(()=>Ye(),100)},[Ie,B,re,Ye]),vt=t.useCallback(e=>{e.preventDefault();const t=ne.current?.getBoundingClientRect();t&&Re({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})},[]),xt=t.useCallback(()=>{Re(e=>({...e,visible:!1}))},[]),gt=t.useCallback(()=>{navigator.clipboard.writeText(qe),xt()},[qe,xt]),ft=t.useCallback(e=>{const t=le.current?.getBoundingClientRect();if(t&&he){const r=(e.clientX-t.left)/t.width;et(r*he)}},[he,et]),wt=t.useCallback(()=>{ce&&!Ae&&Pe(!1)},[ce,Ae]),bt=t.useCallback(()=>{Pe(!0),ae.current&&clearTimeout(ae.current),ce&&(ae.current=setTimeout(wt,F))},[ce,F,wt]),yt=t.useMemo(()=>p(bt,200),[bt]),kt=t.useCallback(()=>{if(xt(),!I)return;const e=Date.now();R&&e-ie.current<300?ct():Ze(),ie.current=e},[I,R,Ze,ct,xt]);t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{oe(!0),q?.()},r=()=>{oe(!1),D?.()},s=()=>{oe(!1),$?.(),B.length>0&&mt()},n=()=>{de(e.currentTime),O?.(e.currentTime),Ge(e.currentTime,e.duration)},l=()=>pe(e.duration),a=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1);ve(t/e.duration*100),U?.(t/e.duration*100)}},i=()=>{ge(e.volume),we(e.muted),Q?.(e.volume,e.muted)},c=()=>{pe(e.duration),Ne(!1),te?.()},o=()=>Ne(!0),u=()=>Ne(!1),d=()=>Ne(!1),h=()=>{ze(e.error),Ne(!1),Y?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",r),e.addEventListener("ended",s),e.addEventListener("timeupdate",n),e.addEventListener("durationchange",l),e.addEventListener("progress",a),e.addEventListener("volumechange",i),e.addEventListener("loadedmetadata",c),e.addEventListener("waiting",o),e.addEventListener("playing",u),e.addEventListener("canplay",d),e.addEventListener("error",h),()=>{e.removeEventListener("play",t),e.removeEventListener("pause",r),e.removeEventListener("ended",s),e.removeEventListener("timeupdate",n),e.removeEventListener("durationchange",l),e.removeEventListener("progress",a),e.removeEventListener("volumechange",i),e.removeEventListener("loadedmetadata",c),e.removeEventListener("waiting",o),e.removeEventListener("playing",u),e.removeEventListener("canplay",d),e.removeEventListener("error",h)}},[q,D,$,O,U,Q,te,Y,Ge,B.length,mt]),t.useEffect(()=>{const e=()=>{const e=!!document.fullscreenElement;ye(e),X?.(e)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[X]),t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{je(!0),K?.(!0)},r=()=>{je(!1),K?.(!1)};return e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",r),()=>{e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",r)}},[K]),t.useEffect(()=>{const e=e=>{if(ne.current?.contains(document.activeElement))switch(e.key){case" ":case"k":e.preventDefault(),Ze();break;case"m":e.preventDefault(),nt();break;case"f":e.preventDefault(),ct();break;case"ArrowLeft":e.preventDefault(),et(ue-10);break;case"ArrowRight":e.preventDefault(),et(ue+10);break;case"ArrowUp":e.preventDefault(),tt(xe+.1);break;case"ArrowDown":e.preventDefault(),tt(xe-.1)}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[Ze,nt,ct,et,tt,ue,xe]),t.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current)},[]),t.useEffect(()=>{const e=()=>xt();if(Fe.visible)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[Fe.visible,xt]),t.useImperativeHandle(s,()=>({play:Ye,pause:Je,stop:We,seek:et,setVolume:tt,mute:rt,unmute:st,toggleMute:nt,enterFullscreen:at,exitFullscreen:it,toggleFullscreen:ct,enterPip:ot,exitPip:ut,togglePip:dt,setPlaybackRate:ht,setQuality:pt,getCurrentTime:()=>se.current?.currentTime||0,getDuration:()=>se.current?.duration||0,getVolume:()=>se.current?.volume||0,isMuted:()=>se.current?.muted??!0,isPlaying:()=>!se.current?.paused,isFullscreen:()=>be,isPip:()=>ke,getVideoElement:()=>se.current}),[Ye,Je,We,et,tt,rt,st,nt,at,it,ct,ot,ut,dt,ht,pt,be,ke]);const jt=he?ue/he*100:0;return e.jsxs("div",{ref:ne,className:`relative bg-black overflow-hidden select-none ${be?"fixed inset-0 z-[9999]":""} ${m}`,style:{width:h,aspectRatio:be?"unset":"16/9","--accent":V,...v},onMouseMove:yt,onMouseLeave:()=>ce&&Pe(!1),onContextMenu:vt,tabIndex:0,children:[e.jsx("video",{ref:se,className:"w-full h-full object-contain",src:qe,poster:De,autoPlay:a,muted:i,loop:Le,preload:H,playsInline:!0,onClick:kt,children:T.map((t,r)=>e.jsx("track",{kind:t.kind,src:t.src,srcLang:t.srclang,label:t.label,default:t.default},r))}),Ce&&!Ee&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("div",{className:"w-12 h-12 border-4 border-transparent rounded-full animate-spin",style:{borderTopColor:V}})}),Ee&&e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/90 text-white",children:[e.jsx("svg",{className:"w-16 h-16 mb-4",fill:V,viewBox:"0 0 24 24",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),e.jsx("p",{className:"text-lg mb-2",children:"Error loading video"}),e.jsx("button",{className:"px-6 py-2 rounded text-black font-medium",style:{backgroundColor:V},onClick:()=>{ze(null),se.current?.load()},children:"Retry"})]}),Oe&&$e&&e.jsxs("div",{className:"absolute inset-0 z-20",children:[e.jsxs("div",{className:"absolute top-4 left-4 flex items-center gap-3 px-3 py-2 bg-black/70 rounded text-white text-sm",children:[e.jsx("span",{className:"px-2 py-0.5 rounded text-xs font-bold",style:{backgroundColor:V,color:"#000"},children:"AD"}),e.jsxs("span",{children:[u(Ue)," remaining"]})]}),e.jsx("button",{className:"absolute bottom-20 right-4 px-5 py-2 border border-white rounded text-white "+(Qe?"hover:bg-white hover:text-black cursor-pointer":"opacity-50 cursor-not-allowed"),onClick:Qe?Xe:void 0,disabled:!Qe,children:Qe?"Skip Ad":`Skip in ${Math.ceil(Ue)}s`})]}),Fe.visible&&e.jsxs("div",{className:"absolute z-50 min-w-[200px] bg-[#1a1a1a]/95 backdrop-blur-md rounded-lg shadow-xl overflow-hidden animate-in fade-in zoom-in-95 duration-150",style:{left:Fe.x,top:Fe.y},onClick:e=>e.stopPropagation(),children:[e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{Ze(),xt()},children:[ce?e.jsx(b,{}):e.jsx(w,{}),e.jsx("span",{className:"flex-1 text-left",children:ce?"Pause":"Play"}),e.jsx("span",{className:"text-white/50 text-xs",children:"Space"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{nt(),xt()},children:[fe?e.jsx(k,{}):e.jsx(y,{}),e.jsx("span",{className:"flex-1 text-left",children:fe?"Unmute":"Mute"}),e.jsx("span",{className:"text-white/50 text-xs",children:"M"})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{lt(),xt()},children:[e.jsx(z,{}),e.jsx("span",{className:"flex-1 text-left",children:Le?"Disable Loop":"Enable Loop"}),Le&&e.jsx("span",{style:{color:V},children:"✓"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=e.indexOf(Se);ht(e[(t+1)%e.length]),xt()},children:[e.jsx(P,{}),e.jsxs("span",{className:"flex-1 text-left",children:["Speed: ",Se,"x"]})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),x&&document.pictureInPictureEnabled&&e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{dt(),xt()},children:[e.jsx(N,{}),e.jsx("span",{className:"flex-1 text-left",children:"Picture in Picture"}),e.jsx("span",{className:"text-white/50 text-xs",children:"P"})]}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:()=>{ct(),xt()},children:[e.jsx(j,{}),e.jsx("span",{className:"flex-1 text-left",children:"Fullscreen"}),e.jsx("span",{className:"text-white/50 text-xs",children:"F"})]}),e.jsx("div",{className:"h-px bg-white/10 my-1"}),e.jsxs("button",{className:"w-full flex items-center gap-3 px-4 py-3 text-white text-sm hover:bg-white/10 transition-colors",onClick:gt,children:[e.jsx(M,{}),e.jsx("span",{className:"flex-1 text-left",children:"Copy Video URL"})]}),e.jsx("div",{className:"px-4 py-2 text-[10px] text-white/40 text-center border-t border-white/10",children:"PlexVideo Player © FRAMESET STUDIO"})]}),d&&!Oe&&e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/90 to-transparent p-4 transition-opacity duration-300 "+(Me?"opacity-100":"opacity-0 pointer-events-none"),children:[e.jsxs("div",{ref:le,className:"relative h-[6px] bg-white/30 rounded-full mb-4 cursor-pointer group hover:h-[10px] transition-all",onClick:ft,children:[e.jsx("div",{className:"absolute top-0 left-0 h-full bg-white/40 rounded-full transition-all",style:{width:`${me}%`}}),e.jsx("div",{className:"absolute top-0 left-0 h-full rounded-full transition-all",style:{width:`${jt}%`,backgroundColor:V}}),e.jsx("div",{className:"absolute top-1/2 w-4 h-4 rounded-full scale-0 group-hover:scale-100 transition-transform shadow-lg",style:{left:`${jt}%`,transform:"translate(-50%, -50%)",backgroundColor:V}})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"w-10 h-10 flex items-center justify-center rounded-full hover:bg-white/10 text-white transition-colors",onClick:Ze,"aria-label":ce?"Pause":"Play",children:ce?e.jsx(b,{}):e.jsx(w,{})}),_&&e.jsxs("div",{className:"flex items-center gap-2 group",children:[e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:nt,"aria-label":fe?"Unmute":"Mute",children:fe||0===xe?e.jsx(k,{}):e.jsx(y,{})}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:fe?0:xe,onChange:e=>tt(parseFloat(e.target.value)),className:"w-0 group-hover:w-20 h-1 rounded-full appearance-none cursor-pointer transition-all overflow-hidden",style:{background:`linear-gradient(to right, ${V} 0%, ${V} ${100*(fe?0:xe)}%, rgba(255,255,255,0.3) ${100*(fe?0:xe)}%)`}})]}),e.jsxs("div",{className:"text-white text-sm font-mono ml-2",children:[u(ue)," / ",u(he)]}),e.jsx("div",{className:"flex-1"}),f&&e.jsxs("div",{className:"relative",children:[e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:()=>Ve(!Ae),"aria-label":"Settings",children:e.jsx(E,{})}),Ae&&e.jsxs("div",{className:"absolute bottom-full right-0 mb-3 min-w-[160px] bg-[#1a1a1a] backdrop-blur-md rounded-lg shadow-2xl overflow-hidden z-[100] border border-white/10",children:[e.jsx("div",{className:"px-4 py-2 text-white/60 text-xs font-semibold uppercase tracking-wide border-b border-white/10",children:"Playback Speed"}),S.map(t=>e.jsxs("button",{className:"w-full px-4 py-2.5 text-left text-sm hover:bg-white/10 transition-colors flex items-center justify-between "+(Se===t?"":"text-white"),style:Se===t?{color:V}:{},onClick:()=>ht(t),children:[e.jsx("span",{children:1===t?"Normal":`${t}x`}),Se===t&&e.jsx("span",{children:"✓"})]},t))]})]}),x&&document.pictureInPictureEnabled&&e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:dt,"aria-label":"Picture in Picture",children:e.jsx(N,{})}),g&&e.jsx("button",{className:"w-8 h-8 flex items-center justify-center rounded hover:bg-white/10 text-white transition-colors",onClick:ct,"aria-label":be?"Exit Fullscreen":"Fullscreen",children:be?e.jsx(C,{}):e.jsx(j,{})})]})]}),!ce&&!Ce&&!Ee&&!Oe&&e.jsx("button",{className:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-20 h-20 rounded-full flex items-center justify-center hover:scale-110 transition-transform shadow-2xl",style:{backgroundColor:V},onClick:Ze,"aria-label":"Play",children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"white",className:"w-8 h-8 ml-1",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})]})});S.displayName="PlexVideoPlayer";const _=(e,t,r,s,n)=>{const l=Math.floor(e/r);return`-${l%10*s}px -${Math.floor(l/10)*n}px`},L=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"})}),T=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M18.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM5 9v6h4l5 5V4L9 9H5z"})}),A=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 9v6h4l5 5V4l-5 5H7z"})}),V=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"})}),F=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58c.18-.14.23-.41.12-.61l-1.92-3.32c-.12-.22-.37-.29-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54c-.04-.24-.24-.41-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58c-.18.14-.23.41-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z"})}),R=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),I=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"})}),H=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})}),B={1:"The video playback was aborted.",2:"A network error occurred while loading the video.",3:"The video format is not supported or cannot be decoded.",4:"The video source is not supported."},q={isPlaying:!1,isPaused:!0,isEnded:!1,isBuffering:!1,isSeeking:!1,isFullscreen:!1,isPip:!1,isMuted:!1,isAdPlaying:!1,volume:1,currentTime:0,duration:0,buffered:0,playbackRate:1,currentQuality:null,error:null},D={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"};exports.AdOverlay=({ad:t,timeRemaining:r,canSkip:s,onSkip:n,onClick:l})=>{const a=s?"Skip Ad":`Skip in ${Math.ceil(r)}s`;return e.jsxs("div",{className:"plex-video-player__ad-overlay",onClick:l,children:[e.jsxs("div",{className:"plex-video-player__ad-info",children:[e.jsx("span",{className:"plex-video-player__ad-badge",children:"Ad"}),e.jsxs("span",{children:[u(r)," remaining"]})]}),t.clickThrough&&e.jsxs("button",{className:"plex-video-player__ad-learn-more",onClick:e=>{e.stopPropagation(),l()},type:"button",children:[e.jsx(I,{size:16}),"Learn More"]}),e.jsx("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),s&&n()},disabled:!s,type:"button",children:a})]})},exports.CaptionsIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-8 7H9.5v-.5h-2v3h2V13H11v1c0 .55-.45 1-1 1H7c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1zm7 0h-1.5v-.5h-2v3h2V13H18v1c0 .55-.45 1-1 1h-3c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v1z"})}),exports.CheckIcon=H,exports.ErrorDisplay=({error:t,onRetry:r})=>{const s=t?.code||0,n=B[s]||"An unknown error occurred.";return e.jsxs("div",{className:"plex-video-player__error",children:[e.jsx(R,{className:"plex-video-player__error-icon",size:60}),e.jsx("div",{className:"plex-video-player__error-message",children:n}),s>0&&e.jsxs("div",{className:"plex-video-player__error-code",children:["Error Code: ",s]}),e.jsx("button",{className:"plex-video-player__error-retry",onClick:r,type:"button",children:"Try Again"})]})},exports.ErrorIcon=R,exports.ExternalLinkIcon=I,exports.ForwardIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"})}),exports.FullscreenExitIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"})}),exports.FullscreenIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),exports.Loader=({visible:t})=>t?e.jsx("div",{className:"plex-video-player__loader",children:e.jsx("div",{className:"plex-video-player__loader-spinner"})}):null,exports.PauseIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),exports.PipExitIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M21 3H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14zM5 7h8v6H5z"})}),exports.PipIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H3V5h18v14z"})}),exports.PlayIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),exports.PlexVideoPlayer=S,exports.ProgressBar=({currentTime:r,duration:s,buffered:n,onSeek:l,thumbnailPreview:a,disabled:i=!1})=>{const c=t.useRef(null),[o,p]=t.useState(!1),[m,v]=t.useState(null),[x,g]=t.useState(0),f=d(r,s),w=d(n,s),b=t.useCallback(e=>{if(!c.current)return 0;const t=c.current.getBoundingClientRect();return h((e-t.left)/t.width,0,1)*s},[s]),y=t.useCallback(e=>{if(!c.current)return;const t=c.current.getBoundingClientRect(),r="clientX"in e?e.clientX:0,s=h(r-t.left,0,t.width),n=b(r);g(s),v(n),o&&l(n)},[o,b,l]),k=t.useCallback(e=>{if(i)return;e.preventDefault(),p(!0);const t=b(e.clientX);l(t)},[i,b,l]),j=t.useCallback(()=>{p(!1)},[]),C=t.useCallback(e=>{const t=b(e.clientX);v(t)},[b]),N=t.useCallback(()=>{v(null)},[]);t.useEffect(()=>{if(o){const e=e=>y(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",j)}}},[o,y,j]);const E=t.useCallback(e=>{if(i)return;e.preventDefault();const t=e.touches[0],r=b(t.clientX);p(!0),l(r)},[i,b,l]),z=t.useCallback(e=>{if(!o)return;const t=e.touches[0],r=b(t.clientX);l(r)},[o,b,l]),M=t.useCallback(()=>{p(!1)},[]);return e.jsxs("div",{ref:c,className:"plex-video-player__progress-container",onMouseDown:k,onMouseEnter:C,onMouseLeave:N,onMouseMove:e=>y(e.nativeEvent),onTouchStart:E,onTouchMove:z,onTouchEnd:M,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":s,"aria-valuenow":r,"aria-valuetext":u(r),tabIndex:0,children:[e.jsxs("div",{className:"plex-video-player__progress",children:[e.jsx("div",{className:"plex-video-player__progress-buffered",style:{width:`${w}%`}}),e.jsx("div",{className:"plex-video-player__progress-played",style:{width:`${f}%`}}),e.jsx("div",{className:"plex-video-player__progress-handle",style:{left:`${f}%`}})]}),a?.enabled&&null!==m&&e.jsxs("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${x}px`,width:a.width||160,height:a.height||90},children:[a.sprites&&e.jsx("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${a.sprites})`,backgroundPosition:_(m,s,a.interval||10,a.width||160,a.height||90),backgroundSize:"cover"}}),e.jsx("div",{className:"plex-video-player__thumbnail-time",children:u(m)})]}),null!==m&&!a?.enabled&&e.jsx("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${x}px`,width:"auto",height:"auto",padding:"4px 8px"},children:e.jsx("span",{style:{color:"white",fontSize:"12px"},children:u(m)})})]})},exports.QualityIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM7.5 13h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2zM7.5 9h2v2H7.5zm4.5 0h2v2h-2zm4.5 0h2v2h-2z"})}),exports.RewindIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"})}),exports.SettingsIcon=F,exports.SettingsMenu=({playbackRate:r,playbackSpeeds:s,onPlaybackRateChange:n,qualityEnabled:l,sources:a,currentQuality:i,onQualityChange:c,captionsEnabled:o,textTracks:u,currentTrack:d,onTrackChange:h})=>{const[p,m]=t.useState(!1),[v,x]=t.useState("main"),g=t.useRef(null);t.useEffect(()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&(m(!1),x("main"))};if(p)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const f=t.useCallback(()=>{m(e=>!e),x("main")},[]),w=t.useCallback(e=>{n(e),x("main")},[n]),b=t.useCallback(e=>{c?.(e),x("main")},[c]),y=t.useCallback(e=>{h?.(e),x("main")},[h]);return e.jsxs("div",{className:"plex-video-player__settings-container",ref:g,children:[e.jsx("button",{className:"plex-video-player__btn",onClick:f,"aria-label":"Settings","aria-expanded":p,title:"Settings",type:"button",children:e.jsx(F,{})}),p&&e.jsxs("div",{className:"plex-video-player__settings-menu "+(p?"plex-video-player__settings-menu--open":""),children:["main"===v&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"plex-video-player__settings-title",children:"Settings"}),e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("speed"),type:"button",children:[e.jsx("span",{children:"Playback Speed"}),e.jsx("span",{children:1===r?"Normal":`${r}x`})]}),l&&a&&a.length>1&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("quality"),type:"button",children:[e.jsx("span",{children:"Quality"}),e.jsx("span",{children:i||"Auto"})]}),o&&u&&u.length>0&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>x("captions"),type:"button",children:[e.jsx("span",{children:"Captions"}),e.jsx("span",{children:d||"Off"})]})]}),"speed"===v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>x("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Playback Speed"}),e.jsx("div",{className:"plex-video-player__speed-menu",children:s.map(t=>e.jsx("button",{className:"plex-video-player__speed-btn "+(r===t?"plex-video-player__speed-btn--active":""),onClick:()=>w(t),type:"button",children:1===t?"Normal":`${t}x`},t))})]}),"quality"===v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>x("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Quality"}),e.jsx("div",{className:"plex-video-player__quality-menu",children:a?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(i===t.quality?"plex-video-player__settings-item--active":""),onClick:()=>b(t.quality||t.src),type:"button",children:[e.jsx("span",{children:t.label||t.quality||"Unknown"}),i===t.quality&&e.jsx(H,{size:16})]},t.quality||t.src))})]}),"captions"===v&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>x("main"),style:{cursor:"pointer",border:"none",background:"transparent",width:"100%",textAlign:"left"},type:"button",children:"← Captions"}),e.jsxs("div",{className:"plex-video-player__quality-menu",children:[e.jsxs("button",{className:"plex-video-player__settings-item "+(d?"":"plex-video-player__settings-item--active"),onClick:()=>y(null),type:"button",children:[e.jsx("span",{children:"Off"}),!d&&e.jsx(H,{size:16})]}),u?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(d===t.srclang?"plex-video-player__settings-item--active":""),onClick:()=>y(t.srclang),type:"button",children:[e.jsx("span",{children:t.label}),d===t.srclang&&e.jsx(H,{size:16})]},t.srclang))]})]})]})]})},exports.SkipNextIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 18l8.5-6L6 6v12zM16 6v12h2V6h-2z"})}),exports.SkipPrevIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M6 6h2v12H6zm3.5 6l8.5 6V6z"})}),exports.SpeedIcon=({className:t,size:r=24})=>e.jsx("svg",{className:t,width:r,height:r,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M20.38 8.57l-1.23 1.85a8 8 0 0 1-.22 7.58H5.07A8 8 0 0 1 15.58 6.85l1.85-1.23A10 10 0 0 0 3.35 19a2 2 0 0 0 1.72 1h13.85a2 2 0 0 0 1.74-1 10 10 0 0 0-.27-10.44zm-9.79 6.84a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"})}),exports.VolumeControl=({volume:r,muted:s,onVolumeChange:n,onToggleMute:l})=>{const a=t.useCallback(e=>{const t=parseFloat(e.target.value);n(t)},[n]);return e.jsxs("div",{className:"plex-video-player__volume-container",children:[e.jsx("button",{className:"plex-video-player__btn",onClick:l,"aria-label":s?"Unmute":"Mute",title:s?"Unmute (M)":"Mute (M)",type:"button",children:s||0===r?e.jsx(V,{}):r<.33?e.jsx(A,{}):r<.66?e.jsx(T,{}):e.jsx(L,{})}),e.jsx("div",{className:"plex-video-player__volume-slider-container",children:e.jsx("input",{type:"range",className:"plex-video-player__volume-slider",min:0,max:1,step:.01,value:s?0:r,onChange:a,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(s?0:r)}%, var(--plex-progress-bg) ${100*(s?0:r)}%, var(--plex-progress-bg) 100%)`}})})]})},exports.VolumeHighIcon=L,exports.VolumeLowIcon=A,exports.VolumeMediumIcon=T,exports.VolumeMuteIcon=V,exports.canPlayType=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},exports.clamp=h,exports.convertToAdInfo=c,exports.debounce=(e,t)=>{let r=null;return(...s)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...s),t)}},exports.default=S,exports.detectVideoType=e=>{const t=e.split("?")[0].split(".").pop()?.toLowerCase();return{mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",mov:"video/quicktime",avi:"video/x-msvideo",mkv:"video/x-matroska"}[t||""]||"video/mp4"},exports.exitFullscreen=g,exports.fetchVastAd=n,exports.fireTrackingPixel=a,exports.fireTrackingPixels=i,exports.formatTime=u,exports.generateId=()=>`plex-${Math.random().toString(36).substring(2,11)}`,exports.getBufferedEnd=f,exports.getFullscreenElement=v,exports.isFullscreenSupported=()=>!!(document.fullscreenEnabled||document.webkitFullscreenEnabled||document.mozFullScreenEnabled||document.msFullscreenEnabled),exports.isHlsNativelySupported=()=>""!==document.createElement("video").canPlayType("application/vnd.apple.mpegurl"),exports.isMobile=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),exports.isPipSupported=m,exports.isTouchDevice=()=>"ontouchstart"in window||navigator.maxTouchPoints>0,exports.parseTime=e=>{const t=e.split(":").map(Number);return 3===t.length?3600*t[0]+60*t[1]+t[2]:2===t.length?60*t[0]+t[1]:t[0]||0},exports.parseVastXml=r,exports.percentage=d,exports.requestFullscreen=x,exports.selectBestMediaFile=l,exports.throttle=p,exports.useKeyboard=({enabled:e,hotkeys:r={},onPlay:s,onMute:n,onFullscreen:l,onPip:a,onSeek:i,onVolume:c,containerRef:o})=>{const u={...D,...r},d=t.useCallback(t=>{if(!e)return;const r=t.target;if("INPUT"===r.tagName||"TEXTAREA"===r.tagName||r.isContentEditable)return;const d=o.current;if(!d||!d.contains(document.activeElement))return;switch(t.key){case u.play:case" ":t.preventDefault(),s();break;case u.mute:case"M":t.preventDefault(),n();break;case u.fullscreen:case"F":t.preventDefault(),l();break;case u.pip:case"P":t.preventDefault(),a();break;case u.seekForward:t.preventDefault(),i(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),i(t.shiftKey?-30:-10);break;case u.volumeUp:t.preventDefault(),c(.1);break;case u.volumeDown:t.preventDefault(),c(-.1);break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":t.preventDefault(),i(-1/0)}},[e,u,s,n,l,a,i,c,o]);t.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[e,d])},exports.usePlayer=(e={})=>{const{autoPlay:r=!1,muted:s=!1,loop:n=!1,volume:l=1,playbackRate:a=1}=e,i=t.useRef(null),c=t.useRef(null),[o,u]=t.useState({...q,volume:l,isMuted:s,playbackRate:a}),d=t.useCallback(e=>{u(t=>({...t,...e}))},[]),h=t.useCallback(async()=>{const e=i.current;if(e)try{await e.play(),d({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[d]),p=t.useCallback(()=>{const e=i.current;e&&(e.pause(),d({isPlaying:!1,isPaused:!0}))},[d]),w=t.useCallback(()=>{o.isPlaying?p():h()},[o.isPlaying,h,p]),b=t.useCallback(e=>{const t=i.current;if(!t)return;const r=Math.max(0,Math.min(e,t.duration||0));t.currentTime=r,d({currentTime:r})},[d]),y=t.useCallback(e=>{const t=i.current;if(!t)return;const r=Math.max(0,Math.min(1,e));t.volume=r,t.muted=0===r,d({volume:r,isMuted:0===r})},[d]),k=t.useCallback(()=>{const e=i.current;e&&(e.muted=!e.muted,d({isMuted:e.muted}))},[d]),j=t.useCallback(e=>{const t=i.current;t&&(t.playbackRate=e,d({playbackRate:e}))},[d]),C=t.useCallback(async()=>{const e=c.current;if(e)try{await x(e),d({isFullscreen:!0})}catch(e){}},[d]),N=t.useCallback(async()=>{try{await g(),d({isFullscreen:!1})}catch(e){}},[d]),E=t.useCallback(async()=>{o.isFullscreen?await N():await C()},[o.isFullscreen,C,N]),z=t.useCallback(async()=>{const e=i.current;if(e&&m())try{await e.requestPictureInPicture(),d({isPip:!0})}catch(e){}},[d]),M=t.useCallback(async()=>{if(document.pictureInPictureElement)try{await document.exitPictureInPicture(),d({isPip:!1})}catch(e){}},[d]),P=t.useCallback(async()=>{o.isPip?await M():await z()},[o.isPip,z,M]);return t.useEffect(()=>{const e=i.current;if(!e)return;e.muted=s,e.volume=l,e.playbackRate=a,e.loop=n;const t={loadedmetadata:()=>{d({duration:e.duration})},timeupdate:()=>{d({currentTime:e.currentTime,buffered:f(e)})},play:()=>{d({isPlaying:!0,isPaused:!1,isEnded:!1})},pause:()=>{d({isPlaying:!1,isPaused:!0})},ended:()=>{d({isPlaying:!1,isPaused:!0,isEnded:!0})},waiting:()=>{d({isBuffering:!0})},canplay:()=>{d({isBuffering:!1})},seeking:()=>{d({isSeeking:!0})},seeked:()=>{d({isSeeking:!1})},volumechange:()=>{d({volume:e.volume,isMuted:e.muted})},ratechange:()=>{d({playbackRate:e.playbackRate})},error:()=>{d({error:e.error})},enterpictureinpicture:()=>{d({isPip:!0})},leavepictureinpicture:()=>{d({isPip:!1})}};return Object.entries(t).forEach(([t,r])=>{e.addEventListener(t,r)}),r&&h(),()=>{Object.entries(t).forEach(([t,r])=>{e.removeEventListener(t,r)})}},[r,s,n,l,a,h,d]),t.useEffect(()=>{const e=()=>{const e=!!v();d({isFullscreen:e})};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}},[d]),{state:o,videoRef:i,containerRef:c,play:h,pause:p,togglePlay:w,seek:b,setVolume:y,toggleMute:k,setPlaybackRate:j,enterFullscreen:C,exitFullscreen:N,toggleFullscreen:E,enterPip:z,exitPip:M,togglePip:P}},exports.useVast=o;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|