{"ast":null,"code":"import { CommonModule } from '@angular/common';\nimport { ReactiveFormsModule, Validators } from '@angular/forms';\nimport { FormsModule } from '@angular/forms';\nimport * as i0 from \"@angular/core\";\nimport * as i1 from \"@angular/forms\";\nimport * as i2 from \"../services/client.service\";\nimport * as i3 from \"../services/scheduling.service\";\nimport * as i4 from \"@angular/common\";\nfunction SchedulingComponent_div_10_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 7)(1, \"label\");\n    i0.ɵɵtext(2, \"Hora di\\u00E1ria (HH:mm): \");\n    i0.ɵɵelement(3, \"input\", 8);\n    i0.ɵɵelementEnd()();\n  }\n}\nfunction SchedulingComponent_div_18_Template(rf, ctx) {\n  if (rf & 1) {\n    i0.ɵɵelementStart(0, \"div\", 7);\n    i0.ɵɵtext(1, \"Enviando\\u2026\");\n    i0.ɵɵelementEnd();\n  }\n}\nexport let SchedulingComponent = /*#__PURE__*/(() => {\n  class SchedulingComponent {\n    constructor(fb, clients, api) {\n      this.fb = fb;\n      this.clients = clients;\n      this.api = api;\n      this.selectedClientId = '';\n      this.loading = false;\n      this.form = this.fb.group({\n        zeroPatio: [false],\n        hour: ['04:00', [Validators.required, Validators.pattern(/^([01]\\d|2[0-3]):[0-5]\\d$/)]]\n      });\n    }\n    ngOnInit() {\n      this.clients.selectedClient$.subscribe(cid => {\n        this.selectedClientId = cid || '';\n        if (cid) {\n          // opcional: carregar agendamento já salvo\n          this.api.getForCustomer(Number(cid)).subscribe({\n            next: cfg => {\n              if (cfg) {\n                this.form.patchValue({\n                  zeroPatio: !!cfg.zero_patio,\n                  hour: cfg.hour || '04:00'\n                });\n              }\n            }\n          });\n        }\n      });\n    }\n    save() {\n      if (!this.selectedClientId) {\n        alert('Selecione um cliente.');\n        return;\n      }\n      if (this.form.invalid) {\n        alert('Hora inválida.');\n        return;\n      }\n      this.loading = true;\n      this.api.createOrUpdate({\n        id_customer: Number(this.selectedClientId),\n        hour: this.form.value.hour,\n        zero_patio: !!this.form.value.zeroPatio\n      }).subscribe({\n        next: () => {\n          this.loading = false;\n          alert('Agendamento salvo com sucesso.');\n        },\n        error: e => {\n          this.loading = false;\n          alert('Erro ao salvar agendamento.');\n          console.error(e);\n        }\n      });\n    }\n    sendResetNow() {\n      if (!this.selectedClientId) {\n        alert('Selecione um cliente.');\n        return;\n      }\n      const key = `${this.selectedClientId}-1`; // id_customer - id_park (ajuste se necessário)\n      this.loading = true;\n      this.api.resetGround(key).subscribe({\n        next: resp => {\n          this.loading = false;\n          alert('Reset enviado para todos os pisos.');\n          console.log(resp);\n        },\n        error: e => {\n          this.loading = false;\n          alert('Erro ao enviar reset.');\n          console.error(e);\n        }\n      });\n    }\n    static #_ = this.ɵfac = function SchedulingComponent_Factory(t) {\n      return new (t || SchedulingComponent)(i0.ɵɵdirectiveInject(i1.FormBuilder), i0.ɵɵdirectiveInject(i2.ClientService), i0.ɵɵdirectiveInject(i3.SchedulingService));\n    };\n    static #_2 = this.ɵcmp = /*@__PURE__*/i0.ɵɵdefineComponent({\n      type: SchedulingComponent,\n      selectors: [[\"app-scheduling\"]],\n      standalone: true,\n      features: [i0.ɵɵStandaloneFeature],\n      decls: 19,\n      vars: 6,\n      consts: [[2, \"margin-bottom\", \"12px\"], [3, \"formGroup\"], [\"type\", \"checkbox\", \"formControlName\", \"zeroPatio\"], [\"style\", \"margin-top: 12px;\", 4, \"ngIf\"], [2, \"margin-top\", \"16px\"], [\"type\", \"button\", 3, \"click\", \"disabled\"], [2, \"margin\", \"20px 0\"], [2, \"margin-top\", \"12px\"], [\"type\", \"time\", \"formControlName\", \"hour\"]],\n      template: function SchedulingComponent_Template(rf, ctx) {\n        if (rf & 1) {\n          i0.ɵɵelementStart(0, \"h2\");\n          i0.ɵɵtext(1, \"Agendamento\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(2, \"div\", 0)(3, \"strong\");\n          i0.ɵɵtext(4, \"Cliente:\");\n          i0.ɵɵelementEnd();\n          i0.ɵɵtext(5);\n          i0.ɵɵelementEnd();\n          i0.ɵɵelementStart(6, \"form\", 1)(7, \"label\");\n          i0.ɵɵelement(8, \"input\", 2);\n          i0.ɵɵtext(9, \" Zerar p\\u00E1tio diariamente? \");\n          i0.ɵɵelementEnd();\n          i0.ɵɵtemplate(10, SchedulingComponent_div_10_Template, 4, 0, \"div\", 3);\n          i0.ɵɵelementStart(11, \"div\", 4)(12, \"button\", 5);\n          i0.ɵɵlistener(\"click\", function SchedulingComponent_Template_button_click_12_listener() {\n            return ctx.save();\n          });\n          i0.ɵɵtext(13, \"Salvar\");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵelement(14, \"hr\", 6);\n          i0.ɵɵelementStart(15, \"div\")(16, \"button\", 5);\n          i0.ɵɵlistener(\"click\", function SchedulingComponent_Template_button_click_16_listener() {\n            return ctx.sendResetNow();\n          });\n          i0.ɵɵtext(17, \" Reset agora (todos os pisos) \");\n          i0.ɵɵelementEnd()();\n          i0.ɵɵtemplate(18, SchedulingComponent_div_18_Template, 2, 0, \"div\", 3);\n          i0.ɵɵelementEnd();\n        }\n        if (rf & 2) {\n          i0.ɵɵadvance(5);\n          i0.ɵɵtextInterpolate1(\" \", ctx.selectedClientId || \"\\u2014\", \"\\n\");\n          i0.ɵɵadvance();\n          i0.ɵɵproperty(\"formGroup\", ctx.form);\n          i0.ɵɵadvance(4);\n          i0.ɵɵproperty(\"ngIf\", ctx.form.controls.zeroPatio.value);\n          i0.ɵɵadvance(2);\n          i0.ɵɵproperty(\"disabled\", ctx.loading || !ctx.selectedClientId);\n          i0.ɵɵadvance(4);\n          i0.ɵɵproperty(\"disabled\", ctx.loading || !ctx.selectedClientId);\n          i0.ɵɵadvance(2);\n          i0.ɵɵproperty(\"ngIf\", ctx.loading);\n        }\n      },\n      dependencies: [CommonModule, i4.NgIf, ReactiveFormsModule, i1.ɵNgNoValidate, i1.DefaultValueAccessor, i1.CheckboxControlValueAccessor, i1.NgControlStatus, i1.NgControlStatusGroup, i1.FormGroupDirective, i1.FormControlName, FormsModule],\n      styles: [\"h2[_ngcontent-%COMP%]{margin:8px 0 16px}label[_ngcontent-%COMP%]{cursor:pointer}button[_ngcontent-%COMP%]{padding:6px 10px}\"]\n    });\n  }\n  return SchedulingComponent;\n})();","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}