vidply 1.0.34 → 1.0.35
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/dev/{vidply.SoundCloudRenderer-RIA3QKP3.js → vidply.SoundCloudRenderer-HCMKXHSX.js} +1 -3
- package/dist/dev/vidply.SoundCloudRenderer-HCMKXHSX.js.map +7 -0
- package/dist/dev/{vidply.TranscriptManager-T3BVTZHZ.js → vidply.TranscriptManager-EIIN5YOF.js} +2 -2
- package/dist/dev/{vidply.VimeoRenderer-DY2FG7LZ.js → vidply.VimeoRenderer-SLEBCZTT.js} +1 -2
- package/dist/dev/vidply.VimeoRenderer-SLEBCZTT.js.map +7 -0
- package/dist/dev/{vidply.YouTubeRenderer-EVXXE34A.js → vidply.YouTubeRenderer-E6F4UGVF.js} +1 -2
- package/dist/dev/vidply.YouTubeRenderer-E6F4UGVF.js.map +7 -0
- package/dist/dev/{vidply.chunk-74NJTDQI.js → vidply.chunk-AXXU22HR.js} +87 -10
- package/dist/dev/{vidply.chunk-74NJTDQI.js.map → vidply.chunk-AXXU22HR.js.map} +2 -2
- package/dist/dev/vidply.esm.js +32 -50
- package/dist/dev/vidply.esm.js.map +2 -2
- package/dist/legacy/vidply.js +119 -58
- package/dist/legacy/vidply.js.map +3 -3
- package/dist/legacy/vidply.min.js +1 -1
- package/dist/legacy/vidply.min.meta.json +18 -18
- package/dist/prod/vidply.SoundCloudRenderer-D2FNOEG6.min.js +6 -0
- package/dist/prod/{vidply.TranscriptManager-GPAOXEK4.min.js → vidply.TranscriptManager-VXCTCJ7X.min.js} +1 -1
- package/dist/prod/vidply.VimeoRenderer-QELFZVDU.min.js +6 -0
- package/dist/prod/vidply.YouTubeRenderer-ZL6YUHTF.min.js +6 -0
- package/dist/prod/{vidply.chunk-OM7DNW5P.min.js → vidply.chunk-Z6BHMOGK.min.js} +1 -1
- package/dist/prod/vidply.esm.min.js +3 -3
- package/dist/vidply.css +218 -108
- package/dist/vidply.esm.min.meta.json +33 -33
- package/dist/vidply.min.css +1 -1
- package/package.json +3 -3
- package/src/controls/ControlBar.js +3 -0
- package/src/controls/KeyboardManager.js +19 -0
- package/src/core/Player.js +1 -64
- package/src/core/SignLanguageManager.js +18 -4
- package/src/index.js +3 -1
- package/src/renderers/SoundCloudRenderer.js +0 -2
- package/src/renderers/VimeoRenderer.js +0 -1
- package/src/renderers/YouTubeRenderer.js +0 -1
- package/src/styles/vidply.css +218 -108
- package/src/utils/DraggableResizable.js +123 -12
- package/dist/dev/vidply.SoundCloudRenderer-RIA3QKP3.js.map +0 -7
- package/dist/dev/vidply.VimeoRenderer-DY2FG7LZ.js.map +0 -7
- package/dist/dev/vidply.YouTubeRenderer-EVXXE34A.js.map +0 -7
- package/dist/prod/vidply.SoundCloudRenderer-BFV5SSIU.min.js +0 -6
- package/dist/prod/vidply.VimeoRenderer-UQWHQ4LC.min.js +0 -6
- package/dist/prod/vidply.YouTubeRenderer-K7A57ICA.min.js +0 -6
- /package/dist/dev/{vidply.TranscriptManager-T3BVTZHZ.js.map → vidply.TranscriptManager-EIIN5YOF.js.map} +0 -0
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"format": "esm"
|
|
110
110
|
},
|
|
111
111
|
"src/controls/ControlBar.js": {
|
|
112
|
-
"bytes":
|
|
112
|
+
"bytes": 147374,
|
|
113
113
|
"imports": [
|
|
114
114
|
{
|
|
115
115
|
"path": "src/utils/DOMUtils.js",
|
|
@@ -181,7 +181,7 @@
|
|
|
181
181
|
"format": "esm"
|
|
182
182
|
},
|
|
183
183
|
"src/controls/KeyboardManager.js": {
|
|
184
|
-
"bytes":
|
|
184
|
+
"bytes": 8719,
|
|
185
185
|
"imports": [],
|
|
186
186
|
"format": "esm"
|
|
187
187
|
},
|
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"format": "esm"
|
|
192
192
|
},
|
|
193
193
|
"src/utils/DraggableResizable.js": {
|
|
194
|
-
"bytes":
|
|
194
|
+
"bytes": 29165,
|
|
195
195
|
"imports": [
|
|
196
196
|
{
|
|
197
197
|
"path": "<runtime>",
|
|
@@ -255,7 +255,7 @@
|
|
|
255
255
|
"format": "esm"
|
|
256
256
|
},
|
|
257
257
|
"src/core/SignLanguageManager.js": {
|
|
258
|
-
"bytes":
|
|
258
|
+
"bytes": 40888,
|
|
259
259
|
"imports": [
|
|
260
260
|
{
|
|
261
261
|
"path": "src/utils/DOMUtils.js",
|
|
@@ -342,12 +342,12 @@
|
|
|
342
342
|
"format": "esm"
|
|
343
343
|
},
|
|
344
344
|
"src/renderers/YouTubeRenderer.js": {
|
|
345
|
-
"bytes":
|
|
345
|
+
"bytes": 7848,
|
|
346
346
|
"imports": [],
|
|
347
347
|
"format": "esm"
|
|
348
348
|
},
|
|
349
349
|
"src/renderers/VimeoRenderer.js": {
|
|
350
|
-
"bytes":
|
|
350
|
+
"bytes": 7618,
|
|
351
351
|
"imports": [],
|
|
352
352
|
"format": "esm"
|
|
353
353
|
},
|
|
@@ -363,12 +363,12 @@
|
|
|
363
363
|
"format": "esm"
|
|
364
364
|
},
|
|
365
365
|
"src/renderers/SoundCloudRenderer.js": {
|
|
366
|
-
"bytes":
|
|
366
|
+
"bytes": 10507,
|
|
367
367
|
"imports": [],
|
|
368
368
|
"format": "esm"
|
|
369
369
|
},
|
|
370
370
|
"src/core/Player.js": {
|
|
371
|
-
"bytes":
|
|
371
|
+
"bytes": 221656,
|
|
372
372
|
"imports": [
|
|
373
373
|
{
|
|
374
374
|
"path": "src/utils/EventEmitter.js",
|
|
@@ -515,7 +515,7 @@
|
|
|
515
515
|
"format": "esm"
|
|
516
516
|
},
|
|
517
517
|
"src/index.js": {
|
|
518
|
-
"bytes":
|
|
518
|
+
"bytes": 5335,
|
|
519
519
|
"imports": [
|
|
520
520
|
{
|
|
521
521
|
"path": "src/core/Player.js",
|
|
@@ -582,7 +582,7 @@
|
|
|
582
582
|
"bytesInOutput": 5469
|
|
583
583
|
},
|
|
584
584
|
"src/utils/DraggableResizable.js": {
|
|
585
|
-
"bytesInOutput":
|
|
585
|
+
"bytesInOutput": 16613
|
|
586
586
|
},
|
|
587
587
|
"src/utils/MenuUtils.js": {
|
|
588
588
|
"bytesInOutput": 2298
|
|
@@ -594,25 +594,25 @@
|
|
|
594
594
|
"bytesInOutput": 43869
|
|
595
595
|
},
|
|
596
596
|
"src/renderers/YouTubeRenderer.js": {
|
|
597
|
-
"bytesInOutput":
|
|
597
|
+
"bytesInOutput": 4391
|
|
598
598
|
},
|
|
599
599
|
"src/renderers/VimeoRenderer.js": {
|
|
600
|
-
"bytesInOutput":
|
|
600
|
+
"bytesInOutput": 4612
|
|
601
601
|
},
|
|
602
602
|
"src/renderers/HLSRenderer.js": {
|
|
603
603
|
"bytesInOutput": 6646
|
|
604
604
|
},
|
|
605
605
|
"src/renderers/SoundCloudRenderer.js": {
|
|
606
|
-
"bytesInOutput":
|
|
606
|
+
"bytesInOutput": 5515
|
|
607
607
|
},
|
|
608
608
|
"src/utils/EventEmitter.js": {
|
|
609
609
|
"bytesInOutput": 437
|
|
610
610
|
},
|
|
611
611
|
"src/core/Player.js": {
|
|
612
|
-
"bytesInOutput":
|
|
612
|
+
"bytesInOutput": 80543
|
|
613
613
|
},
|
|
614
614
|
"src/controls/ControlBar.js": {
|
|
615
|
-
"bytesInOutput":
|
|
615
|
+
"bytesInOutput": 65595
|
|
616
616
|
},
|
|
617
617
|
"src/utils/PerformanceUtils.js": {
|
|
618
618
|
"bytesInOutput": 257
|
|
@@ -624,13 +624,13 @@
|
|
|
624
624
|
"bytesInOutput": 7462
|
|
625
625
|
},
|
|
626
626
|
"src/controls/KeyboardManager.js": {
|
|
627
|
-
"bytesInOutput":
|
|
627
|
+
"bytesInOutput": 4404
|
|
628
628
|
},
|
|
629
629
|
"src/core/AudioDescriptionManager.js": {
|
|
630
630
|
"bytesInOutput": 9690
|
|
631
631
|
},
|
|
632
632
|
"src/core/SignLanguageManager.js": {
|
|
633
|
-
"bytesInOutput":
|
|
633
|
+
"bytesInOutput": 20126
|
|
634
634
|
},
|
|
635
635
|
"src/features/PlaylistManager.js": {
|
|
636
636
|
"bytesInOutput": 24958
|
|
@@ -639,7 +639,7 @@
|
|
|
639
639
|
"bytesInOutput": 1877
|
|
640
640
|
}
|
|
641
641
|
},
|
|
642
|
-
"bytes":
|
|
642
|
+
"bytes": 361859
|
|
643
643
|
}
|
|
644
644
|
}
|
|
645
645
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Universal, Accessible Video Player
|
|
3
|
+
* (c) 2026 Matthias Peltzer
|
|
4
|
+
* Released under GPL-2.0-or-later License
|
|
5
|
+
*/
|
|
6
|
+
var s=class{constructor(e){this.player=e,this.widget=null,this.trackUrl=null,this.isReady=!1,this.iframe=null,this.iframeId=null}async init(){if(this.trackUrl=this.player.currentSource||this.player.element.src||this.player.element.querySelector("source")?.src,!this.trackUrl||!this.isValidSoundCloudUrl(this.trackUrl))throw new Error("Invalid SoundCloud URL");await this.loadSoundCloudAPI(),this.createIframe(),await this.initializeWidget()}isValidSoundCloudUrl(e){return e.includes("soundcloud.com")||e.includes("api.soundcloud.com")}isPlaylist(){return this.trackUrl&&this.trackUrl.includes("/sets/")}getEmbedUrl(){let e=encodeURIComponent(this.trackUrl);return`https://w.soundcloud.com/player/?${new URLSearchParams({url:this.trackUrl,auto_play:this.player.options.autoplay?"true":"false",hide_related:"true",show_comments:"false",show_user:"true",show_reposts:"false",show_teaser:"false",visual:"false",color:"%23007bff"}).toString()}`}async loadSoundCloudAPI(){return window.SC&&window.SC.Widget?Promise.resolve():new Promise((e,t)=>{let i=document.createElement("script");i.src="https://w.soundcloud.com/player/api.js",i.onload=()=>{setTimeout(()=>{window.SC&&window.SC.Widget?e():t(new Error("SoundCloud Widget API not available"))},100)},i.onerror=()=>t(new Error("Failed to load SoundCloud Widget API")),document.head.appendChild(i)})}createIframe(){this.player.element.style.display="none",this.player.element.removeAttribute("poster"),this.player.videoWrapper&&(this.player.videoWrapper.classList.remove("vidply-forced-poster"),this.player.videoWrapper.style.removeProperty("--vidply-poster-image")),this.iframeId=`soundcloud-player-${Math.random().toString(36).substr(2,9)}`,this.iframe=document.createElement("iframe"),this.iframe.id=this.iframeId,this.iframe.scrolling="no",this.iframe.frameBorder="no",this.iframe.allow="autoplay",this.iframe.src=this.getEmbedUrl(),this.iframe.style.width="100%",this.iframe.style.display="block",this.isPlaylist()?this.iframe.classList.add("vidply-soundcloud-iframe","vidply-soundcloud-playlist"):this.iframe.classList.add("vidply-soundcloud-iframe"),this.iframe.style.maxHeight="100%",this.player.element.parentNode.insertBefore(this.iframe,this.player.element)}async initializeWidget(){return new Promise((e,t)=>{this.iframe.addEventListener("load",()=>{try{this.widget=window.SC.Widget(this.iframe),this.widget.bind(window.SC.Widget.Events.READY,()=>{this.isReady=!0,this.attachEvents(),this.player.container&&this.player.container.classList.add("vidply-external-controls"),this.widget.getCurrentSound(i=>{i&&(this.player.state.duration=i.duration/1e3,this.player.emit("loadedmetadata"))}),e()}),this.widget.bind(window.SC.Widget.Events.ERROR,i=>{this.player.handleError(new Error(`SoundCloud error: ${i.message||"Unknown error"}`))})}catch(i){t(i)}}),setTimeout(()=>{this.isReady||t(new Error("SoundCloud widget initialization timeout"))},1e4)})}attachEvents(){if(!this.widget)return;let e=window.SC.Widget.Events;this.widget.bind(e.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.widget.bind(e.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.widget.bind(e.FINISH,()=>{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.seek(0),this.play())}),this.widget.bind(e.PLAY_PROGRESS,t=>{let i=t.currentPosition/1e3;this.player.state.currentTime=i,this.player.emit("timeupdate",i),this.player.options.onTimeUpdate&&this.player.options.onTimeUpdate.call(this.player,i)}),this.widget.bind(e.SEEK,t=>{this.player.state.currentTime=t.currentPosition/1e3,this.player.emit("seeked")}),this.widget.bind(e.LOAD_PROGRESS,t=>{if(this.player.state.duration){let i=t.loadedProgress*this.player.state.duration;this.player.emit("progress",i)}})}play(){if(this.isReady&&this.widget){let e=window.scrollX,t=window.scrollY;this.widget.play(),window.scrollTo(e,t)}}pause(){this.isReady&&this.widget&&this.widget.pause()}seek(e){this.isReady&&this.widget&&(this.widget.seekTo(e*1e3),this.player.state.currentTime=e)}setVolume(e){this.isReady&&this.widget&&(this.widget.setVolume(e*100),this.player.state.volume=e)}setMuted(e){this.isReady&&this.widget&&(e?this.widget.getVolume(t=>{this._previousVolume=t,this.widget.setVolume(0)}):this.widget.setVolume(this._previousVolume||100),this.player.state.muted=e)}setPlaybackSpeed(e){this.player.log("SoundCloud does not support playback speed control","warn")}getCurrentSound(){return new Promise(e=>{this.isReady&&this.widget?this.widget.getCurrentSound(t=>{e(t)}):e(null)})}destroy(){if(this.widget){let e=window.SC.Widget.Events;try{this.widget.unbind(e.READY),this.widget.unbind(e.PLAY),this.widget.unbind(e.PAUSE),this.widget.unbind(e.FINISH),this.widget.unbind(e.PLAY_PROGRESS),this.widget.unbind(e.SEEK),this.widget.unbind(e.LOAD_PROGRESS),this.widget.unbind(e.ERROR)}catch{}}this.iframe&&this.iframe.parentNode&&this.iframe.parentNode.removeChild(this.iframe),this.player.element&&(this.player.element.style.display=""),this.widget=null,this.isReady=!1}},a=s;export{s as SoundCloudRenderer,a as default};
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* (c) 2026 Matthias Peltzer
|
|
4
4
|
* Released under GPL-2.0-or-later License
|
|
5
5
|
*/
|
|
6
|
-
import{a as o,b as r,c as M,d as b,f as v,h as C,i as P,j as f,k as w,m as S,n as z}from"./vidply.chunk-OM7DNW5P.min.js";var W=class{constructor(t){this.player=t,this.transcriptWindow=null,this.transcriptEntries=[],this.metadataCues=[],this.currentActiveEntry=null,this.isVisible=!1,this.storage=new C("vidply"),this.draggableResizable=null,this.settingsMenuVisible=!1,this.settingsMenu=null,this.settingsButton=null,this.settingsMenuJustOpened=!1,this.resizeOptionButton=null,this.resizeOptionText=null,this.dragOptionButton=null,this.dragOptionText=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.languageLabel=null,this.currentTranscriptLanguage=null,this.availableTranscriptLanguages=[],this.languageSelectorHandler=null;let i=this.storage.getTranscriptPreferences();this.autoscrollEnabled=i?.autoscroll!==void 0?i.autoscroll:!0,this.showTimestamps=i?.showTimestamps!==void 0?i.showTimestamps:!1,this.transcriptStyle={fontSize:i?.fontSize||this.player.options.transcriptFontSize||"100%",fontFamily:i?.fontFamily||this.player.options.transcriptFontFamily||"sans-serif",color:i?.color||this.player.options.transcriptColor||"#ffffff",backgroundColor:i?.backgroundColor||this.player.options.transcriptBackgroundColor||"#1e1e1e",opacity:i?.opacity??this.player.options.transcriptOpacity??.98},this.handlers={timeupdate:()=>this.updateActiveEntry(),audiodescriptionenabled:()=>{this.isVisible&&this.loadTranscriptData()},audiodescriptiondisabled:()=>{this.isVisible&&this.loadTranscriptData()},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("audiodescriptionenabled",this.handlers.audiodescriptionenabled),this.player.on("audiodescriptiondisabled",this.handlers.audiodescriptiondisabled),this.player.on("fullscreenchange",()=>{this.isVisible&&(window.innerWidth<768&&this.setupDragAndDrop(),(!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(),v(this.settingsButton,{delay:150});return}this.createTranscriptWindow(),this.loadTranscriptData(),this.transcriptWindow&&(this.transcriptWindow.style.display="flex",(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.setManagedTimeout(()=>this.positionTranscript(),0),v(this.settingsButton,{delay:150})),this.isVisible=!0}hideTranscript({focusButton:t=!1}={}){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(),t){let i=this.player.controlBar?.controls?.transcript;i&&typeof i.focus=="function"&&i.focus({preventScroll:!0})}}createTranscriptWindow(){this.transcriptWindow=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-window`,attributes:{role:"dialog","aria-label":r.t("transcript.ariaLabel"),tabindex:"-1"}}),this.transcriptHeader=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header`,attributes:{tabindex:"0"}}),this.headerLeft=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header-left`});let t=r.t("transcript.settingsMenu");this.settingsButton=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings`,attributes:{type:"button","aria-label":t,"aria-expanded":"false"}}),this.settingsButton.appendChild(b("settings")),o.attachTooltip(this.settingsButton,t,this.player.options.classPrefix),this.handlers.settingsClick=d=>{d.preventDefault(),d.stopPropagation(),this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()},this.settingsButton.addEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown=d=>{d.key==="d"||d.key==="D"?(d.preventDefault(),d.stopPropagation(),this.toggleKeyboardDragMode()):d.key==="r"||d.key==="R"?(d.preventDefault(),d.stopPropagation(),this.toggleResizeMode()):d.key==="Escape"&&this.settingsMenuVisible&&(d.preventDefault(),d.stopPropagation(),this.hideSettingsMenu())},this.settingsButton.addEventListener("keydown",this.handlers.settingsKeydown);let i=o.createElement("h3",{textContent:`${r.t("transcript.title")}. ${r.t("transcript.dragResizePrompt")}`}),e=`${this.player.options.classPrefix}-transcript-autoscroll-${Date.now()}`,a=o.createElement("label",{className:`${this.player.options.classPrefix}-transcript-autoscroll-label`,attributes:{for:e}});this.autoscrollCheckbox=o.createElement("input",{attributes:{id:e,type:"checkbox"}}),this.autoscrollEnabled&&(this.autoscrollCheckbox.checked=!0);let n=o.createElement("span",{textContent:r.t("transcript.autoscroll"),className:`${this.player.options.classPrefix}-transcript-autoscroll-text`});a.appendChild(this.autoscrollCheckbox),a.appendChild(n),this.autoscrollCheckbox.addEventListener("change",d=>{this.autoscrollEnabled=d.target.checked,this.saveAutoscrollPreference()}),this.transcriptHeader.appendChild(i),this.headerLeft.appendChild(this.settingsButton),this.headerLeft.appendChild(a);let p=`${this.player.options.classPrefix}-transcript-language-select-${Date.now()}`,{label:l,select:s}=S({classPrefix:this.player.options.classPrefix,labelClass:`${this.player.options.classPrefix}-transcript-language-label`,selectClass:`${this.player.options.classPrefix}-transcript-language-select`,labelText:"settings.language",selectId:p,hidden:!1});this.languageLabel=l,this.languageSelector=s;let c=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-language-wrapper`,attributes:{style:"display: none;"}});c.appendChild(this.languageLabel),c.appendChild(this.languageSelector),this.languageSelectorWrapper=c,z(c),this.headerLeft.appendChild(c);let h=r.t("transcript.close"),u=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-close`,attributes:{type:"button","aria-label":h}});u.appendChild(b("close")),o.attachTooltip(u,h,this.player.options.classPrefix),u.addEventListener("click",()=>this.hideTranscript({focusButton:!0})),this.transcriptHeader.appendChild(this.headerLeft),this.transcriptHeader.appendChild(u),this.transcriptContent=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-content`}),this.transcriptWindow.appendChild(this.transcriptHeader),this.transcriptWindow.appendChild(this.transcriptContent),this.createResizeHandles(),this.liveRegion=o.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=d=>{this.settingsMenuJustOpened||this.styleDialogJustOpened||this.settingsButton&&this.settingsButton.contains(d.target)||this.settingsMenu&&this.settingsMenu.contains(d.target)||(this.settingsMenuVisible&&this.hideSettingsMenu(),this.styleDialogVisible&&this.styleDialog&&!this.styleDialog.contains(d.target)&&this.hideStyleDialog())},this.documentClickHandlerAdded=!1;let y;this.handlers.resize=()=>{y&&this.clearManagedTimeout(y),y=this.setManagedTimeout(()=>{(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.positionTranscript()},100)},window.addEventListener("resize",this.handlers.resize)}createResizeHandles(){if(!this.transcriptWindow)return;let t=["n","s","e","w","ne","nw","se","sw"];this.transcriptResizeHandles=t.map(i=>{let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-handle ${this.player.options.classPrefix}-transcript-resize-${i}`,attributes:{"data-direction":i,"data-vidply-managed-resize":"true","aria-hidden":"true"}});return e.style.display="none",this.transcriptWindow.appendChild(e),e})}positionTranscript(){if(!this.transcriptWindow||!this.player.videoWrapper||!this.isVisible||this.draggableResizable&&this.draggableResizable.manuallyPositioned)return;let t=window.innerWidth<768,i=this.player.videoWrapper.getBoundingClientRect(),e=this.player.state.fullscreen;if(t&&!e)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.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),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(e){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 a=260,n=Math.max(a,window.innerWidth-40),p=parseFloat(this.transcriptWindow.style.width)||400,l=Math.max(a,Math.min(p,n));this.transcriptWindow.style.width=`${l}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.removeProperty("border-top"),this.transcriptWindow.style.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}else{let a=parseFloat(this.transcriptWindow.style.width)||400,n=20,p=260,l=this.player.container.getBoundingClientRect();window.getComputedStyle(this.player.container).position==="static"&&(this.player.container.style.position="relative");let c=i.right-l.left+n,h=window.innerWidth-i.right-n,u=Math.max(p,Math.min(a,h)),y=i.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=`${u}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.removeProperty("border-top"),this.transcriptWindow.style.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}}getAvailableTranscriptLanguages(){let t=this.player.textTracks,i=new Map;return t.forEach(e=>{(e.kind==="captions"||e.kind==="subtitles")&&e.language&&(i.has(e.language)||i.set(e.language,{language:e.language,label:e.label||e.language,track:e}))}),Array.from(i.values())}updateLanguageSelector(){if(this.languageSelector){if(this.availableTranscriptLanguages=this.getAvailableTranscriptLanguages(),this.languageSelector.innerHTML="",this.availableTranscriptLanguages.length<2){this.languageSelectorWrapper&&(this.languageSelectorWrapper.style.display="none");return}if(this.languageSelectorWrapper&&(this.languageSelectorWrapper.style.display="flex"),this.availableTranscriptLanguages.forEach((t,i)=>{let e=o.createElement("option",{textContent:t.label,attributes:{value:t.language,lang:t.language}});this.languageSelector.appendChild(e)}),this.currentTranscriptLanguage)this.languageSelector.value=this.currentTranscriptLanguage;else if(this.availableTranscriptLanguages.length>0){let t=this.player.textTracks.find(i=>(i.kind==="captions"||i.kind==="subtitles")&&i.mode==="showing");this.currentTranscriptLanguage=t?t.language:this.availableTranscriptLanguages[0].language,this.languageSelector.value=this.currentTranscriptLanguage}this.languageSelectorHandler&&this.languageSelector.removeEventListener("change",this.languageSelectorHandler),this.languageSelectorHandler=t=>{this.currentTranscriptLanguage=t.target.value,this.loadTranscriptData(),this.transcriptContent&&this.currentTranscriptLanguage&&this.transcriptContent.setAttribute("lang",this.currentTranscriptLanguage)},this.languageSelector.addEventListener("change",this.languageSelectorHandler)}}loadTranscriptData(){this.transcriptEntries=[],this.transcriptContent.innerHTML="";let t=this.player.textTracks,i=null;this.currentTranscriptLanguage&&(i=t.find(s=>(s.kind==="captions"||s.kind==="subtitles")&&s.language===this.currentTranscriptLanguage)),i||(i=t.find(s=>s.kind==="captions"||s.kind==="subtitles"),i&&(this.currentTranscriptLanguage=i.language));let e=null;this.currentTranscriptLanguage&&(e=t.find(s=>s.kind==="descriptions"&&s.language===this.currentTranscriptLanguage)),e||(e=t.find(s=>s.kind==="descriptions"));let a=t.find(s=>s.kind==="metadata");if(!i&&!e&&!a){this.showNoTranscriptMessage();return}let n=[i,e,a].filter(Boolean);if(n.forEach(s=>{s.mode==="disabled"&&(s.mode="hidden")}),n.some(s=>!s.cues||s.cues.length===0)){let s=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-loading`,textContent:r.t("transcript.loading")});this.transcriptContent.appendChild(s);let c=0,h=()=>{c++,c>=n.length&&this.loadTranscriptData()};n.forEach(u=>{u.addEventListener("load",h,{once:!0})}),this.setManagedTimeout(()=>{this.loadTranscriptData()},500);return}let l=[];i&&i.cues&&Array.from(i.cues).forEach(s=>{l.push({cue:s,type:"caption"})}),e&&e.cues&&Array.from(e.cues).forEach(s=>{l.push({cue:s,type:"description"})}),a&&a.cues&&(this.metadataCues=Array.from(a.cues),this.setupMetadataHandling()),l.sort((s,c)=>s.cue.startTime-c.cue.startTime),l.forEach((s,c)=>{let h=this.createTranscriptEntry(s.cue,c,s.type);this.transcriptEntries.push({element:h,cue:s.cue,type:s.type,startTime:s.cue.startTime,endTime:s.cue.endTime}),this.transcriptContent.appendChild(h)}),this.applyTranscriptStyles(),this.updateTimestampVisibility(),this.transcriptContent&&this.currentTranscriptLanguage&&this.transcriptContent.setAttribute("lang",this.currentTranscriptLanguage),this.updateLanguageSelector()}setupMetadataHandlingOnLoad(){let t=()=>{let e=this.player.textTracks.find(a=>a.kind==="metadata");if(e){if(e.mode==="disabled"&&(e.mode="hidden"),this.metadataCueChangeHandler&&e.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=()=>{let a=Array.from(e.activeCues||[]);a.length>0&&this.player.options.debug&&console.log("[VidPly Metadata] Active cues:",a.map(n=>({start:n.startTime,end:n.endTime,text:n.text}))),a.forEach(n=>{this.handleMetadataCue(n)})},e.addEventListener("cuechange",this.metadataCueChangeHandler),this.player.options.debug){let a=e.cues?e.cues.length:0;console.log("[VidPly Metadata] Track enabled,",a,"cues available")}}else this.player.options.debug&&console.warn("[VidPly Metadata] No metadata track found")};t(),this.player.on("loadedmetadata",t)}setupMetadataHandling(){!this.metadataCues||this.metadataCues.length===0||this.player.options.debug&&console.log("[VidPly Metadata]",this.metadataCues.length,"cues stored from transcript load")}handleMetadataCue(t){let i=t.text.trim();this.player.options.debug&&console.log("[VidPly Metadata] Processing cue:",{time:t.startTime,text:i}),this.player.emit("metadata",{time:t.startTime,endTime:t.endTime,text:i,cue:t}),i.includes("PAUSE")&&(this.player.state.paused||(this.player.options.debug&&console.log("[VidPly Metadata] Pausing video at",t.startTime),this.player.pause()),this.player.emit("metadata:pause",{time:t.startTime,text:i}));let e=i.match(/FOCUS:([\w#-]+)/);if(e){let n=e[1],p=document.querySelector(n);p?(this.player.options.debug&&console.log("[VidPly Metadata] Focusing element:",n),this.setManagedTimeout(()=>{p.focus({preventScroll:!0})},10)):this.player.options.debug&&console.warn("[VidPly Metadata] Element not found:",n),this.player.emit("metadata:focus",{time:t.startTime,target:n,element:p,text:i})}let a=i.match(/#[\w-]+/g);a&&(this.player.options.debug&&console.log("[VidPly Metadata] Hashtags found:",a),this.player.emit("metadata:hashtags",{time:t.startTime,hashtags:a,text:i}))}createTranscriptEntry(t,i,e="caption"){let a=this.stripVTTFormatting(t.text),n=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-entry ${this.player.options.classPrefix}-transcript-${e}`,attributes:{tabindex:"0","data-start":String(t.startTime),"data-end":String(t.endTime),"data-type":e}}),p=o.createElement("span",{className:`${this.player.options.classPrefix}-transcript-time`,textContent:M.formatTime(t.startTime),attributes:{"aria-hidden":"true"}}),l=o.createElement("span",{className:`${this.player.options.classPrefix}-transcript-text`,textContent:a});n.appendChild(p),n.appendChild(l);let s=()=>{this.player.seek(t.startTime),this.player.state.paused&&this.player.play()};return n.addEventListener("click",s),n.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),s())}),n}stripVTTFormatting(t){return t.replace(/<[^>]+>/g,"").replace(/\n/g," ").trim()}showNoTranscriptMessage(){let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-empty`,textContent:r.t("transcript.noTranscript")});this.transcriptContent.appendChild(t)}updateActiveEntry(){if(!this.isVisible||this.transcriptEntries.length===0)return;let t=this.player.state.currentTime,i=this.transcriptEntries.find(e=>t>=e.startTime&&t<e.endTime);i&&i!==this.currentActiveEntry?(this.currentActiveEntry&&this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),i.element.classList.add(`${this.player.options.classPrefix}-transcript-entry-active`),this.scrollToEntry(i.element),this.currentActiveEntry=i):!i&&this.currentActiveEntry&&(this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),this.currentActiveEntry=null)}scrollToEntry(t){if(!this.transcriptContent||!this.autoscrollEnabled)return;let i=this.transcriptContent.getBoundingClientRect(),e=t.getBoundingClientRect();if(e.top<i.top||e.bottom>i.bottom){let a=t.offsetTop-this.transcriptContent.clientHeight/2+t.clientHeight/2;this.transcriptContent.scrollTo({top:a,behavior:"smooth"})}}saveAutoscrollPreference(){let t=this.storage.getTranscriptPreferences()||{};t.autoscroll=this.autoscrollEnabled,this.storage.saveTranscriptPreferences(t)}setupDragAndDrop(){if(!this.transcriptHeader||!this.transcriptWindow)return;let t=window.innerWidth<768,i=this.player.state.fullscreen;if(t&&!i){this.draggableResizable&&(this.draggableResizable.destroy(),this.draggableResizable=null);return}this.draggableResizable||(this.draggableResizable=new P(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:r.t("transcript.resizeModeHint"),onPointerResizeToggle:e=>{this.transcriptResizeHandles.forEach(a=>{a.style.display=e?"block":"none"}),this.onPointerResizeModeChange(e)},onDragStart:e=>{let a=[`.${this.player.options.classPrefix}-transcript-close`,`.${this.player.options.classPrefix}-transcript-settings`,`.${this.player.options.classPrefix}-transcript-language-select`,`.${this.player.options.classPrefix}-transcript-language-label`,`.${this.player.options.classPrefix}-transcript-settings-menu`,`.${this.player.options.classPrefix}-transcript-style-dialog`];for(let n of a)if(e.target.closest(n))return!1;return!0}}),this.customKeyHandler=e=>{let a=e.key.toLowerCase(),n=e.defaultPrevented;if(!(this.settingsMenuVisible||this.styleDialogVisible)){if(a==="home"){e.preventDefault(),e.stopPropagation(),this.draggableResizable&&(this.draggableResizable.pointerResizeMode&&this.draggableResizable.disablePointerResizeMode(),this.draggableResizable.manuallyPositioned=!1,this.positionTranscript(),this.updateResizeOptionState(),this.announceLive(r.t("transcript.positionReset")));return}if(a==="r"){if(n)return;e.preventDefault(),e.stopPropagation(),this.toggleResizeMode()&&this.transcriptWindow.focus({preventScroll:!0});return}if(a==="escape"){if(this.draggableResizable&&this.draggableResizable.pointerResizeMode){e.preventDefault(),e.stopPropagation(),this.draggableResizable.disablePointerResizeMode();return}if(this.draggableResizable&&this.draggableResizable.keyboardDragMode){e.preventDefault(),e.stopPropagation(),this.draggableResizable.disableKeyboardDragMode(),this.announceLive(r.t("transcript.dragModeDisabled"));return}e.preventDefault(),e.stopPropagation(),this.hideTranscript({focusButton:!0});return}}},this.transcriptWindow.addEventListener("keydown",this.customKeyHandler))}toggleKeyboardDragMode(){if(this.draggableResizable){let t=this.draggableResizable.keyboardDragMode;this.draggableResizable.toggleKeyboardDragMode();let i=this.draggableResizable.keyboardDragMode;!t&&i&&this.enableMoveMode(),this.updateDragOptionState(),this.settingsMenuVisible&&this.hideSettingsMenu(),this.transcriptWindow.focus({preventScroll:!0})}}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.attachSettingsMenuKeyboardNavigation(),this.positionSettingsMenuImmediate(),this.updateResizeOptionState(),setTimeout(()=>{let g=this.settingsMenu.querySelectorAll(`.${this.player.options.classPrefix}-transcript-settings-item`);if(g.length>0){g[0].setAttribute("tabindex","0");for(let m=1;m<g.length;m++)g[m].setAttribute("tabindex","-1");g[0].focus({preventScroll:!0})}},50);return}this.settingsMenu=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-settings-menu`,attributes:{role:"menu"}});let t=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"move",label:"transcript.enableDragMode",hasTextClass:!0,onClick:()=>{this.toggleKeyboardDragMode(),this.hideSettingsMenu()}});t.setAttribute("role","switch"),t.setAttribute("aria-checked","false");let i=t.querySelector(`.${this.player.options.classPrefix}-tooltip`);i&&i.remove();let e=t.querySelector(`.${this.player.options.classPrefix}-button-text`);e&&e.remove(),this.dragOptionButton=t,this.dragOptionText=t.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateDragOptionState();let a=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"settings",label:"transcript.styleTranscript",onClick:g=>{g.preventDefault(),g.stopPropagation(),this.hideSettingsMenu(),setTimeout(()=>{this.showStyleDialog()},50)}}),n=a.querySelector(`.${this.player.options.classPrefix}-tooltip`);n&&n.remove();let p=a.querySelector(`.${this.player.options.classPrefix}-button-text`);p&&p.remove();let l=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"resize",label:"transcript.enableResizeMode",hasTextClass:!0,onClick:g=>{g.preventDefault(),g.stopPropagation(),this.toggleResizeMode({focus:!1})?(this.hideSettingsMenu({focusButton:!1}),setTimeout(()=>{this.transcriptWindow&&this.transcriptWindow.focus({preventScroll:!0})},20)):this.hideSettingsMenu({focusButton:!0})}});l.setAttribute("role","switch"),l.setAttribute("aria-checked","false");let s=l.querySelector(`.${this.player.options.classPrefix}-tooltip`);s&&s.remove();let c=l.querySelector(`.${this.player.options.classPrefix}-button-text`);c&&c.remove(),this.resizeOptionButton=l,this.resizeOptionText=l.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateResizeOptionState();let h=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"clock",label:"transcript.showTimestamps",hasTextClass:!0,onClick:()=>{this.toggleShowTimestamps()}});h.setAttribute("role","switch"),h.setAttribute("aria-checked",this.showTimestamps?"true":"false");let u=h.querySelector(`.${this.player.options.classPrefix}-tooltip`);u&&u.remove();let y=h.querySelector(`.${this.player.options.classPrefix}-button-text`);y&&y.remove(),this.showTimestampsButton=h,this.showTimestampsText=h.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateShowTimestampsState();let d=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"close",label:"transcript.closeMenu",onClick:()=>{this.hideSettingsMenu()}}),x=d.querySelector(`.${this.player.options.classPrefix}-tooltip`);x&&x.remove();let T=d.querySelector(`.${this.player.options.classPrefix}-button-text`);T&&T.remove(),this.settingsMenu.appendChild(t),this.settingsMenu.appendChild(l),this.settingsMenu.appendChild(a),this.settingsMenu.appendChild(h),this.settingsMenu.appendChild(d),this.settingsMenu.style.visibility="hidden",this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.parentNode?this.settingsButton.insertAdjacentElement("afterend",this.settingsMenu):this.headerLeft?this.headerLeft.appendChild(this.settingsMenu):this.transcriptHeader?this.transcriptHeader.appendChild(this.settingsMenu):this.transcriptWindow.appendChild(this.settingsMenu),this.positionSettingsMenuImmediate(),requestAnimationFrame(()=>{this.settingsMenu&&(this.settingsMenu.style.visibility="visible")}),this.settingsMenuKeyHandler=w(this.settingsMenu,this.settingsButton,`.${this.player.options.classPrefix}-transcript-settings-item`,()=>this.hideSettingsMenu({focusButton:!0})),this.settingsMenuVisible=!0,this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.setAttribute("aria-expanded","true"),this.updateResizeOptionState(),setTimeout(()=>{let g=this.settingsMenu.querySelectorAll(`.${this.player.options.classPrefix}-transcript-settings-item`);if(g.length>0){g[0].setAttribute("tabindex","0");for(let m=1;m<g.length;m++)g[m].setAttribute("tabindex","-1");g[0].focus({preventScroll:!0})}},50)}positionSettingsMenuImmediate(){if(!this.settingsMenu||!this.settingsButton)return;let t=this.settingsButton.parentElement;if(!t)return;let i=this.settingsButton.getBoundingClientRect(),e=t.getBoundingClientRect(),a=this.settingsMenu.getBoundingClientRect(),n=window.innerHeight,p=i.left-e.left,l=i.bottom-e.top,s=i.top-e.top,c=n-i.bottom,h=i.top,u=l+4;c<a.height+20&&h>c?(u=s-a.height-4,this.settingsMenu.classList.add("vidply-menu-above")):this.settingsMenu.classList.remove("vidply-menu-above"),this.settingsMenu.style.top=`${u}px`,this.settingsMenu.style.left=`${p}px`,this.settingsMenu.style.right="auto",this.settingsMenu.style.bottom="auto"}positionSettingsMenu(){!this.settingsMenu||!this.settingsButton||requestAnimationFrame(()=>{setTimeout(()=>{this.positionSettingsMenuImmediate()},10)})}attachSettingsMenuKeyboardNavigation(){if(!this.settingsMenu)return;this.settingsMenuKeyHandler&&this.settingsMenu.removeEventListener("keydown",this.settingsMenuKeyHandler,!0);let t=w(this.settingsMenu,this.settingsButton,`.${this.player.options.classPrefix}-transcript-settings-item`,()=>this.hideSettingsMenu({focusButton:!0}));this.settingsMenuKeyHandler=t}hideSettingsMenu({focusButton:t=!0}={}){this.settingsMenu&&(this.settingsMenu.style.display="none",this.settingsMenuVisible=!1,this.settingsMenuJustOpened=!1,this.settingsMenuKeyHandler&&(this.settingsMenu.removeEventListener("keydown",this.settingsMenuKeyHandler,!0),this.settingsMenuKeyHandler=null),this.settingsButton&&(this.settingsButton.setAttribute("aria-expanded","false"),t&&this.settingsButton.focus({preventScroll:!0})))}enableMoveMode(){this.hideResizeModeIndicator(),this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-move-mode`);let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-move-tooltip`,textContent:"Drag with mouse or press D for keyboard drag mode"});this.transcriptHeader.appendChild(t),setTimeout(()=>{this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-move-mode`),t.parentNode&&t.remove()},2e3)}toggleResizeMode({focus:t=!0}={}){return this.draggableResizable?this.draggableResizable.pointerResizeMode?(this.draggableResizable.disablePointerResizeMode({focus:t}),!1):(this.draggableResizable.enablePointerResizeMode({focus:t}),!0):!1}updateDragOptionState(){if(!this.dragOptionButton)return;let t=!!(this.draggableResizable&&this.draggableResizable.keyboardDragMode),i=t?r.t("transcript.disableDragMode"):r.t("transcript.enableDragMode"),e=t?r.t("transcript.disableDragModeAria"):r.t("transcript.enableDragModeAria");this.dragOptionButton.setAttribute("aria-checked",t?"true":"false"),this.dragOptionButton.setAttribute("aria-label",e),this.dragOptionText&&(this.dragOptionText.textContent=i)}updateResizeOptionState(){if(!this.resizeOptionButton)return;let t=!!(this.draggableResizable&&this.draggableResizable.pointerResizeMode),i=t?r.t("transcript.disableResizeMode"):r.t("transcript.enableResizeMode"),e=t?r.t("transcript.disableResizeModeAria"):r.t("transcript.enableResizeModeAria");this.resizeOptionButton.setAttribute("aria-checked",t?"true":"false"),this.resizeOptionButton.setAttribute("aria-label",e),this.resizeOptionText&&(this.resizeOptionText.textContent=i)}toggleShowTimestamps(){this.showTimestamps=!this.showTimestamps,this.updateShowTimestampsState(),this.updateTimestampVisibility(),this.saveTimestampsPreference()}updateShowTimestampsState(){if(!this.showTimestampsButton)return;let t=this.showTimestamps?r.t("transcript.hideTimestamps"):r.t("transcript.showTimestamps"),i=this.showTimestamps?r.t("transcript.hideTimestampsAria"):r.t("transcript.showTimestampsAria");this.showTimestampsButton.setAttribute("aria-checked",this.showTimestamps?"true":"false"),this.showTimestampsButton.setAttribute("aria-label",i),this.showTimestampsText&&(this.showTimestampsText.textContent=t)}updateTimestampVisibility(){if(!this.transcriptContent)return;this.transcriptContent.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(i=>{i.style.display=this.showTimestamps?"":"none"})}saveTimestampsPreference(){let t=this.storage.getTranscriptPreferences()||{};t.showTimestamps=this.showTimestamps,this.storage.saveTranscriptPreferences(t)}showResizeModeIndicator(){if(!this.transcriptHeader)return;this.hideResizeModeIndicator();let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-tooltip`,textContent:r.t("transcript.resizeModeHint")||"Resize handles enabled. Drag edges or corners to adjust. Press Esc or R to exit."});this.transcriptHeader.appendChild(t),this.resizeModeIndicator=t,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(t){this.updateResizeOptionState(),t?(this.showResizeModeIndicator(),this.announceLive(r.t("transcript.resizeModeEnabled"))):(this.hideResizeModeIndicator(),this.announceLive(r.t("transcript.resizeModeDisabled")))}showStyleDialog(){if(this.styleDialog){this.styleDialog.style.display="block",this.styleDialogVisible=!0,this.handlers.styleDialogKeydown&&document.addEventListener("keydown",this.handlers.styleDialogKeydown),this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let s=this.styleDialog.querySelector("select, input");s&&s.focus({preventScroll:!0})},0);return}this.styleDialog=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-dialog`});let t=o.createElement("h4",{textContent:r.t("transcript.styleTitle"),className:`${this.player.options.classPrefix}-transcript-style-title`});this.styleDialog.appendChild(t);let i=this.createStyleSelectControl(r.t("captions.fontSize"),"fontSize",[{label:r.t("fontSizes.small"),value:"90%"},{label:r.t("fontSizes.normal"),value:"100%"},{label:r.t("fontSizes.large"),value:"110%"},{label:r.t("fontSizes.xlarge"),value:"120%"}]);this.styleDialog.appendChild(i);let e=this.createStyleSelectControl(r.t("captions.fontFamily"),"fontFamily",[{label:r.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:r.t("fontFamilies.serif"),value:"serif"},{label:r.t("fontFamilies.monospace"),value:"monospace"}]);this.styleDialog.appendChild(e);let a=this.createStyleColorControl(r.t("captions.color"),"color");this.styleDialog.appendChild(a);let n=this.createStyleColorControl(r.t("captions.backgroundColor"),"backgroundColor");this.styleDialog.appendChild(n);let p=this.createStyleOpacityControl(r.t("captions.opacity"),"opacity");this.styleDialog.appendChild(p);let l=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-style-close`,textContent:r.t("settings.close"),attributes:{type:"button"}});l.addEventListener("click",()=>this.hideStyleDialog()),this.styleDialog.appendChild(l),this.handlers.styleDialogKeydown=s=>{if(this.styleDialogVisible){if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),this.hideStyleDialog();return}if(s.key==="Tab"){let c=this.styleDialog.querySelectorAll("select, input, button"),h=c[0],u=c[c.length-1];s.shiftKey&&document.activeElement===h?(s.preventDefault(),u.focus({preventScroll:!0})):!s.shiftKey&&document.activeElement===u&&(s.preventDefault(),h.focus({preventScroll:!0}))}}},document.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 s=this.styleDialog.querySelector("select, input");s&&s.focus({preventScroll:!0})},0)}hideStyleDialog(){this.styleDialog&&(this.styleDialog.style.display="none",this.styleDialogVisible=!1,this.handlers.styleDialogKeydown&&document.removeEventListener("keydown",this.handlers.styleDialogKeydown),this.settingsButton&&this.settingsButton.focus({preventScroll:!0}))}createStyleSelectControl(t,i,e){let a=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),n=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,p=o.createElement("label",{textContent:t,attributes:{for:n}});a.appendChild(p);let l=o.createElement("select",{className:`${this.player.options.classPrefix}-transcript-style-select`,attributes:{id:n}});return e.forEach(s=>{let c=o.createElement("option",{textContent:s.label,attributes:{value:s.value}});this.transcriptStyle[i]===s.value&&(c.selected=!0),l.appendChild(c)}),l.addEventListener("change",s=>{this.transcriptStyle[i]=s.target.value,this.applyTranscriptStyles(),this.savePreferences()}),a.appendChild(l),a}createStyleColorControl(t,i){let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,n=o.createElement("label",{textContent:t,attributes:{for:a}});e.appendChild(n);let p=o.createElement("input",{attributes:{id:a,type:"color",value:this.transcriptStyle[i]},className:`${this.player.options.classPrefix}-transcript-style-color`});return p.addEventListener("input",l=>{this.transcriptStyle[i]=l.target.value,this.applyTranscriptStyles(),this.savePreferences()}),e.appendChild(p),e}createStyleOpacityControl(t,i){let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,n=o.createElement("label",{textContent:t,attributes:{for:a}});e.appendChild(n);let p=o.createElement("span",{textContent:Math.round(this.transcriptStyle[i]*100)+"%",className:`${this.player.options.classPrefix}-transcript-style-value`}),l=o.createElement("input",{attributes:{id:a,type:"range",min:"0",max:"1",step:"0.1",value:String(this.transcriptStyle[i])},className:`${this.player.options.classPrefix}-transcript-style-range`});l.addEventListener("input",c=>{let h=parseFloat(c.target.value);this.transcriptStyle[i]=h,p.textContent=Math.round(h*100)+"%",this.applyTranscriptStyles(),this.savePreferences()});let s=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-range-container`});return s.appendChild(l),s.appendChild(p),e.appendChild(n),e.appendChild(s),e}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(e=>{e.style.fontSize=this.transcriptStyle.fontSize,e.style.fontFamily=this.transcriptStyle.fontFamily,e.style.color=this.transcriptStyle.color}),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(e=>{e.style.fontFamily=this.transcriptStyle.fontFamily})}setManagedTimeout(t,i){let e=setTimeout(()=>{this.timeouts.delete(e),t()},i);return this.timeouts.add(e),e}clearManagedTimeout(t){t&&(clearTimeout(t),this.timeouts.delete(t))}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.handlers.audiodescriptionenabled&&this.player.off("audiodescriptionenabled",this.handlers.audiodescriptionenabled),this.handlers.audiodescriptiondisabled&&this.player.off("audiodescriptiondisabled",this.handlers.audiodescriptiondisabled),this.settingsButton&&(this.handlers.settingsClick&&this.settingsButton.removeEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown&&this.settingsButton.removeEventListener("keydown",this.handlers.settingsKeydown)),this.handlers.styleDialogKeydown&&document.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(t=>clearTimeout(t)),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(t){this.liveRegion&&(this.liveRegion.textContent=t||"")}};export{W as TranscriptManager};
|
|
6
|
+
import{a as o,b as r,c as M,d as b,f as v,h as C,i as P,j as f,k as w,m as S,n as z}from"./vidply.chunk-Z6BHMOGK.min.js";var W=class{constructor(t){this.player=t,this.transcriptWindow=null,this.transcriptEntries=[],this.metadataCues=[],this.currentActiveEntry=null,this.isVisible=!1,this.storage=new C("vidply"),this.draggableResizable=null,this.settingsMenuVisible=!1,this.settingsMenu=null,this.settingsButton=null,this.settingsMenuJustOpened=!1,this.resizeOptionButton=null,this.resizeOptionText=null,this.dragOptionButton=null,this.dragOptionText=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.languageLabel=null,this.currentTranscriptLanguage=null,this.availableTranscriptLanguages=[],this.languageSelectorHandler=null;let i=this.storage.getTranscriptPreferences();this.autoscrollEnabled=i?.autoscroll!==void 0?i.autoscroll:!0,this.showTimestamps=i?.showTimestamps!==void 0?i.showTimestamps:!1,this.transcriptStyle={fontSize:i?.fontSize||this.player.options.transcriptFontSize||"100%",fontFamily:i?.fontFamily||this.player.options.transcriptFontFamily||"sans-serif",color:i?.color||this.player.options.transcriptColor||"#ffffff",backgroundColor:i?.backgroundColor||this.player.options.transcriptBackgroundColor||"#1e1e1e",opacity:i?.opacity??this.player.options.transcriptOpacity??.98},this.handlers={timeupdate:()=>this.updateActiveEntry(),audiodescriptionenabled:()=>{this.isVisible&&this.loadTranscriptData()},audiodescriptiondisabled:()=>{this.isVisible&&this.loadTranscriptData()},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("audiodescriptionenabled",this.handlers.audiodescriptionenabled),this.player.on("audiodescriptiondisabled",this.handlers.audiodescriptiondisabled),this.player.on("fullscreenchange",()=>{this.isVisible&&(window.innerWidth<768&&this.setupDragAndDrop(),(!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(),v(this.settingsButton,{delay:150});return}this.createTranscriptWindow(),this.loadTranscriptData(),this.transcriptWindow&&(this.transcriptWindow.style.display="flex",(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.setManagedTimeout(()=>this.positionTranscript(),0),v(this.settingsButton,{delay:150})),this.isVisible=!0}hideTranscript({focusButton:t=!1}={}){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(),t){let i=this.player.controlBar?.controls?.transcript;i&&typeof i.focus=="function"&&i.focus({preventScroll:!0})}}createTranscriptWindow(){this.transcriptWindow=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-window`,attributes:{role:"dialog","aria-label":r.t("transcript.ariaLabel"),tabindex:"-1"}}),this.transcriptHeader=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header`,attributes:{tabindex:"0"}}),this.headerLeft=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-header-left`});let t=r.t("transcript.settingsMenu");this.settingsButton=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-settings`,attributes:{type:"button","aria-label":t,"aria-expanded":"false"}}),this.settingsButton.appendChild(b("settings")),o.attachTooltip(this.settingsButton,t,this.player.options.classPrefix),this.handlers.settingsClick=d=>{d.preventDefault(),d.stopPropagation(),this.settingsMenuVisible?this.hideSettingsMenu():this.showSettingsMenu()},this.settingsButton.addEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown=d=>{d.key==="d"||d.key==="D"?(d.preventDefault(),d.stopPropagation(),this.toggleKeyboardDragMode()):d.key==="r"||d.key==="R"?(d.preventDefault(),d.stopPropagation(),this.toggleResizeMode()):d.key==="Escape"&&this.settingsMenuVisible&&(d.preventDefault(),d.stopPropagation(),this.hideSettingsMenu())},this.settingsButton.addEventListener("keydown",this.handlers.settingsKeydown);let i=o.createElement("h3",{textContent:`${r.t("transcript.title")}. ${r.t("transcript.dragResizePrompt")}`}),e=`${this.player.options.classPrefix}-transcript-autoscroll-${Date.now()}`,a=o.createElement("label",{className:`${this.player.options.classPrefix}-transcript-autoscroll-label`,attributes:{for:e}});this.autoscrollCheckbox=o.createElement("input",{attributes:{id:e,type:"checkbox"}}),this.autoscrollEnabled&&(this.autoscrollCheckbox.checked=!0);let n=o.createElement("span",{textContent:r.t("transcript.autoscroll"),className:`${this.player.options.classPrefix}-transcript-autoscroll-text`});a.appendChild(this.autoscrollCheckbox),a.appendChild(n),this.autoscrollCheckbox.addEventListener("change",d=>{this.autoscrollEnabled=d.target.checked,this.saveAutoscrollPreference()}),this.transcriptHeader.appendChild(i),this.headerLeft.appendChild(this.settingsButton),this.headerLeft.appendChild(a);let p=`${this.player.options.classPrefix}-transcript-language-select-${Date.now()}`,{label:l,select:s}=S({classPrefix:this.player.options.classPrefix,labelClass:`${this.player.options.classPrefix}-transcript-language-label`,selectClass:`${this.player.options.classPrefix}-transcript-language-select`,labelText:"settings.language",selectId:p,hidden:!1});this.languageLabel=l,this.languageSelector=s;let c=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-language-wrapper`,attributes:{style:"display: none;"}});c.appendChild(this.languageLabel),c.appendChild(this.languageSelector),this.languageSelectorWrapper=c,z(c),this.headerLeft.appendChild(c);let h=r.t("transcript.close"),u=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-close`,attributes:{type:"button","aria-label":h}});u.appendChild(b("close")),o.attachTooltip(u,h,this.player.options.classPrefix),u.addEventListener("click",()=>this.hideTranscript({focusButton:!0})),this.transcriptHeader.appendChild(this.headerLeft),this.transcriptHeader.appendChild(u),this.transcriptContent=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-content`}),this.transcriptWindow.appendChild(this.transcriptHeader),this.transcriptWindow.appendChild(this.transcriptContent),this.createResizeHandles(),this.liveRegion=o.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=d=>{this.settingsMenuJustOpened||this.styleDialogJustOpened||this.settingsButton&&this.settingsButton.contains(d.target)||this.settingsMenu&&this.settingsMenu.contains(d.target)||(this.settingsMenuVisible&&this.hideSettingsMenu(),this.styleDialogVisible&&this.styleDialog&&!this.styleDialog.contains(d.target)&&this.hideStyleDialog())},this.documentClickHandlerAdded=!1;let y;this.handlers.resize=()=>{y&&this.clearManagedTimeout(y),y=this.setManagedTimeout(()=>{(!this.draggableResizable||!this.draggableResizable.manuallyPositioned)&&this.positionTranscript()},100)},window.addEventListener("resize",this.handlers.resize)}createResizeHandles(){if(!this.transcriptWindow)return;let t=["n","s","e","w","ne","nw","se","sw"];this.transcriptResizeHandles=t.map(i=>{let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-handle ${this.player.options.classPrefix}-transcript-resize-${i}`,attributes:{"data-direction":i,"data-vidply-managed-resize":"true","aria-hidden":"true"}});return e.style.display="none",this.transcriptWindow.appendChild(e),e})}positionTranscript(){if(!this.transcriptWindow||!this.player.videoWrapper||!this.isVisible||this.draggableResizable&&this.draggableResizable.manuallyPositioned)return;let t=window.innerWidth<768,i=this.player.videoWrapper.getBoundingClientRect(),e=this.player.state.fullscreen;if(t&&!e)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.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),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(e){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 a=260,n=Math.max(a,window.innerWidth-40),p=parseFloat(this.transcriptWindow.style.width)||400,l=Math.max(a,Math.min(p,n));this.transcriptWindow.style.width=`${l}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.removeProperty("border-top"),this.transcriptWindow.style.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}else{let a=parseFloat(this.transcriptWindow.style.width)||400,n=20,p=260,l=this.player.container.getBoundingClientRect();window.getComputedStyle(this.player.container).position==="static"&&(this.player.container.style.position="relative");let c=i.right-l.left+n,h=window.innerWidth-i.right-n,u=Math.max(p,Math.min(a,h)),y=i.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=`${u}px`,this.transcriptWindow.style.maxWidth="none",this.transcriptWindow.style.borderRadius="8px",this.transcriptWindow.style.border="1px solid var(--vidply-border)",this.transcriptWindow.style.removeProperty("border-top"),this.transcriptWindow.style.removeProperty("border-right"),this.transcriptWindow.style.removeProperty("border-bottom"),this.transcriptWindow.style.removeProperty("border-left"),this.transcriptWindow.style.removeProperty("border-image"),this.transcriptWindow.style.removeProperty("border-image-source"),this.transcriptWindow.style.removeProperty("border-image-slice"),this.transcriptWindow.style.removeProperty("border-image-width"),this.transcriptWindow.style.removeProperty("border-image-outset"),this.transcriptWindow.style.removeProperty("border-image-repeat"),this.transcriptHeader&&(this.transcriptHeader.style.cursor="move"),this.transcriptWindow.parentNode!==this.player.container&&this.player.container.appendChild(this.transcriptWindow)}}getAvailableTranscriptLanguages(){let t=this.player.textTracks,i=new Map;return t.forEach(e=>{(e.kind==="captions"||e.kind==="subtitles")&&e.language&&(i.has(e.language)||i.set(e.language,{language:e.language,label:e.label||e.language,track:e}))}),Array.from(i.values())}updateLanguageSelector(){if(this.languageSelector){if(this.availableTranscriptLanguages=this.getAvailableTranscriptLanguages(),this.languageSelector.innerHTML="",this.availableTranscriptLanguages.length<2){this.languageSelectorWrapper&&(this.languageSelectorWrapper.style.display="none");return}if(this.languageSelectorWrapper&&(this.languageSelectorWrapper.style.display="flex"),this.availableTranscriptLanguages.forEach((t,i)=>{let e=o.createElement("option",{textContent:t.label,attributes:{value:t.language,lang:t.language}});this.languageSelector.appendChild(e)}),this.currentTranscriptLanguage)this.languageSelector.value=this.currentTranscriptLanguage;else if(this.availableTranscriptLanguages.length>0){let t=this.player.textTracks.find(i=>(i.kind==="captions"||i.kind==="subtitles")&&i.mode==="showing");this.currentTranscriptLanguage=t?t.language:this.availableTranscriptLanguages[0].language,this.languageSelector.value=this.currentTranscriptLanguage}this.languageSelectorHandler&&this.languageSelector.removeEventListener("change",this.languageSelectorHandler),this.languageSelectorHandler=t=>{this.currentTranscriptLanguage=t.target.value,this.loadTranscriptData(),this.transcriptContent&&this.currentTranscriptLanguage&&this.transcriptContent.setAttribute("lang",this.currentTranscriptLanguage)},this.languageSelector.addEventListener("change",this.languageSelectorHandler)}}loadTranscriptData(){this.transcriptEntries=[],this.transcriptContent.innerHTML="";let t=this.player.textTracks,i=null;this.currentTranscriptLanguage&&(i=t.find(s=>(s.kind==="captions"||s.kind==="subtitles")&&s.language===this.currentTranscriptLanguage)),i||(i=t.find(s=>s.kind==="captions"||s.kind==="subtitles"),i&&(this.currentTranscriptLanguage=i.language));let e=null;this.currentTranscriptLanguage&&(e=t.find(s=>s.kind==="descriptions"&&s.language===this.currentTranscriptLanguage)),e||(e=t.find(s=>s.kind==="descriptions"));let a=t.find(s=>s.kind==="metadata");if(!i&&!e&&!a){this.showNoTranscriptMessage();return}let n=[i,e,a].filter(Boolean);if(n.forEach(s=>{s.mode==="disabled"&&(s.mode="hidden")}),n.some(s=>!s.cues||s.cues.length===0)){let s=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-loading`,textContent:r.t("transcript.loading")});this.transcriptContent.appendChild(s);let c=0,h=()=>{c++,c>=n.length&&this.loadTranscriptData()};n.forEach(u=>{u.addEventListener("load",h,{once:!0})}),this.setManagedTimeout(()=>{this.loadTranscriptData()},500);return}let l=[];i&&i.cues&&Array.from(i.cues).forEach(s=>{l.push({cue:s,type:"caption"})}),e&&e.cues&&Array.from(e.cues).forEach(s=>{l.push({cue:s,type:"description"})}),a&&a.cues&&(this.metadataCues=Array.from(a.cues),this.setupMetadataHandling()),l.sort((s,c)=>s.cue.startTime-c.cue.startTime),l.forEach((s,c)=>{let h=this.createTranscriptEntry(s.cue,c,s.type);this.transcriptEntries.push({element:h,cue:s.cue,type:s.type,startTime:s.cue.startTime,endTime:s.cue.endTime}),this.transcriptContent.appendChild(h)}),this.applyTranscriptStyles(),this.updateTimestampVisibility(),this.transcriptContent&&this.currentTranscriptLanguage&&this.transcriptContent.setAttribute("lang",this.currentTranscriptLanguage),this.updateLanguageSelector()}setupMetadataHandlingOnLoad(){let t=()=>{let e=this.player.textTracks.find(a=>a.kind==="metadata");if(e){if(e.mode==="disabled"&&(e.mode="hidden"),this.metadataCueChangeHandler&&e.removeEventListener("cuechange",this.metadataCueChangeHandler),this.metadataCueChangeHandler=()=>{let a=Array.from(e.activeCues||[]);a.length>0&&this.player.options.debug&&console.log("[VidPly Metadata] Active cues:",a.map(n=>({start:n.startTime,end:n.endTime,text:n.text}))),a.forEach(n=>{this.handleMetadataCue(n)})},e.addEventListener("cuechange",this.metadataCueChangeHandler),this.player.options.debug){let a=e.cues?e.cues.length:0;console.log("[VidPly Metadata] Track enabled,",a,"cues available")}}else this.player.options.debug&&console.warn("[VidPly Metadata] No metadata track found")};t(),this.player.on("loadedmetadata",t)}setupMetadataHandling(){!this.metadataCues||this.metadataCues.length===0||this.player.options.debug&&console.log("[VidPly Metadata]",this.metadataCues.length,"cues stored from transcript load")}handleMetadataCue(t){let i=t.text.trim();this.player.options.debug&&console.log("[VidPly Metadata] Processing cue:",{time:t.startTime,text:i}),this.player.emit("metadata",{time:t.startTime,endTime:t.endTime,text:i,cue:t}),i.includes("PAUSE")&&(this.player.state.paused||(this.player.options.debug&&console.log("[VidPly Metadata] Pausing video at",t.startTime),this.player.pause()),this.player.emit("metadata:pause",{time:t.startTime,text:i}));let e=i.match(/FOCUS:([\w#-]+)/);if(e){let n=e[1],p=document.querySelector(n);p?(this.player.options.debug&&console.log("[VidPly Metadata] Focusing element:",n),this.setManagedTimeout(()=>{p.focus({preventScroll:!0})},10)):this.player.options.debug&&console.warn("[VidPly Metadata] Element not found:",n),this.player.emit("metadata:focus",{time:t.startTime,target:n,element:p,text:i})}let a=i.match(/#[\w-]+/g);a&&(this.player.options.debug&&console.log("[VidPly Metadata] Hashtags found:",a),this.player.emit("metadata:hashtags",{time:t.startTime,hashtags:a,text:i}))}createTranscriptEntry(t,i,e="caption"){let a=this.stripVTTFormatting(t.text),n=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-entry ${this.player.options.classPrefix}-transcript-${e}`,attributes:{tabindex:"0","data-start":String(t.startTime),"data-end":String(t.endTime),"data-type":e}}),p=o.createElement("span",{className:`${this.player.options.classPrefix}-transcript-time`,textContent:M.formatTime(t.startTime),attributes:{"aria-hidden":"true"}}),l=o.createElement("span",{className:`${this.player.options.classPrefix}-transcript-text`,textContent:a});n.appendChild(p),n.appendChild(l);let s=()=>{this.player.seek(t.startTime),this.player.state.paused&&this.player.play()};return n.addEventListener("click",s),n.addEventListener("keydown",c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),s())}),n}stripVTTFormatting(t){return t.replace(/<[^>]+>/g,"").replace(/\n/g," ").trim()}showNoTranscriptMessage(){let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-empty`,textContent:r.t("transcript.noTranscript")});this.transcriptContent.appendChild(t)}updateActiveEntry(){if(!this.isVisible||this.transcriptEntries.length===0)return;let t=this.player.state.currentTime,i=this.transcriptEntries.find(e=>t>=e.startTime&&t<e.endTime);i&&i!==this.currentActiveEntry?(this.currentActiveEntry&&this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),i.element.classList.add(`${this.player.options.classPrefix}-transcript-entry-active`),this.scrollToEntry(i.element),this.currentActiveEntry=i):!i&&this.currentActiveEntry&&(this.currentActiveEntry.element.classList.remove(`${this.player.options.classPrefix}-transcript-entry-active`),this.currentActiveEntry=null)}scrollToEntry(t){if(!this.transcriptContent||!this.autoscrollEnabled)return;let i=this.transcriptContent.getBoundingClientRect(),e=t.getBoundingClientRect();if(e.top<i.top||e.bottom>i.bottom){let a=t.offsetTop-this.transcriptContent.clientHeight/2+t.clientHeight/2;this.transcriptContent.scrollTo({top:a,behavior:"smooth"})}}saveAutoscrollPreference(){let t=this.storage.getTranscriptPreferences()||{};t.autoscroll=this.autoscrollEnabled,this.storage.saveTranscriptPreferences(t)}setupDragAndDrop(){if(!this.transcriptHeader||!this.transcriptWindow)return;let t=window.innerWidth<768,i=this.player.state.fullscreen;if(t&&!i){this.draggableResizable&&(this.draggableResizable.destroy(),this.draggableResizable=null);return}this.draggableResizable||(this.draggableResizable=new P(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:r.t("transcript.resizeModeHint"),onPointerResizeToggle:e=>{this.transcriptResizeHandles.forEach(a=>{a.style.display=e?"block":"none"}),this.onPointerResizeModeChange(e)},onDragStart:e=>{let a=[`.${this.player.options.classPrefix}-transcript-close`,`.${this.player.options.classPrefix}-transcript-settings`,`.${this.player.options.classPrefix}-transcript-language-select`,`.${this.player.options.classPrefix}-transcript-language-label`,`.${this.player.options.classPrefix}-transcript-settings-menu`,`.${this.player.options.classPrefix}-transcript-style-dialog`];for(let n of a)if(e.target.closest(n))return!1;return!0}}),this.customKeyHandler=e=>{let a=e.key.toLowerCase(),n=e.defaultPrevented;if(!(this.settingsMenuVisible||this.styleDialogVisible)){if(a==="home"){e.preventDefault(),e.stopPropagation(),this.draggableResizable&&(this.draggableResizable.pointerResizeMode&&this.draggableResizable.disablePointerResizeMode(),this.draggableResizable.manuallyPositioned=!1,this.positionTranscript(),this.updateResizeOptionState(),this.announceLive(r.t("transcript.positionReset")));return}if(a==="r"){if(n)return;e.preventDefault(),e.stopPropagation(),this.toggleResizeMode()&&this.transcriptWindow.focus({preventScroll:!0});return}if(a==="escape"){if(this.draggableResizable&&this.draggableResizable.pointerResizeMode){e.preventDefault(),e.stopPropagation(),this.draggableResizable.disablePointerResizeMode();return}if(this.draggableResizable&&this.draggableResizable.keyboardDragMode){e.preventDefault(),e.stopPropagation(),this.draggableResizable.disableKeyboardDragMode(),this.announceLive(r.t("transcript.dragModeDisabled"));return}e.preventDefault(),e.stopPropagation(),this.hideTranscript({focusButton:!0});return}}},this.transcriptWindow.addEventListener("keydown",this.customKeyHandler))}toggleKeyboardDragMode(){if(this.draggableResizable){let t=this.draggableResizable.keyboardDragMode;this.draggableResizable.toggleKeyboardDragMode();let i=this.draggableResizable.keyboardDragMode;!t&&i&&this.enableMoveMode(),this.updateDragOptionState(),this.settingsMenuVisible&&this.hideSettingsMenu(),this.transcriptWindow.focus({preventScroll:!0})}}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.attachSettingsMenuKeyboardNavigation(),this.positionSettingsMenuImmediate(),this.updateResizeOptionState(),setTimeout(()=>{let g=this.settingsMenu.querySelectorAll(`.${this.player.options.classPrefix}-transcript-settings-item`);if(g.length>0){g[0].setAttribute("tabindex","0");for(let m=1;m<g.length;m++)g[m].setAttribute("tabindex","-1");g[0].focus({preventScroll:!0})}},50);return}this.settingsMenu=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-settings-menu`,attributes:{role:"menu"}});let t=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"move",label:"transcript.enableDragMode",hasTextClass:!0,onClick:()=>{this.toggleKeyboardDragMode(),this.hideSettingsMenu()}});t.setAttribute("role","switch"),t.setAttribute("aria-checked","false");let i=t.querySelector(`.${this.player.options.classPrefix}-tooltip`);i&&i.remove();let e=t.querySelector(`.${this.player.options.classPrefix}-button-text`);e&&e.remove(),this.dragOptionButton=t,this.dragOptionText=t.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateDragOptionState();let a=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"settings",label:"transcript.styleTranscript",onClick:g=>{g.preventDefault(),g.stopPropagation(),this.hideSettingsMenu(),setTimeout(()=>{this.showStyleDialog()},50)}}),n=a.querySelector(`.${this.player.options.classPrefix}-tooltip`);n&&n.remove();let p=a.querySelector(`.${this.player.options.classPrefix}-button-text`);p&&p.remove();let l=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"resize",label:"transcript.enableResizeMode",hasTextClass:!0,onClick:g=>{g.preventDefault(),g.stopPropagation(),this.toggleResizeMode({focus:!1})?(this.hideSettingsMenu({focusButton:!1}),setTimeout(()=>{this.transcriptWindow&&this.transcriptWindow.focus({preventScroll:!0})},20)):this.hideSettingsMenu({focusButton:!0})}});l.setAttribute("role","switch"),l.setAttribute("aria-checked","false");let s=l.querySelector(`.${this.player.options.classPrefix}-tooltip`);s&&s.remove();let c=l.querySelector(`.${this.player.options.classPrefix}-button-text`);c&&c.remove(),this.resizeOptionButton=l,this.resizeOptionText=l.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateResizeOptionState();let h=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"clock",label:"transcript.showTimestamps",hasTextClass:!0,onClick:()=>{this.toggleShowTimestamps()}});h.setAttribute("role","switch"),h.setAttribute("aria-checked",this.showTimestamps?"true":"false");let u=h.querySelector(`.${this.player.options.classPrefix}-tooltip`);u&&u.remove();let y=h.querySelector(`.${this.player.options.classPrefix}-button-text`);y&&y.remove(),this.showTimestampsButton=h,this.showTimestampsText=h.querySelector(`.${this.player.options.classPrefix}-settings-text`),this.updateShowTimestampsState();let d=f({classPrefix:this.player.options.classPrefix,itemClass:`${this.player.options.classPrefix}-transcript-settings-item`,icon:"close",label:"transcript.closeMenu",onClick:()=>{this.hideSettingsMenu()}}),x=d.querySelector(`.${this.player.options.classPrefix}-tooltip`);x&&x.remove();let T=d.querySelector(`.${this.player.options.classPrefix}-button-text`);T&&T.remove(),this.settingsMenu.appendChild(t),this.settingsMenu.appendChild(l),this.settingsMenu.appendChild(a),this.settingsMenu.appendChild(h),this.settingsMenu.appendChild(d),this.settingsMenu.style.visibility="hidden",this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.parentNode?this.settingsButton.insertAdjacentElement("afterend",this.settingsMenu):this.headerLeft?this.headerLeft.appendChild(this.settingsMenu):this.transcriptHeader?this.transcriptHeader.appendChild(this.settingsMenu):this.transcriptWindow.appendChild(this.settingsMenu),this.positionSettingsMenuImmediate(),requestAnimationFrame(()=>{this.settingsMenu&&(this.settingsMenu.style.visibility="visible")}),this.settingsMenuKeyHandler=w(this.settingsMenu,this.settingsButton,`.${this.player.options.classPrefix}-transcript-settings-item`,()=>this.hideSettingsMenu({focusButton:!0})),this.settingsMenuVisible=!0,this.settingsMenu.style.display="block",this.settingsButton&&this.settingsButton.setAttribute("aria-expanded","true"),this.updateResizeOptionState(),setTimeout(()=>{let g=this.settingsMenu.querySelectorAll(`.${this.player.options.classPrefix}-transcript-settings-item`);if(g.length>0){g[0].setAttribute("tabindex","0");for(let m=1;m<g.length;m++)g[m].setAttribute("tabindex","-1");g[0].focus({preventScroll:!0})}},50)}positionSettingsMenuImmediate(){if(!this.settingsMenu||!this.settingsButton)return;let t=this.settingsButton.parentElement;if(!t)return;let i=this.settingsButton.getBoundingClientRect(),e=t.getBoundingClientRect(),a=this.settingsMenu.getBoundingClientRect(),n=window.innerHeight,p=i.left-e.left,l=i.bottom-e.top,s=i.top-e.top,c=n-i.bottom,h=i.top,u=l+4;c<a.height+20&&h>c?(u=s-a.height-4,this.settingsMenu.classList.add("vidply-menu-above")):this.settingsMenu.classList.remove("vidply-menu-above"),this.settingsMenu.style.top=`${u}px`,this.settingsMenu.style.left=`${p}px`,this.settingsMenu.style.right="auto",this.settingsMenu.style.bottom="auto"}positionSettingsMenu(){!this.settingsMenu||!this.settingsButton||requestAnimationFrame(()=>{setTimeout(()=>{this.positionSettingsMenuImmediate()},10)})}attachSettingsMenuKeyboardNavigation(){if(!this.settingsMenu)return;this.settingsMenuKeyHandler&&this.settingsMenu.removeEventListener("keydown",this.settingsMenuKeyHandler,!0);let t=w(this.settingsMenu,this.settingsButton,`.${this.player.options.classPrefix}-transcript-settings-item`,()=>this.hideSettingsMenu({focusButton:!0}));this.settingsMenuKeyHandler=t}hideSettingsMenu({focusButton:t=!0}={}){this.settingsMenu&&(this.settingsMenu.style.display="none",this.settingsMenuVisible=!1,this.settingsMenuJustOpened=!1,this.settingsMenuKeyHandler&&(this.settingsMenu.removeEventListener("keydown",this.settingsMenuKeyHandler,!0),this.settingsMenuKeyHandler=null),this.settingsButton&&(this.settingsButton.setAttribute("aria-expanded","false"),t&&this.settingsButton.focus({preventScroll:!0})))}enableMoveMode(){this.hideResizeModeIndicator(),this.transcriptWindow.classList.add(`${this.player.options.classPrefix}-transcript-move-mode`);let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-move-tooltip`,textContent:"Drag with mouse or press D for keyboard drag mode"});this.transcriptHeader.appendChild(t),setTimeout(()=>{this.transcriptWindow.classList.remove(`${this.player.options.classPrefix}-transcript-move-mode`),t.parentNode&&t.remove()},2e3)}toggleResizeMode({focus:t=!0}={}){return this.draggableResizable?this.draggableResizable.pointerResizeMode?(this.draggableResizable.disablePointerResizeMode({focus:t}),!1):(this.draggableResizable.enablePointerResizeMode({focus:t}),!0):!1}updateDragOptionState(){if(!this.dragOptionButton)return;let t=!!(this.draggableResizable&&this.draggableResizable.keyboardDragMode),i=t?r.t("transcript.disableDragMode"):r.t("transcript.enableDragMode"),e=t?r.t("transcript.disableDragModeAria"):r.t("transcript.enableDragModeAria");this.dragOptionButton.setAttribute("aria-checked",t?"true":"false"),this.dragOptionButton.setAttribute("aria-label",e),this.dragOptionText&&(this.dragOptionText.textContent=i)}updateResizeOptionState(){if(!this.resizeOptionButton)return;let t=!!(this.draggableResizable&&this.draggableResizable.pointerResizeMode),i=t?r.t("transcript.disableResizeMode"):r.t("transcript.enableResizeMode"),e=t?r.t("transcript.disableResizeModeAria"):r.t("transcript.enableResizeModeAria");this.resizeOptionButton.setAttribute("aria-checked",t?"true":"false"),this.resizeOptionButton.setAttribute("aria-label",e),this.resizeOptionText&&(this.resizeOptionText.textContent=i)}toggleShowTimestamps(){this.showTimestamps=!this.showTimestamps,this.updateShowTimestampsState(),this.updateTimestampVisibility(),this.saveTimestampsPreference()}updateShowTimestampsState(){if(!this.showTimestampsButton)return;let t=this.showTimestamps?r.t("transcript.hideTimestamps"):r.t("transcript.showTimestamps"),i=this.showTimestamps?r.t("transcript.hideTimestampsAria"):r.t("transcript.showTimestampsAria");this.showTimestampsButton.setAttribute("aria-checked",this.showTimestamps?"true":"false"),this.showTimestampsButton.setAttribute("aria-label",i),this.showTimestampsText&&(this.showTimestampsText.textContent=t)}updateTimestampVisibility(){if(!this.transcriptContent)return;this.transcriptContent.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(i=>{i.style.display=this.showTimestamps?"":"none"})}saveTimestampsPreference(){let t=this.storage.getTranscriptPreferences()||{};t.showTimestamps=this.showTimestamps,this.storage.saveTranscriptPreferences(t)}showResizeModeIndicator(){if(!this.transcriptHeader)return;this.hideResizeModeIndicator();let t=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-resize-tooltip`,textContent:r.t("transcript.resizeModeHint")||"Resize handles enabled. Drag edges or corners to adjust. Press Esc or R to exit."});this.transcriptHeader.appendChild(t),this.resizeModeIndicator=t,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(t){this.updateResizeOptionState(),t?(this.showResizeModeIndicator(),this.announceLive(r.t("transcript.resizeModeEnabled"))):(this.hideResizeModeIndicator(),this.announceLive(r.t("transcript.resizeModeDisabled")))}showStyleDialog(){if(this.styleDialog){this.styleDialog.style.display="block",this.styleDialogVisible=!0,this.handlers.styleDialogKeydown&&document.addEventListener("keydown",this.handlers.styleDialogKeydown),this.styleDialogJustOpened=!0,setTimeout(()=>{this.styleDialogJustOpened=!1},350),setTimeout(()=>{let s=this.styleDialog.querySelector("select, input");s&&s.focus({preventScroll:!0})},0);return}this.styleDialog=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-dialog`});let t=o.createElement("h4",{textContent:r.t("transcript.styleTitle"),className:`${this.player.options.classPrefix}-transcript-style-title`});this.styleDialog.appendChild(t);let i=this.createStyleSelectControl(r.t("captions.fontSize"),"fontSize",[{label:r.t("fontSizes.small"),value:"90%"},{label:r.t("fontSizes.normal"),value:"100%"},{label:r.t("fontSizes.large"),value:"110%"},{label:r.t("fontSizes.xlarge"),value:"120%"}]);this.styleDialog.appendChild(i);let e=this.createStyleSelectControl(r.t("captions.fontFamily"),"fontFamily",[{label:r.t("fontFamilies.sansSerif"),value:"sans-serif"},{label:r.t("fontFamilies.serif"),value:"serif"},{label:r.t("fontFamilies.monospace"),value:"monospace"}]);this.styleDialog.appendChild(e);let a=this.createStyleColorControl(r.t("captions.color"),"color");this.styleDialog.appendChild(a);let n=this.createStyleColorControl(r.t("captions.backgroundColor"),"backgroundColor");this.styleDialog.appendChild(n);let p=this.createStyleOpacityControl(r.t("captions.opacity"),"opacity");this.styleDialog.appendChild(p);let l=o.createElement("button",{className:`${this.player.options.classPrefix}-transcript-style-close`,textContent:r.t("settings.close"),attributes:{type:"button"}});l.addEventListener("click",()=>this.hideStyleDialog()),this.styleDialog.appendChild(l),this.handlers.styleDialogKeydown=s=>{if(this.styleDialogVisible){if(s.key==="Escape"){s.preventDefault(),s.stopPropagation(),this.hideStyleDialog();return}if(s.key==="Tab"){let c=this.styleDialog.querySelectorAll("select, input, button"),h=c[0],u=c[c.length-1];s.shiftKey&&document.activeElement===h?(s.preventDefault(),u.focus({preventScroll:!0})):!s.shiftKey&&document.activeElement===u&&(s.preventDefault(),h.focus({preventScroll:!0}))}}},document.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 s=this.styleDialog.querySelector("select, input");s&&s.focus({preventScroll:!0})},0)}hideStyleDialog(){this.styleDialog&&(this.styleDialog.style.display="none",this.styleDialogVisible=!1,this.handlers.styleDialogKeydown&&document.removeEventListener("keydown",this.handlers.styleDialogKeydown),this.settingsButton&&this.settingsButton.focus({preventScroll:!0}))}createStyleSelectControl(t,i,e){let a=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),n=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,p=o.createElement("label",{textContent:t,attributes:{for:n}});a.appendChild(p);let l=o.createElement("select",{className:`${this.player.options.classPrefix}-transcript-style-select`,attributes:{id:n}});return e.forEach(s=>{let c=o.createElement("option",{textContent:s.label,attributes:{value:s.value}});this.transcriptStyle[i]===s.value&&(c.selected=!0),l.appendChild(c)}),l.addEventListener("change",s=>{this.transcriptStyle[i]=s.target.value,this.applyTranscriptStyles(),this.savePreferences()}),a.appendChild(l),a}createStyleColorControl(t,i){let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,n=o.createElement("label",{textContent:t,attributes:{for:a}});e.appendChild(n);let p=o.createElement("input",{attributes:{id:a,type:"color",value:this.transcriptStyle[i]},className:`${this.player.options.classPrefix}-transcript-style-color`});return p.addEventListener("input",l=>{this.transcriptStyle[i]=l.target.value,this.applyTranscriptStyles(),this.savePreferences()}),e.appendChild(p),e}createStyleOpacityControl(t,i){let e=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-group`}),a=`${this.player.options.classPrefix}-transcript-${i}-${Date.now()}`,n=o.createElement("label",{textContent:t,attributes:{for:a}});e.appendChild(n);let p=o.createElement("span",{textContent:Math.round(this.transcriptStyle[i]*100)+"%",className:`${this.player.options.classPrefix}-transcript-style-value`}),l=o.createElement("input",{attributes:{id:a,type:"range",min:"0",max:"1",step:"0.1",value:String(this.transcriptStyle[i])},className:`${this.player.options.classPrefix}-transcript-style-range`});l.addEventListener("input",c=>{let h=parseFloat(c.target.value);this.transcriptStyle[i]=h,p.textContent=Math.round(h*100)+"%",this.applyTranscriptStyles(),this.savePreferences()});let s=o.createElement("div",{className:`${this.player.options.classPrefix}-transcript-style-range-container`});return s.appendChild(l),s.appendChild(p),e.appendChild(n),e.appendChild(s),e}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(e=>{e.style.fontSize=this.transcriptStyle.fontSize,e.style.fontFamily=this.transcriptStyle.fontFamily,e.style.color=this.transcriptStyle.color}),this.transcriptWindow.querySelectorAll(`.${this.player.options.classPrefix}-transcript-time`).forEach(e=>{e.style.fontFamily=this.transcriptStyle.fontFamily})}setManagedTimeout(t,i){let e=setTimeout(()=>{this.timeouts.delete(e),t()},i);return this.timeouts.add(e),e}clearManagedTimeout(t){t&&(clearTimeout(t),this.timeouts.delete(t))}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.handlers.audiodescriptionenabled&&this.player.off("audiodescriptionenabled",this.handlers.audiodescriptionenabled),this.handlers.audiodescriptiondisabled&&this.player.off("audiodescriptiondisabled",this.handlers.audiodescriptiondisabled),this.settingsButton&&(this.handlers.settingsClick&&this.settingsButton.removeEventListener("click",this.handlers.settingsClick),this.handlers.settingsKeydown&&this.settingsButton.removeEventListener("keydown",this.handlers.settingsKeydown)),this.handlers.styleDialogKeydown&&document.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(t=>clearTimeout(t)),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(t){this.liveRegion&&(this.liveRegion.textContent=t||"")}};export{W as TranscriptManager};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Universal, Accessible Video Player
|
|
3
|
+
* (c) 2026 Matthias Peltzer
|
|
4
|
+
* Released under GPL-2.0-or-later License
|
|
5
|
+
*/
|
|
6
|
+
var a=class{constructor(e){this.player=e,this.vimeo=null,this.videoId=null,this.isReady=!1,this.iframe=null}async init(){let e=this.player.currentSource||this.player.element.src;if(this.videoId=this.extractVideoId(e),!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.maxHeight="100%",this.player.element.parentNode.insertBefore(this.iframe,this.player.element)}async initializePlayer(){let e={id:this.videoId,width:"100%",height:"100%",controls:!0,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;let t=this.iframe.querySelector("iframe");t&&(t.style.width="100%",t.style.height="100%",t.setAttribute("width","100%"),t.setAttribute("height","100%")),this.player.container&&this.player.container.classList.add("vidply-external-controls"),this.attachEvents();try{let i=await this.vimeo.getDuration();this.player.state.duration=i,this.player.emit("loadedmetadata")}catch(i){this.player.log("Error getting duration:",i,"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(){if(this.isReady&&this.vimeo){let e=window.scrollX,t=window.scrollY;this.vimeo.play().catch(i=>{this.player.log("Play error:",i,"warn")}),window.scrollTo(e,t)}}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="")}};export{a as VimeoRenderer};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Universal, Accessible Video Player
|
|
3
|
+
* (c) 2026 Matthias Peltzer
|
|
4
|
+
* Released under GPL-2.0-or-later License
|
|
5
|
+
*/
|
|
6
|
+
var s=class{constructor(e){this.player=e,this.youtube=null,this.videoId=null,this.isReady=!1,this.iframe=null}async init(){let e=this.player.currentSource||this.player.element.src;if(this.videoId=this.extractVideoId(e),!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 a=e.match(i);if(a&&a[1])return a[1]}return null}async loadYouTubeAPI(){return window.YT&&window.YT.Player?Promise.resolve():new Promise((e,t)=>{if(window.onYouTubeIframeAPIReady){let r=window.onYouTubeIframeAPIReady;window.onYouTubeIframeAPIReady=()=>{r(),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 a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(i,a)})}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.maxHeight="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:1,disablekb:0,fs:1,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(),this.player.container&&this.player.container.classList.add("vidply-external-controls"),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(){if(this.isReady&&this.youtube){let e=window.scrollX,t=window.scrollY;this.youtube.playVideo(),window.scrollTo(e,t)}}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="")}};export{s as YouTubeRenderer};
|