{
  "kind": "dsl",
  "metadata": {
    "title": "List Sequence Markers By Type",
    "descriptionMarkdown": "Choose a marker type, then activate the intended sequence before clicking OK. Lists matching marker names, types and start times in seconds in the run log, followed by a count. Choose All to include every type. Reads sequence markers only; it does not change markers or media. FLV cue points and segmentation markers are separate types."
  },
  "dsl": {
    "version": 0,
    "entry": "prompt",
    "blocks": {
      "prompt": {
        "type": "uiPromptForm",
        "inputs": {
          "title": "List Sequence Markers By Type",
          "message": "Choose a marker type. Activate the intended sequence before clicking OK.\n\nResults appear in the run log. No markers or media are changed.",
          "fields": [
            {
              "type": "uiPromptField",
              "inputs": {
                "kind": "SELECT",
                "label": "Marker type",
                "var": "markerType",
                "required": true,
                "options": [
                  "All",
                  "Comment",
                  "Chapter",
                  "WebLink",
                  "FLVCuePoint",
                  "Segmentation"
                ],
                "defaultValue": "Comment"
              }
            }
          ],
          "cancelBehavior": "STOP"
        },
        "next": "sequence"
      },
      "sequence": {
        "type": "setVar",
        "inputs": {
          "name": "sequenceRef",
          "value": {
            "type": "prGetActiveSequenceRef",
            "inputs": {}
          }
        },
        "next": "name"
      },
      "name": {
        "type": "setVar",
        "inputs": {
          "name": "sequenceName",
          "value": {
            "type": "prGetSequenceProperty",
            "inputs": {
              "sequence": {
                "var": "sequenceRef"
              },
              "property": "NAME"
            }
          }
        },
        "next": "types"
      },
      "types": {
        "type": "setVar",
        "inputs": {
          "name": "wantedTypes",
          "value": []
        },
        "next": "choose"
      },
      "choose": {
        "type": "if",
        "inputs": {
          "branches": [
            {
              "condition": {
                "type": "logicCompare",
                "inputs": {
                  "op": "NEQ",
                  "a": {
                    "var": "markerType"
                  },
                  "b": "All"
                }
              },
              "body": [
                {
                  "type": "setVar",
                  "inputs": {
                    "name": "wantedTypes",
                    "value": [
                      {
                        "var": "markerType"
                      }
                    ]
                  }
                }
              ]
            }
          ]
        },
        "next": "list"
      },
      "list": {
        "type": "setVar",
        "inputs": {
          "name": "markerRefs",
          "value": {
            "type": "prListMarkers",
            "inputs": {
              "owner": {
                "var": "sequenceRef"
              },
              "types": {
                "var": "wantedTypes"
              }
            }
          }
        },
        "next": "report"
      },
      "report": {
        "type": "forEachListItem",
        "inputs": {
          "list": {
            "var": "markerRefs"
          },
          "itemVar": "markerRef"
        },
        "body": [
          {
            "type": "esConsoleLog",
            "inputs": {
              "message": {
                "type": "textJoin",
                "inputs": {
                  "items": [
                    "MARKER|startSeconds=",
                    {
                      "type": "prGetMarkerProperty",
                      "inputs": {
                        "marker": {
                          "var": "markerRef"
                        },
                        "property": "START_SECONDS"
                      }
                    },
                    "|type=",
                    {
                      "type": "prGetMarkerProperty",
                      "inputs": {
                        "marker": {
                          "var": "markerRef"
                        },
                        "property": "TYPE"
                      }
                    },
                    "|name=",
                    {
                      "type": "prGetMarkerProperty",
                      "inputs": {
                        "marker": {
                          "var": "markerRef"
                        },
                        "property": "NAME"
                      }
                    }
                  ]
                }
              }
            }
          }
        ],
        "next": "summary"
      },
      "summary": {
        "type": "esConsoleLog",
        "inputs": {
          "message": {
            "type": "textJoin",
            "inputs": {
              "items": [
                "SUMMARY|workflow=markers-by-type|sequence=",
                {
                  "var": "sequenceName"
                },
                "|type=",
                {
                  "var": "markerType"
                },
                "|matches=",
                {
                  "type": "listLength",
                  "inputs": {
                    "list": {
                      "var": "markerRefs"
                    }
                  }
                }
              ]
            }
          }
        }
      }
    }
  }
}
