import{r as o,d as t,h as e}from"./p-846bd001.js";import{t as i}from"./p-9732f456.js";import{s as n}from"./p-4ff8bb4b.js";import"./p-18891da7.js";import"./p-8cd54418.js";import"./p-5cd01495.js";import"./p-259f1737.js";import"./p-ae2fb9dc.js";import"./p-65879f9e.js";import"./p-dca1478c.js";const a=class{constructor(e){o(this,e),this.floodteamCloseModal=t(this,"floodteamCloseModal",7),this.fireenjinFetch=t(this,"fireenjinFetch",7),this.steps=["note","options","preview"],this.heading="Add a Note",this.jobId=void 0,this.userId=void 0,this.note={},this.noteInput={},this.previewHTML=void 0}async onEditorChange(){var o;(null===(o=this.editorEl)||void 0===o?void 0:o.exportHTML)&&(this.previewHTML=await this.editorEl.exportHTML())}async onChange(o){var t,e,i,n;"sendAlert"===(null===(t=null==o?void 0:o.target)||void 0===t?void 0:t.name)?this.noteInput.sendAlert=!!(null===(e=null==o?void 0:o.detail)||void 0===e?void 0:e.checked):"tags"===(null===(i=null==o?void 0:o.target)||void 0===i?void 0:i.name)&&(this.noteInput.tags=(null===(n=null==o?void 0:o.target)||void 0===n?void 0:n.value)?o.target.value:[])}onReset(o){var t;if("addNote"===(null===(t=o.detail)||void 0===t?void 0:t.endpoint)){const o=document.querySelector("ion-modal.modal-note");(null==o?void 0:o.dismiss)&&o.dismiss()}}async onSuccess(o){var t;if("addNote"===(null===(t=o.detail)||void 0===t?void 0:t.endpoint)){const o=document.querySelector("ion-modal.modal-note");(null==o?void 0:o.dismiss)&&(await o.dismiss(),this.presentToast())}}async presentToast(){(await i.create({message:"Note has been added successfully!",duration:2e3})).present()}render(){var o,t;return[e("ion-header",null,e("ion-toolbar",null,e("ion-title",null,this.heading),e("ion-buttons",{slot:"end"},e("ion-button",{onClick:()=>this.floodteamCloseModal.emit()},e("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),e("ion-content",null,e("ion-tabs",{ref:o=>this.tabsEl=o},e("ion-tab-bar",{ref:o=>this.tabBarEl=o,slot:"top"},e("ion-tab-button",{tab:"note"},e("ion-icon",{name:"create"}),e("ion-label",null,"Note")),e("ion-tab-button",{tab:"options"},e("ion-icon",{name:"cog"}),e("ion-label",null,"Options")),e("ion-tab-button",{tab:"preview"},e("ion-icon",{name:"eye"}),e("ion-label",null,"Preview"))),e("ion-tab",{tab:"note"},e("ion-content",null,e("ion-card",{style:{overflow:"visible"}},e("fireenjin-form",{name:"note",endpoint:"addNote",beforeSubmit:async o=>({...this.noteInput,...o,jobId:this.jobId,userId:this.userId,html:this.previewHTML}),submitButton:"Save",resetButton:"Cancel",resetButtonColor:"medium",disableLoader:!0,disableEnterButton:!0},e("fireenjin-editor",{partials:n.templates,ref:o=>this.editorEl=o}))))),e("ion-tab",{tab:"options"},e("ion-content",null,e("ion-card",{class:"ion-padding",style:{overflow:"visible"}},e("fireenjin-form",{name:"note",hideControls:!0},e("fireenjin-toggle",{label:"Send an Alert",name:"sendAlert",value:!!(null===(o=this.note)||void 0===o?void 0:o.alert)}),e("fireenjin-select-tags",{name:"tags",label:"Tags",labelPosition:"stacked",value:(null===(t=this.note)||void 0===t?void 0:t.tags)?this.note.tags:[],allowAdding:!0,options:[{label:"Important",value:"important"},{label:"Referral",value:"referral"},{label:"Plumber",value:"plumber"},{label:"Staff",value:"staff"},{label:"Agent",value:"agent"},{label:"Property Manager",value:"property manager"},{label:"PEU",value:"peu"}]}))))),e("ion-tab",{tab:"preview"},e("ion-content",null,e("ion-card",{class:"ion-padding"},e("floodteam-template",{templateId:"fBRGqXAzDw8CwFfJtQgJ",data:{html:this.previewHTML?this.previewHTML:"",user:null==n?void 0:n.profile,createdAt:new Date}}))))))]}};a.style="modal-note fireenjin-editor{width:calc(100% - 75px);margin:0 0 0 60px}modal-note fireenjin-editor .codex-editor__redactor{padding-bottom:0 !important}@media only screen and (max-width: 800px){.modal-note{--width:100%;--max-width:auto}}";export{a as modal_note}