{
  "schemaVersion": 1,
  "slug": "pet-age-calculator",
  "category": "pets",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "1b4f0d57794b9573ee2c64c4df896e700a991add3d0706bc5d0faaa328a19483",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/pet-age-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "E = {14, s=1 ∧ z=1; 11.5, s=1 ∧ z=2; 9, s=1 ∧ z=3; 15, s=2; 9, s=3; 2.5, s=4; 28, s=5; 50, s=6}; H = {12.5y, s ∈ {1,2} ∧ y ≤ 2; 25 + (y−2)·{5.5, E > 10; 7.5, E ≤ 10}, s=1 ∧ y > 2; 25 + (y−2)·4.5, s=2 ∧ y > 2; 20, s=3 ∧ y ≤ 1; 20 + (y−1)·9, s=3 ∧ y > 1; min(90, 34y), s=4; 6.5, s=5 ∧ y ≤ 1; 6.5 + (y−1)·2.6, s=5 ∧ y > 1; 12, s=6 ∧ y ≤ 1; 12 + (y−1)·1.5, s=6 ∧ y > 1}; L% = y ÷ E × 100",
    "vars": [
      [
        "y",
        "Pet age in years"
      ],
      [
        "s",
        "Species code (see note)"
      ],
      [
        "z",
        "Dog size code (see note)"
      ],
      [
        "E",
        "Average life expectancy (years)"
      ],
      [
        "H",
        "Equivalent human age (years)"
      ],
      [
        "L%",
        "Percentage of lifespan lived"
      ]
    ],
    "note": "s: 1 dog, 2 cat, 3 rabbit, 4 hamster, 5 horse, 6 bird. z (dog only): 1 small, 2 medium, 3 large. Life-stage thresholds at 15/50/75%."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "let human, expectancy; if (petType === 'dog') { expectancy = size === 'small' ? 14 : size === 'large' ? 9 : 11.5; const firstTwo = 25; human = petYears <= 2 ? petYears*12.5 : firstTwo+(petYears-2)*(expectancy > 10 ? 5.5 : 7.5); } else if (petType === 'cat') { expectancy = 15; human = petYears <= 2 ? petYears*12.5 : 25+(petYears-2)*4.5; } else if (petType === 'rabbit') { expectancy = 9; human = petYears <= 1 ? 20 : 20+(petYears-1)*9; } else if (petType === 'hamster') { expectancy = 2.5; human = Math.min(90, petYears*34); } else if (petType === 'horse') { expectancy = 28; human = petYears <= 1 ? 6.5 : 6.5+(petYears-1)*2.6; } else { expectancy = 50; human = petYears <= 1 ? 12 : 12+(petYears-1)*1.5; } const pct = expectancy > 0 ? petYears/expectancy*100 : 0; const stage = pct < 15 ? 'Young — rapid growth phase' : pct < 50 ? 'Adult — prime of life' : pct < 75 ? 'Mature — watch weight and teeth' : 'Senior — more frequent vet checks'; return { humanYears: human, lifeStage: stage, percentLifespan: pct, lifeExpectancy: expectancy };",
    "inputs": [
      {
        "name": "petType",
        "type": "select",
        "default": "dog",
        "options": [
          {
            "value": "dog"
          },
          {
            "value": "cat"
          },
          {
            "value": "rabbit"
          },
          {
            "value": "hamster"
          },
          {
            "value": "horse"
          },
          {
            "value": "bird"
          }
        ]
      },
      {
        "name": "petYears",
        "type": "number",
        "default": 5,
        "min": 0,
        "max": 60,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "size",
        "type": "select",
        "default": "medium",
        "options": [
          {
            "value": "small"
          },
          {
            "value": "medium"
          },
          {
            "value": "large"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "humanYears",
        "precision": 1,
        "unit": "years"
      },
      {
        "name": "lifeStage",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "percentLifespan",
        "precision": 1,
        "unit": "%"
      },
      {
        "name": "lifeExpectancy",
        "precision": 0,
        "unit": "years"
      }
    ],
    "interpret": null
  }
}
