import type { ChadClient } from '#shared/types' import { createGlobalState, useLocalStorage } from '@vueuse/core' export const useGlobalState = createGlobalState(() => { const username = useLocalStorage('username', '') const clients = ref([]) const me = computed(() => clients.value.find(client => client.isMe)) const clientByIdMap = computed(() => { return clients.value.reduce>((result, client) => { result[client.id] = client return result }, {}) }) function reset() { clients.value = [] } return { username, me, clients, clientByIdMap, reset, } })