@lobehub/ui 6.17.1 → 6.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/es/AgentAvatar/AgentAvatar.mjs +89 -139
  2. package/es/AgentAvatar/AgentAvatar.mjs.map +1 -1
  3. package/es/AgentAvatar/AgentAvatarPicker.d.mts +3 -0
  4. package/es/AgentAvatar/AgentAvatarPicker.mjs +109 -0
  5. package/es/AgentAvatar/AgentAvatarPicker.mjs.map +1 -0
  6. package/es/AgentAvatar/createAgentAvatarTab.d.mts +4 -0
  7. package/es/AgentAvatar/createAgentAvatarTab.mjs +46 -0
  8. package/es/AgentAvatar/createAgentAvatarTab.mjs.map +1 -0
  9. package/es/AgentAvatar/eyes.mjs +83 -0
  10. package/es/AgentAvatar/eyes.mjs.map +1 -0
  11. package/es/AgentAvatar/index.d.mts +5 -2
  12. package/es/AgentAvatar/index.mjs +4 -1
  13. package/es/AgentAvatar/liveLoop.mjs +97 -0
  14. package/es/AgentAvatar/liveLoop.mjs.map +1 -0
  15. package/es/AgentAvatar/look.mjs +193 -0
  16. package/es/AgentAvatar/look.mjs.map +1 -0
  17. package/es/AgentAvatar/painter.mjs +114 -0
  18. package/es/AgentAvatar/painter.mjs.map +1 -0
  19. package/es/AgentAvatar/pickerStyle.mjs +68 -0
  20. package/es/AgentAvatar/pickerStyle.mjs.map +1 -0
  21. package/es/AgentAvatar/scene.mjs +91 -0
  22. package/es/AgentAvatar/scene.mjs.map +1 -0
  23. package/es/AgentAvatar/shapes.mjs +215 -180
  24. package/es/AgentAvatar/shapes.mjs.map +1 -1
  25. package/es/AgentAvatar/stable.mjs +11 -1
  26. package/es/AgentAvatar/stable.mjs.map +1 -1
  27. package/es/AgentAvatar/still.mjs +39 -0
  28. package/es/AgentAvatar/still.mjs.map +1 -0
  29. package/es/AgentAvatar/stills.generated.mjs +126 -0
  30. package/es/AgentAvatar/stills.generated.mjs.map +1 -0
  31. package/es/AgentAvatar/style.mjs +13 -146
  32. package/es/AgentAvatar/style.mjs.map +1 -1
  33. package/es/AgentAvatar/type.d.mts +64 -14
  34. package/es/AgentAvatar/useLiveAvatar.mjs +91 -0
  35. package/es/AgentAvatar/useLiveAvatar.mjs.map +1 -0
  36. package/es/AgentAvatar/utils.d.mts +2 -2
  37. package/es/AgentAvatar/utils.mjs +49 -45
  38. package/es/AgentAvatar/utils.mjs.map +1 -1
  39. package/es/AgentAvatar/value.d.mts +5 -0
  40. package/es/AgentAvatar/value.mjs +18 -0
  41. package/es/AgentAvatar/value.mjs.map +1 -0
  42. package/es/AutoComplete/style.d.mts +1 -1
  43. package/es/EditorSlashMenu/atoms.mjs +1 -2
  44. package/es/EditorSlashMenu/atoms.mjs.map +1 -1
  45. package/es/EmojiPicker/EmojiPicker.mjs +27 -19
  46. package/es/EmojiPicker/EmojiPicker.mjs.map +1 -1
  47. package/es/EmojiPicker/index.d.mts +2 -2
  48. package/es/EmojiPicker/type.d.mts +24 -1
  49. package/es/brand/Lobot/Lobot.d.mts +3 -0
  50. package/es/brand/Lobot/Lobot.mjs +74 -0
  51. package/es/brand/Lobot/Lobot.mjs.map +1 -0
  52. package/es/brand/Lobot/index.d.mts +3 -0
  53. package/es/brand/Lobot/stable.mjs +15 -0
  54. package/es/brand/Lobot/stable.mjs.map +1 -0
  55. package/es/brand/Lobot/type.d.mts +18 -0
  56. package/es/brand/LobotBrandLoading/LobotBrandLoading.d.mts +11 -0
  57. package/es/brand/LobotBrandLoading/LobotBrandLoading.mjs +130 -0
  58. package/es/brand/LobotBrandLoading/LobotBrandLoading.mjs.map +1 -0
  59. package/es/brand/LobotBrandLoading/index.d.mts +3 -0
  60. package/es/brand/LobotBrandLoading/stable.mjs +13 -0
  61. package/es/brand/LobotBrandLoading/stable.mjs.map +1 -0
  62. package/es/brand/LobotBrandLoading/style.mjs +111 -0
  63. package/es/brand/LobotBrandLoading/style.mjs.map +1 -0
  64. package/es/brand/LobotBrandLoading/type.d.mts +9 -0
  65. package/es/brand/LobotBrandLoading3d/LobotBrandLoading3d.d.mts +9 -0
  66. package/es/brand/LobotBrandLoading3d/LobotBrandLoading3d.mjs +87 -0
  67. package/es/brand/LobotBrandLoading3d/LobotBrandLoading3d.mjs.map +1 -0
  68. package/es/brand/LobotBrandLoading3d/choreography.mjs +120 -0
  69. package/es/brand/LobotBrandLoading3d/choreography.mjs.map +1 -0
  70. package/es/brand/LobotBrandLoading3d/index.d.mts +3 -0
  71. package/es/brand/LobotBrandLoading3d/live.mjs +72 -0
  72. package/es/brand/LobotBrandLoading3d/live.mjs.map +1 -0
  73. package/es/brand/LobotBrandLoading3d/stable.mjs +14 -0
  74. package/es/brand/LobotBrandLoading3d/stable.mjs.map +1 -0
  75. package/es/brand/LobotBrandLoading3d/style.mjs +38 -0
  76. package/es/brand/LobotBrandLoading3d/style.mjs.map +1 -0
  77. package/es/brand/LobotBrandLoading3d/type.d.mts +9 -0
  78. package/es/brand/LobotBrandLoading3d/useLiveLoading.mjs +58 -0
  79. package/es/brand/LobotBrandLoading3d/useLiveLoading.mjs.map +1 -0
  80. package/es/brand/LobotMono/LobotMono.d.mts +8 -0
  81. package/es/brand/LobotMono/LobotMono.mjs +46 -0
  82. package/es/brand/LobotMono/LobotMono.mjs.map +1 -0
  83. package/es/brand/LobotMono/index.d.mts +3 -0
  84. package/es/brand/LobotMono/stable.mjs +9 -0
  85. package/es/brand/LobotMono/stable.mjs.map +1 -0
  86. package/es/brand/LobotMono/type.d.mts +8 -0
  87. package/es/brand/LobotText/LobotText.d.mts +4 -0
  88. package/es/brand/LobotText/LobotText.mjs +20 -0
  89. package/es/brand/LobotText/LobotText.mjs.map +1 -0
  90. package/es/brand/LobotText/index.d.mts +3 -0
  91. package/es/brand/LobotText/stable.mjs +9 -0
  92. package/es/brand/LobotText/stable.mjs.map +1 -0
  93. package/es/brand/LobotText/type.d.mts +8 -0
  94. package/es/brand/index.d.mts +16 -1
  95. package/es/brand/index.mjs +6 -1
  96. package/es/chat/ChatItem/type.d.mts +2 -2
  97. package/es/css/AgentAvatar.css +686 -199
  98. package/es/css/brand/Lobot.css +27 -0
  99. package/es/css/brand/LobotBrandLoading.css +219 -0
  100. package/es/css/brand/LobotBrandLoading3d.css +61 -0
  101. package/es/css/brand/LobotMono.css +15 -0
  102. package/es/css/brand/LobotText.css +15 -0
  103. package/es/i18n/resources/en/agentAvatar.d.mts +39 -0
  104. package/es/i18n/resources/en/agentAvatar.mjs +42 -0
  105. package/es/i18n/resources/en/agentAvatar.mjs.map +1 -0
  106. package/es/i18n/resources/en/index.d.mts +19 -18
  107. package/es/i18n/resources/en/index.mjs +3 -1
  108. package/es/i18n/resources/en/index.mjs.map +1 -1
  109. package/es/i18n/resources/zhCn/agentAvatar.d.mts +39 -0
  110. package/es/i18n/resources/zhCn/agentAvatar.mjs +42 -0
  111. package/es/i18n/resources/zhCn/agentAvatar.mjs.map +1 -0
  112. package/es/i18n/resources/zhCn/index.d.mts +19 -18
  113. package/es/i18n/resources/zhCn/index.mjs +3 -1
  114. package/es/i18n/resources/zhCn/index.mjs.map +1 -1
  115. package/es/i18n/types.d.mts +18 -17
  116. package/es/index.d.mts +48 -45
  117. package/es/index.mjs +6 -3
  118. package/es/style.css +201 -242
  119. package/package.json +3 -1
@@ -1,56 +1,39 @@
1
1
  "use client";
2
2
  import clsx$1 from "clsx";
3
- import { memo, useId } from "react";
3
+ import { memo, useId, useMemo } from "react";
4
4
  import { styleProps } from "../styles/stylex/props.mjs";
5
5
  import { useThemeMode } from "../styles/theme/scope.mjs";
6
6
  import { toDataAttributes } from "../utils/bem.mjs";
7
- import { SHAPE_GEOMETRY, happyEyePath, scleraPath } from "./shapes.mjs";
8
7
  import { agentAvatarClasses } from "./stable.mjs";
