@ssgoi/core 0.0.1 → 0.0.2

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.
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var E=Object.defineProperty;var b=(o,t,n)=>t in o?E(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n;var d=(o,t,n)=>b(o,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("popmotion"),R=require("./utils-BSgyev81.cjs");class v{constructor(t){d(this,"options");d(this,"currentValue");d(this,"velocity",0);d(this,"isAnimating",!1);d(this,"controls",null);d(this,"animate",(t=!1)=>{!this.isAnimating&&this.options.onStart&&this.options.onStart(),this.isAnimating=!0;const n=t?this.options.from:this.options.to;let s=this.currentValue,c=performance.now();this.controls=P.animate({from:this.currentValue,to:n,velocity:this.velocity*1e3,stiffness:this.options.spring.stiffness,damping:this.options.spring.damping,mass:1,onUpdate:u=>{const l=performance.now(),S=(l-c)/1e3;if(S>0){const w=(u-s)/S;this.velocity=w/1e3,s=u,c=l}this.currentValue=u,this.options.onUpdate(u)},onComplete:()=>{this.currentValue=n,this.isAnimating=!1,this.controls=null,this.velocity=0,this.options.onComplete()}})});this.options={from:t.from??0,to:t.to??1,spring:t.spring??{stiffness:100,damping:10},onUpdate:t.onUpdate??(()=>{}),onComplete:t.onComplete??(()=>{}),onStart:t.onStart},this.currentValue=this.options.from}forward(){this.stop(),this.animate(!1)}backward(){this.stop(),this.animate(!0)}reverse(){const t=this.options.from;if(this.options.from=this.options.to,this.options.to=t,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(t){this.velocity=t}setValue(t){this.currentValue=t}updateOptions(t){if(this.options={...this.options,...t},this.isAnimating&&this.controls){const n=this.currentValue<this.options.to;this.stop(),this.animate(!n)}}static fromState(t,n){const s=new v(n);return s.setValue(t.position),s.setVelocity(t.velocity),s}}function k(o,t){let n=null,s=null,c=null,u=null,l=!1;const S=async f=>{var h;if(n&&n.getIsAnimating()&&!l){const m=n.getCurrentState();n.stop(),s&&(s.remove(),s=null),l=!0;const r=o();if(!r.out)return;const e=await Promise.resolve(r.out(f));n=v.fromState(m,{from:1,to:0,spring:e.spring,onStart:e.onStart,onUpdate:i=>{var a;(a=e.tick)==null||a.call(e,i)},onComplete:()=>{var i;n=null,l=!1,(i=e.onEnd)==null||i.call(e)}}),n.backward();return}if(!n||!n.getIsAnimating()){l=!0;const m=o();if(!m.in)return;const r=await Promise.resolve(m.in(f));(h=r.prepare)==null||h.call(r,f),n=new v({from:0,to:1,spring:r.spring,onStart:r.onStart,onUpdate:e=>{var i;(i=r.tick)==null||i.call(r,e)},onComplete:()=>{var e;n=null,l=!1,(e=r.onEnd)==null||e.call(r)}}),n.forward()}};function w(f){const h=()=>{!c||!s||(u&&c.contains(u)?c.insertBefore(s,u):c.appendChild(s))},m=()=>{var e;s&&(s.remove(),s=null),n=null,l=!1,(e=t==null?void 0:t.onCleanupEnd)==null||e.call(t)},r=o();if(s=f.cloneNode(!0),n&&n.getIsAnimating()&&l){const e=n.getCurrentState();if(n.stop(),l=!1,!r.in){s=null,m();return}Promise.resolve(r.in(s)).then(async i=>{var p;const a=s&&await((p=r.out)==null?void 0:p.call(r,s));a!=null&&a.prepare&&s&&a.prepare(s),h(),n=v.fromState(e,{from:0,to:1,spring:i.spring,onStart:i.onStart,onUpdate:y=>{var A;(A=i.tick)==null||A.call(i,y)},onComplete:()=>{var y;(y=i.onEnd)==null||y.call(i),m()}}),n.backward()});return}if(!n||!n.getIsAnimating()||!l){if(l=!1,!r.out){s=null,m();return}Promise.resolve(r.out(s)).then(e=>{var i;s&&((i=e.prepare)==null||i.call(e,s)),h(),n=new v({from:1,to:0,spring:e.spring,onStart:e.onStart,onUpdate:a=>{var p;(p=e.tick)==null||p.call(e,a)},onComplete:()=>{var a;(a=e.onEnd)==null||a.call(e),m()}}),n.forward()})}}return f=>f?(c=f.parentElement,u=f.nextElementSibling,o().in&&S(f),()=>{w(f)}):void 0}const V=new Map,x=new Map;function U(o,t){V.set(o,t);let n=x.get(o);return n||(n=k(()=>{const s=V.get(o);return s||(console.warn(`Transition "${String(o)}" not found`),{})},{onCleanupEnd:()=>T(o)}),x.set(o,n),n)}function T(o){V.delete(o),x.delete(o)}function I(o){return U(o.key,{in:o.in,out:o.out})}function M(o){let t=null;const n=[...o.transitions],s=[];for(const r of o.transitions)r.symmetric&&(n.some(i=>i.from===r.to&&i.to===r.from)||s.push({from:r.to,to:r.from,transition:r.transition}));n.push(...s);let c=null;const u=new Map;let l=null;const S=()=>{c&&l&&u.set(l,{x:c.scrollLeft,y:c.scrollTop})},w=(r,e)=>{c||(c=R.getScrollingElement(r),c.addEventListener("scroll",S,{passive:!0})),l=e},f=()=>{const r=t==null?void 0:t.from,e=t==null?void 0:t.to,i=r&&u.has(r)?u.get(r):{x:0,y:0},a=e&&u.has(e)?u.get(e):{x:0,y:0};return{x:-a.x+i.x,y:-a.y+i.y}};function h(){if(t!=null&&t.from&&(t!=null&&t.to)){const e=O(t.from,t.to,n)||o.defaultTransition,a={scrollOffset:f()};e&&(e.out&&t.outResolve&&t.outResolve(p=>e.out(p,a)),e.in&&t.inResolve&&t.inResolve(p=>e.in(p,a))),t=null}}const m=async(r,e)=>e==="in"&&(!t||!t.from)?()=>({}):(t||(t={}),e==="out"?(t.from=r,new Promise(i=>{t.outResolve=i,h()})):(t.to=r,new Promise(i=>{t.inResolve=i,h()})));return r=>({key:r,in:async e=>(w(e,r),(await m(r,"in"))(e)),out:async e=>(await m(r,"out"))(e)})}function O(o,t,n){for(const s of n)if(g(o,s.from)&&g(t,s.to))return s.transition;for(const s of n)if((s.from==="*"||g(o,s.from))&&(s.to==="*"||g(t,s.to)))return s.transition;return null}function g(o,t){if(t==="*")return!0;if(t.endsWith("/*")){const n=t.slice(0,-2);return o===n||o.startsWith(n+"/")}return o===t}exports.createSggoiTransitionContext=M;exports.transition=I;
package/dist/index.js ADDED
@@ -0,0 +1,311 @@
1
+ var E = Object.defineProperty;
2
+ var R = (o, t, n) => t in o ? E(o, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[t] = n;
3
+ var d = (o, t, n) => R(o, typeof t != "symbol" ? t + "" : t, n);
4
+ import { animate as P } from "popmotion";
5
+ import { g as b } from "./utils-DR41YsAh.js";
6
+ class v {
7
+ constructor(t) {
8
+ d(this, "options");
9
+ d(this, "currentValue");
10
+ d(this, "velocity", 0);
11
+ d(this, "isAnimating", !1);
12
+ d(this, "controls", null);
13
+ d(this, "animate", (t = !1) => {
14
+ !this.isAnimating && this.options.onStart && this.options.onStart(), this.isAnimating = !0;
15
+ const n = t ? this.options.from : this.options.to;
16
+ let s = this.currentValue, c = performance.now();
17
+ this.controls = P({
18
+ from: this.currentValue,
19
+ to: n,
20
+ velocity: this.velocity * 1e3,
21
+ // Convert to px/s
22
+ stiffness: this.options.spring.stiffness,
23
+ damping: this.options.spring.damping,
24
+ mass: 1,
25
+ onUpdate: (u) => {
26
+ const l = performance.now(), S = (l - c) / 1e3;
27
+ if (S > 0) {
28
+ const w = (u - s) / S;
29
+ this.velocity = w / 1e3, s = u, c = l;
30
+ }
31
+ this.currentValue = u, this.options.onUpdate(u);
32
+ },
33
+ onComplete: () => {
34
+ this.currentValue = n, this.isAnimating = !1, this.controls = null, this.velocity = 0, this.options.onComplete();
35
+ }
36
+ });
37
+ });
38
+ this.options = {
39
+ from: t.from ?? 0,
40
+ to: t.to ?? 1,
41
+ spring: t.spring ?? { stiffness: 100, damping: 10 },
42
+ onUpdate: t.onUpdate ?? (() => {
43
+ }),
44
+ onComplete: t.onComplete ?? (() => {
45
+ }),
46
+ onStart: t.onStart
47
+ }, this.currentValue = this.options.from;
48
+ }
49
+ // Animation control methods
50
+ forward() {
51
+ this.stop(), this.animate(!1);
52
+ }
53
+ backward() {
54
+ this.stop(), this.animate(!0);
55
+ }
56
+ reverse() {
57
+ const t = this.options.from;
58
+ if (this.options.from = this.options.to, this.options.to = t, this.isAnimating) {
59
+ const n = this.currentValue > (this.options.from + this.options.to) / 2;
60
+ this.stop(), this.animate(!n);
61
+ }
62
+ }
63
+ stop() {
64
+ this.isAnimating = !1, this.controls && (this.controls.stop(), this.controls = null);
65
+ }
66
+ // State getters
67
+ getVelocity() {
68
+ return this.velocity;
69
+ }
70
+ getCurrentValue() {
71
+ return this.currentValue;
72
+ }
73
+ getIsAnimating() {
74
+ return this.isAnimating;
75
+ }
76
+ getCurrentState() {
77
+ return {
78
+ position: this.currentValue,
79
+ velocity: this.velocity
80
+ };
81
+ }
82
+ // State setters
83
+ setVelocity(t) {
84
+ this.velocity = t;
85
+ }
86
+ setValue(t) {
87
+ this.currentValue = t;
88
+ }
89
+ // Configuration
90
+ updateOptions(t) {
91
+ if (this.options = { ...this.options, ...t }, this.isAnimating && this.controls) {
92
+ const n = this.currentValue < this.options.to;
93
+ this.stop(), this.animate(!n);
94
+ }
95
+ }
96
+ // Static factory method
97
+ static fromState(t, n) {
98
+ const s = new v(n);
99
+ return s.setValue(t.position), s.setVelocity(t.velocity), s;
100
+ }
101
+ }
102
+ function k(o, t) {
103
+ let n = null, s = null, c = null, u = null, l = !1;
104
+ const S = async (f) => {
105
+ var h;
106
+ if (n && n.getIsAnimating() && !l) {
107
+ const m = n.getCurrentState();
108
+ n.stop(), s && (s.remove(), s = null), l = !0;
109
+ const e = o();
110
+ if (!e.out) return;
111
+ const r = await Promise.resolve(e.out(f));
112
+ n = v.fromState(m, {
113
+ from: 1,
114
+ to: 0,
115
+ spring: r.spring,
116
+ onStart: r.onStart,
117
+ onUpdate: (i) => {
118
+ var a;
119
+ (a = r.tick) == null || a.call(r, i);
120
+ },
121
+ onComplete: () => {
122
+ var i;
123
+ n = null, l = !1, (i = r.onEnd) == null || i.call(r);
124
+ }
125
+ }), n.backward();
126
+ return;
127
+ }
128
+ if (!n || !n.getIsAnimating()) {
129
+ l = !0;
130
+ const m = o();
131
+ if (!m.in) return;
132
+ const e = await Promise.resolve(m.in(f));
133
+ (h = e.prepare) == null || h.call(e, f), n = new v({
134
+ from: 0,
135
+ to: 1,
136
+ spring: e.spring,
137
+ onStart: e.onStart,
138
+ onUpdate: (r) => {
139
+ var i;
140
+ (i = e.tick) == null || i.call(e, r);
141
+ },
142
+ onComplete: () => {
143
+ var r;
144
+ n = null, l = !1, (r = e.onEnd) == null || r.call(e);
145
+ }
146
+ }), n.forward();
147
+ }
148
+ };
149
+ function w(f) {
150
+ const h = () => {
151
+ !c || !s || (u && c.contains(u) ? c.insertBefore(s, u) : c.appendChild(s));
152
+ }, m = () => {
153
+ var r;
154
+ s && (s.remove(), s = null), n = null, l = !1, (r = t == null ? void 0 : t.onCleanupEnd) == null || r.call(t);
155
+ }, e = o();
156
+ if (s = f.cloneNode(!0), n && n.getIsAnimating() && l) {
157
+ const r = n.getCurrentState();
158
+ if (n.stop(), l = !1, !e.in) {
159
+ s = null, m();
160
+ return;
161
+ }
162
+ Promise.resolve(e.in(s)).then(async (i) => {
163
+ var p;
164
+ const a = s && await ((p = e.out) == null ? void 0 : p.call(e, s));
165
+ a != null && a.prepare && s && a.prepare(s), h(), n = v.fromState(r, {
166
+ from: 0,
167
+ to: 1,
168
+ spring: i.spring,
169
+ onStart: i.onStart,
170
+ onUpdate: (y) => {
171
+ var A;
172
+ (A = i.tick) == null || A.call(i, y);
173
+ },
174
+ onComplete: () => {
175
+ var y;
176
+ (y = i.onEnd) == null || y.call(i), m();
177
+ }
178
+ }), n.backward();
179
+ });
180
+ return;
181
+ }
182
+ if (!n || !n.getIsAnimating() || !l) {
183
+ if (l = !1, !e.out) {
184
+ s = null, m();
185
+ return;
186
+ }
187
+ Promise.resolve(e.out(s)).then((r) => {
188
+ var i;
189
+ s && ((i = r.prepare) == null || i.call(r, s)), h(), n = new v({
190
+ from: 1,
191
+ to: 0,
192
+ spring: r.spring,
193
+ onStart: r.onStart,
194
+ onUpdate: (a) => {
195
+ var p;
196
+ (p = r.tick) == null || p.call(r, a);
197
+ },
198
+ onComplete: () => {
199
+ var a;
200
+ (a = r.onEnd) == null || a.call(r), m();
201
+ }
202
+ }), n.forward();
203
+ });
204
+ }
205
+ }
206
+ return (f) => f ? (c = f.parentElement, u = f.nextElementSibling, o().in && S(f), () => {
207
+ w(f);
208
+ }) : void 0;
209
+ }
210
+ const g = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
211
+ function U(o, t) {
212
+ g.set(o, t);
213
+ let n = x.get(o);
214
+ return n || (n = k(
215
+ () => {
216
+ const s = g.get(o);
217
+ return s || (console.warn(`Transition "${String(o)}" not found`), {});
218
+ },
219
+ {
220
+ onCleanupEnd: () => I(o)
221
+ }
222
+ ), x.set(o, n), n);
223
+ }
224
+ function I(o) {
225
+ g.delete(o), x.delete(o);
226
+ }
227
+ function L(o) {
228
+ return U(o.key, {
229
+ in: o.in,
230
+ out: o.out
231
+ });
232
+ }
233
+ function W(o) {
234
+ let t = null;
235
+ const n = [...o.transitions], s = [];
236
+ for (const e of o.transitions)
237
+ e.symmetric && (n.some(
238
+ (i) => i.from === e.to && i.to === e.from
239
+ ) || s.push({
240
+ from: e.to,
241
+ to: e.from,
242
+ transition: e.transition
243
+ // Don't add symmetric flag to the reverse to avoid infinite loop
244
+ }));
245
+ n.push(...s);
246
+ let c = null;
247
+ const u = /* @__PURE__ */ new Map();
248
+ let l = null;
249
+ const S = () => {
250
+ c && l && u.set(l, {
251
+ x: c.scrollLeft,
252
+ y: c.scrollTop
253
+ });
254
+ }, w = (e, r) => {
255
+ c || (c = b(e), c.addEventListener("scroll", S, {
256
+ passive: !0
257
+ })), l = r;
258
+ }, f = () => {
259
+ const e = t == null ? void 0 : t.from, r = t == null ? void 0 : t.to, i = e && u.has(e) ? u.get(e) : { x: 0, y: 0 }, a = r && u.has(r) ? u.get(r) : { x: 0, y: 0 };
260
+ return {
261
+ x: -a.x + i.x,
262
+ y: -a.y + i.y
263
+ };
264
+ };
265
+ function h() {
266
+ if (t != null && t.from && (t != null && t.to)) {
267
+ const r = T(
268
+ t.from,
269
+ t.to,
270
+ n
271
+ ) || o.defaultTransition, a = { scrollOffset: f() };
272
+ r && (r.out && t.outResolve && t.outResolve(
273
+ (p) => r.out(p, a)
274
+ ), r.in && t.inResolve && t.inResolve(
275
+ (p) => r.in(p, a)
276
+ )), t = null;
277
+ }
278
+ }
279
+ const m = async (e, r) => r === "in" && (!t || !t.from) ? () => ({}) : (t || (t = {}), r === "out" ? (t.from = e, new Promise((i) => {
280
+ t.outResolve = i, h();
281
+ })) : (t.to = e, new Promise((i) => {
282
+ t.inResolve = i, h();
283
+ })));
284
+ return (e) => ({
285
+ key: e,
286
+ in: async (r) => (w(r, e), (await m(e, "in"))(r)),
287
+ out: async (r) => (await m(e, "out"))(r)
288
+ });
289
+ }
290
+ function T(o, t, n) {
291
+ for (const s of n)
292
+ if (V(o, s.from) && V(t, s.to))
293
+ return s.transition;
294
+ for (const s of n)
295
+ if ((s.from === "*" || V(o, s.from)) && (s.to === "*" || V(t, s.to)))
296
+ return s.transition;
297
+ return null;
298
+ }
299
+ function V(o, t) {
300
+ if (t === "*")
301
+ return !0;
302
+ if (t.endsWith("/*")) {
303
+ const n = t.slice(0, -2);
304
+ return o === n || o.startsWith(n + "/");
305
+ }
306
+ return o === t;
307
+ }
308
+ export {
309
+ W as createSggoiTransitionContext,
310
+ L as transition
311
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../utils-BSgyev81.cjs"),C=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??30};return{in:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()}}),out:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()},prepare:k.prepareOutgoing})}};function E(t,n){return t.querySelector(`[data-hero-key="${n}"]`)}function A(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}const D=(t={})=>{var l,r;const n={stiffness:((l=t.spring)==null?void 0:l.stiffness)??300,damping:((r=t.spring)==null?void 0:r.damping)??30},e=t.timeout??300;let i=null,s=null;return{in:async(c,o)=>{const h=c,g=Array.from(h.querySelectorAll("[data-hero-key]"));if(g.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(a=>{i?a(!0):(s=a,setTimeout(()=>{s=null,a(!1)},e))})||!i)return i=null,{spring:n,tick:()=>{}};const p=g.map(a=>{const f=a.getAttribute("data-hero-key");if(!f)return null;const u=E(i,f);if(!u)return null;const d=a,$=A(i,u),w=A(h,d),x=$.left-w.left-o.scrollOffset.x,M=$.top-w.top-o.scrollOffset.y,q=$.width/w.width,O=$.height/w.height,T=d.style.transform,P=d.style.position,b=d.style.transformOrigin;return{toEl:d,dx:x,dy:M,dw:q,dh:O,originalTransform:T,originalPosition:P,originalTransformOrigin:b}}).filter(Boolean);return i=null,p.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{p.forEach(({toEl:a})=>{a.style.position="relative",a.style.transformOrigin="top left"})},tick:a=>{p.forEach(({toEl:f,dx:u,dy:d,dw:$,dh:w})=>{f.style.transform=`translate(${(1-a)*u}px,${(1-a)*d}px) scale(${a+(1-a)*$}, ${a+(1-a)*w})`})},onEnd:()=>{p.forEach(({toEl:a,originalTransform:f,originalPosition:u,originalTransformOrigin:d})=>{a.style.transform=f,a.style.position=u,a.style.transformOrigin=d})}}},out:async c=>({onStart:()=>{i=c,s&&(s(!0),s=null)},prepare:o=>{k.prepareOutgoing(o),o.style.opacity="0"}})}};function S(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}function H({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2-i.x,r=n.top-t.top+(n.height-t.height)/2-i.y,c=n.width/t.width,o=n.height/t.height,h=Math.max(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u}px, ${r*u}px) scale(${1+(h-1)*u})`}}function F({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2+e.x,l=n.top-t.top+(n.height-t.height)/2+e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const g=1-h;i.style.transform=`translate(${s*g-e.x}px, ${l*g-e.y}px) scale(${1+(o-1)*g})`,i.style.opacity=`${1-g}`}}function I({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2-e.x,l=n.top-t.top+(n.height-t.height)/2-e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{const g=1-h,y=h;i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,i.style.transform=`translate(${s*g}px, ${l*g}px) scale(${1+(o-1)*g})`,i.style.opacity=`${y}`}}function L({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2+i.x,r=n.top-t.top+(n.height-t.height)/2+i.y,c=n.width/t.width,o=n.height/t.height,h=Math.min(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u-i.x}px, ${r*u-i.y}px) scale(${1+(h-1)*u})`}}function X(t,n,e){const i=t.querySelector("[data-pinterest-detail-key]"),s=n.querySelector("[data-pinterest-detail-key]");if(t.querySelectorAll("[data-pinterest-detail-key]").length>1||n.querySelectorAll("[data-pinterest-detail-key]").length>1)return null;let l=null,r=null,c=!1;if(!i&&s){r=s;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=t.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!0)}else if(i&&!s){r=i;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=n.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!1)}if(!l||!r)return null;const o=S(c?t:n,l),h=S(c?n:t,r),g=n.getBoundingClientRect();return c?{inAnimation:H({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},n),outAnimation:F({galleryRect:o,detailRect:h,scrollOffset:e},t)}:{inAnimation:I({galleryRect:o,detailRect:h,scrollOffset:e},n),outAnimation:L({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},t)}}const Y=(t={})=>{var r,c;const n={stiffness:((r=t.spring)==null?void 0:r.stiffness)??50,damping:((c=t.spring)==null?void 0:c.damping)??10},e=t.timeout??300;let i=null,s=null,l=null;return{in:async(o,{scrollOffset:h})=>{const g=o;return!await new Promise(p=>{i?p(!0):(s=p,setTimeout(()=>{s=null,p(!1)},e))})||!i?(i=null,{spring:n,tick:()=>{}}):(l=X(i,g,h),l?(i=null,{spring:n,tick:p=>{l&&l.inAnimation(p)}}):{spring:n,tick:()=>{}})},out:async o=>({spring:n,onStart:()=>{i=o,s&&(s(!0),s=null)},prepare:h=>{k.prepareOutgoing(h),h.style.zIndex="-1"},tick:h=>{l&&l.outAnimation(h)}})}};function B(t){const n=t.getBoundingClientRect(),e=t.clientHeight,s=50*(window.innerHeight-n.top)/e;return Math.min(Math.max(s,0),100)}const m=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??200};return{in:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`}}},out:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`,s.style.zIndex="100"},prepare:k.prepareOutgoing}}}};exports.fade=C;exports.hero=D;exports.pinterest=Y;exports.ripple=m;
@@ -1,4 +1,4 @@
1
- import { p as k } from "./utils-DR41YsAh.js";
1
+ import { p as k } from "../utils-DR41YsAh.js";
2
2
  const X = (t = {}) => {
3
3
  var e, i;
4
4
  const n = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ssgoi/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "A smooth page transition library",
5
5
  "private": false,
6
6
  "type": "module",
@@ -31,16 +31,24 @@
31
31
  },
32
32
  "files": [
33
33
  "dist",
34
- "src"
34
+ "!dist/**/*.test.*",
35
+ "!dist/**/*.spec.*"
35
36
  ],
36
37
  "keywords": [
37
38
  "page-transition",
38
39
  "animation",
39
40
  "typescript",
40
- "vanilla"
41
+ "vanilla",
42
+ "spring-physics",
43
+ "ssgoi"
41
44
  ],
42
45
  "author": "",
43
46
  "license": "MIT",
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "https://github.com/yourusername/ssgoi.git",
50
+ "directory": "packages/core"
51
+ },
44
52
  "devDependencies": {
45
53
  "@types/node": "^22.10.6",
46
54
  "typescript": "^5.7.3",
package/dist/ssgoi2.cjs DELETED
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("./utils-BSgyev81.cjs"),C=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??30};return{in:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()}}),out:s=>({spring:n,tick:l=>{s.style.opacity=l.toString()},prepare:k.prepareOutgoing})}};function E(t,n){return t.querySelector(`[data-hero-key="${n}"]`)}function A(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}const D=(t={})=>{var l,r;const n={stiffness:((l=t.spring)==null?void 0:l.stiffness)??300,damping:((r=t.spring)==null?void 0:r.damping)??30},e=t.timeout??300;let i=null,s=null;return{in:async(c,o)=>{const h=c,g=Array.from(h.querySelectorAll("[data-hero-key]"));if(g.length===0)return{spring:n,tick:()=>{}};if(!await new Promise(a=>{i?a(!0):(s=a,setTimeout(()=>{s=null,a(!1)},e))})||!i)return i=null,{spring:n,tick:()=>{}};const p=g.map(a=>{const f=a.getAttribute("data-hero-key");if(!f)return null;const u=E(i,f);if(!u)return null;const d=a,$=A(i,u),w=A(h,d),x=$.left-w.left-o.scrollOffset.x,M=$.top-w.top-o.scrollOffset.y,q=$.width/w.width,O=$.height/w.height,T=d.style.transform,P=d.style.position,b=d.style.transformOrigin;return{toEl:d,dx:x,dy:M,dw:q,dh:O,originalTransform:T,originalPosition:P,originalTransformOrigin:b}}).filter(Boolean);return i=null,p.length===0?{spring:n,tick:()=>{}}:{spring:n,prepare:()=>{p.forEach(({toEl:a})=>{a.style.position="relative",a.style.transformOrigin="top left"})},tick:a=>{p.forEach(({toEl:f,dx:u,dy:d,dw:$,dh:w})=>{f.style.transform=`translate(${(1-a)*u}px,${(1-a)*d}px) scale(${a+(1-a)*$}, ${a+(1-a)*w})`})},onEnd:()=>{p.forEach(({toEl:a,originalTransform:f,originalPosition:u,originalTransformOrigin:d})=>{a.style.transform=f,a.style.position=u,a.style.transformOrigin=d})}}},out:async c=>({onStart:()=>{i=c,s&&(s(!0),s=null)},prepare:o=>{k.prepareOutgoing(o),o.style.opacity="0"}})}};function S(t,n){const e=t.getBoundingClientRect(),i=n.getBoundingClientRect();return new DOMRect(i.left-e.left,i.top-e.top,i.width,i.height)}function H({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2-i.x,r=n.top-t.top+(n.height-t.height)/2-i.y,c=n.width/t.width,o=n.height/t.height,h=Math.max(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u}px, ${r*u}px) scale(${1+(h-1)*u})`}}function F({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2+e.x,l=n.top-t.top+(n.height-t.height)/2+e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`;const g=1-h;i.style.transform=`translate(${s*g-e.x}px, ${l*g-e.y}px) scale(${1+(o-1)*g})`,i.style.opacity=`${1-g}`}}function I({galleryRect:t,detailRect:n,scrollOffset:e},i){const s=n.left-t.left+(n.width-t.width)/2-e.x,l=n.top-t.top+(n.height-t.height)/2-e.y,r=n.width/t.width,c=n.height/t.height,o=Math.max(r,c);return h=>{const g=1-h,y=h;i.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,i.style.transform=`translate(${s*g}px, ${l*g}px) scale(${1+(o-1)*g})`,i.style.opacity=`${y}`}}function L({detailRect:t,galleryRect:n,pageRect:e,scrollOffset:i},s){const l=n.left-t.left+(n.width-t.width)/2+i.x,r=n.top-t.top+(n.height-t.height)/2+i.y,c=n.width/t.width,o=n.height/t.height,h=Math.min(c,o),g=t.top/e.height*100,y=(e.width-(t.left+t.width))/e.width*100,p=(e.height-(t.top+t.height))/e.height*100,a=t.left/e.width*100;return s.style.transformOrigin=`${t.left+t.width/2}px ${t.top+t.height/2}px`,f=>{const u=1-f,d=g*u,$=y*u,w=p*u,x=a*u;s.style.clipPath=`inset(${d}% ${$}% ${w}% ${x}%)`,s.style.transform=`translate(${l*u-i.x}px, ${r*u-i.y}px) scale(${1+(h-1)*u})`}}function X(t,n,e){const i=t.querySelector("[data-pinterest-detail-key]"),s=n.querySelector("[data-pinterest-detail-key]");if(t.querySelectorAll("[data-pinterest-detail-key]").length>1||n.querySelectorAll("[data-pinterest-detail-key]").length>1)return null;let l=null,r=null,c=!1;if(!i&&s){r=s;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=t.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!0)}else if(i&&!s){r=i;const y=r.getAttribute("data-pinterest-detail-key");if(!y)return null;l=n.querySelector(`[data-pinterest-gallery-key="${y}"]`),l&&(c=!1)}if(!l||!r)return null;const o=S(c?t:n,l),h=S(c?n:t,r),g=n.getBoundingClientRect();return c?{inAnimation:H({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},n),outAnimation:F({galleryRect:o,detailRect:h,scrollOffset:e},t)}:{inAnimation:I({galleryRect:o,detailRect:h,scrollOffset:e},n),outAnimation:L({detailRect:h,galleryRect:o,pageRect:g,scrollOffset:e},t)}}const Y=(t={})=>{var r,c;const n={stiffness:((r=t.spring)==null?void 0:r.stiffness)??50,damping:((c=t.spring)==null?void 0:c.damping)??10},e=t.timeout??300;let i=null,s=null,l=null;return{in:async(o,{scrollOffset:h})=>{const g=o;return!await new Promise(p=>{i?p(!0):(s=p,setTimeout(()=>{s=null,p(!1)},e))})||!i?(i=null,{spring:n,tick:()=>{}}):(l=X(i,g,h),l?(i=null,{spring:n,tick:p=>{l&&l.inAnimation(p)}}):{spring:n,tick:()=>{}})},out:async o=>({spring:n,onStart:()=>{i=o,s&&(s(!0),s=null)},prepare:h=>{k.prepareOutgoing(h),h.style.zIndex="-1"},tick:h=>{l&&l.outAnimation(h)}})}};function B(t){const n=t.getBoundingClientRect(),e=t.clientHeight,s=50*(window.innerHeight-n.top)/e;return Math.min(Math.max(s,0),100)}const m=(t={})=>{var e,i;const n={stiffness:((e=t.spring)==null?void 0:e.stiffness)??300,damping:((i=t.spring)==null?void 0:i.damping)??200};return{in:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`}}},out:s=>{const l=B(s);return{spring:n,tick:r=>{s.style.clipPath=`circle(${r*100}% at 50% ${l}%)`,s.style.zIndex="100"},prepare:k.prepareOutgoing}}}};exports.fade=C;exports.hero=D;exports.pinterest=Y;exports.ripple=m;
package/dist/ssgoi4.cjs DELETED
@@ -1 +0,0 @@
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;