{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "owlf": {
      "type": "string",
      "const": "0.1"
    },
    "source": {
      "type": "object",
      "properties": {
        "app": {
          "type": "string",
          "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "generator": {
          "type": "string"
        }
      },
      "required": [
        "app",
        "name"
      ],
      "additionalProperties": false
    },
    "scales": {
      "type": "object",
      "properties": {
        "mood": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "size": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "levels": {
                  "minItems": 1,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "label": {
                        "type": "string"
                      },
                      "position": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "color": {
                        "type": "string",
                        "pattern": "^#[0-9a-fA-F]{6}$"
                      },
                      "valence": {
                        "type": "number",
                        "minimum": -1,
                        "maximum": 1
                      }
                    },
                    "required": [
                      "id",
                      "label",
                      "position"
                    ],
                    "additionalProperties": false
                  }
                },
                "continuous": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    },
                    "unit": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "min",
                    "max"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "size",
                "levels"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        },
        "sleep": {
          "anyOf": [
            {
              "type": "object",
              "properties": {
                "size": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9007199254740991
                },
                "levels": {
                  "minItems": 1,
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string",
                        "minLength": 1
                      },
                      "label": {
                        "type": "string"
                      },
                      "position": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 9007199254740991
                      },
                      "color": {
                        "type": "string",
                        "pattern": "^#[0-9a-fA-F]{6}$"
                      },
                      "valence": {
                        "type": "number",
                        "minimum": -1,
                        "maximum": 1
                      }
                    },
                    "required": [
                      "id",
                      "label",
                      "position"
                    ],
                    "additionalProperties": false
                  }
                },
                "continuous": {
                  "type": "object",
                  "properties": {
                    "min": {
                      "type": "number"
                    },
                    "max": {
                      "type": "number"
                    },
                    "unit": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "min",
                    "max"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "size",
                "levels"
              ],
              "additionalProperties": false
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "required": [
        "mood",
        "sleep"
      ],
      "additionalProperties": false
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "date": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "time": {
            "anyOf": [
              {
                "type": "string",
                "pattern": "^([01]\\d|2[0-3]):[0-5]\\d(:[0-5]\\d)?$"
              },
              {
                "type": "null"
              }
            ]
          },
          "instant": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time",
                "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z|([+-](?:[01]\\d|2[0-3]):[0-5]\\d)))$"
              },
              {
                "type": "null"
              }
            ]
          },
          "zoneless": {
            "type": "boolean"
          },
          "utcDate": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "mood": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "level": {
                    "type": "string",
                    "minLength": 1
                  },
                  "raw": {
                    "type": [
                      "string",
                      "number"
                    ]
                  },
                  "label": {
                    "type": "string"
                  }
                },
                "required": [
                  "level",
                  "raw"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "sleep": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "level": {
                    "type": "string",
                    "minLength": 1
                  },
                  "raw": {
                    "type": [
                      "string",
                      "number"
                    ]
                  },
                  "label": {
                    "type": "string"
                  }
                },
                "required": [
                  "level",
                  "raw"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "title": {
            "type": [
              "string",
              "null"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "prompts": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "prompt": {
                  "type": "string"
                },
                "answer": {
                  "type": "string"
                }
              },
              "required": [
                "prompt",
                "answer"
              ],
              "additionalProperties": false
            }
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                },
                "group": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              },
              "required": [
                "name",
                "group"
              ],
              "additionalProperties": false
            }
          },
          "emotions": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "required": [
                "name"
              ],
              "additionalProperties": false
            }
          },
          "people": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1
            }
          },
          "media": {
            "type": "object",
            "properties": {
              "photos": {
                "type": "integer",
                "minimum": 0,
                "maximum": 9007199254740991
              }
            },
            "required": [
              "photos"
            ],
            "additionalProperties": false
          },
          "dropped": {
            "type": "object",
            "propertyNames": {
              "type": "string"
            },
            "additionalProperties": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            }
          }
        },
        "required": [
          "date",
          "time",
          "instant",
          "mood",
          "sleep",
          "title",
          "note",
          "prompts",
          "tags",
          "emotions",
          "people",
          "media",
          "dropped"
        ],
        "additionalProperties": false
      }
    },
    "warnings": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  },
  "required": [
    "owlf",
    "source",
    "scales",
    "entries",
    "warnings"
  ],
  "additionalProperties": false,
  "$id": "https://owlf.org/schema/0.1.json",
  "title": "OWL document 0.1"
}
