{
	"$schema": "https://json-schema.org/draft/2020-12/schema",
	"$id": "https://themetoken.dev/v1/schema.json",
	"title": "Theme Token",
	"description": "Theme Token source document for blockchain inscription. Install a published theme with: bunx shadcn@latest add https://themetoken.dev/r/themes/[origin].json",
	"type": "object",
	"required": ["$schema", "name", "styles"],
	"properties": {
		"$schema": {
			"type": "string",
			"const": "https://themetoken.dev/v1/schema.json",
			"description": "JSON Schema URL for validation"
		},
		"name": {
			"type": "string",
			"minLength": 1,
			"description": "Theme name"
		},
		"author": {
			"type": "string",
			"description": "Free-form creator identity; npm person-string syntax is recommended when including an email or URL"
		},
		"styles": {
			"type": "object",
			"required": ["light", "dark"],
			"properties": {
				"light": { "$ref": "#/$defs/themeStyleProps" },
				"dark": { "$ref": "#/$defs/themeStyleProps" }
			}
		},
		"assets": {
			"type": "array",
			"maxItems": 16,
			"description": "Verified relationships to immutable fonts, patterns, and wallpapers",
			"items": { "$ref": "#/$defs/asset" }
		},
		"bundle": { "$ref": "#/$defs/bundle" },
		"generation": { "$ref": "#/$defs/generation" },
		"css": {
			"type": "object",
			"description": "Optional CSS rules for @layer base",
			"additionalProperties": false,
			"properties": {
				"@layer base": {
					"type": "object",
					"additionalProperties": {
						"type": "object",
						"additionalProperties": { "type": "string" }
					}
				}
			}
		}
	},
	"$defs": {
		"asset": {
			"type": "object",
			"required": ["role", "kind", "source", "mediaType", "integrity"],
			"properties": {
				"role": { "type": "string", "minLength": 1 },
				"kind": { "enum": ["font", "pattern", "wallpaper"] },
				"source": {
					"oneOf": [
						{
							"type": "object",
							"required": ["kind", "vout"],
							"properties": {
								"kind": { "const": "sibling" },
								"vout": {
									"type": "integer",
									"minimum": 0,
									"maximum": 9007199254740991
								},
								"path": { "$ref": "#/$defs/path" }
							},
							"additionalProperties": false
						},
						{
							"type": "object",
							"required": ["kind", "origin"],
							"properties": {
								"kind": { "const": "origin" },
								"origin": {
									"type": "string",
									"pattern": "^[0-9a-f]{64}_(0|[1-9][0-9]*)$"
								},
								"path": { "$ref": "#/$defs/path" }
							},
							"additionalProperties": false
						}
					]
				},
				"mediaType": {
					"type": "string",
					"pattern": "^[a-z0-9][a-z0-9!#$&^_.+-]*/[a-z0-9][a-z0-9!#$&^_.+-]*$"
				},
				"integrity": {
					"type": "string",
					"pattern": "^sha256:[0-9a-f]{64}$"
				},
				"delivery": { "enum": ["linked", "vendored"] },
				"required": { "type": "boolean", "default": true },
				"render": {
					"type": "object",
					"properties": {
						"mode": { "enum": ["image", "mask"] },
						"repeat": {
							"enum": [
								"repeat",
								"no-repeat",
								"repeat-x",
								"repeat-y",
								"space",
								"round"
							]
						},
						"size": { "enum": ["auto", "cover", "contain"] },
						"position": {
							"enum": [
								"center",
								"top",
								"bottom",
								"left",
								"right",
								"top left",
								"top right",
								"bottom left",
								"bottom right"
							]
						},
						"color": {
							"type": "string",
							"pattern": "^(currentColor|transparent|#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})|var\\(--[a-z0-9-]+\\))$"
						}
					},
					"dependentSchemas": {
						"color": {
							"required": ["mode"],
							"properties": { "mode": { "const": "mask" } }
						}
					},
					"additionalProperties": false
				}
			},
			"dependentSchemas": {
				"render": {
					"properties": {
						"kind": { "enum": ["pattern", "wallpaper"] }
					}
				}
			},
			"additionalProperties": false
		},
		"path": {
			"type": "string",
			"minLength": 1,
			"pattern": "^(?!/)(?!.*(?:^|/)(?:\\.|\\.\\.)(?:/|$))(?!.*//)[^%\\\\?#\\u0000-\\u001F\\u007F]+$"
		},
		"bundle": {
			"type": "object",
			"required": ["version", "assets"],
			"properties": {
				"version": { "const": 1 },
				"assets": {
					"type": "array",
					"items": {
						"type": "object",
						"required": ["vout", "type", "slot"],
						"properties": {
							"vout": { "type": "integer", "minimum": 0 },
							"type": { "enum": ["font", "pattern", "wallpaper", "icon"] },
							"slot": { "type": "string" }
						}
					}
				}
			}
		},
		"generation": {
			"type": "object",
			"required": ["prompt"],
			"properties": {
				"prompt": { "type": "string" },
				"provider": { "type": "string" },
				"model": { "type": "string" },
				"timestamp": { "type": "number" }
			}
		},
		"themeStyleProps": {
			"type": "object",
			"required": [
				"background",
				"foreground",
				"card",
				"card-foreground",
				"popover",
				"popover-foreground",
				"primary",
				"primary-foreground",
				"secondary",
				"secondary-foreground",
				"muted",
				"muted-foreground",
				"accent",
				"accent-foreground",
				"destructive",
				"destructive-foreground",
				"border",
				"input",
				"ring",
				"radius"
			],
			"properties": {
				"background": {
					"type": "string",
					"description": "Default background color"
				},
				"foreground": {
					"type": "string",
					"description": "Default foreground color"
				},
				"card": { "type": "string", "description": "Card background color" },
				"card-foreground": { "type": "string" },
				"popover": {
					"type": "string",
					"description": "Popover background color"
				},
				"popover-foreground": { "type": "string" },
				"primary": { "type": "string", "description": "Primary brand color" },
				"primary-foreground": { "type": "string" },
				"secondary": { "type": "string", "description": "Secondary color" },
				"secondary-foreground": { "type": "string" },
				"muted": { "type": "string", "description": "Muted background color" },
				"muted-foreground": { "type": "string" },
				"accent": { "type": "string", "description": "Accent/highlight color" },
				"accent-foreground": { "type": "string" },
				"destructive": {
					"type": "string",
					"description": "Destructive action color"
				},
				"destructive-foreground": { "type": "string" },
				"border": { "type": "string", "description": "Border color" },
				"input": { "type": "string", "description": "Input field color" },
				"ring": { "type": "string", "description": "Focus ring color" },
				"chart-1": { "type": "string" },
				"chart-2": { "type": "string" },
				"chart-3": { "type": "string" },
				"chart-4": { "type": "string" },
				"chart-5": { "type": "string" },
				"sidebar": { "type": "string", "description": "Sidebar background" },
				"sidebar-foreground": { "type": "string" },
				"sidebar-primary": { "type": "string" },
				"sidebar-primary-foreground": { "type": "string" },
				"sidebar-accent": { "type": "string" },
				"sidebar-accent-foreground": { "type": "string" },
				"sidebar-border": { "type": "string" },
				"sidebar-ring": { "type": "string" },
				"font-sans": {
					"type": "string",
					"description": "Primary UI font: Google Font name (e.g. 'Inter'), system font, or on-chain path '/content/{outpoint}'"
				},
				"font-serif": {
					"type": "string",
					"description": "Serif font: Google Font name, system font, or on-chain path '/content/{outpoint}'"
				},
				"font-mono": {
					"type": "string",
					"description": "Monospace font: Google Font name, system font, or on-chain path '/content/{outpoint}'"
				},
				"radius": {
					"type": "string",
					"description": "Border radius (e.g. 0.5rem)"
				},
				"shadow-color": { "type": "string" },
				"shadow-opacity": { "type": "string" },
				"shadow-blur": { "type": "string" },
				"shadow-spread": { "type": "string" },
				"shadow-offset-x": { "type": "string" },
				"shadow-offset-y": { "type": "string" },
				"shadow-2xs": { "type": "string" },
				"shadow-xs": { "type": "string" },
				"shadow-sm": { "type": "string" },
				"shadow": { "type": "string" },
				"shadow-md": { "type": "string" },
				"shadow-lg": { "type": "string" },
				"shadow-xl": { "type": "string" },
				"shadow-2xl": { "type": "string" },
				"letter-spacing": { "type": "string" },
				"spacing": { "type": "string" },
				"bg-image": {
					"type": "string",
					"description": "Page background image: URL or on-chain path '/content/{outpoint}'"
				},
				"bg-image-opacity": {
					"type": "string",
					"description": "Background image opacity (e.g. '0.1', '0.5', '1')"
				},
				"bg-image-size": {
					"type": "string",
					"description": "Background size: 'cover', 'contain', 'auto', or pixel value"
				},
				"bg-image-position": {
					"type": "string",
					"description": "Background position: 'center', 'top', 'bottom', etc."
				},
				"bg-image-repeat": {
					"type": "string",
					"description": "Background repeat: 'no-repeat', 'repeat', 'repeat-x', 'repeat-y'"
				},
				"bg-image-mode": {
					"type": "string",
					"description": "Render mode: 'mask' (theme-reactive) or 'image' (literal)"
				},
				"bg-image-color": {
					"type": "string",
					"description": "For mask mode: color to show through the pattern"
				},
				"card-bg-image": {
					"type": "string",
					"description": "Card background image: URL or on-chain path"
				},
				"sidebar-bg-image": {
					"type": "string",
					"description": "Sidebar background image: URL or on-chain path"
				}
			},
			"additionalProperties": { "type": "string" }
		}
	}
}
