import type { Nullable } from "@thi.ng/api" ; import { mergeDeepObj } from "@thi.ng/associative/merge-deep" ; import { serialize } from "@thi.ng/hiccup/serialize" ; import { map } from "@thi.ng/transducers/map" ; import type { AppContext , HTMLDoc } from "../common/api" ; import { DEFAULT_DOC } from "../common/config" ; param doc export const html = ( doc ) => { doc = mergeDeepObj ( DEFAULT_DOC , doc ) ; return `<!DOCTYPE html>${ serialize ( [ "html" , { lang : doc . lang || "en" } , [ "head" , map ( ( meta ) => [ "meta" , meta ] , doc . head ! . meta || [ ] ) , map ( ( s ) => script ( null , s ) , doc . head ! . scripts || [ ] ) , map ( ( link ) => [ "link" , link ] , doc . head ! . links || [ ] ) , map ( ( css ) => [ "style" , css ] , doc . head ! . styles || [ ] ) , [ "title" , doc . head ! . title || "" ] , ] , [ "body" , doc . ctx ! . ui . body , ... doc . body ] , ] , doc . ctx ) }` ; } ; export const script = ( _ , script ) => [ "script" , { type : "text/javascript" , ... script } ] ;