@broadcastingplatforms/player 1.5.2 → 1.5.7
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 +43 -18
- package/dist/bp-player.mjs +43 -18
- package/dist/bp-player.standalone.mjs +35 -10
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* BP Player (v1.5.
|
|
2
|
+
* BP Player (v1.5.7)
|
|
3
3
|
* Universal video player web component
|
|
4
4
|
*/
|
|
5
5
|
var Yb=Object.defineProperty;var Mx=Object.getOwnPropertyDescriptor;var Ox=Object.getPrototypeOf;var Nx=Reflect.get;var zb=n=>{throw TypeError(n)};var Ux=(n,e,t)=>e in n?Yb(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?Mx(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&&Yb(e,t,s),s};var we=(n,e,t)=>Ux(n,typeof e!="symbol"?e+"":e,t),hp=(n,e,t)=>e.has(n)||zb("Cannot "+t);var x=(n,e,t)=>(hp(n,e,"read from private field"),t?t.call(n):e.get(n)),ie=(n,e,t)=>e.has(n)?zb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),F=(n,e,t,i)=>(hp(n,e,"write to private field"),i?i.call(n,t):e.set(n,t),t),oe=(n,e,t)=>(hp(n,e,"access private method"),t);var fp=(n,e,t)=>Nx(Ox(n),t,e);var eu=globalThis,tu=eu.ShadowRoot&&(eu.ShadyCSS===void 0||eu.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,mp=Symbol(),Qb=new WeakMap,Dl=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==mp)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(tu&&e===void 0){let i=t!==void 0&&t.length===1;i&&(e=Qb.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&Qb.set(t,e))}return e}toString(){return this.cssText}},Xb=n=>new Dl(typeof n=="string"?n:n+"",void 0,mp),Ml=(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 Dl(t,n,mp)},Jb=(n,e)=>{if(tu)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(let t of e){let i=document.createElement("style"),s=eu.litNonce;s!==void 0&&i.setAttribute("nonce",s),i.textContent=t.cssText,n.appendChild(i)}},pp=tu?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(let i of e.cssRules)t+=i.cssText;return Xb(t)})(n):n;var{is:Fx,defineProperty:Bx,getOwnPropertyDescriptor:$x,getOwnPropertyNames:Vx,getOwnPropertySymbols:Hx,getPrototypeOf:Gx}=Object,xs=globalThis,Zb=xs.trustedTypes,Kx=Zb?Zb.emptyScript:"",gp=xs.reactiveElementPolyfillSupport,Ol=(n,e)=>n,Nl={toAttribute(n,e){switch(e){case Boolean:n=n?Kx: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}},iu=(n,e)=>!Fx(n,e),eT={attribute:!0,type:String,converter:Nl,reflect:!1,useDefault:!1,hasChanged:iu};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),xs.litPropertyMetadata??(xs.litPropertyMetadata=new WeakMap);var ss=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=eT){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&&Bx(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){let{get:s,set:r}=$x(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)??eT}static _$Ei(){if(this.hasOwnProperty(Ol("elementProperties")))return;let e=Gx(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Ol("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Ol("properties"))){let t=this.properties,i=[...Vx(t),...Hx(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(pp(s))}else e!==void 0&&t.push(pp(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 Jb(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:Nl).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:Nl;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??iu)(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){}};ss.elementStyles=[],ss.shadowRootOptions={mode:"open"},ss[Ol("elementProperties")]=new Map,ss[Ol("finalized")]=new Map,gp==null||gp({ReactiveElement:ss}),(xs.reactiveElementVersions??(xs.reactiveElementVersions=[])).push("2.1.2");var Fl=globalThis,tT=n=>n,nu=Fl.trustedTypes,iT=nu?nu.createPolicy("lit-html",{createHTML:n=>n}):void 0,lT="$lit$",Ls=`lit$${Math.random().toFixed(9).slice(2)}$`,cT="?"+Ls,Wx=`<${cT}>`,Mr=document,Bl=()=>Mr.createComment(""),$l=n=>n===null||typeof n!="object"&&typeof n!="function",kp=Array.isArray,qx=n=>kp(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",vp=`[
|
|
6
6
|
\f\r]`,Ul=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nT=/-->/g,sT=/>/g,wr=RegExp(`>|${vp}(?:([^\\s"'>=/]+)(${vp}*=${vp}*(?:[^
|
|
7
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),rT=/'/g,aT=/"/g,dT=/^(?:script|style|textarea|title)$/i,Ap=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),Bi=Ap(1),IB=Ap(2),RB=Ap(3),Or=Symbol.for("lit-noChange"),Mt=Symbol.for("lit-nothing"),oT=new WeakMap,Dr=Mr.createTreeWalker(Mr,129);function uT(n,e){if(!kp(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return iT!==void 0?iT.createHTML(e):e}var jx=(n,e)=>{let t=n.length-1,i=[],s,r=e===2?"<svg>":e===3?"<math>":"",a=Ul;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===Ul?d[1]==="!--"?a=nT:d[1]!==void 0?a=sT:d[2]!==void 0?(dT.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=wr):d[3]!==void 0&&(a=wr):a===wr?d[0]===">"?(a=s??Ul,u=-1):d[1]===void 0?u=-2:(u=a.lastIndex-d[2].length,c=d[1],a=d[3]===void 0?wr:d[3]==='"'?aT:rT):a===aT||a===rT?a=wr:a===nT||a===sT?a=Ul:(a=wr,s=void 0);let f=a===wr&&n[o+1].startsWith("/>")?" ":"";r+=a===Ul?l+Wx:u>=0?(i.push(c),l.slice(0,u)+lT+l.slice(u)+Ls+f):l+Ls+(u===-2?o:f)}return[uT(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Vl=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]=jx(e,t);if(this.el=n.createElement(c,i),Dr.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Dr.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(let u of s.getAttributeNames())if(u.endsWith(lT)){let h=d[a++],f=s.getAttribute(u).split(Ls),m=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:m[2],strings:f,ctor:m[1]==="."?bp:m[1]==="?"?Tp:m[1]==="@"?Sp:Ba}),s.removeAttribute(u)}else u.startsWith(Ls)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(dT.test(s.tagName)){let u=s.textContent.split(Ls),h=u.length-1;if(h>0){s.textContent=nu?nu.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],Bl()),Dr.nextNode(),l.push({type:2,index:++r});s.append(u[h],Bl())}}}else if(s.nodeType===8)if(s.data===cT)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(Ls,u+1))!==-1;)l.push({type:7,index:r}),u+=Ls.length-1}r++}}static createElement(e,t){let i=Mr.createElement("template");return i.innerHTML=e,i}};function Fa(n,e,t=n,i){var a,o;if(e===Or)return e;let s=i!==void 0?(a=t._$Co)==null?void 0:a[i]:t._$Cl,r=$l(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=Fa(n,s._$AS(n,e.values),s,i)),e}var Ep=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)??Mr).importNode(t,!0);Dr.currentNode=s;let r=Dr.nextNode(),a=0,o=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new Hl(r,r.nextSibling,this,e):l.type===1?c=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(c=new _p(r,this,e)),this._$AV.push(c),l=i[++o]}a!==(l==null?void 0:l.index)&&(r=Dr.nextNode(),a++)}return Dr.currentNode=Mr,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++}},Hl=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=Mt,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=Fa(this,e,t),$l(e)?e===Mt||e==null||e===""?(this._$AH!==Mt&&this._$AR(),this._$AH=Mt):e!==this._$AH&&e!==Or&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):qx(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!==Mt&&$l(this._$AH)?this._$AA.nextSibling.data=e:this.T(Mr.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=Vl.createElement(uT(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 Ep(s,this),o=a.u(this.options);a.p(t),this.T(o),this._$AH=a}}_$AC(e){let t=oT.get(e.strings);return t===void 0&&oT.set(e.strings,t=new Vl(e)),t}k(e){kp(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(Bl()),this.O(Bl()),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=tT(e).nextSibling;tT(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Ba=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Mt,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=Mt}_$AI(e,t=this,i,s){let r=this.strings,a=!1;if(r===void 0)e=Fa(this,e,t,0),a=!$l(e)||e!==this._$AH&&e!==Or,a&&(this._$AH=e);else{let o=e,l,c;for(e=r[0],l=0;l<r.length-1;l++)c=Fa(this,o[i+l],t,l),c===Or&&(c=this._$AH[l]),a||(a=!$l(c)||c!==this._$AH[l]),c===Mt?e=Mt:e!==Mt&&(e+=(c??"")+r[l+1]),this._$AH[l]=c}a&&!s&&this.j(e)}j(e){e===Mt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},bp=class extends Ba{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Mt?void 0:e}},Tp=class extends Ba{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Mt)}},Sp=class extends Ba{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=Fa(this,e,t,0)??Mt)===Or)return;let i=this._$AH,s=e===Mt&&i!==Mt||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Mt&&(i===Mt||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)}},_p=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){Fa(this,e)}};var yp=Fl.litHtmlPolyfillSupport;yp==null||yp(Vl,Hl),(Fl.litHtmlVersions??(Fl.litHtmlVersions=[])).push("3.3.2");var hT=(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 Hl(e.insertBefore(Bl(),r),r,void 0,t??{})}return s._$AI(n),s};var Nr=globalThis,ci=class extends ss{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=hT(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 Or}},fT;ci._$litElement$=!0,ci.finalized=!0,(fT=Nr.litElementHydrateSupport)==null||fT.call(Nr,{LitElement:ci});var Cp=Nr.litElementPolyfillSupport;Cp==null||Cp({LitElement:ci});(Nr.litElementVersions??(Nr.litElementVersions=[])).push("4.2.2");var Ps=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};var Yx={attribute:!0,type:String,converter:Nl,reflect:!1,hasChanged:iu},zx=(n=Yx,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"?zx(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 ws(n){return Be({...n,state:!0,attribute:!1})}var Qx=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Ip(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 Rp(n){return n===4e3||n===4001?"network":"unknown"}var Ji={network:6001,media:6002,keySystem:6003,other:6004,auth:6005};function xp(n){switch(n){case Ji.network:return"network";case Ji.media:return"media";case Ji.keySystem:case Ji.auth:return"security";default:return"unknown"}}function ru(){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 au(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"streamId"in n}function ou(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"clipId"in n}function Lp(n){return au(n)||ou(n)}var Sn=class extends Error{constructor(t,i,s){super(t);this.code=i;this.status=s;this.name="BPLiveError"}},Gl=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 Sn("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 Sn(`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 Sn("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 Sn(`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,au(e))return this.resolveStreamSource(e);if(ou(e))return this.resolveClipSource(e);throw new Sn("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 Sn("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 Sn("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 Kl(n){return n!=null&&typeof n.then=="function"}function mT(n){return new Promise((e,t)=>{let i=!1,s=r=>{i||(i=!0,r?t(r):e())};try{let r=n(s);Kl(r)&&(i=!0,r.then(()=>e(),t))}catch(r){s(r)}})}var Pp=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());Kl(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");Kl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(mT(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())}},wp=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());Kl(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");Kl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(mT(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())}},Wl=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 Pp(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 wp(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 Xx(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 pT(n){return typeof n=="object"&&n!==null&&n.type==="bplive"}var Jx=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],Dp=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 Wl;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._attachedElementGeneration=0;this._state=ru()}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=pT(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(pT(e)){if(a!=null&&a.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new Gl(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=Xx(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,error:null,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;this._attachedElementGeneration=this._loadGeneration,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){this._attachedElementGeneration=this._loadGeneration;for(let t of Jx){let i=s=>{t==="error"&&this._attachedElementGeneration!==this._loadGeneration||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({error:null,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=Ip(l),f=h!=="offline"&&h!=="autoplay"):this._state.providerType==="livekit"&&l>0?(h=Rp(l),f=!0):this._state.providerType==="video"&&l>=6e3&&(h=xp(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({...ru(),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 Mp(){return new Dp}var $a="bpPlayerObservedProperties";function Op(n){return $a in n&&Array.isArray(n[$a])}function Zx(n,e){class t extends n{get[$a](){return e}}return t}function eL(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 Va(n,e,t){if(e!=null&&e.contains(n))return;n.nodeName.includes("-")&&!Op(n)&&(await Promise.resolve(),await customElements.whenDefined(n.nodeName.toLowerCase()),customElements.upgrade(n)),Op(n)&&t(n);let i=eL(n);i.length>0&&await Promise.all(i.map(s=>Va(s,e,t)))}function lu(n,e,t){let i=n[$a];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 cu(n){n[$a].includes("player")&&(n.player=void 0)}var gT=`/**
|
|
7
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),rT=/'/g,aT=/"/g,dT=/^(?:script|style|textarea|title)$/i,Ap=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),Bi=Ap(1),IB=Ap(2),RB=Ap(3),Or=Symbol.for("lit-noChange"),Mt=Symbol.for("lit-nothing"),oT=new WeakMap,Dr=Mr.createTreeWalker(Mr,129);function uT(n,e){if(!kp(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return iT!==void 0?iT.createHTML(e):e}var jx=(n,e)=>{let t=n.length-1,i=[],s,r=e===2?"<svg>":e===3?"<math>":"",a=Ul;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===Ul?d[1]==="!--"?a=nT:d[1]!==void 0?a=sT:d[2]!==void 0?(dT.test(d[2])&&(s=RegExp("</"+d[2],"g")),a=wr):d[3]!==void 0&&(a=wr):a===wr?d[0]===">"?(a=s??Ul,u=-1):d[1]===void 0?u=-2:(u=a.lastIndex-d[2].length,c=d[1],a=d[3]===void 0?wr:d[3]==='"'?aT:rT):a===aT||a===rT?a=wr:a===nT||a===sT?a=Ul:(a=wr,s=void 0);let f=a===wr&&n[o+1].startsWith("/>")?" ":"";r+=a===Ul?l+Wx:u>=0?(i.push(c),l.slice(0,u)+lT+l.slice(u)+Ls+f):l+Ls+(u===-2?o:f)}return[uT(n,r+(n[t]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),i]},Vl=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]=jx(e,t);if(this.el=n.createElement(c,i),Dr.currentNode=this.el.content,t===2||t===3){let u=this.el.content.firstChild;u.replaceWith(...u.childNodes)}for(;(s=Dr.nextNode())!==null&&l.length<o;){if(s.nodeType===1){if(s.hasAttributes())for(let u of s.getAttributeNames())if(u.endsWith(lT)){let h=d[a++],f=s.getAttribute(u).split(Ls),m=/([.?@])?(.*)/.exec(h);l.push({type:1,index:r,name:m[2],strings:f,ctor:m[1]==="."?bp:m[1]==="?"?Tp:m[1]==="@"?Sp:Ba}),s.removeAttribute(u)}else u.startsWith(Ls)&&(l.push({type:6,index:r}),s.removeAttribute(u));if(dT.test(s.tagName)){let u=s.textContent.split(Ls),h=u.length-1;if(h>0){s.textContent=nu?nu.emptyScript:"";for(let f=0;f<h;f++)s.append(u[f],Bl()),Dr.nextNode(),l.push({type:2,index:++r});s.append(u[h],Bl())}}}else if(s.nodeType===8)if(s.data===cT)l.push({type:2,index:r});else{let u=-1;for(;(u=s.data.indexOf(Ls,u+1))!==-1;)l.push({type:7,index:r}),u+=Ls.length-1}r++}}static createElement(e,t){let i=Mr.createElement("template");return i.innerHTML=e,i}};function Fa(n,e,t=n,i){var a,o;if(e===Or)return e;let s=i!==void 0?(a=t._$Co)==null?void 0:a[i]:t._$Cl,r=$l(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=Fa(n,s._$AS(n,e.values),s,i)),e}var Ep=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)??Mr).importNode(t,!0);Dr.currentNode=s;let r=Dr.nextNode(),a=0,o=0,l=i[0];for(;l!==void 0;){if(a===l.index){let c;l.type===2?c=new Hl(r,r.nextSibling,this,e):l.type===1?c=new l.ctor(r,l.name,l.strings,this,e):l.type===6&&(c=new _p(r,this,e)),this._$AV.push(c),l=i[++o]}a!==(l==null?void 0:l.index)&&(r=Dr.nextNode(),a++)}return Dr.currentNode=Mr,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++}},Hl=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=Mt,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=Fa(this,e,t),$l(e)?e===Mt||e==null||e===""?(this._$AH!==Mt&&this._$AR(),this._$AH=Mt):e!==this._$AH&&e!==Or&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):qx(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!==Mt&&$l(this._$AH)?this._$AA.nextSibling.data=e:this.T(Mr.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=Vl.createElement(uT(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 Ep(s,this),o=a.u(this.options);a.p(t),this.T(o),this._$AH=a}}_$AC(e){let t=oT.get(e.strings);return t===void 0&&oT.set(e.strings,t=new Vl(e)),t}k(e){kp(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(Bl()),this.O(Bl()),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=tT(e).nextSibling;tT(e).remove(),e=s}}setConnected(e){var t;this._$AM===void 0&&(this._$Cv=e,(t=this._$AP)==null||t.call(this,e))}},Ba=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,i,s,r){this.type=1,this._$AH=Mt,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=Mt}_$AI(e,t=this,i,s){let r=this.strings,a=!1;if(r===void 0)e=Fa(this,e,t,0),a=!$l(e)||e!==this._$AH&&e!==Or,a&&(this._$AH=e);else{let o=e,l,c;for(e=r[0],l=0;l<r.length-1;l++)c=Fa(this,o[i+l],t,l),c===Or&&(c=this._$AH[l]),a||(a=!$l(c)||c!==this._$AH[l]),c===Mt?e=Mt:e!==Mt&&(e+=(c??"")+r[l+1]),this._$AH[l]=c}a&&!s&&this.j(e)}j(e){e===Mt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}},bp=class extends Ba{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Mt?void 0:e}},Tp=class extends Ba{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Mt)}},Sp=class extends Ba{constructor(e,t,i,s,r){super(e,t,i,s,r),this.type=5}_$AI(e,t=this){if((e=Fa(this,e,t,0)??Mt)===Or)return;let i=this._$AH,s=e===Mt&&i!==Mt||e.capture!==i.capture||e.once!==i.once||e.passive!==i.passive,r=e!==Mt&&(i===Mt||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)}},_p=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){Fa(this,e)}};var yp=Fl.litHtmlPolyfillSupport;yp==null||yp(Vl,Hl),(Fl.litHtmlVersions??(Fl.litHtmlVersions=[])).push("3.3.2");var hT=(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 Hl(e.insertBefore(Bl(),r),r,void 0,t??{})}return s._$AI(n),s};var Nr=globalThis,ci=class extends ss{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=hT(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 Or}},fT;ci._$litElement$=!0,ci.finalized=!0,(fT=Nr.litElementHydrateSupport)==null||fT.call(Nr,{LitElement:ci});var Cp=Nr.litElementPolyfillSupport;Cp==null||Cp({LitElement:ci});(Nr.litElementVersions??(Nr.litElementVersions=[])).push("4.2.2");var Ps=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};var Yx={attribute:!0,type:String,converter:Nl,reflect:!1,hasChanged:iu},zx=(n=Yx,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"?zx(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 ws(n){return Be({...n,state:!0,attribute:!1})}var Qx=[1005,1007,1008,1009,3001,3002,3003,3004,3005,3100,3101,3200,4003];function Ip(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 Rp(n){return n===4e3||n===4001?"network":"unknown"}var Ji={network:6001,media:6002,keySystem:6003,other:6004,auth:6005};function xp(n){switch(n){case Ji.network:return"network";case Ji.media:return"media";case Ji.keySystem:case Ji.auth:return"security";default:return"unknown"}}function ru(){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 au(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"streamId"in n}function ou(n){return typeof n=="object"&&n!==null&&"type"in n&&n.type==="bplive"&&"clipId"in n}function Lp(n){return au(n)||ou(n)}var Sn=class extends Error{constructor(t,i,s){super(t);this.code=i;this.status=s;this.name="BPLiveError"}},Gl=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 Sn("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 Sn(`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 Sn("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 Sn(`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,au(e))return this.resolveStreamSource(e);if(ou(e))return this.resolveClipSource(e);throw new Sn("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 Sn("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 Sn("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 Kl(n){return n!=null&&typeof n.then=="function"}function mT(n){return new Promise((e,t)=>{let i=!1,s=r=>{i||(i=!0,r?t(r):e())};try{let r=n(s);Kl(r)&&(i=!0,r.then(()=>e(),t))}catch(r){s(r)}})}var Pp=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());Kl(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");Kl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(mT(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())}},wp=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());Kl(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");Kl(e)?this._handleWaitUntil(e):typeof e=="function"&&this._handleWaitUntil(mT(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())}},Wl=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 Pp(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 wp(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 Xx(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 pT(n){return typeof n=="object"&&n!==null&&n.type==="bplive"}var Jx=["loadstart","loadedmetadata","loadeddata","canplay","canplaythrough","play","playing","pause","waiting","seeking","seeked","timeupdate","durationchange","ratechange","volumechange","ended","progress","error","resize"],Dp=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 Wl;this._currentProviderType=null;this._ready=!1;this._loadGeneration=0;this._attachedElementGeneration=0;this._state=ru()}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=pT(e)?"clipId"in e?"clip":"stream":"video";this.updateState({error:null,connectionState:"connecting",ended:!1,contentType:o}),this.dispatch("sourcechange",{source:e});try{let l=e,c=o,d,u,h;if(pT(e)){if(a!=null&&a.bpLive&&(this._bpLive&&this._bpLive.destroy(),this._bpLive=new Gl(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}else this._bpLive&&(this._bpLive.destroy(),this._bpLive=null);let f=Xx(l),g=f==="nano"||f==="livekit"||c==="stream"?"live":"vod";return this._mediaElement&&this.destroyMediaElement(),this._state.targetQuality&&this.setTargetQuality(null),this._currentProviderType=f,this.updateState({providerType:f,contentType:c,streamType:g,error:null,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._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;this._attachedElementGeneration=this._loadGeneration,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){this._attachedElementGeneration=this._loadGeneration;for(let t of Jx){let i=s=>{t==="error"&&this._attachedElementGeneration!==this._loadGeneration||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({error:null,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=Ip(l),f=h!=="offline"&&h!=="autoplay"):this._state.providerType==="livekit"&&l>0?(h=Rp(l),f=!0):this._state.providerType==="video"&&l>=6e3&&(h=xp(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._loadGeneration++,this.destroyMediaElement(),this._currentProviderType=null,this._bpLive&&(this._bpLive.destroy(),this._bpLive=null),this.updateState({...ru(),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._container=null,this._config=void 0,this._ready=!1,this.dispatch("destroy",void 0),this._listeners.clear())}};function Mp(){return new Dp}var $a="bpPlayerObservedProperties";function Op(n){return $a in n&&Array.isArray(n[$a])}function Zx(n,e){class t extends n{get[$a](){return e}}return t}function eL(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 Va(n,e,t){if(e!=null&&e.contains(n))return;n.nodeName.includes("-")&&!Op(n)&&(await Promise.resolve(),await customElements.whenDefined(n.nodeName.toLowerCase()),customElements.upgrade(n)),Op(n)&&t(n);let i=eL(n);i.length>0&&await Promise.all(i.map(s=>Va(s,e,t)))}function lu(n,e,t){let i=n[$a];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 cu(n){n[$a].includes("player")&&(n.player=void 0)}var gT=`/**
|
|
8
8
|
* BP Player CSS Custom Properties
|
|
9
9
|
*
|
|
10
10
|
* All styling can be customized by overriding these CSS variables.
|
|
@@ -190,22 +190,28 @@ bp-player[hidden] {
|
|
|
190
190
|
height: 100% !important;
|
|
191
191
|
max-width: 100%;
|
|
192
192
|
max-height: 100%;
|
|
193
|
+
object-fit: var(--media-object-fit, contain);
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
/* ============================================
|
|
196
197
|
Scaling Modes
|
|
198
|
+
|
|
199
|
+
--media-object-fit inherits into the provider elements' shadow roots,
|
|
200
|
+
where custom-media-element's <video> consumes it (object-fit:
|
|
201
|
+
var(--media-object-fit, contain)). Light-DOM provider videos are
|
|
202
|
+
covered by the .bp-player-provider video rule above.
|
|
197
203
|
============================================ */
|
|
198
204
|
|
|
199
|
-
.bp-player-container--letterbox .bp-player-provider
|
|
200
|
-
object-fit: var(--bp-video-object-fit, contain);
|
|
205
|
+
.bp-player-container--letterbox .bp-player-provider {
|
|
206
|
+
--media-object-fit: var(--bp-video-object-fit, contain);
|
|
201
207
|
}
|
|
202
208
|
|
|
203
|
-
.bp-player-container--crop .bp-player-provider
|
|
204
|
-
object-fit: cover;
|
|
209
|
+
.bp-player-container--crop .bp-player-provider {
|
|
210
|
+
--media-object-fit: cover;
|
|
205
211
|
}
|
|
206
212
|
|
|
207
|
-
.bp-player-container--fill .bp-player-provider
|
|
208
|
-
object-fit: fill;
|
|
213
|
+
.bp-player-container--fill .bp-player-provider {
|
|
214
|
+
--media-object-fit: fill;
|
|
209
215
|
}
|
|
210
216
|
|
|
211
217
|
/* ============================================
|
|
@@ -2689,6 +2695,25 @@ bp-default-ui[debug-hitboxes] media-controller *:hover {
|
|
|
2689
2695
|
outline: 2px solid rgba(0, 255, 0, 1) !important;
|
|
2690
2696
|
background: rgba(0, 255, 0, 0.3) !important;
|
|
2691
2697
|
}
|
|
2698
|
+
|
|
2699
|
+
/* ============================================
|
|
2700
|
+
Poster Scaling
|
|
2701
|
+
|
|
2702
|
+
Mirrors bp-player.css's scaling modes so the poster
|
|
2703
|
+
matches the video fit before playback starts.
|
|
2704
|
+
============================================ */
|
|
2705
|
+
|
|
2706
|
+
bp-default-ui media-poster-image {
|
|
2707
|
+
--media-object-fit: var(--bp-video-object-fit, contain);
|
|
2708
|
+
}
|
|
2709
|
+
|
|
2710
|
+
bp-default-ui[scaling="crop"] media-poster-image {
|
|
2711
|
+
--media-object-fit: cover;
|
|
2712
|
+
}
|
|
2713
|
+
|
|
2714
|
+
bp-default-ui[scaling="fill"] media-poster-image {
|
|
2715
|
+
--media-object-fit: fill;
|
|
2716
|
+
}
|
|
2692
2717
|
`;var F_=!1;function TD(){if(F_||(F_=!0,document.getElementById("bp-default-ui-styles")))return;ql();let n=document.createElement("style");n.id="bp-default-ui-styles",n.textContent=U_,document.head.appendChild(n)}var at=class extends ci{constructor(){super(...arguments);this.autoplay=!1;this.muted=!1;this.loop=!1;this.scaling="letterbox";this.debug=!1;this.autohide=2;this.hotkeys=!0;this.mobile=!1;this.live=!1;this.fluid=!1;this._player=null;this._providerType=null;this._error=null;this._connectionState="idle";this._showEndedOverlay=!1;this._cleanupListeners=[]}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),TD(),this.detectMobile()}disconnectedCallback(){super.disconnectedCallback(),this._cleanupListeners.forEach(t=>t()),this._cleanupListeners=[]}get player(){return this._player}get mediaController(){return this.querySelector("media-controller")}get bpLive(){var t;return((t=this._player)==null?void 0:t.bpLive)??null}detectMobile(){let t=/Android|iPhone|iPad|iPod|webOS|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);this.mobile=t}_getPoster(){var t;return((t=this.source)==null?void 0:t.poster)??this.poster??null}firstUpdated(t){super.firstUpdated(t),this.setupPlayer(),this._moveSlottedContent()}willUpdate(t){super.willUpdate(t),t.has("source")&&(this._applySourceHints(),this._error=null,this._showEndedOverlay=!1,Ot(this,"has-error",!1))}updated(t){super.updated(t),this._moveSlottedContent(),t.has("debug")&&this.toggleAttribute("debug-hitboxes",this.debug)}_applySourceHints(){var i;let t=(i=this.source)==null?void 0:i.sources;if(t){for(let s of t)if(Lp(s)){if("clipId"in s){if(this.setAttribute("content-type","clip"),this.fluid&&s.preferredOrientation){let r=s.preferredOrientation==="portrait";this.style.setProperty("--bp-video-width",r?"9":"16"),this.style.setProperty("--bp-video-height",r?"16":"9")}}else this.setAttribute("content-type","stream");return}this.setAttribute("content-type","video")}}_updateVideoDimensions(t,i){t>0&&i>0?(this.style.setProperty("--bp-video-width",String(t)),this.style.setProperty("--bp-video-height",String(i))):(this.style.removeProperty("--bp-video-width"),this.style.removeProperty("--bp-video-height"))}_clearVideoDimensions(){this.style.removeProperty("--bp-video-width"),this.style.removeProperty("--bp-video-height")}_moveSlottedContent(){let t=this.querySelector("media-controller");if(!t)return;let i=[{from:"top-chrome",to:"top-chrome",marker:"has-custom-top-chrome"},{from:"centered-chrome",to:"centered-chrome",marker:"has-custom-centered-chrome"},{from:"middle-chrome",to:"middle-chrome",marker:"has-custom-middle-chrome"},{from:"bottom-chrome",to:null,marker:"has-custom-bottom-chrome"}];for(let{from:s,to:r,marker:a}of i){let o=this.querySelectorAll(`:scope > [slot="${s}"]`);o.length>0&&this.setAttribute(a,""),o.forEach(l=>{l.parentElement!==t&&(r?l.setAttribute("slot",r):l.removeAttribute("slot"),t.appendChild(l))})}}setupPlayer(){let t=this.querySelector("bp-player");if(!t)return;let i=s=>{s.stopPropagation(),this._player=s.detail,this.setupPlayerListeners(),this.dispatchEvent(Ur(Xl,{detail:this._player})),this.requestUpdate()};t.addEventListener("ready",i),this._cleanupListeners.push(()=>t.removeEventListener("ready",i))}setupPlayerListeners(){if(!this._player)return;let t=()=>{var h;let d=((h=this._player)==null?void 0:h.state.error)??null;this._error=d;let u=d!==null&&d.fatal&&d.category!=="offline";Ot(this,"has-error",u)},i=()=>{var u;let d=(u=this._player)==null?void 0:u.state;if(d&&(this._connectionState=d.connectionState,this._providerType=d.providerType,this.live=d.streamType==="live",this.setAttribute("content-type",d.contentType),this.setAttribute("stream-type",d.streamType),Ot(this,"paused",d.paused),Ot(this,"ended",d.ended),Ot(this,"waiting",d.waiting),d.error!==this._error)){this._error=d.error;let h=d.error!==null&&d.error.fatal&&d.error.category!=="offline";Ot(this,"has-error",h)}},s=()=>{this._error=null,this._showEndedOverlay=!1,Ot(this,"has-error",!1)},r=()=>{this.live&&(this._showEndedOverlay=!0)},a=()=>{this._error=null,this._showEndedOverlay=!1,Ot(this,"has-error",!1)},o=d=>{this.debug&&console.log("[BPDefaultUI] updateVideoDimensions called",{fluid:this.fluid,...d}),this.fluid&&(this._updateVideoDimensions(d.videoWidth,d.videoHeight),this.debug&&console.log("[BPDefaultUI] Set video dimensions:",{width:d.videoWidth,height:d.videoHeight}))};this._player.addEventListener("error",t),this._player.addEventListener("statechange",i),this._player.addEventListener("playing",s),this._player.addEventListener("ended",r),this._player.addEventListener("sourcechange",a),this._player.addEventListener("resize",o),this._player.addEventListener("loadedmetadata",o);let{videoWidth:l,videoHeight:c}=this._player.state;this.debug&&console.log("[BPDefaultUI] Initial dimensions check",{videoWidth:l,videoHeight:c,fluid:this.fluid}),l>0&&c>0&&o({videoWidth:l,videoHeight:c}),this._cleanupListeners.push(()=>{var d;return(d=this._player)==null?void 0:d.removeEventListener("error",t)},()=>{var d;return(d=this._player)==null?void 0:d.removeEventListener("statechange",i)},()=>{var d;return(d=this._player)==null?void 0:d.removeEventListener("playing",s)},()=>{var d;return(d=this._player)==null?void 0:d.removeEventListener("ended",r)},()=>{var d;return(d=this._player)==null?void 0:d.removeEventListener("sourcechange",a)},()=>{var d;return(d=this._player)==null?void 0:d.removeEventListener("resize",o)},()=>{var d;return(d=this._player)==null?void 0:d.removeEventListener("loadedmetadata",o)})}renderDefaultControls(){return this._providerType==="nano"||this._providerType==="livekit"?Bi`
|
|
2693
2718
|
<media-control-bar>
|
|
2694
2719
|
<media-play-button notooltip clip-hidden></media-play-button>
|
|
@@ -2764,7 +2789,7 @@ bp-default-ui[debug-hitboxes] media-controller *:hover {
|
|
|
2764
2789
|
<div class="bp-layer bp-error-layer">
|
|
2765
2790
|
<bp-error-display .error="${this._error}" ?showCode="${this.debug}"></bp-error-display>
|
|
2766
2791
|
</div>
|
|
2767
|
-
`}};_e([Be({converter:Ha()})],at.prototype,"source",2),_e([Be({type:Boolean})],at.prototype,"autoplay",2),_e([Be({type:Boolean})],at.prototype,"muted",2),_e([Be({type:Boolean})],at.prototype,"loop",2),_e([Be({type:String})],at.prototype,"poster",2),_e([Be({type:String})],at.prototype,"scaling",2),_e([Be({type:String,attribute:"aspect-ratio"})],at.prototype,"aspectRatio",2),_e([Be({converter:Ha()})],at.prototype,"config",2),_e([Be({type:Boolean})],at.prototype,"debug",2),_e([Be({type:Number})],at.prototype,"autohide",2),_e([Be({type:Boolean})],at.prototype,"hotkeys",2),_e([Be({type:Boolean,reflect:!0})],at.prototype,"mobile",2),_e([Be({type:Boolean,reflect:!0})],at.prototype,"live",2),_e([Be({type:Boolean,reflect:!0})],at.prototype,"fluid",2),_e([ws()],at.prototype,"_player",2),_e([ws()],at.prototype,"_providerType",2),_e([ws()],at.prototype,"_error",2),_e([ws()],at.prototype,"_connectionState",2),_e([ws()],at.prototype,"_showEndedOverlay",2),at=_e([Ps("bp-default-ui")],at);var SD=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
2792
|
+
`}};_e([Be({converter:Ha()})],at.prototype,"source",2),_e([Be({type:Boolean})],at.prototype,"autoplay",2),_e([Be({type:Boolean})],at.prototype,"muted",2),_e([Be({type:Boolean})],at.prototype,"loop",2),_e([Be({type:String})],at.prototype,"poster",2),_e([Be({type:String,reflect:!0})],at.prototype,"scaling",2),_e([Be({type:String,attribute:"aspect-ratio"})],at.prototype,"aspectRatio",2),_e([Be({converter:Ha()})],at.prototype,"config",2),_e([Be({type:Boolean})],at.prototype,"debug",2),_e([Be({type:Number})],at.prototype,"autohide",2),_e([Be({type:Boolean})],at.prototype,"hotkeys",2),_e([Be({type:Boolean,reflect:!0})],at.prototype,"mobile",2),_e([Be({type:Boolean,reflect:!0})],at.prototype,"live",2),_e([Be({type:Boolean,reflect:!0})],at.prototype,"fluid",2),_e([ws()],at.prototype,"_player",2),_e([ws()],at.prototype,"_providerType",2),_e([ws()],at.prototype,"_error",2),_e([ws()],at.prototype,"_connectionState",2),_e([ws()],at.prototype,"_showEndedOverlay",2),at=_e([Ps("bp-default-ui")],at);var SD=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
2768
2793
|
<circle cx="12" cy="12" r="10" stroke-opacity="0.25"/>
|
|
2769
2794
|
<path d="M12 2a10 10 0 0 1 10 10" stroke-linecap="round">
|
|
2770
2795
|
<animateTransform attributeName="transform" type="rotate" from="0 12 12" to="360 12 12" dur="1s" repeatCount="indefinite"/>
|
|
@@ -2990,7 +3015,7 @@ a=extmap-allow-mixed`)!==-1){let r=s.sdp.split(`
|
|
|
2990
3015
|
${JSON.stringify(i.config||{})}
|
|
2991
3016
|
<\/script>
|
|
2992
3017
|
${vi.getTemplateHTML(a)}
|
|
2993
|
-
`}get activeVideoElement(){return x(this,ht)}get config(){return x(this,Ui)}set config(t){F(this,Ui,t)}get url(){return this.getAttribute("url")}set url(t){t?this.setAttribute("url",t):this.removeAttribute("url")}get token(){return this.getAttribute("token")}set token(t){t?this.setAttribute("token",t):this.removeAttribute("token")}attributeChangedCallback(t,i,s){(t==="url"||t==="token")&&i!==s?this.url&&this.token?this.load():x(this,be)&&oe(this,Me,op).call(this):t!=="url"&&t!=="token"&&super.attributeChangedCallback(t,i,s)}async load(){var T,S,R;let t=!x(this,be);oe(this,Me,op).call(this);let i=this.url,s=this.token;if(!i||!s)return;if(F(this,Ma,new Promise(_=>{F(this,Lr,_)})),t&&!x(this,Ui))try{F(this,Ui,JSON.parse(((S=(T=this.shadowRoot)==null?void 0:T.getElementById("config"))==null?void 0:S.textContent)||"{}"))}catch(_){console.error("[livekit-video] Failed to parse config:",_),F(this,Ui,{})}let r=oe(this,Me,Px).call(this),a=oe(this,Me,wx).call(this);F(this,be,new Rl(r)),this.room=x(this,be);let o=()=>{F(this,ns,"connected")},l=_=>{let A=_!=null?Oi[_]??String(_):"undefined";console.log("[livekit-video] Disconnected",{reason:_,reasonName:A,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState}),F(this,ns,"disconnected"),oe(this,Me,jd).call(this),_?this.dispatchEvent(di(new Error(`LiveKit disconnected: ${A} (${_})`),4001)):this.dispatchEvent(He(Yl))},c=()=>{console.log("[livekit-video] Reconnecting",{documentHidden:document.hidden,documentHasFocus:document.hasFocus()}),F(this,ns,"reconnecting"),this.dispatchEvent(He(Ga))},d=()=>{console.log("[livekit-video] Reconnected"),F(this,ns,"connected"),this.dispatchEvent(He(Ds))},u=()=>{console.log("[livekit-video] SignalReconnecting")},h=_=>{console.log("[livekit-video] ConnectionStateChanged",_)},f=_=>{console.error("[livekit-video] MediaDevicesError",_)},m=_=>{console.log("[livekit-video] AudioPlaybackStatusChanged",_),_?(oe(this,Me,jd).call(this),oe(this,Me,xl).call(this)):oe(this,Me,jb).call(this)},p=(_,A,I)=>{console.error("[livekit-video] TrackSubscriptionFailed",{trackSid:_,reason:I})},g=_=>{console.log("[livekit-video] TrackMuted",{sid:_.trackSid,kind:_.kind})},v=_=>{console.log("[livekit-video] TrackUnmuted",{sid:_.trackSid,kind:_.kind})},E=(_,A)=>{var I,C,w,O;if(_.kind===$.Kind.Video){let N=_.attach();N.style.width="100%",N.style.height="100%",N.style.objectFit="contain",N.style.position="absolute",N.style.top="0",N.style.left="0",N.playsInline=!0,N.setAttribute("playsinline",""),N.setAttribute("webkit-playsinline",""),this.nativeEl.muted&&(N.muted=!0),this.nativeEl.style.display="none",(I=this.shadowRoot)==null||I.appendChild(N),F(this,ht,N),oe(this,Me,xx).call(this,N),oe(this,Me,Lx).call(this,A),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:N}})),this.dispatchEvent(He(Fp)),this.dispatchEvent(He(Ms)),this.dispatchEvent(He(Ql)),this.dispatchEvent(He(Ds)),(C=x(this,Lr))==null||C.call(this)}else if(_.kind===$.Kind.Audio){let N=_.attach();N.style.display="none",(w=this.shadowRoot)==null||w.appendChild(N),F(this,Ht,N),oe(this,Me,xl).call(this);let q=()=>{x(this,Ht)===N&&oe(this,Me,xl).call(this)};N.addEventListener(Ka,q),(O=x(this,Is))==null||O.call(this),F(this,Is,()=>N.removeEventListener(Ka,q)),x(this,be)&&!x(this,be).canPlaybackAudio&&oe(this,Me,jb).call(this)}},b=_=>{var A;_.kind===$.Kind.Video?(_.detach(),oe(this,Me,lp).call(this),x(this,ht)&&(x(this,zi).forEach(I=>I()),F(this,zi,[]),x(this,ht).remove(),F(this,ht,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}})))):_.kind===$.Kind.Audio&&(_.detach(),x(this,Ht)&&(x(this,Ht).remove(),F(this,Ht,null)),(A=x(this,Is))==null||A.call(this),F(this,Is,null),oe(this,Me,jd).call(this))};x(this,be).on(B.Connected,o),x(this,be).on(B.Disconnected,l),x(this,be).on(B.Reconnecting,c),x(this,be).on(B.Reconnected,d),x(this,be).on(B.SignalReconnecting,u),x(this,be).on(B.ConnectionStateChanged,h),x(this,be).on(B.MediaDevicesError,f),x(this,be).on(B.AudioPlaybackStatusChanged,m),x(this,be).on(B.TrackSubscribed,E),x(this,be).on(B.TrackUnsubscribed,b),x(this,be).on(B.TrackSubscriptionFailed,p),x(this,be).on(B.TrackMuted,g),x(this,be).on(B.TrackUnmuted,v),F(this,Pl,[()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Connected,o)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Disconnected,l)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Reconnecting,c)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Reconnected,d)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.SignalReconnecting,u)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.ConnectionStateChanged,h)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.MediaDevicesError,f)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.AudioPlaybackStatusChanged,m)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackSubscribed,E)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackUnsubscribed,b)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackSubscriptionFailed,p)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackMuted,g)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackUnmuted,v)}]),F(this,ns,"connecting"),this.dispatchEvent(He(Up));try{await x(this,be).connect(i,s,a)}catch(_){F(this,ns,"failed"),console.error("[livekit-video] Failed to connect:",_);let A=_ instanceof Error?_.message:"Failed to connect to LiveKit room";this.dispatchEvent(di(new Error(A),4e3)),(R=x(this,Lr))==null||R.call(this)}}async play(){return x(this,Ma)&&await x(this,Ma),x(this,ht)?x(this,ht).play():super.play()}pause(){if(x(this,ht)){x(this,ht).pause();return}super.pause()}get currentTime(){var t;return((t=x(this,ht))==null?void 0:t.currentTime)??super.currentTime}set currentTime(t){x(this,be)||(super.currentTime=t)}get duration(){return 1/0}get paused(){var t;return((t=x(this,ht))==null?void 0:t.paused)??super.paused}get volume(){return super.volume}set volume(t){super.volume=t,x(this,ht)&&(x(this,ht).volume=t),x(this,Ht)&&(x(this,Ht).volume=t)}get muted(){return super.muted}set muted(t){super.muted=t,x(this,ht)&&(x(this,ht).muted=t),x(this,Ht)&&(x(this,Ht).muted=t)}get videoWidth(){var t;return((t=x(this,ht))==null?void 0:t.videoWidth)??super.videoWidth}get videoHeight(){var t;return((t=x(this,ht))==null?void 0:t.videoHeight)??super.videoHeight}disconnectedCallback(){var t;oe(this,Me,op).call(this),(t=super.disconnectedCallback)==null||t.call(this)}};Ui=new WeakMap,be=new WeakMap,ht=new WeakMap,Ht=new WeakMap,zi=new WeakMap,Ll=new WeakMap,Pl=new WeakMap,ns=new WeakMap,Ma=new WeakMap,Lr=new WeakMap,Oa=new WeakMap,Is=new WeakMap,Me=new WeakSet,op=function(){var t,i;(t=x(this,Lr))==null||t.call(this),F(this,Ma,null),F(this,Lr,null),x(this,zi).forEach(s=>s()),F(this,zi,[]),oe(this,Me,lp).call(this),x(this,Pl).forEach(s=>s()),F(this,Pl,[]),x(this,be)&&(x(this,be).disconnect(),F(this,be,null),this.room=null),x(this,ht)&&(x(this,ht).remove(),F(this,ht,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}}))),x(this,Ht)&&(x(this,Ht).remove(),F(this,Ht,null)),(i=x(this,Is))==null||i.call(this),F(this,Is,null),oe(this,Me,jd).call(this),F(this,ns,"disconnected")},jb=function(){if(x(this,Oa))return;let t=!1,i=()=>{let s=x(this,be);if(!s)return;let r=s.startAudio();oe(this,Me,xl).call(this),r.then(()=>{x(this,be)===s&&oe(this,Me,xl).call(this)}).catch(a=>{t||(t=!0,console.warn("[livekit-video] startAudio failed",a))})};document.addEventListener("click",i,{capture:!0}),document.addEventListener("touchend",i,{capture:!0,passive:!0}),document.addEventListener("keydown",i,{capture:!0}),F(this,Oa,()=>{document.removeEventListener("click",i,{capture:!0}),document.removeEventListener("touchend",i,{capture:!0}),document.removeEventListener("keydown",i,{capture:!0})})},jd=function(){var t;(t=x(this,Oa))==null||t.call(this),F(this,Oa,null)},xl=function(){x(this,Ht)&&(x(this,Ht).muted=fp(Yd.prototype,this,"muted"),x(this,Ht).volume=fp(Yd.prototype,this,"volume"))},xx=function(t){x(this,zi).forEach(a=>a()),F(this,zi,[]);let i=[zl,jl,Ds,Fr,Ms];for(let a of i){let o=()=>{this.dispatchEvent(He(a))};t.addEventListener(a,o),x(this,zi).push(()=>t.removeEventListener(a,o))}let s=()=>{var o,l,c;let a=t.srcObject;console.error("[livekit-video] attached <video> error",{code:(o=t.error)==null?void 0:o.code,message:(l=t.error)==null?void 0:l.message,readyState:t.readyState,networkState:t.networkState,paused:t.paused,srcObjectActive:a==null?void 0:a.active,tracks:a==null?void 0:a.getTracks().map(d=>({kind:d.kind,readyState:d.readyState,muted:d.muted,enabled:d.enabled})),documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState,roomState:(c=x(this,be))==null?void 0:c.state})};t.addEventListener("error",s),x(this,zi).push(()=>t.removeEventListener("error",s));let r=()=>{console.warn("[livekit-video] attached <video> stalled",{readyState:t.readyState,networkState:t.networkState,documentHidden:document.hidden})};t.addEventListener("stalled",r),x(this,zi).push(()=>t.removeEventListener("stalled",r))},Lx=function(t){var o;oe(this,Me,lp).call(this);let i=(o=t.trackInfo)==null?void 0:o.layers;if(!i||i.length===0)return;let s=this.addVideoTrack("main");s.id="main",s.selected=!0;let r=[...i].sort((l,c)=>l.quality-c.quality);for(let l of r){let c=s.addRendition("",l.width,l.height,void 0,l.bitrate);c.id=`${l.quality}`}let a=()=>{let l=this.videoRenditions.selectedIndex;if(l<0)t.setVideoQuality(li.HIGH);else{let c=r[l];c&&t.setVideoQuality(c.quality)}};this.videoRenditions.addEventListener("change",a),x(this,Ll).push(()=>this.videoRenditions.removeEventListener("change",a))},lp=function(){x(this,Ll).forEach(t=>t()),F(this,Ll,[]);for(let t of this.videoTracks)this.removeVideoTrack(t);for(let t of this.audioTracks)this.removeAudioTrack(t)},Px=function(){var t,i,s;return{adaptiveStream:((t=x(this,Ui))==null?void 0:t.adaptiveStream)??!1,dynacast:((i=x(this,Ui))==null?void 0:i.dynacast)??!0,disconnectOnPageLeave:((s=x(this,Ui))==null?void 0:s.disconnectOnPageLeave)??!1}},wx=function(){var t,i;return{autoSubscribe:!0,peerConnectionTimeout:((t=x(this,Ui))==null?void 0:t.peerConnectionTimeout)??8e3,rtcConfig:{iceTransportPolicy:((i=x(this,Ui))==null?void 0:i.iceTransportPolicy)??"all"}}},cp=function(t){if(Object.prototype.hasOwnProperty.call(this,t)){let i=this[t];delete this[t],this[t]=i}},Yd.shadowRootOptions={...vi.shadowRootOptions};var wl=Yd;globalThis.customElements&&!globalThis.customElements.get("livekit-video")&&globalThis.customElements.define("livekit-video",wl);var Dx=wl;export{du as Attribute,at as BPDefaultUI,Ys as BPErrorDisplay,Sn as BPLiveError,Gl as BPLiveService,us as BPOverlay,ui as BPPlayer,Ji as HLS_ERROR_CODES,mt as Hls,_a as HlsVideo,FC as HlsVideoElement,wl as LiveKitVideo,Dx as LiveKitVideoElement,Qx as NANOPLAYER_NO_REPLAY_CODES,Ia as NanoVideo,GC as NanoVideoElement,Zx as StateReceiverMixin,$a as StateReceiverProps,ql as addGlobalStyles,xp as classifyHlsError,Rp as classifyLiveKitError,Ip as classifyNanoPlayerError,ru as createInitialState,Mp as createPlayerCore,nL as createTemplate,Va as forEachStateReceiverElement,ou as isBPLiveClipSource,Lp as isBPLiveSource,au as isBPLiveStreamSource,Op as isStateReceiverElement,lu as propagateStateToReceiver,cu as removeStateFromReceiver,sL as templateWithStyles,Ot as toggleAttribute};
|
|
3018
|
+
`}get activeVideoElement(){return x(this,ht)}get config(){return x(this,Ui)}set config(t){F(this,Ui,t)}get url(){return this.getAttribute("url")}set url(t){t?this.setAttribute("url",t):this.removeAttribute("url")}get token(){return this.getAttribute("token")}set token(t){t?this.setAttribute("token",t):this.removeAttribute("token")}attributeChangedCallback(t,i,s){(t==="url"||t==="token")&&i!==s?this.url&&this.token?this.load():x(this,be)&&oe(this,Me,op).call(this):t!=="url"&&t!=="token"&&super.attributeChangedCallback(t,i,s)}async load(){var T,S,R;let t=!x(this,be);oe(this,Me,op).call(this);let i=this.url,s=this.token;if(!i||!s)return;if(F(this,Ma,new Promise(_=>{F(this,Lr,_)})),t&&!x(this,Ui))try{F(this,Ui,JSON.parse(((S=(T=this.shadowRoot)==null?void 0:T.getElementById("config"))==null?void 0:S.textContent)||"{}"))}catch(_){console.error("[livekit-video] Failed to parse config:",_),F(this,Ui,{})}let r=oe(this,Me,Px).call(this),a=oe(this,Me,wx).call(this);F(this,be,new Rl(r)),this.room=x(this,be);let o=()=>{F(this,ns,"connected")},l=_=>{let A=_!=null?Oi[_]??String(_):"undefined";console.log("[livekit-video] Disconnected",{reason:_,reasonName:A,documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState}),F(this,ns,"disconnected"),oe(this,Me,jd).call(this),_?this.dispatchEvent(di(new Error(`LiveKit disconnected: ${A} (${_})`),4001)):this.dispatchEvent(He(Yl))},c=()=>{console.log("[livekit-video] Reconnecting",{documentHidden:document.hidden,documentHasFocus:document.hasFocus()}),F(this,ns,"reconnecting"),this.dispatchEvent(He(Ga))},d=()=>{console.log("[livekit-video] Reconnected"),F(this,ns,"connected"),this.dispatchEvent(He(Ds))},u=()=>{console.log("[livekit-video] SignalReconnecting")},h=_=>{console.log("[livekit-video] ConnectionStateChanged",_)},f=_=>{console.error("[livekit-video] MediaDevicesError",_)},m=_=>{console.log("[livekit-video] AudioPlaybackStatusChanged",_),_?(oe(this,Me,jd).call(this),oe(this,Me,xl).call(this)):oe(this,Me,jb).call(this)},p=(_,A,I)=>{console.error("[livekit-video] TrackSubscriptionFailed",{trackSid:_,reason:I})},g=_=>{console.log("[livekit-video] TrackMuted",{sid:_.trackSid,kind:_.kind})},v=_=>{console.log("[livekit-video] TrackUnmuted",{sid:_.trackSid,kind:_.kind})},E=(_,A)=>{var I,C,w,O;if(_.kind===$.Kind.Video){let N=_.attach();N.style.width="100%",N.style.height="100%",N.style.position="absolute",N.style.top="0",N.style.left="0",N.playsInline=!0,N.setAttribute("playsinline",""),N.setAttribute("webkit-playsinline",""),this.nativeEl.muted&&(N.muted=!0),this.nativeEl.style.display="none",(I=this.shadowRoot)==null||I.appendChild(N),F(this,ht,N),oe(this,Me,xx).call(this,N),oe(this,Me,Lx).call(this,A),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:N}})),this.dispatchEvent(He(Fp)),this.dispatchEvent(He(Ms)),this.dispatchEvent(He(Ql)),this.dispatchEvent(He(Ds)),(C=x(this,Lr))==null||C.call(this)}else if(_.kind===$.Kind.Audio){let N=_.attach();N.style.display="none",(w=this.shadowRoot)==null||w.appendChild(N),F(this,Ht,N),oe(this,Me,xl).call(this);let q=()=>{x(this,Ht)===N&&oe(this,Me,xl).call(this)};N.addEventListener(Ka,q),(O=x(this,Is))==null||O.call(this),F(this,Is,()=>N.removeEventListener(Ka,q)),x(this,be)&&!x(this,be).canPlaybackAudio&&oe(this,Me,jb).call(this)}},b=_=>{var A;_.kind===$.Kind.Video?(_.detach(),oe(this,Me,lp).call(this),x(this,ht)&&(x(this,zi).forEach(I=>I()),F(this,zi,[]),x(this,ht).remove(),F(this,ht,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}})))):_.kind===$.Kind.Audio&&(_.detach(),x(this,Ht)&&(x(this,Ht).remove(),F(this,Ht,null)),(A=x(this,Is))==null||A.call(this),F(this,Is,null),oe(this,Me,jd).call(this))};x(this,be).on(B.Connected,o),x(this,be).on(B.Disconnected,l),x(this,be).on(B.Reconnecting,c),x(this,be).on(B.Reconnected,d),x(this,be).on(B.SignalReconnecting,u),x(this,be).on(B.ConnectionStateChanged,h),x(this,be).on(B.MediaDevicesError,f),x(this,be).on(B.AudioPlaybackStatusChanged,m),x(this,be).on(B.TrackSubscribed,E),x(this,be).on(B.TrackUnsubscribed,b),x(this,be).on(B.TrackSubscriptionFailed,p),x(this,be).on(B.TrackMuted,g),x(this,be).on(B.TrackUnmuted,v),F(this,Pl,[()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Connected,o)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Disconnected,l)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Reconnecting,c)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.Reconnected,d)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.SignalReconnecting,u)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.ConnectionStateChanged,h)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.MediaDevicesError,f)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.AudioPlaybackStatusChanged,m)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackSubscribed,E)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackUnsubscribed,b)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackSubscriptionFailed,p)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackMuted,g)},()=>{var _;return(_=x(this,be))==null?void 0:_.off(B.TrackUnmuted,v)}]),F(this,ns,"connecting"),this.dispatchEvent(He(Up));try{await x(this,be).connect(i,s,a)}catch(_){F(this,ns,"failed"),console.error("[livekit-video] Failed to connect:",_);let A=_ instanceof Error?_.message:"Failed to connect to LiveKit room";this.dispatchEvent(di(new Error(A),4e3)),(R=x(this,Lr))==null||R.call(this)}}async play(){return x(this,Ma)&&await x(this,Ma),x(this,ht)?x(this,ht).play():super.play()}pause(){if(x(this,ht)){x(this,ht).pause();return}super.pause()}get currentTime(){var t;return((t=x(this,ht))==null?void 0:t.currentTime)??super.currentTime}set currentTime(t){x(this,be)||(super.currentTime=t)}get duration(){return 1/0}get paused(){var t;return((t=x(this,ht))==null?void 0:t.paused)??super.paused}get volume(){return super.volume}set volume(t){super.volume=t,x(this,ht)&&(x(this,ht).volume=t),x(this,Ht)&&(x(this,Ht).volume=t)}get muted(){return super.muted}set muted(t){super.muted=t,x(this,ht)&&(x(this,ht).muted=t),x(this,Ht)&&(x(this,Ht).muted=t)}get videoWidth(){var t;return((t=x(this,ht))==null?void 0:t.videoWidth)??super.videoWidth}get videoHeight(){var t;return((t=x(this,ht))==null?void 0:t.videoHeight)??super.videoHeight}disconnectedCallback(){var t;oe(this,Me,op).call(this),(t=super.disconnectedCallback)==null||t.call(this)}};Ui=new WeakMap,be=new WeakMap,ht=new WeakMap,Ht=new WeakMap,zi=new WeakMap,Ll=new WeakMap,Pl=new WeakMap,ns=new WeakMap,Ma=new WeakMap,Lr=new WeakMap,Oa=new WeakMap,Is=new WeakMap,Me=new WeakSet,op=function(){var t,i;(t=x(this,Lr))==null||t.call(this),F(this,Ma,null),F(this,Lr,null),x(this,zi).forEach(s=>s()),F(this,zi,[]),oe(this,Me,lp).call(this),x(this,Pl).forEach(s=>s()),F(this,Pl,[]),x(this,be)&&(x(this,be).disconnect(),F(this,be,null),this.room=null),x(this,ht)&&(x(this,ht).remove(),F(this,ht,null),this.dispatchEvent(new CustomEvent("activevideoelementchange",{detail:{video:null}}))),x(this,Ht)&&(x(this,Ht).remove(),F(this,Ht,null)),(i=x(this,Is))==null||i.call(this),F(this,Is,null),oe(this,Me,jd).call(this),F(this,ns,"disconnected")},jb=function(){if(x(this,Oa))return;let t=!1,i=()=>{let s=x(this,be);if(!s)return;let r=s.startAudio();oe(this,Me,xl).call(this),r.then(()=>{x(this,be)===s&&oe(this,Me,xl).call(this)}).catch(a=>{t||(t=!0,console.warn("[livekit-video] startAudio failed",a))})};document.addEventListener("click",i,{capture:!0}),document.addEventListener("touchend",i,{capture:!0,passive:!0}),document.addEventListener("keydown",i,{capture:!0}),F(this,Oa,()=>{document.removeEventListener("click",i,{capture:!0}),document.removeEventListener("touchend",i,{capture:!0}),document.removeEventListener("keydown",i,{capture:!0})})},jd=function(){var t;(t=x(this,Oa))==null||t.call(this),F(this,Oa,null)},xl=function(){x(this,Ht)&&(x(this,Ht).muted=fp(Yd.prototype,this,"muted"),x(this,Ht).volume=fp(Yd.prototype,this,"volume"))},xx=function(t){x(this,zi).forEach(a=>a()),F(this,zi,[]);let i=[zl,jl,Ds,Fr,Ms];for(let a of i){let o=()=>{this.dispatchEvent(He(a))};t.addEventListener(a,o),x(this,zi).push(()=>t.removeEventListener(a,o))}let s=()=>{var o,l,c;let a=t.srcObject;console.error("[livekit-video] attached <video> error",{code:(o=t.error)==null?void 0:o.code,message:(l=t.error)==null?void 0:l.message,readyState:t.readyState,networkState:t.networkState,paused:t.paused,srcObjectActive:a==null?void 0:a.active,tracks:a==null?void 0:a.getTracks().map(d=>({kind:d.kind,readyState:d.readyState,muted:d.muted,enabled:d.enabled})),documentHidden:document.hidden,documentHasFocus:document.hasFocus(),visibilityState:document.visibilityState,roomState:(c=x(this,be))==null?void 0:c.state})};t.addEventListener("error",s),x(this,zi).push(()=>t.removeEventListener("error",s));let r=()=>{console.warn("[livekit-video] attached <video> stalled",{readyState:t.readyState,networkState:t.networkState,documentHidden:document.hidden})};t.addEventListener("stalled",r),x(this,zi).push(()=>t.removeEventListener("stalled",r))},Lx=function(t){var o;oe(this,Me,lp).call(this);let i=(o=t.trackInfo)==null?void 0:o.layers;if(!i||i.length===0)return;let s=this.addVideoTrack("main");s.id="main",s.selected=!0;let r=[...i].sort((l,c)=>l.quality-c.quality);for(let l of r){let c=s.addRendition("",l.width,l.height,void 0,l.bitrate);c.id=`${l.quality}`}let a=()=>{let l=this.videoRenditions.selectedIndex;if(l<0)t.setVideoQuality(li.HIGH);else{let c=r[l];c&&t.setVideoQuality(c.quality)}};this.videoRenditions.addEventListener("change",a),x(this,Ll).push(()=>this.videoRenditions.removeEventListener("change",a))},lp=function(){x(this,Ll).forEach(t=>t()),F(this,Ll,[]);for(let t of this.videoTracks)this.removeVideoTrack(t);for(let t of this.audioTracks)this.removeAudioTrack(t)},Px=function(){var t,i,s;return{adaptiveStream:((t=x(this,Ui))==null?void 0:t.adaptiveStream)??!1,dynacast:((i=x(this,Ui))==null?void 0:i.dynacast)??!0,disconnectOnPageLeave:((s=x(this,Ui))==null?void 0:s.disconnectOnPageLeave)??!1}},wx=function(){var t,i;return{autoSubscribe:!0,peerConnectionTimeout:((t=x(this,Ui))==null?void 0:t.peerConnectionTimeout)??8e3,rtcConfig:{iceTransportPolicy:((i=x(this,Ui))==null?void 0:i.iceTransportPolicy)??"all"}}},cp=function(t){if(Object.prototype.hasOwnProperty.call(this,t)){let i=this[t];delete this[t],this[t]=i}},Yd.shadowRootOptions={...vi.shadowRootOptions};var wl=Yd;globalThis.customElements&&!globalThis.customElements.get("livekit-video")&&globalThis.customElements.define("livekit-video",wl);var Dx=wl;export{du as Attribute,at as BPDefaultUI,Ys as BPErrorDisplay,Sn as BPLiveError,Gl as BPLiveService,us as BPOverlay,ui as BPPlayer,Ji as HLS_ERROR_CODES,mt as Hls,_a as HlsVideo,FC as HlsVideoElement,wl as LiveKitVideo,Dx as LiveKitVideoElement,Qx as NANOPLAYER_NO_REPLAY_CODES,Ia as NanoVideo,GC as NanoVideoElement,Zx as StateReceiverMixin,$a as StateReceiverProps,ql as addGlobalStyles,xp as classifyHlsError,Rp as classifyLiveKitError,Ip as classifyNanoPlayerError,ru as createInitialState,Mp as createPlayerCore,nL as createTemplate,Va as forEachStateReceiverElement,ou as isBPLiveClipSource,Lp as isBPLiveSource,au as isBPLiveStreamSource,Op as isStateReceiverElement,lu as propagateStateToReceiver,cu as removeStateFromReceiver,sL as templateWithStyles,Ot as toggleAttribute};
|
|
2994
3019
|
/*! Bundled license information:
|
|
2995
3020
|
|
|
2996
3021
|
@lit/reactive-element/css-tag.js:
|