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