"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=t=>!!e.isValidElement(t)&&(null!==t.key&&("ref"in t&&"object"==typeof t.ref&&null!==t.ref&&"current"in t.ref&&null!==t.ref.current&&"object"==typeof t.ref.current&&"style"in t.ref.current)),r=(e,t,r,{x:n,y:s})=>{requestAnimationFrame((()=>{const i="data-glide",a=`${i}-bak`,o=`${i}-t`,u=(Date.now()+e).toString(),c=((e,t)=>{const r=""!==t.trim(),{classList:n,style:s}=e,i=(t,r)=>e.setAttribute(t,r),a=t=>e.hasAttribute(t),o=t=>e.getAttribute(t),u=t=>e.removeAttribute(t),c=e=>`transform ${e}ms`,l=(e,t)=>{s.transition=e,s.transform=t};return{get:o,set:i,del:u,delWith:(e,t)=>{o(e)===t&&u(e)},classy:e=>{r&&(e?n.add(t):n.remove(t))},backup:e=>{if(a(e))return;const{transform:t,transition:r}=s,n=[r,t];i(e,JSON.stringify(n))},restore:e=>{const t=o(e);if(u(e),"string"!=typeof t)return;const[r,n]=JSON.parse(t);l(r,n)},jump:(e,t)=>{l(c(0),`translate(${e}px, ${t}px)`)},glide:e=>{l(c(e),"")},clearPrior:e=>{if(!a(e))return;const t=o(e);null!==t&&clearTimeout(parseInt(t,10)),u(e)}}})(r,t),l=()=>c.get(i)!==u;c.clearPrior(o),c.backup(a),c.classy(!0),c.set(i,u),c.jump(n,s),requestAnimationFrame((()=>{if(l())return;c.glide(e);const t=setTimeout((()=>{l()||(c.delWith(o,t),c.classy(!1),c.restore(a),c.del(i))}),e).toString();c.set(o,t)}))}))};exports.default=({ms:n=500,className:s="glider",children:i})=>{const[a,o]=e.useState([]);return e.useLayoutEffect((()=>{if(!Array.isArray(i))return;const e=i.filter(t).map(((e,t,n)=>s=>{const{key:i,ref:{current:a}}=s;let o=!0;const{x:u,y:c}=a.getBoundingClientRect(),l=n.find((e=>e.key===i));if(l){const n={x:l.x-u,y:l.y-c};o=0!==n.y||0!==n.x,o&&r(e,t,a,n)}return{key:i,x:u,y:c,changed:o}})(n,s,a));e.some((({changed:e})=>e))&&o(e)}),[i]),i}; //# sourceMappingURL=index.min.cjs.map