package main

import "github.com/nbd-wtf/go-nostr/sdk"

var compileTimeTs string

templ headCommonTemplate(params HeadParams) {
	<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
	if params.Oembed != "" {
		<link rel="alternate" type="application/json+oembed" href={ params.Oembed + "&format=json" }/>
		<link rel="alternate" type="text/xml+oembed" href={ params.Oembed + "&format=xml" }/>
	}
	if params.IsProfile {
		<link rel="apple-touch-icon" sizes="180x180" href="/njump/static/favicon/profile/apple-touch-icon.png?v=2"/>
		<link rel="icon" type="image/png" sizes="32x32" href="/njump/static/favicon/profile/favicon-32x32.png?v=2"/>
		<link rel="icon" type="image/png" sizes="16x16" href="/njump/static/favicon/profile/favicon-16x16.png?v=2"/>
	} else {
		<link rel="apple-touch-icon" sizes="180x180" href="/njump/static/favicon/event/apple-touch-icon.png?v=2"/>
		<link rel="icon" type="image/png" sizes="32x32" href="/njump/static/favicon/event/favicon-32x32.png?v=2"/>
		<link rel="icon" type="image/png" sizes="16x16" href="/njump/static/favicon/event/favicon-16x16.png?v=2"/>
	}
	<script src="https://unpkg.com/hyperscript.org@0.9.12"></script>
	if tailwindDebugStuff != "" {
		@templ.Raw(tailwindDebugStuff)
	} else {
		<link rel="stylesheet" type="text/css" href={ "/njump/static/tailwind-bundle.min.css?t=" + compileTimeTs }/>
	}
	<style>
		@media print { @page { margin: 2cm 3cm; } }
	</style>
	<meta name="theme-color" content="#e42a6d"/>
	if params.NaddrNaked != "" {
		<link rel="canonical" href={ "https://njump.me/" + params.NaddrNaked }/>
	} else {
		<link rel="canonical" href={ "https://njump.me/" + params.NeventNaked }/>
	}
	<script type="text/hyperscript">
on load get [navigator.userAgent.includes('Safari'), navigator.userAgent.includes('Chrome')] then if it[0] is true and it[1] is false add .safari to <body /> end
	</script>
}

templ authorHeaderTemplate(metadata sdk.ProfileMetadata) {
	<header
		itemprop="author"
		itemscope
		itemtype="https://schema.org/Person"
		class="mb-4 max-w-full"
	>
		<a class="flex items-center" itemprop="url" href={ templ.URL("/" + metadata.Npub()) }>
			<div class="print:basis-1-12 imgclip mr-2 flex-shrink-0 basis-1/6 overflow-hidden sm:mr-4">
				<img itemprop="image" class="block h-auto w-full" src={ metadata.Picture }/>
			</div>
			<div class="block print:text-base grow">
				<div class="leading-4 sm:text-2xl">
					<span itemprop="name">{ metadata.Name }</span>
					if metadata.DisplayName != "" && metadata.Name != metadata.DisplayName {
						<span class="text-stone-400 sm:text-xl">/ <span itemprop="alternateName">{ metadata.DisplayName } </span></span>
					}
				</div>
				<div class="text-sm leading-4 text-stone-400 sm:text-base">
					{ metadata.NpubShort() }
				</div>
			</div>
		</a>
	</header>
}
