Spaces:
Sleeping
Sleeping
| import { type ClassValue, clsx } from 'clsx'; | |
| import { twMerge } from 'tailwind-merge'; | |
| export function cn(...inputs: ClassValue[]) { | |
| return twMerge(clsx(inputs)); | |
| } | |
| const DEVICE_KEY_STORAGE_KEY = 'matcha-moments-device-key'; | |
| export function ensureDeviceKey(): string { | |
| if (typeof window === 'undefined') return ''; | |
| const existing = window.localStorage.getItem(DEVICE_KEY_STORAGE_KEY); | |
| if (existing) return existing; | |
| const next = | |
| typeof window.crypto?.randomUUID === 'function' | |
| ? window.crypto.randomUUID() | |
| : `device-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`; | |
| window.localStorage.setItem(DEVICE_KEY_STORAGE_KEY, next); | |
| return next; | |
| } | |