{"version":3,"file":"use_effective_date_as_planned_date_controller-DQ18-3iZ.js","sources":["../../app/javascript/entrypoints/controllers/use_effective_date_as_planned_date_controller.js"],"sourcesContent":["import { Controller } from \"@hotwired/stimulus\";\n\nexport default class extends Controller {\n static targets = [\n \"plannedStart\",\n \"plannedEnd\",\n \"effectiveStart\",\n \"effectiveEnd\",\n ];\n\n connect() {\n this.initializePlannedDatesWithEffectiveDates();\n }\n\n initializePlannedDatesWithEffectiveDates() {\n const plannedStartDate = this.plannedStartTarget.value;\n const plannedEndDate = this.plannedEndTarget.value;\n const effectiveStartDate = this.effectiveStartTarget.value;\n const effectiveEndDate = this.effectiveEndTarget.value;\n\n if (\n !(plannedStartDate && plannedEndDate) &&\n effectiveStartDate &&\n effectiveEndDate\n ) {\n this.plannedStartTarget.value = this.effectiveStartTarget.value;\n this.plannedEndTarget.value = this.effectiveEndTarget.value;\n }\n\n if (plannedStartDate && !plannedEndDate) {\n this.plannedEndTarget.value = this.plannedStartTarget.value;\n }\n\n if (effectiveStartDate && !effectiveEndDate) {\n this.effectiveEndTarget.value = this.effectiveStartTarget.value;\n }\n\n if (new Date(effectiveStartDate) > new Date(effectiveEndDate)) {\n this.effectiveEndTarget.value = this.effectiveStartTarget.value;\n }\n\n if (new Date(plannedStartDate) > new Date(plannedEndDate)) {\n this.plannedEndTarget.value = this.plannedStartTarget.value;\n }\n }\n\n setEffectiveDateSameAsPlannedDate() {\n this.effectiveStartTarget.value = this.plannedStartTarget.value;\n this.effectiveEndTarget.value = this.plannedEndTarget.value;\n }\n}\n"],"names":["use_effective_date_as_planned_date_controller","Controller","plannedStartDate","plannedEndDate","effectiveStartDate","effectiveEndDate","__publicField"],"mappings":"+MAEe,MAAKA,UAASC,CAAW,CAQtC,SAAU,CACR,KAAK,yCAAwC,CAC9C,CAED,0CAA2C,CACzC,MAAMC,EAAmB,KAAK,mBAAmB,MAC3CC,EAAiB,KAAK,iBAAiB,MACvCC,EAAqB,KAAK,qBAAqB,MAC/CC,EAAmB,KAAK,mBAAmB,MAG/C,EAAEH,GAAoBC,IACtBC,GACAC,IAEA,KAAK,mBAAmB,MAAQ,KAAK,qBAAqB,MAC1D,KAAK,iBAAiB,MAAQ,KAAK,mBAAmB,OAGpDH,GAAoB,CAACC,IACvB,KAAK,iBAAiB,MAAQ,KAAK,mBAAmB,OAGpDC,GAAsB,CAACC,IACzB,KAAK,mBAAmB,MAAQ,KAAK,qBAAqB,OAGxD,IAAI,KAAKD,CAAkB,EAAI,IAAI,KAAKC,CAAgB,IAC1D,KAAK,mBAAmB,MAAQ,KAAK,qBAAqB,OAGxD,IAAI,KAAKH,CAAgB,EAAI,IAAI,KAAKC,CAAc,IACtD,KAAK,iBAAiB,MAAQ,KAAK,mBAAmB,MAEzD,CAED,mCAAoC,CAClC,KAAK,qBAAqB,MAAQ,KAAK,mBAAmB,MAC1D,KAAK,mBAAmB,MAAQ,KAAK,iBAAiB,KACvD,CACH,CA/CEG,EADkBN,EACX,UAAU,CACf,eACA,aACA,iBACA,cACJ"}