"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../context/MotionContext/index.mjs.js"),n=require("../../context/PresenceContext.mjs.js"),o=require("../../utils/use-constant.mjs.js"),s=require("../../../../../motion-dom/dist/es/value/utils/resolve-motion-value.mjs.js"),i=require("../../../../../motion-dom/dist/es/render/utils/is-controlling-variants.mjs.js"),r=require("../../../../../motion-dom/dist/es/render/utils/is-animation-controls.mjs.js"),a=require("../../../../../motion-dom/dist/es/render/utils/resolve-variants.mjs.js");function l(e,t,n,o){const l={},u=o(e,{});for(const e in u)l[e]=s.resolveMotionValue(u[e]);let{initial:c,animate:m}=e;const d=i.isControllingVariants(e),j=i.isVariantNode(e);t&&j&&!d&&!1!==e.inherit&&(void 0===c&&(c=t.initial),void 0===m&&(m=t.animate));let v=!!n&&!1===n.initial;v=v||!1===c;const f=v?m:c;if(f&&"boolean"!=typeof f&&!r.isAnimationControls(f)){const t=Array.isArray(f)?f:[f];for(let n=0;n<t.length;n++){const o=a.resolveVariantFromProps(e,t[n]);if(o){const{transitionEnd:e,transition:t,...n}=o;for(const e in n){let t=n[e];if(Array.isArray(t)){t=t[v?t.length-1:0]}null!==t&&(l[e]=t)}for(const t in e)l[t]=e[t]}}}return l}exports.makeUseVisualState=s=>(i,r)=>{const a=e.useContext(t.MotionContext),u=e.useContext(n.PresenceContext),c=()=>function(e,t,n,o){let{scrapeMotionValuesFromProps:s,createRenderState:i}=e;return{latestValues:l(t,n,o,s),renderState:i()}}(s,i,a,u);return r?c():o.useConstant(c)};
//# sourceMappingURL=use-visual-state.mjs.js.map
