{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://platoskallipolis.com/schemas/resource-citation.v1.json",
  "title": "Plato's Kallipolis Resource Citation",
  "type": "object",
  "additionalProperties": false,
  "required": ["schema", "resourceId", "version", "contentHash", "citationId", "resolverUrl", "state", "publishedAt"],
  "properties": {
    "schema": {"const": "kallipolis.resource-citation.v1"},
    "resourceId": {"type": "string", "pattern": "^resource\\.[a-z0-9]+(?:[.-][a-z0-9]+)*$"},
    "version": {"type": "string", "pattern": "^[0-9]+\\.[0-9]+\\.[0-9]+$"},
    "contentHash": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"},
    "citationId": {"type": "string", "pattern": "^urn:platos-kallipolis:resource:resource\\.[a-z0-9.-]+:version:[0-9]+\\.[0-9]+\\.[0-9]+:digest:sha256:[a-f0-9]{64}$"},
    "resolverUrl": {"type": "string", "format": "uri"},
    "state": {"enum": ["active", "superseded", "withdrawn"]},
    "publishedAt": {"type": "string", "format": "date-time"},
    "supersededBy": {"type": "string"},
    "withdrawnAt": {"type": "string", "format": "date-time"}
  },
  "allOf": [
    {"if": {"properties": {"state": {"const": "superseded"}}, "required": ["state"]}, "then": {"required": ["supersededBy"]}},
    {"if": {"properties": {"state": {"const": "withdrawn"}}, "required": ["state"]}, "then": {"required": ["withdrawnAt"]}}
  ]
}
