import type { EndRoute, LocalizedRoute } from "./interfaces"; import type { EndRoutePath, LocaleType } from "./types"; export class LocalizedEndRoute implements EndRoute, LocalizedRoute { localizedPaths: Map; ref: RouteRef; constructor(localizedPaths: Map, ref: RouteRef) { this.localizedPaths = localizedPaths; this.ref = ref; Object.freeze(this); } getPath(locale?: Locales): EndRoutePath { if (!locale) throw new Error("Missing locale"); return this.localizedPaths.get(locale)!; } isSegment(): false { return false; } isLocalized(): true { return true; } toJSON(): unknown[] { return [...this.localizedPaths.entries()]; } toString(): string { return JSON.stringify(this.toJSON()); } }