mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-15 03:02:17 -05:00
45 lines
15 KiB
JavaScript
45 lines
15 KiB
JavaScript
const C=["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"],q=["autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"];function $(e){return`
|
|
<style>
|
|
:host {
|
|
display: inline-flex;
|
|
line-height: 0;
|
|
flex-direction: column;
|
|
justify-content: end;
|
|
}
|
|
|
|
audio {
|
|
width: 100%;
|
|
}
|
|
</style>
|
|
<slot name="media">
|
|
<audio${O(e)}></audio>
|
|
</slot>
|
|
<slot></slot>
|
|
`}function V(e){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${O(e)}></video>
|
|
</slot>
|
|
<slot></slot>
|
|
`}function M(e,{tag:t,is:i}){const o=globalThis.document?.createElement?.(t,{is:i}),d=o?I(o):[];return class k extends e{static getTemplateHTML=t.endsWith("audio")?$:V;static shadowRootOptions={mode:"open"};static Events=C;static#t=!1;static get observedAttributes(){return k.#i(),[...o?.constructor?.observedAttributes??[],...q]}static#i(){if(this.#t)return;this.#t=!0;const n=new Set(this.observedAttributes);n.delete("muted");for(const s of d)if(!(s in this.prototype))if(typeof o[s]=="function")this.prototype[s]=function(...a){return this.#o(),this.call?this.call(s,...a):this.nativeEl?.[s]?.apply(this.nativeEl,a)};else{const a={get(){this.#o();const c=s.toLowerCase();if(n.has(c)){const h=this.getAttribute(c);return h===null?!1:h===""?!0:h}return this.get?.(s)??this.nativeEl?.[s]}};s!==s.toUpperCase()&&(a.set=function(c){this.#o();const h=s.toLowerCase();if(n.has(h)){c===!0||c===!1||c==null?this.toggleAttribute(h,!!c):this.setAttribute(h,c);return}if(this.set){this.set(s,c);return}this.nativeEl&&(this.nativeEl[s]=c)}),Object.defineProperty(this.prototype,s,a)}}#e=!1;#n=null;#r=new Map;#d;#s;get;set;call;get nativeEl(){return this.#o(),this.#n??this.querySelector(":scope > [slot=media]")??this.querySelector(t)??this.shadowRoot?.querySelector(t)??null}set nativeEl(n){this.#n=n}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(n){this.toggleAttribute("muted",n)}get src(){return this.getAttribute("src")}set src(n){this.setAttribute("src",`${n}`)}get preload(){return this.getAttribute("preload")??this.nativeEl?.preload}set preload(n){this.setAttribute("preload",`${n}`)}#o(){this.#e||(this.#e=!0,this.init())}init(){if(!this.shadowRoot){this.attachShadow({mode:"open"});const n=H(this.attributes);i&&(n.is=i),t&&(n.part=t),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(n)}this.nativeEl.muted=this.hasAttribute("muted");for(const n of d)this.#f(n);this.#a()}#a(){this.#d=new MutationObserver(this.#u.bind(this)),this.#s=()=>this.#c(),this.shadowRoot?.addEventListener("slotchange",this.#s),this.#c();for(const n of this.constructor.Events)this.shadowRoot?.addEventListener(n,this,!0)}handleEvent(n){n.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(n.type,{detail:n.detail}))}#c(){const n=new Map(this.#r);(this.shadowRoot?.querySelector("slot:not([name])")?.assignedElements({flatten:!0}).filter(c=>["track","source"].includes(c.localName))).forEach(c=>{n.delete(c);let h=this.#r.get(c);h||(h=c.cloneNode(),this.#r.set(c,h),this.#d?.observe(c,{attributes:!0})),this.nativeEl?.append(h),this.#h(h)}),n.forEach((c,h)=>{c.remove(),this.#r.delete(h)})}#u(n){for(const s of n)if(s.type==="attributes"){const{target:a,attributeName:c}=s,h=this.#r.get(a);h&&c&&(h.setAttribute(c,a.getAttribute(c)??""),this.#h(h))}}#h(n){n&&n.localName==="track"&&n.default&&(n.kind==="chapters"||n.kind==="metadata")&&n.track.mode==="disabled"&&(n.track.mode="hidden")}#f(n){if(Object.prototype.hasOwnProperty.call(this,n)){const s=this[n];delete this[n],this[n]=s}}attributeChangedCallback(n,s,a){this.#o(),this.#l(n,s,a)}#l(n,s,a){["id","class"].includes(n)||!k.observedAttributes.includes(n)&&this.constructor.observedAttributes.includes(n)||(a===null?this.nativeEl?.removeAttribute(n):this.nativeEl?.getAttribute(n)!==a&&this.nativeEl?.setAttribute(n,a))}connectedCallback(){this.#o(),this.#s||this.#a()}disconnectedCallback(){this.#d?.disconnect(),this.#d=void 0,this.#s&&(this.shadowRoot?.removeEventListener("slotchange",this.#s),this.#s=void 0);for(const n of this.constructor.Events)this.shadowRoot?.removeEventListener(n,this,!0);this.#r.forEach(n=>n.remove()),this.#r.clear(),this.#n=null}}}function I(e){const t=[];for(let i=Object.getPrototypeOf(e);i&&i!==HTMLElement.prototype;i=Object.getPrototypeOf(i)){const o=Object.getOwnPropertyNames(i);t.push(...o)}return t}function O(e){let t="";for(const i in e){if(!q.includes(i))continue;const o=e[i];o===""?t+=` ${i}`:t+=` ${i}="${o}"`}return t}function H(e){const t={};for(const i of e)t[i.name]=i.value;return t}const Z=M(globalThis.HTMLElement??class{},{tag:"video"});M(globalThis.HTMLElement??class{},{tag:"audio"});class p extends Event{track;constructor(t,i){super(t),this.track=i.track}}const m=new WeakMap;function r(e){return m.get(e)??z(e,{})}function z(e,t){let i=m.get(e);return i||m.set(e,i={}),Object.assign(i,t)}function y(e,t){const i=e.videoTracks;r(t).media=new WeakRef(e),r(t).renditionSet||(r(t).renditionSet=new Set);const o=r(i).trackSet;o.add(t);const d=o.size-1;d in T.prototype||Object.defineProperty(T.prototype,d,{get(){return[...r(this).trackSet][d]}}),queueMicrotask(()=>{i.dispatchEvent(new p("addtrack",{track:t}))})}function b(e){const t=r(e).media?.deref()?.videoTracks;if(!t)return;r(t).trackSet.delete(e),queueMicrotask(()=>{t.dispatchEvent(new p("removetrack",{track:e}))})}function B(e){const t=r(e).media?.deref()?.videoTracks??[];let i=!1;for(const o of t)o!==e&&(o.selected=!1,i=!0);if(i){if(r(t).changeRequested)return;r(t).changeRequested=!0,queueMicrotask(()=>{delete r(t).changeRequested,t.dispatchEvent(new Event("change"))})}}class T extends EventTarget{#t;#i;#e;constructor(){super(),r(this).trackSet=new Set}get#n(){return r(this).trackSet}[Symbol.iterator](){return this.#n.values()}get length(){return this.#n.size}getTrackById(t){return[...this.#n].find(i=>i.id===t)??null}get selectedIndex(){return[...this.#n].findIndex(t=>t.selected)}get onaddtrack(){return this.#t}set onaddtrack(t){this.#t&&(this.removeEventListener("addtrack",this.#t),this.#t=void 0),typeof t=="function"&&(this.#t=t,this.addEventListener("addtrack",t))}get onremovetrack(){return this.#i}set onremovetrack(t){this.#i&&(this.removeEventListener("removetrack",this.#i),this.#i=void 0),typeof t=="function"&&(this.#i=t,this.addEventListener("removetrack",t))}get onchange(){return this.#e}set onchange(t){this.#e&&(this.removeEventListener("change",this.#e),this.#e=void 0),typeof t=="function"&&(this.#e=t,this.addEventListener("change",t))}}class g extends Event{rendition;constructor(t,i){super(t),this.rendition=i.rendition}}function F(e,t){const i=r(e).media?.deref()?.videoRenditions;r(t).media=r(e).media,r(t).track=e;const o=r(e).renditionSet;o.add(t);const d=o.size-1;d in E.prototype||Object.defineProperty(E.prototype,d,{get(){return f(this)[d]}}),queueMicrotask(()=>{!i||!e.selected||i.dispatchEvent(new g("addrendition",{rendition:t}))})}function W(e){const t=r(e).media?.deref()?.videoRenditions,i=r(e).track;r(i).renditionSet.delete(e),queueMicrotask(()=>{const d=r(e).track;!t||!d.selected||t.dispatchEvent(new g("removerendition",{rendition:e}))})}function D(e){const t=r(e).media?.deref()?.videoRenditions;!t||r(t).changeRequested||(r(t).changeRequested=!0,queueMicrotask(()=>{delete r(t).changeRequested,r(e).track.selected&&t.dispatchEvent(new Event("change"))}))}function f(e){const t=r(e).media?.deref();return t?[...t.videoTracks].filter(i=>i.selected).flatMap(i=>[...r(i).renditionSet]):[]}class E extends EventTarget{#t;#i;#e;[Symbol.iterator](){return f(this).values()}get length(){return f(this).length}getRenditionById(t){return f(this).find(i=>`${i.id}`==`${t}`)??null}get selectedIndex(){return f(this).findIndex(t=>t.selected)}set selectedIndex(t){for(const[i,o]of f(this).entries())o.selected=i===t}get onaddrendition(){return this.#t}set onaddrendition(t){this.#t&&(this.removeEventListener("addrendition",this.#t),this.#t=void 0),typeof t=="function"&&(this.#t=t,this.addEventListener("addrendition",t))}get onremoverendition(){return this.#i}set onremoverendition(t){this.#i&&(this.removeEventListener("removerendition",this.#i),this.#i=void 0),typeof t=="function"&&(this.#i=t,this.addEventListener("removerendition",t))}get onchange(){return this.#e}set onchange(t){this.#e&&(this.removeEventListener("change",this.#e),this.#e=void 0),typeof t=="function"&&(this.#e=t,this.addEventListener("change",t))}}class N{src;id;width;height;bitrate;frameRate;codec;#t=!1;get selected(){return this.#t}set selected(t){this.#t!==t&&(this.#t=t,D(this))}}class j{id;kind;label="";language="";sourceBuffer;#t=!1;addRendition(t,i,o,d,u,n){const s=new N;return s.src=t,s.width=i,s.height=o,s.frameRate=n,s.bitrate=u,s.codec=d,F(this,s),s}removeRendition(t){W(t)}get selected(){return this.#t}set selected(t){this.#t!==t&&(this.#t=t,t===!0&&B(this))}}function U(e,t){const i=r(e).media?.deref()?.audioRenditions;r(t).media=r(e).media,r(t).track=e;const o=r(e).renditionSet;o.add(t);const d=o.size-1;d in R.prototype||Object.defineProperty(R.prototype,d,{get(){return l(this)[d]}}),queueMicrotask(()=>{!i||!e.enabled||i.dispatchEvent(new g("addrendition",{rendition:t}))})}function G(e){const t=r(e).media?.deref()?.audioRenditions,i=r(e).track;r(i).renditionSet.delete(e),queueMicrotask(()=>{const d=r(e).track;!t||!d.enabled||t.dispatchEvent(new g("removerendition",{rendition:e}))})}function J(e){const t=r(e).media?.deref()?.audioRenditions;!t||r(t).changeRequested||(r(t).changeRequested=!0,queueMicrotask(()=>{delete r(t).changeRequested,r(e).track.enabled&&t.dispatchEvent(new Event("change"))}))}function l(e){const t=r(e).media?.deref();return t?[...t.audioTracks].filter(i=>i.enabled).flatMap(i=>[...r(i).renditionSet]):[]}class R extends EventTarget{#t;#i;#e;[Symbol.iterator](){return l(this).values()}get length(){return l(this).length}getRenditionById(t){return l(this).find(i=>`${i.id}`==`${t}`)??null}get selectedIndex(){return l(this).findIndex(t=>t.selected)}set selectedIndex(t){for(const[i,o]of l(this).entries())o.selected=i===t}get onaddrendition(){return this.#t}set onaddrendition(t){this.#t&&(this.removeEventListener("addrendition",this.#t),this.#t=void 0),typeof t=="function"&&(this.#t=t,this.addEventListener("addrendition",t))}get onremoverendition(){return this.#i}set onremoverendition(t){this.#i&&(this.removeEventListener("removerendition",this.#i),this.#i=void 0),typeof t=="function"&&(this.#i=t,this.addEventListener("removerendition",t))}get onchange(){return this.#e}set onchange(t){this.#e&&(this.removeEventListener("change",this.#e),this.#e=void 0),typeof t=="function"&&(this.#e=t,this.addEventListener("change",t))}}class K{src;id;bitrate;codec;#t=!1;get selected(){return this.#t}set selected(t){this.#t!==t&&(this.#t=t,J(this))}}function w(e,t){const i=e.audioTracks;r(t).media=new WeakRef(e),r(t).renditionSet||(r(t).renditionSet=new Set);const o=r(i).trackSet;o.add(t);const d=o.size-1;d in S.prototype||Object.defineProperty(S.prototype,d,{get(){return[...r(this).trackSet][d]}}),queueMicrotask(()=>{i.dispatchEvent(new p("addtrack",{track:t}))})}function L(e){const t=r(e).media?.deref()?.audioTracks;if(!t)return;r(t).trackSet.delete(e),queueMicrotask(()=>{t.dispatchEvent(new p("removetrack",{track:e}))})}function Q(e){const t=r(e).media?.deref()?.audioTracks;!t||r(t).changeRequested||(r(t).changeRequested=!0,queueMicrotask(()=>{delete r(t).changeRequested,t.dispatchEvent(new Event("change"))}))}class S extends EventTarget{#t;#i;#e;constructor(){super(),r(this).trackSet=new Set}get#n(){return r(this).trackSet}[Symbol.iterator](){return this.#n.values()}get length(){return this.#n.size}getTrackById(t){return[...this.#n].find(i=>i.id===t)??null}get onaddtrack(){return this.#t}set onaddtrack(t){this.#t&&(this.removeEventListener("addtrack",this.#t),this.#t=void 0),typeof t=="function"&&(this.#t=t,this.addEventListener("addtrack",t))}get onremovetrack(){return this.#i}set onremovetrack(t){this.#i&&(this.removeEventListener("removetrack",this.#i),this.#i=void 0),typeof t=="function"&&(this.#i=t,this.addEventListener("removetrack",t))}get onchange(){return this.#e}set onchange(t){this.#e&&(this.removeEventListener("change",this.#e),this.#e=void 0),typeof t=="function"&&(this.#e=t,this.addEventListener("change",t))}}class P{id;kind;label="";language="";sourceBuffer;#t=!1;addRendition(t,i,o){const d=new K;return d.src=t,d.codec=i,d.bitrate=o,U(this,d),d}removeRendition(t){G(t)}get enabled(){return this.#t}set enabled(t){this.#t!==t&&(this.#t=t,Q(this))}}const A=v(globalThis.HTMLMediaElement,"video"),x=v(globalThis.HTMLMediaElement,"audio");function _(e){if(!e?.prototype)return e;const t=v(e,"video");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(e.prototype,"videoTracks",{get(){return X(this)}});const i=v(e,"audio");(!i||`${i}`.includes("[native code]"))&&Object.defineProperty(e.prototype,"audioTracks",{get(){return Y(this)}}),"addVideoTrack"in e.prototype||(e.prototype.addVideoTrack=function(u,n="",s=""){const a=new j;return a.kind=u,a.label=n,a.language=s,y(this,a),a}),"removeVideoTrack"in e.prototype||(e.prototype.removeVideoTrack=b),"addAudioTrack"in e.prototype||(e.prototype.addAudioTrack=function(u,n="",s=""){const a=new P;return a.kind=u,a.label=n,a.language=s,w(this,a),a}),"removeAudioTrack"in e.prototype||(e.prototype.removeAudioTrack=L),"videoRenditions"in e.prototype||Object.defineProperty(e.prototype,"videoRenditions",{get(){return o(this)}});const o=u=>{let n=r(u).videoRenditions;return n||(n=new E,r(n).media=new WeakRef(u),r(u).videoRenditions=n),n};"audioRenditions"in e.prototype||Object.defineProperty(e.prototype,"audioRenditions",{get(){return d(this)}});const d=u=>{let n=r(u).audioRenditions;return n||(n=new R,r(n).media=new WeakRef(u),r(u).audioRenditions=n),n};return e}function v(e,t){if(e?.prototype)return Object.getOwnPropertyDescriptor(e.prototype,`${t}Tracks`)?.get}function X(e){let t=r(e).videoTracks;if(!t&&(t=new T,r(e).videoTracks=t,A)){const i=A.call(e.nativeEl??e);for(const n of i)y(e,n);const o=()=>{t.dispatchEvent(new Event("change"))},d=n=>{if([...t].some(s=>s instanceof j)){for(const s of i)b(s);return}y(e,n.track)},u=n=>{b(n.track)};i.addEventListener("change",o),i.addEventListener("addtrack",d),i.addEventListener("removetrack",u)}return t}function Y(e){let t=r(e).audioTracks;if(!t&&(t=new S,r(e).audioTracks=t,x)){const i=x.call(e.nativeEl??e);for(const n of i)w(e,n);const o=()=>{t.dispatchEvent(new Event("change"))},d=n=>{if([...t].some(s=>s instanceof P)){for(const s of i)L(s);return}w(e,n.track)},u=n=>{L(n.track)};i.addEventListener("change",o),i.addEventListener("addtrack",d),i.addEventListener("removetrack",u)}return t}export{Z as C,_ as M};
|
|
//# sourceMappingURL=mixin-BY5xW4uI.js.map
|