"use strict";(self.webpackChunkfindagrave_frontend=self.webpackChunkfindagrave_frontend||[]).push([[898],{50898(e,t,o){o.d(t,{A:()=>p});var n=o(56533),i=o(56267),a=o(60842),r=o(71757),s=o.n(r);var l=o(25938),d=o.n(l),c=function(e,t,o,n){return new(o||(o=Promise))(function(i,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};var u=function(e,t,o,n){return new(o||(o=Promise))(function(i,a){function r(e){try{l(n.next(e))}catch(e){a(e)}}function s(e){try{l(n.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(r,s)}l((n=n.apply(e,t||[])).next())})};class p{constructor(e,t,o,r,l,d,c,u,p,f,y){this.prefix=e,this.afterBrowse=y,this.lat=41.862548,this.lon=-87.609965,this.zoom=10,this.minZoom=5,this.maxZoom=19,this.created=!1;let m=this;if(this.confirm=r,this.pinDropped=!1,this.zoom=l||10,this.minZoom=d||5,this.maxZoom=c||19,this.mapboxStyle=p||"mapbox://styles/ancestrymapbox/ckh3vkj11062v19qoaum1i72f",a.accessToken=u||"pk.eyJ1IjoiYW5jZXN0cnltYXBib3giLCJhIjoiY2l5dWp3dzB5MDB1YTJxcjVzd2JrMDd4dyJ9.B9y6l3i3hEx3hy3DAMU3aQ",this.setGeoLocation(t||this.lat,o||this.lon),new i.A({bindElement:`#${e}city-county`,idElement:`#${e}city-county-id`,locationsWithoutCemeteries:!0,limitToCountyCity:!0,limitToCoordinates:!0,apolloClient:f}),s()(`#${e}saveLatLong`).on("click",function(t){if(s()(`#${e}dropPin`).addClass("hidden"),m.pinDropped){let e=isNaN(m.lat)?"":m.lat,t=isNaN(m.lon)?"":m.lon;return m.confirm(e,t)}t.preventDefault(),t.stopPropagation(),s()(`#${e}dropPin`).removeClass("hidden")}),s()(`#${e}dragLat`).on("focusout",function(){m.updateLatLongFromText(m)}),s()(`#${e}dragLong`).on("focusout",function(){m.updateLatLongFromText(m)}),s()(`#${e}dragLat`).on("keypress",function(e){13==e.which&&m.updateLatLongFromText(m)}),s()(`#${e}dragLong`).on("keypress",function(e){13==e.which&&m.updateLatLongFromText(m)}),s()(`#${e}city-county`).on("browse:set",function(e,t){m.afterBrowse&&(m.afterBrowse(e,t),m.lat=t.coordinates.lat,m.lon=t.coordinates.lon,m.pinDropped=!0,m.setMarkerPosition(),m.map.easeTo({center:[t.coordinates.lon,t.coordinates.lat]}),s()(`#${m.prefix}saveLatLong`).prop("disabled",!0))}),s()(`#${e}city-county`).length>0){let t;(0,n.Ay)().singleTypeahead({inputId:`#${e}city-county`,targetId:`#${e}city-county-id`,type:["city","county"],apolloClient:f}),s()(`#${e}city-county`).on("typeahead:set",function(e,o){o.id!==t&&(t=o.id,m.map.easeTo({center:[o.coordinates.lon,o.coordinates.lat]}),s()(`#${m.prefix}saveLatLong`).prop("disabled",!0))})}}setGeoLocation(e,t,o,n){let i=this,a=!1;isNaN(parseFloat(e))||isNaN(parseFloat(t))?navigator.geolocation?(n&&(a=!0,setTimeout(function(){a&&s()(n).show()},200)),navigator.geolocation.getCurrentPosition(function(e){n&&(a=!1,s()(n).hide());i.created&&!o||(i.lat=e.coords.latitude.toFixed(7),i.lon=e.coords.longitude.toFixed(7),i.setMarkerPosition(!0))},function(e){n&&(a=!1,s()(n).hide());console.log("Failed to get location",e),i.lat=40.43467,i.lon=-87.60996,i.setMarkerPosition(!0)})):(this.lat=40.43467,this.lon=-87.60996,this.setMarkerPosition(!0)):(this.lat=e,this.lon=t,this.setMarkerPosition(!0))}makeOrShowMap(e){let t=e.mapboxStyle;e.map?e.map.once("render",e.map.resize):(41.862548===e.lat&&-87.609965===e.lon&&(e.zoom=5),e.map=new a.Map({container:`${this.prefix}map_canvas_plot`,style:t,center:[e.lon,e.lat],zoom:e.zoom,minZoom:e.minZoom,maxZoom:e.maxZoom}),e.created=!0,e.map.addControl(new a.NavigationControl,"bottom-right"),e.geojson={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[e.lon,e.lat]}}]},e.map.on("load",function(){e.map.resize(),e.map.addSource("point",{type:"geojson",data:e.geojson}),e.map.addLayer({id:"point",type:"symbol",source:"point",layout:{"icon-image":"cemetery","icon-size":.25,"icon-allow-overlap":!0,"icon-offset":[0,-60]},paint:{"icon-opacity":.8}}),function(e){if(!findagrave.boundaries||0===findagrave.boundaries.length)return;const t=findagrave.boundaries.filter(e=>!e.type||"cemetery"===e.type).flatMap(e=>(Array.isArray(e.geoJSON)?e.geoJSON:[e.geoJSON]).filter(Boolean));t.length>0&&(e.addSource("cemetery-boundaries",{type:"geojson",data:{type:"FeatureCollection",features:t}}),e.addLayer({id:"cemetery-boundary-fill",type:"fill",source:"cemetery-boundaries",paint:{"fill-color":"#3bb2d0","fill-opacity":.1}}),e.addLayer({id:"cemetery-boundary-stroke",type:"line",source:"cemetery-boundaries",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}}));const o=findagrave.boundaries.filter(e=>"section"===e.type);if(0===o.length)return;const n=o.flatMap(e=>(Array.isArray(e.geoJSON)?e.geoJSON:[e.geoJSON]).filter(Boolean));n.length>0&&(e.addSource("cemetery-sections",{type:"geojson",data:{type:"FeatureCollection",features:n}}),e.addLayer({id:"cemetery-section-fill",type:"fill",source:"cemetery-sections",paint:{"fill-color":"#9b59b6","fill-opacity":.1}}),e.addLayer({id:"cemetery-section-stroke",type:"line",source:"cemetery-sections",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#9b59b6","line-width":2}}));const i=[];o.forEach(e=>{var t,o,n,a,r,s,l;const d=(Array.isArray(e.geoJSON)?e.geoJSON:[e.geoJSON]).find(Boolean);if(!d||!(null===(o=null===(t=d.geometry)||void 0===t?void 0:t.coordinates)||void 0===o?void 0:o[0]))return;const c=(null===(n=d.properties)||void 0===n?void 0:n.names)||e.names||[],u=(null===(a=navigator.language)||void 0===a?void 0:a.split("-")[0])||"en",p=(null===(r=c.find(e=>e.language===u))||void 0===r?void 0:r.name)||(null===(s=c.find(e=>"en"===e.language))||void 0===s?void 0:s.name)||(null===(l=c[0])||void 0===l?void 0:l.name)||e.keyId||"";if(!p)return;const f=d.geometry.coordinates[0];let y=0,m=0;const g=f.length;f.forEach(e=>{y+=e[0],m+=e[1]});const h=[y/g,m/g];i.push({type:"Feature",geometry:{type:"Point",coordinates:h},properties:{text:p}})}),i.length>0&&(e.addSource("cemetery-section-labels",{type:"geojson",data:{type:"FeatureCollection",features:i}}),e.addLayer({id:"cemetery-section-labels-layer",type:"symbol",source:"cemetery-section-labels",layout:{"text-field":["get","text"],"text-size":14,"text-anchor":"center"},paint:{"text-color":"#9b59b6","text-halo-color":"#ffffff","text-halo-width":2}}))}(e.map),e.map.on("click",function(t){e.clearClick(),s()(`#${e.prefix}too-distant`).addClass("hidden"),s()(`#${e.prefix}outside-boundary`).addClass("hidden"),e.clickTimeout=setTimeout(function(){return u(this,void 0,void 0,function*(){s()(`#${e.prefix}dropPin`).addClass("hidden");let n=t.lngLat.wrap();if(e.lat=Number.parseFloat(n.lat.toFixed(7)),e.lon=Number.parseFloat(n.lng.toFixed(7)),e.setMarkerPosition(),e.pinDropped=!0,(null===findagrave||void 0===findagrave?void 0:findagrave.boundaries)&&findagrave.boundaries.length>0){(yield function(e,t){return c(this,void 0,void 0,function*(){if(!e||!t)return!1;if(findagrave.boundaries&&findagrave.boundaries.length>0)try{const n=yield Promise.all([o.e(3375),o.e(886),o.e(7975)]).then(o.bind(o,43375)),i=n.point([t,e]),a=findagrave.boundaries.filter(e=>!e.type||"cemetery"===e.type).flatMap(e=>(Array.isArray(e.geoJSON)?e.geoJSON:[e.geoJSON]).filter(Boolean));for(const e of a){const t=n.buffer(e,2,{units:"meters"});if(!t)continue;const o="FeatureCollection"===t.type?t.features:[t];for(const e of o)if(n.booleanPointInPolygon(i,e))return!0}return!1}catch(e){console.error("Boundary containment check error:",e)}let n=0;return findagrave.cemeteryLatitude&&findagrave.cemeteryLongitude&&(n=d()({latitude:e,longitude:t},{latitude:findagrave.cemeteryLatitude,longitude:findagrave.cemeteryLongitude})),!isNaN(n)&&n<3219})}(e.lat,e.lon))?(s()(`#${e.prefix}outside-boundary`).addClass("hidden"),s()(`#${e.prefix}saveLatLong`).prop("disabled",!1)):(s()(`#${e.prefix}outside-boundary`).removeClass("hidden"),s()(`#${e.prefix}saveLatLong`).prop("disabled",!0))}})},500)}),e.map.on("dblclick",function(t){setTimeout(e.clearClick.bind(e),0)})}))}clearClick(){null!==this.clickTimeout&&(clearTimeout(this.clickTimeout),this.clickTimeout=null)}setMarkerPosition(e=!1){this.geojson&&(this.geojson.features[0].geometry.coordinates=[this.lon,this.lat],this.map.getSource("point").setData(this.geojson)),s()(`#${this.prefix}dragLat`).val(this.lat),s()(`#${this.prefix}dragLong`).val(this.lon),this.map&&this.map.jumpTo({center:this.geojson.features[0].geometry.coordinates}),!e&&s()(`#${this.prefix}saveLatLong`).prop("disabled",!1)}updateLatLongFromText(e){e.lat=parseFloat(s()(`#${e.prefix}dragLat`).val()),e.lon=parseFloat(s()(`#${e.prefix}dragLong`).val()),isNaN(e.lat)||isNaN(e.lon)||e.setMarkerPosition()}static valid(e,t,o){const n=(o,n)=>"number"==typeof e&&"number"==typeof t&&!(0===e&&0===t)&&e>=-90&&e<=90&&t>=-180&&t<=180,i=n();if(i&&o&&n(o.lat,o.lon)){return((e,t,o,n)=>{const i=.017453292519943295,a=Math.cos,r=.5-a((o-e)*i)/2+a(e*i)*a(o*i)*(1-a((n-t)*i))/2;return 12742*Math.asin(Math.sqrt(r))})(e,t,o.lat,o.lon)