package web

import (
	"embed"
	"io/fs"
)

//go:embed all:dist
var staticFiles embed.FS

// FS returns the embedded frontend/dist subtree.
func FS() fs.FS {
	sub, err := fs.Sub(staticFiles, "dist")
	if err != nil {
		// dist not present (pre-build); return an empty FS so the server still starts
		return emptyFS{}
	}
	return sub
}

type emptyFS struct{}

func (emptyFS) Open(name string) (fs.File, error) {
	return nil, &fs.PathError{Op: "open", Path: name, Err: fs.ErrNotExist}
}
