import{c as X,e as F}from"./extend-Dkjn-TUj.js";import{MotionConfigContext as H,animate as g}from"motion/react";import{useRef as c,useCallback as d,useEffect as v,useMemo as w,useImperativeHandle as K,use as V,createElement as W}from"react";function q(t){const e=c(t);return e.current=t,d((...r)=>e.current(...r),[])}const P=t=>[typeof t=="object"?t.x:null,typeof t=="object"?t.y:null,typeof t!="object"?t:null],O=(t,e)=>v(t,P(e)),z=(t,e)=>w(t,P(e)),A=["alpha","angle","rotation","x","y","width","height"],B=["scale","pivot","position","skew"],$=[...A,...B],u=t=>{if(t===void 0)return;const e=Object.fromEntries(Object.entries(t).filter(([r])=>!(r in $)));if(Object.keys(e).length!==0)return e};function G(t){return function({initial:e,animate:r,ref:f,transition:b,...x}){const a=c(null);K(f,()=>a.current);const M=c(!0),E=V(H).transition,j=q(n=>{const o=r?.transition,i=r?.transition?.[n],s=b,m=b?.[n],l=E,R=E?.[n];return u(i)??u(o)??u(m)??u(s)??u(R)??u(l)}),I=n=>{const o=x[n],i=c(e?.[n]??o??r?.[n]).current;return z(()=>M.current?i:o,o)},p=c({}),y=d((n,o)=>{var i;(i=p.current)[n]??(i[n]=[]),p.current[n].push(o)},[]),D=d(n=>{p.current[n]?.forEach(o=>o.stop()),p.current[n]=[]},[]),L=d((n,o)=>{if(o===void 0||!a.current)return;const i=j(n);if(typeof o=="object"){const s=a.current?.[n],{x:m,y:l}=o;if(!s)return;m!==void 0&&y(n,g(s,{x:[s.x,m]},i)),l!==void 0&&y(n,g(s,{y:[s.y,l]},i))}else y(n,g(a.current,{[n]:o},i))},[j]),C=c({});for(const n of $)C.current[n]=I(n),O(()=>()=>D(n),x[n]),O(()=>L(n,r?.[n]),r?.[n]);return v(()=>{M.current=!1},[]),W(t,{...x,...C.current,ref:a})}}const h=new Proxy({},{get(t,e){if(!(e in t))throw e in X?new Error(`${e} is part of the PIXI namespace, but is not part of the motion namespace! Did you forget to extendMotion?`):new Error(`${e} is not part of the motion namespace! Did you forget to extendMotion?`);return t[e]},set(t,e,r){if(typeof e=="string"){const f=G(`pixi${e}`);t[e.toLowerCase()]=f,t[`pixi${e}`]=f}else t[e]=r;return!0}});function k(t){Object.assign(h,t),F(t)}function J(t){w(()=>{k(t)},[t])}export{h as default,k as extendMotion,h as pixiMotion,J as useExtendMotion};
//# sourceMappingURL=pixi-react.min2.mjs.map
