{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://studio.kandins.com/wallpaper-kit/v1/submission.schema.json",
  "title": "Kandins Wallpaper submission v1",
  "description": "Admission for a creator work. The SHA-256 digests, binary media structure and byte lengths are checked by the companion validator.",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "format",
    "version",
    "edition",
    "title",
    "creator",
    "description",
    "rights",
    "price_krw",
    "export_price_krw",
    "scene",
    "poster",
    "preview"
  ],
  "properties": {
    "format": {
      "const": "kandins-wallpaper"
    },
    "version": {
      "const": 1
    },
    "edition": {
      "const": "submission"
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 80,
      "pattern": "\\S"
    },
    "creator": {
      "type": "string",
      "minLength": 1,
      "maxLength": 60,
      "pattern": "\\S"
    },
    "description": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1500,
      "pattern": "\\S"
    },
    "rights": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "pattern": "\\S"
    },
    "price_krw": {
      "type": "integer",
      "minimum": 0,
      "maximum": 9999999
    },
    "export_price_krw": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 0,
          "maximum": 9999999
        },
        {
          "type": "null"
        }
      ]
    },
    "source": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "url",
        "commit"
      ],
      "properties": {
        "url": {
          "type": "string",
          "maxLength": 500,
          "pattern": "^https://github\\.com/[\\w.-]+/[\\w.-]+/?$"
        },
        "commit": {
          "type": "string",
          "pattern": "^[a-f0-9]{40}$"
        },
        "notices": {
          "type": "string",
          "minLength": 1,
          "maxLength": 65536
        }
      }
    },
    "scene": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mime",
        "encoding",
        "bytes",
        "sha256",
        "data"
      ],
      "properties": {
        "mime": {
          "enum": [
            "text/html",
            "video/mp4"
          ]
        },
        "encoding": {
          "const": "base64"
        },
        "bytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 16777216
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "data": {
          "type": "string",
          "contentEncoding": "base64",
          "minLength": 4,
          "maxLength": 22369624
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "mime": {
                "const": "text/html"
              }
            }
          },
          "then": {
            "properties": {
              "bytes": {
                "maximum": 2097152
              },
              "data": {
                "maxLength": 2796204
              }
            }
          }
        }
      ]
    },
    "poster": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mime",
        "encoding",
        "bytes",
        "sha256",
        "data"
      ],
      "properties": {
        "mime": {
          "enum": [
            "image/jpeg"
          ]
        },
        "encoding": {
          "const": "base64"
        },
        "bytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 1048576
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "data": {
          "type": "string",
          "contentEncoding": "base64",
          "minLength": 4,
          "maxLength": 1398104
        }
      }
    },
    "preview": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "mime",
        "encoding",
        "bytes",
        "sha256",
        "data"
      ],
      "properties": {
        "mime": {
          "enum": [
            "video/mp4"
          ]
        },
        "encoding": {
          "const": "base64"
        },
        "bytes": {
          "type": "integer",
          "minimum": 1,
          "maximum": 3145728
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        },
        "data": {
          "type": "string",
          "contentEncoding": "base64",
          "minLength": 4,
          "maxLength": 4194304
        }
      }
    }
  }
}
