@frameset/plex-player 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
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;
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 s=e.getAttribute("id")||"",l=t.querySelector("AdTitle")?.textContent||"",i=t.querySelector("Description")?.textContent||void 0,a=t.querySelectorAll("Creative");let o,c,u=0;const d=[],p=[],h={};a.forEach(e=>{const t=e.querySelector("Linear");if(!t)return;const r=t.querySelector("Duration")?.textContent;r&&(u=n(r));const s=t.getAttribute("skipoffset");s&&(o=n(s));t.querySelectorAll("MediaFile").forEach(e=>{const t=e.textContent?.trim();t&&p.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&&(c=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&&(h[t]||(h[t]=[]),h[t].push(r))})});const m=[];t.querySelectorAll("Impression").forEach(e=>{const t=e.textContent?.trim();t&&m.push(t)}),p.length>0&&r.push({id:s,title:l,description:i,duration:u,skipOffset:o,clickThrough:c,clickTracking:d,impressionUrls:m,mediaFiles:p,trackingEvents:h})}),{ads:r}},n=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])},s=async e=>{try{const t=await fetch(e.url,{method:"GET",headers:{Accept:"application/xml"}});if(!t.ok)return null;const n=await t.text(),s=r(n);if(s.error||0===s.ads.length)return null;const l=s.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,n=t.width*t.height;return r!==n?n-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]},i=e=>{(new Image).src=e},a=e=>{e.forEach(i)},o=e=>({id:e.id,title:e.title,duration:e.duration,skipOffset:e.skipOffset,clickThrough:e.clickThrough}),c=({vastConfig:e,videoRef:r,onAdStart:n,onAdEnd:i,onAdSkip:c,onAdError:u})=>{const[d,p]=t.useState(!1),[h,m]=t.useState(null),[x,v]=t.useState(0),[g,f]=t.useState(!1),b=t.useRef(null),y=t.useRef(""),w=t.useRef(0),k=t.useRef(new Set),j=t.useRef(null),C=Array.isArray(e)?e:e?[e]:[],E=t.useCallback(async e=>{const t=r.current;if(t&&!d)try{const r=await s(e);if(!r)return void u?.(new Error("Failed to fetch VAST ad"));const i=l(r.mediaFiles);if(!i)return void u?.(new Error("No compatible media file found"));y.current=t.currentSrc,w.current=t.currentTime,a(r.impressionUrls),b.current=r,m(o(r)),p(!0),v(r.duration),f(void 0===r.skipOffset||0===r.skipOffset),t.src=i.url,t.currentTime=0,await t.play(),r.trackingEvents.start&&a(r.trackingEvents.start),n?.(o(r)),j.current=window.setInterval(()=>{const e=Math.max(0,r.duration-t.currentTime);v(e),r.skipOffset&&t.currentTime>=r.skipOffset&&f(!0);const n=t.currentTime/r.duration*100;n>=25&&r.trackingEvents.firstQuartile&&a(r.trackingEvents.firstQuartile),n>=50&&r.trackingEvents.midpoint&&a(r.trackingEvents.midpoint),n>=75&&r.trackingEvents.thirdQuartile&&a(r.trackingEvents.thirdQuartile)},250);const c=()=>{r.trackingEvents.complete&&a(r.trackingEvents.complete),z()};t.addEventListener("ended",c,{once:!0})}catch(e){u?.(e instanceof Error?e:new Error("Ad playback failed")),z()}},[r,d,n,u]),z=t.useCallback(()=>{const e=r.current;e&&(j.current&&(clearInterval(j.current),j.current=null),y.current&&(e.src=y.current,e.currentTime=w.current,e.play().catch(()=>{})),p(!1),m(null),v(0),f(!1),b.current=null,i?.())},[r,i]),S=t.useCallback(()=>{if(!g||!b.current)return;const e=b.current;e.trackingEvents.skip&&a(e.trackingEvents.skip),c?.(),z()},[g,z,c]),M=t.useCallback(()=>{if(!b.current)return;const e=b.current;e.clickThrough&&window.open(e.clickThrough,"_blank"),e.clickTracking&&a(e.clickTracking)},[]),P=t.useCallback((e,t)=>{d||0===C.length||C.forEach(r=>{const n=r.position||"preroll",s=`${n}-${r.midrollTime||0}`;if(k.current.has(s))return;let l=!1;switch(n){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(s),E(r))})},[C,d,E]);return t.useEffect(()=>()=>{j.current&&clearInterval(j.current)},[]),{isAdPlaying:d,currentAd:h,adTimeRemaining:x,canSkip:g,skipAd:S,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),n=Math.floor(e%60);return t>0?`${t}:${r.toString().padStart(2,"0")}:${n.toString().padStart(2,"0")}`:`${r}:${n.toString().padStart(2,"0")}`},d=(e,t)=>0===t?0:Math.min(100,Math.max(0,e/t*100)),p=(e,t,r)=>Math.min(r,Math.max(t,e)),h=(e,t)=>{let r=!1;return(...n)=>{r||(e(...n),r=!0,setTimeout(()=>r=!1,t))}},m=()=>"pictureInPictureEnabled"in document&&document.pictureInPictureEnabled,x=()=>document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement||null,v=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)},b=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M8 5v14l11-7z"})}),y=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-6 h-6",children:e.jsx("path",{d:"M6 19h4V5H6v14zm8-14v14h4V5h-4z"})}),w=()=>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"})}),E=()=>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"})}),z=()=>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"})}),S=()=>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"})}),N=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",style:{width:20,height:20},children:e.jsx("path",{d:"M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"})}),_=t.forwardRef((r,n)=>{const{src:s,poster:l,autoPlay:i=!1,muted:a=!1,loop:o=!1,controls:d=!0,width:p="100%",className:m="",style:x={},pip:v=!0,fullscreen:g=!0,playbackSpeed:f=!0,playbackSpeeds:_=[.5,.75,1,1.25,1.5,2],volume:L=!0,initialVolume:T=1,textTracks:A=[],vast:I,accentColor:F="#f5c518",controlsTimeout:R=3e3,doubleClickFullscreen:V=!0,clickToPlay:B=!0,preload:H="metadata",playlist:q=[],onPlay:D,onPause:$,onEnded:O,onTimeUpdate:U,onProgress:X,onVolumeChange:Q,onFullscreenChange:W,onPipChange:K,onQualityChange:Y,onError:G,onAdStart:J,onAdEnd:Z,onAdSkip:ee,onAdError:te,onReady:re,onPlaylistItemChange:ne}=r,se=t.useRef(null),le=t.useRef(null),ie=t.useRef(null),ae=t.useRef(null),oe=t.useRef(0),[ce,ue]=t.useState(!1),[de,pe]=t.useState(0),[he,me]=t.useState(0),[xe,ve]=t.useState(0),[ge,fe]=t.useState(a?0:T),[be,ye]=t.useState(a),[we,ke]=t.useState(!1),[je,Ce]=t.useState(!1),[Ee,ze]=t.useState(!0),[Se,Me]=t.useState(null),[Pe,Ne]=t.useState(!0),[_e,Le]=t.useState(1),[Te,Ae]=t.useState(o),[Ie,Fe]=t.useState(!1),[Re,Ve]=t.useState(!1),[Be,He]=t.useState(null),[qe,De]=t.useState({x:0,y:0,visible:!1}),[$e,Oe]=t.useState(0),Ue=t.useMemo(()=>"string"==typeof s?[{src:s,type:"video/mp4"}]:s,[s]),Xe=t.useMemo(()=>q.length>0&&q[$e]?q[$e].src:Ue[0]?.src||"",[q,$e,Ue]),Qe=t.useMemo(()=>q.length>0&&q[$e]?.poster?q[$e].poster:l,[q,$e,l]),{currentAd:We,isAdPlaying:Ke,adTimeRemaining:Ye,canSkip:Ge,skipAd:Je,handleAdClick:Ze,checkForAd:et}=c({vastConfig:I,videoRef:se,onAdStart:J,onAdEnd:Z,onAdSkip:ee,onAdError:te}),tt=t.useCallback(async()=>{const e=se.current;if(e)try{await e.play()}catch(e){}},[]),rt=t.useCallback(()=>{se.current?.pause()},[]),nt=t.useCallback(()=>{const e=se.current;e&&(e.pause(),e.currentTime=0)},[]),st=t.useCallback(()=>{se.current?.paused?tt():rt()},[tt,rt]),lt=t.useCallback(e=>{const t=se.current;t&&(t.currentTime=Math.max(0,Math.min(e,t.duration||0)))},[]),it=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,fe(r),ye(0===r)},[]),at=t.useCallback(()=>{se.current&&(se.current.muted=!0,ye(!0))},[]),ot=t.useCallback(()=>{const e=se.current;e&&(e.muted=!1,0===e.volume&&(e.volume=.5,fe(.5)),ye(!1))},[]),ct=t.useCallback(()=>{se.current?.muted?ot():at()},[at,ot]),ut=t.useCallback(()=>{se.current&&(se.current.loop=!se.current.loop,Ae(se.current.loop))},[]),dt=t.useCallback(async()=>{try{await(le.current?.requestFullscreen()),ke(!0)}catch(e){}},[]),pt=t.useCallback(async()=>{try{document.fullscreenElement&&(await document.exitFullscreen(),ke(!1))}catch(e){}},[]),ht=t.useCallback(async()=>{document.fullscreenElement?await pt():await dt()},[dt,pt]),mt=t.useCallback(async()=>{try{await(se.current?.requestPictureInPicture()),Ce(!0)}catch(e){}},[]),xt=t.useCallback(async()=>{try{document.pictureInPictureElement&&(await document.exitPictureInPicture(),Ce(!1))}catch(e){}},[]),vt=t.useCallback(async()=>{document.pictureInPictureElement?await xt():await mt()},[mt,xt]),gt=t.useCallback(e=>{se.current&&(se.current.playbackRate=e,Le(e),Fe(!1))},[]),ft=t.useCallback(e=>{const t=Ue.find(t=>t.label===e||t.quality===e);if(t&&se.current){const r=se.current,n=!r.paused,s=r.currentTime;r.src=t.src,r.currentTime=s,n&&r.play(),Y?.(e)}},[Ue,Y]),bt=t.useCallback(()=>{if(0===q.length)return;const e=($e+1)%q.length;Oe(e),ne?.(e,q[e]),setTimeout(()=>tt(),100)},[$e,q,ne,tt]),yt=t.useCallback(e=>{e.preventDefault();const t=le.current?.getBoundingClientRect();t&&De({x:e.clientX-t.left,y:e.clientY-t.top,visible:!0})},[]),wt=t.useCallback(()=>{De(e=>({...e,visible:!1}))},[]),kt=t.useCallback(()=>{navigator.clipboard.writeText(Xe),wt()},[Xe,wt]),jt=t.useCallback(e=>{const t=ie.current?.getBoundingClientRect();if(t&&he){const r=(e.clientX-t.left)/t.width;lt(r*he)}},[he,lt]),Ct=t.useCallback(e=>{const t=ie.current?.getBoundingClientRect();if(t&&he){const r=(e.clientX-t.left)/t.width*he;He({time:Math.max(0,Math.min(he,r)),x:e.clientX-t.left})}},[he]),Et=t.useCallback(()=>{He(null)},[]),zt=t.useCallback(()=>{ce&&!Ie&&Ne(!1)},[ce,Ie]),St=t.useCallback(()=>{Ne(!0),ae.current&&clearTimeout(ae.current),ce&&(ae.current=setTimeout(zt,R))},[ce,R,zt]),Mt=t.useMemo(()=>h(St,200),[St]),Pt=t.useCallback(()=>{if(wt(),!B)return;const e=Date.now();V&&e-oe.current<300?ht():st(),oe.current=e},[B,V,st,ht,wt]);t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{ue(!0),D?.()},r=()=>{ue(!1),$?.()},n=()=>{ue(!1),O?.(),q.length>0&&bt()},s=()=>{pe(e.currentTime),U?.(e.currentTime),et(e.currentTime,e.duration)},l=()=>me(e.duration),i=()=>{if(e.buffered.length>0){const t=e.buffered.end(e.buffered.length-1);ve(t/e.duration*100),X?.(t/e.duration*100)}},a=()=>{fe(e.volume),ye(e.muted),Q?.(e.volume,e.muted)},o=()=>{me(e.duration),ze(!1),re?.()},c=()=>ze(!0),u=()=>ze(!1),d=()=>ze(!1),p=()=>{Me(e.error),ze(!1),G?.(e.error)};return e.addEventListener("play",t),e.addEventListener("pause",r),e.addEventListener("ended",n),e.addEventListener("timeupdate",s),e.addEventListener("durationchange",l),e.addEventListener("progress",i),e.addEventListener("volumechange",a),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",r),e.removeEventListener("ended",n),e.removeEventListener("timeupdate",s),e.removeEventListener("durationchange",l),e.removeEventListener("progress",i),e.removeEventListener("volumechange",a),e.removeEventListener("loadedmetadata",o),e.removeEventListener("waiting",c),e.removeEventListener("playing",u),e.removeEventListener("canplay",d),e.removeEventListener("error",p)}},[D,$,O,U,X,Q,re,G,et,q.length,bt]),t.useEffect(()=>{const e=()=>{const e=!!document.fullscreenElement;ke(e),W?.(e)};return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[W]),t.useEffect(()=>{const e=se.current;if(!e)return;const t=()=>{Ce(!0),K?.(!0)},r=()=>{Ce(!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(le.current?.contains(document.activeElement))switch(e.key){case" ":case"k":e.preventDefault(),st();break;case"m":e.preventDefault(),ct();break;case"f":e.preventDefault(),ht();break;case"ArrowLeft":e.preventDefault(),lt(de-10);break;case"ArrowRight":e.preventDefault(),lt(de+10);break;case"ArrowUp":e.preventDefault(),it(ge+.1);break;case"ArrowDown":e.preventDefault(),it(ge-.1)}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[st,ct,ht,lt,it,de,ge]),t.useEffect(()=>()=>{ae.current&&clearTimeout(ae.current)},[]),t.useEffect(()=>{const e=()=>wt();if(qe.visible)return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[qe.visible,wt]),t.useImperativeHandle(n,()=>({play:tt,pause:rt,stop:nt,seek:lt,setVolume:it,mute:at,unmute:ot,toggleMute:ct,enterFullscreen:dt,exitFullscreen:pt,toggleFullscreen:ht,enterPip:mt,exitPip:xt,togglePip:vt,setPlaybackRate:gt,setQuality:ft,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:()=>we,isPip:()=>je,getVideoElement:()=>se.current}),[tt,rt,nt,lt,it,at,ot,ct,dt,pt,ht,mt,xt,vt,gt,ft,we,je]);const Nt=he?de/he*100:0;return e.jsxs("div",{ref:le,className:m,style:{position:we?"fixed":"relative",inset:we?0:void 0,zIndex:we?9999:void 0,width:p,aspectRatio:we?"unset":"16/9",height:we?"100%":void 0,backgroundColor:"#000",overflow:"hidden",userSelect:"none",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',...x},onMouseMove:Mt,onMouseLeave:()=>ce&&Ne(!1),onContextMenu:yt,tabIndex:0,children:[e.jsx("video",{ref:se,style:{width:"100%",height:"100%",objectFit:"contain"},src:Xe,poster:Qe,autoPlay:i,muted:a,loop:Te,preload:H,playsInline:!0,onClick:Pt,children:A.map((t,r)=>e.jsx("track",{kind:t.kind,src:t.src,srcLang:t.srclang,label:t.label,default:t.default},r))}),Ee&&!Se&&e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:e.jsx("div",{style:{width:48,height:48,border:"4px solid transparent",borderTopColor:F,borderRadius:"50%",animation:"spin 1s linear infinite"}})}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"}),Se&&e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.9)",color:"#fff"},children:[e.jsx("svg",{style:{width:64,height:64,marginBottom:16},fill:F,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",{style:{fontSize:18,marginBottom:8},children:"Error loading video"}),e.jsx("button",{onClick:()=>{Me(null),se.current?.load()},style:{padding:"8px 24px",borderRadius:4,border:"none",backgroundColor:F,color:"#000",fontWeight:500,cursor:"pointer"},children:"Retry"})]}),Ke&&We&&e.jsxs("div",{style:{position:"absolute",inset:0,zIndex:20},children:[e.jsxs("div",{style:{position:"absolute",top:16,left:16,display:"flex",alignItems:"center",gap:12,padding:"8px 12px",background:"rgba(0,0,0,0.7)",borderRadius:4,color:"#fff",fontSize:14},children:[e.jsx("span",{style:{padding:"2px 8px",borderRadius:4,fontSize:11,fontWeight:700,backgroundColor:F,color:"#000"},children:"AD"}),e.jsxs("span",{children:[u(Ye)," remaining"]})]}),e.jsx("button",{onClick:Ge?Je:void 0,disabled:!Ge,style:{position:"absolute",bottom:80,right:16,padding:"8px 20px",border:"1px solid #fff",borderRadius:4,background:"transparent",color:"#fff",cursor:Ge?"pointer":"not-allowed",opacity:Ge?1:.5},children:Ge?"Skip Ad":`Skip in ${Math.ceil(Ye)}s`})]}),qe.visible&&e.jsxs("div",{style:{position:"absolute",left:qe.x,top:qe.y,zIndex:50,minWidth:200,background:"rgba(26,26,26,0.95)",backdropFilter:"blur(8px)",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",overflow:"hidden"},onClick:e=>e.stopPropagation(),children:[e.jsxs("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{st(),wt()},children:[ce?e.jsx(y,{}):e.jsx(b,{}),e.jsx("span",{style:{flex:1},children:ce?"Pause":"Play"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"Space"})]}),e.jsxs("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{ct(),wt()},children:[be?e.jsx(k,{}):e.jsx(w,{}),e.jsx("span",{style:{flex:1},children:be?"Unmute":"Mute"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"M"})]}),e.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),e.jsxs("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{ut(),wt()},children:[e.jsx(S,{}),e.jsx("span",{style:{flex:1},children:Te?"Disable Loop":"Enable Loop"}),Te&&e.jsx("span",{style:{color:F},children:"✓"})]}),e.jsxs("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{const e=[.5,.75,1,1.25,1.5,2],t=e.indexOf(_e);gt(e[(t+1)%e.length]),wt()},children:[e.jsx(P,{}),e.jsxs("span",{style:{flex:1},children:["Speed: ",_e,"x"]})]}),e.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),v&&document.pictureInPictureEnabled&&e.jsxs("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{vt(),wt()},children:[e.jsx(E,{}),e.jsx("span",{style:{flex:1},children:"Picture in Picture"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"P"})]}),e.jsxs("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:()=>{ht(),wt()},children:[e.jsx(j,{}),e.jsx("span",{style:{flex:1},children:"Fullscreen"}),e.jsx("span",{style:{color:"rgba(255,255,255,0.5)",fontSize:11},children:"F"})]}),e.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.1)",margin:"4px 0"}}),e.jsxs("button",{style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:"12px 16px",background:"transparent",border:"none",color:"#fff",fontSize:14,cursor:"pointer",textAlign:"left"},onClick:kt,children:[e.jsx(M,{}),e.jsx("span",{style:{flex:1},children:"Copy Video URL"})]}),e.jsx("div",{style:{padding:"8px 16px",fontSize:10,color:"rgba(255,255,255,0.4)",textAlign:"center",borderTop:"1px solid rgba(255,255,255,0.1)"},children:"PlexVideo Player © FRAMESET STUDIO"})]}),d&&!Ke&&e.jsxs("div",{style:{position:"absolute",bottom:0,left:0,right:0,background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",padding:16,transition:"opacity 0.3s",opacity:Pe?1:0,pointerEvents:Pe?"auto":"none"},children:[e.jsxs("div",{ref:ie,onClick:jt,onMouseMove:Ct,onMouseLeave:Et,style:{position:"relative",height:8,background:"rgba(255,255,255,0.3)",borderRadius:4,marginBottom:16,cursor:"pointer"},children:[e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${xe}%`,background:"rgba(255,255,255,0.5)",borderRadius:4}}),e.jsx("div",{style:{position:"absolute",top:0,left:0,height:"100%",width:`${Nt}%`,background:F,borderRadius:4}}),e.jsx("div",{style:{position:"absolute",top:"50%",left:`${Nt}%`,transform:"translate(-50%, -50%)",width:16,height:16,borderRadius:"50%",background:F,boxShadow:"0 2px 8px rgba(0,0,0,0.5)"}}),Be&&e.jsx("div",{style:{position:"absolute",bottom:"100%",left:Be.x,transform:"translateX(-50%)",marginBottom:8,padding:"4px 8px",background:"rgba(0,0,0,0.9)",color:"#fff",fontSize:12,borderRadius:4,whiteSpace:"nowrap",pointerEvents:"none"},children:u(Be.time)})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("button",{onClick:st,"aria-label":ce?"Pause":"Play",style:{width:44,height:44,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"transparent",border:"none",color:"#fff",cursor:"pointer"},children:ce?e.jsx(y,{}):e.jsx(b,{})}),L&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[e.jsx("button",{onClick:ct,"aria-label":be?"Unmute":"Mute",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer"},children:be||0===ge?e.jsx(k,{}):e.jsx(w,{})}),e.jsx("input",{type:"range",min:"0",max:"1",step:"0.01",value:be?0:ge,onChange:e=>it(parseFloat(e.target.value)),style:{width:70,height:4,cursor:"pointer",accentColor:F}})]}),e.jsxs("div",{style:{color:"#fff",fontSize:13,fontFamily:"monospace",marginLeft:8},children:[u(de)," / ",u(he)]}),e.jsx("div",{style:{flex:1}}),q.length>0&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>Ve(!Re),"aria-label":"Playlist",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:Re?"rgba(255,255,255,0.2)":"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:e.jsx(N,{})}),Re&&e.jsxs("div",{style:{position:"absolute",bottom:48,right:0,width:280,maxHeight:300,overflowY:"auto",background:"#1a1a1a",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",border:"1px solid rgba(255,255,255,0.1)",zIndex:100},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.6)",fontSize:12,fontWeight:600,textTransform:"uppercase"},children:["Playlist (",q.length," items)"]}),q.map((t,r)=>e.jsxs("button",{onClick:()=>{Oe(r),ne?.(r,t),Ve(!1),setTimeout(()=>tt(),100)},style:{width:"100%",padding:"10px 16px",display:"flex",alignItems:"center",gap:12,background:$e===r?"rgba(255,255,255,0.1)":"transparent",border:"none",color:$e===r?F:"#fff",cursor:"pointer",textAlign:"left",fontSize:14},children:[e.jsx("span",{style:{width:24,color:"rgba(255,255,255,0.5)"},children:r+1}),e.jsx("span",{style:{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.title}),$e===r&&e.jsx("span",{children:"▶"})]},t.id))]})]}),f&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:()=>Fe(!Ie),"aria-label":"Settings",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:Ie?"rgba(255,255,255,0.2)":"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:e.jsx(z,{})}),Ie&&e.jsxs("div",{style:{position:"absolute",bottom:48,right:0,minWidth:160,background:"#1a1a1a",borderRadius:8,boxShadow:"0 8px 32px rgba(0,0,0,0.5)",border:"1px solid rgba(255,255,255,0.1)",zIndex:100,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.6)",fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:.5},children:"Playback Speed"}),_.map(t=>e.jsxs("button",{onClick:()=>gt(t),style:{width:"100%",padding:"10px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",background:"transparent",border:"none",color:_e===t?F:"#fff",cursor:"pointer",fontSize:14},children:[e.jsx("span",{children:1===t?"Normal":`${t}x`}),_e===t&&e.jsx("span",{children:"✓"})]},t))]})]}),v&&document.pictureInPictureEnabled&&e.jsx("button",{onClick:vt,"aria-label":"Picture in Picture",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:e.jsx(E,{})}),g&&e.jsx("button",{onClick:ht,"aria-label":we?"Exit Fullscreen":"Fullscreen",style:{width:36,height:36,display:"flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"none",color:"#fff",cursor:"pointer",borderRadius:4},children:we?e.jsx(C,{}):e.jsx(j,{})})]})]}),!ce&&!Ee&&!Se&&!Ke&&e.jsx("button",{onClick:st,"aria-label":"Play",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:80,height:80,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",border:"none",cursor:"pointer",backgroundColor:F,boxShadow:"0 8px 32px rgba(0,0,0,0.4)",transition:"transform 0.2s"},children:e.jsx("svg",{viewBox:"0 0 24 24",fill:"white",style:{width:32,height:32,marginLeft:4},children:e.jsx("path",{d:"M8 5v14l11-7z"})})})]})});_.displayName="PlexVideoPlayer";const L=(e,t,r,n,s)=>{const l=Math.floor(e/r);return`-${l%10*n}px -${Math.floor(l/10)*s}px`},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:"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"})}),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:"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"})}),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:"M7 9v6h4l5 5V4l-5 5H7z"})}),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:"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"})}),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:"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"})}),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:"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"})}),B=({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"})}),q={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."},D={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},$={play:"Space",mute:"m",fullscreen:"f",pip:"p",seekForward:"ArrowRight",seekBackward:"ArrowLeft",volumeUp:"ArrowUp",volumeDown:"ArrowDown"};exports.AdOverlay=({ad:t,timeRemaining:r,canSkip:n,onSkip:s,onClick:l})=>{const i=n?"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(B,{size:16}),"Learn More"]}),e.jsx("button",{className:"plex-video-player__ad-skip",onClick:e=>{e.stopPropagation(),n&&s()},disabled:!n,type:"button",children:i})]})},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 n=t?.code||0,s=q[n]||"An unknown error occurred.";return e.jsxs("div",{className:"plex-video-player__error",children:[e.jsx(V,{className:"plex-video-player__error-icon",size:60}),e.jsx("div",{className:"plex-video-player__error-message",children:s}),n>0&&e.jsxs("div",{className:"plex-video-player__error-code",children:["Error Code: ",n]}),e.jsx("button",{className:"plex-video-player__error-retry",onClick:r,type:"button",children:"Try Again"})]})},exports.ErrorIcon=V,exports.ExternalLinkIcon=B,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=_,exports.ProgressBar=({currentTime:r,duration:n,buffered:s,onSeek:l,thumbnailPreview:i,disabled:a=!1})=>{const o=t.useRef(null),[c,h]=t.useState(!1),[m,x]=t.useState(null),[v,g]=t.useState(0),f=d(r,n),b=d(s,n),y=t.useCallback(e=>{if(!o.current)return 0;const t=o.current.getBoundingClientRect();return p((e-t.left)/t.width,0,1)*n},[n]),w=t.useCallback(e=>{if(!o.current)return;const t=o.current.getBoundingClientRect(),r="clientX"in e?e.clientX:0,n=p(r-t.left,0,t.width),s=y(r);g(n),x(s),c&&l(s)},[c,y,l]),k=t.useCallback(e=>{if(a)return;e.preventDefault(),h(!0);const t=y(e.clientX);l(t)},[a,y,l]),j=t.useCallback(()=>{h(!1)},[]),C=t.useCallback(e=>{const t=y(e.clientX);x(t)},[y]),E=t.useCallback(()=>{x(null)},[]);t.useEffect(()=>{if(c){const e=e=>w(e);return window.addEventListener("mousemove",e),window.addEventListener("mouseup",j),()=>{window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",j)}}},[c,w,j]);const z=t.useCallback(e=>{if(a)return;e.preventDefault();const t=e.touches[0],r=y(t.clientX);h(!0),l(r)},[a,y,l]),S=t.useCallback(e=>{if(!c)return;const t=e.touches[0],r=y(t.clientX);l(r)},[c,y,l]),M=t.useCallback(()=>{h(!1)},[]);return e.jsxs("div",{ref:o,className:"plex-video-player__progress-container",onMouseDown:k,onMouseEnter:C,onMouseLeave:E,onMouseMove:e=>w(e.nativeEvent),onTouchStart:z,onTouchMove:S,onTouchEnd:M,role:"slider","aria-label":"Video progress","aria-valuemin":0,"aria-valuemax":n,"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:`${b}%`}}),e.jsx("div",{className:"plex-video-player__progress-played",style:{width:`${f}%`}}),e.jsx("div",{className:"plex-video-player__progress-handle",style:{left:`${f}%`}})]}),i?.enabled&&null!==m&&e.jsxs("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${v}px`,width:i.width||160,height:i.height||90},children:[i.sprites&&e.jsx("div",{style:{width:"100%",height:"100%",backgroundImage:`url(${i.sprites})`,backgroundPosition:L(m,n,i.interval||10,i.width||160,i.height||90),backgroundSize:"cover"}}),e.jsx("div",{className:"plex-video-player__thumbnail-time",children:u(m)})]}),null!==m&&!i?.enabled&&e.jsx("div",{className:"plex-video-player__thumbnail-preview",style:{left:`${v}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=R,exports.SettingsMenu=({playbackRate:r,playbackSpeeds:n,onPlaybackRateChange:s,qualityEnabled:l,sources:i,currentQuality:a,onQualityChange:o,captionsEnabled:c,textTracks:u,currentTrack:d,onTrackChange:p})=>{const[h,m]=t.useState(!1),[x,v]=t.useState("main"),g=t.useRef(null);t.useEffect(()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&(m(!1),v("main"))};if(h)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[h]);const f=t.useCallback(()=>{m(e=>!e),v("main")},[]),b=t.useCallback(e=>{s(e),v("main")},[s]),y=t.useCallback(e=>{o?.(e),v("main")},[o]),w=t.useCallback(e=>{p?.(e),v("main")},[p]);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":h,title:"Settings",type:"button",children:e.jsx(R,{})}),h&&e.jsxs("div",{className:"plex-video-player__settings-menu "+(h?"plex-video-player__settings-menu--open":""),children:["main"===x&&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:()=>v("speed"),type:"button",children:[e.jsx("span",{children:"Playback Speed"}),e.jsx("span",{children:1===r?"Normal":`${r}x`})]}),l&&i&&i.length>1&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>v("quality"),type:"button",children:[e.jsx("span",{children:"Quality"}),e.jsx("span",{children:a||"Auto"})]}),c&&u&&u.length>0&&e.jsxs("button",{className:"plex-video-player__settings-item",onClick:()=>v("captions"),type:"button",children:[e.jsx("span",{children:"Captions"}),e.jsx("span",{children:d||"Off"})]})]}),"speed"===x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>v("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:n.map(t=>e.jsx("button",{className:"plex-video-player__speed-btn "+(r===t?"plex-video-player__speed-btn--active":""),onClick:()=>b(t),type:"button",children:1===t?"Normal":`${t}x`},t))})]}),"quality"===x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>v("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:i?.map(t=>e.jsxs("button",{className:"plex-video-player__settings-item "+(a===t.quality?"plex-video-player__settings-item--active":""),onClick:()=>y(t.quality||t.src),type:"button",children:[e.jsx("span",{children:t.label||t.quality||"Unknown"}),a===t.quality&&e.jsx(H,{size:16})]},t.quality||t.src))})]}),"captions"===x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"plex-video-player__settings-title",onClick:()=>v("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(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:()=>w(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:n,onVolumeChange:s,onToggleMute:l})=>{const i=t.useCallback(e=>{const t=parseFloat(e.target.value);s(t)},[s]);return e.jsxs("div",{className:"plex-video-player__volume-container",children:[e.jsx("button",{className:"plex-video-player__btn",onClick:l,"aria-label":n?"Unmute":"Mute",title:n?"Unmute (M)":"Mute (M)",type:"button",children:n||0===r?e.jsx(F,{}):r<.33?e.jsx(I,{}):r<.66?e.jsx(A,{}):e.jsx(T,{})}),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:n?0:r,onChange:i,"aria-label":"Volume",style:{background:`linear-gradient(to right, var(--plex-primary) 0%, var(--plex-primary) ${100*(n?0:r)}%, var(--plex-progress-bg) ${100*(n?0:r)}%, var(--plex-progress-bg) 100%)`}})})]})},exports.VolumeHighIcon=T,exports.VolumeLowIcon=I,exports.VolumeMediumIcon=A,exports.VolumeMuteIcon=F,exports.canPlayType=e=>{const t=document.createElement("video").canPlayType(e);return"probably"===t||"maybe"===t},exports.clamp=p,exports.convertToAdInfo=o,exports.debounce=(e,t)=>{let r=null;return(...n)=>{r&&clearTimeout(r),r=setTimeout(()=>e(...n),t)}},exports.default=_,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=s,exports.fireTrackingPixel=i,exports.fireTrackingPixels=a,exports.formatTime=u,exports.generateId=()=>`plex-${Math.random().toString(36).substring(2,11)}`,exports.getBufferedEnd=f,exports.getFullscreenElement=x,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=v,exports.selectBestMediaFile=l,exports.throttle=h,exports.useKeyboard=({enabled:e,hotkeys:r={},onPlay:n,onMute:s,onFullscreen:l,onPip:i,onSeek:a,onVolume:o,containerRef:c})=>{const u={...$,...r},d=t.useCallback(t=>{if(!e)return;const r=t.target;if("INPUT"===r.tagName||"TEXTAREA"===r.tagName||r.isContentEditable)return;const d=c.current;if(!d||!d.contains(document.activeElement))return;switch(t.key){case u.play:case" ":t.preventDefault(),n();break;case u.mute:case"M":t.preventDefault(),s();break;case u.fullscreen:case"F":t.preventDefault(),l();break;case u.pip:case"P":t.preventDefault(),i();break;case u.seekForward:t.preventDefault(),a(t.shiftKey?30:10);break;case u.seekBackward:t.preventDefault(),a(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(),a(-1/0)}},[e,u,n,s,l,i,a,o,c]);t.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[e,d])},exports.usePlayer=(e={})=>{const{autoPlay:r=!1,muted:n=!1,loop:s=!1,volume:l=1,playbackRate:i=1}=e,a=t.useRef(null),o=t.useRef(null),[c,u]=t.useState({...D,volume:l,isMuted:n,playbackRate:i}),d=t.useCallback(e=>{u(t=>({...t,...e}))},[]),p=t.useCallback(async()=>{const e=a.current;if(e)try{await e.play(),d({isPlaying:!0,isPaused:!1,isEnded:!1})}catch(e){}},[d]),h=t.useCallback(()=>{const e=a.current;e&&(e.pause(),d({isPlaying:!1,isPaused:!0}))},[d]),b=t.useCallback(()=>{c.isPlaying?h():p()},[c.isPlaying,p,h]),y=t.useCallback(e=>{const t=a.current;if(!t)return;const r=Math.max(0,Math.min(e,t.duration||0));t.currentTime=r,d({currentTime:r})},[d]),w=t.useCallback(e=>{const t=a.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=a.current;e&&(e.muted=!e.muted,d({isMuted:e.muted}))},[d]),j=t.useCallback(e=>{const t=a.current;t&&(t.playbackRate=e,d({playbackRate:e}))},[d]),C=t.useCallback(async()=>{const e=o.current;if(e)try{await v(e),d({isFullscreen:!0})}catch(e){}},[d]),E=t.useCallback(async()=>{try{await g(),d({isFullscreen:!1})}catch(e){}},[d]),z=t.useCallback(async()=>{c.isFullscreen?await E():await C()},[c.isFullscreen,C,E]),S=t.useCallback(async()=>{const e=a.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()=>{c.isPip?await M():await S()},[c.isPip,S,M]);return t.useEffect(()=>{const e=a.current;if(!e)return;e.muted=n,e.volume=l,e.playbackRate=i,e.loop=s;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&&p(),()=>{Object.entries(t).forEach(([t,r])=>{e.removeEventListener(t,r)})}},[r,n,s,l,i,p,d]),t.useEffect(()=>{const e=()=>{const e=!!x();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:c,videoRef:a,containerRef:o,play:p,pause:h,togglePlay:b,seek:y,setVolume:w,toggleMute:k,setPlaybackRate:j,enterFullscreen:C,exitFullscreen:E,toggleFullscreen:z,enterPip:S,exitPip:M,togglePip:P}},exports.useVast=c;
2
2
  //# sourceMappingURL=index.js.map