import{r as i,d as t,B as s,h as o,H as n,e}from"./p-03169580.js";import{G as a}from"./p-d5534cd3.js";import{L as l}from"./p-29d0604b.js";import"./p-f13bd533.js";import"./p-bf71b10e.js";const r="fireenjin-map{position:relative;display:block}fireenjin-map #map{display:block;height:0px;width:100%;margin:0 auto;opacity:0;transition:all ease 0.5s}fireenjin-map.map-is-visible #map{height:var(--map-height, 300px);opacity:1}";let d=class{constructor(s){i(this,s);this.fireenjinTrigger=t(this,"fireenjinTrigger",7);this.mapMarkers=[];this.options={};this.visible=true;this.markers=[];this.isVisible=true}async addMarker(i){var t;if(!this.google)this.google=((t=window===null||window===void 0?void 0:window.google)===null||t===void 0?void 0:t.maps)?window.google:await this.loadGoogleMaps();const s=typeof i==="string"?JSON.parse(i):i;const o=new this.google.maps.Marker({position:s.position,map:this.map,title:(s===null||s===void 0?void 0:s.name)||"",icon:(s===null||s===void 0?void 0:s.icon)?{url:s.icon,origin:new this.google.maps.Point(0,0),anchor:new this.google.maps.Point(15,15),scaledSize:new this.google.maps.Size(34,34),shape:{coords:[17,17,18],type:"circle"},optimized:false}:null});o.addListener("click",(()=>{this.onMarkerClick(o,s)}));this.mapMarkers.push(o);return o}async updateMarkers(){await this.clearMarkers();if(this.markers.length>=1){this.markers.map(this.addMarker.bind(this))}return this.markers}async setMarkers(i=[]){this.markers=i;await this.clearMarkers();if(this.markers.length>=1){this.markers.map(this.addMarker.bind(this))}return this.markers}async setZoom(i){return this.map.setZoom(i)}async setCenter(i){return this.map.setCenter(i)}async clearMarkers(){var i;for(let t=0;t<this.mapMarkers.length;t++){if(!((i=this.mapMarkers[t])===null||i===void 0?void 0:i.setMap))continue;this.mapMarkers[t].setMap(null)}this.mapMarkers=[];return true}onMarkerClick(i,t){this.map.setZoom(12);this.map.setCenter(i.getPosition());this.fireenjinTrigger.emit({name:"markerClick",payload:{marker:i,location:t}})}getLocationCoords(i){try{a.getCurrentPosition().then((t=>{if(i&&typeof i==="function"){i(t.coords)}})).catch((async t=>{fetch("http://ip-api.com/json").then((async t=>{const s=await t.json();i({latitude:s.lat,longitude:s.lon})}));if(i&&typeof i==="function"){i(false)}}))}catch(t){i(false)}}async createMap(i){var t;if(!this.google)this.google=((t=window===null||window===void 0?void 0:window.google)===null||t===void 0?void 0:t.maps)?window.google:await this.loadGoogleMaps();this.map=new this.google.maps.Map(this.mapEl.querySelector("#map"),{zoom:9,center:{lat:i.latitude,lng:i.longitude}})}async loadGoogleMaps(i){const t=new l(this.googleMapsKey,i||{});return t.load()}async componentDidLoad(){var i;if(!(s===null||s===void 0?void 0:s.isBrowser))return;this.isVisible=this.visible;this.google=((i=window===null||window===void 0?void 0:window.google)===null||i===void 0?void 0:i.maps)?window.google:await this.loadGoogleMaps();setTimeout((()=>{this.getLocationCoords((async i=>{this.position=i?i:{latitude:38.6270025,longitude:-90.19940419999999};this.createMap(this.position);await this.setMarkers(this.markers)}))}),100)}render(){return o(n,{class:{"map-is-visible":this.isVisible}},o("div",{id:"map"}))}get mapEl(){return e(this)}static get watchers(){return{markers:["updateMarkers"]}}};d.style=r;let h=class{constructor(t){i(this,t);this.lines="inset"}render(){var i,t,s,n,e,a,l,r,d,h,c,u,v;return o("ion-item",{lines:this.lines,href:`/jobs/${(i=this.job)===null||i===void 0?void 0:i.id}`,detail:true},o("fireenjin-avatar",{slot:"start",style:{display:"inline-block",position:"relative",borderRadius:"4px",padding:"0 !important",overflow:"hidden",marginRight:"10px"},initials:((t=this.job)===null||t===void 0?void 0:t.title)?(s=this.job)===null||s===void 0?void 0:s.title.charAt(0):"",src:(a=(e=(n=this.job)===null||n===void 0?void 0:n.photos)===null||e===void 0?void 0:e[0])===null||a===void 0?void 0:a.url}),o("ion-label",{class:"ion-text-wrap",style:{position:"relative",textOverflow:"initial"}},o("h2",null,(l=this.job)===null||l===void 0?void 0:l.title),o("fireenjin-chip-bar",null,o("floodteam-select-status",{jobId:(r=this.job)===null||r===void 0?void 0:r.id,value:(d=this.job)===null||d===void 0?void 0:d.status}),o("floodteam-select-location",{disabled:true,jobId:(h=this.job)===null||h===void 0?void 0:h.id,value:(u=(c=this.job)===null||c===void 0?void 0:c.location)===null||u===void 0?void 0:u.id}),o("ion-router-link",{onClick:i=>i.stopPropagation(),href:`/jobs/${(v=this.job)===null||v===void 0?void 0:v.id}/scope`},o("ion-chip",null,o("ion-icon",{class:"ft-icon-style",name:"list"}),o("ion-label",null,"View Scope"))))))}};export{d as fireenjin_map,h as floodteam_item_job};
//# sourceMappingURL=p-41dbf3e7.entry.js.map