{
  "schemaVersion": 1,
  "slug": "dress-size-calculator",
  "category": "fashion",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "04fd1b63405de68af4caa9a4e480840dbefb07bdd36965e90e2320c168231079",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/dress-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": "nW = max(0, round((W − 24) ÷ 1.5) + 2); nH = max(0, round((H − 34) ÷ 1.5) + 2); nB = max(0, round((B − 31) ÷ 1.5) + 2); N = max(nB, nW, nH)",
    "vars": [
      [
        "B",
        "bust, inches"
      ],
      [
        "W",
        "waist, inches"
      ],
      [
        "H",
        "hip, inches"
      ],
      [
        "nB",
        "size by bust"
      ],
      [
        "nW",
        "size by waist"
      ],
      [
        "nH",
        "size by hip"
      ],
      [
        "N",
        "largest estimated US size"
      ]
    ],
    "note": "Convert bust, waist and hip to inches. size estimate = max(0, round((bust−31)/1.5)+2, round((waist−24)/1.5)+2, round((hip−34)/1.5)+2). The fixed baselines are a simplified US reference model, not a brand chart."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const k=unit==='cm'?1/2.54:1,b=bust*k,w=waist*k,h=hip*k,valid=(v,minIn,maxIn)=>Number.isFinite(v)&&v>=(unit==='cm'?minIn*2.54:minIn)&&v<=(unit==='cm'?maxIn*2.54:maxIn); if(!valid(bust,25,70)||!valid(waist,20,70)||!valid(hip,25,80))return {sizeByBust:null,sizeByWaist:null,sizeByHip:null,recommendedSize:null,letterSize:null,__error:'inputError'}; const byB=Math.max(0,Math.round((b-31)/1.5)+2),byW=Math.max(0,Math.round((w-24)/1.5)+2),byH=Math.max(0,Math.round((h-34)/1.5)+2),rec=Math.max(byB,byW,byH); return {sizeByBust:byB,sizeByWaist:byW,sizeByHip:byH,recommendedSize:rec,letterSize:rec<=2?'XS':rec<=6?'S':rec<=10?'M':rec<=14?'L':rec<=18?'XL':rec<=22?'XXL':'3XL'};",
    "inputs": [
      {
        "name": "bust",
        "type": "number",
        "default": 36,
        "min": 25,
        "max": 70,
        "step": 0.5,
        "unitField": "unit",
        "minByUnit": {
          "in": 25,
          "cm": 63.5
        },
        "maxByUnit": {
          "in": 70,
          "cm": 177.8
        },
        "unitScales": {
          "in": 1,
          "cm": 0.39370078740157477
        }
      },
      {
        "name": "waist",
        "type": "number",
        "default": 29,
        "min": 20,
        "max": 70,
        "step": 0.5,
        "unitField": "unit",
        "minByUnit": {
          "in": 20,
          "cm": 50.8
        },
        "maxByUnit": {
          "in": 70,
          "cm": 177.8
        },
        "unitScales": {
          "in": 1,
          "cm": 0.39370078740157477
        }
      },
      {
        "name": "hip",
        "type": "number",
        "default": 39,
        "min": 25,
        "max": 80,
        "step": 0.5,
        "unitField": "unit",
        "minByUnit": {
          "in": 25,
          "cm": 63.5
        },
        "maxByUnit": {
          "in": 80,
          "cm": 203.2
        },
        "unitScales": {
          "in": 1,
          "cm": 0.39370078740157477
        }
      },
      {
        "name": "unit",
        "type": "select",
        "default": "in",
        "options": [
          {
            "value": "in"
          },
          {
            "value": "cm"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "sizeByBust",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "sizeByWaist",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "sizeByHip",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "recommendedSize",
        "precision": 0,
        "unit": ""
      },
      {
        "name": "letterSize",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
