import * as z from "zod/mini"; import { colorSchemeConfigInputSchema, debugInputSchema, } from "../widget-config.js"; import { type Generation, generationSchema } from "./v3-generation.js"; /** @internal Prepared hosted-document input, carried by Core through Loader. */ export const hostedViewBootstrapSchema = z.strictObject({ loader: z.strictObject({ instanceId: z.string().check(z.minLength(1)), viewId: z.string().check(z.minLength(1)), generation: generationSchema, debugConfig: debugInputSchema, hideCloseButton: z.optional(z.boolean()), }), // View owns admission of its payload before applying bootstrap effects. payload: z.unknown(), themeCss: z.string(), colorScheme: z.intersection(colorSchemeConfigInputSchema, z.string()), }); export type HostedViewBootstrap = z.output; export function hasHostedViewBootstrapIdentity( bootstrap: HostedViewBootstrap, identity: { viewId: string; instanceId: string; generation: Generation }, ): boolean { return ( bootstrap.loader.viewId === identity.viewId && bootstrap.loader.instanceId === identity.instanceId && bootstrap.loader.generation === identity.generation ); } /** Optional Loader HELLO capability, never an SDK or targeting capability. */ export const HOSTED_VIEW_BOOTSTRAP_V1_CAPABILITY = "hosted-view-bootstrap-v1";