{
  "schemaVersion": 1,
  "slug": "bed-size-calculator",
  "category": "household",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "4a60d2170779a40a21b4980f1146b6676f7d6eba99e826ebd698c0dd1db0c47e",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/bed-size-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": "F = L_r × W_r − w × l ÷ 144",
    "vars": [
      [
        "w",
        "Bed width, in"
      ],
      [
        "l",
        "Bed length, in"
      ],
      [
        "L_r",
        "Room length, ft"
      ],
      [
        "W_r",
        "Room width, ft"
      ],
      [
        "F",
        "Free floor area, ft²"
      ]
    ],
    "note": "Nominal regional/product dimensions in inches; 1 sq ft = 144 sq in. The bed must fit room length × width in either orientation. Walkway follows the bed dimension along room length; other furniture and side clearance are excluded."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const B={twin:[38,75],twinXl:[38,80],full:[54,75],queen:[60,80],king:[76,80],calKing:[72,84],ukSingle:[35.4,74.8],ukDouble:[53.1,74.8],euDouble:[55.1,78.7],euKing:[63,78.7]};const dim=B[size]||B.queen,w=dim[0],l=dim[1],L=roomLength*12,W=roomWidth*12,aligned=l<=L&&w<=W,rotated=w<=L&&l<=W;if(!aligned&&!rotated)return {__error:'bedDoesNotFit'};const bedLength=aligned?l:w;return {bedWidthIn:w,bedLengthIn:l,bedWidthCm:w*2.54,bedLengthCm:l*2.54,freeFloor:roomLength*roomWidth-w*l/144,walkspace:roomLength*12-bedLength};",
    "inputs": [
      {
        "name": "size",
        "type": "select",
        "default": "queen",
        "options": [
          {
            "value": "twin"
          },
          {
            "value": "twinXl"
          },
          {
            "value": "full"
          },
          {
            "value": "queen"
          },
          {
            "value": "king"
          },
          {
            "value": "calKing"
          },
          {
            "value": "ukSingle"
          },
          {
            "value": "ukDouble"
          },
          {
            "value": "euDouble"
          },
          {
            "value": "euKing"
          }
        ]
      },
      {
        "name": "roomLength",
        "type": "number",
        "default": 12,
        "min": 1,
        "max": 100,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "roomWidth",
        "type": "number",
        "default": 10,
        "min": 1,
        "max": 100,
        "step": 0.5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "bedWidthIn",
        "precision": 0,
        "unit": "in"
      },
      {
        "name": "bedLengthIn",
        "precision": 0,
        "unit": "in"
      },
      {
        "name": "bedWidthCm",
        "precision": 1,
        "unit": "cm"
      },
      {
        "name": "bedLengthCm",
        "precision": 1,
        "unit": "cm"
      },
      {
        "name": "freeFloor",
        "precision": 1,
        "unit": "sq ft"
      },
      {
        "name": "walkspace",
        "precision": 1,
        "unit": "in"
      }
    ],
    "interpret": null
  }
}
