{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://kotowa.gellyfish.dev/pack-unit.schema.json",
  "title": "Kotowa pack unit (units/<id>.json)",
  "$comment": "Field meanings: https://kotowa.gellyfish.dev/pack-format.html. The app checks less than this schema does.",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "order": {
      "type": "string"
    },
    "parentId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "day": {
      "type": "string"
    },
    "moment": {
      "type": "string"
    },
    "label": {
      "type": "string"
    },
    "labelNote": {
      "type": "string"
    },
    "kind": {
      "type": "string"
    },
    "items": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ContentItem"
      }
    }
  },
  "required": [
    "id",
    "title",
    "order",
    "items"
  ],
  "$defs": {
    "LanguageCode": {
      "type": "string"
    },
    "ContentItem": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "speaker": {
          "$ref": "#/$defs/SpeakerInfo"
        },
        "lines": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/ContentLine"
          }
        },
        "translations": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "image": {
          "type": "string"
        },
        "timing": {
          "$ref": "#/$defs/ItemTiming"
        }
      },
      "required": [
        "id",
        "lines",
        "translations"
      ]
    },
    "ContentLine": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string"
        },
        "transliteration": {
          "type": "string"
        },
        "gloss": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GlossPiece"
          }
        },
        "furigana": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FuriganaToken"
          }
        },
        "translations": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "required": [
        "source"
      ]
    },
    "FuriganaToken": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "reading": {
          "type": "string"
        }
      },
      "required": [
        "text"
      ]
    },
    "GlossAttach": {
      "type": "object",
      "properties": {
        "head": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "predicate": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "GlossFreq": {
      "type": "object",
      "properties": {
        "band": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "GlossKanji": {
      "type": "object",
      "properties": {
        "char": {
          "type": "string"
        },
        "es": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "en": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "grade": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "jlpt": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "char"
      ]
    },
    "GlossLoan": {
      "type": "object",
      "properties": {
        "word": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "lang": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "wasei": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "GlossPattern": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "es": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "en": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "name"
      ]
    },
    "GlossPiece": {
      "type": "object",
      "properties": {
        "raw": {
          "type": "string"
        },
        "span": {
          "type": "string"
        },
        "japanese": {
          "type": "string"
        },
        "pos": {
          "type": "string"
        },
        "lemma": {
          "type": "string"
        },
        "reading": {
          "type": "string"
        },
        "translations": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "note": {
          "type": "string"
        },
        "confidence": {
          "type": "string"
        },
        "lemma_kanji": {
          "type": "string"
        },
        "word_class": {
          "$ref": "#/$defs/GlossWordClass"
        },
        "steps": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GlossStep"
          }
        },
        "expanded": {
          "type": "string"
        },
        "attach": {
          "$ref": "#/$defs/GlossAttach"
        },
        "register": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "loan": {
          "$ref": "#/$defs/GlossLoan"
        },
        "kanji": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GlossKanji"
          }
        },
        "pitch": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/GlossPitch"
          }
        },
        "freq": {
          "$ref": "#/$defs/GlossFreq"
        },
        "pattern": {
          "$ref": "#/$defs/GlossPattern"
        },
        "seen": {
          "$ref": "#/$defs/GlossSeen"
        },
        "sources": {
          "type": "object",
          "additionalProperties": {
            "$ref": "#/$defs/GlossSource"
          }
        }
      },
      "required": [
        "raw"
      ]
    },
    "GlossPitch": {
      "type": "object",
      "properties": {
        "form": {
          "type": "string"
        },
        "reading": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "accents": {
          "type": "array",
          "items": {
            "type": "number"
          }
        }
      },
      "required": [
        "form",
        "accents"
      ]
    },
    "GlossSeen": {
      "type": "object",
      "properties": {
        "count": {
          "type": "number"
        },
        "first_part": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "first_unit": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "count"
      ]
    },
    "GlossSource": {
      "type": "object",
      "properties": {
        "source": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "support": {
          "anyOf": [
            {
              "$ref": "#/$defs/GlossSupport"
            },
            {
              "type": "null"
            }
          ]
        }
      }
    },
    "GlossStep": {
      "type": "object",
      "properties": {
        "form": {
          "type": "string"
        },
        "label": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "stem": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "token": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "form"
      ]
    },
    "GlossSupport": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string"
        },
        "bucket": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "key": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "matched_by": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "n": {
          "type": "number"
        },
        "share": {
          "anyOf": [
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "top_sense": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "matches_pick": {
          "anyOf": [
            {
              "type": "boolean"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "kind",
        "n"
      ]
    },
    "GlossWordClass": {
      "type": "object",
      "properties": {
        "cls": {
          "type": "string"
        },
        "conj_class": {
          "type": "string"
        },
        "transitivity": {
          "type": "string"
        }
      }
    },
    "ItemTiming": {
      "type": "object",
      "properties": {
        "video": {
          "type": "string"
        },
        "start": {
          "type": "number"
        },
        "end": {
          "type": "number"
        }
      },
      "required": [
        "video",
        "start"
      ]
    },
    "SpeakerInfo": {
      "type": "object",
      "properties": {
        "text": {
          "type": "string"
        },
        "furigana": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/FuriganaToken"
          }
        },
        "tier": {
          "const": "minor"
        },
        "romaji": {
          "type": "string"
        },
        "translations": {
          "type": "object",
          "additionalProperties": {
            "type": "string"
          }
        },
        "character": {
          "type": "string"
        },
        "characterName": {
          "type": "object",
          "properties": {
            "text": {
              "type": "string"
            },
            "furigana": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/FuriganaToken"
              }
            }
          },
          "required": [
            "text"
          ]
        }
      },
      "required": [
        "text"
      ]
    }
  }
}
