import { BooleanContentSchema, BooleanContentType } from "../boolean" import type { BooleanContent } from "../boolean" import { BooleanLegacySchema } from "../legacy/boolean" import type { BooleanLegacy } from "../legacy/boolean" import type { LegacyContentCtx, LegacyCodec } from "./legacyContentCtx" export const BooleanLegacyCodec = ( ctx: LegacyContentCtx, ): LegacyCodec => ({ name: "BooleanLegacy", is(input): input is BooleanContent { return BooleanContentSchema.safeParse(input).success }, toContent(input) { const parsed = BooleanLegacySchema.safeParse(input) if (!parsed.success) { return parsed } return { success: true, data: { __TYPE__: BooleanContentType, value: parsed.data, }, } }, fromContent(input) { return { content: input.value, types: { [ctx.keyOfType]: "Boolean" }, keys: {}, } }, })