{
  "version": 0,
  "execution": {
    "transactionMode": "SAFE_AUTO_COMMIT"
  },
  "requires": [
    {
      "id": "runtime.python"
    }
  ],
  "entry": "b1",
  "blocks": {
    "b1": {
      "type": "setVar",
      "inputs": {
        "name": "pythonPath",
        "value": {
          "type": "resolveCapabilityExecutable",
          "inputs": {
            "id": "runtime.python"
          }
        }
      },
      "next": "b2"
    },
    "b2": {
      "type": "setVar",
      "inputs": {
        "name": "selectedItems",
        "value": {
          "type": "prListProjectItems",
          "inputs": {
            "onlySelected": true,
            "includeSubbins": "BIN_AND_SUBBINS"
          }
        }
      },
      "next": "b3"
    },
    "b3": {
      "type": "setVar",
      "inputs": {
        "name": "selectedItem",
        "value": {
          "type": "listGet",
          "inputs": {
            "list": {
              "var": "selectedItems"
            },
            "where": "FIRST"
          }
        }
      },
      "next": "b4"
    },
    "b4": {
      "type": "setVar",
      "inputs": {
        "name": "cameraMetadataJson",
        "value": {
          "type": "jsonStringify",
          "inputs": {
            "value": {
              "type": "prGetProjectItemCameraMetadata",
              "inputs": {
                "item": {
                  "var": "selectedItem"
                }
              }
            },
            "pretty": false
          }
        }
      },
      "next": "b5"
    },
    "b5": {
      "type": "setVar",
      "inputs": {
        "name": "cameraMetadataJsonLength",
        "value": {
          "type": "textLength",
          "inputs": {
            "value": {
              "var": "cameraMetadataJson"
            }
          }
        }
      },
      "next": "b6"
    },
    "b6": {
      "type": "if",
      "inputs": {
        "branches": [
          {
            "condition": {
              "type": "logicCompare",
              "inputs": {
                "op": "GT",
                "a": {
                  "var": "cameraMetadataJsonLength"
                },
                "b": 4096
              }
            },
            "body": [
              {
                "type": "fail",
                "inputs": {
                  "message": "Camera metadata JSON exceeds the 4096-character direct-argument limit. Use the file-backed Python handoff pattern instead."
                }
              }
            ]
          }
        ]
      },
      "next": "b7"
    },
    "b7": {
      "type": "runExternalProgram",
      "inputs": {
        "program": {
          "var": "pythonPath"
        },
        "args": [
          "-I",
          "-c",
          "import json,sys; data=json.loads(sys.argv[1]); print(json.dumps({'fieldCount':len(data),'model':data.get('model')},separators=(',',':')))",
          {
            "var": "cameraMetadataJson"
          }
        ],
        "timeoutMs": 10000,
        "maxOutputBytes": 4096,
        "storeExitCodeIn": "pythonExitCode",
        "storeStdoutIn": "pythonStdout",
        "storeStderrIn": "pythonStderr"
      },
      "next": "b8"
    },
    "b8": {
      "type": "esConsoleLog",
      "inputs": {
        "message": {
          "type": "textJoin",
          "inputs": {
            "items": [
              "SUMMARY|pythonExitCode=",
              {
                "var": "pythonExitCode"
              },
              "|stdout=\"",
              {
                "var": "pythonStdout"
              },
              "\"|stderr=\"",
              {
                "var": "pythonStderr"
              },
              "\""
            ]
          }
        }
      },
      "next": null
    }
  }
}
