/*!
* artplayer-plugin-hls-control.js v1.0.2
* Github: https://github.com/zhw2590582/ArtPlayer
* (c) 2017-2026 Harvey Zhao
* Released under the MIT License.
*/
function t(t,e){const l=/* @__PURE__ */new Map;return t.filter(t=>{const o=t[e];return void 0===o||!l.has(o)&&l.set(o,1)})}function e(e={}){return l=>{const{$video:o}=l.template,{errorHandle:n}=l.constructor.utils;function a(){n(l.hls?.media===o,'Cannot find instance of HLS from "art.hls"'),function(o){if(!o.levels.length)return;const n=e.quality||{},a=n.auto||"Auto",c=n.title||"Quality",s=n.getName||(t=>t.name||`${t.height}P`),i=o.levels[o.currentLevel],r=i?s(i):a,u=t(o.levels.map((t,e)=>({html:s(t,e),value:e,default:o.currentLevel===e})),"html").sort((t,e)=>e.value-t.value);u.push({html:a,value:-1,default:-1===o.currentLevel});const h=t=>(o.currentLevel=t.value,l.notice.show=`${c}: ${t.html}`,n.control&&l.controls.check(t),n.setting&&l.setting.check(t),t.html);n.control&&l.controls.update({name:"hls-quality",position:"right",html:r,style:{padding:"0 10px"},selector:u,onSelect:h}),n.setting&&l.setting.update({name:"hls-quality",tooltip:r,html:c,icon:'',width:200,selector:u,onSelect:h})}(l.hls),function(o){if(!o.audioTracks.length)return;const n=e.audio||{},a=n.auto||"Auto",c=n.title||"Audio",s=n.getName||(t=>t.name||t.lang||t.language),i=o.audioTracks[o.audioTrack],r=i?s(i):a,u=t(o.audioTracks.map((t,e)=>({html:s(t,e),value:t.id,default:o.audioTrack===t.id})),"html"),h=t=>(o.audioTrack=t.value,l.notice.show=`${c}: ${t.html}`,n.control&&l.controls.check(t),n.setting&&l.setting.check(t),t.html);n.control&&l.controls.update({name:"hls-audio",position:"right",html:r,style:{padding:"0 10px"},selector:u,onSelect:h}),n.setting&&l.setting.update({name:"hls-audio",tooltip:r,html:c,icon:'',width:200,selector:u,onSelect:h})}(l.hls)}return l.on("ready",a),l.on("restart",a),{name:"artplayerPluginHlsControl",update:a}}}export{e as default};