import type { ReactNode } from 'react' import { createRoutes } from '../routes.ts' export type DocumentProps = { title: string appBasePath: string assetBasePath: string clientModuleUrl: string | null runningSha?: string page?: string children?: ReactNode } export function Document({ title, appBasePath, assetBasePath, clientModuleUrl, runningSha, page, children, }: DocumentProps) { const appBase = appBasePath.replace(/\/$/, '') const assetBase = assetBasePath.replace(/\/$/, '') const routes = createRoutes(appBase) const icon192 = `${routes.icon192.href()}?v=4` const manifest = routes.manifest.href() const swUrl = assetBase ? `${assetBase}/sw.js` : `${appBase}/sw.js` const pakConfig = JSON.stringify({ appName: '__APP_TITLE__', appLabel: '__APP_TITLE__', hintDismissKey: '__PACKAGE_ID__-install-hint-dismissed', versionPath: '/api/version', appBase, assetBase: assetBase || undefined, clientModuleUrl: clientModuleUrl || undefined, swUrl, }) return (