@ssgoi/core 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +34 -0
  2. package/dist/animator.d.ts +41 -0
  3. package/dist/animator.d.ts.map +1 -0
  4. package/dist/create-ssgoi-transition-context.d.ts +15 -0
  5. package/dist/create-ssgoi-transition-context.d.ts.map +1 -0
  6. package/dist/create-transition-callback.d.ts +36 -0
  7. package/dist/create-transition-callback.d.ts.map +1 -0
  8. package/dist/index.d.ts +4 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/ssgoi.cjs +1 -0
  11. package/dist/ssgoi.js +1 -0
  12. package/dist/ssgoi2.cjs +1 -0
  13. package/dist/ssgoi2.js +305 -0
  14. package/dist/ssgoi3.cjs +1 -0
  15. package/dist/ssgoi3.js +173 -0
  16. package/dist/ssgoi4.cjs +1 -0
  17. package/dist/ssgoi4.js +764 -0
  18. package/dist/transition.d.ts +16 -0
  19. package/dist/transition.d.ts.map +1 -0
  20. package/dist/transitions/blur.d.ts +27 -0
  21. package/dist/transitions/blur.d.ts.map +1 -0
  22. package/dist/transitions/bounce.d.ts +27 -0
  23. package/dist/transitions/bounce.d.ts.map +1 -0
  24. package/dist/transitions/fade.d.ts +26 -0
  25. package/dist/transitions/fade.d.ts.map +1 -0
  26. package/dist/transitions/index.d.ts +8 -0
  27. package/dist/transitions/index.d.ts.map +1 -0
  28. package/dist/transitions/none.d.ts +24 -0
  29. package/dist/transitions/none.d.ts.map +1 -0
  30. package/dist/transitions/rotate.d.ts +28 -0
  31. package/dist/transitions/rotate.d.ts.map +1 -0
  32. package/dist/transitions/scale.d.ts +27 -0
  33. package/dist/transitions/scale.d.ts.map +1 -0
  34. package/dist/transitions/slide.d.ts +27 -0
  35. package/dist/transitions/slide.d.ts.map +1 -0
  36. package/dist/transitions.d.ts +2 -0
  37. package/dist/types.d.ts +38 -0
  38. package/dist/types.d.ts.map +1 -0
  39. package/dist/utils-BSgyev81.cjs +1 -0
  40. package/dist/utils-DR41YsAh.js +16 -0
  41. package/dist/utils.d.ts +11 -0
  42. package/dist/utils.d.ts.map +1 -0
  43. package/dist/view-transitions/fade.d.ts +7 -0
  44. package/dist/view-transitions/fade.d.ts.map +1 -0
  45. package/dist/view-transitions/hero.d.ts +8 -0
  46. package/dist/view-transitions/hero.d.ts.map +1 -0
  47. package/dist/view-transitions/index.d.ts +5 -0
  48. package/dist/view-transitions/index.d.ts.map +1 -0
  49. package/dist/view-transitions/pinterest.d.ts +8 -0
  50. package/dist/view-transitions/pinterest.d.ts.map +1 -0
  51. package/dist/view-transitions/ripple.d.ts +7 -0
  52. package/dist/view-transitions/ripple.d.ts.map +1 -0
  53. package/dist/view-transitions.d.ts +2 -0
  54. package/package.json +58 -0
  55. package/src/lib/animator.ts +172 -0
  56. package/src/lib/create-ssgoi-transition-context.ts +265 -0
  57. package/src/lib/create-transition-callback.ts +246 -0
  58. package/src/lib/index.ts +3 -0
  59. package/src/lib/transition.ts +76 -0
  60. package/src/lib/transitions/blur.ts +55 -0
  61. package/src/lib/transitions/bounce.ts +61 -0
  62. package/src/lib/transitions/fade.ts +33 -0
  63. package/src/lib/transitions/index.ts +7 -0
  64. package/src/lib/transitions/none.ts +27 -0
  65. package/src/lib/transitions/rotate.ts +57 -0
  66. package/src/lib/transitions/scale.ts +34 -0
  67. package/src/lib/transitions/slide.ts +53 -0
  68. package/src/lib/types.ts +60 -0
  69. package/src/lib/utils.ts +39 -0
  70. package/src/lib/view-transitions/fade.ts +29 -0
  71. package/src/lib/view-transitions/hero.ts +179 -0
  72. package/src/lib/view-transitions/index.ts +4 -0
  73. package/src/lib/view-transitions/pinterest.ts +403 -0
  74. package/src/lib/view-transitions/ripple.ts +45 -0