8
+ import { buildStillScene } from "./still.mjs";
9
9
  import { styles } from "./style.mjs";
10
+ import { useLiveAvatar } from "./useLiveAvatar.mjs";
10
11
  import { useReducedMotion } from "./useReducedMotion.mjs";
11
- import { AGENT_AVATAR_COLOR_TOKENS, BLOCKED_PUPIL_RATIO, BLOCKED_SCLERA_SCALE, GAZE_UNIT_RADIUS, PUPIL_COLOR, PUPIL_RATIO, PUPIL_RATIO_SMALL, SCLERA_COLOR, STILL_GAZE, getAgentAvatarTraits, isAgentAvatarColor } from "./utils.mjs";
12
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
12
+ import { AGENT_AVATAR_COLOR_TOKENS, PUPIL_COLOR, SCLERA_COLOR, getAgentAvatarTraits, isAgentAvatarColor } from "./utils.mjs";
13
+ import { jsx, jsxs } from "react/jsx-runtime";
13
14
  // src/AgentAvatar/AgentAvatar.tsx
14
- const round = (value) => Math.round(value * 100) / 100;
15
- const BODY_MOTION = {
16
- blocked: styles.bodyBlocked,
17
- done: styles.bodyDone,
18
- idle: styles.bodyIdle,
19
- thinking: styles.bodyThinking,
20
- waiting: styles.bodyWaiting,
21
- working: styles.bodyWorking
22
- };
23
- const BLINK_MOTION = {
24
- idle: styles.blinkIdle,
25
- thinking: styles.blinkThinking,
26
- waiting: styles.blinkWaiting,
27
- working: styles.blinkWorking
28
- };
29
- const GAZE_MOTION = {
30
- idle: styles.gazeIdle,
31
- thinking: styles.gazeThinking,
32
- working: styles.gazeWorking
33
- };
34
- /** Thought bubbles: offset from the anchor and radius, smallest last. */
15
+ /** Center of the `blocked` badge: the bottom-right corner, clear of ears and antennas. */
16
+ const BADGE = [86, 86];
17
+ /** Thought bubbles in the top-right corner of the box: center and radius, largest first. */
35
18
  const THOUGHT_DOTS = [
36
19
  [
37
- 0,
38
- 8,
39
- 8.5
20
+ 73,
21
+ 17,
22
+ 6
40
23
  ],
41
24
  [
42
- 12,
43
- 2,
44
- 6.5
25
+ 84,
26
+ 10,
27
+ 4.4
45
28
  ],
46
29
  [
47
- 20,
48
- -5,
49
- 4.5
30
+ 92.5,
31
+ 5.5,
32
+ 3
50
33
  ]
51
34
  ];
