/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/rettime@0.11.11/build/index.mjs
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import{LensList}from"./lens-list.mjs";const kDefaultPrevented=Symbol("kDefaultPrevented"),kPropagationStopped=Symbol("kPropagationStopped"),kImmediatePropagationStopped=Symbol("kImmediatePropagationStopped");var TypedEvent=class extends MessageEvent{#e;[kDefaultPrevented];[kPropagationStopped];[kImmediatePropagationStopped];constructor(...e){super(e[0],e[1]),this[kDefaultPrevented]=!1}get defaultPrevented(){return this[kDefaultPrevented]}preventDefault(){super.preventDefault(),this[kDefaultPrevented]=!0}stopImmediatePropagation(){super.stopImmediatePropagation(),this[kImmediatePropagationStopped]=!0}},Emitter=class{#t;#s;#n;#i;#r;#o;#a;hooks;constructor(){this.#t=new LensList,this.#s=new WeakMap,this.#n=new WeakMap,this.#i=new WeakSet,this.#r=new LensList,this.#o=new WeakMap,this.#a=new WeakMap,this.hooks={on:(e,t,s)=>{if(!s?.signal?.aborted){if(s?.once){const s=t,n=(...t)=>(this.#l(e,n),s(...t));t=n}if(this.#r.append(e,t),s&&this.#o.set(t,s),s?.signal){const{signal:n}=s,i=()=>{this.#l(e,t)};n.addEventListener("abort",i,{once:!0}),this.#a.set(t,(()=>{n.removeEventListener("abort",i)}))}}},removeListener:(e,t)=>{this.#l(e,t)}}}#l(e,t){this.#r.delete(e,t);const s=this.#a.get(t);s&&(s(),this.#a.delete(t))}#p(e,t){const s=this.#t.delete(e,t),n=this.#n.get(t);return n&&(n(),this.#n.delete(t)),s}on(e,t,s){return this.#h(e,t,s),this}once(e,t,s){return this.on(e,t,{...s||{},once:!0})}earlyOn(e,t,s){return this.#h(e,t,s,"prepend"),this}earlyOnce(e,t,s){return this.earlyOn(e,t,{...s||{},once:!0})}emit(e){if(0===this.#t.size)return!1;const t=this.listenerCount(e.type)>0,s=this.#d(e);for(const t of this.#L(e.type)){if(null!=s.event[kPropagationStopped]&&s.event[kPropagationStopped]!==this)return s.revoke(),!1;if(s.event[kImmediatePropagationStopped])break;this.#k(s.event,t)}return s.revoke(),t}async emitAsPromise(e){if(0===this.#t.size)return[];const t=[],s=this.#d(e);for(const n of this.#L(e.type)){if(null!=s.event[kPropagationStopped]&&s.event[kPropagationStopped]!==this)return s.revoke(),[];if(s.event[kImmediatePropagationStopped])break;const e=await Promise.resolve(this.#k(s.event,n));this.#u(n)||t.push(e)}return s.revoke(),Promise.allSettled(t).then((e=>e.map((e=>"fulfilled"===e.status?e.value:e.reason))))}*emitAsGenerator(e){if(0===this.#t.size)return;const t=this.#d(e);for(const s of this.#L(e.type)){if(null!=t.event[kPropagationStopped]&&t.event[kPropagationStopped]!==this)return void t.revoke();if(t.event[kImmediatePropagationStopped])break;const e=this.#k(t.event,s);this.#u(s)||(yield e)}t.revoke()}removeListener(e,t){const s=this.#s.get(t);if(this.#p(e,t))for(const n of this.#r.get("removeListener").slice())n(e,t,s)}removeAllListeners(e){if(null==e){for(const[e,t]of this.#t.entries())for(;t.length>0;)this.removeListener(e,t[0]);for(const[e,t]of[...this.#r])this.#o.get(t)?.persist||this.#l(e,t);return}const t=this.listeners(e);for(;t.length>0;)this.removeListener(e,t[0])}listeners(e){return null==e?this.#t.getAll():this.#t.get(e)}listenerCount(e){return null==e?this.#t.size:this.listeners(e).length}#h(e,t,s,n="append"){if(!s?.signal?.aborted){for(const n of this.#r.get("newListener").slice())n(e,t,s);if("*"===e&&this.#i.add(t),"prepend"===n?this.#t.prepend(e,t):this.#t.append(e,t),s&&(this.#s.set(t,s),s.signal)){const{signal:n}=s,i=()=>{this.removeListener(e,t)};n.addEventListener("abort",i,{once:!0}),this.#n.set(t,(()=>{n.removeEventListener("abort",i)}))}}}#d(e){const{stopPropagation:t}=e;return e.stopPropagation=()=>{e[kPropagationStopped]=this,t.call(e)},{event:e,revoke(){e.stopPropagation=t}}}#k(e,t){for(const t of this.#r.get("beforeEmit").slice())if(!1===t(e))return;const s=t.call(this,e),n=this.#s.get(t);if(n?.once){const s=this.#u(t)?"*":e.type;if(this.#p(s,t))for(const e of this.#r.get("removeListener").slice())e(s,t,n)}return s}*#L(e){const t=[];for(const[s,n]of this.#t)"*"!==s&&s!==e||t.push(n);yield*t}#u(e){return this.#i.has(e)}};export{Emitter,TypedEvent};
//# sourceMappingURL=/sm/3d005aca05bdf5c2a4fa2e70594de00743af279377f37b28ab45ca8951241f0b.map