2025-05-21 21:34:22 +03:00
< script lang = "ts" >
import '../app.css';
2025-05-22 13:17:11 +03:00
import * as Sidebar from '$lib/components/ui/sidebar/index.js';
2025-05-23 16:26:02 +03:00
import { Toaster } from '$lib/components/ui/sonner';
2025-05-22 13:17:11 +03:00
import AppSidebar from '$lib/components/self/AppSidebar.svelte';
import { USER_DATA } from '$lib/stores/user-data';
2025-05-29 17:41:09 +03:00
import { onMount , onDestroy } from 'svelte'; // onDestroy is already imported
2025-05-22 13:17:11 +03:00
import { invalidateAll } from '$app/navigation';
2025-05-22 14:08:37 +03:00
import { ModeWatcher } from 'mode-watcher';
2025-05-23 16:26:02 +03:00
import { page } from '$app/state';
2025-05-26 15:06:45 +03:00
import { websocketController } from '$lib/stores/websocket';
2025-05-22 13:17:11 +03:00
let { data , children } = $props< {
data: { userSession? : any } ;
children: any;
}>();
2025-05-29 17:41:09 +03:00
USER_DATA.set(data?.userSession ?? null);
2025-05-22 13:17:11 +03:00
$effect(() => {
2025-05-29 17:41:09 +03:00
USER_DATA.set(data?.userSession ?? null);
2025-05-22 13:17:11 +03:00
});
onMount(() => {
2025-05-26 15:06:45 +03:00
websocketController.connect();
2025-05-22 13:17:11 +03:00
console.log(
`%c .--
.=--:
:=*#*:
.=******+#*.
.+*****+*#*+**#*
:**++**####*###*++#-
=***+*####******###*+#*
=***++#####***+++***%#*+*%:
=*++*###+=++++====****##%#**#=
.+**+=*##=*###+####*#+++*###%#**#=
:#*=**####=*#+-*##=-*##+**#####%##*%=
. :+**++*###***++=*#++=*###**######%%%####:.--:
.---=******+*###****=***=-**+##*#+*###%%%***##%%#=--:
:-: =#++**##***+++=******#*=##**#%%%##*#%*:
.**++*##***++**+**#*####+*%%#**#%+.
+***+##*=**=++******##%%*####:
-#+++###***+*######%####%+
.#*++*##**#####%%#**##=
*#*+*######%%#*###=
+#**#%%%%##**##-
=#***#*###%+.
-%#####*:
.=%#*:
.=--=.
::`,
'color: #4962ee; font-family: monospace; font-size: 12px; font-weight: bold; text-shadow: 2px 2px rgba(0,0,0,0.2);'
);
console.log(
'%c Welcome to Rugplay! DO NOT FUCKING PASTE ANYTHING IN THE CONSOLE UNLESS YOU KNOW WHAT YOU ARE DOING.',
'color: #4962ee; font-family: monospace; font-size: 12px; font-weight: bold; text-shadow: 2px 2px rgba(0,0,0,0.2);'
);
console.log(
'%c A product by Outpoot.com',
'color: #4962ee; font-family: monospace; font-size: 12px; font-weight: bold; text-shadow: 2px 2px rgba(0,0,0,0.2);'
);
const url = new URL(window.location.href);
2025-05-22 14:00:43 +03:00
if (url.searchParams.has('signIn')) {
url.searchParams.delete('signIn');
2025-05-22 13:17:11 +03:00
window.history.replaceState({} , '', url);
invalidateAll();
}
2025-05-26 15:06:45 +03:00
return () => {
websocketController.disconnect();
};
2025-05-22 13:17:11 +03:00
});
2025-05-24 15:50:10 +03:00
function getPageTitle(routeId: string | null): string {
if (!routeId) return 'Rugplay';
const titleMap: Record< string , string > = {
'/': 'Home',
'/market': 'Market',
2025-05-29 17:41:09 +03:00
'/portfolio': 'Portfolio',
2025-05-24 15:50:10 +03:00
'/leaderboard': 'Leaderboard',
'/coin/create': 'Create Coin',
'/settings': 'Settings',
'/admin': 'Admin',
2025-05-28 16:49:13 +03:00
'/admin/promo': 'Promo Codes',
'/transactions': 'Transactions',
'/hopium': 'Hopium',
'/gambling': 'Gambling',
'/live': 'Live Trades',
'/treemap': 'Treemap'
2025-05-24 15:50:10 +03:00
};
// Handle dynamic routes
if (routeId.startsWith('/coin/[coinSymbol]')) {
return 'Coin Details';
}
2025-05-28 16:49:13 +03:00
if (routeId.startsWith('/user/[username]')) {
2025-05-24 15:50:10 +03:00
return 'User Profile';
}
2025-05-28 16:49:13 +03:00
if (routeId.startsWith('/hopium/[id]')) {
return 'Prediction Question';
}
2025-05-24 15:50:10 +03:00
return titleMap[routeId] || 'Rugplay';
}
2025-05-21 21:34:22 +03:00
< / script >
2025-05-22 14:08:37 +03:00
< ModeWatcher / >
2025-05-23 16:26:02 +03:00
< Toaster richColors = { true } / >
2025-05-22 14:08:37 +03:00
2025-05-22 13:17:11 +03:00
< Sidebar.Provider >
< AppSidebar / >
< Sidebar.Inset class = "sidebar-container" >
< header
class="group-has-data-[collapsible=icon]/sidebar-wrapper:h-12 flex h-12 shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear"
>
< div class = "flex w-full items-center gap-4 px-4 lg:px-6" >
< Sidebar.Trigger class = "-ml-1" / >
2025-05-23 16:26:02 +03:00
< h1 class = "mr-6 text-base font-medium" >
2025-05-24 15:50:10 +03:00
{ getPageTitle ( page . route . id )}
2025-05-23 16:26:02 +03:00
< / h1 >
2025-05-22 13:17:11 +03:00
< / div >
< / header >
< div class = "main-content-area" >
< div class = "@container/main flex flex-col gap-2" >
< div class = "flex flex-col gap-4 md:gap-6" >
< div class = "px-4 md:py-4 lg:px-6" >
{ @render children ()}
< / div >
< / div >
< / div >
< / div >
< / Sidebar.Inset >
< / Sidebar.Provider >