{
  "id": "pot_calc_root",
  "type": "module",
  "version": "1.1",
  "context": {
    "_title": "Retirement Pot",
    "_icon": "eurosign.circle.fill",
    "layout": "phone"
  },
  "state": {
    "growth": [
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1,
      1.010046,
      1.020193,
      1.030442,
      1.040793,
      1.051249,
      1.06181,
      1.072477,
      1.083251,
      1.094133,
      1.105125,
      1.116227,
      1.127441,
      1.138767,
      1.150207,
      1.161762,
      1.173433,
      1.185221,
      1.197128,
      1.209154,
      1.221301,
      1.23357,
      1.245963,
      1.258479,
      1.271122,
      1.283892,
      1.29679,
      1.309817,
      1.322976,
      1.336266,
      1.34969,
      1.363249,
      1.376944,
      1.390777,
      1.404749,
      1.418861,
      1.433115,
      1.447512,
      1.462053,
      1.476741,
      1.491576,
      1.020184,
      1.040776,
      1.061784,
      1.083215,
      1.105079,
      1.127384,
      1.15014,
      1.173355,
      1.197038,
      1.221199,
      1.245849,
      1.270995,
      1.296649,
      1.322821,
      1.349522,
      1.376761,
      1.40455,
      1.4329,
      1.461822,
      1.491328,
      1.52143,
      1.552139,
      1.583468,
      1.615429,
      1.648035,
      1.6813,
      1.715236,
      1.749857,
      1.785176,
      1.821209,
      1.857969,
      1.895471,
      1.93373,
      1.972761,
      2.01258,
      2.053202,
      2.094645,
      2.136924,
      2.180056,
      2.224059,
      1.025288,
      1.051216,
      1.0778,
      1.105056,
      1.133001,
      1.161653,
      1.191029,
      1.221149,
      1.25203,
      1.283692,
      1.316154,
      1.349438,
      1.383563,
      1.418551,
      1.454424,
      1.491204,
      1.528914,
      1.567578,
      1.60722,
      1.647864,
      1.689536,
      1.732262,
      1.776068,
      1.820982,
      1.867032,
      1.914246,
      1.962654,
      2.012287,
      2.063175,
      2.115349,
      2.168843,
      2.22369,
      2.279923,
      2.337579,
      2.396693,
      2.457302,
      2.519443,
      2.583156,
      2.64848,
      2.715456,
      1.030416,
      1.061757,
      1.094051,
      1.127328,
      1.161617,
      1.196948,
      1.233355,
      1.270868,
      1.309523,
      1.349354,
      1.390395,
      1.432686,
      1.476262,
      1.521164,
      1.567432,
      1.615107,
      1.664232,
      1.714851,
      1.76701,
      1.820755,
      1.876135,
      1.933199,
      1.992,
      2.052588,
      2.11502,
      2.17935,
      2.245637,
      2.31394,
      2.384321,
      2.456842,
      2.531569,
      2.60857,
      2.687912,
      2.769667,
      2.853909,
      2.940714,
      3.030158,
      3.122323,
      3.217292,
      3.315149,
      1.035567,
      1.072399,
      1.110541,
      1.150039,
      1.190943,
      1.233301,
      1.277166,
      1.322591,
      1.369631,
      1.418345,
      1.468791,
      1.521031,
      1.57513,
      1.631152,
      1.689168,
      1.749246,
      1.811461,
      1.87589,
      1.942609,
      2.011702,
      2.083252,
      2.157347,
      2.234077,
      2.313537,
      2.395822,
      2.481034,
      2.569277,
      2.660658,
      2.75529,
      2.853287,
      2.95477,
      3.059862,
      3.168692,
      3.281393,
      3.398102,
      3.518962,
      3.644121,
      3.773731,
      3.907951,
      4.046945,
      1.037634,
      1.076684,
      1.117204,
      1.159249,
      1.202876,
      1.248145,
      1.295118,
      1.343858,
      1.394433,
      1.446911,
      1.501364,
      1.557866,
      1.616495,
      1.67733,
      1.740454,
      1.805954,
      1.87392,
      1.944443,
      2.01762,
      2.093551,
      2.172339,
      2.254093,
      2.338923,
      2.426946,
      2.518282,
      2.613055,
      2.711394,
      2.813435,
      2.919316,
      3.029181,
      3.143181,
      3.261471,
      3.384213,
      3.511575,
      3.643729,
      3.780857,
      3.923146,
      4.070789,
      4.223989,
      4.382954,
      1.040742,
      1.083143,
      1.127272,
      1.173199,
      1.220997,
      1.270742,
      1.322514,
      1.376395,
      1.432472,
      1.490833,
      1.551572,
      1.614785,
      1.680574,
      1.749043,
      1.820302,
      1.894464,
      1.971647,
      2.051975,
      2.135575,
      2.222582,
      2.313134,
      2.407374,
      2.505454,
      2.60753,
      2.713765,
      2.824328,
      2.939396,
      3.059151,
      3.183786,
      3.313498,
      3.448495,
      3.588992,
      3.735213,
      3.887391,
      4.04577,
      4.210601,
      4.382147,
      4.560682,
      4.746492,
      4.939871,
      1.04594,
      1.09399,
      1.144248,
      1.196814,
      1.251796,
      1.309303,
      1.369452,
      1.432365,
      1.498167,
      1.566993,
      1.63898,
      1.714275,
      1.793028,
      1.875399,
      1.961555,
      2.051669,
      2.145922,
      2.244505,
      2.347617,
      2.455466,
      2.56827,
      2.686256,
      2.809662,
      2.938737,
      3.073743,
      3.21495,
      3.362644,
      3.517123,
      3.678699,
      3.847698,
      4.024461,
      4.209344,
      4.40272,
      4.60498,
      4.816532,
      5.037803,
      5.269239,
      5.511307,
      5.764495,
      6.029315,
      1.051162,
      1.104941,
      1.161472,
      1.220895,
      1.283359,
      1.349018,
      1.418036,
      1.490585,
      1.566847,
      1.647009,
      1.731274,
      1.819849,
      1.912956,
      2.010826,
      2.113704,
      2.221845,
      2.335519,
      2.455008,
      2.580611,
      2.71264,
      2.851424,
      2.997308,
      3.150656,
      3.31185,
      3.48129,
      3.6594,
      3.846622,
      4.043422,
      4.250291,
      4.467744,
      4.696323,
      4.936595,
      5.189161,
      5.454648,
      5.733718,
      6.027066,
      6.335423,
      6.659555,
      7.00027,
      7.358417,
      1.061678,
      1.12716,
      1.196681,
      1.270489,
      1.34885,
      1.432044,
      1.52037,
      1.614143,
      1.713699,
      1.819397,
      1.931613,
      2.050751,
      2.177237,
      2.311524,
      2.454094,
      2.605457,
      2.766156,
      2.936766,
      3.117899,
      3.310204,
      3.514371,
      3.731129,
      3.961257,
      4.205579,
      4.46497,
      4.740359,
      5.032734,
      5.343142,
      5.672696,
      6.022575,
      6.394034,
      6.788405,
      7.207098,
      7.651617,
      8.123551,
      8.624594,
      9.15654,
      9.721296,
      10.32088,
      10.95745,
      1.07229,
      1.149806,
      1.232926,
      1.322054,
      1.417625,
      1.520106,
      1.629994,
      1.747826,
      1.874177,
      2.009661,
      2.15494,
      2.310721,
      2.477763,
      2.656881,
      2.848947,
      3.054897,
      3.275736,
      3.512539,
      3.766461,
      4.038739,
      4.3307,
      4.643766,
      4.979464,
      5.33943,
      5.725418,
      6.139309,
      6.58312,
      7.059015,
      7.569311,
      8.116497,
      8.70324,
      9.332398,
      10.00704,
      10.73045,
      11.50615,
      12.33793,
      13.22984,
      14.18623,
      15.21175,
      16.31141
    ],
    "potText": "108917",
    "pot": 108917,
    "contribText": "1500",
    "contrib": 1500,
    "targetText": "2000",
    "target": 2000,
    "yearsRaw": 0.435897,
    "rateRaw": 0.545455,
    "rates": [
      0,
      1,
      2,
      2.5,
      3,
      3.5,
      3.7,
      4,
      4.5,
      5,
      6,
      7
    ],
    "ratePct": 3.7,
    "wdRaw": 0.375,
    "yearIdx": 17,
    "rateIdx": 6,
    "wdIdx": 15,
    "gF": 1.944443,
    "aF": 306.305838
  },
  "dependencies": [
    {
      "action": {
        "state": {
          "id": "recalc",
          "input": {
            "yearIdx": "{{ cast(${yearsRaw} * 39 + 0.5, 'int') }}",
            "rateIdx": "{{ cast(${rateRaw} * 11 + 0.5, 'int') }}",
            "ratePct": "{{ ${rates}[cast(${rateRaw} * 11 + 0.5, 'int')] }}",
            "wdIdx": "{{ cast(${wdRaw} * 40 + 0.5, 'int') }}",
            "gF": "{{ ${growth}[cast(${rateRaw} * 11 + 0.5, 'int') * 40 + cast(${yearsRaw} * 39 + 0.5, 'int')] }}",
            "aF": "{{ ${rates}[cast(${rateRaw} * 11 + 0.5, 'int')] == 0 ? (cast(${yearsRaw} * 39 + 0.5, 'int') + 1) * 12 : (${growth}[cast(${rateRaw} * 11 + 0.5, 'int') * 40 + cast(${yearsRaw} * 39 + 0.5, 'int')] - 1) * 1200 / ${rates}[cast(${rateRaw} * 11 + 0.5, 'int')] }}"
          }
        }
      }
    }
  ],
  "children": [
    {
      "id": "pc_bg",
      "type": "vstack",
      "context": {
        "_spacing": 0
      },
      "style": {
        "layout": {
          "maxWidth": "infinity",
          "maxHeight": "infinity"
        },
        "common": {
          "background": {
            "gradient": {
              "linear": {
                "colors": [
                  "#0A3B34",
                  "#14584C"
                ],
                "startPoint": "topLeading",
                "endPoint": "bottomTrailing"
              }
            }
          }
        }
      },
      "children": [
        {
          "id": "pc_scroll",
          "type": "scroll",
          "style": {
            "scroll": {
              "dismissesKeyboard": "immediately"
            }
          },
          "children": [
            {
              "id": "pc_stack",
              "type": "vstack",
              "context": {
                "_spacing": 14
              },
              "style": {
                "layout": {
                  "padding": {
                    "horizontal": 18,
                    "top": 18,
                    "bottom": 28
                  }
                }
              },
              "children": [
                {
                  "id": "pc_hero",
                  "type": "vstack",
                  "context": {
                    "_spacing": 6
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity",
                      "padding": 24
                    },
                    "common": {
                      "background": {
                        "color": {
                          "color": "white",
                          "opacity": 0.18
                        }
                      },
                      "cornerRadius": 24
                    },
                    "shadow": {
                      "color": {
                        "color": "black",
                        "opacity": 0.25
                      },
                      "radius": 16,
                      "x": 0,
                      "y": 8
                    }
                  },
                  "children": [
                    {
                      "id": "pc_hero_hdr",
                      "type": "hstack",
                      "context": {
                        "_spacing": 8
                      },
                      "children": [
                        {
                          "id": "pc_hero_icon",
                          "type": "image",
                          "context": {
                            "_source": "sf://chart.line.uptrend.xyaxis"
                          },
                          "style": {
                            "layout": {
                              "width": 15,
                              "height": 15
                            },
                            "common": {
                              "foreground": {
                                "color": "#F4C55C"
                              }
                            }
                          }
                        },
                        {
                          "id": "pc_hero_lab",
                          "type": "text",
                          "context": {
                            "_text": "{{ 'POT AFTER ' + cast(${yearIdx} + 1, 'string') + ' YEARS' }}"
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 12,
                                "weight": "semibold"
                              },
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 0.75
                                }
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_hero_val",
                      "type": "text",
                      "context": {
                        "_text": "{{ ${pot} * ${gF} + ${contrib} * ${aF} }}",
                        "_format": {
                          "number": {
                            "style": "currency",
                            "currencyCode": "EUR",
                            "maximumFractionDigits": 0
                          }
                        }
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 46,
                            "weight": "bold",
                            "design": "rounded"
                          },
                          "foreground": {
                            "color": "#F4C55C"
                          }
                        },
                        "text": {
                          "lineLimit": 1,
                          "minimumScaleFactor": 0.45
                        },
                        "animation": {
                          "kind": "easeInOut",
                          "value": "${gF}",
                          "duration": 0.35
                        }
                      }
                    },
                    {
                      "id": "pc_hero_div",
                      "type": "divider"
                    },
                    {
                      "id": "pc_hero_inc_lab",
                      "type": "text",
                      "context": {
                        "_text": "{{ 'pays you, drawing ' + cast(2 + ${wdIdx} / 10, 'string') + '% a year' }}"
                      },
                      "style": {
                        "common": {
                          "font": "caption",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.55
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_hero_inc",
                      "type": "hstack",
                      "context": {
                        "_alignment": "firstTextBaseline",
                        "_spacing": 6
                      },
                      "children": [
                        {
                          "id": "pc_hero_inc_v",
                          "type": "text",
                          "context": {
                            "_text": "{{ (${pot} * ${gF} + ${contrib} * ${aF}) * (2 + ${wdIdx} / 10) / 1200 }}",
                            "_format": {
                              "number": {
                                "style": "currency",
                                "currencyCode": "EUR",
                                "maximumFractionDigits": 0
                              }
                            }
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 30,
                                "weight": "bold",
                                "design": "rounded"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            },
                            "text": {
                              "lineLimit": 1,
                              "minimumScaleFactor": 0.5
                            }
                          }
                        },
                        {
                          "id": "pc_hero_inc_u",
                          "type": "text",
                          "context": {
                            "_text": "a month"
                          },
                          "style": {
                            "common": {
                              "font": "subheadline",
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 0.6
                                }
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_hero_note",
                      "type": "text",
                      "context": {
                        "_text": "All figures in today's money"
                      },
                      "style": {
                        "common": {
                          "font": "caption2",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.45
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                {
                  "id": "pc_inputs",
                  "type": "vstack",
                  "context": {
                    "_spacing": 10
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity",
                      "padding": 18
                    },
                    "common": {
                      "background": {
                        "color": {
                          "color": "white",
                          "opacity": 0.12
                        }
                      },
                      "cornerRadius": 20
                    }
                  },
                  "children": [
                    {
                      "id": "pc_in_hdr",
                      "type": "text",
                      "context": {
                        "_text": "YOUR PLAN"
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 12,
                            "weight": "semibold"
                          },
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.55
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_pot_lab",
                      "type": "text",
                      "context": {
                        "_text": "Portfolio today"
                      },
                      "style": {
                        "common": {
                          "font": "footnote",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.7
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_pot_f",
                      "type": "textfield",
                      "context": {
                        "_label": "0",
                        "_text": "${potText}",
                        "_keyboard": "decimalPad",
                        "_debounce": 0.25
                      },
                      "style": {
                        "textField": {
                          "standard": "roundedBorder"
                        },
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 20,
                            "weight": "semibold",
                            "design": "rounded"
                          }
                        }
                      },
                      "events": {
                        "onChange": {
                          "observed": "potText",
                          "actions": [
                            {
                              "state": {
                                "id": "parse_pot",
                                "input": {
                                  "pot": "{{ cast(${potText}, 'double') ?? 0 }}"
                                }
                              }
                            }
                          ]
                        }
                      }
                    },
                    {
                      "id": "pc_con_lab",
                      "type": "text",
                      "context": {
                        "_text": "Added every month"
                      },
                      "style": {
                        "common": {
                          "font": "footnote",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.7
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_con_f",
                      "type": "textfield",
                      "context": {
                        "_label": "0",
                        "_text": "${contribText}",
                        "_keyboard": "decimalPad",
                        "_debounce": 0.25
                      },
                      "style": {
                        "textField": {
                          "standard": "roundedBorder"
                        },
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 20,
                            "weight": "semibold",
                            "design": "rounded"
                          }
                        }
                      },
                      "events": {
                        "onChange": {
                          "observed": "contribText",
                          "actions": [
                            {
                              "state": {
                                "id": "parse_con",
                                "input": {
                                  "contrib": "{{ cast(${contribText}, 'double') ?? 0 }}"
                                }
                              }
                            }
                          ]
                        }
                      }
                    },
                    {
                      "id": "pc_warn",
                      "type": "text",
                      "context": {
                        "_text": "{{ ${pot} + ${contrib} <= 0 ? 'Enter a portfolio value or a monthly amount to project.' : '' }}"
                      },
                      "style": {
                        "common": {
                          "font": "caption",
                          "foreground": {
                            "color": "#F4C55C"
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_in_div",
                      "type": "divider"
                    },
                    {
                      "id": "pc_years",
                      "type": "vstack",
                      "context": {
                        "_spacing": 6
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_years_hdr",
                          "type": "hstack",
                          "style": {
                            "layout": {
                              "maxWidth": "infinity"
                            }
                          },
                          "children": [
                            {
                              "id": "pc_years_lab",
                              "type": "text",
                              "context": {
                                "_text": "YEARS OF SAVING"
                              },
                              "style": {
                                "common": {
                                  "font": {
                                    "kind": "system",
                                    "size": 12,
                                    "weight": "semibold"
                                  },
                                  "foreground": {
                                    "color": {
                                      "color": "white",
                                      "opacity": 0.6
                                    }
                                  }
                                }
                              }
                            },
                            {
                              "id": "pc_years_sp",
                              "type": "spacer"
                            },
                            {
                              "id": "pc_years_val",
                              "type": "text",
                              "context": {
                                "_text": "{{ cast(${yearIdx} + 1, 'string') }}"
                              },
                              "style": {
                                "common": {
                                  "font": {
                                    "kind": "system",
                                    "size": 19,
                                    "weight": "bold",
                                    "design": "rounded"
                                  },
                                  "foreground": {
                                    "color": "#F4C55C"
                                  }
                                }
                              }
                            }
                          ]
                        },
                        {
                          "id": "pc_years_sl",
                          "type": "slider",
                          "context": {
                            "_value": "${yearsRaw}"
                          },
                          "style": {
                            "common": {
                              "tint": "#F4C55C"
                            }
                          },
                          "events": {
                            "onChange": {
                              "observed": "yearsRaw",
                              "actions": [
                                {
                                  "template": {
                                    "id": "recalc_years",
                                    "input": "recalc"
                                  }
                                }
                              ]
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_rate",
                      "type": "vstack",
                      "context": {
                        "_spacing": 6
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_rate_hdr",
                          "type": "hstack",
                          "style": {
                            "layout": {
                              "maxWidth": "infinity"
                            }
                          },
                          "children": [
                            {
                              "id": "pc_rate_lab",
                              "type": "text",
                              "context": {
                                "_text": "RETURN AFTER INFLATION"
                              },
                              "style": {
                                "common": {
                                  "font": {
                                    "kind": "system",
                                    "size": 12,
                                    "weight": "semibold"
                                  },
                                  "foreground": {
                                    "color": {
                                      "color": "white",
                                      "opacity": 0.6
                                    }
                                  }
                                }
                              }
                            },
                            {
                              "id": "pc_rate_sp",
                              "type": "spacer"
                            },
                            {
                              "id": "pc_rate_val",
                              "type": "text",
                              "context": {
                                "_text": "{{ cast(${ratePct}, 'string') + '%' }}"
                              },
                              "style": {
                                "common": {
                                  "font": {
                                    "kind": "system",
                                    "size": 19,
                                    "weight": "bold",
                                    "design": "rounded"
                                  },
                                  "foreground": {
                                    "color": "#F4C55C"
                                  }
                                }
                              }
                            }
                          ]
                        },
                        {
                          "id": "pc_rate_sl",
                          "type": "slider",
                          "context": {
                            "_value": "${rateRaw}"
                          },
                          "style": {
                            "common": {
                              "tint": "#F4C55C"
                            }
                          },
                          "events": {
                            "onChange": {
                              "observed": "rateRaw",
                              "actions": [
                                {
                                  "template": {
                                    "id": "recalc_rate",
                                    "input": "recalc"
                                  }
                                }
                              ]
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_rate_note",
                      "type": "text",
                      "context": {
                        "_text": "Your simulated portfolio median is 3.7%. World equities have historically done nearer 5%."
                      },
                      "style": {
                        "common": {
                          "font": "caption2",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.45
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_wd",
                      "type": "vstack",
                      "context": {
                        "_spacing": 6
                      },
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_wd_hdr",
                          "type": "hstack",
                          "style": {
                            "layout": {
                              "maxWidth": "infinity"
                            }
                          },
                          "children": [
                            {
                              "id": "pc_wd_lab",
                              "type": "text",
                              "context": {
                                "_text": "WITHDRAWAL RATE"
                              },
                              "style": {
                                "common": {
                                  "font": {
                                    "kind": "system",
                                    "size": 12,
                                    "weight": "semibold"
                                  },
                                  "foreground": {
                                    "color": {
                                      "color": "white",
                                      "opacity": 0.6
                                    }
                                  }
                                }
                              }
                            },
                            {
                              "id": "pc_wd_sp",
                              "type": "spacer"
                            },
                            {
                              "id": "pc_wd_val",
                              "type": "text",
                              "context": {
                                "_text": "{{ cast(2 + ${wdIdx} / 10, 'string') + '%' }}"
                              },
                              "style": {
                                "common": {
                                  "font": {
                                    "kind": "system",
                                    "size": 19,
                                    "weight": "bold",
                                    "design": "rounded"
                                  },
                                  "foreground": {
                                    "color": "#F4C55C"
                                  }
                                }
                              }
                            }
                          ]
                        },
                        {
                          "id": "pc_wd_sl",
                          "type": "slider",
                          "context": {
                            "_value": "${wdRaw}"
                          },
                          "style": {
                            "common": {
                              "tint": "#F4C55C"
                            }
                          },
                          "events": {
                            "onChange": {
                              "observed": "wdRaw",
                              "actions": [
                                {
                                  "template": {
                                    "id": "recalc_wd",
                                    "input": "recalc"
                                  }
                                }
                              ]
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_wd_note",
                      "type": "text",
                      "context": {
                        "_text": "3.5% is the cautious rate for a 30-year retirement; 4% is the classic rule."
                      },
                      "style": {
                        "common": {
                          "font": "caption2",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.45
                            }
                          }
                        }
                      }
                    }
                  ]
                },
                {
                  "id": "pc_break",
                  "type": "vstack",
                  "context": {
                    "_spacing": 10
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity",
                      "padding": 18
                    },
                    "common": {
                      "background": {
                        "color": {
                          "color": "white",
                          "opacity": 0.12
                        }
                      },
                      "cornerRadius": 20
                    }
                  },
                  "children": [
                    {
                      "id": "pc_br_hdr",
                      "type": "text",
                      "context": {
                        "_text": "WHERE THE POT COMES FROM"
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 12,
                            "weight": "semibold"
                          },
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.55
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_br_start",
                      "type": "hstack",
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_br_start_l",
                          "type": "text",
                          "context": {
                            "_text": "Already invested"
                          },
                          "style": {
                            "common": {
                              "font": "body",
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 0.8
                                }
                              }
                            }
                          }
                        },
                        {
                          "id": "pc_br_start_s",
                          "type": "spacer"
                        },
                        {
                          "id": "pc_br_start_v",
                          "type": "text",
                          "context": {
                            "_text": "${pot}",
                            "_format": {
                              "number": {
                                "style": "currency",
                                "currencyCode": "EUR",
                                "maximumFractionDigits": 0
                              }
                            }
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 16,
                                "weight": "regular",
                                "design": "rounded"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_br_paid",
                      "type": "hstack",
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_br_paid_l",
                          "type": "text",
                          "context": {
                            "_text": "Paid in from here"
                          },
                          "style": {
                            "common": {
                              "font": "body",
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 0.8
                                }
                              }
                            }
                          }
                        },
                        {
                          "id": "pc_br_paid_s",
                          "type": "spacer"
                        },
                        {
                          "id": "pc_br_paid_v",
                          "type": "text",
                          "context": {
                            "_text": "{{ ${contrib} * 12 * (${yearIdx} + 1) }}",
                            "_format": {
                              "number": {
                                "style": "currency",
                                "currencyCode": "EUR",
                                "maximumFractionDigits": 0
                              }
                            }
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 16,
                                "weight": "regular",
                                "design": "rounded"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_br_grow",
                      "type": "hstack",
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_br_grow_l",
                          "type": "text",
                          "context": {
                            "_text": "Market growth"
                          },
                          "style": {
                            "common": {
                              "font": "body",
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 0.8
                                }
                              }
                            }
                          }
                        },
                        {
                          "id": "pc_br_grow_s",
                          "type": "spacer"
                        },
                        {
                          "id": "pc_br_grow_v",
                          "type": "text",
                          "context": {
                            "_text": "{{ ${pot} * ${gF} + ${contrib} * ${aF} - ${pot} - ${contrib} * 12 * (${yearIdx} + 1) }}",
                            "_format": {
                              "number": {
                                "style": "currency",
                                "currencyCode": "EUR",
                                "maximumFractionDigits": 0
                              }
                            }
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 16,
                                "weight": "regular",
                                "design": "rounded"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_br_div",
                      "type": "divider"
                    },
                    {
                      "id": "pc_br_tot",
                      "type": "hstack",
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_br_tot_l",
                          "type": "text",
                          "context": {
                            "_text": "Total pot"
                          },
                          "style": {
                            "common": {
                              "font": "body",
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 1
                                }
                              }
                            }
                          }
                        },
                        {
                          "id": "pc_br_tot_s",
                          "type": "spacer"
                        },
                        {
                          "id": "pc_br_tot_v",
                          "type": "text",
                          "context": {
                            "_text": "{{ ${pot} * ${gF} + ${contrib} * ${aF} }}",
                            "_format": {
                              "number": {
                                "style": "currency",
                                "currencyCode": "EUR",
                                "maximumFractionDigits": 0
                              }
                            }
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 17,
                                "weight": "semibold",
                                "design": "rounded"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        }
                      ]
                    }
                  ]
                },
                {
                  "id": "pc_target",
                  "type": "vstack",
                  "context": {
                    "_spacing": 10
                  },
                  "style": {
                    "layout": {
                      "maxWidth": "infinity",
                      "padding": 18
                    },
                    "common": {
                      "background": {
                        "color": {
                          "color": "white",
                          "opacity": 0.12
                        }
                      },
                      "cornerRadius": 20
                    }
                  },
                  "children": [
                    {
                      "id": "pc_tg_hdr",
                      "type": "text",
                      "context": {
                        "_text": "WORK BACKWARDS"
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 12,
                            "weight": "semibold"
                          },
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.55
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_tg_lab",
                      "type": "text",
                      "context": {
                        "_text": "Monthly income you want, in today's money"
                      },
                      "style": {
                        "common": {
                          "font": "footnote",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.7
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_tg_f",
                      "type": "textfield",
                      "context": {
                        "_label": "0",
                        "_text": "${targetText}",
                        "_keyboard": "decimalPad",
                        "_debounce": 0.25
                      },
                      "style": {
                        "textField": {
                          "standard": "roundedBorder"
                        },
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 20,
                            "weight": "semibold",
                            "design": "rounded"
                          }
                        }
                      },
                      "events": {
                        "onChange": {
                          "observed": "targetText",
                          "actions": [
                            {
                              "state": {
                                "id": "parse_tg",
                                "input": {
                                  "target": "{{ cast(${targetText}, 'double') ?? 0 }}"
                                }
                              }
                            }
                          ]
                        }
                      }
                    },
                    {
                      "id": "pc_tg_need",
                      "type": "hstack",
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_tg_need_l",
                          "type": "text",
                          "context": {
                            "_text": "Pot it needs"
                          },
                          "style": {
                            "common": {
                              "font": "body",
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 0.85
                                }
                              }
                            }
                          }
                        },
                        {
                          "id": "pc_tg_need_s",
                          "type": "spacer"
                        },
                        {
                          "id": "pc_tg_need_v",
                          "type": "text",
                          "context": {
                            "_text": "{{ ${target} * 1200 / (2 + ${wdIdx} / 10) }}",
                            "_format": {
                              "number": {
                                "style": "currency",
                                "currencyCode": "EUR",
                                "maximumFractionDigits": 0
                              }
                            }
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 17,
                                "weight": "semibold",
                                "design": "rounded"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_tg_gap",
                      "type": "hstack",
                      "style": {
                        "layout": {
                          "maxWidth": "infinity"
                        }
                      },
                      "children": [
                        {
                          "id": "pc_tg_gap_l",
                          "type": "text",
                          "context": {
                            "_text": "{{ ${pot} * ${gF} + ${contrib} * ${aF} - ${target} * 1200 / (2 + ${wdIdx} / 10) >= 0 ? 'Your plan is ahead by' : 'Your plan is short by' }}"
                          },
                          "style": {
                            "common": {
                              "font": "body",
                              "foreground": {
                                "color": {
                                  "color": "white",
                                  "opacity": 0.85
                                }
                              }
                            }
                          }
                        },
                        {
                          "id": "pc_tg_gap_s",
                          "type": "spacer"
                        },
                        {
                          "id": "pc_tg_gap_v",
                          "type": "text",
                          "context": {
                            "_text": "{{ ${pot} * ${gF} + ${contrib} * ${aF} - ${target} * 1200 / (2 + ${wdIdx} / 10) >= 0 ? ${pot} * ${gF} + ${contrib} * ${aF} - ${target} * 1200 / (2 + ${wdIdx} / 10) : ${target} * 1200 / (2 + ${wdIdx} / 10) - ${pot} * ${gF} - ${contrib} * ${aF} }}",
                            "_format": {
                              "number": {
                                "style": "currency",
                                "currencyCode": "EUR",
                                "maximumFractionDigits": 0
                              }
                            }
                          },
                          "style": {
                            "common": {
                              "font": {
                                "kind": "system",
                                "size": 16,
                                "weight": "regular",
                                "design": "rounded"
                              },
                              "foreground": {
                                "color": "white"
                              }
                            }
                          }
                        }
                      ]
                    },
                    {
                      "id": "pc_tg_div",
                      "type": "divider"
                    },
                    {
                      "id": "pc_tg_ans_lab",
                      "type": "text",
                      "context": {
                        "_text": "Monthly saving that reaches it"
                      },
                      "style": {
                        "common": {
                          "font": "caption",
                          "foreground": {
                            "color": {
                              "color": "white",
                              "opacity": 0.55
                            }
                          }
                        }
                      }
                    },
                    {
                      "id": "pc_tg_ans",
                      "type": "text",
                      "context": {
                        "_text": "{{ ${target} * 1200 / (2 + ${wdIdx} / 10) - ${pot} * ${gF} <= 0 ? 0 : (${target} * 1200 / (2 + ${wdIdx} / 10) - ${pot} * ${gF}) / ${aF} }}",
                        "_format": {
                          "number": {
                            "style": "currency",
                            "currencyCode": "EUR",
                            "maximumFractionDigits": 0
                          }
                        }
                      },
                      "style": {
                        "common": {
                          "font": {
                            "kind": "system",
                            "size": 32,
                            "weight": "bold",
                            "design": "rounded"
                          },
                          "foreground": {
                            "color": "#F4C55C"
                          }
                        },
                        "text": {
                          "lineLimit": 1,
                          "minimumScaleFactor": 0.5
                        },
                        "animation": {
                          "kind": "easeInOut",
                          "value": "${target}",
                          "duration": 0.3
                        }
                      }
                    }
                  ]
                },
                {
                  "id": "pc_foot",
                  "type": "text",
                  "context": {
                    "_text": "Return and withdrawal are real rates — inflation is already taken out, so every euro shown buys what it buys today. The pot is drawn down over about 30 years, not kept for ever. This is arithmetic, not advice."
                  },
                  "style": {
                    "layout": {
                      "padding": {
                        "horizontal": 4,
                        "top": 4
                      }
                    },
                    "common": {
                      "font": "caption2",
                      "foreground": {
                        "color": {
                          "color": "white",
                          "opacity": 0.4
                        }
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}