Peach: Local-first video metadata scraper and media manager.
import{a as e,f as t,i as n,o as r}from"./predicate-DSCS8XT4.js";import{t as i}from"./context-provider-ivCWVZbp.js";import{C as a,T as o,_ as s,a as c,b as l,d as u,f as d,g as f,h as p,i as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,y as S}from"./volume-DmN9I9eo.js";import{t as C}from"./ui-element-tYNJ8-5H.js";import{n as w,t as T}from"./casing-CxqC0yQL.js";import{i as E,n as D,r as O,t as k}from"./context-BEwcGq-j.js";import{n as A,r as j}from"./controller-BPemWnqI.js";import{t as M}from"./registered-media-BTb9nUxf.js";function N(t,r){return new Proxy(t,{get(e,t){if(t===M)return e;let i=P(r,t)??e,a=i[t];return n(a)&&t!==`constructor`?a.bind(i):a},set(e,t,n){let i=P(r,t)??e;return Reflect.set(i,t,n)},has(t,n){return!e(P(r,n))||n in t}})}function P(n,r){if(Object.hasOwn(Object.prototype,r))return null;for(let{mediaOverride:i}of n())if(!e(i)&&!t(i[r]))return i;return null}function F(e){return!!e&&`mediaOverride`in e}var I=class{#e=/* @__PURE__ */ new Map;#t=/* @__PURE__ */ new WeakMap;#n={initTime:Date.now()};#r;#i=null;constructor(e){this.#r=e}get size(){return this.#e.size}get(e){return this.#e.get(e)}register(e){let t=e.constructor,n=this.#e.get(t);return n!==e&&(n&&this.#s(n),this.#e.set(t,e),e.connect?.(this.#n),this.#i&&e.attach?.(this.#i),(F(n)||F(e))&&this.#r()),()=>this.#o(e)}attach(e){if(this.#i?.media===e.media){this.#i=e;return}this.detach(),this.#i=e;for(let t of this.#e.values())t.attach?.(e)}detach(){if(this.#i){for(let e of this.#e.values())e.detach?.();this.#i=null}}destroy(){this.detach();for(let e of this.#e.values())e.disconnect?.();this.#e.clear()}getStoreMedia(e){if(!this.#a())return e;let t=this.#t.get(e);return t||(t=N(e,()=>this.#e.values()),this.#t.set(e,t)),t}#a(){for(let e of this.#e.values())if(F(e))return!0;return!1}#o(e){let t=e.constructor;this.#e.get(t)===e&&(this.#e.delete(t),this.#s(e),F(e)&&this.#r())}#s(e){this.#i&&e.detach?.(),e.disconnect?.()}};function L(...e){let t=e.map(e=>e.derived??{});return{state:t=>{let n=e.map(e=>e.state(t));return Object.assign({},...n)},preserve:Array.from(new Set(e.flatMap(e=>e.preserve??[]))),derived:Object.assign({},...t),attach:t=>{for(let n of e)try{n.attach?.(t)}catch(e){t.reportError(e)}}}}const R=[u,b,_,l,x,g,m,S,p,d,c,s,y,f,v],z=[u,b,x,g,m,S,f,v],B=[],V=[u,x,g,m,S,p,d,c,s,y,f,h,v],H=[u,x,g,m,S,f,h,v];function U(e){return Object.entries(e).map(([e,t])=>{let n=t.html?.attribute??w(e);return{property:T(n),attribute:n,entry:t}})}function W(e){let t=U(e.config);class n extends C{static{this.properties={...C.properties,...Object.fromEntries(t.map(({property:e,attribute:t})=>[e,{type:String,attribute:t}]))}}#e=e.factory();#t=null;#n=null;#r=!1;#i=null;#a=null;#o=null;#s=null;#c=[];#l=[];#u=new MutationObserver(()=>this.#b());#d=new I(()=>this.#T());#f=e=>this.#d.register(e);#p=e=>{let t={value:e};return this.#c.push(t),this.#v(),()=>{let e=this.#c.indexOf(t);e<0||(this.#c.splice(e,1),this.#b(),this.#v())}};#m=e=>{let t={value:e};return this.#l.push(t),this.#y(),()=>{let e=this.#l.indexOf(t);e<0||(this.#l.splice(e,1),this.#y())}};#h=new i(this,{context:e.playerContext,initialValue:this.store});#g=new i(this,{context:e.mediaContext,initialValue:{media:this.#i,registerMedia:this.#p}});#_=new i(this,{context:e.containerContext,initialValue:{container:this.#o,registerContainer:this.#m}});constructor(){super(),new i(this,{context:e.extensionContext,initialValue:{registerExtension:this.#f}})}get store(){return r(this.#e)&&(this.#e=e.factory()),this.#e}connectedCallback(){this.#r=!0,super.connectedCallback(),this.#D(),this.#h.setValue(this.store),this.#x(),this.#S(),this.#u.observe(this,{childList:!0,subtree:!0}),queueMicrotask(()=>{this.#r&&this.#b()}),this.#C()}disconnectedCallback(){this.#r=!1,this.#u.disconnect(),this.#E(),super.disconnectedCallback()}destroyCallback(){this.#u.disconnect(),this.#E(),this.#d.destroy(),this.#e?.destroy(),this.#e=null,super.destroyCallback()}willUpdate(e){super.willUpdate(e);for(let{property:n,entry:r}of t){if(!e.has(n))continue;let t=n;o(this.store,r,this[t])}}#v(){let e=this.#c.at(-1)?.value??null??this.#a;this.#i!==e&&(this.#i=e,this.#x(),this.#C())}#y(){let e=this.#l.at(-1)?.value??null;this.#o!==e&&(this.#o=e,this.#S(),this.#C())}#b(){let e=this.querySelector(`video, audio`);this.#a!==e&&(this.#a=e,this.#v())}#x(){this.#g.setValue({media:this.#i,registerMedia:this.#p})}#S(){this.#_.setValue({container:this.#o,registerContainer:this.#m})}#C(){if(!this.#r||!this.#e)return;if(!this.#i){this.#E();return}let e={media:this.#i,container:this.#o},t=this.#s?.media!==e.media,n=this.#s?.container!==e.container;(t||n)&&this.#w(e)}#w(e){let t=this.#e;t&&(this.#n?.(),this.#s=e,this.#d.attach(e),this.#n=t.attach({media:this.#d.getStoreMedia(e.media),container:e.container}))}#T(){this.#s&&this.#w(this.#s)}#E(){this.#n?.(),this.#n=null,this.#d.detach(),this.#s=null}#D(){let e=this.store;if(this.#t!==e){for(let{property:n,entry:r}of t){let t=n;o(e,r,this[t])}this.#t=e}}}return n}function G(e){let t=L(...e.features),n=a(e.features);return{PlayerElement:W({playerContext:E,mediaContext:O,containerContext:k,extensionContext:D,factory:()=>j()(t),config:n}),PlayerController:A(E),playerContext:E}}export{V as a,H as i,z as n,R as o,B as r,G as t};
//# sourceMappingURL=create-player-eV9W_b2p.js.map