{
  "schemaVersion": 1,
  "slug": "biorhythm-calculator",
  "category": "party",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "6e40c57920d6ff2b3e5f1ef2463f4c0747bbbe9ff0022add42719b1ea1bf4ff0",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/biorhythm-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": "P = 100·sin(2πd/23), E = 100·sin(2πd/28), I = 100·sin(2πd/33)",
    "vars": [
      [
        "d",
        "Days since birth"
      ],
      [
        "P",
        "Physical cycle (%)"
      ],
      [
        "E",
        "Emotional cycle (%)"
      ],
      [
        "I",
        "Intellectual cycle (%)"
      ]
    ],
    "note": "Overall = (P + E + I)/3; the physical phase is flagged critical within ±5 of zero; cycle lengths are 23, 28 and 33 days."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const parse=s=>{const m=/^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(String(s));if(!m)return null;const y=+m[1],mo=+m[2],day=+m[3],x=new Date(0);x.setUTCFullYear(y,mo-1,day);x.setUTCHours(0,0,0,0);return x.getUTCFullYear()===y&&x.getUTCMonth()===mo-1&&x.getUTCDate()===day?x:null};const b=parse(birthDate),t=parse(targetDate);if(!b||!t||t<b)return{daysAlive:null,physical:null,emotional:null,intellectual:null,overall:null,physicalPhase:null,__error:'inputError'};const days=Math.round((t-b)/86400000),p=Math.sin(2*Math.PI*days/23)*100,e=Math.sin(2*Math.PI*days/28)*100,i=Math.sin(2*Math.PI*days/33)*100;return{__targetDate:String(targetDate),daysAlive:days,physical:p,emotional:e,intellectual:i,overall:(p+e+i)/3,physicalPhase:p>5?'High':p< -5?'Low':'Critical (crossing zero)'};",
    "inputs": [
      {
        "name": "birthDate",
        "type": "date",
        "default": "1990-01-01",
        "step": 1,
        "preserveEmpty": true,
        "requiredValue": true
      },
      {
        "name": "targetDate",
        "type": "date",
        "default": "@today",
        "step": 1,
        "preserveEmpty": true,
        "requiredValue": true
      }
    ],
    "outputs": [
      {
        "name": "physical",
        "precision": 1,
        "unit": "%",
        "trimTrailingZeros": true
      },
      {
        "name": "emotional",
        "precision": 1,
        "unit": "%",
        "trimTrailingZeros": true
      },
      {
        "name": "intellectual",
        "precision": 1,
        "unit": "%",
        "trimTrailingZeros": true
      },
      {
        "name": "daysAlive",
        "precision": 0,
        "unit": "days",
        "trimTrailingZeros": true
      },
      {
        "name": "overall",
        "precision": 1,
        "unit": "%",
        "trimTrailingZeros": true
      },
      {
        "name": "physicalPhase",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
