import{a as h}from"./chunk-ACEI6MBA.js";import{a as m,b}from"./chunk-2KOUG6TA.js";import{e as S}from"./chunk-VBOPLLOX.js";import{d as y,e as g,q as v}from"./chunk-DYX6BCMX.js";import{k as s}from"./chunk-SEQSEAFF.js";import{Hb as p,J as d,M as o}from"./chunk-ZH46IRAU.js";import{f as n}from"./chunk-4IDNTCH7.js";var w=(()=>{let r=class r{constructor(t,e,a,l,i,c){this.http=t,this.storageService=e,this.logService=a,this.contentService=l,this.appointmentService=i,this.opportunityService=c,this.migrateAppointments()}appointmentToOpportunity(t){let e=new y;return e.id=t.id,e.jobId=t.jobId,e.job=s(t.job),e.assignedTo=s(t.assignedTo),e.customer=s(t.customer),e.property=s(t.property),e.opportunityNotes=t.opportunityNotes,e.opportunityTypes=t.opportunityTypes,e.opportunityPlumbingIssues=t.opportunityPlumbingIssues,e.opportunityCouponCode=t.opportunityCouponCode,e.isEmergency=t.isEmergency,e.status=g[t.status],e.statusDescription=t.statusDescription,e.availablePromotions=s(t.availablePromotions)??[],e.availableFixtures=s(t.availableFixtures)??[],e.availableEntities=s(t.availableEntities)??[],e.availableSkus=s(t.availableSkus)??[],e.availablePaymentSettings=s(t.availablePaymentSettings)??[],e.availableDocuments=s(t.availableDocuments)??[],e.availableDispositionStatuses=s(t.availableDispositionStatuses)??[],e.availableShops=s(t.availableShops)??[],e.scheduled_Utc=t.scheduled_Utc,e.created_Utc=t.created_Utc,e.accepted=t.accepted,e.accepted_Utc=t.accepted_Utc,e.assigned_Utc=t.assigned_Utc,e.dispositionStatus=t.dispositionStatus,e.selectedShopId=t.selectedShopId,e.preferredInstallDate=t.preferredInstallDate,e.customerNeeds=s(t.customerNeeds)??{},e.paymentSetting=s(t.paymentSetting),e.payments=s(t.payments)??[],e.lenders=s(t.lenders)??[],e.price=s(t.price),e.customPrice=s(t.customPrice),e.documents=s(t.documents)??[],e}migrateAppointments(){return n(this,null,function*(){let t=yield this.storageService.getAppointments(999),e=[];for(var a=0,l=t.length;a<l;a++){let i=t[a];if(i.migratedToOpportunity_Utc==null)try{let c=this.appointmentToOpportunity(i);yield this.storageService.storeOpportunity(c),i.migratedToOpportunity_Utc=new Date,yield this.storageService.storeAppointment(i),e.push({appointmentId:i.id,migrated:!0,message:void 0})}catch(c){e.push({appointmentId:i.id,migrated:!1,message:JSON.stringify(c)})}}return e})}ngOnDestroy(){}};r.\u0275fac=function(e){return new(e||r)(o(p),o(v),o(m),o(S),o(h),o(b))},r.\u0275prov=d({token:r,factory:r.\u0275fac});let u=r;return u})();export{w as a};
