{
  "schemaVersion": 1,
  "slug": "nickname-generator-calculator",
  "category": "fun",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "c620567df76ee79480ae8ff6559fec2a1616dbef60f8b870ebc9a881f90ee217",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/nickname-generator-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": "k = floor(u×m) mod m; nickname = L_k",
    "vars": [
      [
        "k",
        "selected candidate index"
      ],
      [
        "u",
        "seeded random value 0–1"
      ],
      [
        "m",
        "number of candidates"
      ],
      [
        "L_k",
        "candidate nickname"
      ]
    ],
    "note": "u is the first output of the seeded mulberry32 generator; candidate lists are built from the first/last name per style (short, initials, epic, cute); alternative = L_{(k+1) mod m}."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const rng=(s)=>{let a=Math.floor(s)>>>0;return()=>{a=(a+0x6D2B79F5)>>>0;let t=a;t=Math.imul(t^(t>>>15),t|1);t^=t+Math.imul(t^(t>>>7),t|61);return((t^(t>>>14))>>>0)/4294967296;};};const parts=String(name).trim().split(/\\s+/).filter((x)=>x.length>0),chars=Array.from(parts[0]||'Friend'),last=parts.length>1?Array.from(parts[parts.length-1]):[],first=chars.join(''),cut=(n)=>chars.slice(0,n).join(''),caps=(s)=>{const c=Array.from(String(s));return c.length?c[0].toUpperCase()+c.slice(1).join('').toLowerCase():'';},r=rng(seed);let list=[];if(style==='short'){list=[cut(3),cut(4),cut(Math.max(2,chars.length-3))];}else if(style==='initials'){list=[((chars[0]||'')+(last[0]||'')).toUpperCase(),caps((chars[0]||'')+((last.length?last:chars).slice(0,3).join('')))];}else if(style==='epic'){list=[caps(cut(4))+'dor',caps(cut(3))+'thos',caps(cut(4))+'ax'];}else{list=[caps(first)+'y',caps(first)+'ie',caps(cut(Math.max(2,chars.length-1)))+'y'];}const pick=Math.floor(r()*list.length)%list.length,pick2=(pick+1)%list.length;return{nickname:caps(list[pick]),alternative:caps(list[pick2]),styleUsed:style,baseName:first};",
    "inputs": [
      {
        "name": "name",
        "type": "text",
        "default": "Alexander",
        "step": 1
      },
      {
        "name": "style",
        "type": "select",
        "default": "cute",
        "options": [
          {
            "value": "cute"
          },
          {
            "value": "short"
          },
          {
            "value": "initials"
          },
          {
            "value": "epic"
          }
        ]
      },
      {
        "name": "seed",
        "type": "number",
        "default": 12,
        "min": 0,
        "max": 1000000,
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "nickname",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "alternative",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "styleUsed",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "baseName",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
