import { CSSResultGroup, html, LitElement, TemplateResult, unsafeCSS } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { createRef, Ref, ref } from 'lit/directives/ref.js';
import { CameraConfig } from '../../../config/schema/cameras';
import { HomeAssistant } from '../../../ha/types';
import '../../../patches/ha-camera-stream';
import '../../../patches/ha-hls-player.js';
import '../../../patches/ha-web-rtc-player.js';
import liveHAStyle from '../../../scss/live-ha.scss';
import {
MediaPlayer,
MediaPlayerController,
MediaPlayerElement,
} from '../../../types.js';
@customElement('advanced-camera-card-live-ha')
export class AdvancedCameraCardLiveHA extends LitElement implements MediaPlayer {
@property({ attribute: false })
public hass?: HomeAssistant;
@property({ attribute: false })
public cameraConfig?: CameraConfig;
@property({ attribute: true, type: Boolean })
public controls = false;
protected _playerRef: Ref = createRef();
public async getMediaPlayerController(): Promise {
await this.updateComplete;
return (await this._playerRef.value?.getMediaPlayerController()) ?? null;
}
protected render(): TemplateResult | void {
if (!this.hass) {
return;
}
return html`
`;
}
static get styles(): CSSResultGroup {
return unsafeCSS(liveHAStyle);
}
}
declare global {
interface HTMLElementTagNameMap {
'advanced-camera-card-live-ha': AdvancedCameraCardLiveHA;
}
}