{"version":3,"sources":["../src/index.ts","../src/utils.ts","../src/wilks.ts","../src/dots.ts","../src/schwartz-malone.ts","../src/glossbrenner.ts","../src/reshel.ts"],"sourcesContent":["export type { Formula, Gender, Mass } from './types'\n\nexport { wilks, wilks2020 } from './wilks'\nexport { dots } from './dots'\nexport { glossbrenner } from './glossbrenner'\nexport { schwartzmalone } from './schwartz-malone'\nexport { reshel } from './reshel'\n","const KG_POUNDS = 2.20462262\n\nexport const toKilograms = (pounds: number): number => pounds / KG_POUNDS\n\nexport const toPounds = (kilograms: number): number => kilograms * KG_POUNDS\n\nexport const format = (value: number): number => Math.round(value * 100) / 100\n\nexport const coefficient = (dividend: number, weight: number, params: number[]) => \n    dividend / params.reduce((acc, cur, index) => acc + cur * Math.pow(weight, index), 0)\n\nexport const clamp = (val: number, min: number, max: number): number => Math.min(Math.max(val, min), max)\n","import { Formula, Gender, Mass } from \"./types\"\nimport { coefficient, format, toKilograms } from \"./utils\"\n\ntype Coefficients = { [key in Gender]: [number, number, number, number, number, number] }\n\nconst COEFFICIENTS_ORIGINAL: Coefficients = {\n  male: [-216.0475144, 16.2606339, -0.002388645, -0.00113732, 7.01863e-6, -1.291e-8],\n  female: [594.31747775582, -27.23842536447, 0.82112226871, -0.00930733913, 4.731582e-5, -9.054e-8]\n}\n\nexport const wilksCoefficient = (weightKG: number, gender: Gender): number =>\n  coefficient(500, weightKG, COEFFICIENTS_ORIGINAL[gender])\n\nexport const wilks: Formula = (weight: number, total: number, gender: Gender, mass: Mass = 'kg'): number => {\n  const _total = mass === 'kg' ? total : toKilograms(total)\n  const _weight = mass === 'kg' ? weight : toKilograms(weight)\n\n  return format(_total * wilksCoefficient(_weight, gender))\n}\n\nconst COEFFICIENTS_2020: Coefficients = {\n  male: [47.46178854, 8.472061379, 0.07369410346, -0.001395833811, 7.07665973070743e-6, -1.208043364823153e-8],\n  female: [-125.4255398, 13.71219419, -0.03307250631, -0.001050400051, 9.38773881462799e-6, -2.3334613884954e-8]\n}\n\nexport const wilks2020Coefficient = (weightKG: number, gender: Gender): number =>\n  coefficient(600, weightKG, COEFFICIENTS_2020[gender])\n\nexport const wilks2020: Formula = (weight: number, total: number, gender: Gender, mass: Mass = 'kg'): number => {\n  const _total = mass === 'kg' ? total : toKilograms(total)\n  const _weight = mass === 'kg' ? weight : toKilograms(weight)\n\n  return format(_total * wilks2020Coefficient(_weight, gender))\n}\n","import { Formula, Gender, Mass } from \"./types\"\nimport { coefficient, format, toKilograms } from \"./utils\"\n\ntype Coefficients = { [key in Gender]: [number, number, number, number, number] }\n\nconst COEFFICIENTS: Coefficients = {\n  male: [-307.75076, 24.0900756, -0.1918759221, 7.391293e-4, -1.093e-6],\n  female: [-57.96288, 13.6175032, -0.1126655495, 5.158568e-4, -1.0706e-6],\n}\n\nexport const dotsCoefficient = (weightKG: number, gender: Gender): number =>\n  coefficient(500, weightKG, COEFFICIENTS[gender])\n\nexport const dots: Formula = (weight: number, total: number, gender: Gender, mass: Mass = 'kg'): number => {\n  const _total = mass === 'kg' ? total : toKilograms(total)\n  const _weight = mass === 'kg' ? weight : toKilograms(weight)\n\n  return format(_total * dotsCoefficient(_weight, gender))\n}\n","import { Formula, Gender, Mass } from \"./types\"\nimport { clamp, format, toKilograms } from \"./utils\"\n\n/**\nCalculates the Schwartz coefficient, used for men.\n\nThe Schwartz formula replaced the Hoffman formula.\nSchwartz was proposed around February 1971.\n\nThe exact formula was found in the magazine Powerlifting USA,\nVol.6, No.2, August 1982, on page 61. That text is reproduced below:\n\nComputerized Schwartz Formula...Dr. Lyle Schwartz has often been\nasked for a means by which the formula he has given Powerlifting can be\nprogrammed into a computer or a hand held calculator with sufficient\nmemory. To obtain the Schwartz Formula (SF) for bodyweights (BW)\n- between 40 and 126 kg, the expression is:\n  SF = 0.631926 exp(+01) - 0.262349 exp(+00) (BW) + 0.511550 exp(-02) (BW)^2 - 0.519738 exp(-04) (BW)^3 + 0.267626 exp(-06) (BW)^4 - 0.540132 exp(-09) (BW)^5 - 0.728875 exp(-13) (BW)^6.\n\nFor higher bodyweights, the following simple formulae are used:\n- for BW 126-136:\n  SF = 0.5210-0.0012 (BW - 125)\n- for BW 136-146:\n  SF = 0.5090-0011 (BW - 135)\n- for BW 146-156:\n  SF = 0.4980-0.0010 (BW - 145)\n- and for BW 156-166:\n  SF = 0.4880-0.0090 (BW - 156)\n\nSchwartz is quoted as saying about the formula's development,\n\n\"Since powerlifting was still a young sport in the early 1970s\nthere was uneven development in the three lifts on the part of most\nself-trained athletes. I compensated for such unevenness by creating\nartificial 'best' totals by adding together the current records in the\nindividual lifts. A 'best' total would have been achieved by that ideal\nlifter who could match the best performances to date in all three\npowerlifts. Then I fitted these data to an artificial curve and picked\noff numbers from the curve.\"\n */\nexport const schwartz = (weightKG: number): number => {\n  const _weight = clamp(weightKG, 40, 166)\n\n  if (_weight <= 126) {\n    const x0 = 0.631926e1;\n    const x1 = 0.262349e0 * _weight;\n    const x2 = 0.511550e-2 * Math.pow(_weight, 2);\n    const x3 = 0.519738e-4 * Math.pow(_weight, 3);\n    const x4 = 0.267626e-6 * Math.pow(_weight, 4);\n    const x5 = 0.540132e-9 * Math.pow(_weight, 5);\n    const x6 = 0.728875e-13 * Math.pow(_weight, 6);\n    return x0 - x1 + x2 - x3 + x4 - x5 - x6\n  } else if (_weight <= 136) {\n    return 0.5210 - 0.0012 * (_weight - 125.0)\n  } else if (_weight <= 146) {\n    return 0.5090 - 0.0011 * (_weight - 135.0)\n  } else if (_weight <= 156) {\n    return 0.4980 - 0.0010 * (_weight - 145.0)\n  } else {\n    return 0.4879 - 0.00088185 * (_weight - 155.0)\n  }\n}\n\n/**\n * Calculates the Malone coefficient, used for women.\n */\nexport const malone = (weightKG: number): number => {\n  const A = 106.011586323613;\n  const B = -1.293027130579051;\n  const C = 0.322935585328304;\n\n  const _weight = Math.max(weightKG, 29.24)\n\n  return A * Math.pow(_weight, B) + C\n}\n\nexport const schwartzmalone: Formula = (weight: number, total: number, gender: Gender, mass: Mass = 'kg'): number => {\n  const _total = mass === 'kg' ? total : toKilograms(total)\n  const _weight = mass === 'kg' ? weight : toKilograms(weight)\n\n  const _coefficient = gender === 'male'\n    ? schwartz(_weight)\n    : malone(_weight)\n\n  return format(_total * _coefficient)\n}","import { malone, schwartz } from \"./schwartz-malone\"\nimport { Formula, Gender, Mass } from \"./types\"\nimport { format, toKilograms } from \"./utils\"\nimport { wilksCoefficient } from \"./wilks\"\n\nexport const glossbrennerMen = (bodyweightkg: number): number => {\n  // Glossbrenner is defined piecewise.\n  if (bodyweightkg < 153.05) {\n      return (schwartz(bodyweightkg) + wilksCoefficient(bodyweightkg, 'male')) / 2.0\n  } else {\n    // Linear coefficients found by fitting to a table.\n    const A = -0.000821668402557;\n    const B = 0.676940740094416;\n    return (schwartz(bodyweightkg) + A * bodyweightkg + B) / 2.0\n  }\n}\n\nexport const glossbrennerWoman = (bodyweightkg: number): number => {\n  // Glossbrenner is defined piecewise.\n  if (bodyweightkg < 106.3) {\n      return (malone(bodyweightkg) + wilksCoefficient(bodyweightkg, 'female')) / 2.0\n  } else {\n      // Linear coefficients found by fitting to a table.\n      const A = -0.000313738002024;\n      const B = 0.852664892884785;\n      return (malone(bodyweightkg) + A * bodyweightkg + B) / 2.0\n  }\n}\n\n/**\n * Glossbrenner is the average of two older systems, Schwartz-Malone and Wilks, with a piecewise linear section\n * \n * This points system is most often used by GPC affiliates.\n */\nexport const glossbrenner: Formula = (weight: number, total: number, gender: Gender, mass: Mass = 'kg'): number => {\n  const _total = mass === 'kg' ? total : toKilograms(total)\n  const _weight = mass === 'kg' ? weight : toKilograms(weight)\n\n  const _coefficient = gender === 'male'\n    ? glossbrennerMen(_weight)\n    : glossbrennerWoman(_weight)\n\n  return format(_total * _coefficient)\n}","import { Formula, Gender, Mass } from \"./types\"\nimport { clamp, format, toKilograms } from \"./utils\"\n\n/**\n *  TODO: Improve the accuracy of this implementation. Shared with OpenLifter.\n *  This implementation uses a curve of best fit from GNUPlot.\n *  At worst, it is off by about six Reshel points (0.01), affecting middleweights.\n */\nexport const reshelCoefficientMen = (weightKg: number): number => {\n    const A = 23740.8329088123;\n    const B = -9.75618720662844;\n    const C = 0.787990994925928;\n    const D = -2.68445158813578;\n\n    const _weight = clamp(weightKg, 50, 174.75);\n    return A * (_weight + B) ** D + C\n}\n\nexport const reshelCoefficientWomen = (weightKg: number): number => {\n    const A = 239.894659799145;\n    const B = -20.5105859285582;\n    const C = 1.16052601684125;\n    const D = -1.61417872668708;\n\n    const _weight = clamp(weightKg, 40, 118.75);\n    return A * (_weight + B) ** D + C\n}\n\n/**\n * Calculates Reshel points.\n * \n * Reshel points are published only as [heavily-rounded coefficient tables](http://www.irondawg.com/reshel_formula.htm)\n * separately for men and women.\n */\nexport const reshel: Formula = (weight: number, total: number, gender: Gender, mass: Mass = 'kg'): number => {\n  const _total = mass === 'kg' ? total : toKilograms(total)\n  const _weight = mass === 'kg' ? weight : toKilograms(weight)\n\n  const _coefficient = gender === 'male'\n    ? reshelCoefficientMen(_weight)\n    : reshelCoefficientWomen(_weight)\n\n  return format(_total * _coefficient)\n}"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,UAAAE,EAAA,iBAAAC,EAAA,WAAAC,EAAA,mBAAAC,EAAA,UAAAC,EAAA,cAAAC,IAAA,eAAAC,EAAAR,GCAA,IAAMS,EAAY,WAELC,EAAeC,GAA2BA,EAASF,EAIzD,IAAMG,EAAUC,GAA0B,KAAK,MAAMA,EAAQ,GAAG,EAAI,IAE9DC,EAAc,CAACC,EAAkBC,EAAgBC,IAC1DF,EAAWE,EAAO,OAAO,CAACC,EAAKC,EAAKC,IAAUF,EAAMC,EAAM,KAAK,IAAIH,EAAQI,CAAK,EAAG,CAAC,EAE3EC,EAAQ,CAACC,EAAaC,EAAaC,IAAwB,KAAK,IAAI,KAAK,IAAIF,EAAKC,CAAG,EAAGC,CAAG,ECNxG,IAAMC,EAAsC,CAC1C,KAAM,CAAC,aAAc,WAAY,YAAc,WAAa,WAAY,SAAS,EAC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CAEjE,GAAIA,EAAe,MACf,OAAQM,EAAON,CAAY,EAAIE,EAAiBF,EAAc,QAAQ,GAAK,EACxE,CAEH,IAAMG,EAAI,kBACJC,EAAI,iBACV,OAAQE,EAAON,CAAY,EAAIG,EAAIH,EAAeI,GAAK,CAC3D,CACF,EAOaG,EAAwB,CAACC,EAAgBC,EAAeC,EAAgBC,EAAa,OAAiB,CACjH,IAAMC,EAASD,IAAS,KAAOF,EAAQI,EAAYJ,CAAK,EAClDK,EAAUH,IAAS,KAAOH,EAASK,EAAYL,CAAM,EAErDO,EAAeL,IAAW,OAC5BX,EAAgBe,CAAO,EACvBT,EAAkBS,CAAO,EAE7B,OAAOE,EAAOJ,EAASG,CAAY,CACrC,ECnCO,IAAME,EAAwBC,GAA6B,CAC9D,IAAMC,EAAI,iBACJC,EAAI,kBACJC,EAAI,iBACJC,EAAI,kBAEJC,EAAUC,EAAMN,EAAU,GAAI,MAAM,EAC1C,OAAOC,GAAKI,EAAUH,IAAME,EAAID,CACpC,EAEaI,EAA0BP,GAA6B,CAChE,IAAMC,EAAI,iBACJC,EAAI,kBACJC,EAAI,iBACJC,EAAI,kBAEJC,EAAUC,EAAMN,EAAU,GAAI,MAAM,EAC1C,OAAOC,GAAKI,EAAUH,IAAME,EAAID,CACpC,EAQaK,EAAkB,CAACC,EAAgBC,EAAeC,EAAgBC,EAAa,OAAiB,CAC3G,IAAMC,EAASD,IAAS,KAAOF,EAAQI,EAAYJ,CAAK,EAClDL,EAAUO,IAAS,KAAOH,EAASK,EAAYL,CAAM,EAErDM,EAAeJ,IAAW,OAC5BZ,EAAqBM,CAAO,EAC5BE,EAAuBF,CAAO,EAElC,OAAOW,EAAOH,EAASE,CAAY,CACrC","names":["src_exports","__export","dots","glossbrenner","reshel","schwartzmalone","wilks","wilks2020","__toCommonJS","KG_POUNDS","toKilograms","pounds","format","value","coefficient","dividend","weight","params","acc","cur","index","clamp","val","min","max","COEFFICIENTS_ORIGINAL","wilksCoefficient","weightKG","gender","coefficient","wilks","weight","total","mass","_total","toKilograms","_weight","format","COEFFICIENTS_2020","wilks2020Coefficient","wilks2020","COEFFICIENTS","dotsCoefficient","weightKG","gender","coefficient","dots","weight","total","mass","_total","toKilograms","_weight","format","schwartz","weightKG","_weight","clamp","x1","x2","x3","x4","x5","x6","malone","A","B","C","schwartzmalone","weight","total","gender","mass","_total","toKilograms","_coefficient","format","glossbrennerMen","bodyweightkg","schwartz","wilksCoefficient","A","B","glossbrennerWoman","malone","glossbrenner","weight","total","gender","mass","_total","toKilograms","_weight","_coefficient","format","reshelCoefficientMen","weightKg","A","B","C","D","_weight","clamp","reshelCoefficientWomen","reshel","weight","total","gender","mass","_total","toKilograms","_coefficient","format"]}