import { GeoPointContentSchema } from "../geopoint" import type { GeoPointContent } from "../geopoint" import { GeoPointLegacySchema } from "../legacy/geopoint" import type { GeoPointLegacy } from "../legacy/geopoint" import type { LegacyCodec, LegacyContentCtx } from "./legacyContentCtx" const GeoPointContentType = "GeoPointContent" export const GeoPointLegacyCodec = ( ctx: LegacyContentCtx, ): LegacyCodec => ({ name: "GeoPointLegacy", is(input): input is GeoPointContent { return GeoPointContentSchema.safeParse(input).success }, toContent(input) { const parsed = GeoPointLegacySchema.safeParse(input) if (!parsed.success) { return parsed } return { success: true, data: { ...parsed.data, __TYPE__: GeoPointContentType, }, } }, fromContent(input) { return { content: { position: input.position }, types: { [ctx.keyOfType]: "GeoPoint" }, keys: {}, } }, })