dirk-cfx-react 1.0.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.mjs ADDED
@@ -0,0 +1,1220 @@
1
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2
+ import { Flex, Text, Image, createTheme, useMantineTheme, MantineProvider, BackgroundImage } from '@mantine/core';
3
+ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
4
+ import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
5
+ import { createContext, useRef, useState, useEffect, useContext } from 'react';
6
+ import { create, useStore } from 'zustand';
7
+ import '@mantine/notifications/styles.css';
8
+ import '@mantine/core/styles.css';
9
+ import '@/styles/niceFont.css';
10
+ import '@/styles/scrollBar.css';
11
+ import { library } from '@fortawesome/fontawesome-svg-core';
12
+ import { fab } from '@fortawesome/free-brands-svg-icons';
13
+ import { far } from '@fortawesome/free-regular-svg-icons';
14
+ import { fas } from '@fortawesome/free-solid-svg-icons';
15
+
16
+ // src/components/BorderedIcon.tsx
17
+
18
+ // src/utils/colorWithAlpha.ts
19
+ var colorNames = {
20
+ AliceBlue: { r: 240, g: 248, b: 255 },
21
+ AntiqueWhite: { r: 250, g: 235, b: 215 },
22
+ Aqua: { r: 0, g: 255, b: 255 },
23
+ Aquamarine: { r: 127, g: 255, b: 212 },
24
+ Azure: { r: 240, g: 255, b: 255 },
25
+ Beige: { r: 245, g: 245, b: 220 },
26
+ Bisque: { r: 255, g: 228, b: 196 },
27
+ Black: { r: 0, g: 0, b: 0 },
28
+ BlanchedAlmond: { r: 255, g: 235, b: 205 },
29
+ Blue: { r: 0, g: 0, b: 255 },
30
+ BlueViolet: { r: 138, g: 43, b: 226 },
31
+ Brown: { r: 165, g: 42, b: 42 },
32
+ BurlyWood: { r: 222, g: 184, b: 135 },
33
+ CadetBlue: { r: 95, g: 158, b: 160 },
34
+ Chartreuse: { r: 127, g: 255, b: 0 },
35
+ Chocolate: { r: 210, g: 105, b: 30 },
36
+ Coral: { r: 255, g: 127, b: 80 },
37
+ CornflowerBlue: { r: 100, g: 149, b: 237 },
38
+ Cornsilk: { r: 255, g: 248, b: 220 },
39
+ Crimson: { r: 220, g: 20, b: 60 },
40
+ Cyan: { r: 0, g: 255, b: 255 },
41
+ DarkBlue: { r: 0, g: 0, b: 139 },
42
+ DarkCyan: { r: 0, g: 139, b: 139 },
43
+ DarkGoldenRod: { r: 184, g: 134, b: 11 },
44
+ DarkGray: { r: 169, g: 169, b: 169 },
45
+ DarkGreen: { r: 0, g: 100, b: 0 },
46
+ DarkKhaki: { r: 189, g: 183, b: 107 },
47
+ DarkMagenta: { r: 139, g: 0, b: 139 },
48
+ DarkOliveGreen: { r: 85, g: 107, b: 47 },
49
+ DarkOrange: { r: 255, g: 140, b: 0 },
50
+ DarkOrchid: { r: 153, g: 50, b: 204 },
51
+ DarkRed: { r: 139, g: 0, b: 0 },
52
+ DarkSalmon: { r: 233, g: 150, b: 122 },
53
+ DarkSeaGreen: { r: 143, g: 188, b: 143 },
54
+ DarkSlateBlue: { r: 72, g: 61, b: 139 },
55
+ DarkSlateGray: { r: 47, g: 79, b: 79 },
56
+ DarkTurquoise: { r: 0, g: 206, b: 209 },
57
+ DarkViolet: { r: 148, g: 0, b: 211 },
58
+ DeepPink: { r: 255, g: 20, b: 147 },
59
+ DeepSkyBlue: { r: 0, g: 191, b: 255 },
60
+ DimGray: { r: 105, g: 105, b: 105 },
61
+ DodgerBlue: { r: 30, g: 144, b: 255 },
62
+ FireBrick: { r: 178, g: 34, b: 34 },
63
+ FloralWhite: { r: 255, g: 250, b: 240 },
64
+ ForestGreen: { r: 34, g: 139, b: 34 },
65
+ Fuchsia: { r: 255, g: 0, b: 255 },
66
+ Gainsboro: { r: 220, g: 220, b: 220 },
67
+ GhostWhite: { r: 248, g: 248, b: 255 },
68
+ Gold: { r: 255, g: 215, b: 0 },
69
+ GoldenRod: { r: 218, g: 165, b: 32 },
70
+ Gray: { r: 128, g: 128, b: 128 },
71
+ Green: { r: 0, g: 128, b: 0 },
72
+ GreenYellow: { r: 173, g: 255, b: 47 },
73
+ HoneyDew: { r: 240, g: 255, b: 240 },
74
+ HotPink: { r: 255, g: 105, b: 180 },
75
+ IndianRed: { r: 205, g: 92, b: 92 },
76
+ Indigo: { r: 75, g: 0, b: 130 },
77
+ Ivory: { r: 255, g: 255, b: 240 },
78
+ Khaki: { r: 240, g: 230, b: 140 },
79
+ Lavender: { r: 230, g: 230, b: 250 },
80
+ LavenderBlush: { r: 255, g: 240, b: 245 },
81
+ LawnGreen: { r: 124, g: 252, b: 0 },
82
+ LemonChiffon: { r: 255, g: 250, b: 205 },
83
+ LightBlue: { r: 173, g: 216, b: 230 },
84
+ LightCoral: { r: 240, g: 128, b: 128 },
85
+ LightCyan: { r: 224, g: 255, b: 255 },
86
+ LightGoldenRodYellow: { r: 250, g: 250, b: 210 },
87
+ LightGray: { r: 211, g: 211, b: 211 },
88
+ LightGreen: { r: 144, g: 238, b: 144 },
89
+ LightPink: { r: 255, g: 182, b: 193 },
90
+ LightSalmon: { r: 255, g: 160, b: 122 },
91
+ LightSeaGreen: { r: 32, g: 178, b: 170 },
92
+ LightSkyBlue: { r: 135, g: 206, b: 250 },
93
+ LightSlateGray: { r: 119, g: 136, b: 153 },
94
+ LightSteelBlue: { r: 176, g: 196, b: 222 },
95
+ LightYellow: { r: 255, g: 255, b: 224 },
96
+ Lime: { r: 0, g: 255, b: 0 },
97
+ LimeGreen: { r: 50, g: 205, b: 50 },
98
+ Linen: { r: 250, g: 240, b: 230 },
99
+ Magenta: { r: 255, g: 0, b: 255 },
100
+ Maroon: { r: 128, g: 0, b: 0 },
101
+ // Maroon
102
+ MediumAquaMarine: { r: 102, g: 205, b: 170 },
103
+ MediumBlue: { r: 0, g: 0, b: 205 },
104
+ MediumOrchid: { r: 186, g: 85, b: 211 },
105
+ MediumPurple: { r: 147, g: 112, b: 219 },
106
+ MediumSeaGreen: { r: 60, g: 179, b: 113 },
107
+ MediumSlateBlue: { r: 123, g: 104, b: 238 },
108
+ MediumSpringGreen: { r: 0, g: 250, b: 154 },
109
+ MediumTurquoise: { r: 72, g: 209, b: 204 },
110
+ MediumVioletRed: { r: 199, g: 21, b: 133 },
111
+ MidnightBlue: { r: 25, g: 25, b: 112 },
112
+ MintCream: { r: 245, g: 255, b: 250 },
113
+ MistyRose: { r: 255, g: 228, b: 225 },
114
+ Moccasin: { r: 255, g: 228, b: 181 },
115
+ NavajoWhite: { r: 255, g: 222, b: 173 },
116
+ Navy: { r: 0, g: 0, b: 128 },
117
+ OldLace: { r: 253, g: 245, b: 230 },
118
+ Olive: { r: 128, g: 128, b: 0 },
119
+ OliveDrab: { r: 107, g: 142, b: 35 },
120
+ Orange: { r: 255, g: 165, b: 0 },
121
+ OrangeRed: { r: 255, g: 69, b: 0 },
122
+ Orchid: { r: 218, g: 112, b: 214 },
123
+ PaleGoldenRod: { r: 238, g: 232, b: 170 },
124
+ PaleGreen: { r: 152, g: 251, b: 152 },
125
+ PaleTurquoise: { r: 175, g: 238, b: 238 },
126
+ PaleVioletRed: { r: 219, g: 112, b: 147 },
127
+ PapayaWhip: { r: 255, g: 239, b: 213 },
128
+ PeachPuff: { r: 255, g: 218, b: 185 },
129
+ Peru: { r: 205, g: 133, b: 63 },
130
+ Pink: { r: 255, g: 192, b: 203 },
131
+ Plum: { r: 221, g: 160, b: 221 },
132
+ PowderBlue: { r: 176, g: 224, b: 230 },
133
+ Purple: { r: 128, g: 0, b: 128 },
134
+ RebeccaPurple: { r: 102, g: 51, b: 153 },
135
+ Red: { r: 255, g: 0, b: 0 },
136
+ RosyBrown: { r: 188, g: 143, b: 143 },
137
+ RoyalBlue: { r: 65, g: 105, b: 225 },
138
+ SaddleBrown: { r: 139, g: 69, b: 19 },
139
+ Salmon: { r: 250, g: 128, b: 114 },
140
+ SandyBrown: { r: 244, g: 164, b: 96 },
141
+ SeaGreen: { r: 46, g: 139, b: 87 },
142
+ SeaShell: { r: 255, g: 245, b: 238 },
143
+ Sienna: { r: 160, g: 82, b: 45 },
144
+ Silver: { r: 192, g: 192, b: 192 },
145
+ SkyBlue: { r: 135, g: 206, b: 235 },
146
+ SlateBlue: { r: 106, g: 90, b: 205 },
147
+ SlateGray: { r: 112, g: 128, b: 144 },
148
+ Snow: { r: 255, g: 250, b: 250 },
149
+ SpringGreen: { r: 0, g: 255, b: 127 },
150
+ SteelBlue: { r: 70, g: 130, b: 180 },
151
+ Tan: { r: 210, g: 180, b: 140 },
152
+ Teal: { r: 0, g: 128, b: 128 },
153
+ Thistle: { r: 216, g: 191, b: 216 },
154
+ Tomato: { r: 255, g: 99, b: 71 },
155
+ Turquoise: { r: 64, g: 224, b: 208 },
156
+ Violet: { r: 238, g: 130, b: 238 },
157
+ Wheat: { r: 245, g: 222, b: 179 },
158
+ White: { r: 255, g: 255, b: 255 },
159
+ WhiteSmoke: { r: 245, g: 245, b: 245 },
160
+ Yellow: { r: 255, g: 255, b: 0 },
161
+ YellowGreen: { r: 154, g: 205, b: 50 }
162
+ };
163
+ function colorWithAlpha(color, alpha) {
164
+ const lowerCasedColor = color.toLowerCase();
165
+ if (colorNames[lowerCasedColor]) {
166
+ const rgb = colorNames[lowerCasedColor];
167
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
168
+ }
169
+ if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
170
+ const hex = color.slice(1);
171
+ const bigint = parseInt(hex, 16);
172
+ const r = bigint >> 16 & 255;
173
+ const g = bigint >> 8 & 255;
174
+ const b = bigint & 255;
175
+ return `rgba(${r}, ${g}, ${b}, ${alpha})`;
176
+ }
177
+ if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
178
+ const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
179
+ if (result) {
180
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha})`;
181
+ }
182
+ }
183
+ return color;
184
+ }
185
+ function BorderedIcon(props) {
186
+ const theme2 = useMantineTheme();
187
+ return /* @__PURE__ */ jsx(
188
+ FontAwesomeIcon,
189
+ {
190
+ icon: props.icon,
191
+ color: colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][theme2.primaryShade], props.hovered ? 0.9 : 0.9),
192
+ style: {
193
+ // backgroundColor: colorWithAlpha(props.color ? props.color : theme.colors[theme.primaryColor][7 as number], (props.hoverable ? (props.hovered ? 0.3 : 0.2) : 0.2)),
194
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
195
+ padding: props.p || theme2.spacing.xs,
196
+ transition: "all 0.2s ease-in-out",
197
+ aspectRatio: "1/1",
198
+ fontSize: props.fontSize ? props.fontSize : "2.5vh",
199
+ borderRadius: theme2.radius.xs,
200
+ // border: `2px solid var(--mantine-primary-color-9)`,
201
+ outline: `0.2vh solid ${colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][9], 0.8)}`,
202
+ boxShadow: `inset 0 0 2vh ${colorWithAlpha(props.color ? props.color : theme2.colors[theme2.primaryColor][7], 0.5)}`
203
+ }
204
+ }
205
+ );
206
+ }
207
+ var MotionFlex = motion(Flex);
208
+ var MotionText = motion(Text);
209
+ var MotionIcon = motion(FontAwesomeIcon);
210
+ var MotionImage = motion(Image);
211
+ function Counter(props) {
212
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: props.count > 0 && /* @__PURE__ */ jsx(
213
+ MotionFlex,
214
+ {
215
+ initial: { opacity: 0 },
216
+ animate: { opacity: 1 },
217
+ exit: { opacity: 0 },
218
+ fz: "1.25vh",
219
+ h: "1.75vh",
220
+ justify: "center",
221
+ align: "center",
222
+ bg: props.color || "rgba(0, 0, 0, 0.51)",
223
+ style: {
224
+ borderRadius: "50%",
225
+ aspectRatio: "1/1",
226
+ marginBottom: "0.3vh",
227
+ fontFamily: "Akrobat Bold",
228
+ boxShadow: "0 0 5px rgba(0, 0, 0, 0.3)"
229
+ },
230
+ children: props.count
231
+ },
232
+ "counter"
233
+ ) });
234
+ }
235
+ var FloatingParticles = ({
236
+ icons = [],
237
+ particleCount = 55,
238
+ color = "#00a552ff",
239
+ size = 32,
240
+ speed = "slow",
241
+ opacity = 0.3,
242
+ style = {},
243
+ mouseRepelDistance = 150,
244
+ mouseRepelStrength = 50,
245
+ backgroundColor = "transparent"
246
+ }) => {
247
+ const containerRef = useRef(null);
248
+ const [particles, setParticles] = useState([]);
249
+ const mouseX = useMotionValue(0);
250
+ const mouseY = useMotionValue(0);
251
+ const durationMap = {
252
+ slow: { base: 10, variance: 10 },
253
+ medium: { base: 2, variance: 2 },
254
+ fast: { base: 4, variance: 2 }
255
+ };
256
+ const duration = durationMap[speed];
257
+ const seededRandom = (seed) => {
258
+ const x = Math.sin(seed) * 1e4;
259
+ return x - Math.floor(x);
260
+ };
261
+ useEffect(() => {
262
+ if (!containerRef.current) return;
263
+ const bounds = containerRef.current.getBoundingClientRect();
264
+ const newParticles = [...Array(particleCount)].map((_, i) => {
265
+ const seedX = i * 123.456;
266
+ const seedY = i * 789.012;
267
+ const seedDuration = i * 345.678;
268
+ const baseX = seededRandom(seedX) * bounds.width;
269
+ const baseY = seededRandom(seedY) * bounds.height;
270
+ return {
271
+ id: i,
272
+ baseX,
273
+ baseY,
274
+ currentX: baseX,
275
+ currentY: baseY,
276
+ icon: icons.length > 0 ? icons[i % icons.length] : null,
277
+ animationDuration: duration.base + seededRandom(seedDuration) * duration.variance
278
+ };
279
+ });
280
+ setParticles(newParticles);
281
+ }, [particleCount, icons.length, duration.base, duration.variance]);
282
+ useEffect(() => {
283
+ if (!containerRef.current) return;
284
+ const handleMouseMove = (e) => {
285
+ const bounds = containerRef.current.getBoundingClientRect();
286
+ const x = e.clientX - bounds.left;
287
+ const y = e.clientY - bounds.top;
288
+ mouseX.set(x);
289
+ mouseY.set(y);
290
+ setParticles(
291
+ (prevParticles) => prevParticles.map((particle) => {
292
+ const dx = x - particle.baseX;
293
+ const dy = y - particle.baseY;
294
+ const distance = Math.sqrt(dx * dx + dy * dy);
295
+ if (distance < mouseRepelDistance && distance > 0) {
296
+ const force = (mouseRepelDistance - distance) / mouseRepelDistance;
297
+ const repelX = dx / distance * force * mouseRepelStrength * -1;
298
+ const repelY = dy / distance * force * mouseRepelStrength * -1;
299
+ return {
300
+ ...particle,
301
+ currentX: particle.baseX + repelX,
302
+ currentY: particle.baseY + repelY
303
+ };
304
+ } else {
305
+ return {
306
+ ...particle,
307
+ currentX: particle.baseX,
308
+ currentY: particle.baseY
309
+ };
310
+ }
311
+ })
312
+ );
313
+ };
314
+ const handleMouseLeave = () => {
315
+ setParticles(
316
+ (prevParticles) => prevParticles.map((particle) => ({
317
+ ...particle,
318
+ currentX: particle.baseX,
319
+ currentY: particle.baseY
320
+ }))
321
+ );
322
+ };
323
+ const container = containerRef.current;
324
+ container.addEventListener("mousemove", handleMouseMove);
325
+ container.addEventListener("mouseleave", handleMouseLeave);
326
+ return () => {
327
+ container.removeEventListener("mousemove", handleMouseMove);
328
+ container.removeEventListener("mouseleave", handleMouseLeave);
329
+ };
330
+ }, [mouseX, mouseY, mouseRepelDistance, mouseRepelStrength]);
331
+ useEffect(() => {
332
+ const handleResize = () => {
333
+ if (!containerRef.current) return;
334
+ const bounds = containerRef.current.getBoundingClientRect();
335
+ setParticles(
336
+ (prevParticles) => prevParticles.map((particle, i) => {
337
+ const seedX = i * 123.456 + bounds.width;
338
+ const seedY = i * 789.012 + bounds.height;
339
+ const newBaseX = seededRandom(seedX) * bounds.width;
340
+ const newBaseY = seededRandom(seedY) * bounds.height;
341
+ return {
342
+ ...particle,
343
+ baseX: newBaseX,
344
+ baseY: newBaseY,
345
+ currentX: newBaseX,
346
+ currentY: newBaseY
347
+ };
348
+ })
349
+ );
350
+ };
351
+ window.addEventListener("resize", handleResize);
352
+ return () => window.removeEventListener("resize", handleResize);
353
+ }, []);
354
+ return /* @__PURE__ */ jsx(
355
+ "div",
356
+ {
357
+ ref: containerRef,
358
+ style: {
359
+ position: "absolute",
360
+ overflow: "hidden",
361
+ width: "100%",
362
+ height: "100%",
363
+ zIndex: -1,
364
+ backgroundColor,
365
+ ...style
366
+ },
367
+ children: /* @__PURE__ */ jsx("div", { style: { position: "absolute", inset: 0, pointerEvents: "none" }, children: particles.map((particle) => /* @__PURE__ */ jsx(
368
+ motion.div,
369
+ {
370
+ style: {
371
+ position: "absolute",
372
+ width: size,
373
+ height: size,
374
+ color,
375
+ opacity,
376
+ left: 0,
377
+ top: 0
378
+ },
379
+ animate: {
380
+ x: particle.currentX,
381
+ y: particle.currentY,
382
+ scale: [0.8, 1.1, 0.8],
383
+ opacity: [opacity * 0.5, opacity, opacity * 0.5],
384
+ // random rotate between 0 and 360 so that not all particles rotate the same
385
+ rotate: particle.id % 2 === 0 ? [0, 360] : [360, 0]
386
+ },
387
+ transition: {
388
+ x: { type: "spring", stiffness: 150, damping: 20 },
389
+ y: { type: "spring", stiffness: 150, damping: 20 },
390
+ rotate: {
391
+ duration: particle.animationDuration,
392
+ repeat: Infinity,
393
+ ease: "linear"
394
+ },
395
+ scale: {
396
+ duration: particle.animationDuration,
397
+ repeat: Infinity,
398
+ delay: seededRandom(particle.id * 111.222) * 5,
399
+ ease: "easeInOut"
400
+ },
401
+ opacity: {
402
+ duration: particle.animationDuration,
403
+ repeat: Infinity,
404
+ delay: seededRandom(particle.id * 333.444) * 5,
405
+ ease: "easeInOut"
406
+ }
407
+ },
408
+ children: particle.icon ? /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ jsx(FontAwesomeIcon, { icon: particle.icon, style: { width: "70%", height: "70%" } }) }) : /* @__PURE__ */ jsx(
409
+ "div",
410
+ {
411
+ style: {
412
+ width: "100%",
413
+ height: "100%",
414
+ borderRadius: "50%",
415
+ backgroundColor: color
416
+ }
417
+ }
418
+ )
419
+ },
420
+ particle.id
421
+ )) })
422
+ }
423
+ );
424
+ };
425
+ function Icon(props) {
426
+ return /* @__PURE__ */ jsx(Fragment, {});
427
+ }
428
+ function InfoBox(props) {
429
+ const theme2 = useMantineTheme();
430
+ return /* @__PURE__ */ jsxs(
431
+ Flex,
432
+ {
433
+ w: "fit-content",
434
+ h: "fit-content",
435
+ style: {
436
+ borderRadius: theme2.radius.xs,
437
+ overflow: "hidden",
438
+ border: `0.2vh solid rgba(77,77,77,0.3)`
439
+ },
440
+ align: "center",
441
+ children: [
442
+ /* @__PURE__ */ jsx(
443
+ Flex,
444
+ {
445
+ miw: "4vh",
446
+ p: "xxs",
447
+ bg: "rgba(77,77,77,0.2)",
448
+ direction: "column",
449
+ justify: "center",
450
+ align: "center",
451
+ children: /* @__PURE__ */ jsx(
452
+ Text,
453
+ {
454
+ c: "lightgrey",
455
+ size: "xxs",
456
+ style: {
457
+ fontFamily: "Akrobat Bold",
458
+ letterSpacing: "0.05em",
459
+ textTransform: "uppercase"
460
+ },
461
+ children: props.leftSide
462
+ }
463
+ )
464
+ }
465
+ ),
466
+ /* @__PURE__ */ jsx(
467
+ Flex,
468
+ {
469
+ p: "xxs",
470
+ flex: 1,
471
+ miw: "4vh",
472
+ bg: "rgba(77,77,77,0.5)",
473
+ direction: "column",
474
+ align: "center",
475
+ justify: "center",
476
+ children: /* @__PURE__ */ jsx(
477
+ Text,
478
+ {
479
+ c: "lightgrey",
480
+ size: "xxs",
481
+ style: {
482
+ fontFamily: "Akrobat Bold",
483
+ letterSpacing: "0.05em",
484
+ textTransform: "uppercase"
485
+ },
486
+ children: props.rightSide
487
+ }
488
+ )
489
+ }
490
+ )
491
+ ]
492
+ }
493
+ );
494
+ }
495
+ function InputContainer(props) {
496
+ const theme2 = useMantineTheme();
497
+ return /* @__PURE__ */ jsxs(
498
+ MotionFlex,
499
+ {
500
+ w: props.w || "100%",
501
+ flex: props.flex,
502
+ direction: "column",
503
+ h: props.h,
504
+ gap: props.title ? "xs" : 0,
505
+ bg: props.bg || "rgba(69, 69, 69, 0.42)",
506
+ p: "sm",
507
+ style: {
508
+ borderRadius: theme2.radius.xs,
509
+ boxShadow: theme2.shadows.sm,
510
+ overflow: "hidden",
511
+ outline: props.error ? `1px solid rgba(255, 100, 100, 0.8)` : "none"
512
+ },
513
+ variants: props.variants,
514
+ children: [
515
+ /* @__PURE__ */ jsxs(
516
+ Flex,
517
+ {
518
+ align: "center",
519
+ gap: "xs",
520
+ children: [
521
+ /* @__PURE__ */ jsxs(
522
+ Flex,
523
+ {
524
+ direction: "column",
525
+ gap: "xxs",
526
+ children: [
527
+ props.title && /* @__PURE__ */ jsx(
528
+ Text,
529
+ {
530
+ size: "sm",
531
+ style: {
532
+ lineHeight: "1.25vh",
533
+ fontFamily: "Akrobat Bold",
534
+ letterSpacing: "0.05em",
535
+ textTransform: "uppercase"
536
+ },
537
+ children: props.title
538
+ }
539
+ ),
540
+ props.description && /* @__PURE__ */ jsx(
541
+ Text,
542
+ {
543
+ size: "xs",
544
+ c: "rgba(255, 255, 255, 0.8)",
545
+ fw: 400,
546
+ children: props.description
547
+ }
548
+ )
549
+ ]
550
+ }
551
+ ),
552
+ props.error && /* @__PURE__ */ jsx(
553
+ Text,
554
+ {
555
+ size: "xs",
556
+ c: theme2.colors.red[9],
557
+ fw: 600,
558
+ mb: "auto",
559
+ lh: "0.8",
560
+ children: props.error
561
+ }
562
+ ),
563
+ /* @__PURE__ */ jsx(
564
+ Flex,
565
+ {
566
+ ml: "auto",
567
+ children: props.rightSection
568
+ }
569
+ )
570
+ ]
571
+ }
572
+ ),
573
+ props.children
574
+ ]
575
+ }
576
+ );
577
+ }
578
+
579
+ // src/hooks/useAudio/click_sound.mp3
580
+ var click_sound_default = "./click_sound-PNCRRTM4.mp3";
581
+
582
+ // src/hooks/useAudio/hover_sound.mp3
583
+ var hover_sound_default = "./hover_sound-NBUA222C.mp3";
584
+
585
+ // src/hooks/useAudio/store.ts
586
+ var useAudio = create(() => {
587
+ const audioRefs = {};
588
+ const sounds = {
589
+ click: click_sound_default,
590
+ hover: hover_sound_default
591
+ };
592
+ for (const [key, src] of Object.entries(sounds)) {
593
+ audioRefs[key] = new Audio(src);
594
+ }
595
+ return {
596
+ play: (sound) => {
597
+ const audio = audioRefs[sound];
598
+ if (!audio) return console.warn(`Sound '${sound}' not found.`);
599
+ audio.currentTime = 0;
600
+ audio.volume = 0.1;
601
+ audio.play();
602
+ },
603
+ stop: (sound) => {
604
+ const audio = audioRefs[sound];
605
+ if (!audio) return console.warn(`Sound '${sound}' not found.`);
606
+ audio.pause();
607
+ audio.currentTime = 0;
608
+ }
609
+ };
610
+ });
611
+
612
+ // src/utils/misc.ts
613
+ var isEnvBrowser = () => !window.invokeNative;
614
+ var noop = () => {
615
+ };
616
+ var splitFAString = (faString) => {
617
+ const [prefix, newIcon] = faString.split("-");
618
+ if (!prefix || !newIcon) return { prefix: "fas", newIcon: "question" };
619
+ return { prefix, newIcon };
620
+ };
621
+ var numberToRoman = (num) => {
622
+ const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX"];
623
+ return romanNumerals[num];
624
+ };
625
+ var copyToClipboard = (text) => {
626
+ const el = document.createElement("textarea");
627
+ el.value = text;
628
+ document.body.appendChild(el);
629
+ el.select();
630
+ document.execCommand("copy");
631
+ document.body.removeChild(el);
632
+ };
633
+ var openLink = (url) => {
634
+ if (isEnvBrowser()) {
635
+ window.open(url, "_blank");
636
+ } else {
637
+ window.invokeNative("openLink", url);
638
+ }
639
+ };
640
+
641
+ // src/utils/fetchNui.ts
642
+ async function fetchNui(eventName, data, mockData) {
643
+ const options = {
644
+ method: "post",
645
+ headers: {
646
+ "Content-Type": "application/json; charset=UTF-8"
647
+ },
648
+ body: JSON.stringify(data)
649
+ };
650
+ console.log("Mock Data:", mockData);
651
+ console.log("Is Env Browser:", isEnvBrowser());
652
+ if (isEnvBrowser() && mockData !== void 0) return mockData;
653
+ const resourceName = window.GetParentResourceName ? window.GetParentResourceName() : "nui-frame-app";
654
+ const resp = await fetch(`https://${resourceName}/${eventName}`, options);
655
+ const respFormatted = await resp.json();
656
+ return respFormatted;
657
+ }
658
+ function fetchOnLoad(eventName, data, mockData) {
659
+ return fetchNui(eventName, data, mockData).catch((err) => {
660
+ console.error(`[fetchOnLoad] Failed for ${eventName}:`, err);
661
+ throw err;
662
+ });
663
+ }
664
+ var fetchLuaTable = (tableName) => () => {
665
+ if (isEnvBrowser()) {
666
+ return Promise.resolve({});
667
+ }
668
+ return fetchNui("GET_LUA_TABLE", { tableName });
669
+ };
670
+
671
+ // src/utils/internalEvent.ts
672
+ var internalEvent = (events, timer = 1e3) => {
673
+ if (isEnvBrowser()) {
674
+ for (const event of events) {
675
+ setTimeout(() => {
676
+ window.dispatchEvent(
677
+ new MessageEvent("message", {
678
+ data: {
679
+ action: event.action,
680
+ data: event.data
681
+ }
682
+ })
683
+ );
684
+ }, timer);
685
+ }
686
+ }
687
+ };
688
+ var localeStore = create((set, get) => {
689
+ return {
690
+ locales: {
691
+ "OccupantsDesc": "Here you can view and manage the occupants of your traphouse. These occupants can be used mainly for selling drugs to the NPCs surrounding your traphouse. However they have other uses to so be careful who you add as an occupant."
692
+ },
693
+ locale: (key, ...args) => {
694
+ const exists = get().locales[key];
695
+ let translation = exists || key;
696
+ if (args.length) {
697
+ translation = translation.replace(/%s/g, () => String(args.shift() || ""));
698
+ }
699
+ return translation;
700
+ }
701
+ };
702
+ });
703
+ var locale = localeStore.getState().locale;
704
+ fetchOnLoad("GET_LOCALES").then((data) => {
705
+ localeStore.setState({ locales: data });
706
+ });
707
+ function SegmentedControl(props) {
708
+ const theme2 = useMantineTheme();
709
+ const play = useAudio((state) => state.play);
710
+ const handleChange = (newValue) => {
711
+ if (props.sounds) play("click");
712
+ if (props.onChange) {
713
+ props.onChange(newValue);
714
+ }
715
+ };
716
+ return /* @__PURE__ */ jsx(
717
+ Flex,
718
+ {
719
+ bg: "rgba(33, 33, 33, 0.6)",
720
+ w: props.w || "fit-content",
721
+ style: {
722
+ borderRadius: theme2.radius.xs,
723
+ overflow: "hidden"
724
+ },
725
+ ...props,
726
+ children: props.items.map((item, index) => /* @__PURE__ */ jsx(
727
+ motion.div,
728
+ {
729
+ initial: { x: -100, opacity: 0 },
730
+ animate: { x: 0, opacity: 1 },
731
+ transition: { duration: 0.3, delay: index * 0.1, ease: "easeInOut" },
732
+ style: {
733
+ display: "flex",
734
+ flexDirection: "row",
735
+ alignItems: "center",
736
+ flex: 1
737
+ },
738
+ children: /* @__PURE__ */ jsx(
739
+ Segment,
740
+ {
741
+ label: item.label,
742
+ value: item.value,
743
+ icon: item.icon,
744
+ rightSection: item.rightSection,
745
+ fz: props.fz,
746
+ selected: !props.multi ? props.value === item.value : Array.isArray(props.value) && props.value.includes(item.value),
747
+ onClick: () => {
748
+ if (props.multi) {
749
+ const newValue = Array.isArray(props.value) ? props.value.includes(item.value) ? props.value.filter((v) => v !== item.value) : [...props.value, item.value] : [item.value];
750
+ handleChange(newValue);
751
+ } else {
752
+ handleChange(item.value);
753
+ }
754
+ }
755
+ },
756
+ item.value
757
+ )
758
+ },
759
+ index
760
+ ))
761
+ }
762
+ );
763
+ }
764
+ function Segment(props) {
765
+ const theme2 = useMantineTheme();
766
+ return /* @__PURE__ */ jsxs(
767
+ MotionFlex,
768
+ {
769
+ onClick: props.onClick,
770
+ w: "100%",
771
+ direction: "column",
772
+ align: "center",
773
+ h: "100%",
774
+ bg: props.selected ? colorWithAlpha(theme2.colors[theme2.primaryColor][theme2.primaryShade], 0.2) : "transparent",
775
+ pos: "relative",
776
+ style: {
777
+ // position: "relative",
778
+ cursor: "pointer"
779
+ },
780
+ justify: "center",
781
+ whileHover: { scale: 1.05 },
782
+ whileTap: { scale: 0.95 },
783
+ children: [
784
+ /* @__PURE__ */ jsxs(
785
+ Flex,
786
+ {
787
+ align: "center",
788
+ gap: "xs",
789
+ p: "xs",
790
+ children: [
791
+ props.icon && /* @__PURE__ */ jsx(
792
+ MotionIcon,
793
+ {
794
+ icon: props.icon,
795
+ initial: {
796
+ color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
797
+ },
798
+ animate: {
799
+ color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
800
+ },
801
+ exit: {
802
+ color: "inherit"
803
+ },
804
+ style: {
805
+ fontSize: theme2.fontSizes.xs,
806
+ marginBottom: "0.2vh"
807
+ }
808
+ }
809
+ ),
810
+ /* @__PURE__ */ jsx(
811
+ MotionText,
812
+ {
813
+ size: props.fz || "xs",
814
+ initial: {
815
+ color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
816
+ },
817
+ animate: {
818
+ color: props.selected ? theme2.colors[theme2.primaryColor][5] : "inherit"
819
+ },
820
+ exit: {
821
+ color: "inherit"
822
+ },
823
+ style: {
824
+ fontFamily: "Akrobat Bold",
825
+ letterSpacing: "0.1em",
826
+ textTransform: "uppercase"
827
+ },
828
+ children: props.label.toUpperCase()
829
+ }
830
+ ),
831
+ props.rightSection
832
+ ]
833
+ }
834
+ ),
835
+ /* @__PURE__ */ jsx(
836
+ motion.div,
837
+ {
838
+ initial: false,
839
+ animate: {
840
+ scaleX: props.selected ? 1 : 0,
841
+ opacity: props.selected ? 1 : 0
842
+ },
843
+ transition: {
844
+ duration: 0.3,
845
+ ease: [0.4, 0, 0.2, 1]
846
+ // Custom easing curve for smooth feel
847
+ },
848
+ style: {
849
+ position: "absolute",
850
+ bottom: 0,
851
+ left: 0,
852
+ right: 0,
853
+ height: "0.2vh",
854
+ backgroundColor: theme2.colors[theme2.primaryColor][5],
855
+ transformOrigin: "center"
856
+ }
857
+ }
858
+ )
859
+ ]
860
+ }
861
+ );
862
+ }
863
+ var NavigationContext = createContext(null);
864
+ function useNavigation(selector) {
865
+ const navigation = useContext(NavigationContext);
866
+ if (!navigation) {
867
+ throw new Error("useNavigation must be used within a NavigationProvider");
868
+ }
869
+ return useStore(navigation, selector);
870
+ }
871
+ function useNavigationStore() {
872
+ const navigation = useContext(NavigationContext);
873
+ if (!navigation) {
874
+ throw new Error("useNavigationStore must be used within a NavigationProvider");
875
+ }
876
+ return navigation;
877
+ }
878
+ function NavigationProvider({ children, defaultPage }) {
879
+ const storeRef = useRef(
880
+ create(() => ({
881
+ pageId: defaultPage || "home"
882
+ }))
883
+ );
884
+ return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: storeRef.current, children });
885
+ }
886
+ function NavBar(props) {
887
+ const pageId = useNavigation((state) => state.pageId);
888
+ const store = useNavigationStore();
889
+ return /* @__PURE__ */ jsx(
890
+ SegmentedControl,
891
+ {
892
+ sounds: true,
893
+ w: "100%",
894
+ value: pageId,
895
+ items: props.items,
896
+ onChange: (value) => {
897
+ store.setState({ pageId: value });
898
+ }
899
+ }
900
+ );
901
+ }
902
+ var containerVariants = {
903
+ hidden: { opacity: 0 },
904
+ visible: {
905
+ opacity: 1,
906
+ transition: {
907
+ staggerChildren: 0.1,
908
+ delayChildren: 0.05
909
+ }
910
+ },
911
+ exit: {
912
+ opacity: 0,
913
+ transition: {
914
+ staggerChildren: 0.05,
915
+ staggerDirection: -1
916
+ }
917
+ }
918
+ };
919
+ var itemVariants = {
920
+ hidden: {
921
+ opacity: 0,
922
+ x: 20,
923
+ scale: 0.95
924
+ },
925
+ visible: {
926
+ opacity: 1,
927
+ x: 0,
928
+ scale: 1,
929
+ transition: {
930
+ type: "spring",
931
+ stiffness: 300,
932
+ damping: 24
933
+ }
934
+ },
935
+ exit: {
936
+ opacity: 0,
937
+ x: -10,
938
+ scale: 0.95,
939
+ transition: {
940
+ duration: 0.2
941
+ }
942
+ }
943
+ };
944
+ function SegmentedProgress(props) {
945
+ const progressPerSegment = 100 / props.segments;
946
+ const filledSegments = Math.floor(props.progress / progressPerSegment);
947
+ const partialFill = props.progress % progressPerSegment / progressPerSegment;
948
+ return /* @__PURE__ */ jsx(
949
+ MotionFlex,
950
+ {
951
+ w: "100%",
952
+ h: props.size || "1vh",
953
+ gap: "xs",
954
+ initial: "hidden",
955
+ animate: "visible",
956
+ variants: containerVariants,
957
+ children: [...Array(props.segments)].map((_, index) => {
958
+ const isFilled = index < filledSegments;
959
+ const isPartial = index === filledSegments;
960
+ return /* @__PURE__ */ jsx(
961
+ motion.div,
962
+ {
963
+ variants: itemVariants,
964
+ style: {
965
+ width: `${100 / props.segments}%`,
966
+ // Ensures equal width distribution
967
+ height: "100%",
968
+ background: isFilled ? "rgba(255, 255, 255, 0.8)" : isPartial ? `linear-gradient(to right, rgba(255, 255, 255, 0.8) ${partialFill * 100}%, rgba(255, 255, 255, 0.2) ${partialFill * 100}%)` : "rgba(255, 255, 255, 0.2)",
969
+ transition: "background 0.3s ease"
970
+ }
971
+ },
972
+ index
973
+ );
974
+ })
975
+ }
976
+ );
977
+ }
978
+ function Title(props) {
979
+ const theme2 = useMantineTheme();
980
+ return /* @__PURE__ */ jsx(
981
+ Flex,
982
+ {
983
+ mt: props.mt,
984
+ direction: "column",
985
+ bg: props.bg || "transparent",
986
+ gap: "xs",
987
+ w: props.w || "100%",
988
+ p: props.p || "0",
989
+ style: {
990
+ userSelect: "none",
991
+ borderBottom: props.removeBorder ? "none" : `0.2vh solid ${props.borderColor || colorWithAlpha(theme2.colors[theme2.primaryColor][9], 0.5)}`
992
+ },
993
+ children: /* @__PURE__ */ jsxs(
994
+ Flex,
995
+ {
996
+ align: "center",
997
+ justify: "center",
998
+ children: [
999
+ /* @__PURE__ */ jsxs(
1000
+ Flex,
1001
+ {
1002
+ align: "center",
1003
+ gap: "sm",
1004
+ pr: "xs",
1005
+ children: [
1006
+ /* @__PURE__ */ jsx(
1007
+ BorderedIcon,
1008
+ {
1009
+ icon: props.icon,
1010
+ fontSize: theme2.fontSizes.md,
1011
+ color: props.iconColor
1012
+ }
1013
+ ),
1014
+ /* @__PURE__ */ jsxs(
1015
+ Flex,
1016
+ {
1017
+ direction: "column",
1018
+ gap: "0.25vh",
1019
+ children: [
1020
+ /* @__PURE__ */ jsx(Text, { p: "0", size: "sm", style: {
1021
+ lineHeight: theme2.fontSizes.md,
1022
+ fontFamily: "Akrobat Bold",
1023
+ letterSpacing: "0.05em",
1024
+ textTransform: "uppercase"
1025
+ }, children: props.title }),
1026
+ /* @__PURE__ */ jsx(
1027
+ Text,
1028
+ {
1029
+ size: "xs",
1030
+ c: "grey",
1031
+ style: { whiteSpace: "normal", wordWrap: "break-word" },
1032
+ children: props.description
1033
+ }
1034
+ )
1035
+ ]
1036
+ }
1037
+ )
1038
+ ]
1039
+ }
1040
+ ),
1041
+ /* @__PURE__ */ jsx(
1042
+ Flex,
1043
+ {
1044
+ ml: "auto",
1045
+ align: "center",
1046
+ gap: "xs",
1047
+ children: props.rightSection
1048
+ }
1049
+ )
1050
+ ]
1051
+ }
1052
+ )
1053
+ }
1054
+ );
1055
+ }
1056
+ var useNuiEvent = (action, handler) => {
1057
+ const savedHandler = useRef(noop);
1058
+ useEffect(() => {
1059
+ savedHandler.current = handler;
1060
+ }, [handler]);
1061
+ useEffect(() => {
1062
+ const eventListener = (event) => {
1063
+ const { action: eventAction, data } = event.data;
1064
+ if (savedHandler.current) {
1065
+ if (eventAction === action) {
1066
+ savedHandler.current(data);
1067
+ }
1068
+ }
1069
+ };
1070
+ window.addEventListener("message", eventListener);
1071
+ return () => window.removeEventListener("message", eventListener);
1072
+ }, [action]);
1073
+ };
1074
+ var theme = createTheme({
1075
+ primaryColor: "dirk",
1076
+ primaryShade: 9,
1077
+ defaultRadius: "xxs",
1078
+ fontFamily: "Akrobat Regular, sans-serif",
1079
+ radius: {
1080
+ xxs: "0.2vh",
1081
+ xs: "0.4vh",
1082
+ sm: "0.75vh",
1083
+ md: "1vh",
1084
+ lg: "1.5vh",
1085
+ xl: "2vh",
1086
+ xxl: "3vh"
1087
+ },
1088
+ fontSizes: {
1089
+ xxs: "1.2vh",
1090
+ xs: "1.5vh",
1091
+ sm: "1.8vh",
1092
+ md: "2.2vh",
1093
+ lg: "2.8vh",
1094
+ xl: "3.3vh",
1095
+ xxl: "3.8vh"
1096
+ },
1097
+ spacing: {
1098
+ xxs: "0.5vh",
1099
+ xs: "0.75vh",
1100
+ sm: "1.5vh",
1101
+ md: "2vh",
1102
+ lg: "3vh",
1103
+ xl: "4vh",
1104
+ xxl: "5vh"
1105
+ },
1106
+ components: {
1107
+ Progress: {
1108
+ styles: {
1109
+ root: {
1110
+ backgroundColor: "rgba(77, 77, 77, 0.4)"
1111
+ }
1112
+ }
1113
+ },
1114
+ Select: {
1115
+ styles: {
1116
+ dropdown: {
1117
+ borderRadius: "var(--mantine-radius-xxs)"
1118
+ },
1119
+ input: {
1120
+ padding: "var(--mantine-spacing-sm)"
1121
+ },
1122
+ item: {
1123
+ borderRadius: "var(--mantine-radius-xxs)"
1124
+ },
1125
+ wrapper: {
1126
+ borderRadius: "var(--mantine-radius-xxs)"
1127
+ },
1128
+ option: {
1129
+ borderRadius: "var(--mantine-radius-xxs)"
1130
+ }
1131
+ }
1132
+ },
1133
+ MultiSelect: {
1134
+ styles: {
1135
+ dropdown: {
1136
+ borderRadius: "var(--mantine-radius-xxs)"
1137
+ },
1138
+ pill: {
1139
+ borderRadius: "var(--mantine-radius-xxs)"
1140
+ },
1141
+ item: {
1142
+ borderRadius: "var(--mantine-radius-xxs)"
1143
+ },
1144
+ wrapper: {
1145
+ borderRadius: "var(--mantine-radius-xxs)"
1146
+ },
1147
+ option: {
1148
+ borderRadius: "var(--mantine-radius-xxs)"
1149
+ }
1150
+ }
1151
+ },
1152
+ TextInput: {
1153
+ styles: {
1154
+ section: {
1155
+ marginRight: "0.2vh"
1156
+ },
1157
+ input: {
1158
+ padding: "var(--mantine-spacing-sm)"
1159
+ }
1160
+ }
1161
+ }
1162
+ },
1163
+ colors: {
1164
+ dark: [
1165
+ "#ffffff",
1166
+ "#e2e2e2",
1167
+ "#c6c6c6",
1168
+ "#aaaaaa",
1169
+ "#8d8d8d",
1170
+ "#717171",
1171
+ "#555555",
1172
+ "#393939",
1173
+ "#1c1c1c",
1174
+ "#000000"
1175
+ ],
1176
+ dirk: [
1177
+ "#ffffff",
1178
+ "#f3fce9",
1179
+ "#dbf5bd",
1180
+ "#c3ee91",
1181
+ "#ace765",
1182
+ "#94e039",
1183
+ "#7ac61f",
1184
+ "#5f9a18",
1185
+ "#29420a",
1186
+ "#446e11"
1187
+ ]
1188
+ }
1189
+ });
1190
+ var theme_default = theme;
1191
+ library.add(fas, far, fab);
1192
+ var useSettings = create((set) => ({
1193
+ game: "rdr3",
1194
+ primaryColor: "teal",
1195
+ primaryShade: 6,
1196
+ customTheme: {}
1197
+ }));
1198
+ function DirkProvider(props) {
1199
+ useSettings((data) => data.primaryColor);
1200
+ useSettings((data) => data.primaryShade);
1201
+ useSettings((data) => data.customTheme);
1202
+ return /* @__PURE__ */ jsx(MantineProvider, { theme: theme_default, defaultColorScheme: "dark", children: /* @__PURE__ */ jsx(Wrapper, { children: props.children }) });
1203
+ }
1204
+ function Wrapper({ children }) {
1205
+ const game = useSettings((data) => data.game);
1206
+ return isEnvBrowser() ? /* @__PURE__ */ jsx(
1207
+ BackgroundImage,
1208
+ {
1209
+ w: "100vw",
1210
+ h: "100vh",
1211
+ style: { overflow: "hidden" },
1212
+ src: game === "fivem" ? "https://i.ytimg.com/vi/TOxuNbXrO28/maxresdefault.jpg" : "https://raw.githubusercontent.com/Jump-On-Studios/RedM-jo_libs/refs/heads/main/source-repositories/Menu/public/assets/images/background_dev.jpg",
1213
+ children
1214
+ }
1215
+ ) : /* @__PURE__ */ jsx(Fragment, { children });
1216
+ }
1217
+
1218
+ export { BorderedIcon, Counter, DirkProvider, FloatingParticles, Icon, InfoBox, InputContainer, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, Segment, SegmentedControl, SegmentedProgress, Title, colorWithAlpha, copyToClipboard, fetchLuaTable, fetchNui, fetchOnLoad, internalEvent, isEnvBrowser, locale, localeStore, noop, numberToRoman, openLink, splitFAString, useNavigation, useNavigationStore, useNuiEvent, useSettings };
1219
+ //# sourceMappingURL=index.mjs.map
1220
+ //# sourceMappingURL=index.mjs.map