cos-design 2.2.0 → 2.4.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 CHANGED
@@ -1,113 +1,298 @@
1
- import { useCallback as e, useEffect as t, useRef as n, useState as r } from "react";
2
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
3
- import './index.css';var o = {
4
- canvasClock: "cos-canvasClock",
5
- canvasTarget: "cos-canvasTarget"
6
- }, s = ({ width: r = 400, height: a = 400 }) => {
7
- let s = n(null), c = Math.min(r, a), l = c / 2 - 16, u = c / 2, d = e((e) => {
8
- e.clearRect(0, 0, c, c), e.save(), e.translate(u, u), e.beginPath(), e.arc(0, 0, l, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill(), e.strokeStyle = "#d1d5db", e.lineWidth = 2, e.stroke();
1
+ import { forwardRef as e, useCallback as t, useEffect as n, useImperativeHandle as r, useMemo as i, useRef as a, useState as o } from "react";
2
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
3
+ import './index.css';var u = {
4
+ canvasClock: "cos-canvasClock-QvdV3",
5
+ canvasTarget: "cos-canvasTarget-x-odC"
6
+ }, d = ({ width: e = 400, height: r = 400 }) => {
7
+ let i = a(null), o = Math.min(e, r), s = o / 2 - 16, l = o / 2, d = t((e) => {
8
+ e.clearRect(0, 0, o, o), e.save(), e.translate(l, l), e.beginPath(), e.arc(0, 0, s, 0, Math.PI * 2), e.fillStyle = "#fff", e.fill(), e.strokeStyle = "#d1d5db", e.lineWidth = 2, e.stroke();
9
9
  for (let t = 0; t < 60; t++) {
10
- let n = t / 60 * Math.PI * 2, r = l - (t % 5 == 0 ? 14 : 8);
11
- e.beginPath(), e.moveTo(Math.cos(n) * r, Math.sin(n) * r), e.lineTo(Math.cos(n) * l, Math.sin(n) * l), e.strokeStyle = t % 5 == 0 ? "#374151" : "#9ca3af", e.lineWidth = t % 5 == 0 ? 2 : 1, e.stroke();
10
+ let n = t / 60 * Math.PI * 2, r = s - (t % 5 == 0 ? 14 : 8);
11
+ e.beginPath(), e.moveTo(Math.cos(n) * r, Math.sin(n) * r), e.lineTo(Math.cos(n) * s, Math.sin(n) * s), e.strokeStyle = t % 5 == 0 ? "#374151" : "#9ca3af", e.lineWidth = t % 5 == 0 ? 2 : 1, e.stroke();
12
12
  }
13
- e.fillStyle = "#111827", e.font = `bold ${Math.floor(c / 22)}px system-ui, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
13
+ e.fillStyle = "#111827", e.font = `bold ${Math.floor(o / 22)}px system-ui, sans-serif`, e.textAlign = "center", e.textBaseline = "middle";
14
14
  for (let t = 1; t <= 12; t++) {
15
- let n = t / 12 * Math.PI * 2 - Math.PI / 2, r = l - 32;
15
+ let n = t / 12 * Math.PI * 2 - Math.PI / 2, r = s - 32;
16
16
  e.fillText(String(t), Math.cos(n) * r, Math.sin(n) * r);
17
17
  }
18
- let t = /* @__PURE__ */ new Date(), n = t.getHours() % 12, r = t.getMinutes(), i = t.getSeconds(), a = t.getMilliseconds(), o = (t, n, r, i, a) => {
18
+ let t = /* @__PURE__ */ new Date(), n = t.getHours() % 12, r = t.getMinutes(), i = t.getSeconds(), a = t.getMilliseconds(), c = (t, n, r, i, a) => {
19
19
  e.save(), e.rotate(t), e.beginPath(), e.moveTo(0, r), e.lineTo(n, 0), e.lineTo(0, -r), e.closePath(), e.fillStyle = i, e.shadowColor = a, e.shadowBlur = 4, e.fill(), e.restore();
20
- }, s = (n + r / 60) / 12 * Math.PI * 2 - Math.PI / 2, d = (r + i / 60) / 60 * Math.PI * 2 - Math.PI / 2, f = (i + a / 1e3) / 60 * Math.PI * 2 - Math.PI / 2;
21
- o(s, l * .5, 4, "#111827", "rgb(0 0 0 / 40%)"), o(d, l * .72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), o(f, l * .85, 2, "#e9686b", "rgb(233 104 107 / 40%)"), e.beginPath(), e.arc(0, 0, 5, 0, Math.PI * 2), e.fillStyle = "#111827", e.fill(), e.restore();
20
+ }, u = (n + r / 60) / 12 * Math.PI * 2 - Math.PI / 2, d = (r + i / 60) / 60 * Math.PI * 2 - Math.PI / 2, f = (i + a / 1e3) / 60 * Math.PI * 2 - Math.PI / 2;
21
+ c(u, s * .5, 4, "#111827", "rgb(0 0 0 / 40%)"), c(d, s * .72, 3, "#1e80ff", "rgb(30 128 255 / 40%)"), c(f, s * .85, 2, "#e9686b", "rgb(233 104 107 / 40%)"), e.beginPath(), e.arc(0, 0, 5, 0, Math.PI * 2), e.fillStyle = "#111827", e.fill(), e.restore();
22
22
  }, [
23
- u,
24
23
  l,
25
- c
24
+ s,
25
+ o
26
26
  ]);
27
- return t(() => {
28
- let e = s.current;
27
+ return n(() => {
28
+ let e = i.current;
29
29
  if (!e) return;
30
30
  let t = window.devicePixelRatio || 1;
31
- e.width = c * t, e.height = c * t;
31
+ e.width = o * t, e.height = o * t;
32
32
  let n = e.getContext("2d");
33
33
  if (!n) return;
34
34
  n.setTransform(t, 0, 0, t, 0, 0);
35
- let r = 0, i = () => {
36
- d(n), r = requestAnimationFrame(i);
35
+ let r = 0, a = () => {
36
+ d(n), r = requestAnimationFrame(a);
37
37
  };
38
- return i(), () => cancelAnimationFrame(r);
39
- }, [d, c]), /* @__PURE__ */ i("div", {
40
- className: o.canvasClock,
38
+ return a(), () => cancelAnimationFrame(r);
39
+ }, [d, o]), /* @__PURE__ */ c("div", {
40
+ className: u.canvasClock,
41
41
  style: {
42
- width: c,
43
- height: c
42
+ width: o,
43
+ height: o
44
44
  },
45
- children: /* @__PURE__ */ i("canvas", {
46
- ref: s,
47
- className: o.canvasTarget,
45
+ children: /* @__PURE__ */ c("canvas", {
46
+ ref: i,
47
+ className: u.canvasTarget,
48
48
  style: {
49
- width: c,
50
- height: c
49
+ width: o,
50
+ height: o
51
51
  }
52
52
  })
53
53
  });
54
- }, c = {
55
- chargeContainer: "cos-chargeContainer",
56
- contrast: "cos-contrast",
57
- hueRotate: "cos-hueRotate",
58
- text: "cos-text",
59
- moveUp: "cos-moveUp",
60
- circle: "cos-circle",
61
- circleRotate: "cos-circleRotate",
62
- button: "cos-button"
63
- }, l = (e) => {
64
- let { initQuantity: n = 0 } = e, [o, s] = r(n);
65
- return t(() => {
66
- let e = o;
67
- setInterval(() => {
68
- e = Number(Number(e += .01).toFixed(2)), s(e);
69
- }, 500);
70
- }, []), /* @__PURE__ */ i("div", {
71
- className: c.chargeContainer,
72
- children: /* @__PURE__ */ a("div", {
73
- className: c.contrast,
54
+ }, f = (e) => {
55
+ let t = () => e(document.hidden);
56
+ return document.addEventListener("visibilitychange", t), () => document.removeEventListener("visibilitychange", t);
57
+ }, p = (e, t, n) => Math.min(n, Math.max(t, e)), m = {
58
+ chargeContainer: "cos-chargeContainer-4t9qo",
59
+ contrast: "cos-contrast-PNep9",
60
+ hueRotate: "cos-hueRotate-bMJ-k",
61
+ text: "cos-text-2k7eH",
62
+ moveUp: "cos-moveUp-1Vz9j",
63
+ circle: "cos-circle-m4vwX",
64
+ circleRotate: "cos-circleRotate-bgFw5",
65
+ button: "cos-button-myCst"
66
+ }, h = (e) => {
67
+ let { initQuantity: t = 0, value: r, onChange: i, autoCharge: s = !0, interval: u = 500, step: d = .01 } = e, f = a(null), h = r !== void 0, [g, _] = o(() => p(t, 0, 100)), v = p(h ? r : g, 0, 100), y = a(v), b = a(i);
68
+ n(() => {
69
+ b.current = i;
70
+ }, [i]), n(() => {
71
+ y.current = v;
72
+ }, [v]), n(() => {
73
+ let e = f.current;
74
+ if (!e) return;
75
+ let t = () => {
76
+ e.style.setProperty("--charge-h", `${e.clientHeight}px`);
77
+ };
78
+ t();
79
+ let n = new ResizeObserver(t);
80
+ return n.observe(e), () => n.disconnect();
81
+ }, []), n(() => {
82
+ if (!s) return;
83
+ let e = window.setInterval(() => {
84
+ if (y.current >= 100) return;
85
+ let e = Math.min(100, Number((y.current + d).toFixed(2)));
86
+ h ? b.current?.(e) : _(e);
87
+ }, u);
88
+ return () => clearInterval(e);
89
+ }, [
90
+ s,
91
+ u,
92
+ h,
93
+ d
94
+ ]);
95
+ let x = v.toFixed(2);
96
+ return /* @__PURE__ */ c("div", {
97
+ ref: f,
98
+ className: m.chargeContainer,
99
+ children: /* @__PURE__ */ l("div", {
100
+ className: m.contrast,
74
101
  children: [
75
- /* @__PURE__ */ a("div", {
76
- className: c.text,
77
- children: [o ? o.toString().padEnd(4, "0") : 0, "%"]
102
+ /* @__PURE__ */ l("div", {
103
+ className: m.text,
104
+ children: [x, "%"]
78
105
  }),
79
- /* @__PURE__ */ i("span", {}),
80
- /* @__PURE__ */ i("span", {}),
81
- /* @__PURE__ */ i("span", {}),
82
- /* @__PURE__ */ i("span", {}),
83
- /* @__PURE__ */ i("span", {}),
84
- /* @__PURE__ */ i("span", {}),
85
- /* @__PURE__ */ i("span", {}),
86
- /* @__PURE__ */ i("span", {}),
87
- /* @__PURE__ */ i("span", {}),
88
- /* @__PURE__ */ i("span", {}),
89
- /* @__PURE__ */ i("span", {}),
90
- /* @__PURE__ */ i("span", {}),
91
- /* @__PURE__ */ i("span", {}),
92
- /* @__PURE__ */ i("span", {}),
93
- /* @__PURE__ */ i("span", {}),
94
- /* @__PURE__ */ i("div", { className: c.circle }),
95
- /* @__PURE__ */ i("div", { className: c.button })
106
+ /* @__PURE__ */ c("span", {}),
107
+ /* @__PURE__ */ c("span", {}),
108
+ /* @__PURE__ */ c("span", {}),
109
+ /* @__PURE__ */ c("span", {}),
110
+ /* @__PURE__ */ c("span", {}),
111
+ /* @__PURE__ */ c("span", {}),
112
+ /* @__PURE__ */ c("span", {}),
113
+ /* @__PURE__ */ c("span", {}),
114
+ /* @__PURE__ */ c("span", {}),
115
+ /* @__PURE__ */ c("span", {}),
116
+ /* @__PURE__ */ c("span", {}),
117
+ /* @__PURE__ */ c("span", {}),
118
+ /* @__PURE__ */ c("span", {}),
119
+ /* @__PURE__ */ c("span", {}),
120
+ /* @__PURE__ */ c("span", {}),
121
+ /* @__PURE__ */ c("div", { className: m.circle }),
122
+ /* @__PURE__ */ c("div", { className: m.button })
96
123
  ]
97
124
  })
98
125
  });
99
- }, u = {
100
- fireworks: "cos-fireworks",
101
- canvas: "cos-canvas",
102
- hint: "cos-hint"
103
- }, d = [
126
+ }, g = {
127
+ confetti: "cos-confetti-MeNtU",
128
+ canvas: "cos-canvas-0T3Vs",
129
+ hint: "cos-hint-sGHEi"
130
+ }, _ = [
131
+ "#ff6b6b",
132
+ "#ffd93d",
133
+ "#6bcb77",
134
+ "#4d96ff",
135
+ "#a66cff",
136
+ "#ff85c0",
137
+ "#38bdf8"
138
+ ], v = () => _[Math.floor(Math.random() * _.length)], y = (e, t, n) => {
139
+ let r = e / 2, i = t * .6;
140
+ return Array.from({ length: n }, () => {
141
+ let e = (Math.random() - .5) * Math.PI, t = Math.random() * 12 + 6;
142
+ return {
143
+ x: r + (Math.random() - .5) * 40,
144
+ y: i,
145
+ vx: Math.cos(e) * t,
146
+ vy: Math.sin(e) * t - Math.random() * 8,
147
+ rotation: Math.random() * 360,
148
+ rotationSpeed: (Math.random() - .5) * 12,
149
+ color: v(),
150
+ width: Math.random() * 8 + 4,
151
+ height: Math.random() * 6 + 3,
152
+ alpha: 1,
153
+ gravity: Math.random() * .15 + .12
154
+ };
155
+ });
156
+ }, b = e(({ width: e = 800, height: i = 400, auto: o = !0, particleCount: s = 120 }, u) => {
157
+ let d = a(null), p = a([]), m = a(0), h = a({
158
+ width: e,
159
+ height: i,
160
+ particleCount: s
161
+ });
162
+ h.current = {
163
+ width: e,
164
+ height: i,
165
+ particleCount: s
166
+ };
167
+ let _ = t(() => {
168
+ let { width: e, height: t, particleCount: n } = h.current;
169
+ p.current.push(...y(e, t, n));
170
+ }, []);
171
+ return r(u, () => ({ burst: _ }), [_]), n(() => {
172
+ o && _();
173
+ }, [o, _]), n(() => {
174
+ let t = d.current;
175
+ if (!t) return;
176
+ let n = window.devicePixelRatio || 1;
177
+ t.width = e * n, t.height = i * n;
178
+ let r = t.getContext("2d");
179
+ if (!r) return;
180
+ r.setTransform(n, 0, 0, n, 0, 0);
181
+ let a = document.hidden, o = f((e) => {
182
+ a = e;
183
+ }), s = () => {
184
+ m.current = requestAnimationFrame(s), !a && (r.clearRect(0, 0, e, i), p.current = p.current.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += e.gravity, e.vx *= .99, e.rotation += e.rotationSpeed, e.alpha -= .008, e.alpha <= 0 || e.y > i + 20 ? !1 : (r.save(), r.translate(e.x, e.y), r.rotate(e.rotation * Math.PI / 180), r.globalAlpha = e.alpha, r.fillStyle = e.color, r.fillRect(-e.width / 2, -e.height / 2, e.width, e.height), r.restore(), !0))));
185
+ };
186
+ return s(), () => {
187
+ cancelAnimationFrame(m.current), o();
188
+ };
189
+ }, [i, e]), /* @__PURE__ */ l("div", {
190
+ className: g.confetti,
191
+ style: {
192
+ width: e,
193
+ height: i
194
+ },
195
+ children: [/* @__PURE__ */ c("canvas", {
196
+ ref: d,
197
+ className: g.canvas,
198
+ style: {
199
+ width: e,
200
+ height: i
201
+ },
202
+ onClick: _
203
+ }), /* @__PURE__ */ c("p", {
204
+ className: g.hint,
205
+ children: "点击画布再次喷射"
206
+ })]
207
+ });
208
+ });
209
+ b.displayName = "Confetti";
210
+ var x = {
211
+ countdown: "cos-countdown-5ZKKP",
212
+ unit: "cos-unit-dth8N",
213
+ value: "cos-value-yVzcP",
214
+ label: "cos-label-pAMEs",
215
+ ended: "cos-ended-c0dsD",
216
+ pulse: "cos-pulse-krQd-",
217
+ invalid: "cos-invalid-d6t-L"
218
+ }, S = (e) => e instanceof Date ? e.getTime() : typeof e == "number" ? e : new Date(e).getTime(), C = (e) => {
219
+ let t = Math.max(0, e - Date.now()), n = Math.floor(t / 1e3);
220
+ return {
221
+ total: t,
222
+ days: Math.floor(n / 86400),
223
+ hours: Math.floor(n % 86400 / 3600),
224
+ minutes: Math.floor(n % 3600 / 60),
225
+ seconds: n % 60
226
+ };
227
+ }, ee = [
228
+ {
229
+ key: "days",
230
+ label: "天"
231
+ },
232
+ {
233
+ key: "hours",
234
+ label: "时"
235
+ },
236
+ {
237
+ key: "minutes",
238
+ label: "分"
239
+ },
240
+ {
241
+ key: "seconds",
242
+ label: "秒"
243
+ }
244
+ ], w = ({ targetDate: e, onEnd: t, showLabels: r = !0, color: s = "#f472b6" }) => {
245
+ let u = i(() => S(e), [e]), d = !Number.isNaN(u), [, f] = o(0), p = a(!1), m = a(t), h = d ? C(u) : {
246
+ days: 0,
247
+ hours: 0,
248
+ minutes: 0,
249
+ seconds: 0,
250
+ total: 0
251
+ };
252
+ return n(() => {
253
+ m.current = t;
254
+ }, [t]), n(() => {
255
+ if (!d) return;
256
+ p.current = !1;
257
+ let e = window.setInterval(() => {
258
+ f((e) => e + 1), Date.now() >= u && !p.current && (p.current = !0, m.current?.(), clearInterval(e));
259
+ }, 1e3);
260
+ return () => clearInterval(e);
261
+ }, [d, u]), d ? /* @__PURE__ */ l("div", {
262
+ className: x.countdown,
263
+ style: { "--countdown-color": s },
264
+ children: [ee.map(({ key: e, label: t }) => /* @__PURE__ */ l("div", {
265
+ className: x.unit,
266
+ children: [/* @__PURE__ */ c("div", {
267
+ className: x.value,
268
+ children: String(h[e]).padStart(2, "0")
269
+ }), r && /* @__PURE__ */ c("span", {
270
+ className: x.label,
271
+ children: t
272
+ })]
273
+ }, e)), h.total <= 0 && /* @__PURE__ */ c("p", {
274
+ className: x.ended,
275
+ children: "时间到!"
276
+ })]
277
+ }) : /* @__PURE__ */ c("div", {
278
+ className: x.countdown,
279
+ children: /* @__PURE__ */ c("p", {
280
+ className: x.invalid,
281
+ children: "无效的目标时间"
282
+ })
283
+ });
284
+ }, T = {
285
+ fireworks: "cos-fireworks-fsSqL",
286
+ canvas: "cos-canvas-spL8G",
287
+ hint: "cos-hint-5XDRH"
288
+ }, E = [
104
289
  "#ff6b6b",
105
290
  "#ffd93d",
106
291
  "#6bcb77",
107
292
  "#4d96ff",
108
293
  "#a66cff",
109
294
  "#ff85c0"
110
- ], f = () => d[Math.floor(Math.random() * d.length)], p = (e, t, n) => {
295
+ ], D = .12, O = 240, k = () => E[Math.floor(Math.random() * E.length)], A = (e, t, n) => {
111
296
  let r = 60 + Math.floor(Math.random() * 30);
112
297
  return Array.from({ length: r }, () => {
113
298
  let r = Math.random() * Math.PI * 2, i = Math.random() * 4 + 2;
@@ -117,268 +302,443 @@ import './index.css';var o = {
117
302
  vx: Math.cos(r) * i,
118
303
  vy: Math.sin(r) * i,
119
304
  alpha: 1,
120
- color: Math.random() > .3 ? n : f(),
305
+ color: Math.random() > .3 ? n : k(),
121
306
  decay: Math.random() * .015 + .01
122
307
  };
123
308
  });
124
- }, m = ({ width: r = 800, height: o = 500, auto: s = !0 }) => {
125
- let c = n(null), l = n([]), d = n(0), m = e((e) => {
126
- let t = e ?? Math.random() * r * .6 + r * .2;
127
- l.current.push({
128
- x: t,
129
- y: o,
309
+ }, j = e(({ width: e = 800, height: i = 500, auto: o = !0 }, s) => {
310
+ let u = a(null), d = a([]), p = a(0), m = t((t) => {
311
+ let n = t ?? Math.random() * e * .6 + e * .2;
312
+ d.current.push({
313
+ x: n,
314
+ y: i,
130
315
  vy: -(Math.random() * 4 + 6),
131
- targetY: Math.random() * o * .4 + o * .1,
132
- color: f(),
316
+ targetY: Math.random() * i * .35 + i * .15,
317
+ color: k(),
133
318
  exploded: !1,
134
- particles: []
319
+ particles: [],
320
+ age: 0
135
321
  });
136
- }, [o, r]);
137
- return t(() => {
138
- let e = c.current;
139
- if (!e) return;
140
- let t = window.devicePixelRatio || 1;
141
- e.width = r * t, e.height = o * t;
142
- let n = e.getContext("2d");
143
- if (!n) return;
144
- n.setTransform(t, 0, 0, t, 0, 0);
145
- let i = 0, a = () => {
146
- d.current = requestAnimationFrame(a), n.fillStyle = "rgb(15 23 42 / 25%)", n.fillRect(0, 0, r, o), s && Math.random() < .03 && m(), l.current = l.current.filter((e) => e.exploded ? (e.particles = e.particles.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += .06, e.alpha -= e.decay, e.alpha <= 0 ? !1 : (n.beginPath(), n.arc(e.x, e.y, 2, 0, Math.PI * 2), n.fillStyle = e.color, n.globalAlpha = e.alpha, n.fill(), n.globalAlpha = 1, !0))), e.particles.length > 0) : (e.y += e.vy, e.vy *= .98, n.beginPath(), n.arc(e.x, e.y, 2.5, 0, Math.PI * 2), n.fillStyle = e.color, n.fill(), (e.vy >= 0 || e.y <= e.targetY) && (e.exploded = !0, e.particles = p(e.x, e.y, e.color)), !0));
322
+ }, [i, e]);
323
+ return r(s, () => ({ launch: m }), [m]), n(() => {
324
+ let t = u.current;
325
+ if (!t) return;
326
+ let n = window.devicePixelRatio || 1;
327
+ t.width = e * n, t.height = i * n;
328
+ let r = t.getContext("2d");
329
+ if (!r) return;
330
+ r.setTransform(n, 0, 0, n, 0, 0);
331
+ let a = 0, s = document.hidden, c = f((e) => {
332
+ s = e;
333
+ }), l = () => {
334
+ p.current = requestAnimationFrame(l), !s && (r.fillStyle = "rgb(15 23 42 / 25%)", r.fillRect(0, 0, e, i), d.current = d.current.filter((e) => {
335
+ if (!e.exploded) {
336
+ e.age += 1, e.y += e.vy, e.vy += D, r.beginPath(), r.arc(e.x, e.y, 2.5, 0, Math.PI * 2), r.fillStyle = e.color, r.fill();
337
+ let t = e.vy >= 0, n = e.y <= e.targetY, i = e.y < 0, a = e.age >= O;
338
+ return (t || n || i || a) && (e.exploded = !0, e.particles = A(e.x, e.y, e.color)), !0;
339
+ }
340
+ return e.particles = e.particles.filter((e) => (e.x += e.vx, e.y += e.vy, e.vy += .06, e.alpha -= e.decay, e.alpha <= 0 ? !1 : (r.beginPath(), r.arc(e.x, e.y, 2, 0, Math.PI * 2), r.fillStyle = e.color, r.globalAlpha = e.alpha, r.fill(), r.globalAlpha = 1, !0))), e.particles.length > 0;
341
+ }));
147
342
  };
148
- return a(), s && (i = window.setInterval(() => m(), 1200)), () => {
149
- cancelAnimationFrame(d.current), clearInterval(i);
343
+ return l(), o && (a = window.setInterval(() => m(), 1200)), () => {
344
+ cancelAnimationFrame(p.current), clearInterval(a), c();
150
345
  };
151
346
  }, [
152
- s,
153
347
  o,
348
+ i,
154
349
  m,
155
- r
156
- ]), /* @__PURE__ */ a("div", {
157
- className: u.fireworks,
350
+ e
351
+ ]), /* @__PURE__ */ l("div", {
352
+ className: T.fireworks,
158
353
  style: {
159
- width: r,
160
- height: o
354
+ width: e,
355
+ height: i
161
356
  },
162
- children: [/* @__PURE__ */ i("canvas", {
163
- ref: c,
164
- className: u.canvas,
357
+ children: [/* @__PURE__ */ c("canvas", {
358
+ ref: u,
359
+ className: T.canvas,
165
360
  style: {
166
- width: r,
167
- height: o
361
+ width: e,
362
+ height: i
168
363
  },
169
364
  onClick: (e) => {
170
365
  let t = e.currentTarget.getBoundingClientRect();
171
366
  m(e.clientX - t.left);
172
367
  }
173
- }), /* @__PURE__ */ i("p", {
174
- className: u.hint,
368
+ }), /* @__PURE__ */ c("p", {
369
+ className: T.hint,
175
370
  children: "点击画布燃放烟花"
176
371
  })]
177
372
  });
178
- }, h = {
179
- matrixRain: "cos-matrixRain",
180
- canvas: "cos-canvas",
181
- overlay: "cos-overlay",
182
- title: "cos-title",
183
- flicker: "cos-flicker",
184
- subtitle: "cos-subtitle"
185
- }, g = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", _ = ({ width: e = 800, height: r = 500, density: o = .6, color: s = "#00ff41" }) => {
186
- let c = n(null);
187
- return t(() => {
188
- let t = c.current;
189
- if (!t) return;
190
- let n = window.devicePixelRatio || 1;
191
- t.width = e * n, t.height = r * n;
192
- let i = t.getContext("2d");
193
- if (!i) return;
194
- i.setTransform(n, 0, 0, n, 0, 0);
195
- let a = Math.floor(e / 16 * o), l = Array.from({ length: a }, () => Math.random() * -50), u = 0, d = () => {
196
- i.fillStyle = "rgb(0 0 0 / 8%)", i.fillRect(0, 0, e, r), i.fillStyle = s, i.font = "16px monospace", l.forEach((e, t) => {
197
- let n = g[Math.floor(Math.random() * 53)], a = t / o * 16;
198
- i.fillStyle = s, i.fillText(n, a, e * 16), e * 16 > r && Math.random() > .975 && (l[t] = 0), l[t] += 1;
199
- }), u = requestAnimationFrame(d);
373
+ });
374
+ j.displayName = "Fireworks";
375
+ var M = {
376
+ flipCounter: "cos-flipCounter-3LuI0",
377
+ digit: "cos-digit-yJRPy",
378
+ digitCard: "cos-digitCard-zZUzt",
379
+ staticTop: "cos-staticTop-aLQcm",
380
+ staticBottom: "cos-staticBottom-9y0gu",
381
+ flap: "cos-flap-i3YKR",
382
+ flapTop: "cos-flapTop-70z-k",
383
+ flapBottom: "cos-flapBottom-zhMZe",
384
+ isFlipping: "cos-isFlipping-EVEdI",
385
+ "fold-top": "cos-fold-top-v-6XJ",
386
+ "unfold-bottom": "cos-unfold-bottom-e2gzU"
387
+ }, N = (e, t) => Math.max(0, Math.floor(e)).toString().padStart(t, "0").slice(-t), P = ({ digit: e, color: t, duration: r }) => {
388
+ let i = a(e), [u, d] = o(!1), [f, p] = o(e);
389
+ n(() => {
390
+ if (e === i.current) return;
391
+ p(i.current), d(!0), i.current = e;
392
+ let t = window.setTimeout(() => d(!1), r);
393
+ return () => clearTimeout(t);
394
+ }, [e, r]);
395
+ let m = u ? f : e;
396
+ return /* @__PURE__ */ c("div", {
397
+ className: M.digit,
398
+ style: {
399
+ "--flip-color": t,
400
+ "--flip-duration": `${r}ms`
401
+ },
402
+ children: /* @__PURE__ */ l("div", {
403
+ className: `${M.digitCard} ${u ? M.isFlipping : ""}`,
404
+ children: [
405
+ /* @__PURE__ */ c("div", {
406
+ className: M.staticTop,
407
+ children: /* @__PURE__ */ c("span", { children: m })
408
+ }),
409
+ /* @__PURE__ */ c("div", {
410
+ className: M.staticBottom,
411
+ children: /* @__PURE__ */ c("span", { children: m })
412
+ }),
413
+ u && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("div", {
414
+ className: `${M.flap} ${M.flapTop}`,
415
+ children: /* @__PURE__ */ c("span", { children: f })
416
+ }), /* @__PURE__ */ c("div", {
417
+ className: `${M.flap} ${M.flapBottom}`,
418
+ children: /* @__PURE__ */ c("span", { children: e })
419
+ })] })
420
+ ]
421
+ })
422
+ });
423
+ }, F = ({ value: e, digits: t = 4, color: n = "#38bdf8", duration: r = 600 }) => {
424
+ let i = N(e, t).split("");
425
+ return /* @__PURE__ */ c("div", {
426
+ className: M.flipCounter,
427
+ children: i.map((e, t) => /* @__PURE__ */ c(P, {
428
+ digit: e,
429
+ color: n,
430
+ duration: r
431
+ }, t))
432
+ });
433
+ }, I = {
434
+ glitchText: "cos-glitchText-dZ-sR",
435
+ text: "cos-text-JsPHN",
436
+ "glitch-1": "cos-glitch-1-s9pqH",
437
+ "glitch-2": "cos-glitch-2-GhFB-"
438
+ }, te = ({ text: e = "GLITCH", color: t = "#f8fafc", glitchColor1: n = "#ff00de", glitchColor2: r = "#00f0ff", fontSize: i = 64 }) => /* @__PURE__ */ c("div", {
439
+ className: I.glitchText,
440
+ children: /* @__PURE__ */ c("h1", {
441
+ className: I.text,
442
+ "data-text": e,
443
+ style: {
444
+ fontSize: i,
445
+ "--glitch-color": t,
446
+ "--glitch-c1": n,
447
+ "--glitch-c2": r
448
+ },
449
+ children: e
450
+ })
451
+ }), L = {
452
+ matrixRain: "cos-matrixRain-qg9HC",
453
+ canvas: "cos-canvas--AvpG",
454
+ overlay: "cos-overlay-knj3b",
455
+ title: "cos-title-sDfhs",
456
+ flicker: "cos-flicker-smHxl",
457
+ subtitle: "cos-subtitle-CWheW"
458
+ }, ne = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*アイウエオカキクケコ", R = ({ width: e = 800, height: t = 500, density: r = .6, color: i = "#00ff41", showOverlay: o = !0, title: s = "MATRIX", subtitle: u = "数字雨效果" }) => {
459
+ let d = a(null);
460
+ return n(() => {
461
+ let n = d.current;
462
+ if (!n) return;
463
+ let a = window.devicePixelRatio || 1;
464
+ n.width = e * a, n.height = t * a;
465
+ let o = n.getContext("2d");
466
+ if (!o) return;
467
+ o.setTransform(a, 0, 0, a, 0, 0);
468
+ let s = Math.floor(e / 16 * r), c = Array.from({ length: s }, () => Math.random() * -50), l = 0, u = document.hidden, p = f((e) => {
469
+ u = e;
470
+ }), m = () => {
471
+ l = requestAnimationFrame(m), !u && (o.fillStyle = "rgb(0 0 0 / 8%)", o.fillRect(0, 0, e, t), o.font = "16px monospace", c.forEach((e, n) => {
472
+ let a = ne[Math.floor(Math.random() * 53)], s = n / r * 16;
473
+ o.fillStyle = i, o.fillText(a, s, e * 16), e * 16 > t && Math.random() > .975 && (c[n] = 0), c[n] += 1;
474
+ }));
475
+ };
476
+ return m(), () => {
477
+ cancelAnimationFrame(l), p();
200
478
  };
201
- return d(), () => cancelAnimationFrame(u);
202
479
  }, [
203
- s,
204
- o,
480
+ i,
205
481
  r,
482
+ t,
206
483
  e
207
- ]), /* @__PURE__ */ a("div", {
208
- className: h.matrixRain,
484
+ ]), /* @__PURE__ */ l("div", {
485
+ className: L.matrixRain,
209
486
  style: {
210
487
  width: e,
211
- height: r
488
+ height: t
212
489
  },
213
- children: [/* @__PURE__ */ i("canvas", {
214
- ref: c,
215
- className: h.canvas,
490
+ children: [/* @__PURE__ */ c("canvas", {
491
+ ref: d,
492
+ className: L.canvas,
216
493
  style: {
217
494
  width: e,
218
- height: r
495
+ height: t
219
496
  }
220
- }), /* @__PURE__ */ a("div", {
221
- className: h.overlay,
222
- children: [/* @__PURE__ */ i("h2", {
223
- className: h.title,
224
- children: "MATRIX"
225
- }), /* @__PURE__ */ i("p", {
226
- className: h.subtitle,
227
- children: "数字雨效果"
497
+ }), o && /* @__PURE__ */ l("div", {
498
+ className: L.overlay,
499
+ children: [/* @__PURE__ */ c("h2", {
500
+ className: L.title,
501
+ children: s
502
+ }), /* @__PURE__ */ c("p", {
503
+ className: L.subtitle,
504
+ children: u
228
505
  })]
229
506
  })]
230
507
  });
231
- }, v = {
232
- neonText: "cos-neonText",
233
- text: "cos-text",
234
- flicker: "cos-flicker",
235
- "neon-flicker": "cos-neon-flicker",
236
- reflection: "cos-reflection"
237
- }, y = ({ text: e = "NEON", color: t = "#ff00de", fontSize: n = 72, flicker: r = !0 }) => /* @__PURE__ */ a("div", {
238
- className: v.neonText,
239
- children: [/* @__PURE__ */ i("h1", {
240
- className: `${v.text} ${r ? v.flicker : ""}`,
508
+ }, z = {
509
+ meteorRain: "cos-meteorRain-v8RNI",
510
+ canvas: "cos-canvas-hyFMr"
511
+ }, B = ({ width: e = 800, height: t = 500, meteorCount: r = 8 }) => {
512
+ let i = a(null), o = a([]), s = a(0);
513
+ return n(() => {
514
+ o.current = Array.from({ length: r }, () => ({
515
+ x: Math.random() * e,
516
+ y: Math.random() * t * .5,
517
+ length: Math.random() * 60 + 40,
518
+ speed: Math.random() * 6 + 4,
519
+ opacity: Math.random() * .5 + .3
520
+ }));
521
+ }, [
522
+ t,
523
+ r,
524
+ e
525
+ ]), n(() => {
526
+ let n = i.current;
527
+ if (!n) return;
528
+ let r = window.devicePixelRatio || 1;
529
+ n.width = e * r, n.height = t * r;
530
+ let a = n.getContext("2d");
531
+ if (!a) return;
532
+ a.setTransform(r, 0, 0, r, 0, 0);
533
+ let c = document.hidden, l = f((e) => {
534
+ c = e;
535
+ }), u = () => {
536
+ s.current = requestAnimationFrame(u), !c && (a.fillStyle = "rgb(15 23 42 / 15%)", a.fillRect(0, 0, e, t), o.current.forEach((n) => {
537
+ n.x += n.speed, n.y += n.speed * .6, (n.x > e + n.length || n.y > t + n.length) && (n.x = -n.length, n.y = Math.random() * t * .4, n.length = Math.random() * 60 + 40, n.speed = Math.random() * 6 + 4, n.opacity = Math.random() * .5 + .3);
538
+ let r = n.x - n.length, i = n.y - n.length * .6;
539
+ a.beginPath(), a.strokeStyle = `rgb(255 255 255 / ${n.opacity})`, a.lineWidth = 2, a.moveTo(n.x, n.y), a.lineTo(r, i), a.stroke(), a.beginPath(), a.fillStyle = `rgb(255 255 255 / ${Math.min(1, n.opacity + .2)})`, a.arc(n.x, n.y, 1.5, 0, Math.PI * 2), a.fill();
540
+ }));
541
+ };
542
+ return u(), () => {
543
+ cancelAnimationFrame(s.current), l();
544
+ };
545
+ }, [t, e]), /* @__PURE__ */ c("div", {
546
+ className: z.meteorRain,
547
+ style: {
548
+ width: e,
549
+ height: t
550
+ },
551
+ children: /* @__PURE__ */ c("canvas", {
552
+ ref: i,
553
+ className: z.canvas,
554
+ style: {
555
+ width: e,
556
+ height: t
557
+ }
558
+ })
559
+ });
560
+ }, V = {
561
+ neonText: "cos-neonText-JMP7i",
562
+ text: "cos-text-GTO-0",
563
+ flicker: "cos-flicker-nXceV",
564
+ "neon-flicker": "cos-neon-flicker-uDkmM",
565
+ reflection: "cos-reflection-aEYj6"
566
+ }, H = ({ text: e = "NEON", color: t = "#ff00de", fontSize: n = 72, flicker: r = !0 }) => /* @__PURE__ */ l("div", {
567
+ className: V.neonText,
568
+ children: [/* @__PURE__ */ c("h1", {
569
+ className: `${V.text} ${r ? V.flicker : ""}`,
241
570
  style: {
242
571
  fontSize: n,
243
572
  "--neon-color": t
244
573
  },
245
574
  children: e
246
- }), /* @__PURE__ */ i("p", {
247
- className: v.reflection,
575
+ }), /* @__PURE__ */ c("p", {
576
+ className: V.reflection,
248
577
  style: {
249
578
  fontSize: n * .35,
250
579
  color: t
251
580
  },
252
581
  children: e
253
582
  })]
254
- }), b = {
255
- particleNetwork: "cos-particleNetwork",
256
- canvas: "cos-canvas",
257
- hint: "cos-hint"
258
- }, x = ({ width: r = 800, height: o = 500, particleCount: s = 60, linkDistance: c = 120, color: l = "#38bdf8" }) => {
259
- let u = n(null), d = n([]), f = n({
583
+ }), U = {
584
+ particleNetwork: "cos-particleNetwork-GSZq-",
585
+ canvas: "cos-canvas-E-BGP",
586
+ hint: "cos-hint-LEO5o"
587
+ }, W = ({ width: e = 800, height: r = 500, particleCount: i = 60, linkDistance: o = 120, repelRadius: s = 150, color: u = "#38bdf8" }) => {
588
+ let d = a(null), p = a([]), m = a({
260
589
  x: -1e3,
261
590
  y: -1e3
262
- }), p = e(() => {
263
- d.current = Array.from({ length: s }, () => ({
264
- x: Math.random() * r,
265
- y: Math.random() * o,
591
+ }), h = t(() => {
592
+ p.current = Array.from({ length: i }, () => ({
593
+ x: Math.random() * e,
594
+ y: Math.random() * r,
266
595
  vx: (Math.random() - .5) * 1.2,
267
596
  vy: (Math.random() - .5) * 1.2,
268
597
  radius: Math.random() * 2 + 1
269
598
  }));
270
599
  }, [
271
- o,
272
- s,
273
- r
600
+ r,
601
+ i,
602
+ e
274
603
  ]);
275
- return t(() => {
276
- p();
277
- }, [p]), t(() => {
278
- let e = u.current;
279
- if (!e) return;
280
- let t = window.devicePixelRatio || 1;
281
- e.width = r * t, e.height = o * t;
282
- let n = e.getContext("2d");
283
- if (!n) return;
284
- n.setTransform(t, 0, 0, t, 0, 0);
285
- let i = 0, a = () => {
286
- n.fillStyle = "#0f172a", n.fillRect(0, 0, r, o);
287
- let e = d.current, t = f.current;
288
- e.forEach((e) => {
289
- e.x += e.vx, e.y += e.vy, (e.x < 0 || e.x > r) && (e.vx *= -1), (e.y < 0 || e.y > o) && (e.vy *= -1);
290
- let n = t.x - e.x, i = t.y - e.y;
291
- Math.sqrt(n * n + i * i) < 150 && (e.vx -= n * 3e-4, e.vy -= i * 3e-4);
604
+ n(() => {
605
+ h();
606
+ }, [h]), n(() => {
607
+ let t = d.current;
608
+ if (!t) return;
609
+ let n = window.devicePixelRatio || 1;
610
+ t.width = e * n, t.height = r * n;
611
+ let i = t.getContext("2d");
612
+ if (!i) return;
613
+ i.setTransform(n, 0, 0, n, 0, 0);
614
+ let a = 0, c = document.hidden, l = f((e) => {
615
+ c = e;
616
+ }), h = () => {
617
+ if (c) {
618
+ a = requestAnimationFrame(h);
619
+ return;
620
+ }
621
+ i.fillStyle = "#0f172a", i.fillRect(0, 0, e, r);
622
+ let t = p.current, n = m.current, l = s * s;
623
+ t.forEach((t) => {
624
+ t.x += t.vx, t.y += t.vy, (t.x < 0 || t.x > e) && (t.vx *= -1), (t.y < 0 || t.y > r) && (t.vy *= -1);
625
+ let i = n.x - t.x, a = n.y - t.y, o = i * i + a * a;
626
+ if (o < l && o > 0) {
627
+ let e = Math.sqrt(o);
628
+ t.vx -= i / e * .15, t.vy -= a / e * .15;
629
+ }
292
630
  });
293
- for (let t = 0; t < e.length; t++) for (let r = t + 1; r < e.length; r++) {
294
- let i = e[t].x - e[r].x, a = e[t].y - e[r].y, o = Math.sqrt(i * i + a * a);
295
- o < c && (n.beginPath(), n.moveTo(e[t].x, e[t].y), n.lineTo(e[r].x, e[r].y), n.strokeStyle = l, n.globalAlpha = 1 - o / c, n.lineWidth = .8, n.stroke(), n.globalAlpha = 1);
631
+ for (let e = 0; e < t.length; e++) for (let n = e + 1; n < t.length; n++) {
632
+ let r = t[e].x - t[n].x, a = t[e].y - t[n].y, s = r * r + a * a;
633
+ if (s < o * o) {
634
+ let r = Math.sqrt(s);
635
+ i.beginPath(), i.moveTo(t[e].x, t[e].y), i.lineTo(t[n].x, t[n].y), i.strokeStyle = u, i.globalAlpha = 1 - r / o, i.lineWidth = .8, i.stroke(), i.globalAlpha = 1;
636
+ }
296
637
  }
297
- e.forEach((e) => {
298
- n.beginPath(), n.arc(e.x, e.y, e.radius, 0, Math.PI * 2), n.fillStyle = l, n.fill();
299
- }), i = requestAnimationFrame(a);
638
+ t.forEach((e) => {
639
+ i.beginPath(), i.arc(e.x, e.y, e.radius, 0, Math.PI * 2), i.fillStyle = u, i.fill();
640
+ }), a = requestAnimationFrame(h);
641
+ };
642
+ return h(), () => {
643
+ cancelAnimationFrame(a), l();
300
644
  };
301
- return a(), () => cancelAnimationFrame(i);
302
645
  }, [
303
- l,
646
+ u,
647
+ r,
648
+ h,
304
649
  o,
305
- p,
306
- c,
307
- r
308
- ]), /* @__PURE__ */ a("div", {
309
- className: b.particleNetwork,
650
+ s,
651
+ e
652
+ ]);
653
+ let g = (e, t, n) => {
654
+ m.current = {
655
+ x: e - n.left,
656
+ y: t - n.top
657
+ };
658
+ }, _ = (e) => {
659
+ g(e.clientX, e.clientY, e.currentTarget.getBoundingClientRect());
660
+ }, v = (e) => {
661
+ let t = e.touches[0];
662
+ t && g(t.clientX, t.clientY, e.currentTarget.getBoundingClientRect());
663
+ }, y = () => {
664
+ m.current = {
665
+ x: -1e3,
666
+ y: -1e3
667
+ };
668
+ };
669
+ return /* @__PURE__ */ l("div", {
670
+ className: U.particleNetwork,
310
671
  style: {
311
- width: r,
312
- height: o
672
+ width: e,
673
+ height: r
313
674
  },
314
- children: [/* @__PURE__ */ i("canvas", {
315
- ref: u,
316
- className: b.canvas,
675
+ children: [/* @__PURE__ */ c("canvas", {
676
+ ref: d,
677
+ className: U.canvas,
317
678
  style: {
318
- width: r,
319
- height: o
320
- },
321
- onMouseMove: (e) => {
322
- let t = e.currentTarget.getBoundingClientRect();
323
- f.current = {
324
- x: e.clientX - t.left,
325
- y: e.clientY - t.top
326
- };
679
+ width: e,
680
+ height: r
327
681
  },
328
- onMouseLeave: () => {
329
- f.current = {
330
- x: -1e3,
331
- y: -1e3
332
- };
333
- }
334
- }), /* @__PURE__ */ i("p", {
335
- className: b.hint,
336
- children: "移动鼠标与粒子互动"
682
+ onMouseMove: _,
683
+ onMouseLeave: y,
684
+ onTouchMove: v,
685
+ onTouchEnd: y
686
+ }), /* @__PURE__ */ c("p", {
687
+ className: U.hint,
688
+ children: "移动鼠标或手指与粒子互动"
337
689
  })]
338
690
  });
339
- }, S = {
340
- returnCityContainer: "cos-returnCityContainer",
341
- star: "cos-star",
342
- glassWrap: "cos-glassWrap",
343
- rotate: "cos-rotate",
344
- glassItem: "cos-glassItem"
345
- }, C = () => {
346
- let e = (e, t) => {
347
- for (let n = 0; n < t; n++) setTimeout(function() {
348
- let t = document.createElement("div");
349
- t.className = S.star;
350
- let n = document.body.clientWidth, r = document.body.clientHeight, i = Math.random() * n + "px", a = Math.random() * r + "px";
351
- t.style.top = a, t.style.left = i, e.append(t);
352
- }, Math.random() * 2e3);
353
- }, n = () => {
354
- let e = document.getElementById("glassWrap");
355
- if (e) for (let t = 0; t < 6; t++) {
691
+ }, G = {
692
+ returnCityContainer: "cos-returnCityContainer-6XTxj",
693
+ star: "cos-star-a59Dx",
694
+ glassWrap: "cos-glassWrap-golMO",
695
+ rotate: "cos-rotate-7X9Jj",
696
+ glassItem: "cos-glassItem-OwlFI"
697
+ }, K = ({ starCount: e, glassCount: t = 8, glassRadius: r = 150 }) => {
698
+ let i = a(null), o = a(null);
699
+ return n(() => {
700
+ let n = i.current, a = o.current;
701
+ if (!n || !a) return;
702
+ let s = [], c = [], l = [], { width: u, height: d } = n.getBoundingClientRect(), f = e ?? Math.max(20, Math.floor(u / 20));
703
+ for (let e = 0; e < f; e++) {
704
+ let e = window.setTimeout(() => {
705
+ let e = document.createElement("div");
706
+ e.className = G.star, e.style.top = `${Math.random() * d}px`, e.style.left = `${Math.random() * u}px`, n.append(e), c.push(e);
707
+ }, Math.random() * 2e3);
708
+ s.push(e);
709
+ }
710
+ for (let e = 0; e < t; e++) {
356
711
  let n = document.createElement("div");
357
- n.className = S.glassItem, n.style.transform = `rotateY(${360 / 6 * t}deg) translateZ(150px)`, e.appendChild(n), setTimeout(() => {
712
+ n.className = G.glassItem, n.style.transform = `rotateY(${360 / t * e}deg) translateZ(${r}px)`, a.appendChild(n), l.push(n);
713
+ let i = window.setTimeout(() => {
358
714
  n.style.top = "0px", n.style.opacity = "1";
359
- }, t * 300);
715
+ }, e * 300);
716
+ s.push(i);
360
717
  }
361
- };
362
- return t(() => {
363
- let t = document.getElementById("returnCityContainer");
364
- t && e(t, document.documentElement.clientWidth / 20), n();
365
- }, []), /* @__PURE__ */ i("div", {
366
- id: "returnCityContainer",
367
- className: S.returnCityContainer,
368
- children: /* @__PURE__ */ i("div", {
369
- id: "glassWrap",
370
- className: S.glassWrap
718
+ return () => {
719
+ s.forEach(clearTimeout), c.forEach((e) => e.remove()), l.forEach((e) => e.remove());
720
+ };
721
+ }, [
722
+ e,
723
+ t,
724
+ r
725
+ ]), /* @__PURE__ */ c("div", {
726
+ ref: i,
727
+ className: G.returnCityContainer,
728
+ children: /* @__PURE__ */ c("div", {
729
+ ref: o,
730
+ className: G.glassWrap
371
731
  })
372
732
  });
373
- }, w = {
374
- turntable: "cos-turntable",
375
- wheelWrap: "cos-wheelWrap",
376
- canvas: "cos-canvas",
377
- pointer: "cos-pointer",
378
- spinBtn: "cos-spinBtn",
379
- result: "cos-result",
380
- "fade-in": "cos-fade-in"
381
- }, T = [
733
+ }, q = {
734
+ turntable: "cos-turntable-dkc32",
735
+ wheelWrap: "cos-wheelWrap-n7lhc",
736
+ canvas: "cos-canvas-A1-4x",
737
+ pointer: "cos-pointer-Rk1S9",
738
+ spinBtn: "cos-spinBtn-l9JIC",
739
+ result: "cos-result-H8q2c",
740
+ "fade-in": "cos-fade-in-U9bUC"
741
+ }, J = [
382
742
  "#FF6B6B",
383
743
  "#4ECDC4",
384
744
  "#FFE66D",
@@ -387,177 +747,188 @@ import './index.css';var o = {
387
747
  "#F472B6",
388
748
  "#34D399",
389
749
  "#FB923C"
390
- ], E = [
750
+ ], Y = [
391
751
  { label: "一等奖" },
392
752
  { label: "二等奖" },
393
753
  { label: "三等奖" },
394
754
  { label: "谢谢参与" },
395
755
  { label: "优惠券" },
396
756
  { label: "再来一次" }
397
- ], D = (e) => 1 - (1 - e) ** 3, O = ({ prizes: o = E, size: s = 360, spinDuration: c = 4e3, spinRounds: l = 5, buttonText: u = "开始抽奖", onSpinEnd: d }) => {
398
- let f = n(null), p = n(0), m = n(0), h = n(1), [g, _] = r(!1), [v, y] = r(null), b = s + 48, x = (e, t) => t.color ?? T[e % T.length], S = e((e) => {
399
- let t = f.current;
400
- if (!t) return;
401
- let n = t.getContext("2d");
757
+ ], X = (e) => 1 - (1 - e) ** 3, re = ({ prizes: e = Y, size: r = 360, spinDuration: i = 4e3, spinRounds: s = 5, buttonText: u = "开始抽奖", onSpinEnd: d }) => {
758
+ let f = a(null), p = a(0), m = a(0), h = a(1), [g, _] = o(!1), [v, y] = o(null), b = r + 48, x = (e, t) => t.color ?? J[e % J.length], S = t((t) => {
759
+ let n = f.current;
402
760
  if (!n) return;
403
- let r = b / 2, i = s / 2, a = Math.PI * 2 / o.length;
404
- n.clearRect(0, 0, b, b), n.save(), n.translate(r, r), n.rotate(e), o.forEach((e, t) => {
405
- let r = t * a - Math.PI / 2, o = r + a, c = x(t, e);
406
- n.beginPath(), n.moveTo(0, 0), n.arc(0, 0, i, r, o), n.closePath(), n.fillStyle = c, n.fill(), n.strokeStyle = "rgb(255 255 255 / 35%)", n.lineWidth = 2, n.stroke(), n.save(), n.rotate(r + a / 2), n.textAlign = "right", n.fillStyle = "#fff", n.font = `bold ${Math.max(12, Math.floor(s / 22))}px system-ui, sans-serif`, n.shadowColor = "rgb(0 0 0 / 30%)", n.shadowBlur = 4, n.fillText(e.label, i - 18, 6), n.restore();
407
- }), n.beginPath(), n.arc(0, 0, i, 0, Math.PI * 2), n.strokeStyle = "#fbbf24", n.lineWidth = 6, n.stroke(), n.beginPath(), n.arc(0, 0, i - 4, 0, Math.PI * 2), n.strokeStyle = "#f59e0b", n.lineWidth = 2, n.stroke(), n.restore(), n.save(), n.translate(r, r);
761
+ let i = n.getContext("2d");
762
+ if (!i) return;
763
+ let a = b / 2, o = r / 2, s = Math.PI * 2 / e.length;
764
+ i.clearRect(0, 0, b, b), i.save(), i.translate(a, a), i.rotate(t), e.forEach((e, t) => {
765
+ let n = t * s - Math.PI / 2, a = n + s, c = x(t, e);
766
+ i.beginPath(), i.moveTo(0, 0), i.arc(0, 0, o, n, a), i.closePath(), i.fillStyle = c, i.fill(), i.strokeStyle = "rgb(255 255 255 / 35%)", i.lineWidth = 2, i.stroke(), i.save(), i.rotate(n + s / 2), i.textAlign = "right", i.fillStyle = "#fff", i.font = `bold ${Math.max(12, Math.floor(r / 22))}px system-ui, sans-serif`, i.shadowColor = "rgb(0 0 0 / 30%)", i.shadowBlur = 4, i.fillText(e.label, o - 18, 6), i.restore();
767
+ }), i.beginPath(), i.arc(0, 0, o, 0, Math.PI * 2), i.strokeStyle = "#fbbf24", i.lineWidth = 6, i.stroke(), i.beginPath(), i.arc(0, 0, o - 4, 0, Math.PI * 2), i.strokeStyle = "#f59e0b", i.lineWidth = 2, i.stroke(), i.restore(), i.save(), i.translate(a, a);
408
768
  for (let e = 0; e < 12; e++) {
409
- let t = e / 12 * Math.PI * 2, r = Math.cos(t) * (i + 14), a = Math.sin(t) * (i + 14);
410
- n.beginPath(), n.arc(r, a, 3, 0, Math.PI * 2), n.fillStyle = e % 2 == 0 ? "#fde68a" : "#f59e0b", n.fill();
769
+ let t = e / 12 * Math.PI * 2, n = Math.cos(t) * (o + 14), r = Math.sin(t) * (o + 14);
770
+ i.beginPath(), i.arc(n, r, 3, 0, Math.PI * 2), i.fillStyle = e % 2 == 0 ? "#fde68a" : "#f59e0b", i.fill();
411
771
  }
412
- n.restore();
772
+ i.restore();
413
773
  }, [
414
774
  b,
415
- o,
416
- s
775
+ e,
776
+ r
417
777
  ]);
418
- t(() => {
778
+ n(() => {
419
779
  let e = f.current;
420
780
  if (!e) return;
421
781
  let t = window.devicePixelRatio || 1;
422
782
  h.current = t, e.width = b * t, e.height = b * t;
423
783
  let n = e.getContext("2d");
424
784
  n && n.setTransform(t, 0, 0, t, 0, 0), S(p.current);
425
- }, [b, S]), t(() => () => {
785
+ }, [b, S]), n(() => () => {
426
786
  m.current && cancelAnimationFrame(m.current);
427
787
  }, []);
428
- let C = (e) => {
429
- let t = 360 / o.length, n = (180 / Math.PI * e % 360 + 360) % 360;
430
- return Math.floor((360 - n + t / 2) % 360 / t) % o.length;
788
+ let C = (t) => {
789
+ let n = 360 / e.length, r = (180 / Math.PI * t % 360 + 360) % 360;
790
+ return Math.floor((360 - r + n / 2) % 360 / n) % e.length;
431
791
  };
432
- return /* @__PURE__ */ a("div", {
433
- className: w.turntable,
792
+ return /* @__PURE__ */ l("div", {
793
+ className: q.turntable,
434
794
  style: {
435
795
  width: b,
436
796
  height: b + 80
437
797
  },
438
- children: [/* @__PURE__ */ a("div", {
439
- className: w.wheelWrap,
798
+ children: [/* @__PURE__ */ l("div", {
799
+ className: q.wheelWrap,
440
800
  style: {
441
801
  width: b,
442
802
  height: b
443
803
  },
444
804
  children: [
445
- /* @__PURE__ */ i("div", { className: w.pointer }),
446
- /* @__PURE__ */ i("canvas", {
805
+ /* @__PURE__ */ c("div", { className: q.pointer }),
806
+ /* @__PURE__ */ c("canvas", {
447
807
  ref: f,
448
- className: w.canvas,
808
+ className: q.canvas,
449
809
  style: {
450
810
  width: b,
451
811
  height: b
452
812
  }
453
813
  }),
454
- /* @__PURE__ */ i("button", {
814
+ /* @__PURE__ */ c("button", {
455
815
  type: "button",
456
- className: w.spinBtn,
816
+ className: q.spinBtn,
457
817
  onClick: () => {
458
- if (g || o.length === 0) return;
818
+ if (g || e.length === 0) return;
459
819
  _(!0), y(null);
460
- let e = Math.PI * 2 / o.length, t = Math.floor(Math.random() * o.length) * e + e / 2, n = p.current, r = n + l * Math.PI * 2 + (Math.PI * 2 - t) - n % (Math.PI * 2), i = n, a = performance.now(), s = (e) => {
461
- let t = e - a, n = Math.min(t / c, 1), l = D(n), u = i + (r - i) * l;
462
- if (p.current = u, S(u), n < 1) m.current = requestAnimationFrame(s);
820
+ let t = Math.PI * 2 / e.length, n = Math.floor(Math.random() * e.length) * t + t / 2, r = p.current, a = r + s * Math.PI * 2 + (Math.PI * 2 - n) - r % (Math.PI * 2), o = r, c = performance.now(), l = (t) => {
821
+ let n = t - c, r = Math.min(n / i, 1), s = X(r), u = o + (a - o) * s;
822
+ if (p.current = u, S(u), r < 1) m.current = requestAnimationFrame(l);
463
823
  else {
464
- let e = C(u), t = o[e];
465
- p.current = u, _(!1), y(t), d?.(t, e);
824
+ let t = C(u), n = e[t];
825
+ p.current = u, _(!1), y(n), d?.(n, t);
466
826
  }
467
827
  };
468
- m.current = requestAnimationFrame(s);
828
+ m.current = requestAnimationFrame(l);
469
829
  },
470
830
  disabled: g,
471
831
  children: g ? "抽奖中..." : u
472
832
  })
473
833
  ]
474
- }), v && !g && /* @__PURE__ */ a("p", {
475
- className: w.result,
476
- children: ["恭喜获得:", /* @__PURE__ */ i("strong", { children: v.label })]
834
+ }), v && !g && /* @__PURE__ */ l("p", {
835
+ className: q.result,
836
+ children: ["恭喜获得:", /* @__PURE__ */ c("strong", { children: v.label })]
477
837
  })]
478
838
  });
479
- }, k = {
480
- typewriter: "cos-typewriter",
481
- terminal: "cos-terminal",
482
- dots: "cos-dots",
483
- text: "cos-text",
484
- prompt: "cos-prompt",
485
- cursor: "cos-cursor",
486
- blink: "cos-blink"
487
- }, A = [
839
+ }, Z = {
840
+ typewriter: "cos-typewriter-7UhOL",
841
+ terminal: "cos-terminal-NWNVN",
842
+ dots: "cos-dots-oulNg",
843
+ text: "cos-text-ICV5T",
844
+ prompt: "cos-prompt-Y4hVD",
845
+ cursor: "cos-cursor-m8hGi",
846
+ blink: "cos-blink-XykM7"
847
+ }, Q = [
488
848
  "Hello, cos-design!",
489
849
  "欢迎来到组件库 ✨",
490
850
  "Build something fun 🚀"
491
- ], j = ({ texts: e = A, speed: n = 100, deleteSpeed: o = 50, pause: s = 2e3 }) => {
492
- let [c, l] = r(""), [u, d] = r(0), [f, p] = r(!1);
493
- return t(() => {
494
- let t = e[u % e.length], r;
495
- if (!f && c === t) r = setTimeout(() => p(!0), s);
496
- else if (f && c === "") r = setTimeout(() => {
851
+ ], ie = ({ texts: e, speed: t, deleteSpeed: r, pause: i }) => {
852
+ let [a, s] = o(""), [u, d] = o(0), [f, p] = o(!1);
853
+ return n(() => {
854
+ let n = e[u % e.length], o;
855
+ if (!f && a === n) o = setTimeout(() => p(!0), i);
856
+ else if (f && a === "") o = setTimeout(() => {
497
857
  p(!1), d((t) => (t + 1) % e.length);
498
858
  }, 0);
499
859
  else {
500
- let e = f ? t.slice(0, c.length - 1) : t.slice(0, c.length + 1);
501
- r = setTimeout(() => l(e), f ? o : n);
860
+ let e = f ? n.slice(0, a.length - 1) : n.slice(0, a.length + 1);
861
+ o = setTimeout(() => s(e), f ? r : t);
502
862
  }
503
- return () => clearTimeout(r);
863
+ return () => clearTimeout(o);
504
864
  }, [
505
- c,
865
+ a,
506
866
  f,
507
867
  u,
508
868
  e,
509
- n,
510
- o,
511
- s
512
- ]), /* @__PURE__ */ i("div", {
513
- className: k.typewriter,
514
- children: /* @__PURE__ */ a("div", {
515
- className: k.terminal,
516
- children: [/* @__PURE__ */ a("div", {
517
- className: k.dots,
869
+ t,
870
+ r,
871
+ i
872
+ ]), /* @__PURE__ */ c("div", {
873
+ className: Z.typewriter,
874
+ children: /* @__PURE__ */ l("div", {
875
+ className: Z.terminal,
876
+ children: [/* @__PURE__ */ l("div", {
877
+ className: Z.dots,
518
878
  children: [
519
- /* @__PURE__ */ i("span", {}),
520
- /* @__PURE__ */ i("span", {}),
521
- /* @__PURE__ */ i("span", {})
879
+ /* @__PURE__ */ c("span", {}),
880
+ /* @__PURE__ */ c("span", {}),
881
+ /* @__PURE__ */ c("span", {})
522
882
  ]
523
- }), /* @__PURE__ */ a("p", {
524
- className: k.text,
883
+ }), /* @__PURE__ */ l("p", {
884
+ className: Z.text,
525
885
  children: [
526
- /* @__PURE__ */ i("span", {
527
- className: k.prompt,
886
+ /* @__PURE__ */ c("span", {
887
+ className: Z.prompt,
528
888
  children: ">"
529
889
  }),
530
- c,
531
- /* @__PURE__ */ i("span", {
532
- className: k.cursor,
890
+ a,
891
+ /* @__PURE__ */ c("span", {
892
+ className: Z.cursor,
533
893
  children: "|"
534
894
  })
535
895
  ]
536
896
  })]
537
897
  })
538
898
  });
539
- }, M = {
540
- waveButton: "cos-waveButton",
541
- btn: "cos-btn",
542
- label: "cos-label",
543
- wave: "cos-wave",
544
- ripple: "cos-ripple"
545
- }, N = ({ text: e = "点我试试", onClick: t, color: n = "#38bdf8" }) => /* @__PURE__ */ i("div", {
546
- className: M.waveButton,
547
- children: /* @__PURE__ */ a("button", {
899
+ }, ae = ({ texts: e = Q, speed: t = 100, deleteSpeed: n = 50, pause: r = 2e3 }) => {
900
+ let i = e.length > 0 ? e : Q;
901
+ return /* @__PURE__ */ c(ie, {
902
+ texts: i,
903
+ speed: t,
904
+ deleteSpeed: n,
905
+ pause: r
906
+ }, i.join("\0"));
907
+ }, $ = {
908
+ waveButton: "cos-waveButton-Aa7G-",
909
+ btn: "cos-btn-WJrEN",
910
+ label: "cos-label-9BHOU",
911
+ wave: "cos-wave-GycLU",
912
+ ripple: "cos-ripple-5ZFpr"
913
+ }, oe = ({ text: e = "点我试试", color: t = "#38bdf8", className: n, style: r, ...i }) => /* @__PURE__ */ c("div", {
914
+ className: $.waveButton,
915
+ children: /* @__PURE__ */ l("button", {
548
916
  type: "button",
549
- className: M.btn,
550
- style: { "--wave-color": n },
551
- onClick: t,
917
+ className: `${$.btn} ${n ?? ""}`,
918
+ style: {
919
+ "--wave-color": t,
920
+ ...r
921
+ },
922
+ ...i,
552
923
  children: [
553
- /* @__PURE__ */ i("span", { className: M.wave }),
554
- /* @__PURE__ */ i("span", { className: M.wave }),
555
- /* @__PURE__ */ i("span", {
556
- className: M.label,
924
+ /* @__PURE__ */ c("span", { className: $.wave }),
925
+ /* @__PURE__ */ c("span", { className: $.wave }),
926
+ /* @__PURE__ */ c("span", {
927
+ className: $.label,
557
928
  children: e
558
929
  })
559
930
  ]
560
931
  })
561
932
  });
562
933
  //#endregion
563
- export { s as CanvasClock, l as Charge, m as Fireworks, _ as MatrixRain, y as NeonText, x as ParticleNetwork, C as ReturnCity, O as Turntable, j as Typewriter, N as WaveButton };
934
+ export { d as CanvasClock, h as Charge, b as Confetti, w as Countdown, j as Fireworks, F as FlipCounter, te as GlitchText, R as MatrixRain, B as MeteorRain, H as NeonText, W as ParticleNetwork, K as ReturnCity, re as Turntable, ae as Typewriter, oe as WaveButton };