// rfc-4122 v4 uuid from Math.random. client-minted entity ids and idempotency
// keys need uniqueness, not cryptographic unpredictability, so this stays a
// pure js helper — no native crypto dependency, no dev-client rebuild
export const uuid = (): string =>
  'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (char) => {
    const rand = (Math.random() * 16) | 0
    const value = char === 'x' ? rand : (rand & 0x3) | 0x8
    return value.toString(16)
  })
