import{r as t,d as i,B as s,h as o}from"./p-f8363b1b.js";import{t as e}from"./p-510e3bc9.js";import{s as n}from"./p-c78d1e1b.js";import"./p-d2ac57a0.js";import"./p-f44f0a67.js";import"./p-3775d1fc.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-5717491f.js";import"./p-de14d315.js";const a=class{constructor(s){t(this,s),this.fireenjinSubmit=i(this,"fireenjinSubmit",7),this.floodteamCloseModal=i(this,"floodteamCloseModal",7),this.headerTitle="E-sign",this.loading=!1,this.signed=!1,this.isLoaded=!1}onModalPresent(){this.isLoaded=!0}async onChange(t){var i;if("signature"===(null===(i=null==t?void 0:t.target)||void 0===i?void 0:i.name)){if((await t.target.toDataURL()).length<=10)return void alert("Signature is required to submit!");this.loading=!0,this.fireenjinSubmit.emit({endpoint:"signContract",data:{jobId:this.jobId,signature:await t.target.toDataURL(),templateId:this.templateId}})}}async onSuccess(t){var i,s;"signContract"===(null===(i=null==t?void 0:t.detail)||void 0===i?void 0:i.endpoint)?(this.presentToast(),this.loading=!1,this.signed=!0,this.floodteamCloseModal.emit()):"findJob"===(null===(s=t.detail)||void 0===s?void 0:s.endpoint)&&(this.loading=!1)}async presentToast(){(await e.create({message:"File(s) added successfully to Efile!",duration:2e3})).present()}componentDidLoad(){if(null==s?void 0:s.isBrowser)try{this.templateEl.querySelector("fireenjin-render-template").shadowRoot.querySelector(".contract-header").remove(),this.templateEl.querySelector("fireenjin-render-template").shadowRoot.querySelector(".contract-footer").remove()}catch(t){console.log(t)}}render(){return[o("ion-header",null,o("ion-toolbar",null,o("ion-title",null,this.headerTitle),o("ion-buttons",{slot:"end"},o("ion-button",{onClick:()=>this.floodteamCloseModal.emit()},o("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),o("ion-content",{class:{"ion-padding":!0,"is-loading":this.loading}},this.signed?o("div",{style:{width:"90%",maxWidth:"500px",margin:"0 auto"}},o("ion-icon",{name:"checkmark-circle",color:"success",style:{height:"150px",width:"150px",display:"block",margin:"30px auto"}}),o("h1",null,"Signature Submitted!"),o("p",null,"Thank you for your time, you can now close this browser tab.")):o("div",null,o("floodteam-template",{ref:t=>this.templateEl=t,class:"fullscreen",templateId:this.templateId,data:{timestamp:(new Date).toISOString(),job:this.job,user:null==n?void 0:n.profile}}))),this.isLoaded&&o("floodteam-signature-pad",{class:{"is-loading":this.loading},ref:t=>this.signaturePadEl=t})]}};export{a as modal_esign}