import{dh as e,cO as t,x as s,cY as a,ds as i,dt as r,du as o,dr as d,r as h,eE as n,_ as l,t as c,eH as p,eI as u,cK as y,a as m,cL as _,cP as f,n as v}from"./card-e5d55e5b.js";import{c as g,e as $}from"./ha-hls-player-1787796f.js";import{s as b,d as w,h as L,c as R}from"./media-921a03ae.js";import{m as I}from"./audio-cf3a75aa.js";customElements.whenDefined("ha-web-rtc-player").then((()=>{let p=class extends(customElements.get("ha-web-rtc-player")){async play(){return this._video?.play()}async pause(){this._video?.pause()}async mute(){this._video&&(this._video.muted=!0)}async unmute(){this._video&&(this._video.muted=!1)}isMuted(){return this._video?.muted??!0}async seek(e){this._video&&(this._video.currentTime=e)}async setControls(e){this._video&&b(this._video,e??this.controls)}isPaused(){return this._video?.paused??!0}async getScreenshotURL(){return this._video?e(this._video):null}render(){return this._error?(w(this),t({type:"error",message:this._error,context:{entity_id:this.entityid}})):s` `}_loadedDataHandler(e){super._loadedData(),d(this,e,{player:this,capabilities:{supportsPause:!0,hasAudio:I(this._video)},technology:["webrtc"]})}static get styles(){return[super.styles,h(g),n` :host { width: 100%; height: 100%; } video { width: 100%; height: 100%; } `]}};l([$("#remote-stream")],p.prototype,"_video",void 0),p=l([c("frigate-card-ha-web-rtc-player")],p)})),customElements.whenDefined("ha-camera-stream").then((()=>{const e="web_rtc",t="mjpeg";let a=class extends(customElements.get("ha-camera-stream")){constructor(){super(...arguments),this._mediaLoadedInfoPerStream={},this._mediaLoadedInfoDispatched=null}async play(){return this._player?.play()}async pause(){this._player?.pause()}async mute(){this._player?.mute()}async unmute(){this._player?.unmute()}isMuted(){return this._player?.isMuted()??!0}async seek(e){this._player?.seek(e)}async setControls(e){this._player&&this._player.setControls(e??this.controls)}isPaused(){return this._player?.isPaused()??!0}async getScreenshotURL(){return this._player?await this._player.getScreenshotURL():null}_storeMediaLoadedInfoHandler(e,t){this._storeMediaLoadedInfo(e,t.detail),t.stopPropagation()}_storeMediaLoadedInfo(e,t){this._mediaLoadedInfoPerStream[e]=t,this.requestUpdate()}_renderStream(a){return this.stateObj?a.type===t?s` this._storeMediaLoadedInfo(t,u(e,{player:this,technology:["mjpeg"]}))} .src=${void 0===this._connected||this._connected?(i=this.stateObj,`/api/camera_proxy_stream/${i.entity_id}?token=${i.attributes.access_token}`):this._posterUrl||""} /> `:"hls"===a.type?s` this._storeMediaLoadedInfoHandler("hls",e)} @streams=${this._handleHlsStreams} class="player ${a.visible?"":"hidden"}" >`:a.type===e?s`this._storeMediaLoadedInfoHandler(e,t)} @streams=${this._handleWebRtcStreams} class="player ${a.visible?"":"hidden"}" >`:p:p;var i}updated(e){super.updated(e);const t=this._streams(this._capabilities?.frontend_stream_types,this._hlsStreams,this._webRtcStreams).find((e=>e.visible))??null;if(t){const e=this._mediaLoadedInfoPerStream[t.type];e&&e!==this._mediaLoadedInfoDispatched&&(this._mediaLoadedInfoDispatched=e,y(this,e))}}static get styles(){return[super.styles,h(g),n` :host { width: 100%; height: 100%; } img { width: 100%; height: 100%; } `]}};l([$(".player:not(.hidden)")],a.prototype,"_player",void 0),a=l([c("frigate-card-ha-camera-stream")],a)}));let P=class extends m{constructor(){super(...arguments),this.controls=!1,this._playerRef=_()}async play(){return this._playerRef.value?.play()}async pause(){this._playerRef.value?.pause()}async mute(){this._playerRef.value?.mute()}async unmute(){this._playerRef.value?.unmute()}isMuted(){return this._playerRef.value?.isMuted()??!0}async seek(e){this._playerRef.value?.seek(e)}async setControls(e){this._playerRef.value?.setControls(e??this.controls)}isPaused(){return this._playerRef.value?.isPaused()??!0}async getScreenshotURL(){return await(this._playerRef.value?.getScreenshotURL())??null}render(){if(this.hass)return s` `}static get styles(){return h(":host {\n width: 100%;\n height: 100%;\n display: block;\n}")}};l([v({attribute:!1})],P.prototype,"hass",void 0),l([v({attribute:!1})],P.prototype,"cameraConfig",void 0),l([v({attribute:!0,type:Boolean})],P.prototype,"controls",void 0),P=l([c("frigate-card-live-ha")],P);export{P as FrigateCardLiveHA};