import{r as i,d as o,h as l}from"./p-03169580.js";import{j as t,l as v}from"./p-795b799a.js";import{s as d}from"./p-ac5f2e11.js";import"./p-bd8b186e.js";import"./p-59c95c5f.js";import"./p-c9699503.js";import"./p-3a8e6af1.js";const n=".popover-site-service{--min-width:300px;--offset-y:-50px}popover-site-service ion-accordion-group{background:var(--background-color) !important;--ion-item-background:var(--background-color);--background:var(--background-color);background-color:var(--background-color) !important}popover-site-service ion-list ion-item{--ion-item-background:transparent}popover-site-service fireenjin-input ion-label{font-size:12px !important}";let e=class{constructor(l){i(this,l);this.fireenjinFetch=o(this,"fireenjinFetch",7);this.service={};this.scopeToServiceMap={};this.sites=[]}async onSuccess(i){var o;if(["editScopeService","addScopeService","deleteScopeService"].includes((o=i===null||i===void 0?void 0:i.detail)===null||o===void 0?void 0:o.endpoint)){this.accordionEl.requestAccordionToggle(null,false)}}getAutoFillValue(i,o,l={},d){var n,e,s,r,u,c,a;let h=d;try{h=((e=(n=this.scopeToServiceMap)===null||n===void 0?void 0:n[i])===null||e===void 0?void 0:e[o])||((r=(s=this.service)===null||s===void 0?void 0:s.autofill)===null||r===void 0?void 0:r[o])&&((u=t===null||t===void 0?void 0:v.apply)===null||u===void 0?void 0:u.call(t,(a=(c=this.service)===null||c===void 0?void 0:c.autofill)===null||a===void 0?void 0:a[o],l||{}))||d}catch(i){console.log(`Error applying json logic to ${o}: `,this.service.id,i)}return h}render(){var i,o,t,v,n,e,s,r,u,c,a,h,p,m;const f=((t=(o=(i=this.service)===null||i===void 0?void 0:i.tab)===null||o===void 0?void 0:o.toLowerCase)===null||t===void 0?void 0:t.call(o))==="general";const $={service:this.service,job:d===null||d===void 0?void 0:d.job};return[l("ion-content",null,l("ion-item-divider",null,((v=this.service)===null||v===void 0?void 0:v.name)||"No Name Given"),l("ion-accordion-group",{ref:i=>this.accordionEl=i,value:this.currentExpanded},f?l("floodteam-form-site-service",{isGeneral:true,serviceId:(n=this.service)===null||n===void 0?void 0:n.id,jobId:this.jobId,siteServiceId:((r=(e=this.scopeToServiceMap)===null||e===void 0?void 0:e[`${this.jobId}-${(s=this.service)===null||s===void 0?void 0:s.id}`])===null||r===void 0?void 0:r.id)||null,amount:this.getAutoFillValue(`${this.jobId}-${(u=this.service)===null||u===void 0?void 0:u.id}`,"amount",$,0),price:this.getAutoFillValue(`${this.jobId}-${(c=this.service)===null||c===void 0?void 0:c.id}`,"price",$,(h=(a=this.service)===null||a===void 0?void 0:a.prices)===null||h===void 0?void 0:h.default),quantity:this.getAutoFillValue(`${this.jobId}-${(p=this.service)===null||p===void 0?void 0:p.id}`,"quantity",$,1),unit:(m=this.service)===null||m===void 0?void 0:m.unit}):(this.sites||[]).sort(((i,o)=>(i===null||i===void 0?void 0:i.name)>(o===null||o===void 0?void 0:o.name)?1:-1)).map((i=>{var o,t,v,d,n,e,s,r,u,c;return l("floodteam-form-site-service",{siteId:i===null||i===void 0?void 0:i.id,jobId:this.jobId,serviceId:(o=this.service)===null||o===void 0?void 0:o.id,siteServiceId:((d=(t=this.scopeToServiceMap)===null||t===void 0?void 0:t[`${i===null||i===void 0?void 0:i.id}-${(v=this.service)===null||v===void 0?void 0:v.id}`])===null||d===void 0?void 0:d.id)||null,amount:this.getAutoFillValue(`${i===null||i===void 0?void 0:i.id}-${(n=this.service)===null||n===void 0?void 0:n.id}`,"amount",{...$,site:i},0),price:this.getAutoFillValue(`${i===null||i===void 0?void 0:i.id}-${(e=this.service)===null||e===void 0?void 0:e.id}`,"price",{...$,site:i},(r=(s=this.service)===null||s===void 0?void 0:s.prices)===null||r===void 0?void 0:r.default),quantity:this.getAutoFillValue(`${i===null||i===void 0?void 0:i.id}-${(u=this.service)===null||u===void 0?void 0:u.id}`,"quantity",{...$,site:i},1),name:i===null||i===void 0?void 0:i.name,unit:(c=this.service)===null||c===void 0?void 0:c.unit})}))))]}};e.style=n;export{e as popover_site_service};
//# sourceMappingURL=p-08bd360c.entry.js.map