{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "ReClash Provider Config",
  "description": "The YAML manifest a provider hosts for ReClash, named by the reclash-config response header. Anchors and aliases are rejected, and the document is limited to 512 KiB. Unknown keys are ignored with a warning and an invalid section is ignored whole, so the schema is stricter than the parser.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "version"
  ],
  "properties": {
    "version": {
      "const": 1,
      "type": "integer"
    },
    "view": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "proxies": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "type": {
              "enum": [
                "tab",
                "list"
              ]
            },
            "sort": {
              "enum": [
                "none",
                "delay",
                "name"
              ]
            },
            "layout": {
              "enum": [
                "loose",
                "standard",
                "tight"
              ]
            },
            "icon": {
              "enum": [
                "filled",
                "plain",
                "hidden"
              ]
            },
            "card": {
              "enum": [
                "loose",
                "standard",
                "compact",
                "oneline"
              ]
            }
          }
        },
        "app": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "navbar": {
              "enum": [
                "floating",
                "docked"
              ]
            },
            "glass": {
              "enum": [
                "none",
                "standard",
                "ultra"
              ]
            },
            "color": {
              "$ref": "#/$defs/color"
            },
            "color-dark": {
              "$ref": "#/$defs/color"
            },
            "style": {
              "enum": [
                "vivid",
                "tinted",
                "soft",
                "monochrome"
              ]
            },
            "black": {
              "type": "boolean"
            },
            "seasonal": {
              "type": "boolean",
              "description": "Turns the client's Seasonal effects theme setting on or off."
            }
          }
        }
      }
    },
    "power-button": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "shape": {
          "anyOf": [
            {
              "$ref": "#/$defs/powerShape"
            },
            {
              "type": "array",
              "minItems": 1,
              "uniqueItems": true,
              "items": {
                "$ref": "#/$defs/powerShape"
              }
            }
          ]
        },
        "type": {
          "enum": [
            "solid",
            "tonal",
            "outline"
          ]
        }
      }
    },
    "wallpaper": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "url"
      ],
      "properties": {
        "url": {
          "type": "string",
          "pattern": "^https://",
          "maxLength": 2048
        },
        "opacity": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "default": 8
        }
      }
    },
    "seasonal": {
      "type": "object",
      "description": "Particle effects behind the app content on chosen dates.",
      "additionalProperties": false,
      "properties": {
        "calendar": {
          "enum": [
            "default",
            "none"
          ],
          "default": "default",
          "description": "'none' turns off the client's built-in calendar for this subscription."
        },
        "effects": {
          "type": "array",
          "maxItems": 16,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "effect",
              "from",
              "to"
            ],
            "properties": {
              "effect": {
                "enum": [
                  "snow",
                  "lights",
                  "stars",
                  "leaves",
                  "petals",
                  "confetti",
                  "hearts"
                ]
              },
              "from": {
                "type": "string",
                "pattern": "^(\\d{4}-)?\\d{2}-\\d{2}$",
                "description": "MM-DD or YYYY-MM-DD, inclusive, device local date."
              },
              "to": {
                "type": "string",
                "pattern": "^(\\d{4}-)?\\d{2}-\\d{2}$",
                "description": "Same form as from, inclusive. MM-DD ranges may wrap past the new year."
              },
              "density": {
                "enum": [
                  "low",
                  "medium",
                  "high"
                ],
                "default": "medium"
              },
              "colors": {
                "type": "array",
                "minItems": 1,
                "maxItems": 8,
                "items": {
                  "type": "string",
                  "pattern": "^#?[0-9a-fA-F]{6}$"
                },
                "description": "Replaces the effect's own palette."
              }
            }
          }
        }
      }
    },
    "widgets": {
      "type": "array",
      "uniqueItems": true,
      "maxItems": 32,
      "items": {
        "enum": [
          "currentOutbound",
          "health",
          "networkSpeed",
          "outboundMode",
          "vpnButton",
          "networkTakeover",
          "serviceStatus",
          "profiles",
          "proxyGroups",
          "connectionStats",
          "intranetIp",
          "memoryInfo"
        ]
      }
    },
    "cards": {
      "type": "array",
      "maxItems": 8,
      "items": {
        "$ref": "#/$defs/card"
      }
    },
    "power-labels": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "off": {
          "$ref": "#/$defs/powerLabelState"
        },
        "connecting": {
          "$ref": "#/$defs/powerLabelState"
        },
        "on": {
          "$ref": "#/$defs/powerLabelState"
        },
        "paused": {
          "$ref": "#/$defs/powerLabelState"
        },
        "expired": {
          "$ref": "#/$defs/powerLabelState"
        },
        "exhausted": {
          "$ref": "#/$defs/powerLabelState"
        },
        "ending": {
          "$ref": "#/$defs/powerLabelState"
        },
        "grace": {
          "$ref": "#/$defs/powerLabelState"
        }
      }
    },
    "provider": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "name": {
          "$ref": "#/$defs/text160"
        },
        "logo": {
          "type": "string",
          "format": "uri",
          "maxLength": 1024,
          "pattern": "^https?://"
        },
        "logo-dark": {
          "type": "string",
          "format": "uri",
          "maxLength": 1024,
          "pattern": "^https?://"
        },
        "support-url": {
          "type": "string",
          "maxLength": 1024
        },
        "web-url": {
          "type": "string",
          "format": "uri",
          "maxLength": 1024,
          "pattern": "^https?://"
        },
        "type": {
          "type": "string",
          "maxLength": 32,
          "description": "test, promo or dev show a badge in the import dialog; other values show none."
        },
        "hide-url": {
          "type": "boolean"
        },
        "server-group": {
          "type": "string",
          "maxLength": 256
        },
        "announce": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "text": {
              "$ref": "#/$defs/text1024"
            },
            "url": {
              "type": "string",
              "format": "uri",
              "maxLength": 1024,
              "pattern": "^https?://"
            }
          }
        },
        "notice": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "text": {
              "$ref": "#/$defs/text1024"
            },
            "url": {
              "type": "string",
              "format": "uri",
              "maxLength": 1024,
              "pattern": "^https?://"
            }
          }
        },
        "renew": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "maxLength": 1024,
              "pattern": "^https?://"
            },
            "days": {
              "type": "integer",
              "minimum": 1,
              "maximum": 3650
            }
          }
        },
        "top-up": {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "maxLength": 1024,
              "pattern": "^https?://"
            },
            "percent": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100
            }
          }
        }
      }
    },
    "reminders": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "expire-days": {
          "type": "array",
          "maxItems": 8,
          "uniqueItems": true,
          "items": {
            "type": "integer",
            "minimum": 0,
            "maximum": 365
          }
        },
        "traffic-percent": {
          "type": "array",
          "maxItems": 8,
          "uniqueItems": true,
          "items": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100
          }
        }
      }
    },
    "settings": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "minimize-on-exit": {
          "type": "boolean"
        },
        "launch-at-login": {
          "type": "boolean"
        },
        "start-hidden": {
          "type": "boolean"
        },
        "connect-on-launch": {
          "type": "boolean"
        },
        "check-app-updates": {
          "type": "boolean"
        },
        "capture-logs": {
          "type": "boolean"
        },
        "close-connections": {
          "type": "boolean"
        }
      }
    },
    "apps": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "exclude": {
          "type": "array",
          "maxItems": 512,
          "items": {
            "$ref": "#/$defs/androidPackage"
          }
        },
        "include": {
          "type": "array",
          "maxItems": 512,
          "items": {
            "$ref": "#/$defs/androidPackage"
          }
        },
        "routing": {
          "type": "string",
          "pattern": "^domestic(:[A-Za-z]{2})?$"
        }
      }
    },
    "transport": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "fallback-hosts": {
          "type": "array",
          "maxItems": 5,
          "items": {
            "$ref": "#/$defs/authority"
          }
        },
        "new-domain": {
          "$ref": "#/$defs/authority"
        }
      }
    },
    "support": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "keys": {
          "type": "array",
          "maxItems": 2,
          "items": {
            "type": "string",
            "pattern": "^ed25519:[A-Za-z0-9_-]{43}$"
          }
        },
        "upload-url": {
          "$ref": "#/$defs/httpsUrl"
        }
      }
    },
    "routing": {
      "type": "object",
      "additionalProperties": false,
      "description": "Profiles, scenarios and bindings as the Core reads them; the Core validates their content.",
      "properties": {
        "profiles": {
          "type": "object"
        },
        "scenarios": {
          "type": "object"
        },
        "scenario": {
          "type": "string"
        },
        "bindings": {
          "type": "object",
          "description": "Proxy-group name to binding."
        }
      }
    },
    "chains": {
      "type": "array",
      "maxItems": 16,
      "description": "Routes through two or three of the subscription's own nodes or groups.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "hops"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "The chain's group name in the running config; unique within the section."
          },
          "hops": {
            "type": "array",
            "minItems": 2,
            "maxItems": 3,
            "items": {
              "type": "string",
              "minLength": 1
            },
            "description": "Names of nodes or groups of the subscription, entry first."
          },
          "target-group": {
            "type": "string",
            "minLength": 1,
            "description": "Group the chain is offered in; the main group without it."
          },
          "offered": {
            "type": "boolean",
            "description": "False keeps the chain out of every group."
          },
          "fingerprints": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "null"
                },
                {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "type",
                    "server",
                    "port"
                  ],
                  "properties": {
                    "type": {
                      "type": "string",
                      "minLength": 1
                    },
                    "server": {
                      "type": "string",
                      "minLength": 1
                    },
                    "port": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 65535
                    }
                  }
                }
              ]
            },
            "description": "One entry per hop, null where the hop has none; a renamed hop follows its only match."
          }
        }
      }
    },
    "policy": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "global": {
          "enum": [
            "any",
            "listed",
            "off"
          ]
        },
        "apps": {
          "enum": [
            "recommended",
            "required"
          ]
        },
        "local-ports": {
          "enum": [
            "open",
            "closed"
          ]
        },
        "dashboard": {
          "enum": [
            "editable",
            "locked"
          ]
        }
      }
    }
  },
  "$defs": {
    "color": {
      "type": "string",
      "pattern": "^#?([0-9a-fA-F]{6}|[0-9a-fA-F]{8})$"
    },
    "powerShape": {
      "anyOf": [
        {
          "enum": [
            "random"
          ]
        },
        {
          "enum": [
            "cookie",
            "circle",
            "scallop",
            "sunny",
            "flower",
            "clover",
            "burst",
            "puffy",
            "puffyDiamond",
            "clover8Leaf",
            "cookie4Sided",
            "cookie6Sided",
            "verySunny",
            "square",
            "diamond",
            "pentagon",
            "gem",
            "pixelCircle",
            "softBoom",
            "boom",
            "sharpBurst"
          ]
        }
      ]
    },
    "text32": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "\\S",
          "maxLength": 32
        },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]+)*$"
          },
          "additionalProperties": {
            "type": "string",
            "pattern": "\\S",
            "maxLength": 32
          }
        }
      ]
    },
    "text64": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "\\S",
          "maxLength": 64
        },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]+)*$"
          },
          "additionalProperties": {
            "type": "string",
            "pattern": "\\S",
            "maxLength": 64
          }
        }
      ]
    },
    "text80": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "\\S",
          "maxLength": 80
        },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]+)*$"
          },
          "additionalProperties": {
            "type": "string",
            "pattern": "\\S",
            "maxLength": 80
          }
        }
      ]
    },
    "text96": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "\\S",
          "maxLength": 96
        },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]+)*$"
          },
          "additionalProperties": {
            "type": "string",
            "pattern": "\\S",
            "maxLength": 96
          }
        }
      ]
    },
    "text280": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "\\S",
          "maxLength": 280
        },
        {
          "type": "object",
          "minProperties": 1,
          "propertyNames": {
            "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]+)*$"
          },
          "additionalProperties": {
            "type": "string",
            "pattern": "\\S",
            "maxLength": 280
          }
        }
      ]
    },
    "cardId": {
      "type": "string",
      "pattern": "^[a-z0-9._:#-]{1,64}$"
    },
    "when": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "from": {
          "type": "integer",
          "minimum": 0,
          "maximum": 253402300799
        },
        "until": {
          "type": "integer",
          "minimum": 0,
          "maximum": 253402300799
        },
        "days-left-below": {
          "type": "integer",
          "minimum": 1
        },
        "traffic-above": {
          "type": "integer",
          "minimum": 0,
          "maximum": 100
        },
        "platforms": {
          "type": "array",
          "uniqueItems": true,
          "items": {
            "enum": [
              "android",
              "windows",
              "macos",
              "linux"
            ]
          }
        },
        "client-below": {
          "type": "string"
        }
      }
    },
    "urlAction": {
      "type": "string",
      "pattern": "^(https?://|tg://)",
      "maxLength": 2048
    },
    "copyAction": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256,
      "description": "At most 256 bytes in UTF-8."
    },
    "shareAction": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1024,
      "description": "At most 1024 bytes in UTF-8."
    },
    "appAction": {
      "enum": [
        "support",
        "website",
        "renew",
        "topUp",
        "updateProfile",
        "speedTest",
        "doctor",
        "updateApp"
      ]
    },
    "exactlyOneAction": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "url"
          ]
        },
        {
          "type": "object",
          "required": [
            "copy"
          ]
        },
        {
          "type": "object",
          "required": [
            "share"
          ]
        },
        {
          "type": "object",
          "required": [
            "app"
          ]
        }
      ]
    },
    "atMostOneAction": {
      "oneOf": [
        {
          "type": "object",
          "required": [
            "url"
          ]
        },
        {
          "type": "object",
          "required": [
            "copy"
          ]
        },
        {
          "type": "object",
          "required": [
            "share"
          ]
        },
        {
          "type": "object",
          "required": [
            "app"
          ]
        },
        {
          "not": {
            "anyOf": [
              {
                "type": "object",
                "required": [
                  "url"
                ]
              },
              {
                "type": "object",
                "required": [
                  "copy"
                ]
              },
              {
                "type": "object",
                "required": [
                  "share"
                ]
              },
              {
                "type": "object",
                "required": [
                  "app"
                ]
              }
            ]
          }
        }
      ]
    },
    "icon": {
      "description": "An unknown name renders a neutral icon in the app.",
      "enum": [
        "support",
        "help",
        "chat",
        "speed",
        "link",
        "open",
        "copy",
        "share",
        "refresh",
        "update",
        "sync",
        "info",
        "warning",
        "star",
        "bolt",
        "key",
        "lock",
        "gift",
        "sparkle",
        "web",
        "website",
        "globe",
        "send",
        "telegram",
        "download",
        "doctor",
        "tools",
        "clock",
        "renew",
        "account"
      ]
    },
    "card": {
      "oneOf": [
        {
          "$ref": "#/$defs/banner"
        },
        {
          "$ref": "#/$defs/note"
        },
        {
          "$ref": "#/$defs/actions"
        }
      ]
    },
    "banner": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id"
      ],
      "properties": {
        "type": {
          "const": "banner"
        },
        "id": {
          "$ref": "#/$defs/cardId"
        },
        "when": {
          "$ref": "#/$defs/when"
        },
        "dismissible": {
          "type": "boolean"
        },
        "layout": {
          "enum": [
            "hero",
            "split",
            "strip",
            "image"
          ],
          "default": "hero"
        },
        "title": {
          "$ref": "#/$defs/text80"
        },
        "text": {
          "$ref": "#/$defs/text280"
        },
        "image": {
          "type": "string",
          "pattern": "^https://",
          "maxLength": 2048
        },
        "image-dark": {
          "type": "string",
          "pattern": "^https://",
          "maxLength": 2048
        },
        "side": {
          "enum": [
            "start",
            "end"
          ],
          "default": "end"
        },
        "tone": {
          "enum": [
            "surface",
            "primary",
            "secondary",
            "tertiary"
          ],
          "default": "surface"
        },
        "countdown": {
          "type": "integer",
          "minimum": 0,
          "maximum": 253402300799
        },
        "button": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "label"
          ],
          "properties": {
            "label": {
              "$ref": "#/$defs/text32"
            },
            "url": {
              "$ref": "#/$defs/urlAction"
            },
            "copy": {
              "$ref": "#/$defs/copyAction"
            },
            "share": {
              "$ref": "#/$defs/shareAction"
            },
            "app": {
              "$ref": "#/$defs/appAction"
            }
          },
          "allOf": [
            {
              "$ref": "#/$defs/exactlyOneAction"
            }
          ]
        },
        "url": {
          "$ref": "#/$defs/urlAction"
        },
        "copy": {
          "$ref": "#/$defs/copyAction"
        },
        "share": {
          "$ref": "#/$defs/shareAction"
        },
        "app": {
          "$ref": "#/$defs/appAction"
        }
      },
      "allOf": [
        {
          "$ref": "#/$defs/atMostOneAction"
        }
      ]
    },
    "note": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "text"
      ],
      "properties": {
        "type": {
          "const": "note"
        },
        "id": {
          "$ref": "#/$defs/cardId"
        },
        "when": {
          "$ref": "#/$defs/when"
        },
        "dismissible": {
          "type": "boolean"
        },
        "text": {
          "$ref": "#/$defs/text280"
        },
        "level": {
          "enum": [
            "info",
            "warning",
            "critical"
          ],
          "default": "info"
        },
        "url": {
          "$ref": "#/$defs/urlAction"
        },
        "copy": {
          "$ref": "#/$defs/copyAction"
        },
        "share": {
          "$ref": "#/$defs/shareAction"
        },
        "app": {
          "$ref": "#/$defs/appAction"
        }
      },
      "allOf": [
        {
          "$ref": "#/$defs/atMostOneAction"
        }
      ]
    },
    "actions": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "id",
        "items"
      ],
      "properties": {
        "type": {
          "const": "actions"
        },
        "id": {
          "$ref": "#/$defs/cardId"
        },
        "when": {
          "$ref": "#/$defs/when"
        },
        "dismissible": {
          "type": "boolean"
        },
        "items": {
          "type": "array",
          "minItems": 2,
          "maxItems": 6,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "icon",
              "label"
            ],
            "properties": {
              "icon": {
                "$ref": "#/$defs/icon"
              },
              "label": {
                "$ref": "#/$defs/text32"
              },
              "url": {
                "$ref": "#/$defs/urlAction"
              },
              "copy": {
                "$ref": "#/$defs/copyAction"
              },
              "share": {
                "$ref": "#/$defs/shareAction"
              },
              "app": {
                "$ref": "#/$defs/appAction"
              }
            },
            "allOf": [
              {
                "$ref": "#/$defs/exactlyOneAction"
              }
            ]
          }
        }
      }
    },
    "powerLabelEntry": {
      "anyOf": [
        {
          "$ref": "#/$defs/text64"
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "title"
          ],
          "properties": {
            "title": {
              "$ref": "#/$defs/text64"
            },
            "hint": {
              "$ref": "#/$defs/text96"
            }
          }
        }
      ]
    },
    "powerLabelState": {
      "anyOf": [
        {
          "$ref": "#/$defs/powerLabelEntry"
        },
        {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/powerLabelEntry"
          }
        }
      ]
    },
    "text160": {
      "oneOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 160
        },
        {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": {
            "type": "string",
            "minLength": 1,
            "maxLength": 160
          }
        }
      ]
    },
    "text1024": {
      "oneOf": [
        {
          "type": "string",
          "minLength": 1,
          "maxLength": 1024
        },
        {
          "type": "object",
          "minProperties": 1,
          "additionalProperties": {
            "type": "string",
            "minLength": 1,
            "maxLength": 1024
          }
        }
      ]
    },
    "httpsUrl": {
      "type": "string",
      "format": "uri",
      "pattern": "^https://",
      "maxLength": 1024
    },
    "androidPackage": {
      "type": "string",
      "maxLength": 255,
      "pattern": "^[A-Za-z][A-Za-z0-9_]*(\\.[A-Za-z][A-Za-z0-9_]*)+$"
    },
    "authority": {
      "type": "string",
      "maxLength": 259
    }
  }
}
