@basmilius/apple-devices 0.0.80 → 0.0.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +2013 -1
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -1 +1,2013 @@
1
- var xf=Object.defineProperty;var Ro=(o,t)=>{for(var f in t)xf(o,f,{get:t[f],enumerable:!0,configurable:!0,set:(i)=>t[f]=()=>i})};var No=2000,s=Symbol("com.basmilius.airplay:protocol"),v=Symbol("com.basmilius.airplay:subscribe"),T=Symbol("com.basmilius.airplay:unsubscribe");import{EventEmitter as Dr}from"node:events";import{AirPlay as Qr,DataStreamMessage as L}from"@basmilius/apple-airplay";import{reporter as c,waitFor as Kr}from"@basmilius/apple-common";import{DataStreamMessage as b}from"@basmilius/apple-airplay";import{Proto as lf}from"@basmilius/apple-airplay";import{waitFor as Wo}from"@basmilius/apple-common";class $o{get#o(){return this.#f.dataStream}get#f(){return this.#i[s]}#i;constructor(o){this.#i=o}async up(){await this.pressAndRelease(1,140)}async down(){await this.pressAndRelease(1,141)}async left(){await this.pressAndRelease(1,139)}async right(){await this.pressAndRelease(1,138)}async menu(){await this.pressAndRelease(1,134)}async play(){await this.pressAndRelease(12,176)}async playPause(){if(this.#i.state.nowPlayingClient?.playbackState===lf.PlaybackState_Enum.Playing)await this.pause();else await this.play()}async pause(){await this.pressAndRelease(12,177)}async next(){await this.pressAndRelease(12,181)}async previous(){await this.pressAndRelease(12,182)}async suspend(){await this.pressAndRelease(1,130)}async select(){await this.pressAndRelease(1,137)}async wake(){await this.pressAndRelease(1,131)}async home(){await this.pressAndRelease(12,64)}async volumeUp(){await this.pressAndRelease(12,233)}async volumeDown(){await this.pressAndRelease(12,234)}async mute(){await this.pressAndRelease(12,226)}async doublePress(o,t){await this.pressAndRelease(o,t),await Wo(150),await this.pressAndRelease(o,t)}async longPress(o,t,f=1000){await this.#o.exchange(b.sendHIDEvent(o,t,!0)),await Wo(f),await this.#o.exchange(b.sendHIDEvent(o,t,!1))}async pressAndRelease(o,t){await this.#o.exchange(b.sendHIDEvent(o,t,!0)),await Wo(25),await this.#o.exchange(b.sendHIDEvent(o,t,!1))}}import{EventEmitter as Cr}from"node:events";import{Proto as Rr}from"@basmilius/apple-airplay";import{Proto as Sr}from"@basmilius/apple-airplay";var af=typeof global=="object"&&global&&global.Object===Object&&global,k=af;var Pf=typeof self=="object"&&self&&self.Object===Object&&self,wf=k||Pf||Function("return this")(),w=wf;var sf=w.Symbol,U=sf;var Jo=Object.prototype,uf=Jo.hasOwnProperty,hf=Jo.toString,M=U?U.toStringTag:void 0;function Ef(o){var t=uf.call(o,M),f=o[M];try{o[M]=void 0;var i=!0}catch(m){}var r=hf.call(o);if(i)if(t)o[M]=f;else delete o[M];return r}var Zo=Ef;var Sf=Object.prototype,Cf=Sf.toString;function Rf(o){return Cf.call(o)}var Xo=Rf;var Wf="[object Null]",Df="[object Undefined]",Lo=U?U.toStringTag:void 0;function Qf(o){if(o==null)return o===void 0?Df:Wf;return Lo&&Lo in Object(o)?Zo(o):Xo(o)}var S=Qf;function Kf(o){return o!=null&&typeof o=="object"}var u=Kf;var Uf=Array.isArray,F=Uf;function qf(o){var t=typeof o;return o!=null&&(t=="object"||t=="function")}var l=qf;function If(o){return o}var g=If;var Yf="[object AsyncFunction]",Bf="[object Function]",Nf="[object GeneratorFunction]",$f="[object Proxy]";function Jf(o){if(!l(o))return!1;var t=S(o);return t==Bf||t==Nf||t==Yf||t==$f}var q=Jf;var Zf=w["__core-js_shared__"],e=Zf;var zo=function(){var o=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return o?"Symbol(src)_1."+o:""}();function Xf(o){return!!zo&&zo in o}var Ho=Xf;var Lf=Function.prototype,zf=Lf.toString;function Hf(o){if(o!=null){try{return zf.call(o)}catch(t){}try{return o+""}catch(t){}}return""}var Mo=Hf;var Mf=/[\\^$.*+?()[\]{}|]/g,Ff=/^\[object .+?Constructor\]$/,Gf=Function.prototype,Af=Object.prototype,Vf=Gf.toString,Of=Af.hasOwnProperty,_f=RegExp("^"+Vf.call(Of).replace(Mf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function cf(o){if(!l(o)||Ho(o))return!1;var t=q(o)?_f:Ff;return t.test(Mo(o))}var Fo=cf;function yf(o,t){return o==null?void 0:o[t]}var Go=yf;function vf(o,t){var f=Go(o,t);return Fo(f)?f:void 0}var I=vf;var Ao=Object.create,Tf=function(){function o(){}return function(t){if(!l(t))return{};if(Ao)return Ao(t);o.prototype=t;var f=new o;return o.prototype=void 0,f}}(),Vo=Tf;function bf(o,t,f){switch(f.length){case 0:return o.call(t);case 1:return o.call(t,f[0]);case 2:return o.call(t,f[0],f[1]);case 3:return o.call(t,f[0],f[1],f[2])}return o.apply(t,f)}var Oo=bf;function kf(o,t){var f=-1,i=o.length;t||(t=Array(i));while(++f<i)t[f]=o[f];return t}var _o=kf;var gf=800,ef=16,jf=Date.now;function oi(o){var t=0,f=0;return function(){var i=jf(),r=ef-(i-f);if(f=i,r>0){if(++t>=gf)return arguments[0]}else t=0;return o.apply(void 0,arguments)}}var co=oi;function ti(o){return function(){return o}}var yo=ti;var fi=function(){try{var o=I(Object,"defineProperty");return o({},"",{}),o}catch(t){}}(),Y=fi;var ii=!Y?g:function(o,t){return Y(o,"toString",{configurable:!0,enumerable:!1,value:yo(t),writable:!0})},vo=ii;var di=co(vo),To=di;var ri=9007199254740991,mi=/^(?:0|[1-9]\d*)$/;function ni(o,t){var f=typeof o;return t=t==null?ri:t,!!t&&(f=="number"||f!="symbol"&&mi.test(o))&&(o>-1&&o%1==0&&o<t)}var j=ni;function pi(o,t,f){if(t=="__proto__"&&Y)Y(o,t,{configurable:!0,enumerable:!0,value:f,writable:!0});else o[t]=f}var B=pi;function xi(o,t){return o===t||o!==o&&t!==t}var C=xi;var li=Object.prototype,ai=li.hasOwnProperty;function Pi(o,t,f){var i=o[t];if(!(ai.call(o,t)&&C(i,f))||f===void 0&&!(t in o))B(o,t,f)}var bo=Pi;function wi(o,t,f,i){var r=!f;f||(f={});var m=-1,p=t.length;while(++m<p){var d=t[m],x=i?i(f[d],o[d],d,f,o):void 0;if(x===void 0)x=o[d];if(r)B(f,d,x);else bo(f,d,x)}return f}var ko=wi;var go=Math.max;function si(o,t,f){return t=go(t===void 0?o.length-1:t,0),function(){var i=arguments,r=-1,m=go(i.length-t,0),p=Array(m);while(++r<m)p[r]=i[t+r];r=-1;var d=Array(t+1);while(++r<t)d[r]=i[r];return d[t]=f(p),Oo(o,this,d)}}var eo=si;function ui(o,t){return To(eo(o,t,g),o+"")}var jo=ui;var hi=9007199254740991;function Ei(o){return typeof o=="number"&&o>-1&&o%1==0&&o<=hi}var oo=Ei;function Si(o){return o!=null&&oo(o.length)&&!q(o)}var N=Si;function Ci(o,t,f){if(!l(f))return!1;var i=typeof t;if(i=="number"?N(f)&&j(t,f.length):i=="string"&&(t in f))return C(f[t],o);return!1}var ot=Ci;function Ri(o){return jo(function(t,f){var i=-1,r=f.length,m=r>1?f[r-1]:void 0,p=r>2?f[2]:void 0;if(m=o.length>3&&typeof m=="function"?(r--,m):void 0,p&&ot(f[0],f[1],p))m=r<3?void 0:m,r=1;t=Object(t);while(++i<r){var d=f[i];if(d)o(t,d,i,m)}return t})}var tt=Ri;var Wi=Object.prototype;function Di(o){var t=o&&o.constructor,f=typeof t=="function"&&t.prototype||Wi;return o===f}var to=Di;function Qi(o,t){var f=-1,i=Array(o);while(++f<o)i[f]=t(f);return i}var ft=Qi;var Ki="[object Arguments]";function Ui(o){return u(o)&&S(o)==Ki}var Do=Ui;var it=Object.prototype,qi=it.hasOwnProperty,Ii=it.propertyIsEnumerable,Yi=Do(function(){return arguments}())?Do:function(o){return u(o)&&qi.call(o,"callee")&&!Ii.call(o,"callee")},G=Yi;var io={};Ro(io,{default:()=>A});function Bi(){return!1}var dt=Bi;var nt=typeof io=="object"&&io&&!io.nodeType&&io,rt=nt&&typeof fo=="object"&&fo&&!fo.nodeType&&fo,Ni=rt&&rt.exports===nt,mt=Ni?w.Buffer:void 0,$i=mt?mt.isBuffer:void 0,Ji=$i||dt,A=Ji;var Zi="[object Arguments]",Xi="[object Array]",Li="[object Boolean]",zi="[object Date]",Hi="[object Error]",Mi="[object Function]",Fi="[object Map]",Gi="[object Number]",Ai="[object Object]",Vi="[object RegExp]",Oi="[object Set]",_i="[object String]",ci="[object WeakMap]",yi="[object ArrayBuffer]",vi="[object DataView]",Ti="[object Float32Array]",bi="[object Float64Array]",ki="[object Int8Array]",gi="[object Int16Array]",ei="[object Int32Array]",ji="[object Uint8Array]",od="[object Uint8ClampedArray]",td="[object Uint16Array]",fd="[object Uint32Array]",n={};n[Ti]=n[bi]=n[ki]=n[gi]=n[ei]=n[ji]=n[od]=n[td]=n[fd]=!0;n[Zi]=n[Xi]=n[yi]=n[Li]=n[vi]=n[zi]=n[Hi]=n[Mi]=n[Fi]=n[Gi]=n[Ai]=n[Vi]=n[Oi]=n[_i]=n[ci]=!1;function id(o){return u(o)&&oo(o.length)&&!!n[S(o)]}var pt=id;function dd(o){return function(t){return o(t)}}var xt=dd;var mo={};Ro(mo,{default:()=>no});var lt=typeof mo=="object"&&mo&&!mo.nodeType&&mo,V=lt&&typeof ro=="object"&&ro&&!ro.nodeType&&ro,rd=V&&V.exports===lt,Qo=rd&&k.process,md=function(){try{var o=V&&V.require&&V.require("util").types;if(o)return o;return Qo&&Qo.binding&&Qo.binding("util")}catch(t){}}(),no=md;var at=no&&no.isTypedArray,nd=at?xt(at):pt,po=nd;var pd=Object.prototype,xd=pd.hasOwnProperty;function ld(o,t){var f=F(o),i=!f&&G(o),r=!f&&!i&&A(o),m=!f&&!i&&!r&&po(o),p=f||i||r||m,d=p?ft(o.length,String):[],x=d.length;for(var P in o)if((t||xd.call(o,P))&&!(p&&(P=="length"||r&&(P=="offset"||P=="parent")||m&&(P=="buffer"||P=="byteLength"||P=="byteOffset")||j(P,x))))d.push(P);return d}var Pt=ld;function ad(o,t){return function(f){return o(t(f))}}var wt=ad;function Pd(o){var t=[];if(o!=null)for(var f in Object(o))t.push(f);return t}var st=Pd;var wd=Object.prototype,sd=wd.hasOwnProperty;function ud(o){if(!l(o))return st(o);var t=to(o),f=[];for(var i in o)if(!(i=="constructor"&&(t||!sd.call(o,i))))f.push(i);return f}var ut=ud;function hd(o){return N(o)?Pt(o,!0):ut(o)}var xo=hd;var Ed=I(Object,"create"),E=Ed;function Sd(){this.__data__=E?E(null):{},this.size=0}var ht=Sd;function Cd(o){var t=this.has(o)&&delete this.__data__[o];return this.size-=t?1:0,t}var Et=Cd;var Rd="__lodash_hash_undefined__",Wd=Object.prototype,Dd=Wd.hasOwnProperty;function Qd(o){var t=this.__data__;if(E){var f=t[o];return f===Rd?void 0:f}return Dd.call(t,o)?t[o]:void 0}var St=Qd;var Kd=Object.prototype,Ud=Kd.hasOwnProperty;function qd(o){var t=this.__data__;return E?t[o]!==void 0:Ud.call(t,o)}var Ct=qd;var Id="__lodash_hash_undefined__";function Yd(o,t){var f=this.__data__;return this.size+=this.has(o)?0:1,f[o]=E&&t===void 0?Id:t,this}var Rt=Yd;function $(o){var t=-1,f=o==null?0:o.length;this.clear();while(++t<f){var i=o[t];this.set(i[0],i[1])}}$.prototype.clear=ht;$.prototype.delete=Et;$.prototype.get=St;$.prototype.has=Ct;$.prototype.set=Rt;var Ko=$;function Bd(){this.__data__=[],this.size=0}var Wt=Bd;function Nd(o,t){var f=o.length;while(f--)if(C(o[f][0],t))return f;return-1}var R=Nd;var $d=Array.prototype,Jd=$d.splice;function Zd(o){var t=this.__data__,f=R(t,o);if(f<0)return!1;var i=t.length-1;if(f==i)t.pop();else Jd.call(t,f,1);return--this.size,!0}var Dt=Zd;function Xd(o){var t=this.__data__,f=R(t,o);return f<0?void 0:t[f][1]}var Qt=Xd;function Ld(o){return R(this.__data__,o)>-1}var Kt=Ld;function zd(o,t){var f=this.__data__,i=R(f,o);if(i<0)++this.size,f.push([o,t]);else f[i][1]=t;return this}var Ut=zd;function J(o){var t=-1,f=o==null?0:o.length;this.clear();while(++t<f){var i=o[t];this.set(i[0],i[1])}}J.prototype.clear=Wt;J.prototype.delete=Dt;J.prototype.get=Qt;J.prototype.has=Kt;J.prototype.set=Ut;var W=J;var Hd=I(w,"Map"),lo=Hd;function Md(){this.size=0,this.__data__={hash:new Ko,map:new(lo||W),string:new Ko}}var qt=Md;function Fd(o){var t=typeof o;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?o!=="__proto__":o===null}var It=Fd;function Gd(o,t){var f=o.__data__;return It(t)?f[typeof t=="string"?"string":"hash"]:f.map}var D=Gd;function Ad(o){var t=D(this,o).delete(o);return this.size-=t?1:0,t}var Yt=Ad;function Vd(o){return D(this,o).get(o)}var Bt=Vd;function Od(o){return D(this,o).has(o)}var Nt=Od;function _d(o,t){var f=D(this,o),i=f.size;return f.set(o,t),this.size+=f.size==i?0:1,this}var $t=_d;function Z(o){var t=-1,f=o==null?0:o.length;this.clear();while(++t<f){var i=o[t];this.set(i[0],i[1])}}Z.prototype.clear=qt;Z.prototype.delete=Yt;Z.prototype.get=Bt;Z.prototype.has=Nt;Z.prototype.set=$t;var Jt=Z;var cd=wt(Object.getPrototypeOf,Object),ao=cd;var yd="[object Object]",vd=Function.prototype,Td=Object.prototype,Zt=vd.toString,bd=Td.hasOwnProperty,kd=Zt.call(Object);function gd(o){if(!u(o)||S(o)!=yd)return!1;var t=ao(o);if(t===null)return!0;var f=bd.call(t,"constructor")&&t.constructor;return typeof f=="function"&&f instanceof f&&Zt.call(f)==kd}var Xt=gd;function ed(){this.__data__=new W,this.size=0}var Lt=ed;function jd(o){var t=this.__data__,f=t.delete(o);return this.size=t.size,f}var zt=jd;function or(o){return this.__data__.get(o)}var Ht=or;function tr(o){return this.__data__.has(o)}var Mt=tr;var fr=200;function ir(o,t){var f=this.__data__;if(f instanceof W){var i=f.__data__;if(!lo||i.length<fr-1)return i.push([o,t]),this.size=++f.size,this;f=this.__data__=new Jt(i)}return f.set(o,t),this.size=f.size,this}var Ft=ir;function X(o){var t=this.__data__=new W(o);this.size=t.size}X.prototype.clear=Lt;X.prototype.delete=zt;X.prototype.get=Ht;X.prototype.has=Mt;X.prototype.set=Ft;var Gt=X;var wo={};Ro(wo,{default:()=>Uo});var _t=typeof wo=="object"&&wo&&!wo.nodeType&&wo,At=_t&&typeof Po=="object"&&Po&&!Po.nodeType&&Po,dr=At&&At.exports===_t,Vt=dr?w.Buffer:void 0,Ot=Vt?Vt.allocUnsafe:void 0;function rr(o,t){if(t)return o.slice();var f=o.length,i=Ot?Ot(f):new o.constructor(f);return o.copy(i),i}var Uo=rr;var mr=w.Uint8Array,qo=mr;function nr(o){var t=new o.constructor(o.byteLength);return new qo(t).set(new qo(o)),t}var ct=nr;function pr(o,t){var f=t?ct(o.buffer):o.buffer;return new o.constructor(f,o.byteOffset,o.length)}var yt=pr;function xr(o){return typeof o.constructor=="function"&&!to(o)?Vo(ao(o)):{}}var vt=xr;function lr(o){return function(t,f,i){var r=-1,m=Object(t),p=i(t),d=p.length;while(d--){var x=p[o?d:++r];if(f(m[x],x,m)===!1)break}return t}}var Tt=lr;var ar=Tt(),bt=ar;function Pr(o,t,f){if(f!==void 0&&!C(o[t],f)||f===void 0&&!(t in o))B(o,t,f)}var O=Pr;function wr(o){return u(o)&&N(o)}var kt=wr;function sr(o,t){if(t==="constructor"&&typeof o[t]==="function")return;if(t=="__proto__")return;return o[t]}var _=sr;function ur(o){return ko(o,xo(o))}var gt=ur;function hr(o,t,f,i,r,m,p){var d=_(o,f),x=_(t,f),P=p.get(x);if(P){O(o,f,P);return}var a=m?m(d,x,f+"",o,t,p):void 0,H=a===void 0;if(H){var So=F(x),Co=!So&&A(x),Bo=!So&&!Co&&po(x);if(a=x,So||Co||Bo)if(F(d))a=d;else if(kt(d))a=_o(d);else if(Co)H=!1,a=Uo(x,!0);else if(Bo)H=!1,a=yt(x,!0);else a=[];else if(Xt(x)||G(x)){if(a=d,G(d))a=gt(d);else if(!l(d)||q(d))a=vt(x)}else H=!1}if(H)p.set(x,a),r(a,x,i,m,p),p.delete(x);O(o,f,a)}var et=hr;function jt(o,t,f,i,r){if(o===t)return;bt(t,function(m,p){if(r||(r=new Gt),l(m))et(o,t,p,f,jt,i,r);else{var d=i?i(_(o,p),m,p+"",o,t,r):void 0;if(d===void 0)d=m;O(o,p,d)}},xo)}var of=jt;var Er=tt(function(o,t,f){of(o,t,f)}),Io=Er;class so{get bundleIdentifier(){return this.#o}get displayName(){return this.#f}get playbackQueue(){return this.#i}get playbackState(){return this.#r}get playbackStateTimestamp(){return this.#m}get supportedCommands(){return this.#t}#o;#f;#i=null;#r;#m;#t=[];constructor(o,t){this.#o=o,this.#f=t,this.#r=Sr.PlaybackState_Enum.Unknown,this.#t=[]}isCommandSupported(o){return this.#t.some((t)=>t.command===o)}setPlaybackQueue(o){this.#i=o}setPlaybackState(o,t){this.#r=o,this.#m=t}setSupportedCommands(o){this.#t=o}updateContentItem(o){if(!this.#i)return;let t=this.#i.contentItems.findIndex((f)=>f.identifier===o.identifier);if(t===-1)return;this.#i.contentItems[t]=Io(o,this.#i.contentItems[t])}}class tf extends Cr{get#o(){return this.#f.dataStream}get#f(){return this.#i[s]}get clients(){return this.#r}get nowPlayingClient(){return this.#m?this.#r[this.#m]??null:null}get outputDeviceUID(){return this.#t}get volume(){return this.#x}get volumeAvailable(){return this.#n}get volumeCapabilities(){return this.#d}#i;#r;#m;#t;#x;#n;#d;constructor(o){super();this.#i=o,this.clear(),this.onDeviceInfo=this.onDeviceInfo.bind(this),this.onDeviceInfoUpdate=this.onDeviceInfoUpdate.bind(this),this.onOriginClientProperties=this.onOriginClientProperties.bind(this),this.onPlayerClientProperties=this.onPlayerClientProperties.bind(this),this.onRemoveClient=this.onRemoveClient.bind(this),this.onSendCommandResult=this.onSendCommandResult.bind(this),this.onSetArtwork=this.onSetArtwork.bind(this),this.onSetDefaultSupportedCommands=this.onSetDefaultSupportedCommands.bind(this),this.onSetNowPlayingClient=this.onSetNowPlayingClient.bind(this),this.onSetNowPlayingPlayer=this.onSetNowPlayingPlayer.bind(this),this.onSetState=this.onSetState.bind(this),this.onUpdateClient=this.onUpdateClient.bind(this),this.onUpdateContentItem=this.onUpdateContentItem.bind(this),this.onUpdateContentItemArtwork=this.onUpdateContentItemArtwork.bind(this),this.onUpdatePlayer=this.onUpdatePlayer.bind(this),this.onUpdateOutputDevice=this.onUpdateOutputDevice.bind(this),this.onVolumeControlAvailability=this.onVolumeControlAvailability.bind(this),this.onVolumeControlCapabilitiesDidChange=this.onVolumeControlCapabilitiesDidChange.bind(this),this.onVolumeDidChange=this.onVolumeDidChange.bind(this)}async[v](){this.#o.on("deviceInfo",this.onDeviceInfo),this.#o.on("deviceInfoUpdate",this.onDeviceInfoUpdate),this.#o.on("originClientProperties",this.onOriginClientProperties),this.#o.on("playerClientProperties",this.onPlayerClientProperties),this.#o.on("removeClient",this.onRemoveClient),this.#o.on("sendCommandResult",this.onSendCommandResult),this.#o.on("setArtwork",this.onSetArtwork),this.#o.on("setDefaultSupportedCommands",this.onSetDefaultSupportedCommands),this.#o.on("setNowPlayingClient",this.onSetNowPlayingClient),this.#o.on("setNowPlayingPlayer",this.onSetNowPlayingPlayer),this.#o.on("setState",this.onSetState),this.#o.on("updateClient",this.onUpdateClient),this.#o.on("updateContentItem",this.onUpdateContentItem),this.#o.on("updateContentItemArtwork",this.onUpdateContentItemArtwork),this.#o.on("updatePlayer",this.onUpdatePlayer),this.#o.on("updateOutputDevice",this.onUpdateOutputDevice),this.#o.on("volumeControlAvailability",this.onVolumeControlAvailability),this.#o.on("volumeControlCapabilitiesDidChange",this.onVolumeControlCapabilitiesDidChange),this.#o.on("volumeDidChange",this.onVolumeDidChange)}async[T](){let o=this.#o;if(!o)return;o.off("deviceInfo",this.onDeviceInfo),o.off("deviceInfoUpdate",this.onDeviceInfoUpdate),o.off("originClientProperties",this.onOriginClientProperties),o.off("playerClientProperties",this.onPlayerClientProperties),o.off("removeClient",this.onRemoveClient),o.off("sendCommandResult",this.onSendCommandResult),o.off("setArtwork",this.onSetArtwork),o.off("setDefaultSupportedCommands",this.onSetDefaultSupportedCommands),o.off("setNowPlayingClient",this.onSetNowPlayingClient),o.off("setNowPlayingPlayer",this.onSetNowPlayingPlayer),o.off("setState",this.onSetState),o.off("updateClient",this.onUpdateClient),o.off("updateContentItem",this.onUpdateContentItem),o.off("updateContentItemArtwork",this.onUpdateContentItemArtwork),o.off("updatePlayer",this.onUpdatePlayer),o.off("updateOutputDevice",this.onUpdateOutputDevice),o.off("volumeControlAvailability",this.onVolumeControlAvailability),o.off("volumeControlCapabilitiesDidChange",this.onVolumeControlCapabilitiesDidChange),o.off("volumeDidChange",this.onVolumeDidChange)}clear(){this.#r={},this.#m=null,this.#t=null,this.#x=0,this.#n=!1,this.#d=Rr.VolumeCapabilities_Enum.None}async onDeviceInfo(o){if(o.clusterID)this.#t=o.clusterID;else if(o.deviceUID)this.#t=o.deviceUID;else if(o.uniqueIdentifier)this.#t=o.uniqueIdentifier;this.emit("deviceInfo",o)}async onDeviceInfoUpdate(o){if(o.clusterID)this.#t=o.clusterID;else if(o.deviceUID)this.#t=o.deviceUID;else if(o.uniqueIdentifier)this.#t=o.uniqueIdentifier;this.emit("deviceInfoUpdate",o)}async onOriginClientProperties(o){this.emit("originClientProperties",o)}async onPlayerClientProperties(o){this.emit("playerClientProperties",o)}async onRemoveClient(o){if(!(o.client.bundleIdentifier in this.#r))return;delete this.#r[o.client.bundleIdentifier],this.emit("clients",this.#r)}async onSendCommandResult(o){this.emit("sendCommandResult",o)}async onSetArtwork(o){this.emit("setArtwork",o)}async onSetDefaultSupportedCommands(o){this.emit("setDefaultSupportedCommands",o)}async onSetNowPlayingClient(o){this.#m=o.client?.bundleIdentifier??null,this.emit("setNowPlayingClient",o)}async onSetNowPlayingPlayer(o){this.emit("setNowPlayingPlayer",o)}async onSetState(o){let t=this.#p(o.playerPath.client.bundleIdentifier,o.displayName);if(o.playbackState)t.setPlaybackState(o.playbackState,o.playbackStateTimestamp);if(o.supportedCommands)t.setSupportedCommands(o.supportedCommands.supportedCommands);if(o.playbackQueue)t.setPlaybackQueue(o.playbackQueue);this.emit("setState",o)}async onUpdateContentItem(o){let t=this.#p(o.playerPath.client.bundleIdentifier,o.playerPath.client.displayName);if(!t)return;for(let f of o.contentItems)t.updateContentItem(f);this.emit("updateContentItem",o)}async onUpdateContentItemArtwork(o){this.emit("updateContentItemArtwork",o)}async onUpdatePlayer(o){this.emit("updatePlayer",o)}async onUpdateClient(o){this.#p(o.client.bundleIdentifier,o.client.displayName),this.emit("clients",this.#r)}async onUpdateOutputDevice(o){this.emit("updateOutputDevice",o)}async onVolumeControlAvailability(o){this.#n=o.volumeControlAvailable,this.#d=o.volumeCapabilities,this.emit("volumeControlAvailability",o.volumeControlAvailable,o.volumeCapabilities)}async onVolumeControlCapabilitiesDidChange(o){this.#n=o.capabilities.volumeControlAvailable,this.#d=o.capabilities.volumeCapabilities,this.emit("volumeControlCapabilitiesDidChange",o.capabilities.volumeControlAvailable,o.capabilities.volumeCapabilities)}async onVolumeDidChange(o){this.#x=o.volume,this.emit("volumeDidChange",o.volume)}#p(o,t){if(o in this.#r)return this.#r[o];else{let f=new so(o,t);return this.#r[o]=f,this.emit("clients",this.#r),f}}}import{DataStreamMessage as Yo,Proto as h}from"@basmilius/apple-airplay";import{reporter as Wr}from"@basmilius/apple-common";var ff=0.05;class df{get#o(){return this.#i[s]}get#f(){return this.#i.state}#i;constructor(o){this.#i=o}async down(){switch(this.#f.volumeCapabilities){case h.VolumeCapabilities_Enum.Absolute:case h.VolumeCapabilities_Enum.Both:let o=Math.max(0,this.#f.volume-ff);await this.set(o);break;case h.VolumeCapabilities_Enum.Relative:await this.#i.remote.volumeDown();break;default:throw Error("Volume control is not available.")}}async up(){switch(this.#f.volumeCapabilities){case h.VolumeCapabilities_Enum.Absolute:case h.VolumeCapabilities_Enum.Both:let o=Math.max(0,this.#f.volume+ff);await this.set(o);break;case h.VolumeCapabilities_Enum.Relative:await this.#i.remote.volumeUp();break;default:throw Error("Volume control is not available.")}}async get(){if(!this.#f.outputDeviceUID)throw Error("No output device active.");let o=await this.#o.dataStream.exchange(Yo.getVolume(this.#f.outputDeviceUID));if(o.type===h.ProtocolMessage_Type.GET_VOLUME_RESULT_MESSAGE)return Yo.getExtension(o,h.getVolumeResultMessage).volume;throw Error("Failed to get volume.")}async set(o){if(!this.#f.outputDeviceUID)throw Error("No output device active.");if(![h.VolumeCapabilities_Enum.Absolute,h.VolumeCapabilities_Enum.Both].includes(this.#f.volumeCapabilities))throw Error("Absolute volume control is not available.");o=Math.min(1,Math.max(0,o)),Wr.info(`Setting volume to ${o} for device ${this.#f.outputDeviceUID}`),await this.#o.dataStream.exchange(Yo.setVolume(this.#f.outputDeviceUID,o))}}class z extends Dr{get[s](){return this.#d}get isConnected(){return this.#d?.rtsp?.isConnected??!1}get remote(){return this.#f}get state(){return this.#i}get volume(){return this.#r}get timingServer(){return this.#p}set timingServer(o){this.#p=o}#o;#f;#i;#r;#m;#t=!1;#x;#n;#d;#p;constructor(o){super();this.#o=o,this.#f=new $o(this),this.#i=new tf(this),this.#r=new df(this)}async connect(){if(this.#t=!1,this.#i.clear(),this.#d=new Qr(this.#o),this.#d.rtsp.on("close",async()=>this.#P()),this.#d.rtsp.on("error",async(o)=>this.#l(o)),this.#d.rtsp.on("timeout",async()=>this.#w()),await this.#d.connect(),this.#m)this.#n=await this.#d.verify.start(this.#m);else await this.#d.pairing.start(),this.#n=await this.#d.pairing.transient();await this.#u(),this.emit("connected")}async disconnect(){this.#t=!0,clearInterval(this.#x),await this.#s(),await this.#d.disconnect(),this.emit("disconnected",!1)}async disconnectSafely(){try{await this.disconnect()}catch(o){}}async requestPlaybackQueue(o){await this.#d.dataStream.exchange(L.playbackQueueRequest(0,o))}async sendCommand(o,t){await this.#d.dataStream.exchange(L.sendCommand(o,t))}async setCredentials(o){this.#m=o}async#a(){try{await this.#d.feedback()}catch(o){c.error("Feedback error",o)}}async#P(){if(this.#t)return;clearInterval(this.#x),this.emit("disconnected",!0)}async#l(o){c.error("AirPlay error",o),await this.disconnectSafely(),this.emit("disconnected",!0)}async#w(){c.error("AirPlay timeout"),await this.disconnectSafely(),this.emit("disconnected",!0)}async#u(){let o=this.#n;if(await this.#d.rtsp.enableEncryption(o.accessoryToControllerKey,o.controllerToAccessoryKey),await this.#s(),this.#p)await this.#d.setupTimingServer(this.#p);await this.#d.setupEventStream(o.pairingId,o.sharedSecret),await this.#d.setupDataStream(o.sharedSecret),await this.#h(),this.#d.dataStream.on("error",async(i)=>this.#l(i)),this.#d.dataStream.on("timeout",async()=>this.#w()),this.#d.eventStream.on("error",async(i)=>this.#l(i)),this.#d.eventStream.on("timeout",async()=>this.#w()),this.#x=setInterval(async()=>await this.#a(),No);let t=this.#o.packet.additionals.find((i)=>("rdata"in i)&&typeof i.rdata==="object"&&("gid"in i.rdata))?.rdata.gid;if(t)await this.#d.dataStream.exchange(L.configureConnection(t));if(await this.#d.dataStream.exchange(L.deviceInfo(o.pairingId)),!await Promise.race([new Promise((i)=>{this.#d.dataStream.on("deviceInfo",async()=>{await this.#d.dataStream.exchange(L.setConnectionState()),await this.#d.dataStream.exchange(L.clientUpdatesConfig()),i(!0)})}),async()=>{return await Kr(3000),!1}]))await this.#l(Error("Device did not respond in time with its info."));else c.info("Device info received successfully, protocol should be ready.")}async#h(){await this.#i[v]()}async#s(){try{await this.#i[T]()}catch(o){c.error("State unsubscribe error",o)}}}var uo=Symbol("com.basmilius.companion-link:protocol");import{EventEmitter as Ur}from"node:events";import{reporter as y}from"@basmilius/apple-common";import{CompanionLink as qr,convertAttentionState as rf}from"@basmilius/apple-companion-link";class ho extends Ur{get[uo](){return this.#t}get isConnected(){return this.#t?.socket?.isConnected??!1}#o;#f=!1;#i;#r;#m;#t;constructor(o){super();this.#i=o,this.onSystemStatus=this.onSystemStatus.bind(this),this.onTVSystemStatus=this.onTVSystemStatus.bind(this)}async connect(){if(!this.#o)throw Error("Credentials are required to connect to a Companion Link device.");this.#f=!1,this.#t=new qr(this.#i),this.#t.socket.on("close",async()=>this.#n()),this.#t.socket.on("error",async(o)=>this.#d(o)),this.#t.socket.on("timeout",async()=>this.#p()),await this.#t.connect(),this.#m=await this.#t.verify.start(this.#o),await this.#a(),this.emit("connected")}async disconnect(){this.#f=!0,clearInterval(this.#r),await this.#l(),await this.#t.disconnect(),this.emit("disconnected",!1)}async disconnectSafely(){try{await this.disconnect()}catch(o){}}async setCredentials(o){this.#o=o}async setDiscoveryResult(o){this.#i=o}async getAttentionState(){return await this.#t.api.getAttentionState()}async getLaunchableApps(){return await this.#t.api.getLaunchableApps()}async getUserAccounts(){return await this.#t.api.getUserAccounts()}async launchApp(o){await this.#t.api.launchApp(o)}async launchUrl(o){await this.#t.api.launchUrl(o)}async mediaControlCommand(o,t){await this.#t.api.mediaControlCommand(o,t)}async pressButton(o,t,f){await this.#t.api.pressButton(o,t,f)}async switchUserAccount(o){await this.#t.api.switchUserAccount(o)}async#x(){try{await this.#t.api._systemInfo(this.#o.pairingId)}catch(o){y.error("Heartbeat error",o)}}async#n(){if(this.#f)return;clearInterval(this.#r),this.emit("disconnected",!0)}async#d(o){y.error("Companion Link error",o);try{await this.disconnect()}catch(t){}this.emit("disconnected",!0)}async#p(){y.error("Companion Link timeout"),await this.disconnectSafely(),this.emit("disconnected",!0)}async#a(){let o=this.#m;await this.#t.socket.enableEncryption(o.accessoryToControllerKey,o.controllerToAccessoryKey),await this.#t.api._systemInfo(this.#o.pairingId),await this.#t.api._touchStart(),await this.#t.api._sessionStart(),await this.#t.api._tvrcSessionStart(),await this.#t.api._unsubscribe("_iMC"),this.#r=setInterval(async()=>await this.#x(),15000),await this.#P()}async#P(){await this.#t.api._subscribe("SystemStatus",this.onSystemStatus),await this.#t.api._subscribe("TVSystemStatus",this.onTVSystemStatus);let o=await this.getAttentionState();this.emit("power",o)}async#l(){await this.#t.api._unsubscribe("SystemStatus",this.onSystemStatus),await this.#t.api._unsubscribe("TVSystemStatus",this.onTVSystemStatus)}async onSystemStatus(o){y.info("System Status",o),this.emit("power",rf(o.state))}async onTVSystemStatus(o){y.info("TV System Status",o),this.emit("power",rf(o.state))}}import{EventEmitter as Ir}from"node:events";import{Proto as Q}from"@basmilius/apple-airplay";class mf extends Ir{get airplay(){return this.#o}get companionLink(){return this.#f}get bundleIdentifier(){return this.#o.state.nowPlayingClient?.bundleIdentifier??null}get displayName(){return this.#o.state.nowPlayingClient?.displayName??null}get isConnected(){return this.#o.isConnected&&this.#f.isConnected}get isPlaying(){return this.playbackState===Q.PlaybackState_Enum.Playing}get playbackQueue(){return this.#o.state.nowPlayingClient?.playbackQueue??null}get playbackState(){return this.#o.state.nowPlayingClient?.playbackState??Q.PlaybackState_Enum.Unknown}get playbackStateTimestamp(){return this.#o.state.nowPlayingClient?.playbackStateTimestamp??-1}#o;#f;#i=!1;constructor(o,t){super();this.#o=new z(o),this.#f=new ho(t),this.#o.on("connected",()=>this.#r()),this.#o.on("disconnected",(f)=>this.#m(f)),this.#f.on("connected",()=>this.#r()),this.#f.on("disconnected",(f)=>this.#m(f))}async connect(o){await this.#o.setCredentials(o),await this.#f.setCredentials(o),await this.#o.connect(),await this.#f.connect(),this.#i=!1}async disconnect(){await this.#o.disconnect(),await this.#f.disconnect()}async turnOff(){await this.#o.remote.suspend()}async turnOn(){await this.#o.remote.wake()}async pause(){await this.#o.sendCommand(Q.Command.Pause)}async playPause(){await this.#o.sendCommand(Q.Command.TogglePlayPause)}async play(){await this.#o.sendCommand(Q.Command.Play)}async stop(){await this.#o.sendCommand(Q.Command.Stop)}async next(){await this.#o.sendCommand(Q.Command.NextInContext)}async previous(){await this.#o.sendCommand(Q.Command.PreviousInContext)}async volumeDown(){await this.#o.remote.volumeDown()}async volumeMute(){await this.#o.remote.mute()}async volumeUp(){await this.#o.remote.volumeUp()}async getCommandInfo(o){let t=this.#o.state.nowPlayingClient;if(!t)return null;return t.supportedCommands.find((f)=>f.command===o)??null}async isCommandSupported(o){let t=this.#o.state.nowPlayingClient;if(!t)return!1;return t.isCommandSupported(o)}async#r(){if(!this.#o.isConnected||!this.#f.isConnected)return;this.emit("connected")}async#m(o){if(this.#i)return;this.#i=!0,await this.disconnect(),this.emit("disconnected",o)}}import{EventEmitter as Yr}from"node:events";import{Proto as K}from"@basmilius/apple-airplay";class Eo extends Yr{get airplay(){return this.#o}get bundleIdentifier(){return this.#o.state.nowPlayingClient?.bundleIdentifier??null}get displayName(){return this.#o.state.nowPlayingClient?.displayName??null}get isConnected(){return this.#o.isConnected}get isPlaying(){return this.playbackState===K.PlaybackState_Enum.Playing}get playbackQueue(){return this.#o.state.nowPlayingClient?.playbackQueue??null}get playbackState(){return this.#o.state.nowPlayingClient?.playbackState??K.PlaybackState_Enum.Unknown}get playbackStateTimestamp(){return this.#o.state.nowPlayingClient?.playbackStateTimestamp??-1}get volume(){return this.#o.state.volume??0}#o;#f=!1;constructor(o){super();this.#o=new z(o),this.#o.on("connected",()=>this.#i()),this.#o.on("disconnected",(t)=>this.#r(t))}async connect(){await this.#o.connect(),this.#f=!1}async disconnect(){await this.#o.disconnect()}async pause(){await this.#o.sendCommand(K.Command.Pause)}async playPause(){await this.#o.sendCommand(K.Command.TogglePlayPause)}async play(){await this.#o.sendCommand(K.Command.Play)}async stop(){await this.#o.sendCommand(K.Command.Stop)}async next(){await this.#o.sendCommand(K.Command.NextInContext)}async previous(){await this.#o.sendCommand(K.Command.PreviousInContext)}async getCommandInfo(o){let t=this.#o.state.nowPlayingClient;if(!t)return null;return t.supportedCommands.find((f)=>f.command===o)??null}async isCommandSupported(o){let t=this.#o.state.nowPlayingClient;if(!t)return!1;return t.isCommandSupported(o)}async#i(){this.emit("connected")}async#r(o){if(this.#f)return;this.#f=!0,await this.disconnect(),this.emit("disconnected",o)}}class nf extends Eo{}class pf extends Eo{}export{pf as HomePodMini,nf as HomePod,ho as CompanionLinkDevice,uo as COMPANION_LINK,mf as AppleTV,z as AirPlayDevice,s as AIRPLAY};
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+
12
+ // src/airplay/const.ts
13
+ var FEEDBACK_INTERVAL = 2000;
14
+ var PROTOCOL = Symbol("com.basmilius.airplay:protocol");
15
+ var STATE_SUBSCRIBE_SYMBOL = Symbol("com.basmilius.airplay:subscribe");
16
+ var STATE_UNSUBSCRIBE_SYMBOL = Symbol("com.basmilius.airplay:unsubscribe");
17
+ // src/airplay/device.ts
18
+ import { EventEmitter as EventEmitter2 } from "node:events";
19
+ import { AirPlay as AirPlay2, DataStreamMessage as DataStreamMessage3 } from "@basmilius/apple-airplay";
20
+ import { reporter as reporter2, waitFor as waitFor2 } from "@basmilius/apple-common";
21
+
22
+ // src/airplay/remote.ts
23
+ import { DataStreamMessage } from "@basmilius/apple-airplay";
24
+ import { Proto } from "@basmilius/apple-airplay";
25
+ import { waitFor } from "@basmilius/apple-common";
26
+ class remote_default {
27
+ get #dataStream() {
28
+ return this.#protocol.dataStream;
29
+ }
30
+ get #protocol() {
31
+ return this.#device[PROTOCOL];
32
+ }
33
+ #device;
34
+ constructor(device) {
35
+ this.#device = device;
36
+ }
37
+ async up() {
38
+ await this.pressAndRelease(1, 140);
39
+ }
40
+ async down() {
41
+ await this.pressAndRelease(1, 141);
42
+ }
43
+ async left() {
44
+ await this.pressAndRelease(1, 139);
45
+ }
46
+ async right() {
47
+ await this.pressAndRelease(1, 138);
48
+ }
49
+ async menu() {
50
+ await this.pressAndRelease(1, 134);
51
+ }
52
+ async play() {
53
+ await this.pressAndRelease(12, 176);
54
+ }
55
+ async playPause() {
56
+ if (this.#device.state.nowPlayingClient?.playbackState === Proto.PlaybackState_Enum.Playing) {
57
+ await this.pause();
58
+ } else {
59
+ await this.play();
60
+ }
61
+ }
62
+ async pause() {
63
+ await this.pressAndRelease(12, 177);
64
+ }
65
+ async next() {
66
+ await this.pressAndRelease(12, 181);
67
+ }
68
+ async previous() {
69
+ await this.pressAndRelease(12, 182);
70
+ }
71
+ async suspend() {
72
+ await this.pressAndRelease(1, 130);
73
+ }
74
+ async select() {
75
+ await this.pressAndRelease(1, 137);
76
+ }
77
+ async wake() {
78
+ await this.pressAndRelease(1, 131);
79
+ }
80
+ async home() {
81
+ await this.pressAndRelease(12, 64);
82
+ }
83
+ async volumeUp() {
84
+ await this.pressAndRelease(12, 233);
85
+ }
86
+ async volumeDown() {
87
+ await this.pressAndRelease(12, 234);
88
+ }
89
+ async mute() {
90
+ await this.pressAndRelease(12, 226);
91
+ }
92
+ async doublePress(usePage, usage) {
93
+ await this.pressAndRelease(usePage, usage);
94
+ await waitFor(150);
95
+ await this.pressAndRelease(usePage, usage);
96
+ }
97
+ async longPress(usePage, usage, duration = 1000) {
98
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, true));
99
+ await waitFor(duration);
100
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, false));
101
+ }
102
+ async pressAndRelease(usePage, usage) {
103
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, true));
104
+ await waitFor(25);
105
+ await this.#dataStream.exchange(DataStreamMessage.sendHIDEvent(usePage, usage, false));
106
+ }
107
+ }
108
+
109
+ // src/airplay/state.ts
110
+ import { EventEmitter } from "node:events";
111
+ import { Proto as Proto3 } from "@basmilius/apple-airplay";
112
+
113
+ // src/airplay/client.ts
114
+ import { Proto as Proto2 } from "@basmilius/apple-airplay";
115
+
116
+ // ../../node_modules/lodash-es/_freeGlobal.js
117
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
118
+ var _freeGlobal_default = freeGlobal;
119
+
120
+ // ../../node_modules/lodash-es/_root.js
121
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
122
+ var root = _freeGlobal_default || freeSelf || Function("return this")();
123
+ var _root_default = root;
124
+
125
+ // ../../node_modules/lodash-es/_Symbol.js
126
+ var Symbol2 = _root_default.Symbol;
127
+ var _Symbol_default = Symbol2;
128
+
129
+ // ../../node_modules/lodash-es/_getRawTag.js
130
+ var objectProto = Object.prototype;
131
+ var hasOwnProperty = objectProto.hasOwnProperty;
132
+ var nativeObjectToString = objectProto.toString;
133
+ var symToStringTag = _Symbol_default ? _Symbol_default.toStringTag : undefined;
134
+ function getRawTag(value) {
135
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
136
+ try {
137
+ value[symToStringTag] = undefined;
138
+ var unmasked = true;
139
+ } catch (e) {}
140
+ var result = nativeObjectToString.call(value);
141
+ if (unmasked) {
142
+ if (isOwn) {
143
+ value[symToStringTag] = tag;
144
+ } else {
145
+ delete value[symToStringTag];
146
+ }
147
+ }
148
+ return result;
149
+ }
150
+ var _getRawTag_default = getRawTag;
151
+
152
+ // ../../node_modules/lodash-es/_objectToString.js
153
+ var objectProto2 = Object.prototype;
154
+ var nativeObjectToString2 = objectProto2.toString;
155
+ function objectToString(value) {
156
+ return nativeObjectToString2.call(value);
157
+ }
158
+ var _objectToString_default = objectToString;
159
+
160
+ // ../../node_modules/lodash-es/_baseGetTag.js
161
+ var nullTag = "[object Null]";
162
+ var undefinedTag = "[object Undefined]";
163
+ var symToStringTag2 = _Symbol_default ? _Symbol_default.toStringTag : undefined;
164
+ function baseGetTag(value) {
165
+ if (value == null) {
166
+ return value === undefined ? undefinedTag : nullTag;
167
+ }
168
+ return symToStringTag2 && symToStringTag2 in Object(value) ? _getRawTag_default(value) : _objectToString_default(value);
169
+ }
170
+ var _baseGetTag_default = baseGetTag;
171
+
172
+ // ../../node_modules/lodash-es/isObjectLike.js
173
+ function isObjectLike(value) {
174
+ return value != null && typeof value == "object";
175
+ }
176
+ var isObjectLike_default = isObjectLike;
177
+
178
+ // ../../node_modules/lodash-es/isArray.js
179
+ var isArray = Array.isArray;
180
+ var isArray_default = isArray;
181
+
182
+ // ../../node_modules/lodash-es/isObject.js
183
+ function isObject(value) {
184
+ var type = typeof value;
185
+ return value != null && (type == "object" || type == "function");
186
+ }
187
+ var isObject_default = isObject;
188
+
189
+ // ../../node_modules/lodash-es/identity.js
190
+ function identity(value) {
191
+ return value;
192
+ }
193
+ var identity_default = identity;
194
+
195
+ // ../../node_modules/lodash-es/isFunction.js
196
+ var asyncTag = "[object AsyncFunction]";
197
+ var funcTag = "[object Function]";
198
+ var genTag = "[object GeneratorFunction]";
199
+ var proxyTag = "[object Proxy]";
200
+ function isFunction(value) {
201
+ if (!isObject_default(value)) {
202
+ return false;
203
+ }
204
+ var tag = _baseGetTag_default(value);
205
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
206
+ }
207
+ var isFunction_default = isFunction;
208
+
209
+ // ../../node_modules/lodash-es/_coreJsData.js
210
+ var coreJsData = _root_default["__core-js_shared__"];
211
+ var _coreJsData_default = coreJsData;
212
+
213
+ // ../../node_modules/lodash-es/_isMasked.js
214
+ var maskSrcKey = function() {
215
+ var uid = /[^.]+$/.exec(_coreJsData_default && _coreJsData_default.keys && _coreJsData_default.keys.IE_PROTO || "");
216
+ return uid ? "Symbol(src)_1." + uid : "";
217
+ }();
218
+ function isMasked(func) {
219
+ return !!maskSrcKey && maskSrcKey in func;
220
+ }
221
+ var _isMasked_default = isMasked;
222
+
223
+ // ../../node_modules/lodash-es/_toSource.js
224
+ var funcProto = Function.prototype;
225
+ var funcToString = funcProto.toString;
226
+ function toSource(func) {
227
+ if (func != null) {
228
+ try {
229
+ return funcToString.call(func);
230
+ } catch (e) {}
231
+ try {
232
+ return func + "";
233
+ } catch (e) {}
234
+ }
235
+ return "";
236
+ }
237
+ var _toSource_default = toSource;
238
+
239
+ // ../../node_modules/lodash-es/_baseIsNative.js
240
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
241
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
242
+ var funcProto2 = Function.prototype;
243
+ var objectProto3 = Object.prototype;
244
+ var funcToString2 = funcProto2.toString;
245
+ var hasOwnProperty2 = objectProto3.hasOwnProperty;
246
+ var reIsNative = RegExp("^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$");
247
+ function baseIsNative(value) {
248
+ if (!isObject_default(value) || _isMasked_default(value)) {
249
+ return false;
250
+ }
251
+ var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
252
+ return pattern.test(_toSource_default(value));
253
+ }
254
+ var _baseIsNative_default = baseIsNative;
255
+
256
+ // ../../node_modules/lodash-es/_getValue.js
257
+ function getValue(object, key) {
258
+ return object == null ? undefined : object[key];
259
+ }
260
+ var _getValue_default = getValue;
261
+
262
+ // ../../node_modules/lodash-es/_getNative.js
263
+ function getNative(object, key) {
264
+ var value = _getValue_default(object, key);
265
+ return _baseIsNative_default(value) ? value : undefined;
266
+ }
267
+ var _getNative_default = getNative;
268
+
269
+ // ../../node_modules/lodash-es/_baseCreate.js
270
+ var objectCreate = Object.create;
271
+ var baseCreate = function() {
272
+ function object() {}
273
+ return function(proto) {
274
+ if (!isObject_default(proto)) {
275
+ return {};
276
+ }
277
+ if (objectCreate) {
278
+ return objectCreate(proto);
279
+ }
280
+ object.prototype = proto;
281
+ var result = new object;
282
+ object.prototype = undefined;
283
+ return result;
284
+ };
285
+ }();
286
+ var _baseCreate_default = baseCreate;
287
+
288
+ // ../../node_modules/lodash-es/_apply.js
289
+ function apply(func, thisArg, args) {
290
+ switch (args.length) {
291
+ case 0:
292
+ return func.call(thisArg);
293
+ case 1:
294
+ return func.call(thisArg, args[0]);
295
+ case 2:
296
+ return func.call(thisArg, args[0], args[1]);
297
+ case 3:
298
+ return func.call(thisArg, args[0], args[1], args[2]);
299
+ }
300
+ return func.apply(thisArg, args);
301
+ }
302
+ var _apply_default = apply;
303
+
304
+ // ../../node_modules/lodash-es/_copyArray.js
305
+ function copyArray(source, array) {
306
+ var index = -1, length = source.length;
307
+ array || (array = Array(length));
308
+ while (++index < length) {
309
+ array[index] = source[index];
310
+ }
311
+ return array;
312
+ }
313
+ var _copyArray_default = copyArray;
314
+
315
+ // ../../node_modules/lodash-es/_shortOut.js
316
+ var HOT_COUNT = 800;
317
+ var HOT_SPAN = 16;
318
+ var nativeNow = Date.now;
319
+ function shortOut(func) {
320
+ var count = 0, lastCalled = 0;
321
+ return function() {
322
+ var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
323
+ lastCalled = stamp;
324
+ if (remaining > 0) {
325
+ if (++count >= HOT_COUNT) {
326
+ return arguments[0];
327
+ }
328
+ } else {
329
+ count = 0;
330
+ }
331
+ return func.apply(undefined, arguments);
332
+ };
333
+ }
334
+ var _shortOut_default = shortOut;
335
+
336
+ // ../../node_modules/lodash-es/constant.js
337
+ function constant(value) {
338
+ return function() {
339
+ return value;
340
+ };
341
+ }
342
+ var constant_default = constant;
343
+
344
+ // ../../node_modules/lodash-es/_defineProperty.js
345
+ var defineProperty = function() {
346
+ try {
347
+ var func = _getNative_default(Object, "defineProperty");
348
+ func({}, "", {});
349
+ return func;
350
+ } catch (e) {}
351
+ }();
352
+ var _defineProperty_default = defineProperty;
353
+
354
+ // ../../node_modules/lodash-es/_baseSetToString.js
355
+ var baseSetToString = !_defineProperty_default ? identity_default : function(func, string) {
356
+ return _defineProperty_default(func, "toString", {
357
+ configurable: true,
358
+ enumerable: false,
359
+ value: constant_default(string),
360
+ writable: true
361
+ });
362
+ };
363
+ var _baseSetToString_default = baseSetToString;
364
+
365
+ // ../../node_modules/lodash-es/_setToString.js
366
+ var setToString = _shortOut_default(_baseSetToString_default);
367
+ var _setToString_default = setToString;
368
+
369
+ // ../../node_modules/lodash-es/_isIndex.js
370
+ var MAX_SAFE_INTEGER = 9007199254740991;
371
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
372
+ function isIndex(value, length) {
373
+ var type = typeof value;
374
+ length = length == null ? MAX_SAFE_INTEGER : length;
375
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
376
+ }
377
+ var _isIndex_default = isIndex;
378
+
379
+ // ../../node_modules/lodash-es/_baseAssignValue.js
380
+ function baseAssignValue(object, key, value) {
381
+ if (key == "__proto__" && _defineProperty_default) {
382
+ _defineProperty_default(object, key, {
383
+ configurable: true,
384
+ enumerable: true,
385
+ value,
386
+ writable: true
387
+ });
388
+ } else {
389
+ object[key] = value;
390
+ }
391
+ }
392
+ var _baseAssignValue_default = baseAssignValue;
393
+
394
+ // ../../node_modules/lodash-es/eq.js
395
+ function eq(value, other) {
396
+ return value === other || value !== value && other !== other;
397
+ }
398
+ var eq_default = eq;
399
+
400
+ // ../../node_modules/lodash-es/_assignValue.js
401
+ var objectProto4 = Object.prototype;
402
+ var hasOwnProperty3 = objectProto4.hasOwnProperty;
403
+ function assignValue(object, key, value) {
404
+ var objValue = object[key];
405
+ if (!(hasOwnProperty3.call(object, key) && eq_default(objValue, value)) || value === undefined && !(key in object)) {
406
+ _baseAssignValue_default(object, key, value);
407
+ }
408
+ }
409
+ var _assignValue_default = assignValue;
410
+
411
+ // ../../node_modules/lodash-es/_copyObject.js
412
+ function copyObject(source, props, object, customizer) {
413
+ var isNew = !object;
414
+ object || (object = {});
415
+ var index = -1, length = props.length;
416
+ while (++index < length) {
417
+ var key = props[index];
418
+ var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined;
419
+ if (newValue === undefined) {
420
+ newValue = source[key];
421
+ }
422
+ if (isNew) {
423
+ _baseAssignValue_default(object, key, newValue);
424
+ } else {
425
+ _assignValue_default(object, key, newValue);
426
+ }
427
+ }
428
+ return object;
429
+ }
430
+ var _copyObject_default = copyObject;
431
+
432
+ // ../../node_modules/lodash-es/_overRest.js
433
+ var nativeMax = Math.max;
434
+ function overRest(func, start, transform) {
435
+ start = nativeMax(start === undefined ? func.length - 1 : start, 0);
436
+ return function() {
437
+ var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
438
+ while (++index < length) {
439
+ array[index] = args[start + index];
440
+ }
441
+ index = -1;
442
+ var otherArgs = Array(start + 1);
443
+ while (++index < start) {
444
+ otherArgs[index] = args[index];
445
+ }
446
+ otherArgs[start] = transform(array);
447
+ return _apply_default(func, this, otherArgs);
448
+ };
449
+ }
450
+ var _overRest_default = overRest;
451
+
452
+ // ../../node_modules/lodash-es/_baseRest.js
453
+ function baseRest(func, start) {
454
+ return _setToString_default(_overRest_default(func, start, identity_default), func + "");
455
+ }
456
+ var _baseRest_default = baseRest;
457
+
458
+ // ../../node_modules/lodash-es/isLength.js
459
+ var MAX_SAFE_INTEGER2 = 9007199254740991;
460
+ function isLength(value) {
461
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
462
+ }
463
+ var isLength_default = isLength;
464
+
465
+ // ../../node_modules/lodash-es/isArrayLike.js
466
+ function isArrayLike(value) {
467
+ return value != null && isLength_default(value.length) && !isFunction_default(value);
468
+ }
469
+ var isArrayLike_default = isArrayLike;
470
+
471
+ // ../../node_modules/lodash-es/_isIterateeCall.js
472
+ function isIterateeCall(value, index, object) {
473
+ if (!isObject_default(object)) {
474
+ return false;
475
+ }
476
+ var type = typeof index;
477
+ if (type == "number" ? isArrayLike_default(object) && _isIndex_default(index, object.length) : type == "string" && (index in object)) {
478
+ return eq_default(object[index], value);
479
+ }
480
+ return false;
481
+ }
482
+ var _isIterateeCall_default = isIterateeCall;
483
+
484
+ // ../../node_modules/lodash-es/_createAssigner.js
485
+ function createAssigner(assigner) {
486
+ return _baseRest_default(function(object, sources) {
487
+ var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : undefined, guard = length > 2 ? sources[2] : undefined;
488
+ customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : undefined;
489
+ if (guard && _isIterateeCall_default(sources[0], sources[1], guard)) {
490
+ customizer = length < 3 ? undefined : customizer;
491
+ length = 1;
492
+ }
493
+ object = Object(object);
494
+ while (++index < length) {
495
+ var source = sources[index];
496
+ if (source) {
497
+ assigner(object, source, index, customizer);
498
+ }
499
+ }
500
+ return object;
501
+ });
502
+ }
503
+ var _createAssigner_default = createAssigner;
504
+
505
+ // ../../node_modules/lodash-es/_isPrototype.js
506
+ var objectProto5 = Object.prototype;
507
+ function isPrototype(value) {
508
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto5;
509
+ return value === proto;
510
+ }
511
+ var _isPrototype_default = isPrototype;
512
+
513
+ // ../../node_modules/lodash-es/_baseTimes.js
514
+ function baseTimes(n, iteratee) {
515
+ var index = -1, result = Array(n);
516
+ while (++index < n) {
517
+ result[index] = iteratee(index);
518
+ }
519
+ return result;
520
+ }
521
+ var _baseTimes_default = baseTimes;
522
+
523
+ // ../../node_modules/lodash-es/_baseIsArguments.js
524
+ var argsTag = "[object Arguments]";
525
+ function baseIsArguments(value) {
526
+ return isObjectLike_default(value) && _baseGetTag_default(value) == argsTag;
527
+ }
528
+ var _baseIsArguments_default = baseIsArguments;
529
+
530
+ // ../../node_modules/lodash-es/isArguments.js
531
+ var objectProto6 = Object.prototype;
532
+ var hasOwnProperty4 = objectProto6.hasOwnProperty;
533
+ var propertyIsEnumerable = objectProto6.propertyIsEnumerable;
534
+ var isArguments = _baseIsArguments_default(function() {
535
+ return arguments;
536
+ }()) ? _baseIsArguments_default : function(value) {
537
+ return isObjectLike_default(value) && hasOwnProperty4.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
538
+ };
539
+ var isArguments_default = isArguments;
540
+
541
+ // ../../node_modules/lodash-es/isBuffer.js
542
+ var exports_isBuffer = {};
543
+ __export(exports_isBuffer, {
544
+ default: () => isBuffer_default
545
+ });
546
+
547
+ // ../../node_modules/lodash-es/stubFalse.js
548
+ function stubFalse() {
549
+ return false;
550
+ }
551
+ var stubFalse_default = stubFalse;
552
+
553
+ // ../../node_modules/lodash-es/isBuffer.js
554
+ var freeExports = typeof exports_isBuffer == "object" && exports_isBuffer && !exports_isBuffer.nodeType && exports_isBuffer;
555
+ var freeModule = freeExports && typeof module_isBuffer == "object" && module_isBuffer && !module_isBuffer.nodeType && module_isBuffer;
556
+ var moduleExports = freeModule && freeModule.exports === freeExports;
557
+ var Buffer = moduleExports ? _root_default.Buffer : undefined;
558
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
559
+ var isBuffer = nativeIsBuffer || stubFalse_default;
560
+ var isBuffer_default = isBuffer;
561
+
562
+ // ../../node_modules/lodash-es/_baseIsTypedArray.js
563
+ var argsTag2 = "[object Arguments]";
564
+ var arrayTag = "[object Array]";
565
+ var boolTag = "[object Boolean]";
566
+ var dateTag = "[object Date]";
567
+ var errorTag = "[object Error]";
568
+ var funcTag2 = "[object Function]";
569
+ var mapTag = "[object Map]";
570
+ var numberTag = "[object Number]";
571
+ var objectTag = "[object Object]";
572
+ var regexpTag = "[object RegExp]";
573
+ var setTag = "[object Set]";
574
+ var stringTag = "[object String]";
575
+ var weakMapTag = "[object WeakMap]";
576
+ var arrayBufferTag = "[object ArrayBuffer]";
577
+ var dataViewTag = "[object DataView]";
578
+ var float32Tag = "[object Float32Array]";
579
+ var float64Tag = "[object Float64Array]";
580
+ var int8Tag = "[object Int8Array]";
581
+ var int16Tag = "[object Int16Array]";
582
+ var int32Tag = "[object Int32Array]";
583
+ var uint8Tag = "[object Uint8Array]";
584
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
585
+ var uint16Tag = "[object Uint16Array]";
586
+ var uint32Tag = "[object Uint32Array]";
587
+ var typedArrayTags = {};
588
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
589
+ typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
590
+ function baseIsTypedArray(value) {
591
+ return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[_baseGetTag_default(value)];
592
+ }
593
+ var _baseIsTypedArray_default = baseIsTypedArray;
594
+
595
+ // ../../node_modules/lodash-es/_baseUnary.js
596
+ function baseUnary(func) {
597
+ return function(value) {
598
+ return func(value);
599
+ };
600
+ }
601
+ var _baseUnary_default = baseUnary;
602
+
603
+ // ../../node_modules/lodash-es/_nodeUtil.js
604
+ var exports__nodeUtil = {};
605
+ __export(exports__nodeUtil, {
606
+ default: () => _nodeUtil_default
607
+ });
608
+ var freeExports2 = typeof exports__nodeUtil == "object" && exports__nodeUtil && !exports__nodeUtil.nodeType && exports__nodeUtil;
609
+ var freeModule2 = freeExports2 && typeof module__nodeUtil == "object" && module__nodeUtil && !module__nodeUtil.nodeType && module__nodeUtil;
610
+ var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
611
+ var freeProcess = moduleExports2 && _freeGlobal_default.process;
612
+ var nodeUtil = function() {
613
+ try {
614
+ var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
615
+ if (types) {
616
+ return types;
617
+ }
618
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
619
+ } catch (e) {}
620
+ }();
621
+ var _nodeUtil_default = nodeUtil;
622
+
623
+ // ../../node_modules/lodash-es/isTypedArray.js
624
+ var nodeIsTypedArray = _nodeUtil_default && _nodeUtil_default.isTypedArray;
625
+ var isTypedArray = nodeIsTypedArray ? _baseUnary_default(nodeIsTypedArray) : _baseIsTypedArray_default;
626
+ var isTypedArray_default = isTypedArray;
627
+
628
+ // ../../node_modules/lodash-es/_arrayLikeKeys.js
629
+ var objectProto7 = Object.prototype;
630
+ var hasOwnProperty5 = objectProto7.hasOwnProperty;
631
+ function arrayLikeKeys(value, inherited) {
632
+ var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? _baseTimes_default(value.length, String) : [], length = result.length;
633
+ for (var key in value) {
634
+ if ((inherited || hasOwnProperty5.call(value, key)) && !(skipIndexes && (key == "length" || isBuff && (key == "offset" || key == "parent") || isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || _isIndex_default(key, length)))) {
635
+ result.push(key);
636
+ }
637
+ }
638
+ return result;
639
+ }
640
+ var _arrayLikeKeys_default = arrayLikeKeys;
641
+
642
+ // ../../node_modules/lodash-es/_overArg.js
643
+ function overArg(func, transform) {
644
+ return function(arg) {
645
+ return func(transform(arg));
646
+ };
647
+ }
648
+ var _overArg_default = overArg;
649
+
650
+ // ../../node_modules/lodash-es/_nativeKeysIn.js
651
+ function nativeKeysIn(object) {
652
+ var result = [];
653
+ if (object != null) {
654
+ for (var key in Object(object)) {
655
+ result.push(key);
656
+ }
657
+ }
658
+ return result;
659
+ }
660
+ var _nativeKeysIn_default = nativeKeysIn;
661
+
662
+ // ../../node_modules/lodash-es/_baseKeysIn.js
663
+ var objectProto8 = Object.prototype;
664
+ var hasOwnProperty6 = objectProto8.hasOwnProperty;
665
+ function baseKeysIn(object) {
666
+ if (!isObject_default(object)) {
667
+ return _nativeKeysIn_default(object);
668
+ }
669
+ var isProto = _isPrototype_default(object), result = [];
670
+ for (var key in object) {
671
+ if (!(key == "constructor" && (isProto || !hasOwnProperty6.call(object, key)))) {
672
+ result.push(key);
673
+ }
674
+ }
675
+ return result;
676
+ }
677
+ var _baseKeysIn_default = baseKeysIn;
678
+
679
+ // ../../node_modules/lodash-es/keysIn.js
680
+ function keysIn(object) {
681
+ return isArrayLike_default(object) ? _arrayLikeKeys_default(object, true) : _baseKeysIn_default(object);
682
+ }
683
+ var keysIn_default = keysIn;
684
+
685
+ // ../../node_modules/lodash-es/_nativeCreate.js
686
+ var nativeCreate = _getNative_default(Object, "create");
687
+ var _nativeCreate_default = nativeCreate;
688
+
689
+ // ../../node_modules/lodash-es/_hashClear.js
690
+ function hashClear() {
691
+ this.__data__ = _nativeCreate_default ? _nativeCreate_default(null) : {};
692
+ this.size = 0;
693
+ }
694
+ var _hashClear_default = hashClear;
695
+
696
+ // ../../node_modules/lodash-es/_hashDelete.js
697
+ function hashDelete(key) {
698
+ var result = this.has(key) && delete this.__data__[key];
699
+ this.size -= result ? 1 : 0;
700
+ return result;
701
+ }
702
+ var _hashDelete_default = hashDelete;
703
+
704
+ // ../../node_modules/lodash-es/_hashGet.js
705
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
706
+ var objectProto9 = Object.prototype;
707
+ var hasOwnProperty7 = objectProto9.hasOwnProperty;
708
+ function hashGet(key) {
709
+ var data = this.__data__;
710
+ if (_nativeCreate_default) {
711
+ var result = data[key];
712
+ return result === HASH_UNDEFINED ? undefined : result;
713
+ }
714
+ return hasOwnProperty7.call(data, key) ? data[key] : undefined;
715
+ }
716
+ var _hashGet_default = hashGet;
717
+
718
+ // ../../node_modules/lodash-es/_hashHas.js
719
+ var objectProto10 = Object.prototype;
720
+ var hasOwnProperty8 = objectProto10.hasOwnProperty;
721
+ function hashHas(key) {
722
+ var data = this.__data__;
723
+ return _nativeCreate_default ? data[key] !== undefined : hasOwnProperty8.call(data, key);
724
+ }
725
+ var _hashHas_default = hashHas;
726
+
727
+ // ../../node_modules/lodash-es/_hashSet.js
728
+ var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
729
+ function hashSet(key, value) {
730
+ var data = this.__data__;
731
+ this.size += this.has(key) ? 0 : 1;
732
+ data[key] = _nativeCreate_default && value === undefined ? HASH_UNDEFINED2 : value;
733
+ return this;
734
+ }
735
+ var _hashSet_default = hashSet;
736
+
737
+ // ../../node_modules/lodash-es/_Hash.js
738
+ function Hash(entries) {
739
+ var index = -1, length = entries == null ? 0 : entries.length;
740
+ this.clear();
741
+ while (++index < length) {
742
+ var entry = entries[index];
743
+ this.set(entry[0], entry[1]);
744
+ }
745
+ }
746
+ Hash.prototype.clear = _hashClear_default;
747
+ Hash.prototype["delete"] = _hashDelete_default;
748
+ Hash.prototype.get = _hashGet_default;
749
+ Hash.prototype.has = _hashHas_default;
750
+ Hash.prototype.set = _hashSet_default;
751
+ var _Hash_default = Hash;
752
+
753
+ // ../../node_modules/lodash-es/_listCacheClear.js
754
+ function listCacheClear() {
755
+ this.__data__ = [];
756
+ this.size = 0;
757
+ }
758
+ var _listCacheClear_default = listCacheClear;
759
+
760
+ // ../../node_modules/lodash-es/_assocIndexOf.js
761
+ function assocIndexOf(array, key) {
762
+ var length = array.length;
763
+ while (length--) {
764
+ if (eq_default(array[length][0], key)) {
765
+ return length;
766
+ }
767
+ }
768
+ return -1;
769
+ }
770
+ var _assocIndexOf_default = assocIndexOf;
771
+
772
+ // ../../node_modules/lodash-es/_listCacheDelete.js
773
+ var arrayProto = Array.prototype;
774
+ var splice = arrayProto.splice;
775
+ function listCacheDelete(key) {
776
+ var data = this.__data__, index = _assocIndexOf_default(data, key);
777
+ if (index < 0) {
778
+ return false;
779
+ }
780
+ var lastIndex = data.length - 1;
781
+ if (index == lastIndex) {
782
+ data.pop();
783
+ } else {
784
+ splice.call(data, index, 1);
785
+ }
786
+ --this.size;
787
+ return true;
788
+ }
789
+ var _listCacheDelete_default = listCacheDelete;
790
+
791
+ // ../../node_modules/lodash-es/_listCacheGet.js
792
+ function listCacheGet(key) {
793
+ var data = this.__data__, index = _assocIndexOf_default(data, key);
794
+ return index < 0 ? undefined : data[index][1];
795
+ }
796
+ var _listCacheGet_default = listCacheGet;
797
+
798
+ // ../../node_modules/lodash-es/_listCacheHas.js
799
+ function listCacheHas(key) {
800
+ return _assocIndexOf_default(this.__data__, key) > -1;
801
+ }
802
+ var _listCacheHas_default = listCacheHas;
803
+
804
+ // ../../node_modules/lodash-es/_listCacheSet.js
805
+ function listCacheSet(key, value) {
806
+ var data = this.__data__, index = _assocIndexOf_default(data, key);
807
+ if (index < 0) {
808
+ ++this.size;
809
+ data.push([key, value]);
810
+ } else {
811
+ data[index][1] = value;
812
+ }
813
+ return this;
814
+ }
815
+ var _listCacheSet_default = listCacheSet;
816
+
817
+ // ../../node_modules/lodash-es/_ListCache.js
818
+ function ListCache(entries) {
819
+ var index = -1, length = entries == null ? 0 : entries.length;
820
+ this.clear();
821
+ while (++index < length) {
822
+ var entry = entries[index];
823
+ this.set(entry[0], entry[1]);
824
+ }
825
+ }
826
+ ListCache.prototype.clear = _listCacheClear_default;
827
+ ListCache.prototype["delete"] = _listCacheDelete_default;
828
+ ListCache.prototype.get = _listCacheGet_default;
829
+ ListCache.prototype.has = _listCacheHas_default;
830
+ ListCache.prototype.set = _listCacheSet_default;
831
+ var _ListCache_default = ListCache;
832
+
833
+ // ../../node_modules/lodash-es/_Map.js
834
+ var Map = _getNative_default(_root_default, "Map");
835
+ var _Map_default = Map;
836
+
837
+ // ../../node_modules/lodash-es/_mapCacheClear.js
838
+ function mapCacheClear() {
839
+ this.size = 0;
840
+ this.__data__ = {
841
+ hash: new _Hash_default,
842
+ map: new (_Map_default || _ListCache_default),
843
+ string: new _Hash_default
844
+ };
845
+ }
846
+ var _mapCacheClear_default = mapCacheClear;
847
+
848
+ // ../../node_modules/lodash-es/_isKeyable.js
849
+ function isKeyable(value) {
850
+ var type = typeof value;
851
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
852
+ }
853
+ var _isKeyable_default = isKeyable;
854
+
855
+ // ../../node_modules/lodash-es/_getMapData.js
856
+ function getMapData(map, key) {
857
+ var data = map.__data__;
858
+ return _isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
859
+ }
860
+ var _getMapData_default = getMapData;
861
+
862
+ // ../../node_modules/lodash-es/_mapCacheDelete.js
863
+ function mapCacheDelete(key) {
864
+ var result = _getMapData_default(this, key)["delete"](key);
865
+ this.size -= result ? 1 : 0;
866
+ return result;
867
+ }
868
+ var _mapCacheDelete_default = mapCacheDelete;
869
+
870
+ // ../../node_modules/lodash-es/_mapCacheGet.js
871
+ function mapCacheGet(key) {
872
+ return _getMapData_default(this, key).get(key);
873
+ }
874
+ var _mapCacheGet_default = mapCacheGet;
875
+
876
+ // ../../node_modules/lodash-es/_mapCacheHas.js
877
+ function mapCacheHas(key) {
878
+ return _getMapData_default(this, key).has(key);
879
+ }
880
+ var _mapCacheHas_default = mapCacheHas;
881
+
882
+ // ../../node_modules/lodash-es/_mapCacheSet.js
883
+ function mapCacheSet(key, value) {
884
+ var data = _getMapData_default(this, key), size = data.size;
885
+ data.set(key, value);
886
+ this.size += data.size == size ? 0 : 1;
887
+ return this;
888
+ }
889
+ var _mapCacheSet_default = mapCacheSet;
890
+
891
+ // ../../node_modules/lodash-es/_MapCache.js
892
+ function MapCache(entries) {
893
+ var index = -1, length = entries == null ? 0 : entries.length;
894
+ this.clear();
895
+ while (++index < length) {
896
+ var entry = entries[index];
897
+ this.set(entry[0], entry[1]);
898
+ }
899
+ }
900
+ MapCache.prototype.clear = _mapCacheClear_default;
901
+ MapCache.prototype["delete"] = _mapCacheDelete_default;
902
+ MapCache.prototype.get = _mapCacheGet_default;
903
+ MapCache.prototype.has = _mapCacheHas_default;
904
+ MapCache.prototype.set = _mapCacheSet_default;
905
+ var _MapCache_default = MapCache;
906
+
907
+ // ../../node_modules/lodash-es/_getPrototype.js
908
+ var getPrototype = _overArg_default(Object.getPrototypeOf, Object);
909
+ var _getPrototype_default = getPrototype;
910
+
911
+ // ../../node_modules/lodash-es/isPlainObject.js
912
+ var objectTag2 = "[object Object]";
913
+ var funcProto3 = Function.prototype;
914
+ var objectProto11 = Object.prototype;
915
+ var funcToString3 = funcProto3.toString;
916
+ var hasOwnProperty9 = objectProto11.hasOwnProperty;
917
+ var objectCtorString = funcToString3.call(Object);
918
+ function isPlainObject(value) {
919
+ if (!isObjectLike_default(value) || _baseGetTag_default(value) != objectTag2) {
920
+ return false;
921
+ }
922
+ var proto = _getPrototype_default(value);
923
+ if (proto === null) {
924
+ return true;
925
+ }
926
+ var Ctor = hasOwnProperty9.call(proto, "constructor") && proto.constructor;
927
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
928
+ }
929
+ var isPlainObject_default = isPlainObject;
930
+
931
+ // ../../node_modules/lodash-es/_stackClear.js
932
+ function stackClear() {
933
+ this.__data__ = new _ListCache_default;
934
+ this.size = 0;
935
+ }
936
+ var _stackClear_default = stackClear;
937
+
938
+ // ../../node_modules/lodash-es/_stackDelete.js
939
+ function stackDelete(key) {
940
+ var data = this.__data__, result = data["delete"](key);
941
+ this.size = data.size;
942
+ return result;
943
+ }
944
+ var _stackDelete_default = stackDelete;
945
+
946
+ // ../../node_modules/lodash-es/_stackGet.js
947
+ function stackGet(key) {
948
+ return this.__data__.get(key);
949
+ }
950
+ var _stackGet_default = stackGet;
951
+
952
+ // ../../node_modules/lodash-es/_stackHas.js
953
+ function stackHas(key) {
954
+ return this.__data__.has(key);
955
+ }
956
+ var _stackHas_default = stackHas;
957
+
958
+ // ../../node_modules/lodash-es/_stackSet.js
959
+ var LARGE_ARRAY_SIZE = 200;
960
+ function stackSet(key, value) {
961
+ var data = this.__data__;
962
+ if (data instanceof _ListCache_default) {
963
+ var pairs = data.__data__;
964
+ if (!_Map_default || pairs.length < LARGE_ARRAY_SIZE - 1) {
965
+ pairs.push([key, value]);
966
+ this.size = ++data.size;
967
+ return this;
968
+ }
969
+ data = this.__data__ = new _MapCache_default(pairs);
970
+ }
971
+ data.set(key, value);
972
+ this.size = data.size;
973
+ return this;
974
+ }
975
+ var _stackSet_default = stackSet;
976
+
977
+ // ../../node_modules/lodash-es/_Stack.js
978
+ function Stack(entries) {
979
+ var data = this.__data__ = new _ListCache_default(entries);
980
+ this.size = data.size;
981
+ }
982
+ Stack.prototype.clear = _stackClear_default;
983
+ Stack.prototype["delete"] = _stackDelete_default;
984
+ Stack.prototype.get = _stackGet_default;
985
+ Stack.prototype.has = _stackHas_default;
986
+ Stack.prototype.set = _stackSet_default;
987
+ var _Stack_default = Stack;
988
+
989
+ // ../../node_modules/lodash-es/_cloneBuffer.js
990
+ var exports__cloneBuffer = {};
991
+ __export(exports__cloneBuffer, {
992
+ default: () => _cloneBuffer_default
993
+ });
994
+ var freeExports3 = typeof exports__cloneBuffer == "object" && exports__cloneBuffer && !exports__cloneBuffer.nodeType && exports__cloneBuffer;
995
+ var freeModule3 = freeExports3 && typeof module__cloneBuffer == "object" && module__cloneBuffer && !module__cloneBuffer.nodeType && module__cloneBuffer;
996
+ var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
997
+ var Buffer2 = moduleExports3 ? _root_default.Buffer : undefined;
998
+ var allocUnsafe = Buffer2 ? Buffer2.allocUnsafe : undefined;
999
+ function cloneBuffer(buffer, isDeep) {
1000
+ if (isDeep) {
1001
+ return buffer.slice();
1002
+ }
1003
+ var length = buffer.length, result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
1004
+ buffer.copy(result);
1005
+ return result;
1006
+ }
1007
+ var _cloneBuffer_default = cloneBuffer;
1008
+
1009
+ // ../../node_modules/lodash-es/_Uint8Array.js
1010
+ var Uint8Array = _root_default.Uint8Array;
1011
+ var _Uint8Array_default = Uint8Array;
1012
+
1013
+ // ../../node_modules/lodash-es/_cloneArrayBuffer.js
1014
+ function cloneArrayBuffer(arrayBuffer) {
1015
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1016
+ new _Uint8Array_default(result).set(new _Uint8Array_default(arrayBuffer));
1017
+ return result;
1018
+ }
1019
+ var _cloneArrayBuffer_default = cloneArrayBuffer;
1020
+
1021
+ // ../../node_modules/lodash-es/_cloneTypedArray.js
1022
+ function cloneTypedArray(typedArray, isDeep) {
1023
+ var buffer = isDeep ? _cloneArrayBuffer_default(typedArray.buffer) : typedArray.buffer;
1024
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1025
+ }
1026
+ var _cloneTypedArray_default = cloneTypedArray;
1027
+
1028
+ // ../../node_modules/lodash-es/_initCloneObject.js
1029
+ function initCloneObject(object) {
1030
+ return typeof object.constructor == "function" && !_isPrototype_default(object) ? _baseCreate_default(_getPrototype_default(object)) : {};
1031
+ }
1032
+ var _initCloneObject_default = initCloneObject;
1033
+
1034
+ // ../../node_modules/lodash-es/_createBaseFor.js
1035
+ function createBaseFor(fromRight) {
1036
+ return function(object, iteratee, keysFunc) {
1037
+ var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
1038
+ while (length--) {
1039
+ var key = props[fromRight ? length : ++index];
1040
+ if (iteratee(iterable[key], key, iterable) === false) {
1041
+ break;
1042
+ }
1043
+ }
1044
+ return object;
1045
+ };
1046
+ }
1047
+ var _createBaseFor_default = createBaseFor;
1048
+
1049
+ // ../../node_modules/lodash-es/_baseFor.js
1050
+ var baseFor = _createBaseFor_default();
1051
+ var _baseFor_default = baseFor;
1052
+
1053
+ // ../../node_modules/lodash-es/_assignMergeValue.js
1054
+ function assignMergeValue(object, key, value) {
1055
+ if (value !== undefined && !eq_default(object[key], value) || value === undefined && !(key in object)) {
1056
+ _baseAssignValue_default(object, key, value);
1057
+ }
1058
+ }
1059
+ var _assignMergeValue_default = assignMergeValue;
1060
+
1061
+ // ../../node_modules/lodash-es/isArrayLikeObject.js
1062
+ function isArrayLikeObject(value) {
1063
+ return isObjectLike_default(value) && isArrayLike_default(value);
1064
+ }
1065
+ var isArrayLikeObject_default = isArrayLikeObject;
1066
+
1067
+ // ../../node_modules/lodash-es/_safeGet.js
1068
+ function safeGet(object, key) {
1069
+ if (key === "constructor" && typeof object[key] === "function") {
1070
+ return;
1071
+ }
1072
+ if (key == "__proto__") {
1073
+ return;
1074
+ }
1075
+ return object[key];
1076
+ }
1077
+ var _safeGet_default = safeGet;
1078
+
1079
+ // ../../node_modules/lodash-es/toPlainObject.js
1080
+ function toPlainObject(value) {
1081
+ return _copyObject_default(value, keysIn_default(value));
1082
+ }
1083
+ var toPlainObject_default = toPlainObject;
1084
+
1085
+ // ../../node_modules/lodash-es/_baseMergeDeep.js
1086
+ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
1087
+ var objValue = _safeGet_default(object, key), srcValue = _safeGet_default(source, key), stacked = stack.get(srcValue);
1088
+ if (stacked) {
1089
+ _assignMergeValue_default(object, key, stacked);
1090
+ return;
1091
+ }
1092
+ var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : undefined;
1093
+ var isCommon = newValue === undefined;
1094
+ if (isCommon) {
1095
+ var isArr = isArray_default(srcValue), isBuff = !isArr && isBuffer_default(srcValue), isTyped = !isArr && !isBuff && isTypedArray_default(srcValue);
1096
+ newValue = srcValue;
1097
+ if (isArr || isBuff || isTyped) {
1098
+ if (isArray_default(objValue)) {
1099
+ newValue = objValue;
1100
+ } else if (isArrayLikeObject_default(objValue)) {
1101
+ newValue = _copyArray_default(objValue);
1102
+ } else if (isBuff) {
1103
+ isCommon = false;
1104
+ newValue = _cloneBuffer_default(srcValue, true);
1105
+ } else if (isTyped) {
1106
+ isCommon = false;
1107
+ newValue = _cloneTypedArray_default(srcValue, true);
1108
+ } else {
1109
+ newValue = [];
1110
+ }
1111
+ } else if (isPlainObject_default(srcValue) || isArguments_default(srcValue)) {
1112
+ newValue = objValue;
1113
+ if (isArguments_default(objValue)) {
1114
+ newValue = toPlainObject_default(objValue);
1115
+ } else if (!isObject_default(objValue) || isFunction_default(objValue)) {
1116
+ newValue = _initCloneObject_default(srcValue);
1117
+ }
1118
+ } else {
1119
+ isCommon = false;
1120
+ }
1121
+ }
1122
+ if (isCommon) {
1123
+ stack.set(srcValue, newValue);
1124
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
1125
+ stack["delete"](srcValue);
1126
+ }
1127
+ _assignMergeValue_default(object, key, newValue);
1128
+ }
1129
+ var _baseMergeDeep_default = baseMergeDeep;
1130
+
1131
+ // ../../node_modules/lodash-es/_baseMerge.js
1132
+ function baseMerge(object, source, srcIndex, customizer, stack) {
1133
+ if (object === source) {
1134
+ return;
1135
+ }
1136
+ _baseFor_default(source, function(srcValue, key) {
1137
+ stack || (stack = new _Stack_default);
1138
+ if (isObject_default(srcValue)) {
1139
+ _baseMergeDeep_default(object, source, key, srcIndex, baseMerge, customizer, stack);
1140
+ } else {
1141
+ var newValue = customizer ? customizer(_safeGet_default(object, key), srcValue, key + "", object, source, stack) : undefined;
1142
+ if (newValue === undefined) {
1143
+ newValue = srcValue;
1144
+ }
1145
+ _assignMergeValue_default(object, key, newValue);
1146
+ }
1147
+ }, keysIn_default);
1148
+ }
1149
+ var _baseMerge_default = baseMerge;
1150
+
1151
+ // ../../node_modules/lodash-es/merge.js
1152
+ var merge = _createAssigner_default(function(object, source, srcIndex) {
1153
+ _baseMerge_default(object, source, srcIndex);
1154
+ });
1155
+ var merge_default = merge;
1156
+ // src/airplay/client.ts
1157
+ class Client {
1158
+ get bundleIdentifier() {
1159
+ return this.#bundleIdentifier;
1160
+ }
1161
+ get displayName() {
1162
+ return this.#displayName;
1163
+ }
1164
+ get playbackQueue() {
1165
+ return this.#playbackQueue;
1166
+ }
1167
+ get playbackState() {
1168
+ return this.#playbackState;
1169
+ }
1170
+ get playbackStateTimestamp() {
1171
+ return this.#playbackStateTimestamp;
1172
+ }
1173
+ get supportedCommands() {
1174
+ return this.#supportedCommands;
1175
+ }
1176
+ #bundleIdentifier;
1177
+ #displayName;
1178
+ #playbackQueue = null;
1179
+ #playbackState;
1180
+ #playbackStateTimestamp;
1181
+ #supportedCommands = [];
1182
+ constructor(bundleIdentifier, displayName) {
1183
+ this.#bundleIdentifier = bundleIdentifier;
1184
+ this.#displayName = displayName;
1185
+ this.#playbackState = Proto2.PlaybackState_Enum.Unknown;
1186
+ this.#supportedCommands = [];
1187
+ }
1188
+ isCommandSupported(command) {
1189
+ return this.#supportedCommands.some((c) => c.command === command);
1190
+ }
1191
+ setPlaybackQueue(playbackQueue) {
1192
+ this.#playbackQueue = playbackQueue;
1193
+ }
1194
+ setPlaybackState(playbackState, playbackStateTimestamp) {
1195
+ this.#playbackState = playbackState;
1196
+ this.#playbackStateTimestamp = playbackStateTimestamp;
1197
+ }
1198
+ setSupportedCommands(supportedCommands) {
1199
+ this.#supportedCommands = supportedCommands;
1200
+ }
1201
+ updateContentItem(item) {
1202
+ if (!this.#playbackQueue) {
1203
+ return;
1204
+ }
1205
+ const index = this.#playbackQueue.contentItems.findIndex((i) => i.identifier === item.identifier);
1206
+ if (index === -1) {
1207
+ return;
1208
+ }
1209
+ this.#playbackQueue.contentItems[index] = merge_default(item, this.#playbackQueue.contentItems[index]);
1210
+ }
1211
+ }
1212
+
1213
+ // src/airplay/state.ts
1214
+ class state_default extends EventEmitter {
1215
+ get #dataStream() {
1216
+ return this.#protocol.dataStream;
1217
+ }
1218
+ get #protocol() {
1219
+ return this.#device[PROTOCOL];
1220
+ }
1221
+ get clients() {
1222
+ return this.#clients;
1223
+ }
1224
+ get nowPlayingClient() {
1225
+ return this.#nowPlayingClientBundleIdentifier ? this.#clients[this.#nowPlayingClientBundleIdentifier] ?? null : null;
1226
+ }
1227
+ get outputDeviceUID() {
1228
+ return this.#outputDeviceUID;
1229
+ }
1230
+ get volume() {
1231
+ return this.#volume;
1232
+ }
1233
+ get volumeAvailable() {
1234
+ return this.#volumeAvailable;
1235
+ }
1236
+ get volumeCapabilities() {
1237
+ return this.#volumeCapabilities;
1238
+ }
1239
+ #device;
1240
+ #clients;
1241
+ #nowPlayingClientBundleIdentifier;
1242
+ #outputDeviceUID;
1243
+ #volume;
1244
+ #volumeAvailable;
1245
+ #volumeCapabilities;
1246
+ constructor(device) {
1247
+ super();
1248
+ this.#device = device;
1249
+ this.clear();
1250
+ this.onDeviceInfo = this.onDeviceInfo.bind(this);
1251
+ this.onDeviceInfoUpdate = this.onDeviceInfoUpdate.bind(this);
1252
+ this.onOriginClientProperties = this.onOriginClientProperties.bind(this);
1253
+ this.onPlayerClientProperties = this.onPlayerClientProperties.bind(this);
1254
+ this.onRemoveClient = this.onRemoveClient.bind(this);
1255
+ this.onSendCommandResult = this.onSendCommandResult.bind(this);
1256
+ this.onSetArtwork = this.onSetArtwork.bind(this);
1257
+ this.onSetDefaultSupportedCommands = this.onSetDefaultSupportedCommands.bind(this);
1258
+ this.onSetNowPlayingClient = this.onSetNowPlayingClient.bind(this);
1259
+ this.onSetNowPlayingPlayer = this.onSetNowPlayingPlayer.bind(this);
1260
+ this.onSetState = this.onSetState.bind(this);
1261
+ this.onUpdateClient = this.onUpdateClient.bind(this);
1262
+ this.onUpdateContentItem = this.onUpdateContentItem.bind(this);
1263
+ this.onUpdateContentItemArtwork = this.onUpdateContentItemArtwork.bind(this);
1264
+ this.onUpdatePlayer = this.onUpdatePlayer.bind(this);
1265
+ this.onUpdateOutputDevice = this.onUpdateOutputDevice.bind(this);
1266
+ this.onVolumeControlAvailability = this.onVolumeControlAvailability.bind(this);
1267
+ this.onVolumeControlCapabilitiesDidChange = this.onVolumeControlCapabilitiesDidChange.bind(this);
1268
+ this.onVolumeDidChange = this.onVolumeDidChange.bind(this);
1269
+ }
1270
+ async[STATE_SUBSCRIBE_SYMBOL]() {
1271
+ this.#dataStream.on("deviceInfo", this.onDeviceInfo);
1272
+ this.#dataStream.on("deviceInfoUpdate", this.onDeviceInfoUpdate);
1273
+ this.#dataStream.on("originClientProperties", this.onOriginClientProperties);
1274
+ this.#dataStream.on("playerClientProperties", this.onPlayerClientProperties);
1275
+ this.#dataStream.on("removeClient", this.onRemoveClient);
1276
+ this.#dataStream.on("sendCommandResult", this.onSendCommandResult);
1277
+ this.#dataStream.on("setArtwork", this.onSetArtwork);
1278
+ this.#dataStream.on("setDefaultSupportedCommands", this.onSetDefaultSupportedCommands);
1279
+ this.#dataStream.on("setNowPlayingClient", this.onSetNowPlayingClient);
1280
+ this.#dataStream.on("setNowPlayingPlayer", this.onSetNowPlayingPlayer);
1281
+ this.#dataStream.on("setState", this.onSetState);
1282
+ this.#dataStream.on("updateClient", this.onUpdateClient);
1283
+ this.#dataStream.on("updateContentItem", this.onUpdateContentItem);
1284
+ this.#dataStream.on("updateContentItemArtwork", this.onUpdateContentItemArtwork);
1285
+ this.#dataStream.on("updatePlayer", this.onUpdatePlayer);
1286
+ this.#dataStream.on("updateOutputDevice", this.onUpdateOutputDevice);
1287
+ this.#dataStream.on("volumeControlAvailability", this.onVolumeControlAvailability);
1288
+ this.#dataStream.on("volumeControlCapabilitiesDidChange", this.onVolumeControlCapabilitiesDidChange);
1289
+ this.#dataStream.on("volumeDidChange", this.onVolumeDidChange);
1290
+ }
1291
+ async[STATE_UNSUBSCRIBE_SYMBOL]() {
1292
+ const dataStream = this.#dataStream;
1293
+ if (!dataStream) {
1294
+ return;
1295
+ }
1296
+ dataStream.off("deviceInfo", this.onDeviceInfo);
1297
+ dataStream.off("deviceInfoUpdate", this.onDeviceInfoUpdate);
1298
+ dataStream.off("originClientProperties", this.onOriginClientProperties);
1299
+ dataStream.off("playerClientProperties", this.onPlayerClientProperties);
1300
+ dataStream.off("removeClient", this.onRemoveClient);
1301
+ dataStream.off("sendCommandResult", this.onSendCommandResult);
1302
+ dataStream.off("setArtwork", this.onSetArtwork);
1303
+ dataStream.off("setDefaultSupportedCommands", this.onSetDefaultSupportedCommands);
1304
+ dataStream.off("setNowPlayingClient", this.onSetNowPlayingClient);
1305
+ dataStream.off("setNowPlayingPlayer", this.onSetNowPlayingPlayer);
1306
+ dataStream.off("setState", this.onSetState);
1307
+ dataStream.off("updateClient", this.onUpdateClient);
1308
+ dataStream.off("updateContentItem", this.onUpdateContentItem);
1309
+ dataStream.off("updateContentItemArtwork", this.onUpdateContentItemArtwork);
1310
+ dataStream.off("updatePlayer", this.onUpdatePlayer);
1311
+ dataStream.off("updateOutputDevice", this.onUpdateOutputDevice);
1312
+ dataStream.off("volumeControlAvailability", this.onVolumeControlAvailability);
1313
+ dataStream.off("volumeControlCapabilitiesDidChange", this.onVolumeControlCapabilitiesDidChange);
1314
+ dataStream.off("volumeDidChange", this.onVolumeDidChange);
1315
+ }
1316
+ clear() {
1317
+ this.#clients = {};
1318
+ this.#nowPlayingClientBundleIdentifier = null;
1319
+ this.#outputDeviceUID = null;
1320
+ this.#volume = 0;
1321
+ this.#volumeAvailable = false;
1322
+ this.#volumeCapabilities = Proto3.VolumeCapabilities_Enum.None;
1323
+ }
1324
+ async onDeviceInfo(message) {
1325
+ if (message.clusterID) {
1326
+ this.#outputDeviceUID = message.clusterID;
1327
+ } else if (message.deviceUID) {
1328
+ this.#outputDeviceUID = message.deviceUID;
1329
+ } else if (message.uniqueIdentifier) {
1330
+ this.#outputDeviceUID = message.uniqueIdentifier;
1331
+ }
1332
+ this.emit("deviceInfo", message);
1333
+ }
1334
+ async onDeviceInfoUpdate(message) {
1335
+ if (message.clusterID) {
1336
+ this.#outputDeviceUID = message.clusterID;
1337
+ } else if (message.deviceUID) {
1338
+ this.#outputDeviceUID = message.deviceUID;
1339
+ } else if (message.uniqueIdentifier) {
1340
+ this.#outputDeviceUID = message.uniqueIdentifier;
1341
+ }
1342
+ this.emit("deviceInfoUpdate", message);
1343
+ }
1344
+ async onOriginClientProperties(message) {
1345
+ this.emit("originClientProperties", message);
1346
+ }
1347
+ async onPlayerClientProperties(message) {
1348
+ this.emit("playerClientProperties", message);
1349
+ }
1350
+ async onRemoveClient(message) {
1351
+ if (!(message.client.bundleIdentifier in this.#clients)) {
1352
+ return;
1353
+ }
1354
+ delete this.#clients[message.client.bundleIdentifier];
1355
+ this.emit("clients", this.#clients);
1356
+ }
1357
+ async onSendCommandResult(message) {
1358
+ this.emit("sendCommandResult", message);
1359
+ }
1360
+ async onSetArtwork(message) {
1361
+ this.emit("setArtwork", message);
1362
+ }
1363
+ async onSetDefaultSupportedCommands(message) {
1364
+ this.emit("setDefaultSupportedCommands", message);
1365
+ }
1366
+ async onSetNowPlayingClient(message) {
1367
+ this.#nowPlayingClientBundleIdentifier = message.client?.bundleIdentifier ?? null;
1368
+ this.emit("setNowPlayingClient", message);
1369
+ }
1370
+ async onSetNowPlayingPlayer(message) {
1371
+ this.emit("setNowPlayingPlayer", message);
1372
+ }
1373
+ async onSetState(message) {
1374
+ const client = this.#client(message.playerPath.client.bundleIdentifier, message.displayName);
1375
+ if (message.playbackState) {
1376
+ client.setPlaybackState(message.playbackState, message.playbackStateTimestamp);
1377
+ }
1378
+ if (message.supportedCommands) {
1379
+ client.setSupportedCommands(message.supportedCommands.supportedCommands);
1380
+ }
1381
+ if (message.playbackQueue) {
1382
+ client.setPlaybackQueue(message.playbackQueue);
1383
+ }
1384
+ this.emit("setState", message);
1385
+ }
1386
+ async onUpdateContentItem(message) {
1387
+ const client = this.#client(message.playerPath.client.bundleIdentifier, message.playerPath.client.displayName);
1388
+ if (!client) {
1389
+ return;
1390
+ }
1391
+ for (const item of message.contentItems) {
1392
+ client.updateContentItem(item);
1393
+ }
1394
+ this.emit("updateContentItem", message);
1395
+ }
1396
+ async onUpdateContentItemArtwork(message) {
1397
+ this.emit("updateContentItemArtwork", message);
1398
+ }
1399
+ async onUpdatePlayer(message) {
1400
+ this.emit("updatePlayer", message);
1401
+ }
1402
+ async onUpdateClient(message) {
1403
+ this.#client(message.client.bundleIdentifier, message.client.displayName);
1404
+ this.emit("clients", this.#clients);
1405
+ }
1406
+ async onUpdateOutputDevice(message) {
1407
+ this.emit("updateOutputDevice", message);
1408
+ }
1409
+ async onVolumeControlAvailability(message) {
1410
+ this.#volumeAvailable = message.volumeControlAvailable;
1411
+ this.#volumeCapabilities = message.volumeCapabilities;
1412
+ this.emit("volumeControlAvailability", message.volumeControlAvailable, message.volumeCapabilities);
1413
+ }
1414
+ async onVolumeControlCapabilitiesDidChange(message) {
1415
+ this.#volumeAvailable = message.capabilities.volumeControlAvailable;
1416
+ this.#volumeCapabilities = message.capabilities.volumeCapabilities;
1417
+ this.emit("volumeControlCapabilitiesDidChange", message.capabilities.volumeControlAvailable, message.capabilities.volumeCapabilities);
1418
+ }
1419
+ async onVolumeDidChange(message) {
1420
+ this.#volume = message.volume;
1421
+ this.emit("volumeDidChange", message.volume);
1422
+ }
1423
+ #client(bundleIdentifier, displayName) {
1424
+ if (bundleIdentifier in this.#clients) {
1425
+ return this.#clients[bundleIdentifier];
1426
+ } else {
1427
+ const client = new Client(bundleIdentifier, displayName);
1428
+ this.#clients[bundleIdentifier] = client;
1429
+ this.emit("clients", this.#clients);
1430
+ return client;
1431
+ }
1432
+ }
1433
+ }
1434
+
1435
+ // src/airplay/volume.ts
1436
+ import { DataStreamMessage as DataStreamMessage2, Proto as Proto4 } from "@basmilius/apple-airplay";
1437
+ import { reporter } from "@basmilius/apple-common";
1438
+ var VOLUME_STEP = 0.05;
1439
+
1440
+ class volume_default {
1441
+ get #airplay() {
1442
+ return this.#device[PROTOCOL];
1443
+ }
1444
+ get #state() {
1445
+ return this.#device.state;
1446
+ }
1447
+ #device;
1448
+ constructor(device) {
1449
+ this.#device = device;
1450
+ }
1451
+ async down() {
1452
+ switch (this.#state.volumeCapabilities) {
1453
+ case Proto4.VolumeCapabilities_Enum.Absolute:
1454
+ case Proto4.VolumeCapabilities_Enum.Both:
1455
+ const newVolume = Math.max(0, this.#state.volume - VOLUME_STEP);
1456
+ await this.set(newVolume);
1457
+ break;
1458
+ case Proto4.VolumeCapabilities_Enum.Relative:
1459
+ await this.#device.remote.volumeDown();
1460
+ break;
1461
+ default:
1462
+ throw new Error("Volume control is not available.");
1463
+ }
1464
+ }
1465
+ async up() {
1466
+ switch (this.#state.volumeCapabilities) {
1467
+ case Proto4.VolumeCapabilities_Enum.Absolute:
1468
+ case Proto4.VolumeCapabilities_Enum.Both:
1469
+ const newVolume = Math.max(0, this.#state.volume + VOLUME_STEP);
1470
+ await this.set(newVolume);
1471
+ break;
1472
+ case Proto4.VolumeCapabilities_Enum.Relative:
1473
+ await this.#device.remote.volumeUp();
1474
+ break;
1475
+ default:
1476
+ throw new Error("Volume control is not available.");
1477
+ }
1478
+ }
1479
+ async get() {
1480
+ if (!this.#state.outputDeviceUID) {
1481
+ throw new Error("No output device active.");
1482
+ }
1483
+ const response = await this.#airplay.dataStream.exchange(DataStreamMessage2.getVolume(this.#state.outputDeviceUID));
1484
+ if (response.type === Proto4.ProtocolMessage_Type.GET_VOLUME_RESULT_MESSAGE) {
1485
+ const message = DataStreamMessage2.getExtension(response, Proto4.getVolumeResultMessage);
1486
+ return message.volume;
1487
+ }
1488
+ throw new Error("Failed to get volume.");
1489
+ }
1490
+ async set(volume) {
1491
+ if (!this.#state.outputDeviceUID) {
1492
+ throw new Error("No output device active.");
1493
+ }
1494
+ if (![Proto4.VolumeCapabilities_Enum.Absolute, Proto4.VolumeCapabilities_Enum.Both].includes(this.#state.volumeCapabilities)) {
1495
+ throw new Error("Absolute volume control is not available.");
1496
+ }
1497
+ volume = Math.min(1, Math.max(0, volume));
1498
+ reporter.info(`Setting volume to ${volume} for device ${this.#state.outputDeviceUID}`);
1499
+ await this.#airplay.dataStream.exchange(DataStreamMessage2.setVolume(this.#state.outputDeviceUID, volume));
1500
+ }
1501
+ }
1502
+
1503
+ // src/airplay/device.ts
1504
+ class device_default extends EventEmitter2 {
1505
+ get [PROTOCOL]() {
1506
+ return this.#protocol;
1507
+ }
1508
+ get isConnected() {
1509
+ return this.#protocol?.rtsp?.isConnected ?? false;
1510
+ }
1511
+ get remote() {
1512
+ return this.#remote;
1513
+ }
1514
+ get state() {
1515
+ return this.#state;
1516
+ }
1517
+ get volume() {
1518
+ return this.#volume;
1519
+ }
1520
+ get timingServer() {
1521
+ return this.#timingServer;
1522
+ }
1523
+ set timingServer(timingServer) {
1524
+ this.#timingServer = timingServer;
1525
+ }
1526
+ #discoveryResult;
1527
+ #remote;
1528
+ #state;
1529
+ #volume;
1530
+ #credentials;
1531
+ #disconnect = false;
1532
+ #feedbackInterval;
1533
+ #keys;
1534
+ #protocol;
1535
+ #timingServer;
1536
+ constructor(discoveryResult) {
1537
+ super();
1538
+ this.#discoveryResult = discoveryResult;
1539
+ this.#remote = new remote_default(this);
1540
+ this.#state = new state_default(this);
1541
+ this.#volume = new volume_default(this);
1542
+ }
1543
+ async connect() {
1544
+ this.#disconnect = false;
1545
+ this.#state.clear();
1546
+ this.#protocol = new AirPlay2(this.#discoveryResult);
1547
+ this.#protocol.rtsp.on("close", async () => this.#onClose());
1548
+ this.#protocol.rtsp.on("error", async (err) => this.#onError(err));
1549
+ this.#protocol.rtsp.on("timeout", async () => this.#onTimeout());
1550
+ await this.#protocol.connect();
1551
+ if (this.#credentials) {
1552
+ this.#keys = await this.#protocol.verify.start(this.#credentials);
1553
+ } else {
1554
+ await this.#protocol.pairing.start();
1555
+ this.#keys = await this.#protocol.pairing.transient();
1556
+ }
1557
+ await this.#setup();
1558
+ this.emit("connected");
1559
+ }
1560
+ async disconnect() {
1561
+ this.#disconnect = true;
1562
+ clearInterval(this.#feedbackInterval);
1563
+ await this.#unsubscribe();
1564
+ await this.#protocol.disconnect();
1565
+ this.emit("disconnected", false);
1566
+ }
1567
+ async disconnectSafely() {
1568
+ try {
1569
+ await this.disconnect();
1570
+ } catch (_) {}
1571
+ }
1572
+ async requestPlaybackQueue(length) {
1573
+ await this.#protocol.dataStream.exchange(DataStreamMessage3.playbackQueueRequest(0, length));
1574
+ }
1575
+ async sendCommand(command, options) {
1576
+ await this.#protocol.dataStream.exchange(DataStreamMessage3.sendCommand(command, options));
1577
+ }
1578
+ async setCredentials(credentials) {
1579
+ this.#credentials = credentials;
1580
+ }
1581
+ async#feedback() {
1582
+ try {
1583
+ await this.#protocol.feedback();
1584
+ } catch (err) {
1585
+ reporter2.error("Feedback error", err);
1586
+ }
1587
+ }
1588
+ async#onClose() {
1589
+ if (this.#disconnect) {
1590
+ return;
1591
+ }
1592
+ clearInterval(this.#feedbackInterval);
1593
+ this.emit("disconnected", true);
1594
+ }
1595
+ async#onError(err) {
1596
+ reporter2.error("AirPlay error", err);
1597
+ await this.disconnectSafely();
1598
+ this.emit("disconnected", true);
1599
+ }
1600
+ async#onTimeout() {
1601
+ reporter2.error("AirPlay timeout");
1602
+ await this.disconnectSafely();
1603
+ this.emit("disconnected", true);
1604
+ }
1605
+ async#setup() {
1606
+ const keys = this.#keys;
1607
+ await this.#protocol.rtsp.enableEncryption(keys.accessoryToControllerKey, keys.controllerToAccessoryKey);
1608
+ await this.#unsubscribe();
1609
+ if (this.#timingServer) {
1610
+ await this.#protocol.setupTimingServer(this.#timingServer);
1611
+ }
1612
+ await this.#protocol.setupEventStream(keys.pairingId, keys.sharedSecret);
1613
+ await this.#protocol.setupDataStream(keys.sharedSecret);
1614
+ await this.#subscribe();
1615
+ this.#protocol.dataStream.on("error", async (err) => this.#onError(err));
1616
+ this.#protocol.dataStream.on("timeout", async () => this.#onTimeout());
1617
+ this.#protocol.eventStream.on("error", async (err) => this.#onError(err));
1618
+ this.#protocol.eventStream.on("timeout", async () => this.#onTimeout());
1619
+ this.#feedbackInterval = setInterval(async () => await this.#feedback(), FEEDBACK_INTERVAL);
1620
+ const gid = this.#discoveryResult.packet.additionals.find((a) => ("rdata" in a) && typeof a["rdata"] === "object" && ("gid" in a["rdata"]))?.["rdata"]["gid"];
1621
+ if (gid) {
1622
+ await this.#protocol.dataStream.exchange(DataStreamMessage3.configureConnection(gid));
1623
+ }
1624
+ await this.#protocol.dataStream.exchange(DataStreamMessage3.deviceInfo(keys.pairingId));
1625
+ const result = await Promise.race([
1626
+ new Promise((resolve) => {
1627
+ this.#protocol.dataStream.on("deviceInfo", async () => {
1628
+ await this.#protocol.dataStream.exchange(DataStreamMessage3.setConnectionState());
1629
+ await this.#protocol.dataStream.exchange(DataStreamMessage3.clientUpdatesConfig());
1630
+ resolve(true);
1631
+ });
1632
+ }),
1633
+ async () => {
1634
+ await waitFor2(3000);
1635
+ return false;
1636
+ }
1637
+ ]);
1638
+ if (!result) {
1639
+ await this.#onError(new Error("Device did not respond in time with its info."));
1640
+ } else {
1641
+ reporter2.info("Device info received successfully, protocol should be ready.");
1642
+ }
1643
+ }
1644
+ async#subscribe() {
1645
+ await this.#state[STATE_SUBSCRIBE_SYMBOL]();
1646
+ }
1647
+ async#unsubscribe() {
1648
+ try {
1649
+ await this.#state[STATE_UNSUBSCRIBE_SYMBOL]();
1650
+ } catch (err) {
1651
+ reporter2.error("State unsubscribe error", err);
1652
+ }
1653
+ }
1654
+ }
1655
+ // src/companion-link/const.ts
1656
+ var PROTOCOL2 = Symbol("com.basmilius.companion-link:protocol");
1657
+ // src/companion-link/device.ts
1658
+ import { EventEmitter as EventEmitter3 } from "node:events";
1659
+ import { reporter as reporter3 } from "@basmilius/apple-common";
1660
+ import { CompanionLink, convertAttentionState } from "@basmilius/apple-companion-link";
1661
+ class device_default2 extends EventEmitter3 {
1662
+ get [PROTOCOL2]() {
1663
+ return this.#protocol;
1664
+ }
1665
+ get isConnected() {
1666
+ return this.#protocol?.socket?.isConnected ?? false;
1667
+ }
1668
+ #credentials;
1669
+ #disconnect = false;
1670
+ #discoveryResult;
1671
+ #heartbeatInterval;
1672
+ #keys;
1673
+ #protocol;
1674
+ constructor(discoveryResult) {
1675
+ super();
1676
+ this.#discoveryResult = discoveryResult;
1677
+ this.onSystemStatus = this.onSystemStatus.bind(this);
1678
+ this.onTVSystemStatus = this.onTVSystemStatus.bind(this);
1679
+ }
1680
+ async connect() {
1681
+ if (!this.#credentials) {
1682
+ throw new Error("Credentials are required to connect to a Companion Link device.");
1683
+ }
1684
+ this.#disconnect = false;
1685
+ this.#protocol = new CompanionLink(this.#discoveryResult);
1686
+ this.#protocol.socket.on("close", async () => this.#onClose());
1687
+ this.#protocol.socket.on("error", async (err) => this.#onError(err));
1688
+ this.#protocol.socket.on("timeout", async () => this.#onTimeout());
1689
+ await this.#protocol.connect();
1690
+ this.#keys = await this.#protocol.verify.start(this.#credentials);
1691
+ await this.#setup();
1692
+ this.emit("connected");
1693
+ }
1694
+ async disconnect() {
1695
+ this.#disconnect = true;
1696
+ clearInterval(this.#heartbeatInterval);
1697
+ await this.#unsubscribe();
1698
+ await this.#protocol.disconnect();
1699
+ this.emit("disconnected", false);
1700
+ }
1701
+ async disconnectSafely() {
1702
+ try {
1703
+ await this.disconnect();
1704
+ } catch (_) {}
1705
+ }
1706
+ async setCredentials(credentials) {
1707
+ this.#credentials = credentials;
1708
+ }
1709
+ async setDiscoveryResult(discoveryResult) {
1710
+ this.#discoveryResult = discoveryResult;
1711
+ }
1712
+ async getAttentionState() {
1713
+ return await this.#protocol.api.getAttentionState();
1714
+ }
1715
+ async getLaunchableApps() {
1716
+ return await this.#protocol.api.getLaunchableApps();
1717
+ }
1718
+ async getUserAccounts() {
1719
+ return await this.#protocol.api.getUserAccounts();
1720
+ }
1721
+ async launchApp(bundleId) {
1722
+ await this.#protocol.api.launchApp(bundleId);
1723
+ }
1724
+ async launchUrl(url) {
1725
+ await this.#protocol.api.launchUrl(url);
1726
+ }
1727
+ async mediaControlCommand(command, content) {
1728
+ await this.#protocol.api.mediaControlCommand(command, content);
1729
+ }
1730
+ async pressButton(command, type, holdDelayMs) {
1731
+ await this.#protocol.api.pressButton(command, type, holdDelayMs);
1732
+ }
1733
+ async switchUserAccount(accountId) {
1734
+ await this.#protocol.api.switchUserAccount(accountId);
1735
+ }
1736
+ async#heartbeat() {
1737
+ try {
1738
+ await this.#protocol.api._systemInfo(this.#credentials.pairingId);
1739
+ } catch (err) {
1740
+ reporter3.error("Heartbeat error", err);
1741
+ }
1742
+ }
1743
+ async#onClose() {
1744
+ if (this.#disconnect) {
1745
+ return;
1746
+ }
1747
+ clearInterval(this.#heartbeatInterval);
1748
+ this.emit("disconnected", true);
1749
+ }
1750
+ async#onError(err) {
1751
+ reporter3.error("Companion Link error", err);
1752
+ try {
1753
+ await this.disconnect();
1754
+ } catch (_) {}
1755
+ this.emit("disconnected", true);
1756
+ }
1757
+ async#onTimeout() {
1758
+ reporter3.error("Companion Link timeout");
1759
+ await this.disconnectSafely();
1760
+ this.emit("disconnected", true);
1761
+ }
1762
+ async#setup() {
1763
+ const keys = this.#keys;
1764
+ await this.#protocol.socket.enableEncryption(keys.accessoryToControllerKey, keys.controllerToAccessoryKey);
1765
+ await this.#protocol.api._systemInfo(this.#credentials.pairingId);
1766
+ await this.#protocol.api._touchStart();
1767
+ await this.#protocol.api._sessionStart();
1768
+ await this.#protocol.api._tvrcSessionStart();
1769
+ await this.#protocol.api._unsubscribe("_iMC");
1770
+ this.#heartbeatInterval = setInterval(async () => await this.#heartbeat(), 15000);
1771
+ await this.#subscribe();
1772
+ }
1773
+ async#subscribe() {
1774
+ await this.#protocol.api._subscribe("SystemStatus", this.onSystemStatus);
1775
+ await this.#protocol.api._subscribe("TVSystemStatus", this.onTVSystemStatus);
1776
+ const state = await this.getAttentionState();
1777
+ this.emit("power", state);
1778
+ }
1779
+ async#unsubscribe() {
1780
+ await this.#protocol.api._unsubscribe("SystemStatus", this.onSystemStatus);
1781
+ await this.#protocol.api._unsubscribe("TVSystemStatus", this.onTVSystemStatus);
1782
+ }
1783
+ async onSystemStatus(data) {
1784
+ reporter3.info("System Status", data);
1785
+ this.emit("power", convertAttentionState(data.state));
1786
+ }
1787
+ async onTVSystemStatus(data) {
1788
+ reporter3.info("TV System Status", data);
1789
+ this.emit("power", convertAttentionState(data.state));
1790
+ }
1791
+ }
1792
+ // src/model/apple-tv.ts
1793
+ import { EventEmitter as EventEmitter4 } from "node:events";
1794
+ import { Proto as Proto6 } from "@basmilius/apple-airplay";
1795
+ class apple_tv_default extends EventEmitter4 {
1796
+ get airplay() {
1797
+ return this.#airplay;
1798
+ }
1799
+ get companionLink() {
1800
+ return this.#companionLink;
1801
+ }
1802
+ get bundleIdentifier() {
1803
+ return this.#airplay.state.nowPlayingClient?.bundleIdentifier ?? null;
1804
+ }
1805
+ get displayName() {
1806
+ return this.#airplay.state.nowPlayingClient?.displayName ?? null;
1807
+ }
1808
+ get isConnected() {
1809
+ return this.#airplay.isConnected && this.#companionLink.isConnected;
1810
+ }
1811
+ get isPlaying() {
1812
+ return this.playbackState === Proto6.PlaybackState_Enum.Playing;
1813
+ }
1814
+ get playbackQueue() {
1815
+ return this.#airplay.state.nowPlayingClient?.playbackQueue ?? null;
1816
+ }
1817
+ get playbackState() {
1818
+ return this.#airplay.state.nowPlayingClient?.playbackState ?? Proto6.PlaybackState_Enum.Unknown;
1819
+ }
1820
+ get playbackStateTimestamp() {
1821
+ return this.#airplay.state.nowPlayingClient?.playbackStateTimestamp ?? -1;
1822
+ }
1823
+ #airplay;
1824
+ #companionLink;
1825
+ #disconnect = false;
1826
+ constructor(airplayDiscoveryResult, companionLinkDiscoveryResult) {
1827
+ super();
1828
+ this.#airplay = new device_default(airplayDiscoveryResult);
1829
+ this.#companionLink = new device_default2(companionLinkDiscoveryResult);
1830
+ this.#airplay.on("connected", () => this.#onConnected());
1831
+ this.#airplay.on("disconnected", (unexpected) => this.#onDisconnected(unexpected));
1832
+ this.#companionLink.on("connected", () => this.#onConnected());
1833
+ this.#companionLink.on("disconnected", (unexpected) => this.#onDisconnected(unexpected));
1834
+ }
1835
+ async connect(credentials) {
1836
+ await this.#airplay.setCredentials(credentials);
1837
+ await this.#companionLink.setCredentials(credentials);
1838
+ await this.#airplay.connect();
1839
+ await this.#companionLink.connect();
1840
+ this.#disconnect = false;
1841
+ }
1842
+ async disconnect() {
1843
+ await this.#airplay.disconnect();
1844
+ await this.#companionLink.disconnect();
1845
+ }
1846
+ async turnOff() {
1847
+ await this.#airplay.remote.suspend();
1848
+ }
1849
+ async turnOn() {
1850
+ await this.#airplay.remote.wake();
1851
+ }
1852
+ async pause() {
1853
+ await this.#airplay.sendCommand(Proto6.Command.Pause);
1854
+ }
1855
+ async playPause() {
1856
+ await this.#airplay.sendCommand(Proto6.Command.TogglePlayPause);
1857
+ }
1858
+ async play() {
1859
+ await this.#airplay.sendCommand(Proto6.Command.Play);
1860
+ }
1861
+ async stop() {
1862
+ await this.#airplay.sendCommand(Proto6.Command.Stop);
1863
+ }
1864
+ async next() {
1865
+ await this.#airplay.sendCommand(Proto6.Command.NextInContext);
1866
+ }
1867
+ async previous() {
1868
+ await this.#airplay.sendCommand(Proto6.Command.PreviousInContext);
1869
+ }
1870
+ async volumeDown() {
1871
+ await this.#airplay.remote.volumeDown();
1872
+ }
1873
+ async volumeMute() {
1874
+ await this.#airplay.remote.mute();
1875
+ }
1876
+ async volumeUp() {
1877
+ await this.#airplay.remote.volumeUp();
1878
+ }
1879
+ async getCommandInfo(command) {
1880
+ const client = this.#airplay.state.nowPlayingClient;
1881
+ if (!client) {
1882
+ return null;
1883
+ }
1884
+ return client.supportedCommands.find((c) => c.command === command) ?? null;
1885
+ }
1886
+ async isCommandSupported(command) {
1887
+ const client = this.#airplay.state.nowPlayingClient;
1888
+ if (!client) {
1889
+ return false;
1890
+ }
1891
+ return client.isCommandSupported(command);
1892
+ }
1893
+ async#onConnected() {
1894
+ if (!this.#airplay.isConnected || !this.#companionLink.isConnected) {
1895
+ return;
1896
+ }
1897
+ this.emit("connected");
1898
+ }
1899
+ async#onDisconnected(unexpected) {
1900
+ if (this.#disconnect) {
1901
+ return;
1902
+ }
1903
+ this.#disconnect = true;
1904
+ await this.disconnect();
1905
+ this.emit("disconnected", unexpected);
1906
+ }
1907
+ }
1908
+ // src/model/homepod-base.ts
1909
+ import { EventEmitter as EventEmitter5 } from "node:events";
1910
+ import { Proto as Proto7 } from "@basmilius/apple-airplay";
1911
+ class homepod_base_default extends EventEmitter5 {
1912
+ get airplay() {
1913
+ return this.#airplay;
1914
+ }
1915
+ get bundleIdentifier() {
1916
+ return this.#airplay.state.nowPlayingClient?.bundleIdentifier ?? null;
1917
+ }
1918
+ get displayName() {
1919
+ return this.#airplay.state.nowPlayingClient?.displayName ?? null;
1920
+ }
1921
+ get isConnected() {
1922
+ return this.#airplay.isConnected;
1923
+ }
1924
+ get isPlaying() {
1925
+ return this.playbackState === Proto7.PlaybackState_Enum.Playing;
1926
+ }
1927
+ get playbackQueue() {
1928
+ return this.#airplay.state.nowPlayingClient?.playbackQueue ?? null;
1929
+ }
1930
+ get playbackState() {
1931
+ return this.#airplay.state.nowPlayingClient?.playbackState ?? Proto7.PlaybackState_Enum.Unknown;
1932
+ }
1933
+ get playbackStateTimestamp() {
1934
+ return this.#airplay.state.nowPlayingClient?.playbackStateTimestamp ?? -1;
1935
+ }
1936
+ get volume() {
1937
+ return this.#airplay.state.volume ?? 0;
1938
+ }
1939
+ #airplay;
1940
+ #disconnect = false;
1941
+ constructor(discoveryResult) {
1942
+ super();
1943
+ this.#airplay = new device_default(discoveryResult);
1944
+ this.#airplay.on("connected", () => this.#onConnected());
1945
+ this.#airplay.on("disconnected", (unexpected) => this.#onDisconnected(unexpected));
1946
+ }
1947
+ async connect() {
1948
+ await this.#airplay.connect();
1949
+ this.#disconnect = false;
1950
+ }
1951
+ async disconnect() {
1952
+ await this.#airplay.disconnect();
1953
+ }
1954
+ async pause() {
1955
+ await this.#airplay.sendCommand(Proto7.Command.Pause);
1956
+ }
1957
+ async playPause() {
1958
+ await this.#airplay.sendCommand(Proto7.Command.TogglePlayPause);
1959
+ }
1960
+ async play() {
1961
+ await this.#airplay.sendCommand(Proto7.Command.Play);
1962
+ }
1963
+ async stop() {
1964
+ await this.#airplay.sendCommand(Proto7.Command.Stop);
1965
+ }
1966
+ async next() {
1967
+ await this.#airplay.sendCommand(Proto7.Command.NextInContext);
1968
+ }
1969
+ async previous() {
1970
+ await this.#airplay.sendCommand(Proto7.Command.PreviousInContext);
1971
+ }
1972
+ async getCommandInfo(command) {
1973
+ const client = this.#airplay.state.nowPlayingClient;
1974
+ if (!client) {
1975
+ return null;
1976
+ }
1977
+ return client.supportedCommands.find((c) => c.command === command) ?? null;
1978
+ }
1979
+ async isCommandSupported(command) {
1980
+ const client = this.#airplay.state.nowPlayingClient;
1981
+ if (!client) {
1982
+ return false;
1983
+ }
1984
+ return client.isCommandSupported(command);
1985
+ }
1986
+ async#onConnected() {
1987
+ this.emit("connected");
1988
+ }
1989
+ async#onDisconnected(unexpected) {
1990
+ if (this.#disconnect) {
1991
+ return;
1992
+ }
1993
+ this.#disconnect = true;
1994
+ await this.disconnect();
1995
+ this.emit("disconnected", unexpected);
1996
+ }
1997
+ }
1998
+
1999
+ // src/model/homepod.ts
2000
+ class homepod_default extends homepod_base_default {
2001
+ }
2002
+ // src/model/homepod-mini.ts
2003
+ class homepod_mini_default extends homepod_base_default {
2004
+ }
2005
+ export {
2006
+ homepod_mini_default as HomePodMini,
2007
+ homepod_default as HomePod,
2008
+ device_default2 as CompanionLinkDevice,
2009
+ PROTOCOL2 as COMPANION_LINK,
2010
+ apple_tv_default as AppleTV,
2011
+ device_default as AirPlayDevice,
2012
+ PROTOCOL as AIRPLAY
2013
+ };