UNPKG

nice-avatar-svg

Version:

Library to generate SVG avatar

337 lines (336 loc) 11.3 kB
import { l as b, g as ne, m as E, u as re, N as oe } from "./NiceAvatar-BaV-2Ux6.js"; var W = /[\s\n\\/='"\0<>]/, q = /^(xlink|xmlns|xml)([A-Z])/, ae = /^accessK|^auto[A-Z]|^ch|^col|cont|cross|dateT|encT|form[A-Z]|frame|hrefL|inputM|maxL|minL|noV|playsI|readO|rowS|spellC|src[A-Z]|tabI|item[A-Z]/, ie = /^ac|^ali|arabic|basel|cap|clipPath$|clipRule$|color|dominant|enable|fill|flood|font|glyph[^R]|horiz|image|letter|lighting|marker[^WUH]|overline|panose|pointe|paint|rendering|shape|stop|strikethrough|stroke|text[^L]|transform|underline|unicode|units|^v[^i]|^w|^xH/, se = /["&<]/; function U(e) { if (e.length === 0 || se.test(e) === !1) return e; for (var n = 0, t = 0, r = "", a = ""; t < e.length; t++) { switch (e.charCodeAt(t)) { case 34: a = "&quot;"; break; case 38: a = "&amp;"; break; case 60: a = "&lt;"; break; default: continue; } t !== n && (r += e.slice(n, t)), r += a, n = t + 1; } return t !== n && (r += e.slice(n, t)), r; } var G = {}, ce = /* @__PURE__ */ new Set(["animation-iteration-count", "border-image-outset", "border-image-slice", "border-image-width", "box-flex", "box-flex-group", "box-ordinal-group", "column-count", "fill-opacity", "flex", "flex-grow", "flex-negative", "flex-order", "flex-positive", "flex-shrink", "flood-opacity", "font-weight", "grid-column", "grid-row", "line-clamp", "line-height", "opacity", "order", "orphans", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-miterlimit", "stroke-opacity", "stroke-width", "tab-size", "widows", "z-index", "zoom"]), le = /[A-Z]/g; function ue(e) { var n = ""; for (var t in e) { var r = e[t]; if (r != null && r !== "") { var a = t[0] == "-" ? t : G[t] || (G[t] = t.replace(le, "-$&").toLowerCase()), o = ";"; typeof r != "number" || a.startsWith("--") || ce.has(a) || (o = "px;"), n = n + a + ":" + r + o; } } return n || void 0; } function m(e, n, t) { if (!e.s) { if (t instanceof I) { if (!t.s) return void (t.o = m.bind(null, e, n)); 1 & n && (n = t.s), t = t.v; } if (t && t.then) return void t.then(m.bind(null, e, n), m.bind(null, e, 2)); e.s = n, e.v = t; const r = e.o; r && r(e); } } var I = /* @__PURE__ */ function() { function e() { } return e.prototype.then = function(n, t) { var r = new e(), a = this.s; if (a) { var o = 1 & a ? n : t; if (o) { try { m(r, 1, o(this.v)); } catch (c) { m(r, 2, c); } return r; } return this; } return this.o = function(c) { try { var l = c.v; 1 & c.s ? m(r, 1, n ? n(l) : l) : t ? m(r, 1, t(l)) : m(r, 2, l); } catch (d) { m(r, 2, d); } }, r; }, e; }(); function N(e) { return e instanceof I && 1 & e.s; } function fe(e, n, t) { for (var r; ; ) { var a = e(); if (N(a) && (a = a.v), !a) return o; if (a.then) { r = 0; break; } var o = t(); if (o && o.then) { if (!N(o)) { r = 1; break; } o = o.s; } var c; } var l = new I(), d = m.bind(null, l, 2); return (r === 0 ? a.then(y) : r === 1 ? o.then(v) : c.then(_)).then(void 0, d), l; function v(w) { o = w; do { if (!(a = e()) || N(a) && !a.v) return void m(l, 1, o); if (a.then) return void a.then(y).then(void 0, d); N(o = t()) && (o = o.v); } while (!o || !o.then); o.then(v).then(void 0, d); } function y(w) { w ? (o = t()) && o.then ? o.then(v).then(void 0, d) : v(o) : m(l, 1, o); } function _() { (a = e()) ? a.then ? a.then(y).then(void 0, d) : y(a) : m(l, 1, o); } } function pe(e, n) { try { var t = e(); } catch (r) { return n(!0, r); } return t && t.then ? t.then(n.bind(null, !1), n.bind(null, !0)) : n(!1, t); } var z, S, P, L, he = function(e, n) { try { var t, r = b.__s; b.__s = !0, z = b.__b, S = b.diffed, P = b.__r, L = b.unmount; var a = ne(E, null); return a.__k = [e], Promise.resolve(pe(function() { var o = k(e, n || Y, !1, void 0, a, !0), c = function() { if (Array.isArray(o)) { var l = function() { var _ = v.join(""); return t = 1, _; }, d = 0, v = o, y = fe(function() { return !!v.some(function(_) { return typeof _.then == "function"; }) && d++ < 25; }, void 0, function() { return Promise.resolve(Promise.all(v)).then(function(_) { v = _.flat(); }); }); return y && y.then ? y.then(l) : l(); } }(); return c && c.then ? c.then(function(l) { return t ? l : o; }) : t ? c : o; }, function(o, c) { if (b.__c && b.__c(e, J), b.__s = r, J.length = 0, o) throw c; return c; })); } catch (o) { return Promise.reject(o); } }, J = [], M = Array.isArray, B = Object.assign; function Q() { this.__d = !0; } var Y = {}; function X(e, n) { var t, r = e.type, a = !0; return e.__c ? (a = !1, (t = e.__c).state = t.__s) : t = new r(e.props, n), e.__c = t, t.__v = e, t.props = e.props, t.context = n, t.__d = !0, t.state == null && (t.state = Y), t.__s == null && (t.__s = t.state), r.getDerivedStateFromProps ? t.state = B({}, t.state, r.getDerivedStateFromProps(t.props, t.state)) : a && t.componentWillMount ? (t.componentWillMount(), t.state = t.__s !== t.state ? t.__s : t.state) : !a && t.componentWillUpdate && t.componentWillUpdate(), P && P(e), t.render(t.props, t.state, n); } function k(e, n, t, r, a, o) { if (e == null || e === !0 || e === !1 || e === "") return ""; if (typeof e != "object") return typeof e == "function" ? "" : U(e + ""); if (M(e)) { var c, l = ""; a.__k = e; for (var d = 0; d < e.length; d++) { var v = e[d]; if (v != null && typeof v != "boolean") { var y, _ = k(v, n, t, r, a, o); typeof _ == "string" ? l += _ : (c = c || [], l && c.push(l), l = "", Array.isArray(_) ? (y = c).push.apply(y, _) : c.push(_)); } } return c ? (l && c.push(l), c) : l; } if (e.constructor !== void 0) return ""; e.__ = a, z && z(e); var w, i, h, u = e.type, p = e.props, T = n; if (typeof u == "function") { if (u === E) { if (p.tpl) { for (var Z = "", j = 0; j < p.tpl.length; j++) if (Z += p.tpl[j], p.exprs && j < p.exprs.length) { var D = p.exprs[j]; if (D == null) continue; typeof D != "object" || D.constructor !== void 0 && !M(D) ? Z += D : Z += k(D, n, t, r, e, o); } return Z; } if (p.UNSTABLE_comment) return "<!--" + U(p.UNSTABLE_comment || "") + "-->"; i = p.children; } else { if ((w = u.contextType) != null) { var R = n[w.__c]; T = R ? R.props.value : w.__; } if (u.prototype && typeof u.prototype.render == "function") i = X(e, T), h = e.__c; else { e.__c = h = { __v: e, props: p, context: T, setState: Q, forceUpdate: Q, __d: !0, __h: [] }; for (var K = 0; h.__d && K++ < 25; ) h.__d = !1, P && P(e), i = u.call(h, p, T); h.__d = !0; } if (h.getChildContext != null && (n = B({}, n, h.getChildContext())), (u.getDerivedStateFromError || h.componentDidCatch) && b.errorBoundaries) { var $ = ""; i = i != null && i.type === E && i.key == null ? i.props.children : i; try { return $ = k(i, n, t, r, e, o); } catch (C) { return u.getDerivedStateFromError && (h.__s = u.getDerivedStateFromError(C)), h.componentDidCatch && h.componentDidCatch(C, {}), h.__d && (i = X(e, n), (h = e.__c).getChildContext != null && (n = B({}, n, h.getChildContext())), $ = k(i = i != null && i.type === E && i.key == null ? i.props.children : i, n, t, r, e, o)), $; } finally { S && S(e), e.__ = null, L && L(e); } } } i = i != null && i.type === E && i.key == null && i.props.tpl == null ? i.props.children : i; try { var V = k(i, n, t, r, e, o); return S && S(e), e.__ = null, L && L(e), V; } catch (C) { if (!C || typeof C.then != "function") throw C; var ee = function te() { try { return k(i, n, t, r, e, o); } catch (F) { if (!F || typeof F.then != "function") throw F; return F.then(function() { return k(i, n, t, r, e, o); }, function() { return te(); }); } }; return C.then(function() { return ee(); }); } } var x, A = "<" + u, g = ""; for (var s in p) { var f = p[s]; switch (s) { case "children": x = f; continue; case "key": case "ref": case "__self": case "__source": continue; case "htmlFor": if ("for" in p) continue; s = "for"; break; case "className": if ("class" in p) continue; s = "class"; break; case "defaultChecked": s = "checked"; break; case "defaultSelected": s = "selected"; break; case "defaultValue": case "value": switch (s = "value", u) { case "textarea": x = f; continue; case "select": r = f; continue; case "option": r != f || "selected" in p || (A += " selected"); } break; case "dangerouslySetInnerHTML": g = f && f.__html; continue; case "style": typeof f == "object" && (f = ue(f)); break; case "acceptCharset": s = "accept-charset"; break; case "httpEquiv": s = "http-equiv"; break; default: if (q.test(s)) s = s.replace(q, "$1:$2").toLowerCase(); else { if (W.test(s)) continue; s[4] !== "-" && s !== "draggable" || f == null ? t ? ie.test(s) && (s = s === "panose1" ? "panose-1" : s.replace(/([A-Z])/g, "-$1").toLowerCase()) : ae.test(s) && (s = s.toLowerCase()) : f += ""; } } f != null && f !== !1 && typeof f != "function" && (A = f === !0 || f === "" ? A + " " + s : A + " " + s + '="' + U(f + "") + '"'); } if (W.test(u)) throw new Error(u + " is not a valid HTML tag name in " + A + ">"); if (g || (typeof x == "string" ? g = U(x) : x != null && x !== !1 && x !== !0 && (g = k(x, n, u === "svg" || u !== "foreignObject" && t, r, e, o))), S && S(e), e.__ = null, L && L(e), !g && de.has(u)) return A + "/>"; var H = "</" + u + ">", O = A + ">"; return Array.isArray(g) ? [O].concat(g, [H]) : typeof g != "string" ? [O, g, H] : O + g + H; } var de = /* @__PURE__ */ new Set(["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]); function ve(e) { return he(re(oe, { ...e })); } ve().then(console.log).catch(console.error); export { ve as default };