{
  "settings": {
    "type": "object",
    "title": "Time",
    "description": "use the 'time' property to dispatch timed next cues",
    "additionalProperties": false,
    "readonly": true
  },
  "definitions":{
    "time": {
      "title":"Time",
      "anyOf": [
        {
          "type": "string",
          "description": "Clock time of current or scheduled day",
          "title": "Pick Time",
          "format": "time",
          "isAdaptorContent": false
        },
        {
          "type": "string",
          "title": "Custom",
          "isAdaptorContent": false
        }
      ]
    },
    "month": {
      "title": "Month",
      "description": "Month of current year. Number between 1 - 12 or Month Name 'January' - 'December'. Use negative number to go from last month of year.",
      "isAdaptorContent": false,
      "anyOf": [
        {
          "type": "string",
          "title": "Select",
          "enum":["January","February","March","April","May","June","July","August","September","October","November","December"]
        },
        {
          "type": "string",
          "title": "Custom"
        }
      ]
    }
  },
  "actions": {
    "timeout": {
      "description": "Cue the next state after a fixed timeout.",
      "documentation":"https://docs.adaptorex.org/basics/actions/time/timeout.html",
      "mode": "listen",
      "type": "object",
      "title": "Timeout",
      "required": [
        "timeout",
        "next"
      ],
      "additionalProperties": false,
      "template": "{const title = `time ${action.name}`;const subtitle = undefined;const body = [{ text: `Wait for ${payload.timeout}`, next: payload.next }];return { title, subtitle, body };}",
      "properties": {
        "timeout": {
          "type": "string",
          "minLength": 1,
          "description": "Timeout in seconds or hh:mm:ss",
          "isAdaptorContent": false
        },
        "next": {
          "$ref": "#/definitions/next"
        }
      }
    },
    "datetime": {
      "type": "object",
      "title": "Date and Time",
      "description": "Goto the next state on a specific date at a specific time.",
      "documentation":"https://docs.adaptorex.org/basics/actions/time/datetime.html",
      "template": "{const title = `time ${action.name}`;const subtitle = undefined;const body = [{ text: `Wait until ${payload.datetime}`, next: payload.next }];return { title, subtitle, body };}",
      "required": [
        "datetime",
        "next"
      ],
      "mode": "listen",
      "additionalProperties": false,
      "properties": {
        "datetime": {
          "title":"Date and Time",
          "anyOf": [
            {
              "type": "string",
              "title": "Pick Date",
              "format": "datetime-local",
              "isAdaptorContent": false
            },
            {
              "type": "string",
              "description": "Set Time only if you want to goto next the same day.",
              "title": "Custom Date"
            }
          ]
        },
        "next": {
          "$ref": "#/definitions/next"
        }
      }
    },
    "schedule": {
      "type": "object",
      "title": "Schedule",
      "description": "Goto next state on the next occurrence of a day of the week, a day of month of the current or an upcoming month or at a specific time or hour.",
      "documentation":"https://docs.adaptorex.org/basics/actions/time/schedule.html",
      "mode": "listen",
      "oneOf":[
        {
          "title":"Clock Time",
          "required": ["time", "next"],
          "additionalProperties": false,
          "properties":{
            "time": {
              "$ref": "#/definitions/time"
            },
            "next": {
              "$ref": "#/definitions/next"
            }
          }
        },
        {
            "title":"Minute of Hour",
            "required": ["minuteOfHour", "next"],
            "additionalProperties": false,
            "properties":{
              "minuteOfHour": {
                "type":"string",
                "title":"Minute of Hour",
                "minLength":1,
                "description":"Minute of the current or upcoming hour. E.g.: Set to 0 to goto next on upcoming full hour or 30 on upcoming half hour",
                "isAdaptorContent": false
              },
              "next": {
                "$ref": "#/definitions/next"
              }
            }
        },
        {
          "title":"Day of the Week",
          "required": ["dayOfWeek", "next"],
          "additionalProperties": false,
          "properties": {
            "time": {
              "$ref": "#/definitions/time"
            },
            "dayOfWeek": {
              "minLength": 1,
              "description": "Day of current or scheduled week between 0 - 6 or 'Sunday' - 'Monday'.",
              "title":"Day of Week",
              "isAdaptorContent": false,
              "anyOf": [
                {
                  "type": "string",
                  "title": "Select",
                  "enum":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
                },
                {
                  "type": "string",
                  "title": "Custom"
                }
              ]
            },
            "occurrence": {
              "type": "string",
              "title": "Occurrence Day of Week",
              "description": "Occurrence of day in current or scheduled month. Number between 1 - 6. Week that might not exist defaults to last week of month. Use negative number to go from last week of month.",
              "isAdaptorContent": false
            },
            "month": {
              "$ref": "#/definitions/month"
            },
            "next": {
              "$ref": "#/definitions/next"
            }
          }
        },
        {
          "title":"Day of the Month",
          "required": ["dayOfMonth", "next"],
          "additionalProperties": false,
          "properties": {
            "time": {
              "$ref": "#/definitions/time"
            },
            "dayOfMonth": {
              "type": "string",
              "title":"Day Of Month",
              "minLength": 1,
              "description": "Day of current or scheduled month. Number between 1 - 31. Day that might not exist (28, 29, 30, 31) defaults to last day of month. Use negative number to go from last day of month. -2 Would be 29th of January or 26th of February.",
              "isAdaptorContent": false
            },
            "month": {
              "$ref": "#/definitions/month"
            },
            "next": {
              "$ref": "#/definitions/next"
            }
          }
        }
      ]
    }
  }
}