import { findEmojis as e, findShortCodes as t } from "../../common/emoji/index.js";
import { ICON_SIZE_MODIFIERS as n } from "../icon/icon-constants.js";
import r from "../emoji/emoji.js";
import { h as i, resolveDynamicComponent as a } from "vue";
//#region components/emoji_text_wrapper/emoji_text_wrapper.vue
var o = i(a(null)).type, s = {
	compatConfig: { MODE: 3 },
	name: "DtEmojiTextWrapper",
	components: { DtEmoji: r },
	props: {
		elementType: {
			type: String,
			default: "div"
		},
		size: {
			type: String,
			default: "500",
			validator: (e) => Object.keys(n).includes(e)
		}
	},
	data() {
		return { loadingEmojiJson: !0 };
	},
	async created() {
		this.loadingEmojiJson = !1;
	},
	methods: {
		replaceDtEmojis(e, t) {
			if (!e.length) return t;
			let n = e.map((e) => e.replace(/\*/g, "\\*")), a = RegExp(`(${n.join("|")})`, "g");
			return t.split(a).filter((e) => e.trim() !== "").map((t) => e.includes(t) ? i(r, {
				code: t,
				size: this.size
			}) : i("span", { class: "d-emoji-text-wrapper__text" }, t));
		},
		searchVNodes(e) {
			if (!e) return;
			if (typeof e == "string") return this.searchCodes(e);
			if (e.type === o) return e;
			if (typeof e.type == "symbol") return this.searchCodes(e.children);
			if (e.props?.innerHTML) return this.searchVNodes(e.props.innerHTML);
			let t = Array.isArray(e.children) ? e.children : [e.children];
			return i(e.type, e.props, t.map((e) => this.searchVNodes(e)));
		},
		replaceVueComponentVNodeContent() {},
		searchCodes(n) {
			let r = t(n), i = e(n), a = [...r, ...i];
			return a.length === 0 ? n : this.replaceDtEmojis(a, n);
		}
	},
	render() {
		let e = this.$slots.default ? this.$slots.default() : [];
		return i(this.elementType, {
			"data-qa": "emoji-text-wrapper",
			class: "d-emoji-text-wrapper"
		}, this.loadingEmojiJson ? e : e.map((e) => this.searchVNodes(e)));
	}
};
//#endregion
export { s as default };

//# sourceMappingURL=emoji-text-wrapper.js.map