"use client"; import { createSlot } from "./chunk-YWBEB5PG.js"; import { require_shim } from "./chunk-TXHHHGR3.js"; import { useCallbackRef, useLayoutEffect2 } from "./chunk-23FVUG5N.js"; import "./chunk-2VUH7NEY.js"; import { require_react_dom } from "./chunk-YF4B4G2L.js"; import { require_jsx_runtime } from "./chunk-2YVA4HRZ.js"; import { require_react } from "./chunk-WUR7D6NS.js"; import { __toESM } from "./chunk-G3PMV62Z.js"; // node_modules/@radix-ui/react-avatar/dist/index.mjs var React3 = __toESM(require_react(), 1); // node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-context/dist/index.mjs var React = __toESM(require_react(), 1); var import_jsx_runtime = __toESM(require_jsx_runtime(), 1); function createContextScope(scopeName, createContextScopeDeps = []) { let defaultContexts = []; function createContext3(rootComponentName, defaultContext) { const BaseContext = React.createContext(defaultContext); BaseContext.displayName = rootComponentName + "Context"; const index = defaultContexts.length; defaultContexts = [...defaultContexts, defaultContext]; const Provider = (props) => { const { scope, children, ...context } = props; const Context = scope?.[scopeName]?.[index] || BaseContext; const value = React.useMemo(() => context, Object.values(context)); return (0, import_jsx_runtime.jsx)(Context.Provider, { value, children }); }; Provider.displayName = rootComponentName + "Provider"; function useContext2(consumerName, scope) { const Context = scope?.[scopeName]?.[index] || BaseContext; const context = React.useContext(Context); if (context) return context; if (defaultContext !== void 0) return defaultContext; throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``); } return [Provider, useContext2]; } const createScope = () => { const scopeContexts = defaultContexts.map((defaultContext) => { return React.createContext(defaultContext); }); return function useScope(scope) { const contexts = scope?.[scopeName] || scopeContexts; return React.useMemo( () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }), [scope, contexts] ); }; }; createScope.scopeName = scopeName; return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)]; } function composeContextScopes(...scopes) { const baseScope = scopes[0]; if (scopes.length === 1) return baseScope; const createScope = () => { const scopeHooks = scopes.map((createScope2) => ({ useScope: createScope2(), scopeName: createScope2.scopeName })); return function useComposedScopes(overrideScopes) { const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => { const scopeProps = useScope(overrideScopes); const currentScope = scopeProps[`__scope${scopeName}`]; return { ...nextScopes2, ...currentScope }; }, {}); return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]); }; }; createScope.scopeName = baseScope.scopeName; return createScope; } // node_modules/@radix-ui/react-avatar/node_modules/@radix-ui/react-primitive/dist/index.mjs var React2 = __toESM(require_react(), 1); var ReactDOM = __toESM(require_react_dom(), 1); var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1); var NODES = [ "a", "button", "div", "form", "h2", "h3", "img", "input", "label", "li", "nav", "ol", "p", "select", "span", "svg", "ul" ]; var Primitive = NODES.reduce((primitive, node) => { const Slot = createSlot(`Primitive.${node}`); const Node = React2.forwardRef((props, forwardedRef) => { const { asChild, ...primitiveProps } = props; const Comp = asChild ? Slot : node; if (typeof window !== "undefined") { window[/* @__PURE__ */ Symbol.for("radix-ui")] = true; } return (0, import_jsx_runtime2.jsx)(Comp, { ...primitiveProps, ref: forwardedRef }); }); Node.displayName = `Primitive.${node}`; return { ...primitive, [node]: Node }; }, {}); // node_modules/@radix-ui/react-use-is-hydrated/dist/index.mjs var import_shim = __toESM(require_shim(), 1); function useIsHydrated() { return (0, import_shim.useSyncExternalStore)( subscribe, () => true, () => false ); } function subscribe() { return () => { }; } // node_modules/@radix-ui/react-avatar/dist/index.mjs var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1); var AVATAR_NAME = "Avatar"; var [createAvatarContext, createAvatarScope] = createContextScope(AVATAR_NAME); var [AvatarProvider, useAvatarContext] = createAvatarContext(AVATAR_NAME); var Avatar = React3.forwardRef( (props, forwardedRef) => { const { __scopeAvatar, ...avatarProps } = props; const [imageLoadingStatus, setImageLoadingStatus] = React3.useState("idle"); return (0, import_jsx_runtime3.jsx)( AvatarProvider, { scope: __scopeAvatar, imageLoadingStatus, onImageLoadingStatusChange: setImageLoadingStatus, children: (0, import_jsx_runtime3.jsx)(Primitive.span, { ...avatarProps, ref: forwardedRef }) } ); } ); Avatar.displayName = AVATAR_NAME; var IMAGE_NAME = "AvatarImage"; var AvatarImage = React3.forwardRef( (props, forwardedRef) => { const { __scopeAvatar, src, onLoadingStatusChange = () => { }, ...imageProps } = props; const context = useAvatarContext(IMAGE_NAME, __scopeAvatar); const imageLoadingStatus = useImageLoadingStatus(src, imageProps); const handleLoadingStatusChange = useCallbackRef((status) => { onLoadingStatusChange(status); context.onImageLoadingStatusChange(status); }); useLayoutEffect2(() => { if (imageLoadingStatus !== "idle") { handleLoadingStatusChange(imageLoadingStatus); } }, [imageLoadingStatus, handleLoadingStatusChange]); return imageLoadingStatus === "loaded" ? (0, import_jsx_runtime3.jsx)(Primitive.img, { ...imageProps, ref: forwardedRef, src }) : null; } ); AvatarImage.displayName = IMAGE_NAME; var FALLBACK_NAME = "AvatarFallback"; var AvatarFallback = React3.forwardRef( (props, forwardedRef) => { const { __scopeAvatar, delayMs, ...fallbackProps } = props; const context = useAvatarContext(FALLBACK_NAME, __scopeAvatar); const [canRender, setCanRender] = React3.useState(delayMs === void 0); React3.useEffect(() => { if (delayMs !== void 0) { const timerId = window.setTimeout(() => setCanRender(true), delayMs); return () => window.clearTimeout(timerId); } }, [delayMs]); return canRender && context.imageLoadingStatus !== "loaded" ? (0, import_jsx_runtime3.jsx)(Primitive.span, { ...fallbackProps, ref: forwardedRef }) : null; } ); AvatarFallback.displayName = FALLBACK_NAME; function resolveLoadingStatus(image, src) { if (!image) { return "idle"; } if (!src) { return "error"; } if (image.src !== src) { image.src = src; } return image.complete && image.naturalWidth > 0 ? "loaded" : "loading"; } function useImageLoadingStatus(src, { referrerPolicy, crossOrigin }) { const isHydrated = useIsHydrated(); const imageRef = React3.useRef(null); const image = (() => { if (!isHydrated) return null; if (!imageRef.current) { imageRef.current = new window.Image(); } return imageRef.current; })(); const [loadingStatus, setLoadingStatus] = React3.useState( () => resolveLoadingStatus(image, src) ); useLayoutEffect2(() => { setLoadingStatus(resolveLoadingStatus(image, src)); }, [image, src]); useLayoutEffect2(() => { const updateStatus = (status) => () => { setLoadingStatus(status); }; if (!image) return; const handleLoad = updateStatus("loaded"); const handleError = updateStatus("error"); image.addEventListener("load", handleLoad); image.addEventListener("error", handleError); if (referrerPolicy) { image.referrerPolicy = referrerPolicy; } if (typeof crossOrigin === "string") { image.crossOrigin = crossOrigin; } return () => { image.removeEventListener("load", handleLoad); image.removeEventListener("error", handleError); }; }, [image, crossOrigin, referrerPolicy]); return loadingStatus; } var Root = Avatar; var Image = AvatarImage; var Fallback = AvatarFallback; export { Avatar, AvatarFallback, AvatarImage, Fallback, Image, Root, createAvatarScope }; //# sourceMappingURL=@radix-ui_react-avatar.js.map