package upload
import (
"strconv"
"strings"
"gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia/media/v1"
"gno.land/p/g1jz6j9hj6rdf5ltl2kcrpa4jwtdh3w30z0yul06/sinopia/safe/v1"
)
// cardSVG is the generic card: the registration sample (unique
// fingerprint, CV-L3), RenderWith output, and the answer to any call that
// is not core's real render of a revealed, bound token.
const cardSVG = ``
// certificateSVG stands in for raster and IPFS art on core's TokenURI
// path, which only carries allowlisted SVG (§10.1). Every text is
// XML-escaped; the document stays far below MaxSVGBytes.
func certificateSVG(r resolved) string {
a := r.art
title := a.Title
if title == "" {
title = "Artwork #" + strconv.FormatInt(a.Index+1, 10)
}
tier := "no tier"
if a.Tier != "" {
tier = a.Tier + " — creator tier"
}
where := strings.ToUpper(media.MimeName(a.Mime)) + " · " + sizeLabel(a.Size) + " · stored on-chain"
if a.Kind != media.KindChain {
where = "IPFS · " + strings.ToUpper(media.MimeName(a.Mime)) + " · " + sizeLabel(a.Size)
}
var b strings.Builder
b.WriteString(``)
return b.String()
}
func sizeLabel(n int64) string {
if n < 1024 {
return strconv.FormatInt(n, 10) + " B"
}
tenths := (n*10 + 512) / 1024
return strconv.FormatInt(tenths/10, 10) + "." + strconv.FormatInt(tenths%10, 10) + " KB"
}