{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://tattvabodha.com/schemas/tattvabodha-experience-v1.0.0.schema.json",
  "title": "Tattvabodha Experience",
  "description": "Portable experience and phase records for Tattvabodha Content Integration Specification v1.0.0.",
  "$ref": "#/$defs/Experience",
  "$defs": {
    "Identifier": {
      "type": "string",
      "minLength": 1,
      "pattern": "^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$"
    },
    "ExperiencePhase": {
      "type": "object",
      "required": [
        "id",
        "type",
        "title",
        "order"
      ],
      "properties": {
        "id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "type": "string",
          "minLength": 1
        },
        "title": {
          "type": "string",
          "minLength": 1
        },
        "order": {
          "type": "integer",
          "minimum": 1
        },
        "practiceId": {
          "$ref": "#/$defs/Identifier"
        },
        "content": {
          "type": "string"
        },
        "prompt": {
          "type": "string"
        },
        "description": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "durationSeconds": {
          "type": "integer",
          "minimum": 1,
          "description": "Resolved phase duration in seconds. For Object Focus, this is practice durationMinutes multiplied by 60."
        },
        "durationSource": {
          "type": "string",
          "enum": [
            "practice_duration"
          ],
          "description": "On a template definition, indicates the duration is derived from practice duration. Instantiated phases may include both this source and the resolved durationSeconds."
        },
        "configuration": {
          "type": "object",
          "additionalProperties": true
        },
        "motif": {},
        "transition": {
          "type": "string"
        },
        "transitionBehavior": {
          "type": "string"
        },
        "autoAdvance": {
          "type": "boolean"
        },
        "userDismissed": {
          "type": "boolean"
        }
      },
      "additionalProperties": true
    },
    "Experience": {
      "type": "object",
      "required": [
        "id",
        "type",
        "name",
        "practiceId",
        "experienceType",
        "durationMinutes",
        "phases"
      ],
      "properties": {
        "schemaVersion": {
          "type": "string"
        },
        "id": {
          "type": "string",
          "minLength": 1
        },
        "type": {
          "const": "experience"
        },
        "name": {
          "type": "string",
          "minLength": 1
        },
        "practiceId": {
          "$ref": "#/$defs/Identifier"
        },
        "experienceType": {
          "type": "string",
          "minLength": 1
        },
        "templateId": {
          "type": "string",
          "minLength": 1
        },
        "durationMinutes": {
          "type": "number",
          "exclusiveMinimum": 0
        },
        "source": {
          "type": "string"
        },
        "motif": {},
        "configuration": {
          "type": "object",
          "additionalProperties": true
        },
        "activePhaseId": {
          "type": "string"
        },
        "activePhaseIndex": {
          "type": "integer",
          "minimum": 0
        },
        "activePracticeId": {
          "$ref": "#/$defs/Identifier"
        },
        "phases": {
          "type": "array",
          "minItems": 1,
          "items": {
            "$ref": "#/$defs/ExperiencePhase"
          }
        }
      },
      "additionalProperties": true
    }
  }
}
