import{g as e}from"./p-811c9fd4.js";import{i,a as n,l as o}from"./p-f021dfd0.js";const t=o=>{const t=i(o,HTMLElement)?o:e(o);let r=t;for(;!n(r)&&!/^VIME-PLAYER$/.test(null==r?void 0:r.nodeName);)r=r.parentElement;if(n(r))throw Error("Can't find root player given: "+t);return r},r=new Set(["isFullscreenActive","isControlsActive","isPiPActive","isLive","isTouch","isAudio","isVideo","isAudioView","isVideoView"]),s=new Set(["ready","playbackStarted","playbackEnded","playbackReady"]),a=e=>r.has(e)?`v${e.replace("is","").replace("Active","")}Change`:s.has(e)?`v${e.charAt(0).toUpperCase()}${e.slice(1)}`:`v${e.charAt(0).toUpperCase()}${e.slice(1)}Change`,u=(i,n)=>function(i,n,o){void 0===o&&(o=!0);var t="Function"===i.constructor.name?i.prototype:i,r=t.componentWillLoad;t.componentWillLoad=function(){var i,t=this,s=e(this),a={promise:new Promise((function(e){i=e})),resolve:i},u=new CustomEvent("openWormhole",{bubbles:!0,composed:!0,detail:{consumer:this,fields:n,updater:function(e,i){t[e]=i},onOpen:a}});s.dispatchEvent(u);var c=function(){if(r)return r.call(t)};return o?a.promise.then((function(){return c()})):c()}}(i,n),c=(e,i,n,r)=>{const s=null!=r?r:t(e),u=i.map((e=>{const i=a(e);return o(s,i,(()=>{n(e,s[e])}))}));return()=>{u.forEach((e=>e()))}};export{t as f,a as g,c as u,u as w}