// Canonical v1.1 tour -- every pax construct appears at least once.


// InitializeVariable with all five v1 types.
var total: int = 0
var completed: int = 0
var label: string = "pending"
var flag: bool = true
var results: object = {
  "region": "us-east",
  "retries": 3
}
var tasks: array = [
  { "title": "Buy groceries", "done": true  },
  { "title": "Write memo",    "done": false },
  { "title": "Call plumber",  "done": false },
]
var pending_titles: array = []

// Foreach with iterator, object member access, mutation inside the body.
foreach task in tasks {
  total += 1
  if task.done {
    completed += 1
  } else {
    pending_titles += task.title
  }
}

// Arithmetic, comparison, boolean ops.
let remaining = total - completed
let all_done = remaining == 0 && total > 0

// Function call + string concat (& loosest).
let summary = concat("Completed ", completed, " of ", total)
let full_summary = summary & " tasks"

// if / else if / else using comparisons.
if all_done {
  label = "done"
} else if remaining > 0 {
  label = "in progress"
} else {
  label = "empty"
}

// Compose captures an object member access.
let region = results.region

// Opaque PA action -- the body is whatever PA's Peek code shows for the
// action, stored verbatim in pa/Send_reminder_email.json next to this
// source. paxc reads the file at compile time and drops it in unchanged.
// PA expression strings inside the JSON keep their `@{variables('X')}`
// and `@{outputs('Y')}` references.
pa Send_reminder_email