52
- const AgentAvatar = memo(({ "animated": animatedProp = false, "aria-label": ariaLabel, className, classNames, "color": colorProp, name, ref, seed, "shape": shapeProp, size, state = "idle", style, "styles": customStyles, tilt = true, ...rest }) => {
53
- const id = useId().replaceAll(/[^\w-]/g, "");
35
+ const AgentAvatar = memo(({ "animated": animatedProp = false, "aria-label": ariaLabel, className, classNames, "color": colorProp, followPointer = false, name, ref, seed, "shape": shapeProp, size, state = "idle", style, "styles": customStyles, tilt = true, ...rest }) => {
36
+ const idPrefix = `${useId().replaceAll(/[^\w-]/g, "")}-`;
54
37
  const { isDarkMode } = useThemeMode();
55
38
  const reducedMotion = useReducedMotion();
56
39
  const animated = animatedProp && !reducedMotion;
@@ -59,77 +42,22 @@ const AgentAvatar = memo(({ "animated": animatedProp = false, "aria-label": aria
59
42
  const colorKey = colorProp ?? traits.color;
60
43
  const isPreset = isAgentAvatarColor(colorKey);
61
44
  const color = isPreset ? AGENT_AVATAR_COLOR_TOKENS[colorKey][isDarkMode ? "dark" : "light"] : colorKey;
62
- const geometry = SHAPE_GEOMETRY[shape];
63
- const { gap, r: baseRadius, y: eyeY } = geometry.eyes;
64
- const eyeXs = [50 - gap / 2, 50 + gap / 2];
65
- const gazeScale = baseRadius / GAZE_UNIT_RADIUS;
66
- const blocked = state === "blocked";
67
- const radius = blocked ? baseRadius * BLOCKED_SCLERA_SCALE : baseRadius;
68
- const small = size !== void 0 && size <= 24;
69
- const pupilRadius = baseRadius * (blocked ? BLOCKED_PUPIL_RATIO : small ? PUPIL_RATIO_SMALL : PUPIL_RATIO);
70
- const [gazeX, gazeY] = STILL_GAZE[state];
71
- const label = ariaLabel ?? name;
72
- const motion = (value) => animated ? value : void 0;
73
- const eyes = /* @__PURE__ */ jsxs(Fragment$1, { children: [
74
- /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("clipPath", {
75
- id: `${id}-eyes`,
76
- children: eyeXs.map((x) => /* @__PURE__ */ jsx("path", { d: scleraPath(x, eyeY, radius) }, x))
77
- }) }),
78
- eyeXs.map((x) => /* @__PURE__ */ jsx("path", {
79
- d: scleraPath(x, eyeY, radius),
80
- fill: SCLERA_COLOR
81
- }, x)),
82
- /* @__PURE__ */ jsx("g", {
83
- clipPath: `url(#${id}-eyes)`,
84
- children: /* @__PURE__ */ jsx("g", {
85
- className: styleProps([styles.pupils, motion(GAZE_MOTION[state])]).className,
86
- style: {
87
- "--lobe-agent-avatar-gaze": String(round(gazeScale)),
88
- "transform": `translate(${round(gazeX * gazeScale)}px, ${round(gazeY * gazeScale)}px)`
89
- },
90
- children: eyeXs.map((x) => /* @__PURE__ */ jsx("circle", {
91
- cx: x,
92
- cy: eyeY,
93
- fill: PUPIL_COLOR,
94
- r: round(pupilRadius)
95
- }, x))
96
- })
97
- })
98
- ] });
99
- const closedEyes = /* @__PURE__ */ jsx("g", {
100
- fill: "none",
101
- stroke: SCLERA_COLOR,
102
- strokeLinecap: "round",
103
- strokeWidth: round((small ? 7.5 : 6.5) * gazeScale),
104
- children: eyeXs.map((x) => /* @__PURE__ */ jsx("path", { d: happyEyePath(x, eyeY, baseRadius) }, x))
105
- });
106
- const eyesClassName = clsx$1(agentAvatarClasses("eyes"), classNames?.eyes);
107
- let eyeLayer;
108
- if (state === "done") eyeLayer = /* @__PURE__ */ jsxs("g", {
109
- className: styleProps([styles.eyes], eyesClassName).className,
110
- style: customStyles?.eyes,
111
- children: [animated && /* @__PURE__ */ jsx("g", {
112
- className: styleProps([styles.eyesOpenLate]).className,
113
- opacity: 0,
114
- children: eyes
115
- }), /* @__PURE__ */ jsx("g", {
116
- className: styleProps([motion(styles.eyesClosedEarly)]).className || void 0,
117
- children: closedEyes
118
- })]
45
+ const layers = useLiveAvatar({
46
+ enabled: animated,
47
+ followPointer,
48
+ idPrefix,
49
+ phase: -traits.phase,
50
+ shape,
51
+ state
119
52
  });
120
- else eyeLayer = /* @__PURE__ */ jsx("g", {
121
- style: {
122
- transformOrigin: `50px ${eyeY}px`,
123
- ...customStyles?.eyes
124
- },
125
- className: styleProps([styles.eyes, motion(BLINK_MOTION[state])], eyesClassName).className,
126
- children: eyes
127
- });
128
- const [badgeX, badgeY] = geometry.badge;
129
- const [thoughtX, thoughtY] = geometry.thought;
130
- const thoughtDirection = geometry.thoughtFlip ? -1 : 1;
131
- const thoughtHalo = geometry.thoughtHalo ?? true;
53
+ const still = useMemo(() => layers.live ? null : buildStillScene(shape, state), [
54
+ layers.live,
55
+ shape,
56
+ state
57
+ ]);
58
+ const label = ariaLabel ?? name;
132
59
  const lean = tilt ? traits.tilt : 0;
60
+ const motion = (value) => animated ? value : void 0;
133
61
  return /* @__PURE__ */ jsxs("svg", {
134
62
  "aria-hidden": label ? void 0 : true,
135
63
  "aria-label": label,
@@ -145,7 +73,6 @@ const AgentAvatar = memo(({ "animated": animatedProp = false, "aria-label": aria
145
73
  ...rest,
146
74
  ...styleProps([styles.root], clsx$1(agentAvatarClasses(), className, classNames?.root), {
147
75
  "--lobe-agent-avatar-color": color,
148
- ...animated && { "--lobe-agent-avatar-delay": `${traits.phase}s` },
149
76
  ...size !== void 0 && {
150
77
  height: size,
151
78
  width: size
@@ -154,63 +81,86 @@ const AgentAvatar = memo(({ "animated": animatedProp = false, "aria-label": aria
154
81
  ...style
155
82
  }),
156
83
  children: [
84
+ /* @__PURE__ */ jsx("defs", { ref: layers.defs }),
157
85
  /* @__PURE__ */ jsx("g", {
158
- transform: lean ? `rotate(${lean} 50 94)` : void 0,
86
+ transform: lean ? `rotate(${lean} 50 50)` : void 0,
159
87
  children: /* @__PURE__ */ jsxs("g", {
160
- className: styleProps([styles.bodyMotion, motion(BODY_MOTION[state])]).className,
161
- style: state === "waiting" ? { transform: "rotate(-3deg)" } : void 0,
162
- children: [/* @__PURE__ */ jsx("path", {
163
- d: geometry.d,
88
+ transform: still?.stage,
89
+ children: [/* @__PURE__ */ jsxs("g", {
90
+ ref: layers.body,
164
91
  style: customStyles?.body,
165
- className: styleProps([styles.body], clsx$1(agentAvatarClasses("body"), classNames?.body)).className
166
- }), eyeLayer]
92
+ className: styleProps([styles.body], clsx$1(agentAvatarClasses("body"), classNames?.body)).className,
93
+ children: [still && /* @__PURE__ */ jsx("path", { d: still.body }), still?.extra && /* @__PURE__ */ jsx("path", {
94
+ d: still.extra.d,
95
+ transform: still.extra.transform
96
+ })]
97
+ }), /* @__PURE__ */ jsx("g", {
98
+ className: clsx$1(agentAvatarClasses("eyes"), classNames?.eyes),
99
+ ref: layers.eyes,
100
+ style: customStyles?.eyes,
101
+ children: still?.eyes.map(({ pupil, sclera, smile, smileWidth, transform }, index) => /* @__PURE__ */ jsxs("g", {
102
+ transform,
103
+ children: [
104
+ sclera && /* @__PURE__ */ jsx("path", {
105
+ d: sclera,
106
+ fill: SCLERA_COLOR
107
+ }),
108
+ pupil && /* @__PURE__ */ jsx("path", {
109
+ d: pupil,
110
+ fill: PUPIL_COLOR
111
+ }),
112
+ smile && /* @__PURE__ */ jsx("path", {
113
+ d: smile,
114
+ fill: "none",
115
+ stroke: SCLERA_COLOR,
116
+ strokeLinecap: "round",
117
+ strokeWidth: smileWidth
118
+ })
119
+ ]
120
+ }, index))
121
+ })]
167
122
  })
168
123
  }),
169
124
  state === "thinking" && /* @__PURE__ */ jsx("g", {
170
125
  className: clsx$1(agentAvatarClasses("thought"), classNames?.thought),
171
126
  style: customStyles?.thought,
172
- children: THOUGHT_DOTS.map(([dx, dy, r], index) => /* @__PURE__ */ jsx("circle", {
173
- cx: thoughtX + dx * thoughtDirection,
174
- cy: thoughtY + dy,
175
- opacity: round(.9 - index * .15),
127
+ children: THOUGHT_DOTS.map(([cx, cy, r], index) => /* @__PURE__ */ jsx("circle", {
128
+ className: styleProps([styles.thoughtDot, motion(styles.thoughtMotion)]).className,
129
+ cx,
130
+ cy,
176
131
  r,
177
- className: styleProps([
178
- styles.thoughtDot,
179
- thoughtHalo && styles.thoughtHalo,
180
- motion(styles.thoughtRise)
181
- ]).className,
182
- style: animated ? { animationDelay: `calc(var(--lobe-agent-avatar-delay, 0s) + ${round(index * .35)}s)` } : void 0
132
+ style: animated ? { animationDelay: `${index * .22}s` } : void 0
183
133
  }, r))
184
134
  }),
185
- blocked && /* @__PURE__ */ jsxs("g", {
135
+ state === "blocked" && /* @__PURE__ */ jsxs("g", {
186
136
  style: customStyles?.badge,
187
- className: styleProps([motion(styles.badgeMotion)], clsx$1(agentAvatarClasses("badge"), classNames?.badge)).className,
137
+ className: styleProps([styles.badge, motion(styles.badgeMotion)], clsx$1(agentAvatarClasses("badge"), classNames?.badge)).className,
188
138
  children: [
189
139
  /* @__PURE__ */ jsx("circle", {
190
140
  className: styleProps([styles.badgeRing]).className,
191
- cx: badgeX,
192
- cy: badgeY,
193
- r: 11.5
141
+ cx: BADGE[0],
142
+ cy: BADGE[1],
143
+ r: 13
194
144
  }),
195
145
  /* @__PURE__ */ jsx("circle", {
196
146
  className: styleProps([styles.badgeDot]).className,
197
- cx: badgeX,
198
- cy: badgeY,
199
- r: 9
147
+ cx: BADGE[0],
148
+ cy: BADGE[1],
149
+ r: 10.5
200
150
  }),
201
151
  /* @__PURE__ */ jsx("rect", {
202
152
  className: styleProps([styles.badgeMark]).className,
203
- height: 6.8,
204
- rx: 1.25,
205
- width: 2.5,
206
- x: badgeX - 1.25,
207
- y: badgeY - 6.2
153
+ height: 8,
154
+ rx: 1.4,
155
+ width: 2.8,
156
+ x: BADGE[0] - 1.4,
157
+ y: BADGE[1] - 7
208
158
  }),
209
159
  /* @__PURE__ */ jsx("circle", {
210
160
  className: styleProps([styles.badgeMark]).className,
211
- cx: badgeX,
212
- cy: badgeY + 4.4,
213
- r: 1.45
161
+ cx: BADGE[0],
162
+ cy: BADGE[1] + 5,
163
+ r: 1.7
214
164
  })
215
165
  ]
216
166
  })
@@ -1 +1 @@
1
- {"version":3,"file":"AgentAvatar.mjs","names":["clsx"],"sources":["../../src/AgentAvatar/AgentAvatar.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { type CSSProperties, memo, type ReactNode, useId } from 'react';\n\nimport { styleProps } from '@/styles/stylex/props';\nimport { useThemeMode } from '@/styles/theme/scope';\nimport { toDataAttributes } from '@/utils/bem';\n\nimport { happyEyePath, scleraPath, SHAPE_GEOMETRY } from './shapes';\nimport { agentAvatarClasses } from './stable';\nimport { styles } from './style';\nimport type { AgentAvatarProps, AgentAvatarState } from './type';\nimport { useReducedMotion } from './useReducedMotion';\nimport {\n AGENT_AVATAR_COLOR_TOKENS,\n BLOCKED_PUPIL_RATIO,\n BLOCKED_SCLERA_SCALE,\n GAZE_UNIT_RADIUS,\n getAgentAvatarTraits,\n isAgentAvatarColor,\n PUPIL_COLOR,\n PUPIL_RATIO,\n PUPIL_RATIO_SMALL,\n SCLERA_COLOR,\n SMALL_SIZE,\n STILL_GAZE,\n} from './utils';\n\nconst round = (value: number) => Math.round(value * 100) / 100;\n\nconst BODY_MOTION = {\n blocked: styles.bodyBlocked,\n done: styles.bodyDone,\n idle: styles.bodyIdle,\n thinking: styles.bodyThinking,\n waiting: styles.bodyWaiting,\n working: styles.bodyWorking,\n} satisfies Record<AgentAvatarState, unknown>;\n\nconst BLINK_MOTION = {\n idle: styles.blinkIdle,\n thinking: styles.blinkThinking,\n waiting: styles.blinkWaiting,\n working: styles.blinkWorking,\n} satisfies Partial<Record<AgentAvatarState, unknown>>;\n\nconst GAZE_MOTION = {\n idle: styles.gazeIdle,\n thinking: styles.gazeThinking,\n working: styles.gazeWorking,\n} satisfies Partial<Record<AgentAvatarState, unknown>>;\n\n/** Thought bubbles: offset from the anchor and radius, smallest last. */\nconst THOUGHT_DOTS: [number, number, number][] = [\n [0, 8, 8.5],\n [12, 2, 6.5],\n [20, -5, 4.5],\n];\n\nconst AgentAvatar = memo<AgentAvatarProps>(\n ({\n 'animated': animatedProp = false,\n 'aria-label': ariaLabel,\n className,\n classNames,\n 'color': colorProp,\n name,\n ref,\n seed,\n 'shape': shapeProp,\n size,\n state = 'idle',\n style,\n 'styles': customStyles,\n tilt = true,\n ...rest\n }) => {\n const id = useId().replaceAll(/[^\\w-]/g, '');\n const { isDarkMode } = useThemeMode();\n const reducedMotion = useReducedMotion();\n const animated = animatedProp && !reducedMotion;\n\n const traits = getAgentAvatarTraits(seed ?? name ?? '');\n const shape = shapeProp ?? traits.shape;\n const colorKey = colorProp ?? traits.color;\n const isPreset = isAgentAvatarColor(colorKey);\n const color = isPreset\n ? AGENT_AVATAR_COLOR_TOKENS[colorKey][isDarkMode ? 'dark' : 'light']\n : colorKey;\n\n const geometry = SHAPE_GEOMETRY[shape];\n const { gap, r: baseRadius, y: eyeY } = geometry.eyes;\n const eyeXs = [50 - gap / 2, 50 + gap / 2];\n const gazeScale = baseRadius / GAZE_UNIT_RADIUS;\n const blocked = state === 'blocked';\n const radius = blocked ? baseRadius * BLOCKED_SCLERA_SCALE : baseRadius;\n const small = size !== undefined && size <= SMALL_SIZE;\n const pupilRadius =\n baseRadius * (blocked ? BLOCKED_PUPIL_RATIO : small ? PUPIL_RATIO_SMALL : PUPIL_RATIO);\n const [gazeX, gazeY] = STILL_GAZE[state];\n\n const label = ariaLabel ?? name;\n const motion = <T,>(value: T) => (animated ? value : undefined);\n\n const eyes = (\n <>\n <defs>\n <clipPath id={`${id}-eyes`}>\n {eyeXs.map((x) => (\n <path d={scleraPath(x, eyeY, radius)} key={x} />\n ))}\n </clipPath>\n </defs>\n {eyeXs.map((x) => (\n <path d={scleraPath(x, eyeY, radius)} fill={SCLERA_COLOR} key={x} />\n ))}\n <g clipPath={`url(#${id}-eyes)`}>\n <g\n className={\n styleProps([styles.pupils, motion(GAZE_MOTION[state as keyof typeof GAZE_MOTION])])\n .className\n }\n style={\n {\n '--lobe-agent-avatar-gaze': String(round(gazeScale)),\n 'transform': `translate(${round(gazeX * gazeScale)}px, ${round(gazeY * gazeScale)}px)`,\n } as CSSProperties\n }\n >\n {eyeXs.map((x) => (\n <circle cx={x} cy={eyeY} fill={PUPIL_COLOR} key={x} r={round(pupilRadius)} />\n ))}\n </g>\n </g>\n </>\n );\n\n const closedEyes = (\n <g\n fill=\"none\"\n stroke={SCLERA_COLOR}\n strokeLinecap=\"round\"\n strokeWidth={round((small ? 7.5 : 6.5) * gazeScale)}\n >\n {eyeXs.map((x) => (\n <path d={happyEyePath(x, eyeY, baseRadius)} key={x} />\n ))}\n </g>\n );\n\n const eyesClassName = clsx(agentAvatarClasses('eyes'), classNames?.eyes);\n let eyeLayer: ReactNode;\n if (state === 'done') {\n eyeLayer = (\n <g\n className={styleProps([styles.eyes], eyesClassName).className}\n style={customStyles?.eyes}\n >\n {animated && (\n <g className={styleProps([styles.eyesOpenLate]).className} opacity={0}>\n {eyes}\n </g>\n )}\n <g className={styleProps([motion(styles.eyesClosedEarly)]).className || undefined}>\n {closedEyes}\n </g>\n </g>\n );\n } else {\n eyeLayer = (\n <g\n style={{ transformOrigin: `50px ${eyeY}px`, ...customStyles?.eyes }}\n className={\n styleProps(\n [styles.eyes, motion(BLINK_MOTION[state as keyof typeof BLINK_MOTION])],\n eyesClassName,\n ).className\n }\n >\n {eyes}\n </g>\n );\n }\n\n const [badgeX, badgeY] = geometry.badge;\n const [thoughtX, thoughtY] = geometry.thought;\n const thoughtDirection = geometry.thoughtFlip ? -1 : 1;\n const thoughtHalo = geometry.thoughtHalo ?? true;\n // Only the body and eyes lean; the badge and thought bubbles stay upright and in place.\n const lean = tilt ? traits.tilt : 0;\n\n return (\n <svg\n aria-hidden={label ? undefined : true}\n aria-label={label}\n ref={ref}\n role={label ? 'img' : undefined}\n viewBox=\"0 0 100 100\"\n {...toDataAttributes({\n animated,\n color: isPreset ? colorKey : undefined,\n shape,\n state,\n })}\n {...rest}\n {...styleProps([styles.root], clsx(agentAvatarClasses(), className, classNames?.root), {\n '--lobe-agent-avatar-color': color,\n ...(animated && { '--lobe-agent-avatar-delay': `${traits.phase}s` }),\n ...(size !== undefined && { height: size, width: size }),\n ...customStyles?.root,\n ...style,\n } as CSSProperties)}\n >\n <g transform={lean ? `rotate(${lean} 50 94)` : undefined}>\n <g\n className={styleProps([styles.bodyMotion, motion(BODY_MOTION[state])]).className}\n style={state === 'waiting' ? { transform: 'rotate(-3deg)' } : undefined}\n >\n <path\n d={geometry.d}\n style={customStyles?.body}\n className={\n styleProps([styles.body], clsx(agentAvatarClasses('body'), classNames?.body))\n .className\n }\n />\n {eyeLayer}\n </g>\n </g>\n {state === 'thinking' && (\n <g\n className={clsx(agentAvatarClasses('thought'), classNames?.thought)}\n style={customStyles?.thought}\n >\n {THOUGHT_DOTS.map(([dx, dy, r], index) => (\n <circle\n cx={thoughtX + dx * thoughtDirection}\n cy={thoughtY + dy}\n key={r}\n opacity={round(0.9 - index * 0.15)}\n r={r}\n className={\n styleProps([\n styles.thoughtDot,\n thoughtHalo && styles.thoughtHalo,\n motion(styles.thoughtRise),\n ]).className\n }\n style={\n animated\n ? {\n animationDelay: `calc(var(--lobe-agent-avatar-delay, 0s) + ${round(index * 0.35)}s)`,\n }\n : undefined\n }\n />\n ))}\n </g>\n )}\n {blocked && (\n <g\n style={customStyles?.badge}\n className={\n styleProps(\n [motion(styles.badgeMotion)],\n clsx(agentAvatarClasses('badge'), classNames?.badge),\n ).className\n }\n >\n <circle\n className={styleProps([styles.badgeRing]).className}\n cx={badgeX}\n cy={badgeY}\n r={11.5}\n />\n <circle\n className={styleProps([styles.badgeDot]).className}\n cx={badgeX}\n cy={badgeY}\n r={9}\n />\n <rect\n className={styleProps([styles.badgeMark]).className}\n height={6.8}\n rx={1.25}\n width={2.5}\n x={badgeX - 1.25}\n y={badgeY - 6.2}\n />\n <circle\n className={styleProps([styles.badgeMark]).className}\n cx={badgeX}\n cy={badgeY + 4.4}\n r={1.45}\n />\n </g>\n )}\n </svg>\n );\n },\n);\n\nAgentAvatar.displayName = 'AgentAvatar';\n\nexport default AgentAvatar;\n"],"mappings":";;;;;;;;;;;;;AA6BA,MAAM,SAAS,UAAkB,KAAK,MAAM,QAAQ,GAAG,IAAI;AAE3D,MAAM,cAAc;CAClB,SAAS,OAAO;CAChB,MAAM,OAAO;CACb,MAAM,OAAO;CACb,UAAU,OAAO;CACjB,SAAS,OAAO;CAChB,SAAS,OAAO;A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IAAI;MACJ,OAAO;MACP,GAAG,SAAS;MACZ,GAAG,SAAS;KACb,CAAA;KACD,oBAAC,UAAD;MACE,WAAW,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;MAC1C,IAAI;MACJ,IAAI,SAAS;MACb,GAAG;KACJ,CAAA;IACA;;EAEF;;AAET,CACF;AAEA,YAAY,cAAc"}
1
+ {"version":3,"file":"AgentAvatar.mjs","names":["clsx"],"sources":["../../src/AgentAvatar/AgentAvatar.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { type CSSProperties, memo, useId, useMemo } from 'react';\n\nimport { styleProps } from '@/styles/stylex/props';\nimport { useThemeMode } from '@/styles/theme/scope';\nimport { toDataAttributes } from '@/utils/bem';\n\nimport { agentAvatarClasses } from './stable';\nimport { buildStillScene } from './still';\nimport { styles } from './style';\nimport type { AgentAvatarProps } from './type';\nimport { useLiveAvatar } from './useLiveAvatar';\nimport { useReducedMotion } from './useReducedMotion';\nimport {\n AGENT_AVATAR_COLOR_TOKENS,\n getAgentAvatarTraits,\n isAgentAvatarColor,\n PUPIL_COLOR,\n SCLERA_COLOR,\n} from './utils';\n\n/** Center of the `blocked` badge: the bottom-right corner, clear of ears and antennas. */\nconst BADGE = [86, 86] as const;\n/** Thought bubbles in the top-right corner of the box: center and radius, largest first. */\nconst THOUGHT_DOTS = [\n [73, 17, 6],\n [84, 10, 4.4],\n [92.5, 5.5, 3],\n] as const;\n\nconst AgentAvatar = memo<AgentAvatarProps>(\n ({\n 'animated': animatedProp = false,\n 'aria-label': ariaLabel,\n className,\n classNames,\n 'color': colorProp,\n followPointer = false,\n name,\n ref,\n seed,\n 'shape': shapeProp,\n size,\n state = 'idle',\n style,\n 'styles': customStyles,\n tilt = true,\n ...rest\n }) => {\n const idPrefix = `${useId().replaceAll(/[^\\w-]/g, '')}-`;\n const { isDarkMode } = useThemeMode();\n const reducedMotion = useReducedMotion();\n const animated = animatedProp && !reducedMotion;\n\n const traits = getAgentAvatarTraits(seed ?? name ?? '');\n const shape = shapeProp ?? traits.shape;\n const colorKey = colorProp ?? traits.color;\n const isPreset = isAgentAvatarColor(colorKey);\n const color = isPreset\n ? AGENT_AVATAR_COLOR_TOKENS[colorKey][isDarkMode ? 'dark' : 'light']\n : colorKey;\n\n const layers = useLiveAvatar({\n enabled: animated,\n followPointer,\n idPrefix,\n phase: -traits.phase,\n shape,\n state,\n });\n\n const still = useMemo(\n () => (layers.live ? null : buildStillScene(shape, state)),\n [layers.live, shape, state],\n );\n\n const label = ariaLabel ?? name;\n // Only the body and eyes lean; the badge and thought bubbles stay upright.\n const lean = tilt ? traits.tilt : 0;\n const motion = <T,>(value: T) => (animated ? value : undefined);\n\n return (\n <svg\n aria-hidden={label ? undefined : true}\n aria-label={label}\n ref={ref}\n role={label ? 'img' : undefined}\n viewBox=\"0 0 100 100\"\n {...toDataAttributes({\n animated,\n color: isPreset ? colorKey : undefined,\n shape,\n state,\n })}\n {...rest}\n {...styleProps([styles.root], clsx(agentAvatarClasses(), className, classNames?.root), {\n '--lobe-agent-avatar-color': color,\n ...(size !== undefined && { height: size, width: size }),\n ...customStyles?.root,\n ...style,\n } as CSSProperties)}\n >\n <defs ref={layers.defs} />\n <g transform={lean ? `rotate(${lean} 50 50)` : undefined}>\n <g transform={still?.stage}>\n <g\n ref={layers.body}\n style={customStyles?.body}\n className={\n styleProps([styles.body], clsx(agentAvatarClasses('body'), classNames?.body))\n .className\n }\n >\n {still && <path d={still.body} />}\n {still?.extra && <path d={still.extra.d} transform={still.extra.transform} />}\n </g>\n <g\n className={clsx(agentAvatarClasses('eyes'), classNames?.eyes)}\n ref={layers.eyes}\n style={customStyles?.eyes}\n >\n {still?.eyes.map(({ pupil, sclera, smile, smileWidth, transform }, index) => (\n <g key={index} transform={transform}>\n {sclera && <path d={sclera} fill={SCLERA_COLOR} />}\n {pupil && <path d={pupil} fill={PUPIL_COLOR} />}\n {smile && (\n <path\n d={smile}\n fill=\"none\"\n stroke={SCLERA_COLOR}\n strokeLinecap=\"round\"\n strokeWidth={smileWidth}\n />\n )}\n </g>\n ))}\n </g>\n </g>\n </g>\n {state === 'thinking' && (\n <g\n className={clsx(agentAvatarClasses('thought'), classNames?.thought)}\n style={customStyles?.thought}\n >\n {THOUGHT_DOTS.map(([cx, cy, r], index) => (\n <circle\n className={styleProps([styles.thoughtDot, motion(styles.thoughtMotion)]).className}\n cx={cx}\n cy={cy}\n key={r}\n r={r}\n style={animated ? { animationDelay: `${index * 0.22}s` } : undefined}\n />\n ))}\n </g>\n )}\n {state === 'blocked' && (\n <g\n style={customStyles?.badge}\n className={\n styleProps(\n [styles.badge, motion(styles.badgeMotion)],\n clsx(agentAvatarClasses('badge'), classNames?.badge),\n ).className\n }\n >\n <circle\n className={styleProps([styles.badgeRing]).className}\n cx={BADGE[0]}\n cy={BADGE[1]}\n r={13}\n />\n <circle\n className={styleProps([styles.badgeDot]).className}\n cx={BADGE[0]}\n cy={BADGE[1]}\n r={10.5}\n />\n <rect\n className={styleProps([styles.badgeMark]).className}\n height={8}\n rx={1.4}\n width={2.8}\n x={BADGE[0] - 1.4}\n y={BADGE[1] - 7}\n />\n <circle\n className={styleProps([styles.badgeMark]).className}\n cx={BADGE[0]}\n cy={BADGE[1] + 5}\n r={1.7}\n />\n </g>\n )}\n </svg>\n );\n },\n);\n\nAgentAvatar.displayName = 'AgentAvatar';\n\nexport default AgentAvatar;\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,MAAM,QAAQ,CAAC,IAAI,EAAE;;AAErB,MAAM,eAAe;CACnB;EAAC;EAAI;EAAI;CAAC;CACV;EAAC;EAAI;EAAI;CAAG;CACZ;EAAC;EAAM;EAAK;CAAC;AACf;AAEA,MAAM,cAAc,MACjB,EACC,YAAY,eAAe,OAC3B,cAAc,WACd,WACA,YACA,SAAS,WACT,gBAAgB,OAChB,MACA,KACA,MACA,SAAS,WACT,MACA,QAAQ,QACR,OACA,UAAU,cACV,OAAO,MACP,GAAG,WACC;CACJ,MAAM,W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AAO,cAAc;IACrB,WACE,WACE,CAAC,OAAO,OAAO,OAAO,OAAO,WAAW,CAAC,GACzCA,OAAK,mBAAmB,OAAO,GAAG,YAAY,KAAK,CACrD,CAAC,CAAC;IANN,UAAA;KASE,oBAAC,UAAD;MACE,WAAW,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;MAC1C,IAAI,MAAM;MACV,IAAI,MAAM;MACV,GAAG;KACJ,CAAA;KACD,oBAAC,UAAD;MACE,WAAW,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC;MACzC,IAAI,MAAM;MACV,IAAI,MAAM;MACV,GAAG;KACJ,CAAA;KACD,oBAAC,QAAD;MACE,WAAW,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;MAC1C,QAAQ;MACR,IAAI;MACJ,OAAO;MACP,GAAG,MAAM,KAAK;MACd,GAAG,MAAM,KAAK;KACf,CAAA;KACD,oBAAC,UAAD;MACE,WAAW,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;MAC1C,IAAI,MAAM;MACV,IAAI,MAAM,KAAK;MACf,GAAG;KACJ,CAAA;IACA;;EAEF;;AAET,CACF;AAEA,YAAY,cAAc"}
@@ -0,0 +1,3 @@
1
+ import { AgentAvatarPickerProps } from "./type.mjs";
2
+ declare const AgentAvatarPicker: import("react").NamedExoticComponent<AgentAvatarPickerProps>;
3
+ export { AgentAvatarPicker as default };
@@ -0,0 +1,109 @@
1
+ "use client";
2
+ import clsx$1 from "clsx";
3
+ import { memo } from "react";
4
+ import { useControlledState } from "../hooks/useControlledState.mjs";
5
+ import agentAvatar_default from "../i18n/resources/en/agentAvatar.mjs";
6
+ import { useTranslation } from "../i18n/useTranslation.mjs";
7
+ import { focusRing } from "../styles/stylex/focusRing.mjs";
8
+ import { styleProps } from "../styles/stylex/props.mjs";
9
+ import { useThemeMode } from "../styles/theme/scope.mjs";
10
+ import AgentAvatar from "./AgentAvatar.mjs";
11
+ import { styles } from "./pickerStyle.mjs";
12
+ import { agentAvatarPickerClasses } from "./stable.mjs";
13
+ import { AGENT_AVATAR_COLORS, AGENT_AVATAR_COLOR_TOKENS, AGENT_AVATAR_SHAPES } from "./utils.mjs";
14
+ import { jsx, jsxs } from "react/jsx-runtime";
15
+ // src/AgentAvatar/AgentAvatarPicker.tsx
16
+ const DEFAULT_VALUE = {
17
+ color: "geekblue",
18
+ shape: "lobot"
19
+ };
20
+ const AgentAvatarPicker = memo(({ className, defaultValue, onChange, preview = true, ref, style, texts, value, ...rest }) => {
21
+ const { t } = useTranslation(agentAvatar_default);
22
+ const { isDarkMode } = useThemeMode();
23
+ const [current, setCurrent] = useControlledState({
24
+ ...DEFAULT_VALUE,
25
+ ...defaultValue
26
+ }, {
27
+ defaultValue: {
28
+ ...DEFAULT_VALUE,
29
+ ...defaultValue
30
+ },
31
+ onChange: onChange && ((next) => onChange(next)),
32
+ value
33
+ });
34
+ return /* @__PURE__ */ jsxs("div", {
35
+ ref,
36
+ ...rest,
37
+ ...styleProps([styles.root], clsx$1(agentAvatarPickerClasses(), className), style),
38
+ children: [
39
+ preview && /* @__PURE__ */ jsx("div", {
40
+ ...styleProps([styles.preview], agentAvatarPickerClasses("preview")),
41
+ children: /* @__PURE__ */ jsx(AgentAvatar, {
42
+ animated: true,
43
+ followPointer: true,
44
+ color: current.color,
45
+ shape: current.shape,
46
+ size: 88
47
+ })
48
+ }),
49
+ /* @__PURE__ */ jsx("div", {
50
+ "aria-label": texts?.shapes ?? t("agentAvatar.shapes"),
51
+ role: "group",
52
+ ...styleProps([styles.shapes], agentAvatarPickerClasses("shapes")),
53
+ children: AGENT_AVATAR_SHAPES.map((shape) => {
54
+ const label = t(`agentAvatar.shape.${shape}`);
55
+ const active = shape === current.shape;
56
+ return /* @__PURE__ */ jsx("button", {
57
+ "aria-label": label,
58
+ "aria-pressed": active,
59
+ title: label,
60
+ type: "button",
61
+ onClick: () => setCurrent({
62
+ ...current,
63
+ shape
64
+ }),
65
+ ...styleProps([
66
+ styles.shape,
67
+ active && styles.shapeActive,
68
+ focusRing.info
69
+ ], agentAvatarPickerClasses("shape")),
70
+ children: /* @__PURE__ */ jsx(AgentAvatar, {
71
+ color: current.color,
72
+ shape,
73
+ size: 36,
74
+ tilt: false
75
+ })
76
+ }, shape);
77
+ })
78
+ }),
79
+ /* @__PURE__ */ jsx("div", {
80
+ "aria-label": texts?.colors ?? t("agentAvatar.colors"),
81
+ role: "group",
82
+ ...styleProps([styles.colors], agentAvatarPickerClasses("colors")),
83
+ children: AGENT_AVATAR_COLORS.map((color) => {
84
+ const label = t(`agentAvatar.color.${color}`);
85
+ const active = color === current.color;
86
+ return /* @__PURE__ */ jsx("button", {
87
+ "aria-label": label,
88
+ "aria-pressed": active,
89
+ title: label,
90
+ type: "button",
91
+ onClick: () => setCurrent({
92
+ ...current,
93
+ color
94
+ }),
95
+ ...styleProps([
96
+ styles.color,
97
+ active && styles.colorActive,
98
+ focusRing.info
99
+ ], agentAvatarPickerClasses("color"), { background: AGENT_AVATAR_COLOR_TOKENS[color][isDarkMode ? "dark" : "light"] })
100
+ }, color);
101
+ })
102
+ })
103
+ ]
104
+ });
105
+ });
106
+ AgentAvatarPicker.displayName = "AgentAvatarPicker";
107
+ export { AgentAvatarPicker as default };
108
+
109
+ //# sourceMappingURL=AgentAvatarPicker.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentAvatarPicker.mjs","names":["agentAvatarMessages","clsx"],"sources":["../../src/AgentAvatar/AgentAvatarPicker.tsx"],"sourcesContent":["'use client';\n\nimport clsx from 'clsx';\nimport { memo } from 'react';\n\nimport { useControlledState } from '@/hooks/useControlledState';\nimport agentAvatarMessages from '@/i18n/resources/en/agentAvatar';\nimport { useTranslation } from '@/i18n/useTranslation';\nimport { focusRing } from '@/styles/stylex/focusRing';\nimport { styleProps } from '@/styles/stylex/props';\nimport { useThemeMode } from '@/styles/theme/scope';\n\nimport AgentAvatar from './AgentAvatar';\nimport { styles } from './pickerStyle';\nimport { agentAvatarPickerClasses } from './stable';\nimport type { AgentAvatarPickerProps, AgentAvatarValue } from './type';\nimport { AGENT_AVATAR_COLOR_TOKENS, AGENT_AVATAR_COLORS, AGENT_AVATAR_SHAPES } from './utils';\n\nconst DEFAULT_VALUE: AgentAvatarValue = { color: 'geekblue', shape: 'lobot' };\n\nconst AgentAvatarPicker = memo<AgentAvatarPickerProps>(\n ({ className, defaultValue, onChange, preview = true, ref, style, texts, value, ...rest }) => {\n const { t } = useTranslation(agentAvatarMessages);\n const { isDarkMode } = useThemeMode();\n const [current, setCurrent] = useControlledState<AgentAvatarValue>(\n { ...DEFAULT_VALUE, ...defaultValue },\n {\n defaultValue: { ...DEFAULT_VALUE, ...defaultValue },\n onChange: onChange && ((next) => onChange(next)),\n value,\n },\n );\n\n return (\n <div\n ref={ref}\n {...rest}\n {...styleProps([styles.root], clsx(agentAvatarPickerClasses(), className), style)}\n >\n {preview && (\n <div {...styleProps([styles.preview], agentAvatarPickerClasses('preview'))}>\n <AgentAvatar\n animated\n followPointer\n color={current.color}\n shape={current.shape}\n size={88}\n />\n </div>\n )}\n <div\n aria-label={texts?.shapes ?? t('agentAvatar.shapes')}\n role=\"group\"\n {...styleProps([styles.shapes], agentAvatarPickerClasses('shapes'))}\n >\n {AGENT_AVATAR_SHAPES.map((shape) => {\n const label = t(`agentAvatar.shape.${shape}`);\n const active = shape === current.shape;\n return (\n <button\n aria-label={label}\n aria-pressed={active}\n key={shape}\n title={label}\n type=\"button\"\n onClick={() => setCurrent({ ...current, shape })}\n {...styleProps(\n [styles.shape, active && styles.shapeActive, focusRing.info],\n agentAvatarPickerClasses('shape'),\n )}\n >\n <AgentAvatar color={current.color} shape={shape} size={36} tilt={false} />\n </button>\n );\n })}\n </div>\n <div\n aria-label={texts?.colors ?? t('agentAvatar.colors')}\n role=\"group\"\n {...styleProps([styles.colors], agentAvatarPickerClasses('colors'))}\n >\n {AGENT_AVATAR_COLORS.map((color) => {\n const label = t(`agentAvatar.color.${color}`);\n const active = color === current.color;\n return (\n <button\n aria-label={label}\n aria-pressed={active}\n key={color}\n title={label}\n type=\"button\"\n onClick={() => setCurrent({ ...current, color })}\n {...styleProps(\n [styles.color, active && styles.colorActive, focusRing.info],\n agentAvatarPickerClasses('color'),\n { background: AGENT_AVATAR_COLOR_TOKENS[color][isDarkMode ? 'dark' : 'light'] },\n )}\n />\n );\n })}\n </div>\n </div>\n );\n },\n);\n\nAgentAvatarPicker.displayName = 'AgentAvatarPicker';\n\nexport default AgentAvatarPicker;\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,MAAM,gBAAkC;CAAE,OAAO;CAAY,OAAO;AAAQ;AAE5E,MAAM,oBAAoB,MACvB,EAAE,WAAW,cAAc,UAAU,UAAU,MAAM,KAAK,OAAO,OAAO,OAAO,GAAG,WAAW;CAC5F,MAAM,EAAE,MAAM,eAAeA,mBAAmB;CAChD,MAAM,EAAE,eAAe,aAAa;CACpC,MAAM,CAAC,SAAS,cAAc,mBAC5B;EAAE,GAAG;EAAe,GAAG;CAAa,GACpC;EACE,cAAc;GAAE,GAAG;GAAe,GAAG;EAAa;EAClD,UAAU,cAAc,SAAS,SAAS,IAAI;EAC9C;CACF,CACF;CAEA,OACE,qBAAC,OAAD;EACO;EACL,GAAI;EACJ,GAAI,WAAW,CAAC,OAAO,IAAI,GAAGC,OAAK,yBAAyB,GAAG,SAAS,GAAG,KAAK;EAHlF,UAAA;GAKG,WACC,oBAAC,OAAD;IAAK,GAAI,WAAW,CAAC,OAAO,OAAO,GAAG,yBAAyB,SAAS,CAAC;IACvE,UAAA,oBAAC,aAAD;KACE,UAAA;KACA,eAAA;KACA,OAAO,QAAQ;KACf,OAAO,QAAQ;KACf,MAAM;IACP,CAAA;GACE,CAAA;GAEP,oBAAC,OAAD;IACE,cAAY,OAAO,UAAU,EAAE,oBAAoB;IACnD,MAAK;IACL,GAAI,WAAW,CAAC,OAAO,MAAM,GAAG,yBAAyB,QAAQ,CAAC;IAEjE,UAAA,oBAAoB,KAAK,UAAU;KAClC,MAAM,QAAQ,EAAE,qBAAqB,OAAO;KAC5C,MAAM,SAAS,UAAU,QAAQ;KACjC,OACE,oBAAC,UAAD;MACE,cAAY;MACZ,gBAAc;MAEd,OAAO;MACP,MAAK;MACL,eAAe,WAAW;OAAE,GAAG;OAAS;MAAM,CAAC;MAC/C,GAAI,WACF;OAAC,OAAO;OAAO,UAAU,OAAO;OAAa,UAAU;MAAI,GAC3D,yBAAyB,OAAO,CAClC;MAEA,UAAA,oBAAC,aAAD;OAAa,OAAO,QAAQ;OAAc;OAAO,MAAM;OAAI,MAAM;MAAQ,CAAA;KACnE,GAVD,KAUC;IAEZ,CAAC;GACE,CAAA;GACL,oBAAC,OAAD;IACE,cAAY,OAAO,UAAU,EAAE,oBAAoB;IACnD,MAAK;IACL,GAAI,WAAW,CAAC,OAAO,MAAM,GAAG,yBAAyB,QAAQ,CAAC;IAEjE,UAAA,oBAAoB,KAAK,UAAU;KAClC,MAAM,QAAQ,EAAE,qBAAqB,OAAO;KAC5C,MAAM,SAAS,UAAU,QAAQ;KACjC,OACE,oBAAC,UAAD;MACE,cAAY;MACZ,gBAAc;MAEd,OAAO;MACP,MAAK;MACL,eAAe,WAAW;OAAE,GAAG;OAAS;MAAM,CAAC;MAC/C,GAAI,WACF;OAAC,OAAO;OAAO,UAAU,OAAO;OAAa,UAAU;MAAI,GAC3D,yBAAyB,OAAO,GAChC,EAAE,YAAY,0BAA0B,MAAM,CAAC,aAAa,SAAS,SAAS,CAChF;KACD,GATM,KASN;IAEL,CAAC;GACE,CAAA;EACF;;AAET,CACF;AAEA,kBAAkB,cAAc"}
@@ -0,0 +1,4 @@
1
+ import { EmojiPickerCustomTab } from "../EmojiPicker/type.mjs";
2
+ import { CreateAgentAvatarTabOptions } from "./type.mjs";
3
+ /** A custom `EmojiPicker` tab for choosing an AgentAvatar. Its values are `agent-avatar:…` strings. */
4
+ export declare const createAgentAvatarTab: ({ label, placement, texts, value }?: CreateAgentAvatarTabOptions) => EmojiPickerCustomTab;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+ import { memo } from "react";
3
+ import agentAvatar_default from "../i18n/resources/en/agentAvatar.mjs";
4
+ import { useTranslation } from "../i18n/useTranslation.mjs";
5
+ import { Tooltip } from "../Tooltip/Tooltip.mjs";
6
+ import AgentAvatar from "./AgentAvatar.mjs";
7
+ import AgentAvatarPicker from "./AgentAvatarPicker.mjs";
8
+ import { parseAgentAvatar, stringifyAgentAvatar } from "./value.mjs";
9
+ import { jsx } from "react/jsx-runtime";
10
+ // src/AgentAvatar/createAgentAvatarTab.tsx
11
+ const TabLabel = memo(({ title }) => {
12
+ const { t } = useTranslation(agentAvatar_default);
13
+ return /* @__PURE__ */ jsx(Tooltip, {
14
+ title: title ?? t("agentAvatar.tab"),
15
+ children: /* @__PURE__ */ jsx(AgentAvatar, {
16
+ color: "currentColor",
17
+ shape: "lobot",
18
+ size: 22,
19
+ tilt: false
20
+ })
21
+ });
22
+ });
23
+ TabLabel.displayName = "AgentAvatarTabLabel";
24
+ /** A custom `EmojiPicker` tab for choosing an AgentAvatar. Its values are `agent-avatar:…` strings. */
25
+ const createAgentAvatarTab = ({ label, placement = "start", texts, value = "agent-avatar" } = {}) => ({
26
+ label: label ?? /* @__PURE__ */ jsx(TabLabel, { title: texts?.tab }),
27
+ placement,
28
+ render: (handleAvatarChange, avatar) => /* @__PURE__ */ jsx(AgentAvatarPicker, {
29
+ defaultValue: parseAgentAvatar(avatar),
30
+ style: { width: 300 },
31
+ texts,
32
+ onChange: (choice) => handleAvatarChange(stringifyAgentAvatar(choice), { keepOpen: true })
33
+ }),
34
+ renderValue: (avatar, size) => {
35
+ const choice = parseAgentAvatar(avatar);
36
+ return choice ? /* @__PURE__ */ jsx(AgentAvatar, {
37
+ ...choice,
38
+ size,
39
+ tilt: false
40
+ }) : void 0;
41
+ },
42
+ value
43
+ });
44
+ export { createAgentAvatarTab };
45
+
46
+ //# sourceMappingURL=createAgentAvatarTab.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createAgentAvatarTab.mjs","names":["agentAvatarMessages"],"sources":["../../src/AgentAvatar/createAgentAvatarTab.tsx"],"sourcesContent":["'use client';\n\nimport { memo } from 'react';\n\nimport type { EmojiPickerCustomTab } from '@/EmojiPicker/type';\nimport agentAvatarMessages from '@/i18n/resources/en/agentAvatar';\nimport { useTranslation } from '@/i18n/useTranslation';\nimport Tooltip from '@/Tooltip';\n\nimport AgentAvatar from './AgentAvatar';\nimport AgentAvatarPicker from './AgentAvatarPicker';\nimport type { CreateAgentAvatarTabOptions } from './type';\nimport { parseAgentAvatar, stringifyAgentAvatar } from './value';\n\nconst TabLabel = memo<{ title?: string }>(({ title }) => {\n const { t } = useTranslation(agentAvatarMessages);\n return (\n <Tooltip title={title ?? t('agentAvatar.tab')}>\n <AgentAvatar color=\"currentColor\" shape=\"lobot\" size={22} tilt={false} />\n </Tooltip>\n );\n});\n\nTabLabel.displayName = 'AgentAvatarTabLabel';\n\n/** A custom `EmojiPicker` tab for choosing an AgentAvatar. Its values are `agent-avatar:…` strings. */\nexport const createAgentAvatarTab = ({\n label,\n placement = 'start',\n texts,\n value = 'agent-avatar',\n}: CreateAgentAvatarTabOptions = {}): EmojiPickerCustomTab => ({\n label: label ?? <TabLabel title={texts?.tab} />,\n placement,\n render: (handleAvatarChange, avatar) => (\n <AgentAvatarPicker\n defaultValue={parseAgentAvatar(avatar)}\n style={{ width: 300 }}\n texts={texts}\n onChange={(choice) => handleAvatarChange(stringifyAgentAvatar(choice), { keepOpen: true })}\n />\n ),\n renderValue: (avatar, size) => {\n const choice = parseAgentAvatar(avatar);\n return choice ? <AgentAvatar {...choice} size={size} tilt={false} /> : undefined;\n },\n value,\n});\n"],"mappings":";;;;;;;;;;AAcA,MAAM,WAAW,MAA0B,EAAE,YAAY;CACvD,MAAM,EAAE,MAAM,eAAeA,mBAAmB;CAChD,OACE,oBAAC,SAAD;EAAS,OAAO,SAAS,EAAE,iBAAiB;EAC1C,UAAA,oBAAC,aAAD;GAAa,OAAM;GAAe,OAAM;GAAQ,MAAM;GAAI,MAAM;EAAQ,CAAA;CACjE,CAAA;AAEb,CAAC;AAED,SAAS,cAAc;;AAGvB,MAAa,wBAAwB,EACnC,OACA,YAAY,SACZ,OACA,QAAQ,mBACuB,CAAC,OAA6B;CAC7D,OAAO,SAAS,oBAAC,UAAD,EAAU,OAAO,OAAO,IAAM,CAAA;CAC9C;CACA,SAAS,oBAAoB,WAC3B,oBAAC,mBAAD;EACE,cAAc,iBAAiB,MAAM;EACrC,OAAO,EAAE,OAAO,IAAI;EACb;EACP,WAAW,WAAW,mBAAmB,qBAAqB,MAAM,GAAG,EAAE,UAAU,KAAK,CAAC;CAC1F,CAAA;CAEH,cAAc,QAAQ,SAAS;EAC7B,MAAM,SAAS,iBAAiB,MAAM;EACtC,OAAO,SAAS,oBAAC,aAAD;GAAa,GAAI;GAAc;GAAM,MAAM;EAAQ,CAAA,IAAI,KAAA;CACzE;CACA;AACF"}
@@ -0,0 +1,83 @@
1
+ // src/AgentAvatar/eyes.ts
2
+ /**
3
+ * The eyes of the Lobot logo as geometry: tall white ovals with large black pupils that sit toward
4
+ * the nose and a little low. All ratios are measured from the logo SVG (eye 41 × 47, pupil
5
+ * 21.5 × 24, eye centers 105 apart, pupils 7 in and 7 down).
6
+ */
7
+ const LOGO_EYE = {
8
+ /** Eye height / width. */
9
+ aspect: 47 / 41,
10
+ /** Distance between eye centers / eye x-radius. */
11
+ gap: 105 / 41,
12
+ /** Resting pupil offset toward the nose / eye x-radius. */
13
+ lookIn: 7 / 41,
14
+ /** Resting pupil offset downward / eye y-radius. */
15
+ lookDown: 7 / 47,
16
+ /** Pupil x-radius / eye x-radius. */
17
+ pupilX: 21.5 / 41,
18
+ /** Pupil y-radius / eye y-radius. */
19
+ pupilY: 24 / 47
20
+ };
21
+ /** How much of the free space inside the eye white the pupil may use. */
22
+ const PUPIL_TRAVEL = .9;
23
+ /** How far the lid comes down at a full `slit` look, as a share of the eye height. */
24
+ const LID_DROP = .46;
25
+ /** The eye never renders thinner than this share of its height, so a blink stays visible. */
26
+ const MIN_OPEN = .09;
27
+ const SMILE_STROKE = .5;
28
+ /** At a full `wide` look the eye grows by this share and the pupil shrinks to this share. */
29
+ const WIDE_EYE = .1;
30
+ const round = (value) => Math.round(value * 100) / 100;
31
+ const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
32
+ /** An ellipse, optionally with everything above `cutY` removed. `null` when nothing is left. */
33
+ const ellipsePath = (cx, cy, rx, ry, cutY) => {
34
+ if (cutY === void 0 || cutY <= cy - ry) return `M${round(cx - rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 1 ${round(cx + rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 1 ${round(cx - rx)} ${round(cy)}Z`;
35
+ if (cutY >= cy + ry) return null;
36
+ const half = rx * Math.sqrt(1 - ((cutY - cy) / ry) ** 2);
37
+ return `M${round(cx - half)} ${round(cutY)}A${round(rx)} ${round(ry)} 0 ${cutY < cy ? 1 : 0} 0 ${round(cx + half)} ${round(cutY)}Z`;
38
+ };
39
+ /**
40
+ * Draw one eye in its face plane. `side` is -1 for the left eye and 1 for the right. A change to
41
+ * or from the happy arc closes the open eye first and then draws the arc.
42
+ */
43
+ const drawEye = (cx, cy, baseRx, side, pose) => {
44
+ const wide = clamp(pose.wide ?? 0, 0, 1);
45
+ const rx = baseRx * (1 + WIDE_EYE * wide);
46
+ const ry = rx * LOGO_EYE.aspect;
47
+ const arc = clamp(pose.arc, 0, 1);
48
+ if (arc >= .5) {
49
+ const k = (arc - .5) * 2;
50
+ const halfWidth = rx * .82;
51
+ return {
52
+ pupil: null,
53
+ sclera: null,
54
+ smile: `M${round(cx - halfWidth)} ${round(cy + ry * .24)}Q${round(cx)} ${round(cy + ry * (.24 - .92 * k))} ${round(cx + halfWidth)} ${round(cy + ry * .24)}`,
55
+ smileWidth: round(rx * SMILE_STROKE)
56
+ };
57
+ }
58
+ const openRy = ry * Math.max(MIN_OPEN, (1 - clamp(pose.blink, 0, 1)) * (1 - clamp(pose.squint, 0, 1) * .4) * (1 - arc * 2));
59
+ const eyeY = cy + (ry - openRy) * .18;
60
+ const slit = clamp(pose.slit, 0, 1);
61
+ const cutY = slit > 0 ? eyeY - openRy + 2 * openRy * LID_DROP * slit : void 0;
62
+ const pupilScale = 1 + -.4 * wide;
63
+ const pupilRx = rx * LOGO_EYE.pupilX * pupilScale;
64
+ const pupilRy = openRy * LOGO_EYE.pupilY * pupilScale;
65
+ const freeX = rx - pupilRx;
66
+ const freeY = openRy - pupilRy;
67
+ let dx = -side * rx * LOGO_EYE.lookIn * (1 - wide) + pose.gazeX * freeX * PUPIL_TRAVEL;
68
+ let dy = openRy * LOGO_EYE.lookDown * (1 - wide) + pose.gazeY * freeY * PUPIL_TRAVEL;
69
+ const reach = Math.hypot(dx / freeX, dy / Math.max(freeY, .01));
70
+ if (reach > PUPIL_TRAVEL) {
71
+ dx *= PUPIL_TRAVEL / reach;
72
+ dy *= PUPIL_TRAVEL / reach;
73
+ }
74
+ return {
75
+ pupil: ellipsePath(cx + dx, eyeY + dy, pupilRx, pupilRy, cutY),
76
+ sclera: ellipsePath(cx, eyeY, rx, openRy, cutY),
77
+ smile: null,
78
+ smileWidth: 0
79
+ };
80
+ };
81
+ export { LOGO_EYE, drawEye, ellipsePath };
82
+
83
+ //# sourceMappingURL=eyes.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eyes.mjs","names":[],"sources":["../../src/AgentAvatar/eyes.ts"],"sourcesContent":["/**\n * The eyes of the Lobot logo as geometry: tall white ovals with large black pupils that sit toward\n * the nose and a little low. All ratios are measured from the logo SVG (eye 41 × 47, pupil\n * 21.5 × 24, eye centers 105 apart, pupils 7 in and 7 down).\n */\nexport const LOGO_EYE = {\n /** Eye height / width. */\n aspect: 47 / 41,\n /** Distance between eye centers / eye x-radius. */\n gap: 105 / 41,\n /** Resting pupil offset toward the nose / eye x-radius. */\n lookIn: 7 / 41,\n /** Resting pupil offset downward / eye y-radius. */\n lookDown: 7 / 47,\n /** Pupil x-radius / eye x-radius. */\n pupilX: 21.5 / 41,\n /** Pupil y-radius / eye y-radius. */\n pupilY: 24 / 47,\n} as const;\n\n/** How much of the free space inside the eye white the pupil may use. */\nconst PUPIL_TRAVEL = 0.9;\n/** How far the lid comes down at a full `slit` look, as a share of the eye height. */\nconst LID_DROP = 0.46;\n/** The eye never renders thinner than this share of its height, so a blink stays visible. */\nconst MIN_OPEN = 0.09;\nconst SMILE_STROKE = 0.5;\n/** At a full `wide` look the eye grows by this share and the pupil shrinks to this share. */\nconst WIDE_EYE = 0.1;\nconst WIDE_PUPIL = 0.6;\n\nconst round = (value: number) => Math.round(value * 100) / 100;\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\n\n/** An ellipse, optionally with everything above `cutY` removed. `null` when nothing is left. */\nexport const ellipsePath = (cx: number, cy: number, rx: number, ry: number, cutY?: number) => {\n if (cutY === undefined || cutY <= cy - ry) {\n return `M${round(cx - rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 1 ${round(cx + rx)} ${round(cy)}A${round(rx)} ${round(ry)} 0 1 1 ${round(cx - rx)} ${round(cy)}Z`;\n }\n if (cutY >= cy + ry) return null;\n const half = rx * Math.sqrt(1 - ((cutY - cy) / ry) ** 2);\n return `M${round(cx - half)} ${round(cutY)}A${round(rx)} ${round(ry)} 0 ${cutY < cy ? 1 : 0} 0 ${round(cx + half)} ${round(cutY)}Z`;\n};\n\nexport interface EyePose {\n /** 0 = open eye, 1 = closed happy arc. */\n arc: number;\n /** 0 = open, 1 = closed. */\n blink: number;\n /** Look direction, -1..1 per axis. */\n gazeX: number;\n gazeY: number;\n /** 0 = open eye, 1 = heavy lid of a waiting avatar. */\n slit: number;\n /** Extra narrowing of this eye, 0..1. */\n squint: number;\n /** 0 = logo eyes, 1 = wide eyes with small pupils (`blocked`). */\n wide?: number;\n}\n\nexport interface EyeDrawing {\n /** Pupil outline, absent while the eye is closed into an arc. */\n pupil: string | null;\n /** Eye white outline, absent while the eye is closed into an arc. */\n sclera: string | null;\n /** Closed smiling arc. */\n smile: string | null;\n /** Stroke width of `smile`. */\n smileWidth: number;\n}\n\n/**\n * Draw one eye in its face plane. `side` is -1 for the left eye and 1 for the right. A change to\n * or from the happy arc closes the open eye first and then draws the arc.\n */\nexport const drawEye = (\n cx: number,\n cy: number,\n baseRx: number,\n side: -1 | 1,\n pose: EyePose,\n): EyeDrawing => {\n const wide = clamp(pose.wide ?? 0, 0, 1);\n const rx = baseRx * (1 + WIDE_EYE * wide);\n const ry = rx * LOGO_EYE.aspect;\n const arc = clamp(pose.arc, 0, 1);\n\n if (arc >= 0.5) {\n const k = (arc - 0.5) * 2;\n const halfWidth = rx * 0.82;\n return {\n pupil: null,\n sclera: null,\n smile: `M${round(cx - halfWidth)} ${round(cy + ry * 0.24)}Q${round(cx)} ${round(cy + ry * (0.24 - 0.92 * k))} ${round(cx + halfWidth)} ${round(cy + ry * 0.24)}`,\n smileWidth: round(rx * SMILE_STROKE),\n };\n }\n\n const open = Math.max(\n MIN_OPEN,\n (1 - clamp(pose.blink, 0, 1)) * (1 - clamp(pose.squint, 0, 1) * 0.4) * (1 - arc * 2),\n );\n const openRy = ry * open;\n // Lids close toward a point a little below the center, as in the logo's low gaze.\n const eyeY = cy + (ry - openRy) * 0.18;\n const slit = clamp(pose.slit, 0, 1);\n const cutY = slit > 0 ? eyeY - openRy + 2 * openRy * LID_DROP * slit : undefined;\n\n const pupilScale = 1 + (WIDE_PUPIL - 1) * wide;\n const pupilRx = rx * LOGO_EYE.pupilX * pupilScale;\n const pupilRy = openRy * LOGO_EYE.pupilY * pupilScale;\n const freeX = rx - pupilRx;\n const freeY = openRy - pupilRy;\n let dx = -side * rx * LOGO_EYE.lookIn * (1 - wide) + pose.gazeX * freeX * PUPIL_TRAVEL;\n let dy = openRy * LOGO_EYE.lookDown * (1 - wide) + pose.gazeY * freeY * PUPIL_TRAVEL;\n // Keep the whole pupil inside the eye white, whatever the resting offset and gaze add up to.\n const reach = Math.hypot(dx / freeX, dy / Math.max(freeY, 0.01));\n if (reach > PUPIL_TRAVEL) {\n dx *= PUPIL_TRAVEL / reach;\n dy *= PUPIL_TRAVEL / reach;\n }\n\n return {\n pupil: ellipsePath(cx + dx, eyeY + dy, pupilRx, pupilRy, cutY),\n sclera: ellipsePath(cx, eyeY, rx, openRy, cutY),\n smile: null,\n smileWidth: 0,\n };\n};\n"],"mappings":";;;;;;AAKA,MAAa,WAAW;;CAEtB,QAAQ,KAAK;;CAEb,KAAK,MAAM;;CAEX,QAAQ,IAAI;;CAEZ,UAAU,IAAI;;CAEd,QAAQ,OAAO;;CAEf,QAAQ,KAAK;AACf;;AAGA,MAAM,eAAe;;AAErB,MAAM,WAAW;;AAEjB,MAAM,WAAW;AACjB,MAAM,eAAe;;AAErB,MAAM,WAAW;AAGjB,MAAM,SAAS,UAAkB,KAAK,MAAM,QAAQ,GAAG,IAAI;AAC3D,MAAM,SAAS,OAAe,KAAa,QAAgB,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,CAAC;;AAG7F,MAAa,eAAe,IAAY,IAAY,IAAY,IAAY,SAAkB;CAC5F,IAAI,SAAS,KAAA,KAAa,QAAQ,KAAK,IACrC,OAAO,IAAI,MAAM,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,SAAS,MAAM,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE,SAAS,MAAM,KAAK,EAAE,EAAE,GAAG,MAAM,EAAE,EAAE;CAEvK,IAAI,QAAQ,KAAK,IAAI,OAAO;CAC5B,MAAM,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,MAAM,OAAO,CAAC;CACvD,OAAO,IAAI,MAAM,KAAK,IAAI,EAAE,GAAG,MAAM,IAAI,EAAE,GAAG,MAAM,EAAE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