@@ -0,0 +1 @@
1
+ "use strict";var Ct=Object.defineProperty;var Lt=(t,e,n)=>e in t?Ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var v=(t,e,n)=>Lt(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qt=require("./utils-BSgyev81.cjs");function ht(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(t);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(t,r[s])&&(n[r[s]]=t[r[s]]);return n}var Y=function(){},F=function(){};process.env.NODE_ENV!=="production"&&(Y=function(t,e){!t&&typeof console<"u"&&console.warn(e)},F=function(t,e){if(!t)throw new Error(e)});const G=(t,e,n)=>Math.min(Math.max(n,t),e),B=.001,Bt=.01,at=10,_t=.05,Wt=1;function Gt({duration:t=800,bounce:e=.25,velocity:n=0,mass:r=1}){let s,a;Y(t<=at*1e3,"Spring duration must be 10 seconds or less");let o=1-e;o=G(_t,Wt,o),t=G(Bt,at,t/1e3),o<1?(s=c=>{const m=c*o,h=m*t,l=m-n,i=H(c,o),p=Math.exp(-h);return B-l/i*p},a=c=>{const h=c*o*t,l=h*n+n,i=Math.pow(o,2)*Math.pow(c,2)*t,p=Math.exp(-h),d=H(Math.pow(c,2),o);return(-s(c)+B>0?-1:1)*((l-i)*p)/d}):(s=c=>{const m=Math.exp(-c*t),h=(c-n)*t+1;return-B+m*h},a=c=>{const m=Math.exp(-c*t),h=(n-c)*(t*t);return m*h});const u=5/t,f=Kt(s,a,u);if(t=t*1e3,isNaN(f))return{stiffness:100,damping:10,duration:t};{const c=Math.pow(f,2)*r;return{stiffness:c,damping:o*2*Math.sqrt(r*c),duration:t}}}const Ht=12;function Kt(t,e,n){let r=n;for(let s=1;s<Ht;s++)r=r-t(r)/e(r);return r}function H(t,e){return t*Math.sqrt(1-e*e)}const zt=["duration","bounce"],Zt=["stiffness","damping","mass"];function it(t,e){return e.some(n=>t[n]!==void 0)}function Jt(t){let e=Object.assign({velocity:0,stiffness:100,damping:10,mass:1,isResolvedFromDuration:!1},t);if(!it(t,Zt)&&it(t,zt)){const n=Gt(t);e=Object.assign(Object.assign(Object.assign({},e),n),{velocity:0,mass:1}),e.isResolvedFromDuration=!0}return e}function tt(t){var{from:e=0,to:n=1,restSpeed:r=2,restDelta:s}=t,a=ht(t,["from","to","restSpeed","restDelta"]);const o={done:!1,value:e};let{stiffness:u,damping:f,mass:c,velocity:m,duration:h,isResolvedFromDuration:l}=Jt(a),i=lt,p=lt;function d(){const g=m?-(m/1e3):0,y=n-e,b=f/(2*Math.sqrt(u*c)),M=Math.sqrt(u/c)/1e3;if(s===void 0&&(s=Math.min(Math.abs(n-e)/100,.4)),b<1){const x=H(M,b);i=S=>{const w=Math.exp(-b*M*S);return n-w*((g+b*M*y)/x*Math.sin(x*S)+y*Math.cos(x*S))},p=S=>{const w=Math.exp(-b*M*S);return b*M*w*(Math.sin(x*S)*(g+b*M*y)/x+y*Math.cos(x*S))-w*(Math.cos(x*S)*(g+b*M*y)-x*y*Math.sin(x*S))}}else if(b===1)i=x=>n-Math.exp(-M*x)*(y+(g+M*y)*x);else{const x=M*Math.sqrt(b*b-1);i=S=>{const w=Math.exp(-b*M*S),R=Math.min(x*S,300);return n-w*((g+b*M*y)*Math.sinh(R)+x*y*Math.cosh(R))/x}}}return d(),{next:g=>{const y=i(g);if(l)o.done=g>=h;else{const b=p(g)*1e3,M=Math.abs(b)<=r,x=Math.abs(n-y)<=s;o.done=M&&x}return o.value=o.done?n:y,o},flipTarget:()=>{m=-m,[e,n]=[n,e],d()}}}tt.needsInterpolation=(t,e)=>typeof t=="string"||typeof e=="string";const lt=t=>0,dt=(t,e,n)=>{const r=e-t;return r===0?1:(n-t)/r},et=(t,e,n)=>-n*t+n*e+t,gt=(t,e)=>n=>Math.max(Math.min(n,e),t),E=t=>t%1?Number(t.toFixed(5)):t,U=/(-)?([\d]*\.?[\d])+/g,K=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))/gi,Qt=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;function D(t){return typeof t=="string"}const $={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},yt=Object.assign(Object.assign({},$),{transform:gt(0,1)});Object.assign(Object.assign({},$),{default:1});const Xt=t=>({test:e=>D(e)&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}),V=Xt("%");Object.assign(Object.assign({},V),{parse:t=>V.parse(t)/100,transform:t=>V.transform(t*100)});const nt=(t,e)=>n=>!!(D(n)&&Qt.test(n)&&n.startsWith(t)||e&&Object.prototype.hasOwnProperty.call(n,e)),bt=(t,e,n)=>r=>{if(!D(r))return r;const[s,a,o,u]=r.match(U);return{[t]:parseFloat(s),[e]:parseFloat(a),[n]:parseFloat(o),alpha:u!==void 0?parseFloat(u):1}},A={test:nt("hsl","hue"),parse:bt("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:n,alpha:r=1})=>"hsla("+Math.round(t)+", "+V.transform(E(e))+", "+V.transform(E(n))+", "+E(yt.transform(r))+")"},Yt=gt(0,255),_=Object.assign(Object.assign({},$),{transform:t=>Math.round(Yt(t))}),O={test:nt("rgb","red"),parse:bt("red","green","blue"),transform:({red:t,green:e,blue:n,alpha:r=1})=>"rgba("+_.transform(t)+", "+_.transform(e)+", "+_.transform(n)+", "+E(yt.transform(r))+")"};function te(t){let e="",n="",r="",s="";return t.length>5?(e=t.substr(1,2),n=t.substr(3,2),r=t.substr(5,2),s=t.substr(7,2)):(e=t.substr(1,1),n=t.substr(2,1),r=t.substr(3,1),s=t.substr(4,1),e+=e,n+=n,r+=r,s+=s),{red:parseInt(e,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:s?parseInt(s,16)/255:1}}const z={test:nt("#"),parse:te,transform:O.transform},C={test:t=>O.test(t)||z.test(t)||A.test(t),parse:t=>O.test(t)?O.parse(t):A.test(t)?A.parse(t):z.parse(t),transform:t=>D(t)?t:t.hasOwnProperty("red")?O.transform(t):A.transform(t)},xt="${c}",Mt="${n}";function ee(t){var e,n,r,s;return isNaN(t)&&D(t)&&((n=(e=t.match(U))===null||e===void 0?void 0:e.length)!==null&&n!==void 0?n:0)+((s=(r=t.match(K))===null||r===void 0?void 0:r.length)!==null&&s!==void 0?s:0)>0}function St(t){typeof t=="number"&&(t=`${t}`);const e=[];let n=0;const r=t.match(K);r&&(n=r.length,t=t.replace(K,xt),e.push(...r.map(C.parse)));const s=t.match(U);return s&&(t=t.replace(U,Mt),e.push(...s.map($.parse))),{values:e,numColors:n,tokenised:t}}function wt(t){return St(t).values}function Ot(t){const{values:e,numColors:n,tokenised:r}=St(t),s=e.length;return a=>{let o=r;for(let u=0;u<s;u++)o=o.replace(u<n?xt:Mt,u<n?C.transform(a[u]):E(a[u]));return o}}const ne=t=>typeof t=="number"?0:t;function re(t){const e=wt(t);return Ot(t)(e.map(ne))}const vt={test:ee,parse:wt,createTransformer:Ot,getAnimatableNone:re};function W(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+(e-t)*6*n:n<1/2?e:n<2/3?t+(e-t)*(2/3-n)*6:t}function ct({hue:t,saturation:e,lightness:n,alpha:r}){t/=360,e/=100,n/=100;let s=0,a=0,o=0;if(!e)s=a=o=n;else{const u=n<.5?n*(1+e):n+e-n*e,f=2*n-u;s=W(f,u,t+1/3),a=W(f,u,t),o=W(f,u,t-1/3)}return{red:Math.round(s*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}const se=(t,e,n)=>{const r=t*t,s=e*e;return Math.sqrt(Math.max(0,n*(s-r)+r))},oe=[z,O,A],ut=t=>oe.find(e=>e.test(t)),ft=t=>`'${t}' is not an animatable color. Use the equivalent color code instead.`,At=(t,e)=>{let n=ut(t),r=ut(e);F(!!n,ft(t)),F(!!r,ft(e));let s=n.parse(t),a=r.parse(e);n===A&&(s=ct(s),n=O),r===A&&(a=ct(a),r=O);const o=Object.assign({},s);return u=>{for(const f in o)f!=="alpha"&&(o[f]=se(s[f],a[f],u));return o.alpha=et(s.alpha,a.alpha,u),n.transform(o)}},ae=t=>typeof t=="number",ie=(t,e)=>n=>e(t(n)),Rt=(...t)=>t.reduce(ie);function Tt(t,e){return ae(t)?n=>et(t,e,n):C.test(t)?At(t,e):Vt(t,e)}const Et=(t,e)=>{const n=[...t],r=n.length,s=t.map((a,o)=>Tt(a,e[o]));return a=>{for(let o=0;o<r;o++)n[o]=s[o](a);return n}},le=(t,e)=>{const n=Object.assign(Object.assign({},t),e),r={};for(const s in n)t[s]!==void 0&&e[s]!==void 0&&(r[s]=Tt(t[s],e[s]));return s=>{for(const a in r)n[a]=r[a](s);return n}};function pt(t){const e=vt.parse(t),n=e.length;let r=0,s=0,a=0;for(let o=0;o<n;o++)r||typeof e[o]=="number"?r++:e[o].hue!==void 0?a++:s++;return{parsed:e,numNumbers:r,numRGB:s,numHSL:a}}const Vt=(t,e)=>{const n=vt.createTransformer(e),r=pt(t),s=pt(e);return r.numHSL===s.numHSL&&r.numRGB===s.numRGB&&r.numNumbers>=s.numNumbers?Rt(Et(r.parsed,s.parsed),n):(Y(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),o=>`${o>0?e:t}`)},ce=(t,e)=>n=>et(t,e,n);function ue(t){if(typeof t=="number")return ce;if(typeof t=="string")return C.test(t)?At:Vt;if(Array.isArray(t))return Et;if(typeof t=="object")return le}function fe(t,e,n){const r=[],s=n||ue(t[0]),a=t.length-1;for(let o=0;o<a;o++){let u=s(t[o],t[o+1]);if(e){const f=Array.isArray(e)?e[o]:e;u=Rt(f,u)}r.push(u)}return r}function pe([t,e],[n]){return r=>n(dt(t,e,r))}function me(t,e){const n=t.length,r=n-1;return s=>{let a=0,o=!1;if(s<=t[0]?o=!0:s>=t[r]&&(a=r-1,o=!0),!o){let f=1;for(;f<n&&!(t[f]>s||f===r);f++);a=f-1}const u=dt(t[a],t[a+1],s);return e[a](u)}}function jt(t,e,{clamp:n=!0,ease:r,mixer:s}={}){const a=t.length;F(a===e.length,"Both input and output ranges must be the same length"),F(!r||!Array.isArray(r)||r.length===a-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),t[0]>t[a-1]&&(t=[].concat(t),e=[].concat(e),t.reverse(),e.reverse());const o=fe(e,r,s),u=a===2?pe(t,o):me(t,o);return n?f=>u(G(t[0],t[a-1],f)):u}const he=t=>e=>e<=.5?t(2*e)/2:(2-t(2*(1-e)))/2,de=t=>e=>Math.pow(e,t),ge=de(2),ye=he(ge);function be(t,e){return t.map(()=>e||ye).splice(0,t.length-1)}function xe(t){const e=t.length;return t.map((n,r)=>r!==0?r/(e-1):0)}function Me(t,e){return t.map(n=>n*e)}function k({from:t=0,to:e=1,ease:n,offset:r,duration:s=300}){const a={done:!1,value:t},o=Array.isArray(e)?e:[t,e],u=Me(r&&r.length===o.length?r:xe(o),s);function f(){return jt(u,o,{ease:Array.isArray(n)?n:be(o,n)})}let c=f();return{next:m=>(a.value=c(m),a.done=m>=s,a),flipTarget:()=>{o.reverse(),c=f()}}}function Se({velocity:t=0,from:e=0,power:n=.8,timeConstant:r=350,restDelta:s=.5,modifyTarget:a}){const o={done:!1,value:e};let u=n*t;const f=e+u,c=a===void 0?f:a(f);return c!==f&&(u=c-e),{next:m=>{const h=-u*Math.exp(-m/r);return o.done=!(h>s||h<-s),o.value=o.done?c:c+h,o},flipTarget:()=>{}}}const mt={keyframes:k,spring:tt,decay:Se};function we(t){if(Array.isArray(t.to))return k;if(mt[t.type])return mt[t.type];const e=new Set(Object.keys(t));return e.has("ease")||e.has("duration")&&!e.has("dampingRatio")?k:e.has("dampingRatio")||e.has("stiffness")||e.has("mass")||e.has("damping")||e.has("restSpeed")||e.has("restDelta")?tt:k}const Ft=1/60*1e3,Oe=typeof performance<"u"?()=>performance.now():()=>Date.now(),It=typeof window<"u"?t=>window.requestAnimationFrame(t):t=>setTimeout(()=>t(Oe()),Ft);function ve(t){let e=[],n=[],r=0,s=!1,a=!1;const o=new WeakSet,u={schedule:(f,c=!1,m=!1)=>{const h=m&&s,l=h?e:n;return c&&o.add(f),l.indexOf(f)===-1&&(l.push(f),h&&s&&(r=e.length)),f},cancel:f=>{const c=n.indexOf(f);c!==-1&&n.splice(c,1),o.delete(f)},process:f=>{if(s){a=!0;return}if(s=!0,[e,n]=[n,e],n.length=0,r=e.length,r)for(let c=0;c<r;c++){const m=e[c];m(f),o.has(m)&&(u.schedule(m),t())}s=!1,a&&(a=!1,u.process(f))}};return u}const Ae=40;let Z=!0,I=!1,J=!1;const j={delta:0,timestamp:0},N=["read","update","preRender","render","postRender"],L=N.reduce((t,e)=>(t[e]=ve(()=>I=!0),t),{}),Re=N.reduce((t,e)=>{const n=L[e];return t[e]=(r,s=!1,a=!1)=>(I||Ve(),n.schedule(r,s,a)),t},{}),Te=N.reduce((t,e)=>(t[e]=L[e].cancel,t),{});N.reduce((t,e)=>(t[e]=()=>L[e].process(j),t),{});const Ee=t=>L[t].process(j),Dt=t=>{I=!1,j.delta=Z?Ft:Math.max(Math.min(t-j.timestamp,Ae),1),j.timestamp=t,J=!0,N.forEach(Ee),J=!1,I&&(Z=!1,It(Dt))},Ve=()=>{I=!0,Z=!0,J||It(Dt)};function Nt(t,e,n=0){return t-e-n}function je(t,e,n=0,r=!0){return r?Nt(e+-t,e,n):e-(t-e)+n}function Fe(t,e,n,r){return r?t>=e+n:t<=-n}const Ie=t=>{const e=({delta:n})=>t(n);return{start:()=>Re.update(e,!0),stop:()=>Te.update(e)}};function De(t){var e,n,{from:r,autoplay:s=!0,driver:a=Ie,elapsed:o=0,repeat:u=0,repeatType:f="loop",repeatDelay:c=0,onPlay:m,onStop:h,onComplete:l,onRepeat:i,onUpdate:p}=t,d=ht(t,["from","autoplay","driver","elapsed","repeat","repeatType","repeatDelay","onPlay","onStop","onComplete","onRepeat","onUpdate"]);let{to:g}=d,y,b=0,M=d.duration,x,S=!1,w=!0,R;const rt=we(d);!((n=(e=rt).needsInterpolation)===null||n===void 0)&&n.call(e,r,g)&&(R=jt([0,100],[r,g],{clamp:!1}),r=0,g=100);const st=rt(Object.assign(Object.assign({},d),{from:r,to:g}));function Pt(){b++,f==="reverse"?(w=b%2===0,o=je(o,M,c,w)):(o=Nt(o,M,c),f==="mirror"&&st.flipTarget()),S=!1,i&&i()}function kt(){y.stop(),l&&l()}function Ut(q){if(w||(q=-q),o+=q,!S){const ot=st.next(Math.max(0,o));x=ot.value,R&&(x=R(x)),S=w?ot.done:o<=0}p==null||p(x),S&&(b===0&&(M??(M=o)),b<u?Fe(o,M,c,w)&&Pt():kt())}function $t(){m==null||m(),y=a(Ut),y.start()}return s&&$t(),{stop:()=>{h==null||h(),y.stop()}}}class T{constructor(e){v(this,"options");v(this,"currentValue");v(this,"velocity",0);v(this,"isAnimating",!1);v(this,"controls",null);v(this,"animate",(e=!1)=>{!this.isAnimating&&this.options.onStart&&this.options.onStart(),this.isAnimating=!0;const n=e?this.options.from:this.options.to;let r=this.currentValue,s=performance.now();this.controls=De({from:this.currentValue,to:n,velocity:this.velocity*1e3,stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1,onUpdate:a=>{const o=performance.now(),u=(o-s)/1e3;if(u>0){const f=(a-r)/u;this.velocity=f/1e3,r=a,s=o}this.currentValue=a,this.options.onUpdate(a)},onComplete:()=>{this.currentValue=n,this.isAnimating=!1,this.controls=null,this.velocity=0,this.options.onComplete()}})});this.options={from:e.from??0,to:e.to??1,spring:e.spring??{stiffness:100,damping:10},onUpdate:e.onUpdate??(()=>{}),onComplete:e.onComplete??(()=>{}),onStart:e.onStart},this.currentValue=this.options.from}forward(){this.stop(),this.animate(!1)}backward(){this.stop(),this.animate(!0)}reverse(){const e=this.options.from;if(this.options.from=this.options.to,this.options.to=e,this.isAnimating){const n=this.currentValue>(this.options.from+this.options.to)/2;this.stop(),this.animate(!n)}}stop(){this.isAnimating=!1,this.controls&&(this.controls.stop(),this.controls=null)}getVelocity(){return this.velocity}getCurrentValue(){return this.currentValue}getIsAnimating(){return this.isAnimating}getCurrentState(){return{position:this.currentValue,velocity:this.velocity}}setVelocity(e){this.velocity=e}setValue(e){this.currentValue=e}updateOptions(e){if(this.options={...this.options,...e},this.isAnimating&&this.controls){const n=this.currentValue<this.options.to;this.stop(),this.animate(!n)}}static fromState(e,n){const r=new T(n);return r.setValue(e.position),r.setVelocity(e.velocity),r}}function Ne(t,e){let n=null,r=null,s=null,a=null,o=!1;const u=async c=>{var m;if(n&&n.getIsAnimating()&&!o){const h=n.getCurrentState();n.stop(),r&&(r.remove(),r=null),o=!0;const l=t();if(!l.out)return;const i=await Promise.resolve(l.out(c));n=T.fromState(h,{from:1,to:0,spring:i.spring,onStart:i.onStart,onUpdate:p=>{var d;(d=i.tick)==null||d.call(i,p)},onComplete:()=>{var p;n=null,o=!1,(p=i.onEnd)==null||p.call(i)}}),n.backward();return}if(!n||!n.getIsAnimating()){o=!0;const h=t();if(!h.in)return;const l=await Promise.resolve(h.in(c));(m=l.prepare)==null||m.call(l,c),n=new T({from:0,to:1,spring:l.spring,onStart:l.onStart,onUpdate:i=>{var p;(p=l.tick)==null||p.call(l,i)},onComplete:()=>{var i;n=null,o=!1,(i=l.onEnd)==null||i.call(l)}}),n.forward()}};function f(c){const m=()=>{!s||!r||(a&&s.contains(a)?s.insertBefore(r,a):s.appendChild(r))},h=()=>{var i;r&&(r.remove(),r=null),n=null,o=!1,(i=e==null?void 0:e.onCleanupEnd)==null||i.call(e)},l=t();if(r=c.cloneNode(!0),n&&n.getIsAnimating()&&o){const i=n.getCurrentState();if(n.stop(),o=!1,!l.in){r=null,h();return}Promise.resolve(l.in(r)).then(async p=>{var g;const d=r&&await((g=l.out)==null?void 0:g.call(l,r));d!=null&&d.prepare&&r&&d.prepare(r),m(),n=T.fromState(i,{from:0,to:1,spring:p.spring,onStart:p.onStart,onUpdate:y=>{var b;(b=p.tick)==null||b.call(p,y)},onComplete:()=>{var y;(y=p.onEnd)==null||y.call(p),h()}}),n.backward()});return}if(!n||!n.getIsAnimating()||!o){if(o=!1,!l.out){r=null,h();return}Promise.resolve(l.out(r)).then(i=>{var p;r&&((p=i.prepare)==null||p.call(i,r)),m(),n=new T({from:1,to:0,spring:i.spring,onStart:i.onStart,onUpdate:d=>{var g;(g=i.tick)==null||g.call(i,d)},onComplete:()=>{var d;(d=i.onEnd)==null||d.call(i),h()}}),n.forward()})}}return c=>c?(s=c.parentElement,a=c.nextElementSibling,t().in&&u(c),()=>{f(c)}):void 0}const Q=new Map,X=new Map;function Pe(t,e){Q.set(t,e);let n=X.get(t);return n||(n=Ne(()=>{const r=Q.get(t);return r||(console.warn(`Transition "${String(t)}" not found`),{})},{onCleanupEnd:()=>ke(t)}),X.set(t,n),n)}function ke(t){Q.delete(t),X.delete(t)}function Ue(t){return Pe(t.key,{in:t.in,out:t.out})}function $e(t){let e=null;const n=[...t.transitions],r=[];for(const l of t.transitions)l.symmetric&&(n.some(p=>p.from===l.to&&p.to===l.from)||r.push({from:l.to,to:l.from,transition:l.transition}));n.push(...r);let s=null;const a=new Map;let o=null;const u=()=>{s&&o&&a.set(o,{x:s.scrollLeft,y:s.scrollTop})},f=(l,i)=>{s||(s=qt.getScrollingElement(l),s.addEventListener("scroll",u,{passive:!0})),o=i},c=()=>{const l=e==null?void 0:e.from,i=e==null?void 0:e.to,p=l&&a.has(l)?a.get(l):{x:0,y:0},d=i&&a.has(i)?a.get(i):{x:0,y:0};return{x:-d.x+p.x,y:-d.y+p.y}};function m(){if(e!=null&&e.from&&(e!=null&&e.to)){const i=Ce(e.from,e.to,n)||t.defaultTransition,d={scrollOffset:c()};i&&(i.out&&e.outResolve&&e.outResolve(g=>i.out(g,d)),i.in&&e.inResolve&&e.inResolve(g=>i.in(g,d))),e=null}}const h=async(l,i)=>i==="in"&&(!e||!e.from)?()=>({}):(e||(e={}),i==="out"?(e.from=l,new Promise(p=>{e.outResolve=p,m()})):(e.to=l,new Promise(p=>{e.inResolve=p,m()})));return l=>({key:l,in:async i=>(f(i,l),(await h(l,"in"))(i)),out:async i=>(await h(l,"out"))(i)})}function Ce(t,e,n){for(const r of n)if(P(t,r.from)&&P(e,r.to))return r.transition;for(const r of n)if((r.from==="*"||P(t,r.from))&&(r.to==="*"||P(e,r.to)))return r.transition;return null}function P(t,e){if(e==="*")return!0;if(e.endsWith("/*")){const n=e.slice(0,-2);return t===n||t.startsWith(n+"/")}return t===e}exports.createSggoiTransitionContext=$e;exports.transition=Ue;