@lobehub/ui 6.13.1 → 6.14.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.
- package/es/AgentAvatar/AgentAvatar.mjs +21 -11
- package/es/AgentAvatar/AgentAvatar.mjs.map +1 -1
- package/es/AgentAvatar/shapes.mjs +7 -5
- package/es/AgentAvatar/shapes.mjs.map +1 -1
- package/es/AgentAvatar/style.mjs +5 -2
- package/es/AgentAvatar/style.mjs.map +1 -1
- package/es/AgentAvatar/type.d.mts +6 -0
- package/es/AgentAvatar/utils.d.mts +3 -1
- package/es/AgentAvatar/utils.mjs +3 -2
- package/es/AgentAvatar/utils.mjs.map +1 -1
- package/es/AutoComplete/style.d.mts +1 -1
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ const THOUGHT_DOTS = [
|
|
|
49
49
|
4.5
|
|
50
50
|
]
|
|
51
51
|
];
|
|
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, ...rest }) => {
|
|
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
53
|
const id = useId().replaceAll(/[^\w-]/g, "");
|
|
54
54
|
const { isDarkMode } = useThemeMode();
|
|
55
55
|
const reducedMotion = useReducedMotion();
|
|
@@ -127,6 +127,9 @@ const AgentAvatar = memo(({ "animated": animatedProp = false, "aria-label": aria
|
|
|
127
127
|
});
|
|
128
128
|
const [badgeX, badgeY] = geometry.badge;
|
|
129
129
|
const [thoughtX, thoughtY] = geometry.thought;
|
|
130
|
+
const thoughtDirection = geometry.thoughtFlip ? -1 : 1;
|
|
131
|
+
const thoughtHalo = geometry.thoughtHalo ?? true;
|
|
132
|
+
const lean = tilt ? traits.tilt : 0;
|
|
130
133
|
return /* @__PURE__ */ jsxs("svg", {
|
|
131
134
|
"aria-hidden": label ? void 0 : true,
|
|
132
135
|
"aria-label": label,
|
|
@@ -151,24 +154,31 @@ const AgentAvatar = memo(({ "animated": animatedProp = false, "aria-label": aria
|
|
|
151
154
|
...style
|
|
152
155
|
}),
|
|
153
156
|
children: [
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
/* @__PURE__ */ jsx("g", {
|
|
158
|
+
transform: lean ? `rotate(${lean} 50 94)` : void 0,
|
|
159
|
+
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,
|
|
164
|
+
style: customStyles?.body,
|
|
165
|
+
className: styleProps([styles.body], clsx$1(agentAvatarClasses("body"), classNames?.body)).className
|
|
166
|
+
}), eyeLayer]
|
|
167
|
+
})
|
|
162
168
|
}),
|
|
163
169
|
state === "thinking" && /* @__PURE__ */ jsx("g", {
|
|
164
170
|
className: clsx$1(agentAvatarClasses("thought"), classNames?.thought),
|
|
165
171
|
style: customStyles?.thought,
|
|
166
172
|
children: THOUGHT_DOTS.map(([dx, dy, r], index) => /* @__PURE__ */ jsx("circle", {
|
|
167
|
-
|
|
168
|
-
cx: thoughtX + dx,
|
|
173
|
+
cx: thoughtX + dx * thoughtDirection,
|
|
169
174
|
cy: thoughtY + dy,
|
|
170
175
|
opacity: round(.9 - index * .15),
|
|
171
176
|
r,
|
|
177
|
+
className: styleProps([
|
|
178
|
+
styles.thoughtDot,
|
|
179
|
+
thoughtHalo && styles.thoughtHalo,
|
|
180
|
+
motion(styles.thoughtRise)
|
|
181
|
+
]).className,
|
|
172
182
|
style: animated ? { animationDelay: `calc(var(--lobe-agent-avatar-delay, 0s) + ${round(index * .35)}s)` } : void 0
|
|
173
183
|
}, r))
|
|
174
184
|
}),
|
|
@@ -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 ...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\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\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 {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 className={styleProps([styles.thoughtDot, motion(styles.thoughtRise)]).className}\n cx={thoughtX + dx}\n cy={thoughtY + dy}\n key={r}\n opacity={round(0.9 - index * 0.15)}\n r={r}\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,cAA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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, 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;AAClB;AAEA,MAAM,eAAe;CACnB,MAAM,OAAO;CACb,UAAU,OAAO;CACjB,SAAS,OAAO;CAChB,SAAS,OAAO;AAClB;AAEA,MAAM,cAAc;CAClB,MAAM,OAAO;CACb,UAAU,OAAO;CACjB,SAAS,OAAO;AAClB;;AAGA,MAAM,eAA2C;CAC/C;EAAC;EAAG;EAAG;CAAG;CACV;EAAC;EAAI;EAAG;CAAG;CACX;EAAC;EAAI;EAAI;CAAG;AACd;AAEA,MAAM,cAAc,MACjB,EACC,YAAY,eAAe,OAC3B,cAAc,WACd,WACA,YACA,SAAS,WACT,MACA,KACA,MACA,SAAS,WACT,MACA,QAAQ,QACR,OACA,UAAU,cACV,OAAO,MACP,GAAG,WACC;CACJ,MAAM,KAAK,MAAM,CAAC,CAAC,WAAW,WAAW,EAAE;CAC3C,MAAM,EAAE,eAAe,aAAa;CACpC,MAAM,gBAAgB,iBAAiB;CACvC,MAAM,WAAW,gBAAgB,CAAC;CAElC,MAAM,SAAS,qBAAqB,QAAQ,QAAQ,EAAE;CACtD,MAAM,QAAQ,aAAa,OAAO;CAClC,MAAM,WAAW,aAAa,OAAO;CACrC,MAAM,WAAW,mBAAmB,QAAQ;CAC5C,MAAM,QAAQ,WACV,0BAA0B,SAAS,CAAC,aAAa,SAAS,WAC1D;CAEJ,MAAM,WAAW,eAAe;CAChC,MAAM,EAAE,KAAK,GAAG,YAAY,GAAG,SAAS,SAAS;CACjD,MA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ANN,UAAA;KASE,oBAAC,UAAD;MACE,WAAW,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;MAC1C,IAAI;MACJ,IAAI;MACJ,GAAG;KACJ,CAAA;KACD,oBAAC,UAAD;MACE,WAAW,WAAW,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC;MACzC,IAAI;MACJ,IAAI;MACJ,GAAG;KACJ,CAAA;KACD,oBAAC,QAAD;MACE,WAAW,WAAW,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;MAC1C,QAAQ;MACR,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"}
|
|
@@ -116,14 +116,16 @@ const SHAPE_GEOMETRY = {
|
|
|
116
116
|
thought: [70, 2]
|
|
117
117
|
},
|
|
118
118
|
cat: {
|
|
119
|
-
badge: [91,
|
|
119
|
+
badge: [91, 91],
|
|
120
120
|
d: "M12 57A38 38 0 1 1 88 57A38 38 0 1 1 12 57ZM19 40L17 12Q17 6 22.5 8.5L44 21ZM56 21L77.5 8.5Q83 6 83 12L81 40Z",
|
|
121
121
|
eyes: {
|
|
122
122
|
gap: 30,
|
|
123
123
|
r: 14,
|
|
124
124
|
y: 56
|
|
125
125
|
},
|
|
126
|
-
thought: [
|
|
126
|
+
thought: [48, 0],
|
|
127
|
+
thoughtFlip: true,
|
|
128
|
+
thoughtHalo: false
|
|
127
129
|
},
|
|
128
130
|
cloud: {
|
|
129
131
|
badge: [88, 14],
|
|
@@ -156,7 +158,7 @@ const SHAPE_GEOMETRY = {
|
|
|
156
158
|
thought: [70, 2]
|
|
157
159
|
},
|
|
158
160
|
ghost: {
|
|
159
|
-
badge: [
|
|
161
|
+
badge: [91, 9],
|
|
160
162
|
d: ghostPath(),
|
|
161
163
|
eyes: {
|
|
162
164
|
gap: 29,
|
|
@@ -176,7 +178,7 @@ const SHAPE_GEOMETRY = {
|
|
|
176
178
|
thought: [70, 2]
|
|
177
179
|
},
|
|
178
180
|
pudding: {
|
|
179
|
-
badge: [91,
|
|
181
|
+
badge: [91, 9],
|
|
180
182
|
d: "M30 14H70Q79 14 81 23Q87 50 93 80Q95 92 83 92H17Q5 92 7 80Q13 50 19 23Q21 14 30 14Z",
|
|
181
183
|
eyes: {
|
|
182
184
|
gap: 29,
|
|
@@ -186,7 +188,7 @@ const SHAPE_GEOMETRY = {
|
|
|
186
188
|
thought: [70, 2]
|
|
187
189
|
},
|
|
188
190
|
shield: {
|
|
189
|
-
badge: [91,
|
|
191
|
+
badge: [91, 9],
|
|
190
192
|
d: "M18 18Q18 8 28 8H72Q82 8 82 18L88 48Q90 72 50 94Q10 72 12 48Z",
|
|
191
193
|
eyes: {
|
|
192
194
|
gap: 26,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shapes.mjs","names":[],"sources":["../../src/AgentAvatar/shapes.ts"],"sourcesContent":["/**\n * Silhouette and eye geometry on a 100 × 100 canvas. Every silhouette fits the 6–94 box and\n * shares the same construction: a flat body plus the big logo eyes, no mouth, no backing plate.\n */\nimport type { AgentAvatarShape } from './type';\n\ntype Point = [number, number];\n\nconst round = (value: number) => Math.round(value * 100) / 100;\n\nconst polygon = (points: Point[]) =>\n `M${points.map(([x, y]) => `${round(x)} ${round(y)}`).join('L')}Z`;\n\n/** Closed curve sampled from a polar radius function around (cx, cy). */\nconst polar = (radius: (angle: number) => number, cx = 50, cy = 50, steps = 240) =>\n polygon(\n Array.from({ length: steps }, (_, index) => {\n const angle = (index / steps) * Math.PI * 2;\n const r = radius(angle);\n return [cx + r * Math.cos(angle), cy + r * Math.sin(angle)];\n }),\n );\n\nconst superellipse = (cx: number, cy: number, a: number, b: number, n: number) =>\n polygon(\n Array.from({ length: 120 }, (_, index) => {\n const angle = (index / 120) * Math.PI * 2;\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n return [\n cx + a * Math.sign(cos) * Math.abs(cos) ** (2 / n),\n cy + b * Math.sign(sin) * Math.abs(sin) ** (2 / n),\n ];\n }),\n );\n\n/** The LobeHub logo face: a ball cut flat at the top, with a slightly domed top edge. */\nconst facePath = () => {\n const r = 44;\n const cx = 50;\n const cy = 40.5;\n const cut = 15.5;\n const fillet = 0.24;\n const inset = 9;\n const a0 = Math.asin((cy - cut) / r);\n const at = (angle: number): Point => [cx + r * Math.cos(angle), cy - r * Math.sin(angle)];\n const [rx, ry] = at(a0 - fillet);\n const [lx, ly] = at(Math.PI - a0 + fillet);\n const hx = Math.sqrt(r * r - (cy - cut) ** 2);\n return `M${round(cx - hx + inset)} ${cut}Q${cx} ${cut - 1.5} ${round(cx + hx - inset)} ${cut}Q${round(cx + hx)} ${cut} ${round(rx)} ${round(ry)}A${r} ${r} 0 1 1 ${round(lx)} ${round(ly)}Q${round(cx - hx)} ${cut} ${round(cx - hx + inset)} ${cut}Z`;\n};\n\n/** Flat top with rounded corners and a U-shaped superellipse bottom. */\nconst bowlPath = () => {\n const n = 2.6;\n const points: string[] = [];\n for (let index = 1; index <= 40; index++) {\n const angle = (index / 40) * Math.PI;\n const cos = Math.cos(angle);\n points.push(\n `${round(50 + 41 * Math.sign(cos) * Math.abs(cos) ** (2 / n))} ${round(52 + 42 * Math.sin(angle) ** (2 / n))}`,\n );\n }\n return `M6 30Q6 14 22 14H78Q94 14 94 30L91 52L${points.join('L')}L6 30Z`;\n};\n\n/** Outline of the union of three circles, sampled by casting rays from the center. */\nconst cloudPath = () => {\n const circles: [number, number, number][] = [\n [34, 54, 30],\n [66, 54, 30],\n [50, 34, 27],\n ];\n const points: Point[] = [];\n for (let index = 0; index < 180; index++) {\n const angle = (index / 180) * Math.PI * 2 - Math.PI / 2;\n const dx = Math.cos(angle);\n const dy = Math.sin(angle);\n let far = 0;\n for (const [cx, cy, r] of circles) {\n const fx = 50 - cx;\n const fy = 50 - cy;\n const b = 2 * (fx * dx + fy * dy);\n const disc = b * b - 4 * (fx * fx + fy * fy - r * r);\n if (disc >= 0) far = Math.max(far, (-b + Math.sqrt(disc)) / 2);\n }\n points.push([50 + far * dx, 50 + far * dy]);\n }\n return polygon(points);\n};\n\nconst hexPath = () => {\n const vertices = Array.from({ length: 6 }, (_, index): Point => {\n const angle = Math.PI / 6 + (index * Math.PI) / 3;\n return [50 + 44 * Math.cos(angle), 50 + 44 * Math.sin(angle)];\n });\n const lerp = (a: Point, b: Point, t: number): Point => [\n a[0] + (b[0] - a[0]) * t,\n a[1] + (b[1] - a[1]) * t,\n ];\n let d = '';\n for (const [index, corner] of vertices.entries()) {\n const start = lerp(corner, vertices[(index + 5) % 6], 0.22);\n const end = lerp(corner, vertices[(index + 1) % 6], 0.22);\n d += `${index === 0 ? 'M' : 'L'}${round(start[0])} ${round(start[1])}Q${round(corner[0])} ${round(corner[1])} ${round(end[0])} ${round(end[1])}`;\n }\n return `${d}Z`;\n};\n\nconst ghostPath = () => {\n let d = 'M14 42A36 36 0 0 1 86 42V84';\n for (let index = 0; index < 3; index++) d += `A12 9 0 0 1 ${86 - (index + 1) * 24} 84`;\n return `${d}Z`;\n};\n\nexport interface AgentAvatarShapeGeometry {\n /**\n * Centre of the `blocked` badge. Picked per shape so the badge never sits on a feature\n * (cat ears, star points) and stays inside the 100×100 canvas.\n */\n badge: Point;\n /** Silhouette path. */\n d: string;\n /** Eyes: center height, sclera radius and the distance between the two eye centers. */\n eyes: { gap: number; r: number; y: number };\n /** Anchor of the `thinking` thought bubbles (bottom-left dot). */\n thought: Point;\n}\n\nexport const SHAPE_GEOMETRY: Record<AgentAvatarShape, AgentAvatarShapeGeometry> = {\n bowl: { badge: [91, 9], d: bowlPath(), eyes: { gap: 34, r: 16, y: 46 }, thought: [70, 2] },\n capsule: {\n badge: [88, 14],\n d: 'M36 20H64A30 30 0 0 1 64 80H36A30 30 0 0 1 36 20Z',\n eyes: { gap: 34, r: 16, y: 49 },\n thought: [70, 2],\n },\n cat: {\n badge: [91, 26],\n d: 'M12 57A38 38 0 1 1 88 57A38 38 0 1 1 12 57ZM19 40L17 12Q17 6 22.5 8.5L44 21ZM56 21L77.5 8.5Q83 6 83 12L81 40Z',\n eyes: { gap: 30, r: 14, y: 56 },\n thought: [70, 2],\n },\n cloud: { badge: [88, 14], d: cloudPath(), eyes: { gap: 34, r: 16, y: 52 }, thought: [70, 2] },\n cookie: {\n badge: [89, 9],\n d: polar((angle) => 39.5 + 4.5 * Math.abs(Math.cos(5 * angle)) ** 0.55, 50, 50, 400),\n eyes: { gap: 31, r: 14.5, y: 48 },\n thought: [70, 2],\n },\n face: { badge: [91, 9], d: facePath(), eyes: { gap: 34, r: 16, y: 42 }, thought: [70, 2] },\n ghost: { badge: [90, 13], d: ghostPath(), eyes: { gap: 29, r: 13.5, y: 46 }, thought: [70, 2] },\n hex: { badge: [89, 13], d: hexPath(), eyes: { gap: 27, r: 12.5, y: 47 }, thought: [70, 2] },\n pudding: {\n badge: [91, 12],\n d: 'M30 14H70Q79 14 81 23Q87 50 93 80Q95 92 83 92H17Q5 92 7 80Q13 50 19 23Q21 14 30 14Z',\n eyes: { gap: 29, r: 13.5, y: 52 },\n thought: [70, 2],\n },\n shield: {\n badge: [91, 12],\n d: 'M18 18Q18 8 28 8H72Q82 8 82 18L88 48Q90 72 50 94Q10 72 12 48Z',\n eyes: { gap: 26, r: 12, y: 42 },\n thought: [70, 2],\n },\n star: {\n badge: [88, 14],\n d: polar((angle) => 45 * (0.76 + 0.24 * Math.abs(Math.cos(2 * angle)) ** 2.2)),\n eyes: { gap: 27, r: 12.5, y: 49 },\n thought: [70, 2],\n },\n tile: {\n badge: [91, 9],\n d: superellipse(50, 50, 42, 42, 5),\n eyes: { gap: 33, r: 15.5, y: 46 },\n thought: [70, 2],\n },\n};\n\n/** Share of the sclera bottom shaved off by the cheek, as in the logo. */\nconst CHEEK = 0.74;\n\n/** Eye white: a circle whose bottom is cut by a shallow arc. */\nexport const scleraPath = (x: number, y: number, r: number) => {\n const cut = y + r * CHEEK;\n const half = Math.sqrt(r * r - (r * CHEEK) ** 2);\n return `M${round(x - half)} ${round(cut)}A${r} ${r} 0 1 1 ${round(x + half)} ${round(cut)}Q${round(x)} ${round(cut - r * 0.2)} ${round(x - half)} ${round(cut)}Z`;\n};\n\n/** Closed \"smiling\" eye arc used by the `done` state. */\nexport const happyEyePath = (x: number, y: number, r: number) => {\n const k = r / 14.5;\n return `M${round(x - 9.5 * k)} ${round(y + 4 * k)}Q${round(x)} ${round(y - 10 * k)} ${round(x + 9.5 * k)} ${round(y + 4 * k)}`;\n};\n"],"mappings":";AAQA,MAAM,SAAS,UAAkB,KAAK,MAAM,QAAQ,GAAG,IAAI;AAE3D,MAAM,WAAW,WACf,IAAI,OAAO,KAAK,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;;AAGlE,MAAM,SAAS,QAAmC,KAAK,IAAI,KAAK,IAAI,QAAQ,QAC1E,QACE,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAAU;CAC1C,MAAM,QAAS,QAAQ,QAAS,KAAK,KAAK;CAC1C,MAAM,IAAI,OAAO,KAAK;CACtB,OAAO,CAAC,KAAK,IAAI,KAAK,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,CAAC;AAC5D,CAAC,CACH;AAEF,MAAM,gBAAgB,IAAY,IAAY,GAAW,GAAW,MAClE,QACE,MAAM,KAAK,EAAE,QAAQ,IAAI,IAAI,GAAG,UAAU;CACxC,MAAM,QAAS,QAAQ,MAAO,KAAK,KAAK;CACxC,MAAM,MAAM,KAAK,IAAI,KAAK;CAC1B,MAAM,MAAM,KAAK,IAAI,KAAK;CAC1B,OAAO,CACL,KAAK,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,IAAI,GAAG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Aa,IAAI,IAAI,IAAI,IAAI,CAAC;EACjC,MAAM;GAAE,KAAK;GAAI,GAAG;GAAM,GAAG;EAAG;EAChC,SAAS,CAAC,IAAI,CAAC;CACjB;AACF;;AAGA,MAAM,QAAQ;;AAGd,MAAa,cAAc,GAAW,GAAW,MAAc;CAC7D,MAAM,MAAM,IAAI,IAAI;CACpB,MAAM,OAAO,KAAK,KAAK,IAAI,KAAK,IAAI,UAAU,CAAC;CAC/C,OAAO,IAAI,MAAM,IAAI,IAAI,EAAE,GAAG,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,MAAM,IAAI,IAAI,EAAE,GAAG,MAAM,GAAG,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,MAAM,IAAI,EAAG,EAAE,GAAG,MAAM,IAAI,IAAI,EAAE,GAAG,MAAM,GAAG,EAAE;AACjK;;AAGA,MAAa,gBAAgB,GAAW,GAAW,MAAc;CAC/D,MAAM,IAAI,IAAI;CACd,OAAO,IAAI,MAAM,IAAI,MAAM,CAAC,EAAE,GAAG,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,IAAI,KAAK,CAAC,EAAE,GAAG,MAAM,IAAI,MAAM,CAAC,EAAE,GAAG,MAAM,IAAI,IAAI,CAAC;AAC7H"}
|
|
1
|
+
{"version":3,"file":"shapes.mjs","names":[],"sources":["../../src/AgentAvatar/shapes.ts"],"sourcesContent":["/**\n * Silhouette and eye geometry on a 100 × 100 canvas. Every silhouette fits the 6–94 box and\n * shares the same construction: a flat body plus the big logo eyes, no mouth, no backing plate.\n */\nimport type { AgentAvatarShape } from './type';\n\ntype Point = [number, number];\n\nconst round = (value: number) => Math.round(value * 100) / 100;\n\nconst polygon = (points: Point[]) =>\n `M${points.map(([x, y]) => `${round(x)} ${round(y)}`).join('L')}Z`;\n\n/** Closed curve sampled from a polar radius function around (cx, cy). */\nconst polar = (radius: (angle: number) => number, cx = 50, cy = 50, steps = 240) =>\n polygon(\n Array.from({ length: steps }, (_, index) => {\n const angle = (index / steps) * Math.PI * 2;\n const r = radius(angle);\n return [cx + r * Math.cos(angle), cy + r * Math.sin(angle)];\n }),\n );\n\nconst superellipse = (cx: number, cy: number, a: number, b: number, n: number) =>\n polygon(\n Array.from({ length: 120 }, (_, index) => {\n const angle = (index / 120) * Math.PI * 2;\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n return [\n cx + a * Math.sign(cos) * Math.abs(cos) ** (2 / n),\n cy + b * Math.sign(sin) * Math.abs(sin) ** (2 / n),\n ];\n }),\n );\n\n/** The LobeHub logo face: a ball cut flat at the top, with a slightly domed top edge. */\nconst facePath = () => {\n const r = 44;\n const cx = 50;\n const cy = 40.5;\n const cut = 15.5;\n const fillet = 0.24;\n const inset = 9;\n const a0 = Math.asin((cy - cut) / r);\n const at = (angle: number): Point => [cx + r * Math.cos(angle), cy - r * Math.sin(angle)];\n const [rx, ry] = at(a0 - fillet);\n const [lx, ly] = at(Math.PI - a0 + fillet);\n const hx = Math.sqrt(r * r - (cy - cut) ** 2);\n return `M${round(cx - hx + inset)} ${cut}Q${cx} ${cut - 1.5} ${round(cx + hx - inset)} ${cut}Q${round(cx + hx)} ${cut} ${round(rx)} ${round(ry)}A${r} ${r} 0 1 1 ${round(lx)} ${round(ly)}Q${round(cx - hx)} ${cut} ${round(cx - hx + inset)} ${cut}Z`;\n};\n\n/** Flat top with rounded corners and a U-shaped superellipse bottom. */\nconst bowlPath = () => {\n const n = 2.6;\n const points: string[] = [];\n for (let index = 1; index <= 40; index++) {\n const angle = (index / 40) * Math.PI;\n const cos = Math.cos(angle);\n points.push(\n `${round(50 + 41 * Math.sign(cos) * Math.abs(cos) ** (2 / n))} ${round(52 + 42 * Math.sin(angle) ** (2 / n))}`,\n );\n }\n return `M6 30Q6 14 22 14H78Q94 14 94 30L91 52L${points.join('L')}L6 30Z`;\n};\n\n/** Outline of the union of three circles, sampled by casting rays from the center. */\nconst cloudPath = () => {\n const circles: [number, number, number][] = [\n [34, 54, 30],\n [66, 54, 30],\n [50, 34, 27],\n ];\n const points: Point[] = [];\n for (let index = 0; index < 180; index++) {\n const angle = (index / 180) * Math.PI * 2 - Math.PI / 2;\n const dx = Math.cos(angle);\n const dy = Math.sin(angle);\n let far = 0;\n for (const [cx, cy, r] of circles) {\n const fx = 50 - cx;\n const fy = 50 - cy;\n const b = 2 * (fx * dx + fy * dy);\n const disc = b * b - 4 * (fx * fx + fy * fy - r * r);\n if (disc >= 0) far = Math.max(far, (-b + Math.sqrt(disc)) / 2);\n }\n points.push([50 + far * dx, 50 + far * dy]);\n }\n return polygon(points);\n};\n\nconst hexPath = () => {\n const vertices = Array.from({ length: 6 }, (_, index): Point => {\n const angle = Math.PI / 6 + (index * Math.PI) / 3;\n return [50 + 44 * Math.cos(angle), 50 + 44 * Math.sin(angle)];\n });\n const lerp = (a: Point, b: Point, t: number): Point => [\n a[0] + (b[0] - a[0]) * t,\n a[1] + (b[1] - a[1]) * t,\n ];\n let d = '';\n for (const [index, corner] of vertices.entries()) {\n const start = lerp(corner, vertices[(index + 5) % 6], 0.22);\n const end = lerp(corner, vertices[(index + 1) % 6], 0.22);\n d += `${index === 0 ? 'M' : 'L'}${round(start[0])} ${round(start[1])}Q${round(corner[0])} ${round(corner[1])} ${round(end[0])} ${round(end[1])}`;\n }\n return `${d}Z`;\n};\n\nconst ghostPath = () => {\n let d = 'M14 42A36 36 0 0 1 86 42V84';\n for (let index = 0; index < 3; index++) d += `A12 9 0 0 1 ${86 - (index + 1) * 24} 84`;\n return `${d}Z`;\n};\n\nexport interface AgentAvatarShapeGeometry {\n /**\n * Centre of the `blocked` badge. The badge does not tilt; the position is picked per shape so\n * it never covers a feature (cat ears, star points) at any seeded tilt and stays inside the\n * 100×100 canvas. On shapes that fill their corners the background ring may cut into a plain\n * edge.\n */\n badge: Point;\n /** Silhouette path. */\n d: string;\n /** Eyes: center height, sclera radius and the distance between the two eye centers. */\n eyes: { gap: number; r: number; y: number };\n /** Anchor of the `thinking` thought bubbles (center of the largest bubble, minus its drop). */\n thought: Point;\n /** Rise towards the top-left instead of the top-right. */\n thoughtFlip?: boolean;\n /**\n * Outline the bubbles with the background color where they cross the silhouette.\n * @default true\n */\n thoughtHalo?: boolean;\n}\n\nexport const SHAPE_GEOMETRY: Record<AgentAvatarShape, AgentAvatarShapeGeometry> = {\n bowl: { badge: [91, 9], d: bowlPath(), eyes: { gap: 34, r: 16, y: 46 }, thought: [70, 2] },\n capsule: {\n badge: [88, 14],\n d: 'M36 20H64A30 30 0 0 1 64 80H36A30 30 0 0 1 36 20Z',\n eyes: { gap: 34, r: 16, y: 49 },\n thought: [70, 2],\n },\n cat: {\n badge: [91, 91],\n d: 'M12 57A38 38 0 1 1 88 57A38 38 0 1 1 12 57ZM19 40L17 12Q17 6 22.5 8.5L44 21ZM56 21L77.5 8.5Q83 6 83 12L81 40Z',\n eyes: { gap: 30, r: 14, y: 56 },\n thought: [48, 0],\n thoughtFlip: true,\n thoughtHalo: false,\n },\n cloud: { badge: [88, 14], d: cloudPath(), eyes: { gap: 34, r: 16, y: 52 }, thought: [70, 2] },\n cookie: {\n badge: [89, 9],\n d: polar((angle) => 39.5 + 4.5 * Math.abs(Math.cos(5 * angle)) ** 0.55, 50, 50, 400),\n eyes: { gap: 31, r: 14.5, y: 48 },\n thought: [70, 2],\n },\n face: { badge: [91, 9], d: facePath(), eyes: { gap: 34, r: 16, y: 42 }, thought: [70, 2] },\n ghost: { badge: [91, 9], d: ghostPath(), eyes: { gap: 29, r: 13.5, y: 46 }, thought: [70, 2] },\n hex: { badge: [89, 13], d: hexPath(), eyes: { gap: 27, r: 12.5, y: 47 }, thought: [70, 2] },\n pudding: {\n badge: [91, 9],\n d: 'M30 14H70Q79 14 81 23Q87 50 93 80Q95 92 83 92H17Q5 92 7 80Q13 50 19 23Q21 14 30 14Z',\n eyes: { gap: 29, r: 13.5, y: 52 },\n thought: [70, 2],\n },\n shield: {\n badge: [91, 9],\n d: 'M18 18Q18 8 28 8H72Q82 8 82 18L88 48Q90 72 50 94Q10 72 12 48Z',\n eyes: { gap: 26, r: 12, y: 42 },\n thought: [70, 2],\n },\n star: {\n badge: [88, 14],\n d: polar((angle) => 45 * (0.76 + 0.24 * Math.abs(Math.cos(2 * angle)) ** 2.2)),\n eyes: { gap: 27, r: 12.5, y: 49 },\n thought: [70, 2],\n },\n tile: {\n badge: [91, 9],\n d: superellipse(50, 50, 42, 42, 5),\n eyes: { gap: 33, r: 15.5, y: 46 },\n thought: [70, 2],\n },\n};\n\n/** Share of the sclera bottom shaved off by the cheek, as in the logo. */\nconst CHEEK = 0.74;\n\n/** Eye white: a circle whose bottom is cut by a shallow arc. */\nexport const scleraPath = (x: number, y: number, r: number) => {\n const cut = y + r * CHEEK;\n const half = Math.sqrt(r * r - (r * CHEEK) ** 2);\n return `M${round(x - half)} ${round(cut)}A${r} ${r} 0 1 1 ${round(x + half)} ${round(cut)}Q${round(x)} ${round(cut - r * 0.2)} ${round(x - half)} ${round(cut)}Z`;\n};\n\n/** Closed \"smiling\" eye arc used by the `done` state. */\nexport const happyEyePath = (x: number, y: number, r: number) => {\n const k = r / 14.5;\n return `M${round(x - 9.5 * k)} ${round(y + 4 * k)}Q${round(x)} ${round(y - 10 * k)} ${round(x + 9.5 * k)} ${round(y + 4 * k)}`;\n};\n"],"mappings":";AAQA,MAAM,SAAS,UAAkB,KAAK,MAAM,QAAQ,GAAG,IAAI;AAE3D,MAAM,WAAW,WACf,IAAI,OAAO,KAAK,CAAC,GAAG,OAAO,GAAG,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE;;AAGlE,MAAM,SAAS,QAAmC,KAAK,IAAI,KAAK,IAAI,QAAQ,QAC1E,QACE,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAAU;CAC1C,MAAM,QAAS,QAAQ,QAAS,KAAK,KAAK;CAC1C,MAAM,IAAI,OAAO,KAAK;CACtB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C;AAC7H"}
|
package/es/AgentAvatar/style.mjs
CHANGED
|
@@ -167,11 +167,14 @@ const styles = {
|
|
|
167
167
|
},
|
|
168
168
|
thoughtDot: {
|
|
169
169
|
kDwRjp: "lb1swbzct",
|
|
170
|
+
kR8GR0: "lb1764fhq",
|
|
171
|
+
k3nNDw: "lb1g0ag68",
|
|
172
|
+
$$css: true
|
|
173
|
+
},
|
|
174
|
+
thoughtHalo: {
|
|
170
175
|
kjVXCG: "lb19ikkms",
|
|
171
176
|
kfJifR: "lb1ip4yf",
|
|
172
177
|
kCrYw0: "lb1x0jnz8",
|
|
173
|
-
kR8GR0: "lb1764fhq",
|
|
174
|
-
k3nNDw: "lb1g0ag68",
|
|
175
178
|
$$css: true
|
|
176
179
|
},
|
|
177
180
|
thoughtRise: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.mjs","names":[],"sources":["../../src/AgentAvatar/style.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nconst reducedMotion = '@media (prefers-reduced-motion: reduce)';\n\nconst bodyIdle = stylex.keyframes({\n '0%, 100%': { transform: 'scale(1, 1)' },\n '50%': { transform: 'scale(1.015, 0.982)' },\n});\nconst bodyWorking = stylex.keyframes({\n '0%, 100%': { transform: 'translate(0, 0)' },\n '50%': { transform: 'translate(0, -1.6px)' },\n});\nconst bodyWaiting = stylex.keyframes({\n '0%, 100%': { transform: 'rotate(0deg)' },\n '25%': { transform: 'rotate(-4deg)' },\n '75%': { transform: 'rotate(4deg)' },\n});\nconst bodyBlocked = stylex.keyframes({\n '0%, 24%, 100%': { transform: 'translate(0, 0)' },\n '6%': { transform: 'translate(-1.8px, 0)' },\n '12%': { transform: 'translate(1.8px, 0)' },\n '18%': { transform: 'translate(-1px, 0)' },\n});\nconst bodyThinking = stylex.keyframes({\n '0%, 100%': { transform: 'rotate(-2deg)' },\n '50%': { transform: 'rotate(0deg)' },\n});\nconst bodyDone = stylex.keyframes({\n '0%, 32%, 100%': { transform: 'translate(0, 0) scale(1, 1)' },\n '8%': { transform: 'translate(0, 1px) scale(1.05, 0.93)' },\n '18%': { transform: 'translate(0, -5px) scale(0.97, 1.04)' },\n '26%': { transform: 'translate(0, 0.5px) scale(1.04, 0.95)' },\n});\n\nconst blinkIdle = stylex.keyframes({\n '0%, 30%, 35%, 82%, 87%, 100%': { transform: 'scale(1, 1)' },\n '32.5%, 84.5%': { transform: 'scale(1, 0.08)' },\n});\nconst blinkWorking = stylex.keyframes({\n '0%, 90%, 95%, 100%': { transform: 'scale(1, 1)' },\n '92.5%': { transform: 'scale(1, 0.08)' },\n});\nconst blinkWaiting = stylex.keyframes({\n '0%, 60%, 65%, 100%': { transform: 'scale(1, 1)' },\n '62.5%': { transform: 'scale(1, 0.08)' },\n});\nconst blinkThinking = stylex.keyframes({\n '0%, 45%, 50%, 100%': { transform: 'scale(1, 1)' },\n '47.5%': { transform: 'scale(1, 0.08)' },\n});\n\nconst gazeIdle = stylex.keyframes({\n '0%, 100%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 0px), calc(var(--lobe-agent-avatar-gaze) * 1.6px))',\n },\n '18%, 40%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * -3px), calc(var(--lobe-agent-avatar-gaze) * 1px))',\n },\n '62%, 84%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 3px), calc(var(--lobe-agent-avatar-gaze) * 0.6px))',\n },\n});\nconst gazeWorking = stylex.keyframes({\n '0%, 90%, 100%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * -3.2px), calc(var(--lobe-agent-avatar-gaze) * 3.4px))',\n },\n '40%, 50%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 3.2px), calc(var(--lobe-agent-avatar-gaze) * 3.4px))',\n },\n});\n// Kept inside the eye white: the pupil top stays ~15% of the radius below the sclera edge.\nconst gazeThinking = stylex.keyframes({\n '0%, 100%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 1.8px), calc(var(--lobe-agent-avatar-gaze) * -3.1px))',\n },\n '50%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * -1px), calc(var(--lobe-agent-avatar-gaze) * -3.4px))',\n },\n});\n\nconst eyesOpenLate = stylex.keyframes({\n '0%': { opacity: 0 },\n '75%, 100%': { opacity: 1 },\n});\nconst eyesClosedEarly = stylex.keyframes({\n '0%': { opacity: 1 },\n '75%, 100%': { opacity: 0 },\n});\n\nconst thoughtRise = stylex.keyframes({\n '0%': { opacity: 0, transform: 'translate(0, 6px) scale(0)' },\n '20%': { opacity: 0.95 },\n '25%': { transform: 'translate(0, 2.5px) scale(1)' },\n '70%': { opacity: 0.7, transform: 'translate(0, -3.8px) scale(0.9)' },\n '100%': { opacity: 0, transform: 'translate(0, -8px) scale(0)' },\n});\n\nconst badgeBounce = stylex.keyframes({\n '0%, 16%, 100%': { transform: 'translate(0, 0)' },\n '8%': { transform: 'translate(0, -2px)' },\n});\n\nexport const styles = stylex.create({\n badgeDot: {\n fill: cssVar.colorError,\n },\n badgeMark: {\n fill: cssVar.colorTextLightSolid,\n },\n badgeMotion: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.5s',\n animationIterationCount: 'infinite',\n animationName: { default: badgeBounce, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n badgeRing: {\n fill: cssVar.colorBgContainer,\n },\n blinkIdle: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '6s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkIdle, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n blinkThinking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkThinking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n blinkWaiting: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkWaiting, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n blinkWorking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkWorking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n body: {\n fill: 'var(--lobe-agent-avatar-color)',\n },\n bodyBlocked: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.5s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyBlocked, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyDone: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyDone, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyIdle: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyIdle, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyMotion: {\n transformBox: 'view-box',\n transformOrigin: '50px 94px',\n },\n bodyThinking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyThinking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyWaiting: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyWaiting, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyWorking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '0.75s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyWorking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n eyes: {\n transformBox: 'view-box',\n },\n eyesClosedEarly: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: eyesClosedEarly, [reducedMotion]: 'none' },\n animationTimingFunction: 'steps(1, end)',\n },\n eyesOpenLate: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: eyesOpenLate, [reducedMotion]: 'none' },\n animationTimingFunction: 'steps(1, end)',\n },\n gazeIdle: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '6s',\n animationIterationCount: 'infinite',\n animationName: { default: gazeIdle, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n gazeThinking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: gazeThinking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n gazeWorking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.5s',\n animationIterationCount: 'infinite',\n animationName: { default: gazeWorking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n pupils: {\n transformBox: 'view-box',\n },\n root: {\n flex: 'none',\n overflow: 'visible',\n display: 'block',\n height: 40,\n width: 40,\n },\n thoughtDot: {\n fill: 'var(--lobe-agent-avatar-color)',\n stroke: cssVar.colorBgContainer,\n strokeWidth: 2.5,\n // A background halo keeps the bubbles readable where they cross ears or corners.\n paintOrder: 'stroke',\n transformBox: 'fill-box',\n transformOrigin: 'center',\n },\n thoughtRise: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.8s',\n animationIterationCount: 'infinite',\n animationName: { default: thoughtRise, [reducedMotion]: 'none' },\n animationTimingFunction: 'linear',\n },\n});\n"],"mappings":";AAsBA,MAAa,SAAS;CACpB,UAAU;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,eAAe;EACb,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,OAAO;CACT;CACA,iBAAiB;EACf,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,UAAU;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,cAAc;EACZ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,QAAQ;EACN,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"style.mjs","names":[],"sources":["../../src/AgentAvatar/style.ts"],"sourcesContent":["import * as stylex from '@stylexjs/stylex';\n\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nconst reducedMotion = '@media (prefers-reduced-motion: reduce)';\n\nconst bodyIdle = stylex.keyframes({\n '0%, 100%': { transform: 'scale(1, 1)' },\n '50%': { transform: 'scale(1.015, 0.982)' },\n});\nconst bodyWorking = stylex.keyframes({\n '0%, 100%': { transform: 'translate(0, 0)' },\n '50%': { transform: 'translate(0, -1.6px)' },\n});\nconst bodyWaiting = stylex.keyframes({\n '0%, 100%': { transform: 'rotate(0deg)' },\n '25%': { transform: 'rotate(-4deg)' },\n '75%': { transform: 'rotate(4deg)' },\n});\nconst bodyBlocked = stylex.keyframes({\n '0%, 24%, 100%': { transform: 'translate(0, 0)' },\n '6%': { transform: 'translate(-1.8px, 0)' },\n '12%': { transform: 'translate(1.8px, 0)' },\n '18%': { transform: 'translate(-1px, 0)' },\n});\nconst bodyThinking = stylex.keyframes({\n '0%, 100%': { transform: 'rotate(-2deg)' },\n '50%': { transform: 'rotate(0deg)' },\n});\nconst bodyDone = stylex.keyframes({\n '0%, 32%, 100%': { transform: 'translate(0, 0) scale(1, 1)' },\n '8%': { transform: 'translate(0, 1px) scale(1.05, 0.93)' },\n '18%': { transform: 'translate(0, -5px) scale(0.97, 1.04)' },\n '26%': { transform: 'translate(0, 0.5px) scale(1.04, 0.95)' },\n});\n\nconst blinkIdle = stylex.keyframes({\n '0%, 30%, 35%, 82%, 87%, 100%': { transform: 'scale(1, 1)' },\n '32.5%, 84.5%': { transform: 'scale(1, 0.08)' },\n});\nconst blinkWorking = stylex.keyframes({\n '0%, 90%, 95%, 100%': { transform: 'scale(1, 1)' },\n '92.5%': { transform: 'scale(1, 0.08)' },\n});\nconst blinkWaiting = stylex.keyframes({\n '0%, 60%, 65%, 100%': { transform: 'scale(1, 1)' },\n '62.5%': { transform: 'scale(1, 0.08)' },\n});\nconst blinkThinking = stylex.keyframes({\n '0%, 45%, 50%, 100%': { transform: 'scale(1, 1)' },\n '47.5%': { transform: 'scale(1, 0.08)' },\n});\n\nconst gazeIdle = stylex.keyframes({\n '0%, 100%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 0px), calc(var(--lobe-agent-avatar-gaze) * 1.6px))',\n },\n '18%, 40%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * -3px), calc(var(--lobe-agent-avatar-gaze) * 1px))',\n },\n '62%, 84%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 3px), calc(var(--lobe-agent-avatar-gaze) * 0.6px))',\n },\n});\nconst gazeWorking = stylex.keyframes({\n '0%, 90%, 100%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * -3.2px), calc(var(--lobe-agent-avatar-gaze) * 3.4px))',\n },\n '40%, 50%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 3.2px), calc(var(--lobe-agent-avatar-gaze) * 3.4px))',\n },\n});\n// Kept inside the eye white: the pupil top stays ~15% of the radius below the sclera edge.\nconst gazeThinking = stylex.keyframes({\n '0%, 100%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * 1.8px), calc(var(--lobe-agent-avatar-gaze) * -3.1px))',\n },\n '50%': {\n transform:\n 'translate(calc(var(--lobe-agent-avatar-gaze) * -1px), calc(var(--lobe-agent-avatar-gaze) * -3.4px))',\n },\n});\n\nconst eyesOpenLate = stylex.keyframes({\n '0%': { opacity: 0 },\n '75%, 100%': { opacity: 1 },\n});\nconst eyesClosedEarly = stylex.keyframes({\n '0%': { opacity: 1 },\n '75%, 100%': { opacity: 0 },\n});\n\nconst thoughtRise = stylex.keyframes({\n '0%': { opacity: 0, transform: 'translate(0, 6px) scale(0)' },\n '20%': { opacity: 0.95 },\n '25%': { transform: 'translate(0, 2.5px) scale(1)' },\n '70%': { opacity: 0.7, transform: 'translate(0, -3.8px) scale(0.9)' },\n '100%': { opacity: 0, transform: 'translate(0, -8px) scale(0)' },\n});\n\nconst badgeBounce = stylex.keyframes({\n '0%, 16%, 100%': { transform: 'translate(0, 0)' },\n '8%': { transform: 'translate(0, -2px)' },\n});\n\nexport const styles = stylex.create({\n badgeDot: {\n fill: cssVar.colorError,\n },\n badgeMark: {\n fill: cssVar.colorTextLightSolid,\n },\n badgeMotion: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.5s',\n animationIterationCount: 'infinite',\n animationName: { default: badgeBounce, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n badgeRing: {\n fill: cssVar.colorBgContainer,\n },\n blinkIdle: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '6s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkIdle, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n blinkThinking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkThinking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n blinkWaiting: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkWaiting, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n blinkWorking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: blinkWorking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n body: {\n fill: 'var(--lobe-agent-avatar-color)',\n },\n bodyBlocked: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.5s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyBlocked, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyDone: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyDone, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyIdle: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyIdle, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyMotion: {\n transformBox: 'view-box',\n transformOrigin: '50px 94px',\n },\n bodyThinking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyThinking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyWaiting: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyWaiting, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n bodyWorking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '0.75s',\n animationIterationCount: 'infinite',\n animationName: { default: bodyWorking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n eyes: {\n transformBox: 'view-box',\n },\n eyesClosedEarly: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: eyesClosedEarly, [reducedMotion]: 'none' },\n animationTimingFunction: 'steps(1, end)',\n },\n eyesOpenLate: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: eyesOpenLate, [reducedMotion]: 'none' },\n animationTimingFunction: 'steps(1, end)',\n },\n gazeIdle: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '6s',\n animationIterationCount: 'infinite',\n animationName: { default: gazeIdle, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n gazeThinking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '3s',\n animationIterationCount: 'infinite',\n animationName: { default: gazeThinking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n gazeWorking: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.5s',\n animationIterationCount: 'infinite',\n animationName: { default: gazeWorking, [reducedMotion]: 'none' },\n animationTimingFunction: 'cubic-bezier(0.45, 0, 0.55, 1)',\n },\n pupils: {\n transformBox: 'view-box',\n },\n root: {\n flex: 'none',\n overflow: 'visible',\n display: 'block',\n height: 40,\n width: 40,\n },\n thoughtDot: {\n fill: 'var(--lobe-agent-avatar-color)',\n transformBox: 'fill-box',\n transformOrigin: 'center',\n },\n // A background halo keeps the bubbles readable where they cross the silhouette.\n thoughtHalo: {\n stroke: cssVar.colorBgContainer,\n strokeWidth: 2.5,\n paintOrder: 'stroke',\n },\n thoughtRise: {\n animationDelay: 'var(--lobe-agent-avatar-delay, 0s)',\n animationDuration: '1.8s',\n animationIterationCount: 'infinite',\n animationName: { default: thoughtRise, [reducedMotion]: 'none' },\n animationTimingFunction: 'linear',\n },\n});\n"],"mappings":";AAsBA,MAAa,SAAS;CACpB,UAAU;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,OAAO;CACT;CACA,WAAW;EACT,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,eAAe;EACb,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QA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;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,QAAQ;EACN,QAAQ;EACR,OAAO;CACT;CACA,MAAM;EACJ,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,YAAY;EACV,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;CACA,aAAa;EACX,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,QAAQ;EACR,OAAO;CACT;AACF"}
|
|
@@ -71,5 +71,11 @@ export interface AgentAvatarProps extends Omit<SVGProps<SVGSVGElement>, 'childre
|
|
|
71
71
|
state?: AgentAvatarState;
|
|
72
72
|
/** Inline styles of the semantic parts. */
|
|
73
73
|
styles?: AgentAvatarStyles;
|
|
74
|
+
/**
|
|
75
|
+
* Lean the body a few degrees (-3° to 3°), derived from the seed like the shape and color, so a
|
|
76
|
+
* group of avatars feels less rigid. The badge and thought bubbles stay upright.
|
|
77
|
+
* @default true
|
|
78
|
+
*/
|
|
79
|
+
tilt?: boolean;
|
|
74
80
|
}
|
|
75
81
|
//# sourceMappingURL=type.d.mts.map
|
|
@@ -7,7 +7,9 @@ export interface AgentAvatarTraits {
|
|
|
7
7
|
/** Animation offset in seconds (negative), so a list of avatars does not blink in sync. */
|
|
8
8
|
phase: number;
|
|
9
9
|
shape: AgentAvatarShape;
|
|
10
|
+
/** Resting lean in degrees, an integer from -3 to 3, rotated around the bottom center. */
|
|
11
|
+
tilt: number;
|
|
10
12
|
}
|
|
11
|
-
/** Shape, color and animation phase derived from a seed. Pure and deterministic. */
|
|
13
|
+
/** Shape, color, tilt and animation phase derived from a seed. Pure and deterministic. */
|
|
12
14
|
export declare const getAgentAvatarTraits: (seed: string) => AgentAvatarTraits;
|
|
13
15
|
//# sourceMappingURL=utils.d.mts.map
|
package/es/AgentAvatar/utils.mjs
CHANGED
|
@@ -86,13 +86,14 @@ const hashSeed = (seed) => {
|
|
|
86
86
|
hash ^= hash >>> 16;
|
|
87
87
|
return hash >>> 0;
|
|
88
88
|
};
|
|
89
|
-
/** Shape, color and animation phase derived from a seed. Pure and deterministic. */
|
|
89
|
+
/** Shape, color, tilt and animation phase derived from a seed. Pure and deterministic. */
|
|
90
90
|
const getAgentAvatarTraits = (seed) => {
|
|
91
91
|
const hash = hashSeed(`${SEED_SALT}${seed}`);
|
|
92
92
|
return {
|
|
93
93
|
color: AGENT_AVATAR_COLORS[(hash >>> 3) % AGENT_AVATAR_COLORS.length],
|
|
94
94
|
phase: -((hash >>> 7) % 3e3 / 1e3),
|
|
95
|
-
shape: AGENT_AVATAR_SHAPES[hash % AGENT_AVATAR_SHAPES.length]
|
|
95
|
+
shape: AGENT_AVATAR_SHAPES[hash % AGENT_AVATAR_SHAPES.length],
|
|
96
|
+
tilt: (hash >>> 11) % 7 - 3
|
|
96
97
|
};
|
|
97
98
|
};
|
|
98
99
|
const isAgentAvatarColor = (color) => AGENT_AVATAR_COLORS.includes(color);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/AgentAvatar/utils.ts"],"sourcesContent":["import gray from '@/color/colors/gray';\nimport orange from '@/color/colors/orange';\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nimport type { AgentAvatarColor, AgentAvatarShape, AgentAvatarState } from './type';\n\nexport const AGENT_AVATAR_SHAPES = [\n 'face',\n 'bowl',\n 'cloud',\n 'tile',\n 'hex',\n 'shield',\n 'pudding',\n 'cookie',\n 'star',\n 'capsule',\n 'ghost',\n 'cat',\n] as const satisfies readonly AgentAvatarShape[];\n\nexport const AGENT_AVATAR_COLORS = [\n 'purple',\n 'orange',\n 'geekblue',\n 'volcano',\n 'magenta',\n 'ink',\n 'gray',\n] as const satisfies readonly AgentAvatarColor[];\n\nexport const AGENT_AVATAR_STATES = [\n 'idle',\n 'working',\n 'waiting',\n 'blocked',\n 'thinking',\n 'done',\n] as const satisfies readonly AgentAvatarState[];\n\n/**\n * Theme color per palette key, one scale step per appearance. The dark steps are lifted so the\n * body keeps at least 3:1 against the dark container background; `ink` and `gray` cannot reuse\n * their light step there because the neutral scale flips to near-white in dark mode.\n */\nexport const AGENT_AVATAR_COLOR_TOKENS: Record<AgentAvatarColor, { dark: string; light: string }> =\n {\n geekblue: { dark: cssVar.geekblue9, light: cssVar.geekblue8 },\n gray: { dark: cssVar.gray10, light: cssVar.gray9 },\n ink: { dark: cssVar.gray7, light: cssVar.gray11 },\n magenta: { dark: cssVar.magenta9, light: cssVar.magenta8 },\n orange: { dark: cssVar.orange9, light: cssVar.orange9 },\n purple: { dark: cssVar.purple9, light: cssVar.purple8 },\n volcano: { dark: cssVar.volcano9, light: cssVar.volcano8 },\n };\n\n/** Logo eyes: warm white and near black, identical for every color and appearance. */\nexport const SCLERA_COLOR = orange.light[2];\nexport const PUPIL_COLOR = gray.light[12];\n\nconst SEED_SALT = 'lh3174:';\n\n/** FNV-1a followed by the murmur3 finalizer: cheap, deterministic and well spread. */\nexport const hashSeed = (seed: string) => {\n let hash = 2_166_136_261;\n for (let index = 0; index < seed.length; index++) {\n hash ^= seed.charCodeAt(index);\n hash = Math.imul(hash, 16_777_619);\n }\n hash ^= hash >>> 16;\n hash = Math.imul(hash, 0x85_EB_CA_6B);\n hash ^= hash >>> 13;\n hash = Math.imul(hash, 0xC2_B2_AE_35);\n hash ^= hash >>> 16;\n return hash >>> 0;\n};\n\nexport interface AgentAvatarTraits {\n color: AgentAvatarColor;\n /** Animation offset in seconds (negative), so a list of avatars does not blink in sync. */\n phase: number;\n shape: AgentAvatarShape;\n}\n\n/** Shape, color and animation phase derived from a seed. Pure and deterministic. */\nexport const getAgentAvatarTraits = (seed: string): AgentAvatarTraits => {\n const hash = hashSeed(`${SEED_SALT}${seed}`);\n return {\n color: AGENT_AVATAR_COLORS[(hash >>> 3) % AGENT_AVATAR_COLORS.length],\n phase: -(((hash >>> 7) % 3000) / 1000),\n shape: AGENT_AVATAR_SHAPES[hash % AGENT_AVATAR_SHAPES.length],\n };\n};\n\nexport const isAgentAvatarColor = (color: string): color is AgentAvatarColor =>\n (AGENT_AVATAR_COLORS as readonly string[]).includes(color);\n\n/** Pupil / sclera radius ratio. */\nexport const PUPIL_RATIO = 0.6;\n/** Smaller pupils at sidebar sizes keep a visible ring of white. */\nexport const PUPIL_RATIO_SMALL = 0.5;\nexport const SMALL_SIZE = 24;\n\n/** Motion values are authored for a sclera radius of 14.5 and scaled per shape. */\nexport const GAZE_UNIT_RADIUS = 14.5;\n\n/**\n * Still pose of the pupils per state, in gaze units. `thinking` looks up but keeps a band of\n * white above the pupil (the keyframes in `style.ts` use the same bound).\n */\nexport const STILL_GAZE: Record<AgentAvatarState, [number, number]> = {\n blocked: [0, 0],\n done: [0, 0],\n idle: [0, 1.6],\n thinking: [1.8, -3.1],\n waiting: [0, 1.4],\n working: [-2, 3.4],\n};\n\n/** `blocked` widens the eyes and shrinks the pupils. */\nexport const BLOCKED_SCLERA_SCALE = 1.1;\nexport const BLOCKED_PUPIL_RATIO = 0.36;\n"],"mappings":";;;;AAMA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAa,4BACX;CACE,UAAU;EAAE,MAAM,OAAO;EAAW,OAAO,OAAO;CAAU;CAC5D,MAAM;EAAE,MAAM,OAAO;EAAQ,OAAO,OAAO;CAAM;CACjD,KAAK;EAAE,MAAM,OAAO;EAAO,OAAO,OAAO;CAAO;CAChD,SAAS;EAAE,MAAM,OAAO;EAAU,OAAO,OAAO;CAAS;CACzD,QAAQ;EAAE,MAAM,OAAO;EAAS,OAAO,OAAO;CAAQ;CACtD,QAAQ;EAAE,MAAM,OAAO;EAAS,OAAO,OAAO;CAAQ;CACtD,SAAS;EAAE,MAAM,OAAO;EAAU,OAAO,OAAO;CAAS;AAC3D;;AAGF,MAAa,eAAe,OAAO,MAAM;AACzC,MAAa,cAAc,KAAK,MAAM;AAEtC,MAAM,YAAY;;AAGlB,MAAa,YAAY,SAAiB;CACxC,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,QAAQ,KAAK,WAAW,KAAK;EAC7B,OAAO,KAAK,KAAK,MAAM,QAAU;CACnC;CACA,QAAQ,SAAS;CACjB,OAAO,KAAK,KAAK,MAAM,UAAa;CACpC,QAAQ,SAAS;CACjB,OAAO,KAAK,KAAK,MAAM,UAAa;CACpC,QAAQ,SAAS;CACjB,OAAO,SAAS;AAClB;;
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/AgentAvatar/utils.ts"],"sourcesContent":["import gray from '@/color/colors/gray';\nimport orange from '@/color/colors/orange';\nimport { cssVar } from '@/styles/stylex/cssVar.stylex';\n\nimport type { AgentAvatarColor, AgentAvatarShape, AgentAvatarState } from './type';\n\nexport const AGENT_AVATAR_SHAPES = [\n 'face',\n 'bowl',\n 'cloud',\n 'tile',\n 'hex',\n 'shield',\n 'pudding',\n 'cookie',\n 'star',\n 'capsule',\n 'ghost',\n 'cat',\n] as const satisfies readonly AgentAvatarShape[];\n\nexport const AGENT_AVATAR_COLORS = [\n 'purple',\n 'orange',\n 'geekblue',\n 'volcano',\n 'magenta',\n 'ink',\n 'gray',\n] as const satisfies readonly AgentAvatarColor[];\n\nexport const AGENT_AVATAR_STATES = [\n 'idle',\n 'working',\n 'waiting',\n 'blocked',\n 'thinking',\n 'done',\n] as const satisfies readonly AgentAvatarState[];\n\n/**\n * Theme color per palette key, one scale step per appearance. The dark steps are lifted so the\n * body keeps at least 3:1 against the dark container background; `ink` and `gray` cannot reuse\n * their light step there because the neutral scale flips to near-white in dark mode.\n */\nexport const AGENT_AVATAR_COLOR_TOKENS: Record<AgentAvatarColor, { dark: string; light: string }> =\n {\n geekblue: { dark: cssVar.geekblue9, light: cssVar.geekblue8 },\n gray: { dark: cssVar.gray10, light: cssVar.gray9 },\n ink: { dark: cssVar.gray7, light: cssVar.gray11 },\n magenta: { dark: cssVar.magenta9, light: cssVar.magenta8 },\n orange: { dark: cssVar.orange9, light: cssVar.orange9 },\n purple: { dark: cssVar.purple9, light: cssVar.purple8 },\n volcano: { dark: cssVar.volcano9, light: cssVar.volcano8 },\n };\n\n/** Logo eyes: warm white and near black, identical for every color and appearance. */\nexport const SCLERA_COLOR = orange.light[2];\nexport const PUPIL_COLOR = gray.light[12];\n\nconst SEED_SALT = 'lh3174:';\n\n/** FNV-1a followed by the murmur3 finalizer: cheap, deterministic and well spread. */\nexport const hashSeed = (seed: string) => {\n let hash = 2_166_136_261;\n for (let index = 0; index < seed.length; index++) {\n hash ^= seed.charCodeAt(index);\n hash = Math.imul(hash, 16_777_619);\n }\n hash ^= hash >>> 16;\n hash = Math.imul(hash, 0x85_EB_CA_6B);\n hash ^= hash >>> 13;\n hash = Math.imul(hash, 0xC2_B2_AE_35);\n hash ^= hash >>> 16;\n return hash >>> 0;\n};\n\nexport interface AgentAvatarTraits {\n color: AgentAvatarColor;\n /** Animation offset in seconds (negative), so a list of avatars does not blink in sync. */\n phase: number;\n shape: AgentAvatarShape;\n /** Resting lean in degrees, an integer from -3 to 3, rotated around the bottom center. */\n tilt: number;\n}\n\n/** Shape, color, tilt and animation phase derived from a seed. Pure and deterministic. */\nexport const getAgentAvatarTraits = (seed: string): AgentAvatarTraits => {\n const hash = hashSeed(`${SEED_SALT}${seed}`);\n return {\n color: AGENT_AVATAR_COLORS[(hash >>> 3) % AGENT_AVATAR_COLORS.length],\n phase: -(((hash >>> 7) % 3000) / 1000),\n shape: AGENT_AVATAR_SHAPES[hash % AGENT_AVATAR_SHAPES.length],\n tilt: ((hash >>> 11) % 7) - 3,\n };\n};\n\nexport const isAgentAvatarColor = (color: string): color is AgentAvatarColor =>\n (AGENT_AVATAR_COLORS as readonly string[]).includes(color);\n\n/** Pupil / sclera radius ratio. */\nexport const PUPIL_RATIO = 0.6;\n/** Smaller pupils at sidebar sizes keep a visible ring of white. */\nexport const PUPIL_RATIO_SMALL = 0.5;\nexport const SMALL_SIZE = 24;\n\n/** Motion values are authored for a sclera radius of 14.5 and scaled per shape. */\nexport const GAZE_UNIT_RADIUS = 14.5;\n\n/**\n * Still pose of the pupils per state, in gaze units. `thinking` looks up but keeps a band of\n * white above the pupil (the keyframes in `style.ts` use the same bound).\n */\nexport const STILL_GAZE: Record<AgentAvatarState, [number, number]> = {\n blocked: [0, 0],\n done: [0, 0],\n idle: [0, 1.6],\n thinking: [1.8, -3.1],\n waiting: [0, 1.4],\n working: [-2, 3.4],\n};\n\n/** `blocked` widens the eyes and shrinks the pupils. */\nexport const BLOCKED_SCLERA_SCALE = 1.1;\nexport const BLOCKED_PUPIL_RATIO = 0.36;\n"],"mappings":";;;;AAMA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,MAAa,sBAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAOA,MAAa,4BACX;CACE,UAAU;EAAE,MAAM,OAAO;EAAW,OAAO,OAAO;CAAU;CAC5D,MAAM;EAAE,MAAM,OAAO;EAAQ,OAAO,OAAO;CAAM;CACjD,KAAK;EAAE,MAAM,OAAO;EAAO,OAAO,OAAO;CAAO;CAChD,SAAS;EAAE,MAAM,OAAO;EAAU,OAAO,OAAO;CAAS;CACzD,QAAQ;EAAE,MAAM,OAAO;EAAS,OAAO,OAAO;CAAQ;CACtD,QAAQ;EAAE,MAAM,OAAO;EAAS,OAAO,OAAO;CAAQ;CACtD,SAAS;EAAE,MAAM,OAAO;EAAU,OAAO,OAAO;CAAS;AAC3D;;AAGF,MAAa,eAAe,OAAO,MAAM;AACzC,MAAa,cAAc,KAAK,MAAM;AAEtC,MAAM,YAAY;;AAGlB,MAAa,YAAY,SAAiB;CACxC,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS;EAChD,QAAQ,KAAK,WAAW,KAAK;EAC7B,OAAO,KAAK,KAAK,MAAM,QAAU;CACnC;CACA,QAAQ,SAAS;CACjB,OAAO,KAAK,KAAK,MAAM,UAAa;CACpC,QAAQ,SAAS;CACjB,OAAO,KAAK,KAAK,MAAM,UAAa;CACpC,QAAQ,SAAS;CACjB,OAAO,SAAS;AAClB;;AAYA,MAAa,wBAAwB,SAAoC;CACvE,MAAM,OAAO,SAAS,GAAG,YAAY,MAAM;CAC3C,OAAO;EACL,OAAO,qBAAqB,SAAS,KAAK,oBAAoB;EAC9D,OAAO,GAAI,SAAS,KAAK,MAAQ;EACjC,OAAO,oBAAoB,OAAO,oBAAoB;EACtD,OAAQ,SAAS,MAAM,IAAK;CAC9B;AACF;AAEA,MAAa,sBAAsB,UAChC,oBAA0C,SAAS,KAAK;;AAG3D,MAAa,cAAc;;AAE3B,MAAa,oBAAoB;;AAIjC,MAAa,mBAAmB;;;;;AAMhC,MAAa,aAAyD;CACpE,SAAS,CAAC,GAAG,CAAC;CACd,MAAM,CAAC,GAAG,CAAC;CACX,MAAM,CAAC,GAAG,GAAG;CACb,UAAU,CAAC,KAAK,IAAI;CACpB,SAAS,CAAC,GAAG,GAAG;CAChB,SAAS,CAAC,IAAI,GAAG;AACnB;;AAGA,MAAa,uBAAuB;AACpC,MAAa,sBAAsB"}
|
|
@@ -41,7 +41,7 @@ declare const styleArrays: {
|
|
|
41
41
|
}> | Readonly<{
|
|
42
42
|
readonly backgroundColor: stylex.StyleXClassNameFor<"backgroundColor", "transparent">;
|
|
43
43
|
readonly cursor: stylex.StyleXClassNameFor<"cursor", "default">;
|
|
44
|
-
readonly display: stylex.StyleXClassNameFor<"display", "
|
|
44
|
+
readonly display: stylex.StyleXClassNameFor<"display", "flex" | "none">;
|
|
45
45
|
}>)[];
|
|
46
46
|
item: Readonly<{
|
|
47
47
|
readonly borderRadius: stylex.StyleXClassNameFor<"borderRadius", string>;
|