{"version":3,"file":"use-render.mjs","sources":["../../../../src/render/dom/use-render.ts"],"sourcesContent":["\"use client\"\n\nimport { isMotionValue } from \"motion-dom\"\nimport { Fragment, createElement, useMemo } from \"react\"\nimport { MotionProps } from \"../../motion/types\"\nimport { VisualState } from \"../../motion/utils/use-visual-state\"\nimport { HTMLRenderState } from \"../html/types\"\nimport { useHTMLProps } from \"../html/use-props\"\nimport { SVGRenderState } from \"../svg/types\"\nimport { useSVGProps } from \"../svg/use-props\"\nimport { DOMMotionComponents } from \"./types\"\nimport { filterProps } from \"./utils/filter-props\"\nimport { isSVGComponent } from \"./utils/is-svg-component\"\n\nexport function useRender<\n    Props = {},\n    TagName extends keyof DOMMotionComponents | string = \"div\"\n>(\n    Component: TagName | string | React.ComponentType<Props>,\n    props: MotionProps,\n    ref: React.Ref<HTMLElement | SVGElement>,\n    {\n        latestValues,\n    }: VisualState<HTMLElement | SVGElement, HTMLRenderState | SVGRenderState>,\n    isStatic: boolean,\n    forwardMotionProps: boolean = false,\n    isSVG?: boolean\n) {\n    const useVisualProps =\n        (isSVG ?? isSVGComponent(Component)) ? useSVGProps : useHTMLProps\n\n    const visualProps = useVisualProps(\n        props as any,\n        latestValues,\n        isStatic,\n        Component as any\n    )\n    const filteredProps = filterProps(\n        props,\n        typeof Component === \"string\",\n        forwardMotionProps\n    )\n    const elementProps =\n        Component !== Fragment ? { ...filteredProps, ...visualProps, ref } : {}\n\n    /**\n     * If component has been handed a motion value as its child,\n     * memoise its initial value and render that. Subsequent updates\n     * will be handled by the onChange handler\n     */\n    const { children } = props\n    const renderedChildren = useMemo(\n        () => (isMotionValue(children) ? children.get() : children),\n        [children]\n    )\n\n    return createElement<any>(Component, {\n        ...elementProps,\n        children: renderedChildren,\n    })\n}\n"],"names":[],"mappings":";;;;;;;;;AA4BI;AAGA;AAMA;;AAQA;;;;AAIG;AACH;AACA;;AAMI;AACA;AACH;AACL;;"}