{"release_id":"01a247c3-a6b6-0000-74b2-4a83f2c91090","chunk_id":"01a247c3-a93b-78d2-b69a-50334b0ab634","file":"opSfv1rC.mjs","mappings":"gWAQA,MAAMA,EAAc,OAAO,KAAKC,CAAS,EAE5BC,EAAc,CAC1B,OACA,QACA,cACA,SACA,aACA,qBACA,SACD,EAEaC,EAAY,CACxB,OACA,OACA,QACA,QACA,OACA,MACA,QACA,OACA,WACA,OACD,EAKaC,EAAoC,CAAC,OAAQ,OAAQ,QAAS,QAAS,MAAM,EAC7EC,EAAWC,GAAgBF,EAAa,SAASE,CAAC,EAClDC,EAAa,CAAC,QAAS,QAAS,QAAS,OAAQ,MAAM,EAGvDC,EAAU,CAAC,OAAQ,QAAS,UAAW,MAAO,QAAS,OAAQ,IAAI,EAInEC,EAAe,CAC3B,QACA,SACA,SACA,MACA,SACA,UACA,YACA,OACA,OACA,OACD,EAEaC,EAAe,CAC3B,MACA,OACA,SACA,QACA,QACA,WACA,SACA,OACA,UACA,SACA,QACA,MACD,EAGaC,EAAY,CAAC,WAAY,WAAY,YAAa,YAAa,UAAU,EACzEC,EAAc,CAAC,QAAS,UAAW,UAAW,KAAK,EAInDC,EAAe,CAAC,GAAGF,EAAW,GAAGC,CAAW,EAenDE,EAAU,CACf,GAAG,OAAO,YAAY,CAAC,GAAGL,EAAc,GAAGC,CAAY,EAAE,IAAKK,GAAM,CAACA,EAAG,EAAG,CAAC,CAAC,EAC7E,GAAG,OAAO,YAAYF,EAAa,IAAKE,GAAM,CAACA,EAAG,CAAC,CAAC,CAAC,CACtD,EAIaC,EAAM,CAAC,MAAO,QAAS,OAAO,EAKpC,SAASC,EAAcC,EAAyBC,EAAyB,CAE/E,OADiBA,IAAQ,QAAUD,IAAS,QAAUA,IAAS,SAE5D,CACA,GAAGJ,EACH,MAAO,EACP,QAASI,IAAS,QAAU,GAAM,IAClC,KAAM,IACN,KAAM,OACN,KAAM,OACN,QAAS,QACT,KAAM,QACN,OAAQ,MAAA,EAER,CACA,GAAGJ,EACH,MAAO,EACP,QAASI,IAAS,QAAU,IAAO,GACnC,KAAM,OACN,KAAM,QACN,QAAS,OACT,KAAM,QACN,OAAQ,MAAA,CAEZ,CAEA,MAAME,EAAO,CAAmBC,EAAYC,EAAuBC,IAClE,OAAOF,GAAM,UAAaC,EAA8B,SAASD,CAAC,EAAKA,EAAUE,EAG3E,SAASC,EACfC,EACAP,EACAC,EACsB,CACtB,GAAI,CAACM,GAAS,OAAOA,GAAU,UAAY,MAAM,QAAQA,CAAK,EAAG,OAAO,KACxE,MAAMC,EAAMD,EACNE,EAAMV,EAAcC,EAAMC,CAAG,EAC7BS,EAAM,CAAE,GAAGD,CAAA,EACjB,UAAWZ,IAAK,CAAC,GAAGN,EAAc,GAAGC,EAAc,GAAGG,CAAY,EAAG,CACpE,MAAMQ,EAAIK,EAAIX,CAAC,EACTc,EAAI,OAAOR,GAAM,UAAY,OAAO,SAASA,CAAC,EAAIA,EAAIM,EAAIZ,CAAC,EACjEa,EAAIb,CAAC,EAAI,KAAK,MAAM,KAAK,IAAI,EAAG,KAAK,IAAI,EAAGc,CAAC,CAAC,EAAI,GAAI,EAAI,GAC3D,CACA,OAAAD,EAAI,KAAOR,EAAKM,EAAI,KAAMxB,EAAayB,EAAI,IAAI,EAC/CC,EAAI,KAAOR,EAAKM,EAAI,KAAMvB,EAAWwB,EAAI,IAAI,EAC7CC,EAAI,QAAUR,EAAKM,EAAI,QAAS1B,EAAa2B,EAAI,OAAO,EACxDC,EAAI,KAAOR,EAAKM,EAAI,KAAMnB,EAAYoB,EAAI,IAAI,EAC9CC,EAAI,OAASR,EAAKM,EAAI,OAAQlB,EAASmB,EAAI,MAAM,EAC1CC,CACR","names":["HAIR_COLORS","HAIR_COLS","FACE_SHAPES","HEAD_HAIR","BALDING_HAIR","canBald","h","EYE_COLORS","PRESETS","BODY_SLIDERS","FACE_SLIDERS","BODY_HAIR","AGE_SLIDERS","ZERO_SLIDERS","NEUTRAL","k","WHO","defaultAvatar","body","who","pick","v","allowed","fallback","sanitizeAvatar","input","src","def","out","x"],"sources":["../../../../../../src/lib/sculpt/avatar/params.ts"],"sourcesContent":["// The full-body avatar of a sculpt (RAT-687): the Body and Face tabs. Shared by the editor and the\n// server like the rest of the params, so every value goes through sanitizeAvatar. All sliders run\n// 0..1 with 0.5 as MakeHuman's average, except `build` (0 feminine .. 1 masculine). `fat` (RAT-740)\n// came later: a row saved before it reads 0.5, which adds nothing, so an old body looks as it did.\n\nimport { HAIR_COLS } from '../engine/color';\nimport type { HairColor } from '../params';\n\nconst HAIR_COLORS = Object.keys(HAIR_COLS) as HairColor[];\n\nexport const FACE_SHAPES = [\n\t'oval',\n\t'round',\n\t'rectangular',\n\t'square',\n\t'triangular',\n\t'invertedtriangular',\n\t'diamond'\n] as const;\nexport type FaceShape = (typeof FACE_SHAPES)[number];\nexport const HEAD_HAIR = [\n\t'none',\n\t'buzz',\n\t'short',\n\t'messy',\n\t'afro',\n\t'bob',\n\t'blunt',\n\t'long',\n\t'ponytail',\n\t'braid'\n] as const;\nexport type HeadHair = (typeof HEAD_HAIR)[number];\n/** RAT-740: the styles a receding hairline works on (short hair, a buzz cut, none). Longer styles' cards\n *  hang from the crown: cut out there, they leave holes and a wig hanging below, and a woman's hair\n *  thins all over rather than receding. */\nexport const BALDING_HAIR: readonly HeadHair[] = ['none', 'buzz', 'short', 'messy', 'afro'];\nexport const canBald = (h: HeadHair) => BALDING_HAIR.includes(h);\nexport const EYE_COLORS = ['brown', 'hazel', 'green', 'blue', 'grey'] as const;\nexport type EyeColor = (typeof EYE_COLORS)[number];\n/** A ready Daz character's head and body as the starting shape (the sliders work on top of it). */\nexport const PRESETS = ['none', 'amala', 'fabrice', 'kat', 'laura', 'matt', 'ty'] as const;\nexport type Preset = (typeof PRESETS)[number];\n\n/** The sliders of the Body tab, in the order they show. */\nexport const BODY_SLIDERS = [\n\t'build',\n\t'height',\n\t'weight',\n\t'fat',\n\t'muscle',\n\t'breasts',\n\t'shoulders',\n\t'hips',\n\t'butt',\n\t'belly'\n] as const;\n/** The sliders of the Face tab, in the order they show. */\nexport const FACE_SLIDERS = [\n\t'jaw',\n\t'chin',\n\t'cheeks',\n\t'noseW',\n\t'noseL',\n\t'noseHump',\n\t'mouthW',\n\t'lips',\n\t'eyeSize',\n\t'eyeGap',\n\t'brows',\n\t'ears'\n] as const;\n/** RAT-740: hair on the body, by zone, and an older man's head: none at 0, which is what a row saved\n *  before them reads (so an old body looks as it did). */\nexport const BODY_HAIR = ['hairLegs', 'hairArms', 'hairChest', 'hairBelly', 'hairButt'] as const;\nexport const AGE_SLIDERS = ['beard', 'balding', 'greying', 'age'] as const;\nexport type BodyHairSlider = (typeof BODY_HAIR)[number];\nexport type AgeSlider = (typeof AGE_SLIDERS)[number];\n/** the sliders that start at 0 (none) rather than at 0.5 (average) */\nexport const ZERO_SLIDERS = [...BODY_HAIR, ...AGE_SLIDERS] as const;\nexport type ZeroSlider = BodyHairSlider | AgeSlider;\nexport type BodySlider = (typeof BODY_SLIDERS)[number];\nexport type FaceSlider = (typeof FACE_SLIDERS)[number];\nexport type AvatarSlider = BodySlider | FaceSlider;\n\nexport type AvatarParams = Record<AvatarSlider, number> &\n\tRecord<ZeroSlider, number> & {\n\t\tface: FaceShape;\n\t\thair: HeadHair;\n\t\thairCol: HairColor;\n\t\teyes: EyeColor;\n\t\tpreset: Preset;\n\t};\n\nconst NEUTRAL = {\n\t...Object.fromEntries([...BODY_SLIDERS, ...FACE_SLIDERS].map((k) => [k, 0.5])),\n\t...Object.fromEntries(ZERO_SLIDERS.map((k) => [k, 0]))\n} as Record<AvatarSlider | ZeroSlider, number>;\n\n/** Who a character is (RAT-698): the sculpt's genitals stay its own, the body and the pronouns follow\n *  this. A trans woman is a penis sculpt with a feminine body, a trans man a vulva with a masculine one. */\nexport const WHO = ['man', 'woman', 'trans'] as const;\nexport type Who = (typeof WHO)[number];\n\n/** His default and hers: the body follows the sculpt's own body (and who they are: a trans woman starts\n *  feminine on a penis, a trans man masculine on a vulva) until the sliders say otherwise. */\nexport function defaultAvatar(body: 'penis' | 'vulva', who?: Who): AvatarParams {\n\tconst feminine = who === 'trans' ? body === 'penis' : body === 'vulva';\n\treturn feminine\n\t\t? {\n\t\t\t\t...NEUTRAL,\n\t\t\t\tbuild: 0,\n\t\t\t\tbreasts: body === 'penis' ? 0.6 : 0.55,\n\t\t\t\thips: 0.55,\n\t\t\t\tface: 'oval',\n\t\t\t\thair: 'long',\n\t\t\t\thairCol: 'brown',\n\t\t\t\teyes: 'brown',\n\t\t\t\tpreset: 'none'\n\t\t\t}\n\t\t: {\n\t\t\t\t...NEUTRAL,\n\t\t\t\tbuild: 1,\n\t\t\t\tbreasts: body === 'vulva' ? 0.35 : 0.5,\n\t\t\t\tface: 'oval',\n\t\t\t\thair: 'short',\n\t\t\t\thairCol: 'dark',\n\t\t\t\teyes: 'brown',\n\t\t\t\tpreset: 'none'\n\t\t\t};\n}\n\nconst pick = <T extends string>(v: unknown, allowed: readonly T[], fallback: T): T =>\n\ttypeof v === 'string' && (allowed as readonly string[]).includes(v) ? (v as T) : fallback;\n\n/** Anything (client JSON, old rows) as a valid avatar, or null when there is none. Never throws. */\nexport function sanitizeAvatar(\n\tinput: unknown,\n\tbody: 'penis' | 'vulva',\n\twho?: Who\n): AvatarParams | null {\n\tif (!input || typeof input !== 'object' || Array.isArray(input)) return null;\n\tconst src = input as Record<string, unknown>;\n\tconst def = defaultAvatar(body, who);\n\tconst out = { ...def };\n\tfor (const k of [...BODY_SLIDERS, ...FACE_SLIDERS, ...ZERO_SLIDERS]) {\n\t\tconst v = src[k];\n\t\tconst x = typeof v === 'number' && Number.isFinite(v) ? v : def[k];\n\t\tout[k] = Math.round(Math.min(1, Math.max(0, x)) * 1000) / 1000;\n\t}\n\tout.face = pick(src.face, FACE_SHAPES, def.face);\n\tout.hair = pick(src.hair, HEAD_HAIR, def.hair);\n\tout.hairCol = pick(src.hairCol, HAIR_COLORS, def.hairCol);\n\tout.eyes = pick(src.eyes, EYE_COLORS, def.eyes);\n\tout.preset = pick(src.preset, PRESETS, def.preset);\n\treturn out;\n}\n"],"version":3}