import{r as i,d as t,h as s}from"./p-03169580.js";import{t as e}from"./p-5a032a89.js";import{s as o}from"./p-e1ee6da1.js";import"./p-4cb16df5.js";import"./p-f44f0a67.js";import"./p-59c95c5f.js";import"./p-3775d1fc.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-5717491f.js";import"./p-de14d315.js";const a="";let n=class{constructor(s){i(this,s);this.fireenjinFetch=t(this,"fireenjinFetch",7);this.fireenjinSubmit=t(this,"fireenjinSubmit",7);this.forceResize=t(this,"forceResize",7);this.loading=false;this.signed=false}async onChange(i){var t;if(((t=i===null||i===void 0?void 0:i.target)===null||t===void 0?void 0:t.name)==="signature"){const t=await i.target.toDataURL();if(t.length<=10){alert("Signature is required to submit!");return}this.loading=true;this.fireenjinSubmit.emit({endpoint:"signContract",data:{jobId:this.jobId,signature:await i.target.toDataURL(),templateId:this.templateId}})}}async onSuccess(i){var t,s,e,o;if(((t=i===null||i===void 0?void 0:i.detail)===null||t===void 0?void 0:t.endpoint)==="signContract"){this.presentToast();this.loading=false;this.signed=true}else if(((s=i.detail)===null||s===void 0?void 0:s.endpoint)==="findTemplate"){this.template=((o=(e=i.detail)===null||e===void 0?void 0:e.data)===null||o===void 0?void 0:o.template)?i.detail.data.template:null}}async fetchJob(){if(!this.jobId)return;this.fireenjinFetch.emit({endpoint:"findJob",params:{id:this.jobId,withPayments:false,withUsers:true,withSites:false,withPayModel:false,withPhotos:false,withEfiles:false,withPayables:false,withReadings:false}})}async presentToast(){const i=await e.create({message:`File(s) added successfully to Efile!`,duration:2e3});i.present()}componentDidLoad(){{this.fetchJob();setTimeout((()=>{this.forceResize.emit({})}),1e3)}}render(){var i;return[s("ion-content",{class:"ion-padding"},s("floodteam-title-bar",{back:((i=o===null||o===void 0?void 0:o.session)===null||i===void 0?void 0:i.uid)?`/jobs/${this.jobId}`:"/"},"E-Sign"),this.signed?s("div",{style:{width:"90%",maxWidth:"500px",margin:"0 auto"}},s("ion-icon",{name:"checkmark-circle",color:"success",style:{height:"150px",width:"150px",display:"block",margin:"30px auto"}}),s("h1",null,"Signature Submitted!"),s("p",null,"Thank you for your time, you can now close this browser tab.")):s("div",{style:{position:"relative"},class:{"is-loading":this.loading}},s("floodteam-template",{style:{padding:"60px 2em"},disablePositioning:true,templateId:this.templateId,data:{timestamp:(new Date).toISOString(),job:o.job,user:o===null||o===void 0?void 0:o.profile}}),s("floodteam-signature-pad",{ref:i=>this.signaturePadEl=i}))),s("floodteam-navigation-footer",null)]}};n.style=a;export{n as app_sign};
//# sourceMappingURL=p-c19ce370.entry.js.map