@broadcastingplatforms/player 1.4.9 → 1.5.0

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/bp-player.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * BP Player (v1.4.9)
2
+ * BP Player (v1.5.0)
3
3
  * Universal video player web component
4
4
  */
5
5
  "use strict";var BPPlayer=(()=>{var kv=Object.create;var Cr=Object.defineProperty;var Gu=Object.getOwnPropertyDescriptor;var Lv=Object.getOwnPropertyNames;var zu=Object.getPrototypeOf,wv=Object.prototype.hasOwnProperty;var Iv=Reflect.get;var Yu=i=>{throw TypeError(i)};var Cv=(i,e,t)=>e in i?Cr(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Qu=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Rv=(i,e)=>{for(var t in e)Cr(i,t,{get:e[t],enumerable:!0})},Zu=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Lv(e))!wv.call(i,n)&&n!==t&&Cr(i,n,{get:()=>e[n],enumerable:!(r=Gu(e,n))||r.enumerable});return i};var Mv=(i,e,t)=>(t=i!=null?kv(zu(i)):{},Zu(e||!i||!i.__esModule?Cr(t,"default",{value:i,enumerable:!0}):t,i)),xv=i=>Zu(Cr({},"__esModule",{value:!0}),i),V=(i,e,t,r)=>{for(var n=r>1?void 0:r?Gu(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(r?s(e,t,n):s(n))||n);return r&&n&&Cr(e,t,n),n};var q=(i,e,t)=>Cv(i,typeof e!="symbol"?e+"":e,t),rd=(i,e,t)=>e.has(i)||Yu("Cannot "+t);var c=(i,e,t)=>(rd(i,e,"read from private field"),t?t.call(i):e.get(i)),k=(i,e,t)=>e.has(i)?Yu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),v=(i,e,t,r)=>(rd(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),C=(i,e,t)=>(rd(i,e,"access private method"),t);var nd=(i,e,t)=>Iv(zu(i),t,e);var xb={};Rv(xb,{Attribute:()=>vo,BPDefaultUI:()=>ae,BPErrorDisplay:()=>Kt,BPLiveError:()=>rt,BPLiveService:()=>xr,BPOverlay:()=>Ot,BPPlayer:()=>Re,Hls:()=>xe.default,HlsVideo:()=>Ri,HlsVideoElement:()=>Tu,LiveKitVideo:()=>Lr,LiveKitVideoElement:()=>Lu,NANOPLAYER_NO_REPLAY_CODES:()=>vh,NanoVideo:()=>Di,NanoVideoElement:()=>Su,StateReceiverMixin:()=>gh,StateReceiverProps:()=>Bi,addGlobalStyles:()=>Pr,classifyLiveKitError:()=>$s,classifyNanoPlayerError:()=>Hs,createInitialState:()=>ao,createPlayerCore:()=>Bs,createTemplate:()=>Th,forEachStateReceiverElement:()=>Wi,isBPLiveClipSource:()=>co,isBPLiveSource:()=>Vs,isBPLiveStreamSource:()=>lo,isStateReceiverElement:()=>Ws,propagateStateToReceiver:()=>po,removeStateFromReceiver:()=>mo,templateWithStyles:()=>Ah,toggleAttribute:()=>ge});var Ps=globalThis,Ds=Ps.ShadowRoot&&(Ps.ShadyCSS===void 0||Ps.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,od=Symbol(),Xu=new WeakMap,Xn=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==od)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Ds&&e===void 0){let r=t!==void 0&&t.length===1;r&&(e=Xu.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Xu.set(t,e))}return e}toString(){return this.cssText}},ju=i=>new Xn(typeof i=="string"?i:i+"",void 0,od),jn=(i,...e)=>{let t=i.length===1?i[0]:e.reduce((r,n,o)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+i[o+1],i[0]);return new Xn(t,i,od)},Ju=(i,e)=>{if(Ds)i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let r=document.createElement("style"),n=Ps.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=t.cssText,i.appendChild(r)}},sd=Ds?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(let r of e.cssRules)t+=r.cssText;return ju(t)})(i):i;var{is:Pv,defineProperty:Dv,getOwnPropertyDescriptor:Ov,getOwnPropertyNames:Nv,getOwnPropertySymbols:Uv,getPrototypeOf:Hv}=Object,Jt=globalThis,eh=Jt.trustedTypes,$v=eh?eh.emptyScript:"",ad=Jt.reactiveElementPolyfillSupport,Jn=(i,e)=>i,eo={toAttribute(i,e){switch(e){case Boolean:i=i?$v:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},Os=(i,e)=>!Pv(i,e),th={attribute:!0,type:String,converter:eo,reflect:!1,useDefault:!1,hasChanged:Os};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Jt.litPropertyMetadata??(Jt.litPropertyMetadata=new WeakMap);var Ht=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=th){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let r=Symbol(),n=this.getPropertyDescriptor(e,r,t);n!==void 0&&Dv(this.prototype,e,n)}}static getPropertyDescriptor(e,t,r){let{get:n,set:o}=Ov(this.prototype,e)??{get(){return this[t]},set(s){this[t]=s}};return{get:n,set(s){let l=n==null?void 0:n.call(this);o==null||o.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??th}static _$Ei(){if(this.hasOwnProperty(Jn("elementProperties")))return;let e=Hv(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Jn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Jn("properties"))){let t=this.properties,r=[...Nv(t),...Uv(t)];for(let n of r)this.createProperty(n,t[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[r,n]of t)this.elementProperties.set(r,n)}this._$Eh=new Map;for(let[t,r]of this.elementProperties){let n=this._$Eu(t,r);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let n of r)t.unshift(sd(n))}else e!==void 0&&t.push(sd(e));return t}static _$Eu(e,t){let r=t.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let r of t.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Ju(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var r;return(r=t.hostConnected)==null?void 0:r.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var r;return(r=t.hostDisconnected)==null?void 0:r.call(t)})}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ET(e,t){var o;let r=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,r);if(n!==void 0&&r.reflect===!0){let s=(((o=r.converter)==null?void 0:o.toAttribute)!==void 0?r.converter:eo).toAttribute(t,r.type);this._$Em=e,s==null?this.removeAttribute(n):this.setAttribute(n,s),this._$Em=null}}_$AK(e,t){var o,s;let r=this.constructor,n=r._$Eh.get(e);if(n!==void 0&&this._$Em!==n){let l=r.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:eo;this._$Em=n;let h=d.fromAttribute(t,l.type);this[n]=h??((s=this._$Ej)==null?void 0:s.get(n))??h,this._$Em=null}}requestUpdate(e,t,r,n=!1,o){var s;if(e!==void 0){let l=this.constructor;if(n===!1&&(o=this[e]),r??(r=l.getPropertyOptions(e)),!((r.hasChanged??Os)(o,t)||r.useDefault&&r.reflect&&o===((s=this._$Ej)==null?void 0:s.get(e))&&!this.hasAttribute(l._$Eu(e,r))))return;this.C(e,t,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:r,reflect:n,wrapped:o},s){r&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,s??t??this[e]),o!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(t=void 0),this._$AL.set(e,t)),n===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[o,s]of this._$Ep)this[o]=s;this._$Ep=void 0}let n=this.constructor.elementProperties;if(n.size>0)for(let[o,s]of n){let{wrapped:l}=s,d=this[o];l!==!0||this._$AL.has(o)||d===void 0||this.C(o,void 0,s,d)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(r=this._$EO)==null||r.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(t)):this._$EM()}catch(n){throw e=!1,this._$EM(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(r=>{var n;return(n=r.hostUpdated)==null?void 0:n.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};Ht.elementStyles=[],Ht.shadowRootOptions={mode:"open"},Ht[Jn("elementProperties")]=new Map,Ht[Jn("finalized")]=new Map,ad==null||ad({ReactiveElement:Ht}),(Jt.reactiveElementVersions??(Jt.reactiveElementVersions=[])).push("2.1.2");var io=globalThis,ih=i=>i,Ns=io.trustedTypes,rh=Ns?Ns.createPolicy("lit-html",{createHTML:i=>i}):void 0,dh="$lit$",ei=`lit$${Math.random().toFixed(9).slice(2)}$`,ch="?"+ei,Vv=`<${ch}>`,Hi=document,ro=()=>Hi.createComment(""),no=i=>i===null||typeof i!="object"&&typeof i!="function",vd=Array.isArray,Bv=i=>vd(i)||typeof(i==null?void 0:i[Symbol.iterator])=="function",ld=`[
6
6
  \f\r]`,to=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nh=/-->/g,oh=/>/g,Ni=RegExp(`>|${ld}(?:([^\\s"'>=/]+)(${ld}*=${ld}*(?:[^
7
- \f\r"'\`<>=]|("|')|))|$)`,"g"),sh=/'/g,ah=/"/g,uh=/^(?:script|style|textarea|title)$/i,fd=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),Ye=fd(1),$b=fd(2),Vb=fd(3),$i=Symbol.for("lit-noChange"),ye=Symbol.for("lit-nothing"),lh=new WeakMap,Ui=Hi.createTreeWalker(Hi,129);function hh(i,e){if(!vd(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return rh!==void 0?rh.createHTML(e):e}var Wv=(i,e)=>{let t=i.length-1,r=[],n,o=e===2?"<svg>":e===3?"<math>":"",s=to;for(let l=0;l<t;l++){let d=i[l],h,p,f=-1,E=0;for(;E<d.length&&(s.lastIndex=E,p=s.exec(d),p!==null);)E=s.lastIndex,s===to?p[1]==="!--"?s=nh:p[1]!==void 0?s=oh:p[2]!==void 0?(uh.test(p[2])&&(n=RegExp("</"+p[2],"g")),s=Ni):p[3]!==void 0&&(s=Ni):s===Ni?p[0]===">"?(s=n??to,f=-1):p[1]===void 0?f=-2:(f=s.lastIndex-p[2].length,h=p[1],s=p[3]===void 0?Ni:p[3]==='"'?ah:sh):s===ah||s===sh?s=Ni:s===nh||s===oh?s=to:(s=Ni,n=void 0);let m=s===Ni&&i[l+1].startsWith("/>")?" ":"";o+=s===to?d+Vv:f>=0?(r.push(h),d.slice(0,f)+dh+d.slice(f)+ei+m):d+ei+(f===-2?l:m)}return[hh(i,o+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},oo=class i{constructor({strings:e,_$litType$:t},r){let n;this.parts=[];let o=0,s=0,l=e.length-1,d=this.parts,[h,p]=Wv(e,t);if(this.el=i.createElement(h,r),Ui.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(n=Ui.nextNode())!==null&&d.length<l;){if(n.nodeType===1){if(n.hasAttributes())for(let f of n.getAttributeNames())if(f.endsWith(dh)){let E=p[s++],m=n.getAttribute(f).split(ei),_=/([.?@])?(.*)/.exec(E);d.push({type:1,index:o,name:_[2],strings:m,ctor:_[1]==="."?ud:_[1]==="?"?hd:_[1]==="@"?pd:Mr}),n.removeAttribute(f)}else f.startsWith(ei)&&(d.push({type:6,index:o}),n.removeAttribute(f));if(uh.test(n.tagName)){let f=n.textContent.split(ei),E=f.length-1;if(E>0){n.textContent=Ns?Ns.emptyScript:"";for(let m=0;m<E;m++)n.append(f[m],ro()),Ui.nextNode(),d.push({type:2,index:++o});n.append(f[E],ro())}}}else if(n.nodeType===8)if(n.data===ch)d.push({type:2,index:o});else{let f=-1;for(;(f=n.data.indexOf(ei,f+1))!==-1;)d.push({type:7,index:o}),f+=ei.length-1}o++}}static createElement(e,t){let r=Hi.createElement("template");return r.innerHTML=e,r}};function Rr(i,e,t=i,r){var s,l;if(e===$i)return e;let n=r!==void 0?(s=t._$Co)==null?void 0:s[r]:t._$Cl,o=no(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((l=n==null?void 0:n._$AO)==null||l.call(n,!1),o===void 0?n=void 0:(n=new o(i),n._$AT(i,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=n:t._$Cl=n),n!==void 0&&(e=Rr(i,n._$AS(i,e.values),n,r)),e}var cd=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:r}=this._$AD,n=((e==null?void 0:e.creationScope)??Hi).importNode(t,!0);Ui.currentNode=n;let o=Ui.nextNode(),s=0,l=0,d=r[0];for(;d!==void 0;){if(s===d.index){let h;d.type===2?h=new so(o,o.nextSibling,this,e):d.type===1?h=new d.ctor(o,d.name,d.strings,this,e):d.type===6&&(h=new md(o,this,e)),this._$AV.push(h),d=r[++l]}s!==(d==null?void 0:d.index)&&(o=Ui.nextNode(),s++)}return Ui.currentNode=Hi,n}p(e){let t=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}},so=class i{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,n){this.type=2,this._$AH=ye,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Rr(this,e,t),no(e)?e===ye||e==null||e===""?(this._$AH!==ye&&this._$AR(),this._$AH=ye):e!==this._$AH&&e!==$i&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Bv(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ye&&no(this._$AH)?this._$AA.nextSibling.data=e:this.T(Hi.createTextNode(e)),this._$AH=e}$(e){var o;let{values:t,_$litType$:r}=e,n=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=oo.createElement(hh(r.h,r.h[0]),this.options)),r);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(t);else{let s=new cd(n,this),l=s.u(this.options);s.p(t),this.T(l),this._$AH=s}}_$AC(e){let t=lh.get(e.strings);return t===void 0&&lh.set(e.strings,t=new oo(e)),t}k(e){vd(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,r,n=0;for(let o of e)n===t.length?t.push(r=new i(this.O(ro()),this.O(ro()),this,this.options)):r=t[n],r._$AI(o),n++;n<t.length&&(this._$AR(r&&r._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){let n=ih(e).nextSibling;ih(e).remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Mr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,n,o){this.type=1,this._$AH=ye,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ye}_$AI(e,t=this,r,n){let o=this.strings,s=!1;if(o===void 0)e=Rr(this,e,t,0),s=!no(e)||e!==this._$AH&&e!==$i,s&&(this._$AH=e);else{let l=e,d,h;for(e=o[0],d=0;d<o.length-1;d++)h=Rr(this,l[r+d],t,d),h===$i&&(h=this._$AH[d]),s||(s=!no(h)||h!==this._$AH[d]),h===ye?e=ye:e!==ye&&(e+=(h??"")+o[d+1]),this._$AH[d]=h}s&&!n&&this.j(e)}j(e){e===ye?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},ud=class extends Mr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ye?void 0:e}},hd=class extends Mr{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ye)}},pd=class extends Mr{constructor(e,t,r,n,o){super(e,t,r,n,o),this.type=5}_$AI(e,t=this){if((e=Rr(this,e,t,0)??ye)===$i)return;let r=this._$AH,n=e===ye&&r!==ye||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,o=e!==ye&&(r===ye||n);n&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},md=class{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Rr(this,e)}};var dd=io.litHtmlPolyfillSupport;dd==null||dd(oo,so),(io.litHtmlVersions??(io.litHtmlVersions=[])).push("3.3.2");var ph=(i,e,t)=>{let r=(t==null?void 0:t.renderBefore)??e,n=r._$litPart$;if(n===void 0){let o=(t==null?void 0:t.renderBefore)??null;r._$litPart$=n=new so(e.insertBefore(ro(),o),o,void 0,t??{})}return n._$AI(i),n};var Vi=globalThis,De=class extends Ht{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ph(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return $i}},mh;De._$litElement$=!0,De.finalized=!0,(mh=Vi.litElementHydrateSupport)==null||mh.call(Vi,{LitElement:De});var Ed=Vi.litElementPolyfillSupport;Ed==null||Ed({LitElement:De});(Vi.litElementVersions??(Vi.litElementVersions=[])).push("4.2.2");var ti=i=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(i,e)}):customElements.define(i,e)};var Fv={attribute:!0,type:String,converter:eo,reflect:!1,hasChanged:Os},qv=(i=Fv,e,t)=>{let{kind:r,metadata:n}=t,o=globalThis.litPropertyMetadata.get(n);if(o===void 0&&globalThis.litPropertyMetadata.set(n,o=new Map),r==="setter"&&((i=Object.create(i)).wrapped=!0),o.set(t.name,i),r==="accessor"){let{name:s}=t;return{set(l){let d=e.get.call(this);e.set.call(this,l),this.requestUpdate(s,d,i,!0,l)},init(l){return l!==void 0&&this.C(s,void 0,i,l),l}}}if(r==="setter"){let{name:s}=t;return function(l){let d=this[s];e.call(this,l),this.requestUpdate(s,d,i,!0,l)}}throw Error("Unsupported decorator location: "+r)};function Q(i){return(e,t)=>typeof t=="object"?qv(i,e,t):((r,n,o)=>{let s=n.hasOwnProperty(o);return n.constructor.createProperty(o,r),s?Object.getOwnPropertyDescriptor(n,o):void 0})(i,e,t)}function ii(i){return Q({...i,state:!0,attribute:!1})}var vh=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Hs(i){return i===1005||i===1007||i===1009?"autoplay":i>=2001&&i<=2004?"offline":i>=3e3&&i<=3999?"media":i>=4900&&i<=4999?"security":i>=4e3&&i<=4899?"network":i>=5e3&&i<=5999?"setup":i>=1e3&&i<=1999?"media":"unknown"}function $s(i){return i===4e3||i===4001?"network":"unknown"}function ao(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function lo(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"streamId"in i}function co(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"clipId"in i}function Vs(i){return lo(i)||co(i)}var rt=class extends Error{constructor(t,r,n){super(t);this.code=r;this.status=n;this.name="BPLiveError"}},xr=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new rt("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,r={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let s=await this._network.intercept({url:t,method:"GET",type:"api",headers:r});if(s.response)return s.response.body;t=s.url,r=s.headers}let n=new AbortController,o=setTimeout(()=>n.abort(),3e4);try{let s=await fetch(t,{method:"GET",headers:r,signal:n.signal});if(!s.ok)throw new rt(`HTTP ${s.status}: ${s.statusText}`,"HTTP_ERROR",s.status);let l=await s.json();return this._network&&(l=(await this._network.interceptResponse({url:t,status:s.status,headers:Object.fromEntries(s.headers),body:l})).body),l}catch(s){throw s instanceof Error&&s.name==="AbortError"?new rt("Request timeout after 30s","TIMEOUT"):s}finally{clearTimeout(o)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...r}=e;return{type:"nano",source:r}}throw new rt(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let r=e.filter(l=>l.type==="clip");if(r.length===0)return null;let n=r.find(l=>l.orientation===t);if(n)return n;let o=t==="landscape"?"portrait":"landscape",s=r.find(l=>l.orientation===o);return s||r[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,lo(e))return this.resolveStreamSource(e);if(co(e))return this.resolveClipSource(e);throw new rt("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var l,d,h,p,f,E,m,_,g;let r=(await this.getStream(e.streamId)).data;this._stream=r;let n=this.extractStreamPoster(r);if(!!r.ended_at&&((d=(l=r.media)==null?void 0:l.vod)==null?void 0:d.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(h=I.dimension)==null?void 0:h.width,videoHeight:(p=I.dimension)==null?void 0:p.height}}let s=r.player_source??((f=r.active_stream)==null?void 0:f.player_source);if(s)return{source:this.mapPlayerSourceToResolvedSource(s),contentType:"stream",poster:n};if(((m=(E=r.media)==null?void 0:E.vod)==null?void 0:m.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(_=I.dimension)==null?void 0:_.width,videoHeight:(g=I.dimension)==null?void 0:g.height}}throw new rt("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let r=(await this.getClip(e.clipId)).data;this._clip=r;let n=this.selectClipMedia(r.media,e.preferredOrientation);if(!n)throw new rt("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(n),contentType:"clip",poster:n.thumbnail??void 0,videoWidth:n.width,videoHeight:n.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function uo(i){return i!=null&&typeof i.then=="function"}function fh(i){return new Promise((e,t)=>{let r=!1,n=o=>{r||(r=!0,o?t(o):e())};try{let o=i(n);uo(o)&&(r=!0,o.then(()=>e(),t))}catch(o){n(o)}})}var gd=class{constructor(e,t,r){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((n,o)=>{this._resolve=n,this._reject=o}),this._state=e,this._interceptor=t,this._canModify=r,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());uo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");uo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(fh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},bd=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((r,n)=>{this._resolve=r,this._reject=n}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());uo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");uo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(fh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},ho=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},r=!1,n=null;for(let o of this._requestInterceptors.slice()){let s=new gd(t,o,!r);try{await s.promise}catch{continue}s.responseResult&&!r&&(r=!0,n=s.responseResult),s.redirectResult&&!r&&(t=s.redirectResult)}return{url:t.url,headers:t.headers,response:n}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let r of this._responseInterceptors.slice()){let n=new bd(t,r);try{await n.promise}catch{continue}n.responseResult&&(t={...t,status:n.responseResult.status!==void 0?n.responseResult.status:t.status,headers:n.responseResult.headers!==void 0?n.responseResult.headers:t.headers,body:"body"in n.responseResult?n.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Kv(i){if(typeof i=="string")return"video";switch(i.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function Eh(i){return typeof i=="object"&&i!==null&&i.type==="bplive"}var Gv=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],_d=class{constructor(){this._mediaElement=null;this._container=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new ho;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=ao()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r)this._listeners.has(n)||this._listeners.set(n,new Set),this._listeners.get(n).add(t)}removeEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r){let o=this._listeners.get(n);o&&(o.delete(t),o.size===0&&this._listeners.delete(n))}}dispatch(e,t){let r=this._listeners.get(e);if(r)for(let n of r)try{n(t)}catch(o){console.error(`[PlayerCore] Error in event listener for "${e}":`,o)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,r){if(this._destroyed)return;let n=++this._loadGeneration,o=t??this._container,s=r??this._config;if(!o){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=o,s&&(this._config=s);let l=Eh(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...l&&{contentType:l}}),this.dispatch("sourcechange",{source:e});try{let d=e,h=this._state.contentType,p,f,E;if(Eh(e)){if(s!=null&&s.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new xr(s.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let L=await this._bpLive.resolveSource(e);if(n!==this._loadGeneration)return;d=L.source,h=L.contentType,p=L.poster,f=L.videoWidth,E=L.videoHeight}let m=Kv(d),I=m==="nano"||m==="livekit"||h==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=m,this.updateState({providerType:m,contentType:h,streamType:I,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(m,d,s),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),o.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:p,videoWidth:f,videoHeight:E}}catch(d){if(n!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",d);let h={code:-1,message:d instanceof Error?d.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:h,connectionState:"failed"}),this.dispatch("error",h)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,r){switch(e){case"nano":{let n=document.createElement("nano-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.libraryLocation=(r==null?void 0:r.libraryLocation)??"/vendor/bp-player",o.source?n.sourceConfig=o.source:o.streamid&&(n.streamid=o.streamid),r!=null&&r.nano&&(n.config=r.nano),n}case"livekit":{let n=document.createElement("livekit-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.url=o.url,n.token=o.token,r!=null&&r.livekit&&(n.config=r.livekit),n}case"video":default:{let n=document.createElement("hls-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=typeof t=="string"?t:t.url;n.src=o;let s={...r==null?void 0:r.video},l=this._network,d=s.xhrSetup;return s.xhrSetup=async(h,p)=>{let f=p.includes(".m3u8")?"manifest":p.includes(".ts")||p.includes(".m4s")||p.includes(".fmp4")?"segment":"other",E=await l.intercept({url:p,method:"GET",type:f,headers:{}});E.url!==p&&h.open("GET",E.url,!0);for(let[m,_]of Object.entries(E.headers))h.setRequestHeader(m,_);d&&await d(h,E.url)},n.config=s,n}}}attachMediaElementListeners(e){for(let t of Gv){let r=n=>this.handleMediaEvent(t,e,n);e.addEventListener(t,r),this._eventCleanup.push(()=>e.removeEventListener(t,r))}}attachActiveVideoElementForwarding(e){let t=r=>{let n=r.detail;this.dispatch("activevideoelementchange",{video:(n==null?void 0:n.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,r){var n,o,s,l;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:d}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:d}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let d=-1,h="Unknown error",p="none";r instanceof ErrorEvent&&r.error?(d=r.error.code??-1,h=r.error.message??r.message??"Unknown error",p="ErrorEvent"):t.error&&(d=t.error.code??-1,h=t.error.message??"Unknown error",p="element.error");let f=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(n=r.target)==null?void 0:n.tagName,source:p,code:d,message:h,eventIsErrorEvent:r instanceof ErrorEvent,eventErrorCode:r instanceof ErrorEvent?(o=r.error)==null?void 0:o.code:void 0,elementErrorCode:(s=t.error)==null?void 0:s.code,nativeElTag:f==null?void 0:f.tagName,nativeElErrorCode:(l=f==null?void 0:f.error)==null?void 0:l.code,nativeElSrc:f==null?void 0:f.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let E="media",m=!0;this._state.providerType==="nano"&&d>0?(E=Hs(d),m=E!=="offline"&&E!=="autoplay"):this._state.providerType==="livekit"&&d>0&&(E=$s(d),m=!0);let _={code:d,message:h,fatal:m,category:E};this.updateState({error:_}),this.dispatch("error",_);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...ao(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"});let t=this._getFullscreenTarget();t&&(e&&!document.fullscreenElement?await t.requestFullscreen():!e&&document.fullscreenElement&&await document.exitFullscreen())}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){this._destroyed||(this._destroyed=!0,this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function Bs(){return new _d}var Bi="bpPlayerObservedProperties";function Ws(i){return Bi in i&&Array.isArray(i[Bi])}function gh(i,e){class t extends i{get[Bi](){return e}}return t}function zv(i){if(i.shadowRoot)return Array.from(i.shadowRoot.children);if(i.localName==="slot"){let t=i.assignedNodes();if(t.length>0)return t.filter(r=>r.nodeType===Node.ELEMENT_NODE)}return Array.from(i.children)}async function Wi(i,e,t){if(e!=null&&e.contains(i))return;i.nodeName.includes("-")&&!Ws(i)&&(await Promise.resolve(),await customElements.whenDefined(i.nodeName.toLowerCase()),customElements.upgrade(i)),Ws(i)&&t(i);let r=zv(i);r.length>0&&await Promise.all(r.map(n=>Wi(n,e,t)))}function po(i,e,t){let r=i[Bi];r.includes("player")&&(i.player=e),r.includes("paused")&&(i.paused=t.paused),r.includes("playing")&&(i.playing=t.playing),r.includes("ended")&&(i.ended=t.ended),r.includes("seeking")&&(i.seeking=t.seeking),r.includes("currentTime")&&(i.currentTime=t.currentTime),r.includes("duration")&&(i.duration=t.duration),r.includes("volume")&&(i.volume=t.volume),r.includes("muted")&&(i.muted=t.muted),r.includes("playbackRate")&&(i.playbackRate=t.playbackRate),r.includes("readyState")&&(i.readyState=t.readyState),r.includes("videoWidth")&&(i.videoWidth=t.videoWidth),r.includes("videoHeight")&&(i.videoHeight=t.videoHeight),r.includes("qualities")&&(i.qualities=t.qualities),r.includes("currentQuality")&&(i.currentQuality=t.currentQuality),r.includes("targetQuality")&&(i.targetQuality=t.targetQuality),r.includes("fullscreen")&&(i.fullscreen=t.fullscreen),r.includes("presentationMode")&&(i.presentationMode=t.presentationMode),r.includes("connectionState")&&(i.connectionState=t.connectionState),r.includes("streamType")&&(i.streamType=t.streamType),r.includes("error")&&(i.error=t.error)}function mo(i){i[Bi].includes("player")&&(i.player=void 0)}var bh=`/**
7
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),sh=/'/g,ah=/"/g,uh=/^(?:script|style|textarea|title)$/i,fd=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),Ye=fd(1),$b=fd(2),Vb=fd(3),$i=Symbol.for("lit-noChange"),ye=Symbol.for("lit-nothing"),lh=new WeakMap,Ui=Hi.createTreeWalker(Hi,129);function hh(i,e){if(!vd(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return rh!==void 0?rh.createHTML(e):e}var Wv=(i,e)=>{let t=i.length-1,r=[],n,o=e===2?"<svg>":e===3?"<math>":"",s=to;for(let l=0;l<t;l++){let d=i[l],h,p,f=-1,E=0;for(;E<d.length&&(s.lastIndex=E,p=s.exec(d),p!==null);)E=s.lastIndex,s===to?p[1]==="!--"?s=nh:p[1]!==void 0?s=oh:p[2]!==void 0?(uh.test(p[2])&&(n=RegExp("</"+p[2],"g")),s=Ni):p[3]!==void 0&&(s=Ni):s===Ni?p[0]===">"?(s=n??to,f=-1):p[1]===void 0?f=-2:(f=s.lastIndex-p[2].length,h=p[1],s=p[3]===void 0?Ni:p[3]==='"'?ah:sh):s===ah||s===sh?s=Ni:s===nh||s===oh?s=to:(s=Ni,n=void 0);let m=s===Ni&&i[l+1].startsWith("/>")?" ":"";o+=s===to?d+Vv:f>=0?(r.push(h),d.slice(0,f)+dh+d.slice(f)+ei+m):d+ei+(f===-2?l:m)}return[hh(i,o+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},oo=class i{constructor({strings:e,_$litType$:t},r){let n;this.parts=[];let o=0,s=0,l=e.length-1,d=this.parts,[h,p]=Wv(e,t);if(this.el=i.createElement(h,r),Ui.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(n=Ui.nextNode())!==null&&d.length<l;){if(n.nodeType===1){if(n.hasAttributes())for(let f of n.getAttributeNames())if(f.endsWith(dh)){let E=p[s++],m=n.getAttribute(f).split(ei),_=/([.?@])?(.*)/.exec(E);d.push({type:1,index:o,name:_[2],strings:m,ctor:_[1]==="."?ud:_[1]==="?"?hd:_[1]==="@"?pd:Mr}),n.removeAttribute(f)}else f.startsWith(ei)&&(d.push({type:6,index:o}),n.removeAttribute(f));if(uh.test(n.tagName)){let f=n.textContent.split(ei),E=f.length-1;if(E>0){n.textContent=Ns?Ns.emptyScript:"";for(let m=0;m<E;m++)n.append(f[m],ro()),Ui.nextNode(),d.push({type:2,index:++o});n.append(f[E],ro())}}}else if(n.nodeType===8)if(n.data===ch)d.push({type:2,index:o});else{let f=-1;for(;(f=n.data.indexOf(ei,f+1))!==-1;)d.push({type:7,index:o}),f+=ei.length-1}o++}}static createElement(e,t){let r=Hi.createElement("template");return r.innerHTML=e,r}};function Rr(i,e,t=i,r){var s,l;if(e===$i)return e;let n=r!==void 0?(s=t._$Co)==null?void 0:s[r]:t._$Cl,o=no(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((l=n==null?void 0:n._$AO)==null||l.call(n,!1),o===void 0?n=void 0:(n=new o(i),n._$AT(i,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=n:t._$Cl=n),n!==void 0&&(e=Rr(i,n._$AS(i,e.values),n,r)),e}var cd=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:r}=this._$AD,n=((e==null?void 0:e.creationScope)??Hi).importNode(t,!0);Ui.currentNode=n;let o=Ui.nextNode(),s=0,l=0,d=r[0];for(;d!==void 0;){if(s===d.index){let h;d.type===2?h=new so(o,o.nextSibling,this,e):d.type===1?h=new d.ctor(o,d.name,d.strings,this,e):d.type===6&&(h=new md(o,this,e)),this._$AV.push(h),d=r[++l]}s!==(d==null?void 0:d.index)&&(o=Ui.nextNode(),s++)}return Ui.currentNode=Hi,n}p(e){let t=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}},so=class i{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,n){this.type=2,this._$AH=ye,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Rr(this,e,t),no(e)?e===ye||e==null||e===""?(this._$AH!==ye&&this._$AR(),this._$AH=ye):e!==this._$AH&&e!==$i&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Bv(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==ye&&no(this._$AH)?this._$AA.nextSibling.data=e:this.T(Hi.createTextNode(e)),this._$AH=e}$(e){var o;let{values:t,_$litType$:r}=e,n=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=oo.createElement(hh(r.h,r.h[0]),this.options)),r);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(t);else{let s=new cd(n,this),l=s.u(this.options);s.p(t),this.T(l),this._$AH=s}}_$AC(e){let t=lh.get(e.strings);return t===void 0&&lh.set(e.strings,t=new oo(e)),t}k(e){vd(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,r,n=0;for(let o of e)n===t.length?t.push(r=new i(this.O(ro()),this.O(ro()),this,this.options)):r=t[n],r._$AI(o),n++;n<t.length&&(this._$AR(r&&r._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){let n=ih(e).nextSibling;ih(e).remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Mr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,n,o){this.type=1,this._$AH=ye,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=ye}_$AI(e,t=this,r,n){let o=this.strings,s=!1;if(o===void 0)e=Rr(this,e,t,0),s=!no(e)||e!==this._$AH&&e!==$i,s&&(this._$AH=e);else{let l=e,d,h;for(e=o[0],d=0;d<o.length-1;d++)h=Rr(this,l[r+d],t,d),h===$i&&(h=this._$AH[d]),s||(s=!no(h)||h!==this._$AH[d]),h===ye?e=ye:e!==ye&&(e+=(h??"")+o[d+1]),this._$AH[d]=h}s&&!n&&this.j(e)}j(e){e===ye?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},ud=class extends Mr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===ye?void 0:e}},hd=class extends Mr{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==ye)}},pd=class extends Mr{constructor(e,t,r,n,o){super(e,t,r,n,o),this.type=5}_$AI(e,t=this){if((e=Rr(this,e,t,0)??ye)===$i)return;let r=this._$AH,n=e===ye&&r!==ye||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,o=e!==ye&&(r===ye||n);n&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},md=class{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Rr(this,e)}};var dd=io.litHtmlPolyfillSupport;dd==null||dd(oo,so),(io.litHtmlVersions??(io.litHtmlVersions=[])).push("3.3.2");var ph=(i,e,t)=>{let r=(t==null?void 0:t.renderBefore)??e,n=r._$litPart$;if(n===void 0){let o=(t==null?void 0:t.renderBefore)??null;r._$litPart$=n=new so(e.insertBefore(ro(),o),o,void 0,t??{})}return n._$AI(i),n};var Vi=globalThis,De=class extends Ht{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ph(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return $i}},mh;De._$litElement$=!0,De.finalized=!0,(mh=Vi.litElementHydrateSupport)==null||mh.call(Vi,{LitElement:De});var Ed=Vi.litElementPolyfillSupport;Ed==null||Ed({LitElement:De});(Vi.litElementVersions??(Vi.litElementVersions=[])).push("4.2.2");var ti=i=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(i,e)}):customElements.define(i,e)};var Fv={attribute:!0,type:String,converter:eo,reflect:!1,hasChanged:Os},qv=(i=Fv,e,t)=>{let{kind:r,metadata:n}=t,o=globalThis.litPropertyMetadata.get(n);if(o===void 0&&globalThis.litPropertyMetadata.set(n,o=new Map),r==="setter"&&((i=Object.create(i)).wrapped=!0),o.set(t.name,i),r==="accessor"){let{name:s}=t;return{set(l){let d=e.get.call(this);e.set.call(this,l),this.requestUpdate(s,d,i,!0,l)},init(l){return l!==void 0&&this.C(s,void 0,i,l),l}}}if(r==="setter"){let{name:s}=t;return function(l){let d=this[s];e.call(this,l),this.requestUpdate(s,d,i,!0,l)}}throw Error("Unsupported decorator location: "+r)};function Q(i){return(e,t)=>typeof t=="object"?qv(i,e,t):((r,n,o)=>{let s=n.hasOwnProperty(o);return n.constructor.createProperty(o,r),s?Object.getOwnPropertyDescriptor(n,o):void 0})(i,e,t)}function ii(i){return Q({...i,state:!0,attribute:!1})}var vh=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Hs(i){return i===1005||i===1007||i===1009?"autoplay":i>=2001&&i<=2004?"offline":i>=3e3&&i<=3999?"media":i>=4900&&i<=4999?"security":i>=4e3&&i<=4899?"network":i>=5e3&&i<=5999?"setup":i>=1e3&&i<=1999?"media":"unknown"}function $s(i){return i===4e3||i===4001?"network":"unknown"}function ao(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function lo(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"streamId"in i}function co(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"clipId"in i}function Vs(i){return lo(i)||co(i)}var rt=class extends Error{constructor(t,r,n){super(t);this.code=r;this.status=n;this.name="BPLiveError"}},xr=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new rt("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,r={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let s=await this._network.intercept({url:t,method:"GET",type:"api",headers:r});if(s.response)return s.response.body;t=s.url,r=s.headers}let n=new AbortController,o=setTimeout(()=>n.abort(),3e4);try{let s=await fetch(t,{method:"GET",headers:r,signal:n.signal});if(!s.ok)throw new rt(`HTTP ${s.status}: ${s.statusText}`,"HTTP_ERROR",s.status);let l=await s.json();return this._network&&(l=(await this._network.interceptResponse({url:t,status:s.status,headers:Object.fromEntries(s.headers),body:l})).body),l}catch(s){throw s instanceof Error&&s.name==="AbortError"?new rt("Request timeout after 30s","TIMEOUT"):s}finally{clearTimeout(o)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...r}=e;return{type:"nano",source:r}}throw new rt(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let r=e.filter(l=>l.type==="clip");if(r.length===0)return null;let n=r.find(l=>l.orientation===t);if(n)return n;let o=t==="landscape"?"portrait":"landscape",s=r.find(l=>l.orientation===o);return s||r[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,lo(e))return this.resolveStreamSource(e);if(co(e))return this.resolveClipSource(e);throw new rt("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var l,d,h,p,f,E,m,_,g;let r=(await this.getStream(e.streamId)).data;this._stream=r;let n=this.extractStreamPoster(r);if(!!r.ended_at&&((d=(l=r.media)==null?void 0:l.vod)==null?void 0:d.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(h=I.dimension)==null?void 0:h.width,videoHeight:(p=I.dimension)==null?void 0:p.height}}let s=r.player_source??((f=r.active_stream)==null?void 0:f.player_source);if(s)return{source:this.mapPlayerSourceToResolvedSource(s),contentType:"stream",poster:n};if(((m=(E=r.media)==null?void 0:E.vod)==null?void 0:m.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(_=I.dimension)==null?void 0:_.width,videoHeight:(g=I.dimension)==null?void 0:g.height}}throw new rt("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let r=(await this.getClip(e.clipId)).data;this._clip=r;let n=this.selectClipMedia(r.media,e.preferredOrientation);if(!n)throw new rt("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(n),contentType:"clip",poster:n.thumbnail??void 0,videoWidth:n.width,videoHeight:n.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function uo(i){return i!=null&&typeof i.then=="function"}function fh(i){return new Promise((e,t)=>{let r=!1,n=o=>{r||(r=!0,o?t(o):e())};try{let o=i(n);uo(o)&&(r=!0,o.then(()=>e(),t))}catch(o){n(o)}})}var gd=class{constructor(e,t,r){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((n,o)=>{this._resolve=n,this._reject=o}),this._state=e,this._interceptor=t,this._canModify=r,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());uo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");uo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(fh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},bd=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((r,n)=>{this._resolve=r,this._reject=n}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());uo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");uo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(fh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},ho=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},r=!1,n=null;for(let o of this._requestInterceptors.slice()){let s=new gd(t,o,!r);try{await s.promise}catch{continue}s.responseResult&&!r&&(r=!0,n=s.responseResult),s.redirectResult&&!r&&(t=s.redirectResult)}return{url:t.url,headers:t.headers,response:n}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let r of this._responseInterceptors.slice()){let n=new bd(t,r);try{await n.promise}catch{continue}n.responseResult&&(t={...t,status:n.responseResult.status!==void 0?n.responseResult.status:t.status,headers:n.responseResult.headers!==void 0?n.responseResult.headers:t.headers,body:"body"in n.responseResult?n.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Kv(i){if(typeof i=="string")return"video";switch(i.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function Eh(i){return typeof i=="object"&&i!==null&&i.type==="bplive"}var Gv=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],_d=class{constructor(){this._mediaElement=null;this._container=null;this._webkitFullscreen=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new ho;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=ao()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r)this._listeners.has(n)||this._listeners.set(n,new Set),this._listeners.get(n).add(t)}removeEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r){let o=this._listeners.get(n);o&&(o.delete(t),o.size===0&&this._listeners.delete(n))}}dispatch(e,t){let r=this._listeners.get(e);if(r)for(let n of r)try{n(t)}catch(o){console.error(`[PlayerCore] Error in event listener for "${e}":`,o)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,r){if(this._destroyed)return;let n=++this._loadGeneration,o=t??this._container,s=r??this._config;if(!o){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=o,s&&(this._config=s);let l=Eh(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...l&&{contentType:l}}),this.dispatch("sourcechange",{source:e});try{let d=e,h=this._state.contentType,p,f,E;if(Eh(e)){if(s!=null&&s.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new xr(s.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let L=await this._bpLive.resolveSource(e);if(n!==this._loadGeneration)return;d=L.source,h=L.contentType,p=L.poster,f=L.videoWidth,E=L.videoHeight}let m=Kv(d),I=m==="nano"||m==="livekit"||h==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=m,this.updateState({providerType:m,contentType:h,streamType:I,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(m,d,s),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),o.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:p,videoWidth:f,videoHeight:E}}catch(d){if(n!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",d);let h={code:-1,message:d instanceof Error?d.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:h,connectionState:"failed"}),this.dispatch("error",h)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,r){switch(e){case"nano":{let n=document.createElement("nano-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.libraryLocation=(r==null?void 0:r.libraryLocation)??"/vendor/bp-player",o.source?n.sourceConfig=o.source:o.streamid&&(n.streamid=o.streamid),r!=null&&r.nano&&(n.config=r.nano),n}case"livekit":{let n=document.createElement("livekit-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.url=o.url,n.token=o.token,r!=null&&r.livekit&&(n.config=r.livekit),n}case"video":default:{let n=document.createElement("hls-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=typeof t=="string"?t:t.url;n.src=o;let s={...r==null?void 0:r.video},l=this._network,d=s.xhrSetup;return s.xhrSetup=async(h,p)=>{let f=p.includes(".m3u8")?"manifest":p.includes(".ts")||p.includes(".m4s")||p.includes(".fmp4")?"segment":"other",E=await l.intercept({url:p,method:"GET",type:f,headers:{}});E.url!==p&&h.open("GET",E.url,!0);for(let[m,_]of Object.entries(E.headers))h.setRequestHeader(m,_);d&&await d(h,E.url)},n.config=s,n}}}attachMediaElementListeners(e){for(let t of Gv){let r=n=>this.handleMediaEvent(t,e,n);e.addEventListener(t,r),this._eventCleanup.push(()=>e.removeEventListener(t,r))}}attachActiveVideoElementForwarding(e){let t=r=>{let n=r.detail;this.dispatch("activevideoelementchange",{video:(n==null?void 0:n.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,r){var n,o,s,l;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:d}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:d}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let d=-1,h="Unknown error",p="none";r instanceof ErrorEvent&&r.error?(d=r.error.code??-1,h=r.error.message??r.message??"Unknown error",p="ErrorEvent"):t.error&&(d=t.error.code??-1,h=t.error.message??"Unknown error",p="element.error");let f=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(n=r.target)==null?void 0:n.tagName,source:p,code:d,message:h,eventIsErrorEvent:r instanceof ErrorEvent,eventErrorCode:r instanceof ErrorEvent?(o=r.error)==null?void 0:o.code:void 0,elementErrorCode:(s=t.error)==null?void 0:s.code,nativeElTag:f==null?void 0:f.tagName,nativeElErrorCode:(l=f==null?void 0:f.error)==null?void 0:l.code,nativeElSrc:f==null?void 0:f.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let E="media",m=!0;this._state.providerType==="nano"&&d>0?(E=Hs(d),m=E!=="offline"&&E!=="autoplay"):this._state.providerType==="livekit"&&d>0&&(E=$s(d),m=!0);let _={code:d,message:h,fatal:m,category:E};this.updateState({error:_}),this.dispatch("error",_);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...ao(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){var t;if(this._applyFullscreenState(e),e){let r=this._getFullscreenTarget();if(!r){this._applyFullscreenState(!1);return}if(document.fullscreenElement){document.fullscreenElement!==r&&this._applyFullscreenState(!1);return}if(typeof r.requestFullscreen=="function")try{await r.requestFullscreen()}catch(n){throw this._applyFullscreenState(!1),n}else this._enterWebkitVideoFullscreen()}else if(document.fullscreenElement)await document.exitFullscreen();else{let r=this._webkitFullscreen,n=(r==null?void 0:r.video)??this.activeVideoElement;n!=null&&n.webkitDisplayingFullscreen&&(r==null||r.disarm(),(t=n.webkitExitFullscreen)==null||t.call(n))}}_applyFullscreenState(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"})}_enterWebkitVideoFullscreen(){var n;let e=this.activeVideoElement;if(!(e!=null&&e.webkitEnterFullscreen)){this._applyFullscreenState(!1);return}(n=this._webkitFullscreen)==null||n.disarm();let t=()=>{this._webkitFullscreen=null,this._applyFullscreenState(!1)};e.addEventListener("webkitendfullscreen",t,{once:!0});let r={video:e,disarm:()=>{this._webkitFullscreen=null,e.removeEventListener("webkitendfullscreen",t)}};if(this._webkitFullscreen=r,!e.webkitDisplayingFullscreen)try{e.webkitEnterFullscreen()}catch(o){throw r.disarm(),this._applyFullscreenState(!1),o}}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){var e;this._destroyed||(this._destroyed=!0,(e=this._webkitFullscreen)==null||e.disarm(),this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function Bs(){return new _d}var Bi="bpPlayerObservedProperties";function Ws(i){return Bi in i&&Array.isArray(i[Bi])}function gh(i,e){class t extends i{get[Bi](){return e}}return t}function zv(i){if(i.shadowRoot)return Array.from(i.shadowRoot.children);if(i.localName==="slot"){let t=i.assignedNodes();if(t.length>0)return t.filter(r=>r.nodeType===Node.ELEMENT_NODE)}return Array.from(i.children)}async function Wi(i,e,t){if(e!=null&&e.contains(i))return;i.nodeName.includes("-")&&!Ws(i)&&(await Promise.resolve(),await customElements.whenDefined(i.nodeName.toLowerCase()),customElements.upgrade(i)),Ws(i)&&t(i);let r=zv(i);r.length>0&&await Promise.all(r.map(n=>Wi(n,e,t)))}function po(i,e,t){let r=i[Bi];r.includes("player")&&(i.player=e),r.includes("paused")&&(i.paused=t.paused),r.includes("playing")&&(i.playing=t.playing),r.includes("ended")&&(i.ended=t.ended),r.includes("seeking")&&(i.seeking=t.seeking),r.includes("currentTime")&&(i.currentTime=t.currentTime),r.includes("duration")&&(i.duration=t.duration),r.includes("volume")&&(i.volume=t.volume),r.includes("muted")&&(i.muted=t.muted),r.includes("playbackRate")&&(i.playbackRate=t.playbackRate),r.includes("readyState")&&(i.readyState=t.readyState),r.includes("videoWidth")&&(i.videoWidth=t.videoWidth),r.includes("videoHeight")&&(i.videoHeight=t.videoHeight),r.includes("qualities")&&(i.qualities=t.qualities),r.includes("currentQuality")&&(i.currentQuality=t.currentQuality),r.includes("targetQuality")&&(i.targetQuality=t.targetQuality),r.includes("fullscreen")&&(i.fullscreen=t.fullscreen),r.includes("presentationMode")&&(i.presentationMode=t.presentationMode),r.includes("connectionState")&&(i.connectionState=t.connectionState),r.includes("streamType")&&(i.streamType=t.streamType),r.includes("error")&&(i.error=t.error)}function mo(i){i[Bi].includes("player")&&(i.player=void 0)}var bh=`/**
8
8
  * BP Player CSS Custom Properties
9
9
  *
10
10
  * All styling can be customized by overriding these CSS variables.
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * BP Player (v1.4.9)
2
+ * BP Player (v1.5.0)
3
3
  * Universal video player web component
4
4
  */
5
5
  var Fu=Object.defineProperty;var gv=Object.getOwnPropertyDescriptor;var bv=Object.getPrototypeOf;var _v=Reflect.get;var qu=i=>{throw TypeError(i)};var yv=(i,e,t)=>e in i?Fu(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var V=(i,e,t,r)=>{for(var n=r>1?void 0:r?gv(e,t):e,o=i.length-1,s;o>=0;o--)(s=i[o])&&(n=(r?s(e,t,n):s(n))||n);return r&&n&&Fu(e,t,n),n};var F=(i,e,t)=>yv(i,typeof e!="symbol"?e+"":e,t),jl=(i,e,t)=>e.has(i)||qu("Cannot "+t);var c=(i,e,t)=>(jl(i,e,"read from private field"),t?t.call(i):e.get(i)),k=(i,e,t)=>e.has(i)?qu("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),v=(i,e,t,r)=>(jl(i,e,"write to private field"),r?r.call(i,t):e.set(i,t),t),C=(i,e,t)=>(jl(i,e,"access private method"),t);var Jl=(i,e,t)=>_v(bv(i),t,e);var Ls=globalThis,ws=Ls.ShadowRoot&&(Ls.ShadyCSS===void 0||Ls.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ed=Symbol(),Ku=new WeakMap,Yn=class{constructor(e,t,r){if(this._$cssResult$=!0,r!==ed)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(ws&&e===void 0){let r=t!==void 0&&t.length===1;r&&(e=Ku.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&Ku.set(t,e))}return e}toString(){return this.cssText}},Gu=i=>new Yn(typeof i=="string"?i:i+"",void 0,ed),Qn=(i,...e)=>{let t=i.length===1?i[0]:e.reduce((r,n,o)=>r+(s=>{if(s._$cssResult$===!0)return s.cssText;if(typeof s=="number")return s;throw Error("Value passed to 'css' function must be a 'css' function result: "+s+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+i[o+1],i[0]);return new Yn(t,i,ed)},zu=(i,e)=>{if(ws)i.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let r=document.createElement("style"),n=Ls.litNonce;n!==void 0&&r.setAttribute("nonce",n),r.textContent=t.cssText,i.appendChild(r)}},td=ws?i=>i:i=>i instanceof CSSStyleSheet?(e=>{let t="";for(let r of e.cssRules)t+=r.cssText;return Gu(t)})(i):i;var{is:Tv,defineProperty:Av,getOwnPropertyDescriptor:Sv,getOwnPropertyNames:kv,getOwnPropertySymbols:Lv,getPrototypeOf:wv}=Object,jt=globalThis,Yu=jt.trustedTypes,Iv=Yu?Yu.emptyScript:"",id=jt.reactiveElementPolyfillSupport,Zn=(i,e)=>i,Xn={toAttribute(i,e){switch(e){case Boolean:i=i?Iv:null;break;case Object:case Array:i=i==null?i:JSON.stringify(i)}return i},fromAttribute(i,e){let t=i;switch(e){case Boolean:t=i!==null;break;case Number:t=i===null?null:Number(i);break;case Object:case Array:try{t=JSON.parse(i)}catch{t=null}}return t}},Is=(i,e)=>!Tv(i,e),Qu={attribute:!0,type:String,converter:Xn,reflect:!1,useDefault:!1,hasChanged:Is};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),jt.litPropertyMetadata??(jt.litPropertyMetadata=new WeakMap);var Ut=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Qu){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let r=Symbol(),n=this.getPropertyDescriptor(e,r,t);n!==void 0&&Av(this.prototype,e,n)}}static getPropertyDescriptor(e,t,r){let{get:n,set:o}=Sv(this.prototype,e)??{get(){return this[t]},set(s){this[t]=s}};return{get:n,set(s){let l=n==null?void 0:n.call(this);o==null||o.call(this,s),this.requestUpdate(e,l,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Qu}static _$Ei(){if(this.hasOwnProperty(Zn("elementProperties")))return;let e=wv(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Zn("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Zn("properties"))){let t=this.properties,r=[...kv(t),...Lv(t)];for(let n of r)this.createProperty(n,t[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[r,n]of t)this.elementProperties.set(r,n)}this._$Eh=new Map;for(let[t,r]of this.elementProperties){let n=this._$Eu(t,r);n!==void 0&&this._$Eh.set(n,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let r=new Set(e.flat(1/0).reverse());for(let n of r)t.unshift(td(n))}else e!==void 0&&t.push(td(e));return t}static _$Eu(e,t){let r=t.attribute;return r===!1?void 0:typeof r=="string"?r:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let r of t.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return zu(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var r;return(r=t.hostConnected)==null?void 0:r.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var r;return(r=t.hostDisconnected)==null?void 0:r.call(t)})}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ET(e,t){var o;let r=this.constructor.elementProperties.get(e),n=this.constructor._$Eu(e,r);if(n!==void 0&&r.reflect===!0){let s=(((o=r.converter)==null?void 0:o.toAttribute)!==void 0?r.converter:Xn).toAttribute(t,r.type);this._$Em=e,s==null?this.removeAttribute(n):this.setAttribute(n,s),this._$Em=null}}_$AK(e,t){var o,s;let r=this.constructor,n=r._$Eh.get(e);if(n!==void 0&&this._$Em!==n){let l=r.getPropertyOptions(n),d=typeof l.converter=="function"?{fromAttribute:l.converter}:((o=l.converter)==null?void 0:o.fromAttribute)!==void 0?l.converter:Xn;this._$Em=n;let h=d.fromAttribute(t,l.type);this[n]=h??((s=this._$Ej)==null?void 0:s.get(n))??h,this._$Em=null}}requestUpdate(e,t,r,n=!1,o){var s;if(e!==void 0){let l=this.constructor;if(n===!1&&(o=this[e]),r??(r=l.getPropertyOptions(e)),!((r.hasChanged??Is)(o,t)||r.useDefault&&r.reflect&&o===((s=this._$Ej)==null?void 0:s.get(e))&&!this.hasAttribute(l._$Eu(e,r))))return;this.C(e,t,r)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:r,reflect:n,wrapped:o},s){r&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,s??t??this[e]),o!==!0||s!==void 0)||(this._$AL.has(e)||(this.hasUpdated||r||(t=void 0),this._$AL.set(e,t)),n===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var r;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[o,s]of this._$Ep)this[o]=s;this._$Ep=void 0}let n=this.constructor.elementProperties;if(n.size>0)for(let[o,s]of n){let{wrapped:l}=s,d=this[o];l!==!0||this._$AL.has(o)||d===void 0||this.C(o,void 0,s,d)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(r=this._$EO)==null||r.forEach(n=>{var o;return(o=n.hostUpdate)==null?void 0:o.call(n)}),this.update(t)):this._$EM()}catch(n){throw e=!1,this._$EM(),n}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(r=>{var n;return(n=r.hostUpdated)==null?void 0:n.call(r)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};Ut.elementStyles=[],Ut.shadowRootOptions={mode:"open"},Ut[Zn("elementProperties")]=new Map,Ut[Zn("finalized")]=new Map,id==null||id({ReactiveElement:Ut}),(jt.reactiveElementVersions??(jt.reactiveElementVersions=[])).push("2.1.2");var Jn=globalThis,Zu=i=>i,Cs=Jn.trustedTypes,Xu=Cs?Cs.createPolicy("lit-html",{createHTML:i=>i}):void 0,rh="$lit$",Jt=`lit$${Math.random().toFixed(9).slice(2)}$`,nh="?"+Jt,Cv=`<${nh}>`,Ni=document,eo=()=>Ni.createComment(""),to=i=>i===null||typeof i!="object"&&typeof i!="function",cd=Array.isArray,Rv=i=>cd(i)||typeof(i==null?void 0:i[Symbol.iterator])=="function",rd=`[
6
6
  \f\r]`,jn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,ju=/-->/g,Ju=/>/g,Di=RegExp(`>|${rd}(?:([^\\s"'>=/]+)(${rd}*=${rd}*(?:[^
7
- \f\r"'\`<>=]|("|')|))|$)`,"g"),eh=/'/g,th=/"/g,oh=/^(?:script|style|textarea|title)$/i,ud=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),Ye=ud(1),Db=ud(2),Ob=ud(3),Ui=Symbol.for("lit-noChange"),_e=Symbol.for("lit-nothing"),ih=new WeakMap,Oi=Ni.createTreeWalker(Ni,129);function sh(i,e){if(!cd(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Xu!==void 0?Xu.createHTML(e):e}var Mv=(i,e)=>{let t=i.length-1,r=[],n,o=e===2?"<svg>":e===3?"<math>":"",s=jn;for(let l=0;l<t;l++){let d=i[l],h,p,f=-1,E=0;for(;E<d.length&&(s.lastIndex=E,p=s.exec(d),p!==null);)E=s.lastIndex,s===jn?p[1]==="!--"?s=ju:p[1]!==void 0?s=Ju:p[2]!==void 0?(oh.test(p[2])&&(n=RegExp("</"+p[2],"g")),s=Di):p[3]!==void 0&&(s=Di):s===Di?p[0]===">"?(s=n??jn,f=-1):p[1]===void 0?f=-2:(f=s.lastIndex-p[2].length,h=p[1],s=p[3]===void 0?Di:p[3]==='"'?th:eh):s===th||s===eh?s=Di:s===ju||s===Ju?s=jn:(s=Di,n=void 0);let m=s===Di&&i[l+1].startsWith("/>")?" ":"";o+=s===jn?d+Cv:f>=0?(r.push(h),d.slice(0,f)+rh+d.slice(f)+Jt+m):d+Jt+(f===-2?l:m)}return[sh(i,o+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},io=class i{constructor({strings:e,_$litType$:t},r){let n;this.parts=[];let o=0,s=0,l=e.length-1,d=this.parts,[h,p]=Mv(e,t);if(this.el=i.createElement(h,r),Oi.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(n=Oi.nextNode())!==null&&d.length<l;){if(n.nodeType===1){if(n.hasAttributes())for(let f of n.getAttributeNames())if(f.endsWith(rh)){let E=p[s++],m=n.getAttribute(f).split(Jt),_=/([.?@])?(.*)/.exec(E);d.push({type:1,index:o,name:_[2],strings:m,ctor:_[1]==="."?sd:_[1]==="?"?ad:_[1]==="@"?ld:wr}),n.removeAttribute(f)}else f.startsWith(Jt)&&(d.push({type:6,index:o}),n.removeAttribute(f));if(oh.test(n.tagName)){let f=n.textContent.split(Jt),E=f.length-1;if(E>0){n.textContent=Cs?Cs.emptyScript:"";for(let m=0;m<E;m++)n.append(f[m],eo()),Oi.nextNode(),d.push({type:2,index:++o});n.append(f[E],eo())}}}else if(n.nodeType===8)if(n.data===nh)d.push({type:2,index:o});else{let f=-1;for(;(f=n.data.indexOf(Jt,f+1))!==-1;)d.push({type:7,index:o}),f+=Jt.length-1}o++}}static createElement(e,t){let r=Ni.createElement("template");return r.innerHTML=e,r}};function Lr(i,e,t=i,r){var s,l;if(e===Ui)return e;let n=r!==void 0?(s=t._$Co)==null?void 0:s[r]:t._$Cl,o=to(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((l=n==null?void 0:n._$AO)==null||l.call(n,!1),o===void 0?n=void 0:(n=new o(i),n._$AT(i,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=n:t._$Cl=n),n!==void 0&&(e=Lr(i,n._$AS(i,e.values),n,r)),e}var od=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:r}=this._$AD,n=((e==null?void 0:e.creationScope)??Ni).importNode(t,!0);Oi.currentNode=n;let o=Oi.nextNode(),s=0,l=0,d=r[0];for(;d!==void 0;){if(s===d.index){let h;d.type===2?h=new ro(o,o.nextSibling,this,e):d.type===1?h=new d.ctor(o,d.name,d.strings,this,e):d.type===6&&(h=new dd(o,this,e)),this._$AV.push(h),d=r[++l]}s!==(d==null?void 0:d.index)&&(o=Oi.nextNode(),s++)}return Oi.currentNode=Ni,n}p(e){let t=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}},ro=class i{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,n){this.type=2,this._$AH=_e,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Lr(this,e,t),to(e)?e===_e||e==null||e===""?(this._$AH!==_e&&this._$AR(),this._$AH=_e):e!==this._$AH&&e!==Ui&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Rv(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_e&&to(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ni.createTextNode(e)),this._$AH=e}$(e){var o;let{values:t,_$litType$:r}=e,n=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=io.createElement(sh(r.h,r.h[0]),this.options)),r);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(t);else{let s=new od(n,this),l=s.u(this.options);s.p(t),this.T(l),this._$AH=s}}_$AC(e){let t=ih.get(e.strings);return t===void 0&&ih.set(e.strings,t=new io(e)),t}k(e){cd(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,r,n=0;for(let o of e)n===t.length?t.push(r=new i(this.O(eo()),this.O(eo()),this,this.options)):r=t[n],r._$AI(o),n++;n<t.length&&(this._$AR(r&&r._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){let n=Zu(e).nextSibling;Zu(e).remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},wr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,n,o){this.type=1,this._$AH=_e,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=_e}_$AI(e,t=this,r,n){let o=this.strings,s=!1;if(o===void 0)e=Lr(this,e,t,0),s=!to(e)||e!==this._$AH&&e!==Ui,s&&(this._$AH=e);else{let l=e,d,h;for(e=o[0],d=0;d<o.length-1;d++)h=Lr(this,l[r+d],t,d),h===Ui&&(h=this._$AH[d]),s||(s=!to(h)||h!==this._$AH[d]),h===_e?e=_e:e!==_e&&(e+=(h??"")+o[d+1]),this._$AH[d]=h}s&&!n&&this.j(e)}j(e){e===_e?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},sd=class extends wr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===_e?void 0:e}},ad=class extends wr{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==_e)}},ld=class extends wr{constructor(e,t,r,n,o){super(e,t,r,n,o),this.type=5}_$AI(e,t=this){if((e=Lr(this,e,t,0)??_e)===Ui)return;let r=this._$AH,n=e===_e&&r!==_e||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,o=e!==_e&&(r===_e||n);n&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},dd=class{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Lr(this,e)}};var nd=Jn.litHtmlPolyfillSupport;nd==null||nd(io,ro),(Jn.litHtmlVersions??(Jn.litHtmlVersions=[])).push("3.3.2");var ah=(i,e,t)=>{let r=(t==null?void 0:t.renderBefore)??e,n=r._$litPart$;if(n===void 0){let o=(t==null?void 0:t.renderBefore)??null;r._$litPart$=n=new ro(e.insertBefore(eo(),o),o,void 0,t??{})}return n._$AI(i),n};var Hi=globalThis,xe=class extends Ut{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ah(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Ui}},lh;xe._$litElement$=!0,xe.finalized=!0,(lh=Hi.litElementHydrateSupport)==null||lh.call(Hi,{LitElement:xe});var hd=Hi.litElementPolyfillSupport;hd==null||hd({LitElement:xe});(Hi.litElementVersions??(Hi.litElementVersions=[])).push("4.2.2");var ei=i=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(i,e)}):customElements.define(i,e)};var xv={attribute:!0,type:String,converter:Xn,reflect:!1,hasChanged:Is},Pv=(i=xv,e,t)=>{let{kind:r,metadata:n}=t,o=globalThis.litPropertyMetadata.get(n);if(o===void 0&&globalThis.litPropertyMetadata.set(n,o=new Map),r==="setter"&&((i=Object.create(i)).wrapped=!0),o.set(t.name,i),r==="accessor"){let{name:s}=t;return{set(l){let d=e.get.call(this);e.set.call(this,l),this.requestUpdate(s,d,i,!0,l)},init(l){return l!==void 0&&this.C(s,void 0,i,l),l}}}if(r==="setter"){let{name:s}=t;return function(l){let d=this[s];e.call(this,l),this.requestUpdate(s,d,i,!0,l)}}throw Error("Unsupported decorator location: "+r)};function Y(i){return(e,t)=>typeof t=="object"?Pv(i,e,t):((r,n,o)=>{let s=n.hasOwnProperty(o);return n.constructor.createProperty(o,r),s?Object.getOwnPropertyDescriptor(n,o):void 0})(i,e,t)}function ti(i){return Y({...i,state:!0,attribute:!1})}var Dv=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function pd(i){return i===1005||i===1007||i===1009?"autoplay":i>=2001&&i<=2004?"offline":i>=3e3&&i<=3999?"media":i>=4900&&i<=4999?"security":i>=4e3&&i<=4899?"network":i>=5e3&&i<=5999?"setup":i>=1e3&&i<=1999?"media":"unknown"}function md(i){return i===4e3||i===4001?"network":"unknown"}function Ms(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function xs(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"streamId"in i}function Ps(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"clipId"in i}function vd(i){return xs(i)||Ps(i)}var pt=class extends Error{constructor(t,r,n){super(t);this.code=r;this.status=n;this.name="BPLiveError"}},no=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new pt("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,r={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let s=await this._network.intercept({url:t,method:"GET",type:"api",headers:r});if(s.response)return s.response.body;t=s.url,r=s.headers}let n=new AbortController,o=setTimeout(()=>n.abort(),3e4);try{let s=await fetch(t,{method:"GET",headers:r,signal:n.signal});if(!s.ok)throw new pt(`HTTP ${s.status}: ${s.statusText}`,"HTTP_ERROR",s.status);let l=await s.json();return this._network&&(l=(await this._network.interceptResponse({url:t,status:s.status,headers:Object.fromEntries(s.headers),body:l})).body),l}catch(s){throw s instanceof Error&&s.name==="AbortError"?new pt("Request timeout after 30s","TIMEOUT"):s}finally{clearTimeout(o)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...r}=e;return{type:"nano",source:r}}throw new pt(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let r=e.filter(l=>l.type==="clip");if(r.length===0)return null;let n=r.find(l=>l.orientation===t);if(n)return n;let o=t==="landscape"?"portrait":"landscape",s=r.find(l=>l.orientation===o);return s||r[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,xs(e))return this.resolveStreamSource(e);if(Ps(e))return this.resolveClipSource(e);throw new pt("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var l,d,h,p,f,E,m,_,g;let r=(await this.getStream(e.streamId)).data;this._stream=r;let n=this.extractStreamPoster(r);if(!!r.ended_at&&((d=(l=r.media)==null?void 0:l.vod)==null?void 0:d.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(h=I.dimension)==null?void 0:h.width,videoHeight:(p=I.dimension)==null?void 0:p.height}}let s=r.player_source??((f=r.active_stream)==null?void 0:f.player_source);if(s)return{source:this.mapPlayerSourceToResolvedSource(s),contentType:"stream",poster:n};if(((m=(E=r.media)==null?void 0:E.vod)==null?void 0:m.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(_=I.dimension)==null?void 0:_.width,videoHeight:(g=I.dimension)==null?void 0:g.height}}throw new pt("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let r=(await this.getClip(e.clipId)).data;this._clip=r;let n=this.selectClipMedia(r.media,e.preferredOrientation);if(!n)throw new pt("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(n),contentType:"clip",poster:n.thumbnail??void 0,videoWidth:n.width,videoHeight:n.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function oo(i){return i!=null&&typeof i.then=="function"}function dh(i){return new Promise((e,t)=>{let r=!1,n=o=>{r||(r=!0,o?t(o):e())};try{let o=i(n);oo(o)&&(r=!0,o.then(()=>e(),t))}catch(o){n(o)}})}var fd=class{constructor(e,t,r){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((n,o)=>{this._resolve=n,this._reject=o}),this._state=e,this._interceptor=t,this._canModify=r,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());oo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");oo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(dh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},Ed=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((r,n)=>{this._resolve=r,this._reject=n}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());oo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");oo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(dh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},so=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},r=!1,n=null;for(let o of this._requestInterceptors.slice()){let s=new fd(t,o,!r);try{await s.promise}catch{continue}s.responseResult&&!r&&(r=!0,n=s.responseResult),s.redirectResult&&!r&&(t=s.redirectResult)}return{url:t.url,headers:t.headers,response:n}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let r of this._responseInterceptors.slice()){let n=new Ed(t,r);try{await n.promise}catch{continue}n.responseResult&&(t={...t,status:n.responseResult.status!==void 0?n.responseResult.status:t.status,headers:n.responseResult.headers!==void 0?n.responseResult.headers:t.headers,body:"body"in n.responseResult?n.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Ov(i){if(typeof i=="string")return"video";switch(i.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function ch(i){return typeof i=="object"&&i!==null&&i.type==="bplive"}var Nv=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],gd=class{constructor(){this._mediaElement=null;this._container=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new so;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=Ms()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r)this._listeners.has(n)||this._listeners.set(n,new Set),this._listeners.get(n).add(t)}removeEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r){let o=this._listeners.get(n);o&&(o.delete(t),o.size===0&&this._listeners.delete(n))}}dispatch(e,t){let r=this._listeners.get(e);if(r)for(let n of r)try{n(t)}catch(o){console.error(`[PlayerCore] Error in event listener for "${e}":`,o)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,r){if(this._destroyed)return;let n=++this._loadGeneration,o=t??this._container,s=r??this._config;if(!o){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=o,s&&(this._config=s);let l=ch(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...l&&{contentType:l}}),this.dispatch("sourcechange",{source:e});try{let d=e,h=this._state.contentType,p,f,E;if(ch(e)){if(s!=null&&s.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new no(s.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let L=await this._bpLive.resolveSource(e);if(n!==this._loadGeneration)return;d=L.source,h=L.contentType,p=L.poster,f=L.videoWidth,E=L.videoHeight}let m=Ov(d),I=m==="nano"||m==="livekit"||h==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=m,this.updateState({providerType:m,contentType:h,streamType:I,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(m,d,s),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),o.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:p,videoWidth:f,videoHeight:E}}catch(d){if(n!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",d);let h={code:-1,message:d instanceof Error?d.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:h,connectionState:"failed"}),this.dispatch("error",h)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,r){switch(e){case"nano":{let n=document.createElement("nano-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.libraryLocation=(r==null?void 0:r.libraryLocation)??"/vendor/bp-player",o.source?n.sourceConfig=o.source:o.streamid&&(n.streamid=o.streamid),r!=null&&r.nano&&(n.config=r.nano),n}case"livekit":{let n=document.createElement("livekit-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.url=o.url,n.token=o.token,r!=null&&r.livekit&&(n.config=r.livekit),n}case"video":default:{let n=document.createElement("hls-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=typeof t=="string"?t:t.url;n.src=o;let s={...r==null?void 0:r.video},l=this._network,d=s.xhrSetup;return s.xhrSetup=async(h,p)=>{let f=p.includes(".m3u8")?"manifest":p.includes(".ts")||p.includes(".m4s")||p.includes(".fmp4")?"segment":"other",E=await l.intercept({url:p,method:"GET",type:f,headers:{}});E.url!==p&&h.open("GET",E.url,!0);for(let[m,_]of Object.entries(E.headers))h.setRequestHeader(m,_);d&&await d(h,E.url)},n.config=s,n}}}attachMediaElementListeners(e){for(let t of Nv){let r=n=>this.handleMediaEvent(t,e,n);e.addEventListener(t,r),this._eventCleanup.push(()=>e.removeEventListener(t,r))}}attachActiveVideoElementForwarding(e){let t=r=>{let n=r.detail;this.dispatch("activevideoelementchange",{video:(n==null?void 0:n.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,r){var n,o,s,l;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:d}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:d}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let d=-1,h="Unknown error",p="none";r instanceof ErrorEvent&&r.error?(d=r.error.code??-1,h=r.error.message??r.message??"Unknown error",p="ErrorEvent"):t.error&&(d=t.error.code??-1,h=t.error.message??"Unknown error",p="element.error");let f=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(n=r.target)==null?void 0:n.tagName,source:p,code:d,message:h,eventIsErrorEvent:r instanceof ErrorEvent,eventErrorCode:r instanceof ErrorEvent?(o=r.error)==null?void 0:o.code:void 0,elementErrorCode:(s=t.error)==null?void 0:s.code,nativeElTag:f==null?void 0:f.tagName,nativeElErrorCode:(l=f==null?void 0:f.error)==null?void 0:l.code,nativeElSrc:f==null?void 0:f.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let E="media",m=!0;this._state.providerType==="nano"&&d>0?(E=pd(d),m=E!=="offline"&&E!=="autoplay"):this._state.providerType==="livekit"&&d>0&&(E=md(d),m=!0);let _={code:d,message:h,fatal:m,category:E};this.updateState({error:_}),this.dispatch("error",_);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...Ms(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"});let t=this._getFullscreenTarget();t&&(e&&!document.fullscreenElement?await t.requestFullscreen():!e&&document.fullscreenElement&&await document.exitFullscreen())}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){this._destroyed||(this._destroyed=!0,this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function bd(){return new gd}var Ir="bpPlayerObservedProperties";function _d(i){return Ir in i&&Array.isArray(i[Ir])}function Uv(i,e){class t extends i{get[Ir](){return e}}return t}function Hv(i){if(i.shadowRoot)return Array.from(i.shadowRoot.children);if(i.localName==="slot"){let t=i.assignedNodes();if(t.length>0)return t.filter(r=>r.nodeType===Node.ELEMENT_NODE)}return Array.from(i.children)}async function Cr(i,e,t){if(e!=null&&e.contains(i))return;i.nodeName.includes("-")&&!_d(i)&&(await Promise.resolve(),await customElements.whenDefined(i.nodeName.toLowerCase()),customElements.upgrade(i)),_d(i)&&t(i);let r=Hv(i);r.length>0&&await Promise.all(r.map(n=>Cr(n,e,t)))}function Ds(i,e,t){let r=i[Ir];r.includes("player")&&(i.player=e),r.includes("paused")&&(i.paused=t.paused),r.includes("playing")&&(i.playing=t.playing),r.includes("ended")&&(i.ended=t.ended),r.includes("seeking")&&(i.seeking=t.seeking),r.includes("currentTime")&&(i.currentTime=t.currentTime),r.includes("duration")&&(i.duration=t.duration),r.includes("volume")&&(i.volume=t.volume),r.includes("muted")&&(i.muted=t.muted),r.includes("playbackRate")&&(i.playbackRate=t.playbackRate),r.includes("readyState")&&(i.readyState=t.readyState),r.includes("videoWidth")&&(i.videoWidth=t.videoWidth),r.includes("videoHeight")&&(i.videoHeight=t.videoHeight),r.includes("qualities")&&(i.qualities=t.qualities),r.includes("currentQuality")&&(i.currentQuality=t.currentQuality),r.includes("targetQuality")&&(i.targetQuality=t.targetQuality),r.includes("fullscreen")&&(i.fullscreen=t.fullscreen),r.includes("presentationMode")&&(i.presentationMode=t.presentationMode),r.includes("connectionState")&&(i.connectionState=t.connectionState),r.includes("streamType")&&(i.streamType=t.streamType),r.includes("error")&&(i.error=t.error)}function Os(i){i[Ir].includes("player")&&(i.player=void 0)}var uh=`/**
7
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),eh=/'/g,th=/"/g,oh=/^(?:script|style|textarea|title)$/i,ud=i=>(e,...t)=>({_$litType$:i,strings:e,values:t}),Ye=ud(1),Db=ud(2),Ob=ud(3),Ui=Symbol.for("lit-noChange"),_e=Symbol.for("lit-nothing"),ih=new WeakMap,Oi=Ni.createTreeWalker(Ni,129);function sh(i,e){if(!cd(i)||!i.hasOwnProperty("raw"))throw Error("invalid template strings array");return Xu!==void 0?Xu.createHTML(e):e}var Mv=(i,e)=>{let t=i.length-1,r=[],n,o=e===2?"<svg>":e===3?"<math>":"",s=jn;for(let l=0;l<t;l++){let d=i[l],h,p,f=-1,E=0;for(;E<d.length&&(s.lastIndex=E,p=s.exec(d),p!==null);)E=s.lastIndex,s===jn?p[1]==="!--"?s=ju:p[1]!==void 0?s=Ju:p[2]!==void 0?(oh.test(p[2])&&(n=RegExp("</"+p[2],"g")),s=Di):p[3]!==void 0&&(s=Di):s===Di?p[0]===">"?(s=n??jn,f=-1):p[1]===void 0?f=-2:(f=s.lastIndex-p[2].length,h=p[1],s=p[3]===void 0?Di:p[3]==='"'?th:eh):s===th||s===eh?s=Di:s===ju||s===Ju?s=jn:(s=Di,n=void 0);let m=s===Di&&i[l+1].startsWith("/>")?" ":"";o+=s===jn?d+Cv:f>=0?(r.push(h),d.slice(0,f)+rh+d.slice(f)+Jt+m):d+Jt+(f===-2?l:m)}return[sh(i,o+(i[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),r]},io=class i{constructor({strings:e,_$litType$:t},r){let n;this.parts=[];let o=0,s=0,l=e.length-1,d=this.parts,[h,p]=Mv(e,t);if(this.el=i.createElement(h,r),Oi.currentNode=this.el.content,t===2||t===3){let f=this.el.content.firstChild;f.replaceWith(...f.childNodes)}for(;(n=Oi.nextNode())!==null&&d.length<l;){if(n.nodeType===1){if(n.hasAttributes())for(let f of n.getAttributeNames())if(f.endsWith(rh)){let E=p[s++],m=n.getAttribute(f).split(Jt),_=/([.?@])?(.*)/.exec(E);d.push({type:1,index:o,name:_[2],strings:m,ctor:_[1]==="."?sd:_[1]==="?"?ad:_[1]==="@"?ld:wr}),n.removeAttribute(f)}else f.startsWith(Jt)&&(d.push({type:6,index:o}),n.removeAttribute(f));if(oh.test(n.tagName)){let f=n.textContent.split(Jt),E=f.length-1;if(E>0){n.textContent=Cs?Cs.emptyScript:"";for(let m=0;m<E;m++)n.append(f[m],eo()),Oi.nextNode(),d.push({type:2,index:++o});n.append(f[E],eo())}}}else if(n.nodeType===8)if(n.data===nh)d.push({type:2,index:o});else{let f=-1;for(;(f=n.data.indexOf(Jt,f+1))!==-1;)d.push({type:7,index:o}),f+=Jt.length-1}o++}}static createElement(e,t){let r=Ni.createElement("template");return r.innerHTML=e,r}};function Lr(i,e,t=i,r){var s,l;if(e===Ui)return e;let n=r!==void 0?(s=t._$Co)==null?void 0:s[r]:t._$Cl,o=to(e)?void 0:e._$litDirective$;return(n==null?void 0:n.constructor)!==o&&((l=n==null?void 0:n._$AO)==null||l.call(n,!1),o===void 0?n=void 0:(n=new o(i),n._$AT(i,t,r)),r!==void 0?(t._$Co??(t._$Co=[]))[r]=n:t._$Cl=n),n!==void 0&&(e=Lr(i,n._$AS(i,e.values),n,r)),e}var od=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:r}=this._$AD,n=((e==null?void 0:e.creationScope)??Ni).importNode(t,!0);Oi.currentNode=n;let o=Oi.nextNode(),s=0,l=0,d=r[0];for(;d!==void 0;){if(s===d.index){let h;d.type===2?h=new ro(o,o.nextSibling,this,e):d.type===1?h=new d.ctor(o,d.name,d.strings,this,e):d.type===6&&(h=new dd(o,this,e)),this._$AV.push(h),d=r[++l]}s!==(d==null?void 0:d.index)&&(o=Oi.nextNode(),s++)}return Oi.currentNode=Ni,n}p(e){let t=0;for(let r of this._$AV)r!==void 0&&(r.strings!==void 0?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}},ro=class i{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,r,n){this.type=2,this._$AH=_e,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=n,this._$Cv=(n==null?void 0:n.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Lr(this,e,t),to(e)?e===_e||e==null||e===""?(this._$AH!==_e&&this._$AR(),this._$AH=_e):e!==this._$AH&&e!==Ui&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Rv(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_e&&to(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ni.createTextNode(e)),this._$AH=e}$(e){var o;let{values:t,_$litType$:r}=e,n=typeof r=="number"?this._$AC(e):(r.el===void 0&&(r.el=io.createElement(sh(r.h,r.h[0]),this.options)),r);if(((o=this._$AH)==null?void 0:o._$AD)===n)this._$AH.p(t);else{let s=new od(n,this),l=s.u(this.options);s.p(t),this.T(l),this._$AH=s}}_$AC(e){let t=ih.get(e.strings);return t===void 0&&ih.set(e.strings,t=new io(e)),t}k(e){cd(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,r,n=0;for(let o of e)n===t.length?t.push(r=new i(this.O(eo()),this.O(eo()),this,this.options)):r=t[n],r._$AI(o),n++;n<t.length&&(this._$AR(r&&r._$AB.nextSibling,n),t.length=n)}_$AR(e=this._$AA.nextSibling,t){var r;for((r=this._$AP)==null?void 0:r.call(this,!1,!0,t);e!==this._$AB;){let n=Zu(e).nextSibling;Zu(e).remove(),e=n}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},wr=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,n,o){this.type=1,this._$AH=_e,this._$AN=void 0,this.element=e,this.name=t,this._$AM=n,this.options=o,r.length>2||r[0]!==""||r[1]!==""?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=_e}_$AI(e,t=this,r,n){let o=this.strings,s=!1;if(o===void 0)e=Lr(this,e,t,0),s=!to(e)||e!==this._$AH&&e!==Ui,s&&(this._$AH=e);else{let l=e,d,h;for(e=o[0],d=0;d<o.length-1;d++)h=Lr(this,l[r+d],t,d),h===Ui&&(h=this._$AH[d]),s||(s=!to(h)||h!==this._$AH[d]),h===_e?e=_e:e!==_e&&(e+=(h??"")+o[d+1]),this._$AH[d]=h}s&&!n&&this.j(e)}j(e){e===_e?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},sd=class extends wr{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===_e?void 0:e}},ad=class extends wr{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==_e)}},ld=class extends wr{constructor(e,t,r,n,o){super(e,t,r,n,o),this.type=5}_$AI(e,t=this){if((e=Lr(this,e,t,0)??_e)===Ui)return;let r=this._$AH,n=e===_e&&r!==_e||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,o=e!==_e&&(r===_e||n);n&&this.element.removeEventListener(this.name,this,r),o&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},dd=class{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){Lr(this,e)}};var nd=Jn.litHtmlPolyfillSupport;nd==null||nd(io,ro),(Jn.litHtmlVersions??(Jn.litHtmlVersions=[])).push("3.3.2");var ah=(i,e,t)=>{let r=(t==null?void 0:t.renderBefore)??e,n=r._$litPart$;if(n===void 0){let o=(t==null?void 0:t.renderBefore)??null;r._$litPart$=n=new ro(e.insertBefore(eo(),o),o,void 0,t??{})}return n._$AI(i),n};var Hi=globalThis,xe=class extends Ut{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=ah(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Ui}},lh;xe._$litElement$=!0,xe.finalized=!0,(lh=Hi.litElementHydrateSupport)==null||lh.call(Hi,{LitElement:xe});var hd=Hi.litElementPolyfillSupport;hd==null||hd({LitElement:xe});(Hi.litElementVersions??(Hi.litElementVersions=[])).push("4.2.2");var ei=i=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(i,e)}):customElements.define(i,e)};var xv={attribute:!0,type:String,converter:Xn,reflect:!1,hasChanged:Is},Pv=(i=xv,e,t)=>{let{kind:r,metadata:n}=t,o=globalThis.litPropertyMetadata.get(n);if(o===void 0&&globalThis.litPropertyMetadata.set(n,o=new Map),r==="setter"&&((i=Object.create(i)).wrapped=!0),o.set(t.name,i),r==="accessor"){let{name:s}=t;return{set(l){let d=e.get.call(this);e.set.call(this,l),this.requestUpdate(s,d,i,!0,l)},init(l){return l!==void 0&&this.C(s,void 0,i,l),l}}}if(r==="setter"){let{name:s}=t;return function(l){let d=this[s];e.call(this,l),this.requestUpdate(s,d,i,!0,l)}}throw Error("Unsupported decorator location: "+r)};function Y(i){return(e,t)=>typeof t=="object"?Pv(i,e,t):((r,n,o)=>{let s=n.hasOwnProperty(o);return n.constructor.createProperty(o,r),s?Object.getOwnPropertyDescriptor(n,o):void 0})(i,e,t)}function ti(i){return Y({...i,state:!0,attribute:!1})}var Dv=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function pd(i){return i===1005||i===1007||i===1009?"autoplay":i>=2001&&i<=2004?"offline":i>=3e3&&i<=3999?"media":i>=4900&&i<=4999?"security":i>=4e3&&i<=4899?"network":i>=5e3&&i<=5999?"setup":i>=1e3&&i<=1999?"media":"unknown"}function md(i){return i===4e3||i===4001?"network":"unknown"}function Ms(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function xs(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"streamId"in i}function Ps(i){return typeof i=="object"&&i!==null&&"type"in i&&i.type==="bplive"&&"clipId"in i}function vd(i){return xs(i)||Ps(i)}var pt=class extends Error{constructor(t,r,n){super(t);this.code=r;this.status=n;this.name="BPLiveError"}},no=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new pt("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,r={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let s=await this._network.intercept({url:t,method:"GET",type:"api",headers:r});if(s.response)return s.response.body;t=s.url,r=s.headers}let n=new AbortController,o=setTimeout(()=>n.abort(),3e4);try{let s=await fetch(t,{method:"GET",headers:r,signal:n.signal});if(!s.ok)throw new pt(`HTTP ${s.status}: ${s.statusText}`,"HTTP_ERROR",s.status);let l=await s.json();return this._network&&(l=(await this._network.interceptResponse({url:t,status:s.status,headers:Object.fromEntries(s.headers),body:l})).body),l}catch(s){throw s instanceof Error&&s.name==="AbortError"?new pt("Request timeout after 30s","TIMEOUT"):s}finally{clearTimeout(o)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...r}=e;return{type:"nano",source:r}}throw new pt(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let r=e.filter(l=>l.type==="clip");if(r.length===0)return null;let n=r.find(l=>l.orientation===t);if(n)return n;let o=t==="landscape"?"portrait":"landscape",s=r.find(l=>l.orientation===o);return s||r[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,xs(e))return this.resolveStreamSource(e);if(Ps(e))return this.resolveClipSource(e);throw new pt("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var l,d,h,p,f,E,m,_,g;let r=(await this.getStream(e.streamId)).data;this._stream=r;let n=this.extractStreamPoster(r);if(!!r.ended_at&&((d=(l=r.media)==null?void 0:l.vod)==null?void 0:d.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(h=I.dimension)==null?void 0:h.width,videoHeight:(p=I.dimension)==null?void 0:p.height}}let s=r.player_source??((f=r.active_stream)==null?void 0:f.player_source);if(s)return{source:this.mapPlayerSourceToResolvedSource(s),contentType:"stream",poster:n};if(((m=(E=r.media)==null?void 0:E.vod)==null?void 0:m.length)>0){let I=r.media.vod[0];return{source:{type:"video",url:I.original},contentType:"video",poster:n??I.thumb??void 0,videoWidth:(_=I.dimension)==null?void 0:_.width,videoHeight:(g=I.dimension)==null?void 0:g.height}}throw new pt("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let r=(await this.getClip(e.clipId)).data;this._clip=r;let n=this.selectClipMedia(r.media,e.preferredOrientation);if(!n)throw new pt("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(n),contentType:"clip",poster:n.thumbnail??void 0,videoWidth:n.width,videoHeight:n.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function oo(i){return i!=null&&typeof i.then=="function"}function dh(i){return new Promise((e,t)=>{let r=!1,n=o=>{r||(r=!0,o?t(o):e())};try{let o=i(n);oo(o)&&(r=!0,o.then(()=>e(),t))}catch(o){n(o)}})}var fd=class{constructor(e,t,r){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((n,o)=>{this._resolve=n,this._reject=o}),this._state=e,this._interceptor=t,this._canModify=r,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());oo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");oo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(dh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},Ed=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((r,n)=>{this._resolve=r,this._reject=n}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());oo(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");oo(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(dh(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},so=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},r=!1,n=null;for(let o of this._requestInterceptors.slice()){let s=new fd(t,o,!r);try{await s.promise}catch{continue}s.responseResult&&!r&&(r=!0,n=s.responseResult),s.redirectResult&&!r&&(t=s.redirectResult)}return{url:t.url,headers:t.headers,response:n}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let r of this._responseInterceptors.slice()){let n=new Ed(t,r);try{await n.promise}catch{continue}n.responseResult&&(t={...t,status:n.responseResult.status!==void 0?n.responseResult.status:t.status,headers:n.responseResult.headers!==void 0?n.responseResult.headers:t.headers,body:"body"in n.responseResult?n.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Ov(i){if(typeof i=="string")return"video";switch(i.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function ch(i){return typeof i=="object"&&i!==null&&i.type==="bplive"}var Nv=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],gd=class{constructor(){this._mediaElement=null;this._container=null;this._webkitFullscreen=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new so;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=Ms()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r)this._listeners.has(n)||this._listeners.set(n,new Set),this._listeners.get(n).add(t)}removeEventListener(e,t){let r=Array.isArray(e)?e:[e];for(let n of r){let o=this._listeners.get(n);o&&(o.delete(t),o.size===0&&this._listeners.delete(n))}}dispatch(e,t){let r=this._listeners.get(e);if(r)for(let n of r)try{n(t)}catch(o){console.error(`[PlayerCore] Error in event listener for "${e}":`,o)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,r){if(this._destroyed)return;let n=++this._loadGeneration,o=t??this._container,s=r??this._config;if(!o){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=o,s&&(this._config=s);let l=ch(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...l&&{contentType:l}}),this.dispatch("sourcechange",{source:e});try{let d=e,h=this._state.contentType,p,f,E;if(ch(e)){if(s!=null&&s.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new no(s.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let L=await this._bpLive.resolveSource(e);if(n!==this._loadGeneration)return;d=L.source,h=L.contentType,p=L.poster,f=L.videoWidth,E=L.videoHeight}let m=Ov(d),I=m==="nano"||m==="livekit"||h==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=m,this.updateState({providerType:m,contentType:h,streamType:I,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(m,d,s),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),o.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:p,videoWidth:f,videoHeight:E}}catch(d){if(n!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",d);let h={code:-1,message:d instanceof Error?d.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:h,connectionState:"failed"}),this.dispatch("error",h)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,r){switch(e){case"nano":{let n=document.createElement("nano-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.libraryLocation=(r==null?void 0:r.libraryLocation)??"/vendor/bp-player",o.source?n.sourceConfig=o.source:o.streamid&&(n.streamid=o.streamid),r!=null&&r.nano&&(n.config=r.nano),n}case"livekit":{let n=document.createElement("livekit-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=t;return n.url=o.url,n.token=o.token,r!=null&&r.livekit&&(n.config=r.livekit),n}case"video":default:{let n=document.createElement("hls-video");n.setAttribute("playsinline",""),n.setAttribute("webkit-playsinline","");let o=typeof t=="string"?t:t.url;n.src=o;let s={...r==null?void 0:r.video},l=this._network,d=s.xhrSetup;return s.xhrSetup=async(h,p)=>{let f=p.includes(".m3u8")?"manifest":p.includes(".ts")||p.includes(".m4s")||p.includes(".fmp4")?"segment":"other",E=await l.intercept({url:p,method:"GET",type:f,headers:{}});E.url!==p&&h.open("GET",E.url,!0);for(let[m,_]of Object.entries(E.headers))h.setRequestHeader(m,_);d&&await d(h,E.url)},n.config=s,n}}}attachMediaElementListeners(e){for(let t of Nv){let r=n=>this.handleMediaEvent(t,e,n);e.addEventListener(t,r),this._eventCleanup.push(()=>e.removeEventListener(t,r))}}attachActiveVideoElementForwarding(e){let t=r=>{let n=r.detail;this.dispatch("activevideoelementchange",{video:(n==null?void 0:n.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,r){var n,o,s,l;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:d}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let d=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:d}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let d=-1,h="Unknown error",p="none";r instanceof ErrorEvent&&r.error?(d=r.error.code??-1,h=r.error.message??r.message??"Unknown error",p="ErrorEvent"):t.error&&(d=t.error.code??-1,h=t.error.message??"Unknown error",p="element.error");let f=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(n=r.target)==null?void 0:n.tagName,source:p,code:d,message:h,eventIsErrorEvent:r instanceof ErrorEvent,eventErrorCode:r instanceof ErrorEvent?(o=r.error)==null?void 0:o.code:void 0,elementErrorCode:(s=t.error)==null?void 0:s.code,nativeElTag:f==null?void 0:f.tagName,nativeElErrorCode:(l=f==null?void 0:f.error)==null?void 0:l.code,nativeElSrc:f==null?void 0:f.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let E="media",m=!0;this._state.providerType==="nano"&&d>0?(E=pd(d),m=E!=="offline"&&E!=="autoplay"):this._state.providerType==="livekit"&&d>0&&(E=md(d),m=!0);let _={code:d,message:h,fatal:m,category:E};this.updateState({error:_}),this.dispatch("error",_);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...Ms(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){var t;if(this._applyFullscreenState(e),e){let r=this._getFullscreenTarget();if(!r){this._applyFullscreenState(!1);return}if(document.fullscreenElement){document.fullscreenElement!==r&&this._applyFullscreenState(!1);return}if(typeof r.requestFullscreen=="function")try{await r.requestFullscreen()}catch(n){throw this._applyFullscreenState(!1),n}else this._enterWebkitVideoFullscreen()}else if(document.fullscreenElement)await document.exitFullscreen();else{let r=this._webkitFullscreen,n=(r==null?void 0:r.video)??this.activeVideoElement;n!=null&&n.webkitDisplayingFullscreen&&(r==null||r.disarm(),(t=n.webkitExitFullscreen)==null||t.call(n))}}_applyFullscreenState(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"})}_enterWebkitVideoFullscreen(){var n;let e=this.activeVideoElement;if(!(e!=null&&e.webkitEnterFullscreen)){this._applyFullscreenState(!1);return}(n=this._webkitFullscreen)==null||n.disarm();let t=()=>{this._webkitFullscreen=null,this._applyFullscreenState(!1)};e.addEventListener("webkitendfullscreen",t,{once:!0});let r={video:e,disarm:()=>{this._webkitFullscreen=null,e.removeEventListener("webkitendfullscreen",t)}};if(this._webkitFullscreen=r,!e.webkitDisplayingFullscreen)try{e.webkitEnterFullscreen()}catch(o){throw r.disarm(),this._applyFullscreenState(!1),o}}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){var e;this._destroyed||(this._destroyed=!0,(e=this._webkitFullscreen)==null||e.disarm(),this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function bd(){return new gd}var Ir="bpPlayerObservedProperties";function _d(i){return Ir in i&&Array.isArray(i[Ir])}function Uv(i,e){class t extends i{get[Ir](){return e}}return t}function Hv(i){if(i.shadowRoot)return Array.from(i.shadowRoot.children);if(i.localName==="slot"){let t=i.assignedNodes();if(t.length>0)return t.filter(r=>r.nodeType===Node.ELEMENT_NODE)}return Array.from(i.children)}async function Cr(i,e,t){if(e!=null&&e.contains(i))return;i.nodeName.includes("-")&&!_d(i)&&(await Promise.resolve(),await customElements.whenDefined(i.nodeName.toLowerCase()),customElements.upgrade(i)),_d(i)&&t(i);let r=Hv(i);r.length>0&&await Promise.all(r.map(n=>Cr(n,e,t)))}function Ds(i,e,t){let r=i[Ir];r.includes("player")&&(i.player=e),r.includes("paused")&&(i.paused=t.paused),r.includes("playing")&&(i.playing=t.playing),r.includes("ended")&&(i.ended=t.ended),r.includes("seeking")&&(i.seeking=t.seeking),r.includes("currentTime")&&(i.currentTime=t.currentTime),r.includes("duration")&&(i.duration=t.duration),r.includes("volume")&&(i.volume=t.volume),r.includes("muted")&&(i.muted=t.muted),r.includes("playbackRate")&&(i.playbackRate=t.playbackRate),r.includes("readyState")&&(i.readyState=t.readyState),r.includes("videoWidth")&&(i.videoWidth=t.videoWidth),r.includes("videoHeight")&&(i.videoHeight=t.videoHeight),r.includes("qualities")&&(i.qualities=t.qualities),r.includes("currentQuality")&&(i.currentQuality=t.currentQuality),r.includes("targetQuality")&&(i.targetQuality=t.targetQuality),r.includes("fullscreen")&&(i.fullscreen=t.fullscreen),r.includes("presentationMode")&&(i.presentationMode=t.presentationMode),r.includes("connectionState")&&(i.connectionState=t.connectionState),r.includes("streamType")&&(i.streamType=t.streamType),r.includes("error")&&(i.error=t.error)}function Os(i){i[Ir].includes("player")&&(i.player=void 0)}var uh=`/**
8
8
  * BP Player CSS Custom Properties
9
9
  *
10
10
  * All styling can be customized by overriding these CSS variables.
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * BP Player (v1.4.9)
2
+ * BP Player (v1.5.0)
3
3
  * Universal video player web component
4
4
  */
5
5
  var Wb=Object.defineProperty;var Px=Object.getOwnPropertyDescriptor;var wx=Object.getPrototypeOf;var Dx=Reflect.get;var qb=n=>{throw TypeError(n)};var Mx=(n,e,t)=>e in n?Wb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var _e=(n,e,t,i)=>{for(var s=i>1?void 0:i?Px(e,t):e,r=n.length-1,a;r>=0;r--)(a=n[r])&&(s=(i?a(e,t,s):a(s))||s);return i&&s&&Wb(e,t,s),s};var we=(n,e,t)=>Mx(n,typeof e!="symbol"?e+"":e,t),dp=(n,e,t)=>e.has(n)||qb("Cannot "+t);var x=(n,e,t)=>(dp(n,e,"read from private field"),t?t.call(n):e.get(n)),ne=(n,e,t)=>e.has(n)?qb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),B=(n,e,t,i)=>(dp(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),oe=(n,e,t)=>(dp(n,e,"access private method"),t);var up=(n,e,t)=>Dx(wx(n),t,e);var Jd=globalThis,Zd=Jd.ShadowRoot&&(Jd.ShadyCSS===void 0||Jd.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,hp=Symbol(),jb=new WeakMap,Pl=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==hp)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(Zd&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=jb.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&jb.set(t,e))}return e}toString(){return this.cssText}},Yb=n=>new Pl(typeof n=="string"?n:n+"",void 0,hp),wl=(n,...e)=>{let t=n.length===1?n[0]:e.reduce((i,s,r)=>i+(a=>{if(a._$cssResult$===!0)return a.cssText;if(typeof a=="number")return a;throw Error("Value passed to 'css' function must be a 'css' function result: "+a+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+n[r+1],n[0]);return new Pl(t,n,hp)},zb=(n,e)=>{if(Zd)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=Jd.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,n.appendChild(i)}},fp=Zd?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return Yb(t)})(n):n;var{is:Ox,defineProperty:Nx,getOwnPropertyDescriptor:Ux,getOwnPropertyNames:Fx,getOwnPropertySymbols:Bx,getPrototypeOf:$x}=Object,Rs=globalThis,Qb=Rs.trustedTypes,Vx=Qb?Qb.emptyScript:"",mp=Rs.reactiveElementPolyfillSupport,Dl=(n,e)=>n,Ml={toAttribute(n,e){switch(e){case Boolean:n=n?Vx:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},eu=(n,e)=>!Ox(n,e),Xb={attribute:!0,type:String,converter:Ml,reflect:!1,useDefault:!1,hasChanged:eu};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),Rs.litPropertyMetadata??(Rs.litPropertyMetadata=new WeakMap);var ns=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??(this.l=[])).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Xb){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let i=Symbol(),s=this.getPropertyDescriptor(e,i,t);s!==void 0&&Nx(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:r}=Ux(this.prototype,e)??{get(){return this[t]},set(a){this[t]=a}};return{get:s,set(a){let o=s==null?void 0:s.call(this);r==null||r.call(this,a),this.requestUpdate(e,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Xb}static _$Ei(){if(this.hasOwnProperty(Dl("elementProperties")))return;let e=$x(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Dl("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Dl("properties"))){let t=this.properties,i=[...Fx(t),...Bx(t)];for(let s of i)this.createProperty(s,t[s])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[i,s]of t)this.elementProperties.set(i,s)}this._$Eh=new Map;for(let[t,i]of this.elementProperties){let s=this._$Eu(t,i);s!==void 0&&this._$Eh.set(s,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let i=new Set(e.flat(1/0).reverse());for(let s of i)t.unshift(fp(s))}else e!==void 0&&t.push(fp(e));return t}static _$Eu(e,t){let i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),(e=this.constructor.l)==null||e.forEach(t=>t(this))}addController(e){var t;(this._$EO??(this._$EO=new Set)).add(e),this.renderRoot!==void 0&&this.isConnected&&((t=e.hostConnected)==null||t.call(e))}removeController(e){var t;(t=this._$EO)==null||t.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return zb(e,this.constructor.elementStyles),e}connectedCallback(){var e;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostConnected)==null?void 0:i.call(t)})}enableUpdating(e){}disconnectedCallback(){var e;(e=this._$EO)==null||e.forEach(t=>{var i;return(i=t.hostDisconnected)==null?void 0:i.call(t)})}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$ET(e,t){var r;let i=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,i);if(s!==void 0&&i.reflect===!0){let a=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:Ml).toAttribute(t,i.type);this._$Em=e,a==null?this.removeAttribute(s):this.setAttribute(s,a),this._$Em=null}}_$AK(e,t){var r,a;let i=this.constructor,s=i._$Eh.get(e);if(s!==void 0&&this._$Em!==s){let o=i.getPropertyOptions(s),l=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:Ml;this._$Em=s;let c=l.fromAttribute(t,o.type);this[s]=c??((a=this._$Ej)==null?void 0:a.get(s))??c,this._$Em=null}}requestUpdate(e,t,i,s=!1,r){var a;if(e!==void 0){let o=this.constructor;if(s===!1&&(r=this[e]),i??(i=o.getPropertyOptions(e)),!((i.hasChanged??eu)(r,t)||i.useDefault&&i.reflect&&r===((a=this._$Ej)==null?void 0:a.get(e))&&!this.hasAttribute(o._$Eu(e,i))))return;this.C(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,t,{useDefault:i,reflect:s,wrapped:r},a){i&&!(this._$Ej??(this._$Ej=new Map)).has(e)&&(this._$Ej.set(e,a??t??this[e]),r!==!0||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||i||(t=void 0),this._$AL.set(e,t)),s===!0&&this._$Em!==e&&(this._$Eq??(this._$Eq=new Set)).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(let[r,a]of this._$Ep)this[r]=a;this._$Ep=void 0}let s=this.constructor.elementProperties;if(s.size>0)for(let[r,a]of s){let{wrapped:o}=a,l=this[r];o!==!0||this._$AL.has(r)||l===void 0||this.C(r,void 0,a,l)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(t)):this._$EM()}catch(s){throw e=!1,this._$EM(),s}e&&this._$AE(t)}willUpdate(e){}_$AE(e){var t;(t=this._$EO)==null||t.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(t=>this._$ET(t,this[t]))),this._$EM()}updated(e){}firstUpdated(e){}};ns.elementStyles=[],ns.shadowRootOptions={mode:"open"},ns[Dl("elementProperties")]=new Map,ns[Dl("finalized")]=new Map,mp==null||mp({ReactiveElement:ns}),(Rs.reactiveElementVersions??(Rs.reactiveElementVersions=[])).push("2.1.2");var Nl=globalThis,Jb=n=>n,tu=Nl.trustedTypes,Zb=tu?tu.createPolicy("lit-html",{createHTML:n=>n}):void 0,rT="$lit$",xs=`lit$${Math.random().toFixed(9).slice(2)}$`,aT="?"+xs,Hx=`<${aT}>`,wr=document,Ul=()=>wr.createComment(""),Fl=n=>n===null||typeof n!="object"&&typeof n!="function",Sp=Array.isArray,Gx=n=>Sp(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",pp=`[
6
6
  \f\r]`,Ol=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,eT=/-->/g,tT=/>/g,Lr=RegExp(`>|${pp}(?:([^\\s"'>=/]+)(${pp}*=${pp}*(?:[^
7
- \f\r"'\`<>=]|("|')|))|$)`,"g"),iT=/'/g,nT=/"/g,oT=/^(?:script|style|textarea|title)$/i,_p=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),Fi=_p(1),SB=_p(2),_B=_p(3),Dr=Symbol.for("lit-noChange"),Dt=Symbol.for("lit-nothing"),sT=new WeakMap,Pr=wr.createTreeWalker(wr,129);function lT(n,e){if(!Sp(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Zb!==void 0?Zb.createHTML(e):e}var Kx=(n,e)=>{let t=n.length-1,i=[],s,r=e===2?"<svg>":e===3?"<math>":"",a=Ol;for(let o=0;o<t;o++){let l=n[o],c,d,u=-1,h=0;for(;h<l.length&&(a.lastIndex=h,d=a.exec(l),d!==null);)h=a.lastIndex,a===Ol?d[1]==="!--"?a=eT:d[1]!==void 0?a=tT:d[2]!==void 0?(oT.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=Lr):d[3]!==void 0&&(a=Lr):a===Lr?d[0]===">"?(a=s??Ol,u=-1):d[1]===void 0?u=-2:(u=a.lastIndex-d[2].length,c=d[1],a=d[3]===void 0?Lr:d[3]==='"'?nT:iT):a===nT||a===iT?a=Lr:a===eT||a===tT?a=Ol:(a=Lr,s=void 0);let f=a===Lr&&n[o+1].startsWith("/>")?" ":"";r+=a===Ol?l+Hx:u>=0?(i.push(c),l.slice(0,u)+rT+l.slice(u)+xs+f):l+xs+(u===-2?o:f)}return[lT(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Bl=class n{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,a=0,o=e.length-1,l=this.parts,[c,d]=Kx(e,t);if(this.el=n.createElement(c,i),Pr.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Pr.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(let u of s.getAttributeNames())if(u.endsWith(rT)){let h=d[a++],f=s.getAttribute(u).split(xs),m=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:m[2],strings:f,ctor:m[1]==="."?yp:m[1]==="?"?Ep:m[1]==="@"?bp:Ua}),s.removeAttribute(u)}else u.startsWith(xs)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(oT.test(s.tagName)){let u=s.textContent.split(xs),h=u.length-1;if(h>0){s.textContent=tu?tu.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],Ul()),Pr.nextNode(),l.push({type:2,index:++r});s.append(u[h],Ul())}}}else if(s.nodeType===8)if(s.data===aT)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(xs,u+1))!==-1;)l.push({type:7,index:r}),u+=xs.length-1}r++}}static createElement(e,t){let i=wr.createElement("template");return i.innerHTML=e,i}};function Na(n,e,t=n,i){var a,o;if(e===Dr)return e;let s=i!==void 0?(a=t._$Co)==null?void 0:a[i]:t._$Cl,r=Fl(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((o=s==null?void 0:s._$AO)==null||o.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=Na(n,s._$AS(n,e.values),s,i)),e}var vp=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??wr).importNode(t,!0);Pr.currentNode=s;let r=Pr.nextNode(),a=0,o=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new $l(r,r.nextSibling,this,e):l.type===1?c=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(c=new Tp(r,this,e)),this._$AV.push(c),l=i[++o]}a!==(l==null?void 0:l.index)&&(r=Pr.nextNode(),a++)}return Pr.currentNode=wr,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},$l=class n{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Dt,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Na(this,e,t),Fl(e)?e===Dt||e==null||e===""?(this._$AH!==Dt&&this._$AR(),this._$AH=Dt):e!==this._$AH&&e!==Dr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Gx(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Dt&&Fl(this._$AH)?this._$AA.nextSibling.data=e:this.T(wr.createTextNode(e)),this._$AH=e}$(e){var r;let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Bl.createElement(lT(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{let a=new vp(s,this),o=a.u(this.options);a.p(t),this.T(o),this._$AH=a}}_$AC(e){let t=sT.get(e.strings);return t===void 0&&sT.set(e.strings,t=new Bl(e)),t}k(e){Sp(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let r of e)s===t.length?t.push(i=new n(this.O(Ul()),this.O(Ul()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){let s=Jb(e).nextSibling;Jb(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Ua=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Dt,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Dt}_$AI(e,t=this,i,s){let r=this.strings,a=!1;if(r===void 0)e=Na(this,e,t,0),a=!Fl(e)||e!==this._$AH&&e!==Dr,a&&(this._$AH=e);else{let o=e,l,c;for(e=r[0],l=0;l<r.length-1;l++)c=Na(this,o[i+l],t,l),c===Dr&&(c=this._$AH[l]),a||(a=!Fl(c)||c!==this._$AH[l]),c===Dt?e=Dt:e!==Dt&&(e+=(c??"")+r[l+1]),this._$AH[l]=c}a&&!s&&this.j(e)}j(e){e===Dt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},yp=class extends Ua{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Dt?void 0:e}},Ep=class extends Ua{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Dt)}},bp=class extends Ua{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=Na(this,e,t,0)??Dt)===Dr)return;let i=this._$AH,s=e===Dt&&i!==Dt||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Dt&&(i===Dt||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},Tp=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){Na(this,e)}};var gp=Nl.litHtmlPolyfillSupport;gp==null||gp(Bl,$l),(Nl.litHtmlVersions??(Nl.litHtmlVersions=[])).push("3.3.2");var cT=(n,e,t)=>{let i=(t==null?void 0:t.renderBefore)??e,s=i._$litPart$;if(s===void 0){let r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new $l(e.insertBefore(Ul(),r),r,void 0,t??{})}return s._$AI(n),s};var Mr=globalThis,ci=class extends ns{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=cT(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Dr}},dT;ci._$litElement$=!0,ci.finalized=!0,(dT=Mr.litElementHydrateSupport)==null||dT.call(Mr,{LitElement:ci});var kp=Mr.litElementPolyfillSupport;kp==null||kp({LitElement:ci});(Mr.litElementVersions??(Mr.litElementVersions=[])).push("4.2.2");var Ls=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};var Wx={attribute:!0,type:String,converter:Ml,reflect:!1,hasChanged:eu},qx=(n=Wx,e,t)=>{let{kind:i,metadata:s}=t,r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(t.name,n),i==="accessor"){let{name:a}=t;return{set(o){let l=e.get.call(this);e.set.call(this,o),this.requestUpdate(a,l,n,!0,o)},init(o){return o!==void 0&&this.C(a,void 0,n,o),o}}}if(i==="setter"){let{name:a}=t;return function(o){let l=this[a];e.call(this,o),this.requestUpdate(a,l,n,!0,o)}}throw Error("Unsupported decorator location: "+i)};function Be(n){return(e,t)=>typeof t=="object"?qx(n,e,t):((i,s,r)=>{let a=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),a?Object.getOwnPropertyDescriptor(s,r):void 0})(n,e,t)}function Ps(n){return Be({...n,state:!0,attribute:!1})}var jx=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Ap(n){return n===1005||n===1007||n===1009?"autoplay":n>=2001&&n<=2004?"offline":n>=3e3&&n<=3999?"media":n>=4900&&n<=4999?"security":n>=4e3&&n<=4899?"network":n>=5e3&&n<=5999?"setup":n>=1e3&&n<=1999?"media":"unknown"}function Cp(n){return n===4e3||n===4001?"network":"unknown"}function nu(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function su(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"streamId"in n}function ru(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"clipId"in n}function Ip(n){return su(n)||ru(n)}var Tn=class extends Error{constructor(t,i,s){super(t);this.code=i;this.status=s;this.name="BPLiveError"}},Vl=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new Tn("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,i={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let a=await this._network.intercept({url:t,method:"GET",type:"api",headers:i});if(a.response)return a.response.body;t=a.url,i=a.headers}let s=new AbortController,r=setTimeout(()=>s.abort(),3e4);try{let a=await fetch(t,{method:"GET",headers:i,signal:s.signal});if(!a.ok)throw new Tn(`HTTP ${a.status}: ${a.statusText}`,"HTTP_ERROR",a.status);let o=await a.json();return this._network&&(o=(await this._network.interceptResponse({url:t,status:a.status,headers:Object.fromEntries(a.headers),body:o})).body),o}catch(a){throw a instanceof Error&&a.name==="AbortError"?new Tn("Request timeout after 30s","TIMEOUT"):a}finally{clearTimeout(r)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...i}=e;return{type:"nano",source:i}}throw new Tn(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let i=e.filter(o=>o.type==="clip");if(i.length===0)return null;let s=i.find(o=>o.orientation===t);if(s)return s;let r=t==="landscape"?"portrait":"landscape",a=i.find(o=>o.orientation===r);return a||i[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,su(e))return this.resolveStreamSource(e);if(ru(e))return this.resolveClipSource(e);throw new Tn("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var o,l,c,d,u,h,f,m,p;let i=(await this.getStream(e.streamId)).data;this._stream=i;let s=this.extractStreamPoster(i);if(!!i.ended_at&&((l=(o=i.media)==null?void 0:o.vod)==null?void 0:l.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(c=g.dimension)==null?void 0:c.width,videoHeight:(d=g.dimension)==null?void 0:d.height}}let a=i.player_source??((u=i.active_stream)==null?void 0:u.player_source);if(a)return{source:this.mapPlayerSourceToResolvedSource(a),contentType:"stream",poster:s};if(((f=(h=i.media)==null?void 0:h.vod)==null?void 0:f.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(m=g.dimension)==null?void 0:m.width,videoHeight:(p=g.dimension)==null?void 0:p.height}}throw new Tn("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let i=(await this.getClip(e.clipId)).data;this._clip=i;let s=this.selectClipMedia(i.media,e.preferredOrientation);if(!s)throw new Tn("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(s),contentType:"clip",poster:s.thumbnail??void 0,videoWidth:s.width,videoHeight:s.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function Hl(n){return n!=null&&typeof n.then=="function"}function uT(n){return new Promise((e,t)=>{let i=!1,s=r=>{i||(i=!0,r?t(r):e())};try{let r=n(s);Hl(r)&&(i=!0,r.then(()=>e(),t))}catch(r){s(r)}})}var Rp=class{constructor(e,t,i){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((s,r)=>{this._resolve=s,this._reject=r}),this._state=e,this._interceptor=t,this._canModify=i,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Hl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");Hl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(uT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},xp=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((i,s)=>{this._resolve=i,this._reject=s}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Hl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");Hl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(uT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},Gl=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},i=!1,s=null;for(let r of this._requestInterceptors.slice()){let a=new Rp(t,r,!i);try{await a.promise}catch{continue}a.responseResult&&!i&&(i=!0,s=a.responseResult),a.redirectResult&&!i&&(t=a.redirectResult)}return{url:t.url,headers:t.headers,response:s}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let i of this._responseInterceptors.slice()){let s=new xp(t,i);try{await s.promise}catch{continue}s.responseResult&&(t={...t,status:s.responseResult.status!==void 0?s.responseResult.status:t.status,headers:s.responseResult.headers!==void 0?s.responseResult.headers:t.headers,body:"body"in s.responseResult?s.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Yx(n){if(typeof n=="string")return"video";switch(n.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function hT(n){return typeof n=="object"&&n!==null&&n.type==="bplive"}var zx=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],Lp=class{constructor(){this._mediaElement=null;this._container=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new Gl;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=nu()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i)this._listeners.has(s)||this._listeners.set(s,new Set),this._listeners.get(s).add(t)}removeEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i){let r=this._listeners.get(s);r&&(r.delete(t),r.size===0&&this._listeners.delete(s))}}dispatch(e,t){let i=this._listeners.get(e);if(i)for(let s of i)try{s(t)}catch(r){console.error(`[PlayerCore] Error in event listener for "${e}":`,r)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,i){if(this._destroyed)return;let s=++this._loadGeneration,r=t??this._container,a=i??this._config;if(!r){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=r,a&&(this._config=a);let o=hT(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...o&&{contentType:o}}),this.dispatch("sourcechange",{source:e});try{let l=e,c=this._state.contentType,d,u,h;if(hT(e)){if(a!=null&&a.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new Vl(a.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let v=await this._bpLive.resolveSource(e);if(s!==this._loadGeneration)return;l=v.source,c=v.contentType,d=v.poster,u=v.videoWidth,h=v.videoHeight}let f=Yx(l),g=f==="nano"||f==="livekit"||c==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=f,this.updateState({providerType:f,contentType:c,streamType:g,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(f,l,a),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),r.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:d,videoWidth:u,videoHeight:h}}catch(l){if(s!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",l);let c={code:-1,message:l instanceof Error?l.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:c,connectionState:"failed"}),this.dispatch("error",c)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,i){switch(e){case"nano":{let s=document.createElement("nano-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=t;return s.libraryLocation=(i==null?void 0:i.libraryLocation)??"/vendor/bp-player",r.source?s.sourceConfig=r.source:r.streamid&&(s.streamid=r.streamid),i!=null&&i.nano&&(s.config=i.nano),s}case"livekit":{let s=document.createElement("livekit-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=t;return s.url=r.url,s.token=r.token,i!=null&&i.livekit&&(s.config=i.livekit),s}case"video":default:{let s=document.createElement("hls-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=typeof t=="string"?t:t.url;s.src=r;let a={...i==null?void 0:i.video},o=this._network,l=a.xhrSetup;return a.xhrSetup=async(c,d)=>{let u=d.includes(".m3u8")?"manifest":d.includes(".ts")||d.includes(".m4s")||d.includes(".fmp4")?"segment":"other",h=await o.intercept({url:d,method:"GET",type:u,headers:{}});h.url!==d&&c.open("GET",h.url,!0);for(let[f,m]of Object.entries(h.headers))c.setRequestHeader(f,m);l&&await l(c,h.url)},s.config=a,s}}}attachMediaElementListeners(e){for(let t of zx){let i=s=>this.handleMediaEvent(t,e,s);e.addEventListener(t,i),this._eventCleanup.push(()=>e.removeEventListener(t,i))}}attachActiveVideoElementForwarding(e){let t=i=>{let s=i.detail;this.dispatch("activevideoelementchange",{video:(s==null?void 0:s.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,i){var s,r,a,o;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:l}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:l}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let l=-1,c="Unknown error",d="none";i instanceof ErrorEvent&&i.error?(l=i.error.code??-1,c=i.error.message??i.message??"Unknown error",d="ErrorEvent"):t.error&&(l=t.error.code??-1,c=t.error.message??"Unknown error",d="element.error");let u=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(s=i.target)==null?void 0:s.tagName,source:d,code:l,message:c,eventIsErrorEvent:i instanceof ErrorEvent,eventErrorCode:i instanceof ErrorEvent?(r=i.error)==null?void 0:r.code:void 0,elementErrorCode:(a=t.error)==null?void 0:a.code,nativeElTag:u==null?void 0:u.tagName,nativeElErrorCode:(o=u==null?void 0:u.error)==null?void 0:o.code,nativeElSrc:u==null?void 0:u.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let h="media",f=!0;this._state.providerType==="nano"&&l>0?(h=Ap(l),f=h!=="offline"&&h!=="autoplay"):this._state.providerType==="livekit"&&l>0&&(h=Cp(l),f=!0);let m={code:l,message:c,fatal:f,category:h};this.updateState({error:m}),this.dispatch("error",m);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...nu(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"});let t=this._getFullscreenTarget();t&&(e&&!document.fullscreenElement?await t.requestFullscreen():!e&&document.fullscreenElement&&await document.exitFullscreen())}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){this._destroyed||(this._destroyed=!0,this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function Pp(){return new Lp}var Fa="bpPlayerObservedProperties";function wp(n){return Fa in n&&Array.isArray(n[Fa])}function Qx(n,e){class t extends n{get[Fa](){return e}}return t}function Xx(n){if(n.shadowRoot)return Array.from(n.shadowRoot.children);if(n.localName==="slot"){let t=n.assignedNodes();if(t.length>0)return t.filter(i=>i.nodeType===Node.ELEMENT_NODE)}return Array.from(n.children)}async function Ba(n,e,t){if(e!=null&&e.contains(n))return;n.nodeName.includes("-")&&!wp(n)&&(await Promise.resolve(),await customElements.whenDefined(n.nodeName.toLowerCase()),customElements.upgrade(n)),wp(n)&&t(n);let i=Xx(n);i.length>0&&await Promise.all(i.map(s=>Ba(s,e,t)))}function au(n,e,t){let i=n[Fa];i.includes("player")&&(n.player=e),i.includes("paused")&&(n.paused=t.paused),i.includes("playing")&&(n.playing=t.playing),i.includes("ended")&&(n.ended=t.ended),i.includes("seeking")&&(n.seeking=t.seeking),i.includes("currentTime")&&(n.currentTime=t.currentTime),i.includes("duration")&&(n.duration=t.duration),i.includes("volume")&&(n.volume=t.volume),i.includes("muted")&&(n.muted=t.muted),i.includes("playbackRate")&&(n.playbackRate=t.playbackRate),i.includes("readyState")&&(n.readyState=t.readyState),i.includes("videoWidth")&&(n.videoWidth=t.videoWidth),i.includes("videoHeight")&&(n.videoHeight=t.videoHeight),i.includes("qualities")&&(n.qualities=t.qualities),i.includes("currentQuality")&&(n.currentQuality=t.currentQuality),i.includes("targetQuality")&&(n.targetQuality=t.targetQuality),i.includes("fullscreen")&&(n.fullscreen=t.fullscreen),i.includes("presentationMode")&&(n.presentationMode=t.presentationMode),i.includes("connectionState")&&(n.connectionState=t.connectionState),i.includes("streamType")&&(n.streamType=t.streamType),i.includes("error")&&(n.error=t.error)}function ou(n){n[Fa].includes("player")&&(n.player=void 0)}var fT=`/**
7
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),iT=/'/g,nT=/"/g,oT=/^(?:script|style|textarea|title)$/i,_p=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),Fi=_p(1),SB=_p(2),_B=_p(3),Dr=Symbol.for("lit-noChange"),Dt=Symbol.for("lit-nothing"),sT=new WeakMap,Pr=wr.createTreeWalker(wr,129);function lT(n,e){if(!Sp(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return Zb!==void 0?Zb.createHTML(e):e}var Kx=(n,e)=>{let t=n.length-1,i=[],s,r=e===2?"<svg>":e===3?"<math>":"",a=Ol;for(let o=0;o<t;o++){let l=n[o],c,d,u=-1,h=0;for(;h<l.length&&(a.lastIndex=h,d=a.exec(l),d!==null);)h=a.lastIndex,a===Ol?d[1]==="!--"?a=eT:d[1]!==void 0?a=tT:d[2]!==void 0?(oT.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=Lr):d[3]!==void 0&&(a=Lr):a===Lr?d[0]===">"?(a=s??Ol,u=-1):d[1]===void 0?u=-2:(u=a.lastIndex-d[2].length,c=d[1],a=d[3]===void 0?Lr:d[3]==='"'?nT:iT):a===nT||a===iT?a=Lr:a===eT||a===tT?a=Ol:(a=Lr,s=void 0);let f=a===Lr&&n[o+1].startsWith("/>")?" ":"";r+=a===Ol?l+Hx:u>=0?(i.push(c),l.slice(0,u)+rT+l.slice(u)+xs+f):l+xs+(u===-2?o:f)}return[lT(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Bl=class n{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let r=0,a=0,o=e.length-1,l=this.parts,[c,d]=Kx(e,t);if(this.el=n.createElement(c,i),Pr.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Pr.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(let u of s.getAttributeNames())if(u.endsWith(rT)){let h=d[a++],f=s.getAttribute(u).split(xs),m=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:m[2],strings:f,ctor:m[1]==="."?yp:m[1]==="?"?Ep:m[1]==="@"?bp:Ua}),s.removeAttribute(u)}else u.startsWith(xs)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(oT.test(s.tagName)){let u=s.textContent.split(xs),h=u.length-1;if(h>0){s.textContent=tu?tu.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],Ul()),Pr.nextNode(),l.push({type:2,index:++r});s.append(u[h],Ul())}}}else if(s.nodeType===8)if(s.data===aT)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(xs,u+1))!==-1;)l.push({type:7,index:r}),u+=xs.length-1}r++}}static createElement(e,t){let i=wr.createElement("template");return i.innerHTML=e,i}};function Na(n,e,t=n,i){var a,o;if(e===Dr)return e;let s=i!==void 0?(a=t._$Co)==null?void 0:a[i]:t._$Cl,r=Fl(e)?void 0:e._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((o=s==null?void 0:s._$AO)==null||o.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,t,i)),i!==void 0?(t._$Co??(t._$Co=[]))[i]=s:t._$Cl=s),s!==void 0&&(e=Na(n,s._$AS(n,e.values),s,i)),e}var vp=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:i}=this._$AD,s=((e==null?void 0:e.creationScope)??wr).importNode(t,!0);Pr.currentNode=s;let r=Pr.nextNode(),a=0,o=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new $l(r,r.nextSibling,this,e):l.type===1?c=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(c=new Tp(r,this,e)),this._$AV.push(c),l=i[++o]}a!==(l==null?void 0:l.index)&&(r=Pr.nextNode(),a++)}return Pr.currentNode=wr,s}p(e){let t=0;for(let i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(e,i,t),t+=i.strings.length-2):i._$AI(e[t])),t++}},$l=class n{get _$AU(){var e;return((e=this._$AM)==null?void 0:e._$AU)??this._$Cv}constructor(e,t,i,s){this.type=2,this._$AH=Dt,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=i,this.options=s,this._$Cv=(s==null?void 0:s.isConnected)??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&(e==null?void 0:e.nodeType)===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Na(this,e,t),Fl(e)?e===Dt||e==null||e===""?(this._$AH!==Dt&&this._$AR(),this._$AH=Dt):e!==this._$AH&&e!==Dr&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):Gx(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Dt&&Fl(this._$AH)?this._$AA.nextSibling.data=e:this.T(wr.createTextNode(e)),this._$AH=e}$(e){var r;let{values:t,_$litType$:i}=e,s=typeof i=="number"?this._$AC(e):(i.el===void 0&&(i.el=Bl.createElement(lT(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(t);else{let a=new vp(s,this),o=a.u(this.options);a.p(t),this.T(o),this._$AH=a}}_$AC(e){let t=sT.get(e.strings);return t===void 0&&sT.set(e.strings,t=new Bl(e)),t}k(e){Sp(this._$AH)||(this._$AH=[],this._$AR());let t=this._$AH,i,s=0;for(let r of e)s===t.length?t.push(i=new n(this.O(Ul()),this.O(Ul()),this,this.options)):i=t[s],i._$AI(r),s++;s<t.length&&(this._$AR(i&&i._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,t);e!==this._$AB;){let s=Jb(e).nextSibling;Jb(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Ua=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Dt,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Dt}_$AI(e,t=this,i,s){let r=this.strings,a=!1;if(r===void 0)e=Na(this,e,t,0),a=!Fl(e)||e!==this._$AH&&e!==Dr,a&&(this._$AH=e);else{let o=e,l,c;for(e=r[0],l=0;l<r.length-1;l++)c=Na(this,o[i+l],t,l),c===Dr&&(c=this._$AH[l]),a||(a=!Fl(c)||c!==this._$AH[l]),c===Dt?e=Dt:e!==Dt&&(e+=(c??"")+r[l+1]),this._$AH[l]=c}a&&!s&&this.j(e)}j(e){e===Dt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},yp=class extends Ua{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Dt?void 0:e}},Ep=class extends Ua{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Dt)}},bp=class extends Ua{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=Na(this,e,t,0)??Dt)===Dr)return;let i=this._$AH,s=e===Dt&&i!==Dt||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Dt&&(i===Dt||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t;typeof this._$AH=="function"?this._$AH.call(((t=this.options)==null?void 0:t.host)??this.element,e):this._$AH.handleEvent(e)}},Tp=class{constructor(e,t,i){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(e){Na(this,e)}};var gp=Nl.litHtmlPolyfillSupport;gp==null||gp(Bl,$l),(Nl.litHtmlVersions??(Nl.litHtmlVersions=[])).push("3.3.2");var cT=(n,e,t)=>{let i=(t==null?void 0:t.renderBefore)??e,s=i._$litPart$;if(s===void 0){let r=(t==null?void 0:t.renderBefore)??null;i._$litPart$=s=new $l(e.insertBefore(Ul(),r),r,void 0,t??{})}return s._$AI(n),s};var Mr=globalThis,ci=class extends ns{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t;let e=super.createRenderRoot();return(t=this.renderOptions).renderBefore??(t.renderBefore=e.firstChild),e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=cT(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),(e=this._$Do)==null||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),(e=this._$Do)==null||e.setConnected(!1)}render(){return Dr}},dT;ci._$litElement$=!0,ci.finalized=!0,(dT=Mr.litElementHydrateSupport)==null||dT.call(Mr,{LitElement:ci});var kp=Mr.litElementPolyfillSupport;kp==null||kp({LitElement:ci});(Mr.litElementVersions??(Mr.litElementVersions=[])).push("4.2.2");var Ls=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};var Wx={attribute:!0,type:String,converter:Ml,reflect:!1,hasChanged:eu},qx=(n=Wx,e,t)=>{let{kind:i,metadata:s}=t,r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),i==="setter"&&((n=Object.create(n)).wrapped=!0),r.set(t.name,n),i==="accessor"){let{name:a}=t;return{set(o){let l=e.get.call(this);e.set.call(this,o),this.requestUpdate(a,l,n,!0,o)},init(o){return o!==void 0&&this.C(a,void 0,n,o),o}}}if(i==="setter"){let{name:a}=t;return function(o){let l=this[a];e.call(this,o),this.requestUpdate(a,l,n,!0,o)}}throw Error("Unsupported decorator location: "+i)};function Be(n){return(e,t)=>typeof t=="object"?qx(n,e,t):((i,s,r)=>{let a=s.hasOwnProperty(r);return s.constructor.createProperty(r,i),a?Object.getOwnPropertyDescriptor(s,r):void 0})(n,e,t)}function Ps(n){return Be({...n,state:!0,attribute:!1})}var jx=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Ap(n){return n===1005||n===1007||n===1009?"autoplay":n>=2001&&n<=2004?"offline":n>=3e3&&n<=3999?"media":n>=4900&&n<=4999?"security":n>=4e3&&n<=4899?"network":n>=5e3&&n<=5999?"setup":n>=1e3&&n<=1999?"media":"unknown"}function Cp(n){return n===4e3||n===4001?"network":"unknown"}function nu(){return{paused:!0,playing:!1,ended:!1,seeking:!1,waiting:!1,currentTime:0,duration:NaN,buffered:null,volume:1,muted:!1,loop:!1,playbackRate:1,readyState:0,videoWidth:0,videoHeight:0,qualities:[],currentQuality:null,targetQuality:null,fullscreen:!1,presentationMode:"inline",providerType:null,connectionState:"idle",streamType:"vod",contentType:"video",error:null}}function su(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"streamId"in n}function ru(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"clipId"in n}function Ip(n){return su(n)||ru(n)}var Tn=class extends Error{constructor(t,i,s){super(t);this.code=i;this.status=s;this.name="BPLiveError"}},Vl=class{constructor(e,t){this._authToken=null;this._stream=null;this._clip=null;this._config=e,this._authToken=e.authToken??null,this._network=t??null}get config(){return this._config}get authToken(){return this._authToken}get stream(){return this._stream}get clip(){return this._clip}async fetch(e){if(!this._authToken)throw new Tn("No auth token provided. Ensure config.bpLive.authToken is set before loading a BPLive source.","AUTH_REQUIRED");let t=`${this._config.discoveryUrl}${e}`,i={"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${this._authToken}`};if(this._network){let a=await this._network.intercept({url:t,method:"GET",type:"api",headers:i});if(a.response)return a.response.body;t=a.url,i=a.headers}let s=new AbortController,r=setTimeout(()=>s.abort(),3e4);try{let a=await fetch(t,{method:"GET",headers:i,signal:s.signal});if(!a.ok)throw new Tn(`HTTP ${a.status}: ${a.statusText}`,"HTTP_ERROR",a.status);let o=await a.json();return this._network&&(o=(await this._network.interceptResponse({url:t,status:a.status,headers:Object.fromEntries(a.headers),body:o})).body),o}catch(a){throw a instanceof Error&&a.name==="AbortError"?new Tn("Request timeout after 30s","TIMEOUT"):a}finally{clearTimeout(r)}}async getStream(e){return this.fetch(`/streams/${e}`)}async getClip(e){return this.fetch(`/clips/${e}`)}mapPlayerSourceToResolvedSource(e){if(e.provider==="livekit")return{type:"livekit",url:e.url,token:e.token,room:e.room};if(e.provider==="nanoplayer"){let{provider:t,...i}=e;return{type:"nano",source:i}}throw new Tn(`Unknown player source provider: ${e.provider}`,"UNKNOWN_PROVIDER")}selectClipMedia(e,t="landscape"){let i=e.filter(o=>o.type==="clip");if(i.length===0)return null;let s=i.find(o=>o.orientation===t);if(s)return s;let r=t==="landscape"?"portrait":"landscape",a=i.find(o=>o.orientation===r);return a||i[0]}mapClipMediaToPlayerSource(e){return{type:"video",url:e.url}}async resolveSource(e){if(this._stream=null,this._clip=null,su(e))return this.resolveStreamSource(e);if(ru(e))return this.resolveClipSource(e);throw new Tn("Invalid BPLive source","INVALID_SOURCE")}extractStreamPoster(e){var t;return e.cover_photo??((t=e.channel)==null?void 0:t.cover_image)??void 0}async resolveStreamSource(e){var o,l,c,d,u,h,f,m,p;let i=(await this.getStream(e.streamId)).data;this._stream=i;let s=this.extractStreamPoster(i);if(!!i.ended_at&&((l=(o=i.media)==null?void 0:o.vod)==null?void 0:l.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(c=g.dimension)==null?void 0:c.width,videoHeight:(d=g.dimension)==null?void 0:d.height}}let a=i.player_source??((u=i.active_stream)==null?void 0:u.player_source);if(a)return{source:this.mapPlayerSourceToResolvedSource(a),contentType:"stream",poster:s};if(((f=(h=i.media)==null?void 0:h.vod)==null?void 0:f.length)>0){let g=i.media.vod[0];return{source:{type:"video",url:g.original},contentType:"video",poster:s??g.thumb??void 0,videoWidth:(m=g.dimension)==null?void 0:m.width,videoHeight:(p=g.dimension)==null?void 0:p.height}}throw new Tn("Stream is not live and has no VOD content","STREAM_OFFLINE")}async resolveClipSource(e){let i=(await this.getClip(e.clipId)).data;this._clip=i;let s=this.selectClipMedia(i.media,e.preferredOrientation);if(!s)throw new Tn("No playable media found in clip","NO_MEDIA");return{source:this.mapClipMediaToPlayerSource(s),contentType:"clip",poster:s.thumbnail??void 0,videoWidth:s.width,videoHeight:s.height}}destroy(){this._authToken=null,this._stream=null,this._clip=null}};function Hl(n){return n!=null&&typeof n.then=="function"}function uT(n){return new Promise((e,t)=>{let i=!1,s=r=>{i||(i=!0,r?t(r):e())};try{let r=n(s);Hl(r)&&(i=!0,r.then(()=>e(),t))}catch(r){s(r)}})}var Rp=class{constructor(e,t,i){this._closed=!1;this._pendingCount=0;this._firstError=null;this._redirectResult=null;this._responseResult=null;this.promise=new Promise((s,r)=>{this._resolve=s,this._reject=r}),this._state=e,this._interceptor=t,this._canModify=i,this._start()}get redirectResult(){return this._redirectResult}get responseResult(){return this._responseResult}get _open(){return this._canModify&&!this._closed}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Hl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get method(){return e._state.method},get type(){return e._state.type},get headers(){return{...e._state.headers}},get closed(){return!e._open},redirect(t){e._redirect(t)},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_redirect(e){if(!this._open)throw new Error("Request is closed");let t=typeof e=="string"?{url:e}:e;this._redirectResult={url:t.url??this._state.url,method:t.method??this._state.method,type:this._state.type,headers:t.headers??{...this._state.headers}},this._close()}_respondWith(e){if(!this._open)throw new Error("Request is closed");this._responseResult=e,this._close()}_waitUntil(e){if(!this._open)throw new Error("Request is closed");Hl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(uT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},xp=class{constructor(e,t){this._closed=!1;this._pendingCount=0;this._firstError=null;this._responseResult=null;this.promise=new Promise((i,s)=>{this._resolve=i,this._reject=s}),this._state=e,this._interceptor=t,this._start()}get responseResult(){return this._responseResult}_close(){this._closed=!0,this._resolve()}_error(e){this._closed=!0,this._reject(e)}_start(){try{let e=this._interceptor(this._createFacade());Hl(e)?this._handleWaitUntil(e):!this._pendingCount&&!this._closed&&this._close()}catch(e){this._error(e)}}_createFacade(){let e=this;return{get url(){return e._state.url},get status(){return e._state.status},get headers(){return{...e._state.headers}},get body(){return e._state.body},get closed(){return e._closed},respondWith(t){e._respondWith(t)},waitUntil(t){e._waitUntil(t)}}}_respondWith(e){if(this._closed)throw new Error("Response is closed");this._responseResult=e,this._close()}_waitUntil(e){if(this._closed)throw new Error("Response is closed");Hl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(uT(e))}async _handleWaitUntil(e){this._pendingCount++;try{await e}catch(t){this._firstError||(this._firstError=t)}this._pendingCount--,!this._pendingCount&&!this._closed&&(this._firstError?this._error(this._firstError):this._close())}},Gl=class{constructor(){this._requestInterceptors=[];this._responseInterceptors=[]}addRequestInterceptor(e){this._requestInterceptors.unshift(e)}removeRequestInterceptor(e){let t=this._requestInterceptors.indexOf(e);t>=0&&this._requestInterceptors.splice(t,1)}addResponseInterceptor(e){this._responseInterceptors.unshift(e)}removeResponseInterceptor(e){let t=this._responseInterceptors.indexOf(e);t>=0&&this._responseInterceptors.splice(t,1)}async intercept(e){let t={...e,headers:{...e.headers}},i=!1,s=null;for(let r of this._requestInterceptors.slice()){let a=new Rp(t,r,!i);try{await a.promise}catch{continue}a.responseResult&&!i&&(i=!0,s=a.responseResult),a.redirectResult&&!i&&(t=a.redirectResult)}return{url:t.url,headers:t.headers,response:s}}async interceptResponse(e){let t={...e,headers:{...e.headers}};for(let i of this._responseInterceptors.slice()){let s=new xp(t,i);try{await s.promise}catch{continue}s.responseResult&&(t={...t,status:s.responseResult.status!==void 0?s.responseResult.status:t.status,headers:s.responseResult.headers!==void 0?s.responseResult.headers:t.headers,body:"body"in s.responseResult?s.responseResult.body:t.body})}return{status:t.status,headers:t.headers,body:t.body}}};function Yx(n){if(typeof n=="string")return"video";switch(n.type){case"video":return"video";case"nano":return"nano";case"livekit":return"livekit";default:return"video"}}function hT(n){return typeof n=="object"&&n!==null&&n.type==="bplive"}var zx=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],Lp=class{constructor(){this._mediaElement=null;this._container=null;this._webkitFullscreen=null;this._listeners=new Map;this._eventCleanup=[];this._destroyed=!1;this._bpLive=null;this._network=new Gl;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._state=nu()}get state(){return this._state}get videoElement(){return this._mediaElement}get activeVideoElement(){let e=this._mediaElement;return(e==null?void 0:e.activeVideoElement)??null}get bpLive(){return this._bpLive}get network(){return this._network}get ready(){return this._ready}get providerType(){return this._currentProviderType}addEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i)this._listeners.has(s)||this._listeners.set(s,new Set),this._listeners.get(s).add(t)}removeEventListener(e,t){let i=Array.isArray(e)?e:[e];for(let s of i){let r=this._listeners.get(s);r&&(r.delete(t),r.size===0&&this._listeners.delete(s))}}dispatch(e,t){let i=this._listeners.get(e);if(i)for(let s of i)try{s(t)}catch(r){console.error(`[PlayerCore] Error in event listener for "${e}":`,r)}}updateState(e){this._state={...this._state,...e},this.dispatch("statechange",{state:this._state})}attach(e,t){this._destroyed||(this._container=e,this._config=t,this._ready=!0)}async loadSource(e,t,i){if(this._destroyed)return;let s=++this._loadGeneration,r=t??this._container,a=i??this._config;if(!r){console.error("[PlayerCore] No container provided. Call attach() first or provide container to loadSource().");return}this._container=r,a&&(this._config=a);let o=hT(e)?"clipId"in e?"clip":"stream":void 0;this.updateState({error:null,connectionState:"connecting",ended:!1,...o&&{contentType:o}}),this.dispatch("sourcechange",{source:e});try{let l=e,c=this._state.contentType,d,u,h;if(hT(e)){if(a!=null&&a.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new Vl(a.bpLive,this._network)),!this._bpLive)throw new Error("BPLive source requires config.bpLive configuration.");let v=await this._bpLive.resolveSource(e);if(s!==this._loadGeneration)return;l=v.source,c=v.contentType,d=v.poster,u=v.videoWidth,h=v.videoHeight}let f=Yx(l),g=f==="nano"||f==="livekit"||c==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._currentProviderType=f,this.updateState({providerType:f,contentType:c,streamType:g,paused:!0,playing:!1,waiting:!1,seeking:!1,readyState:0,currentTime:0,duration:NaN,buffered:null}),this._mediaElement=this.createMediaElement(f,l,a),this._mediaElement.style.width="100%",this._mediaElement.style.height="100%",this._mediaElement.style.objectFit="contain",this._state.muted&&(this._mediaElement.muted=!0),this._state.loop&&(this._mediaElement.loop=!0),this.attachMediaElementListeners(this._mediaElement),this.attachActiveVideoElementForwarding(this._mediaElement),r.appendChild(this._mediaElement),this._ready=!0,this.dispatch("videoelementchange",{video:this._mediaElement}),this.dispatch("activevideoelementchange",{video:this.activeVideoElement}),{poster:d,videoWidth:u,videoHeight:h}}catch(l){if(s!==this._loadGeneration)return;console.error("[PlayerCore] loadSource error:",l);let c={code:-1,message:l instanceof Error?l.message:"Failed to load source",fatal:!0,category:"setup"};this.updateState({error:c,connectionState:"failed"}),this.dispatch("error",c)}}destroyMediaElement(){if(this._eventCleanup.forEach(e=>e()),this._eventCleanup=[],this._mediaElement&&(this._mediaElement.remove(),this._mediaElement=null,this.dispatch("emptied",void 0),this.dispatch("videoelementchange",{video:null}),this.dispatch("activevideoelementchange",{video:null})),this._container)for(;this._container.firstChild;)this._container.removeChild(this._container.firstChild)}createMediaElement(e,t,i){switch(e){case"nano":{let s=document.createElement("nano-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=t;return s.libraryLocation=(i==null?void 0:i.libraryLocation)??"/vendor/bp-player",r.source?s.sourceConfig=r.source:r.streamid&&(s.streamid=r.streamid),i!=null&&i.nano&&(s.config=i.nano),s}case"livekit":{let s=document.createElement("livekit-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=t;return s.url=r.url,s.token=r.token,i!=null&&i.livekit&&(s.config=i.livekit),s}case"video":default:{let s=document.createElement("hls-video");s.setAttribute("playsinline",""),s.setAttribute("webkit-playsinline","");let r=typeof t=="string"?t:t.url;s.src=r;let a={...i==null?void 0:i.video},o=this._network,l=a.xhrSetup;return a.xhrSetup=async(c,d)=>{let u=d.includes(".m3u8")?"manifest":d.includes(".ts")||d.includes(".m4s")||d.includes(".fmp4")?"segment":"other",h=await o.intercept({url:d,method:"GET",type:u,headers:{}});h.url!==d&&c.open("GET",h.url,!0);for(let[f,m]of Object.entries(h.headers))c.setRequestHeader(f,m);l&&await l(c,h.url)},s.config=a,s}}}attachMediaElementListeners(e){for(let t of zx){let i=s=>this.handleMediaEvent(t,e,s);e.addEventListener(t,i),this._eventCleanup.push(()=>e.removeEventListener(t,i))}}attachActiveVideoElementForwarding(e){let t=i=>{let s=i.detail;this.dispatch("activevideoelementchange",{video:(s==null?void 0:s.video)??null})};e.addEventListener("activevideoelementchange",t),this._eventCleanup.push(()=>e.removeEventListener("activevideoelementchange",t))}handleMediaEvent(e,t,i){var s,r,a,o;switch(e){case"loadstart":this.updateState({readyState:1}),this.dispatch("loadstart",void 0);break;case"loadedmetadata":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight,streamType:l}),this.dispatch("loadedmetadata",{duration:t.duration,videoWidth:t.videoWidth,videoHeight:t.videoHeight});break}case"loadeddata":this.updateState({readyState:2}),this.dispatch("loadeddata",void 0);break;case"canplay":this.updateState({readyState:3,connectionState:"connected"}),this.dispatch("canplay",void 0),this.dispatch("connectionstatechange",{state:"connected"});break;case"canplaythrough":this.updateState({readyState:4}),this.dispatch("canplaythrough",void 0);break;case"play":this.updateState({paused:!1,ended:!1}),this.dispatch("play",void 0);break;case"playing":this.updateState({paused:!1,playing:!0,ended:!1,waiting:!1,readyState:4}),this.dispatch("playing",void 0);break;case"pause":this.updateState({paused:!0,playing:!1,waiting:!1}),this.dispatch("pause",void 0);break;case"waiting":this.updateState({playing:!1,waiting:!0,readyState:2}),this.dispatch("waiting",void 0);break;case"seeking":this.updateState({seeking:!0,currentTime:t.currentTime}),this.dispatch("seeking",{currentTime:t.currentTime});break;case"seeked":this.updateState({seeking:!1,currentTime:t.currentTime}),this.dispatch("seeked",{currentTime:t.currentTime});break;case"timeupdate":this.updateState({currentTime:t.currentTime,duration:t.duration}),this.dispatch("timeupdate",{currentTime:t.currentTime,duration:t.duration});break;case"durationchange":{let l=t.duration===1/0?"live":this._state.streamType;this.updateState({duration:t.duration,streamType:l}),this.dispatch("durationchange",{duration:t.duration}),this.dispatch("streamtypechange",{streamType:this._state.streamType});break}case"ratechange":this.updateState({playbackRate:t.playbackRate}),this.dispatch("ratechange",{playbackRate:t.playbackRate});break;case"volumechange":this.updateState({volume:t.volume,muted:t.muted}),this.dispatch("volumechange",{volume:t.volume,muted:t.muted});break;case"ended":this.updateState({ended:!0,paused:!0,playing:!1}),this.dispatch("ended",void 0);break;case"progress":this.updateState({buffered:t.buffered}),this.dispatch("progress",{buffered:t.buffered});break;case"error":{let l=-1,c="Unknown error",d="none";i instanceof ErrorEvent&&i.error?(l=i.error.code??-1,c=i.error.message??i.message??"Unknown error",d="ErrorEvent"):t.error&&(l=t.error.code??-1,c=t.error.message??"Unknown error",d="element.error");let u=t.nativeEl;console.error("[PlayerCore] error event",{providerType:this._state.providerType,elementTag:t.tagName,eventTarget:(s=i.target)==null?void 0:s.tagName,source:d,code:l,message:c,eventIsErrorEvent:i instanceof ErrorEvent,eventErrorCode:i instanceof ErrorEvent?(r=i.error)==null?void 0:r.code:void 0,elementErrorCode:(a=t.error)==null?void 0:a.code,nativeElTag:u==null?void 0:u.tagName,nativeElErrorCode:(o=u==null?void 0:u.error)==null?void 0:o.code,nativeElSrc:u==null?void 0:u.currentSrc,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState});let h="media",f=!0;this._state.providerType==="nano"&&l>0?(h=Ap(l),f=h!=="offline"&&h!=="autoplay"):this._state.providerType==="livekit"&&l>0&&(h=Cp(l),f=!0);let m={code:l,message:c,fatal:f,category:h};this.updateState({error:m}),this.dispatch("error",m);break}case"resize":t.videoWidth&&t.videoHeight&&(this.updateState({videoWidth:t.videoWidth,videoHeight:t.videoHeight}),this.dispatch("resize",{videoWidth:t.videoWidth,videoHeight:t.videoHeight}));break}}unloadSource(){this.destroyMediaElement(),this._currentProviderType=null,this.updateState({...nu(),volume:this._state.volume,muted:this._state.muted,loop:this._state.loop,playbackRate:this._state.playbackRate}),this.dispatch("sourcechange",{source:null})}async play(){if(this._mediaElement){this.updateState({paused:!1});try{await this._mediaElement.play()}catch(e){throw this.updateState({paused:!0}),e}}}pause(){this._mediaElement&&(this.updateState({paused:!0,playing:!1}),this._mediaElement.pause())}seek(e){this._mediaElement&&(this._mediaElement.currentTime=e)}setVolume(e){let t=Math.max(0,Math.min(1,e));this.updateState({volume:t}),this._mediaElement&&(this._mediaElement.volume=t),this.dispatch("volumechange",{volume:t,muted:this._state.muted})}setMuted(e){this.updateState({muted:e}),this._mediaElement&&(this._mediaElement.muted=e),this.dispatch("volumechange",{volume:this._state.volume,muted:e})}setLoop(e){this.updateState({loop:e}),this._mediaElement&&(this._mediaElement.loop=e)}setPlaybackRate(e){this.updateState({playbackRate:e}),this._mediaElement&&(this._mediaElement.playbackRate=e),this.dispatch("ratechange",{playbackRate:e})}setTargetQuality(e){this.updateState({targetQuality:e}),this.dispatch("targetqualitychanged",{quality:e});let t=this._mediaElement;t!=null&&t.videoRenditions&&(t.videoRenditions.selectedIndex=(e==null?void 0:e.index)??-1)}setQuality(e){this.setTargetQuality(e)}_getFullscreenTarget(){return this._container?this._container.closest("media-controller")??this._container.parentElement:null}async setFullscreen(e){var t;if(this._applyFullscreenState(e),e){let i=this._getFullscreenTarget();if(!i){this._applyFullscreenState(!1);return}if(document.fullscreenElement){document.fullscreenElement!==i&&this._applyFullscreenState(!1);return}if(typeof i.requestFullscreen=="function")try{await i.requestFullscreen()}catch(s){throw this._applyFullscreenState(!1),s}else this._enterWebkitVideoFullscreen()}else if(document.fullscreenElement)await document.exitFullscreen();else{let i=this._webkitFullscreen,s=(i==null?void 0:i.video)??this.activeVideoElement;s!=null&&s.webkitDisplayingFullscreen&&(i==null||i.disarm(),(t=s.webkitExitFullscreen)==null||t.call(s))}}_applyFullscreenState(e){this.updateState({fullscreen:e,presentationMode:e?"fullscreen":"inline"}),this.dispatch("fullscreenchange",{fullscreen:e}),this.dispatch("presentationmodechange",{mode:e?"fullscreen":"inline"})}_enterWebkitVideoFullscreen(){var s;let e=this.activeVideoElement;if(!(e!=null&&e.webkitEnterFullscreen)){this._applyFullscreenState(!1);return}(s=this._webkitFullscreen)==null||s.disarm();let t=()=>{this._webkitFullscreen=null,this._applyFullscreenState(!1)};e.addEventListener("webkitendfullscreen",t,{once:!0});let i={video:e,disarm:()=>{this._webkitFullscreen=null,e.removeEventListener("webkitendfullscreen",t)}};if(this._webkitFullscreen=i,!e.webkitDisplayingFullscreen)try{e.webkitEnterFullscreen()}catch(r){throw i.disarm(),this._applyFullscreenState(!1),r}}setPresentationMode(e){this.updateState({presentationMode:e,fullscreen:e==="fullscreen"}),this.dispatch("presentationmodechange",{mode:e})}destroy(){var e;this._destroyed||(this._destroyed=!0,(e=this._webkitFullscreen)==null||e.disarm(),this.unloadSource(),this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function Pp(){return new Lp}var Fa="bpPlayerObservedProperties";function wp(n){return Fa in n&&Array.isArray(n[Fa])}function Qx(n,e){class t extends n{get[Fa](){return e}}return t}function Xx(n){if(n.shadowRoot)return Array.from(n.shadowRoot.children);if(n.localName==="slot"){let t=n.assignedNodes();if(t.length>0)return t.filter(i=>i.nodeType===Node.ELEMENT_NODE)}return Array.from(n.children)}async function Ba(n,e,t){if(e!=null&&e.contains(n))return;n.nodeName.includes("-")&&!wp(n)&&(await Promise.resolve(),await customElements.whenDefined(n.nodeName.toLowerCase()),customElements.upgrade(n)),wp(n)&&t(n);let i=Xx(n);i.length>0&&await Promise.all(i.map(s=>Ba(s,e,t)))}function au(n,e,t){let i=n[Fa];i.includes("player")&&(n.player=e),i.includes("paused")&&(n.paused=t.paused),i.includes("playing")&&(n.playing=t.playing),i.includes("ended")&&(n.ended=t.ended),i.includes("seeking")&&(n.seeking=t.seeking),i.includes("currentTime")&&(n.currentTime=t.currentTime),i.includes("duration")&&(n.duration=t.duration),i.includes("volume")&&(n.volume=t.volume),i.includes("muted")&&(n.muted=t.muted),i.includes("playbackRate")&&(n.playbackRate=t.playbackRate),i.includes("readyState")&&(n.readyState=t.readyState),i.includes("videoWidth")&&(n.videoWidth=t.videoWidth),i.includes("videoHeight")&&(n.videoHeight=t.videoHeight),i.includes("qualities")&&(n.qualities=t.qualities),i.includes("currentQuality")&&(n.currentQuality=t.currentQuality),i.includes("targetQuality")&&(n.targetQuality=t.targetQuality),i.includes("fullscreen")&&(n.fullscreen=t.fullscreen),i.includes("presentationMode")&&(n.presentationMode=t.presentationMode),i.includes("connectionState")&&(n.connectionState=t.connectionState),i.includes("streamType")&&(n.streamType=t.streamType),i.includes("error")&&(n.error=t.error)}function ou(n){n[Fa].includes("player")&&(n.player=void 0)}var fT=`/**
8
8
  * BP Player CSS Custom Properties
9
9
  *
10
10
  * All styling can be customized by overriding these CSS variables.
@@ -153,6 +153,7 @@ export declare class PlayerCoreImpl implements PlayerCore {
153
153
  private _state;
154
154
  private _mediaElement;
155
155
  private _container;
156
+ private _webkitFullscreen;
156
157
  private _config;
157
158
  private _listeners;
158
159
  private _eventCleanup;
@@ -196,6 +197,8 @@ export declare class PlayerCoreImpl implements PlayerCore {
196
197
  setQuality(quality: QualityLevel | null): void;
197
198
  private _getFullscreenTarget;
198
199
  setFullscreen(fullscreen: boolean): Promise<void>;
200
+ private _applyFullscreenState;
201
+ private _enterWebkitVideoFullscreen;
199
202
  setPresentationMode(mode: PresentationMode): void;
200
203
  destroy(): void;
201
204
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@broadcastingplatforms/player",
3
- "version": "1.4.9",
3
+ "version": "1.5.0",
4
4
  "description": "Universal video player web component built with Lit",
5
5
  "type": "module",
6
6
  "main": "dist/bp-player.js",