var Pt=Object.defineProperty;var $t=(i,e,t)=>e in i?Pt(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var l=(i,e,t)=>($t(i,typeof e!="symbol"?e+"":e,t),t),dt=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)};var r=(i,e,t)=>(dt(i,e,"read from private field"),t?t.call(i):e.get(i)),f=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},h=(i,e,t,n)=>(dt(i,e,"write to private field"),n?n.call(i,t):e.set(i,t),t);var y=(i,e,t)=>(dt(i,e,"access private method"),t);const Mt=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Rt=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function Vt(i){return`
    <style>
      :host {
        display: inline-flex;
        line-height: 0;
        flex-direction: column;
        justify-content: end;
      }

      audio {
        width: 100%;
      }
    </style>
    <slot name="media">
      <audio${qt(i)}></audio>
    </slot>
    <slot></slot>
  `}function It(i){return`
    <style>
      :host {
        display: inline-block;
        line-height: 0;
      }

      video {
        max-width: 100%;
        max-height: 100%;
        min-width: 100%;
        min-height: 100%;
        object-fit: var(--media-object-fit, contain);
        object-position: var(--media-object-position, 50% 50%);
      }

      video::-webkit-media-text-track-container {
        transform: var(--media-webkit-text-track-transform);
        transition: var(--media-webkit-text-track-transition);
      }
    </style>
    <slot name="media">
      <video${qt(i)}></video>
    </slot>
    <slot></slot>
  `}function xt(i,{tag:e,is:t}){var c,a,v,m,_,wt,K,z,T,I,E,R,C,Q,at,X,ct,tt,Lt,Y,ht,et,St,it,At;const n=(a=(c=globalThis.document)==null?void 0:c.createElement)==null?void 0:a.call(c,e,{is:t}),d=n?Ct(n):[];return v=class extends i{constructor(){super(...arguments);f(this,R);f(this,Q);f(this,X);f(this,tt);f(this,Y);f(this,et);f(this,it);f(this,K,!1);f(this,z,null);f(this,T,new Map);f(this,I,void 0);f(this,E,void 0);l(this,"get");l(this,"set");l(this,"call")}static get observedAttributes(){var u,k;return y(u=v,_,wt).call(u),[...((k=n==null?void 0:n.constructor)==null?void 0:k.observedAttributes)??[],...Rt]}get nativeEl(){var s;return y(this,R,C).call(this),r(this,z)??this.querySelector(":scope > [slot=media]")??this.querySelector(e)??((s=this.shadowRoot)==null?void 0:s.querySelector(e))??null}set nativeEl(s){h(this,z,s)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(s){this.toggleAttribute("muted",s)}get src(){return this.getAttribute("src")}set src(s){this.setAttribute("src",`${s}`)}get preload(){var s;return this.getAttribute("preload")??((s=this.nativeEl)==null?void 0:s.preload)}set preload(s){this.setAttribute("preload",`${s}`)}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});const s=Ht(this.attributes);t&&(s.is=t),e&&(s.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(s)}this.nativeEl.muted=this.hasAttribute("muted");for(const s of d)y(this,et,St).call(this,s);y(this,Q,at).call(this)}handleEvent(s){s.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(s.type,{detail:s.detail}))}attributeChangedCallback(s,u,k){y(this,R,C).call(this),y(this,it,At).call(this,s,u,k)}connectedCallback(){y(this,R,C).call(this),r(this,E)||y(this,Q,at).call(this)}disconnectedCallback(){var s,u,k;(s=r(this,I))==null||s.disconnect(),h(this,I,void 0),r(this,E)&&((u=this.shadowRoot)==null||u.removeEventListener("slotchange",r(this,E)),h(this,E,void 0));for(const g of this.constructor.Events)(k=this.shadowRoot)==null||k.removeEventListener(g,this,!0);r(this,T).forEach(g=>g.remove()),r(this,T).clear(),h(this,z,null)}},m=new WeakMap,_=new WeakSet,wt=function(){if(r(this,m))return;h(this,m,!0);const s=new Set(this.observedAttributes);s.delete("muted");for(const u of d)if(!(u in this.prototype))if(typeof n[u]=="function")this.prototype[u]=function(...k){return y(this,R,C).call(this),(()=>{var b;if(this.call)return this.call(u,...k);const p=(b=this.nativeEl)==null?void 0:b[u];return p==null?void 0:p.apply(this.nativeEl,k)})()};else{const k={get(){var p,b;y(this,R,C).call(this);const g=u.toLowerCase();if(s.has(g)){const B=this.getAttribute(g);return B===null?!1:B===""?!0:B}return((p=this.get)==null?void 0:p.call(this,u))??((b=this.nativeEl)==null?void 0:b[u])}};u!==u.toUpperCase()&&(k.set=function(g){y(this,R,C).call(this);const p=u.toLowerCase();if(s.has(p)){g===!0||g===!1||g==null?this.toggleAttribute(p,!!g):this.setAttribute(p,g);return}if(this.set){this.set(u,g);return}this.nativeEl&&(this.nativeEl[u]=g)}),Object.defineProperty(this.prototype,u,k)}},K=new WeakMap,z=new WeakMap,T=new WeakMap,I=new WeakMap,E=new WeakMap,R=new WeakSet,C=function(){r(this,K)||(h(this,K,!0),this.init())},Q=new WeakSet,at=function(){var s,u;h(this,I,new MutationObserver(y(this,tt,Lt).bind(this))),h(this,E,()=>y(this,X,ct).call(this)),(s=this.shadowRoot)==null||s.addEventListener("slotchange",r(this,E)),y(this,X,ct).call(this);for(const k of this.constructor.Events)(u=this.shadowRoot)==null||u.addEventListener(k,this,!0)},X=new WeakSet,ct=function(){var g;const s=new Map(r(this,T)),u=(g=this.shadowRoot)==null?void 0:g.querySelector("slot:not([name])");(u==null?void 0:u.assignedElements({flatten:!0}).filter(p=>["track","source"].includes(p.localName))).forEach(p=>{var B,bt;s.delete(p);let b=r(this,T).get(p);b||(b=p.cloneNode(),r(this,T).set(p,b),(B=r(this,I))==null||B.observe(p,{attributes:!0})),(bt=this.nativeEl)==null||bt.append(b),y(this,Y,ht).call(this,b)}),s.forEach((p,b)=>{p.remove(),r(this,T).delete(b)})},tt=new WeakSet,Lt=function(s){for(const u of s)if(u.type==="attributes"){const{target:k,attributeName:g}=u,p=r(this,T).get(k);p&&g&&(p.setAttribute(g,k.getAttribute(g)??""),y(this,Y,ht).call(this,p))}},Y=new WeakSet,ht=function(s){s&&s.localName==="track"&&s.default&&(s.kind==="chapters"||s.kind==="metadata")&&s.track.mode==="disabled"&&(s.track.mode="hidden")},et=new WeakSet,St=function(s){if(Object.prototype.hasOwnProperty.call(this,s)){const u=this[s];delete this[s],this[s]=u}},it=new WeakSet,At=function(s,u,k){var g,p,b;["id","class"].includes(s)||!v.observedAttributes.includes(s)&&this.constructor.observedAttributes.includes(s)||(k===null?(g=this.nativeEl)==null||g.removeAttribute(s):((p=this.nativeEl)==null?void 0:p.getAttribute(s))!==k&&((b=this.nativeEl)==null||b.setAttribute(s,k)))},f(v,_),l(v,"getTemplateHTML",e.endsWith("audio")?Vt:It),l(v,"shadowRootOptions",{mode:"open"}),l(v,"Events",Mt),f(v,m,!1),v}function Ct(i){const e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t)){const n=Object.getOwnPropertyNames(t);e.push(...n)}return e}function qt(i){let e="";for(const t in i){if(!Rt.includes(t))continue;const n=i[t];n===""?e+=` ${t}`:e+=` ${t}="${n}"`}return e}function Ht(i){const e={};for(const t of i)e[t.name]=t.value;return e}const te=xt(globalThis.HTMLElement??class{},{tag:"video"});xt(globalThis.HTMLElement??class{},{tag:"audio"});class ot extends Event{constructor(t,n){super(t);l(this,"track");this.track=n.track}}const ut=new WeakMap;function o(i){return ut.get(i)??zt(i,{})}function zt(i,e){let t=ut.get(i);return t||ut.set(i,t={}),Object.assign(t,e)}function ft(i,e){const t=i.videoTracks;o(e).media=new WeakRef(i),o(e).renditionSet||(o(e).renditionSet=new Set);const n=o(t).trackSet;n.add(e);const d=n.size-1;d in lt.prototype||Object.defineProperty(lt.prototype,d,{get(){return[...o(this).trackSet][d]}}),queueMicrotask(()=>{t.dispatchEvent(new ot("addtrack",{track:e}))})}function vt(i){var n,d;const e=(d=(n=o(i).media)==null?void 0:n.deref())==null?void 0:d.videoTracks;if(!e)return;o(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new ot("removetrack",{track:i}))})}function Bt(i){var n,d;const e=((d=(n=o(i).media)==null?void 0:n.deref())==null?void 0:d.videoTracks)??[];let t=!1;for(const c of e)c!==i&&(c.selected=!1,t=!0);if(t){if(o(e).changeRequested)return;o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,e.dispatchEvent(new Event("change"))})}}var w,L,S,H,Z;class lt extends EventTarget{constructor(){super();f(this,H);f(this,w,void 0);f(this,L,void 0);f(this,S,void 0);o(this).trackSet=new Set}[Symbol.iterator](){return r(this,H,Z).values()}get length(){return r(this,H,Z).size}getTrackById(t){return[...r(this,H,Z)].find(n=>n.id===t)??null}get selectedIndex(){return[...r(this,H,Z)].findIndex(t=>t.selected)}get onaddtrack(){return r(this,w)}set onaddtrack(t){r(this,w)&&(this.removeEventListener("addtrack",r(this,w)),h(this,w,void 0)),typeof t=="function"&&(h(this,w,t),this.addEventListener("addtrack",t))}get onremovetrack(){return r(this,L)}set onremovetrack(t){r(this,L)&&(this.removeEventListener("removetrack",r(this,L)),h(this,L,void 0)),typeof t=="function"&&(h(this,L,t),this.addEventListener("removetrack",t))}get onchange(){return r(this,S)}set onchange(t){r(this,S)&&(this.removeEventListener("change",r(this,S)),h(this,S,void 0)),typeof t=="function"&&(h(this,S,t),this.addEventListener("change",t))}}w=new WeakMap,L=new WeakMap,S=new WeakMap,H=new WeakSet,Z=function(){return o(this).trackSet};class st extends Event{constructor(t,n){super(t);l(this,"rendition");this.rendition=n.rendition}}function Wt(i,e){var c,a;const t=(a=(c=o(i).media)==null?void 0:c.deref())==null?void 0:a.videoRenditions;o(e).media=o(i).media,o(e).track=i;const n=o(i).renditionSet;n.add(e);const d=n.size-1;d in pt.prototype||Object.defineProperty(pt.prototype,d,{get(){return W(this)[d]}}),queueMicrotask(()=>{!t||!i.selected||t.dispatchEvent(new st("addrendition",{rendition:e}))})}function Ft(i){var d,c;const e=(c=(d=o(i).media)==null?void 0:d.deref())==null?void 0:c.videoRenditions,t=o(i).track;o(t).renditionSet.delete(i),queueMicrotask(()=>{const a=o(i).track;!e||!a.selected||e.dispatchEvent(new st("removerendition",{rendition:i}))})}function Dt(i){var t,n;const e=(n=(t=o(i).media)==null?void 0:t.deref())==null?void 0:n.videoRenditions;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,o(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function W(i){var t;const e=(t=o(i).media)==null?void 0:t.deref();return e?[...e.videoTracks].filter(n=>n.selected).flatMap(n=>[...o(n).renditionSet]):[]}var A,x,q;class pt extends EventTarget{constructor(){super(...arguments);f(this,A,void 0);f(this,x,void 0);f(this,q,void 0)}[Symbol.iterator](){return W(this).values()}get length(){return W(this).length}getRenditionById(t){return W(this).find(n=>`${n.id}`==`${t}`)??null}get selectedIndex(){return W(this).findIndex(t=>t.selected)}set selectedIndex(t){for(const[n,d]of W(this).entries())d.selected=n===t}get onaddrendition(){return r(this,A)}set onaddrendition(t){r(this,A)&&(this.removeEventListener("addrendition",r(this,A)),h(this,A,void 0)),typeof t=="function"&&(h(this,A,t),this.addEventListener("addrendition",t))}get onremoverendition(){return r(this,x)}set onremoverendition(t){r(this,x)&&(this.removeEventListener("removerendition",r(this,x)),h(this,x,void 0)),typeof t=="function"&&(h(this,x,t),this.addEventListener("removerendition",t))}get onchange(){return r(this,q)}set onchange(t){r(this,q)&&(this.removeEventListener("change",r(this,q)),h(this,q,void 0)),typeof t=="function"&&(h(this,q,t),this.addEventListener("change",t))}}A=new WeakMap,x=new WeakMap,q=new WeakMap;var D;class Nt{constructor(){l(this,"src");l(this,"id");l(this,"width");l(this,"height");l(this,"bitrate");l(this,"frameRate");l(this,"codec");f(this,D,!1)}get selected(){return r(this,D)}set selected(e){r(this,D)!==e&&(h(this,D,e),Dt(this))}}D=new WeakMap;var N;class Ot{constructor(){l(this,"id");l(this,"kind");l(this,"label","");l(this,"language","");l(this,"sourceBuffer");f(this,N,!1)}addRendition(e,t,n,d,c,a){const v=new Nt;return v.src=e,v.width=t,v.height=n,v.frameRate=a,v.bitrate=c,v.codec=d,Wt(this,v),v}removeRendition(e){Ft(e)}get selected(){return r(this,N)}set selected(e){r(this,N)!==e&&(h(this,N,e),e===!0&&Bt(this))}}N=new WeakMap;function Ut(i,e){var c,a;const t=(a=(c=o(i).media)==null?void 0:c.deref())==null?void 0:a.audioRenditions;o(e).media=o(i).media,o(e).track=i;const n=o(i).renditionSet;n.add(e);const d=n.size-1;d in gt.prototype||Object.defineProperty(gt.prototype,d,{get(){return F(this)[d]}}),queueMicrotask(()=>{!t||!i.enabled||t.dispatchEvent(new st("addrendition",{rendition:e}))})}function Gt(i){var d,c;const e=(c=(d=o(i).media)==null?void 0:d.deref())==null?void 0:c.audioRenditions,t=o(i).track;o(t).renditionSet.delete(i),queueMicrotask(()=>{const a=o(i).track;!e||!a.enabled||e.dispatchEvent(new st("removerendition",{rendition:i}))})}function Jt(i){var t,n;const e=(n=(t=o(i).media)==null?void 0:t.deref())==null?void 0:n.audioRenditions;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,o(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function F(i){var t;const e=(t=o(i).media)==null?void 0:t.deref();return e?[...e.audioTracks].filter(n=>n.enabled).flatMap(n=>[...o(n).renditionSet]):[]}var O,j,P;class gt extends EventTarget{constructor(){super(...arguments);f(this,O,void 0);f(this,j,void 0);f(this,P,void 0)}[Symbol.iterator](){return F(this).values()}get length(){return F(this).length}getRenditionById(t){return F(this).find(n=>`${n.id}`==`${t}`)??null}get selectedIndex(){return F(this).findIndex(t=>t.selected)}set selectedIndex(t){for(const[n,d]of F(this).entries())d.selected=n===t}get onaddrendition(){return r(this,O)}set onaddrendition(t){r(this,O)&&(this.removeEventListener("addrendition",r(this,O)),h(this,O,void 0)),typeof t=="function"&&(h(this,O,t),this.addEventListener("addrendition",t))}get onremoverendition(){return r(this,j)}set onremoverendition(t){r(this,j)&&(this.removeEventListener("removerendition",r(this,j)),h(this,j,void 0)),typeof t=="function"&&(h(this,j,t),this.addEventListener("removerendition",t))}get onchange(){return r(this,P)}set onchange(t){r(this,P)&&(this.removeEventListener("change",r(this,P)),h(this,P,void 0)),typeof t=="function"&&(h(this,P,t),this.addEventListener("change",t))}}O=new WeakMap,j=new WeakMap,P=new WeakMap;var U;class Kt{constructor(){l(this,"src");l(this,"id");l(this,"bitrate");l(this,"codec");f(this,U,!1)}get selected(){return r(this,U)}set selected(e){r(this,U)!==e&&(h(this,U,e),Jt(this))}}U=new WeakMap;function kt(i,e){const t=i.audioTracks;o(e).media=new WeakRef(i),o(e).renditionSet||(o(e).renditionSet=new Set);const n=o(t).trackSet;n.add(e);const d=n.size-1;d in yt.prototype||Object.defineProperty(yt.prototype,d,{get(){return[...o(this).trackSet][d]}}),queueMicrotask(()=>{t.dispatchEvent(new ot("addtrack",{track:e}))})}function mt(i){var n,d;const e=(d=(n=o(i).media)==null?void 0:n.deref())==null?void 0:d.audioTracks;if(!e)return;o(e).trackSet.delete(i),queueMicrotask(()=>{e.dispatchEvent(new ot("removetrack",{track:i}))})}function Qt(i){var t,n;const e=(n=(t=o(i).media)==null?void 0:t.deref())==null?void 0:n.audioTracks;!e||o(e).changeRequested||(o(e).changeRequested=!0,queueMicrotask(()=>{delete o(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var $,M,V,G,nt;class yt extends EventTarget{constructor(){super();f(this,G);f(this,$,void 0);f(this,M,void 0);f(this,V,void 0);o(this).trackSet=new Set}[Symbol.iterator](){return r(this,G,nt).values()}get length(){return r(this,G,nt).size}getTrackById(t){return[...r(this,G,nt)].find(n=>n.id===t)??null}get onaddtrack(){return r(this,$)}set onaddtrack(t){r(this,$)&&(this.removeEventListener("addtrack",r(this,$)),h(this,$,void 0)),typeof t=="function"&&(h(this,$,t),this.addEventListener("addtrack",t))}get onremovetrack(){return r(this,M)}set onremovetrack(t){r(this,M)&&(this.removeEventListener("removetrack",r(this,M)),h(this,M,void 0)),typeof t=="function"&&(h(this,M,t),this.addEventListener("removetrack",t))}get onchange(){return r(this,V)}set onchange(t){r(this,V)&&(this.removeEventListener("change",r(this,V)),h(this,V,void 0)),typeof t=="function"&&(h(this,V,t),this.addEventListener("change",t))}}$=new WeakMap,M=new WeakMap,V=new WeakMap,G=new WeakSet,nt=function(){return o(this).trackSet};var J;class jt{constructor(){l(this,"id");l(this,"kind");l(this,"label","");l(this,"language","");l(this,"sourceBuffer");f(this,J,!1)}addRendition(e,t,n){const d=new Kt;return d.src=e,d.codec=t,d.bitrate=n,Ut(this,d),d}removeRendition(e){Gt(e)}get enabled(){return r(this,J)}set enabled(e){r(this,J)!==e&&(h(this,J,e),Qt(this))}}J=new WeakMap;const Tt=rt(globalThis.HTMLMediaElement,"video"),Et=rt(globalThis.HTMLMediaElement,"audio");function ee(i){if(!(i!=null&&i.prototype))return i;const e=rt(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return Xt(this)}});const t=rt(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return Yt(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(c,a="",v=""){const m=new Ot;return m.kind=c,m.label=a,m.language=v,ft(this,m),m}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=vt),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(c,a="",v=""){const m=new jt;return m.kind=c,m.label=a,m.language=v,kt(this,m),m}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=mt),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return n(this)}});const n=c=>{let a=o(c).videoRenditions;return a||(a=new pt,o(a).media=new WeakRef(c),o(c).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return d(this)}});const d=c=>{let a=o(c).audioRenditions;return a||(a=new gt,o(a).media=new WeakRef(c),o(c).audioRenditions=a),a};return i}function rt(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function Xt(i){let e=o(i).videoTracks;if(!e&&(e=new lt,o(i).videoTracks=e,Tt)){const t=Tt.call(i.nativeEl??i);for(const a of t)ft(i,a);const n=()=>{e.dispatchEvent(new Event("change"))},d=a=>{if([...e].some(v=>v instanceof Ot)){for(const v of t)vt(v);return}ft(i,a.track)},c=a=>{vt(a.track)};t.addEventListener("change",n),t.addEventListener("addtrack",d),t.addEventListener("removetrack",c)}return e}function Yt(i){let e=o(i).audioTracks;if(!e&&(e=new yt,o(i).audioTracks=e,Et)){const t=Et.call(i.nativeEl??i);for(const a of t)kt(i,a);const n=()=>{e.dispatchEvent(new Event("change"))},d=a=>{if([...e].some(v=>v instanceof jt)){for(const v of t)mt(v);return}kt(i,a.track)},c=a=>{mt(a.track)};t.addEventListener("change",n),t.addEventListener("addtrack",d),t.addEventListener("removetrack",c)}return e}export{te as C,ee as M};
