, dark: array} */ public static function load(?string $path = null): array { $default = static::read(dirname(__DIR__, 2).'/resources/css/tokens/scheme.json'); $scheme = static::read($path ?? (string) config('livewire-material.scheme')); return [ 'light' => [...$default['light'], ...$scheme['light']], 'dark' => [...$default['dark'], ...$scheme['dark']], ]; } /** * The light roles: what a mail wears. * * @return array */ public static function light(?string $path = null): array { return static::load($path)['light']; } /** * @return array{light: array, dark: array} */ protected static function read(string $path): array { $data = is_file($path) ? json_decode((string) file_get_contents($path), true) : null; return [ 'light' => static::roles($data['light'] ?? null), 'dark' => static::roles($data['dark'] ?? null), ]; } /** * @return array */ protected static function roles(mixed $roles): array { if (! is_array($roles)) { return []; } return array_filter( $roles, fn (mixed $hex, mixed $role): bool => is_string($role) && preg_match('/^[a-z-]+$/', $role) === 1 && is_string($hex) && preg_match('/^#[0-9a-fA-F]{6}$/', $hex) === 1, ARRAY_FILTER_USE_BOTH, ); } }