| 42 | } |
| 43 | |
| 44 | export function parseMessageRef(ref: string): number | null { |
| 45 | const normalized = ref.trim().toLowerCase() |
| 46 | const match = normalized.match(MESSAGE_REF_REGEX) |
| 47 | if (!match) { |
| 48 | return null |
| 49 | } |
| 50 | const index = Number.parseInt(match[1], 10) |
| 51 | if (!Number.isInteger(index)) { |
| 52 | return null |
| 53 | } |
| 54 | if (index < MESSAGE_REF_MIN_INDEX || index > MESSAGE_REF_MAX_INDEX) { |
| 55 | return null |
| 56 | } |
| 57 | return index |
| 58 | } |
| 59 | |
| 60 | export function parseBlockRef(ref: string): number | null { |
| 61 | const normalized = ref.trim().toLowerCase() |