{"version":3,"file":"roi_calculator_controller-Bc9_uvOm.js","names":[],"sources":["../../../app/javascript/entrypoints/site_controllers/roi_calculator_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\"\n\n// Re-entry cost calculator: yearly cost of double data entry and how many weeks the\n// express automation takes to pay for itself. Working weeks and the share of time recovered\n// come from the server (Diagnostics::Simulation), like the full simulator.\nexport default class extends Controller {\n static targets = [\"people\", \"hours\", \"rate\", \"peopleOut\", \"hoursOut\", \"rateOut\", \"yearly\", \"payback\"]\n static values = { price: Number, weeks: { type: Number, default: 47 }, share: { type: Number, default: 0.6 }, hourUnit: String, weekUnit: String }\n\n connect() {\n this.update()\n }\n\n update() {\n const people = Number(this.peopleTarget.value)\n const hours = Number(this.hoursTarget.value)\n const rate = Number(this.rateTarget.value)\n const weekly = people * hours * rate\n\n this.peopleOutTarget.textContent = people\n this.hoursOutTarget.textContent = `${hours} ${this.hourUnitValue}`\n this.rateOutTarget.textContent = this.euros(rate)\n this.yearlyTarget.textContent = this.euros(weekly * this.weeksValue)\n this.paybackTarget.textContent = `${Math.max(1, Math.ceil(this.priceValue / (weekly * this.shareValue)))} ${this.weekUnitValue}`\n }\n\n euros(amount) {\n return new Intl.NumberFormat(document.documentElement.lang, { style: \"currency\", currency: \"EUR\", maximumFractionDigits: 0 }).format(amount)\n }\n}\n"],"mappings":"4GAKA,EAAA,cAA6B,CAAW,CACtC,OAAO,QAAU,CAAC,SAAU,QAAS,OAAQ,YAAa,WAAY,UAAW,SAAU,UAAU,CACrG,OAAO,OAAS,CAAE,MAAO,OAAQ,MAAO,CAAE,KAAM,OAAQ,QAAS,GAAI,CAAE,MAAO,CAAE,KAAM,OAAQ,QAAS,GAAK,CAAE,SAAU,OAAQ,SAAU,OAAQ,CAElJ,SAAU,CACR,KAAK,QAAQ,CAGf,QAAS,CACP,IAAM,EAAS,OAAO,KAAK,aAAa,MAAM,CACxC,EAAQ,OAAO,KAAK,YAAY,MAAM,CACtC,EAAO,OAAO,KAAK,WAAW,MAAM,CACpC,EAAS,EAAS,EAAQ,EAEhC,KAAK,gBAAgB,YAAc,EACnC,KAAK,eAAe,YAAc,GAAG,EAAM,GAAG,KAAK,gBACnD,KAAK,cAAc,YAAc,KAAK,MAAM,EAAK,CACjD,KAAK,aAAa,YAAc,KAAK,MAAM,EAAS,KAAK,WAAW,CACpE,KAAK,cAAc,YAAc,GAAG,KAAK,IAAI,EAAG,KAAK,KAAK,KAAK,YAAc,EAAS,KAAK,YAAY,CAAC,CAAC,GAAG,KAAK,gBAGnH,MAAM,EAAQ,CACZ,OAAO,IAAI,KAAK,aAAa,SAAS,gBAAgB,KAAM,CAAE,MAAO,WAAY,SAAU,MAAO,sBAAuB,EAAG,CAAC,CAAC,OAAO,EAAO"}