{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "A single flashcard (front/back) with spaced-repetition scheduling state. rkey is the client's card id (see the `id` property below), written via putRecord — this makes a retried push idempotent (a network-timeout retry overwrites the same rkey instead of creating a duplicate) rather than requiring the client to track which pushes already succeeded. Note: unlike most other app.studynext.* records this property is named `id`, not `localId`.",
      "key": "any",
      "record": {
        "properties": {
          "back": {
            "maxLength": 15000,
            "type": "string"
          },
          "createdAt": {
            "format": "datetime",
            "type": "string"
          },
          "deckId": {
            "maxLength": 512,
            "type": "string"
          },
          "difficulty": {
            "description": "FSRS difficulty 1-10, stringified — AT Protocol's data model has no float type. Old clients ignore this field.",
            "type": "string"
          },
          "dueDate": {
            "description": "Calendar date in YYYY-MM-DD format; not a timestamp.",
            "type": "string"
          },
          "easeFactor": {
            "description": "Spaced-repetition ease factor, stringified — AT Protocol's data model has no float type.",
            "type": "string"
          },
          "firstReviewDate": {
            "description": "Calendar date in YYYY-MM-DD format; not a timestamp.",
            "type": "string"
          },
          "flag": {
            "description": "Anki cards.flags low 3 bits (0=none, 1-7 colors). Old clients ignore this field.",
            "maximum": 7,
            "minimum": 0,
            "type": "integer"
          },
          "front": {
            "maxLength": 15000,
            "type": "string"
          },
          "id": {
            "description": "Matches local FlashCard.id and equals this record's own rkey (see the record-level description above).",
            "maxLength": 300,
            "type": "string"
          },
          "interval": {
            "description": "Spaced-repetition interval in days, stringified — AT Protocol's data model has no float type.",
            "type": "string"
          },
          "lapses": {
            "description": "Review failure count. Old clients ignore this field.",
            "minimum": 0,
            "type": "integer"
          },
          "lastGrade": {
            "description": "Most recent grading result (drives the problem-number chip color in 'problem-by-problem' plans). Absent for ungraded cards; old clients ignore this field. Also duplicated in app.studynext.cardMetadata so an old client's whole-record rewrite cannot erase it.",
            "knownValues": [
              "again",
              "hard",
              "good",
              "easy"
            ],
            "type": "string"
          },
          "lastReviewDate": {
            "description": "Calendar date in YYYY-MM-DD format; not a timestamp.",
            "type": "string"
          },
          "media": {
            "description": "Attached media manifest. File bytes live in PDS blobs; front/back reference them by name (<img src>/[sound:]). Old clients ignore this field.",
            "items": {
              "ref": "#mediaEntry",
              "type": "ref"
            },
            "type": "array"
          },
          "pdsRkey": {
            "description": "Canonical migrated TID rkey. It points to a create-only copy while the legacy source record remains readable.",
            "format": "tid",
            "type": "string"
          },
          "problemRounds": {
            "description": "For cards owned by a 'problem-by-problem' plan: how many times this item was graded good or better while in review state (round progress toward the plan's targetRounds). Absent for standard cards; old clients ignore this field.",
            "minimum": 0,
            "type": "integer"
          },
          "repetitions": {
            "minimum": 0,
            "type": "integer"
          },
          "stability": {
            "description": "FSRS stability in days, stringified — AT Protocol's data model has no float type. Old clients ignore this field.",
            "type": "string"
          },
          "state": {
            "knownValues": [
              "new",
              "learning",
              "review",
              "relearning"
            ],
            "type": "string"
          },
          "stepIndex": {
            "minimum": 0,
            "type": "integer"
          },
          "suspended": {
            "description": "Anki queue=-1 (suspended). Excluded from the study queue. Old clients ignore this field.",
            "type": "boolean"
          },
          "syncedAt": {
            "description": "ISO timestamp of the last successful push. Used by the pushing client for its own last-write-wins pull-merge decisions.",
            "format": "datetime",
            "type": "string"
          },
          "tags": {
            "items": {
              "maxLength": 150,
              "type": "string"
            },
            "maxLength": 20,
            "type": "array"
          }
        },
        "required": [
          "id",
          "deckId",
          "front",
          "back",
          "tags",
          "state",
          "interval",
          "easeFactor",
          "repetitions",
          "stepIndex",
          "dueDate"
        ],
        "type": "object"
      },
      "type": "record"
    },
    "mediaEntry": {
      "properties": {
        "blob": {
          "accept": [
            "image/*",
            "audio/*"
          ],
          "maxSize": 26214400,
          "type": "blob"
        },
        "mimeType": {
          "maxLength": 100,
          "type": "string"
        },
        "name": {
          "maxLength": 200,
          "type": "string"
        },
        "size": {
          "minimum": 0,
          "type": "integer"
        }
      },
      "required": [
        "name",
        "mimeType",
        "size",
        "blob"
      ],
      "type": "object"
    }
  },
  "id": "app.studynext.cards",
  "lexicon": 1
}
