@ssgoi/react 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.
package/dist/index.js ADDED
@@ -0,0 +1,770 @@
1
+ import { jsx as mt } from "react/jsx-runtime";
2
+ import { createContext as Lt, useContext as qt, useMemo as Bt } from "react";
3
+ import { g as _t } from "./utils-DR41YsAh.js";
4
+ function ht(t, e) {
5
+ var n = {};
6
+ for (var r in t) Object.prototype.hasOwnProperty.call(t, r) && e.indexOf(r) < 0 && (n[r] = t[r]);
7
+ if (t != null && typeof Object.getOwnPropertySymbols == "function")
8
+ for (var s = 0, r = Object.getOwnPropertySymbols(t); s < r.length; s++)
9
+ e.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(t, r[s]) && (n[r[s]] = t[r[s]]);
10
+ return n;
11
+ }
12
+ var X = function() {
13
+ }, V = function() {
14
+ };
15
+ process.env.NODE_ENV !== "production" && (X = function(t, e) {
16
+ !t && typeof console < "u" && console.warn(e);
17
+ }, V = function(t, e) {
18
+ if (!t)
19
+ throw new Error(e);
20
+ });
21
+ const W = (t, e, n) => Math.min(Math.max(n, t), e), q = 1e-3, Wt = 0.01, ot = 10, Gt = 0.05, Ht = 1;
22
+ function Kt({ duration: t = 800, bounce: e = 0.25, velocity: n = 0, mass: r = 1 }) {
23
+ let s, i;
24
+ X(t <= ot * 1e3, "Spring duration must be 10 seconds or less");
25
+ let o = 1 - e;
26
+ o = W(Gt, Ht, o), t = W(Wt, ot, t / 1e3), o < 1 ? (s = (a) => {
27
+ const p = a * o, m = p * t, u = p - n, f = G(a, o), h = Math.exp(-m);
28
+ return q - u / f * h;
29
+ }, i = (a) => {
30
+ const m = a * o * t, u = m * n + n, f = Math.pow(o, 2) * Math.pow(a, 2) * t, h = Math.exp(-m), x = G(Math.pow(a, 2), o);
31
+ return (-s(a) + q > 0 ? -1 : 1) * ((u - f) * h) / x;
32
+ }) : (s = (a) => {
33
+ const p = Math.exp(-a * t), m = (a - n) * t + 1;
34
+ return -q + p * m;
35
+ }, i = (a) => {
36
+ const p = Math.exp(-a * t), m = (n - a) * (t * t);
37
+ return p * m;
38
+ });
39
+ const l = 5 / t, c = Zt(s, i, l);
40
+ if (t = t * 1e3, isNaN(c))
41
+ return {
42
+ stiffness: 100,
43
+ damping: 10,
44
+ duration: t
45
+ };
46
+ {
47
+ const a = Math.pow(c, 2) * r;
48
+ return {
49
+ stiffness: a,
50
+ damping: o * 2 * Math.sqrt(r * a),
51
+ duration: t
52
+ };
53
+ }
54
+ }
55
+ const zt = 12;
56
+ function Zt(t, e, n) {
57
+ let r = n;
58
+ for (let s = 1; s < zt; s++)
59
+ r = r - t(r) / e(r);
60
+ return r;
61
+ }
62
+ function G(t, e) {
63
+ return t * Math.sqrt(1 - e * e);
64
+ }
65
+ const Jt = ["duration", "bounce"], Qt = ["stiffness", "damping", "mass"];
66
+ function it(t, e) {
67
+ return e.some((n) => t[n] !== void 0);
68
+ }
69
+ function Xt(t) {
70
+ let e = Object.assign({ velocity: 0, stiffness: 100, damping: 10, mass: 1, isResolvedFromDuration: !1 }, t);
71
+ if (!it(t, Qt) && it(t, Jt)) {
72
+ const n = Kt(t);
73
+ e = Object.assign(Object.assign(Object.assign({}, e), n), { velocity: 0, mass: 1 }), e.isResolvedFromDuration = !0;
74
+ }
75
+ return e;
76
+ }
77
+ function Y(t) {
78
+ var { from: e = 0, to: n = 1, restSpeed: r = 2, restDelta: s } = t, i = ht(t, ["from", "to", "restSpeed", "restDelta"]);
79
+ const o = { done: !1, value: e };
80
+ let { stiffness: l, damping: c, mass: a, velocity: p, duration: m, isResolvedFromDuration: u } = Xt(i), f = at, h = at;
81
+ function x() {
82
+ const y = p ? -(p / 1e3) : 0, S = n - e, b = c / (2 * Math.sqrt(l * a)), g = Math.sqrt(l / a) / 1e3;
83
+ if (s === void 0 && (s = Math.min(Math.abs(n - e) / 100, 0.4)), b < 1) {
84
+ const d = G(g, b);
85
+ f = (M) => {
86
+ const w = Math.exp(-b * g * M);
87
+ return n - w * ((y + b * g * S) / d * Math.sin(d * M) + S * Math.cos(d * M));
88
+ }, h = (M) => {
89
+ const w = Math.exp(-b * g * M);
90
+ return b * g * w * (Math.sin(d * M) * (y + b * g * S) / d + S * Math.cos(d * M)) - w * (Math.cos(d * M) * (y + b * g * S) - d * S * Math.sin(d * M));
91
+ };
92
+ } else if (b === 1)
93
+ f = (d) => n - Math.exp(-g * d) * (S + (y + g * S) * d);
94
+ else {
95
+ const d = g * Math.sqrt(b * b - 1);
96
+ f = (M) => {
97
+ const w = Math.exp(-b * g * M), O = Math.min(d * M, 300);
98
+ return n - w * ((y + b * g * S) * Math.sinh(O) + d * S * Math.cosh(O)) / d;
99
+ };
100
+ }
101
+ }
102
+ return x(), {
103
+ next: (y) => {
104
+ const S = f(y);
105
+ if (u)
106
+ o.done = y >= m;
107
+ else {
108
+ const b = h(y) * 1e3, g = Math.abs(b) <= r, d = Math.abs(n - S) <= s;
109
+ o.done = g && d;
110
+ }
111
+ return o.value = o.done ? n : S, o;
112
+ },
113
+ flipTarget: () => {
114
+ p = -p, [e, n] = [n, e], x();
115
+ }
116
+ };
117
+ }
118
+ Y.needsInterpolation = (t, e) => typeof t == "string" || typeof e == "string";
119
+ const at = (t) => 0, dt = (t, e, n) => {
120
+ const r = e - t;
121
+ return r === 0 ? 1 : (n - t) / r;
122
+ }, tt = (t, e, n) => -n * t + n * e + t, gt = (t, e) => (n) => Math.max(Math.min(n, e), t), A = (t) => t % 1 ? Number(t.toFixed(5)) : t, N = /(-)?([\d]*\.?[\d])+/g, H = /(#[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, Yt = /^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2}(-?[\d\.]+%?)\s*[\,\/]?\s*[\d\.]*%?\))$/i;
123
+ function j(t) {
124
+ return typeof t == "string";
125
+ }
126
+ const k = {
127
+ test: (t) => typeof t == "number",
128
+ parse: parseFloat,
129
+ transform: (t) => t
130
+ }, yt = Object.assign(Object.assign({}, k), { transform: gt(0, 1) });
131
+ Object.assign(Object.assign({}, k), { default: 1 });
132
+ const te = (t) => ({
133
+ test: (e) => j(e) && e.endsWith(t) && e.split(" ").length === 1,
134
+ parse: parseFloat,
135
+ transform: (e) => `${e}${t}`
136
+ }), R = te("%");
137
+ Object.assign(Object.assign({}, R), { parse: (t) => R.parse(t) / 100, transform: (t) => R.transform(t * 100) });
138
+ const et = (t, e) => (n) => !!(j(n) && Yt.test(n) && n.startsWith(t) || e && Object.prototype.hasOwnProperty.call(n, e)), bt = (t, e, n) => (r) => {
139
+ if (!j(r))
140
+ return r;
141
+ const [s, i, o, l] = r.match(N);
142
+ return {
143
+ [t]: parseFloat(s),
144
+ [e]: parseFloat(i),
145
+ [n]: parseFloat(o),
146
+ alpha: l !== void 0 ? parseFloat(l) : 1
147
+ };
148
+ }, C = {
149
+ test: et("hsl", "hue"),
150
+ parse: bt("hue", "saturation", "lightness"),
151
+ transform: ({ hue: t, saturation: e, lightness: n, alpha: r = 1 }) => "hsla(" + Math.round(t) + ", " + R.transform(A(e)) + ", " + R.transform(A(n)) + ", " + A(yt.transform(r)) + ")"
152
+ }, ee = gt(0, 255), B = Object.assign(Object.assign({}, k), { transform: (t) => Math.round(ee(t)) }), v = {
153
+ test: et("rgb", "red"),
154
+ parse: bt("red", "green", "blue"),
155
+ transform: ({ red: t, green: e, blue: n, alpha: r = 1 }) => "rgba(" + B.transform(t) + ", " + B.transform(e) + ", " + B.transform(n) + ", " + A(yt.transform(r)) + ")"
156
+ };
157
+ function ne(t) {
158
+ let e = "", n = "", r = "", s = "";
159
+ 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), {
160
+ red: parseInt(e, 16),
161
+ green: parseInt(n, 16),
162
+ blue: parseInt(r, 16),
163
+ alpha: s ? parseInt(s, 16) / 255 : 1
164
+ };
165
+ }
166
+ const K = {
167
+ test: et("#"),
168
+ parse: ne,
169
+ transform: v.transform
170
+ }, U = {
171
+ test: (t) => v.test(t) || K.test(t) || C.test(t),
172
+ parse: (t) => v.test(t) ? v.parse(t) : C.test(t) ? C.parse(t) : K.parse(t),
173
+ transform: (t) => j(t) ? t : t.hasOwnProperty("red") ? v.transform(t) : C.transform(t)
174
+ }, xt = "${c}", St = "${n}";
175
+ function re(t) {
176
+ var e, n, r, s;
177
+ return isNaN(t) && j(t) && ((n = (e = t.match(N)) === null || e === void 0 ? void 0 : e.length) !== null && n !== void 0 ? n : 0) + ((s = (r = t.match(H)) === null || r === void 0 ? void 0 : r.length) !== null && s !== void 0 ? s : 0) > 0;
178
+ }
179
+ function Mt(t) {
180
+ typeof t == "number" && (t = `${t}`);
181
+ const e = [];
182
+ let n = 0;
183
+ const r = t.match(H);
184
+ r && (n = r.length, t = t.replace(H, xt), e.push(...r.map(U.parse)));
185
+ const s = t.match(N);
186
+ return s && (t = t.replace(N, St), e.push(...s.map(k.parse))), { values: e, numColors: n, tokenised: t };
187
+ }
188
+ function wt(t) {
189
+ return Mt(t).values;
190
+ }
191
+ function vt(t) {
192
+ const { values: e, numColors: n, tokenised: r } = Mt(t), s = e.length;
193
+ return (i) => {
194
+ let o = r;
195
+ for (let l = 0; l < s; l++)
196
+ o = o.replace(l < n ? xt : St, l < n ? U.transform(i[l]) : A(i[l]));
197
+ return o;
198
+ };
199
+ }
200
+ const se = (t) => typeof t == "number" ? 0 : t;
201
+ function oe(t) {
202
+ const e = wt(t);
203
+ return vt(t)(e.map(se));
204
+ }
205
+ const Ct = { test: re, parse: wt, createTransformer: vt, getAnimatableNone: oe };
206
+ function _(t, e, n) {
207
+ 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;
208
+ }
209
+ function lt({ hue: t, saturation: e, lightness: n, alpha: r }) {
210
+ t /= 360, e /= 100, n /= 100;
211
+ let s = 0, i = 0, o = 0;
212
+ if (!e)
213
+ s = i = o = n;
214
+ else {
215
+ const l = n < 0.5 ? n * (1 + e) : n + e - n * e, c = 2 * n - l;
216
+ s = _(c, l, t + 1 / 3), i = _(c, l, t), o = _(c, l, t - 1 / 3);
217
+ }
218
+ return {
219
+ red: Math.round(s * 255),
220
+ green: Math.round(i * 255),
221
+ blue: Math.round(o * 255),
222
+ alpha: r
223
+ };
224
+ }
225
+ const ie = (t, e, n) => {
226
+ const r = t * t, s = e * e;
227
+ return Math.sqrt(Math.max(0, n * (s - r) + r));
228
+ }, ae = [K, v, C], ct = (t) => ae.find((e) => e.test(t)), ut = (t) => `'${t}' is not an animatable color. Use the equivalent color code instead.`, Ot = (t, e) => {
229
+ let n = ct(t), r = ct(e);
230
+ V(!!n, ut(t)), V(!!r, ut(e));
231
+ let s = n.parse(t), i = r.parse(e);
232
+ n === C && (s = lt(s), n = v), r === C && (i = lt(i), r = v);
233
+ const o = Object.assign({}, s);
234
+ return (l) => {
235
+ for (const c in o)
236
+ c !== "alpha" && (o[c] = ie(s[c], i[c], l));
237
+ return o.alpha = tt(s.alpha, i.alpha, l), n.transform(o);
238
+ };
239
+ }, le = (t) => typeof t == "number", ce = (t, e) => (n) => e(t(n)), Tt = (...t) => t.reduce(ce);
240
+ function At(t, e) {
241
+ return le(t) ? (n) => tt(t, e, n) : U.test(t) ? Ot(t, e) : Et(t, e);
242
+ }
243
+ const Rt = (t, e) => {
244
+ const n = [...t], r = n.length, s = t.map((i, o) => At(i, e[o]));
245
+ return (i) => {
246
+ for (let o = 0; o < r; o++)
247
+ n[o] = s[o](i);
248
+ return n;
249
+ };
250
+ }, ue = (t, e) => {
251
+ const n = Object.assign(Object.assign({}, t), e), r = {};
252
+ for (const s in n)
253
+ t[s] !== void 0 && e[s] !== void 0 && (r[s] = At(t[s], e[s]));
254
+ return (s) => {
255
+ for (const i in r)
256
+ n[i] = r[i](s);
257
+ return n;
258
+ };
259
+ };
260
+ function ft(t) {
261
+ const e = Ct.parse(t), n = e.length;
262
+ let r = 0, s = 0, i = 0;
263
+ for (let o = 0; o < n; o++)
264
+ r || typeof e[o] == "number" ? r++ : e[o].hue !== void 0 ? i++ : s++;
265
+ return { parsed: e, numNumbers: r, numRGB: s, numHSL: i };
266
+ }
267
+ const Et = (t, e) => {
268
+ const n = Ct.createTransformer(e), r = ft(t), s = ft(e);
269
+ return r.numHSL === s.numHSL && r.numRGB === s.numRGB && r.numNumbers >= s.numNumbers ? Tt(Rt(r.parsed, s.parsed), n) : (X(!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}`);
270
+ }, fe = (t, e) => (n) => tt(t, e, n);
271
+ function pe(t) {
272
+ if (typeof t == "number")
273
+ return fe;
274
+ if (typeof t == "string")
275
+ return U.test(t) ? Ot : Et;
276
+ if (Array.isArray(t))
277
+ return Rt;
278
+ if (typeof t == "object")
279
+ return ue;
280
+ }
281
+ function me(t, e, n) {
282
+ const r = [], s = n || pe(t[0]), i = t.length - 1;
283
+ for (let o = 0; o < i; o++) {
284
+ let l = s(t[o], t[o + 1]);
285
+ if (e) {
286
+ const c = Array.isArray(e) ? e[o] : e;
287
+ l = Tt(c, l);
288
+ }
289
+ r.push(l);
290
+ }
291
+ return r;
292
+ }
293
+ function he([t, e], [n]) {
294
+ return (r) => n(dt(t, e, r));
295
+ }
296
+ function de(t, e) {
297
+ const n = t.length, r = n - 1;
298
+ return (s) => {
299
+ let i = 0, o = !1;
300
+ if (s <= t[0] ? o = !0 : s >= t[r] && (i = r - 1, o = !0), !o) {
301
+ let c = 1;
302
+ for (; c < n && !(t[c] > s || c === r); c++)
303
+ ;
304
+ i = c - 1;
305
+ }
306
+ const l = dt(t[i], t[i + 1], s);
307
+ return e[i](l);
308
+ };
309
+ }
310
+ function Vt(t, e, { clamp: n = !0, ease: r, mixer: s } = {}) {
311
+ const i = t.length;
312
+ V(i === e.length, "Both input and output ranges must be the same length"), V(!r || !Array.isArray(r) || r.length === i - 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[i - 1] && (t = [].concat(t), e = [].concat(e), t.reverse(), e.reverse());
313
+ const o = me(e, r, s), l = i === 2 ? he(t, o) : de(t, o);
314
+ return n ? (c) => l(W(t[0], t[i - 1], c)) : l;
315
+ }
316
+ const ge = (t) => (e) => e <= 0.5 ? t(2 * e) / 2 : (2 - t(2 * (1 - e))) / 2, ye = (t) => (e) => Math.pow(e, t), be = ye(2), xe = ge(be);
317
+ function Se(t, e) {
318
+ return t.map(() => e || xe).splice(0, t.length - 1);
319
+ }
320
+ function Me(t) {
321
+ const e = t.length;
322
+ return t.map((n, r) => r !== 0 ? r / (e - 1) : 0);
323
+ }
324
+ function we(t, e) {
325
+ return t.map((n) => n * e);
326
+ }
327
+ function P({ from: t = 0, to: e = 1, ease: n, offset: r, duration: s = 300 }) {
328
+ const i = { done: !1, value: t }, o = Array.isArray(e) ? e : [t, e], l = we(r && r.length === o.length ? r : Me(o), s);
329
+ function c() {
330
+ return Vt(l, o, {
331
+ ease: Array.isArray(n) ? n : Se(o, n)
332
+ });
333
+ }
334
+ let a = c();
335
+ return {
336
+ next: (p) => (i.value = a(p), i.done = p >= s, i),
337
+ flipTarget: () => {
338
+ o.reverse(), a = c();
339
+ }
340
+ };
341
+ }
342
+ function ve({ velocity: t = 0, from: e = 0, power: n = 0.8, timeConstant: r = 350, restDelta: s = 0.5, modifyTarget: i }) {
343
+ const o = { done: !1, value: e };
344
+ let l = n * t;
345
+ const c = e + l, a = i === void 0 ? c : i(c);
346
+ return a !== c && (l = a - e), {
347
+ next: (p) => {
348
+ const m = -l * Math.exp(-p / r);
349
+ return o.done = !(m > s || m < -s), o.value = o.done ? a : a + m, o;
350
+ },
351
+ flipTarget: () => {
352
+ }
353
+ };
354
+ }
355
+ const pt = { keyframes: P, spring: Y, decay: ve };
356
+ function Ce(t) {
357
+ if (Array.isArray(t.to))
358
+ return P;
359
+ if (pt[t.type])
360
+ return pt[t.type];
361
+ const e = new Set(Object.keys(t));
362
+ return e.has("ease") || e.has("duration") && !e.has("dampingRatio") ? P : e.has("dampingRatio") || e.has("stiffness") || e.has("mass") || e.has("damping") || e.has("restSpeed") || e.has("restDelta") ? Y : P;
363
+ }
364
+ const It = 1 / 60 * 1e3, Oe = typeof performance < "u" ? () => performance.now() : () => Date.now(), jt = typeof window < "u" ? (t) => window.requestAnimationFrame(t) : (t) => setTimeout(() => t(Oe()), It);
365
+ function Te(t) {
366
+ let e = [], n = [], r = 0, s = !1, i = !1;
367
+ const o = /* @__PURE__ */ new WeakSet(), l = {
368
+ schedule: (c, a = !1, p = !1) => {
369
+ const m = p && s, u = m ? e : n;
370
+ return a && o.add(c), u.indexOf(c) === -1 && (u.push(c), m && s && (r = e.length)), c;
371
+ },
372
+ cancel: (c) => {
373
+ const a = n.indexOf(c);
374
+ a !== -1 && n.splice(a, 1), o.delete(c);
375
+ },
376
+ process: (c) => {
377
+ if (s) {
378
+ i = !0;
379
+ return;
380
+ }
381
+ if (s = !0, [e, n] = [n, e], n.length = 0, r = e.length, r)
382
+ for (let a = 0; a < r; a++) {
383
+ const p = e[a];
384
+ p(c), o.has(p) && (l.schedule(p), t());
385
+ }
386
+ s = !1, i && (i = !1, l.process(c));
387
+ }
388
+ };
389
+ return l;
390
+ }
391
+ const Ae = 40;
392
+ let z = !0, I = !1, Z = !1;
393
+ const E = {
394
+ delta: 0,
395
+ timestamp: 0
396
+ }, F = [
397
+ "read",
398
+ "update",
399
+ "preRender",
400
+ "render",
401
+ "postRender"
402
+ ], $ = F.reduce((t, e) => (t[e] = Te(() => I = !0), t), {}), Re = F.reduce((t, e) => {
403
+ const n = $[e];
404
+ return t[e] = (r, s = !1, i = !1) => (I || Ie(), n.schedule(r, s, i)), t;
405
+ }, {}), Ee = F.reduce((t, e) => (t[e] = $[e].cancel, t), {});
406
+ F.reduce((t, e) => (t[e] = () => $[e].process(E), t), {});
407
+ const Ve = (t) => $[t].process(E), Ft = (t) => {
408
+ I = !1, E.delta = z ? It : Math.max(Math.min(t - E.timestamp, Ae), 1), E.timestamp = t, Z = !0, F.forEach(Ve), Z = !1, I && (z = !1, jt(Ft));
409
+ }, Ie = () => {
410
+ I = !0, z = !0, Z || jt(Ft);
411
+ };
412
+ function Dt(t, e, n = 0) {
413
+ return t - e - n;
414
+ }
415
+ function je(t, e, n = 0, r = !0) {
416
+ return r ? Dt(e + -t, e, n) : e - (t - e) + n;
417
+ }
418
+ function Fe(t, e, n, r) {
419
+ return r ? t >= e + n : t <= -n;
420
+ }
421
+ const De = (t) => {
422
+ const e = ({ delta: n }) => t(n);
423
+ return {
424
+ start: () => Re.update(e, !0),
425
+ stop: () => Ee.update(e)
426
+ };
427
+ };
428
+ function Pe(t) {
429
+ var e, n, { from: r, autoplay: s = !0, driver: i = De, elapsed: o = 0, repeat: l = 0, repeatType: c = "loop", repeatDelay: a = 0, onPlay: p, onStop: m, onComplete: u, onRepeat: f, onUpdate: h } = t, x = ht(t, ["from", "autoplay", "driver", "elapsed", "repeat", "repeatType", "repeatDelay", "onPlay", "onStop", "onComplete", "onRepeat", "onUpdate"]);
430
+ let { to: y } = x, S, b = 0, g = x.duration, d, M = !1, w = !0, O;
431
+ const nt = Ce(x);
432
+ !((n = (e = nt).needsInterpolation) === null || n === void 0) && n.call(e, r, y) && (O = Vt([0, 100], [r, y], {
433
+ clamp: !1
434
+ }), r = 0, y = 100);
435
+ const rt = nt(Object.assign(Object.assign({}, x), { from: r, to: y }));
436
+ function Nt() {
437
+ b++, c === "reverse" ? (w = b % 2 === 0, o = je(o, g, a, w)) : (o = Dt(o, g, a), c === "mirror" && rt.flipTarget()), M = !1, f && f();
438
+ }
439
+ function kt() {
440
+ S.stop(), u && u();
441
+ }
442
+ function Ut(L) {
443
+ if (w || (L = -L), o += L, !M) {
444
+ const st = rt.next(Math.max(0, o));
445
+ d = st.value, O && (d = O(d)), M = w ? st.done : o <= 0;
446
+ }
447
+ h?.(d), M && (b === 0 && (g ?? (g = o)), b < l ? Fe(o, g, a, w) && Nt() : kt());
448
+ }
449
+ function $t() {
450
+ p?.(), S = i(Ut), S.start();
451
+ }
452
+ return s && $t(), {
453
+ stop: () => {
454
+ m?.(), S.stop();
455
+ }
456
+ };
457
+ }
458
+ class T {
459
+ options;
460
+ currentValue;
461
+ velocity = 0;
462
+ isAnimating = !1;
463
+ controls = null;
464
+ constructor(e) {
465
+ this.options = {
466
+ from: e.from ?? 0,
467
+ to: e.to ?? 1,
468
+ spring: e.spring ?? { stiffness: 100, damping: 10 },
469
+ onUpdate: e.onUpdate ?? (() => {
470
+ }),
471
+ onComplete: e.onComplete ?? (() => {
472
+ }),
473
+ onStart: e.onStart
474
+ }, this.currentValue = this.options.from;
475
+ }
476
+ animate = (e = !1) => {
477
+ !this.isAnimating && this.options.onStart && this.options.onStart(), this.isAnimating = !0;
478
+ const n = e ? this.options.from : this.options.to;
479
+ let r = this.currentValue, s = performance.now();
480
+ this.controls = Pe({
481
+ from: this.currentValue,
482
+ to: n,
483
+ velocity: this.velocity * 1e3,
484
+ // Convert to px/s
485
+ stiffness: this.options.spring.stiffness,
486
+ damping: this.options.spring.damping,
487
+ mass: 1,
488
+ onUpdate: (i) => {
489
+ const o = performance.now(), l = (o - s) / 1e3;
490
+ if (l > 0) {
491
+ const c = (i - r) / l;
492
+ this.velocity = c / 1e3, r = i, s = o;
493
+ }
494
+ this.currentValue = i, this.options.onUpdate(i);
495
+ },
496
+ onComplete: () => {
497
+ this.currentValue = n, this.isAnimating = !1, this.controls = null, this.velocity = 0, this.options.onComplete();
498
+ }
499
+ });
500
+ };
501
+ // Animation control methods
502
+ forward() {
503
+ this.stop(), this.animate(!1);
504
+ }
505
+ backward() {
506
+ this.stop(), this.animate(!0);
507
+ }
508
+ reverse() {
509
+ const e = this.options.from;
510
+ if (this.options.from = this.options.to, this.options.to = e, this.isAnimating) {
511
+ const n = this.currentValue > (this.options.from + this.options.to) / 2;
512
+ this.stop(), this.animate(!n);
513
+ }
514
+ }
515
+ stop() {
516
+ this.isAnimating = !1, this.controls && (this.controls.stop(), this.controls = null);
517
+ }
518
+ // State getters
519
+ getVelocity() {
520
+ return this.velocity;
521
+ }
522
+ getCurrentValue() {
523
+ return this.currentValue;
524
+ }
525
+ getIsAnimating() {
526
+ return this.isAnimating;
527
+ }
528
+ getCurrentState() {
529
+ return {
530
+ position: this.currentValue,
531
+ velocity: this.velocity
532
+ };
533
+ }
534
+ // State setters
535
+ setVelocity(e) {
536
+ this.velocity = e;
537
+ }
538
+ setValue(e) {
539
+ this.currentValue = e;
540
+ }
541
+ // Configuration
542
+ updateOptions(e) {
543
+ if (this.options = { ...this.options, ...e }, this.isAnimating && this.controls) {
544
+ const n = this.currentValue < this.options.to;
545
+ this.stop(), this.animate(!n);
546
+ }
547
+ }
548
+ // Static factory method
549
+ static fromState(e, n) {
550
+ const r = new T(n);
551
+ return r.setValue(e.position), r.setVelocity(e.velocity), r;
552
+ }
553
+ }
554
+ function Ne(t, e) {
555
+ let n = null, r = null, s = null, i = null, o = !1;
556
+ const l = async (a) => {
557
+ if (n && n.getIsAnimating() && !o) {
558
+ const p = n.getCurrentState();
559
+ n.stop(), r && (r.remove(), r = null), o = !0;
560
+ const m = t();
561
+ if (!m.out) return;
562
+ const u = await Promise.resolve(m.out(a));
563
+ n = T.fromState(p, {
564
+ from: 1,
565
+ to: 0,
566
+ spring: u.spring,
567
+ onStart: u.onStart,
568
+ onUpdate: (f) => {
569
+ u.tick?.(f);
570
+ },
571
+ onComplete: () => {
572
+ n = null, o = !1, u.onEnd?.();
573
+ }
574
+ }), n.backward();
575
+ return;
576
+ }
577
+ if (!n || !n.getIsAnimating()) {
578
+ o = !0;
579
+ const p = t();
580
+ if (!p.in) return;
581
+ const m = await Promise.resolve(p.in(a));
582
+ m.prepare?.(a), n = new T({
583
+ from: 0,
584
+ to: 1,
585
+ spring: m.spring,
586
+ onStart: m.onStart,
587
+ onUpdate: (u) => {
588
+ m.tick?.(u);
589
+ },
590
+ onComplete: () => {
591
+ n = null, o = !1, m.onEnd?.();
592
+ }
593
+ }), n.forward();
594
+ }
595
+ };
596
+ function c(a) {
597
+ const p = () => {
598
+ !s || !r || (i && s.contains(i) ? s.insertBefore(r, i) : s.appendChild(r));
599
+ }, m = () => {
600
+ r && (r.remove(), r = null), n = null, o = !1, e?.onCleanupEnd?.();
601
+ }, u = t();
602
+ if (r = a.cloneNode(!0), n && n.getIsAnimating() && o) {
603
+ const f = n.getCurrentState();
604
+ if (n.stop(), o = !1, !u.in) {
605
+ r = null, m();
606
+ return;
607
+ }
608
+ Promise.resolve(u.in(r)).then(async (h) => {
609
+ const x = r && await u.out?.(r);
610
+ x?.prepare && r && x.prepare(r), p(), n = T.fromState(f, {
611
+ from: 0,
612
+ to: 1,
613
+ spring: h.spring,
614
+ onStart: h.onStart,
615
+ onUpdate: (y) => {
616
+ h.tick?.(y);
617
+ },
618
+ onComplete: () => {
619
+ h.onEnd?.(), m();
620
+ }
621
+ }), n.backward();
622
+ });
623
+ return;
624
+ }
625
+ if (!n || !n.getIsAnimating() || !o) {
626
+ if (o = !1, !u.out) {
627
+ r = null, m();
628
+ return;
629
+ }
630
+ Promise.resolve(u.out(r)).then((f) => {
631
+ r && f.prepare?.(r), p(), n = new T({
632
+ from: 1,
633
+ to: 0,
634
+ spring: f.spring,
635
+ onStart: f.onStart,
636
+ onUpdate: (h) => {
637
+ f.tick?.(h);
638
+ },
639
+ onComplete: () => {
640
+ f.onEnd?.(), m();
641
+ }
642
+ }), n.forward();
643
+ });
644
+ }
645
+ }
646
+ return (a) => a ? (s = a.parentElement, i = a.nextElementSibling, t().in && l(a), () => {
647
+ c(a);
648
+ }) : void 0;
649
+ }
650
+ const J = /* @__PURE__ */ new Map(), Q = /* @__PURE__ */ new Map();
651
+ function ke(t, e) {
652
+ J.set(t, e);
653
+ let n = Q.get(t);
654
+ return n || (n = Ne(
655
+ () => {
656
+ const r = J.get(t);
657
+ return r || (console.warn(`Transition "${String(t)}" not found`), {});
658
+ },
659
+ {
660
+ onCleanupEnd: () => Ue(t)
661
+ }
662
+ ), Q.set(t, n), n);
663
+ }
664
+ function Ue(t) {
665
+ J.delete(t), Q.delete(t);
666
+ }
667
+ function $e(t) {
668
+ return ke(t.key, {
669
+ in: t.in,
670
+ out: t.out
671
+ });
672
+ }
673
+ function Le(t) {
674
+ let e = null;
675
+ const n = [...t.transitions], r = [];
676
+ for (const u of t.transitions)
677
+ u.symmetric && (n.some(
678
+ (h) => h.from === u.to && h.to === u.from
679
+ ) || r.push({
680
+ from: u.to,
681
+ to: u.from,
682
+ transition: u.transition
683
+ // Don't add symmetric flag to the reverse to avoid infinite loop
684
+ }));
685
+ n.push(...r);
686
+ let s = null;
687
+ const i = /* @__PURE__ */ new Map();
688
+ let o = null;
689
+ const l = () => {
690
+ s && o && i.set(o, {
691
+ x: s.scrollLeft,
692
+ y: s.scrollTop
693
+ });
694
+ }, c = (u, f) => {
695
+ s || (s = _t(u), s.addEventListener("scroll", l, {
696
+ passive: !0
697
+ })), o = f;
698
+ }, a = () => {
699
+ const u = e?.from, f = e?.to, h = u && i.has(u) ? i.get(u) : { x: 0, y: 0 }, x = f && i.has(f) ? i.get(f) : { x: 0, y: 0 };
700
+ return {
701
+ x: -x.x + h.x,
702
+ y: -x.y + h.y
703
+ };
704
+ };
705
+ function p() {
706
+ if (e?.from && e?.to) {
707
+ const f = qe(
708
+ e.from,
709
+ e.to,
710
+ n
711
+ ) || t.defaultTransition, x = { scrollOffset: a() };
712
+ f && (f.out && e.outResolve && e.outResolve(
713
+ (y) => f.out(y, x)
714
+ ), f.in && e.inResolve && e.inResolve(
715
+ (y) => f.in(y, x)
716
+ )), e = null;
717
+ }
718
+ }
719
+ const m = async (u, f) => f === "in" && (!e || !e.from) ? () => ({}) : (e || (e = {}), f === "out" ? (e.from = u, new Promise((h) => {
720
+ e.outResolve = h, p();
721
+ })) : (e.to = u, new Promise((h) => {
722
+ e.inResolve = h, p();
723
+ })));
724
+ return (u) => ({
725
+ key: u,
726
+ in: async (f) => (c(f, u), (await m(u, "in"))(f)),
727
+ out: async (f) => (await m(u, "out"))(f)
728
+ });
729
+ }
730
+ function qe(t, e, n) {
731
+ for (const r of n)
732
+ if (D(t, r.from) && D(e, r.to))
733
+ return r.transition;
734
+ for (const r of n)
735
+ if ((r.from === "*" || D(t, r.from)) && (r.to === "*" || D(e, r.to)))
736
+ return r.transition;
737
+ return null;
738
+ }
739
+ function D(t, e) {
740
+ if (e === "*")
741
+ return !0;
742
+ if (e.endsWith("/*")) {
743
+ const n = e.slice(0, -2);
744
+ return t === n || t.startsWith(n + "/");
745
+ }
746
+ return t === e;
747
+ }
748
+ const Be = $e, Pt = Lt(null), _e = Pt.Provider, We = () => {
749
+ const t = qt(Pt);
750
+ if (!t)
751
+ throw new Error("useSsgoi must be used within SsgoiProvider");
752
+ return t;
753
+ }, ze = ({ config: t, children: e }) => {
754
+ const n = Bt(
755
+ () => Le(t),
756
+ [t]
757
+ );
758
+ return /* @__PURE__ */ mt(_e, { value: n, children: e });
759
+ }, Ze = ({
760
+ children: t,
761
+ id: e
762
+ }) => {
763
+ const n = We();
764
+ return /* @__PURE__ */ mt("div", { ref: Be(n(e)), "data-ssgoi-transition": e, children: t });
765
+ };
766
+ export {
767
+ ze as Ssgoi,
768
+ Ze as SsgoiTransition,
769
+ Be as transition
770
+ };