import { efContext } from "./efContext.js";
import { currentTimeContext } from "./currentTimeContext.js";
import { durationContext } from "./durationContext.js";
import { __decorate } from "../_virtual/_@oxc-project_runtime@0.95.0/helpers/decorate.js";
import { TargetOrContextMixin } from "./TargetOrContextMixin.js";
import { consume } from "@lit/context";
import { LitElement, css, html } from "lit";
import { customElement, property } from "lit/decorators.js";

//#region src/gui/EFTimeDisplay.ts
let EFTimeDisplay = class EFTimeDisplay$1 extends TargetOrContextMixin(LitElement, efContext) {
	constructor(..._args) {
		super(..._args);
		this.currentTimeMs = NaN;
		this.durationMs = 0;
		this.contextCurrentTimeMs = NaN;
		this.contextDurationMs = 0;
	}
	static {
		this.styles = css`
    :host {
      display: inline-flex;
      align-items: center;
      font-family: var(--ef-font-family, system-ui);
      font-size: var(--ef-font-size-xs, 0.75rem);
      color: var(--ef-text-color, var(--ef-color-text));
      white-space: nowrap;
    }

    ::part(time) {}
  `;
	}
	get effectiveCurrentTimeMs() {
		if (!Number.isNaN(this.currentTimeMs)) return this.currentTimeMs;
		if (!Number.isNaN(this.contextCurrentTimeMs)) return this.contextCurrentTimeMs;
		return 0;
	}
	get effectiveDurationMs() {
		return this.durationMs || this.contextDurationMs || 0;
	}
	formatTime(ms) {
		if (!Number.isFinite(ms) || ms < 0) return "0:00";
		const totalSeconds = Math.floor(ms / 1e3);
		return `${Math.floor(totalSeconds / 60)}:${(totalSeconds % 60).toString().padStart(2, "0")}`;
	}
	render() {
		const currentTime = this.effectiveCurrentTimeMs;
		const totalTime = this.effectiveDurationMs;
		return html`
      <span part="time">
        ${this.formatTime(currentTime)} / ${this.formatTime(totalTime)}
      </span>
    `;
	}
};
__decorate([property({
	type: Number,
	attribute: "current-time-ms"
})], EFTimeDisplay.prototype, "currentTimeMs", void 0);
__decorate([property({
	type: Number,
	attribute: "duration-ms"
})], EFTimeDisplay.prototype, "durationMs", void 0);
__decorate([consume({
	context: currentTimeContext,
	subscribe: true
})], EFTimeDisplay.prototype, "contextCurrentTimeMs", void 0);
__decorate([consume({
	context: durationContext,
	subscribe: true
})], EFTimeDisplay.prototype, "contextDurationMs", void 0);
EFTimeDisplay = __decorate([customElement("ef-time-display")], EFTimeDisplay);

//#endregion
export { EFTimeDisplay };
//# sourceMappingURL=EFTimeDisplay.js.map