UNPKG

@dialpad/dialtone

Version:

Dialpad's Dialtone design system monorepo

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