{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://photoflow.local/schemas/component-manifest-v2.schema.json",
  "title": "PhotoFlow Component Manifest V2",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "apiVersion",
    "id",
    "version"
  ],
  "anyOf": [
    {
      "required": [
        "componentHost"
      ]
    },
    {
      "required": [
        "runtimeContributions"
      ],
      "properties": {
        "runtimeContributions": {
          "minItems": 1
        }
      }
    }
  ],
  "not": {
    "anyOf": [
      {
        "required": [
          "hostApiVersion"
        ]
      },
      {
        "required": [
          "minHostApiVersion"
        ]
      },
      {
        "required": [
          "maxHostApiVersion"
        ]
      },
      {
        "required": [
          "negotiatedHostApiVersion"
        ]
      }
    ]
  },
  "properties": {
    "apiVersion": {
      "const": 1
    },
    "id": {
      "type": "string",
      "pattern": "^[a-z0-9][a-z0-9._-]{0,79}$"
    },
    "version": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80
    },
    "icon": {
      "type": "string",
      "maxLength": 512
    },
    "runtimeContributions": {
      "type": "array",
      "maxItems": 16,
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "backendId",
          "displayName",
          "backendVersion",
          "protocolVersion",
          "transport",
          "priority",
          "probe",
          "features"
        ],
        "properties": {
          "type": {
            "const": "media.playbackBackend"
          },
          "backendId": {
            "$ref": "#/$defs/id"
          },
          "displayName": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "backendVersion": {
            "type": "string",
            "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$"
          },
          "protocolVersion": {
            "const": 1
          },
          "transport": {
            "const": "media-playback-backend-v1"
          },
          "priority": {
            "type": "integer",
            "minimum": -1000,
            "maximum": 1000
          },
          "probe": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "containers",
              "codecs",
              "extensions"
            ],
            "properties": {
              "containers": {
                "type": "array",
                "minItems": 1,
                "maxItems": 64,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9][A-Za-z0-9.+_-]{0,63}$"
                }
              },
              "codecs": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "video",
                  "audio"
                ],
                "properties": {
                  "video": {
                    "type": "array",
                    "maxItems": 64,
                    "uniqueItems": true,
                    "items": {
                      "type": "string"
                    }
                  },
                  "audio": {
                    "type": "array",
                    "maxItems": 64,
                    "uniqueItems": true,
                    "items": {
                      "type": "string"
                    }
                  }
                }
              },
              "extensions": {
                "type": "array",
                "minItems": 1,
                "maxItems": 64,
                "uniqueItems": true,
                "items": {
                  "type": "string",
                  "pattern": "^\\.[A-Za-z0-9]{1,12}$"
                }
              }
            }
          },
          "features": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "transforms",
              "hdr",
              "statistics",
              "subtitles",
              "hardwareDecoding",
              "capture"
            ],
            "properties": {
              "transforms": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "aspectModes",
                  "rotation",
                  "flip",
                  "crop"
                ],
                "properties": {
                  "aspectModes": {
                    "type": "array",
                    "minItems": 1,
                    "uniqueItems": true,
                    "items": {
                      "enum": [
                        "source",
                        "contain",
                        "cover",
                        "16:9",
                        "4:3",
                        "1:1"
                      ]
                    }
                  },
                  "rotation": {
                    "type": "boolean"
                  },
                  "flip": {
                    "type": "boolean"
                  },
                  "crop": {
                    "type": "boolean"
                  }
                }
              },
              "hdr": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "passthrough",
                  "toneMapping",
                  "algorithms",
                  "targetPeakControl"
                ],
                "properties": {
                  "passthrough": {
                    "type": "boolean"
                  },
                  "toneMapping": {
                    "type": "boolean"
                  },
                  "algorithms": {
                    "type": "array",
                    "minItems": 1,
                    "uniqueItems": true,
                    "items": {
                      "enum": [
                        "auto",
                        "bt2390",
                        "reinhard",
                        "mobius",
                        "hable"
                      ]
                    }
                  },
                  "targetPeakControl": {
                    "type": "boolean"
                  }
                }
              },
              "statistics": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "basic",
                  "decode",
                  "hdr",
                  "timing",
                  "cache",
                  "gpu",
                  "maxUpdateHz"
                ],
                "properties": {
                  "basic": {
                    "type": "boolean"
                  },
                  "decode": {
                    "type": "boolean"
                  },
                  "hdr": {
                    "type": "boolean"
                  },
                  "timing": {
                    "type": "boolean"
                  },
                  "cache": {
                    "type": "boolean"
                  },
                  "gpu": {
                    "type": "boolean"
                  },
                  "maxUpdateHz": {
                    "type": "number",
                    "minimum": 0.2,
                    "maximum": 4
                  }
                }
              },
              "subtitles": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "embedded",
                  "external",
                  "ass",
                  "styles"
                ],
                "properties": {
                  "embedded": {
                    "type": "boolean"
                  },
                  "external": {
                    "type": "boolean"
                  },
                  "ass": {
                    "type": "boolean"
                  },
                  "styles": {
                    "type": "boolean"
                  }
                }
              },
              "hardwareDecoding": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "supported",
                  "selectable",
                  "softwareFallback"
                ],
                "properties": {
                  "supported": {
                    "type": "boolean"
                  },
                  "selectable": {
                    "type": "boolean"
                  },
                  "softwareFallback": {
                    "type": "boolean"
                  }
                }
              },
              "capture": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "sourceFrame",
                  "displayedFrame"
                ],
                "properties": {
                  "sourceFrame": {
                    "type": "boolean"
                  },
                  "displayedFrame": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "componentHost": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "contractVersion",
        "contributions"
      ],
      "anyOf": [
        { "required": ["service"] },
        {
          "properties": {
            "contributions": {
              "minItems": 1,
              "items": {
                "required": ["type"],
                "properties": { "type": { "const": "application.settingsForm" } },
                "not": { "required": ["customPage"] }
              }
            }
          }
        }
      ],
      "properties": {
        "contractVersion": {
          "const": 2
        },
        "adoptionGrants": {
          "type": "array",
          "maxItems": 2,
          "uniqueItems": true,
          "items": {
            "enum": [
              "component.storage.previous.v1",
              "project.output.existing.v1"
            ]
          }
        },
        "legacySettingsAdoptions": {
          "type": "array",
          "maxItems": 8,
          "uniqueItems": true,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "topLevelKey"
            ],
            "properties": {
              "topLevelKey": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128,
                "pattern": "^[A-Za-z][A-Za-z0-9]*$"
              }
            }
          }
        },
        "contributions": {
          "type": "array",
          "minItems": 0,
          "maxItems": 32,
          "items": {
            "oneOf": [
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "type",
                  "id",
                  "label",
                  "pageId"
                ],
                "properties": {
                  "type": {
                    "const": "workspace.toolbarAction"
                  },
                  "id": {
                    "$ref": "#/$defs/id"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "pageId": {
                    "$ref": "#/$defs/id"
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "type",
                  "id",
                  "title",
                  "entry"
                ],
                "properties": {
                  "type": {
                    "const": "component.fullPage"
                  },
                  "id": {
                    "$ref": "#/$defs/id"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "entry": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "type",
                  "id",
                  "label",
                  "entry",
                  "rpcMethods"
                ],
                "properties": {
                  "type": {
                    "const": "application.settingsPage"
                  },
                  "id": {
                    "$ref": "#/$defs/id"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                  },
                  "entry": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                  },
                  "rpcMethods": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 32,
                    "uniqueItems": true,
                    "items": {
                      "$ref": "#/$defs/versioned"
                    }
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "type",
                  "id",
                  "label",
                  "form"
                ],
                "properties": {
                  "type": {
                    "const": "application.settingsForm"
                  },
                  "id": {
                    "$ref": "#/$defs/id"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80,
                    "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                  },
                  "form": {
                    "$ref": "#/$defs/settingsForm"
                  },
                  "customPage": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "entry",
                      "rpcMethods"
                    ],
                    "properties": {
                      "title": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 160,
                        "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                      },
                      "entry": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512,
                        "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                      },
                      "rpcMethods": {
                        "type": "array",
                        "minItems": 1,
                        "maxItems": 32,
                        "uniqueItems": true,
                        "items": {
                          "$ref": "#/$defs/versioned"
                        }
                      }
                    }
                  }
                }
              },
              {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "type",
                  "id",
                  "label",
                  "pageId",
                  "rpcMethods"
                ],
                "properties": {
                  "type": {
                    "enum": [
                      "component.sidePanel",
                      "media.contextAction",
                      "project.contextAction",
                      "project.importProvider",
                      "project.exportProvider",
                      "application.command",
                      "application.homeCard"
                    ]
                  },
                  "id": {
                    "$ref": "#/$defs/id"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 80
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "description": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 240,
                    "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                  },
                  "pageId": {
                    "$ref": "#/$defs/id"
                  },
                  "contextMenu": { "enum": ["root", "group", "none"] },
                  "fileHandler": {
                    "type": "object", "additionalProperties": false, "required": ["extensions"],
                    "properties": { "extensions": { "type": "array", "minItems": 1, "maxItems": 64, "uniqueItems": true, "items": { "type": "string", "pattern": "^\\.[a-z0-9]{1,16}$" } } }
                  },
                  "selection": {
                    "type": "object", "additionalProperties": false,
                    "properties": {
                      "minCount": { "type": "integer", "minimum": 0, "maximum": 2000 },
                      "maxCount": { "type": "integer", "minimum": 0, "maximum": 2000 },
                      "kinds": { "type": "array", "minItems": 1, "maxItems": 6, "uniqueItems": true, "items": { "enum": ["folder", "image", "raw", "video", "file", "shortcut"] } },
                      "extensions": { "type": "array", "minItems": 1, "maxItems": 64, "uniqueItems": true, "items": { "type": "string", "pattern": "^\\.[a-z0-9]{1,16}$" } },
                      "excludedExtensions": { "type": "array", "minItems": 1, "maxItems": 64, "uniqueItems": true, "items": { "type": "string", "pattern": "^\\.[a-z0-9]{1,16}$" } }
                    }
                  },
                  "placement": {
                    "enum": [
                      "workspace.videoTools",
                      "workspace.imageTools",
                      "workspace.officeTools",
                      "workspace.folderPanel"
                    ]
                  },
                  "rpcMethods": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 128,
                    "uniqueItems": true,
                    "items": {
                      "$ref": "#/$defs/versioned"
                    }
                  }
                },
                "allOf": [
                  {
                    "if": {
                      "required": [
                        "placement"
                      ]
                    },
                    "then": {
                      "properties": {
                        "type": {
                          "enum": [
                            "component.sidePanel",
                            "project.contextAction"
                          ]
                        }
                      }
                    }
                  },
                  {
                    "if": {
                      "required": [
                        "placement"
                      ],
                      "properties": {
                        "placement": {
                          "const": "workspace.folderPanel"
                        }
                      }
                    },
                    "then": {
                      "properties": {
                        "type": {
                          "const": "component.sidePanel"
                        }
                      }
                    }
                  }
                ]
              }
            ]
          }
        },
        "service": {
          "type": "object",
          "additionalProperties": false,
          "required": [
            "protocolVersion",
            "runtime",
            "entrypoints",
            "rpcMethods",
            "capabilities",
            "permissions"
          ],
          "properties": {
            "protocolVersion": {
              "const": 1
            },
            "runtime": {
              "enum": [
                "node",
                "executable"
              ]
            },
            "entrypoints": {
              "type": "object",
              "minProperties": 1,
              "additionalProperties": {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              }
            },
            "rpcMethods": {
              "type": "array",
              "minItems": 1,
              "maxItems": 128,
              "uniqueItems": true,
              "items": {
                "$ref": "#/$defs/versioned"
              }
            },
            "capabilities": {
              "type": "array",
              "maxItems": 32,
              "uniqueItems": true,
              "items": {
                "enum": [
                  "project.media.page",
                  "project.media.variants",
                  "project.input.tokens",
                  "project.output",
                  "version.create",
                  "tasks",
                  "dialogs",
                  "component.storage",
                  "component.settings",
                  "component.events",
                  "component.lifecycle",
                  "component.media",
                  "project.progress",
                  "notifications",
                  "project.files.page",
                  "project.files.search",
                  "project.media.metadata",
                  "project.versions.page",
                  "project.version.graph",
                  "project.media.ratings",
                  "project.media.ratings.write",
                  "project.version.update",
                  "project.version.delete",
                  "project.progress.manage",
                  "project.import",
                  "project.files.mutate",
                  "project.media.process",
                  "component.runtime.execute",
                  "component.secrets",
                  "network.fetch",
                  "project.files.inputToken",
                  "project.files.watch",
                  "component.transfer",
                  "project.preview",
                  "component.panel"
                ]
              }
            },
            "permissions": {
              "type": "array",
              "maxItems": 32,
              "uniqueItems": true,
              "items": {
                "enum": [
                  "project.media.read",
                  "project.input.read",
                  "project.output.write",
                  "project.version.create",
                  "component.storage",
                  "component.settings",
                  "component.secrets",
                  "network.fetch",
                  "tasks",
                  "dialogs",
                  "events",
                  "component.lifecycle.read",
                  "component.lifecycle.manage",
                  "component.media",
                  "project.progress",
                  "notifications",
                  "project.files.read",
                  "project.versions.read",
                  "project.media.ratings.read",
                  "project.media.ratings.write",
                  "project.version.write",
                  "project.version.delete",
                  "project.progress.manage",
                  "project.import",
                  "project.files.write",
                  "project.media.process",
                  "component.runtime.execute",
                  "project.preview.read",
                  "project.preview.control",
                  "component.panel"
                ]
              }
            },
            "events": {
              "type": "array",
              "maxItems": 32,
              "uniqueItems": true,
              "items": {
                "$ref": "#/$defs/versioned"
              }
            },
            "runtimeActions": {
              "type": "array",
              "maxItems": 32,
              "uniqueItems": true,
              "items": {
                "$ref": "#/$defs/id"
              }
            },
            "lifecycleActions": {
              "type": "object",
              "maxProperties": 16
            },
            "networkOrigins": {
              "type": "array",
              "maxItems": 16,
              "uniqueItems": true,
              "items": {
                "type": "string",
                "pattern": "^https://[^/?#@]+$",
                "maxLength": 512
              }
            },
            "secretBindings": {
              "type": "object",
              "maxProperties": 16,
              "propertyNames": {
                "$ref": "#/$defs/id"
              },
              "additionalProperties": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "origin",
                  "header"
                ],
                "properties": {
                  "origin": {
                    "type": "string",
                    "pattern": "^https://[^/?#@\\s]+$",
                    "maxLength": 512
                  },
                  "header": {
                    "type": "string",
                    "pattern": "^(?!(?:host|cookie|set-cookie|connection|upgrade|transfer-encoding|proxy-.*)$)[a-z0-9-]{1,64}$"
                  },
                  "prefix": {
                    "type": "string",
                    "maxLength": 128,
                    "pattern": "^[^\\r\\n]*$"
                  }
                }
              }
            },
            "backupRestore": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "transactionProtocolVersion",
                "sourceManifestProtocolVersion",
                "receiptProtocolVersion",
                "sources"
              ],
              "properties": {
                "transactionProtocolVersion": {
                  "const": 1
                },
                "sourceManifestProtocolVersion": {
                  "const": 1
                },
                "receiptProtocolVersion": {
                  "const": 1
                },
                "workspace": {
                  "$ref": "#/$defs/backupRestoreHook"
                },
                "project": {
                  "$ref": "#/$defs/backupRestoreHook"
                },
                "sources": {
                  "type": "array",
                  "minItems": 1,
                  "maxItems": 16,
                  "uniqueItems": true,
                  "items": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "scope",
                      "path",
                      "format"
                    ],
                    "properties": {
                      "scope": {
                        "enum": [
                          "component-storage",
                          "domain-database"
                        ]
                      },
                      "path": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512,
                        "pattern": "^(?=\\S(?:[\\s\\S]*\\S)?$)(?!/)(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))[^\\\\/\\u0000-\\u001f]+(?:/[^\\\\/\\u0000-\\u001f]+)*$"
                      },
                      "format": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 80,
                        "pattern": "^\\S(?:[\\s\\S]*\\S)?$"
                      }
                    }
                  }
                }
              },
              "anyOf": [
                {
                  "required": [
                    "workspace"
                  ]
                },
                {
                  "required": [
                    "project"
                  ]
                }
              ]
            },
            "projectFolders": {
              "type": "array",
              "maxItems": 32,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160,
                    "pattern": "^\\S(?:[\\s\\S]*[^.\\s])?$"
                  },
                  "protectFromGenericRename": {
                    "type": "boolean"
                  },
                  "reserveProgressRelocationName": {
                    "type": "boolean"
                  },
                  "legacyAdoptionGrant": {
                    "enum": [
                      "component.storage.previous.v1",
                      "project.output.existing.v1"
                    ]
                  }
                },
                "anyOf": [
                  {
                    "required": [
                      "protectFromGenericRename"
                    ],
                    "properties": {
                      "protectFromGenericRename": {
                        "const": true
                      }
                    }
                  },
                  {
                    "required": [
                      "reserveProgressRelocationName"
                    ],
                    "properties": {
                      "reserveProgressRelocationName": {
                        "const": true
                      }
                    }
                  }
                ]
              }
            },
            "previewDecoders": {
              "type": "array",
              "maxItems": 16,
              "items": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "id": {
                    "type": "string",
                    "pattern": "^[a-z0-9][a-z0-9.-]{0,79}$"
                  },
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 160
                  },
                  "extensions": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 64,
                    "uniqueItems": true,
                    "items": {
                      "type": "string",
                      "maxLength": 64,
                      "pattern": "^(\\*|\\.[^\\\\/:*?\"<>|\\u0000-\\u0020]+)$"
                    }
                  },
                  "method": {
                    "$ref": "#/$defs/versioned"
                  },
                  "thumbnailMethod": { "$ref": "#/$defs/versioned" },
                  "priority": {
                    "type": "integer",
                    "minimum": -100,
                    "maximum": 100
                  }
                },
                "required": [
                  "id",
                  "label",
                  "extensions",
                  "method"
                ]
              }
            }
          }
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "contributions": {
                "contains": {
                  "type": "object",
                  "required": [
                    "type"
                  ],
                  "properties": {
                    "type": {
                      "const": "application.settingsForm"
                    }
                  }
                }
              }
            }
          },
          "then": {
            "properties": {
              "service": {
                "properties": {
                  "capabilities": {
                    "contains": {
                      "const": "component.settings"
                    }
                  },
                  "permissions": {
                    "contains": {
                      "const": "component.settings"
                    }
                  }
                }
              }
            }
          }
        },
        {
          "if": {
            "properties": {
              "contributions": {
                "maxItems": 0
              }
            }
          },
          "then": {
            "properties": {
              "service": {
                "required": [
                  "previewDecoders"
                ],
                "properties": {
                  "previewDecoders": {
                    "minItems": 1
                  }
                }
              }
            }
          },
          "else": {
            "anyOf": [
              {
                "properties": {
                  "contributions": {
                    "minItems": 1,
                    "items": {
                      "required": ["type"],
                      "properties": { "type": { "const": "application.settingsForm" } },
                      "not": { "required": ["customPage"] }
                    }
                  }
                }
              },
              {
                "properties": {
                  "contributions": {
                    "minItems": 2,
                    "contains": {
                  "type": "object",
                  "required": [
                    "type"
                  ],
                  "properties": {
                    "type": {
                      "enum": [
                        "workspace.toolbarAction",
                        "component.sidePanel",
                        "application.homeCard"
                      ]
                    }
                  }
                }
                  }
                }
              }
            ]
          }
        }
      ]
    }
  },
  "$defs": {
    "id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,79}$"
    },
    "versioned": {
      "type": "string",
      "pattern": "^[a-z][a-z0-9.-]{0,119}\\.v[1-9][0-9]*$"
    },
    "settingsForm": {
      "type": "object",
      "additionalProperties": false,
      "anyOf": [
        { "properties": { "groups": { "minItems": 1 } } },
        { "required": ["notices"], "properties": { "notices": { "minItems": 1 } } },
        { "required": ["help"], "properties": { "help": { "minItems": 1 } } }
      ],
      "required": [
        "schemaVersion",
        "groups"
      ],
      "properties": {
        "schemaVersion": {
          "const": 1
        },
        "preferenceScope": { "const": "videoPlayback" },
        "help": {
          "type": "array",
          "maxItems": 16,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["title", "description"],
            "properties": {
              "title": { "type": "string", "minLength": 1, "maxLength": 160 },
              "description": { "type": "string", "minLength": 1, "maxLength": 2000 }
            }
          }
        },
        "notices": {
          "type": "array",
          "maxItems": 64,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": ["title", "description", "license", "sourceUrl", "licenseUrl"],
            "properties": {
              "title": { "type": "string", "minLength": 1, "maxLength": 160 },
              "description": { "type": "string", "minLength": 1, "maxLength": 4000 },
              "license": { "type": "string", "minLength": 1, "maxLength": 160 },
              "sourceUrl": { "type": "string", "minLength": 1, "maxLength": 2048, "pattern": "^https://" },
              "licenseUrl": { "type": "string", "minLength": 1, "maxLength": 2048, "pattern": "^https://" }
            }
          }
        },
        "groups": {
          "type": "array",
          "minItems": 0,
          "maxItems": 12,
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "title",
              "fields"
            ],
            "properties": {
              "id": {
                "$ref": "#/$defs/id"
              },
              "title": {
                "type": "string",
                "minLength": 1,
                "maxLength": 120
              },
              "description": {
                "type": "string",
                "minLength": 1,
                "maxLength": 360
              },
              "fields": {
                "type": "array",
                "minItems": 1,
                "maxItems": 24,
                "items": {
                  "oneOf": [
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "type",
                        "label",
                        "default"
                      ],
                      "properties": {
                        "id": {
                          "$ref": "#/$defs/id"
                        },
                        "type": {
                          "const": "toggle"
                        },
                        "label": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 120
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 360
                        },
                        "default": {
                          "type": "boolean"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "type",
                        "label",
                        "default",
                        "options"
                      ],
                      "properties": {
                        "id": {
                          "$ref": "#/$defs/id"
                        },
                        "type": {
                          "const": "select"
                        },
                        "label": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 120
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 360
                        },
                        "default": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128
                        },
                        "options": {
                          "type": "array",
                          "minItems": 2,
                          "maxItems": 32,
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "required": [
                              "value",
                              "label"
                            ],
                            "properties": {
                              "value": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 128
                              },
                              "label": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 120
                              },
                              "description": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 240
                              }
                            }
                          }
                        }
                      }
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "type",
                        "label",
                        "default"
                      ],
                      "properties": {
                        "id": {
                          "$ref": "#/$defs/id"
                        },
                        "type": {
                          "const": "text"
                        },
                        "label": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 120
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 360
                        },
                        "default": {
                          "type": "string",
                          "maxLength": 4000
                        },
                        "placeholder": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 240
                        },
                        "maxLength": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 4000
                        }
                      }
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "id",
                        "type",
                        "label",
                        "default",
                        "min",
                        "max"
                      ],
                      "properties": {
                        "id": {
                          "$ref": "#/$defs/id"
                        },
                        "type": {
                          "enum": [
                            "number",
                            "range"
                          ]
                        },
                        "label": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 120
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 360
                        },
                        "default": {
                          "type": "number"
                        },
                        "min": {
                          "type": "number"
                        },
                        "max": {
                          "type": "number"
                        },
                        "step": {
                          "type": "number",
                          "exclusiveMinimum": 0
                        },
                        "suffix": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 40
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "backupRestoreHook": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "method"
      ],
      "properties": {
        "method": {
          "allOf": [
            {
              "$ref": "#/$defs/versioned"
            },
            {
              "maxLength": 128
            }
          ]
        }
      }
    }
  }
}
