UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

100 lines (99 loc) 2.94 kB
import { emojiPattern as e } from "regex-combined-emojis"; import t from "emoji-toolkit/emoji_strategy.json"; //#region common/emoji/index.js var n = new RegExp(e, "g"), r = "9.0", i = "https://cdn.jsdelivr.net/joypixels/assets/9.0/png/unicode/32/", a = null, o = i, s = ".png", c = i, l = ".png", u = t, d = /(^| |(?<=:))(:\w+:)/g; function f() { return u; } function p(e, t = ".png") { e.endsWith("/") || (e += "/"), o = e, s = t; } function m(e, t = ".svg") { e.endsWith("/") || (e += "/"), c = e, l = t; } function h(e) { a = e; } function g(e) { _(e); } function _(e) { let t = [ "custom", "date_added", "image" ], n = [ "date_added", "image", "unicode_output", "shortname", "shortname_alternates", "custom", "name" ], r = (e, n, r) => { if (e[n] === void 0) { if (!t.includes(n)) return; e[n] = r; } else Array.isArray(e[n]) ? e[n] = e[n].concat(r) : e[n] = r; }; Object.entries(e).forEach((e) => { let [t, i] = e; if (t in u) { let e = u[t]; for (let t in i) { let n = i[t]; r(e, t, n); } } else n.every((e) => i[e] !== void 0) ? u[t] = i : console.error("The following custom emoji doesn't contain the required properties:", i); }); } function v(e) { function t(r, i) { if (!(!r || typeof r != "object")) { if ("shortname" in r && (r.shortname === e || r.shortname_alternates.includes(e))) return r.key = i, n = r, !0; Object.keys(r).some(function(e) { return t(r[e], e); }); } } let n; return t(f(), null), n; } function y(e) { return e.startsWith(":") ? e : u[b(e)]?.shortname; } function b(e) { let t = ""; for (let n of e) { let e = n.codePointAt(0).toString(16).padStart(4, "0"); ["200d", "fe0f"].includes(e) || (t !== "" && (t += "-"), t += e); } return t; } function x(e) { let t = e.split("-"), n = ""; return t.forEach((e) => { n += String.fromCodePoint(parseInt(e, 16)); }), n; } function S(e) { if (e = e?.trim(), e.startsWith(":") && e.endsWith(":")) return v(e); { let t = b(e), n = u[t]; return n && (n.key = t), n; } } function C(e) { return w((e.match(d) || []).map((e) => e.trim())); } function w(e) { let t = e ? e.filter((e) => v(e)) : []; return new Set(t); } function T(e) { let t = [...e.matchAll(n)], r = t.length ? t.map((e) => e[0]) : []; return new Set(r); } //#endregion export { S as codeToEmojiData, a as customEmojiAssetUrl, i as defaultEmojiAssetUrl, l as emojiFileExtensionLarge, s as emojiFileExtensionSmall, c as emojiImageUrlLarge, o as emojiImageUrlSmall, u as emojiJson, n as emojiRegex, d as emojiShortCodeRegex, r as emojiVersion, w as filterValidShortCodes, T as findEmojis, C as findShortCodes, f as getEmojiData, y as getEmojiShortCode, g as setCustomEmojiJson, h as setCustomEmojiUrl, m as setEmojiAssetUrlLarge, p as setEmojiAssetUrlSmall, v as shortcodeToEmojiData, x as stringToUnicode, b as unicodeToString, _ as validateCustomEmojiJson }; //# sourceMappingURL=index.js.map