> */ private array $menus = []; public function __construct( private ThemeRegistry $registry, public readonly Site $site, public readonly ?Appearance $appearance, public readonly bool $isPreview = false, ) {} public function activate(): self { $paths = array_map(fn (ThemeManifest $theme): string => $theme->viewsPath(), $this->chain()); View::replaceNamespace('theme', $paths); View::getFinder()->flush(); return $this; } public function manifest(): ThemeManifest { return $this->registry->get($this->site->theme ?: config('themes.base')); } /** * @return list */ public function chain(): array { return $this->registry->chain($this->manifest()->key); } /** * Colour tokens: theme defaults (base first, then children), site settings, appearance. * * @return array */ public function tokens(): array { $tokens = []; foreach (array_reverse($this->chain()) as $theme) { foreach ($theme->tokens as $key => $token) { $tokens[$key] = $token['default']; } } $overrides = [...($this->site->theme_settings['tokens'] ?? []), ...($this->appearance?->tokens ?? [])]; foreach ($overrides as $key => $value) { if (isset($tokens[$key]) && is_string($value) && preg_match('/^#[0-9a-fA-F]{3,8}$/', $value)) { $tokens[$key] = $value; } } return $tokens; } /** * ":root{--ground:#F6F2EA;…}" for an inline