{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$defs": {
    "StoryLocator": {
      "description": "Story scope. Defaults to document body when omitted. Use {kind:'story', storyType:'body'} for body, or other storyType values for headers, footers, footnotes, endnotes.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "body"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterSlot"
            },
            "section": {
              "$ref": "#/$defs/SectionAddress"
            },
            "headerFooterKind": {
              "enum": [
                "header",
                "footer"
              ]
            },
            "variant": {
              "enum": [
                "default",
                "first",
                "even"
              ]
            },
            "resolution": {
              "enum": [
                "effective",
                "explicit"
              ]
            },
            "onWrite": {
              "enum": [
                "materializeIfInherited",
                "editResolvedPart",
                "error"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "section",
            "headerFooterKind",
            "variant"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "headerFooterPart"
            },
            "refId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "refId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "footnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "endnote"
            },
            "noteId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "noteId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            },
            "storyType": {
              "const": "textbox"
            },
            "textboxId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "storyType",
            "textboxId"
          ]
        }
      ]
    },
    "SectionAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "section"
        },
        "sectionId": {
          "type": "string"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "sectionId"
      ]
    },
    "SDProjectionReviewMode": {
      "enum": [
        "final",
        "original",
        "redline"
      ]
    },
    "SDProjectionScope": {
      "oneOf": [
        {
          "$ref": "#/$defs/BlockNodeAddress"
        },
        {
          "$ref": "#/$defs/SelectionTarget"
        }
      ]
    },
    "BlockNodeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeType": {
          "enum": [
            "paragraph",
            "heading",
            "listItem",
            "table",
            "tableRow",
            "tableCell",
            "tableOfContents",
            "image",
            "sdt"
          ]
        },
        "nodeId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ]
    },
    "SelectionTarget": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "selection"
        },
        "start": {
          "$ref": "#/$defs/SelectionPoint"
        },
        "end": {
          "$ref": "#/$defs/SelectionPoint"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        },
        "coordinateSpace": {
          "$ref": "#/$defs/TextCoordinateSpace"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "start",
        "end"
      ]
    },
    "SelectionPoint": {
      "description": "A point in the document. Use {kind:'text', blockId, offset} for character positions or {kind:'nodeEdge', node:{kind:'block', nodeType, nodeId}, edge:'before'|'after'} for block boundaries.",
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "text"
            },
            "blockId": {
              "type": "string"
            },
            "offset": {
              "type": "integer",
              "minimum": 0
            },
            "story": {
              "$ref": "#/$defs/StoryLocator"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "blockId",
            "offset"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "nodeEdge"
            },
            "node": {
              "$ref": "#/$defs/SelectionEdgeNodeAddress"
            },
            "edge": {
              "enum": [
                "before",
                "after"
              ]
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "node",
            "edge"
          ]
        }
      ]
    },
    "SelectionEdgeNodeAddress": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "block"
        },
        "nodeType": {
          "enum": [
            "paragraph",
            "heading",
            "table",
            "tableOfContents",
            "sdt",
            "image"
          ]
        },
        "nodeId": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "nodeType",
        "nodeId"
      ]
    },
    "TextCoordinateSpace": {
      "enum": [
        "visible",
        "tracked"
      ]
    },
    "SDContentProjectionResult": {
      "type": "object",
      "properties": {
        "format": {
          "$ref": "#/$defs/SDProjectionFormat"
        },
        "content": {
          "type": "string"
        },
        "status": {
          "$ref": "#/$defs/SDProjectionStatus"
        },
        "outcome": {
          "enum": [
            "preserved",
            "preserved-with-warnings",
            "simplified",
            "rejected",
            "no-op",
            "invalid-target",
            "outdated"
          ]
        },
        "reviewMode": {
          "$ref": "#/$defs/SDProjectionReviewMode"
        },
        "evaluatedRevision": {
          "type": "string"
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        },
        "scope": {
          "$ref": "#/$defs/SDResolvedProjectionScope"
        },
        "lossy": {
          "type": "boolean"
        },
        "diagnostics": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SDProjectionDiagnostic"
          }
        },
        "blocks": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SDProjectionBlockMapEntry"
          }
        },
        "annotations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SDProjectionAnnotation"
          }
        },
        "sourceMap": {
          "$ref": "#/$defs/SDProjectionSourceMap"
        }
      },
      "additionalProperties": false,
      "required": [
        "format",
        "content",
        "status",
        "outcome",
        "reviewMode",
        "evaluatedRevision",
        "story",
        "scope",
        "lossy",
        "diagnostics",
        "blocks",
        "annotations"
      ]
    },
    "SDProjectionFormat": {
      "enum": [
        "html",
        "markdown"
      ]
    },
    "SDProjectionStatus": {
      "enum": [
        "success",
        "warning",
        "failed"
      ]
    },
    "SDResolvedProjectionScope": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "story"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "block"
            },
            "target": {
              "$ref": "#/$defs/BlockNodeAddress"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "target"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "range"
            },
            "target": {
              "$ref": "#/$defs/SelectionTarget"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "target"
          ]
        }
      ]
    },
    "SDProjectionDiagnostic": {
      "type": "object",
      "properties": {
        "code": {
          "enum": [
            "projection-normalized-construct",
            "projection-downgraded-construct",
            "projection-unsupported-construct",
            "projection-placeholder-emitted",
            "projection-annotation-omitted",
            "projection-numbering-unresolved",
            "projection-source-coverage-incomplete",
            "projection-scope-unsupported",
            "projection-limit-exceeded",
            "projection-revision-changed",
            "projection-malformed-source"
          ]
        },
        "severity": {
          "enum": [
            "error",
            "warning",
            "info"
          ]
        },
        "message": {
          "type": "string"
        },
        "path": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ]
          }
        },
        "construct": {
          "$ref": "#/$defs/SDProjectionConstruct"
        },
        "disposition": {
          "$ref": "#/$defs/SDProjectionDisposition"
        },
        "lossy": {
          "type": "boolean"
        },
        "source": {
          "type": "object",
          "properties": {
            "story": {
              "$ref": "#/$defs/StoryLocator"
            },
            "blockId": {
              "type": "string"
            },
            "range": {
              "$ref": "#/$defs/Range"
            },
            "coordinateSpace": {
              "const": "tracked"
            },
            "changeIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "commentIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          },
          "additionalProperties": false,
          "required": [
            "story"
          ]
        },
        "output": {
          "type": "object",
          "properties": {
            "format": {
              "$ref": "#/$defs/SDProjectionFormat"
            },
            "range": {
              "$ref": "#/$defs/Range"
            }
          },
          "additionalProperties": false,
          "required": [
            "format"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "code",
        "severity",
        "message",
        "construct",
        "disposition",
        "lossy",
        "source"
      ]
    },
    "SDProjectionConstruct": {
      "enum": [
        "document",
        "source",
        "text",
        "paragraph",
        "emptyParagraph",
        "softBreak",
        "lineBreak",
        "heading",
        "bold",
        "italic",
        "underline",
        "strike",
        "hyperlink",
        "list",
        "listLabel",
        "table",
        "tableHeader",
        "tableRow",
        "tableCell",
        "colSpan",
        "rowSpan",
        "horizontalRule",
        "inlineCode",
        "codeBlock",
        "image",
        "field",
        "contentControl",
        "math",
        "drawing",
        "embeddedObject",
        "sectionBreak",
        "pageBreak",
        "columnBreak",
        "trackedChange",
        "comment",
        "scope",
        "placeholder"
      ]
    },
    "SDProjectionDisposition": {
      "enum": [
        "preserved",
        "normalized",
        "downgraded",
        "placeholder",
        "omitted",
        "rejected"
      ]
    },
    "Range": {
      "type": "object",
      "properties": {
        "start": {
          "type": "integer"
        },
        "end": {
          "type": "integer"
        }
      },
      "additionalProperties": false,
      "required": [
        "start",
        "end"
      ]
    },
    "SDProjectionBlockMapEntry": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "nodeType": {
              "enum": [
                "paragraph",
                "heading",
                "listItem",
                "table",
                "tableRow",
                "tableCell",
                "tableOfContents",
                "image",
                "sdt"
              ]
            },
            "output": {
              "$ref": "#/$defs/Range"
            },
            "parentBlockId": {
              "type": "string"
            },
            "changeIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "commentIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "identity": {
              "const": "public"
            },
            "blockId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "nodeType",
            "output",
            "identity",
            "blockId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "nodeType": {
              "enum": [
                "paragraph",
                "heading",
                "listItem",
                "table",
                "tableRow",
                "tableCell",
                "tableOfContents",
                "image",
                "sdt"
              ]
            },
            "output": {
              "$ref": "#/$defs/Range"
            },
            "parentBlockId": {
              "type": "string"
            },
            "changeIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "commentIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "identity": {
              "const": "unavailable"
            },
            "identityUnavailableReason": {
              "const": "positionDerivedFallback"
            }
          },
          "additionalProperties": false,
          "required": [
            "nodeType",
            "output",
            "identity",
            "identityUnavailableReason"
          ]
        }
      ]
    },
    "SDProjectionAnnotation": {
      "type": "object",
      "properties": {
        "kind": {
          "enum": [
            "trackedChange",
            "comment"
          ]
        },
        "id": {
          "type": "string"
        },
        "blockIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "sourceTarget": {
          "$ref": "#/$defs/TextTarget"
        },
        "outputRanges": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Range"
          }
        },
        "status": {
          "enum": [
            "emitted",
            "partiallyEmitted",
            "omitted"
          ]
        },
        "omittedReason": {
          "enum": [
            "reviewMode",
            "unsupported"
          ]
        },
        "side": {
          "enum": [
            "inserted",
            "deleted",
            "source",
            "destination",
            "formatting"
          ]
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "id",
        "blockIds",
        "outputRanges",
        "status"
      ]
    },
    "TextTarget": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "text"
        },
        "segments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/TextSegment"
          },
          "minItems": 1
        },
        "story": {
          "$ref": "#/$defs/StoryLocator"
        },
        "coordinateSpace": {
          "$ref": "#/$defs/TextCoordinateSpace"
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "segments"
      ]
    },
    "TextSegment": {
      "type": "object",
      "properties": {
        "blockId": {
          "type": "string"
        },
        "range": {
          "$ref": "#/$defs/Range"
        }
      },
      "additionalProperties": false,
      "required": [
        "blockId",
        "range"
      ]
    },
    "SDProjectionSourceMap": {
      "type": "object",
      "properties": {
        "version": {
          "const": "sd-projection-source-map/1"
        },
        "outputCoordinateSpace": {
          "const": "utf16"
        },
        "sourceCoordinateSpace": {
          "const": "tracked"
        },
        "entries": {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/SDProjectionSourceMapTextEntry"
              },
              {
                "$ref": "#/$defs/SDProjectionSourceMapSyntheticEntry"
              }
            ]
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "version",
        "outputCoordinateSpace",
        "sourceCoordinateSpace",
        "entries"
      ]
    },
    "SDProjectionSourceMapTextEntry": {
      "type": "object",
      "properties": {
        "kind": {
          "const": "text"
        },
        "output": {
          "$ref": "#/$defs/Range"
        },
        "source": {
          "$ref": "#/$defs/TextTarget"
        },
        "blockId": {
          "type": "string"
        },
        "changeIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "commentIds": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "kind",
        "output",
        "source",
        "blockId"
      ]
    },
    "SDProjectionSourceMapSyntheticEntry": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "synthetic"
            },
            "output": {
              "$ref": "#/$defs/Range"
            },
            "role": {
              "enum": [
                "listLabel",
                "placeholder"
              ]
            },
            "changeIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "commentIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "identity": {
              "const": "public"
            },
            "blockId": {
              "type": "string"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "output",
            "role",
            "identity",
            "blockId"
          ]
        },
        {
          "type": "object",
          "properties": {
            "kind": {
              "const": "synthetic"
            },
            "output": {
              "$ref": "#/$defs/Range"
            },
            "role": {
              "enum": [
                "listLabel",
                "placeholder"
              ]
            },
            "changeIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "commentIds": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "identity": {
              "const": "unavailable"
            },
            "identityUnavailableReason": {
              "const": "positionDerivedFallback"
            }
          },
          "additionalProperties": false,
          "required": [
            "kind",
            "output",
            "role",
            "identity",
            "identityUnavailableReason"
          ]
        }
      ]
    }
  },
  "operationId": "projectHtml",
  "schemas": {
    "input": {
      "type": "object",
      "properties": {
        "in": {
          "$ref": "#/$defs/StoryLocator"
        },
        "reviewMode": {
          "$ref": "#/$defs/SDProjectionReviewMode"
        },
        "scope": {
          "$ref": "#/$defs/SDProjectionScope"
        },
        "includeSourceMap": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "output": {
      "allOf": [
        {
          "$ref": "#/$defs/SDContentProjectionResult"
        },
        {
          "type": "object",
          "properties": {
            "format": {
              "const": "html"
            }
          }
        }
      ]
    }
  }
}
