import { n as e, t } from "../../utils-C_mWfcFX.js";
//#region src/display/typography/index.ts
function n(e) {
	switch (e) {
		case "h1": return "h1";
		case "h2": return "h2";
		case "h3": return "h3";
		case "h4": return "h4";
		case "h5": return "h5";
		case "h6": return "h6";
		case "body1":
		case "body2": return "p";
		case "caption":
		case "overline": return "span";
	}
}
var r = class {
	el;
	typographyId;
	currentVariant;
	currentText;
	weight;
	align;
	muted;
	truncate;
	clamp;
	className;
	containerRef;
	constructor(r) {
		this.typographyId = e("cmm-typography"), this.currentVariant = r.variant ?? "body1", this.currentText = r.text, this.weight = r.weight, this.align = r.align, this.muted = r.muted === !0, this.truncate = r.truncate === !0, this.clamp = r.clamp, this.className = r.className;
		let i = n(this.currentVariant);
		this.el = document.createElement(i), this.el.id = this.typographyId, this.el.className = this.buildClassName(), this.el.textContent = this.currentText, this.clamp !== void 0 && (this.el.style.webkitLineClamp = String(this.clamp)), r.container !== void 0 && (this.containerRef = t(r.container), this.containerRef.appendChild(this.el));
	}
	setText(e) {
		this.currentText = e, this.el.textContent = e;
	}
	setVariant(e) {
		this.currentVariant = e;
		let t = n(e), r = document.createElement(t);
		r.id = this.typographyId, r.className = this.buildClassName(), r.textContent = this.currentText, this.clamp !== void 0 && (r.style.webkitLineClamp = String(this.clamp)), this.el.replaceWith(r), Object.defineProperty(this, "el", { value: r });
	}
	destroy() {
		this.el.remove();
	}
	buildClassName() {
		let e = ["cmm-typography", `cmm-typography--${this.currentVariant}`];
		return this.weight !== void 0 && e.push(`cmm-typography--${this.weight}`), this.align !== void 0 && e.push(`cmm-typography--${this.align}`), this.muted && e.push("cmm-typography--muted"), this.truncate && e.push("cmm-typography--truncate"), this.clamp !== void 0 && e.push("cmm-typography--clamp"), this.className && e.push(this.className), e.join(" ");
	}
};
//#endregion
export { r as Typography };

//# sourceMappingURL=index.js.map