vidply 1.0.9 → 1.0.10
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/vidply.css +47 -14
- package/dist/vidply.esm.js +1063 -663
- package/dist/vidply.esm.js.map +3 -3
- package/dist/vidply.esm.min.js +3 -3
- package/dist/vidply.esm.min.meta.json +28 -10
- package/dist/vidply.js +1063 -663
- package/dist/vidply.js.map +3 -3
- package/dist/vidply.min.css +1 -1
- package/dist/vidply.min.js +3 -3
- package/dist/vidply.min.meta.json +27 -9
- package/package.json +1 -1
- package/src/controls/ControlBar.js +24 -14
- package/src/controls/TranscriptManager.js +344 -578
- package/src/core/Player.js +150 -276
- package/src/i18n/translations.js +50 -5
- package/src/styles/vidply.css +47 -14
- package/src/utils/DraggableResizable.js +771 -0
package/dist/vidply.min.js
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
* (c) 2025 Matthias Peltzer
|
|
5
5
|
* Released under GPL-2.0-or-later License
|
|
6
6
|
*/
|
|
7
|
-
var VidPly=(()=>{var Q=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var se=Object.prototype.hasOwnProperty;var ae=(d,e)=>()=>(d&&(e=d(d=0)),e);var Y=(d,e)=>{for(var t in e)Q(d,t,{get:e[t],enumerable:!0})},re=(d,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!se.call(d,s)&&s!==t&&Q(d,s,{get:()=>e[s],enumerable:!(i=te(e,s))||i.enumerable});return d};var ne=d=>re(Q({},"__esModule",{value:!0}),d);var J={};Y(J,{HTML5Renderer:()=>V});var V,_=ae(()=>{V=class{constructor(e){this.player=e,this.media=e.element}async init(){this.media.controls=!1,this.media.removeAttribute("controls"),this.attachEvents(),this.media.preload=this.player.options.preload,this.media.load()}attachEvents(){this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player),this.player.options.pauseOthersOnPlay&&this.pauseOtherPlayers()}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume),this.player.options.onVolumeChange&&this.player.options.onVolumeChange.call(this.player,this.media.volume)}),this.media.addEventListener("seeking",()=>{this.player.state.seeking=!0,this.player.emit("seeking")}),this.media.addEventListener("seeked",()=>{this.player.state.seeking=!1,this.player.emit("seeked")}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.media.addEventListener("progress",()=>{if(this.media.buffered.length>0){let e=this.media.buffered.end(this.media.buffered.length-1);this.player.emit("progress",e)}}),this.media.addEventListener("error",e=>{this.player.handleError(this.media.error)}),this.media.addEventListener("ratechange",()=>{this.player.state.playbackSpeed=this.media.playbackRate,this.player.emit("ratechange",this.media.playbackRate)})}pauseOtherPlayers(){document.querySelectorAll(".vidply-player").forEach(t=>{if(t!==this.player.container){let i=t.querySelector("video, audio");i&&!i.paused&&i.pause()}})}play(){let e=this.media.play();e!==void 0&&e.catch(t=>{this.player.log("Play failed:",t,"warn"),this.player.options.autoplay&&!this.player.state.muted&&(this.player.log("Retrying play with muted audio","info"),this.media.muted=!0,this.media.play().catch(i=>{this.player.handleError(i)}))})}pause(){this.media.pause()}seek(e){this.media.currentTime=e}setVolume(e){this.media.volume=e}setMuted(e){this.media.muted=e}setPlaybackSpeed(e){this.media.playbackRate=e}getQualities(){let e=Array.from(this.media.querySelectorAll("source"));return e.length<=1?[]:e.map((t,i)=>{let s=t.getAttribute("data-quality")||t.getAttribute("label")||"",a=t.getAttribute("data-height")||this.extractHeightFromLabel(s),r=t.getAttribute("data-width")||"";return{index:i,height:a?parseInt(a):0,width:r?parseInt(r):0,src:t.src,type:t.type,name:s||(a?`${a}p`:`Quality ${i+1}`)}}).filter(t=>t.height>0)}extractHeightFromLabel(e){let t=e.match(/(\d+)p/i);return t?parseInt(t[1]):0}switchQuality(e){let t=this.getQualities();if(e<0||e>=t.length){this.player.log("Invalid quality index","warn");return}let i=t[e],s=this.media.currentTime,a=!this.media.paused;if(this.media.currentSrc===i.src){this.player.log("Already at this quality level","info");return}this.player.log(`Switching to quality: ${i.name}`,"info"),this.media.src=i.src;let o=()=>{this.media.removeEventListener("loadedmetadata",o),this.media.currentTime=s,a&&this.media.play().catch(n=>{this.player.log("Failed to resume playback after quality switch","warn")}),this.player.emit("qualitychange",{quality:i.name,index:e})};this.media.addEventListener("loadedmetadata",o),this.media.load()}getCurrentQuality(){let e=this.getQualities(),t=this.media.currentSrc;for(let i=0;i<e.length;i++)if(e[i].src===t)return i;return 0}destroy(){this.media.removeEventListener("loadedmetadata",()=>{}),this.media.removeEventListener("play",()=>{}),this.media.removeEventListener("pause",()=>{})}}});var pe={};Y(pe,{Player:()=>z,PlaylistManager:()=>q,default:()=>de});var W=class{constructor(){this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),this}once(e,t){let i=(...s)=>{t(...s),this.off(e,i)};return this.on(e,i)}off(e,t){return this.events[e]?(t?this.events[e]=this.events[e].filter(i=>i!==t):delete this.events[e],this):this}emit(e,...t){return this.events[e]?(this.events[e].forEach(i=>{i(...t)}),this):this}removeAllListeners(){return this.events={},this}};var l={createElement(d,e={}){let t=document.createElement(d);return e.className&&(t.className=e.className),e.attributes&&Object.entries(e.attributes).forEach(([i,s])=>{t.setAttribute(i,s)}),e.innerHTML&&(t.innerHTML=e.innerHTML),e.textContent&&(t.textContent=e.textContent),e.style&&Object.assign(t.style,e.style),e.children&&e.children.forEach(i=>{i&&t.appendChild(i)}),t},addClass(d,e){d&&e&&d.classList.add(e)},removeClass(d,e){d&&e&&d.classList.remove(e)},toggleClass(d,e){d&&e&&d.classList.toggle(e)},hasClass(d,e){return d&&d.classList.contains(e)},show(d){d&&(d.style.display="")},hide(d){d&&(d.style.display="none")},fadeIn(d,e=300){if(!d)return;d.style.opacity="0",d.style.display="";let t=null,i=s=>{t||(t=s);let a=s-t,r=Math.min(a/e,1);d.style.opacity=r,a<e&&requestAnimationFrame(i)};requestAnimationFrame(i)},fadeOut(d,e=300){if(!d)return;let t=parseFloat(getComputedStyle(d).opacity)||1,i=null,s=a=>{i||(i=a);let r=a-i,o=Math.max(t-r/e,0);d.style.opacity=o,r<e?requestAnimationFrame(s):d.style.display="none"};requestAnimationFrame(s)},offset(d){if(!d)return{top:0,left:0};let e=d.getBoundingClientRect();return{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset,width:e.width,height:e.height}},escapeHTML(d){let e=document.createElement("div");return e.textContent=d,e.innerHTML},sanitizeHTML(d){let e=document.createElement("div"),t=d.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/on\w+\s*=/gi,"").replace(/javascript:/gi,"");return e.innerHTML=t,e.innerHTML}};var X={en:{player:{label:"Video Player",play:"Play",pause:"Pause",stop:"Stop",restart:"Restart from beginning",rewind:"Rewind",forward:"Forward",rewindSeconds:"Rewind {seconds} seconds",forwardSeconds:"Forward {seconds} seconds",previous:"Previous track",next:"Next track",volume:"Volume",mute:"Mute",unmute:"Unmute",fullscreen:"Fullscreen",exitFullscreen:"Exit Fullscreen",captions:"Captions",chapters:"Chapters",quality:"Quality",captionStyling:"Caption styling",transcript:"Toggle transcript",audioDescription:"Audio description",signLanguage:"Sign language video",settings:"Settings",speed:"Playback Speed",pip:"Picture in Picture",currentTime:"Current time",duration:"Duration",progress:"Progress",seekForward:"Seek forward {seconds} seconds",seekBackward:"Seek backward {seconds} seconds",volumeUp:"Volume up",volumeDown:"Volume down",loading:"Loading...",loadingChapters:"Loading chapters...",error:"Error loading media",buffering:"Buffering...",signLanguageVideo:"Sign Language Video",noChapters:"No chapters available",noCaptions:"No captions available",auto:"Auto",autoQuality:"Auto (no quality selection available)",noQuality:"Quality selection not available",signLanguageDragResize:"Sign Language Video - Press D to drag with keyboard, R to resize",signLanguageDragActive:"Sign Language Video - Drag mode active. Use arrow keys to move, Escape to exit.",signLanguageResizeActive:"Sign Language Video - Resize mode active. Use left/right arrow keys to resize, Escape to exit.",resizeHandle:"Resize {direction} corner"},captions:{off:"Off",select:"Select captions",fontSize:"Font Size",fontFamily:"Font Family",color:"Text Color",backgroundColor:"Background Color",opacity:"Opacity"},fontSizes:{small:"Small",normal:"Normal",large:"Large",xlarge:"X-Large"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Text Color",background:"Background",font:"Font",fontSize:"Font Size",opacity:"Opacity"},audioDescription:{enable:"Enable audio description",disable:"Disable audio description"},signLanguage:{show:"Show sign language video",hide:"Hide sign language video"},transcript:{title:"Transcript",close:"Close transcript",loading:"Loading transcript...",noTranscript:"No transcript available for this video.",settings:"Transcript settings. Press Enter to open menu, or D to enable drag mode",keyboardDragMode:"Toggle keyboard drag mode with arrow keys. Shortcut: D key",keyboardDragActive:"\u2328\uFE0F Keyboard Drag Mode Active (Arrow keys to move, Shift+Arrows for large steps, D or ESC to exit)",resizeWindow:"Resize Window",styleTranscript:"Open transcript style settings",closeMenu:"Close Menu",styleTitle:"Transcript Style",autoscroll:"Autoscroll"},settings:{title:"Settings",quality:"Quality",speed:"Speed",captions:"Captions",language:"Language",reset:"Reset to defaults",close:"Close"},speeds:{normal:"Normal"},time:{display:"Time display",durationPrefix:"Duration: ",hour:"{count} hour",hours:"{count} hours",minute:"{count} minute",minutes:"{count} minutes",second:"{count} second",seconds:"{count} seconds"}},de:{player:{label:"Videoplayer",play:"Abspielen",pause:"Pause",stop:"Stopp",restart:"Von vorne beginnen",rewind:"Zur\xFCckspulen",forward:"Vorspulen",rewindSeconds:"{seconds} Sekunden zur\xFCckspulen",forwardSeconds:"{seconds} Sekunden vorspulen",previous:"Vorheriger Titel",next:"N\xE4chster Titel",volume:"Lautst\xE4rke",mute:"Stumm",unmute:"Ton ein",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",captions:"Untertitel",chapters:"Kapitel",quality:"Qualit\xE4t",captionStyling:"Untertitel-Stil",transcript:"Transkript umschalten",audioDescription:"Audiodeskription",signLanguage:"Geb\xE4rdensprache-Video",settings:"Einstellungen",speed:"Wiedergabegeschwindigkeit",pip:"Bild-in-Bild",currentTime:"Aktuelle Zeit",duration:"Dauer",progress:"Fortschritt",seekForward:"{seconds} Sekunden vorspulen",seekBackward:"{seconds} Sekunden zur\xFCckspulen",volumeUp:"Lauter",volumeDown:"Leiser",loading:"L\xE4dt...",loadingChapters:"Kapitel werden geladen...",error:"Fehler beim Laden",buffering:"Puffern...",signLanguageVideo:"Geb\xE4rdensprache-Video",noChapters:"Keine Kapitel verf\xFCgbar",noCaptions:"Keine Untertitel verf\xFCgbar",auto:"Automatisch",autoQuality:"Automatisch (keine Qualit\xE4tsauswahl verf\xFCgbar)",noQuality:"Qualit\xE4tsauswahl nicht verf\xFCgbar",signLanguageDragResize:"Geb\xE4rdensprache-Video - Dr\xFCcken Sie D zum Verschieben per Tastatur, R zum \xC4ndern der Gr\xF6\xDFe",signLanguageDragActive:"Geb\xE4rdensprache-Video - Verschiebemodus aktiv. Pfeiltasten zum Bewegen, Escape zum Beenden.",signLanguageResizeActive:"Geb\xE4rdensprache-Video - Gr\xF6\xDFen\xE4nderungsmodus aktiv. Links-/Rechts-Pfeiltasten zum \xC4ndern der Gr\xF6\xDFe, Escape zum Beenden.",resizeHandle:"Gr\xF6\xDFen\xE4nderung {direction}-Ecke"},captions:{off:"Aus",select:"Untertitel ausw\xE4hlen",fontSize:"Schriftgr\xF6\xDFe",fontFamily:"Schriftart",color:"Textfarbe",backgroundColor:"Hintergrundfarbe",opacity:"Deckkraft"},fontSizes:{small:"Klein",normal:"Normal",large:"Gro\xDF",xlarge:"Sehr gro\xDF"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Textfarbe",background:"Hintergrund",font:"Schrift",fontSize:"Schriftgr\xF6\xDFe",opacity:"Deckkraft"},audioDescription:{enable:"Audiodeskription aktivieren",disable:"Audiodeskription deaktivieren"},signLanguage:{show:"Geb\xE4rdensprache-Video anzeigen",hide:"Geb\xE4rdensprache-Video ausblenden"},transcript:{title:"Transkript",close:"Transkript schlie\xDFen",loading:"Transkript wird geladen...",noTranscript:"Kein Transkript f\xFCr dieses Video verf\xFCgbar.",settings:"Transkript-Einstellungen. Eingabetaste zum \xD6ffnen des Men\xFCs dr\xFCcken oder D zum Aktivieren des Verschiebemodus",keyboardDragMode:"Tastatur-Verschiebemodus mit Pfeiltasten umschalten. Tastenkombination: D-Taste",keyboardDragActive:"\u2328\uFE0F Tastatur-Verschiebemodus aktiv (Pfeiltasten zum Bewegen, Umschalt+Pfeiltasten f\xFCr gro\xDFe Schritte, D oder ESC zum Beenden)",resizeWindow:"Fenster vergr\xF6\xDFern/verkleinern",styleTranscript:"Transkript-Stileinstellungen \xF6ffnen",closeMenu:"Men\xFC schlie\xDFen",styleTitle:"Transkript-Stil",autoscroll:"Automatisches Scrollen"},settings:{title:"Einstellungen",quality:"Qualit\xE4t",speed:"Geschwindigkeit",captions:"Untertitel",language:"Sprache",reset:"Zur\xFCcksetzen",close:"Schlie\xDFen"},speeds:{normal:"Normal"},time:{display:"Zeitanzeige",durationPrefix:"Dauer: ",hour:"{count} Stunde",hours:"{count} Stunden",minute:"{count} Minute",minutes:"{count} Minuten",second:"{count} Sekunde",seconds:"{count} Sekunden"}},es:{player:{label:"Reproductor de video",play:"Reproducir",pause:"Pausa",stop:"Detener",restart:"Reiniciar desde el principio",rewind:"Retroceder",forward:"Avanzar",rewindSeconds:"Retroceder {seconds} segundos",forwardSeconds:"Avanzar {seconds} segundos",previous:"Pista anterior",next:"Siguiente pista",volume:"Volumen",mute:"Silenciar",unmute:"Activar sonido",fullscreen:"Pantalla completa",exitFullscreen:"Salir de pantalla completa",captions:"Subt\xEDtulos",chapters:"Cap\xEDtulos",quality:"Calidad",captionStyling:"Estilo de subt\xEDtulos",transcript:"Alternar transcripci\xF3n",audioDescription:"Audiodescripci\xF3n",signLanguage:"Video en lengua de se\xF1as",settings:"Configuraci\xF3n",speed:"Velocidad de reproducci\xF3n",pip:"Imagen en imagen",currentTime:"Tiempo actual",duration:"Duraci\xF3n",progress:"Progreso",seekForward:"Avanzar {seconds} segundos",seekBackward:"Retroceder {seconds} segundos",volumeUp:"Subir volumen",volumeDown:"Bajar volumen",loading:"Cargando...",loadingChapters:"Cargando cap\xEDtulos...",error:"Error al cargar",buffering:"Almacenando en b\xFAfer...",signLanguageVideo:"Video en Lengua de Se\xF1as",noChapters:"No hay cap\xEDtulos disponibles",noCaptions:"No hay subt\xEDtulos disponibles",auto:"Autom\xE1tico",autoQuality:"Autom\xE1tico (selecci\xF3n de calidad no disponible)",noQuality:"Selecci\xF3n de calidad no disponible",signLanguageDragResize:"Video en Lengua de Se\xF1as - Presione D para arrastrar con el teclado, R para cambiar el tama\xF1o",signLanguageDragActive:"Video en Lengua de Se\xF1as - Modo de arrastre activo. Use las teclas de flecha para mover, Escape para salir.",signLanguageResizeActive:"Video en Lengua de Se\xF1as - Modo de cambio de tama\xF1o activo. Use las teclas de flecha izquierda/derecha para cambiar el tama\xF1o, Escape para salir.",resizeHandle:"Cambiar tama\xF1o esquina {direction}"},captions:{off:"Desactivado",select:"Seleccionar subt\xEDtulos",fontSize:"Tama\xF1o de fuente",fontFamily:"Familia de fuente",color:"Color de texto",backgroundColor:"Color de fondo",opacity:"Opacidad"},fontSizes:{small:"Peque\xF1o",normal:"Normal",large:"Grande",xlarge:"Muy grande"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Color de texto",background:"Fondo",font:"Fuente",fontSize:"Tama\xF1o de fuente",opacity:"Opacidad"},audioDescription:{enable:"Activar audiodescripci\xF3n",disable:"Desactivar audiodescripci\xF3n"},signLanguage:{show:"Mostrar video en lengua de se\xF1as",hide:"Ocultar video en lengua de se\xF1as"},transcript:{title:"Transcripci\xF3n",close:"Cerrar transcripci\xF3n",loading:"Cargando transcripci\xF3n...",noTranscript:"No hay transcripci\xF3n disponible para este video.",settings:"Configuraci\xF3n de transcripci\xF3n. Presione Enter para abrir el men\xFA o D para activar el modo de arrastre",keyboardDragMode:"Alternar modo de arrastre con teclado usando teclas de flecha. Atajo: tecla D",keyboardDragActive:"\u2328\uFE0F Modo de Arrastre con Teclado Activo (Teclas de flecha para mover, May\xFAs+Flechas para pasos grandes, D o ESC para salir)",resizeWindow:"Cambiar tama\xF1o de ventana",styleTranscript:"Abrir configuraci\xF3n de estilo de transcripci\xF3n",closeMenu:"Cerrar men\xFA",styleTitle:"Estilo de Transcripci\xF3n",autoscroll:"Desplazamiento autom\xE1tico"},settings:{title:"Configuraci\xF3n",quality:"Calidad",speed:"Velocidad",captions:"Subt\xEDtulos",language:"Idioma",reset:"Restablecer",close:"Cerrar"},speeds:{normal:"Normal"},time:{display:"Visualizaci\xF3n de tiempo",durationPrefix:"Duraci\xF3n: ",hour:"{count} hora",hours:"{count} horas",minute:"{count} minuto",minutes:"{count} minutos",second:"{count} segundo",seconds:"{count} segundos"}},fr:{player:{label:"Lecteur vid\xE9o",play:"Lecture",pause:"Pause",stop:"Arr\xEAt",restart:"Red\xE9marrer du d\xE9but",rewind:"Reculer",forward:"Avancer",rewindSeconds:"Reculer de {seconds} secondes",forwardSeconds:"Avancer de {seconds} secondes",previous:"Piste pr\xE9c\xE9dente",next:"Piste suivante",volume:"Volume",mute:"Muet",unmute:"Activer le son",fullscreen:"Plein \xE9cran",exitFullscreen:"Quitter le plein \xE9cran",captions:"Sous-titres",chapters:"Chapitres",quality:"Qualit\xE9",captionStyling:"Style des sous-titres",transcript:"Activer/d\xE9sactiver la transcription",audioDescription:"Audiodescription",signLanguage:"Vid\xE9o en langue des signes",settings:"Param\xE8tres",speed:"Vitesse de lecture",pip:"Image dans l'image",currentTime:"Temps actuel",duration:"Dur\xE9e",progress:"Progression",seekForward:"Avancer de {seconds} secondes",seekBackward:"Reculer de {seconds} secondes",volumeUp:"Augmenter le volume",volumeDown:"Diminuer le volume",loading:"Chargement...",loadingChapters:"Chargement des chapitres...",error:"Erreur de chargement",buffering:"Mise en m\xE9moire tampon...",signLanguageVideo:"Vid\xE9o en Langue des Signes",noChapters:"Aucun chapitre disponible",noCaptions:"Aucun sous-titre disponible",auto:"Automatique",autoQuality:"Automatique (s\xE9lection de qualit\xE9 non disponible)",noQuality:"S\xE9lection de qualit\xE9 non disponible",signLanguageDragResize:"Vid\xE9o en Langue des Signes - Appuyez sur D pour d\xE9placer avec le clavier, R pour redimensionner",signLanguageDragActive:"Vid\xE9o en Langue des Signes - Mode glissement actif. Utilisez les touches fl\xE9ch\xE9es pour d\xE9placer, \xC9chap pour quitter.",signLanguageResizeActive:"Vid\xE9o en Langue des Signes - Mode redimensionnement actif. Utilisez les touches fl\xE9ch\xE9es gauche/droite pour redimensionner, \xC9chap pour quitter.",resizeHandle:"Redimensionner coin {direction}"},captions:{off:"D\xE9sactiv\xE9",select:"S\xE9lectionner les sous-titres",fontSize:"Taille de police",fontFamily:"Police",color:"Couleur du texte",backgroundColor:"Couleur de fond",opacity:"Opacit\xE9"},fontSizes:{small:"Petit",normal:"Normal",large:"Grand",xlarge:"Tr\xE8s grand"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Couleur du texte",background:"Arri\xE8re-plan",font:"Police",fontSize:"Taille de police",opacity:"Opacit\xE9"},audioDescription:{enable:"Activer l'audiodescription",disable:"D\xE9sactiver l'audiodescription"},signLanguage:{show:"Afficher la vid\xE9o en langue des signes",hide:"Masquer la vid\xE9o en langue des signes"},transcript:{title:"Transcription",close:"Fermer la transcription",loading:"Chargement de la transcription...",noTranscript:"Aucune transcription disponible pour cette vid\xE9o.",settings:"Param\xE8tres de transcription. Appuyez sur Entr\xE9e pour ouvrir le menu ou D pour activer le mode glissement",keyboardDragMode:"Basculer le mode glissement avec les touches fl\xE9ch\xE9es. Raccourci: touche D",keyboardDragActive:"\u2328\uFE0F Mode Glissement Clavier Actif (Touches fl\xE9ch\xE9es pour d\xE9placer, Maj+Fl\xE9ch\xE9es pour grands pas, D ou \xC9chap pour quitter)",resizeWindow:"Redimensionner la fen\xEAtre",styleTranscript:"Ouvrir les param\xE8tres de style de transcription",closeMenu:"Fermer le menu",styleTitle:"Style de Transcription",autoscroll:"D\xE9filement automatique"},settings:{title:"Param\xE8tres",quality:"Qualit\xE9",speed:"Vitesse",captions:"Sous-titres",language:"Langue",reset:"R\xE9initialiser",close:"Fermer"},speeds:{normal:"Normal"},time:{display:"Affichage du temps",durationPrefix:"Dur\xE9e : ",hour:"{count} heure",hours:"{count} heures",minute:"{count} minute",minutes:"{count} minutes",second:"{count} seconde",seconds:"{count} secondes"}},ja:{player:{label:"\u30D3\u30C7\u30AA\u30D7\u30EC\u30FC\u30E4\u30FC",play:"\u518D\u751F",pause:"\u4E00\u6642\u505C\u6B62",stop:"\u505C\u6B62",restart:"\u6700\u521D\u304B\u3089\u518D\u751F",rewind:"\u5DFB\u304D\u623B\u3057",forward:"\u65E9\u9001\u308A",rewindSeconds:"{seconds}\u79D2\u623B\u3059",forwardSeconds:"{seconds}\u79D2\u9032\u3081\u308B",previous:"\u524D\u306E\u30C8\u30E9\u30C3\u30AF",next:"\u6B21\u306E\u30C8\u30E9\u30C3\u30AF",volume:"\u97F3\u91CF",mute:"\u30DF\u30E5\u30FC\u30C8",unmute:"\u30DF\u30E5\u30FC\u30C8\u89E3\u9664",fullscreen:"\u5168\u753B\u9762\u8868\u793A",exitFullscreen:"\u5168\u753B\u9762\u8868\u793A\u3092\u7D42\u4E86",captions:"\u5B57\u5E55",chapters:"\u30C1\u30E3\u30D7\u30BF\u30FC",quality:"\u753B\u8CEA",captionStyling:"\u5B57\u5E55\u30B9\u30BF\u30A4\u30EB",transcript:"\u6587\u5B57\u8D77\u3053\u3057\u5207\u308A\u66FF\u3048",audioDescription:"\u97F3\u58F0\u89E3\u8AAC",signLanguage:"\u624B\u8A71\u52D5\u753B",settings:"\u8A2D\u5B9A",speed:"\u518D\u751F\u901F\u5EA6",pip:"\u30D4\u30AF\u30C1\u30E3\u30FC\u30A4\u30F3\u30D4\u30AF\u30C1\u30E3\u30FC",currentTime:"\u73FE\u5728\u306E\u6642\u9593",duration:"\u518D\u751F\u6642\u9593",progress:"\u9032\u884C\u72B6\u6CC1",seekForward:"{seconds}\u79D2\u9032\u3081\u308B",seekBackward:"{seconds}\u79D2\u623B\u3059",volumeUp:"\u97F3\u91CF\u3092\u4E0A\u3052\u308B",volumeDown:"\u97F3\u91CF\u3092\u4E0B\u3052\u308B",loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",loadingChapters:"\u30C1\u30E3\u30D7\u30BF\u30FC\u8AAD\u307F\u8FBC\u307F\u4E2D...",error:"\u8AAD\u307F\u8FBC\u307F\u30A8\u30E9\u30FC",buffering:"\u30D0\u30C3\u30D5\u30A1\u30EA\u30F3\u30B0\u4E2D...",signLanguageVideo:"\u624B\u8A71\u52D5\u753B",noChapters:"\u30C1\u30E3\u30D7\u30BF\u30FC\u304C\u3042\u308A\u307E\u305B\u3093",noCaptions:"\u5B57\u5E55\u304C\u3042\u308A\u307E\u305B\u3093",auto:"\u81EA\u52D5",autoQuality:"\u81EA\u52D5\uFF08\u753B\u8CEA\u9078\u629E\u4E0D\u53EF\uFF09",noQuality:"\u753B\u8CEA\u9078\u629E\u4E0D\u53EF",signLanguageDragResize:"\u624B\u8A71\u52D5\u753B - \u30AD\u30FC\u30DC\u30FC\u30C9\u3067\u30C9\u30E9\u30C3\u30B0\u3059\u308B\u306B\u306FD\u30AD\u30FC\u3092\u3001\u30B5\u30A4\u30BA\u5909\u66F4\u3059\u308B\u306B\u306FR\u30AD\u30FC\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044",signLanguageDragActive:"\u624B\u8A71\u52D5\u753B - \u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u304C\u6709\u52B9\u3067\u3059\u3002\u77E2\u5370\u30AD\u30FC\u3067\u79FB\u52D5\u3001Escape\u3067\u7D42\u4E86\u3057\u307E\u3059\u3002",signLanguageResizeActive:"\u624B\u8A71\u52D5\u753B - \u30B5\u30A4\u30BA\u5909\u66F4\u30E2\u30FC\u30C9\u304C\u6709\u52B9\u3067\u3059\u3002\u5DE6\u53F3\u306E\u77E2\u5370\u30AD\u30FC\u3067\u30B5\u30A4\u30BA\u5909\u66F4\u3001Escape\u3067\u7D42\u4E86\u3057\u307E\u3059\u3002",resizeHandle:"{direction}\u30B3\u30FC\u30CA\u30FC\u306E\u30B5\u30A4\u30BA\u5909\u66F4"},captions:{off:"\u30AA\u30D5",select:"\u5B57\u5E55\u3092\u9078\u629E",fontSize:"\u30D5\u30A9\u30F3\u30C8\u30B5\u30A4\u30BA",fontFamily:"\u30D5\u30A9\u30F3\u30C8",color:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",backgroundColor:"\u80CC\u666F\u8272",opacity:"\u4E0D\u900F\u660E\u5EA6"},fontSizes:{small:"\u5C0F",normal:"\u6A19\u6E96",large:"\u5927",xlarge:"\u7279\u5927"},fontFamilies:{sansSerif:"\u30B5\u30F3\u30BB\u30EA\u30D5",serif:"\u30BB\u30EA\u30D5",monospace:"\u7B49\u5E45"},styleLabels:{textColor:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",background:"\u80CC\u666F",font:"\u30D5\u30A9\u30F3\u30C8",fontSize:"\u30D5\u30A9\u30F3\u30C8\u30B5\u30A4\u30BA",opacity:"\u4E0D\u900F\u660E\u5EA6"},audioDescription:{enable:"\u97F3\u58F0\u89E3\u8AAC\u3092\u6709\u52B9\u306B\u3059\u308B",disable:"\u97F3\u58F0\u89E3\u8AAC\u3092\u7121\u52B9\u306B\u3059\u308B"},signLanguage:{show:"\u624B\u8A71\u52D5\u753B\u3092\u8868\u793A",hide:"\u624B\u8A71\u52D5\u753B\u3092\u975E\u8868\u793A"},transcript:{title:"\u6587\u5B57\u8D77\u3053\u3057",close:"\u6587\u5B57\u8D77\u3053\u3057\u3092\u9589\u3058\u308B",loading:"\u6587\u5B57\u8D77\u3053\u3057\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D...",noTranscript:"\u3053\u306E\u30D3\u30C7\u30AA\u306E\u6587\u5B57\u8D77\u3053\u3057\u306F\u3042\u308A\u307E\u305B\u3093\u3002",settings:"\u6587\u5B57\u8D77\u3053\u3057\u8A2D\u5B9A\u3002Enter\u30AD\u30FC\u3067\u30E1\u30CB\u30E5\u30FC\u3092\u958B\u304F\u3001\u307E\u305F\u306FD\u30AD\u30FC\u3067\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u3092\u6709\u52B9\u306B\u3059\u308B",keyboardDragMode:"\u77E2\u5370\u30AD\u30FC\u3067\u30AD\u30FC\u30DC\u30FC\u30C9\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u3092\u5207\u308A\u66FF\u3048\u3002\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\uFF1AD\u30AD\u30FC",keyboardDragActive:"\u2328\uFE0F \u30AD\u30FC\u30DC\u30FC\u30C9\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u6709\u52B9\uFF08\u77E2\u5370\u30AD\u30FC\u3067\u79FB\u52D5\u3001Shift+\u77E2\u5370\u30AD\u30FC\u3067\u5927\u304D\u304F\u79FB\u52D5\u3001D\u307E\u305F\u306FESC\u3067\u7D42\u4E86\uFF09",resizeWindow:"\u30A6\u30A3\u30F3\u30C9\u30A6\u306E\u30B5\u30A4\u30BA\u5909\u66F4",styleTranscript:"\u6587\u5B57\u8D77\u3053\u3057\u30B9\u30BF\u30A4\u30EB\u8A2D\u5B9A\u3092\u958B\u304F",closeMenu:"\u30E1\u30CB\u30E5\u30FC\u3092\u9589\u3058\u308B",styleTitle:"\u6587\u5B57\u8D77\u3053\u3057\u30B9\u30BF\u30A4\u30EB",autoscroll:"\u81EA\u52D5\u30B9\u30AF\u30ED\u30FC\u30EB"},settings:{title:"\u8A2D\u5B9A",quality:"\u753B\u8CEA",speed:"\u901F\u5EA6",captions:"\u5B57\u5E55",language:"\u8A00\u8A9E",reset:"\u30EA\u30BB\u30C3\u30C8",close:"\u9589\u3058\u308B"},speeds:{normal:"\u901A\u5E38"},time:{display:"\u6642\u9593\u8868\u793A",durationPrefix:"\u518D\u751F\u6642\u9593: ",hour:"{count}\u6642\u9593",hours:"{count}\u6642\u9593",minute:"{count}\u5206",minutes:"{count}\u5206",second:"{count}\u79D2",seconds:"{count}\u79D2"}}};var K=class{constructor(){this.currentLanguage="en",this.translations=X}setLanguage(e){this.translations[e]?this.currentLanguage=e:(console.warn(`Language "${e}" not found, falling back to English`),this.currentLanguage="en")}getLanguage(){return this.currentLanguage}t(e,t={}){let i=e.split("."),s=this.translations[this.currentLanguage];for(let a of i)if(s&&typeof s=="object"&&a in s)s=s[a];else{s=this.translations.en;for(let r of i)if(s&&typeof s=="object"&&r in s)s=s[r];else return e;break}return typeof s=="string"&&Object.entries(t).forEach(([a,r])=>{s=s.replace(new RegExp(`{${a}}`,"g"),r)}),s}addTranslation(e,t){this.translations[e]||(this.translations[e]={}),Object.assign(this.translations[e],t)}},h=new K;var A={formatTime(d,e=!1){if(!isFinite(d)||d<0)return e?"00:00:00":"00:00";let t=Math.floor(d/3600),i=Math.floor(d%3600/60),s=Math.floor(d%60),a=r=>String(r).padStart(2,"0");return t>0||e?`${a(t)}:${a(i)}:${a(s)}`:`${a(i)}:${a(s)}`},parseTime(d){let e=d.split(":").map(t=>parseInt(t,10));return e.length===3?e[0]*3600+e[1]*60+e[2]:e.length===2?e[0]*60+e[1]:e.length===1?e[0]:0},formatDuration(d){if(!isFinite(d)||d<0)return h.t("time.seconds",{count:0});let e=Math.floor(d/3600),t=Math.floor(d%3600/60),i=Math.floor(d%60),s=[];if(e>0){let a=e===1?"time.hour":"time.hours";s.push(h.t(a,{count:e}))}if(t>0){let a=t===1?"time.minute":"time.minutes";s.push(h.t(a,{count:t}))}if(i>0||s.length===0){let a=i===1?"time.second":"time.seconds";s.push(h.t(a,{count:i}))}return s.join(", ")},formatPercentage(d,e){return e===0?0:Math.round(d/e*100)}};var oe={play:'<path d="M8 5v14l11-7z"/>',pause:'<path d="M6 4h4v16H6V4zm8 0h4v16h-4V4z"/>',stop:'<rect x="6" y="6" width="12" height="12"/>',rewind:'<path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/>',forward:'<path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/>',skipPrevious:'<path d="M6 6h2v12H6V6zm3 6l8.5 6V6L9 12z"/>',skipNext:'<path d="M16 6h2v12h-2V6zM6 6l8.5 6L6 18V6z"/>',restart:'<path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/>',volumeHigh:'<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"/>',volumeMedium:'<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.02z"/>',volumeLow:'<path d="M7 9v6h4l5 5V4l-5 5H7z"/>',volumeMuted:'<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"/>',fullscreen:'<path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>',fullscreenExit:'<path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>',settings:'<path d="M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.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-.94L14.4 2.81c-.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-.05.3-.09.63-.09.94s.02.64.07.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"/>',captions:'<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"/>',captionsOff:'<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"/><path d="M0 0h24v24H0z" fill="none"/>',pip:'<path d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98V5c0-1.1-.9-2-2-2zm0 16.01H3V4.98h18v14.03z"/>',speed:'<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.44z"/><path d="M10.59 15.41a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"/>',close:'<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>',check:'<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>',arrowUp:'<path d="M7 14l5-5 5 5z"/>',arrowDown:'<path d="M7 10l5 5 5-5z"/>',arrowLeft:'<path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>',arrowRight:'<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>',loading:'<path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"/>',error:'<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"/>',download:'<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>',link:'<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>',playlist:'<path d="M15 6H3v2h12V6zm0 4H3v2h12v-2zM3 16h8v-2H3v2zM17 6v8.18c-.31-.11-.65-.18-1-.18-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3V8h3V6h-5z"/>',language:'<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"/>',hd:'<path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm7-1c0 .55-.45 1-1 1h-.75v1.5h-1.5V15H14c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v4zm-3.5-.5h2v-3h-2v3z"/>',transcript:'<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/>',audioDescription:'<rect x="2" y="5" width="20" height="14" rx="2" fill="#ffffff" stroke="#ffffff" stroke-width="2"/><text x="12" y="16" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#1a1a1a">AD</text>',audioDescriptionOn:'<rect x="2" y="5" width="20" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><text x="12" y="16" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="currentColor">AD</text>',signLanguage:'<g transform="scale(1.5)"><path d="M16 11.3c-.1-.9-4.8 1.3-5.4 1.1-2.6-1 5.8-1.3 5.1-2.9s-5.1 1.5-6 1.4C6.5 9.4 16.5 9.1 13.5 8c-1.9-.6-8.8 2.9-6.8.4.7-.6.7-1.9-.7-1.7-9.7 7.2-.7 12.2 8.8 7 0-1.3-3.5.4-4.1.4-2.6 0 5.6-2 5.4-3ZM3.9 7.8c3.2-4.2 3.7 1.2 6 .1s.2-.2.2-.3c.7-2.7 2.5-7.5-1.5-1.3-1.6 0 1.1-4 1-4.6C8.9-1 7.3 4.4 7.2 4.9c-1.6.7-.9-1.4-.7-1.5 3-6-.6-3.1-.9.4-2.5 1.8 0-2.8 0-3.5C2.8-.9 4 9.4 1.1 4.9S.1 4.6 0 5c-.4 2.7 2.6 7.2 3.9 2.8Z"/></g>',signLanguageOn:'<g transform="scale(1.5)"><path d="M16 11.3c-.1-.9-4.8 1.3-5.4 1.1-2.6-1 5.8-1.3 5.1-2.9s-5.1 1.5-6 1.4C6.5 9.4 16.5 9.1 13.5 8c-1.9-.6-8.8 2.9-6.8.4.7-.6.7-1.9-.7-1.7-9.7 7.2-.7 12.2 8.8 7 0-1.3-3.5.4-4.1.4-2.6 0 5.6-2 5.4-3ZM3.9 7.8c3.2-4.2 3.7 1.2 6 .1s.2-.2.2-.3c.7-2.7 2.5-7.5-1.5-1.3-1.6 0 1.1-4 1-4.6C8.9-1 7.3 4.4 7.2 4.9c-1.6.7-.9-1.4-.7-1.5 3-6-.6-3.1-.9.4-2.5 1.8 0-2.8 0-3.5C2.8-.9 4 9.4 1.1 4.9S.1 4.6 0 5c-.4 2.7 2.6 7.2 3.9 2.8Z"/></g>',speaker:'<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.02z"/>',music:'<path d="M12 3v9.28c-.47-.17-.97-.28-1.5-.28C8.01 12 6 14.01 6 16.5S8.01 21 10.5 21c2.31 0 4.2-1.75 4.45-4H15V6h4V3h-7zm-1.5 16c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>',moreVertical:'<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>',moreHorizontal:'<path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>',move:'<path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"/>',resize:'<path d="M21.71 11.29l-9-9c-.39-.39-1.02-.39-1.41 0l-9 9c-.39.39-.39 1.02 0 1.41l9 9c.39.39 1.02.39 1.41 0l9-9c.39-.38.39-1.01 0-1.41zM14 14.5V12h-4v2.5L7 11l3-3.5V10h4V7.5l3 3.5-3 3.5z"/>'},le=d=>`<svg viewBox="0 0 24 24" fill="currentColor">${d}</svg>`,j=Object.fromEntries(Object.entries(oe).map(([d,e])=>[d,le(e)]));function ce(d){return j[d]||j.play}function b(d,e=""){let t=document.createElement("span");return t.className=`vidply-icon ${e}`.trim(),t.innerHTML=ce(d),t.setAttribute("aria-hidden","true"),t}function G(){let d=document.createElementNS("http://www.w3.org/2000/svg","svg");d.setAttribute("class","vidply-play-overlay"),d.setAttribute("viewBox","0 0 80 80"),d.setAttribute("width","80"),d.setAttribute("height","80"),d.setAttribute("aria-hidden","true"),d.setAttribute("role","presentation"),d.style.cursor="pointer";let e=document.createElementNS("http://www.w3.org/2000/svg","defs"),t=`vidply-play-shadow-${Math.random().toString(36).substr(2,9)}`,i=document.createElementNS("http://www.w3.org/2000/svg","filter");i.setAttribute("id",t),i.setAttribute("x","-50%"),i.setAttribute("y","-50%"),i.setAttribute("width","200%"),i.setAttribute("height","200%");let s=document.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");s.setAttribute("in","SourceAlpha"),s.setAttribute("stdDeviation","3");let a=document.createElementNS("http://www.w3.org/2000/svg","feOffset");a.setAttribute("dx","0"),a.setAttribute("dy","2"),a.setAttribute("result","offsetblur");let r=document.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer"),o=document.createElementNS("http://www.w3.org/2000/svg","feFuncA");o.setAttribute("type","linear"),o.setAttribute("slope","0.3"),r.appendChild(o);let n=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),c=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode"),u=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");u.setAttribute("in","SourceGraphic"),n.appendChild(c),n.appendChild(u),i.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(n),e.appendChild(i),d.appendChild(e);let y=document.createElementNS("http://www.w3.org/2000/svg","circle");y.setAttribute("cx","40"),y.setAttribute("cy","40"),y.setAttribute("r","40"),y.setAttribute("fill","rgba(255, 255, 255, 0.95)"),y.setAttribute("filter",`url(#${t})`),y.setAttribute("class","vidply-play-overlay-bg"),d.appendChild(y);let m=document.createElementNS("http://www.w3.org/2000/svg","polygon");return m.setAttribute("points","32,28 32,52 54,40"),m.setAttribute("fill","#0a406e"),m.setAttribute("class","vidply-play-overlay-icon"),d.appendChild(m),d}var N=class{constructor(e){this.player=e,this.element=null,this.controls={},this.hideTimeout=null,this.isDraggingProgress=!1,this.isDraggingVolume=!1,this.init()}init(){this.createElement(),this.createControls(),this.attachEvents(),this.setupAutoHide()}isMobile(){return window.innerWidth<640}positionMenu(e,t){this.isMobile()||setTimeout(()=>{let s=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=window.innerWidth,o=window.innerHeight,n=s.top,c=o-s.bottom;n<a.height+20&&c>n&&(e.style.bottom="auto",e.style.top="calc(100% + 8px)",e.classList.add("vidply-menu-below"));let u=s.left+s.width/2-a.width/2;u<10?(e.style.right="auto",e.style.left="0",e.style.transform="translateX(0)"):u+a.width>r-10&&(e.style.left="auto",e.style.right="0",e.style.transform="translateX(0)")},0)}attachMenuCloseHandler(e,t,i=!1){this.positionMenu(e,t),setTimeout(()=>{let s=r=>{i&&e.contains(r.target)||!e.contains(r.target)&&!t.contains(r.target)&&(e.remove(),document.removeEventListener("click",s),document.removeEventListener("keydown",a))},a=r=>{r.key==="Escape"&&(e.remove(),document.removeEventListener("click",s),document.removeEventListener("keydown",a),t.focus())};document.addEventListener("click",s),document.addEventListener("keydown",a)},100)}attachMenuKeyboardNavigation(e){let t=Array.from(e.querySelectorAll(`.${this.player.options.classPrefix}-menu-item`));if(t.length===0)return;let i=s=>{let a=t.indexOf(document.activeElement);switch(s.key){case"ArrowDown":s.preventDefault();let r=(a+1)%t.length;t[r].focus();break;case"ArrowUp":s.preventDefault();let o=(a-1+t.length)%t.length;t[o].focus();break;case"Home":s.preventDefault(),t[0].focus();break;case"End":s.preventDefault(),t[t.length-1].focus();break;case"Enter":case" ":s.preventDefault(),document.activeElement&&t.includes(document.activeElement)&&document.activeElement.click();break}};e.addEventListener("keydown",i)}createElement(){this.element=l.createElement("div",{className:`${this.player.options.classPrefix}-controls`,attributes:{role:"region","aria-label":h.t("player.label")+" controls"}})}createControls(){this.player.options.progressBar&&this.createProgressBar();let e=l.createElement("div",{className:`${this.player.options.classPrefix}-controls-buttons`}),t=l.createElement("div",{className:`${this.player.options.classPrefix}-controls-left`});this.player.playlistManager&&t.appendChild(this.createPreviousButton()),this.player.options.playPauseButton&&t.appendChild(this.createPlayPauseButton()),t.appendChild(this.createRestartButton()),this.player.playlistManager&&t.appendChild(this.createNextButton()),this.player.playlistManager||t.appendChild(this.createRewindButton()),this.player.playlistManager||t.appendChild(this.createForwardButton()),this.player.options.volumeControl&&t.appendChild(this.createVolumeControl()),(this.player.options.currentTime||this.player.options.duration)&&t.appendChild(this.createTimeDisplay()),this.rightButtons=l.createElement("div",{className:`${this.player.options.classPrefix}-controls-right`});let i=this.hasChapterTracks(),s=this.hasCaptionTracks(),a=this.hasQualityLevels(),r=this.hasAudioDescription();this.player.options.chaptersButton&&i&&this.rightButtons.appendChild(this.createChaptersButton()),this.player.options.qualityButton&&a&&this.rightButtons.appendChild(this.createQualityButton()),this.player.options.captionStyleButton&&s&&this.rightButtons.appendChild(this.createCaptionStyleButton()),this.player.options.speedButton&&this.rightButtons.appendChild(this.createSpeedButton()),this.player.options.captionsButton&&s&&this.rightButtons.appendChild(this.createCaptionsButton()),this.player.options.transcriptButton&&s&&this.rightButtons.appendChild(this.createTranscriptButton()),this.player.options.audioDescriptionButton&&r&&this.rightButtons.appendChild(this.createAudioDescriptionButton());let o=this.hasSignLanguage();this.player.options.signLanguageButton&&o&&this.rightButtons.appendChild(this.createSignLanguageButton()),this.player.options.pipButton&&"pictureInPictureEnabled"in document&&this.rightButtons.appendChild(this.createPipButton()),this.player.options.fullscreenButton&&this.rightButtons.appendChild(this.createFullscreenButton()),e.appendChild(t),e.appendChild(this.rightButtons),this.element.appendChild(e)}hasChapterTracks(){let e=this.player.element.textTracks;for(let t=0;t<e.length;t++)if(e[t].kind==="chapters")return!0;return!1}hasCaptionTracks(){let e=this.player.element.textTracks;for(let t=0;t<e.length;t++)if(e[t].kind==="captions"||e[t].kind==="subtitles")return!0;return!1}hasQualityLevels(){if(this.player.renderer&&this.player.renderer.getQualities){let e=this.player.renderer.getQualities();return e&&e.length>1}return!1}hasAudioDescription(){return this.player.audioDescriptionSrc&&this.player.audioDescriptionSrc.length>0?!0:Array.from(this.player.element.textTracks||[]).some(t=>t.kind==="descriptions")}hasSignLanguage(){return this.player.signLanguageSrc&&this.player.signLanguageSrc.length>0}createProgressBar(){let e=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-container`,attributes:{role:"slider","aria-label":h.t("player.progress"),"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":"0",tabindex:"0"}});this.controls.buffered=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-buffered`}),this.controls.played=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-played`}),this.controls.progressHandle=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-handle`}),this.controls.progressTooltip=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-tooltip`}),e.appendChild(this.controls.buffered),e.appendChild(this.controls.played),this.controls.played.appendChild(this.controls.progressHandle),e.appendChild(this.controls.progressTooltip),this.controls.progress=e,this.element.appendChild(e),this.setupProgressBarEvents()}setupProgressBarEvents(){let e=this.controls.progress,t=i=>{let s=e.getBoundingClientRect(),a=Math.max(0,Math.min(1,(i-s.left)/s.width)),r=a*this.player.state.duration;return{percent:a,time:r}};e.addEventListener("mousedown",i=>{this.isDraggingProgress=!0;let{time:s}=t(i.clientX);this.player.seek(s)}),document.addEventListener("mousemove",i=>{if(this.isDraggingProgress){let{time:s}=t(i.clientX);this.player.seek(s)}}),document.addEventListener("mouseup",()=>{this.isDraggingProgress=!1}),e.addEventListener("mousemove",i=>{if(!this.isDraggingProgress){let{time:s}=t(i.clientX);this.controls.progressTooltip.textContent=A.formatTime(s),this.controls.progressTooltip.style.left=`${i.clientX-e.getBoundingClientRect().left}px`,this.controls.progressTooltip.style.display="block"}}),e.addEventListener("mouseleave",()=>{this.controls.progressTooltip.style.display="none"}),e.addEventListener("keydown",i=>{i.key==="ArrowLeft"?(i.preventDefault(),this.player.seekBackward(5)):i.key==="ArrowRight"&&(i.preventDefault(),this.player.seekForward(5))}),e.addEventListener("touchstart",i=>{this.isDraggingProgress=!0;let s=i.touches[0],{time:a}=t(s.clientX);this.player.seek(a)}),e.addEventListener("touchmove",i=>{if(this.isDraggingProgress){i.preventDefault();let s=i.touches[0],{time:a}=t(s.clientX);this.player.seek(a)}}),e.addEventListener("touchend",()=>{this.isDraggingProgress=!1})}createPlayPauseButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-play-pause`,attributes:{type:"button","aria-label":h.t("player.play")}});return e.appendChild(b("play")),e.addEventListener("click",()=>{this.player.toggle()}),this.controls.playPause=e,e}createRestartButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-restart`,attributes:{type:"button","aria-label":h.t("player.restart")}});return e.appendChild(b("restart")),e.addEventListener("click",()=>{this.player.seek(0),this.player.play()}),e}createPreviousButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-previous`,attributes:{type:"button","aria-label":h.t("player.previous")}});e.appendChild(b("skipPrevious")),e.addEventListener("click",()=>{this.player.playlistManager&&this.player.playlistManager.previous()});let t=()=>{this.player.playlistManager&&(e.disabled=!this.player.playlistManager.hasPrevious()&&!this.player.playlistManager.options.loop)};return this.player.on("playlisttrackchange",t),t(),this.controls.previous=e,e}createNextButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-next`,attributes:{type:"button","aria-label":h.t("player.next")}});e.appendChild(b("skipNext")),e.addEventListener("click",()=>{this.player.playlistManager&&this.player.playlistManager.next()});let t=()=>{this.player.playlistManager&&(e.disabled=!this.player.playlistManager.hasNext()&&!this.player.playlistManager.options.loop)};return this.player.on("playlisttrackchange",t),t(),this.controls.next=e,e}createRewindButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-rewind`,attributes:{type:"button","aria-label":h.t("player.rewindSeconds",{seconds:15})}});return e.appendChild(b("rewind")),e.addEventListener("click",()=>{this.player.seekBackward(15)}),e}createForwardButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-forward`,attributes:{type:"button","aria-label":h.t("player.forwardSeconds",{seconds:15})}});return e.appendChild(b("forward")),e.addEventListener("click",()=>{this.player.seekForward(15)}),e}createVolumeControl(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-mute`,attributes:{type:"button","aria-label":h.t("player.volume"),"aria-haspopup":"true"}});return e.appendChild(b("volumeHigh")),e.addEventListener("contextmenu",t=>{t.preventDefault(),this.player.toggleMute()}),e.addEventListener("click",()=>{this.showVolumeSlider(e)}),this.controls.mute=e,e}showVolumeSlider(e){let t=document.querySelector(`.${this.player.options.classPrefix}-volume-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-menu ${this.player.options.classPrefix}-menu`}),s=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-slider`,attributes:{role:"slider","aria-label":h.t("player.volume"),"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":String(Math.round(this.player.state.volume*100)),tabindex:"0"}}),a=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-track`}),r=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-fill`}),o=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-handle`});a.appendChild(r),r.appendChild(o),s.appendChild(a),i.appendChild(s);let n=c=>{let u=a.getBoundingClientRect(),y=Math.max(0,Math.min(1,1-(c-u.top)/u.height));this.player.setVolume(y)};s.addEventListener("mousedown",c=>{c.stopPropagation(),this.isDraggingVolume=!0,n(c.clientY)}),document.addEventListener("mousemove",c=>{this.isDraggingVolume&&n(c.clientY)}),document.addEventListener("mouseup",()=>{this.isDraggingVolume=!1}),s.addEventListener("keydown",c=>{c.key==="ArrowUp"?(c.preventDefault(),this.player.setVolume(Math.min(1,this.player.state.volume+.1))):c.key==="ArrowDown"&&(c.preventDefault(),this.player.setVolume(Math.max(0,this.player.state.volume-.1)))}),i.addEventListener("click",c=>{c.stopPropagation()}),e.appendChild(i),this.controls.volumeSlider=s,this.controls.volumeFill=r,this.attachMenuCloseHandler(i,e,!0)}createTimeDisplay(){let e=l.createElement("div",{className:`${this.player.options.classPrefix}-time`,attributes:{role:"group","aria-label":h.t("time.display")}});this.controls.currentTimeDisplay=l.createElement("span",{className:`${this.player.options.classPrefix}-current-time`,attributes:{"aria-label":h.t("time.seconds",{count:0})}});let t=l.createElement("span",{textContent:"00:00",attributes:{"aria-hidden":"true"}});this.controls.currentTimeDisplay.appendChild(t),this.controls.currentTimeVisual=t;let i=l.createElement("span",{textContent:" / ",attributes:{"aria-hidden":"true"}});this.controls.durationDisplay=l.createElement("span",{className:`${this.player.options.classPrefix}-duration`,attributes:{"aria-label":h.t("time.durationPrefix")+h.t("time.seconds",{count:0})}});let s=l.createElement("span",{textContent:"00:00",attributes:{"aria-hidden":"true"}});return this.controls.durationDisplay.appendChild(s),this.controls.durationVisual=s,e.appendChild(this.controls.currentTimeDisplay),e.appendChild(i),e.appendChild(this.controls.durationDisplay),e}createChaptersButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-chapters`,attributes:{type:"button","aria-label":h.t("player.chapters"),"aria-haspopup":"menu"}});return e.appendChild(b("playlist")),e.addEventListener("click",()=>{this.showChaptersMenu(e)}),this.controls.chapters=e,e}showChaptersMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-chapters-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-chapters-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu","aria-label":h.t("player.chapters")}}),s=Array.from(this.player.element.textTracks).filter(a=>a.kind==="chapters");if(s.length===0){let a=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("player.noChapters"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(a)}else{let a=s[0];if(a.mode==="disabled"&&(a.mode="hidden"),!a.cues||a.cues.length===0){let r=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("player.loadingChapters"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(r);let o=()=>{i.remove(),this.showChaptersMenu(e)};a.addEventListener("load",o,{once:!0}),setTimeout(()=>{a.cues&&a.cues.length>0&&document.contains(i)&&(i.remove(),this.showChaptersMenu(e))},500)}else{let r=a.cues;for(let o=0;o<r.length;o++){let n=r[o],c=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,attributes:{type:"button",role:"menuitem",tabindex:"-1"}}),u=l.createElement("span",{className:`${this.player.options.classPrefix}-chapter-time`,textContent:A.formatTime(n.startTime)}),y=l.createElement("span",{className:`${this.player.options.classPrefix}-chapter-title`,textContent:n.text});c.appendChild(u),c.appendChild(document.createTextNode(" ")),c.appendChild(y),c.addEventListener("click",()=>{this.player.seek(n.startTime),i.remove()}),i.appendChild(c)}this.attachMenuKeyboardNavigation(i),setTimeout(()=>{let o=i.querySelector(`.${this.player.options.classPrefix}-menu-item`);o&&o.focus()},0)}}e.appendChild(i),this.attachMenuCloseHandler(i,e)}createQualityButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-quality`,attributes:{type:"button","aria-label":h.t("player.quality"),"aria-haspopup":"menu"}});e.appendChild(b("hd"));let t=l.createElement("span",{className:`${this.player.options.classPrefix}-quality-text`,textContent:""});return e.appendChild(t),e.addEventListener("click",()=>{this.showQualityMenu(e)}),this.controls.quality=e,this.controls.qualityText=t,setTimeout(()=>this.updateQualityIndicator(),500),e}showQualityMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-quality-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-quality-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu","aria-label":h.t("player.quality")}});if(this.player.renderer&&this.player.renderer.getQualities){let s=this.player.renderer.getQualities(),a=this.player.renderer.getCurrentQuality?this.player.renderer.getCurrentQuality():-1,r=this.player.renderer.hls!==void 0;if(s.length===0){let o=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("player.autoQuality"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(o)}else{let o=null;if(r){let n=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("player.auto"),attributes:{type:"button",role:"menuitem",tabindex:"-1"}});this.player.renderer.hls&&this.player.renderer.hls.currentLevel===-1&&(n.classList.add(`${this.player.options.classPrefix}-menu-item-active`),n.appendChild(b("check")),o=n),n.addEventListener("click",()=>{this.player.renderer.switchQuality&&this.player.renderer.switchQuality(-1),i.remove()}),i.appendChild(n)}s.forEach(n=>{let c=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:n.name||`${n.height}p`,attributes:{type:"button",role:"menuitem",tabindex:"-1"}});n.index===a&&(c.classList.add(`${this.player.options.classPrefix}-menu-item-active`),c.appendChild(b("check")),o=c),c.addEventListener("click",()=>{this.player.renderer.switchQuality&&this.player.renderer.switchQuality(n.index),i.remove()}),i.appendChild(c)}),this.attachMenuKeyboardNavigation(i),setTimeout(()=>{let n=o||i.querySelector(`.${this.player.options.classPrefix}-menu-item`);n&&n.focus()},0)}}else{let s=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("player.noQuality"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(s)}e.appendChild(i),this.attachMenuCloseHandler(i,e)}createCaptionStyleButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-caption-style`,attributes:{type:"button","aria-label":h.t("player.captionStyling"),"aria-haspopup":"menu",title:h.t("player.captionStyling")}}),t=l.createElement("span",{textContent:"Aa",style:{fontSize:"14px",fontWeight:"bold"}});return e.appendChild(t),e.addEventListener("click",()=>{this.showCaptionStyleMenu(e)}),this.controls.captionStyle=e,e}showCaptionStyleMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-caption-style-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-caption-style-menu ${this.player.options.classPrefix}-menu ${this.player.options.classPrefix}-settings-menu`,attributes:{role:"menu","aria-label":h.t("player.captionStyling")}});if(i.addEventListener("click",c=>{c.stopPropagation()}),!this.player.captionManager||this.player.captionManager.tracks.length===0){let c=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("player.noCaptions"),style:{opacity:"0.5",cursor:"default",padding:"12px 16px"}});i.appendChild(c),e.appendChild(i),this.attachMenuCloseHandler(i,e,!0);return}let s=this.createStyleControl(h.t("styleLabels.fontSize"),"captionsFontSize",[{label:h.t("fontSizes.small"),value:"87.5%"},{label:h.t("fontSizes.normal"),value:"100%"},{label:h.t("fontSizes.large"),value:"125%"},{label:h.t("fontSizes.xlarge"),value:"150%"}]);i.appendChild(s);let a=this.createStyleControl(h.t("styleLabels.font"),"captionsFontFamily",[{label:h.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:h.t("fontFamilies.serif"),value:"serif"},{label:h.t("fontFamilies.monospace"),value:"monospace"}]);i.appendChild(a);let r=this.createColorControl(h.t("styleLabels.textColor"),"captionsColor");i.appendChild(r);let o=this.createColorControl(h.t("styleLabels.background"),"captionsBackgroundColor");i.appendChild(o);let n=this.createOpacityControl(h.t("styleLabels.opacity"),"captionsOpacity");i.appendChild(n),i.style.minWidth="220px",e.appendChild(i),this.attachMenuCloseHandler(i,e,!0),setTimeout(()=>{let c=i.querySelector("select");c&&c.focus()},0)}createStyleControl(e,t,i){let s=l.createElement("div",{className:`${this.player.options.classPrefix}-style-group`}),a=l.createElement("label",{textContent:e,style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});s.appendChild(a);let r=l.createElement("select",{className:`${this.player.options.classPrefix}-style-select`,style:{width:"100%",padding:"6px",background:"var(--vidply-white)",border:"1px solid var(--vidply-white-10)",borderRadius:"4px",color:"var(--vidply-black)",fontSize:"13px"}}),o=this.player.options[t];return i.forEach(n=>{let c=l.createElement("option",{textContent:n.label,attributes:{value:n.value}});n.value===o&&(c.selected=!0),r.appendChild(c)}),r.addEventListener("mousedown",n=>{n.stopPropagation()}),r.addEventListener("click",n=>{n.stopPropagation()}),r.addEventListener("change",n=>{n.stopPropagation(),this.player.options[t]=n.target.value,this.player.captionManager&&this.player.captionManager.setCaptionStyle(t.replace("captions","").charAt(0).toLowerCase()+t.replace("captions","").slice(1),n.target.value)}),s.appendChild(r),s}createColorControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-style-group`}),s=l.createElement("label",{textContent:e,style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});i.appendChild(s);let a=l.createElement("input",{attributes:{type:"color",value:this.player.options[t]},style:{width:"100%",height:"32px",padding:"2px",background:"rgba(255,255,255,0.1)",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"4px",cursor:"pointer"}});return a.addEventListener("mousedown",r=>{r.stopPropagation()}),a.addEventListener("click",r=>{r.stopPropagation()}),a.addEventListener("change",r=>{r.stopPropagation(),this.player.options[t]=r.target.value,this.player.captionManager&&this.player.captionManager.setCaptionStyle(t.replace("captions","").charAt(0).toLowerCase()+t.replace("captions","").slice(1),r.target.value)}),i.appendChild(a),i}createOpacityControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-style-group`}),s=l.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"}}),a=l.createElement("label",{textContent:e,style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}}),r=l.createElement("span",{textContent:Math.round(this.player.options[t]*100)+"%",style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}});s.appendChild(a),s.appendChild(r),i.appendChild(s);let o=l.createElement("input",{attributes:{type:"range",min:"0",max:"1",step:"0.1",value:String(this.player.options[t])},style:{width:"100%",cursor:"pointer"}});return o.addEventListener("mousedown",n=>{n.stopPropagation()}),o.addEventListener("click",n=>{n.stopPropagation()}),o.addEventListener("input",n=>{n.stopPropagation();let c=parseFloat(n.target.value);r.textContent=Math.round(c*100)+"%",this.player.options[t]=c,this.player.captionManager&&this.player.captionManager.setCaptionStyle(t.replace("captions","").charAt(0).toLowerCase()+t.replace("captions","").slice(1),c)}),i.appendChild(o),i}createSpeedButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-speed`,attributes:{type:"button","aria-label":h.t("player.speed"),"aria-haspopup":"menu"}});e.appendChild(b("speed"));let t=l.createElement("span",{className:`${this.player.options.classPrefix}-speed-text`,textContent:"1x"});return e.appendChild(t),e.addEventListener("click",()=>{this.showSpeedMenu(e)}),this.controls.speed=e,this.controls.speedText=t,e}formatSpeedLabel(e){return e===1?h.t("speeds.normal"):`${e.toLocaleString(h.getLanguage(),{minimumFractionDigits:0,maximumFractionDigits:2})}\xD7`}showSpeedMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-speed-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-speed-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu"}}),s=[.25,.5,.75,1,1.25,1.5,1.75,2],a=null;s.forEach(r=>{let o=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:this.formatSpeedLabel(r),attributes:{type:"button",role:"menuitem",tabindex:"-1"}});r===this.player.state.playbackSpeed&&(o.classList.add(`${this.player.options.classPrefix}-menu-item-active`),o.appendChild(b("check")),a=o),o.addEventListener("click",()=>{this.player.setPlaybackSpeed(r),i.remove()}),i.appendChild(o)}),e.appendChild(i),this.attachMenuKeyboardNavigation(i),this.attachMenuCloseHandler(i,e),setTimeout(()=>{let r=a||i.querySelector(`.${this.player.options.classPrefix}-menu-item`);r&&r.focus()},0)}createCaptionsButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-captions-button`,attributes:{type:"button","aria-label":h.t("player.captions"),"aria-pressed":"false","aria-haspopup":"menu"}});return e.appendChild(b("captionsOff")),e.addEventListener("click",()=>{this.showCaptionsMenu(e)}),this.controls.captions=e,e}showCaptionsMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-captions-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-captions-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu","aria-label":h.t("captions.select")}});if(!this.player.captionManager||this.player.captionManager.tracks.length===0){let o=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("player.noCaptions"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(o),e.appendChild(i),this.attachMenuCloseHandler(i,e);return}let s=null,a=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:h.t("captions.off"),attributes:{type:"button",role:"menuitem",tabindex:"-1"}});this.player.state.captionsEnabled||(a.classList.add(`${this.player.options.classPrefix}-menu-item-active`),a.appendChild(b("check")),s=a),a.addEventListener("click",()=>{this.player.disableCaptions(),this.updateCaptionsButton(),i.remove()}),i.appendChild(a),this.player.captionManager.getAvailableTracks().forEach(o=>{let n=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:o.label,attributes:{type:"button",role:"menuitem",lang:o.language,tabindex:"-1"}});this.player.state.captionsEnabled&&this.player.captionManager.currentTrack===this.player.captionManager.tracks[o.index]&&(n.classList.add(`${this.player.options.classPrefix}-menu-item-active`),n.appendChild(b("check")),s=n),n.addEventListener("click",()=>{this.player.captionManager.switchTrack(o.index),this.updateCaptionsButton(),i.remove()}),i.appendChild(n)}),e.appendChild(i),this.attachMenuKeyboardNavigation(i),this.attachMenuCloseHandler(i,e),setTimeout(()=>{let o=s||i.querySelector(`.${this.player.options.classPrefix}-menu-item`);o&&o.focus()},0)}updateCaptionsButton(){if(!this.controls.captions)return;let e=this.controls.captions.querySelector(".vidply-icon"),t=this.player.state.captionsEnabled;e.innerHTML=t?b("captions").innerHTML:b("captionsOff").innerHTML,this.controls.captions.setAttribute("aria-pressed",t?"true":"false")}createTranscriptButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-transcript`,attributes:{type:"button","aria-label":h.t("player.transcript"),"aria-pressed":"false"}});return e.appendChild(b("transcript")),e.addEventListener("click",()=>{this.player.transcriptManager&&(this.player.transcriptManager.toggleTranscript(),this.updateTranscriptButton())}),this.controls.transcript=e,e}updateTranscriptButton(){if(!this.controls.transcript)return;let e=this.player.transcriptManager&&this.player.transcriptManager.isVisible;this.controls.transcript.setAttribute("aria-pressed",e?"true":"false")}createAudioDescriptionButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-audio-description`,attributes:{type:"button","aria-label":h.t("player.audioDescription"),"aria-pressed":"false",title:h.t("player.audioDescription")}});return e.appendChild(b("audioDescription")),e.addEventListener("click",async()=>{await this.player.toggleAudioDescription(),this.updateAudioDescriptionButton()}),this.controls.audioDescription=e,e}updateAudioDescriptionButton(){if(!this.controls.audioDescription)return;let e=this.controls.audioDescription.querySelector(".vidply-icon"),t=this.player.state.audioDescriptionEnabled;e.innerHTML=t?b("audioDescriptionOn").innerHTML:b("audioDescription").innerHTML,this.controls.audioDescription.setAttribute("aria-pressed",t?"true":"false"),this.controls.audioDescription.setAttribute("aria-label",t?h.t("audioDescription.disable"):h.t("audioDescription.enable"))}createSignLanguageButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-sign-language`,attributes:{type:"button","aria-label":h.t("player.signLanguage"),"aria-pressed":"false",title:h.t("player.signLanguage")}});return e.appendChild(b("signLanguage")),e.addEventListener("click",()=>{this.player.toggleSignLanguage(),this.updateSignLanguageButton()}),this.controls.signLanguage=e,e}updateSignLanguageButton(){if(!this.controls.signLanguage)return;let e=this.controls.signLanguage.querySelector(".vidply-icon"),t=this.player.state.signLanguageEnabled;e.innerHTML=t?b("signLanguageOn").innerHTML:b("signLanguage").innerHTML,this.controls.signLanguage.setAttribute("aria-pressed",t?"true":"false"),this.controls.signLanguage.setAttribute("aria-label",t?h.t("signLanguage.hide"):h.t("signLanguage.show"))}createSettingsButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-settings`,attributes:{type:"button","aria-label":h.t("player.settings")}});return e.appendChild(b("settings")),e.addEventListener("click",()=>{this.player.showSettings()}),e}createPipButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-pip`,attributes:{type:"button","aria-label":h.t("player.pip")}});return e.appendChild(b("pip")),e.addEventListener("click",()=>{this.player.togglePiP()}),e}createFullscreenButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-fullscreen`,attributes:{type:"button","aria-label":h.t("player.fullscreen")}});return e.appendChild(b("fullscreen")),e.addEventListener("click",()=>{this.player.toggleFullscreen()}),this.controls.fullscreen=e,e}attachEvents(){this.player.on("play",()=>this.updatePlayPauseButton()),this.player.on("pause",()=>this.updatePlayPauseButton()),this.player.on("timeupdate",()=>this.updateProgress()),this.player.on("loadedmetadata",()=>{this.updateDuration(),this.ensureQualityButton(),this.updateQualityIndicator()}),this.player.on("volumechange",()=>this.updateVolumeDisplay()),this.player.on("progress",()=>this.updateBuffered()),this.player.on("playbackspeedchange",()=>this.updateSpeedDisplay()),this.player.on("fullscreenchange",()=>this.updateFullscreenButton()),this.player.on("captionsenabled",()=>this.updateCaptionsButton()),this.player.on("captionsdisabled",()=>this.updateCaptionsButton()),this.player.on("audiodescriptionenabled",()=>this.updateAudioDescriptionButton()),this.player.on("audiodescriptiondisabled",()=>this.updateAudioDescriptionButton()),this.player.on("signlanguageenabled",()=>this.updateSignLanguageButton()),this.player.on("signlanguagedisabled",()=>this.updateSignLanguageButton()),this.player.on("qualitychange",()=>this.updateQualityIndicator()),this.player.on("hlslevelswitched",()=>this.updateQualityIndicator()),this.player.on("hlsmanifestparsed",()=>{this.ensureQualityButton(),this.updateQualityIndicator()})}updatePlayPauseButton(){if(!this.controls.playPause)return;let e=this.controls.playPause.querySelector(".vidply-icon"),t=this.player.state.playing;e.innerHTML=t?b("pause").innerHTML:b("play").innerHTML,this.controls.playPause.setAttribute("aria-label",t?h.t("player.pause"):h.t("player.play"))}updateProgress(){if(!this.controls.played)return;let e=this.player.state.currentTime/this.player.state.duration*100;if(this.controls.played.style.width=`${e}%`,this.controls.progress.setAttribute("aria-valuenow",String(Math.round(e))),this.controls.currentTimeVisual){let t=this.player.state.currentTime;this.controls.currentTimeVisual.textContent=A.formatTime(t),this.controls.currentTimeDisplay.setAttribute("aria-label",A.formatDuration(t))}}updateDuration(){if(this.controls.durationVisual){let e=this.player.state.duration;this.controls.durationVisual.textContent=A.formatTime(e),this.controls.durationDisplay.setAttribute("aria-label",h.t("time.durationPrefix")+A.formatDuration(e))}}updateVolumeDisplay(){let e=this.player.state.volume*100;if(this.controls.volumeFill&&(this.controls.volumeFill.style.height=`${e}%`),this.controls.mute){let t=this.controls.mute.querySelector(".vidply-icon");if(t){let i;this.player.state.muted||this.player.state.volume===0?i="volumeMuted":this.player.state.volume<.3?i="volumeLow":this.player.state.volume<.7?i="volumeMedium":i="volumeHigh",t.innerHTML=b(i).innerHTML,this.controls.mute.setAttribute("aria-label",this.player.state.muted?h.t("player.unmute"):h.t("player.mute"))}}this.controls.volumeSlider&&this.controls.volumeSlider.setAttribute("aria-valuenow",String(Math.round(e)))}updateBuffered(){if(!this.controls.buffered||!this.player.element.buffered||this.player.element.buffered.length===0)return;let t=this.player.element.buffered.end(this.player.element.buffered.length-1)/this.player.state.duration*100;this.controls.buffered.style.width=`${t}%`}updateSpeedDisplay(){this.controls.speedText&&(this.controls.speedText.textContent=`${this.player.state.playbackSpeed}x`)}updateFullscreenButton(){if(!this.controls.fullscreen)return;let e=this.controls.fullscreen.querySelector(".vidply-icon"),t=this.player.state.fullscreen;e.innerHTML=t?b("fullscreenExit").innerHTML:b("fullscreen").innerHTML,this.controls.fullscreen.setAttribute("aria-label",t?h.t("player.exitFullscreen"):h.t("player.fullscreen"))}ensureQualityButton(){if(!this.player.options.qualityButton||this.controls.quality||!this.hasQualityLevels())return;let e=this.createQualityButton(),t=this.rightButtons.querySelector(`.${this.player.options.classPrefix}-speed`),s=this.rightButtons.querySelector(`.${this.player.options.classPrefix}-caption-style`)||t;s?this.rightButtons.insertBefore(e,s):this.rightButtons.insertBefore(e,this.rightButtons.firstChild),this.player.log("Quality button added dynamically","info")}updateQualityIndicator(){if(!this.controls.qualityText||!this.player.renderer||!this.player.renderer.getQualities)return;let e=this.player.renderer.getQualities();if(e.length===0){this.controls.qualityText.textContent="";return}let t="";if(this.player.renderer.hls&&this.player.renderer.hls.currentLevel===-1)t="Auto";else if(this.player.renderer.getCurrentQuality){let i=this.player.renderer.getCurrentQuality(),s=e.find(a=>a.index===i);s&&(t=s.height?`${s.height}p`:"")}this.controls.qualityText.textContent=t}setupAutoHide(){if(this.player.element.tagName!=="VIDEO")return;let e=()=>{this.element.classList.add(`${this.player.options.classPrefix}-controls-visible`),this.player.container.classList.add(`${this.player.options.classPrefix}-controls-visible`),this.player.state.controlsVisible=!0,clearTimeout(this.hideTimeout),this.player.state.playing&&(this.hideTimeout=setTimeout(()=>{this.element.classList.remove(`${this.player.options.classPrefix}-controls-visible`),this.player.container.classList.remove(`${this.player.options.classPrefix}-controls-visible`),this.player.state.controlsVisible=!1},this.player.options.hideControlsDelay))};this.player.container.addEventListener("mousemove",e),this.player.container.addEventListener("touchstart",e),this.player.container.addEventListener("click",e),this.element.addEventListener("focusin",e),this.player.on("pause",()=>{e(),clearTimeout(this.hideTimeout)}),this.player.on("play",()=>{e()}),e()}show(){this.element.style.display=""}hide(){this.element.style.display="none"}destroy(){this.hideTimeout&&clearTimeout(this.hideTimeout),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}};var D=class{constructor(e="vidply"){this.namespace=e,this.storage=this.isStorageAvailable()?localStorage:null}isStorageAvailable(){try{let e="__storage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}getKey(e){return`${this.namespace}_${e}`}set(e,t){if(!this.storage)return!1;try{let i=this.getKey(e);return this.storage.setItem(i,JSON.stringify(t)),!0}catch(i){return console.warn("Failed to save to localStorage:",i),!1}}get(e,t=null){if(!this.storage)return t;try{let i=this.getKey(e),s=this.storage.getItem(i);return s?JSON.parse(s):t}catch(i){return console.warn("Failed to read from localStorage:",i),t}}remove(e){if(!this.storage)return!1;try{let t=this.getKey(e);return this.storage.removeItem(t),!0}catch(t){return console.warn("Failed to remove from localStorage:",t),!1}}clear(){if(!this.storage)return!1;try{return Object.keys(this.storage).forEach(t=>{t.startsWith(this.namespace)&&this.storage.removeItem(t)}),!0}catch(e){return console.warn("Failed to clear localStorage:",e),!1}}saveTranscriptPreferences(e){return this.set("transcript_preferences",e)}getTranscriptPreferences(){return this.get("transcript_preferences",null)}saveCaptionPreferences(e){return this.set("caption_preferences",e)}getCaptionPreferences(){return this.get("caption_preferences",null)}savePlayerPreferences(e){return this.set("player_preferences",e)}getPlayerPreferences(){return this.get("player_preferences",null)}saveSignLanguagePreferences(e){return this.set("sign_language_preferences",e)}getSignLanguagePreferences(){return this.get("sign_language_preferences",null)}};var $=class{constructor(e){this.player=e,this.element=null,this.tracks=[],this.currentTrack=null,this.currentCue=null,this.storage=new D("vidply"),this.loadSavedPreferences(),this.init()}loadSavedPreferences(){let e=this.storage.getCaptionPreferences();e&&(e.fontSize&&(this.player.options.captionsFontSize=e.fontSize),e.fontFamily&&(this.player.options.captionsFontFamily=e.fontFamily),e.color&&(this.player.options.captionsColor=e.color),e.backgroundColor&&(this.player.options.captionsBackgroundColor=e.backgroundColor),e.opacity!==void 0&&(this.player.options.captionsOpacity=e.opacity))}saveCaptionPreferences(){this.storage.saveCaptionPreferences({fontSize:this.player.options.captionsFontSize,fontFamily:this.player.options.captionsFontFamily,color:this.player.options.captionsColor,backgroundColor:this.player.options.captionsBackgroundColor,opacity:this.player.options.captionsOpacity})}init(){this.createElement(),this.loadTracks(),this.attachEvents(),this.player.options.captionsDefault&&this.tracks.length>0&&this.enable()}createElement(){this.element=l.createElement("div",{className:`${this.player.options.classPrefix}-captions`,attributes:{"aria-live":"polite","aria-atomic":"true",role:"region","aria-label":h.t("player.captions")}}),this.updateStyles(),(this.player.videoWrapper||this.player.container).appendChild(this.element)}loadTracks(){let e=this.player.element.textTracks;for(let t=0;t<e.length;t++){let i=e[t];(i.kind==="subtitles"||i.kind==="captions")&&(this.tracks.push({track:i,language:i.language,label:i.label,kind:i.kind,index:t}),i.mode="hidden")}}attachEvents(){this.player.on("timeupdate",()=>{this.updateCaptions()}),this.player.on("captionschange",()=>{this.updateStyles()})}enable(e=0){if(this.tracks.length===0)return;this.currentTrack&&(this.currentTrack.track.mode="hidden");let t=this.tracks[e];t&&(t.track.mode="hidden",this.currentTrack=t,this.player.state.captionsEnabled=!0,this.cueChangeHandler&&t.track.removeEventListener("cuechange",this.cueChangeHandler),this.cueChangeHandler=()=>{this.updateCaptions()},t.track.addEventListener("cuechange",this.cueChangeHandler),this.player.emit("captionsenabled",t))}disable(){this.currentTrack&&(this.currentTrack.track.mode="hidden",this.currentTrack=null),this.element.style.display="none",this.element.innerHTML="",this.currentCue=null,this.player.state.captionsEnabled=!1,this.player.emit("captionsdisabled")}updateCaptions(){if(!this.currentTrack||!this.currentTrack.track.activeCues)return;let e=this.currentTrack.track.activeCues;if(e.length>0){let t=e[0];if(this.currentCue!==t){this.currentCue=t;let i=t.text;i=this.parseVTTFormatting(i),this.element.innerHTML=l.sanitizeHTML(i),this.element.style.display="block",this.player.emit("captionchange",t)}}else this.currentCue&&(this.element.innerHTML="",this.element.style.display="none",this.currentCue=null)}parseVTTFormatting(e){return e=e.replace(/<c[^>]*>(.*?)<\/c>/g,'<span class="caption-class">$1</span>'),e=e.replace(/<b>(.*?)<\/b>/g,"<strong>$1</strong>"),e=e.replace(/<i>(.*?)<\/i>/g,"<em>$1</em>"),e=e.replace(/<u>(.*?)<\/u>/g,"<u>$1</u>"),e=e.replace(/<v\s+([^>]+)>(.*?)<\/v>/g,'<span class="caption-voice" data-voice="$1">$2</span>'),e}updateStyles(){if(!this.element)return;let e=this.player.options;this.element.style.fontSize=e.captionsFontSize,this.element.style.fontFamily=e.captionsFontFamily,this.element.style.color=e.captionsColor,this.element.style.backgroundColor=this.hexToRgba(e.captionsBackgroundColor,e.captionsOpacity)}hexToRgba(e,t){let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return i?`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, ${t})`:e}setCaptionStyle(e,t){switch(e){case"fontSize":this.player.options.captionsFontSize=t;break;case"fontFamily":this.player.options.captionsFontFamily=t;break;case"color":this.player.options.captionsColor=t;break;case"backgroundColor":this.player.options.captionsBackgroundColor=t;break;case"opacity":this.player.options.captionsOpacity=t;break}this.updateStyles(),this.saveCaptionPreferences(),this.player.emit("captionschange")}getAvailableTracks(){return this.tracks.map((e,t)=>({index:t,language:e.language,label:e.label||e.language,kind:e.kind}))}switchTrack(e){e>=0&&e<this.tracks.length&&(this.disable(),this.enable(e))}destroy(){this.disable(),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}};var R=class{constructor(e){this.player=e,this.shortcuts=e.options.keyboardShortcuts,this.init()}init(){this.attachEvents()}attachEvents(){this.player.container.addEventListener("keydown",e=>{this.handleKeydown(e)}),this.player.container.hasAttribute("tabindex")||this.player.container.setAttribute("tabindex","0")}handleKeydown(e){if(e.target.tagName==="INPUT"||e.target.tagName==="TEXTAREA"||e.target.tagName==="SELECT")return;let t=e.key,i=!1;for(let[s,a]of Object.entries(this.shortcuts))if(a.includes(t)&&(i=this.executeAction(s,e),i)){e.preventDefault(),e.stopPropagation(),this.announceAction(s);break}!i&&this.player.options.debug&&console.log("[VidPly] Unhandled key:",e.key,"code:",e.code,"shiftKey:",e.shiftKey)}executeAction(e,t){switch(e){case"play-pause":return this.player.toggle(),!0;case"volume-up":return this.player.setVolume(Math.min(1,this.player.state.volume+.1)),!0;case"volume-down":return this.player.setVolume(Math.max(0,this.player.state.volume-.1)),!0;case"seek-forward":return this.player.seekForward(),!0;case"seek-backward":return this.player.seekBackward(),!0;case"mute":return this.player.toggleMute(),!0;case"fullscreen":return this.player.toggleFullscreen(),!0;case"captions":if(this.player.captionManager&&this.player.captionManager.tracks.length>1){let i=this.player.controlBar&&this.player.controlBar.controls.captions;i?this.player.controlBar.showCaptionsMenu(i):this.player.toggleCaptions()}else this.player.toggleCaptions();return!0;case"caption-style-menu":return this.player.controlBar&&this.player.controlBar.controls.captionStyle?(this.player.controlBar.showCaptionStyleMenu(this.player.controlBar.controls.captionStyle),!0):!1;case"speed-up":return this.player.setPlaybackSpeed(Math.min(2,this.player.state.playbackSpeed+.25)),!0;case"speed-down":return this.player.setPlaybackSpeed(Math.max(.25,this.player.state.playbackSpeed-.25)),!0;case"speed-menu":return this.player.controlBar&&this.player.controlBar.controls.speed?(this.player.controlBar.showSpeedMenu(this.player.controlBar.controls.speed),!0):!1;case"quality-menu":return this.player.controlBar&&this.player.controlBar.controls.quality?(this.player.controlBar.showQualityMenu(this.player.controlBar.controls.quality),!0):!1;case"chapters-menu":return this.player.controlBar&&this.player.controlBar.controls.chapters?(this.player.controlBar.showChaptersMenu(this.player.controlBar.controls.chapters),!0):!1;case"transcript-toggle":return this.player.transcriptManager?(this.player.transcriptManager.toggleTranscript(),!0):!1;default:return!1}}announceAction(e){if(!this.player.options.screenReaderAnnouncements)return;let t="";switch(e){case"play-pause":t=this.player.state.playing?"Playing":"Paused";break;case"volume-up":t=`Volume ${Math.round(this.player.state.volume*100)}%`;break;case"volume-down":t=`Volume ${Math.round(this.player.state.volume*100)}%`;break;case"mute":t=this.player.state.muted?"Muted":"Unmuted";break;case"fullscreen":t=this.player.state.fullscreen?"Fullscreen":"Exit fullscreen";break;case"captions":t=this.player.state.captionsEnabled?"Captions on":"Captions off";break;case"speed-up":case"speed-down":t=`Speed ${this.player.state.playbackSpeed}x`;break}t&&this.announce(t)}announce(e,t="polite"){let i=document.getElementById("vidply-announcer");i||(i=document.createElement("div"),i.id="vidply-announcer",i.className="vidply-sr-only",i.setAttribute("aria-live",t),i.setAttribute("aria-atomic","true"),i.style.cssText=`
|
|
7
|
+
var VidPly=(()=>{var K=Object.defineProperty;var Z=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var te=Object.prototype.hasOwnProperty;var ie=(h,e)=>()=>(h&&(e=h(h=0)),e);var _=(h,e)=>{for(var t in e)K(h,t,{get:e[t],enumerable:!0})},se=(h,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ee(e))!te.call(h,s)&&s!==t&&K(h,s,{get:()=>e[s],enumerable:!(i=Z(e,s))||i.enumerable});return h};var ae=h=>se(K({},"__esModule",{value:!0}),h);var G={};_(G,{HTML5Renderer:()=>B});var B,Q=ie(()=>{B=class{constructor(e){this.player=e,this.media=e.element}async init(){this.media.controls=!1,this.media.removeAttribute("controls"),this.attachEvents(),this.media.preload=this.player.options.preload,this.media.load()}attachEvents(){this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player),this.player.options.pauseOthersOnPlay&&this.pauseOtherPlayers()}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume),this.player.options.onVolumeChange&&this.player.options.onVolumeChange.call(this.player,this.media.volume)}),this.media.addEventListener("seeking",()=>{this.player.state.seeking=!0,this.player.emit("seeking")}),this.media.addEventListener("seeked",()=>{this.player.state.seeking=!1,this.player.emit("seeked")}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.media.addEventListener("progress",()=>{if(this.media.buffered.length>0){let e=this.media.buffered.end(this.media.buffered.length-1);this.player.emit("progress",e)}}),this.media.addEventListener("error",e=>{this.player.handleError(this.media.error)}),this.media.addEventListener("ratechange",()=>{this.player.state.playbackSpeed=this.media.playbackRate,this.player.emit("ratechange",this.media.playbackRate)})}pauseOtherPlayers(){document.querySelectorAll(".vidply-player").forEach(t=>{if(t!==this.player.container){let i=t.querySelector("video, audio");i&&!i.paused&&i.pause()}})}play(){let e=this.media.play();e!==void 0&&e.catch(t=>{this.player.log("Play failed:",t,"warn"),this.player.options.autoplay&&!this.player.state.muted&&(this.player.log("Retrying play with muted audio","info"),this.media.muted=!0,this.media.play().catch(i=>{this.player.handleError(i)}))})}pause(){this.media.pause()}seek(e){this.media.currentTime=e}setVolume(e){this.media.volume=e}setMuted(e){this.media.muted=e}setPlaybackSpeed(e){this.media.playbackRate=e}getQualities(){let e=Array.from(this.media.querySelectorAll("source"));return e.length<=1?[]:e.map((t,i)=>{let s=t.getAttribute("data-quality")||t.getAttribute("label")||"",a=t.getAttribute("data-height")||this.extractHeightFromLabel(s),r=t.getAttribute("data-width")||"";return{index:i,height:a?parseInt(a):0,width:r?parseInt(r):0,src:t.src,type:t.type,name:s||(a?`${a}p`:`Quality ${i+1}`)}}).filter(t=>t.height>0)}extractHeightFromLabel(e){let t=e.match(/(\d+)p/i);return t?parseInt(t[1]):0}switchQuality(e){let t=this.getQualities();if(e<0||e>=t.length){this.player.log("Invalid quality index","warn");return}let i=t[e],s=this.media.currentTime,a=!this.media.paused;if(this.media.currentSrc===i.src){this.player.log("Already at this quality level","info");return}this.player.log(`Switching to quality: ${i.name}`,"info"),this.media.src=i.src;let n=()=>{this.media.removeEventListener("loadedmetadata",n),this.media.currentTime=s,a&&this.media.play().catch(o=>{this.player.log("Failed to resume playback after quality switch","warn")}),this.player.emit("qualitychange",{quality:i.name,index:e})};this.media.addEventListener("loadedmetadata",n),this.media.load()}getCurrentQuality(){let e=this.getQualities(),t=this.media.currentSrc;for(let i=0;i<e.length;i++)if(e[i].src===t)return i;return 0}destroy(){this.media.removeEventListener("loadedmetadata",()=>{}),this.media.removeEventListener("play",()=>{}),this.media.removeEventListener("pause",()=>{})}}});var de={};_(de,{Player:()=>z,PlaylistManager:()=>q,default:()=>ce});var V=class{constructor(){this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),this}once(e,t){let i=(...s)=>{t(...s),this.off(e,i)};return this.on(e,i)}off(e,t){return this.events[e]?(t?this.events[e]=this.events[e].filter(i=>i!==t):delete this.events[e],this):this}emit(e,...t){return this.events[e]?(this.events[e].forEach(i=>{i(...t)}),this):this}removeAllListeners(){return this.events={},this}};var l={createElement(h,e={}){let t=document.createElement(h);return e.className&&(t.className=e.className),e.attributes&&Object.entries(e.attributes).forEach(([i,s])=>{t.setAttribute(i,s)}),e.innerHTML&&(t.innerHTML=e.innerHTML),e.textContent&&(t.textContent=e.textContent),e.style&&Object.assign(t.style,e.style),e.children&&e.children.forEach(i=>{i&&t.appendChild(i)}),t},addClass(h,e){h&&e&&h.classList.add(e)},removeClass(h,e){h&&e&&h.classList.remove(e)},toggleClass(h,e){h&&e&&h.classList.toggle(e)},hasClass(h,e){return h&&h.classList.contains(e)},show(h){h&&(h.style.display="")},hide(h){h&&(h.style.display="none")},fadeIn(h,e=300){if(!h)return;h.style.opacity="0",h.style.display="";let t=null,i=s=>{t||(t=s);let a=s-t,r=Math.min(a/e,1);h.style.opacity=r,a<e&&requestAnimationFrame(i)};requestAnimationFrame(i)},fadeOut(h,e=300){if(!h)return;let t=parseFloat(getComputedStyle(h).opacity)||1,i=null,s=a=>{i||(i=a);let r=a-i,n=Math.max(t-r/e,0);h.style.opacity=n,r<e?requestAnimationFrame(s):h.style.display="none"};requestAnimationFrame(s)},offset(h){if(!h)return{top:0,left:0};let e=h.getBoundingClientRect();return{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset,width:e.width,height:e.height}},escapeHTML(h){let e=document.createElement("div");return e.textContent=h,e.innerHTML},sanitizeHTML(h){let e=document.createElement("div"),t=h.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"").replace(/<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,"").replace(/on\w+\s*=/gi,"").replace(/javascript:/gi,"");return e.innerHTML=t,e.innerHTML}};var Y={en:{player:{label:"Video Player",play:"Play",pause:"Pause",stop:"Stop",restart:"Restart from beginning",rewind:"Rewind",forward:"Forward",rewindSeconds:"Rewind {seconds} seconds",forwardSeconds:"Forward {seconds} seconds",previous:"Previous track",next:"Next track",volume:"Volume",mute:"Mute",unmute:"Unmute",fullscreen:"Fullscreen",exitFullscreen:"Exit Fullscreen",captions:"Captions",chapters:"Chapters",quality:"Quality",captionStyling:"Caption styling",transcript:"Toggle transcript",audioDescription:"Audio description",signLanguage:"Sign language video",settings:"Settings",speed:"Playback Speed",pip:"Picture in Picture",currentTime:"Current time",duration:"Duration",progress:"Progress",seekForward:"Seek forward {seconds} seconds",seekBackward:"Seek backward {seconds} seconds",volumeUp:"Volume up",volumeDown:"Volume down",loading:"Loading...",loadingChapters:"Loading chapters...",error:"Error loading media",buffering:"Buffering...",signLanguageVideo:"Sign Language Video",noChapters:"No chapters available",noCaptions:"No captions available",auto:"Auto",autoQuality:"Auto (no quality selection available)",noQuality:"Quality selection not available",signLanguageDragResize:"Sign Language Video - Press D to drag with keyboard, R to resize",signLanguageDragActive:"Sign Language Video - Drag mode active. Use arrow keys to move, Escape to exit.",signLanguageResizeActive:"Sign Language Video - Resize mode active. Use left/right arrow keys to resize, Escape to exit.",resizeHandle:"Resize {direction} corner"},captions:{off:"Off",select:"Select captions",fontSize:"Font Size",fontFamily:"Font Family",color:"Text Color",backgroundColor:"Background Color",opacity:"Opacity"},fontSizes:{small:"Small",normal:"Normal",large:"Large",xlarge:"X-Large"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Text Color",background:"Background",font:"Font",fontSize:"Font Size",opacity:"Opacity"},audioDescription:{enable:"Enable audio description",disable:"Disable audio description"},signLanguage:{show:"Show sign language video",hide:"Hide sign language video"},transcript:{title:"Transcript",close:"Close transcript",loading:"Loading transcript...",noTranscript:"No transcript available for this video.",settings:"Transcript settings. Press Enter to open menu, or D to enable drag mode",keyboardDragMode:"Toggle keyboard drag mode with arrow keys. Shortcut: D key",keyboardDragActive:"\u2328\uFE0F Keyboard Drag Mode Active (Arrow keys to move, Shift+Arrows for large steps, D or ESC to exit)",dragResizePrompt:"Press D to drag or R to resize. Use Home to reset position, Esc to close.",dragModeEnabled:"Keyboard drag mode enabled. Use arrow keys to move, Shift+Arrow for larger steps. Press D or Esc to exit.",dragModeDisabled:"Keyboard drag mode disabled.",resizeWindow:"Resize Window",disableResizeWindow:"Disable Resize Mode",resizeModeHint:"Resize handles enabled. Drag edges or corners to adjust. Press Esc or R to exit.",resizeModeEnabled:"Resize mode enabled. Drag edges or corners to adjust. Press Esc or R to exit.",resizeModeDisabled:"Resize mode disabled.",positionReset:"Transcript position reset.",styleTranscript:"Open transcript style settings",closeMenu:"Close Menu",styleTitle:"Transcript Style",autoscroll:"Autoscroll",settingsMenu:"Settings menu"},settings:{title:"Settings",quality:"Quality",speed:"Speed",captions:"Captions",language:"Language",reset:"Reset to defaults",close:"Close"},speeds:{normal:"Normal"},time:{display:"Time display",durationPrefix:"Duration: ",hour:"{count} hour",hours:"{count} hours",minute:"{count} minute",minutes:"{count} minutes",second:"{count} second",seconds:"{count} seconds"}},de:{player:{label:"Videoplayer",play:"Abspielen",pause:"Pause",stop:"Stopp",restart:"Von vorne beginnen",rewind:"Zur\xFCckspulen",forward:"Vorspulen",rewindSeconds:"{seconds} Sekunden zur\xFCckspulen",forwardSeconds:"{seconds} Sekunden vorspulen",previous:"Vorheriger Titel",next:"N\xE4chster Titel",volume:"Lautst\xE4rke",mute:"Stumm",unmute:"Ton ein",fullscreen:"Vollbild",exitFullscreen:"Vollbild beenden",captions:"Untertitel",chapters:"Kapitel",quality:"Qualit\xE4t",captionStyling:"Untertitel-Stil",transcript:"Transkript umschalten",audioDescription:"Audiodeskription",signLanguage:"Geb\xE4rdensprache-Video",settings:"Einstellungen",speed:"Wiedergabegeschwindigkeit",pip:"Bild-in-Bild",currentTime:"Aktuelle Zeit",duration:"Dauer",progress:"Fortschritt",seekForward:"{seconds} Sekunden vorspulen",seekBackward:"{seconds} Sekunden zur\xFCckspulen",volumeUp:"Lauter",volumeDown:"Leiser",loading:"L\xE4dt...",loadingChapters:"Kapitel werden geladen...",error:"Fehler beim Laden",buffering:"Puffern...",signLanguageVideo:"Geb\xE4rdensprache-Video",noChapters:"Keine Kapitel verf\xFCgbar",noCaptions:"Keine Untertitel verf\xFCgbar",auto:"Automatisch",autoQuality:"Automatisch (keine Qualit\xE4tsauswahl verf\xFCgbar)",noQuality:"Qualit\xE4tsauswahl nicht verf\xFCgbar",signLanguageDragResize:"Geb\xE4rdensprache-Video - Dr\xFCcken Sie D zum Verschieben per Tastatur, R zum \xC4ndern der Gr\xF6\xDFe",signLanguageDragActive:"Geb\xE4rdensprache-Video - Verschiebemodus aktiv. Pfeiltasten zum Bewegen, Escape zum Beenden.",signLanguageResizeActive:"Geb\xE4rdensprache-Video - Gr\xF6\xDFen\xE4nderungsmodus aktiv. Links-/Rechts-Pfeiltasten zum \xC4ndern der Gr\xF6\xDFe, Escape zum Beenden.",resizeHandle:"Gr\xF6\xDFen\xE4nderung {direction}-Ecke"},captions:{off:"Aus",select:"Untertitel ausw\xE4hlen",fontSize:"Schriftgr\xF6\xDFe",fontFamily:"Schriftart",color:"Textfarbe",backgroundColor:"Hintergrundfarbe",opacity:"Deckkraft"},fontSizes:{small:"Klein",normal:"Normal",large:"Gro\xDF",xlarge:"Sehr gro\xDF"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Textfarbe",background:"Hintergrund",font:"Schrift",fontSize:"Schriftgr\xF6\xDFe",opacity:"Deckkraft"},audioDescription:{enable:"Audiodeskription aktivieren",disable:"Audiodeskription deaktivieren"},signLanguage:{show:"Geb\xE4rdensprache-Video anzeigen",hide:"Geb\xE4rdensprache-Video ausblenden"},transcript:{title:"Transkript",close:"Transkript schlie\xDFen",loading:"Transkript wird geladen...",noTranscript:"Kein Transkript f\xFCr dieses Video verf\xFCgbar.",settings:"Transkript-Einstellungen. Eingabetaste zum \xD6ffnen des Men\xFCs dr\xFCcken oder D zum Aktivieren des Verschiebemodus",keyboardDragMode:"Tastatur-Verschiebemodus mit Pfeiltasten umschalten. Tastenkombination: D-Taste",keyboardDragActive:"\u2328\uFE0F Tastatur-Verschiebemodus aktiv (Pfeiltasten zum Bewegen, Umschalt+Pfeiltasten f\xFCr gro\xDFe Schritte, D oder ESC zum Beenden)",dragResizePrompt:"Dr\xFCcken Sie D zum Verschieben oder R zur Gr\xF6\xDFen\xE4nderung. Home setzt die Position zur\xFCck, Esc schlie\xDFt.",dragModeEnabled:"Tastatur-Verschiebemodus aktiviert. Pfeiltasten zum Bewegen, Umschalt+Pfeiltasten f\xFCr gr\xF6\xDFere Schritte. D oder Esc zum Beenden.",dragModeDisabled:"Tastatur-Verschiebemodus deaktiviert.",resizeWindow:"Fenster vergr\xF6\xDFern/verkleinern",disableResizeWindow:"Resize-Modus deaktivieren",resizeModeHint:"Griffe aktiviert. Ziehen Sie Kanten oder Ecken zum Anpassen. Esc oder R zum Beenden.",resizeModeEnabled:"Resize-Modus aktiviert. Kanten oder Ecken ziehen; Esc oder R beendet.",resizeModeDisabled:"Resize-Modus deaktiviert.",positionReset:"Transkriptposition zur\xFCckgesetzt.",styleTranscript:"Transkript-Stileinstellungen \xF6ffnen",closeMenu:"Men\xFC schlie\xDFen",styleTitle:"Transkript-Stil",autoscroll:"Automatisches Scrollen",settingsMenu:"Einstellungsmen\xFC"},settings:{title:"Einstellungen",quality:"Qualit\xE4t",speed:"Geschwindigkeit",captions:"Untertitel",language:"Sprache",reset:"Zur\xFCcksetzen",close:"Schlie\xDFen"},speeds:{normal:"Normal"},time:{display:"Zeitanzeige",durationPrefix:"Dauer: ",hour:"{count} Stunde",hours:"{count} Stunden",minute:"{count} Minute",minutes:"{count} Minuten",second:"{count} Sekunde",seconds:"{count} Sekunden"}},es:{player:{label:"Reproductor de video",play:"Reproducir",pause:"Pausa",stop:"Detener",restart:"Reiniciar desde el principio",rewind:"Retroceder",forward:"Avanzar",rewindSeconds:"Retroceder {seconds} segundos",forwardSeconds:"Avanzar {seconds} segundos",previous:"Pista anterior",next:"Siguiente pista",volume:"Volumen",mute:"Silenciar",unmute:"Activar sonido",fullscreen:"Pantalla completa",exitFullscreen:"Salir de pantalla completa",captions:"Subt\xEDtulos",chapters:"Cap\xEDtulos",quality:"Calidad",captionStyling:"Estilo de subt\xEDtulos",transcript:"Alternar transcripci\xF3n",audioDescription:"Audiodescripci\xF3n",signLanguage:"Video en lengua de se\xF1as",settings:"Configuraci\xF3n",speed:"Velocidad de reproducci\xF3n",pip:"Imagen en imagen",currentTime:"Tiempo actual",duration:"Duraci\xF3n",progress:"Progreso",seekForward:"Avanzar {seconds} segundos",seekBackward:"Retroceder {seconds} segundos",volumeUp:"Subir volumen",volumeDown:"Bajar volumen",loading:"Cargando...",loadingChapters:"Cargando cap\xEDtulos...",error:"Error al cargar",buffering:"Almacenando en b\xFAfer...",signLanguageVideo:"Video en Lengua de Se\xF1as",noChapters:"No hay cap\xEDtulos disponibles",noCaptions:"No hay subt\xEDtulos disponibles",auto:"Autom\xE1tico",autoQuality:"Autom\xE1tico (selecci\xF3n de calidad no disponible)",noQuality:"Selecci\xF3n de calidad no disponible",signLanguageDragResize:"Video en Lengua de Se\xF1as - Presione D para arrastrar con el teclado, R para cambiar el tama\xF1o",signLanguageDragActive:"Video en Lengua de Se\xF1as - Modo de arrastre activo. Use las teclas de flecha para mover, Escape para salir.",signLanguageResizeActive:"Video en Lengua de Se\xF1as - Modo de cambio de tama\xF1o activo. Use las teclas de flecha izquierda/derecha para cambiar el tama\xF1o, Escape para salir.",resizeHandle:"Cambiar tama\xF1o esquina {direction}"},captions:{off:"Desactivado",select:"Seleccionar subt\xEDtulos",fontSize:"Tama\xF1o de fuente",fontFamily:"Familia de fuente",color:"Color de texto",backgroundColor:"Color de fondo",opacity:"Opacidad"},fontSizes:{small:"Peque\xF1o",normal:"Normal",large:"Grande",xlarge:"Muy grande"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Color de texto",background:"Fondo",font:"Fuente",fontSize:"Tama\xF1o de fuente",opacity:"Opacidad"},audioDescription:{enable:"Activar audiodescripci\xF3n",disable:"Desactivar audiodescripci\xF3n"},signLanguage:{show:"Mostrar video en lengua de se\xF1as",hide:"Ocultar video en lengua de se\xF1as"},transcript:{title:"Transcripci\xF3n",close:"Cerrar transcripci\xF3n",loading:"Cargando transcripci\xF3n...",noTranscript:"No hay transcripci\xF3n disponible para este video.",settings:"Configuraci\xF3n de transcripci\xF3n. Presione Enter para abrir el men\xFA o D para activar el modo de arrastre",keyboardDragMode:"Alternar modo de arrastre con teclado usando teclas de flecha. Atajo: tecla D",keyboardDragActive:"\u2328\uFE0F Modo de Arrastre con Teclado Activo (Teclas de flecha para mover, May\xFAs+Flechas para pasos grandes, D o ESC para salir)",dragResizePrompt:"Pulsa D para mover o R para cambiar el tama\xF1o. Home restablece la posici\xF3n; Esc cierra.",dragModeEnabled:"Modo de arrastre con teclado activado. Usa flechas para mover, May\xFAs+Flechas para pasos grandes. Pulsa D o Esc para salir.",dragModeDisabled:"Modo de arrastre con teclado desactivado.",resizeWindow:"Cambiar tama\xF1o de ventana",disableResizeWindow:"Desactivar modo de cambio de tama\xF1o",resizeModeHint:"Controladores habilitados. Arrastra bordes o esquinas para ajustar. Pulsa Esc o R para salir.",resizeModeEnabled:"Modo de cambio de tama\xF1o activado. Arrastra bordes o esquinas. Pulsa Esc o R para salir.",resizeModeDisabled:"Modo de cambio de tama\xF1o desactivado.",positionReset:"Posici\xF3n de la transcripci\xF3n restablecida.",styleTranscript:"Abrir configuraci\xF3n de estilo de transcripci\xF3n",closeMenu:"Cerrar men\xFA",styleTitle:"Estilo de Transcripci\xF3n",autoscroll:"Desplazamiento autom\xE1tico",settingsMenu:"Men\xFA de configuraci\xF3n"},settings:{title:"Configuraci\xF3n",quality:"Calidad",speed:"Velocidad",captions:"Subt\xEDtulos",language:"Idioma",reset:"Restablecer",close:"Cerrar"},speeds:{normal:"Normal"},time:{display:"Visualizaci\xF3n de tiempo",durationPrefix:"Duraci\xF3n: ",hour:"{count} hora",hours:"{count} horas",minute:"{count} minuto",minutes:"{count} minutos",second:"{count} segundo",seconds:"{count} segundos"}},fr:{player:{label:"Lecteur vid\xE9o",play:"Lecture",pause:"Pause",stop:"Arr\xEAt",restart:"Red\xE9marrer du d\xE9but",rewind:"Reculer",forward:"Avancer",rewindSeconds:"Reculer de {seconds} secondes",forwardSeconds:"Avancer de {seconds} secondes",previous:"Piste pr\xE9c\xE9dente",next:"Piste suivante",volume:"Volume",mute:"Muet",unmute:"Activer le son",fullscreen:"Plein \xE9cran",exitFullscreen:"Quitter le plein \xE9cran",captions:"Sous-titres",chapters:"Chapitres",quality:"Qualit\xE9",captionStyling:"Style des sous-titres",transcript:"Activer/d\xE9sactiver la transcription",audioDescription:"Audiodescription",signLanguage:"Vid\xE9o en langue des signes",settings:"Param\xE8tres",speed:"Vitesse de lecture",pip:"Image dans l'image",currentTime:"Temps actuel",duration:"Dur\xE9e",progress:"Progression",seekForward:"Avancer de {seconds} secondes",seekBackward:"Reculer de {seconds} secondes",volumeUp:"Augmenter le volume",volumeDown:"Diminuer le volume",loading:"Chargement...",loadingChapters:"Chargement des chapitres...",error:"Erreur de chargement",buffering:"Mise en m\xE9moire tampon...",signLanguageVideo:"Vid\xE9o en Langue des Signes",noChapters:"Aucun chapitre disponible",noCaptions:"Aucun sous-titre disponible",auto:"Automatique",autoQuality:"Automatique (s\xE9lection de qualit\xE9 non disponible)",noQuality:"S\xE9lection de qualit\xE9 non disponible",signLanguageDragResize:"Vid\xE9o en Langue des Signes - Appuyez sur D pour d\xE9placer avec le clavier, R pour redimensionner",signLanguageDragActive:"Vid\xE9o en Langue des Signes - Mode glissement actif. Utilisez les touches fl\xE9ch\xE9es pour d\xE9placer, \xC9chap pour quitter.",signLanguageResizeActive:"Vid\xE9o en Langue des Signes - Mode redimensionnement actif. Utilisez les touches fl\xE9ch\xE9es gauche/droite pour redimensionner, \xC9chap pour quitter.",resizeHandle:"Redimensionner coin {direction}"},captions:{off:"D\xE9sactiv\xE9",select:"S\xE9lectionner les sous-titres",fontSize:"Taille de police",fontFamily:"Police",color:"Couleur du texte",backgroundColor:"Couleur de fond",opacity:"Opacit\xE9"},fontSizes:{small:"Petit",normal:"Normal",large:"Grand",xlarge:"Tr\xE8s grand"},fontFamilies:{sansSerif:"Sans-serif",serif:"Serif",monospace:"Monospace"},styleLabels:{textColor:"Couleur du texte",background:"Arri\xE8re-plan",font:"Police",fontSize:"Taille de police",opacity:"Opacit\xE9"},audioDescription:{enable:"Activer l'audiodescription",disable:"D\xE9sactiver l'audiodescription"},signLanguage:{show:"Afficher la vid\xE9o en langue des signes",hide:"Masquer la vid\xE9o en langue des signes"},transcript:{title:"Transcription",close:"Fermer la transcription",loading:"Chargement de la transcription...",noTranscript:"Aucune transcription disponible pour cette vid\xE9o.",settings:"Param\xE8tres de transcription. Appuyez sur Entr\xE9e pour ouvrir le menu ou D pour activer le mode glissement",keyboardDragMode:"Basculer le mode glissement avec les touches fl\xE9ch\xE9es. Raccourci: touche D",keyboardDragActive:"\u2328\uFE0F Mode Glissement Clavier Actif (Touches fl\xE9ch\xE9es pour d\xE9placer, Maj+Fl\xE9ch\xE9es pour grands pas, D ou \xC9chap pour quitter)",dragResizePrompt:"Appuyez sur D pour d\xE9placer ou R pour redimensionner. Home r\xE9initialise la position, \xC9chap ferme.",dragModeEnabled:"Mode glissement clavier activ\xE9. Utilisez les fl\xE8ches pour d\xE9placer, Maj+Fl\xE8ches pour de grands pas. Appuyez sur D ou \xC9chap pour quitter.",dragModeDisabled:"Mode glissement clavier d\xE9sactiv\xE9.",resizeWindow:"Redimensionner la fen\xEAtre",disableResizeWindow:"D\xE9sactiver le mode de redimensionnement",resizeModeHint:"Poign\xE9es activ\xE9es. Faites glisser les bords ou les coins pour ajuster. Appuyez sur \xC9chap ou R pour quitter.",resizeModeEnabled:"Mode redimensionnement activ\xE9. Faites glisser les bords ou coins. Appuyez sur \xC9chap ou R pour quitter.",resizeModeDisabled:"Mode redimensionnement d\xE9sactiv\xE9.",positionReset:"Position de la transcription r\xE9initialis\xE9e.",styleTranscript:"Ouvrir les param\xE8tres de style de transcription",closeMenu:"Fermer le menu",styleTitle:"Style de Transcription",autoscroll:"D\xE9filement automatique",settingsMenu:"Menu des param\xE8tres"},settings:{title:"Param\xE8tres",quality:"Qualit\xE9",speed:"Vitesse",captions:"Sous-titres",language:"Langue",reset:"R\xE9initialiser",close:"Fermer"},speeds:{normal:"Normal"},time:{display:"Affichage du temps",durationPrefix:"Dur\xE9e : ",hour:"{count} heure",hours:"{count} heures",minute:"{count} minute",minutes:"{count} minutes",second:"{count} seconde",seconds:"{count} secondes"}},ja:{player:{label:"\u30D3\u30C7\u30AA\u30D7\u30EC\u30FC\u30E4\u30FC",play:"\u518D\u751F",pause:"\u4E00\u6642\u505C\u6B62",stop:"\u505C\u6B62",restart:"\u6700\u521D\u304B\u3089\u518D\u751F",rewind:"\u5DFB\u304D\u623B\u3057",forward:"\u65E9\u9001\u308A",rewindSeconds:"{seconds}\u79D2\u623B\u3059",forwardSeconds:"{seconds}\u79D2\u9032\u3081\u308B",previous:"\u524D\u306E\u30C8\u30E9\u30C3\u30AF",next:"\u6B21\u306E\u30C8\u30E9\u30C3\u30AF",volume:"\u97F3\u91CF",mute:"\u30DF\u30E5\u30FC\u30C8",unmute:"\u30DF\u30E5\u30FC\u30C8\u89E3\u9664",fullscreen:"\u5168\u753B\u9762\u8868\u793A",exitFullscreen:"\u5168\u753B\u9762\u8868\u793A\u3092\u7D42\u4E86",captions:"\u5B57\u5E55",chapters:"\u30C1\u30E3\u30D7\u30BF\u30FC",quality:"\u753B\u8CEA",captionStyling:"\u5B57\u5E55\u30B9\u30BF\u30A4\u30EB",transcript:"\u6587\u5B57\u8D77\u3053\u3057\u5207\u308A\u66FF\u3048",audioDescription:"\u97F3\u58F0\u89E3\u8AAC",signLanguage:"\u624B\u8A71\u52D5\u753B",settings:"\u8A2D\u5B9A",speed:"\u518D\u751F\u901F\u5EA6",pip:"\u30D4\u30AF\u30C1\u30E3\u30FC\u30A4\u30F3\u30D4\u30AF\u30C1\u30E3\u30FC",currentTime:"\u73FE\u5728\u306E\u6642\u9593",duration:"\u518D\u751F\u6642\u9593",progress:"\u9032\u884C\u72B6\u6CC1",seekForward:"{seconds}\u79D2\u9032\u3081\u308B",seekBackward:"{seconds}\u79D2\u623B\u3059",volumeUp:"\u97F3\u91CF\u3092\u4E0A\u3052\u308B",volumeDown:"\u97F3\u91CF\u3092\u4E0B\u3052\u308B",loading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",loadingChapters:"\u30C1\u30E3\u30D7\u30BF\u30FC\u8AAD\u307F\u8FBC\u307F\u4E2D...",error:"\u8AAD\u307F\u8FBC\u307F\u30A8\u30E9\u30FC",buffering:"\u30D0\u30C3\u30D5\u30A1\u30EA\u30F3\u30B0\u4E2D...",signLanguageVideo:"\u624B\u8A71\u52D5\u753B",noChapters:"\u30C1\u30E3\u30D7\u30BF\u30FC\u304C\u3042\u308A\u307E\u305B\u3093",noCaptions:"\u5B57\u5E55\u304C\u3042\u308A\u307E\u305B\u3093",auto:"\u81EA\u52D5",autoQuality:"\u81EA\u52D5\uFF08\u753B\u8CEA\u9078\u629E\u4E0D\u53EF\uFF09",noQuality:"\u753B\u8CEA\u9078\u629E\u4E0D\u53EF",signLanguageDragResize:"\u624B\u8A71\u52D5\u753B - \u30AD\u30FC\u30DC\u30FC\u30C9\u3067\u30C9\u30E9\u30C3\u30B0\u3059\u308B\u306B\u306FD\u30AD\u30FC\u3092\u3001\u30B5\u30A4\u30BA\u5909\u66F4\u3059\u308B\u306B\u306FR\u30AD\u30FC\u3092\u62BC\u3057\u3066\u304F\u3060\u3055\u3044",signLanguageDragActive:"\u624B\u8A71\u52D5\u753B - \u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u304C\u6709\u52B9\u3067\u3059\u3002\u77E2\u5370\u30AD\u30FC\u3067\u79FB\u52D5\u3001Escape\u3067\u7D42\u4E86\u3057\u307E\u3059\u3002",signLanguageResizeActive:"\u624B\u8A71\u52D5\u753B - \u30B5\u30A4\u30BA\u5909\u66F4\u30E2\u30FC\u30C9\u304C\u6709\u52B9\u3067\u3059\u3002\u5DE6\u53F3\u306E\u77E2\u5370\u30AD\u30FC\u3067\u30B5\u30A4\u30BA\u5909\u66F4\u3001Escape\u3067\u7D42\u4E86\u3057\u307E\u3059\u3002",resizeHandle:"{direction}\u30B3\u30FC\u30CA\u30FC\u306E\u30B5\u30A4\u30BA\u5909\u66F4"},captions:{off:"\u30AA\u30D5",select:"\u5B57\u5E55\u3092\u9078\u629E",fontSize:"\u30D5\u30A9\u30F3\u30C8\u30B5\u30A4\u30BA",fontFamily:"\u30D5\u30A9\u30F3\u30C8",color:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",backgroundColor:"\u80CC\u666F\u8272",opacity:"\u4E0D\u900F\u660E\u5EA6"},fontSizes:{small:"\u5C0F",normal:"\u6A19\u6E96",large:"\u5927",xlarge:"\u7279\u5927"},fontFamilies:{sansSerif:"\u30B5\u30F3\u30BB\u30EA\u30D5",serif:"\u30BB\u30EA\u30D5",monospace:"\u7B49\u5E45"},styleLabels:{textColor:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",background:"\u80CC\u666F",font:"\u30D5\u30A9\u30F3\u30C8",fontSize:"\u30D5\u30A9\u30F3\u30C8\u30B5\u30A4\u30BA",opacity:"\u4E0D\u900F\u660E\u5EA6"},audioDescription:{enable:"\u97F3\u58F0\u89E3\u8AAC\u3092\u6709\u52B9\u306B\u3059\u308B",disable:"\u97F3\u58F0\u89E3\u8AAC\u3092\u7121\u52B9\u306B\u3059\u308B"},signLanguage:{show:"\u624B\u8A71\u52D5\u753B\u3092\u8868\u793A",hide:"\u624B\u8A71\u52D5\u753B\u3092\u975E\u8868\u793A"},transcript:{title:"\u6587\u5B57\u8D77\u3053\u3057",close:"\u6587\u5B57\u8D77\u3053\u3057\u3092\u9589\u3058\u308B",loading:"\u6587\u5B57\u8D77\u3053\u3057\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D...",noTranscript:"\u3053\u306E\u30D3\u30C7\u30AA\u306E\u6587\u5B57\u8D77\u3053\u3057\u306F\u3042\u308A\u307E\u305B\u3093\u3002",settings:"\u6587\u5B57\u8D77\u3053\u3057\u8A2D\u5B9A\u3002Enter\u30AD\u30FC\u3067\u30E1\u30CB\u30E5\u30FC\u3092\u958B\u304F\u3001\u307E\u305F\u306FD\u30AD\u30FC\u3067\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u3092\u6709\u52B9\u306B\u3059\u308B",keyboardDragMode:"\u77E2\u5370\u30AD\u30FC\u3067\u30AD\u30FC\u30DC\u30FC\u30C9\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u3092\u5207\u308A\u66FF\u3048\u3002\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8\uFF1AD\u30AD\u30FC",keyboardDragActive:"\u2328\uFE0F \u30AD\u30FC\u30DC\u30FC\u30C9\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u6709\u52B9\uFF08\u77E2\u5370\u30AD\u30FC\u3067\u79FB\u52D5\u3001Shift+\u77E2\u5370\u30AD\u30FC\u3067\u5927\u304D\u304F\u79FB\u52D5\u3001D\u307E\u305F\u306FESC\u3067\u7D42\u4E86\uFF09",dragResizePrompt:"D\u30AD\u30FC\u3067\u79FB\u52D5\u3001R\u30AD\u30FC\u3067\u30B5\u30A4\u30BA\u5909\u66F4\u3002Home\u3067\u4F4D\u7F6E\u3092\u30EA\u30BB\u30C3\u30C8\u3001Esc\u3067\u9589\u3058\u307E\u3059\u3002",dragModeEnabled:"\u30AD\u30FC\u30DC\u30FC\u30C9\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u3092\u6709\u52B9\u306B\u3057\u307E\u3057\u305F\u3002\u77E2\u5370\u30AD\u30FC\u3067\u79FB\u52D5\u3001Shift+\u77E2\u5370\u30AD\u30FC\u3067\u5927\u304D\u304F\u79FB\u52D5\u3067\u304D\u307E\u3059\u3002\u7D42\u4E86\u3059\u308B\u306B\u306F D \u307E\u305F\u306F Esc \u3092\u62BC\u3057\u307E\u3059\u3002",dragModeDisabled:"\u30AD\u30FC\u30DC\u30FC\u30C9\u30C9\u30E9\u30C3\u30B0\u30E2\u30FC\u30C9\u3092\u7121\u52B9\u306B\u3057\u307E\u3057\u305F\u3002",resizeWindow:"\u30A6\u30A3\u30F3\u30C9\u30A6\u306E\u30B5\u30A4\u30BA\u5909\u66F4",disableResizeWindow:"\u30B5\u30A4\u30BA\u5909\u66F4\u30E2\u30FC\u30C9\u3092\u7121\u52B9\u306B\u3059\u308B",resizeModeHint:"\u30EA\u30B5\u30A4\u30BA\u30CF\u30F3\u30C9\u30EB\u304C\u6709\u52B9\u306B\u306A\u308A\u307E\u3057\u305F\u3002\u8FBA\u3084\u89D2\u3092\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u8ABF\u6574\u3057\u307E\u3059\u3002Esc \u307E\u305F\u306F R \u3067\u7D42\u4E86\u3057\u307E\u3059\u3002",resizeModeEnabled:"\u30B5\u30A4\u30BA\u5909\u66F4\u30E2\u30FC\u30C9\u3092\u6709\u52B9\u306B\u3057\u307E\u3057\u305F\u3002\u8FBA\u3084\u89D2\u3092\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u8ABF\u6574\u3057\u307E\u3059\u3002Esc \u307E\u305F\u306F R \u3067\u7D42\u4E86\u3057\u307E\u3059\u3002",resizeModeDisabled:"\u30B5\u30A4\u30BA\u5909\u66F4\u30E2\u30FC\u30C9\u3092\u7121\u52B9\u306B\u3057\u307E\u3057\u305F\u3002",positionReset:"\u6587\u5B57\u8D77\u3053\u3057\u306E\u4F4D\u7F6E\u3092\u30EA\u30BB\u30C3\u30C8\u3057\u307E\u3057\u305F\u3002",styleTranscript:"\u6587\u5B57\u8D77\u3053\u3057\u30B9\u30BF\u30A4\u30EB\u8A2D\u5B9A\u3092\u958B\u304F",closeMenu:"\u30E1\u30CB\u30E5\u30FC\u3092\u9589\u3058\u308B",styleTitle:"\u6587\u5B57\u8D77\u3053\u3057\u30B9\u30BF\u30A4\u30EB",autoscroll:"\u81EA\u52D5\u30B9\u30AF\u30ED\u30FC\u30EB",settingsMenu:"\u8A2D\u5B9A\u30E1\u30CB\u30E5\u30FC"},settings:{title:"\u8A2D\u5B9A",quality:"\u753B\u8CEA",speed:"\u901F\u5EA6",captions:"\u5B57\u5E55",language:"\u8A00\u8A9E",reset:"\u30EA\u30BB\u30C3\u30C8",close:"\u9589\u3058\u308B"},speeds:{normal:"\u901A\u5E38"},time:{display:"\u6642\u9593\u8868\u793A",durationPrefix:"\u518D\u751F\u6642\u9593: ",hour:"{count}\u6642\u9593",hours:"{count}\u6642\u9593",minute:"{count}\u5206",minutes:"{count}\u5206",second:"{count}\u79D2",seconds:"{count}\u79D2"}}};var U=class{constructor(){this.currentLanguage="en",this.translations=Y}setLanguage(e){this.translations[e]?this.currentLanguage=e:(console.warn(`Language "${e}" not found, falling back to English`),this.currentLanguage="en")}getLanguage(){return this.currentLanguage}t(e,t={}){let i=e.split("."),s=this.translations[this.currentLanguage];for(let a of i)if(s&&typeof s=="object"&&a in s)s=s[a];else{s=this.translations.en;for(let r of i)if(s&&typeof s=="object"&&r in s)s=s[r];else return e;break}return typeof s=="string"&&Object.entries(t).forEach(([a,r])=>{s=s.replace(new RegExp(`{${a}}`,"g"),r)}),s}addTranslation(e,t){this.translations[e]||(this.translations[e]={}),Object.assign(this.translations[e],t)}},d=new U;var L={formatTime(h,e=!1){if(!isFinite(h)||h<0)return e?"00:00:00":"00:00";let t=Math.floor(h/3600),i=Math.floor(h%3600/60),s=Math.floor(h%60),a=r=>String(r).padStart(2,"0");return t>0||e?`${a(t)}:${a(i)}:${a(s)}`:`${a(i)}:${a(s)}`},parseTime(h){let e=h.split(":").map(t=>parseInt(t,10));return e.length===3?e[0]*3600+e[1]*60+e[2]:e.length===2?e[0]*60+e[1]:e.length===1?e[0]:0},formatDuration(h){if(!isFinite(h)||h<0)return d.t("time.seconds",{count:0});let e=Math.floor(h/3600),t=Math.floor(h%3600/60),i=Math.floor(h%60),s=[];if(e>0){let a=e===1?"time.hour":"time.hours";s.push(d.t(a,{count:e}))}if(t>0){let a=t===1?"time.minute":"time.minutes";s.push(d.t(a,{count:t}))}if(i>0||s.length===0){let a=i===1?"time.second":"time.seconds";s.push(d.t(a,{count:i}))}return s.join(", ")},formatPercentage(h,e){return e===0?0:Math.round(h/e*100)}};var re={play:'<path d="M8 5v14l11-7z"/>',pause:'<path d="M6 4h4v16H6V4zm8 0h4v16h-4V4z"/>',stop:'<rect x="6" y="6" width="12" height="12"/>',rewind:'<path d="M11 18V6l-8.5 6 8.5 6zm.5-6l8.5 6V6l-8.5 6z"/>',forward:'<path d="M4 18l8.5-6L4 6v12zm9-12v12l8.5-6L13 6z"/>',skipPrevious:'<path d="M6 6h2v12H6V6zm3 6l8.5 6V6L9 12z"/>',skipNext:'<path d="M16 6h2v12h-2V6zM6 6l8.5 6L6 18V6z"/>',restart:'<path d="M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z"/>',volumeHigh:'<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"/>',volumeMedium:'<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.02z"/>',volumeLow:'<path d="M7 9v6h4l5 5V4l-5 5H7z"/>',volumeMuted:'<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"/>',fullscreen:'<path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/>',fullscreenExit:'<path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/>',settings:'<path d="M19.14 12.94c.04-.3.06-.61.06-.94 0-.32-.02-.64-.07-.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-.94L14.4 2.81c-.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-.05.3-.09.63-.09.94s.02.64.07.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"/>',captions:'<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"/>',captionsOff:'<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"/><path d="M0 0h24v24H0z" fill="none"/>',pip:'<path d="M19 7h-8v6h8V7zm2-4H3c-1.1 0-2 .9-2 2v14c0 1.1.9 1.98 2 1.98h18c1.1 0 2-.88 2-1.98V5c0-1.1-.9-2-2-2zm0 16.01H3V4.98h18v14.03z"/>',speed:'<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.44z"/><path d="M10.59 15.41a2 2 0 0 0 2.83 0l5.66-8.49-8.49 5.66a2 2 0 0 0 0 2.83z"/>',close:'<path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/>',check:'<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>',arrowUp:'<path d="M7 14l5-5 5 5z"/>',arrowDown:'<path d="M7 10l5 5 5-5z"/>',arrowLeft:'<path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>',arrowRight:'<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>',loading:'<path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"/>',error:'<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"/>',download:'<path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"/>',link:'<path d="M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"/>',playlist:'<path d="M15 6H3v2h12V6zm0 4H3v2h12v-2zM3 16h8v-2H3v2zM17 6v8.18c-.31-.11-.65-.18-1-.18-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3V8h3V6h-5z"/>',language:'<path d="M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zm6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56zM12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96zM4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2 0 .68.06 1.34.14 2H4.26zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56zm2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8zM12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96zM14.34 14H9.66c-.09-.66-.16-1.32-.16-2 0-.68.07-1.35.16-2h4.68c.09.65.16 1.32.16 2 0 .68-.07 1.34-.16 2zm.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56zM16.36 14c.08-.66.14-1.32.14-2 0-.68-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2h-3.38z"/>',hd:'<path d="M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.11 0 2-.9 2-2V5c0-1.1-.89-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm7-1c0 .55-.45 1-1 1h-.75v1.5h-1.5V15H14c-.55 0-1-.45-1-1v-4c0-.55.45-1 1-1h3c.55 0 1 .45 1 1v4zm-3.5-.5h2v-3h-2v3z"/>',transcript:'<path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z"/>',audioDescription:'<rect x="2" y="5" width="20" height="14" rx="2" fill="#ffffff" stroke="#ffffff" stroke-width="2"/><text x="12" y="16" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="#1a1a1a">AD</text>',audioDescriptionOn:'<rect x="2" y="5" width="20" height="14" rx="2" fill="none" stroke="currentColor" stroke-width="2"/><text x="12" y="16" font-family="Arial, sans-serif" font-size="10" font-weight="bold" text-anchor="middle" fill="currentColor">AD</text>',signLanguage:'<g transform="scale(1.5)"><path d="M16 11.3c-.1-.9-4.8 1.3-5.4 1.1-2.6-1 5.8-1.3 5.1-2.9s-5.1 1.5-6 1.4C6.5 9.4 16.5 9.1 13.5 8c-1.9-.6-8.8 2.9-6.8.4.7-.6.7-1.9-.7-1.7-9.7 7.2-.7 12.2 8.8 7 0-1.3-3.5.4-4.1.4-2.6 0 5.6-2 5.4-3ZM3.9 7.8c3.2-4.2 3.7 1.2 6 .1s.2-.2.2-.3c.7-2.7 2.5-7.5-1.5-1.3-1.6 0 1.1-4 1-4.6C8.9-1 7.3 4.4 7.2 4.9c-1.6.7-.9-1.4-.7-1.5 3-6-.6-3.1-.9.4-2.5 1.8 0-2.8 0-3.5C2.8-.9 4 9.4 1.1 4.9S.1 4.6 0 5c-.4 2.7 2.6 7.2 3.9 2.8Z"/></g>',signLanguageOn:'<g transform="scale(1.5)"><path d="M16 11.3c-.1-.9-4.8 1.3-5.4 1.1-2.6-1 5.8-1.3 5.1-2.9s-5.1 1.5-6 1.4C6.5 9.4 16.5 9.1 13.5 8c-1.9-.6-8.8 2.9-6.8.4.7-.6.7-1.9-.7-1.7-9.7 7.2-.7 12.2 8.8 7 0-1.3-3.5.4-4.1.4-2.6 0 5.6-2 5.4-3ZM3.9 7.8c3.2-4.2 3.7 1.2 6 .1s.2-.2.2-.3c.7-2.7 2.5-7.5-1.5-1.3-1.6 0 1.1-4 1-4.6C8.9-1 7.3 4.4 7.2 4.9c-1.6.7-.9-1.4-.7-1.5 3-6-.6-3.1-.9.4-2.5 1.8 0-2.8 0-3.5C2.8-.9 4 9.4 1.1 4.9S.1 4.6 0 5c-.4 2.7 2.6 7.2 3.9 2.8Z"/></g>',speaker:'<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.02z"/>',music:'<path d="M12 3v9.28c-.47-.17-.97-.28-1.5-.28C8.01 12 6 14.01 6 16.5S8.01 21 10.5 21c2.31 0 4.2-1.75 4.45-4H15V6h4V3h-7zm-1.5 16c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>',moreVertical:'<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>',moreHorizontal:'<path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"/>',move:'<path d="M10 9h4V6h3l-5-5-5 5h3v3zm-1 1H6V7l-5 5 5 5v-3h3v-4zm14 2l-5-5v3h-3v4h3v3l5-5zm-9 3h-4v3H7l5 5 5-5h-3v-3z"/>',resize:'<path d="M21.71 11.29l-9-9c-.39-.39-1.02-.39-1.41 0l-9 9c-.39.39-.39 1.02 0 1.41l9 9c.39.39 1.02.39 1.41 0l9-9c.39-.38.39-1.01 0-1.41zM14 14.5V12h-4v2.5L7 11l3-3.5V10h4V7.5l3 3.5-3 3.5z"/>'},ne=h=>`<svg viewBox="0 0 24 24" fill="currentColor">${h}</svg>`,j=Object.fromEntries(Object.entries(re).map(([h,e])=>[h,ne(e)]));function oe(h){return j[h]||j.play}function b(h,e=""){let t=document.createElement("span");return t.className=`vidply-icon ${e}`.trim(),t.innerHTML=oe(h),t.setAttribute("aria-hidden","true"),t}function X(){let h=document.createElementNS("http://www.w3.org/2000/svg","svg");h.setAttribute("class","vidply-play-overlay"),h.setAttribute("viewBox","0 0 80 80"),h.setAttribute("width","80"),h.setAttribute("height","80"),h.setAttribute("aria-hidden","true"),h.setAttribute("role","presentation"),h.style.cursor="pointer";let e=document.createElementNS("http://www.w3.org/2000/svg","defs"),t=`vidply-play-shadow-${Math.random().toString(36).substr(2,9)}`,i=document.createElementNS("http://www.w3.org/2000/svg","filter");i.setAttribute("id",t),i.setAttribute("x","-50%"),i.setAttribute("y","-50%"),i.setAttribute("width","200%"),i.setAttribute("height","200%");let s=document.createElementNS("http://www.w3.org/2000/svg","feGaussianBlur");s.setAttribute("in","SourceAlpha"),s.setAttribute("stdDeviation","3");let a=document.createElementNS("http://www.w3.org/2000/svg","feOffset");a.setAttribute("dx","0"),a.setAttribute("dy","2"),a.setAttribute("result","offsetblur");let r=document.createElementNS("http://www.w3.org/2000/svg","feComponentTransfer"),n=document.createElementNS("http://www.w3.org/2000/svg","feFuncA");n.setAttribute("type","linear"),n.setAttribute("slope","0.3"),r.appendChild(n);let o=document.createElementNS("http://www.w3.org/2000/svg","feMerge"),c=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode"),p=document.createElementNS("http://www.w3.org/2000/svg","feMergeNode");p.setAttribute("in","SourceGraphic"),o.appendChild(c),o.appendChild(p),i.appendChild(s),i.appendChild(a),i.appendChild(r),i.appendChild(o),e.appendChild(i),h.appendChild(e);let g=document.createElementNS("http://www.w3.org/2000/svg","circle");g.setAttribute("cx","40"),g.setAttribute("cy","40"),g.setAttribute("r","40"),g.setAttribute("fill","rgba(255, 255, 255, 0.95)"),g.setAttribute("filter",`url(#${t})`),g.setAttribute("class","vidply-play-overlay-bg"),h.appendChild(g);let y=document.createElementNS("http://www.w3.org/2000/svg","polygon");return y.setAttribute("points","32,28 32,52 54,40"),y.setAttribute("fill","#0a406e"),y.setAttribute("class","vidply-play-overlay-icon"),h.appendChild(y),h}var N=class{constructor(e){this.player=e,this.element=null,this.controls={},this.hideTimeout=null,this.isDraggingProgress=!1,this.isDraggingVolume=!1,this.init()}init(){this.createElement(),this.createControls(),this.attachEvents(),this.setupAutoHide()}isMobile(){return window.innerWidth<640}positionMenu(e,t){this.isMobile()||setTimeout(()=>{let s=t.getBoundingClientRect(),a=e.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight,o=s.top,c=n-s.bottom;o<a.height+20&&c>o&&(e.style.bottom="auto",e.style.top="calc(100% + 8px)",e.classList.add("vidply-menu-below"));let p=s.left+s.width/2-a.width/2;p<10?(e.style.right="auto",e.style.left="0",e.style.transform="translateX(0)"):p+a.width>r-10&&(e.style.left="auto",e.style.right="0",e.style.transform="translateX(0)")},0)}attachMenuCloseHandler(e,t,i=!1){this.positionMenu(e,t),setTimeout(()=>{let s=r=>{i&&e.contains(r.target)||!e.contains(r.target)&&!t.contains(r.target)&&(e.remove(),document.removeEventListener("click",s),document.removeEventListener("keydown",a))},a=r=>{r.key==="Escape"&&(e.remove(),document.removeEventListener("click",s),document.removeEventListener("keydown",a),t.focus())};document.addEventListener("click",s),document.addEventListener("keydown",a)},100)}attachMenuKeyboardNavigation(e){let t=Array.from(e.querySelectorAll(`.${this.player.options.classPrefix}-menu-item`));if(t.length===0)return;let i=s=>{let a=t.indexOf(document.activeElement);switch(s.key){case"ArrowDown":s.preventDefault();let r=(a+1)%t.length;t[r].focus();break;case"ArrowUp":s.preventDefault();let n=(a-1+t.length)%t.length;t[n].focus();break;case"Home":s.preventDefault(),t[0].focus();break;case"End":s.preventDefault(),t[t.length-1].focus();break;case"Enter":case" ":s.preventDefault(),document.activeElement&&t.includes(document.activeElement)&&document.activeElement.click();break}};e.addEventListener("keydown",i)}createElement(){this.element=l.createElement("div",{className:`${this.player.options.classPrefix}-controls`,attributes:{role:"region","aria-label":d.t("player.label")+" controls"}})}createControls(){this.player.options.progressBar&&this.createProgressBar();let e=l.createElement("div",{className:`${this.player.options.classPrefix}-controls-buttons`}),t=l.createElement("div",{className:`${this.player.options.classPrefix}-controls-left`});this.player.playlistManager&&t.appendChild(this.createPreviousButton()),this.player.options.playPauseButton&&t.appendChild(this.createPlayPauseButton()),t.appendChild(this.createRestartButton()),this.player.playlistManager&&t.appendChild(this.createNextButton()),this.player.playlistManager||t.appendChild(this.createRewindButton()),this.player.playlistManager||t.appendChild(this.createForwardButton()),this.player.options.volumeControl&&t.appendChild(this.createVolumeControl()),(this.player.options.currentTime||this.player.options.duration)&&t.appendChild(this.createTimeDisplay()),this.rightButtons=l.createElement("div",{className:`${this.player.options.classPrefix}-controls-right`});let i=this.hasChapterTracks(),s=this.hasCaptionTracks(),a=this.hasQualityLevels(),r=this.hasAudioDescription();this.player.options.chaptersButton&&i&&this.rightButtons.appendChild(this.createChaptersButton()),this.player.options.qualityButton&&a&&this.rightButtons.appendChild(this.createQualityButton()),this.player.options.captionStyleButton&&s&&this.rightButtons.appendChild(this.createCaptionStyleButton()),this.player.options.speedButton&&this.rightButtons.appendChild(this.createSpeedButton()),this.player.options.captionsButton&&s&&this.rightButtons.appendChild(this.createCaptionsButton()),this.player.options.transcriptButton&&s&&this.rightButtons.appendChild(this.createTranscriptButton()),this.player.options.audioDescriptionButton&&r&&this.rightButtons.appendChild(this.createAudioDescriptionButton());let n=this.hasSignLanguage();this.player.options.signLanguageButton&&n&&this.rightButtons.appendChild(this.createSignLanguageButton()),this.player.options.pipButton&&"pictureInPictureEnabled"in document&&this.rightButtons.appendChild(this.createPipButton()),this.player.options.fullscreenButton&&this.rightButtons.appendChild(this.createFullscreenButton()),e.appendChild(t),e.appendChild(this.rightButtons),this.element.appendChild(e)}hasChapterTracks(){let e=this.player.element.textTracks;for(let t=0;t<e.length;t++)if(e[t].kind==="chapters")return!0;return!1}hasCaptionTracks(){let e=this.player.element.textTracks;for(let t=0;t<e.length;t++)if(e[t].kind==="captions"||e[t].kind==="subtitles")return!0;return!1}hasQualityLevels(){if(this.player.renderer&&this.player.renderer.getQualities){let e=this.player.renderer.getQualities();return e&&e.length>1}return!1}hasAudioDescription(){return this.player.audioDescriptionSrc&&this.player.audioDescriptionSrc.length>0?!0:Array.from(this.player.element.textTracks||[]).some(t=>t.kind==="descriptions")}hasSignLanguage(){return this.player.signLanguageSrc&&this.player.signLanguageSrc.length>0}createProgressBar(){let e=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-container`,attributes:{role:"slider","aria-label":d.t("player.progress"),"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":"0",tabindex:"0"}});this.controls.buffered=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-buffered`}),this.controls.played=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-played`}),this.controls.progressHandle=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-handle`}),this.controls.progressTooltip=l.createElement("div",{className:`${this.player.options.classPrefix}-progress-tooltip`}),e.appendChild(this.controls.buffered),e.appendChild(this.controls.played),this.controls.played.appendChild(this.controls.progressHandle),e.appendChild(this.controls.progressTooltip),this.controls.progress=e,this.element.appendChild(e),this.setupProgressBarEvents()}setupProgressBarEvents(){let e=this.controls.progress,t=i=>{let s=e.getBoundingClientRect(),a=Math.max(0,Math.min(1,(i-s.left)/s.width)),r=a*this.player.state.duration;return{percent:a,time:r}};e.addEventListener("mousedown",i=>{this.isDraggingProgress=!0;let{time:s}=t(i.clientX);this.player.seek(s)}),document.addEventListener("mousemove",i=>{if(this.isDraggingProgress){let{time:s}=t(i.clientX);this.player.seek(s)}}),document.addEventListener("mouseup",()=>{this.isDraggingProgress=!1}),e.addEventListener("mousemove",i=>{if(!this.isDraggingProgress){let{time:s}=t(i.clientX);this.controls.progressTooltip.textContent=L.formatTime(s),this.controls.progressTooltip.style.left=`${i.clientX-e.getBoundingClientRect().left}px`,this.controls.progressTooltip.style.display="block"}}),e.addEventListener("mouseleave",()=>{this.controls.progressTooltip.style.display="none"}),e.addEventListener("keydown",i=>{i.key==="ArrowLeft"?(i.preventDefault(),this.player.seekBackward(5)):i.key==="ArrowRight"&&(i.preventDefault(),this.player.seekForward(5))}),e.addEventListener("touchstart",i=>{this.isDraggingProgress=!0;let s=i.touches[0],{time:a}=t(s.clientX);this.player.seek(a)}),e.addEventListener("touchmove",i=>{if(this.isDraggingProgress){i.preventDefault();let s=i.touches[0],{time:a}=t(s.clientX);this.player.seek(a)}}),e.addEventListener("touchend",()=>{this.isDraggingProgress=!1})}createPlayPauseButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-play-pause`,attributes:{type:"button","aria-label":d.t("player.play")}});return e.appendChild(b("play")),e.addEventListener("click",()=>{this.player.toggle()}),this.controls.playPause=e,e}createRestartButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-restart`,attributes:{type:"button","aria-label":d.t("player.restart")}});return e.appendChild(b("restart")),e.addEventListener("click",()=>{this.player.seek(0),this.player.play()}),e}createPreviousButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-previous`,attributes:{type:"button","aria-label":d.t("player.previous")}});e.appendChild(b("skipPrevious")),e.addEventListener("click",()=>{this.player.playlistManager&&this.player.playlistManager.previous()});let t=()=>{this.player.playlistManager&&(e.disabled=!this.player.playlistManager.hasPrevious()&&!this.player.playlistManager.options.loop)};return this.player.on("playlisttrackchange",t),t(),this.controls.previous=e,e}createNextButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-next`,attributes:{type:"button","aria-label":d.t("player.next")}});e.appendChild(b("skipNext")),e.addEventListener("click",()=>{this.player.playlistManager&&this.player.playlistManager.next()});let t=()=>{this.player.playlistManager&&(e.disabled=!this.player.playlistManager.hasNext()&&!this.player.playlistManager.options.loop)};return this.player.on("playlisttrackchange",t),t(),this.controls.next=e,e}createRewindButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-rewind`,attributes:{type:"button","aria-label":d.t("player.rewindSeconds",{seconds:15})}});return e.appendChild(b("rewind")),e.addEventListener("click",()=>{this.player.seekBackward(15)}),e}createForwardButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-forward`,attributes:{type:"button","aria-label":d.t("player.forwardSeconds",{seconds:15})}});return e.appendChild(b("forward")),e.addEventListener("click",()=>{this.player.seekForward(15)}),e}createVolumeControl(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-mute`,attributes:{type:"button","aria-label":d.t("player.volume"),"aria-haspopup":"true"}});return e.appendChild(b("volumeHigh")),e.addEventListener("contextmenu",t=>{t.preventDefault(),this.player.toggleMute()}),e.addEventListener("click",()=>{this.showVolumeSlider(e)}),this.controls.mute=e,e}showVolumeSlider(e){let t=document.querySelector(`.${this.player.options.classPrefix}-volume-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-menu ${this.player.options.classPrefix}-menu`}),s=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-slider`,attributes:{role:"slider","aria-label":d.t("player.volume"),"aria-valuemin":"0","aria-valuemax":"100","aria-valuenow":String(Math.round(this.player.state.volume*100)),tabindex:"0"}}),a=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-track`}),r=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-fill`}),n=l.createElement("div",{className:`${this.player.options.classPrefix}-volume-handle`});a.appendChild(r),r.appendChild(n),s.appendChild(a),i.appendChild(s);let o=c=>{let p=a.getBoundingClientRect(),g=Math.max(0,Math.min(1,1-(c-p.top)/p.height));this.player.setVolume(g)};s.addEventListener("mousedown",c=>{c.stopPropagation(),this.isDraggingVolume=!0,o(c.clientY)}),document.addEventListener("mousemove",c=>{this.isDraggingVolume&&o(c.clientY)}),document.addEventListener("mouseup",()=>{this.isDraggingVolume=!1}),s.addEventListener("keydown",c=>{c.key==="ArrowUp"?(c.preventDefault(),this.player.setVolume(Math.min(1,this.player.state.volume+.1))):c.key==="ArrowDown"&&(c.preventDefault(),this.player.setVolume(Math.max(0,this.player.state.volume-.1)))}),i.addEventListener("click",c=>{c.stopPropagation()}),e.appendChild(i),this.controls.volumeSlider=s,this.controls.volumeFill=r,this.attachMenuCloseHandler(i,e,!0)}createTimeDisplay(){let e=l.createElement("div",{className:`${this.player.options.classPrefix}-time`,attributes:{role:"group","aria-label":d.t("time.display")}});this.controls.currentTimeDisplay=l.createElement("span",{className:`${this.player.options.classPrefix}-current-time`});let t=l.createElement("span",{textContent:"00:00",attributes:{"aria-hidden":"true"}}),i=l.createElement("span",{className:"vidply-sr-only",textContent:d.t("time.seconds",{count:0})});this.controls.currentTimeDisplay.appendChild(t),this.controls.currentTimeDisplay.appendChild(i),this.controls.currentTimeVisual=t,this.controls.currentTimeAccessible=i;let s=l.createElement("span",{textContent:" / ",attributes:{"aria-hidden":"true"}});this.controls.durationDisplay=l.createElement("span",{className:`${this.player.options.classPrefix}-duration`});let a=l.createElement("span",{textContent:"00:00",attributes:{"aria-hidden":"true"}}),r=l.createElement("span",{className:"vidply-sr-only",textContent:d.t("time.durationPrefix")+d.t("time.seconds",{count:0})});return this.controls.durationDisplay.appendChild(a),this.controls.durationDisplay.appendChild(r),this.controls.durationVisual=a,this.controls.durationAccessible=r,e.appendChild(this.controls.currentTimeDisplay),e.appendChild(s),e.appendChild(this.controls.durationDisplay),e}createChaptersButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-chapters`,attributes:{type:"button","aria-label":d.t("player.chapters"),"aria-haspopup":"menu"}});return e.appendChild(b("playlist")),e.addEventListener("click",()=>{this.showChaptersMenu(e)}),this.controls.chapters=e,e}showChaptersMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-chapters-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-chapters-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu","aria-label":d.t("player.chapters")}}),s=Array.from(this.player.element.textTracks).filter(a=>a.kind==="chapters");if(s.length===0){let a=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("player.noChapters"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(a)}else{let a=s[0];if(a.mode==="disabled"&&(a.mode="hidden"),!a.cues||a.cues.length===0){let r=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("player.loadingChapters"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(r);let n=()=>{i.remove(),this.showChaptersMenu(e)};a.addEventListener("load",n,{once:!0}),setTimeout(()=>{a.cues&&a.cues.length>0&&document.contains(i)&&(i.remove(),this.showChaptersMenu(e))},500)}else{let r=a.cues;for(let n=0;n<r.length;n++){let o=r[n],c=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,attributes:{type:"button",role:"menuitem",tabindex:"-1"}}),p=l.createElement("span",{className:`${this.player.options.classPrefix}-chapter-time`,textContent:L.formatTime(o.startTime)}),g=l.createElement("span",{className:`${this.player.options.classPrefix}-chapter-title`,textContent:o.text});c.appendChild(p),c.appendChild(document.createTextNode(" ")),c.appendChild(g),c.addEventListener("click",()=>{this.player.seek(o.startTime),i.remove()}),i.appendChild(c)}this.attachMenuKeyboardNavigation(i),setTimeout(()=>{let n=i.querySelector(`.${this.player.options.classPrefix}-menu-item`);n&&n.focus()},0)}}e.appendChild(i),this.attachMenuCloseHandler(i,e)}createQualityButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-quality`,attributes:{type:"button","aria-label":d.t("player.quality"),"aria-haspopup":"menu"}});e.appendChild(b("hd"));let t=l.createElement("span",{className:`${this.player.options.classPrefix}-quality-text`,textContent:""});return e.appendChild(t),e.addEventListener("click",()=>{this.showQualityMenu(e)}),this.controls.quality=e,this.controls.qualityText=t,setTimeout(()=>this.updateQualityIndicator(),500),e}showQualityMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-quality-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-quality-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu","aria-label":d.t("player.quality")}});if(this.player.renderer&&this.player.renderer.getQualities){let s=this.player.renderer.getQualities(),a=this.player.renderer.getCurrentQuality?this.player.renderer.getCurrentQuality():-1,r=this.player.renderer.hls!==void 0;if(s.length===0){let n=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("player.autoQuality"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(n)}else{let n=null;if(r){let o=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("player.auto"),attributes:{type:"button",role:"menuitem",tabindex:"-1"}});this.player.renderer.hls&&this.player.renderer.hls.currentLevel===-1&&(o.classList.add(`${this.player.options.classPrefix}-menu-item-active`),o.appendChild(b("check")),n=o),o.addEventListener("click",()=>{this.player.renderer.switchQuality&&this.player.renderer.switchQuality(-1),i.remove()}),i.appendChild(o)}s.forEach(o=>{let c=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:o.name||`${o.height}p`,attributes:{type:"button",role:"menuitem",tabindex:"-1"}});o.index===a&&(c.classList.add(`${this.player.options.classPrefix}-menu-item-active`),c.appendChild(b("check")),n=c),c.addEventListener("click",()=>{this.player.renderer.switchQuality&&this.player.renderer.switchQuality(o.index),i.remove()}),i.appendChild(c)}),this.attachMenuKeyboardNavigation(i),setTimeout(()=>{let o=n||i.querySelector(`.${this.player.options.classPrefix}-menu-item`);o&&o.focus()},0)}}else{let s=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("player.noQuality"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(s)}e.appendChild(i),this.attachMenuCloseHandler(i,e)}createCaptionStyleButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-caption-style`,attributes:{type:"button","aria-label":d.t("player.captionStyling"),"aria-haspopup":"menu",title:d.t("player.captionStyling")}}),t=l.createElement("span",{textContent:"Aa",style:{fontSize:"14px",fontWeight:"bold"}});return e.appendChild(t),e.addEventListener("click",()=>{this.showCaptionStyleMenu(e)}),this.controls.captionStyle=e,e}showCaptionStyleMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-caption-style-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-caption-style-menu ${this.player.options.classPrefix}-menu ${this.player.options.classPrefix}-settings-menu`,attributes:{role:"menu","aria-label":d.t("player.captionStyling")}});if(i.addEventListener("click",c=>{c.stopPropagation()}),!this.player.captionManager||this.player.captionManager.tracks.length===0){let c=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("player.noCaptions"),style:{opacity:"0.5",cursor:"default",padding:"12px 16px"}});i.appendChild(c),e.appendChild(i),this.attachMenuCloseHandler(i,e,!0);return}let s=this.createStyleControl(d.t("styleLabels.fontSize"),"captionsFontSize",[{label:d.t("fontSizes.small"),value:"87.5%"},{label:d.t("fontSizes.normal"),value:"100%"},{label:d.t("fontSizes.large"),value:"125%"},{label:d.t("fontSizes.xlarge"),value:"150%"}]);i.appendChild(s);let a=this.createStyleControl(d.t("styleLabels.font"),"captionsFontFamily",[{label:d.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:d.t("fontFamilies.serif"),value:"serif"},{label:d.t("fontFamilies.monospace"),value:"monospace"}]);i.appendChild(a);let r=this.createColorControl(d.t("styleLabels.textColor"),"captionsColor");i.appendChild(r);let n=this.createColorControl(d.t("styleLabels.background"),"captionsBackgroundColor");i.appendChild(n);let o=this.createOpacityControl(d.t("styleLabels.opacity"),"captionsOpacity");i.appendChild(o),i.style.minWidth="220px",e.appendChild(i),this.attachMenuCloseHandler(i,e,!0),setTimeout(()=>{let c=i.querySelector("select");c&&c.focus()},0)}createStyleControl(e,t,i){let s=l.createElement("div",{className:`${this.player.options.classPrefix}-style-group`}),a=l.createElement("label",{textContent:e,style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});s.appendChild(a);let r=l.createElement("select",{className:`${this.player.options.classPrefix}-style-select`,style:{width:"100%",padding:"6px",background:"var(--vidply-white)",border:"1px solid var(--vidply-white-10)",borderRadius:"4px",color:"var(--vidply-black)",fontSize:"13px"}}),n=this.player.options[t];return i.forEach(o=>{let c=l.createElement("option",{textContent:o.label,attributes:{value:o.value}});o.value===n&&(c.selected=!0),r.appendChild(c)}),r.addEventListener("mousedown",o=>{o.stopPropagation()}),r.addEventListener("click",o=>{o.stopPropagation()}),r.addEventListener("change",o=>{o.stopPropagation(),this.player.options[t]=o.target.value,this.player.captionManager&&this.player.captionManager.setCaptionStyle(t.replace("captions","").charAt(0).toLowerCase()+t.replace("captions","").slice(1),o.target.value)}),s.appendChild(r),s}createColorControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-style-group`}),s=l.createElement("label",{textContent:e,style:{display:"block",fontSize:"12px",marginBottom:"4px",color:"rgba(255,255,255,0.7)"}});i.appendChild(s);let a=l.createElement("input",{attributes:{type:"color",value:this.player.options[t]},style:{width:"100%",height:"32px",padding:"2px",background:"rgba(255,255,255,0.1)",border:"1px solid rgba(255,255,255,0.2)",borderRadius:"4px",cursor:"pointer"}});return a.addEventListener("mousedown",r=>{r.stopPropagation()}),a.addEventListener("click",r=>{r.stopPropagation()}),a.addEventListener("change",r=>{r.stopPropagation(),this.player.options[t]=r.target.value,this.player.captionManager&&this.player.captionManager.setCaptionStyle(t.replace("captions","").charAt(0).toLowerCase()+t.replace("captions","").slice(1),r.target.value)}),i.appendChild(a),i}createOpacityControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-style-group`}),s=l.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"}}),a=l.createElement("label",{textContent:e,style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}}),r=l.createElement("span",{textContent:Math.round(this.player.options[t]*100)+"%",style:{fontSize:"12px",color:"rgba(255,255,255,0.7)"}});s.appendChild(a),s.appendChild(r),i.appendChild(s);let n=l.createElement("input",{attributes:{type:"range",min:"0",max:"1",step:"0.1",value:String(this.player.options[t])},style:{width:"100%",cursor:"pointer"}});return n.addEventListener("mousedown",o=>{o.stopPropagation()}),n.addEventListener("click",o=>{o.stopPropagation()}),n.addEventListener("input",o=>{o.stopPropagation();let c=parseFloat(o.target.value);r.textContent=Math.round(c*100)+"%",this.player.options[t]=c,this.player.captionManager&&this.player.captionManager.setCaptionStyle(t.replace("captions","").charAt(0).toLowerCase()+t.replace("captions","").slice(1),c)}),i.appendChild(n),i}createSpeedButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-speed`,attributes:{type:"button","aria-label":d.t("player.speed"),"aria-haspopup":"menu"}});e.appendChild(b("speed"));let t=l.createElement("span",{className:`${this.player.options.classPrefix}-speed-text`,textContent:"1x"});return e.appendChild(t),e.addEventListener("click",()=>{this.showSpeedMenu(e)}),this.controls.speed=e,this.controls.speedText=t,e}formatSpeedLabel(e){return e===1?d.t("speeds.normal"):`${e.toLocaleString(d.getLanguage(),{minimumFractionDigits:0,maximumFractionDigits:2})}\xD7`}showSpeedMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-speed-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-speed-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu"}}),s=[.25,.5,.75,1,1.25,1.5,1.75,2],a=null;s.forEach(r=>{let n=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:this.formatSpeedLabel(r),attributes:{type:"button",role:"menuitem",tabindex:"-1"}});r===this.player.state.playbackSpeed&&(n.classList.add(`${this.player.options.classPrefix}-menu-item-active`),n.appendChild(b("check")),a=n),n.addEventListener("click",()=>{this.player.setPlaybackSpeed(r),i.remove()}),i.appendChild(n)}),e.appendChild(i),this.attachMenuKeyboardNavigation(i),this.attachMenuCloseHandler(i,e),setTimeout(()=>{let r=a||i.querySelector(`.${this.player.options.classPrefix}-menu-item`);r&&r.focus()},0)}createCaptionsButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-captions-button`,attributes:{type:"button","aria-label":d.t("player.captions"),"aria-pressed":"false","aria-haspopup":"menu"}});return e.appendChild(b("captionsOff")),e.addEventListener("click",()=>{this.showCaptionsMenu(e)}),this.controls.captions=e,e}showCaptionsMenu(e){let t=document.querySelector(`.${this.player.options.classPrefix}-captions-menu`);if(t){t.remove();return}let i=l.createElement("div",{className:`${this.player.options.classPrefix}-captions-menu ${this.player.options.classPrefix}-menu`,attributes:{role:"menu","aria-label":d.t("captions.select")}});if(!this.player.captionManager||this.player.captionManager.tracks.length===0){let n=l.createElement("div",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("player.noCaptions"),style:{opacity:"0.5",cursor:"default"}});i.appendChild(n),e.appendChild(i),this.attachMenuCloseHandler(i,e);return}let s=null,a=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:d.t("captions.off"),attributes:{type:"button",role:"menuitem",tabindex:"-1"}});this.player.state.captionsEnabled||(a.classList.add(`${this.player.options.classPrefix}-menu-item-active`),a.appendChild(b("check")),s=a),a.addEventListener("click",()=>{this.player.disableCaptions(),this.updateCaptionsButton(),i.remove()}),i.appendChild(a),this.player.captionManager.getAvailableTracks().forEach(n=>{let o=l.createElement("button",{className:`${this.player.options.classPrefix}-menu-item`,textContent:n.label,attributes:{type:"button",role:"menuitem",lang:n.language,tabindex:"-1"}});this.player.state.captionsEnabled&&this.player.captionManager.currentTrack===this.player.captionManager.tracks[n.index]&&(o.classList.add(`${this.player.options.classPrefix}-menu-item-active`),o.appendChild(b("check")),s=o),o.addEventListener("click",()=>{this.player.captionManager.switchTrack(n.index),this.updateCaptionsButton(),i.remove()}),i.appendChild(o)}),e.appendChild(i),this.attachMenuKeyboardNavigation(i),this.attachMenuCloseHandler(i,e),setTimeout(()=>{let n=s||i.querySelector(`.${this.player.options.classPrefix}-menu-item`);n&&n.focus()},0)}updateCaptionsButton(){if(!this.controls.captions)return;let e=this.controls.captions.querySelector(".vidply-icon"),t=this.player.state.captionsEnabled;e.innerHTML=t?b("captions").innerHTML:b("captionsOff").innerHTML,this.controls.captions.setAttribute("aria-pressed",t?"true":"false")}createTranscriptButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-transcript`,attributes:{type:"button","aria-label":d.t("player.transcript"),"aria-pressed":"false"}});return e.appendChild(b("transcript")),e.addEventListener("click",()=>{this.player.transcriptManager&&(this.player.transcriptManager.toggleTranscript(),this.updateTranscriptButton())}),this.controls.transcript=e,e}updateTranscriptButton(){if(!this.controls.transcript)return;let e=this.player.transcriptManager&&this.player.transcriptManager.isVisible;this.controls.transcript.setAttribute("aria-pressed",e?"true":"false")}createAudioDescriptionButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-audio-description`,attributes:{type:"button","aria-label":d.t("player.audioDescription"),"aria-pressed":"false",title:d.t("player.audioDescription")}});return e.appendChild(b("audioDescription")),e.addEventListener("click",async()=>{await this.player.toggleAudioDescription(),this.updateAudioDescriptionButton()}),this.controls.audioDescription=e,e}updateAudioDescriptionButton(){if(!this.controls.audioDescription)return;let e=this.controls.audioDescription.querySelector(".vidply-icon"),t=this.player.state.audioDescriptionEnabled;e.innerHTML=t?b("audioDescriptionOn").innerHTML:b("audioDescription").innerHTML,this.controls.audioDescription.setAttribute("aria-pressed",t?"true":"false"),this.controls.audioDescription.setAttribute("aria-label",t?d.t("audioDescription.disable"):d.t("audioDescription.enable"))}createSignLanguageButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-sign-language`,attributes:{type:"button","aria-label":d.t("player.signLanguage"),"aria-pressed":"false",title:d.t("player.signLanguage")}});return e.appendChild(b("signLanguage")),e.addEventListener("click",()=>{this.player.toggleSignLanguage(),this.updateSignLanguageButton()}),this.controls.signLanguage=e,e}updateSignLanguageButton(){if(!this.controls.signLanguage)return;let e=this.controls.signLanguage.querySelector(".vidply-icon"),t=this.player.state.signLanguageEnabled;e.innerHTML=t?b("signLanguageOn").innerHTML:b("signLanguage").innerHTML,this.controls.signLanguage.setAttribute("aria-pressed",t?"true":"false"),this.controls.signLanguage.setAttribute("aria-label",t?d.t("signLanguage.hide"):d.t("signLanguage.show"))}createSettingsButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-settings`,attributes:{type:"button","aria-label":d.t("player.settings")}});return e.appendChild(b("settings")),e.addEventListener("click",()=>{this.player.showSettings()}),e}createPipButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-pip`,attributes:{type:"button","aria-label":d.t("player.pip")}});return e.appendChild(b("pip")),e.addEventListener("click",()=>{this.player.togglePiP()}),e}createFullscreenButton(){let e=l.createElement("button",{className:`${this.player.options.classPrefix}-button ${this.player.options.classPrefix}-fullscreen`,attributes:{type:"button","aria-label":d.t("player.fullscreen")}});return e.appendChild(b("fullscreen")),e.addEventListener("click",()=>{this.player.toggleFullscreen()}),this.controls.fullscreen=e,e}attachEvents(){this.player.on("play",()=>this.updatePlayPauseButton()),this.player.on("pause",()=>this.updatePlayPauseButton()),this.player.on("timeupdate",()=>this.updateProgress()),this.player.on("loadedmetadata",()=>{this.updateDuration(),this.ensureQualityButton(),this.updateQualityIndicator()}),this.player.on("volumechange",()=>this.updateVolumeDisplay()),this.player.on("progress",()=>this.updateBuffered()),this.player.on("playbackspeedchange",()=>this.updateSpeedDisplay()),this.player.on("fullscreenchange",()=>this.updateFullscreenButton()),this.player.on("captionsenabled",()=>this.updateCaptionsButton()),this.player.on("captionsdisabled",()=>this.updateCaptionsButton()),this.player.on("audiodescriptionenabled",()=>this.updateAudioDescriptionButton()),this.player.on("audiodescriptiondisabled",()=>this.updateAudioDescriptionButton()),this.player.on("signlanguageenabled",()=>this.updateSignLanguageButton()),this.player.on("signlanguagedisabled",()=>this.updateSignLanguageButton()),this.player.on("qualitychange",()=>this.updateQualityIndicator()),this.player.on("hlslevelswitched",()=>this.updateQualityIndicator()),this.player.on("hlsmanifestparsed",()=>{this.ensureQualityButton(),this.updateQualityIndicator()})}updatePlayPauseButton(){if(!this.controls.playPause)return;let e=this.controls.playPause.querySelector(".vidply-icon"),t=this.player.state.playing;e.innerHTML=t?b("pause").innerHTML:b("play").innerHTML,this.controls.playPause.setAttribute("aria-label",t?d.t("player.pause"):d.t("player.play"))}updateProgress(){if(!this.controls.played)return;let e=this.player.state.currentTime/this.player.state.duration*100;if(this.controls.played.style.width=`${e}%`,this.controls.progress.setAttribute("aria-valuenow",String(Math.round(e))),this.controls.currentTimeVisual){let t=this.player.state.currentTime;this.controls.currentTimeVisual.textContent=L.formatTime(t),this.controls.currentTimeAccessible&&(this.controls.currentTimeAccessible.textContent=L.formatDuration(t))}}updateDuration(){if(this.controls.durationVisual){let e=this.player.state.duration;this.controls.durationVisual.textContent=L.formatTime(e),this.controls.durationAccessible&&(this.controls.durationAccessible.textContent=d.t("time.durationPrefix")+L.formatDuration(e))}}updateVolumeDisplay(){let e=this.player.state.volume*100;if(this.controls.volumeFill&&(this.controls.volumeFill.style.height=`${e}%`),this.controls.mute){let t=this.controls.mute.querySelector(".vidply-icon");if(t){let i;this.player.state.muted||this.player.state.volume===0?i="volumeMuted":this.player.state.volume<.3?i="volumeLow":this.player.state.volume<.7?i="volumeMedium":i="volumeHigh",t.innerHTML=b(i).innerHTML,this.controls.mute.setAttribute("aria-label",this.player.state.muted?d.t("player.unmute"):d.t("player.mute"))}}this.controls.volumeSlider&&this.controls.volumeSlider.setAttribute("aria-valuenow",String(Math.round(e)))}updateBuffered(){if(!this.controls.buffered||!this.player.element.buffered||this.player.element.buffered.length===0)return;let t=this.player.element.buffered.end(this.player.element.buffered.length-1)/this.player.state.duration*100;this.controls.buffered.style.width=`${t}%`}updateSpeedDisplay(){this.controls.speedText&&(this.controls.speedText.textContent=`${this.player.state.playbackSpeed}x`)}updateFullscreenButton(){if(!this.controls.fullscreen)return;let e=this.controls.fullscreen.querySelector(".vidply-icon"),t=this.player.state.fullscreen;e.innerHTML=t?b("fullscreenExit").innerHTML:b("fullscreen").innerHTML,this.controls.fullscreen.setAttribute("aria-label",t?d.t("player.exitFullscreen"):d.t("player.fullscreen"))}ensureQualityButton(){if(!this.player.options.qualityButton||this.controls.quality||!this.hasQualityLevels())return;let e=this.createQualityButton(),t=this.rightButtons.querySelector(`.${this.player.options.classPrefix}-speed`),s=this.rightButtons.querySelector(`.${this.player.options.classPrefix}-caption-style`)||t;s?this.rightButtons.insertBefore(e,s):this.rightButtons.insertBefore(e,this.rightButtons.firstChild),this.player.log("Quality button added dynamically","info")}updateQualityIndicator(){if(!this.controls.qualityText||!this.player.renderer||!this.player.renderer.getQualities)return;let e=this.player.renderer.getQualities();if(e.length===0){this.controls.qualityText.textContent="";return}let t="";if(this.player.renderer.hls&&this.player.renderer.hls.currentLevel===-1)t="Auto";else if(this.player.renderer.getCurrentQuality){let i=this.player.renderer.getCurrentQuality(),s=e.find(a=>a.index===i);s&&(t=s.height?`${s.height}p`:"")}this.controls.qualityText.textContent=t}setupAutoHide(){if(this.player.element.tagName!=="VIDEO")return;let e=()=>{this.element.classList.add(`${this.player.options.classPrefix}-controls-visible`),this.player.container.classList.add(`${this.player.options.classPrefix}-controls-visible`),this.player.state.controlsVisible=!0,clearTimeout(this.hideTimeout),this.player.state.playing&&(this.hideTimeout=setTimeout(()=>{this.element.classList.remove(`${this.player.options.classPrefix}-controls-visible`),this.player.container.classList.remove(`${this.player.options.classPrefix}-controls-visible`),this.player.state.controlsVisible=!1},this.player.options.hideControlsDelay))};this.player.container.addEventListener("mousemove",e),this.player.container.addEventListener("touchstart",e),this.player.container.addEventListener("click",e),this.element.addEventListener("focusin",e),this.player.on("pause",()=>{e(),clearTimeout(this.hideTimeout)}),this.player.on("play",()=>{e()}),e()}show(){this.element.style.display=""}hide(){this.element.style.display="none"}destroy(){this.hideTimeout&&clearTimeout(this.hideTimeout),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}};var P=class{constructor(e="vidply"){this.namespace=e,this.storage=this.isStorageAvailable()?localStorage:null}isStorageAvailable(){try{let e="__storage_test__";return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch{return!1}}getKey(e){return`${this.namespace}_${e}`}set(e,t){if(!this.storage)return!1;try{let i=this.getKey(e);return this.storage.setItem(i,JSON.stringify(t)),!0}catch(i){return console.warn("Failed to save to localStorage:",i),!1}}get(e,t=null){if(!this.storage)return t;try{let i=this.getKey(e),s=this.storage.getItem(i);return s?JSON.parse(s):t}catch(i){return console.warn("Failed to read from localStorage:",i),t}}remove(e){if(!this.storage)return!1;try{let t=this.getKey(e);return this.storage.removeItem(t),!0}catch(t){return console.warn("Failed to remove from localStorage:",t),!1}}clear(){if(!this.storage)return!1;try{return Object.keys(this.storage).forEach(t=>{t.startsWith(this.namespace)&&this.storage.removeItem(t)}),!0}catch(e){return console.warn("Failed to clear localStorage:",e),!1}}saveTranscriptPreferences(e){return this.set("transcript_preferences",e)}getTranscriptPreferences(){return this.get("transcript_preferences",null)}saveCaptionPreferences(e){return this.set("caption_preferences",e)}getCaptionPreferences(){return this.get("caption_preferences",null)}savePlayerPreferences(e){return this.set("player_preferences",e)}getPlayerPreferences(){return this.get("player_preferences",null)}saveSignLanguagePreferences(e){return this.set("sign_language_preferences",e)}getSignLanguagePreferences(){return this.get("sign_language_preferences",null)}};var R=class{constructor(e){this.player=e,this.element=null,this.tracks=[],this.currentTrack=null,this.currentCue=null,this.storage=new P("vidply"),this.loadSavedPreferences(),this.init()}loadSavedPreferences(){let e=this.storage.getCaptionPreferences();e&&(e.fontSize&&(this.player.options.captionsFontSize=e.fontSize),e.fontFamily&&(this.player.options.captionsFontFamily=e.fontFamily),e.color&&(this.player.options.captionsColor=e.color),e.backgroundColor&&(this.player.options.captionsBackgroundColor=e.backgroundColor),e.opacity!==void 0&&(this.player.options.captionsOpacity=e.opacity))}saveCaptionPreferences(){this.storage.saveCaptionPreferences({fontSize:this.player.options.captionsFontSize,fontFamily:this.player.options.captionsFontFamily,color:this.player.options.captionsColor,backgroundColor:this.player.options.captionsBackgroundColor,opacity:this.player.options.captionsOpacity})}init(){this.createElement(),this.loadTracks(),this.attachEvents(),this.player.options.captionsDefault&&this.tracks.length>0&&this.enable()}createElement(){this.element=l.createElement("div",{className:`${this.player.options.classPrefix}-captions`,attributes:{"aria-live":"polite","aria-atomic":"true",role:"region","aria-label":d.t("player.captions")}}),this.updateStyles(),(this.player.videoWrapper||this.player.container).appendChild(this.element)}loadTracks(){let e=this.player.element.textTracks;for(let t=0;t<e.length;t++){let i=e[t];(i.kind==="subtitles"||i.kind==="captions")&&(this.tracks.push({track:i,language:i.language,label:i.label,kind:i.kind,index:t}),i.mode="hidden")}}attachEvents(){this.player.on("timeupdate",()=>{this.updateCaptions()}),this.player.on("captionschange",()=>{this.updateStyles()})}enable(e=0){if(this.tracks.length===0)return;this.currentTrack&&(this.currentTrack.track.mode="hidden");let t=this.tracks[e];t&&(t.track.mode="hidden",this.currentTrack=t,this.player.state.captionsEnabled=!0,this.cueChangeHandler&&t.track.removeEventListener("cuechange",this.cueChangeHandler),this.cueChangeHandler=()=>{this.updateCaptions()},t.track.addEventListener("cuechange",this.cueChangeHandler),this.player.emit("captionsenabled",t))}disable(){this.currentTrack&&(this.currentTrack.track.mode="hidden",this.currentTrack=null),this.element.style.display="none",this.element.innerHTML="",this.currentCue=null,this.player.state.captionsEnabled=!1,this.player.emit("captionsdisabled")}updateCaptions(){if(!this.currentTrack||!this.currentTrack.track.activeCues)return;let e=this.currentTrack.track.activeCues;if(e.length>0){let t=e[0];if(this.currentCue!==t){this.currentCue=t;let i=t.text;i=this.parseVTTFormatting(i),this.element.innerHTML=l.sanitizeHTML(i),this.element.style.display="block",this.player.emit("captionchange",t)}}else this.currentCue&&(this.element.innerHTML="",this.element.style.display="none",this.currentCue=null)}parseVTTFormatting(e){return e=e.replace(/<c[^>]*>(.*?)<\/c>/g,'<span class="caption-class">$1</span>'),e=e.replace(/<b>(.*?)<\/b>/g,"<strong>$1</strong>"),e=e.replace(/<i>(.*?)<\/i>/g,"<em>$1</em>"),e=e.replace(/<u>(.*?)<\/u>/g,"<u>$1</u>"),e=e.replace(/<v\s+([^>]+)>(.*?)<\/v>/g,'<span class="caption-voice" data-voice="$1">$2</span>'),e}updateStyles(){if(!this.element)return;let e=this.player.options;this.element.style.fontSize=e.captionsFontSize,this.element.style.fontFamily=e.captionsFontFamily,this.element.style.color=e.captionsColor,this.element.style.backgroundColor=this.hexToRgba(e.captionsBackgroundColor,e.captionsOpacity)}hexToRgba(e,t){let i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return i?`rgba(${parseInt(i[1],16)}, ${parseInt(i[2],16)}, ${parseInt(i[3],16)}, ${t})`:e}setCaptionStyle(e,t){switch(e){case"fontSize":this.player.options.captionsFontSize=t;break;case"fontFamily":this.player.options.captionsFontFamily=t;break;case"color":this.player.options.captionsColor=t;break;case"backgroundColor":this.player.options.captionsBackgroundColor=t;break;case"opacity":this.player.options.captionsOpacity=t;break}this.updateStyles(),this.saveCaptionPreferences(),this.player.emit("captionschange")}getAvailableTracks(){return this.tracks.map((e,t)=>({index:t,language:e.language,label:e.label||e.language,kind:e.kind}))}switchTrack(e){e>=0&&e<this.tracks.length&&(this.disable(),this.enable(e))}destroy(){this.disable(),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}};var W=class{constructor(e){this.player=e,this.shortcuts=e.options.keyboardShortcuts,this.init()}init(){this.attachEvents()}attachEvents(){this.player.container.addEventListener("keydown",e=>{this.handleKeydown(e)}),this.player.container.hasAttribute("tabindex")||this.player.container.setAttribute("tabindex","0")}handleKeydown(e){if(e.target.tagName==="INPUT"||e.target.tagName==="TEXTAREA"||e.target.tagName==="SELECT")return;let t=e.key,i=!1;for(let[s,a]of Object.entries(this.shortcuts))if(a.includes(t)&&(i=this.executeAction(s,e),i)){e.preventDefault(),e.stopPropagation(),this.announceAction(s);break}!i&&this.player.options.debug&&console.log("[VidPly] Unhandled key:",e.key,"code:",e.code,"shiftKey:",e.shiftKey)}executeAction(e,t){switch(e){case"play-pause":return this.player.toggle(),!0;case"volume-up":return this.player.setVolume(Math.min(1,this.player.state.volume+.1)),!0;case"volume-down":return this.player.setVolume(Math.max(0,this.player.state.volume-.1)),!0;case"seek-forward":return this.player.seekForward(),!0;case"seek-backward":return this.player.seekBackward(),!0;case"mute":return this.player.toggleMute(),!0;case"fullscreen":return this.player.toggleFullscreen(),!0;case"captions":if(this.player.captionManager&&this.player.captionManager.tracks.length>1){let i=this.player.controlBar&&this.player.controlBar.controls.captions;i?this.player.controlBar.showCaptionsMenu(i):this.player.toggleCaptions()}else this.player.toggleCaptions();return!0;case"caption-style-menu":return this.player.controlBar&&this.player.controlBar.controls.captionStyle?(this.player.controlBar.showCaptionStyleMenu(this.player.controlBar.controls.captionStyle),!0):!1;case"speed-up":return this.player.setPlaybackSpeed(Math.min(2,this.player.state.playbackSpeed+.25)),!0;case"speed-down":return this.player.setPlaybackSpeed(Math.max(.25,this.player.state.playbackSpeed-.25)),!0;case"speed-menu":return this.player.controlBar&&this.player.controlBar.controls.speed?(this.player.controlBar.showSpeedMenu(this.player.controlBar.controls.speed),!0):!1;case"quality-menu":return this.player.controlBar&&this.player.controlBar.controls.quality?(this.player.controlBar.showQualityMenu(this.player.controlBar.controls.quality),!0):!1;case"chapters-menu":return this.player.controlBar&&this.player.controlBar.controls.chapters?(this.player.controlBar.showChaptersMenu(this.player.controlBar.controls.chapters),!0):!1;case"transcript-toggle":return this.player.transcriptManager?(this.player.transcriptManager.toggleTranscript(),!0):!1;default:return!1}}announceAction(e){if(!this.player.options.screenReaderAnnouncements)return;let t="";switch(e){case"play-pause":t=this.player.state.playing?"Playing":"Paused";break;case"volume-up":t=`Volume ${Math.round(this.player.state.volume*100)}%`;break;case"volume-down":t=`Volume ${Math.round(this.player.state.volume*100)}%`;break;case"mute":t=this.player.state.muted?"Muted":"Unmuted";break;case"fullscreen":t=this.player.state.fullscreen?"Fullscreen":"Exit fullscreen";break;case"captions":t=this.player.state.captionsEnabled?"Captions on":"Captions off";break;case"speed-up":case"speed-down":t=`Speed ${this.player.state.playbackSpeed}x`;break}t&&this.announce(t)}announce(e,t="polite"){let i=document.getElementById("vidply-announcer");i||(i=document.createElement("div"),i.id="vidply-announcer",i.className="vidply-sr-only",i.setAttribute("aria-live",t),i.setAttribute("aria-atomic","true"),i.style.cssText=`
|
|
8
8
|
position: absolute;
|
|
9
9
|
left: -10000px;
|
|
10
10
|
width: 1px;
|
|
11
11
|
height: 1px;
|
|
12
12
|
overflow: hidden;
|
|
13
|
-
`,document.body.appendChild(i)),i.textContent="",setTimeout(()=>{i.textContent=e},100)}updateShortcut(e,t){Array.isArray(t)&&(this.shortcuts[e]=t)}destroy(){}};var B=class{constructor(e){this.player=e,this.transcriptWindow=null,this.transcriptEntries=[],this.metadataCues=[],this.currentActiveEntry=null,this.isVisible=!1,this.storage=new D("vidply"),this.isDragging=!1,this.dragOffsetX=0,this.dragOffsetY=0,this.isResizing=!1,this.resizeDirection=null,this.resizeStartX=0,this.resizeStartY=0,this.resizeStartWidth=0,this.resizeStartHeight=0,this.resizeEnabled=!1,this.settingsMenuVisible=!1,this.settingsMenu=null,this.settingsButton=null,this.settingsMenuJustOpened=!1,this.keyboardDragMode=!1,this.styleDialog=null,this.styleDialogVisible=!1,this.styleDialogJustOpened=!1,this.languageSelector=null,this.currentTranscriptLanguage=null,this.availableTranscriptLanguages=[],this.languageSelectorHandler=null;let t=this.storage.getTranscriptPreferences();this.autoscrollEnabled=(t==null?void 0:t.autoscroll)!==void 0?t.autoscroll:!0,this.transcriptStyle={fontSize:(t==null?void 0:t.fontSize)||this.player.options.transcriptFontSize||"100%",fontFamily:(t==null?void 0:t.fontFamily)||this.player.options.transcriptFontFamily||"sans-serif",color:(t==null?void 0:t.color)||this.player.options.transcriptColor||"#ffffff",backgroundColor:(t==null?void 0:t.backgroundColor)||this.player.options.transcriptBackgroundColor||"#1e1e1e",opacity:(t==null?void 0:t.opacity)??this.player.options.transcriptOpacity??.98},this.handlers={timeupdate:()=>this.updateActiveEntry(),resize:null,mousemove:null,mouseup:null,touchmove:null,touchend:null,mousedown:null,touchstart:null,keydown:null,settingsClick:null,settingsKeydown:null,documentClick:null,styleDialogKeydown:null},this.timeouts=new Set,this.init()}init(){this.setupMetadataHandlingOnLoad(),this.player.on("timeupdate",this.handlers.timeupdate),this.player.on("fullscreenchange",()=>{this.isVisible&&this.setManagedTimeout(()=>this.positionTranscript(),100)})}toggleTranscript(){this.isVisible?this.hideTranscript():this.showTranscript()}showTranscript(){if(this.transcriptWindow){this.transcriptWindow.style.display="flex",this.isVisible=!0,this.setManagedTimeout(()=>{this.settingsButton&&this.settingsButton.focus()},150);return}this.createTranscriptWindow(),this.loadTranscriptData(),this.transcriptWindow&&(this.transcriptWindow.style.display="flex",this.setManagedTimeout(()=>this.positionTranscript(),0),this.setManagedTimeout(()=>{this.settingsButton&&this.settingsButton.focus()},150)),this.isVisible=!0}hideTranscript(){this.transcriptWindow&&(this.transcriptWindow.style.display="none",this.isVisible=!1)}createTranscriptWindow(){this.transcriptWindow=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-window`,attributes:{role:"dialog","aria-label":"Video Transcript",tabindex:"-1"}}),this.transcriptHeader=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header`,attributes:{"aria-label":"Drag to reposition transcript. Use arrow keys to move, Home to reset position, Escape to close.",tabindex:"0"}}),this.headerLeft=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header-left`}),this.settingsButton=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings`,attributes:{type:"button","aria-label":h.t("transcript.settings"),"aria-expanded":"false"}}),this.settingsButton.appendChild(b("settings")),this.handlers.settingsClick=r=>{r.preventDefault(),r.stopPropagation(),this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()},this.settingsButton.addEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown=r=>{r.key==="d"||r.key==="D"?(r.preventDefault(),r.stopPropagation(),this.toggleKeyboardDragMode()):r.key==="r"||r.key==="R"?(r.preventDefault(),r.stopPropagation(),this.toggleResizeMode()):r.key==="Escape"&&this.settingsMenuVisible&&(r.preventDefault(),r.stopPropagation(),this.hideSettingsMenu())},this.settingsButton.addEventListener("keydown",this.handlers.settingsKeydown);let e=l.createElement("h3",{textContent:h.t("transcript.title")}),t=l.createElement("label",{className:`${this.player.options.classPrefix}-transcript-autoscroll-label`,attributes:{title:h.t("transcript.autoscroll")}});this.autoscrollCheckbox=l.createElement("input",{attributes:{type:"checkbox",checked:this.autoscrollEnabled,"aria-label":h.t("transcript.autoscroll")}});let i=l.createElement("span",{textContent:h.t("transcript.autoscroll"),className:`${this.player.options.classPrefix}-transcript-autoscroll-text`});t.appendChild(this.autoscrollCheckbox),t.appendChild(i),this.autoscrollCheckbox.addEventListener("change",r=>{this.autoscrollEnabled=r.target.checked,this.saveAutoscrollPreference()}),this.headerLeft.appendChild(this.settingsButton),this.headerLeft.appendChild(e),this.headerLeft.appendChild(t),this.languageSelector=l.createElement("select",{className:`${this.player.options.classPrefix}-transcript-language-select`,attributes:{"aria-label":h.t("settings.language")||"Language",style:"display: none;"}}),this.headerLeft.appendChild(this.languageSelector);let s=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-close`,attributes:{type:"button","aria-label":h.t("transcript.close")}});s.appendChild(b("close")),s.addEventListener("click",()=>this.hideTranscript()),this.transcriptHeader.appendChild(this.headerLeft),this.transcriptHeader.appendChild(s),this.transcriptContent=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-content`}),this.transcriptWindow.appendChild(this.transcriptHeader),this.transcriptWindow.appendChild(this.transcriptContent),this.player.container.appendChild(this.transcriptWindow),this.positionTranscript(),this.setupDragAndDrop(),this.handlers.documentClick=r=>{this.settingsMenuJustOpened||this.styleDialogJustOpened||this.settingsButton&&this.settingsButton.contains(r.target)||this.settingsMenu&&this.settingsMenu.contains(r.target)||(this.settingsMenuVisible&&this.hideSettingsMenu(),this.styleDialogVisible&&this.styleDialog&&!this.styleDialog.contains(r.target)&&this.hideStyleDialog())},this.documentClickHandlerAdded=!1;let a;this.handlers.resize=()=>{a&&this.clearManagedTimeout(a),a=this.setManagedTimeout(()=>this.positionTranscript(),100)},window.addEventListener("resize",this.handlers.resize)}positionTranscript(){if(!this.transcriptWindow||!this.player.videoWrapper||!this.isVisible)return;let e=window.innerWidth<640,t=this.player.videoWrapper.getBoundingClientRect(),i=this.player.state.fullscreen;e&&!i?(this.transcriptWindow.style.position="relative",this.transcriptWindow.style.left="0",this.transcriptWindow.style.right="0",this.transcriptWindow.style.bottom="auto",this.transcriptWindow.style.top="auto",this.transcriptWindow.style.width="100%",this.transcriptWindow.style.maxWidth="100%",this.transcriptWindow.style.maxHeight="400px",this.transcriptWindow.style.height="auto",this.transcriptWindow.style.borderRadius="0",this.transcriptWindow.style.transform="none",this.transcriptWindow.style.border="none",this.transcriptWindow.style.borderTop="1px solid var(--vidply-border-light)",this.transcriptWindow.style.boxShadow="none",this.transcriptHeader&&(this.transcriptHeader.style.cursor="default"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)):i?(this.transcriptWindow.style.position="fixed",this.transcriptWindow.style.left="auto",this.transcriptWindow.style.right="20px",this.transcriptWindow.style.bottom="80px",this.transcriptWindow.style.top="auto",this.transcriptWindow.style.maxHeight="calc(100vh - 180px)",this.transcriptWindow.style.height="auto",this.transcriptWindow.style.width="400px",this.transcriptWindow.style.maxWidth="400px",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.borderTop="",this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)):(this.transcriptWindow.style.position="absolute",this.transcriptWindow.style.left=`${t.width+8}px`,this.transcriptWindow.style.right="auto",this.transcriptWindow.style.bottom="auto",this.transcriptWindow.style.top="0",this.transcriptWindow.style.height=`${t.height}px`,this.transcriptWindow.style.maxHeight="none",this.transcriptWindow.style.width="400px",this.transcriptWindow.style.maxWidth="400px",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.borderTop="",this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow))}getAvailableTranscriptLanguages(){let e=this.player.textTracks,t=new Map;return e.forEach(i=>{(i.kind==="captions"||i.kind==="subtitles")&&i.language&&(t.has(i.language)||t.set(i.language,{language:i.language,label:i.label||i.language,track:i}))}),Array.from(t.values())}updateLanguageSelector(){if(this.languageSelector){if(this.availableTranscriptLanguages=this.getAvailableTranscriptLanguages(),this.languageSelector.innerHTML="",this.availableTranscriptLanguages.length<2){this.languageSelector.style.display="none";return}if(this.languageSelector.style.display="block",this.availableTranscriptLanguages.forEach((e,t)=>{let i=l.createElement("option",{textContent:e.label,attributes:{value:e.language}});this.languageSelector.appendChild(i)}),this.currentTranscriptLanguage)this.languageSelector.value=this.currentTranscriptLanguage;else if(this.availableTranscriptLanguages.length>0){let e=this.player.textTracks.find(t=>(t.kind==="captions"||t.kind==="subtitles")&&t.mode==="showing");this.currentTranscriptLanguage=e?e.language:this.availableTranscriptLanguages[0].language,this.languageSelector.value=this.currentTranscriptLanguage}this.languageSelectorHandler&&this.languageSelector.removeEventListener("change",this.languageSelectorHandler),this.languageSelectorHandler=e=>{this.currentTranscriptLanguage=e.target.value,this.loadTranscriptData()},this.languageSelector.addEventListener("change",this.languageSelectorHandler)}}loadTranscriptData(){this.transcriptEntries=[],this.transcriptContent.innerHTML="";let e=this.player.textTracks,t=null;this.currentTranscriptLanguage&&(t=e.find(n=>(n.kind==="captions"||n.kind==="subtitles")&&n.language===this.currentTranscriptLanguage)),t||(t=e.find(n=>n.kind==="captions"||n.kind==="subtitles"),t&&(this.currentTranscriptLanguage=t.language));let i=null;this.currentTranscriptLanguage&&(i=e.find(n=>n.kind==="descriptions"&&n.language===this.currentTranscriptLanguage)),i||(i=e.find(n=>n.kind==="descriptions"));let s=e.find(n=>n.kind==="metadata");if(!t&&!i&&!s){this.showNoTranscriptMessage();return}let a=[t,i,s].filter(Boolean);if(a.forEach(n=>{n.mode==="disabled"&&(n.mode="hidden")}),a.some(n=>!n.cues||n.cues.length===0)){let n=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-loading`,textContent:h.t("transcript.loading")});this.transcriptContent.appendChild(n);let c=0,u=()=>{c++,c>=a.length&&this.loadTranscriptData()};a.forEach(y=>{y.addEventListener("load",u,{once:!0})}),this.setManagedTimeout(()=>{this.loadTranscriptData()},500);return}let o=[];t&&t.cues&&Array.from(t.cues).forEach(n=>{o.push({cue:n,type:"caption"})}),i&&i.cues&&Array.from(i.cues).forEach(n=>{o.push({cue:n,type:"description"})}),s&&s.cues&&(this.metadataCues=Array.from(s.cues),this.setupMetadataHandling()),o.sort((n,c)=>n.cue.startTime-c.cue.startTime),o.forEach((n,c)=>{let u=this.createTranscriptEntry(n.cue,c,n.type);this.transcriptEntries.push({element:u,cue:n.cue,type:n.type,startTime:n.cue.startTime,endTime:n.cue.endTime}),this.transcriptContent.appendChild(u)}),this.applyTranscriptStyles(),this.updateLanguageSelector()}setupMetadataHandlingOnLoad(){let e=()=>{let i=this.player.textTracks.find(s=>s.kind==="metadata");if(i){if(i.mode==="disabled"&&(i.mode="hidden"),this.metadataCueChangeHandler&&i.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=()=>{let s=Array.from(i.activeCues||[]);s.length>0&&this.player.options.debug&&console.log("[VidPly Metadata] Active cues:",s.map(a=>({start:a.startTime,end:a.endTime,text:a.text}))),s.forEach(a=>{this.handleMetadataCue(a)})},i.addEventListener("cuechange",this.metadataCueChangeHandler),this.player.options.debug){let s=i.cues?i.cues.length:0;console.log("[VidPly Metadata] Track enabled,",s,"cues available")}}else this.player.options.debug&&console.warn("[VidPly Metadata] No metadata track found")};e(),this.player.on("loadedmetadata",e)}setupMetadataHandling(){!this.metadataCues||this.metadataCues.length===0||this.player.options.debug&&console.log("[VidPly Metadata]",this.metadataCues.length,"cues stored from transcript load")}handleMetadataCue(e){let t=e.text.trim();this.player.options.debug&&console.log("[VidPly Metadata] Processing cue:",{time:e.startTime,text:t}),this.player.emit("metadata",{time:e.startTime,endTime:e.endTime,text:t,cue:e}),t.includes("PAUSE")&&(this.player.state.paused||(this.player.options.debug&&console.log("[VidPly Metadata] Pausing video at",e.startTime),this.player.pause()),this.player.emit("metadata:pause",{time:e.startTime,text:t}));let i=t.match(/FOCUS:([\w#-]+)/);if(i){let a=i[1],r=document.querySelector(a);r?(this.player.options.debug&&console.log("[VidPly Metadata] Focusing element:",a),this.setManagedTimeout(()=>{r.focus()},10)):this.player.options.debug&&console.warn("[VidPly Metadata] Element not found:",a),this.player.emit("metadata:focus",{time:e.startTime,target:a,element:r,text:t})}let s=t.match(/#[\w-]+/g);s&&(this.player.options.debug&&console.log("[VidPly Metadata] Hashtags found:",s),this.player.emit("metadata:hashtags",{time:e.startTime,hashtags:s,text:t}))}createTranscriptEntry(e,t,i="caption"){let s=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-entry ${this.player.options.classPrefix}-transcript-${i}`,attributes:{"data-start":String(e.startTime),"data-end":String(e.endTime),"data-type":i,role:"button",tabindex:"0"}}),a=l.createElement("span",{className:`${this.player.options.classPrefix}-transcript-time`,textContent:A.formatTime(e.startTime)}),r=l.createElement("span",{className:`${this.player.options.classPrefix}-transcript-text`,textContent:this.stripVTTFormatting(e.text)});s.appendChild(a),s.appendChild(r);let o=()=>{this.player.seek(e.startTime),this.player.state.paused&&this.player.play()};return s.addEventListener("click",o),s.addEventListener("keydown",n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),o())}),s}stripVTTFormatting(e){return e.replace(/<[^>]+>/g,"").replace(/\n/g," ").trim()}showNoTranscriptMessage(){let e=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-empty`,textContent:h.t("transcript.noTranscript")});this.transcriptContent.appendChild(e)}updateActiveEntry(){if(!this.isVisible||this.transcriptEntries.length===0)return;let e=this.player.state.currentTime,t=this.transcriptEntries.find(i=>e>=i.startTime&&e<i.endTime);t&&t!==this.currentActiveEntry?(this.currentActiveEntry&&this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),t.element.classList.add(`${this.player.options.classPrefix}-transcript-entry-active`),this.scrollToEntry(t.element),this.currentActiveEntry=t):!t&&this.currentActiveEntry&&(this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),this.currentActiveEntry=null)}scrollToEntry(e){if(!this.transcriptContent||!this.autoscrollEnabled)return;let t=this.transcriptContent.getBoundingClientRect(),i=e.getBoundingClientRect();if(i.top<t.top||i.bottom>t.bottom){let s=e.offsetTop-this.transcriptContent.clientHeight/2+e.clientHeight/2;this.transcriptContent.scrollTo({top:s,behavior:"smooth"})}}saveAutoscrollPreference(){let e=this.storage.getTranscriptPreferences()||{};e.autoscroll=this.autoscrollEnabled,this.storage.saveTranscriptPreferences(e)}setupDragAndDrop(){!this.transcriptHeader||!this.transcriptWindow||(this.handlers.mousedown=e=>{e.target.closest(`.${this.player.options.classPrefix}-transcript-close`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-settings`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-language-select`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-settings-menu`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-style-dialog`)||(this.startDragging(e.clientX,e.clientY),e.preventDefault())},this.handlers.mousemove=e=>{this.isDragging&&this.drag(e.clientX,e.clientY)},this.handlers.mouseup=()=>{this.isDragging&&this.stopDragging()},this.handlers.touchstart=e=>{if(e.target.closest(`.${this.player.options.classPrefix}-transcript-close`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-settings`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-language-select`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-settings-menu`)||e.target.closest(`.${this.player.options.classPrefix}-transcript-style-dialog`))return;let t=window.innerWidth<640,i=this.player.state.fullscreen,s=e.touches[0];t&&!i||this.startDragging(s.clientX,s.clientY)},this.handlers.touchmove=e=>{let t=window.innerWidth<640,i=this.player.state.fullscreen;if(!(t&&!i)&&this.isDragging){let s=e.touches[0];this.drag(s.clientX,s.clientY),e.preventDefault()}},this.handlers.touchend=()=>{this.isDragging&&this.stopDragging()},this.handlers.keydown=e=>{if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)){if(!this.keyboardDragMode)return;e.preventDefault(),e.stopPropagation();let t=e.shiftKey?50:10,i=parseFloat(this.transcriptWindow.style.left)||0,s=parseFloat(this.transcriptWindow.style.top)||0;if(window.getComputedStyle(this.transcriptWindow).transform!=="none"){let n=this.transcriptWindow.getBoundingClientRect();i=n.left,s=n.top,this.transcriptWindow.style.transform="none",this.transcriptWindow.style.left=`${i}px`,this.transcriptWindow.style.top=`${s}px`}let r=i,o=s;switch(e.key){case"ArrowLeft":r-=t;break;case"ArrowRight":r+=t;break;case"ArrowUp":o-=t;break;case"ArrowDown":o+=t;break}this.transcriptWindow.style.left=`${r}px`,this.transcriptWindow.style.top=`${o}px`;return}if(e.key==="Home"){e.preventDefault(),e.stopPropagation(),this.resetPosition();return}if(e.key==="Escape"){e.preventDefault(),e.stopPropagation(),this.styleDialogVisible?this.hideStyleDialog():this.keyboardDragMode?this.disableKeyboardDragMode():this.settingsMenuVisible?this.hideSettingsMenu():this.hideTranscript();return}},this.transcriptHeader.addEventListener("mousedown",this.handlers.mousedown),document.addEventListener("mousemove",this.handlers.mousemove),document.addEventListener("mouseup",this.handlers.mouseup),this.transcriptHeader.addEventListener("touchstart",this.handlers.touchstart),document.addEventListener("touchmove",this.handlers.touchmove),document.addEventListener("touchend",this.handlers.touchend),this.transcriptHeader.addEventListener("keydown",this.handlers.keydown))}startDragging(e,t){let i=this.transcriptWindow.getBoundingClientRect(),s=this.player.container.getBoundingClientRect(),a=i.left-s.left,r=i.top-s.top;window.getComputedStyle(this.transcriptWindow).transform!=="none"&&(this.transcriptWindow.style.transform="none",this.transcriptWindow.style.left=`${a}px`,this.transcriptWindow.style.top=`${r}px`),this.dragOffsetX=e-i.left,this.dragOffsetY=t-i.top,this.isDragging=!0,this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-dragging`),document.body.style.cursor="grabbing",document.body.style.userSelect="none"}drag(e,t){if(!this.isDragging)return;let i=e-this.dragOffsetX,s=t-this.dragOffsetY,a=this.player.container.getBoundingClientRect(),r=i-a.left,o=s-a.top;this.transcriptWindow.style.left=`${r}px`,this.transcriptWindow.style.top=`${o}px`}stopDragging(){this.isDragging=!1,this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-dragging`),document.body.style.cursor="",document.body.style.userSelect=""}setPosition(e,t){let i=this.transcriptWindow.getBoundingClientRect(),s=document.documentElement.clientWidth,a=document.documentElement.clientHeight,r=100,o=-(i.width-r),n=-(i.height-r),c=s-r,u=a-r;e=Math.max(o,Math.min(e,c)),t=Math.max(n,Math.min(t,u)),this.transcriptWindow.style.left=`${e}px`,this.transcriptWindow.style.top=`${t}px`,this.transcriptWindow.style.transform="none"}resetPosition(){this.transcriptWindow.style.left="50%",this.transcriptWindow.style.top="50%",this.transcriptWindow.style.transform="translate(-50%, -50%)"}toggleKeyboardDragMode(){this.keyboardDragMode?this.disableKeyboardDragMode():this.enableKeyboardDragMode()}enableKeyboardDragMode(){this.keyboardDragMode=!0,this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-keyboard-drag`),this.settingsButton&&this.settingsButton.setAttribute("aria-label","Keyboard drag mode active. Use arrow keys to move window. Press D or Escape to exit.");let e=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-drag-indicator`,textContent:h.t("transcript.keyboardDragActive")});this.transcriptHeader.appendChild(e),this.settingsMenuVisible&&this.hideSettingsMenu(),this.transcriptHeader.focus()}disableKeyboardDragMode(){this.keyboardDragMode=!1,this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-keyboard-drag`),this.settingsButton&&this.settingsButton.setAttribute("aria-label","Transcript settings. Press Enter to open menu, or D to enable drag mode");let e=this.transcriptHeader.querySelector(`.${this.player.options.classPrefix}-transcript-drag-indicator`);e&&e.remove(),this.settingsButton&&this.settingsButton.focus()}toggleSettingsMenu(){this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()}showSettingsMenu(){if(this.settingsMenuJustOpened=!0,setTimeout(()=>{this.settingsMenuJustOpened=!1},350),this.documentClickHandlerAdded||setTimeout(()=>{document.addEventListener("click",this.handlers.documentClick),this.documentClickHandlerAdded=!0},300),this.settingsMenu){this.settingsMenu.style.display="block",this.settingsMenuVisible=!0;return}this.settingsMenu=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-settings-menu`});let e=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":h.t("transcript.keyboardDragMode")}}),t=b("move"),i=l.createElement("span",{textContent:h.t("transcript.keyboardDragMode")});e.appendChild(t),e.appendChild(i),e.addEventListener("click",()=>{this.toggleKeyboardDragMode(),this.hideSettingsMenu()});let s=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":h.t("transcript.styleTranscript")}}),a=b("settings"),r=l.createElement("span",{textContent:h.t("transcript.styleTranscript")});s.appendChild(a),s.appendChild(r),s.addEventListener("click",p=>{p.preventDefault(),p.stopPropagation(),this.hideSettingsMenu(),setTimeout(()=>{this.showStyleDialog()},50)});let o=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":h.t("transcript.resizeWindow")}}),n=b("resize"),c=l.createElement("span",{textContent:h.t("transcript.resizeWindow")});o.appendChild(n),o.appendChild(c),o.addEventListener("click",()=>{this.toggleResizeMode(),this.hideSettingsMenu()});let u=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":h.t("transcript.closeMenu")}}),y=b("close"),m=l.createElement("span",{textContent:h.t("transcript.closeMenu")});u.appendChild(y),u.appendChild(m),u.addEventListener("click",()=>{this.hideSettingsMenu()}),this.settingsMenu.appendChild(e),this.settingsMenu.appendChild(o),this.settingsMenu.appendChild(s),this.settingsMenu.appendChild(u),this.headerLeft?this.headerLeft.appendChild(this.settingsMenu):this.transcriptHeader.appendChild(this.settingsMenu),this.settingsMenuVisible=!0,this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.setAttribute("aria-expanded","true"),setTimeout(()=>{let p=this.settingsMenu.querySelector(`.${this.player.options.classPrefix}-transcript-settings-item`);p&&p.focus()},0)}hideSettingsMenu(){this.settingsMenu&&(this.settingsMenu.style.display="none",this.settingsMenuVisible=!1,this.settingsMenuJustOpened=!1,this.settingsButton&&(this.settingsButton.setAttribute("aria-expanded","false"),this.settingsButton.focus()))}enableMoveMode(){this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-move-mode`);let e=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-move-tooltip`,textContent:"Drag with mouse or press D for keyboard drag mode"});this.transcriptHeader.appendChild(e),setTimeout(()=>{this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-move-mode`),e.parentNode&&e.remove()},2e3)}toggleResizeMode(){this.resizeEnabled=!this.resizeEnabled,this.resizeEnabled?this.enableResizeHandles():this.disableResizeHandles()}enableResizeHandles(){if(!this.transcriptWindow)return;["n","s","e","w","ne","nw","se","sw"].forEach(t=>{let i=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-handle ${this.player.options.classPrefix}-transcript-resize-${t}`,attributes:{"data-direction":t}});i.addEventListener("mousedown",s=>this.startResize(s,t)),i.addEventListener("touchstart",s=>this.startResize(s.touches[0],t)),this.transcriptWindow.appendChild(i)}),this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-resizable`),this.handlers.resizeMove=t=>{this.isResizing&&this.performResize(t.clientX,t.clientY)},this.handlers.resizeEnd=()=>{this.isResizing&&this.stopResize()},this.handlers.resizeTouchMove=t=>{this.isResizing&&(this.performResize(t.touches[0].clientX,t.touches[0].clientY),t.preventDefault())},document.addEventListener("mousemove",this.handlers.resizeMove),document.addEventListener("mouseup",this.handlers.resizeEnd),document.addEventListener("touchmove",this.handlers.resizeTouchMove),document.addEventListener("touchend",this.handlers.resizeEnd)}disableResizeHandles(){if(!this.transcriptWindow)return;this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-resize-handle`).forEach(t=>t.remove()),this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-resizable`),this.handlers.resizeMove&&document.removeEventListener("mousemove",this.handlers.resizeMove),this.handlers.resizeEnd&&document.removeEventListener("mouseup",this.handlers.resizeEnd),this.handlers.resizeTouchMove&&document.removeEventListener("touchmove",this.handlers.resizeTouchMove),document.removeEventListener("touchend",this.handlers.resizeEnd)}startResize(e,t){e.stopPropagation(),e.preventDefault(),this.isResizing=!0,this.resizeDirection=t,this.resizeStartX=e.clientX,this.resizeStartY=e.clientY;let i=this.transcriptWindow.getBoundingClientRect();this.resizeStartWidth=i.width,this.resizeStartHeight=i.height,this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-resizing`),document.body.style.cursor=this.getResizeCursor(t),document.body.style.userSelect="none"}performResize(e,t){if(!this.isResizing)return;let i=e-this.resizeStartX,s=t-this.resizeStartY,a=this.resizeStartWidth,r=this.resizeStartHeight,o=this.resizeDirection;o.includes("e")&&(a=this.resizeStartWidth+i),o.includes("w")&&(a=this.resizeStartWidth-i),o.includes("s")&&(r=this.resizeStartHeight+s),o.includes("n")&&(r=this.resizeStartHeight-s);let n=300,c=200,u=window.innerWidth-40,y=window.innerHeight-40;if(a=Math.max(n,Math.min(a,u)),r=Math.max(c,Math.min(r,y)),this.transcriptWindow.style.width=`${a}px`,this.transcriptWindow.style.height=`${r}px`,this.transcriptWindow.style.maxWidth=`${a}px`,this.transcriptWindow.style.maxHeight=`${r}px`,o.includes("w")){let m=parseFloat(this.transcriptWindow.style.left)||0;this.transcriptWindow.style.left=`${m+(this.resizeStartWidth-a)}px`}if(o.includes("n")){let m=parseFloat(this.transcriptWindow.style.top)||0;this.transcriptWindow.style.top=`${m+(this.resizeStartHeight-r)}px`}}stopResize(){this.isResizing=!1,this.resizeDirection=null,this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-resizing`),document.body.style.cursor="",document.body.style.userSelect=""}getResizeCursor(e){return{n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",ne:"nesw-resize",nw:"nwse-resize",se:"nwse-resize",sw:"nesw-resize"}[e]||"default"}showStyleDialog(){if(this.styleDialog){this.styleDialog.style.display="block",this.styleDialogVisible=!0,this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let n=this.styleDialog.querySelector("select, input");n&&n.focus()},0);return}this.styleDialog=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-dialog`});let e=l.createElement("h4",{textContent:h.t("transcript.styleTitle"),className:`${this.player.options.classPrefix}-transcript-style-title`});this.styleDialog.appendChild(e);let t=this.createStyleSelectControl(h.t("captions.fontSize"),"fontSize",[{label:h.t("fontSizes.small"),value:"87.5%"},{label:h.t("fontSizes.normal"),value:"100%"},{label:h.t("fontSizes.large"),value:"125%"},{label:h.t("fontSizes.xlarge"),value:"150%"}]);this.styleDialog.appendChild(t);let i=this.createStyleSelectControl(h.t("captions.fontFamily"),"fontFamily",[{label:h.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:h.t("fontFamilies.serif"),value:"serif"},{label:h.t("fontFamilies.monospace"),value:"monospace"}]);this.styleDialog.appendChild(i);let s=this.createStyleColorControl(h.t("captions.color"),"color");this.styleDialog.appendChild(s);let a=this.createStyleColorControl(h.t("captions.backgroundColor"),"backgroundColor");this.styleDialog.appendChild(a);let r=this.createStyleOpacityControl(h.t("captions.opacity"),"opacity");this.styleDialog.appendChild(r);let o=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-style-close`,textContent:h.t("settings.close"),attributes:{type:"button"}});o.addEventListener("click",()=>this.hideStyleDialog()),this.styleDialog.appendChild(o),this.handlers.styleDialogKeydown=n=>{n.key==="Escape"&&(n.preventDefault(),n.stopPropagation(),this.hideStyleDialog())},this.styleDialog.addEventListener("keydown",this.handlers.styleDialogKeydown),this.headerLeft?this.headerLeft.appendChild(this.styleDialog):this.transcriptHeader.appendChild(this.styleDialog),this.applyTranscriptStyles(),this.styleDialogVisible=!0,this.styleDialog.style.display="block",this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let n=this.styleDialog.querySelector("select, input");n&&n.focus()},0)}hideStyleDialog(){this.styleDialog&&(this.styleDialog.style.display="none",this.styleDialogVisible=!1,this.settingsButton&&this.settingsButton.focus())}createStyleSelectControl(e,t,i){let s=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=l.createElement("label",{textContent:e});s.appendChild(a);let r=l.createElement("select",{className:`${this.player.options.classPrefix}-transcript-style-select`});return i.forEach(o=>{let n=l.createElement("option",{textContent:o.label,attributes:{value:o.value}});this.transcriptStyle[t]===o.value&&(n.selected=!0),r.appendChild(n)}),r.addEventListener("change",o=>{this.transcriptStyle[t]=o.target.value,this.applyTranscriptStyles(),this.savePreferences()}),s.appendChild(r),s}createStyleColorControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),s=l.createElement("label",{textContent:e});i.appendChild(s);let a=l.createElement("input",{attributes:{type:"color",value:this.transcriptStyle[t]},className:`${this.player.options.classPrefix}-transcript-style-color`});return a.addEventListener("input",r=>{this.transcriptStyle[t]=r.target.value,this.applyTranscriptStyles(),this.savePreferences()}),i.appendChild(a),i}createStyleOpacityControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),s=l.createElement("label",{textContent:e});i.appendChild(s);let a=l.createElement("span",{textContent:Math.round(this.transcriptStyle[t]*100)+"%",className:`${this.player.options.classPrefix}-transcript-style-value`}),r=l.createElement("input",{attributes:{type:"range",min:"0",max:"1",step:"0.1",value:String(this.transcriptStyle[t])},className:`${this.player.options.classPrefix}-transcript-style-range`});r.addEventListener("input",n=>{let c=parseFloat(n.target.value);this.transcriptStyle[t]=c,a.textContent=Math.round(c*100)+"%",this.applyTranscriptStyles(),this.savePreferences()});let o=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-range-container`});return o.appendChild(r),o.appendChild(a),i.appendChild(s),i.appendChild(o),i}savePreferences(){this.storage.saveTranscriptPreferences(this.transcriptStyle)}applyTranscriptStyles(){if(!this.transcriptWindow)return;this.transcriptWindow.style.backgroundColor=this.transcriptStyle.backgroundColor,this.transcriptWindow.style.opacity=String(this.transcriptStyle.opacity),this.transcriptContent&&(this.transcriptContent.style.fontSize=this.transcriptStyle.fontSize,this.transcriptContent.style.fontFamily=this.transcriptStyle.fontFamily,this.transcriptContent.style.color=this.transcriptStyle.color),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-text`).forEach(i=>{i.style.fontSize=this.transcriptStyle.fontSize,i.style.fontFamily=this.transcriptStyle.fontFamily,i.style.color=this.transcriptStyle.color}),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(i=>{i.style.fontFamily=this.transcriptStyle.fontFamily})}setManagedTimeout(e,t){let i=setTimeout(()=>{this.timeouts.delete(i),e()},t);return this.timeouts.add(i),i}clearManagedTimeout(e){e&&(clearTimeout(e),this.timeouts.delete(e))}destroy(){this.resizeEnabled&&this.disableResizeHandles(),this.keyboardDragMode&&this.disableKeyboardDragMode(),this.handlers.timeupdate&&this.player.off("timeupdate",this.handlers.timeupdate),this.transcriptHeader&&(this.handlers.mousedown&&this.transcriptHeader.removeEventListener("mousedown",this.handlers.mousedown),this.handlers.touchstart&&this.transcriptHeader.removeEventListener("touchstart",this.handlers.touchstart),this.handlers.keydown&&this.transcriptHeader.removeEventListener("keydown",this.handlers.keydown)),this.settingsButton&&(this.handlers.settingsClick&&this.settingsButton.removeEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown&&this.settingsButton.removeEventListener("keydown",this.handlers.settingsKeydown)),this.styleDialog&&this.handlers.styleDialogKeydown&&this.styleDialog.removeEventListener("keydown",this.handlers.styleDialogKeydown),this.handlers.mousemove&&document.removeEventListener("mousemove",this.handlers.mousemove),this.handlers.mouseup&&document.removeEventListener("mouseup",this.handlers.mouseup),this.handlers.touchmove&&document.removeEventListener("touchmove",this.handlers.touchmove),this.handlers.touchend&&document.removeEventListener("touchend",this.handlers.touchend),this.handlers.documentClick&&document.removeEventListener("click",this.handlers.documentClick),this.handlers.resize&&window.removeEventListener("resize",this.handlers.resize),this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts.clear(),this.handlers=null,this.transcriptWindow&&this.transcriptWindow.parentNode&&this.transcriptWindow.parentNode.removeChild(this.transcriptWindow),this.transcriptWindow=null,this.transcriptHeader=null,this.transcriptContent=null,this.transcriptEntries=[],this.settingsMenu=null,this.styleDialog=null}};_();var F=class{constructor(e){this.player=e,this.youtube=null,this.videoId=null,this.isReady=!1,this.iframe=null}async init(){if(this.videoId=this.extractVideoId(this.player.element.src),!this.videoId)throw new Error("Invalid YouTube URL");await this.loadYouTubeAPI(),this.createIframe(),await this.initializePlayer()}extractVideoId(e){let t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\s]+)/,/youtube\.com\/embed\/([^&\s]+)/];for(let i of t){let s=e.match(i);if(s&&s[1])return s[1]}return null}async loadYouTubeAPI(){return window.YT&&window.YT.Player?Promise.resolve():new Promise((e,t)=>{if(window.onYouTubeIframeAPIReady){let a=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{a(),e()};return}let i=document.createElement("script");i.src="https://www.youtube.com/iframe_api",window.onYouTubeIframeAPIReady=()=>{e()},i.onerror=()=>t(new Error("Failed to load YouTube API"));let s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(i,s)})}createIframe(){this.player.element.style.display="none",this.iframe=document.createElement("div"),this.iframe.id=`youtube-player-${Math.random().toString(36).substr(2,9)}`,this.iframe.style.width="100%",this.iframe.style.height="100%",this.player.element.parentNode.insertBefore(this.iframe,this.player.element)}async initializePlayer(){return new Promise(e=>{this.youtube=new window.YT.Player(this.iframe.id,{videoId:this.videoId,width:"100%",height:"100%",playerVars:{controls:0,disablekb:1,fs:0,modestbranding:1,rel:0,showinfo:0,iv_load_policy:3,autoplay:this.player.options.autoplay?1:0,mute:this.player.options.muted?1:0,start:this.player.options.startTime||0},events:{onReady:t=>{this.isReady=!0,this.attachEvents(),e()},onStateChange:t=>this.handleStateChange(t),onError:t=>this.handleError(t)}})})}attachEvents(){this.timeUpdateInterval=setInterval(()=>{if(this.isReady&&this.youtube){let e=this.youtube.getCurrentTime(),t=this.youtube.getDuration();this.player.state.currentTime=e,this.player.state.duration=t,this.player.emit("timeupdate",e)}},250),this.youtube.getDuration&&(this.player.state.duration=this.youtube.getDuration(),this.player.emit("loadedmetadata"))}handleStateChange(e){let t=window.YT.PlayerState;switch(e.data){case t.PLAYING:this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.state.buffering=!1,this.player.emit("play"),this.player.emit("playing"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player);break;case t.PAUSED:this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player);break;case t.ENDED:this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.youtube.seekTo(0),this.youtube.playVideo());break;case t.BUFFERING:this.player.state.buffering=!0,this.player.emit("waiting");break;case t.CUED:this.player.emit("loadedmetadata");break}}handleError(e){let t={2:"Invalid video ID",5:"HTML5 player error",100:"Video not found",101:"Video not allowed to be played in embedded players",150:"Video not allowed to be played in embedded players"},i=new Error(t[e.data]||"YouTube player error");this.player.handleError(i)}play(){this.isReady&&this.youtube&&this.youtube.playVideo()}pause(){this.isReady&&this.youtube&&this.youtube.pauseVideo()}seek(e){this.isReady&&this.youtube&&this.youtube.seekTo(e,!0)}setVolume(e){this.isReady&&this.youtube&&(this.youtube.setVolume(e*100),this.player.state.volume=e)}setMuted(e){this.isReady&&this.youtube&&(e?this.youtube.mute():this.youtube.unMute(),this.player.state.muted=e)}setPlaybackSpeed(e){this.isReady&&this.youtube&&(this.youtube.setPlaybackRate(e),this.player.state.playbackSpeed=e)}destroy(){this.timeUpdateInterval&&clearInterval(this.timeUpdateInterval),this.youtube&&this.youtube.destroy&&this.youtube.destroy(),this.iframe&&this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.player.element&&(this.player.element.style.display="")}};var O=class{constructor(e){this.player=e,this.vimeo=null,this.videoId=null,this.isReady=!1,this.iframe=null}async init(){if(this.videoId=this.extractVideoId(this.player.element.src),!this.videoId)throw new Error("Invalid Vimeo URL");await this.loadVimeoAPI(),this.createIframe(),await this.initializePlayer()}extractVideoId(e){let t=[/vimeo\.com\/(\d+)/,/vimeo\.com\/video\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/];for(let i of t){let s=e.match(i);if(s&&s[1])return s[1]}return null}async loadVimeoAPI(){return window.Vimeo&&window.Vimeo.Player?Promise.resolve():new Promise((e,t)=>{let i=document.createElement("script");i.src="https://player.vimeo.com/api/player.js",i.onload=()=>e(),i.onerror=()=>t(new Error("Failed to load Vimeo API")),document.head.appendChild(i)})}createIframe(){this.player.element.style.display="none",this.iframe=document.createElement("div"),this.iframe.id=`vimeo-player-${Math.random().toString(36).substr(2,9)}`,this.iframe.style.width="100%",this.iframe.style.height="100%",this.player.element.parentNode.insertBefore(this.iframe,this.player.element)}async initializePlayer(){let e={id:this.videoId,width:"100%",height:"100%",controls:!1,autoplay:this.player.options.autoplay,muted:this.player.options.muted,loop:this.player.options.loop,keyboard:!1};this.player.options.startTime>0&&(e.startTime=this.player.options.startTime),this.vimeo=new window.Vimeo.Player(this.iframe.id,e),await this.vimeo.ready(),this.isReady=!0,this.attachEvents();try{let t=await this.vimeo.getDuration();this.player.state.duration=t,this.player.emit("loadedmetadata")}catch(t){this.player.log("Error getting duration:",t,"warn")}}attachEvents(){this.vimeo.on("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)}),this.vimeo.on("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.vimeo.on("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player)}),this.vimeo.on("timeupdate",e=>{this.player.state.currentTime=e.seconds,this.player.state.duration=e.duration,this.player.emit("timeupdate",e.seconds),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,e.seconds)}),this.vimeo.on("volumechange",e=>{this.player.state.volume=e.volume,this.player.emit("volumechange",e.volume)}),this.vimeo.on("bufferstart",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.vimeo.on("bufferend",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.vimeo.on("seeking",()=>{this.player.state.seeking=!0,this.player.emit("seeking")}),this.vimeo.on("seeked",()=>{this.player.state.seeking=!1,this.player.emit("seeked")}),this.vimeo.on("playbackratechange",e=>{this.player.state.playbackSpeed=e.playbackRate,this.player.emit("ratechange",e.playbackRate)}),this.vimeo.on("error",e=>{this.player.handleError(new Error(`Vimeo error: ${e.message}`))})}play(){this.isReady&&this.vimeo&&this.vimeo.play().catch(e=>{this.player.log("Play error:",e,"warn")})}pause(){this.isReady&&this.vimeo&&this.vimeo.pause().catch(e=>{this.player.log("Pause error:",e,"warn")})}seek(e){this.isReady&&this.vimeo&&this.vimeo.setCurrentTime(e).catch(t=>{this.player.log("Seek error:",t,"warn")})}setVolume(e){this.isReady&&this.vimeo&&(this.vimeo.setVolume(e).catch(t=>{this.player.log("Volume error:",t,"warn")}),this.player.state.volume=e)}setMuted(e){this.isReady&&this.vimeo&&(e?this.vimeo.setVolume(0):this.vimeo.setVolume(this.player.state.volume),this.player.state.muted=e)}setPlaybackSpeed(e){this.isReady&&this.vimeo&&(this.vimeo.setPlaybackRate(e).catch(t=>{this.player.log("Playback rate error:",t,"warn")}),this.player.state.playbackSpeed=e)}destroy(){this.vimeo&&this.vimeo.destroy&&this.vimeo.destroy(),this.iframe&&this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.player.element&&(this.player.element.style.display="")}};var I=class{constructor(e){this.player=e,this.media=e.element,this.hls=null}async init(){this.canPlayNatively()?(this.player.log("Using native HLS support"),await this.initNative()):(this.player.log("Using hls.js for HLS support"),await this.initHlsJs())}canPlayNatively(){return document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}async initNative(){let e=(await Promise.resolve().then(()=>(_(),J))).HTML5Renderer,t=new e(this.player);await t.init(),Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(i=>{i!=="constructor"&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))})}async initHlsJs(){if(this.media.controls=!1,this.media.removeAttribute("controls"),window.Hls||await this.loadHlsJs(),!window.Hls.isSupported())throw new Error("HLS is not supported in this browser");this.hls=new window.Hls({debug:this.player.options.debug,enableWorker:!0,lowLatencyMode:!1,backBufferLength:90,maxBufferLength:30,maxMaxBufferLength:600,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:4,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3}),this.hls.attachMedia(this.media);let e,t=this.player.element.querySelector("source");if(t?e=t.getAttribute("src"):e=this.player.element.getAttribute("src")||this.player.element.src,this.player.log(`Loading HLS source: ${e}`,"log"),!e)throw new Error("No HLS source found");this.hls.loadSource(e),this.attachHlsEvents(),this.attachMediaEvents()}async loadHlsJs(){return new Promise((e,t)=>{let i=document.createElement("script");i.src="https://cdn.jsdelivr.net/npm/hls.js@latest",i.onload=()=>e(),i.onerror=()=>t(new Error("Failed to load hls.js")),document.head.appendChild(i)})}attachHlsEvents(){this.hls.on(window.Hls.Events.MANIFEST_PARSED,(e,t)=>{this.player.log("HLS manifest loaded, found "+t.levels.length+" quality levels"),this.player.emit("hlsmanifestparsed",t)}),this.hls.on(window.Hls.Events.LEVEL_SWITCHED,(e,t)=>{this.player.log("HLS level switched to "+t.level),this.player.emit("hlslevelswitched",t)}),this.hls.on(window.Hls.Events.ERROR,(e,t)=>{this.handleHlsError(t)}),this.hls.on(window.Hls.Events.FRAG_BUFFERED,()=>{this.player.state.buffering=!1})}attachMediaEvents(){this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume)}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.media.addEventListener("error",()=>{this.player.handleError(this.media.error)})}handleHlsError(e){if(this.player.log(`HLS Error - Type: ${e.type}, Details: ${e.details}, Fatal: ${e.fatal}`,"warn"),e.response&&this.player.log(`Response code: ${e.response.code}, URL: ${e.response.url}`,"warn"),e.fatal)switch(e.type){case window.Hls.ErrorTypes.NETWORK_ERROR:this.player.log("Fatal network error, trying to recover...","error"),this.player.log(`Network error details: ${e.details}`,"error"),setTimeout(()=>{this.hls.startLoad()},1e3);break;case window.Hls.ErrorTypes.MEDIA_ERROR:this.player.log("Fatal media error, trying to recover...","error"),this.hls.recoverMediaError();break;default:this.player.log("Fatal error, cannot recover","error"),this.player.handleError(new Error(`HLS Error: ${e.type} - ${e.details}`)),this.hls.destroy();break}else this.player.log("Non-fatal HLS error: "+e.details,"warn")}play(){let e=this.media.play();e!==void 0&&e.catch(t=>{this.player.log("Play failed:",t,"warn")})}pause(){this.media.pause()}seek(e){this.media.currentTime=e}setVolume(e){this.media.volume=e}setMuted(e){this.media.muted=e}setPlaybackSpeed(e){this.media.playbackRate=e}switchQuality(e){this.hls&&(this.hls.currentLevel=e)}getQualities(){return this.hls&&this.hls.levels?this.hls.levels.map((e,t)=>({index:t,height:e.height,width:e.width,bitrate:e.bitrate,name:`${e.height}p`})):[]}destroy(){this.hls&&(this.hls.destroy(),this.hls=null)}};var z=class d extends W{constructor(e,t={}){if(super(),this.element=typeof e=="string"?document.querySelector(e):e,!this.element)throw new Error("VidPly: Element not found");if(this.element.tagName!=="VIDEO"&&this.element.tagName!=="AUDIO"){let s=t.mediaType||"video",a=document.createElement(s);Array.from(this.element.attributes).forEach(o=>{o.name!=="id"&&o.name!=="class"&&!o.name.startsWith("data-")&&a.setAttribute(o.name,o.value)}),this.element.querySelectorAll("track").forEach(o=>{a.appendChild(o.cloneNode(!0))}),this.element.innerHTML="",this.element.appendChild(a),this.element=a}this.options={width:null,height:null,poster:null,responsive:!0,fillContainer:!1,autoplay:!1,loop:!1,muted:!1,volume:.8,playbackSpeed:1,preload:"metadata",startTime:0,playsInline:!0,controls:!0,hideControlsDelay:3e3,playPauseButton:!0,progressBar:!0,currentTime:!0,duration:!0,volumeControl:!0,muteButton:!0,chaptersButton:!0,qualityButton:!0,captionStyleButton:!0,speedButton:!0,captionsButton:!0,transcriptButton:!0,fullscreenButton:!0,pipButton:!1,seekInterval:10,seekIntervalLarge:30,captions:!0,captionsDefault:!1,captionsFontSize:"100%",captionsFontFamily:"sans-serif",captionsColor:"#FFFFFF",captionsBackgroundColor:"#000000",captionsOpacity:.8,audioDescription:!0,audioDescriptionSrc:null,audioDescriptionButton:!0,signLanguage:!0,signLanguageSrc:null,signLanguageButton:!0,signLanguagePosition:"bottom-right",transcript:!1,transcriptPosition:"external",transcriptContainer:null,keyboard:!0,keyboardShortcuts:{"play-pause":[" ","p","k"],"volume-up":["ArrowUp"],"volume-down":["ArrowDown"],"seek-forward":["ArrowRight"],"seek-backward":["ArrowLeft"],mute:["m"],fullscreen:["f"],captions:["c"],"caption-style-menu":["a"],"speed-up":[">"],"speed-down":["<"],"speed-menu":["s"],"quality-menu":["q"],"chapters-menu":["j"],"transcript-toggle":["t"]},ariaLabels:{},screenReaderAnnouncements:!0,highContrast:!1,focusHighlight:!0,metadataAlerts:{},metadataHashtags:{},language:"en",languages:["en"],debug:!1,classPrefix:"vidply",iconType:"svg",pauseOthersOnPlay:!0,onReady:null,onPlay:null,onPause:null,onEnded:null,onTimeUpdate:null,onVolumeChange:null,onError:null,...t},this.options.metadataAlerts=this.options.metadataAlerts||{},this.options.metadataHashtags=this.options.metadataHashtags||{},this.storage=new D("vidply");let i=this.storage.getPlayerPreferences();i&&(i.volume!==void 0&&(this.options.volume=i.volume),i.playbackSpeed!==void 0&&(this.options.playbackSpeed=i.playbackSpeed),i.muted!==void 0&&(this.options.muted=i.muted)),this.state={ready:!1,playing:!1,paused:!0,ended:!1,buffering:!1,seeking:!1,muted:this.options.muted,volume:this.options.volume,currentTime:0,duration:0,playbackSpeed:this.options.playbackSpeed,fullscreen:!1,pip:!1,captionsEnabled:this.options.captionsDefault,currentCaption:null,controlsVisible:!0,audioDescriptionEnabled:!1,signLanguageEnabled:!1},this.originalSrc=null,this.audioDescriptionSrc=this.options.audioDescriptionSrc,this.signLanguageSrc=this.options.signLanguageSrc,this.signLanguageVideo=null,this.audioDescriptionSourceElement=null,this.originalAudioDescriptionSource=null,this.audioDescriptionCaptionTracks=[],this._textTracksCache=null,this._textTracksDirty=!0,this._sourceElementsCache=null,this._sourceElementsDirty=!0,this._trackElementsCache=null,this._trackElementsDirty=!0,this.timeouts=new Set,this.container=null,this.renderer=null,this.controlBar=null,this.captionManager=null,this.keyboardManager=null,this.settingsDialog=null,this.metadataCueChangeHandler=null,this.metadataAlertHandlers=new Map,this.init()}async init(){var e;try{if(this.log("Initializing VidPly player"),!this.options.language||this.options.language==="en"){let i=this.detectHtmlLanguage();i&&(this.options.language=i,this.log(`Auto-detected language from HTML: ${i}`))}h.setLanguage(this.options.language),this.createContainer(),this.element.src||((e=this.element.querySelector("source"))==null?void 0:e.src)?await this.initializeRenderer():this.log("No initial source - waiting for playlist or manual load"),this.options.controls&&(this.controlBar=new N(this),this.videoWrapper.appendChild(this.controlBar.element)),this.options.captions&&(this.captionManager=new $(this)),(this.options.transcript||this.options.transcriptButton)&&(this.transcriptManager=new B(this)),this.setupMetadataHandling(),this.options.keyboard&&(this.keyboardManager=new R(this)),this.setupResponsiveHandlers(),this.options.startTime>0&&this.seek(this.options.startTime),this.options.muted&&this.mute(),this.options.volume!==.8&&this.setVolume(this.options.volume),this.state.ready=!0,this.emit("ready"),this.options.onReady&&this.options.onReady.call(this),this.options.autoplay&&this.play(),this.log("Player initialized successfully")}catch(t){this.handleError(t)}}detectHtmlLanguage(){let e=document.documentElement.lang||document.documentElement.getAttribute("lang");if(!e)return null;let t=e.toLowerCase().split("-")[0];return["en","de","es","fr","ja"].includes(t)?t:(this.log(`Language "${e}" not available, using English as fallback`),"en")}createContainer(){this.container=l.createElement("div",{className:`${this.options.classPrefix}-player`,attributes:{role:"region","aria-label":h.t("player.label"),tabindex:"0"}});let e=this.element.tagName.toLowerCase();this.container.classList.add(`${this.options.classPrefix}-${e}`),this.options.responsive&&this.container.classList.add(`${this.options.classPrefix}-responsive`),this.videoWrapper=l.createElement("div",{className:`${this.options.classPrefix}-video-wrapper`}),this.element.parentNode.insertBefore(this.container,this.element),this.container.appendChild(this.videoWrapper),this.videoWrapper.appendChild(this.element),this.element.controls=!1,this.element.removeAttribute("controls"),this.element.setAttribute("tabindex","-1"),this.element.style.width="100%",this.element.style.height="100%",this.element.tagName==="VIDEO"&&this.options.playsInline&&(this.element.setAttribute("playsinline",""),this.element.setAttribute("webkit-playsinline",""),this.element.playsInline=!0),this.options.width&&(this.container.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width),this.options.height&&(this.container.style.height=typeof this.options.height=="number"?`${this.options.height}px`:this.options.height),this.options.poster&&this.element.tagName==="VIDEO"&&(this.element.poster=this.options.poster),this.element.tagName==="VIDEO"&&this.createPlayButtonOverlay(),this.element.vidply=this,d.instances.push(this),this.element.style.cursor="pointer",this.element.addEventListener("click",t=>{t.target===this.element&&this.toggle()})}createPlayButtonOverlay(){this.playButtonOverlay=G(),this.playButtonOverlay.addEventListener("click",()=>{this.toggle()}),this.videoWrapper.appendChild(this.playButtonOverlay),this.on("play",()=>{this.playButtonOverlay.style.opacity="0",this.playButtonOverlay.style.pointerEvents="none"}),this.on("pause",()=>{this.playButtonOverlay.style.opacity="1",this.playButtonOverlay.style.pointerEvents="auto"}),this.on("ended",()=>{this.playButtonOverlay.style.opacity="1",this.playButtonOverlay.style.pointerEvents="auto"})}async initializeRenderer(){var a;let e=this.element.src||((a=this.element.querySelector("source"))==null?void 0:a.src);if(!e)throw new Error("No media source found");let t=this.sourceElements;for(let r of t){let o=r.getAttribute("data-desc-src"),n=r.getAttribute("data-orig-src");if(o||n){if(this.audioDescriptionSourceElement||(this.audioDescriptionSourceElement=r),n)this.originalAudioDescriptionSource||(this.originalAudioDescriptionSource=n),this.originalSrc||(this.originalSrc=n);else{let c=r.getAttribute("src");!this.originalAudioDescriptionSource&&c&&(this.originalAudioDescriptionSource=c),!this.originalSrc&&c&&(this.originalSrc=c)}o&&!this.audioDescriptionSrc&&(this.audioDescriptionSrc=o)}}this.trackElements.forEach(r=>{let o=r.getAttribute("kind"),n=r.getAttribute("data-desc-src");(o==="captions"||o==="subtitles"||o==="chapters")&&n&&(this.audioDescriptionCaptionTracks.push({trackElement:r,originalSrc:r.getAttribute("src"),describedSrc:n,originalTrackSrc:r.getAttribute("data-orig-src")||r.getAttribute("src"),explicit:!0}),this.log(`Found explicit described ${o} track: ${r.getAttribute("src")} -> ${n}`))}),this.originalSrc||(this.originalSrc=e);let s;e.includes("youtube.com")||e.includes("youtu.be")?s=F:e.includes("vimeo.com")?s=O:e.includes(".m3u8")?s=I:s=V,this.log(`Using ${s.name} renderer`),this.renderer=new s(this),await this.renderer.init(),this.invalidateTrackCache()}get textTracks(){return(!this._textTracksCache||this._textTracksDirty)&&(this._textTracksCache=Array.from(this.element.textTracks||[]),this._textTracksDirty=!1),this._textTracksCache}get sourceElements(){return(!this._sourceElementsCache||this._sourceElementsDirty)&&(this._sourceElementsCache=Array.from(this.element.querySelectorAll("source")),this._sourceElementsDirty=!1),this._sourceElementsCache}get trackElements(){return(!this._trackElementsCache||this._trackElementsDirty)&&(this._trackElementsCache=Array.from(this.element.querySelectorAll("track")),this._trackElementsDirty=!1),this._trackElementsCache}invalidateTrackCache(){this._textTracksDirty=!0,this._trackElementsDirty=!0,this._sourceElementsDirty=!0}findTextTrack(e,t=null){let i=this.textTracks;return t?i.find(s=>s.kind===e&&s.language===t):i.find(s=>s.kind===e)}findSourceElement(e,t=null){let i=this.sourceElements;return t?i.find(s=>s.getAttribute(e)===t):i.find(s=>s.hasAttribute(e))}findTrackElement(e){return this.trackElements.find(t=>t.track===e)}setManagedTimeout(e,t){let i=setTimeout(()=>{this.timeouts.delete(i),e()},t);return this.timeouts.add(i),i}clearManagedTimeout(e){e&&(clearTimeout(e),this.timeouts.delete(e))}async load(e){try{this.log("Loading new media:",e.src),this.renderer&&this.pause(),this.trackElements.forEach(s=>s.remove()),this.invalidateTrackCache(),this.element.src=e.src,e.type&&(this.element.type=e.type),e.poster&&this.element.tagName==="VIDEO"&&(this.element.poster=e.poster),e.tracks&&e.tracks.length>0&&(e.tracks.forEach(s=>{let a=document.createElement("track");a.src=s.src,a.kind=s.kind||"captions",a.srclang=s.srclang||"en",a.label=s.label||s.srclang,s.default&&(a.default=!0),this.element.appendChild(a)}),this.invalidateTrackCache());let i=this.shouldChangeRenderer(e.src);if(i&&this.renderer&&(this.renderer.destroy(),this.renderer=null),!this.renderer||i?await this.initializeRenderer():(this.renderer.media=this.element,this.element.load()),this.captionManager&&(this.captionManager.destroy(),this.captionManager=new $(this)),this.transcriptManager){let s=this.transcriptManager.isVisible;this.transcriptManager.destroy(),this.transcriptManager=new B(this),s&&this.transcriptManager.showTranscript()}this.controlBar&&this.updateControlBar(),this.emit("sourcechange",e),this.log("Media loaded successfully")}catch(t){this.handleError(t)}}updateControlBar(){if(!this.controlBar)return;let e=this.controlBar;e.element.innerHTML="",e.createControls(),e.attachEvents(),e.setupAutoHide()}shouldChangeRenderer(e){if(!this.renderer)return!0;let t=e.includes("youtube.com")||e.includes("youtu.be"),i=e.includes("vimeo.com"),s=e.includes(".m3u8"),a=this.renderer.constructor.name;return!!(t&&a!=="YouTubeRenderer"||i&&a!=="VimeoRenderer"||s&&a!=="HLSRenderer"||!t&&!i&&!s&&a!=="HTML5Renderer")}play(){this.renderer&&this.renderer.play()}pause(){this.renderer&&this.renderer.pause()}stop(){this.pause(),this.seek(0)}toggle(){this.state.playing?this.pause():this.play()}seek(e){this.renderer&&this.renderer.seek(e)}seekForward(e=this.options.seekInterval){this.seek(Math.min(this.state.currentTime+e,this.state.duration))}seekBackward(e=this.options.seekInterval){this.seek(Math.max(this.state.currentTime-e,0))}setVolume(e){let t=Math.max(0,Math.min(1,e));this.renderer&&this.renderer.setVolume(t),this.state.volume=t,t>0&&this.state.muted&&(this.state.muted=!1),this.savePlayerPreferences()}getVolume(){return this.state.volume}mute(){this.renderer&&this.renderer.setMuted(!0),this.state.muted=!0,this.savePlayerPreferences(),this.emit("volumechange")}unmute(){this.renderer&&this.renderer.setMuted(!1),this.state.muted=!1,this.savePlayerPreferences(),this.emit("volumechange")}toggleMute(){this.state.muted?this.unmute():this.mute()}setPlaybackSpeed(e){let t=Math.max(.25,Math.min(2,e));this.renderer&&this.renderer.setPlaybackSpeed(t),this.state.playbackSpeed=t,this.savePlayerPreferences(),this.emit("playbackspeedchange",t)}getPlaybackSpeed(){return this.state.playbackSpeed}savePlayerPreferences(){this.storage.savePlayerPreferences({volume:this.state.volume,muted:this.state.muted,playbackSpeed:this.state.playbackSpeed})}enterFullscreen(){let e=this.container;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen(),this.state.fullscreen=!0,this.container.classList.add(`${this.options.classPrefix}-fullscreen`),this.emit("fullscreenchange",!0)}exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),this.state.fullscreen=!1,this.container.classList.remove(`${this.options.classPrefix}-fullscreen`),this.emit("fullscreenchange",!1)}toggleFullscreen(){this.state.fullscreen?this.exitFullscreen():this.enterFullscreen()}enterPiP(){this.element.requestPictureInPicture&&(this.element.requestPictureInPicture(),this.state.pip=!0,this.emit("pipchange",!0))}exitPiP(){document.pictureInPictureElement&&(document.exitPictureInPicture(),this.state.pip=!1,this.emit("pipchange",!1))}togglePiP(){this.state.pip?this.exitPiP():this.enterPiP()}enableCaptions(){this.captionManager&&(this.captionManager.enable(),this.state.captionsEnabled=!0)}disableCaptions(){this.captionManager&&(this.captionManager.disable(),this.state.captionsEnabled=!1)}toggleCaptions(){this.state.captionsEnabled?this.disableCaptions():this.enableCaptions()}async validateTrackExists(e){try{return(await fetch(e,{method:"HEAD",cache:"no-cache"})).ok}catch{return!1}}async enableAudioDescription(){let e=this.sourceElements.some(r=>r.getAttribute("data-desc-src")),t=this.audioDescriptionCaptionTracks.length>0;if(!this.audioDescriptionSrc&&!e&&!t){console.warn("VidPly: No audio description source, source elements, or tracks provided");return}let i=this.state.currentTime,s=this.state.playing,a=[];if(this.audioDescriptionSourceElement){let r=this.element.currentSrc||this.element.src,o=this.sourceElements,n=null,c=this.audioDescriptionSrc;for(let m of o){let p=m.getAttribute("src"),w=m.getAttribute("data-desc-src"),v=p?p.split("/").pop():"",E=r?r.split("/").pop():"";if(r&&(r===p||r.includes(p)||r.includes(v)||v&&E===v)){n=m,w?c=w:p&&(c=this.audioDescriptionSrc||c);break}}if(!n){n=this.audioDescriptionSourceElement;let m=n.getAttribute("data-desc-src");m&&(c=m)}if(this.audioDescriptionCaptionTracks.length>0){let m=this.audioDescriptionCaptionTracks.map(async v=>{if(v.trackElement&&v.describedSrc)if(v.explicit===!0)try{let E=await this.validateTrackExists(v.describedSrc);return{trackInfo:v,exists:E}}catch{return{trackInfo:v,exists:!1}}else return{trackInfo:v,exists:!1};return{trackInfo:v,exists:!1}}),p=await Promise.all(m),w=p.filter(v=>v.exists);if(w.length>0){let v=new Map;w.forEach(({trackInfo:g})=>{let f=g.trackElement.track;f?v.set(g,{wasShowing:f.mode==="showing",wasHidden:f.mode==="hidden"}):v.set(g,{wasShowing:!1,wasHidden:!1})});let E=w.map(({trackInfo:g})=>{let f=g.trackElement.getAttribute("src"),T=g.trackElement.parentNode,k=g.trackElement.nextSibling,C={};return Array.from(g.trackElement.attributes).forEach(x=>{C[x.name]=x.value}),{trackInfo:g,oldSrc:f,parent:T,nextSibling:k,attributes:C}});E.forEach(({trackInfo:g})=>{g.trackElement.remove()}),this.element.load(),setTimeout(()=>{E.forEach(({trackInfo:f,oldSrc:T,parent:k,nextSibling:C,attributes:x})=>{a.push(f);let M=document.createElement("track");M.setAttribute("src",f.describedSrc),Object.keys(x).forEach(L=>{L!=="src"&&L!=="data-desc-src"&&M.setAttribute(L,x[L])}),C&&C.parentNode?k.insertBefore(M,C):k.appendChild(M),f.trackElement=M}),this.element.load(),this.invalidateTrackCache();let g=()=>{this.setManagedTimeout(()=>{a.forEach(f=>{let k=f.trackElement.track;if(k){let C=v.get(f)||{wasShowing:!1,wasHidden:!1};k.mode="hidden";let x=()=>{C.wasShowing||C.wasHidden?k.mode="hidden":k.mode="disabled"};k.readyState>=2?x():(k.addEventListener("load",x,{once:!0}),k.addEventListener("error",x,{once:!0}))}})},300)};this.element.readyState>=1?setTimeout(g,200):(this.element.addEventListener("loadedmetadata",g,{once:!0}),setTimeout(g,2e3))},100);let S=p.length-w.length}}let u=this.sourceElements,y=[];u.forEach(m=>{let p=m.getAttribute("data-desc-src"),w=m.getAttribute("src");if(p){let v=m.getAttribute("type"),E=m.getAttribute("data-orig-src");E||(E=w),y.push({src:p,type:v,origSrc:E,descSrc:p})}else{let v=m.getAttribute("type"),E=m.getAttribute("src");y.push({src:E,type:v,origSrc:null,descSrc:null})}}),u.forEach(m=>{m.remove()}),y.forEach(m=>{let p=document.createElement("source");p.setAttribute("src",m.src),m.type&&p.setAttribute("type",m.type),m.origSrc&&p.setAttribute("data-orig-src",m.origSrc),m.descSrc&&p.setAttribute("data-desc-src",m.descSrc),this.element.appendChild(p)}),this.element.load(),await new Promise(m=>{let p=()=>{this.element.removeEventListener("loadedmetadata",p),m()};this.element.addEventListener("loadedmetadata",p)}),await new Promise(m=>setTimeout(m,300)),this.element.tagName==="VIDEO"&&i===0&&!s&&this.element.readyState>=1&&(this.element.currentTime=.001,setTimeout(()=>{this.element.currentTime=0},10)),this.seek(i),s&&this.play(),this.state.audioDescriptionEnabled=!0,this.emit("audiodescriptionenabled")}else{if(this.audioDescriptionCaptionTracks.length>0){let n=this.audioDescriptionCaptionTracks.map(async y=>{if(y.trackElement&&y.describedSrc)if(y.explicit===!0)try{let m=await this.validateTrackExists(y.describedSrc);return{trackInfo:y,exists:m}}catch{return{trackInfo:y,exists:!1}}else return{trackInfo:y,exists:!1};return{trackInfo:y,exists:!1}}),u=(await Promise.all(n)).filter(y=>y.exists);if(u.length>0){let y=new Map;u.forEach(({trackInfo:p})=>{let w=p.trackElement.track;w?y.set(p,{wasShowing:w.mode==="showing",wasHidden:w.mode==="hidden"}):y.set(p,{wasShowing:!1,wasHidden:!1})});let m=u.map(({trackInfo:p})=>{let w=p.trackElement.getAttribute("src"),v=p.trackElement.parentNode,E=p.trackElement.nextSibling,S={};return Array.from(p.trackElement.attributes).forEach(g=>{S[g.name]=g.value}),{trackInfo:p,oldSrc:w,parent:v,nextSibling:E,attributes:S}});m.forEach(({trackInfo:p})=>{p.trackElement.remove()}),this.element.load(),setTimeout(()=>{m.forEach(({trackInfo:w,oldSrc:v,parent:E,nextSibling:S,attributes:g})=>{a.push(w);let f=document.createElement("track");f.setAttribute("src",w.describedSrc),Object.keys(g).forEach(T=>{T!=="src"&&T!=="data-desc-src"&&f.setAttribute(T,g[T])}),S&&S.parentNode?E.insertBefore(f,S):E.appendChild(f),w.trackElement=f}),this.element.load();let p=()=>{setTimeout(()=>{a.forEach(w=>{let E=w.trackElement.track;if(E){let S=y.get(w)||{wasShowing:!1,wasHidden:!1};E.mode="hidden";let g=()=>{S.wasShowing||S.wasHidden?E.mode="hidden":E.mode="disabled"};E.readyState>=2?g():(E.addEventListener("load",g,{once:!0}),E.addEventListener("error",g,{once:!0}))}})},300)};this.element.readyState>=1?setTimeout(p,200):(this.element.addEventListener("loadedmetadata",p,{once:!0}),setTimeout(p,2e3))},100)}}let r=this.sourceElements;if(r.some(n=>n.getAttribute("data-desc-src"))){let n=[];r.forEach(c=>{let u=c.getAttribute("data-desc-src"),y=c.getAttribute("src");if(u){let m=c.getAttribute("type"),p=c.getAttribute("data-orig-src");p||(p=y),n.push({src:u,type:m,origSrc:p,descSrc:u})}else{let m=c.getAttribute("type"),p=c.getAttribute("src");n.push({src:p,type:m,origSrc:null,descSrc:null})}}),r.forEach(c=>{c.remove()}),n.forEach(c=>{let u=document.createElement("source");u.setAttribute("src",c.src),c.type&&u.setAttribute("type",c.type),c.origSrc&&u.setAttribute("data-orig-src",c.origSrc),c.descSrc&&u.setAttribute("data-desc-src",c.descSrc),this.element.appendChild(u)}),this.element.load(),this.invalidateTrackCache()}else this.element.src=this.audioDescriptionSrc}if(await new Promise(r=>{let o=()=>{this.element.removeEventListener("loadedmetadata",o),r()};this.element.addEventListener("loadedmetadata",o)}),this.element.tagName==="VIDEO"&&i===0&&!s&&this.element.readyState>=1&&(this.element.currentTime=.001,this.setManagedTimeout(()=>{this.element.currentTime=0},10)),this.seek(i),s&&this.play(),a.length>0&&this.captionManager){let r=this.state.captionsEnabled,o=null;if(this.captionManager.currentTrack){let n=this.captionManager.tracks.findIndex(c=>c.track===this.captionManager.currentTrack.track);n>=0&&(o={language:this.captionManager.tracks[n].language,kind:this.captionManager.tracks[n].kind})}setTimeout(()=>{if(this.captionManager.tracks=[],this.captionManager.loadTracks(),r&&o&&this.captionManager.tracks.length>0){let n=this.captionManager.tracks.findIndex(c=>c.language===o.language&&c.kind===o.kind);n>=0?this.captionManager.enable(n):this.captionManager.tracks.length>0&&this.captionManager.enable(0)}},600)}if(this.transcriptManager&&this.transcriptManager.isVisible){let r=typeof a<"u"?a:[];if(r.length>0){let o=()=>{this.invalidateTrackCache();let c=this.textTracks,u=r.map(p=>{let w=p.trackElement,v=w.getAttribute("src"),E=w.getAttribute("srclang"),S=w.getAttribute("kind"),g=c.find(f=>w.track===f);if(g||(g=c.find(f=>{if(f.language===E&&(f.kind===S||S==="captions"&&f.kind==="subtitles")){let T=this.findTrackElement(f);if(T&&T.getAttribute("src")===v)return!0}return!1})),g){let f=this.findTrackElement(g);if(f&&f.getAttribute("src")!==v)return null}return g}).filter(Boolean);if(u.length===0){this.setManagedTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},1e3);return}u.forEach(p=>{p.mode==="disabled"&&(p.mode="hidden")});let y=0,m=()=>{y++,y>=u.length&&this.setManagedTimeout(()=>{if(this.transcriptManager&&this.transcriptManager.loadTranscriptData){this.invalidateTrackCache();let p=this.textTracks,w=r.map(E=>E.describedSrc);(u.some(E=>{let S=this.findTrackElement(E);return S&&w.includes(S.getAttribute("src"))})||u.length>0)&&this.transcriptManager.loadTranscriptData()}},800)};u.forEach(p=>{p.mode==="disabled"&&(p.mode="hidden");let w=this.findTrackElement(p),v=w?w.getAttribute("src"):null,E=r.find(g=>{let f=g.trackElement;return f&&(f.track===p||f.getAttribute("srclang")===p.language&&f.getAttribute("kind")===p.kind)}),S=E?E.describedSrc:null;if(S&&v&&v!==S){m();return}if(p.readyState>=2&&p.cues&&p.cues.length>0)m();else{p.mode==="disabled"&&(p.mode="hidden");let g=()=>{this.setManagedTimeout(m,300)};p.readyState>=2?this.setManagedTimeout(()=>{p.cues&&p.cues.length>0?m():p.addEventListener("load",g,{once:!0})},100):(p.addEventListener("load",g,{once:!0}),p.addEventListener("error",()=>{m()},{once:!0}))}})};(()=>{this.setManagedTimeout(()=>{this.element.readyState>=1?o():(this.element.addEventListener("loadedmetadata",o,{once:!0}),this.setManagedTimeout(o,2e3))},500)})(),setTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},5e3)}else setTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},800)}this.state.audioDescriptionEnabled=!0,this.emit("audiodescriptionenabled")}async disableAudioDescription(){if(!this.originalSrc)return;let e=this.state.currentTime,t=this.state.playing;this.audioDescriptionCaptionTracks.length>0&&this.audioDescriptionCaptionTracks.forEach(a=>{a.trackElement&&a.originalTrackSrc&&a.trackElement.setAttribute("src",a.originalTrackSrc)});let i=this.sourceElements;if(i.some(a=>a.getAttribute("data-orig-src"))){let a=[];i.forEach(r=>{let o=r.getAttribute("data-orig-src"),n=r.getAttribute("data-desc-src");if(o){let c=r.getAttribute("type");a.push({src:o,type:c,origSrc:o,descSrc:n})}else{let c=r.getAttribute("type"),u=r.getAttribute("src");a.push({src:u,type:c,origSrc:null,descSrc:n})}}),i.forEach(r=>{r.remove()}),a.forEach(r=>{let o=document.createElement("source");o.setAttribute("src",r.src),r.type&&o.setAttribute("type",r.type),r.origSrc&&o.setAttribute("data-orig-src",r.origSrc),r.descSrc&&o.setAttribute("data-desc-src",r.descSrc),this.element.appendChild(o)}),this.element.load()}else{let a=this.originalAudioDescriptionSource||this.originalSrc;this.element.src=a,this.element.load()}await new Promise(a=>{let r=()=>{this.element.removeEventListener("loadedmetadata",r),a()};this.element.addEventListener("loadedmetadata",r)}),this.seek(e),t&&this.play(),this.transcriptManager&&this.transcriptManager.isVisible&&this.setManagedTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},500),this.state.audioDescriptionEnabled=!1,this.emit("audiodescriptiondisabled")}async toggleAudioDescription(){let e=this.findTextTrack("descriptions"),t=this.audioDescriptionSrc||this.sourceElements.some(i=>i.getAttribute("data-desc-src"));if(e&&t)if(this.state.audioDescriptionEnabled)e.mode="hidden",await this.disableAudioDescription();else{await this.enableAudioDescription();let i=()=>{this.invalidateTrackCache();let s=this.findTextTrack("descriptions");s?s.mode==="disabled"?(s.mode="hidden",this.setManagedTimeout(()=>{s.mode="showing"},50)):s.mode="showing":this.element.readyState<2&&this.setManagedTimeout(i,100)};this.element.readyState>=1?this.setManagedTimeout(i,200):this.element.addEventListener("loadedmetadata",()=>{this.setManagedTimeout(i,200)},{once:!0})}else e?e.mode==="showing"?(e.mode="hidden",this.state.audioDescriptionEnabled=!1,this.emit("audiodescriptiondisabled")):(e.mode="showing",this.state.audioDescriptionEnabled=!0,this.emit("audiodescriptionenabled")):t&&(this.state.audioDescriptionEnabled?await this.disableAudioDescription():await this.enableAudioDescription())}enableSignLanguage(){if(!this.signLanguageSrc){console.warn("No sign language video source provided");return}if(this.signLanguageWrapper){this.signLanguageWrapper.style.display="block",this.state.signLanguageEnabled=!0,this.emit("signlanguageenabled");return}this.signLanguageWrapper=document.createElement("div"),this.signLanguageWrapper.className="vidply-sign-language-wrapper",this.signLanguageWrapper.setAttribute("tabindex","0"),this.signLanguageWrapper.setAttribute("aria-label","Sign Language Video - Press D to drag with keyboard, R to resize"),this.signLanguageVideo=document.createElement("video"),this.signLanguageVideo.className="vidply-sign-language-video",this.signLanguageVideo.src=this.signLanguageSrc,this.signLanguageVideo.setAttribute("aria-label",h.t("player.signLanguage")),this.signLanguageVideo.muted=!0;let e=["nw","ne","sw","se"].map(i=>{let s=document.createElement("div");return s.className=`vidply-sign-resize-handle vidply-sign-resize-${i}`,s.setAttribute("data-direction",i),s.setAttribute("aria-label",`Resize ${i.toUpperCase()}`),s});this.signLanguageWrapper.appendChild(this.signLanguageVideo),e.forEach(i=>this.signLanguageWrapper.appendChild(i));let t=this.storage.getSignLanguagePreferences();t&&t.size&&t.size.width?this.signLanguageWrapper.style.width=t.size.width:this.signLanguageWrapper.style.width="280px",this.signLanguageWrapper.style.height="auto",this.signLanguageDesiredPosition=this.options.signLanguagePosition||"bottom-right",this.container.appendChild(this.signLanguageWrapper),requestAnimationFrame(()=>{this.constrainSignLanguagePosition()}),this.signLanguageVideo.currentTime=this.state.currentTime,this.state.paused||this.signLanguageVideo.play(),this.setupSignLanguageInteraction(),this.signLanguageHandlers={play:()=>{this.signLanguageVideo&&this.signLanguageVideo.play()},pause:()=>{this.signLanguageVideo&&this.signLanguageVideo.pause()},timeupdate:()=>{this.signLanguageVideo&&Math.abs(this.signLanguageVideo.currentTime-this.state.currentTime)>.5&&(this.signLanguageVideo.currentTime=this.state.currentTime)},ratechange:()=>{this.signLanguageVideo&&(this.signLanguageVideo.playbackRate=this.state.playbackSpeed)}},this.on("play",this.signLanguageHandlers.play),this.on("pause",this.signLanguageHandlers.pause),this.on("timeupdate",this.signLanguageHandlers.timeupdate),this.on("ratechange",this.signLanguageHandlers.ratechange),this.state.signLanguageEnabled=!0,this.emit("signlanguageenabled")}disableSignLanguage(){this.signLanguageWrapper&&(this.signLanguageWrapper.style.display="none"),this.state.signLanguageEnabled=!1,this.emit("signlanguagedisabled")}toggleSignLanguage(){this.state.signLanguageEnabled?this.disableSignLanguage():this.enableSignLanguage()}setupSignLanguageInteraction(){if(!this.signLanguageWrapper)return;let e=!1,t=!1,i=null,s=0,a=0,r=0,o=0,n=0,c=0,u=!1,y=!1,m=g=>{if(g.target!==this.signLanguageVideo)return;g.preventDefault(),e=!0,s=g.clientX,a=g.clientY;let f=this.signLanguageWrapper.getBoundingClientRect();r=f.left,o=f.top,this.signLanguageWrapper.classList.add("vidply-sign-dragging")},p=g=>{if(!g.target.classList.contains("vidply-sign-resize-handle"))return;g.preventDefault(),g.stopPropagation(),t=!0,i=g.target.getAttribute("data-direction"),s=g.clientX,a=g.clientY;let f=this.signLanguageWrapper.getBoundingClientRect();r=f.left,o=f.top,n=f.width,c=f.height,this.signLanguageWrapper.classList.add("vidply-sign-resizing")},w=g=>{if(e){let f=g.clientX-s,T=g.clientY-a,k=this.videoWrapper.getBoundingClientRect(),C=this.container.getBoundingClientRect(),x=this.signLanguageWrapper.getBoundingClientRect(),M=k.left-C.left,L=k.top-C.top,P=r+f-C.left,H=o+T-C.top,U=95;P=Math.max(M,Math.min(P,M+k.width-x.width)),H=Math.max(L,Math.min(H,L+k.height-x.height-U)),this.signLanguageWrapper.style.left=`${P}px`,this.signLanguageWrapper.style.top=`${H}px`,this.signLanguageWrapper.style.right="auto",this.signLanguageWrapper.style.bottom="auto",this.signLanguageWrapper.classList.remove(...Array.from(this.signLanguageWrapper.classList).filter(ee=>ee.startsWith("vidply-sign-position-")))}else if(t){let f=g.clientX-s,T=this.videoWrapper.getBoundingClientRect(),k=this.container.getBoundingClientRect(),C=n,x=r-k.left;if(i.includes("e")){C=Math.max(150,n+f);let M=T.right-r;C=Math.min(C,M)}if(i.includes("w")){let M=Math.max(150,n-f),L=r+(n-M)-k.left,P=T.left-k.left;L>=P&&(C=M,x=L)}this.signLanguageWrapper.style.width=`${C}px`,this.signLanguageWrapper.style.height="auto",i.includes("w")&&(this.signLanguageWrapper.style.left=`${x}px`),this.signLanguageWrapper.style.right="auto",this.signLanguageWrapper.style.bottom="auto",this.signLanguageWrapper.classList.remove(...Array.from(this.signLanguageWrapper.classList).filter(M=>M.startsWith("vidply-sign-position-")))}},v=()=>{(e||t)&&this.saveSignLanguagePreferences(),e=!1,t=!1,i=null,this.signLanguageWrapper.classList.remove("vidply-sign-dragging","vidply-sign-resizing")},E=g=>{if(g.key==="d"||g.key==="D"){u=!u,y=!1,this.signLanguageWrapper.classList.toggle("vidply-sign-keyboard-drag",u),this.signLanguageWrapper.classList.remove("vidply-sign-keyboard-resize"),g.preventDefault();return}if(g.key==="r"||g.key==="R"){y=!y,u=!1,this.signLanguageWrapper.classList.toggle("vidply-sign-keyboard-resize",y),this.signLanguageWrapper.classList.remove("vidply-sign-keyboard-drag"),g.preventDefault();return}if(g.key==="Escape"){u=!1,y=!1,this.signLanguageWrapper.classList.remove("vidply-sign-keyboard-drag","vidply-sign-keyboard-resize"),g.preventDefault();return}if(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(g.key)){let f=g.shiftKey?10:5,T=this.signLanguageWrapper.getBoundingClientRect(),k=this.videoWrapper.getBoundingClientRect(),C=this.container.getBoundingClientRect(),x=k.left-C.left,M=k.top-C.top;if(u){let L=T.left-C.left,P=T.top-C.top;g.key==="ArrowLeft"&&(L-=f),g.key==="ArrowRight"&&(L+=f),g.key==="ArrowUp"&&(P-=f),g.key==="ArrowDown"&&(P+=f);let H=95;L=Math.max(x,Math.min(L,x+k.width-T.width)),P=Math.max(M,Math.min(P,M+k.height-T.height-H)),this.signLanguageWrapper.style.left=`${L}px`,this.signLanguageWrapper.style.top=`${P}px`,this.signLanguageWrapper.style.right="auto",this.signLanguageWrapper.style.bottom="auto",this.signLanguageWrapper.classList.remove(...Array.from(this.signLanguageWrapper.classList).filter(U=>U.startsWith("vidply-sign-position-"))),this.saveSignLanguagePreferences(),g.preventDefault()}else if(y){let L=T.width;g.key==="ArrowLeft"&&(L-=f),g.key==="ArrowRight"&&(L+=f),g.key==="ArrowUp"&&(L+=f),g.key==="ArrowDown"&&(L-=f),L=Math.max(150,L),L=Math.min(L,k.width),this.signLanguageWrapper.style.width=`${L}px`,this.signLanguageWrapper.style.height="auto",this.saveSignLanguagePreferences(),g.preventDefault()}}};this.signLanguageVideo.addEventListener("mousedown",m);let S=this.signLanguageWrapper.querySelectorAll(".vidply-sign-resize-handle");S.forEach(g=>g.addEventListener("mousedown",p)),document.addEventListener("mousemove",w),document.addEventListener("mouseup",v),this.signLanguageWrapper.addEventListener("keydown",E),this.signLanguageInteractionHandlers={mouseDownVideo:m,mouseDownHandle:p,mouseMove:w,mouseUp:v,keyDown:E,handles:S}}constrainSignLanguagePosition(){if(!this.signLanguageWrapper||!this.videoWrapper)return;(!this.signLanguageWrapper.style.width||this.signLanguageWrapper.style.width==="")&&(this.signLanguageWrapper.style.width="280px");let e=this.videoWrapper.getBoundingClientRect(),t=this.container.getBoundingClientRect(),i=this.signLanguageWrapper.getBoundingClientRect(),s=e.left-t.left,a=e.top-t.top,r=e.width,o=e.height,n=i.width||280,c=i.height||280*9/16,u,y,m=16,p=95;switch(this.signLanguageDesiredPosition||"bottom-right"){case"bottom-right":u=s+r-n-m,y=a+o-c-p;break;case"bottom-left":u=s+m,y=a+o-c-p;break;case"top-right":u=s+r-n-m,y=a+m;break;case"top-left":u=s+m,y=a+m;break;default:u=s+r-n-m,y=a+o-c-p}u=Math.max(s,Math.min(u,s+r-n)),y=Math.max(a,Math.min(y,a+o-c-p)),this.signLanguageWrapper.style.left=`${u}px`,this.signLanguageWrapper.style.top=`${y}px`,this.signLanguageWrapper.style.right="auto",this.signLanguageWrapper.style.bottom="auto",this.signLanguageWrapper.classList.remove(...Array.from(this.signLanguageWrapper.classList).filter(v=>v.startsWith("vidply-sign-position-")))}saveSignLanguagePreferences(){this.signLanguageWrapper&&this.storage.saveSignLanguagePreferences({size:{width:this.signLanguageWrapper.style.width}})}cleanupSignLanguage(){this.signLanguageHandlers&&(this.off("play",this.signLanguageHandlers.play),this.off("pause",this.signLanguageHandlers.pause),this.off("timeupdate",this.signLanguageHandlers.timeupdate),this.off("ratechange",this.signLanguageHandlers.ratechange),this.signLanguageHandlers=null),this.signLanguageInteractionHandlers&&(this.signLanguageVideo&&this.signLanguageVideo.removeEventListener("mousedown",this.signLanguageInteractionHandlers.mouseDownVideo),this.signLanguageInteractionHandlers.handles&&this.signLanguageInteractionHandlers.handles.forEach(e=>{e.removeEventListener("mousedown",this.signLanguageInteractionHandlers.mouseDownHandle)}),document.removeEventListener("mousemove",this.signLanguageInteractionHandlers.mouseMove),document.removeEventListener("mouseup",this.signLanguageInteractionHandlers.mouseUp),this.signLanguageWrapper&&this.signLanguageWrapper.removeEventListener("keydown",this.signLanguageInteractionHandlers.keyDown),this.signLanguageInteractionHandlers=null),this.signLanguageWrapper&&this.signLanguageWrapper.parentNode&&(this.signLanguageVideo&&(this.signLanguageVideo.pause(),this.signLanguageVideo.src=""),this.signLanguageWrapper.parentNode.removeChild(this.signLanguageWrapper),this.signLanguageWrapper=null,this.signLanguageVideo=null)}showSettings(){console.warn("[VidPly] Settings dialog has been removed. Use individual control buttons (speed, captions, etc.)")}hideSettings(){}getCurrentTime(){return this.state.currentTime}getDuration(){return this.state.duration}isPlaying(){return this.state.playing}isPaused(){return this.state.paused}isEnded(){return this.state.ended}isMuted(){return this.state.muted}isFullscreen(){return this.state.fullscreen}handleError(e){this.log("Error:",e,"error"),this.emit("error",e),this.options.onError&&this.options.onError.call(this,e)}log(...e){if(!this.options.debug)return;let t="log";if(e.length>0){let i=e[e.length-1];typeof i=="string"&&console[i]&&(t=i,e=e.slice(0,-1))}e.length===0&&(e=[""]),typeof console[t]=="function"?console[t]("[VidPly]",...e):console.log("[VidPly]",...e)}setupResponsiveHandlers(){if(typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(e=>{for(let t of e){let i=t.contentRect.width;this.controlBar&&typeof this.controlBar.updateControlsForViewport=="function"&&this.controlBar.updateControlsForViewport(i),this.transcriptManager&&this.transcriptManager.isVisible&&this.transcriptManager.positionTranscript()}}),this.resizeObserver.observe(this.container)):(this.resizeHandler=()=>{let e=this.container.clientWidth;this.controlBar&&typeof this.controlBar.updateControlsForViewport=="function"&&this.controlBar.updateControlsForViewport(e),this.transcriptManager&&this.transcriptManager.isVisible&&this.transcriptManager.positionTranscript()},window.addEventListener("resize",this.resizeHandler)),window.matchMedia){this.orientationHandler=t=>{setTimeout(()=>{this.transcriptManager&&this.transcriptManager.isVisible&&this.transcriptManager.positionTranscript()},100)};let e=window.matchMedia("(orientation: portrait)");e.addEventListener?e.addEventListener("change",this.orientationHandler):e.addListener&&e.addListener(this.orientationHandler),this.orientationQuery=e}this.fullscreenChangeHandler=()=>{let e=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);this.state.fullscreen!==e&&(this.state.fullscreen=e,e?this.container.classList.add(`${this.options.classPrefix}-fullscreen`):this.container.classList.remove(`${this.options.classPrefix}-fullscreen`),this.emit("fullscreenchange",e),this.controlBar&&this.controlBar.updateFullscreenButton(),this.signLanguageWrapper&&this.signLanguageWrapper.style.display!=="none"&&this.setManagedTimeout(()=>{requestAnimationFrame(()=>{this.storage.saveSignLanguagePreferences({size:null}),this.signLanguageDesiredPosition="bottom-right",this.signLanguageWrapper.style.width=e?"400px":"280px",this.constrainSignLanguagePosition()})},500))},document.addEventListener("fullscreenchange",this.fullscreenChangeHandler),document.addEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("MSFullscreenChange",this.fullscreenChangeHandler)}destroy(){if(this.log("Destroying player"),this.renderer&&this.renderer.destroy(),this.controlBar&&this.controlBar.destroy(),this.captionManager&&this.captionManager.destroy(),this.keyboardManager&&this.keyboardManager.destroy(),this.transcriptManager&&this.transcriptManager.destroy(),this.cleanupSignLanguage(),this.playButtonOverlay&&this.playButtonOverlay.parentNode&&(this.playButtonOverlay.remove(),this.playButtonOverlay=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.orientationQuery&&this.orientationHandler&&(this.orientationQuery.removeEventListener?this.orientationQuery.removeEventListener("change",this.orientationHandler):this.orientationQuery.removeListener&&this.orientationQuery.removeListener(this.orientationHandler),this.orientationQuery=null,this.orientationHandler=null),this.fullscreenChangeHandler&&(document.removeEventListener("fullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("MSFullscreenChange",this.fullscreenChangeHandler),this.fullscreenChangeHandler=null),this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts.clear(),this.metadataCueChangeHandler){let t=this.textTracks.find(i=>i.kind==="metadata");t&&t.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=null}this.metadataAlertHandlers&&this.metadataAlertHandlers.size>0&&(this.metadataAlertHandlers.forEach(({button:e,handler:t})=>{e&&t&&e.removeEventListener("click",t)}),this.metadataAlertHandlers.clear()),this.container&&this.container.parentNode&&(this.container.parentNode.insertBefore(this.element,this.container),this.container.parentNode.removeChild(this.container)),this.removeAllListeners()}setupMetadataHandling(){let e=()=>{let i=this.textTracks.find(s=>s.kind==="metadata");if(i){if(i.mode==="disabled"&&(i.mode="hidden"),this.metadataCueChangeHandler&&i.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=()=>{let s=Array.from(i.activeCues||[]);s.length>0&&this.options.debug&&this.log("[Metadata] Active cues:",s.map(a=>({start:a.startTime,end:a.endTime,text:a.text}))),s.forEach(a=>{this.handleMetadataCue(a)})},i.addEventListener("cuechange",this.metadataCueChangeHandler),this.options.debug){let s=i.cues?i.cues.length:0;this.log("[Metadata] Track enabled,",s,"cues available")}}else this.options.debug&&this.log("[Metadata] No metadata track found")};e(),this.on("loadedmetadata",e)}normalizeMetadataSelector(e){if(!e)return null;let t=e.trim();return t?t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?t:`#${t}`:null}resolveMetadataConfig(e,t){if(!e||!t)return null;if(Object.prototype.hasOwnProperty.call(e,t))return e[t];let i=t.replace(/^#/,"");return Object.prototype.hasOwnProperty.call(e,i)?e[i]:null}cacheMetadataAlertContent(e,t={}){if(!e)return;let i=t.titleSelector||"[data-vidply-alert-title], h3, header",s=t.messageSelector||"[data-vidply-alert-message], p",a=e.querySelector(i);a&&!a.dataset.vidplyAlertTitleOriginal&&(a.dataset.vidplyAlertTitleOriginal=a.textContent.trim());let r=e.querySelector(s);r&&!r.dataset.vidplyAlertMessageOriginal&&(r.dataset.vidplyAlertMessageOriginal=r.textContent.trim())}restoreMetadataAlertContent(e,t={}){if(!e)return;let i=t.titleSelector||"[data-vidply-alert-title], h3, header",s=t.messageSelector||"[data-vidply-alert-message], p",a=e.querySelector(i);a&&a.dataset.vidplyAlertTitleOriginal&&(a.textContent=a.dataset.vidplyAlertTitleOriginal);let r=e.querySelector(s);r&&r.dataset.vidplyAlertMessageOriginal&&(r.textContent=r.dataset.vidplyAlertMessageOriginal)}focusMetadataTarget(e,t=null){var i,s;if(!(!e||e==="none")){if(e==="alert"&&t){t.focus();return}if(e==="player"){this.container&&this.container.focus();return}if(e==="media"){this.element.focus();return}if(e==="playButton"){let a=(s=(i=this.controlBar)==null?void 0:i.controls)==null?void 0:s.playPause;a&&a.focus();return}if(typeof e=="string"){let a=document.querySelector(e);a&&(a.tabIndex===-1&&!a.hasAttribute("tabindex")&&a.setAttribute("tabindex","-1"),a.focus())}}}handleMetadataAlert(e,t={}){if(!e)return;let i=this.resolveMetadataConfig(this.options.metadataAlerts,e)||{},s=t.element||document.querySelector(e);if(!s){this.options.debug&&this.log("[Metadata] Alert element not found:",e);return}this.options.debug&&this.log("[Metadata] Handling alert",e,{reason:t.reason,config:i}),this.cacheMetadataAlertContent(s,i),s.dataset.vidplyAlertOriginalDisplay||(s.dataset.vidplyAlertOriginalDisplay=s.style.display||""),s.dataset.vidplyAlertDisplay||(s.dataset.vidplyAlertDisplay=i.display||"block");let a=t.show!==void 0?t.show:i.show!==!1;if(a){let c=i.display||s.dataset.vidplyAlertDisplay||"block";s.style.display=c,s.hidden=!1,s.removeAttribute("hidden"),s.setAttribute("aria-hidden","false"),s.setAttribute("data-vidply-alert-active","true")}i.resetContent!==!1&&t.reason==="focus"&&this.restoreMetadataAlertContent(s,i);let o=t.focus!==void 0?t.focus:i.focusOnShow??t.reason!=="focus";a&&o&&(s.tabIndex===-1&&!s.hasAttribute("tabindex")&&s.setAttribute("tabindex","-1"),s.focus()),a&&i.autoScroll!==!1&&t.autoScroll!==!1&&s.scrollIntoView({behavior:"smooth",block:"nearest"});let n=i.continueButton;if(n){let c=null;if(n==="self"||s.matches(n)?c=s:c=s.querySelector(n)||document.querySelector(n),c&&!this.metadataAlertHandlers.has(e)){let u=()=>{if(i.hideOnContinue!==!1){let p=s.dataset.vidplyAlertOriginalDisplay||"";s.style.display=i.hideDisplay||p||"none",s.setAttribute("aria-hidden","true"),s.removeAttribute("data-vidply-alert-active")}i.resume!==!1&&this.state.paused&&this.play();let m=i.focusTarget||"playButton";this.setManagedTimeout(()=>{this.focusMetadataTarget(m,s)},i.focusDelay??100)};c.addEventListener("click",u),this.metadataAlertHandlers.set(e,{button:c,handler:u})}}return s}handleMetadataHashtags(e){if(!Array.isArray(e)||e.length===0)return;let t=this.options.metadataHashtags;t&&e.forEach(i=>{let s=this.resolveMetadataConfig(t,i);if(!s)return;let a=this.normalizeMetadataSelector(s.alert||s.selector||s.target);if(!a)return;let r=document.querySelector(a);if(!r){this.options.debug&&this.log("[Metadata] Hashtag target not found:",a);return}if(this.options.debug&&this.log("[Metadata] Handling hashtag",i,{selector:a,config:s}),this.cacheMetadataAlertContent(r,s),s.title){let c=s.titleSelector||"[data-vidply-alert-title], h3, header",u=r.querySelector(c);u&&(u.textContent=s.title)}if(s.message){let c=s.messageSelector||"[data-vidply-alert-message], p",u=r.querySelector(c);u&&(u.textContent=s.message)}let o=s.show!==!1,n=s.focus!==void 0?s.focus:!1;this.handleMetadataAlert(a,{element:r,show:o,focus:n,autoScroll:s.autoScroll,reason:"hashtag"})})}handleMetadataCue(e){let t=e.text.trim();this.options.debug&&this.log("[Metadata] Processing cue:",{time:e.startTime,text:t}),this.emit("metadata",{time:e.startTime,endTime:e.endTime,text:t,cue:e}),t.includes("PAUSE")&&(this.state.paused||(this.options.debug&&this.log("[Metadata] Pausing video at",e.startTime),this.pause()),this.emit("metadata:pause",{time:e.startTime,text:t}));let i=t.match(/FOCUS:([\w#-]+)/);if(i){let a=i[1],r=this.normalizeMetadataSelector(a),o=r?document.querySelector(r):null;o?(this.options.debug&&this.log("[Metadata] Focusing element:",r),o.tabIndex===-1&&!o.hasAttribute("tabindex")&&o.setAttribute("tabindex","-1"),this.setManagedTimeout(()=>{o.focus(),o.scrollIntoView({behavior:"smooth",block:"nearest"})},10)):this.options.debug&&this.log("[Metadata] Element not found:",r||a),this.emit("metadata:focus",{time:e.startTime,target:a,selector:r,element:o,text:t}),r&&this.handleMetadataAlert(r,{element:o,reason:"focus"})}let s=t.match(/#[\w-]+/g);s&&(this.options.debug&&this.log("[Metadata] Hashtags found:",s),this.emit("metadata:hashtags",{time:e.startTime,hashtags:s,text:t}),this.handleMetadataHashtags(s))}};z.instances=[];var q=class{constructor(e,t={}){this.player=e,this.tracks=[],this.currentIndex=-1,this.options={autoAdvance:t.autoAdvance!==!1,loop:t.loop||!1,showPanel:t.showPanel!==!1,...t},this.container=null,this.playlistPanel=null,this.trackInfoElement=null,this.handleTrackEnd=this.handleTrackEnd.bind(this),this.handleTrackError=this.handleTrackError.bind(this),this.player.playlistManager=this,this.init(),this.updatePlayerControls()}init(){this.player.on("ended",this.handleTrackEnd),this.player.on("error",this.handleTrackError),this.options.showPanel&&this.createUI()}updatePlayerControls(){if(!this.player.controlBar)return;let e=this.player.controlBar;e.element.innerHTML="",e.createControls(),e.attachEvents(),e.setupAutoHide()}loadPlaylist(e){this.tracks=e,this.currentIndex=-1,this.container&&this.container.classList.add("vidply-has-playlist"),this.playlistPanel&&this.renderPlaylist(),e.length>0&&this.play(0)}play(e,t=!1){if(e<0||e>=this.tracks.length){console.warn("VidPly Playlist: Invalid track index",e);return}let i=this.tracks[e];this.currentIndex=e,this.player.load({src:i.src,type:i.type,poster:i.poster,tracks:i.tracks||[]}),this.updateTrackInfo(i),this.updatePlaylistUI(),this.player.emit("playlisttrackchange",{index:e,item:i,total:this.tracks.length}),t&&this.player.container&&this.player.container.focus(),setTimeout(()=>{this.player.play()},100)}next(){let e=this.currentIndex+1;if(e>=this.tracks.length)if(this.options.loop)e=0;else return;this.play(e)}previous(){let e=this.currentIndex-1;if(e<0)if(this.options.loop)e=this.tracks.length-1;else return;this.play(e)}handleTrackEnd(){this.options.autoAdvance&&this.next()}handleTrackError(e){console.error("VidPly Playlist: Track error",e),this.options.autoAdvance&&setTimeout(()=>{this.next()},1e3)}createUI(){if(this.container=this.player.container,!this.container){console.warn("VidPly Playlist: No container found");return}this.trackInfoElement=l.createElement("div",{className:"vidply-track-info",role:"status","aria-live":"polite","aria-atomic":"true"}),this.trackInfoElement.style.display="none",this.container.appendChild(this.trackInfoElement),this.playlistPanel=l.createElement("div",{className:"vidply-playlist-panel",role:"region","aria-label":"Media playlist"}),this.playlistPanel.style.display="none",this.container.appendChild(this.playlistPanel)}updateTrackInfo(e){if(!this.trackInfoElement)return;let t=this.currentIndex+1,i=this.tracks.length,s=e.title||"Untitled",a=e.artist||"",r=`Now playing: Track ${t} of ${i}. ${s}${a?" by "+a:""}`;this.trackInfoElement.innerHTML=`
|
|
13
|
+
`,document.body.appendChild(i)),i.textContent="",setTimeout(()=>{i.textContent=e},100)}updateShortcut(e,t){Array.isArray(t)&&(this.shortcuts[e]=t)}destroy(){}};var D=class{constructor(e,t={}){this.element=e,this.options={dragHandle:null,resizeHandles:[],onDragStart:null,onDrag:null,onDragEnd:null,onResizeStart:null,onResize:null,onResizeEnd:null,constrainToViewport:!0,minWidth:150,minHeight:100,maintainAspectRatio:!1,keyboardDragKey:"d",keyboardResizeKey:"r",keyboardStep:5,keyboardStepLarge:10,maxWidth:null,maxHeight:null,pointerResizeIndicatorText:null,onPointerResizeToggle:null,classPrefix:"draggable",storage:null,storageKey:null,...t},this.isDragging=!1,this.isResizing=!1,this.resizeDirection=null,this.dragOffsetX=0,this.dragOffsetY=0,this.positionOffsetX=0,this.positionOffsetY=0,this.initialMouseX=0,this.initialMouseY=0,this.needsPositionConversion=!1,this.resizeStartX=0,this.resizeStartY=0,this.resizeStartWidth=0,this.resizeStartHeight=0,this.resizeStartLeft=0,this.resizeStartTop=0,this.keyboardDragMode=!1,this.keyboardResizeMode=!1,this.pointerResizeMode=!1,this.manuallyPositioned=!1,this.resizeHandlesManaged=new Map,this.resizeIndicatorElement=null,this.handlers={mousedown:this.onMouseDown.bind(this),mousemove:this.onMouseMove.bind(this),mouseup:this.onMouseUp.bind(this),touchstart:this.onTouchStart.bind(this),touchmove:this.onTouchMove.bind(this),touchend:this.onTouchEnd.bind(this),keydown:this.onKeyDown.bind(this),resizeHandleMousedown:this.onResizeHandleMouseDown.bind(this)},this.init()}hasManagedResizeHandles(){return Array.from(this.resizeHandlesManaged.values()).some(Boolean)}storeOriginalHandleDisplay(e){e.dataset.originalDisplay||(e.dataset.originalDisplay=e.style.display||"")}hideResizeHandle(e){e.style.display="none",e.setAttribute("aria-hidden","true")}showResizeHandle(e){let t=e.dataset.originalDisplay!==void 0?e.dataset.originalDisplay:"";e.style.display=t,e.removeAttribute("aria-hidden")}setManagedHandlesVisible(e){!this.options.resizeHandles||this.options.resizeHandles.length===0||this.options.resizeHandles.forEach(t=>{this.resizeHandlesManaged.get(t)&&(e?this.showResizeHandle(t):this.hideResizeHandle(t))})}init(){let e=this.options.dragHandle||this.element;e.addEventListener("mousedown",this.handlers.mousedown),e.addEventListener("touchstart",this.handlers.touchstart),document.addEventListener("mousemove",this.handlers.mousemove),document.addEventListener("mouseup",this.handlers.mouseup),document.addEventListener("touchmove",this.handlers.touchmove,{passive:!1}),document.addEventListener("touchend",this.handlers.touchend),this.element.addEventListener("keydown",this.handlers.keydown),this.options.resizeHandles&&this.options.resizeHandles.length>0&&this.options.resizeHandles.forEach(t=>{t.addEventListener("mousedown",this.handlers.resizeHandleMousedown),t.addEventListener("touchstart",this.handlers.resizeHandleMousedown);let i=t.dataset.vidplyManagedResize==="true";this.resizeHandlesManaged.set(t,i),i&&(this.storeOriginalHandleDisplay(t),this.hideResizeHandle(t))})}onMouseDown(e){e.target.classList.contains(`${this.options.classPrefix}-resize-handle`)||this.options.onDragStart&&!this.options.onDragStart(e)||(this.startDragging(e.clientX,e.clientY),e.preventDefault())}onTouchStart(e){if(e.target.classList.contains(`${this.options.classPrefix}-resize-handle`)||this.options.onDragStart&&!this.options.onDragStart(e))return;let t=e.touches[0];this.startDragging(t.clientX,t.clientY)}onResizeHandleMouseDown(e){var a,r,n,o;e.preventDefault(),e.stopPropagation();let t=e.target;this.resizeDirection=t.getAttribute("data-direction");let i=e.clientX||((r=(a=e.touches)==null?void 0:a[0])==null?void 0:r.clientX),s=e.clientY||((o=(n=e.touches)==null?void 0:n[0])==null?void 0:o.clientY);this.startResizing(i,s)}onMouseMove(e){this.isDragging?(this.drag(e.clientX,e.clientY),e.preventDefault()):this.isResizing&&(this.resize(e.clientX,e.clientY),e.preventDefault())}onTouchMove(e){if(this.isDragging||this.isResizing){let t=e.touches[0];this.isDragging?this.drag(t.clientX,t.clientY):this.resize(t.clientX,t.clientY),e.preventDefault()}}onMouseUp(){this.isDragging?this.stopDragging():this.isResizing&&this.stopResizing()}onTouchEnd(){this.isDragging?this.stopDragging():this.isResizing&&this.stopResizing()}onKeyDown(e){if(e.key.toLowerCase()===this.options.keyboardDragKey.toLowerCase()){e.preventDefault(),this.toggleKeyboardDragMode();return}if(e.key.toLowerCase()===this.options.keyboardResizeKey.toLowerCase()){e.preventDefault(),this.hasManagedResizeHandles()?this.togglePointerResizeMode():this.toggleKeyboardResizeMode();return}if(e.key==="Escape"){if(this.pointerResizeMode){e.preventDefault(),this.disablePointerResizeMode();return}if(this.keyboardDragMode||this.keyboardResizeMode){e.preventDefault(),this.disableKeyboardDragMode(),this.disableKeyboardResizeMode();return}}["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)&&(this.keyboardDragMode?(e.preventDefault(),e.stopPropagation(),this.keyboardDrag(e.key,e.shiftKey)):this.keyboardResizeMode&&(e.preventDefault(),e.stopPropagation(),this.keyboardResize(e.key,e.shiftKey))),e.key==="Home"&&(this.keyboardDragMode||this.keyboardResizeMode)&&(e.preventDefault(),this.resetPosition())}startDragging(e,t){let i=this.element.getBoundingClientRect(),s=window.getComputedStyle(this.element),a=s.right!=="auto"||s.bottom!=="auto"||s.transform!=="none";if(this.positionOffsetX=0,this.positionOffsetY=0,a){let n,o;if(s.position==="absolute"){let y=(this.element.offsetParent||document.body).getBoundingClientRect();n=i.left-y.left,o=i.top-y.top,this.positionOffsetX=y.left,this.positionOffsetY=y.top}else if(s.position==="fixed"){let g=parseFloat(s.left),y=parseFloat(s.top),m=Number.isFinite(g),u=Number.isFinite(y);n=m?g:i.left,o=u?y:i.top,this.positionOffsetX=i.left-n,this.positionOffsetY=i.top-o}else n=i.left,o=i.top,this.positionOffsetX=i.left-n,this.positionOffsetY=i.top-o;let p=this.element.style.cssText.split(";").filter(g=>{let y=g.trim();return y&&!y.startsWith("right:")&&!y.startsWith("bottom:")&&!y.startsWith("transform:")&&!y.startsWith("left:")&&!y.startsWith("top:")&&!y.startsWith("inset:")}).join("; ");p&&(p+="; "),p+=`left: ${n}px; top: ${o}px; right: auto; bottom: auto; transform: none`,this.element.style.cssText=p}let r=this.element.getBoundingClientRect();this.dragOffsetX=e-r.left,this.dragOffsetY=t-r.top,this.isDragging=!0,this.element.classList.add(`${this.options.classPrefix}-dragging`),document.body.style.cursor="grabbing",document.body.style.userSelect="none"}drag(e,t){if(!this.isDragging)return;let i=e-this.dragOffsetX-this.positionOffsetX,s=t-this.dragOffsetY-this.positionOffsetY;if(this.options.constrainToViewport){let a=this.element.getBoundingClientRect(),r=document.documentElement.clientWidth,n=document.documentElement.clientHeight,o=100,c=-(a.width-o),p=-(a.height-o),g=r-o,y=n-o;i=Math.max(c,Math.min(i,g)),s=Math.max(p,Math.min(s,y))}this.element.style.left=`${i}px`,this.element.style.top=`${s}px`,this.options.onDrag&&this.options.onDrag({x:i,y:s})}stopDragging(){this.isDragging=!1,this.element.classList.remove(`${this.options.classPrefix}-dragging`),document.body.style.cursor="",document.body.style.userSelect="",this.manuallyPositioned=!0,this.options.onDragEnd&&this.options.onDragEnd()}startResizing(e,t){this.isResizing=!0,this.resizeStartX=e,this.resizeStartY=t;let i=this.element.getBoundingClientRect();this.resizeStartWidth=i.width,this.resizeStartHeight=i.height,this.resizeStartLeft=i.left,this.resizeStartTop=i.top,this.element.classList.add(`${this.options.classPrefix}-resizing`),document.body.style.userSelect="none",this.options.onResizeStart&&this.options.onResizeStart()}resize(e,t){if(!this.isResizing)return;let i=e-this.resizeStartX,s=t-this.resizeStartY,a=this.resizeStartWidth,r=this.resizeStartHeight,n=this.resizeStartLeft,o=this.resizeStartTop;if(this.resizeDirection.includes("e")&&(a=Math.max(this.options.minWidth,this.resizeStartWidth+i)),this.resizeDirection.includes("w")){let p=Math.max(this.options.minWidth,this.resizeStartWidth-i);n=this.resizeStartLeft+(this.resizeStartWidth-p),a=p}let c=typeof this.options.maxWidth=="function"?this.options.maxWidth():this.options.maxWidth;if(Number.isFinite(c)){let p=Math.min(a,c);p!==a&&this.resizeDirection.includes("w")&&(n+=a-p),a=p}if(!this.options.maintainAspectRatio){if(this.resizeDirection.includes("s")&&(r=Math.max(this.options.minHeight,this.resizeStartHeight+s)),this.resizeDirection.includes("n")){let g=Math.max(this.options.minHeight,this.resizeStartHeight-s);o=this.resizeStartTop+(this.resizeStartHeight-g),r=g}let p=typeof this.options.maxHeight=="function"?this.options.maxHeight():this.options.maxHeight;if(Number.isFinite(p)){let g=Math.min(r,p);g!==r&&this.resizeDirection.includes("n")&&(o+=r-g),r=g}}this.element.style.width=`${a}px`,this.options.maintainAspectRatio?this.element.style.height="auto":this.element.style.height=`${r}px`,this.resizeDirection.includes("w")&&(this.element.style.left=`${n}px`),this.resizeDirection.includes("n")&&!this.options.maintainAspectRatio&&(this.element.style.top=`${o}px`),this.options.onResize&&this.options.onResize({width:a,height:r,left:n,top:o})}stopResizing(){this.isResizing=!1,this.resizeDirection=null,this.element.classList.remove(`${this.options.classPrefix}-resizing`),document.body.style.userSelect="",this.manuallyPositioned=!0,this.options.onResizeEnd&&this.options.onResizeEnd()}toggleKeyboardDragMode(){this.keyboardDragMode?this.disableKeyboardDragMode():this.enableKeyboardDragMode()}enableKeyboardDragMode(){this.keyboardDragMode=!0,this.keyboardResizeMode=!1,this.element.classList.add(`${this.options.classPrefix}-keyboard-drag`),this.element.classList.remove(`${this.options.classPrefix}-keyboard-resize`),this.focusElement()}disableKeyboardDragMode(){this.keyboardDragMode=!1,this.element.classList.remove(`${this.options.classPrefix}-keyboard-drag`)}toggleKeyboardResizeMode(){this.keyboardResizeMode?this.disableKeyboardResizeMode():this.enableKeyboardResizeMode()}enableKeyboardResizeMode(){this.keyboardResizeMode=!0,this.keyboardDragMode=!1,this.element.classList.add(`${this.options.classPrefix}-keyboard-resize`),this.element.classList.remove(`${this.options.classPrefix}-keyboard-drag`),this.focusElement()}disableKeyboardResizeMode(){this.keyboardResizeMode=!1,this.element.classList.remove(`${this.options.classPrefix}-keyboard-resize`)}enablePointerResizeMode({focus:e=!0}={}){if(!this.hasManagedResizeHandles()){this.enableKeyboardResizeMode();return}this.pointerResizeMode||(this.pointerResizeMode=!0,this.setManagedHandlesVisible(!0),this.element.classList.add(`${this.options.classPrefix}-resizable`),this.enableKeyboardResizeMode(),e&&this.focusElement(),typeof this.options.onPointerResizeToggle=="function"&&this.options.onPointerResizeToggle(!0))}disablePointerResizeMode({focus:e=!1}={}){this.pointerResizeMode&&(this.pointerResizeMode=!1,this.setManagedHandlesVisible(!1),this.element.classList.remove(`${this.options.classPrefix}-resizable`),this.disableKeyboardResizeMode(),e&&this.focusElement(),typeof this.options.onPointerResizeToggle=="function"&&this.options.onPointerResizeToggle(!1))}togglePointerResizeMode(){return this.pointerResizeMode?this.disablePointerResizeMode():this.enablePointerResizeMode(),this.pointerResizeMode}focusElement(){if(typeof this.element.focus=="function")try{this.element.focus({preventScroll:!0})}catch{this.element.focus()}}keyboardDrag(e,t){let i=t?this.options.keyboardStepLarge:this.options.keyboardStep,s=parseFloat(this.element.style.left)||0,a=parseFloat(this.element.style.top)||0;if(window.getComputedStyle(this.element).transform!=="none"){let c=this.element.getBoundingClientRect();s=c.left,a=c.top,this.element.style.transform="none",this.element.style.left=`${s}px`,this.element.style.top=`${a}px`}let n=s,o=a;switch(e){case"ArrowLeft":n-=i;break;case"ArrowRight":n+=i;break;case"ArrowUp":o-=i;break;case"ArrowDown":o+=i;break}this.element.style.left=`${n}px`,this.element.style.top=`${o}px`,this.options.onDrag&&this.options.onDrag({x:n,y:o})}keyboardResize(e,t){let i=t?this.options.keyboardStepLarge:this.options.keyboardStep,s=this.element.getBoundingClientRect(),a=s.width,r=s.height;switch(e){case"ArrowLeft":a-=i;break;case"ArrowRight":a+=i;break;case"ArrowUp":this.options.maintainAspectRatio?a+=i:r-=i;break;case"ArrowDown":this.options.maintainAspectRatio?a-=i:r+=i;break}a=Math.max(this.options.minWidth,a),r=Math.max(this.options.minHeight,r),this.element.style.width=`${a}px`,this.options.maintainAspectRatio?this.element.style.height="auto":this.element.style.height=`${r}px`,this.options.onResize&&this.options.onResize({width:a,height:r})}resetPosition(){this.element.style.left="50%",this.element.style.top="50%",this.element.style.transform="translate(-50%, -50%)",this.element.style.right="",this.element.style.bottom="",this.manuallyPositioned=!1,this.options.onDrag&&this.options.onDrag({centered:!0})}destroy(){let e=this.options.dragHandle||this.element;this.disablePointerResizeMode(),e.removeEventListener("mousedown",this.handlers.mousedown),e.removeEventListener("touchstart",this.handlers.touchstart),document.removeEventListener("mousemove",this.handlers.mousemove),document.removeEventListener("mouseup",this.handlers.mouseup),document.removeEventListener("touchmove",this.handlers.touchmove),document.removeEventListener("touchend",this.handlers.touchend),this.element.removeEventListener("keydown",this.handlers.keydown),this.options.resizeHandles&&this.options.resizeHandles.length>0&&this.options.resizeHandles.forEach(t=>{t.removeEventListener("mousedown",this.handlers.resizeHandleMousedown),t.removeEventListener("touchstart",this.handlers.resizeHandleMousedown)}),this.element.classList.remove(`${this.options.classPrefix}-dragging`,`${this.options.classPrefix}-resizing`,`${this.options.classPrefix}-keyboard-drag`,`${this.options.classPrefix}-keyboard-resize`)}};var H=class{constructor(e){this.player=e,this.transcriptWindow=null,this.transcriptEntries=[],this.metadataCues=[],this.currentActiveEntry=null,this.isVisible=!1,this.storage=new P("vidply"),this.draggableResizable=null,this.settingsMenuVisible=!1,this.settingsMenu=null,this.settingsButton=null,this.settingsMenuJustOpened=!1,this.resizeOptionButton=null,this.resizeOptionText=null,this.resizeModeIndicator=null,this.resizeModeIndicatorTimeout=null,this.transcriptResizeHandles=[],this.liveRegion=null,this.styleDialog=null,this.styleDialogVisible=!1,this.styleDialogJustOpened=!1,this.languageSelector=null,this.currentTranscriptLanguage=null,this.availableTranscriptLanguages=[],this.languageSelectorHandler=null;let t=this.storage.getTranscriptPreferences();this.autoscrollEnabled=(t==null?void 0:t.autoscroll)!==void 0?t.autoscroll:!0,this.transcriptStyle={fontSize:(t==null?void 0:t.fontSize)||this.player.options.transcriptFontSize||"100%",fontFamily:(t==null?void 0:t.fontFamily)||this.player.options.transcriptFontFamily||"sans-serif",color:(t==null?void 0:t.color)||this.player.options.transcriptColor||"#ffffff",backgroundColor:(t==null?void 0:t.backgroundColor)||this.player.options.transcriptBackgroundColor||"#1e1e1e",opacity:(t==null?void 0:t.opacity)??this.player.options.transcriptOpacity??.98},this.handlers={timeupdate:()=>this.updateActiveEntry(),resize:null,settingsClick:null,settingsKeydown:null,documentClick:null,styleDialogKeydown:null},this.timeouts=new Set,this.init()}init(){this.setupMetadataHandlingOnLoad(),this.player.on("timeupdate",this.handlers.timeupdate),this.player.on("fullscreenchange",()=>{this.isVisible&&(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.setManagedTimeout(()=>this.positionTranscript(),100)})}toggleTranscript(){this.isVisible?this.hideTranscript():this.showTranscript()}showTranscript(){if(this.transcriptWindow){this.transcriptWindow.style.display="flex",this.isVisible=!0,this.player.controlBar&&typeof this.player.controlBar.updateTranscriptButton=="function"&&this.player.controlBar.updateTranscriptButton(),this.setManagedTimeout(()=>{this.transcriptHeader&&this.transcriptHeader.focus()},150);return}this.createTranscriptWindow(),this.loadTranscriptData(),this.transcriptWindow&&(this.transcriptWindow.style.display="flex",(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.setManagedTimeout(()=>this.positionTranscript(),0),this.setManagedTimeout(()=>{this.transcriptHeader&&this.transcriptHeader.focus()},150)),this.isVisible=!0}hideTranscript({focusButton:e=!1}={}){var t,i;if(this.transcriptWindow&&(this.transcriptWindow.style.display="none",this.isVisible=!1),this.draggableResizable&&this.draggableResizable.pointerResizeMode&&(this.draggableResizable.disablePointerResizeMode(),this.updateResizeOptionState()),this.hideResizeModeIndicator(),this.announceLive(""),this.player.controlBar&&typeof this.player.controlBar.updateTranscriptButton=="function"&&this.player.controlBar.updateTranscriptButton(),e){let s=(i=(t=this.player.controlBar)==null?void 0:t.controls)==null?void 0:i.transcript;s&&typeof s.focus=="function"&&s.focus()}}createTranscriptWindow(){this.transcriptWindow=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-window`,attributes:{role:"dialog","aria-label":"Video Transcript",tabindex:"-1"}}),this.transcriptHeader=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header`,attributes:{tabindex:"0"}}),this.headerLeft=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header-left`}),this.settingsButton=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings`,attributes:{type:"button","aria-label":d.t("transcript.settingsMenu"),"aria-expanded":"false"}}),this.settingsButton.appendChild(b("settings")),this.handlers.settingsClick=r=>{r.preventDefault(),r.stopPropagation(),this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()},this.settingsButton.addEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown=r=>{r.key==="d"||r.key==="D"?(r.preventDefault(),r.stopPropagation(),this.toggleKeyboardDragMode()):r.key==="r"||r.key==="R"?(r.preventDefault(),r.stopPropagation(),this.toggleResizeMode()):r.key==="Escape"&&this.settingsMenuVisible&&(r.preventDefault(),r.stopPropagation(),this.hideSettingsMenu())},this.settingsButton.addEventListener("keydown",this.handlers.settingsKeydown);let e=l.createElement("h3",{textContent:`${d.t("transcript.title")}. ${d.t("transcript.dragResizePrompt")}`}),t=l.createElement("label",{className:`${this.player.options.classPrefix}-transcript-autoscroll-label`,attributes:{title:d.t("transcript.autoscroll")}});this.autoscrollCheckbox=l.createElement("input",{attributes:{type:"checkbox",checked:this.autoscrollEnabled,"aria-label":d.t("transcript.autoscroll")}});let i=l.createElement("span",{textContent:d.t("transcript.autoscroll"),className:`${this.player.options.classPrefix}-transcript-autoscroll-text`});t.appendChild(this.autoscrollCheckbox),t.appendChild(i),this.autoscrollCheckbox.addEventListener("change",r=>{this.autoscrollEnabled=r.target.checked,this.saveAutoscrollPreference()}),this.transcriptHeader.appendChild(e),this.headerLeft.appendChild(this.settingsButton),this.headerLeft.appendChild(t),this.languageSelector=l.createElement("select",{className:`${this.player.options.classPrefix}-transcript-language-select`,attributes:{"aria-label":d.t("settings.language")||"Language",style:"display: none;"}}),this.headerLeft.appendChild(this.languageSelector);let s=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-close`,attributes:{type:"button","aria-label":d.t("transcript.close")}});s.appendChild(b("close")),s.addEventListener("click",()=>this.hideTranscript({focusButton:!0})),this.transcriptHeader.appendChild(this.headerLeft),this.transcriptHeader.appendChild(s),this.transcriptContent=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-content`}),this.transcriptWindow.appendChild(this.transcriptHeader),this.transcriptWindow.appendChild(this.transcriptContent),this.createResizeHandles(),this.liveRegion=l.createElement("div",{className:"vidply-sr-only",attributes:{"aria-live":"polite","aria-atomic":"true"}}),this.transcriptWindow.appendChild(this.liveRegion),this.player.container.appendChild(this.transcriptWindow),this.setupDragAndDrop(),(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.positionTranscript(),this.handlers.documentClick=r=>{this.settingsMenuJustOpened||this.styleDialogJustOpened||this.settingsButton&&this.settingsButton.contains(r.target)||this.settingsMenu&&this.settingsMenu.contains(r.target)||(this.settingsMenuVisible&&this.hideSettingsMenu(),this.styleDialogVisible&&this.styleDialog&&!this.styleDialog.contains(r.target)&&this.hideStyleDialog())},this.documentClickHandlerAdded=!1;let a;this.handlers.resize=()=>{a&&this.clearManagedTimeout(a),a=this.setManagedTimeout(()=>{(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.positionTranscript()},100)},window.addEventListener("resize",this.handlers.resize)}createResizeHandles(){if(!this.transcriptWindow)return;let e=["n","s","e","w","ne","nw","se","sw"];this.transcriptResizeHandles=e.map(t=>{let i=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-handle ${this.player.options.classPrefix}-transcript-resize-${t}`,attributes:{"data-direction":t,"data-vidply-managed-resize":"true","aria-hidden":"true"}});return i.style.display="none",this.transcriptWindow.appendChild(i),i})}positionTranscript(){if(!this.transcriptWindow||!this.player.videoWrapper||!this.isVisible||this.draggableResizable&&this.draggableResizable.manuallyPositioned)return;let e=window.innerWidth<640,t=this.player.videoWrapper.getBoundingClientRect(),i=this.player.state.fullscreen;if(e&&!i)this.transcriptWindow.style.position="relative",this.transcriptWindow.style.left="0",this.transcriptWindow.style.right="0",this.transcriptWindow.style.bottom="auto",this.transcriptWindow.style.top="auto",this.transcriptWindow.style.width="100%",this.transcriptWindow.style.maxWidth="100%",this.transcriptWindow.style.maxHeight="400px",this.transcriptWindow.style.height="auto",this.transcriptWindow.style.borderRadius="0",this.transcriptWindow.style.transform="none",this.transcriptWindow.style.border="none",this.transcriptWindow.style.borderTop="1px solid var(--vidply-border-light)",this.transcriptWindow.style.boxShadow="none",this.transcriptHeader&&(this.transcriptHeader.style.cursor="default"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow);else if(i){this.transcriptWindow.style.position="fixed",this.transcriptWindow.style.left="auto",this.transcriptWindow.style.right="20px",this.transcriptWindow.style.bottom="80px",this.transcriptWindow.style.top="auto",this.transcriptWindow.style.maxHeight="calc(100vh - 180px)",this.transcriptWindow.style.height="auto";let s=260,a=Math.max(s,window.innerWidth-40),r=parseFloat(this.transcriptWindow.style.width)||400,n=Math.max(s,Math.min(r,a));this.transcriptWindow.style.width=`${n}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.borderTop="",this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}else{let s=parseFloat(this.transcriptWindow.style.width)||400,a=20,r=260,n=this.player.container.getBoundingClientRect();(()=>{window.getComputedStyle(this.player.container).position==="static"&&(this.player.container.style.position="relative")})();let c=t.right-n.left+a,p=window.innerWidth-t.right-a,g=Math.max(r,Math.min(s,p)),y=t.height;this.transcriptWindow.style.position="absolute",this.transcriptWindow.style.left=`${c}px`,this.transcriptWindow.style.right="auto",this.transcriptWindow.style.bottom="auto",this.transcriptWindow.style.top="0",this.transcriptWindow.style.height=`${y}px`,this.transcriptWindow.style.maxHeight="none",this.transcriptWindow.style.width=`${g}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.borderTop="",this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}}getAvailableTranscriptLanguages(){let e=this.player.textTracks,t=new Map;return e.forEach(i=>{(i.kind==="captions"||i.kind==="subtitles")&&i.language&&(t.has(i.language)||t.set(i.language,{language:i.language,label:i.label||i.language,track:i}))}),Array.from(t.values())}updateLanguageSelector(){if(this.languageSelector){if(this.availableTranscriptLanguages=this.getAvailableTranscriptLanguages(),this.languageSelector.innerHTML="",this.availableTranscriptLanguages.length<2){this.languageSelector.style.display="none";return}if(this.languageSelector.style.display="block",this.availableTranscriptLanguages.forEach((e,t)=>{let i=l.createElement("option",{textContent:e.label,attributes:{value:e.language}});this.languageSelector.appendChild(i)}),this.currentTranscriptLanguage)this.languageSelector.value=this.currentTranscriptLanguage;else if(this.availableTranscriptLanguages.length>0){let e=this.player.textTracks.find(t=>(t.kind==="captions"||t.kind==="subtitles")&&t.mode==="showing");this.currentTranscriptLanguage=e?e.language:this.availableTranscriptLanguages[0].language,this.languageSelector.value=this.currentTranscriptLanguage}this.languageSelectorHandler&&this.languageSelector.removeEventListener("change",this.languageSelectorHandler),this.languageSelectorHandler=e=>{this.currentTranscriptLanguage=e.target.value,this.loadTranscriptData()},this.languageSelector.addEventListener("change",this.languageSelectorHandler)}}loadTranscriptData(){this.transcriptEntries=[],this.transcriptContent.innerHTML="";let e=this.player.textTracks,t=null;this.currentTranscriptLanguage&&(t=e.find(o=>(o.kind==="captions"||o.kind==="subtitles")&&o.language===this.currentTranscriptLanguage)),t||(t=e.find(o=>o.kind==="captions"||o.kind==="subtitles"),t&&(this.currentTranscriptLanguage=t.language));let i=null;this.currentTranscriptLanguage&&(i=e.find(o=>o.kind==="descriptions"&&o.language===this.currentTranscriptLanguage)),i||(i=e.find(o=>o.kind==="descriptions"));let s=e.find(o=>o.kind==="metadata");if(!t&&!i&&!s){this.showNoTranscriptMessage();return}let a=[t,i,s].filter(Boolean);if(a.forEach(o=>{o.mode==="disabled"&&(o.mode="hidden")}),a.some(o=>!o.cues||o.cues.length===0)){let o=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-loading`,textContent:d.t("transcript.loading")});this.transcriptContent.appendChild(o);let c=0,p=()=>{c++,c>=a.length&&this.loadTranscriptData()};a.forEach(g=>{g.addEventListener("load",p,{once:!0})}),this.setManagedTimeout(()=>{this.loadTranscriptData()},500);return}let n=[];t&&t.cues&&Array.from(t.cues).forEach(o=>{n.push({cue:o,type:"caption"})}),i&&i.cues&&Array.from(i.cues).forEach(o=>{n.push({cue:o,type:"description"})}),s&&s.cues&&(this.metadataCues=Array.from(s.cues),this.setupMetadataHandling()),n.sort((o,c)=>o.cue.startTime-c.cue.startTime),n.forEach((o,c)=>{let p=this.createTranscriptEntry(o.cue,c,o.type);this.transcriptEntries.push({element:p,cue:o.cue,type:o.type,startTime:o.cue.startTime,endTime:o.cue.endTime}),this.transcriptContent.appendChild(p)}),this.applyTranscriptStyles(),this.updateLanguageSelector()}setupMetadataHandlingOnLoad(){let e=()=>{let i=this.player.textTracks.find(s=>s.kind==="metadata");if(i){if(i.mode==="disabled"&&(i.mode="hidden"),this.metadataCueChangeHandler&&i.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=()=>{let s=Array.from(i.activeCues||[]);s.length>0&&this.player.options.debug&&console.log("[VidPly Metadata] Active cues:",s.map(a=>({start:a.startTime,end:a.endTime,text:a.text}))),s.forEach(a=>{this.handleMetadataCue(a)})},i.addEventListener("cuechange",this.metadataCueChangeHandler),this.player.options.debug){let s=i.cues?i.cues.length:0;console.log("[VidPly Metadata] Track enabled,",s,"cues available")}}else this.player.options.debug&&console.warn("[VidPly Metadata] No metadata track found")};e(),this.player.on("loadedmetadata",e)}setupMetadataHandling(){!this.metadataCues||this.metadataCues.length===0||this.player.options.debug&&console.log("[VidPly Metadata]",this.metadataCues.length,"cues stored from transcript load")}handleMetadataCue(e){let t=e.text.trim();this.player.options.debug&&console.log("[VidPly Metadata] Processing cue:",{time:e.startTime,text:t}),this.player.emit("metadata",{time:e.startTime,endTime:e.endTime,text:t,cue:e}),t.includes("PAUSE")&&(this.player.state.paused||(this.player.options.debug&&console.log("[VidPly Metadata] Pausing video at",e.startTime),this.player.pause()),this.player.emit("metadata:pause",{time:e.startTime,text:t}));let i=t.match(/FOCUS:([\w#-]+)/);if(i){let a=i[1],r=document.querySelector(a);r?(this.player.options.debug&&console.log("[VidPly Metadata] Focusing element:",a),this.setManagedTimeout(()=>{r.focus()},10)):this.player.options.debug&&console.warn("[VidPly Metadata] Element not found:",a),this.player.emit("metadata:focus",{time:e.startTime,target:a,element:r,text:t})}let s=t.match(/#[\w-]+/g);s&&(this.player.options.debug&&console.log("[VidPly Metadata] Hashtags found:",s),this.player.emit("metadata:hashtags",{time:e.startTime,hashtags:s,text:t}))}createTranscriptEntry(e,t,i="caption"){let s=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-entry ${this.player.options.classPrefix}-transcript-${i}`,attributes:{"data-start":String(e.startTime),"data-end":String(e.endTime),"data-type":i,role:"button",tabindex:"0"}}),a=l.createElement("span",{className:`${this.player.options.classPrefix}-transcript-time`,textContent:L.formatTime(e.startTime)}),r=l.createElement("span",{className:`${this.player.options.classPrefix}-transcript-text`,textContent:this.stripVTTFormatting(e.text)});s.appendChild(a),s.appendChild(r);let n=()=>{this.player.seek(e.startTime),this.player.state.paused&&this.player.play()};return s.addEventListener("click",n),s.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),n())}),s}stripVTTFormatting(e){return e.replace(/<[^>]+>/g,"").replace(/\n/g," ").trim()}showNoTranscriptMessage(){let e=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-empty`,textContent:d.t("transcript.noTranscript")});this.transcriptContent.appendChild(e)}updateActiveEntry(){if(!this.isVisible||this.transcriptEntries.length===0)return;let e=this.player.state.currentTime,t=this.transcriptEntries.find(i=>e>=i.startTime&&e<i.endTime);t&&t!==this.currentActiveEntry?(this.currentActiveEntry&&this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),t.element.classList.add(`${this.player.options.classPrefix}-transcript-entry-active`),this.scrollToEntry(t.element),this.currentActiveEntry=t):!t&&this.currentActiveEntry&&(this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),this.currentActiveEntry=null)}scrollToEntry(e){if(!this.transcriptContent||!this.autoscrollEnabled)return;let t=this.transcriptContent.getBoundingClientRect(),i=e.getBoundingClientRect();if(i.top<t.top||i.bottom>t.bottom){let s=e.offsetTop-this.transcriptContent.clientHeight/2+e.clientHeight/2;this.transcriptContent.scrollTo({top:s,behavior:"smooth"})}}saveAutoscrollPreference(){let e=this.storage.getTranscriptPreferences()||{};e.autoscroll=this.autoscrollEnabled,this.storage.saveTranscriptPreferences(e)}setupDragAndDrop(){if(!this.transcriptHeader||!this.transcriptWindow)return;let e=window.innerWidth<640,t=this.player.state.fullscreen;e&&!t||(this.draggableResizable=new D(this.transcriptWindow,{dragHandle:this.transcriptHeader,resizeHandles:this.transcriptResizeHandles,constrainToViewport:!0,classPrefix:`${this.player.options.classPrefix}-transcript`,keyboardDragKey:"d",keyboardResizeKey:"r",keyboardStep:10,keyboardStepLarge:50,minWidth:300,minHeight:200,maxWidth:()=>Math.max(320,window.innerWidth-40),maxHeight:()=>Math.max(200,window.innerHeight-120),pointerResizeIndicatorText:d.t("transcript.resizeModeHint"),onPointerResizeToggle:i=>this.onPointerResizeModeChange(i),onDragStart:i=>{let s=[`.${this.player.options.classPrefix}-transcript-close`,`.${this.player.options.classPrefix}-transcript-settings`,`.${this.player.options.classPrefix}-transcript-language-select`,`.${this.player.options.classPrefix}-transcript-settings-menu`,`.${this.player.options.classPrefix}-transcript-style-dialog`];for(let a of s)if(i.target.closest(a))return!1;return!0}}),this.customKeyHandler=i=>{let s=i.key.toLowerCase(),a=i.defaultPrevented;if(s==="home"){i.preventDefault(),i.stopPropagation(),this.draggableResizable&&(this.draggableResizable.pointerResizeMode&&this.draggableResizable.disablePointerResizeMode(),this.draggableResizable.manuallyPositioned=!1,this.positionTranscript(),this.updateResizeOptionState(),this.announceLive(d.t("transcript.positionReset")));return}if(s==="r"){if(a)return;i.preventDefault(),i.stopPropagation(),this.toggleResizeMode()&&this.transcriptWindow.focus();return}if(s==="escape"){if(i.preventDefault(),i.stopPropagation(),this.draggableResizable&&this.draggableResizable.pointerResizeMode){this.draggableResizable.disablePointerResizeMode();return}this.styleDialogVisible?this.hideStyleDialog():this.draggableResizable&&this.draggableResizable.keyboardDragMode?(this.draggableResizable.disableKeyboardDragMode(),this.announceLive(d.t("transcript.dragModeDisabled"))):this.settingsMenuVisible?this.hideSettingsMenu():this.hideTranscript({focusButton:!0});return}},this.transcriptWindow.addEventListener("keydown",this.customKeyHandler))}toggleKeyboardDragMode(){if(this.draggableResizable){let e=this.draggableResizable.keyboardDragMode;this.draggableResizable.toggleKeyboardDragMode();let t=this.draggableResizable.keyboardDragMode;!e&&t&&this.enableMoveMode(),this.settingsMenuVisible&&this.hideSettingsMenu(),this.transcriptWindow.focus()}}toggleSettingsMenu(){this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()}showSettingsMenu(){if(this.settingsMenuJustOpened=!0,setTimeout(()=>{this.settingsMenuJustOpened=!1},350),this.documentClickHandlerAdded||setTimeout(()=>{document.addEventListener("click",this.handlers.documentClick),this.documentClickHandlerAdded=!0},300),this.settingsMenu){this.settingsMenu.style.display="block",this.settingsMenuVisible=!0,this.settingsButton&&this.settingsButton.setAttribute("aria-expanded","true"),this.updateResizeOptionState(),setTimeout(()=>{let m=this.settingsMenu.querySelector(`.${this.player.options.classPrefix}-transcript-settings-item`);m&&m.focus()},0);return}this.settingsMenu=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-settings-menu`});let e=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":d.t("transcript.keyboardDragMode")}}),t=b("move"),i=l.createElement("span",{textContent:d.t("transcript.keyboardDragMode")});e.appendChild(t),e.appendChild(i),e.addEventListener("click",()=>{this.toggleKeyboardDragMode(),this.hideSettingsMenu()});let s=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":d.t("transcript.styleTranscript")}}),a=b("settings"),r=l.createElement("span",{textContent:d.t("transcript.styleTranscript")});s.appendChild(a),s.appendChild(r),s.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this.hideSettingsMenu(),setTimeout(()=>{this.showStyleDialog()},50)});let n=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":d.t("transcript.resizeWindow"),"aria-pressed":"false"}}),o=b("resize"),c=l.createElement("span",{className:`${this.player.options.classPrefix}-transcript-settings-text`,textContent:d.t("transcript.resizeWindow")});n.appendChild(o),n.appendChild(c),n.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this.toggleResizeMode({focus:!1})?(this.hideSettingsMenu({focusButton:!1}),this.setManagedTimeout(()=>{this.transcriptWindow&&this.transcriptWindow.focus()},20)):this.hideSettingsMenu({focusButton:!0})}),this.resizeOptionButton=n,this.resizeOptionText=c,this.updateResizeOptionState();let p=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings-item`,attributes:{type:"button","aria-label":d.t("transcript.closeMenu")}}),g=b("close"),y=l.createElement("span",{textContent:d.t("transcript.closeMenu")});p.appendChild(g),p.appendChild(y),p.addEventListener("click",()=>{this.hideSettingsMenu()}),this.settingsMenu.appendChild(e),this.settingsMenu.appendChild(n),this.settingsMenu.appendChild(s),this.settingsMenu.appendChild(p),this.headerLeft?this.headerLeft.appendChild(this.settingsMenu):this.transcriptHeader.appendChild(this.settingsMenu),this.settingsMenuVisible=!0,this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.setAttribute("aria-expanded","true"),this.updateResizeOptionState(),setTimeout(()=>{let m=this.settingsMenu.querySelector(`.${this.player.options.classPrefix}-transcript-settings-item`);m&&m.focus()},0)}hideSettingsMenu({focusButton:e=!0}={}){this.settingsMenu&&(this.settingsMenu.style.display="none",this.settingsMenuVisible=!1,this.settingsMenuJustOpened=!1,this.settingsButton&&(this.settingsButton.setAttribute("aria-expanded","false"),e&&this.settingsButton.focus()))}enableMoveMode(){this.hideResizeModeIndicator(),this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-move-mode`);let e=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-move-tooltip`,textContent:"Drag with mouse or press D for keyboard drag mode"});this.transcriptHeader.appendChild(e),setTimeout(()=>{this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-move-mode`),e.parentNode&&e.remove()},2e3)}toggleResizeMode({focus:e=!0}={}){return this.draggableResizable?this.draggableResizable.pointerResizeMode?(this.draggableResizable.disablePointerResizeMode({focus:e}),!1):(this.draggableResizable.enablePointerResizeMode({focus:e}),!0):!1}updateResizeOptionState(){if(!this.resizeOptionButton)return;let e=!!(this.draggableResizable&&this.draggableResizable.pointerResizeMode),t=e?d.t("transcript.disableResizeWindow")||"Disable Resize Mode":d.t("transcript.resizeWindow");this.resizeOptionButton.setAttribute("aria-pressed",e?"true":"false"),this.resizeOptionButton.setAttribute("aria-label",t),this.resizeOptionButton.setAttribute("title",t),this.resizeOptionText&&(this.resizeOptionText.textContent=t)}showResizeModeIndicator(){if(!this.transcriptHeader)return;this.hideResizeModeIndicator();let e=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-tooltip`,textContent:d.t("transcript.resizeModeHint")||"Resize handles enabled. Drag edges or corners to adjust. Press Esc or R to exit."});this.transcriptHeader.appendChild(e),this.resizeModeIndicator=e,this.resizeModeIndicatorTimeout=this.setManagedTimeout(()=>{this.hideResizeModeIndicator()},3e3)}hideResizeModeIndicator(){this.resizeModeIndicatorTimeout&&(this.clearManagedTimeout(this.resizeModeIndicatorTimeout),this.resizeModeIndicatorTimeout=null),this.resizeModeIndicator&&this.resizeModeIndicator.parentNode&&this.resizeModeIndicator.remove(),this.resizeModeIndicator=null}onPointerResizeModeChange(e){this.updateResizeOptionState(),e?(this.showResizeModeIndicator(),this.announceLive(d.t("transcript.resizeModeEnabled"))):(this.hideResizeModeIndicator(),this.announceLive(d.t("transcript.resizeModeDisabled")))}showStyleDialog(){if(this.styleDialog){this.styleDialog.style.display="block",this.styleDialogVisible=!0,this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let o=this.styleDialog.querySelector("select, input");o&&o.focus()},0);return}this.styleDialog=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-dialog`});let e=l.createElement("h4",{textContent:d.t("transcript.styleTitle"),className:`${this.player.options.classPrefix}-transcript-style-title`});this.styleDialog.appendChild(e);let t=this.createStyleSelectControl(d.t("captions.fontSize"),"fontSize",[{label:d.t("fontSizes.small"),value:"87.5%"},{label:d.t("fontSizes.normal"),value:"100%"},{label:d.t("fontSizes.large"),value:"125%"},{label:d.t("fontSizes.xlarge"),value:"150%"}]);this.styleDialog.appendChild(t);let i=this.createStyleSelectControl(d.t("captions.fontFamily"),"fontFamily",[{label:d.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:d.t("fontFamilies.serif"),value:"serif"},{label:d.t("fontFamilies.monospace"),value:"monospace"}]);this.styleDialog.appendChild(i);let s=this.createStyleColorControl(d.t("captions.color"),"color");this.styleDialog.appendChild(s);let a=this.createStyleColorControl(d.t("captions.backgroundColor"),"backgroundColor");this.styleDialog.appendChild(a);let r=this.createStyleOpacityControl(d.t("captions.opacity"),"opacity");this.styleDialog.appendChild(r);let n=l.createElement("button",{className:`${this.player.options.classPrefix}-transcript-style-close`,textContent:d.t("settings.close"),attributes:{type:"button"}});n.addEventListener("click",()=>this.hideStyleDialog()),this.styleDialog.appendChild(n),this.handlers.styleDialogKeydown=o=>{o.key==="Escape"&&(o.preventDefault(),o.stopPropagation(),this.hideStyleDialog())},this.styleDialog.addEventListener("keydown",this.handlers.styleDialogKeydown),this.headerLeft?this.headerLeft.appendChild(this.styleDialog):this.transcriptHeader.appendChild(this.styleDialog),this.applyTranscriptStyles(),this.styleDialogVisible=!0,this.styleDialog.style.display="block",this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let o=this.styleDialog.querySelector("select, input");o&&o.focus()},0)}hideStyleDialog(){this.styleDialog&&(this.styleDialog.style.display="none",this.styleDialogVisible=!1,this.settingsButton&&this.settingsButton.focus())}createStyleSelectControl(e,t,i){let s=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=l.createElement("label",{textContent:e});s.appendChild(a);let r=l.createElement("select",{className:`${this.player.options.classPrefix}-transcript-style-select`});return i.forEach(n=>{let o=l.createElement("option",{textContent:n.label,attributes:{value:n.value}});this.transcriptStyle[t]===n.value&&(o.selected=!0),r.appendChild(o)}),r.addEventListener("change",n=>{this.transcriptStyle[t]=n.target.value,this.applyTranscriptStyles(),this.savePreferences()}),s.appendChild(r),s}createStyleColorControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),s=l.createElement("label",{textContent:e});i.appendChild(s);let a=l.createElement("input",{attributes:{type:"color",value:this.transcriptStyle[t]},className:`${this.player.options.classPrefix}-transcript-style-color`});return a.addEventListener("input",r=>{this.transcriptStyle[t]=r.target.value,this.applyTranscriptStyles(),this.savePreferences()}),i.appendChild(a),i}createStyleOpacityControl(e,t){let i=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),s=l.createElement("label",{textContent:e});i.appendChild(s);let a=l.createElement("span",{textContent:Math.round(this.transcriptStyle[t]*100)+"%",className:`${this.player.options.classPrefix}-transcript-style-value`}),r=l.createElement("input",{attributes:{type:"range",min:"0",max:"1",step:"0.1",value:String(this.transcriptStyle[t])},className:`${this.player.options.classPrefix}-transcript-style-range`});r.addEventListener("input",o=>{let c=parseFloat(o.target.value);this.transcriptStyle[t]=c,a.textContent=Math.round(c*100)+"%",this.applyTranscriptStyles(),this.savePreferences()});let n=l.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-range-container`});return n.appendChild(r),n.appendChild(a),i.appendChild(s),i.appendChild(n),i}savePreferences(){this.storage.saveTranscriptPreferences(this.transcriptStyle)}applyTranscriptStyles(){if(!this.transcriptWindow)return;this.transcriptWindow.style.backgroundColor=this.transcriptStyle.backgroundColor,this.transcriptWindow.style.opacity=String(this.transcriptStyle.opacity),this.transcriptContent&&(this.transcriptContent.style.fontSize=this.transcriptStyle.fontSize,this.transcriptContent.style.fontFamily=this.transcriptStyle.fontFamily,this.transcriptContent.style.color=this.transcriptStyle.color),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-text`).forEach(i=>{i.style.fontSize=this.transcriptStyle.fontSize,i.style.fontFamily=this.transcriptStyle.fontFamily,i.style.color=this.transcriptStyle.color}),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(i=>{i.style.fontFamily=this.transcriptStyle.fontFamily})}setManagedTimeout(e,t){let i=setTimeout(()=>{this.timeouts.delete(i),e()},t);return this.timeouts.add(i),i}clearManagedTimeout(e){e&&(clearTimeout(e),this.timeouts.delete(e))}destroy(){this.hideResizeModeIndicator(),this.draggableResizable&&(this.draggableResizable.pointerResizeMode&&(this.draggableResizable.disablePointerResizeMode(),this.updateResizeOptionState()),this.draggableResizable.destroy(),this.draggableResizable=null),this.transcriptWindow&&this.customKeyHandler&&(this.transcriptWindow.removeEventListener("keydown",this.customKeyHandler),this.customKeyHandler=null),this.handlers.timeupdate&&this.player.off("timeupdate",this.handlers.timeupdate),this.settingsButton&&(this.handlers.settingsClick&&this.settingsButton.removeEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown&&this.settingsButton.removeEventListener("keydown",this.handlers.settingsKeydown)),this.styleDialog&&this.handlers.styleDialogKeydown&&this.styleDialog.removeEventListener("keydown",this.handlers.styleDialogKeydown),this.handlers.documentClick&&document.removeEventListener("click",this.handlers.documentClick),this.handlers.resize&&window.removeEventListener("resize",this.handlers.resize),this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts.clear(),this.handlers=null,this.transcriptWindow&&this.transcriptWindow.parentNode&&this.transcriptWindow.parentNode.removeChild(this.transcriptWindow),this.transcriptWindow=null,this.transcriptHeader=null,this.transcriptContent=null,this.transcriptEntries=[],this.settingsMenu=null,this.styleDialog=null,this.transcriptResizeHandles=[],this.resizeOptionButton=null,this.resizeOptionText=null,this.liveRegion=null}announceLive(e){this.liveRegion&&(this.liveRegion.textContent=e||"")}};Q();var F=class{constructor(e){this.player=e,this.youtube=null,this.videoId=null,this.isReady=!1,this.iframe=null}async init(){if(this.videoId=this.extractVideoId(this.player.element.src),!this.videoId)throw new Error("Invalid YouTube URL");await this.loadYouTubeAPI(),this.createIframe(),await this.initializePlayer()}extractVideoId(e){let t=[/(?:youtube\.com\/watch\?v=|youtu\.be\/)([^&\s]+)/,/youtube\.com\/embed\/([^&\s]+)/];for(let i of t){let s=e.match(i);if(s&&s[1])return s[1]}return null}async loadYouTubeAPI(){return window.YT&&window.YT.Player?Promise.resolve():new Promise((e,t)=>{if(window.onYouTubeIframeAPIReady){let a=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{a(),e()};return}let i=document.createElement("script");i.src="https://www.youtube.com/iframe_api",window.onYouTubeIframeAPIReady=()=>{e()},i.onerror=()=>t(new Error("Failed to load YouTube API"));let s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(i,s)})}createIframe(){this.player.element.style.display="none",this.iframe=document.createElement("div"),this.iframe.id=`youtube-player-${Math.random().toString(36).substr(2,9)}`,this.iframe.style.width="100%",this.iframe.style.height="100%",this.player.element.parentNode.insertBefore(this.iframe,this.player.element)}async initializePlayer(){return new Promise(e=>{this.youtube=new window.YT.Player(this.iframe.id,{videoId:this.videoId,width:"100%",height:"100%",playerVars:{controls:0,disablekb:1,fs:0,modestbranding:1,rel:0,showinfo:0,iv_load_policy:3,autoplay:this.player.options.autoplay?1:0,mute:this.player.options.muted?1:0,start:this.player.options.startTime||0},events:{onReady:t=>{this.isReady=!0,this.attachEvents(),e()},onStateChange:t=>this.handleStateChange(t),onError:t=>this.handleError(t)}})})}attachEvents(){this.timeUpdateInterval=setInterval(()=>{if(this.isReady&&this.youtube){let e=this.youtube.getCurrentTime(),t=this.youtube.getDuration();this.player.state.currentTime=e,this.player.state.duration=t,this.player.emit("timeupdate",e)}},250),this.youtube.getDuration&&(this.player.state.duration=this.youtube.getDuration(),this.player.emit("loadedmetadata"))}handleStateChange(e){let t=window.YT.PlayerState;switch(e.data){case t.PLAYING:this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.state.buffering=!1,this.player.emit("play"),this.player.emit("playing"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player);break;case t.PAUSED:this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player);break;case t.ENDED:this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.youtube.seekTo(0),this.youtube.playVideo());break;case t.BUFFERING:this.player.state.buffering=!0,this.player.emit("waiting");break;case t.CUED:this.player.emit("loadedmetadata");break}}handleError(e){let t={2:"Invalid video ID",5:"HTML5 player error",100:"Video not found",101:"Video not allowed to be played in embedded players",150:"Video not allowed to be played in embedded players"},i=new Error(t[e.data]||"YouTube player error");this.player.handleError(i)}play(){this.isReady&&this.youtube&&this.youtube.playVideo()}pause(){this.isReady&&this.youtube&&this.youtube.pauseVideo()}seek(e){this.isReady&&this.youtube&&this.youtube.seekTo(e,!0)}setVolume(e){this.isReady&&this.youtube&&(this.youtube.setVolume(e*100),this.player.state.volume=e)}setMuted(e){this.isReady&&this.youtube&&(e?this.youtube.mute():this.youtube.unMute(),this.player.state.muted=e)}setPlaybackSpeed(e){this.isReady&&this.youtube&&(this.youtube.setPlaybackRate(e),this.player.state.playbackSpeed=e)}destroy(){this.timeUpdateInterval&&clearInterval(this.timeUpdateInterval),this.youtube&&this.youtube.destroy&&this.youtube.destroy(),this.iframe&&this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.player.element&&(this.player.element.style.display="")}};var O=class{constructor(e){this.player=e,this.vimeo=null,this.videoId=null,this.isReady=!1,this.iframe=null}async init(){if(this.videoId=this.extractVideoId(this.player.element.src),!this.videoId)throw new Error("Invalid Vimeo URL");await this.loadVimeoAPI(),this.createIframe(),await this.initializePlayer()}extractVideoId(e){let t=[/vimeo\.com\/(\d+)/,/vimeo\.com\/video\/(\d+)/,/player\.vimeo\.com\/video\/(\d+)/];for(let i of t){let s=e.match(i);if(s&&s[1])return s[1]}return null}async loadVimeoAPI(){return window.Vimeo&&window.Vimeo.Player?Promise.resolve():new Promise((e,t)=>{let i=document.createElement("script");i.src="https://player.vimeo.com/api/player.js",i.onload=()=>e(),i.onerror=()=>t(new Error("Failed to load Vimeo API")),document.head.appendChild(i)})}createIframe(){this.player.element.style.display="none",this.iframe=document.createElement("div"),this.iframe.id=`vimeo-player-${Math.random().toString(36).substr(2,9)}`,this.iframe.style.width="100%",this.iframe.style.height="100%",this.player.element.parentNode.insertBefore(this.iframe,this.player.element)}async initializePlayer(){let e={id:this.videoId,width:"100%",height:"100%",controls:!1,autoplay:this.player.options.autoplay,muted:this.player.options.muted,loop:this.player.options.loop,keyboard:!1};this.player.options.startTime>0&&(e.startTime=this.player.options.startTime),this.vimeo=new window.Vimeo.Player(this.iframe.id,e),await this.vimeo.ready(),this.isReady=!0,this.attachEvents();try{let t=await this.vimeo.getDuration();this.player.state.duration=t,this.player.emit("loadedmetadata")}catch(t){this.player.log("Error getting duration:",t,"warn")}}attachEvents(){this.vimeo.on("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)}),this.vimeo.on("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.vimeo.on("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player)}),this.vimeo.on("timeupdate",e=>{this.player.state.currentTime=e.seconds,this.player.state.duration=e.duration,this.player.emit("timeupdate",e.seconds),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,e.seconds)}),this.vimeo.on("volumechange",e=>{this.player.state.volume=e.volume,this.player.emit("volumechange",e.volume)}),this.vimeo.on("bufferstart",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.vimeo.on("bufferend",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.vimeo.on("seeking",()=>{this.player.state.seeking=!0,this.player.emit("seeking")}),this.vimeo.on("seeked",()=>{this.player.state.seeking=!1,this.player.emit("seeked")}),this.vimeo.on("playbackratechange",e=>{this.player.state.playbackSpeed=e.playbackRate,this.player.emit("ratechange",e.playbackRate)}),this.vimeo.on("error",e=>{this.player.handleError(new Error(`Vimeo error: ${e.message}`))})}play(){this.isReady&&this.vimeo&&this.vimeo.play().catch(e=>{this.player.log("Play error:",e,"warn")})}pause(){this.isReady&&this.vimeo&&this.vimeo.pause().catch(e=>{this.player.log("Pause error:",e,"warn")})}seek(e){this.isReady&&this.vimeo&&this.vimeo.setCurrentTime(e).catch(t=>{this.player.log("Seek error:",t,"warn")})}setVolume(e){this.isReady&&this.vimeo&&(this.vimeo.setVolume(e).catch(t=>{this.player.log("Volume error:",t,"warn")}),this.player.state.volume=e)}setMuted(e){this.isReady&&this.vimeo&&(e?this.vimeo.setVolume(0):this.vimeo.setVolume(this.player.state.volume),this.player.state.muted=e)}setPlaybackSpeed(e){this.isReady&&this.vimeo&&(this.vimeo.setPlaybackRate(e).catch(t=>{this.player.log("Playback rate error:",t,"warn")}),this.player.state.playbackSpeed=e)}destroy(){this.vimeo&&this.vimeo.destroy&&this.vimeo.destroy(),this.iframe&&this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.player.element&&(this.player.element.style.display="")}};var I=class{constructor(e){this.player=e,this.media=e.element,this.hls=null}async init(){this.canPlayNatively()?(this.player.log("Using native HLS support"),await this.initNative()):(this.player.log("Using hls.js for HLS support"),await this.initHlsJs())}canPlayNatively(){return document.createElement("video").canPlayType("application/vnd.apple.mpegurl")!==""}async initNative(){let e=(await Promise.resolve().then(()=>(Q(),G))).HTML5Renderer,t=new e(this.player);await t.init(),Object.getOwnPropertyNames(Object.getPrototypeOf(t)).forEach(i=>{i!=="constructor"&&typeof t[i]=="function"&&(this[i]=t[i].bind(t))})}async initHlsJs(){if(this.media.controls=!1,this.media.removeAttribute("controls"),window.Hls||await this.loadHlsJs(),!window.Hls.isSupported())throw new Error("HLS is not supported in this browser");this.hls=new window.Hls({debug:this.player.options.debug,enableWorker:!0,lowLatencyMode:!1,backBufferLength:90,maxBufferLength:30,maxMaxBufferLength:600,maxBufferSize:60*1e3*1e3,maxBufferHole:.5,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:4,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3}),this.hls.attachMedia(this.media);let e,t=this.player.element.querySelector("source");if(t?e=t.getAttribute("src"):e=this.player.element.getAttribute("src")||this.player.element.src,this.player.log(`Loading HLS source: ${e}`,"log"),!e)throw new Error("No HLS source found");this.hls.loadSource(e),this.attachHlsEvents(),this.attachMediaEvents()}async loadHlsJs(){return new Promise((e,t)=>{let i=document.createElement("script");i.src="https://cdn.jsdelivr.net/npm/hls.js@latest",i.onload=()=>e(),i.onerror=()=>t(new Error("Failed to load hls.js")),document.head.appendChild(i)})}attachHlsEvents(){this.hls.on(window.Hls.Events.MANIFEST_PARSED,(e,t)=>{this.player.log("HLS manifest loaded, found "+t.levels.length+" quality levels"),this.player.emit("hlsmanifestparsed",t)}),this.hls.on(window.Hls.Events.LEVEL_SWITCHED,(e,t)=>{this.player.log("HLS level switched to "+t.level),this.player.emit("hlslevelswitched",t)}),this.hls.on(window.Hls.Events.ERROR,(e,t)=>{this.handleHlsError(t)}),this.hls.on(window.Hls.Events.FRAG_BUFFERED,()=>{this.player.state.buffering=!1})}attachMediaEvents(){this.media.addEventListener("loadedmetadata",()=>{this.player.state.duration=this.media.duration,this.player.emit("loadedmetadata")}),this.media.addEventListener("play",()=>{this.player.state.playing=!0,this.player.state.paused=!1,this.player.state.ended=!1,this.player.emit("play"),this.player.options.onPlay&&this.player.options.onPlay.call(this.player)}),this.media.addEventListener("pause",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.emit("pause"),this.player.options.onPause&&this.player.options.onPause.call(this.player)}),this.media.addEventListener("ended",()=>{this.player.state.playing=!1,this.player.state.paused=!0,this.player.state.ended=!0,this.player.emit("ended"),this.player.options.onEnded&&this.player.options.onEnded.call(this.player),this.player.options.loop&&(this.player.seek(0),this.player.play())}),this.media.addEventListener("timeupdate",()=>{this.player.state.currentTime=this.media.currentTime,this.player.emit("timeupdate",this.media.currentTime),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,this.media.currentTime)}),this.media.addEventListener("volumechange",()=>{this.player.state.volume=this.media.volume,this.player.state.muted=this.media.muted,this.player.emit("volumechange",this.media.volume)}),this.media.addEventListener("waiting",()=>{this.player.state.buffering=!0,this.player.emit("waiting")}),this.media.addEventListener("canplay",()=>{this.player.state.buffering=!1,this.player.emit("canplay")}),this.media.addEventListener("error",()=>{this.player.handleError(this.media.error)})}handleHlsError(e){if(this.player.log(`HLS Error - Type: ${e.type}, Details: ${e.details}, Fatal: ${e.fatal}`,"warn"),e.response&&this.player.log(`Response code: ${e.response.code}, URL: ${e.response.url}`,"warn"),e.fatal)switch(e.type){case window.Hls.ErrorTypes.NETWORK_ERROR:this.player.log("Fatal network error, trying to recover...","error"),this.player.log(`Network error details: ${e.details}`,"error"),setTimeout(()=>{this.hls.startLoad()},1e3);break;case window.Hls.ErrorTypes.MEDIA_ERROR:this.player.log("Fatal media error, trying to recover...","error"),this.hls.recoverMediaError();break;default:this.player.log("Fatal error, cannot recover","error"),this.player.handleError(new Error(`HLS Error: ${e.type} - ${e.details}`)),this.hls.destroy();break}else this.player.log("Non-fatal HLS error: "+e.details,"warn")}play(){let e=this.media.play();e!==void 0&&e.catch(t=>{this.player.log("Play failed:",t,"warn")})}pause(){this.media.pause()}seek(e){this.media.currentTime=e}setVolume(e){this.media.volume=e}setMuted(e){this.media.muted=e}setPlaybackSpeed(e){this.media.playbackRate=e}switchQuality(e){this.hls&&(this.hls.currentLevel=e)}getQualities(){return this.hls&&this.hls.levels?this.hls.levels.map((e,t)=>({index:t,height:e.height,width:e.width,bitrate:e.bitrate,name:`${e.height}p`})):[]}destroy(){this.hls&&(this.hls.destroy(),this.hls=null)}};var z=class h extends V{constructor(e,t={}){if(super(),this.element=typeof e=="string"?document.querySelector(e):e,!this.element)throw new Error("VidPly: Element not found");if(this.element.tagName!=="VIDEO"&&this.element.tagName!=="AUDIO"){let s=t.mediaType||"video",a=document.createElement(s);Array.from(this.element.attributes).forEach(n=>{n.name!=="id"&&n.name!=="class"&&!n.name.startsWith("data-")&&a.setAttribute(n.name,n.value)}),this.element.querySelectorAll("track").forEach(n=>{a.appendChild(n.cloneNode(!0))}),this.element.innerHTML="",this.element.appendChild(a),this.element=a}this.options={width:null,height:null,poster:null,responsive:!0,fillContainer:!1,autoplay:!1,loop:!1,muted:!1,volume:.8,playbackSpeed:1,preload:"metadata",startTime:0,playsInline:!0,controls:!0,hideControlsDelay:3e3,playPauseButton:!0,progressBar:!0,currentTime:!0,duration:!0,volumeControl:!0,muteButton:!0,chaptersButton:!0,qualityButton:!0,captionStyleButton:!0,speedButton:!0,captionsButton:!0,transcriptButton:!0,fullscreenButton:!0,pipButton:!1,seekInterval:10,seekIntervalLarge:30,captions:!0,captionsDefault:!1,captionsFontSize:"100%",captionsFontFamily:"sans-serif",captionsColor:"#FFFFFF",captionsBackgroundColor:"#000000",captionsOpacity:.8,audioDescription:!0,audioDescriptionSrc:null,audioDescriptionButton:!0,signLanguage:!0,signLanguageSrc:null,signLanguageButton:!0,signLanguagePosition:"bottom-right",transcript:!1,transcriptPosition:"external",transcriptContainer:null,keyboard:!0,keyboardShortcuts:{"play-pause":[" ","p","k"],"volume-up":["ArrowUp"],"volume-down":["ArrowDown"],"seek-forward":["ArrowRight"],"seek-backward":["ArrowLeft"],mute:["m"],fullscreen:["f"],captions:["c"],"caption-style-menu":["a"],"speed-up":[">"],"speed-down":["<"],"speed-menu":["s"],"quality-menu":["q"],"chapters-menu":["j"],"transcript-toggle":["t"]},ariaLabels:{},screenReaderAnnouncements:!0,highContrast:!1,focusHighlight:!0,metadataAlerts:{},metadataHashtags:{},language:"en",languages:["en"],debug:!1,classPrefix:"vidply",iconType:"svg",pauseOthersOnPlay:!0,onReady:null,onPlay:null,onPause:null,onEnded:null,onTimeUpdate:null,onVolumeChange:null,onError:null,...t},this.options.metadataAlerts=this.options.metadataAlerts||{},this.options.metadataHashtags=this.options.metadataHashtags||{},this.storage=new P("vidply");let i=this.storage.getPlayerPreferences();i&&(i.volume!==void 0&&(this.options.volume=i.volume),i.playbackSpeed!==void 0&&(this.options.playbackSpeed=i.playbackSpeed),i.muted!==void 0&&(this.options.muted=i.muted)),this.state={ready:!1,playing:!1,paused:!0,ended:!1,buffering:!1,seeking:!1,muted:this.options.muted,volume:this.options.volume,currentTime:0,duration:0,playbackSpeed:this.options.playbackSpeed,fullscreen:!1,pip:!1,captionsEnabled:this.options.captionsDefault,currentCaption:null,controlsVisible:!0,audioDescriptionEnabled:!1,signLanguageEnabled:!1},this.originalSrc=null,this.audioDescriptionSrc=this.options.audioDescriptionSrc,this.signLanguageSrc=this.options.signLanguageSrc,this.signLanguageVideo=null,this.audioDescriptionSourceElement=null,this.originalAudioDescriptionSource=null,this.audioDescriptionCaptionTracks=[],this._audioDescriptionDesiredState=!1,this._textTracksCache=null,this._textTracksDirty=!0,this._sourceElementsCache=null,this._sourceElementsDirty=!0,this._trackElementsCache=null,this._trackElementsDirty=!0,this.timeouts=new Set,this.container=null,this.renderer=null,this.controlBar=null,this.captionManager=null,this.keyboardManager=null,this.settingsDialog=null,this.metadataCueChangeHandler=null,this.metadataAlertHandlers=new Map,this.init()}async init(){var e;try{if(this.log("Initializing VidPly player"),!this.options.language||this.options.language==="en"){let i=this.detectHtmlLanguage();i&&(this.options.language=i,this.log(`Auto-detected language from HTML: ${i}`))}d.setLanguage(this.options.language),this.createContainer(),this.element.src||((e=this.element.querySelector("source"))==null?void 0:e.src)?await this.initializeRenderer():this.log("No initial source - waiting for playlist or manual load"),this.options.controls&&(this.controlBar=new N(this),this.videoWrapper.appendChild(this.controlBar.element)),this.options.captions&&(this.captionManager=new R(this)),(this.options.transcript||this.options.transcriptButton)&&(this.transcriptManager=new H(this)),this.setupMetadataHandling(),this.options.keyboard&&(this.keyboardManager=new W(this)),this.setupResponsiveHandlers(),this.options.startTime>0&&this.seek(this.options.startTime),this.options.muted&&this.mute(),this.options.volume!==.8&&this.setVolume(this.options.volume),this.state.ready=!0,this.emit("ready"),this.options.onReady&&this.options.onReady.call(this),this.options.autoplay&&this.play(),this.log("Player initialized successfully")}catch(t){this.handleError(t)}}detectHtmlLanguage(){let e=document.documentElement.lang||document.documentElement.getAttribute("lang");if(!e)return null;let t=e.toLowerCase().split("-")[0];return["en","de","es","fr","ja"].includes(t)?t:(this.log(`Language "${e}" not available, using English as fallback`),"en")}createContainer(){this.container=l.createElement("div",{className:`${this.options.classPrefix}-player`,attributes:{role:"region","aria-label":d.t("player.label"),tabindex:"0"}});let e=this.element.tagName.toLowerCase();this.container.classList.add(`${this.options.classPrefix}-${e}`),this.options.responsive&&this.container.classList.add(`${this.options.classPrefix}-responsive`),this.videoWrapper=l.createElement("div",{className:`${this.options.classPrefix}-video-wrapper`}),this.element.parentNode.insertBefore(this.container,this.element),this.container.appendChild(this.videoWrapper),this.videoWrapper.appendChild(this.element),this.element.controls=!1,this.element.removeAttribute("controls"),this.element.setAttribute("tabindex","-1"),this.element.style.width="100%",this.element.style.height="100%",this.element.tagName==="VIDEO"&&this.options.playsInline&&(this.element.setAttribute("playsinline",""),this.element.playsInline=!0),this.options.width&&(this.container.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width),this.options.height&&(this.container.style.height=typeof this.options.height=="number"?`${this.options.height}px`:this.options.height),this.options.poster&&this.element.tagName==="VIDEO"&&(this.element.poster=this.options.poster),this.element.tagName==="VIDEO"&&this.createPlayButtonOverlay(),this.element.vidply=this,h.instances.push(this),this.element.style.cursor="pointer",this.element.addEventListener("click",t=>{t.target===this.element&&this.toggle()}),this.on("play",()=>{this.hidePosterOverlay()}),this.on("timeupdate",()=>{this.state.currentTime>0&&this.hidePosterOverlay()})}createPlayButtonOverlay(){this.playButtonOverlay=X(),this.playButtonOverlay.addEventListener("click",()=>{this.toggle()}),this.videoWrapper.appendChild(this.playButtonOverlay),this.on("play",()=>{this.playButtonOverlay.style.opacity="0",this.playButtonOverlay.style.pointerEvents="none"}),this.on("pause",()=>{this.playButtonOverlay.style.opacity="1",this.playButtonOverlay.style.pointerEvents="auto"}),this.on("ended",()=>{this.playButtonOverlay.style.opacity="1",this.playButtonOverlay.style.pointerEvents="auto"})}async initializeRenderer(){var a;let e=this.element.src||((a=this.element.querySelector("source"))==null?void 0:a.src);if(!e)throw new Error("No media source found");let t=this.sourceElements;for(let r of t){let n=r.getAttribute("data-desc-src"),o=r.getAttribute("data-orig-src");if(n||o){if(this.audioDescriptionSourceElement||(this.audioDescriptionSourceElement=r),o)this.originalAudioDescriptionSource||(this.originalAudioDescriptionSource=o),this.originalSrc||(this.originalSrc=o);else{let c=r.getAttribute("src");!this.originalAudioDescriptionSource&&c&&(this.originalAudioDescriptionSource=c),!this.originalSrc&&c&&(this.originalSrc=c)}n&&!this.audioDescriptionSrc&&(this.audioDescriptionSrc=n)}}this.trackElements.forEach(r=>{let n=r.getAttribute("kind"),o=r.getAttribute("data-desc-src");(n==="captions"||n==="subtitles"||n==="chapters")&&o&&(this.audioDescriptionCaptionTracks.push({trackElement:r,originalSrc:r.getAttribute("src"),describedSrc:o,originalTrackSrc:r.getAttribute("data-orig-src")||r.getAttribute("src"),explicit:!0}),this.log(`Found explicit described ${n} track: ${r.getAttribute("src")} -> ${o}`))}),this.originalSrc||(this.originalSrc=e);let s;e.includes("youtube.com")||e.includes("youtu.be")?s=F:e.includes("vimeo.com")?s=O:e.includes(".m3u8")?s=I:s=B,this.log(`Using ${s.name} renderer`),this.renderer=new s(this),await this.renderer.init(),this.invalidateTrackCache()}get textTracks(){return(!this._textTracksCache||this._textTracksDirty)&&(this._textTracksCache=Array.from(this.element.textTracks||[]),this._textTracksDirty=!1),this._textTracksCache}get sourceElements(){return(!this._sourceElementsCache||this._sourceElementsDirty)&&(this._sourceElementsCache=Array.from(this.element.querySelectorAll("source")),this._sourceElementsDirty=!1),this._sourceElementsCache}get trackElements(){return(!this._trackElementsCache||this._trackElementsDirty)&&(this._trackElementsCache=Array.from(this.element.querySelectorAll("track")),this._trackElementsDirty=!1),this._trackElementsCache}invalidateTrackCache(){this._textTracksDirty=!0,this._trackElementsDirty=!0,this._sourceElementsDirty=!0}findTextTrack(e,t=null){let i=this.textTracks;return t?i.find(s=>s.kind===e&&s.language===t):i.find(s=>s.kind===e)}findSourceElement(e,t=null){let i=this.sourceElements;return t?i.find(s=>s.getAttribute(e)===t):i.find(s=>s.hasAttribute(e))}findTrackElement(e){return this.trackElements.find(t=>t.track===e)}showPosterOverlay(){if(!this.videoWrapper||this.element.tagName!=="VIDEO")return;let e=this.element.getAttribute("poster")||this.element.poster||this.options.poster;e&&(this.videoWrapper.style.setProperty("--vidply-poster-image",`url("${e}")`),this.videoWrapper.classList.add("vidply-forced-poster"))}hidePosterOverlay(){this.videoWrapper&&(this.videoWrapper.classList.remove("vidply-forced-poster"),this.videoWrapper.style.removeProperty("--vidply-poster-image"))}setManagedTimeout(e,t){let i=setTimeout(()=>{this.timeouts.delete(i),e()},t);return this.timeouts.add(i),i}clearManagedTimeout(e){e&&(clearTimeout(e),this.timeouts.delete(e))}async load(e){try{this.log("Loading new media:",e.src),this.renderer&&this.pause(),this.trackElements.forEach(s=>s.remove()),this.invalidateTrackCache(),this.element.src=e.src,e.type&&(this.element.type=e.type),e.poster&&this.element.tagName==="VIDEO"&&(this.element.poster=e.poster),e.tracks&&e.tracks.length>0&&(e.tracks.forEach(s=>{let a=document.createElement("track");a.src=s.src,a.kind=s.kind||"captions",a.srclang=s.srclang||"en",a.label=s.label||s.srclang,s.default&&(a.default=!0),this.element.appendChild(a)}),this.invalidateTrackCache());let i=this.shouldChangeRenderer(e.src);if(i&&this.renderer&&(this.renderer.destroy(),this.renderer=null),!this.renderer||i?await this.initializeRenderer():(this.renderer.media=this.element,this.element.load()),this.captionManager&&(this.captionManager.destroy(),this.captionManager=new R(this)),this.transcriptManager){let s=this.transcriptManager.isVisible;this.transcriptManager.destroy(),this.transcriptManager=new H(this),s&&this.transcriptManager.showTranscript()}this.controlBar&&this.updateControlBar(),this.emit("sourcechange",e),this.log("Media loaded successfully")}catch(t){this.handleError(t)}}updateControlBar(){if(!this.controlBar)return;let e=this.controlBar;e.element.innerHTML="",e.createControls(),e.attachEvents(),e.setupAutoHide()}shouldChangeRenderer(e){if(!this.renderer)return!0;let t=e.includes("youtube.com")||e.includes("youtu.be"),i=e.includes("vimeo.com"),s=e.includes(".m3u8"),a=this.renderer.constructor.name;return!!(t&&a!=="YouTubeRenderer"||i&&a!=="VimeoRenderer"||s&&a!=="HLSRenderer"||!t&&!i&&!s&&a!=="HTML5Renderer")}play(){this.renderer&&this.renderer.play()}pause(){this.renderer&&this.renderer.pause()}stop(){this.pause(),this.seek(0)}toggle(){this.state.playing?this.pause():this.play()}seek(e){this.renderer&&this.renderer.seek(e)}seekForward(e=this.options.seekInterval){this.seek(Math.min(this.state.currentTime+e,this.state.duration))}seekBackward(e=this.options.seekInterval){this.seek(Math.max(this.state.currentTime-e,0))}setVolume(e){let t=Math.max(0,Math.min(1,e));this.renderer&&this.renderer.setVolume(t),this.state.volume=t,t>0&&this.state.muted&&(this.state.muted=!1),this.savePlayerPreferences()}getVolume(){return this.state.volume}mute(){this.renderer&&this.renderer.setMuted(!0),this.state.muted=!0,this.savePlayerPreferences(),this.emit("volumechange")}unmute(){this.renderer&&this.renderer.setMuted(!1),this.state.muted=!1,this.savePlayerPreferences(),this.emit("volumechange")}toggleMute(){this.state.muted?this.unmute():this.mute()}setPlaybackSpeed(e){let t=Math.max(.25,Math.min(2,e));this.renderer&&this.renderer.setPlaybackSpeed(t),this.state.playbackSpeed=t,this.savePlayerPreferences(),this.emit("playbackspeedchange",t)}getPlaybackSpeed(){return this.state.playbackSpeed}savePlayerPreferences(){this.storage.savePlayerPreferences({volume:this.state.volume,muted:this.state.muted,playbackSpeed:this.state.playbackSpeed})}enterFullscreen(){let e=this.container;e.requestFullscreen?e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.msRequestFullscreen&&e.msRequestFullscreen(),this.state.fullscreen=!0,this.container.classList.add(`${this.options.classPrefix}-fullscreen`),this.emit("fullscreenchange",!0)}exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),this.state.fullscreen=!1,this.container.classList.remove(`${this.options.classPrefix}-fullscreen`),this.emit("fullscreenchange",!1)}toggleFullscreen(){this.state.fullscreen?this.exitFullscreen():this.enterFullscreen()}enterPiP(){this.element.requestPictureInPicture&&(this.element.requestPictureInPicture(),this.state.pip=!0,this.emit("pipchange",!0))}exitPiP(){document.pictureInPictureElement&&(document.exitPictureInPicture(),this.state.pip=!1,this.emit("pipchange",!1))}togglePiP(){this.state.pip?this.exitPiP():this.enterPiP()}enableCaptions(){this.captionManager&&(this.captionManager.enable(),this.state.captionsEnabled=!0)}disableCaptions(){this.captionManager&&(this.captionManager.disable(),this.state.captionsEnabled=!1)}toggleCaptions(){this.state.captionsEnabled?this.disableCaptions():this.enableCaptions()}async validateTrackExists(e){try{return(await fetch(e,{method:"HEAD",cache:"no-cache"})).ok}catch{return!1}}async enableAudioDescription(){let e=this.sourceElements.some(n=>n.getAttribute("data-desc-src")),t=this.audioDescriptionCaptionTracks.length>0;if(!this.audioDescriptionSrc&&!e&&!t){console.warn("VidPly: No audio description source, source elements, or tracks provided");return}let i=this.state.currentTime,s=this.state.playing,a=!s&&i===0;a&&this.showPosterOverlay();let r=[];if(this.audioDescriptionSourceElement){let n=this.element.currentSrc||this.element.src,o=this.sourceElements,c=null,p=this.audioDescriptionSrc;for(let m of o){let u=m.getAttribute("src"),f=m.getAttribute("data-desc-src"),E=u?u.split("/").pop():"",v=n?n.split("/").pop():"";if(n&&(n===u||n.includes(u)||n.includes(E)||E&&v===E)){c=m,f?p=f:u&&(p=this.audioDescriptionSrc||p);break}}if(!c){c=this.audioDescriptionSourceElement;let m=c.getAttribute("data-desc-src");m&&(p=m)}if(this.audioDescriptionCaptionTracks.length>0){let m=this.audioDescriptionCaptionTracks.map(async E=>{if(E.trackElement&&E.describedSrc)if(E.explicit===!0)try{let v=await this.validateTrackExists(E.describedSrc);return{trackInfo:E,exists:v}}catch{return{trackInfo:E,exists:!1}}else return{trackInfo:E,exists:!1};return{trackInfo:E,exists:!1}}),u=await Promise.all(m),f=u.filter(E=>E.exists);if(f.length>0){let E=new Map;f.forEach(({trackInfo:w})=>{let k=w.trackElement.track;k?E.set(w,{wasShowing:k.mode==="showing",wasHidden:k.mode==="hidden"}):E.set(w,{wasShowing:!1,wasHidden:!1})});let v=f.map(({trackInfo:w})=>{let k=w.trackElement.getAttribute("src"),C=w.trackElement.parentNode,M=w.trackElement.nextSibling,T={};return Array.from(w.trackElement.attributes).forEach(x=>{T[x.name]=x.value}),{trackInfo:w,oldSrc:k,parent:C,nextSibling:M,attributes:T}});v.forEach(({trackInfo:w})=>{w.trackElement.remove()}),this.element.load(),setTimeout(()=>{v.forEach(({trackInfo:k,oldSrc:C,parent:M,nextSibling:T,attributes:x})=>{r.push(k);let A=document.createElement("track");A.setAttribute("src",k.describedSrc),Object.keys(x).forEach($=>{$!=="src"&&$!=="data-desc-src"&&A.setAttribute($,x[$])}),T&&T.parentNode?M.insertBefore(A,T):M.appendChild(A),k.trackElement=A}),this.element.load(),this.invalidateTrackCache();let w=()=>{this.setManagedTimeout(()=>{r.forEach(k=>{let M=k.trackElement.track;if(M){let T=E.get(k)||{wasShowing:!1,wasHidden:!1};M.mode="hidden";let x=()=>{T.wasShowing||T.wasHidden?M.mode="hidden":M.mode="disabled"};M.readyState>=2?x():(M.addEventListener("load",x,{once:!0}),M.addEventListener("error",x,{once:!0}))}})},300)};this.element.readyState>=1?setTimeout(w,200):(this.element.addEventListener("loadedmetadata",w,{once:!0}),setTimeout(w,2e3))},100);let S=u.length-f.length}}let g=this.sourceElements,y=[];if(g.forEach(m=>{let u=m.getAttribute("data-desc-src"),f=m.getAttribute("src");if(u){let E=m.getAttribute("type"),v=m.getAttribute("data-orig-src");v||(v=f),y.push({src:u,type:E,origSrc:v,descSrc:u})}else{let E=m.getAttribute("type"),v=m.getAttribute("src");y.push({src:v,type:E,origSrc:null,descSrc:null})}}),g.forEach(m=>{m.remove()}),y.forEach(m=>{let u=document.createElement("source");u.setAttribute("src",m.src),m.type&&u.setAttribute("type",m.type),m.origSrc&&u.setAttribute("data-orig-src",m.origSrc),m.descSrc&&u.setAttribute("data-desc-src",m.descSrc);let f=this.element.querySelector("track");f?this.element.insertBefore(u,f):this.element.appendChild(u)}),this._sourceElementsDirty=!0,this._sourceElementsCache=null,this.element.load(),await new Promise(m=>{let u=()=>{this.element.removeEventListener("loadedmetadata",u),m()};this.element.addEventListener("loadedmetadata",u)}),await new Promise(m=>setTimeout(m,300)),i>0&&this.seek(i),s&&this.play(),a||this.hidePosterOverlay(),!this._audioDescriptionDesiredState)return;this.state.audioDescriptionEnabled=!0,this.emit("audiodescriptionenabled")}else{if(this.audioDescriptionCaptionTracks.length>0){let c=this.audioDescriptionCaptionTracks.map(async y=>{if(y.trackElement&&y.describedSrc)if(y.explicit===!0)try{let m=await this.validateTrackExists(y.describedSrc);return{trackInfo:y,exists:m}}catch{return{trackInfo:y,exists:!1}}else return{trackInfo:y,exists:!1};return{trackInfo:y,exists:!1}}),g=(await Promise.all(c)).filter(y=>y.exists);if(g.length>0){let y=new Map;g.forEach(({trackInfo:u})=>{let f=u.trackElement.track;f?y.set(u,{wasShowing:f.mode==="showing",wasHidden:f.mode==="hidden"}):y.set(u,{wasShowing:!1,wasHidden:!1})});let m=g.map(({trackInfo:u})=>{let f=u.trackElement.getAttribute("src"),E=u.trackElement.parentNode,v=u.trackElement.nextSibling,S={};return Array.from(u.trackElement.attributes).forEach(w=>{S[w.name]=w.value}),{trackInfo:u,oldSrc:f,parent:E,nextSibling:v,attributes:S}});m.forEach(({trackInfo:u})=>{u.trackElement.remove()}),this.element.load(),setTimeout(()=>{m.forEach(({trackInfo:f,oldSrc:E,parent:v,nextSibling:S,attributes:w})=>{r.push(f);let k=document.createElement("track");k.setAttribute("src",f.describedSrc),Object.keys(w).forEach(C=>{C!=="src"&&C!=="data-desc-src"&&k.setAttribute(C,w[C])}),S&&S.parentNode?v.insertBefore(k,S):v.appendChild(k),f.trackElement=k}),this.element.load();let u=()=>{setTimeout(()=>{r.forEach(f=>{let v=f.trackElement.track;if(v){let S=y.get(f)||{wasShowing:!1,wasHidden:!1};v.mode="hidden";let w=()=>{S.wasShowing||S.wasHidden?v.mode="hidden":v.mode="disabled"};v.readyState>=2?w():(v.addEventListener("load",w,{once:!0}),v.addEventListener("error",w,{once:!0}))}})},300)};this.element.readyState>=1?setTimeout(u,200):(this.element.addEventListener("loadedmetadata",u,{once:!0}),setTimeout(u,2e3))},100)}}let n=this.sourceElements;if(n.some(c=>c.getAttribute("data-desc-src"))){let c=[];n.forEach(p=>{let g=p.getAttribute("data-desc-src"),y=p.getAttribute("src");if(g){let m=p.getAttribute("type"),u=p.getAttribute("data-orig-src");u||(u=y),c.push({src:g,type:m,origSrc:u,descSrc:g})}else{let m=p.getAttribute("type"),u=p.getAttribute("src");c.push({src:u,type:m,origSrc:null,descSrc:null})}}),n.forEach(p=>{p.remove()}),c.forEach(p=>{let g=document.createElement("source");g.setAttribute("src",p.src),p.type&&g.setAttribute("type",p.type),p.origSrc&&g.setAttribute("data-orig-src",p.origSrc),p.descSrc&&g.setAttribute("data-desc-src",p.descSrc),this.element.appendChild(g)}),this.element.load(),this.invalidateTrackCache()}else this.element.src=this.audioDescriptionSrc}if(await new Promise(n=>{let o=()=>{this.element.removeEventListener("loadedmetadata",o),n()};this.element.addEventListener("loadedmetadata",o)}),this.element.tagName==="VIDEO"&&i===0&&!s&&this.element.readyState>=1&&(this.element.currentTime=.001,this.setManagedTimeout(()=>{this.element.currentTime=0},10)),i>0&&this.seek(i),s&&this.play(),r.length>0&&this.captionManager){let n=this.state.captionsEnabled,o=null;if(this.captionManager.currentTrack){let c=this.captionManager.tracks.findIndex(p=>p.track===this.captionManager.currentTrack.track);c>=0&&(o={language:this.captionManager.tracks[c].language,kind:this.captionManager.tracks[c].kind})}setTimeout(()=>{if(this.captionManager.tracks=[],this.captionManager.loadTracks(),n&&o&&this.captionManager.tracks.length>0){let c=this.captionManager.tracks.findIndex(p=>p.language===o.language&&p.kind===o.kind);c>=0?this.captionManager.enable(c):this.captionManager.tracks.length>0&&this.captionManager.enable(0)}},600)}if(this.transcriptManager&&this.transcriptManager.isVisible){let n=typeof r<"u"?r:[];if(n.length>0){let o=()=>{this.invalidateTrackCache();let p=this.textTracks,g=n.map(u=>{let f=u.trackElement,E=f.getAttribute("src"),v=f.getAttribute("srclang"),S=f.getAttribute("kind"),w=p.find(k=>f.track===k);if(w||(w=p.find(k=>{if(k.language===v&&(k.kind===S||S==="captions"&&k.kind==="subtitles")){let C=this.findTrackElement(k);if(C&&C.getAttribute("src")===E)return!0}return!1})),w){let k=this.findTrackElement(w);if(k&&k.getAttribute("src")!==E)return null}return w}).filter(Boolean);if(g.length===0){this.setManagedTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},1e3);return}g.forEach(u=>{u.mode==="disabled"&&(u.mode="hidden")});let y=0,m=()=>{y++,y>=g.length&&this.setManagedTimeout(()=>{if(this.transcriptManager&&this.transcriptManager.loadTranscriptData){this.invalidateTrackCache();let u=this.textTracks,f=n.map(v=>v.describedSrc);(g.some(v=>{let S=this.findTrackElement(v);return S&&f.includes(S.getAttribute("src"))})||g.length>0)&&this.transcriptManager.loadTranscriptData()}},800)};g.forEach(u=>{u.mode==="disabled"&&(u.mode="hidden");let f=this.findTrackElement(u),E=f?f.getAttribute("src"):null,v=n.find(w=>{let k=w.trackElement;return k&&(k.track===u||k.getAttribute("srclang")===u.language&&k.getAttribute("kind")===u.kind)}),S=v?v.describedSrc:null;if(S&&E&&E!==S){m();return}if(u.readyState>=2&&u.cues&&u.cues.length>0)m();else{u.mode==="disabled"&&(u.mode="hidden");let w=()=>{this.setManagedTimeout(m,300)};u.readyState>=2?this.setManagedTimeout(()=>{u.cues&&u.cues.length>0?m():u.addEventListener("load",w,{once:!0})},100):(u.addEventListener("load",w,{once:!0}),u.addEventListener("error",()=>{m()},{once:!0}))}})};(()=>{this.setManagedTimeout(()=>{this.element.readyState>=1?o():(this.element.addEventListener("loadedmetadata",o,{once:!0}),this.setManagedTimeout(o,2e3))},500)})(),setTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},5e3)}else setTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},800)}a||this.hidePosterOverlay(),this._audioDescriptionDesiredState&&(this.state.audioDescriptionEnabled=!0,this.emit("audiodescriptionenabled"))}async disableAudioDescription(){if(!this.originalSrc)return;let e=this.state.currentTime,t=this.state.playing;this.audioDescriptionCaptionTracks.length>0&&this.audioDescriptionCaptionTracks.forEach(a=>{a.trackElement&&a.originalTrackSrc&&a.trackElement.setAttribute("src",a.originalTrackSrc)});let i=this.sourceElements;if(i.some(a=>a.getAttribute("data-orig-src"))){let a=[];i.forEach(r=>{let n=r.getAttribute("data-orig-src"),o=r.getAttribute("data-desc-src");if(n){let c=r.getAttribute("type");a.push({src:n,type:c,origSrc:n,descSrc:o})}else{let c=r.getAttribute("type"),p=r.getAttribute("src");a.push({src:p,type:c,origSrc:null,descSrc:o})}}),i.forEach(r=>{r.remove()}),a.forEach(r=>{let n=document.createElement("source");n.setAttribute("src",r.src),r.type&&n.setAttribute("type",r.type),r.origSrc&&n.setAttribute("data-orig-src",r.origSrc),r.descSrc&&n.setAttribute("data-desc-src",r.descSrc);let o=this.element.querySelector("track");o?this.element.insertBefore(n,o):this.element.appendChild(n)}),this._sourceElementsDirty=!0,this._sourceElementsCache=null,this.element.load()}else{let a=this.originalAudioDescriptionSource||this.originalSrc;this.element.src=a,this.element.load()}(e>0||t)&&(await new Promise(a=>{let r=()=>{this.element.removeEventListener("loadedmetadata",r),a()};this.element.addEventListener("loadedmetadata",r)}),e>0&&this.seek(e),t&&this.play()),!t&&e===0?this.showPosterOverlay():this.hidePosterOverlay(),this.transcriptManager&&this.transcriptManager.isVisible&&this.setManagedTimeout(()=>{this.transcriptManager&&this.transcriptManager.loadTranscriptData&&this.transcriptManager.loadTranscriptData()},500),!this._audioDescriptionDesiredState&&(this.state.audioDescriptionEnabled=!1,this.emit("audiodescriptiondisabled"))}async toggleAudioDescription(){let e=this.findTextTrack("descriptions"),t=this.audioDescriptionSrc||this.sourceElements.some(i=>i.getAttribute("data-desc-src"));if(e&&t)if(this.state.audioDescriptionEnabled)this._audioDescriptionDesiredState=!1,e.mode="hidden",await this.disableAudioDescription();else{this._audioDescriptionDesiredState=!0,await this.enableAudioDescription();let i=()=>{this.invalidateTrackCache();let s=this.findTextTrack("descriptions");s?s.mode==="disabled"?(s.mode="hidden",this.setManagedTimeout(()=>{s.mode="showing"},50)):s.mode="showing":this.element.readyState<2&&this.setManagedTimeout(i,100)};this.element.readyState>=1?this.setManagedTimeout(i,200):this.element.addEventListener("loadedmetadata",()=>{this.setManagedTimeout(i,200)},{once:!0})}else e?e.mode==="showing"?(this._audioDescriptionDesiredState=!1,e.mode="hidden",this.state.audioDescriptionEnabled=!1,this.emit("audiodescriptiondisabled")):(this._audioDescriptionDesiredState=!0,e.mode="showing",this.state.audioDescriptionEnabled=!0,this.emit("audiodescriptionenabled")):t&&(this.state.audioDescriptionEnabled?(this._audioDescriptionDesiredState=!1,await this.disableAudioDescription()):(this._audioDescriptionDesiredState=!0,await this.enableAudioDescription()))}enableSignLanguage(){if(!this.signLanguageSrc){console.warn("No sign language video source provided");return}if(this.signLanguageWrapper){this.signLanguageWrapper.style.display="block",this.state.signLanguageEnabled=!0,this.emit("signlanguageenabled");return}this.signLanguageWrapper=document.createElement("div"),this.signLanguageWrapper.className="vidply-sign-language-wrapper",this.signLanguageWrapper.setAttribute("tabindex","0"),this.signLanguageWrapper.setAttribute("aria-label","Sign Language Video - Press D to drag with keyboard, R to resize"),this.signLanguageVideo=document.createElement("video"),this.signLanguageVideo.className="vidply-sign-language-video",this.signLanguageVideo.src=this.signLanguageSrc,this.signLanguageVideo.setAttribute("aria-label",d.t("player.signLanguage")),this.signLanguageVideo.muted=!0;let e=["nw","ne","sw","se"].map(i=>{let s=document.createElement("div");return s.className=`vidply-sign-resize-handle vidply-sign-resize-${i}`,s.setAttribute("data-direction",i),s.setAttribute("aria-label",`Resize ${i.toUpperCase()}`),s});this.signLanguageWrapper.appendChild(this.signLanguageVideo),e.forEach(i=>this.signLanguageWrapper.appendChild(i));let t=this.storage.getSignLanguagePreferences();t&&t.size&&t.size.width?this.signLanguageWrapper.style.width=t.size.width:this.signLanguageWrapper.style.width="280px",this.signLanguageWrapper.style.height="auto",this.signLanguageDesiredPosition=this.options.signLanguagePosition||"bottom-right",this.container.appendChild(this.signLanguageWrapper),requestAnimationFrame(()=>{this.constrainSignLanguagePosition()}),this.signLanguageVideo.currentTime=this.state.currentTime,this.state.paused||this.signLanguageVideo.play(),this.setupSignLanguageInteraction(),this.signLanguageHandlers={play:()=>{this.signLanguageVideo&&this.signLanguageVideo.play()},pause:()=>{this.signLanguageVideo&&this.signLanguageVideo.pause()},timeupdate:()=>{this.signLanguageVideo&&Math.abs(this.signLanguageVideo.currentTime-this.state.currentTime)>.5&&(this.signLanguageVideo.currentTime=this.state.currentTime)},ratechange:()=>{this.signLanguageVideo&&(this.signLanguageVideo.playbackRate=this.state.playbackSpeed)}},this.on("play",this.signLanguageHandlers.play),this.on("pause",this.signLanguageHandlers.pause),this.on("timeupdate",this.signLanguageHandlers.timeupdate),this.on("ratechange",this.signLanguageHandlers.ratechange),this.state.signLanguageEnabled=!0,this.emit("signlanguageenabled")}disableSignLanguage(){this.signLanguageWrapper&&(this.signLanguageWrapper.style.display="none"),this.state.signLanguageEnabled=!1,this.emit("signlanguagedisabled")}toggleSignLanguage(){this.state.signLanguageEnabled?this.disableSignLanguage():this.enableSignLanguage()}setupSignLanguageInteraction(){if(!this.signLanguageWrapper)return;let e=Array.from(this.signLanguageWrapper.querySelectorAll(".vidply-sign-resize-handle"));this.signLanguageDraggable=new D(this.signLanguageWrapper,{dragHandle:this.signLanguageVideo,resizeHandles:e,constrainToViewport:!0,maintainAspectRatio:!0,minWidth:150,minHeight:100,classPrefix:"vidply-sign",keyboardDragKey:"d",keyboardResizeKey:"r",keyboardStep:5,keyboardStepLarge:10}),this.signLanguageInteractionHandlers={draggable:this.signLanguageDraggable}}constrainSignLanguagePosition(){if(!this.signLanguageWrapper||!this.videoWrapper)return;(!this.signLanguageWrapper.style.width||this.signLanguageWrapper.style.width==="")&&(this.signLanguageWrapper.style.width="280px");let e=this.videoWrapper.getBoundingClientRect(),t=this.container.getBoundingClientRect(),i=this.signLanguageWrapper.getBoundingClientRect(),s=e.left-t.left,a=e.top-t.top,r=e.width,n=e.height,o=i.width||280,c=i.height||280*9/16,p,g,y=16,m=95;switch(this.signLanguageDesiredPosition||"bottom-right"){case"bottom-right":p=s+r-o-y,g=a+n-c-m;break;case"bottom-left":p=s+y,g=a+n-c-m;break;case"top-right":p=s+r-o-y,g=a+y;break;case"top-left":p=s+y,g=a+y;break;default:p=s+r-o-y,g=a+n-c-m}p=Math.max(s,Math.min(p,s+r-o)),g=Math.max(a,Math.min(g,a+n-c-m)),this.signLanguageWrapper.style.left=`${p}px`,this.signLanguageWrapper.style.top=`${g}px`,this.signLanguageWrapper.style.right="auto",this.signLanguageWrapper.style.bottom="auto",this.signLanguageWrapper.classList.remove(...Array.from(this.signLanguageWrapper.classList).filter(f=>f.startsWith("vidply-sign-position-")))}saveSignLanguagePreferences(){this.signLanguageWrapper&&this.storage.saveSignLanguagePreferences({size:{width:this.signLanguageWrapper.style.width}})}cleanupSignLanguage(){this.signLanguageHandlers&&(this.off("play",this.signLanguageHandlers.play),this.off("pause",this.signLanguageHandlers.pause),this.off("timeupdate",this.signLanguageHandlers.timeupdate),this.off("ratechange",this.signLanguageHandlers.ratechange),this.signLanguageHandlers=null),this.signLanguageDraggable&&(this.signLanguageDraggable.destroy(),this.signLanguageDraggable=null),this.signLanguageInteractionHandlers=null,this.signLanguageWrapper&&this.signLanguageWrapper.parentNode&&(this.signLanguageVideo&&(this.signLanguageVideo.pause(),this.signLanguageVideo.src=""),this.signLanguageWrapper.parentNode.removeChild(this.signLanguageWrapper),this.signLanguageWrapper=null,this.signLanguageVideo=null)}showSettings(){console.warn("[VidPly] Settings dialog has been removed. Use individual control buttons (speed, captions, etc.)")}hideSettings(){}getCurrentTime(){return this.state.currentTime}getDuration(){return this.state.duration}isPlaying(){return this.state.playing}isPaused(){return this.state.paused}isEnded(){return this.state.ended}isMuted(){return this.state.muted}isFullscreen(){return this.state.fullscreen}handleError(e){this.log("Error:",e,"error"),this.emit("error",e),this.options.onError&&this.options.onError.call(this,e)}log(...e){if(!this.options.debug)return;let t="log";if(e.length>0){let i=e[e.length-1];typeof i=="string"&&console[i]&&(t=i,e=e.slice(0,-1))}e.length===0&&(e=[""]),typeof console[t]=="function"?console[t]("[VidPly]",...e):console.log("[VidPly]",...e)}setupResponsiveHandlers(){if(typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(e=>{for(let t of e){let i=t.contentRect.width;this.controlBar&&typeof this.controlBar.updateControlsForViewport=="function"&&this.controlBar.updateControlsForViewport(i),this.transcriptManager&&this.transcriptManager.isVisible&&this.transcriptManager.positionTranscript()}}),this.resizeObserver.observe(this.container)):(this.resizeHandler=()=>{let e=this.container.clientWidth;this.controlBar&&typeof this.controlBar.updateControlsForViewport=="function"&&this.controlBar.updateControlsForViewport(e),this.transcriptManager&&this.transcriptManager.isVisible&&(!this.transcriptManager.draggableResizable||!this.transcriptManager.draggableResizable.manuallyPositioned)&&this.transcriptManager.positionTranscript()},window.addEventListener("resize",this.resizeHandler)),window.matchMedia){this.orientationHandler=t=>{setTimeout(()=>{this.transcriptManager&&this.transcriptManager.isVisible&&(!this.transcriptManager.draggableResizable||!this.transcriptManager.draggableResizable.manuallyPositioned)&&this.transcriptManager.positionTranscript()},100)};let e=window.matchMedia("(orientation: portrait)");e.addEventListener?e.addEventListener("change",this.orientationHandler):e.addListener&&e.addListener(this.orientationHandler),this.orientationQuery=e}this.fullscreenChangeHandler=()=>{let e=!!(document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement);this.state.fullscreen!==e&&(this.state.fullscreen=e,e?this.container.classList.add(`${this.options.classPrefix}-fullscreen`):this.container.classList.remove(`${this.options.classPrefix}-fullscreen`),this.emit("fullscreenchange",e),this.controlBar&&this.controlBar.updateFullscreenButton(),this.signLanguageWrapper&&this.signLanguageWrapper.style.display!=="none"&&this.setManagedTimeout(()=>{requestAnimationFrame(()=>{this.storage.saveSignLanguagePreferences({size:null}),this.signLanguageDesiredPosition="bottom-right",this.signLanguageWrapper.style.width=e?"400px":"280px",this.constrainSignLanguagePosition()})},500))},document.addEventListener("fullscreenchange",this.fullscreenChangeHandler),document.addEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.addEventListener("MSFullscreenChange",this.fullscreenChangeHandler)}destroy(){if(this.log("Destroying player"),this.renderer&&this.renderer.destroy(),this.controlBar&&this.controlBar.destroy(),this.captionManager&&this.captionManager.destroy(),this.keyboardManager&&this.keyboardManager.destroy(),this.transcriptManager&&this.transcriptManager.destroy(),this.cleanupSignLanguage(),this.playButtonOverlay&&this.playButtonOverlay.parentNode&&(this.playButtonOverlay.remove(),this.playButtonOverlay=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null),this.orientationQuery&&this.orientationHandler&&(this.orientationQuery.removeEventListener?this.orientationQuery.removeEventListener("change",this.orientationHandler):this.orientationQuery.removeListener&&this.orientationQuery.removeListener(this.orientationHandler),this.orientationQuery=null,this.orientationHandler=null),this.fullscreenChangeHandler&&(document.removeEventListener("fullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("webkitfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("mozfullscreenchange",this.fullscreenChangeHandler),document.removeEventListener("MSFullscreenChange",this.fullscreenChangeHandler),this.fullscreenChangeHandler=null),this.timeouts.forEach(e=>clearTimeout(e)),this.timeouts.clear(),this.metadataCueChangeHandler){let t=this.textTracks.find(i=>i.kind==="metadata");t&&t.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=null}this.metadataAlertHandlers&&this.metadataAlertHandlers.size>0&&(this.metadataAlertHandlers.forEach(({button:e,handler:t})=>{e&&t&&e.removeEventListener("click",t)}),this.metadataAlertHandlers.clear()),this.container&&this.container.parentNode&&(this.container.parentNode.insertBefore(this.element,this.container),this.container.parentNode.removeChild(this.container)),this.removeAllListeners()}setupMetadataHandling(){let e=()=>{let i=this.textTracks.find(s=>s.kind==="metadata");if(i){if(i.mode==="disabled"&&(i.mode="hidden"),this.metadataCueChangeHandler&&i.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=()=>{let s=Array.from(i.activeCues||[]);s.length>0&&this.options.debug&&this.log("[Metadata] Active cues:",s.map(a=>({start:a.startTime,end:a.endTime,text:a.text}))),s.forEach(a=>{this.handleMetadataCue(a)})},i.addEventListener("cuechange",this.metadataCueChangeHandler),this.options.debug){let s=i.cues?i.cues.length:0;this.log("[Metadata] Track enabled,",s,"cues available")}}else this.options.debug&&this.log("[Metadata] No metadata track found")};e(),this.on("loadedmetadata",e)}normalizeMetadataSelector(e){if(!e)return null;let t=e.trim();return t?t.startsWith("#")||t.startsWith(".")||t.startsWith("[")?t:`#${t}`:null}resolveMetadataConfig(e,t){if(!e||!t)return null;if(Object.prototype.hasOwnProperty.call(e,t))return e[t];let i=t.replace(/^#/,"");return Object.prototype.hasOwnProperty.call(e,i)?e[i]:null}cacheMetadataAlertContent(e,t={}){if(!e)return;let i=t.titleSelector||"[data-vidply-alert-title], h3, header",s=t.messageSelector||"[data-vidply-alert-message], p",a=e.querySelector(i);a&&!a.dataset.vidplyAlertTitleOriginal&&(a.dataset.vidplyAlertTitleOriginal=a.textContent.trim());let r=e.querySelector(s);r&&!r.dataset.vidplyAlertMessageOriginal&&(r.dataset.vidplyAlertMessageOriginal=r.textContent.trim())}restoreMetadataAlertContent(e,t={}){if(!e)return;let i=t.titleSelector||"[data-vidply-alert-title], h3, header",s=t.messageSelector||"[data-vidply-alert-message], p",a=e.querySelector(i);a&&a.dataset.vidplyAlertTitleOriginal&&(a.textContent=a.dataset.vidplyAlertTitleOriginal);let r=e.querySelector(s);r&&r.dataset.vidplyAlertMessageOriginal&&(r.textContent=r.dataset.vidplyAlertMessageOriginal)}focusMetadataTarget(e,t=null){var i,s;if(!(!e||e==="none")){if(e==="alert"&&t){t.focus();return}if(e==="player"){this.container&&this.container.focus();return}if(e==="media"){this.element.focus();return}if(e==="playButton"){let a=(s=(i=this.controlBar)==null?void 0:i.controls)==null?void 0:s.playPause;a&&a.focus();return}if(typeof e=="string"){let a=document.querySelector(e);a&&(a.tabIndex===-1&&!a.hasAttribute("tabindex")&&a.setAttribute("tabindex","-1"),a.focus())}}}handleMetadataAlert(e,t={}){if(!e)return;let i=this.resolveMetadataConfig(this.options.metadataAlerts,e)||{},s=t.element||document.querySelector(e);if(!s){this.options.debug&&this.log("[Metadata] Alert element not found:",e);return}this.options.debug&&this.log("[Metadata] Handling alert",e,{reason:t.reason,config:i}),this.cacheMetadataAlertContent(s,i),s.dataset.vidplyAlertOriginalDisplay||(s.dataset.vidplyAlertOriginalDisplay=s.style.display||""),s.dataset.vidplyAlertDisplay||(s.dataset.vidplyAlertDisplay=i.display||"block");let a=t.show!==void 0?t.show:i.show!==!1;if(a){let c=i.display||s.dataset.vidplyAlertDisplay||"block";s.style.display=c,s.hidden=!1,s.removeAttribute("hidden"),s.setAttribute("aria-hidden","false"),s.setAttribute("data-vidply-alert-active","true")}i.resetContent!==!1&&t.reason==="focus"&&this.restoreMetadataAlertContent(s,i);let n=t.focus!==void 0?t.focus:i.focusOnShow??t.reason!=="focus";a&&n&&(s.tabIndex===-1&&!s.hasAttribute("tabindex")&&s.setAttribute("tabindex","-1"),s.focus()),a&&i.autoScroll!==!1&&t.autoScroll!==!1&&s.scrollIntoView({behavior:"smooth",block:"nearest"});let o=i.continueButton;if(o){let c=null;if(o==="self"||s.matches(o)?c=s:c=s.querySelector(o)||document.querySelector(o),c&&!this.metadataAlertHandlers.has(e)){let p=()=>{if(i.hideOnContinue!==!1){let m=s.dataset.vidplyAlertOriginalDisplay||"";s.style.display=i.hideDisplay||m||"none",s.setAttribute("aria-hidden","true"),s.removeAttribute("data-vidply-alert-active")}i.resume!==!1&&this.state.paused&&this.play();let y=i.focusTarget||"playButton";this.setManagedTimeout(()=>{this.focusMetadataTarget(y,s)},i.focusDelay??100)};c.addEventListener("click",p),this.metadataAlertHandlers.set(e,{button:c,handler:p})}}return s}handleMetadataHashtags(e){if(!Array.isArray(e)||e.length===0)return;let t=this.options.metadataHashtags;t&&e.forEach(i=>{let s=this.resolveMetadataConfig(t,i);if(!s)return;let a=this.normalizeMetadataSelector(s.alert||s.selector||s.target);if(!a)return;let r=document.querySelector(a);if(!r){this.options.debug&&this.log("[Metadata] Hashtag target not found:",a);return}if(this.options.debug&&this.log("[Metadata] Handling hashtag",i,{selector:a,config:s}),this.cacheMetadataAlertContent(r,s),s.title){let c=s.titleSelector||"[data-vidply-alert-title], h3, header",p=r.querySelector(c);p&&(p.textContent=s.title)}if(s.message){let c=s.messageSelector||"[data-vidply-alert-message], p",p=r.querySelector(c);p&&(p.textContent=s.message)}let n=s.show!==!1,o=s.focus!==void 0?s.focus:!1;this.handleMetadataAlert(a,{element:r,show:n,focus:o,autoScroll:s.autoScroll,reason:"hashtag"})})}handleMetadataCue(e){let t=e.text.trim();this.options.debug&&this.log("[Metadata] Processing cue:",{time:e.startTime,text:t}),this.emit("metadata",{time:e.startTime,endTime:e.endTime,text:t,cue:e}),t.includes("PAUSE")&&(this.state.paused||(this.options.debug&&this.log("[Metadata] Pausing video at",e.startTime),this.pause()),this.emit("metadata:pause",{time:e.startTime,text:t}));let i=t.match(/FOCUS:([\w#-]+)/);if(i){let a=i[1],r=this.normalizeMetadataSelector(a),n=r?document.querySelector(r):null;n?(this.options.debug&&this.log("[Metadata] Focusing element:",r),n.tabIndex===-1&&!n.hasAttribute("tabindex")&&n.setAttribute("tabindex","-1"),this.setManagedTimeout(()=>{n.focus(),n.scrollIntoView({behavior:"smooth",block:"nearest"})},10)):this.options.debug&&this.log("[Metadata] Element not found:",r||a),this.emit("metadata:focus",{time:e.startTime,target:a,selector:r,element:n,text:t}),r&&this.handleMetadataAlert(r,{element:n,reason:"focus"})}let s=t.match(/#[\w-]+/g);s&&(this.options.debug&&this.log("[Metadata] Hashtags found:",s),this.emit("metadata:hashtags",{time:e.startTime,hashtags:s,text:t}),this.handleMetadataHashtags(s))}};z.instances=[];var q=class{constructor(e,t={}){this.player=e,this.tracks=[],this.currentIndex=-1,this.options={autoAdvance:t.autoAdvance!==!1,loop:t.loop||!1,showPanel:t.showPanel!==!1,...t},this.container=null,this.playlistPanel=null,this.trackInfoElement=null,this.handleTrackEnd=this.handleTrackEnd.bind(this),this.handleTrackError=this.handleTrackError.bind(this),this.player.playlistManager=this,this.init(),this.updatePlayerControls()}init(){this.player.on("ended",this.handleTrackEnd),this.player.on("error",this.handleTrackError),this.options.showPanel&&this.createUI()}updatePlayerControls(){if(!this.player.controlBar)return;let e=this.player.controlBar;e.element.innerHTML="",e.createControls(),e.attachEvents(),e.setupAutoHide()}loadPlaylist(e){this.tracks=e,this.currentIndex=-1,this.container&&this.container.classList.add("vidply-has-playlist"),this.playlistPanel&&this.renderPlaylist(),e.length>0&&this.play(0)}play(e,t=!1){if(e<0||e>=this.tracks.length){console.warn("VidPly Playlist: Invalid track index",e);return}let i=this.tracks[e];this.currentIndex=e,this.player.load({src:i.src,type:i.type,poster:i.poster,tracks:i.tracks||[]}),this.updateTrackInfo(i),this.updatePlaylistUI(),this.player.emit("playlisttrackchange",{index:e,item:i,total:this.tracks.length}),t&&this.player.container&&this.player.container.focus(),setTimeout(()=>{this.player.play()},100)}next(){let e=this.currentIndex+1;if(e>=this.tracks.length)if(this.options.loop)e=0;else return;this.play(e)}previous(){let e=this.currentIndex-1;if(e<0)if(this.options.loop)e=this.tracks.length-1;else return;this.play(e)}handleTrackEnd(){this.options.autoAdvance&&this.next()}handleTrackError(e){console.error("VidPly Playlist: Track error",e),this.options.autoAdvance&&setTimeout(()=>{this.next()},1e3)}createUI(){if(this.container=this.player.container,!this.container){console.warn("VidPly Playlist: No container found");return}this.trackInfoElement=l.createElement("div",{className:"vidply-track-info",role:"status","aria-live":"polite","aria-atomic":"true"}),this.trackInfoElement.style.display="none",this.container.appendChild(this.trackInfoElement),this.playlistPanel=l.createElement("div",{className:"vidply-playlist-panel",role:"region","aria-label":"Media playlist"}),this.playlistPanel.style.display="none",this.container.appendChild(this.playlistPanel)}updateTrackInfo(e){if(!this.trackInfoElement)return;let t=this.currentIndex+1,i=this.tracks.length,s=e.title||"Untitled",a=e.artist||"",r=`Now playing: Track ${t} of ${i}. ${s}${a?" by "+a:""}`;this.trackInfoElement.innerHTML=`
|
|
14
14
|
<span class="vidply-sr-only">${l.escapeHTML(r)}</span>
|
|
15
15
|
<div class="vidply-track-number" aria-hidden="true">Track ${t} of ${i}</div>
|
|
16
16
|
<div class="vidply-track-title" aria-hidden="true">${l.escapeHTML(s)}</div>
|
|
17
17
|
${a?`<div class="vidply-track-artist" aria-hidden="true">${l.escapeHTML(a)}</div>`:""}
|
|
18
|
-
`,this.trackInfoElement.style.display="block"}renderPlaylist(){if(!this.playlistPanel)return;this.playlistPanel.innerHTML="";let e=l.createElement("h2",{className:"vidply-playlist-header",id:"vidply-playlist-heading"});e.textContent=`Playlist (${this.tracks.length})`,this.playlistPanel.appendChild(e);let t=l.createElement("div",{className:"vidply-sr-only","aria-hidden":"false"});t.textContent="Use arrow keys to navigate between tracks. Press Enter or Space to play a track. Press Home or End to jump to first or last track.",this.playlistPanel.appendChild(t);let i=l.createElement("ul",{className:"vidply-playlist-list","aria-labelledby":"vidply-playlist-heading","aria-describedby":"vidply-playlist-instructions"}),s=l.createElement("div",{className:"vidply-sr-only",id:"vidply-playlist-instructions"});s.textContent=`Playlist with ${this.tracks.length} ${this.tracks.length===1?"track":"tracks"}`,this.playlistPanel.appendChild(s),this.tracks.forEach((a,r)=>{let
|
|
18
|
+
`,this.trackInfoElement.style.display="block"}renderPlaylist(){if(!this.playlistPanel)return;this.playlistPanel.innerHTML="";let e=l.createElement("h2",{className:"vidply-playlist-header",id:"vidply-playlist-heading"});e.textContent=`Playlist (${this.tracks.length})`,this.playlistPanel.appendChild(e);let t=l.createElement("div",{className:"vidply-sr-only","aria-hidden":"false"});t.textContent="Use arrow keys to navigate between tracks. Press Enter or Space to play a track. Press Home or End to jump to first or last track.",this.playlistPanel.appendChild(t);let i=l.createElement("ul",{className:"vidply-playlist-list","aria-labelledby":"vidply-playlist-heading","aria-describedby":"vidply-playlist-instructions"}),s=l.createElement("div",{className:"vidply-sr-only",id:"vidply-playlist-instructions"});s.textContent=`Playlist with ${this.tracks.length} ${this.tracks.length===1?"track":"tracks"}`,this.playlistPanel.appendChild(s),this.tracks.forEach((a,r)=>{let n=this.createPlaylistItem(a,r);i.appendChild(n)}),this.playlistPanel.appendChild(i),this.playlistPanel.style.display="block"}createPlaylistItem(e,t){let i=`Track ${t+1} of ${this.tracks.length}`,s=e.title||`Track ${t+1}`,a=e.artist?` by ${e.artist}`:"",r=t===this.currentIndex,n=r?"Currently playing":"Not playing",o=r?"Press Enter to restart":"Press Enter to play",c=l.createElement("li",{className:"vidply-playlist-item",tabIndex:t===0?0:-1,"aria-label":`${i}. ${s}${a}. ${n}. ${o}.`,"aria-posinset":t+1,"aria-setsize":this.tracks.length,"data-playlist-index":t});r&&(c.classList.add("vidply-playlist-item-active"),c.setAttribute("aria-current","true"),c.setAttribute("tabIndex","0"));let p=l.createElement("span",{className:"vidply-sr-only"});p.textContent=`${i}: `,c.appendChild(p);let g=l.createElement("div",{className:"vidply-playlist-thumbnail","aria-hidden":"true"});if(e.poster)g.style.backgroundImage=`url(${e.poster})`,g.setAttribute("role","img"),g.setAttribute("aria-label",`${s} thumbnail`);else{let f=b("music");f.classList.add("vidply-playlist-thumbnail-icon"),g.appendChild(f)}c.appendChild(g);let y=l.createElement("div",{className:"vidply-playlist-item-info","aria-hidden":"true"}),m=l.createElement("div",{className:"vidply-playlist-item-title"});if(m.textContent=s,y.appendChild(m),e.artist){let f=l.createElement("div",{className:"vidply-playlist-item-artist"});f.textContent=e.artist,y.appendChild(f)}if(c.appendChild(y),r){let f=l.createElement("span",{className:"vidply-sr-only"});f.textContent=" (Currently playing)",c.appendChild(f)}let u=b("play");return u.classList.add("vidply-playlist-item-icon"),u.setAttribute("aria-hidden","true"),c.appendChild(u),c.addEventListener("click",()=>{this.play(t,!0)}),c.addEventListener("keydown",f=>{this.handlePlaylistItemKeydown(f,t)}),c}handlePlaylistItemKeydown(e,t){let i=Array.from(this.playlistPanel.querySelectorAll(".vidply-playlist-item")),s=-1;switch(e.key){case"Enter":case" ":e.preventDefault(),this.play(t,!0);break;case"ArrowDown":e.preventDefault(),t<i.length-1&&(s=t+1);break;case"ArrowUp":e.preventDefault(),t>0&&(s=t-1);break;case"Home":e.preventDefault(),s=0;break;case"End":e.preventDefault(),s=i.length-1;break}s!==-1&&s!==t&&(i[t].setAttribute("tabIndex","-1"),i[s].setAttribute("tabIndex","0"),i[s].focus())}updatePlaylistUI(){if(!this.playlistPanel)return;this.playlistPanel.querySelectorAll(".vidply-playlist-item").forEach((t,i)=>{let s=this.tracks[i],a=`Track ${i+1} of ${this.tracks.length}`,r=s.title||`Track ${i+1}`,n=s.artist?` by ${s.artist}`:"";i===this.currentIndex?(t.classList.add("vidply-playlist-item-active"),t.setAttribute("aria-current","true"),t.setAttribute("tabIndex","0"),t.setAttribute("aria-label",`${a}. ${r}${n}. Currently playing. Press Enter to restart.`),t.scrollIntoView({behavior:"smooth",block:"nearest"})):(t.classList.remove("vidply-playlist-item-active"),t.removeAttribute("aria-current"),t.setAttribute("tabIndex","-1"),t.setAttribute("aria-label",`${a}. ${r}${n}. Not playing. Press Enter to play.`))})}getCurrentTrack(){return this.tracks[this.currentIndex]||null}getPlaylistInfo(){return{currentIndex:this.currentIndex,totalTracks:this.tracks.length,currentTrack:this.getCurrentTrack(),hasNext:this.hasNext(),hasPrevious:this.hasPrevious()}}hasNext(){return this.options.loop?!0:this.currentIndex<this.tracks.length-1}hasPrevious(){return this.options.loop?!0:this.currentIndex>0}addTrack(e){this.tracks.push(e),this.playlistPanel&&this.renderPlaylist()}removeTrack(e){e<0||e>=this.tracks.length||(this.tracks.splice(e,1),e<this.currentIndex?this.currentIndex--:e===this.currentIndex&&(this.currentIndex>=this.tracks.length&&(this.currentIndex=this.tracks.length-1),this.currentIndex>=0&&this.play(this.currentIndex)),this.playlistPanel&&this.renderPlaylist())}clear(){this.tracks=[],this.currentIndex=-1,this.playlistPanel&&(this.playlistPanel.innerHTML="",this.playlistPanel.style.display="none"),this.trackInfoElement&&(this.trackInfoElement.innerHTML="",this.trackInfoElement.style.display="none")}destroy(){this.player.off("ended",this.handleTrackEnd),this.player.off("error",this.handleTrackError),this.trackInfoElement&&this.trackInfoElement.remove(),this.playlistPanel&&this.playlistPanel.remove(),this.clear()}};function J(){document.querySelectorAll("[data-vidply]").forEach(e=>{let t=e.dataset.vidplyOptions?JSON.parse(e.dataset.vidplyOptions):{},s={...le(e.dataset),...t};new z(e,s)})}function le(h){let e={},t={signLanguageSrc:"signLanguageSrc",signLanguageButton:"signLanguageButton",signLanguagePosition:"signLanguagePosition",audioDescriptionSrc:"audioDescriptionSrc",audioDescriptionButton:"audioDescriptionButton",autoplay:"autoplay",loop:"loop",muted:"muted",controls:"controls",poster:"poster",width:"width",height:"height",language:"language",captions:"captions",captionsDefault:"captionsDefault",transcript:"transcript",transcriptButton:"transcriptButton",keyboard:"keyboard",responsive:"responsive",pipButton:"pipButton",fullscreenButton:"fullscreenButton"};return Object.keys(t).forEach(i=>{let s=t[i],a=h[i];a!==void 0&&(a==="true"?e[s]=!0:a==="false"?e[s]=!1:!isNaN(a)&&a!==""?e[s]=Number(a):e[s]=a)}),e}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",J):J();var ce=z;return ae(de);})();
|