1import { t as e } from "./video.es-DWhCbnPv.js"; 2var t = e.getComponent(`MenuItem`), n = e.dom || e, r = class extends t { 3 constructor(e2, t2 = {}) { 4 let n2 = t2.selected; 5 t2.selected = t2.active, super(e2, t2); 6 let r2 = e2.qualityLevels(); 7 this.levels_ = t2.levels, this.selected_ = n2, this.handleQualityChange = this.handleQualityChange.bind(this), this.controlText(t2.controlText), this.on(r2, `change`, this.handleQualityChange), this.on(`dispose`, () => { 8 this.off(r2, `change`, this.handleQualityChange); 9 }); 10 } 11 createEl(e2, t2, r2) { 12 let i2 = super.createEl(e2, t2, r2), a2 = n.createEl(`span`, { className: `vjs-quality-menu-item-sub-label`, innerHTML: this.localize(this.options_.subLabel || ``) }); 13 return this.subLabel_ = a2, i2 && i2.appendChild(a2), i2; 14 } 15 handleClick() { 16 this.updateSiblings_(); 17 let e2 = this.player().qualityLevels(), t2 = e2.selectedIndex; 18 for (let n2 = 0, r2 = e2.length; n2 < r2; n2++) n2 !== t2 && (e2[n2].enabled = false); 19 for (let t3 = 0, n2 = this.levels_.length; t3 < n2; t3++) e2[this.levels_[t3]].enabled = true; 20 t2 !== -1 && this.levels_.indexOf(t2) === -1 && (e2[t2].enabled = false); 21 } 22 handleQualityChange() { 23 let e2 = this.player().qualityLevels(), t2 = this.levels_.indexOf(e2.selectedIndex) > -1; 24 this.selected(t2); 25 } 26 selected(e2) { 27 if (this.selectable) if (this.selected_) { 28 let t2 = this.options_.subLabel; 29 this.addClass(`vjs-selected`), this.el_.setAttribute(`aria-checked`, `true`), this.controlText(this.localize(t2 ? `selected,` : `selected`)); 30 let n2 = this.player().controlBar.getChild(`QualityMenuButton`); 31 e2 ? n2.removeClass(`vjs-quality-menu-button-waiting`) : n2.addClass(`vjs-quality-menu-button-waiting`); 32 } else this.removeClass(`vjs-selected`), this.el_.setAttribute(`aria-checked`, `false`), this.controlText(this.options_.controlText); 33 } 34 updateSiblings_() { 35 let e2 = this.player().qualityLevels(), t2 = this.player().controlBar.getChild(`QualityMenuButton`).items; 36 for (let n2 = 0, r2 = t2.length; n2 < r2; n2++) { 37 let r3 = t2[n2], i2 = r3.levels_.indexOf(e2.selectedIndex) > -1; 38 r3.selected_ = r3 === this, r3.selected(i2); 39 } 40 } 41}, i = e.getComponent(`MenuButton`), a = function(e2) { 42 return Array.from(e2).some((e3) => e3.height); 43}, o = function(e2) { 44 return e2 >= 2160 ? `4K` : e2 >= 720 ? `HD` : ``; 45}, s = class extends i { 46 constructor(e2, t2 = {}) { 47 super(e2, t2), this.el_.setAttribute(`aria-label`, this.localize(`Quality Levels`)), this.controlText(`Quality Levels`), e2.options().experimentalSvgIcons || this.$(`.vjs-icon-placeholder`).classList.add(`vjs-icon-cog`), this.setIcon(`cog`), this.qualityLevels_ = e2.qualityLevels(), this.update = this.update.bind(this), this.hide = this.hide.bind(this), this.handleQualityChange_ = this.handleQualityChange_.bind(this), this.firstChangeHandler_ = this.firstChangeHandler_.bind(this), this.enableDefaultResolution_ = this.enableDefaultResolution_.bind(this), this.on(this.qualityLevels_, `addqualitylevel`, this.update), this.on(this.qualityLevels_, `removequalitylevel`, this.update), this.on(this.qualityLevels_, `change`, this.handleQualityChange_), this.one(this.qualityLevels_, `change`, this.firstChangeHandler_), e2.on(`adstart`, this.hide), e2.on([`adend`, `adtimeout`], this.update), this.update(), this.on(`dispose`, () => { 48 this.off(this.qualityLevels_, `addqualitylevel`, this.update), this.off(this.qualityLevels_, `removequalitylevel`, this.update), this.off(this.qualityLevels_, `change`, this.handleQualityChange_), this.off(this.qualityLevels_, `change`, this.firstChangeHandler_), e2.off(`adstart`, this.hide), e2.off([`adend`, `adtimeout`], this.update), e2.off(`loadedmetadata`, this.enableDefaultResolution_); 49 }); 50 } 51 buildWrapperCSSClass() { 52 return `vjs-quality-menu-wrapper ${super.buildWrapperCSSClass()}`; 53 } 54 buildCSSClass() { 55 return `vjs-quality-menu-button ${super.buildCSSClass()}`; 56 } 57 createItems() { 58 let e2 = []; 59 if (!(this.qualityLevels_ && this.qualityLevels_.length)) return e2; 60 let t2;
61 if (this.options_.useResolutionLabels && a(this.qualityLevels_) ? (t2 = this.groupByResolution_(), this.addClass(`vjs-quality-menu-button-use-resolution`)) : (t2 = this.groupByBitrate_(), this.removeClass(`vjs-quality-menu-button-use-resolution`)), t2.length <= 1) return []; 62 t2.forEach((t3) => { 63 t3.levels.length && (t3.selectable = true, e2.push(new r(this.player(), t3))); 64 }); 65 let n2 = new r(this.player(), { levels: Array.prototype.map.call(this.qualityLevels_, (e3, t3) => t3), label: this.localize(`Auto`), controlText: ``, active: true, selected: true, selectable: true }); 66 return this.autoMenuItem_ = n2, e2.push(n2), e2; 67 } 68 groupByResolution_() { 69 let e2 = {}, t2 = []; 70 for (let n3 = 0, r2 = this.qualityLevels_.length; n3 < r2; n3++) { 71 let r3 = this.qualityLevels_[n3], i2 = this.qualityLevels_.selectedIndex === n3, a2 = r3.height; 72 if (!a2) continue; 73 let s2; 74 if (s2 = this.options_.resolutionLabelBitrates ? `${a2}p @ ${Math.round(r3.bitrate / 1e3)} kbps` : a2 + `p`, !e2[s2]) { 75 let n4 = o(a2); 76 e2[s2] = { levels: [], label: s2, controlText: ``, subLabel: n4 }, t2.push({ label: s2, lines: a2 }); 77 } 78 i2 && (e2[s2].active = true), e2[s2].levels.push(n3); 79 } 80 t2.sort((e3, t3) => t3.lines - e3.lines); 81 let n2 = []; 82 return t2.forEach((t3) => { 83 n2.push(e2[t3.label]); 84 }), n2; 85 } 86 groupByBitrate_() { 87 let e2 = [{ levels: [], label: `HD`, controlText: `High Definition` }, { levels: [], label: `SD`, controlText: `Standard Definition` }]; 88 for (let t2 = 0, n2 = this.qualityLevels_.length; t2 < n2; t2++) { 89 let n3 = this.qualityLevels_[t2], r2 = this.qualityLevels_.selectedIndex === t2, i2; 90 i2 = n3.bitrate < this.options_.sdBitrateLimit ? e2[1] : e2[0], r2 && (i2.active = true), i2.levels.push(t2); 91 } 92 return !e2[0].levels.length || !e2[1].levels.length ? [] : e2; 93 } 94 handleQualityChange_() { 95 let e2 = this.qualityLevels_[this.qualityLevels_.selectedIndex], t2 = this.options_.useResolutionLabels && a(this.qualityLevels_), n2 = ``; 96 e2 && (t2 ? n2 = o(e2.height) : e2.bitrate >= this.options_.sdBitrateLimit && (n2 = `HD`)), n2 === `HD` ? (this.addClass(`vjs-quality-menu-button-HD-flag`), this.removeClass(`vjs-quality-menu-button-4K-flag`)) : n2 === `4K` ? (this.removeClass(`vjs-quality-menu-button-HD-flag`), this.addClass(`vjs-quality-menu-button-4K-flag`)) : (this.removeClass(`vjs-quality-menu-button-HD-flag`), this.removeClass(`vjs-quality-menu-button-4K-flag`)), this.autoMenuItem_ && (this.autoMenuItem_.manuallySelected_ && e2 ? this.autoMenuItem_.subLabel_.innerHTML = this.localize(n2) : this.autoMenuItem_.subLabel_.innerHTML = ``); 97 } 98 enableDefaultResolution_() { 99 let e2 = this.options_.defaultResolution; 100 for (let t2 = 0; t2 < this.items.length; t2++) this.items[t2].options_.label.indexOf(e2) !== -1 && this.items[t2].handleClick(); 101 } 102 firstChangeHandler_() { 103 if (this.player_.readyState() < 1 && this.player_.preload() !== `none`) { 104 this.player_.one(`loadedmetadata`, this.enableDefaultResolution_); 105 return; 106 } 107 this.enableDefaultResolution_(); 108 } 109}; 110e.registerComponent(`QualityMenuButton`, s); 111var c = `1.0.4`, l = { sdBitrateLimit: 2e6, useResolutionLabels: true, resolutionLabelBitrates: false, defaultResolution: `none` }, u = (e2, t2) => { 112 e2.addClass(`vjs-quality-menu`); 113 let n2 = e2.getChild(`controlBar`), r2 = n2.addChild(`QualityMenuButton`, t2, n2.children_.length - 2); 114 return function() { 115 e2.removeClass(`vjs-quality-menu`), n2.removeChild(r2), r2.dispose(); 116 }; 117}, d = function(e2, t2) { 118 if (e2.qualityLevels !== void 0) { 119 e2.qualityLevels(); 120 let n2 = () => { 121 }; 122 e2.ready(() => { 123 n2 = u(e2, t2), e2.on(`loadstart`, () => { 124 n2(), n2 = u(e2, t2); 125 }); 126 }), e2.qualityMenu = () => { 127 }, e2.qualityMenu.VERSION = c; 128 } 129}, f = function(t2) { 130 d(this, e.obj.merge(l, t2)); 131}; 132e.registerPlugin(`qualityMenu`, f), f.VERSION = c; 133export { 134 f as default 135};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.