import{T as S,i as R}from"./chunk-FPDC5TRD.js";import{H as w,Hb as C,J as v,M as l,b as g,d as f}from"./chunk-VEXJN5D7.js";import{f as d}from"./chunk-4IDNTCH7.js";var s=class{constructor(i,x){this.id="",this.title="",this.note="",this.events=[],this.status=o.Created,this.priority=U.Standard,this.scheduled_Utc=new Date,this.created_Utc=new Date,this.lastUpdated_Utc=new Date,this.completing=!1,this.creator=i,this.recipient=x}};var D=(function(r){return r.General="General",r.Appointment="Appointment",r})(D||{}),o=(function(r){return r.Created="Created",r.Completed="Completed",r})(o||{}),U=(function(r){return r.Standard="Standard",r.Critical="Critical",r})(U||{});var $=(()=>{let i=class i{constructor(e,t){this.http=e,this.storageService=t,this.managingReminder=!1,this.reminderSaved=new f}manageReminder(e,t,n){this.reminderToManage=e,e!=null?this.reminderToManage=e:this.reminderToManage=new s(t,n),this.managingReminder=!0}stopManagingReminder(){window.clearTimeout(this.managingReminderTimer),this.managingReminder=!1,this.reminderSaved.next(),this.managingReminderTimer=window.setTimeout(()=>{this.reminderToManage=void 0},250)}getLastRemindersRetrieval(e){let t=localStorage.getItem(`u_${e}_rr`);if(t!=null)try{return parseInt(t)}catch{return}}updateLastRemindersRetrieval(e){let t=new Date;localStorage.setItem(`u_${e}_rr`,`${t.getTime()}`)}syncRemindersForUser(e,t=!1){let n="{{api}}/reminders/latest";if(!t){let a=this.getLastRemindersRetrieval(e);if(a!=null){let c=new Date().getTime()-a;n=n+`/${c}`}}return this.http.get(n).pipe(w(a=>d(this,null,function*(){yield this.storageService.remoteStoreReminders(a),this.updateLastRemindersRetrieval(e)})))}getReminders(e){return new g(t=>{this.storageService.getRemindersForUser(e).then(n=>{t.next(n),t.complete()}).catch(()=>{t.error(),t.complete()})})}createReminder(e,t,n,a,m,c,h,p){let u;h!=null&&p!=null&&(u={referenceId:h,type:p,content:""});let I={id:R(),creator:e,recipient:t,title:n,note:a,events:[],status:o.Created,priority:m,scheduled_Utc:c,created_Utc:new Date,lastUpdated_Utc:new Date,reference:u,completing:!1};this.storeReminder(I)}storeReminder(e){return d(this,null,function*(){yield this.storageService.storeReminder(e)})}};i.\u0275fac=function(t){return new(t||i)(l(C),l(S))},i.\u0275prov=v({token:i,factory:i.\u0275fac,providedIn:"root"});let r=i;return r})();export{D as a,o as b,U as c,$ as d};
