{"version":3,"file":"leaseTermEditingLabel-fbed8b7b.js","sources":["../../../app/frontend/assets/leaseTermEditingLabel.js"],"sourcesContent":["import moment from \"moment\";\nimport _ from \"lodash\";\n\nexport default function (\n state,\n date,\n commencedDate,\n expiredDate,\n subleaseExpirationDate,\n validContractDates,\n) {\n const displayableExpiredDate = subleaseExpirationDate || expiredDate;\n\n if (state === \"closed\") {\n if (commencedDate && displayableExpiredDate && validContractDates) {\n const diff = moment(displayableExpiredDate)\n .add(1, \"days\")\n .diff(commencedDate, \"months\");\n const diffYears = _.floor(diff / 12);\n const diffMonths = diff % 12;\n const yearsMonthsLabel =\n diffMonths > 0\n ? `${diffYears} Yrs, ${diffMonths} Mths`\n : `${diffYears} Yrs`;\n\n return `${executionDateLabel(date)}; Term: ${shortDate(\n commencedDate,\n )} - ${shortDate(\n displayableExpiredDate,\n )}: ${diff} Mths (${yearsMonthsLabel})`;\n } else if (commencedDate && displayableExpiredDate) {\n return `${executionDateLabel(date)}; Term: ${shortDate(\n commencedDate,\n )} - ${shortDate(displayableExpiredDate)}`;\n } else if (commencedDate && !displayableExpiredDate) {\n return `${executionDateLabel(date)}; Term: ${shortDate(\n commencedDate,\n )} - ???`;\n } else if (!commencedDate && displayableExpiredDate) {\n return `${executionDateLabel(date)}; Term: ??? - ${shortDate(\n displayableExpiredDate,\n )}`;\n } else if (date) {\n return `${executionDateLabel(date)}`;\n } else {\n return \"Closed, dates unknown\";\n }\n } else {\n return null;\n }\n}\n\nfunction executionDateLabel(rawDate) {\n if (rawDate) {\n return `Executed: ${shortDate(rawDate)}`;\n } else {\n return \"Closed ???\";\n }\n}\n\nfunction shortDate(rawDate) {\n return moment(rawDate).format(\"M/D/YYYY\");\n}\n"],"names":["leaseTermEditingLabel","state","date","commencedDate","expiredDate","subleaseExpirationDate","validContractDates","displayableExpiredDate","diff","moment","diffYears","_","diffMonths","yearsMonthsLabel","executionDateLabel","shortDate","rawDate"],"mappings":"kFAGe,SAAQA,EACrBC,EACAC,EACAC,EACAC,EACAC,EACAC,EACA,CACA,MAAMC,EAAyBF,GAA0BD,EAEzD,GAAIH,IAAU,SACZ,GAAIE,GAAiBI,GAA0BD,EAAoB,CACjE,MAAME,EAAOC,EAAOF,CAAsB,EACvC,IAAI,EAAG,MAAM,EACb,KAAKJ,EAAe,QAAQ,EACzBO,EAAYC,EAAE,MAAMH,EAAO,EAAE,EAC7BI,EAAaJ,EAAO,GACpBK,EACJD,EAAa,EACT,GAAGF,CAAS,SAASE,CAAU,QAC/B,GAAGF,CAAS,OAElB,MAAO,GAAGI,EAAmBZ,CAAI,CAAC,WAAWa,EAC3CZ,CACD,CAAA,MAAMY,EACLR,CACD,CAAA,KAAKC,CAAI,UAAUK,CAAgB,GAC1C,KAAW,QAAIV,GAAiBI,EACnB,GAAGO,EAAmBZ,CAAI,CAAC,WAAWa,EAC3CZ,CACD,CAAA,MAAMY,EAAUR,CAAsB,CAAC,GAC/BJ,GAAiB,CAACI,EACpB,GAAGO,EAAmBZ,CAAI,CAAC,WAAWa,EAC3CZ,CACD,CAAA,SACQ,CAACA,GAAiBI,EACpB,GAAGO,EAAmBZ,CAAI,CAAC,iBAAiBa,EACjDR,CACD,CAAA,GACQL,EACF,GAAGY,EAAmBZ,CAAI,CAAC,GAE3B,4BAGT,QAAO,IAEX,CAEA,SAASY,EAAmBE,EAAS,CACnC,OAAIA,EACK,aAAaD,EAAUC,CAAO,CAAC,GAE/B,YAEX,CAEA,SAASD,EAAUC,EAAS,CAC1B,OAAOP,EAAOO,CAAO,EAAE,OAAO,UAAU,CAC1C"}