cos-design 2.2.0 → 2.4.0

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