diff --git a/public/dx-maps/doxa-maps-spa/manifest.json b/public/dx-maps/doxa-maps-spa/manifest.json index 22cfb084b..ab5e00ad6 100644 --- a/public/dx-maps/doxa-maps-spa/manifest.json +++ b/public/dx-maps/doxa-maps-spa/manifest.json @@ -663,7 +663,7 @@ "bundle": "my-upg-100-list", "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "output": "dx-maps/my-upg-100-list/my-upg-100-list.js", - "integrity": "sha384-TkiPEj7EL0mDm8I28pBM7VnNIk9VCv+DuLq7WdEOHMfplFSIVc3Sf6k2CDGjcD05", + "integrity": "sha384-+wG3yK20Ln4pMcZawMbDX8Vnux3TS3ywO+F5fXG6PkvoU4/6bjrLlTtC7dnBtNLZ", "elements": [ "my-upg-100-list-map" ], @@ -683,7 +683,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n" + "script": "\n\n" } }, { @@ -697,7 +697,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } }, { @@ -711,7 +711,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } } ] diff --git a/public/dx-maps/manifest.json b/public/dx-maps/manifest.json index 22cfb084b..ab5e00ad6 100644 --- a/public/dx-maps/manifest.json +++ b/public/dx-maps/manifest.json @@ -663,7 +663,7 @@ "bundle": "my-upg-100-list", "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "output": "dx-maps/my-upg-100-list/my-upg-100-list.js", - "integrity": "sha384-TkiPEj7EL0mDm8I28pBM7VnNIk9VCv+DuLq7WdEOHMfplFSIVc3Sf6k2CDGjcD05", + "integrity": "sha384-+wG3yK20Ln4pMcZawMbDX8Vnux3TS3ywO+F5fXG6PkvoU4/6bjrLlTtC7dnBtNLZ", "elements": [ "my-upg-100-list-map" ], @@ -683,7 +683,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n" + "script": "\n\n" } }, { @@ -697,7 +697,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } }, { @@ -711,7 +711,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n" + "script": "\n\n\n\n" } } ] diff --git a/public/dx-maps/my-upg-100-list/my-upg-100-list.js b/public/dx-maps/my-upg-100-list/my-upg-100-list.js index b5320f152..e807cd2fd 100644 --- a/public/dx-maps/my-upg-100-list/my-upg-100-list.js +++ b/public/dx-maps/my-upg-100-list/my-upg-100-list.js @@ -771,7 +771,7 @@ `,"map-control-button"),(t,o)=>(q(),oe("button",{class:De(["mcb",{dark:e.isDark,active:e.active}]),title:e.title,"aria-label":e.title||void 0,disabled:e.disabled,onClick:o[0]||(o[0]=n=>t.$emit("click"))},[An(t.$slots,"default")],10,_P))}},vP={__name:"ZoomInButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(e){const{t}=xt(),o=e;function n(){var a;o.disabled||(a=o.map)==null||a.zoomIn()}return(a,r)=>(q(),lt(fn,{"is-dark":e.isDark,disabled:e.disabled,title:ge(t)("buttons.zoomIn"),onClick:n},{default:Yt(()=>[...r[0]||(r[0]=[E("span",{style:{"font-size":"20px","line-height":"1","font-weight":"600"}},"+",-1)])]),_:1},8,["is-dark","disabled","title"]))}},wP={__name:"ZoomOutButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},setup(e){const{t}=xt(),o=e;function n(){var a;o.disabled||(a=o.map)==null||a.zoomOut()}return(a,r)=>(q(),lt(fn,{"is-dark":e.isDark,disabled:e.disabled,title:ge(t)("buttons.zoomOut"),onClick:n},{default:Yt(()=>[...r[0]||(r[0]=[E("span",{style:{"font-size":"22px","line-height":"1","font-weight":"600"}},"−",-1)])]),_:1},8,["is-dark","disabled","title"]))}},kP={__name:"LocationButton",props:{map:{type:Object,default:null},isDark:{type:Boolean,default:!1},center:{type:Array,default:()=>[20,10]},zoom:{type:Number,default:1.8},userZoom:{type:Number,default:10}},setup(e){const{t}=xt(),o=e;function n(){var r;(r=o.map)==null||r.flyTo({center:o.center,zoom:o.zoom,duration:1200})}function a(){if(o.map){if(typeof navigator>"u"||!navigator.geolocation){n();return}navigator.geolocation.getCurrentPosition(r=>{const{longitude:s,latitude:i}=r.coords;Number.isFinite(s)&&Number.isFinite(i)?o.map.flyTo({center:[s,i],zoom:o.userZoom,duration:1500}):n()},()=>n(),{enableHighAccuracy:!1,timeout:5e3,maximumAge:6e4})}}return(r,s)=>(q(),lt(fn,{"is-dark":e.isDark,title:ge(t)("buttons.resetView"),onClick:a},{default:Yt(()=>[...s[0]||(s[0]=[E("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor"},[E("path",{d:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5A2.5 2.5 0 1 1 12 6.5a2.5 2.5 0 0 1 0 5z"})],-1)])]),_:1},8,["is-dark","title"]))}},xP={key:0,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 29 29",fill:"currentColor"},PP={key:1,xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 29 29",fill:"currentColor"},SP={__name:"FullscreenButton",props:{mapContainer:{type:Object,default:null},isDark:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const{t:o}=xt(),n=e,a=t,r=fe(!1);let s=null,i=null,l=null,u=null,c=null,p=null,d=null,x=null,$=null,b=null,g=null,f=0,m=0,h=null,y=null;function v(){if(typeof document>"u")return!1;const Z=typeof navigator<"u"&&navigator.userAgent||"";return/iPad|iPhone|iPod/.test(Z)||Z.includes("Mac")&&typeof document<"u"&&"ontouchend"in document?!1:!!(document.fullscreenEnabled||document.webkitFullscreenEnabled)}function A(){var Z,D,le;return((le=(D=(Z=n.mapContainer)==null?void 0:Z.getRootNode)==null?void 0:D.call(Z))==null?void 0:le.host)??null}function w(){var D,le;const Z=(le=(D=n.mapContainer)==null?void 0:D.getRootNode)==null?void 0:le.call(D);return document.fullscreenElement||document.webkitFullscreenElement||(Z&&Z instanceof ShadowRoot?Z.fullscreenElement:null)||null}function P(Z){const D=Z.requestFullscreen||Z.webkitRequestFullscreen;if(!D)return Promise.reject(new Error("Fullscreen API unavailable"));const le=D.call(Z);return le&&typeof le.then=="function"?le:Promise.resolve()}function L(){const Z=document.exitFullscreen||document.webkitExitFullscreen;if(!Z)return Promise.reject(new Error("Fullscreen API unavailable"));const D=Z.call(document);return D&&typeof D.then=="function"?D:Promise.resolve()}function J(){const Z=A();if(!Z)return!1;if(l=Z,i=Z.style.cssText,Z.style.position="fixed",Z.style.top="0",Z.style.left="0",Z.style.right="0",Z.style.bottom="0",Z.style.width="100vw",Z.style.height="100vh",Z.style.height="100dvh",Z.style.zIndex="2147483647",Z.style.margin="0",Z.style.borderRadius="0",Z.style.touchAction="pan-x pan-y pinch-zoom",typeof document<"u"){f=window.scrollY||window.pageYOffset||0,m=window.scrollX||window.pageXOffset||0;const D=document.body,le=document.documentElement;u=D?D.style.overflow:null,c=le?le.style.overflow:null,p=D?D.style.position:null,d=D?D.style.top:null,x=D?D.style.left:null,$=D?D.style.width:null,b=D?D.style.touchAction:null,g=le?le.style.touchAction:null,le&&(le.style.overflow="hidden",le.style.touchAction="none"),D&&(D.style.overflow="hidden",D.style.position="fixed",D.style.top=`-${f}px`,D.style.left=`-${m}px`,D.style.width="100%",D.style.touchAction="none"),h=C=>{if(!l)return;const W=C.target;W&&(W===l||l.contains&&l.contains(W))||C.cancelable&&C.preventDefault()},y=C=>{if(!l)return;const W=C.target;W&&(W===l||l.contains&&l.contains(W))||C.cancelable&&C.preventDefault()},document.addEventListener("touchmove",h,{passive:!1,capture:!0}),document.addEventListener("wheel",y,{passive:!1,capture:!0})}return!0}function K(){if(l){if(l.style.cssText=i||"",l=null,i=null,typeof document<"u"){const Z=document.body,D=document.documentElement;Z&&(Z.style.overflow=u??"",Z.style.position=p??"",Z.style.top=d??"",Z.style.left=x??"",Z.style.width=$??"",Z.style.touchAction=b??""),D&&(D.style.overflow=c??"",D.style.touchAction=g??""),h&&(document.removeEventListener("touchmove",h,{capture:!0}),h=null),y&&(document.removeEventListener("wheel",y,{capture:!0}),y=null),typeof window<"u"&&(f||m)&&window.scrollTo(m,f)}u=null,c=null,p=null,d=null,x=null,$=null,b=null,g=null,f=0,m=0}}function O(){typeof window>"u"||window.requestAnimationFrame(()=>{window.dispatchEvent(new Event("resize"))})}function I(){if(!v()){r.value?(K(),r.value=!1,a("change",!1)):J()&&(r.value=!0,a("change",!0)),O();return}if(w())L().then(()=>{r.value=!1,a("change",!1)}).catch(()=>{});else{const D=A()??document.documentElement;P(D).then(()=>{r.value=!0,a("change",!0)}).catch(()=>{P(document.documentElement).then(()=>{r.value=!0,a("change",!0)}).catch(()=>{})})}}function G(){r.value=!!w(),a("change",r.value)}return ho(()=>{var D,le;document.addEventListener("fullscreenchange",G),document.addEventListener("webkitfullscreenchange",G);const Z=(le=(D=n.mapContainer)==null?void 0:D.getRootNode)==null?void 0:le.call(D);Z instanceof ShadowRoot&&(s=Z,Z.addEventListener("fullscreenchange",G),Z.addEventListener("webkitfullscreenchange",G))}),Xt(()=>{document.removeEventListener("fullscreenchange",G),document.removeEventListener("webkitfullscreenchange",G),s&&(s.removeEventListener("fullscreenchange",G),s.removeEventListener("webkitfullscreenchange",G),s=null),l&&K()}),(Z,D)=>(q(),lt(fn,{"is-dark":e.isDark,active:r.value,title:ge(o)("buttons.toggleFullscreen"),onClick:I},{default:Yt(()=>[r.value?(q(),oe("svg",PP,[...D[1]||(D[1]=[E("path",{d:"M18.5 16c-1.75 0-2.5.75-2.5 2.5V24h1l1.5-3 5.5 4 1-1-4-5.5 3-1.5v-1h-5.5zM13 18.5c0-1.75-.75-2.5-2.5-2.5H5v1l3 1.5L4 24l1 1 5.5-4 1.5 3h1v-5.5zm3-8c0 1.75.75 2.5 2.5 2.5H24v-1l-3-1.5L25 5l-1-1-5.5 4L17 5h-1v5.5zM10.5 13c1.75 0 2.5-.75 2.5-2.5V5h-1l-1.5 3L5 4 4 5l4 5.5L5 12v1h5.5z"},null,-1)])])):(q(),oe("svg",xP,[...D[0]||(D[0]=[E("path",{d:"M24 16v5.5c0 1.75-.75 2.5-2.5 2.5H16v-1l3-1.5-4-5.5 1-1 5.5 4 1.5-3h1zM6 16l1.5 3 5.5-4 1 1-4 5.5 3 1.5v1H7.5C5.75 24 5 23.25 5 21.5V16h1zm7-11v1l-3 1.5 4 5.5-1 1-5.5-4L6 13H5V7.5C5 5.75 5.75 5 7.5 5H13zm11 2.5c0-1.75-.75-2.5-2.5-2.5H16v1l3 1.5-4 5.5 1 1 5.5-4 1.5 3h1V7.5z"},null,-1)])]))]),_:1},8,["is-dark","active","title"]))}},AP={style:{"font-size":"16px","line-height":"1"}},LP={__name:"ThemeToggleButton",props:{isDark:{type:Boolean,default:!1}},emits:["toggle"],setup(e){const{t}=xt();return(o,n)=>ge(Lv)?(q(),lt(fn,{key:0,"is-dark":e.isDark,title:e.isDark?ge(t)("buttons.switchToLightMode"):ge(t)("buttons.switchToDarkMode"),onClick:n[0]||(n[0]=a=>o.$emit("toggle"))},{default:Yt(()=>[E("span",AP,ce(e.isDark?"☀️":"🌙"),1)]),_:1},8,["is-dark","title"])):ke("",!0)}},Oo={mapboxGlJs:{url:"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.js",integrity:"sha384-tO0clamXONKwbiz7O6xJpUeyJbTSPugC+xM9clvfFvKTH3i8SmCawHGdf5quMWmZ"},mapboxGlCss:{url:"https://api.mapbox.com/mapbox-gl-js/v3.24.0/mapbox-gl.css",integrity:"sha384-rp1X/jJ9MpWPef9OimfXhOaOc4Gzs87yQvF+ajwY6X2H4PTeHNycNlLWiWvj7ehV"},maplibreGlJs:{url:"https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.js",integrity:"sha384-5+cfbwT0iiub6VsQAdn6yz16nr6sDiQoHx6tm4O8OVYXHYOxcffFmCJBL0dgdvGp"},maplibreGlCss:{url:"https://cdn.jsdelivr.net/npm/maplibre-gl@5.24.0/dist/maplibre-gl.css",integrity:"sha384-uTttxo/aOKbdE5RlD/SPzSDoDmNvGlUYPjONi2MN/b7c9HPSvW07OIuyP7uL6jxK"},mapboxGeocoderJs:{url:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.min.js",integrity:"sha384-Lx9WK8XhZk57czwxt6B6nyaDHB5Ayrcrsu4Fw4bCp/Ot/QLOsUZ0xYqLOpOOSXZw"},mapboxGeocoderCss:{url:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v5.0.0/mapbox-gl-geocoder.css",integrity:"sha384-1KNhwJNCQTr0DCi/5/OnQcFytgycxTahxNZaqKbAtqmY8bUhu26qxXqvDGXXwplS"},maplibreGeocoderJs:{url:"https://cdn.jsdelivr.net/npm/@maplibre/maplibre-gl-geocoder@1.9.4/dist/maplibre-gl-geocoder.min.js",integrity:"sha384-RGV5vfoJd7alk8HE+71IyVfu19ciH1FKA15+AuXs6OeBM2npXrmTPFqG23yMiHXi"},maplibreGeocoderCss:{url:"https://cdn.jsdelivr.net/npm/@maplibre/maplibre-gl-geocoder@1.9.4/dist/maplibre-gl-geocoder.css",integrity:"sha384-UkDpPApjTpHJHpcJiSNAmbobh30W0/dmt0DoKm4V8CWYRYvQ/Jhd/ijFz0tFdVnH"},d3:{url:"https://cdn.jsdelivr.net/npm/d3@7.9.0/dist/d3.min.js",integrity:"sha384-CjloA8y00+1SDAUkjs099PVfnY2KmDC2BZnws9kh8D/lX1s46w6EPhpXdqMfjK6i"}};function Yr(e,t){const o=Object.values(Oo).find(n=>n.url===t);return o&&(e.integrity=o.integrity,e.crossOrigin="anonymous"),e}const CP=["blocs","clusters","peopleGroups","families","languages","dialects","people","places","regions","wagfBlocks","religions"],TP={"people-groups":["blocs","clusters","peopleGroups","people","places","families","languages","dialects","regions","religions"],language:["families","languages","dialects","people","blocs","clusters","peopleGroups","places","regions","religions"],regions:["regions","wagfBlocks","places","blocs","clusters","peopleGroups","people","families","languages","dialects","religions"],religion:["religions","people","blocs","clusters","peopleGroups","places","families","languages","dialects","regions"]};function EP(e){return TP[e]||CP}const RP={blocs:3,clusters:3,peopleGroups:3,families:3,languages:3,dialects:3,people:5,places:2,regions:3,wagfBlocks:3,religions:2},Zr=["peopleGroups","people","places","languages","religions"],MP={regions:[...Zr,"regions","wagfBlocks"],"people-groups":[...Zr,"blocs","clusters"],language:[...Zr,"dialects","families"],religion:[...Zr]},NP=100,FP=50,IP=25,OP=10,il=5,ug=20,DP=[[/ sign language$/i,"Sign Language"]];function GP(e){if(!e||typeof e!="string")return"";const t=e.indexOf(",");return t>0?e.slice(0,t).trim():e.trim()}function zP(e){if(!e||typeof e!="string")return null;const t=e.indexOf(",");return t>=0&&e.slice(t+1).trim()||null}function BP(e){if(!e||typeof e!="string")return null;const t=e.split(",").map(n=>n.trim()).filter(Boolean);if(t.length>=2){const n=[...t].reverse().join(" ");if(Ft[n])return Ft[n];if(t.length>=3){const a=[t[1],t[0]].join(" ");if(Ft[a])return Ft[a]}}if(Ft[e])return Ft[e];const o=e.replace(/\s*\(.*?\)\s*$/,"").trim();if(o!==e&&Ft[o])return Ft[o];for(const[n,a]of DP)if(n.test(e))return a;return null}function dg(e,t){return{id:`doxa-section-header-${ll(e)}`,place_name:e,text:e,center:[0,0],place_type:["doxa-section-header"],geometry:{type:"Point",coordinates:[0,0]},properties:{headerLabel:e,isHeader:!0,isAllDataSection:!!t},feature:null}}function ll(e){return String(e||"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ie(e){return e==null?"":typeof e=="string"?e.toLowerCase():typeof e=="object"&&"label"in e?String(e.label||"").toLowerCase():typeof e=="object"&&"value"in e?String(e.value||"").toLowerCase():String(e).toLowerCase()}function Jr(e){return e==null?"":typeof e=="string"?e:typeof e=="object"?e.label||e.value||"":String(e)}function HP(e){var o,n,a,r,s;if(!Array.isArray(e))return[];const t=[];for(const i of e){if(!i)continue;const l=Number(i.latitude),u=Number(i.longitude);if(!Number.isFinite(l)||!Number.isFinite(u))continue;const c=Ie(i.name)+" "+Ie(i.displayName)+" "+Ie(i.alternateName),p=Ie(i.countryName)+" "+Ie(i.country)+" "+Ie(i.countryIso)+" "+Ie(i.countryIsoLabel),d=Ie(i.religionName)+" "+Ie(i.religion)+" "+Ie(i.religionLabel)+" "+Ie(i.religionCode),x=Ie(i.language)+" "+Ie(i.languageFamily)+" "+Ie(i.languageCode),$=Ie(i.doxaRegion)+" "+Ie(i.wagfRegion)+" "+Ie(i.wagfBlock),b=Ie(i.affinityBlock)+" "+Ie(i.affinityBlockLabel)+" "+Ie((o=i._raw)==null?void 0:o.rop1),g=Ie(i.cluster)+" "+Ie(i.clusterLabel)+" "+Ie((n=i._raw)==null?void 0:n.imb_reg_of_people_2),f=Ie(i.peopleGroup)+" "+Ie(i.peopleGroupLabel)+" "+Ie((a=i._raw)==null?void 0:a.imb_reg_of_people_25),m=((r=i._raw)==null?void 0:r.primary_language)??((s=i._raw)==null?void 0:s.PrimaryLanguage),h=m&&(typeof m=="object"?m.label||m.value:m)||Jr(i.language)||Jr(i.primaryLanguage)||"",y=GP(h),v=zP(h);t.push({feature:i,nameHay:c,countryHay:p,religionHay:d,languageHay:x,regionHay:$,haystack:c+" "+p+" "+d+" "+x+" "+$+" "+b+" "+g+" "+f,blocHay:b,clusterHay:g,pgHay:f,lat:l,lng:u,familyDerived:BP(h)||null,languageLabel:h,baseLang:y,dialectLabel:v})}return t}function UP(e){const t=(o,n,a)=>{const r=new Map;for(const s of e){const i=o(s);if(!i)continue;const l=r.get(i);if(l)l.count+=1,l.lngSum+=s.lng,l.latSum+=s.lat,l.memberIds.push(String(s.feature.uniqueId??s.feature.id??s.feature.slug??"")),l.minLng=Math.min(l.minLng,s.lng),l.maxLng=Math.max(l.maxLng,s.lng),l.minLat=Math.min(l.minLat,s.lat),l.maxLat=Math.max(l.maxLat,s.lat),a&&a(l,s,!1);else{const u={key:i,label:Jr(n(s))||i,count:1,lngSum:s.lng,latSum:s.lat,minLng:s.lng,maxLng:s.lng,minLat:s.lat,maxLat:s.lat,memberIds:[String(s.feature.uniqueId??s.feature.id??s.feature.slug??"")]};a&&a(u,s,!0),r.set(i,u)}}for(const s of r.values())s.lng=s.lngSum/s.count,s.lat=s.latSum/s.count;return Array.from(r.values())};return{countries:t(o=>Ie(o.feature.countryName)||Ie(o.feature.country)||Ie(o.feature.countryIso),o=>o.feature.countryName||o.feature.country||o.feature.countryIso||""),families:t(o=>Ie(o.familyDerived),o=>o.familyDerived||""),languages:t(o=>Ie(o.baseLang),o=>o.baseLang||""),dialects:t(o=>o.dialectLabel?`${Ie(o.baseLang)}__${Ie(o.dialectLabel)}`:"",o=>`${o.baseLang}, ${o.dialectLabel}`,(o,n,a)=>{a?(o.originalLabels=new Set([n.languageLabel]),o.familyDerived=n.familyDerived||"",o.baseLang=n.baseLang||"",o.dialectLabel=n.dialectLabel||""):(o.originalLabels.add(n.languageLabel),!o.familyDerived&&n.familyDerived&&(o.familyDerived=n.familyDerived))}),religions:t(o=>{var n,a,r;return Ma(o.feature.religion||((a=(n=o.feature._raw)==null?void 0:n.religion)==null?void 0:a.value)||((r=o.feature._raw)==null?void 0:r.religion)||"")},o=>{var n,a,r;return Hn[Ma(o.feature.religion||((a=(n=o.feature._raw)==null?void 0:n.religion)==null?void 0:a.value)||((r=o.feature._raw)==null?void 0:r.religion)||"")]||"Unknown"}),regions:t(o=>Ie(o.feature.doxaRegion)||Ie(o.feature.wagfRegion),o=>{var n,a;return o.feature.wagfRegionLabel||o.feature.doxaRegionLabel||((a=(n=o.feature._raw)==null?void 0:n.wagf_region)==null?void 0:a.label)||o.feature.doxaRegion||o.feature.wagfRegion||""}),wagfBlocks:t(o=>Ie(o.feature.wagfBlock),o=>{var n,a;return o.feature.wagfBlockLabel||((a=(n=o.feature._raw)==null?void 0:n.wagf_block)==null?void 0:a.label)||o.feature.wagfBlock||""}),blocs:t(o=>Ie(o.feature.affinityBlockLabel)||Ie(o.feature.affinityBlock),o=>o.feature.affinityBlockLabel||o.feature.affinityBlock||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"")}),clusters:t(o=>{const n=o.feature.affinityBlock||"",a=o.feature.cluster||"";return a?`${n}__${a}`:""},o=>o.feature.clusterLabel||o.feature.cluster||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"",o.blocLabel=n.feature.affinityBlockLabel||"",o.clusterCode=n.feature.cluster||"")}),peopleGroups:t(o=>Ie(o.feature.peopleGroup)||Ie(o.feature.peopleGroupLabel),o=>o.feature.peopleGroupLabel||o.feature.peopleGroup||o.feature.name||"",(o,n,a)=>{a&&(o.blocCode=n.feature.affinityBlock||"",o.blocLabel=n.feature.affinityBlockLabel||"",o.clusterCode=n.feature.cluster||"",o.clusterLabel=n.feature.clusterLabel||"",o.peopleGroupCode=n.feature.peopleGroup||"")})}}function jP(e){const t=e.feature,o=t.name||t.displayName||t.slug||"Unknown",n=t.countryName||t.country||t.countryIso||"",a=t.religionName||t.religion||"",r=t.slug||t.uniqueId||ll(o+"-"+n),s=[e.lng,e.lat],i=[n,a].filter(Boolean).join(" — "),l=i?`${o}, ${i}`:o;return{id:`doxa-pg-${r}`,place_name:l,text:o,center:s,place_type:["people-group"],geometry:{type:"Point",coordinates:s},properties:{slug:r,...t},feature:t}}function _o(e,t){let o,n;switch(e){case"country":o="doxa-country",n="doxa-country-";break;case"region":o="doxa-region",n="doxa-region-";break;case"language-family":o="doxa-language-family",n="doxa-language-family-";break;case"language":o="doxa-language",n="doxa-language-";break;case"dialect":o="doxa-dialect",n="doxa-dialect-";break;case"religion":o="doxa-religion",n="doxa-religion-";break;case"affinity-bloc":o="doxa-affinity-bloc",n="doxa-affinity-bloc-";break;case"cluster":o="doxa-cluster",n="doxa-cluster-";break;case"people-group":o="doxa-people-group",n="doxa-people-group-";break;default:o="doxa",n="doxa-"}const a=Jr(t.label)||t.key,r=ll(t.key),s=[t.lng,t.lat],l={"affinity-bloc":"Affinity Block",cluster:"Cluster","people-group":"PG","pg-in-country":"PGIC"}[e],u=l?`${a} (${l}) · ${t.count}`:`${a} (${t.count})`,c=t.originalLabels?Array.from(t.originalLabels):void 0,p=e==="dialect"?{familyDerived:t.familyDerived||"",baseLang:t.baseLang||"",dialectLabel:t.dialectLabel||""}:null;return{id:`${n}${r}`,place_name:u,text:a,center:s,bbox:[t.minLng,t.minLat,t.maxLng,t.maxLat],place_type:[o],geometry:{type:"Point",coordinates:s},properties:{slug:r,doxaAggregate:e,count:t.count,label:a,memberIds:t.memberIds,bounds:[t.minLng,t.minLat,t.maxLng,t.maxLat],...c?{originalLabels:c}:{},...p||{},...e==="affinity-bloc"?{blocCode:t.blocCode||""}:{},...e==="cluster"?{blocCode:t.blocCode||"",blocLabel:t.blocLabel||"",clusterCode:t.clusterCode||""}:{},...e==="people-group"?{blocCode:t.blocCode||"",blocLabel:t.blocLabel||"",clusterCode:t.clusterCode||"",clusterLabel:t.clusterLabel||"",peopleGroupCode:t.peopleGroupCode||""}:{}},feature:null}}function VP(e={}){const{dataStore:t,dataSourceId:o,getActiveFilter:n,getActiveContext:a}=e,{t:r}=xt(),s=te(()=>{var p,d;if(!t||!t.sources)return[];if(o&&((p=t.sources[o])!=null&&p.features))return t.sources[o].features;for(const x of Object.keys(t.sources)){const $=t.sources[x];if((d=$==null?void 0:$.features)!=null&&d.length)return $.features}return[]}),i=te(()=>HP(s.value)),l=te(()=>UP(i.value));function u(p){const d=String(p||"").trim().toLowerCase(),x={people:[],places:[],regions:[],wagfBlocks:[],families:[],languages:[],dialects:[],religions:[],blocs:[],clusters:[],peopleGroups:[]};if(d.length<2)return x;const $=d.split(/[\s,;]+/).filter(Boolean);if(!$.length)return x;const b=i.value;if(!b.length)return x;const g=l.value,f=[];for(const D of b){let le=!0;for(const W of $)if(!D.haystack.includes(W)){le=!1;break}if(!le)continue;let C=0;$.some(W=>D.nameHay.includes(W))&&(C+=NP),$.some(W=>D.countryHay.includes(W))&&(C+=FP),$.some(W=>D.religionHay.includes(W))&&(C+=IP),$.some(W=>D.languageHay.includes(W))&&(C+=OP),f.push({entry:D,score:C})}f.sort((D,le)=>le.score-D.score);const m=f.slice(0,il).map(D=>jP(D.entry)),h=D=>D.filter(le=>$.every(C=>le.key.includes(C)||Ie(le.label).includes(C))).sort((le,C)=>C.count-le.count).slice(0,il),y=h(g.countries).map(D=>_o("country",D)),v=h(g.regions).map(D=>_o("region",D)),A=h(g.wagfBlocks).map(D=>_o("region",D)),w=h(g.families).map(D=>_o("language-family",D)),P=h(g.languages).map(D=>_o("language",D)),L=h(g.dialects).map(D=>_o("dialect",D)),J=h(g.religions).map(D=>_o("religion",D)),K=h(g.blocs).map(D=>_o("affinity-bloc",D));let O=h(g.clusters).map(D=>_o("cluster",D)),I=h(g.peopleGroups).map(D=>_o("people-group",D));const G=new Set(K.map(D=>Ie(D.text)));O=O.filter(D=>!G.has(Ie(D.text)));const Z=new Set(O.map(D=>Ie(D.text)));return I=I.filter(D=>!G.has(Ie(D.text))&&!Z.has(Ie(D.text))),{people:m,places:y,regions:v,wagfBlocks:A,families:w,languages:P,dialects:L,religions:J,blocs:K,clusters:O,peopleGroups:I}}function c(p){const d=typeof n=="function"?n():null,x=typeof a=="function"?a():null,$=u(p),b=EP(x),g=MP[x],f=g?Object.fromEntries(g.filter(w=>$[w]).map(w=>[w,$[w]])):$,m=b.flatMap(w=>f[w]||[]);if(!(d!=null&&d.key)||!m.length)return m.slice(0,ug);const h=[];for(const w of $.people){const P=i.value.find(J=>J.feature===w.feature);let L=!1;P&&(d.kind==="family"?L=(P.familyDerived||"").toLowerCase()===d.key.toLowerCase():d.kind==="language"&&(L=P.languageLabel.toLowerCase()===d.key.toLowerCase())),L&&h.push(w)}const y=[],v=d.key;h.length&&(y.push(dg(r("search.sections.within",{selection:v}),!1)),y.push(...h.slice(0,il)));const A=b.flatMap(w=>(f[w]||[]).slice(0,RP[w]??3)).map(w=>({...w,properties:{...w.properties,_allDataSection:!0}}));return y.push(dg(r("search.sections.allData"),!0)),y.push(...A),y.slice(0,ug+8)}return{search:c,searchGrouped:u,index:i,aggregates:l}}const KP={__name:"GeocoderComponent",props:{mapInstance:{type:Object,required:!1,default:null},accessToken:{type:String,required:!0},provider:{type:String,default:"mapbox"},isDark:{type:Boolean,default:!1},standalone:{type:Boolean,default:!1},placeholder:{type:String,default:""},dataSourceId:{type:String,default:""},activeContext:{type:String,default:""}},emits:["result","people-group-result","aggregate-result","clear","error"],setup(e,{expose:t,emit:o}){function n(C){return C+C.replace(/mapboxgl/g,"maplibregl")}Lt(n('.mapboxgl-ctrl-geocoder--input,.mapboxgl-ctrl-geocoder input[type="text"],.mapboxgl-ctrl-geocoder input[type="search"]{font-size:16px !important;line-height:1.3;}'),"geocoder-ios-zoom-fix"),Lt(n(".mapboxgl-ctrl-geocoder--icon-loading{display:none !important;}"),"geocoder-hide-loading"),Lt(n(".mapboxgl-ctrl-geocoder{height:35px!important;min-height:35px!important;box-sizing:border-box!important;}.mapboxgl-ctrl-geocoder--input{height:35px!important;min-height:35px!important;box-sizing:border-box!important;padding-top:0!important;padding-bottom:0!important;line-height:35px!important;}.mapboxgl-ctrl-geocoder--icon-search{top:50%!important;transform:translateY(-50%)!important;margin-top:0!important;left:7px!important;}"),"geocoder-height-35"),Lt(n(".mapboxgl-ctrl-geocoder{width:100%!important;max-width:100%!important;min-width:0!important;}@media(max-width:767px){.dg-search-band{top:0!important;left:0!important;right:0!important;width:100%!important;max-width:none!important;margin:0!important;box-sizing:border-box!important;padding:9px 14px!important;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.10);}.dg-search-band--dark{background:#3b463d;box-shadow:0 1px 4px rgba(0,0,0,0.35);}.dg-search-band .mapboxgl-ctrl,.dg-search-band .maplibregl-ctrl{margin:0!important;float:none!important;}}.mapboxgl-ctrl-geocoder{border-radius:999px!important;background:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.15)!important;transition:box-shadow .12s,border-color .12s;}.mapboxgl-ctrl-geocoder:focus-within{box-shadow:0 2px 8px rgba(0,0,0,0.15),0 0 0 3px rgba(59,70,61,0.18)!important;}.mapboxgl-ctrl-geocoder--input{border-radius:999px!important;font-size:13px!important;}.mapboxgl-ctrl-geocoder--input::placeholder{font-size:12px!important;}.mapboxgl-ctrl-geocoder--button{display:none!important;top:50%!important;bottom:auto!important;transform:translateY(-50%)!important;margin:0!important;padding:0!important;width:24px!important;height:24px!important;background:transparent!important;border:none!important;box-shadow:none!important;}.mapboxgl-ctrl-geocoder:has(.mapboxgl-ctrl-geocoder--input:not(:placeholder-shown)) .mapboxgl-ctrl-geocoder--button{display:block!important;}.mapboxgl-ctrl-geocoder--button .mapboxgl-ctrl-geocoder--icon-close{position:absolute!important;top:50%!important;left:50%!important;transform:translate(-50%,-50%)!important;margin:0!important;width:16px!important;height:16px!important;}.mapboxgl-ctrl-geocoder--suggestions,.mapboxgl-ctrl-geocoder .suggestions{z-index:1200!important;position:absolute;max-height:60vh!important;overflow-y:auto!important;}.geocoder-dark.mapboxgl-ctrl-geocoder,.dsm-dark .mapboxgl-ctrl-geocoder{background:#4e594f!important;border:1px solid rgba(255,255,255,0.14)!important;box-shadow:0 2px 8px rgba(0,0,0,0.4)!important;}.geocoder-dark.mapboxgl-ctrl-geocoder:focus-within,.dsm-dark .mapboxgl-ctrl-geocoder:focus-within{box-shadow:0 2px 8px rgba(0,0,0,0.4),0 0 0 3px rgba(115,161,127,0.22)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--input,.dsm-dark .mapboxgl-ctrl-geocoder--input{color:#F3F3F1!important;background:transparent!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--input::placeholder,.dsm-dark .mapboxgl-ctrl-geocoder--input::placeholder{color:rgba(243,243,241,0.65)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--icon,.dsm-dark .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--icon{fill:rgba(243,243,241,0.75)!important;}.geocoder-dark .mapboxgl-ctrl-geocoder--button,.dsm-dark .mapboxgl-ctrl-geocoder--button{background:transparent!important;}"),"geocoder-skin");const{t:a,locale:r}=xt(),s=e,i=te(()=>/^pk\./.test(String(s.accessToken||""))),l=te(()=>s.placeholder||(s.provider==="maplibre"&&!i.value?a("search.placeholderNoPlaces"):a("search.placeholder"))),u=o,c={"&":"&","<":"<",">":">",'"':""","'":"'"};function p(C){return String(C??"").replace(/[&<>"']/g,W=>c[W])}function d(C){return C==null?"":typeof C=="string"?C:typeof C=="object"?C.label||C.value||"":String(C)}const x={"people-group":"people","doxa-people-group":"peopleGroup","doxa-affinity-bloc":"bloc","doxa-cluster":"cluster","doxa-country":"country","doxa-region":"region","doxa-language-family":"family","doxa-language":"languageKind","doxa-dialect":"dialect","doxa-religion":"religionKind"};function $(C){const W=x[C];if(!W)return"";const X=a("search.kinds."+W);return`${p(X)}`}function b(C){var se;if(!C)return"";const W=C.place_type||[];if(W.includes("doxa-section-header"))return`
${p(((se=C.properties)==null?void 0:se.headerLabel)||C.text||"")}
`;if(W.includes("people-group")){const U=C.properties||{},$e=d(U.name)||d(U.displayName)||d(C.text)||"",be=d(U.countryName)||d(U.country)||d(U.countryIso)||"",Se=d(U.language)||d(U.primaryLanguage)||d(U.languageFamily)||"",we=d(U.religionName)||d(U.religion)||"",Le=a("search.labels.place"),B=a("search.labels.language"),de=a("search.labels.religion"),ue=[];return be&&ue.push(`${p(Le)} ${p(be)}`),Se&&ue.push(`${p(B)} ${p(Se)}`),we&&ue.push(`${p(de)} ${p(we)}`),`
${$("people-group")}${p($e)}
`+(ue.length?`
${ue.join("")}
`:"")}const X=W.find(U=>U.startsWith("doxa-"));if(X){const U=C.properties||{},$e=p(d(U.label)||C.text||""),be=Number(U.count)||0,Se=be?` ${be}`:"";return`
${$(X)}${$e}${Se}
`}return`
${p(C.place_name||C.text||"")}
`}const g=Ue("dataStore",null),f=Ue("mapStore",null),m=Ue("uiStore",null);function h(){return f?f.selectedFamily?{kind:"family",key:f.selectedFamily}:f.selectedLanguage?{kind:"language",key:f.selectedLanguage}:null:null}const{search:y}=VP({dataStore:g,dataSourceId:s.dataSourceId||void 0,getActiveFilter:h,getActiveContext:()=>s.activeContext||null}),v=wn(null),A=fe(null),w={mapbox:Oo.mapboxGeocoderCss.url,maplibre:Oo.maplibreGeocoderCss.url},P=Oo.maplibreGeocoderJs.url,L=Oo.mapboxGeocoderJs.url;function J(C,W){const X=w[W]||w.mapbox;if(C.querySelector(`link[href="${X}"]`))return;const se=document.createElement("link");se.rel="stylesheet",se.href=X,Yr(se,X),C.prepend(se)}async function K(C,W){if(typeof window<"u"&&window[W]||typeof document>"u")return;const X=document.querySelector(`script[src="${C}"]`);if(X){if(window[W])return;await new Promise(se=>{X.addEventListener("load",se,{once:!0}),X.addEventListener("error",se,{once:!0})});return}await new Promise(se=>{const U=document.createElement("script");U.src=C,Yr(U,C),U.async=!0,U.addEventListener("load",se,{once:!0}),U.addEventListener("error",se,{once:!0}),document.head.appendChild(U)})}function O(C=document){let W=C.activeElement;for(;W&&W.shadowRoot&&W.shadowRoot.activeElement;)W=W.shadowRoot.activeElement;return W}function I(C){const W=C==null?void 0:C._onKeyDown;typeof W=="function"&&(C._onKeyDown=function(X){const se=O();return!se||se===X.target||typeof se.value!="string"?W.call(C,X):W.call(C,new Proxy(X,{get(U,$e){if($e==="target"||$e==="srcElement")return se;const be=Reflect.get(U,$e);return typeof be=="function"?be.bind(U):be}}))})}async function G(){await K(L,"MapboxGeocoder")}async function Z(){if(typeof window<"u"&&window.MaplibreGeocoder||typeof document>"u")return;const C=document.querySelector(`script[src="${P}"]`);if(C){if(window.MaplibreGeocoder)return;await new Promise(W=>{C.addEventListener("load",W,{once:!0}),C.addEventListener("error",W,{once:!0})});return}await new Promise((W,X)=>{const se=document.createElement("script");se.src=P,se.async=!1,se.addEventListener("load",W,{once:!0}),se.addEventListener("error",()=>X(new Error("[GeocoderComponent] Failed to load MapLibre geocoder")),{once:!0}),document.head.appendChild(se)})}function D(C,W){return async X=>{const se={features:[]};if(!/^pk\./.test(String(C||""))||!(X!=null&&X.query))return se;try{const U=Array.isArray(X.language)?X.language[0]:X.language||W()||"en",$e=new URLSearchParams({access_token:C,autocomplete:"true",limit:String(X.limit||5)});U&&$e.set("language",U);const be=`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(X.query)}.json?${$e.toString()}`,Se=await fetch(be);if(!Se.ok)return se;const we=await Se.json();return we&&Array.isArray(we.features)?we:se}catch{return se}}}ho(async()=>{var U,$e,be,Se,we;const C=s.provider==="maplibre";if(C){if(await Z(),typeof MaplibreGeocoder>"u"){console.error("[GeocoderComponent] MaplibreGeocoder global unavailable.");return}}else if(typeof MapboxGeocoder>"u"&&(await G(),typeof MapboxGeocoder>"u")){console.error("[GeocoderComponent] MapboxGeocoder global unavailable.");return}const W=s.mapInstance;if(!s.standalone&&!W)return;const X=s.standalone?($e=(U=A.value)==null?void 0:U.getRootNode)==null?void 0:$e.call(U):(we=(Se=(be=W.getContainer)==null?void 0:be.call(W))==null?void 0:Se.getRootNode)==null?void 0:we.call(Se);X instanceof ShadowRoot&&J(X,s.provider);const se={marker:!1,flyTo:!s.standalone,trackProximity:!s.standalone,placeholder:l.value,language:r.value||"en",localGeocoder:y,limit:20,zoom:6,render:b};if(C){const Le=typeof maplibregl<"u"?maplibregl:void 0,B={forwardGeocode:D(s.accessToken,()=>r.value)};v.value=new MaplibreGeocoder(B,{...se,maplibregl:Le,showResultsWhileTyping:!0,reverseGeocode:!1})}else v.value=new MapboxGeocoder({accessToken:s.accessToken,mapboxgl,...se});if(I(v.value),v.value.on("result",Le=>{var de,ue,me,S,R,T,Q,ae,ne,he,pe,_,k,M,H,ie,re,z,j,_e,Ee,qe,ft,nt,Pt,so,bt,N,ee,xe;const B=Le==null?void 0:Le.result;B&&((de=B.place_type)!=null&&de.includes("doxa-section-header")||(f&&(f.selectedRegion=null,f.selectedResource=null,f.selectedAffinityBlock=null,f.selectedDialect=null),m&&((ue=m.setPrayerFilter)==null||ue.call(m,null),(me=m.setEngagementFilter)==null||me.call(m,null),(S=m.setAdoptionFilter)==null||S.call(m,null),(R=m.setReligionFilter)==null||R.call(m,null)),(T=B.properties)!=null&&T._allDataSection&&f&&(f.selectedFamily=null,f.selectedLanguage=null),u("result",Le),(Q=B.place_type)!=null&&Q.includes("people-group")&&B.feature?u("people-group-result",{type:"Feature",properties:B.properties||B.feature,geometry:B.geometry||{type:"Point",coordinates:B.center}}):((ae=B.place_type)!=null&&ae.includes("doxa-country")||(ne=B.place_type)!=null&&ne.includes("doxa-region")||(he=B.place_type)!=null&&he.includes("doxa-language-family")||(pe=B.place_type)!=null&&pe.includes("doxa-language")||(_=B.place_type)!=null&&_.includes("doxa-dialect")||(k=B.place_type)!=null&&k.includes("doxa-religion")||(M=B.place_type)!=null&&M.includes("doxa-affinity-bloc")||(H=B.place_type)!=null&&H.includes("doxa-cluster")||(ie=B.place_type)!=null&&ie.includes("doxa-people-group"))&&u("aggregate-result",{kind:B.place_type[0].replace(/^doxa-/,""),label:((re=B.properties)==null?void 0:re.label)||B.text,count:((z=B.properties)==null?void 0:z.count)||0,memberIds:((j=B.properties)==null?void 0:j.memberIds)||[],bounds:((_e=B.properties)==null?void 0:_e.bounds)||null,center:B.center,originalLabels:((Ee=B.properties)==null?void 0:Ee.originalLabels)||null,familyDerived:((qe=B.properties)==null?void 0:qe.familyDerived)||"",baseLang:((ft=B.properties)==null?void 0:ft.baseLang)||"",dialectLabel:((nt=B.properties)==null?void 0:nt.dialectLabel)||"",slug:((Pt=B.properties)==null?void 0:Pt.slug)||null,id:B.id||null,blocCode:((so=B.properties)==null?void 0:so.blocCode)||"",blocLabel:((bt=B.properties)==null?void 0:bt.blocLabel)||"",clusterCode:((N=B.properties)==null?void 0:N.clusterCode)||"",clusterLabel:((ee=B.properties)==null?void 0:ee.clusterLabel)||"",peopleGroupCode:((xe=B.properties)==null?void 0:xe.peopleGroupCode)||"",properties:B.properties||null})))}),v.value.on("clear",()=>u("clear")),v.value.on("error",Le=>u("error",Le)),s.standalone){if(A.value){const Le={on(){},off(){},fire(){},getContainer:()=>A.value,getZoom:()=>0,getCenter:()=>({lng:0,lat:0}),getBounds:()=>null,flyTo(){},fitBounds(){},addControl(){},removeControl(){},hasControl:()=>!1};try{const B=v.value.onAdd(s.mapInstance||Le);B&&A.value.appendChild(B)}catch(B){u("error",B)}}}else W.addControl(v.value,"top-left"),le()});function le(){var W,X;const C=(X=(W=v.value)==null?void 0:W.container)==null?void 0:X.parentElement;C&&(C.classList.add("dg-search-band"),C.classList.toggle("dg-search-band--dark",!!s.isDark))}return et(()=>s.isDark,()=>le()),et(l,C=>{var se,U;const W=v.value;if(!W)return;const X=W._inputEl||((U=(se=W.container)==null?void 0:se.querySelector)==null?void 0:U.call(se,"input.mapboxgl-ctrl-geocoder--input"));X&&(X.placeholder=C,X.setAttribute("placeholder",C)),W.options&&(W.options.placeholder=C)}),et(r,C=>{const W=v.value;W!=null&&W.options&&(W.options.language=C||"en")}),Xt(()=>{var C,W;if(v.value){try{s.standalone?(W=(C=v.value).onRemove)==null||W.call(C):s.mapInstance&&s.mapInstance.removeControl(v.value)}catch{}v.value=null}}),t({geocoder:v}),(C,W)=>e.standalone?(q(),oe("div",{key:0,ref_key:"standaloneContainer",ref:A,class:"dg-standalone-geocoder"},null,512)):An(C.$slots,"default",{},void 0,void 0,1)}},WP=["mapbox","maplibre"],qP="auto";function pg(e){return e&&typeof e=="object"&&"value"in e&&!("provider"in e)&&!("profile"in e)?e.value:e}function gg(e){const t=o=>typeof o=="string"&&!!o.trim()&&!/^YOUR_/.test(o.trim());return t(e==null?void 0:e.tk)||/^https?:\/\//i.test(String((e==null?void 0:e.tokenUrl)||""))?!0:typeof window>"u"?!1:t(window.MAP_TOKEN)||t(window.__doxaMapToken)||!!window.__doxaMapTokenPending}function YP(e,{token:t}={}){const o=pg(e);return ZP(o)||(gg(o)||gg({tk:t})?"mapbox":"maplibre")}function ZP(e){const t=pg(e),o=t==null?void 0:t.provider,n=typeof location<"u"?new URLSearchParams(location.search).get("provider"):void 0,a=typeof window<"u"?window.MAP_PROVIDER:void 0,r=String(o||n||a||qP).toLowerCase().trim();return WP.includes(r)?r:""}const JP="rgba(120, 128, 134, 0.28)",hg="36px",fg=()=>{};function XP(e,t={}){const{enabled:o=!0}=t;if(!o||!e)return fg;const n=Array.from(e.querySelectorAll(".map-scroll-edge"));if(!n.length)return fg;const a=m=>m.classList.contains("map-scroll-edge--left");for(const m of n)m.style.background=`linear-gradient(${a(m)?"to right":"to left"}, ${JP} ${hg}, transparent ${hg})`,m.style.opacity="0",m.style.transition="opacity 0.16s ease",m.style.userSelect="none",m.style.webkitUserSelect="none";const r=m=>{m.style.opacity="1"},s=m=>{m.style.opacity="0"},i=()=>n.find(m=>!a(m))||null,l=new Set;let u=!1,c=null;const p=()=>{for(const m of n)l.has(m)||s(m)},d=()=>{const m=i();m&&(r(m),c&&clearTimeout(c),c=setTimeout(p,250))},x=()=>d(),$=m=>{if(!(m.touches&&m.touches.length===1))return;const h=m.target;h&&h.classList&&h.classList.contains("map-scroll-edge")||d()},b=()=>{c&&clearTimeout(c),p()};e.addEventListener("wheel",x,{passive:!0}),e.addEventListener("touchmove",$,{passive:!0}),e.addEventListener("touchend",b,{passive:!0}),e.addEventListener("touchcancel",b,{passive:!0});const g=()=>{u||d()};typeof window<"u"&&window.addEventListener("scroll",g,{passive:!0});const f=[];for(const m of n){const h=()=>{l.add(m),r(m)},y=()=>{l.delete(m),s(m)},v=()=>{u=!0,r(m)},A=()=>{u=!1,s(m)};m.addEventListener("mouseenter",h),m.addEventListener("mouseleave",y),m.addEventListener("touchstart",v,{passive:!0}),m.addEventListener("touchend",A,{passive:!0}),f.push(()=>{m.removeEventListener("mouseenter",h),m.removeEventListener("mouseleave",y),m.removeEventListener("touchstart",v),m.removeEventListener("touchend",A)})}return function(){c&&(clearTimeout(c),c=null),e.removeEventListener("wheel",x),e.removeEventListener("touchmove",$),e.removeEventListener("touchend",b),e.removeEventListener("touchcancel",b),typeof window<"u"&&window.removeEventListener("scroll",g);for(const h of f)h();for(const h of n)s(h)}}const QP=Object.fromEntries([{id:"midnight-glow",label:"Midnight Glow",mood:"the prayer-map dark — pins glow like embers",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"night",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["doxa-simple-map","my-upg-100-list"]},{id:"daylight",label:"Daylight",mood:"the same Standard world, lights on",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"day",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["doxa-research-map","gospel-resources"]},{id:"dawn",label:"Dawn",mood:"soft warm horizon — hopeful, quiet",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"dawn",maplibre:"https://tiles.openfreemap.org/styles/positron",bestFor:["doxa-simple-map"]},{id:"dusk",label:"Dusk",mood:"blue hour — calm contrast for bright pins",mapbox:"mapbox://styles/mapbox/standard",lightPreset:"dusk",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["my-upg-100-list"]},{id:"paper",label:"Paper",mood:"near-white minimal — data reads like print",mapbox:"mapbox://styles/mapbox/light-v11",maplibre:"https://tiles.openfreemap.org/styles/positron",bestFor:["research-dashboard","cities-internet"]},{id:"ink",label:"Ink",mood:"near-black minimal — maximum pin contrast",mapbox:"mapbox://styles/mapbox/dark-v11",maplibre:"https://tiles.openfreemap.org/styles/dark",bestFor:["my-upg-100-list","cities-internet"]},{id:"streetlife",label:"Street Life",mood:"full street detail — city-scale work",mapbox:"mapbox://styles/mapbox/streets-v12",maplibre:"https://tiles.openfreemap.org/styles/bright",bestFor:["cities-internet","key-cities"]},{id:"terrain",label:"Terrain",mood:"relief + parks — where people actually live",mapbox:"mapbox://styles/mapbox/outdoors-v12",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["doxa-research-map","country-posters"]},{id:"satellite",label:"Satellite",mood:"imagery — the real ground",mapbox:"mapbox://styles/mapbox/satellite-v9",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["country-posters"]},{id:"hybrid",label:"Hybrid",mood:"imagery + labels — orientation without losing ground truth",mapbox:"mapbox://styles/mapbox/satellite-streets-v12",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["key-cities"]},{id:"wayfinder-day",label:"Wayfinder Day",mood:"high-legibility navigation palette",mapbox:"mapbox://styles/mapbox/navigation-day-v1",maplibre:"https://tiles.openfreemap.org/styles/liberty",bestFor:["gospel-resources"]},{id:"wayfinder-night",label:"Wayfinder Night",mood:"dark navigation — dashboards at night",mapbox:"mapbox://styles/mapbox/navigation-night-v1",maplibre:"https://tiles.openfreemap.org/styles/fiord",bestFor:["research-dashboard"]},{id:"galaxy",label:"Galaxy",mood:"the day side of Earth floating in space — normal land, blue oceans, black void behind the sphere",mapbox:"mapbox://styles/mapbox/standard",maplibre:"https://tiles.versatiles.org/assets/styles/colorful/style.json",bestFor:["research-dashboard","my-upg-100-list"]}].map(e=>[e.id,e]));function cl(e,t="mapbox"){if(typeof e!="string"||!e)return{style:void 0,lightPreset:void 0,paint:void 0};const o=QP[e];return o?t==="maplibre"?{style:o.maplibre,lightPreset:void 0,paint:o.paint}:{style:o.mapbox,lightPreset:o.lightPreset,paint:o.paint}:/^(mapbox:\/\/|https?:\/\/)/.test(e)?{style:e,lightPreset:void 0,paint:void 0}:{style:void 0,lightPreset:void 0,paint:void 0}}const mg={mapbox:"https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-rtl-text/v0.3.0/mapbox-gl-rtl-text.js",maplibre:"https://cdn.jsdelivr.net/npm/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js"};function eS(e){return!!e&&typeof window<"u"&&e===window.maplibregl}function tS(e){if(typeof window>"u")return!1;const t=e?[e]:[window.maplibregl,window.mapboxgl].filter(Boolean);let o=!1;for(const n of t)if(!(!n||!n.setRTLTextPlugin))try{if(eS(n)){if(n.getRTLTextPluginStatus&&n.getRTLTextPluginStatus()!=="unavailable")continue;const a=n.setRTLTextPlugin(mg.maplibre,!0);a&&a.catch&&a.catch(()=>{})}else n.setRTLTextPlugin(mg.mapbox,null,!0);o=!0}catch{}return o}const Vn={mapbox:{global:"mapboxgl",js:Oo.mapboxGlJs.url,css:Oo.mapboxGlCss.url},maplibre:{global:"maplibregl",js:Oo.maplibreGlJs.url,css:Oo.maplibreGlCss.url}};function ul(e){var o;const t=((o=Vn[e])==null?void 0:o.global)||Vn.mapbox.global;return typeof window<"u"?window[t]:void 0}function oS(e){return(Vn[e]||Vn.mapbox).css||null}async function nS(e){const t=Vn[e]||Vn.mapbox;if(ul(e)||typeof document>"u")return;if(!document.querySelector(`link[href="${t.css}"]`)){const n=document.createElement("link");n.rel="stylesheet",n.href=t.css,Yr(n,t.css),document.head.appendChild(n)}const o=document.querySelector(`script[src="${t.js}"]`);if(o){if(ul(e))return;await new Promise(n=>{o.addEventListener("load",n,{once:!0}),o.addEventListener("error",n,{once:!0})});return}await new Promise((n,a)=>{const r=document.createElement("script");r.src=t.js,Yr(r,t.js),r.async=!1,r.addEventListener("load",n,{once:!0}),r.addEventListener("error",()=>a(new Error(`[useMapInstance] Failed to load ${e} engine script`)),{once:!0}),document.head.appendChild(r)})}function aS(e,t){return`hsl(${Math.round(e*360/(t||1))}, 72%, 56%)`}function Xr(e){if(typeof e.count=="number")return e.count;if(typeof e.expected_count=="number")return e.expected_count}function bg(e){const t=parseInt(e&&e.population,10);return Number.isFinite(t)?t:0}function rS(e,t){if(!Array.isArray(t)||t.length===0)return;const o=e&&e.selector;if(o==null)return;if(o.type==="pg_slugs"){const r=new Set(Array.isArray(o.values)?o.values:[]);let s=0;for(const i of t)i&&r.has(i.slug)&&(s+=bg(i));return s}const n=zn(o,t);let a=0;for(const r of t)r&&n.has(r.slug)&&(a+=bg(r));return a}function dl(e,t={}){const o=t.deafCount??123,n=Array.isArray(t.records)?t.records:null,a=e.lists||[],r=e.asia_lists||[],s=e.uncovered_lists||[],i={type:"affinity_bloc",rop1:"A017"},l=r.filter(G=>G.id.startsWith("asia-india")),u=r.filter(G=>G.id.startsWith("asia-china")),c=[...a.map(G=>G.id),"deaf",...l.map(G=>G.id),...u.map(G=>G.id),...s.map(G=>G.id)],p=c.length,d=G=>aS(c.indexOf(G),p),x=(G,Z,D)=>{if(!n)return G;const le=D??(Z&&Z.selector);return G.pop=rS({selector:le},n),G},$=G=>n?G.reduce((Z,D)=>Z+(D.pop||0),0):void 0,b=a.map(G=>x({id:G.id,zoneKey:G.id,label:G.label,...G.provinceLabel?{provinceLabel:G.provinceLabel}:{},color:d(G.id),count:Xr(G)},G)),g=x({id:"deaf",zoneKey:"deaf",label:"Deaf (affinity bloc A017)",color:d("deaf"),count:o,info:"Unified deaf row — affinity bloc rop1=A017 (collapses the two deaf_lists; zero-delta vs old deaf_predicate). Population double-counts vs geographic rows (design-approved, slice 08)."},null,i),f=G=>x({id:G.id,zoneKey:G.id,label:G.label,...G.provinceLabel?{provinceLabel:G.provinceLabel}:{},color:d(G.id),count:Xr(G),...Array.isArray(G.adm0)&&G.adm0.length?{adm0:G.adm0}:{},...Array.isArray(G.provinces)&&G.provinces.length?{provinces:G.provinces}:{}},G),m=l.map(f),h=u.map(f),y=G=>G.reduce((Z,D)=>Z+(Xr(D)||0),0),v={id:"asia-india",label:"India",count:y(l),children:m},A={id:"asia-china",label:"China",count:y(u),children:h};n&&(v.pop=$(m),A.pop=$(h)),y(r),n&&$([v,A]);const w=G=>x({id:G.id,zoneKey:G.id,label:G.label,...G.provinceLabel?{provinceLabel:G.provinceLabel}:{},color:d(G.id),count:Xr(G)},G),P=s.map(w);P.length>0&&(()=>{const G={id:"frontier-asia",label:"Frontier Asia (uncovered)",count:y(s),children:P};return n&&(G.pop=$(P)),G})();const L={"west-africa":"Africa",sudan:"Africa","east-africa":"Africa","central-africa":"Africa","southern-africa-islands":"Africa","maghreb-egypt":"Middle East","middle-east-core":"Middle East","uncovered-nas-a":"Central Asia",laos:"Southeast Asia + Oceania","oceania-indonesia":"Southeast Asia + Oceania","mainland-se-asia-philippines":"Southeast Asia + Oceania",brazil:"Americas","andean-caribbean":"Americas","uncovered-scatter":"Americas",europe:"Europe",deaf:"Deaf","deaf-old-world":"Deaf"},J=G=>L[G]||(String(G).startsWith("asia-india-")?"India":String(G).startsWith("asia-china-")?"China + Mongolia":"Other"),K=[...b,g,...m,...h,...P].filter(Boolean),O=new Map;for(const G of K){const Z=J(G.id||G.zoneKey);O.has(Z)||O.set(Z,[]),O.get(Z).push(G)}const I=[...O.entries()].map(([G,Z])=>{Z.sort((le,C)=>(C.count||0)-(le.count||0));const D={id:"region-"+G.toLowerCase().replace(/[^a-z0-9]+/g,"-"),label:G,count:Z.reduce((le,C)=>le+(C.count||0),0),children:Z};return n&&(D.pop=$(Z)),D}).sort((G,Z)=>(Z.count||0)-(G.count||0));return sS(yg(I),{withPop:!!n}),I}function sS(e,{withPop:t=!1}={}){const o=[];for(const n of e||[]){const a=[];(typeof n.id!="string"||!n.id)&&a.push("id"),(typeof n.zoneKey!="string"||!n.zoneKey)&&a.push("zoneKey"),(typeof n.label!="string"||!n.label)&&a.push("label"),(typeof n.color!="string"||!n.color)&&a.push("color"),typeof n.count!="number"&&a.push("count"),t&&typeof n.pop!="number"&&a.push("pop"),a.length&&o.push(`${n.id||"(no-id)"}: missing/!type [${a.join(", ")}]`)}if(o.length)throw new Error(`legend-tree L15: ${o.length} leaf node(s) violate the uniform consumer shape: `+o.join(` `));return!0}function yg(e){const t=[],o=n=>{for(const a of n)a.children&&a.children.length?o(a.children):t.push(a)};return o(e||[]),t}const $g=()=>({type:"FeatureCollection",features:[]});function iS(e,t){const o=zn(e.selector,t),n=new Set;for(const a of t)a&&o.has(a.slug)&&a.country_code&&n.add(a.country_code);return n}function lS(e){return typeof e.id=="string"&&e.id.startsWith("asia-")}function pl(e,t){return{type:"Feature",properties:{...e.properties||{},zoneKey:t.zoneKey??t.id,zoneColor:t.color??t.zoneColor??"#888",zoneLabel:t.label,...t.id==="deaf"?{hatch:!0}:{}},geometry:e.geometry}}function cS(e,t){const{records:o=[],adm0:n,adm1Ind:a,adm1Chn:r}=t||{},s=$g();if(lS(e)){const l=[a,r].filter(Boolean);for(const u of l)for(const c of u.features||[])c.properties&&c.properties.listId===e.id&&s.features.push(pl(c,e));if(Array.isArray(e.adm0)&&e.adm0.length&&n){const u=new Set(e.adm0);for(const c of n.features||[])c.properties&&u.has(c.properties.iso3)&&s.features.push(pl(c,e))}return s}if(!e.selector)return s;const i=iS(e,o);if(n&&i.size)for(const l of n.features||[])l.properties&&i.has(l.properties.iso3)&&s.features.push(pl(l,e));return s}function uS(e,t){const o=$g(),n=new Map;for(const a of e){if(a.id==="deaf"){n.set(a.zoneKey??a.id,0);continue}const r=cS(a,t);n.set(a.zoneKey??a.id,r.features.length);for(const s of r.features)o.features.push(s)}return{tapestry:o,perZone:n}}const dS={"andean-caribbean":"#f9a51f","asia-china-tibet-autonomous-region":"#00f0c8","asia-china-yunnan-province":"#22ddff","asia-frontier-nas-a":"#ff1744","asia-india-andhra-pradesh":"#22ddff","asia-india-assam":"#22ddff","asia-india-chhattisgarh":"#536dfe","asia-india-gujarat":"#536dfe","asia-india-karnataka":"#536dfe","asia-india-kerala":"#2196ff","asia-india-madhya-pradesh":"#2196ff","asia-india-maharashtra":"#2196ff","asia-india-odisha":"#2196ff","asia-india-rajasthan":"#22ddff","asia-india-tamil-nadu":"#7c4dff","asia-india-uttarakhand":"#536dfe","asia-india-west-bengal":"#22ddff",brazil:"#f4c57b","central-africa":"#c20001",deaf:"#18ffff","east-africa":"#ef3410",europe:"#34cb74",laos:"#7c4dff","maghreb-egypt":"#602f74","mainland-se-asia-philippines":"#ff1744","middle-east-core":"#bc8bd0","oceania-indonesia":"#ee892f","southern-africa-islands":"#e75556",sudan:"#e69e93","uncovered-central-asia":"#ff8a00","uncovered-himalaya":"#ff6d00","uncovered-japan":"#ffc400","uncovered-mongolia":"#76ff03","uncovered-nas-a":"#ff1744","uncovered-nepal":"#ffea00","uncovered-sa-west":"#ff1744","uncovered-scatter":"#eeff41","west-africa":"#edcac9"};function pS(e,t){const o=dS[e];return typeof o=="string"&&o?o:t}const Qr={"Andaman and Nicobar Islands":9,"Andhra Pradesh":81,"Arunāchal Pradesh":7,Assam:15,Bihār:18,Chandīgarh:1,Chhattīsgarh:24,Delhi:1,"Dādra and Nagar Haveli and Damān and Diu":1,Goa:5,Gujarāt:90,Haryāna:4,"Himāchal Pradesh":20,"Jammu and Kashmīr":33,Jhārkhand:9,Karnātaka:81,Kerala:72,Ladākh:6,Lakshadweep:1,"Madhya Pradesh":33,Mahārāshtra:54,Manipur:5,Meghālaya:2,Odisha:64,Puducherry:5,Punjab:4,Rājasthān:48,Sikkim:1,"Tamil Nādu":64,Telangāna:26,Tripura:11,"Uttar Pradesh":23,Uttarākhand:7,"West Bengal":30,"Gansu Province":3,"Guangxi Zhuang Autonomous Region":6,"Guizhou Province":34,"Hainan Province":3,"Heilongjiang Province":2,"Hunan Province":5,"Inner Mongolia Autonomous Region":3,"Qinghai Province":3,"Sichuan Province":12,"Tibet Autonomous Region":13,"Xinjiang Uyghur Autonomous Region":7,"Yunnan Province":61},_g={ABW:1,AFG:21,AGO:10,ALB:1,AND:1,ARE:2,ARM:1,ASM:1,ATG:1,AZE:3,BEN:9,BFA:8,BGD:3,BGR:1,BHR:2,BHS:1,BIH:1,BLM:1,BLR:1,BMU:1,BOL:1,BRA:103,BRB:1,BRN:5,BTN:13,CAF:1,CHN:154,CIV:2,CMR:8,COD:9,COG:2,COK:1,COL:27,COM:3,CUB:1,CUW:1,CYM:1,CYP:1,CZE:1,DJI:1,DMA:1,DZA:17,ECU:1,EGY:3,ERI:8,ESP:1,ETH:29,FIN:1,FJI:1,FRO:1,FSM:1,GAB:2,GEO:1,GGY:1,GHA:1,GIN:13,GLP:1,GMB:3,GNB:3,GNQ:1,GRC:1,GRD:1,GUF:2,GUM:1,GUY:1,IDN:36,IRN:20,IRQ:8,ISL:1,ISR:4,JAM:1,JOR:3,JPN:6,KAZ:1,KEN:5,KGZ:2,KHM:1,KIR:1,KWT:1,LAO:95,LBN:4,LBR:2,LBY:15,LCA:1,LIE:1,LKA:1,LUX:1,MAR:4,MDV:1,MHL:1,MLI:13,MLT:1,MMR:7,MNE:1,MNG:1,MNP:1,MOZ:4,MRT:3,MSR:1,MUS:1,MWI:1,MYS:12,MYT:1,NAM:6,NCL:1,NER:2,NGA:38,NIU:1,NPL:34,NZL:1,OMN:7,PAK:24,PAN:1,PER:10,PHL:1,PLW:1,PNG:1,PRK:1,PRY:1,PSE:4,PYF:1,QAT:3,RUS:21,SAU:3,SDN:105,SEN:1,SHN:1,SLB:1,SLE:2,SMR:1,SOM:9,SSD:22,STP:1,SUR:2,SWE:2,SWZ:1,SYR:5,TCA:1,TCD:53,TGO:6,THA:8,TJK:3,TON:1,TUN:2,TUR:3,TZA:16,UGA:6,USA:3,UZB:1,VCT:1,VEN:6,VGB:1,VIR:1,VNM:16,VUT:1,WLF:1,WSM:1,YEM:9,ZAF:2,ZMB:6,ZWE:3},Oa={ABW:"Aruba",IND:"India",AFG:"Afghanistan",AGO:"Angola",ALB:"Albania",AND:"Andorra",ARE:"United Arab Emirates",ARM:"Armenia",ASM:"American Samoa",ATG:"Antigua and Barbuda",AZE:"Azerbaijan",BEN:"Benin",BFA:"Burkina Faso",BGD:"Bangladesh",BGR:"Bulgaria",BHR:"Bahrain",BHS:"Bahamas",BIH:"Bosnia and Herzegovina",BLM:"Saint Barthélemy",BLR:"Belarus",BMU:"Bermuda",BOL:"Bolivia",BRA:"Brazil",BRB:"Barbados",BRN:"Brunei",BTN:"Bhutan",CAF:"Central African Republic",CHN:"China",CIV:"Côte d'Ivoire",CMR:"Cameroon",COD:"DR Congo",COG:"Congo",COK:"Cook Islands",COL:"Colombia",COM:"Comoros",CUB:"Cuba",CUW:"Curaçao",CYM:"Cayman Islands",CYP:"Cyprus",CZE:"Czechia",DJI:"Djibouti",DMA:"Dominica",DZA:"Algeria",ECU:"Ecuador",EGY:"Egypt",ERI:"Eritrea",ESP:"Spain",ETH:"Ethiopia",FIN:"Finland",FJI:"Fiji",FRO:"Faroe Islands",FSM:"Micronesia",GAB:"Gabon",GEO:"Georgia",GGY:"Guernsey",GHA:"Ghana",GIN:"Guinea",GLP:"Guadeloupe",GMB:"Gambia",GNB:"Guinea-Bissau",GNQ:"Equatorial Guinea",GRC:"Greece",GRD:"Grenada",GUF:"French Guiana",GUM:"Guam",GUY:"Guyana",IDN:"Indonesia",IRN:"Iran",IRQ:"Iraq",ISL:"Iceland",ISR:"Israel",JAM:"Jamaica",JOR:"Jordan",JPN:"Japan",KAZ:"Kazakhstan",KEN:"Kenya",KGZ:"Kyrgyzstan",KHM:"Cambodia",KIR:"Kiribati",KWT:"Kuwait",LAO:"Laos",LBN:"Lebanon",LBR:"Liberia",LBY:"Libya",LCA:"Saint Lucia",LIE:"Liechtenstein",LKA:"Sri Lanka",LUX:"Luxembourg",MAR:"Morocco",MDV:"Maldives",MHL:"Marshall Islands",MLI:"Mali",MLT:"Malta",MMR:"Myanmar",MNE:"Montenegro",MNG:"Mongolia",MNP:"Northern Mariana Islands",MOZ:"Mozambique",MRT:"Mauritania",MSR:"Montserrat",MUS:"Mauritius",MWI:"Malawi",MYS:"Malaysia",MYT:"Mayotte",NAM:"Namibia",NCL:"New Caledonia",NER:"Niger",NGA:"Nigeria",NIU:"Niue",NPL:"Nepal",NZL:"New Zealand",OMN:"Oman",PAK:"Pakistan",PAN:"Panama",PER:"Peru",PHL:"Philippines",PLW:"Palau",PNG:"Papua New Guinea",PRK:"North Korea",PRY:"Paraguay",PSE:"Palestine",PYF:"French Polynesia",QAT:"Qatar",RUS:"Russia",SAU:"Saudi Arabia",SDN:"Sudan",SEN:"Senegal",SHN:"Saint Helena",SLB:"Solomon Islands",SLE:"Sierra Leone",SMR:"San Marino",SOM:"Somalia",SSD:"South Sudan",STP:"São Tomé and Príncipe",SUR:"Suriname",SWE:"Sweden",SWZ:"Eswatini",SYR:"Syria",TCA:"Turks and Caicos Islands",TCD:"Chad",TGO:"Togo",THA:"Thailand",TJK:"Tajikistan",TON:"Tonga",TUN:"Tunisia",TUR:"Turkey",TZA:"Tanzania",UGA:"Uganda",USA:"United States",UZB:"Uzbekistan",VCT:"Saint Vincent and the Grenadines",VEN:"Venezuela",VGB:"British Virgin Islands",VIR:"U.S. Virgin Islands",VNM:"Vietnam",VUT:"Vanuatu",WLF:"Wallis and Futuna",WSM:"Samoa",YEM:"Yemen",ZAF:"South Africa",ZMB:"Zambia",ZWE:"Zimbabwe"};function vg(e){const t={...Oa};for(const o of e||[]){const n=o&&o.country_code,a=o&&o.country_code_label;n&&a&&(t[n]=a)}return t}function wg(e,t={}){if(!e||typeof e!="object")return null;const o=t.nameMap||Oa;if(e.shapeName){const n=String(e.shapeName),a=Object.prototype.hasOwnProperty.call(Qr,n)?Qr[n]:null;return{key:"adm1:"+n,name:n,count:a,kind:"adm1"}}if(e.iso3){const n=String(e.iso3),a=o[n]||Oa[n]||n,r=Object.prototype.hasOwnProperty.call(_g,n)?_g[n]:null;return{key:"adm0:"+n,name:a,count:r,kind:"adm0"}}return null}function gS(e,t={}){const o=Array.isArray(e)?e:[],n=o.map(l=>l.name),a=o.reduce((l,u)=>l+(Number(u.count)||0),0),r=t&&typeof t.color=="string"&&t.color?t.color:"",s=n.join(", ")+" — "+a+" UUPG"+(r?" · "+r:""),i=o.map(l=>l.name+" "+(Number(l.count)||0)).join(", ");return s+` -`+i}function Kn(e){return String(e??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function hS(e){return Kn(e).split(/[\s,;]+/).filter(Boolean)}function fS(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null}=e,s=[],i=new Set;for(const u of t){if(!u)continue;const c=u.slug;if(!c||i.has(c))continue;const p=Number(u.latitude),d=Number(u.longitude);if(!Number.isFinite(p)||!Number.isFinite(d))continue;const x=u.name||c;i.add(c),s.push({label:x,kind:"pg",target:{type:"pg",slug:c,lng:d,lat:p},_hay:Kn(x)})}for(const u of o){if(!u)continue;const c=u.zoneKey||u.id,p=u.label||c;c&&s.push({label:p,kind:"zone",target:{type:"zone",zoneId:c},_hay:Kn(p)})}for(const u of Object.keys(n))s.push({label:u,kind:"territory",target:{type:"territory",shapeName:u},_hay:Kn(u)});const l=r||a;for(const u of Object.keys(a)){const c=l&&l[u]||a[u]||u;s.push({label:c,kind:"territory",target:{type:"territory",shapeName:u,iso3:!0},_hay:Kn(c)})}return s}const mS={zone:0,territory:1,pg:2};function bS(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null,centroidFor:s=null}=e,i=[];for(const c of t)c&&i.push(c);const l=(c,p,d)=>!p||!Number.isFinite(p[0])||!Number.isFinite(p[1])?null:{name:c,slug:d.__synthSlug,latitude:p[1],longitude:p[0],...d};for(const c of o){if(!c)continue;const p=c.zoneKey||c.id,d=c.label||p;if(!p)continue;const x=typeof s=="function"?s(b=>b&&b.properties&&b.properties.zoneKey===p):null,$=l(d,x,{__upgKind:"zone",__zoneId:p,__synthSlug:`__zone__${p}`});$&&i.push($)}for(const c of Object.keys(n)){const p=typeof s=="function"?s(x=>x&&x.properties&&x.properties.shapeName===c):null,d=l(c,p,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});d&&i.push(d)}const u=r||a;for(const c of Object.keys(a)){const p=u&&u[c]||a[c]||c,d=typeof s=="function"?s($=>$&&$.properties&&$.properties.iso3===c):null,x=l(p,d,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});x&&i.push(x)}return i}function kg(e,t,o={}){const n=o.limit??8,a=hS(t);if(!a.length)return[];const r=a[0],s=[];for(const i of e){let l=!0;for(const p of a)if(!i._hay.includes(p)){l=!1;break}if(!l)continue;const u=i._hay.startsWith(r)?0:1,c=i._hay===Kn(t)?-1:0;s.push({e:i,starts:u,exact:c,kr:mS[i.kind]??9,len:i._hay.length})}return s.sort((i,l)=>i.exact-l.exact||i.starts-l.starts||i.kr-l.kr||i.len-l.len),s.slice(0,n).map(i=>i.e)}const yS={class:"upg-root"},$S={key:0,class:"upg-map-err"},_S={class:"upg-legend-desktop-slot"},vS={class:"upg-legend-mobile-slot"},wS={class:"upg-detail-desktop-slot"},kS={key:4,class:"upg-hud"},xS={key:0,class:"upg-hud-head"},PS={class:"upg-hud-total"},SS={key:1,class:"upg-hud-names"},AS={key:2,class:"upg-hud-actions"},LS=["disabled"],CS=["disabled"],TS={key:3,class:"upg-hud-flash"},ES={class:"upg-status"},gl="upg-search",xg=1,RS="people-groups",Pg=8,hl=123,MS=Object.freeze(Object.defineProperty({__proto__:null,default:{__name:"upg-100-list",setup(e){const t=Eu(()=>yt(()=>Promise.resolve().then(()=>eP),void 0)),o={lists:rp,asia_lists:sp,uncovered_lists:ip},n=Ue("mapboxToken",fe("")),a=Ue("profileConfig",fe(null)),r=YP(a),s=r==="maplibre",i=te(()=>{var F;return((F=a==null?void 0:a.value)==null?void 0:F.search)===!1?!1:r==="mapbox"}),l=te(()=>{var V;const F=(V=a.value)==null?void 0:V.edgeScrollAffordance;return F==null?!0:!(F===!1||F==="false")}),u=Ue("dataStore",null),c=Ue("uiStore",null),p=fe(null),d=fe("loading…"),x=fe(""),$=wn([]),b=fe(null),g=wn(null),f=fe(!1),m=O1("my-upg-100-list");m.theme.value="light",D1(m);const h=fe([]),y=te(()=>h.value.reduce((F,V)=>F+(Number(V.count)||0),0)),v=te(()=>h.value.length),A=fe("");let w=null;const P=fe(!1);function L(F){const V=F===void 0?!P.value:!!F;return V===P.value||(P.value=V,C&&(C.getCanvas().style.cursor=""),R()),V}function J(){L()}et([P,f],()=>{qt(()=>nt())});function K(F){if(!F)return;const V=h.value,Y=V.findIndex(ye=>ye.key===F.key);Y>=0?h.value=V.filter((ye,Ae)=>Ae!==Y):h.value=[...V,F],R(),A.value=""}const O=fe(""),I=fe("");function G(F){const V=/^#?([0-9a-fA-F]{6})$/.exec(String(F||"").trim());if(!V)return;const Y="#"+V[1].toLowerCase();O.value=O.value===Y?"":Y,R()}const Z=fe(null),D=[{id:"upg100Region",label:"Region",info:"Region — sort the UPG-100 lists by world area (Africa, India, Middle East, Deaf, …). Counts are the UUPGs and population summed across every list beneath it."},{id:"upg100Zone",label:"UPG-100 Lists",info:"UPG-100 Lists — each one is a prayer list of the unreached people groups in an area, and is what the map paints and colours. Every list prints as its own packet."}];let le=[],C=null,W=null,X=[],se=null,U=null,$e=null;const be=typeof window<"u"&&window.MAP_APP_API_URL||void 0||"",{locale:Se,t:we}=xt(),Le=te(()=>we("legend.title.upg100List")),B=te(()=>we("search.upg100Placeholder"));Lt(`.upg-root{position:absolute;inset:0;background:#0a1410;color:#e5e7eb;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.upg-map{position:absolute;inset:0}.upg-map-err{position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);z-index:1;pointer-events:none;text-align:center;padding:0 24px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#9aa7b8}.upg-map-err strong{display:block;font-size:14px;color:#cbd5e1;margin-bottom:4px}.map-scroll-edge{position:absolute;top:0;bottom:0;width:40px;z-index:2;touch-action:pan-y;pointer-events:auto;background:transparent}.map-scroll-edge--left{left:0}.map-scroll-edge--right{right:0}.upg-legend-desktop-slot{--stl-top:8px}.upg-legend-mobile-slot{display:none}@media(max-width:767px){.upg-legend-mobile-slot{display:block}.upg-legend-desktop-slot{display:none}.upg-detail-desktop-slot{display:none}}.upg-status{position:absolute;bottom:10px;right:10px;z-index:5;font:10px/1 ui-monospace,monospace;color:#9aa7b8;background:rgba(10,14,21,.82);padding:6px 10px;border-radius:8px}.upg-detail-panel{position:absolute;top:60px;right:8px;bottom:10px;width:340px;max-width:calc(100vw - 16px);z-index:6;background:#fff;border-radius:12px;box-shadow:0 8px 28px rgba(0,0,0,.45);overflow:hidden;display:flex;flex-direction:column;animation:upgPanelIn .18s ease}.upg-detail-panel.dark{background:#1a1a2e}@keyframes upgPanelIn{from{transform:translateX(16px);opacity:0}to{transform:translateX(0);opacity:1}}@media(max-width:480px){.upg-detail-panel{top:auto;left:8px;right:8px;width:auto;height:55vh}}.upg-hud{position:absolute;bottom:34px;right:10px;z-index:6;min-width:150px;font:11px/1.35 ui-monospace,monospace;color:#e5e7eb;background:rgba(10,20,16,.92);border:1px solid rgba(110,231,183,.35);border-radius:10px;padding:8px 10px;box-shadow:0 4px 16px rgba(0,0,0,.4)}.upg-hud-head{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.upg-hud-total{font-size:15px;font-weight:700;color:#6ee7b7}.upg-hud-band{margin-left:auto;font-size:9px;color:#9aa7b8}.upg-hud-band.ok{color:#6ee7b7}.upg-hud-names{margin-top:5px;max-height:84px;overflow:auto;font-size:10px;color:#cbd5e1;line-height:1.45;word-break:break-word}.upg-hud-actions{display:flex;gap:6px;margin-top:7px}.upg-hud-btn{flex:1;cursor:pointer;border:1px solid rgba(110,231,183,.4);background:rgba(16,185,129,.18);color:#d1fae5;font:12px/1 ui-monospace,monospace;padding:0 10px;min-height:40px;border-radius:8px}.upg-hud-btn:hover{background:rgba(16,185,129,.32)}.upg-hud-btn.clear{background:rgba(148,163,184,.12);border-color:rgba(148,163,184,.4);color:#cbd5e1}.upg-hud-flash{margin-top:5px;font-size:9px;color:#6ee7b7;min-height:11px}.upg-hud-hint{margin-top:4px;font-size:9px;color:#64748b}.upg-hud-swatches{display:flex;gap:6px;margin-top:7px;align-items:center;flex-wrap:wrap}.upg-swatch{width:40px;height:40px;border-radius:9px;cursor:pointer;padding:0;border:1px solid rgba(255,255,255,.3)}.upg-swatch.active{outline:2px solid #fff;outline-offset:1px}.upg-hex{width:84px;min-height:40px;background:rgba(148,163,184,.12);border:1px solid rgba(148,163,184,.4);color:#cbd5e1;font:12px/1 ui-monospace,monospace;padding:0 8px;border-radius:8px}@media(max-width:480px){.upg-hud{left:8px;right:8px;min-width:0;bottom:30px;max-height:48vh;overflow:auto}}.map-toolbar .mcb.upg-batch-on{background:#10b981!important;color:#04241a!important;box-shadow:0 0 0 2px rgba(52,211,153,.45),0 1px 4px rgba(0,0,0,0.2)!important}.map-toolbar .mcb.upg-batch-on.dark{border-color:#34d399!important}.upg-batch-row{position:relative;background:rgba(16,185,129,.16)!important;opacity:1!important;box-shadow:inset 3px 0 0 0 #10b981}.upg-batch-row .stl-name{color:#065f46!important;font-weight:700}.stl-panel[data-theme="dark"] .upg-batch-row .stl-name,.upg-batch-row.dark .stl-name{color:#6ee7b7!important}.upg-batch-row .stl-dot{box-shadow:0 0 0 2px #10b981}.mapboxgl-ctrl-top-left{top:12px!important;left:8px!important;width:380px!important;max-width:380px!important;z-index:1200!important}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{margin:0!important;float:none!important}.stl-panel{--stl-top:8px!important}.upg-root:has(.mapboxgl-ctrl-geocoder) .stl-panel{--stl-top:58px!important}[dir="rtl"] .upg-detail-panel{right:auto!important;left:8px!important}[dir="rtl"] .stl-panel,[dir="rtl"] .stl-panel *{direction:rtl}[dir="rtl"] .stl-panel .stl-count,[dir="rtl"] .stl-panel .stl-pop{direction:ltr;unicode-bidi:isolate}.dg-main{font:13px/1.3 ui-monospace,monospace}.dg-meta{margin-top:2px;font-size:11px;color:#475569;display:flex;flex-wrap:wrap;gap:8px}.dg-field strong{font-weight:700}.dg-section-header-item{padding:4px 8px;font:10px/1.2 ui-monospace,monospace;letter-spacing:.06em;text-transform:uppercase;color:#94a3b8;pointer-events:none}`);function de(F){const V=[];for(const Y of F)V.push(Y.zoneKey,pS(Y.zoneKey,Y.color));return["match",["get","zoneKey"],...V,"#9ca3af"]}function ue(){if(C.getSource("tapestry")&&C.getLayer("tapestry-fill")&&C.getLayer("tapestry-line"))return;C.getSource("tapestry")||C.addSource("tapestry",{type:"geojson",data:W});const F=f.value?.45:.3,V=f.value?.65:.45;if(C.getLayer("tapestry-fill")||C.addLayer({id:"tapestry-fill",type:"fill",source:"tapestry",paint:{"fill-color":se,"fill-opacity":["case",["==",["get","zoneKey"],"deaf"],F,V]}}),C.getLayer("tapestry-line")||C.addLayer({id:"tapestry-line",type:"line",source:"tapestry",paint:{"line-color":se,"line-width":1.2,"line-opacity":.9}}),mn){const Y=mn;qt(()=>{mn===Y&&za(Y)})}}function me(){!C||!C.getSource("tapestry")||C.getLayer("upg-sel-fill")||(C.addLayer({id:"upg-sel-fill",type:"fill",source:"tapestry",filter:["boolean",!1],paint:{"fill-color":"#f59e0b","fill-opacity":.28}}),C.addLayer({id:"upg-sel-line",type:"line",source:"tapestry",filter:["boolean",!1],paint:{"line-color":"#fbbf24","line-width":2.4,"line-opacity":.95}}))}function S(){const F=[],V=[],Y=[];for(const Ae of h.value)Ae.kind==="adm1"?F.push(Ae.name):Ae.kind==="adm0"?V.push(Ae.key.slice(5)):Ae.kind==="zone"&&Y.push(Ae.key.slice(5));const ye=[];return F.length&&ye.push(["in",["get","shapeName"],["literal",F]]),V.length&&ye.push(["in",["get","iso3"],["literal",V]]),Y.length&&ye.push(["in",["get","zoneKey"],["literal",Y]]),ye.length?ye.length===1?ye[0]:["any",...ye]:["boolean",!1]}function R(){if(nt(),!C||!C.getLayer("upg-sel-fill"))return;const F=P.value?S():["boolean",!1];C.setFilter("upg-sel-fill",F),C.setFilter("upg-sel-line",F);const V=O.value;C.setPaintProperty("upg-sel-fill","fill-color",V||"#f59e0b"),C.setPaintProperty("upg-sel-fill","fill-opacity",V?.55:.28),C.setPaintProperty("upg-sel-line","line-color",V||"#fbbf24")}let T=null,Q=!1;function ae(){if(!(!C||!C.getLayer("tapestry-fill"))){if(T)try{C.off("click","tapestry-fill",T)}catch{}T=F=>{const V=F&&F.features&&F.features[0];if(V&&P.value){const Y=wg(V.properties,{nameMap:w});if(!Y){console.warn("[batch-select] clicked feature has no shapeName/iso3",V.properties);return}Y.count==null&&console.warn("[batch-select] no UUPG count for territory",Y.name,V.properties),K(Y)}},C.on("click","tapestry-fill",T),Q||(C.on("mouseenter","tapestry-fill",()=>{C&&(C.getCanvas().style.cursor=P.value?"crosshair":"")}),C.on("mouseleave","tapestry-fill",()=>{C&&(C.getCanvas().style.cursor="")}),Q=!0)}}function ne(){h.value=[],A.value="",O.value="",I.value="",R()}function he(F){if(u&&typeof u.cacheSourceData=="function"){const V=bS({records:F,leafZones:X,adm1Counts:Qr,iso3Names:Oa,countryNameMap:w,centroidFor:Y=>{const ye=z(Y);return ye?[(ye[0][0]+ye[1][0])/2,(ye[0][1]+ye[1][1])/2]:null}});u.cacheSourceData(gl,{normalizedData:V})}le=fS({records:F,leafZones:X,adm1Counts:Qr,iso3Names:Oa,countryNameMap:w}),typeof window<"u"&&(window.__UPG_SEARCH__={size:()=>le.length,counts:()=>{const V={pg:0,zone:0,territory:0};for(const Y of le)V[Y.kind]=(V[Y.kind]||0)+1;return V},query:V=>kg(le,V,{limit:Pg}).map(Y=>({label:Y.label,kind:Y.kind,target:Y.target})),select:V=>{const Y=kg(le,V,{limit:Pg})[0];return Y?(M(Y.target),{label:Y.label,kind:Y.kind,target:Y.target}):null},feedSize:()=>{const V=u&&u.sources&&u.sources[gl];return V&&Array.isArray(V.features)&&V.features.length||0},localGeocoder:V=>{const Y=Z.value&&Z.value.geocoder,ye=Y&&Y.options&&Y.options.localGeocoder;return ye?ye(V).map(Ae=>Ae&&Ae.place_name):null}})}function pe(F){const V=F&&F.properties||{},Y=V.__upgKind;if(Y==="zone")ie(V.__zoneId);else if(Y==="territory")re(V.__shapeName);else{const ye=F&&F.geometry,Ae=ye&&Array.isArray(ye.coordinates)?ye.coordinates:null;Ae&&Number.isFinite(Ae[0])&&Number.isFinite(Ae[1])&&C&&C.flyTo({center:[Ae[0],Ae[1]],zoom:6,duration:800}),H(V.slug)}}function _(F){if(!F||!C)return;const V=new Set(F.memberIds||[]);if(!V.size)return;let Y=[];try{Y=C.querySourceFeatures("upg").filter(He=>{const Pe=He.properties||{};return V.has(Pe.slug)||V.has(Pe.id)||V.has(Pe.peopleGroupId)})}catch{return}if(!Y.length)return;let ye=180,Ae=90,Be=-180,Ke=-90,ze=!1;for(const He of Y){const Pe=He.geometry&&He.geometry.coordinates;!Array.isArray(Pe)||!Number.isFinite(Pe[0])||!Number.isFinite(Pe[1])||(Pe[0]Be&&(Be=Pe[0]),Pe[1]Ke&&(Ke=Pe[1]),ze=!0)}ze&&C.fitBounds([[ye,Ae],[Be,Ke]],{padding:60,duration:800,maxZoom:6})}function k(){qn(null),c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(null)}function M(F){!F||!C||(F.type==="pg"?(Number.isFinite(F.lng)&&Number.isFinite(F.lat)&&C.flyTo({center:[F.lng,F.lat],zoom:6,duration:800}),H(F.slug)):F.type==="zone"?ie(F.zoneId):F.type==="territory"&&re(F.shapeName))}function H(F){if(!F||!c||typeof c.selectPeopleGroup!="function")return;const V=C&&C.getSource&&C.getSource("upg"),ye=(V&&V._data&&V._data.features||[]).find(Ae=>Ae.properties&&Ae.properties.slug===F);ye&&c.selectPeopleGroup(ye)}function ie(F){if(!F||!C||!W)return;const V=z(Y=>Y.properties&&Y.properties.zoneKey===F);V&&C.fitBounds(V,{padding:40,duration:800,maxZoom:6})}function re(F){if(!F||!C||!W)return;const V=z(Y=>{const ye=Y.properties||{};return ye.shapeName===F||ye.iso3===F});V&&C.fitBounds(V,{padding:40,duration:800,maxZoom:6})}function z(F){let V=180,Y=90,ye=-180,Ae=-90,Be=!1;const Ke=ze=>{if(typeof ze[0]=="number"){const[He,Pe]=ze;Heye&&(ye=He),PeAe&&(Ae=Pe),Be=!0;return}for(const He of ze)Ke(He)};for(const ze of W.features)F(ze)&&Ke(ze.geometry.coordinates);return Be?[[V,Y],[ye,Ae]]:null}function j(F){const V=new Set,Y=ye=>{ye.children&&ye.children.length?ye.children.forEach(Y):V.add(ye.zoneKey??ye.id)};return Y(F),V}let _e=null;function Ee(F){if(![...j(F)].length)return;const Y=[],ye=ze=>{ze.children&&ze.children.length?ze.children.forEach(ye):Y.push(ze)};ye(F);const Ae=h.value,Be=new Set(Ae.filter(ze=>ze.kind==="zone").map(ze=>ze.key));if(Y.every(ze=>Be.has("zone:"+(ze.zoneKey??ze.id)))){const ze=new Set(Y.map(He=>"zone:"+(He.zoneKey??He.id)));h.value=Ae.filter(He=>!ze.has(He.key))}else{const ze=Y.filter(He=>!Be.has("zone:"+(He.zoneKey??He.id))).map(He=>({key:"zone:"+(He.zoneKey??He.id),name:He.label||He.id,count:Number(He.count)||0,kind:"zone"}));h.value=[...Ae,...ze]}R(),A.value=""}function qe(){const F=new Set;for(const V of h.value)V.kind==="zone"&&F.add(V.key.slice(5));return F}function ft(){const F=new Map,V=Y=>{const ye=j(Y);Y.label&&F.set(Y.label,ye),Y.children&&Y.children.length&&Y.children.forEach(V)};for(const Y of $.value)V(Y);return F}function nt(){if(typeof document>"u")return;const F=document.querySelector("my-upg-100-list-map"),Y=(F&&F.shadowRoot||document).querySelectorAll(".stl-row");if(!Y.length)return;if(!P.value){Y.forEach(Ke=>Ke.classList.remove("upg-batch-row"));return}const ye=qe(),Ae=ft(),Be=f.value;Y.forEach(Ke=>{const ze=Ke.querySelector(".stl-name"),He=ze?ze.textContent.trim():"",Pe=He&&Ae.get(He),Qe=!!(Pe&&Pe.size&&[...Pe].every($t=>ye.has($t)));Ke.classList.toggle("upg-batch-row",Qe),Ke.classList.toggle("dark",Qe&&Be)})}let Pt=null;function so(){if(typeof document>"u"||Pt)return;const F=document.querySelector("my-upg-100-list-map"),Y=(F&&F.shadowRoot||document).querySelector(".stl-rows");Y&&(Pt=new MutationObserver(()=>{requestAnimationFrame(()=>nt())}),Pt.observe(Y,{childList:!0,subtree:!0}))}Gt("onSemanticTreeSelect",qn),Gt("onLegendExport",bt);async function bt(F){const V=b.value;if(!V)return;if(F==="packet"){await tt(V);return}const Y=Me().find(ye=>ye.id===V)||{id:V};await N.printPoster(Y)}const N=Qd({records:F=>ee(F),lang:()=>Wn(),label:F=>(F==null?void 0:F.label)||(F==null?void 0:F.id)||"",assetsBase:()=>On(a.value),downloadPrefix:"doxa-upg-100"});et(N.exportState,F=>{if(!F){/packet/i.test(d.value)&&(d.value="");return}if(F.phase==="error"){Re(we("messages.packetFailed",{reason:F.message}),4e3);return}d.value=F.phase==="done"?"":`${F.message}…`});async function ee(F){if(!be)throw new Error("no API configured");const Y=await fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url&lang=${Wn()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const ye=Ta(await La(Ea(await Y.json()),a));let Ae;if(F.selector&&F.selector.type==="pg_slugs")Ae=new Set(F.selector.values||[]);else{const{evaluate:Be}=await yt(async()=>{const{evaluate:Ke}=await Promise.resolve().then(()=>vi);return{evaluate:Ke}},void 0);Ae=new Set(Be(F.selector,ye))}return ye.filter(Be=>Ae.has(Be.slug)).sort((Be,Ke)=>String(Be.name).localeCompare(String(Ke.name),Wn()))}async function xe(F,V){try{const Y=On(a.value),ye=await(await fetch(`${Y}/posters/${F}.html`,{cache:"force-cache"})).text(),Ae=ye.match(//);return Ae?`
${Ae[0]}
`:""}catch{return""}}function Ce(F,V,Y){F.value=V,setTimeout(()=>{F.value===V&&(F.value="")},Y)}const Re=(F,V)=>Ce(d,F,V);async function tt(F){const V=Me().find(Be=>Be.id===F);if(!V)return;const[{createPacketRenderer:Y},ye]=await Promise.all([yt(()=>Promise.resolve().then(()=>yl),void 0),yt(()=>Promise.resolve().then(()=>ts),void 0).then(Be=>Be.default||Be)]),Ae=Y({strings:ye,lang:Wn()});await N.printPacket(V,{mapSvg:await xe(F,Ae),funnel:await It()})}function Me(){return[...o.lists||[],...o.asia_lists||[],...o.uncovered_lists||[]]}async function It(){var F;try{const V=(await yt(async()=>{const{default:Be}=await Promise.resolve().then(()=>vA);return{default:Be}},void 0)).default;if(!V||!Array.isArray(V.steps)||!V.steps.length)return null;const Y=Xd(a),ye=Number(V.steps[V.steps.length-1].groups)||0;if(Y===Aa)return{...V,listCount:Me().length,listTotal:ye};let Ae=0;try{const Be=On(a.value),Ke=await fetch(`${Be}/people-groups/lists/${Y}.json`);if(Ke.ok){const ze=await Ke.json();Ae=Number((F=ze==null?void 0:ze.counts)==null?void 0:F.doxa)||(Array.isArray(ze==null?void 0:ze.slugs)?ze.slugs.length:0)}}catch{}return{...V,listTotal:Ae,listId:Y,listLabel:(Yd(Y)||{}).label||Y}}catch{return null}}const pt=fe(!1);function jt(){const F=h.value.filter(Y=>Y.kind==="zone").map(Y=>String(Y.key).replace(/^zone:/,"")),V=new Map(Me().map(Y=>[Y.id,Y]));return F.map(Y=>V.get(Y)).filter(Boolean)}async function $l(){const F=jt();if(!F.length)throw new Error("nothing selected");if(!be)throw new Error("no API configured");const Y=await fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url&lang=${Wn()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const ye=Ta(await La(Ea(await Y.json()),a)),{evaluate:Ae}=await yt(async()=>{const{evaluate:He}=await Promise.resolve().then(()=>vi);return{evaluate:He}},void 0),Be=new Set;for(const He of F)if(He.selector&&He.selector.type==="pg_slugs")for(const Pe of He.selector.values||[])Be.add(Pe);else for(const Pe of Ae(He.selector,ye))Be.add(Pe);const Ke=F.map(He=>He.label||He.id);return{id:"selection",label:Ke.length<=3?Ke.join(" + "):`${Ke.slice(0,2).join(" + ")} +${Ke.length-2} more`,count:Be.size,selector:{type:"pg_slugs",values:[...Be]}}}async function wA(){if(!pt.value){pt.value=!0;try{const F=await $l(),[{createPacketRenderer:V},Y]=await Promise.all([yt(()=>Promise.resolve().then(()=>yl),void 0),yt(()=>Promise.resolve().then(()=>ts),void 0).then(ze=>ze.default||ze)]),ye=V({strings:Y,lang:Wn()}),Ae=jt(),Be=Ae.length===1?await xe(Ae[0].id,ye):"",Ke=await It();await N.printPacket(F,{mapSvg:Be,funnel:Ke&&Ae.length===1?Ke:Ke?{...Ke,listCount:0}:null})}catch(F){Re(we("messages.selectionPacketFailed",{reason:String((F==null?void 0:F.message)||F).slice(0,90)}),4e3)}finally{pt.value=!1}}}async function kA(){if(!pt.value){pt.value=!0;try{const F=jt();if(!F.length)throw new Error("nothing selected");if(F.length>1){Re(we("messages.posterOneTerritory",{count:F.length}),5e3);return}await N.printPoster(F[0])}catch(F){Re(we("messages.selectionPosterFailed",{reason:String((F==null?void 0:F.message)||F).slice(0,90)}),4e3)}finally{pt.value=!1}}}function Wn(){const F=Se&&(Se.value??Se);return typeof F=="string"&&F||"en"}function qn(F){if(!C||!C.getLayer("tapestry-fill"))return!1;if(P.value)return F&&Ee(F),!0;if(!F)return _e=null,b.value=null,C.setFilter("tapestry-fill",null),C.setFilter("tapestry-line",null),C.setPaintProperty("upg-pins","circle-opacity",1),!0;_e=F;const V=[...j(F)];b.value=V.length===1?V[0]:F.id??null;const Y=["in",["get","zoneKey"],["literal",V]];C.setFilter("tapestry-fill",Y),C.setFilter("tapestry-line",Y),C.getLayer("upg-pins")&&C.setPaintProperty("upg-pins","circle-opacity",["case",["in",["get","zoneKey"],["literal",V]],.95,.05]);const ye=z(Ae=>V.includes(Ae.properties.zoneKey));return ye&&C.fitBounds(ye,{padding:40,duration:700,maxZoom:6}),!0}function _l(){C&&(typeof $e=="function"&&$e(),W&&(ue(),me(),ae(),R(),b.value&&C.getLayer("tapestry-fill")&&qn(_e)))}function xA(){C&&(f.value=!f.value,m.theme.value=f.value?"dark":"light",C.setStyle(f.value?cl("ink",r).style||"mapbox://styles/mapbox/dark-v11":cl("paper",r).style||"mapbox://styles/mapbox/light-v11"),C.once("style.load",_l))}function Wg(){!C||!C.getLayer("upg-pins")||(C.on("click","upg-pins",F=>{const V=F&&F.features&&F.features[0];V&&c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(V)}),C.on("mouseenter","upg-pins",()=>{C&&(C.getCanvas().style.cursor="pointer")}),C.on("mouseleave","upg-pins",()=>{C&&(C.getCanvas().style.cursor="")}))}let Ga=null,mn,Yn=null;function os(F,V){var Y,ye,Ae;try{const Be=(Ae=(ye=(Y=p.value)==null?void 0:Y.getRootNode)==null?void 0:ye.call(Y))==null?void 0:Ae.host;if(!Be)return;Be.setAttribute("data-doxa-select-zone-state",F),V&&Be.setAttribute("data-doxa-select-zone-applied",String(V))}catch{}}function za(F){if(!F)return qn(null),mn=void 0,os("cleared",""),!0;const V=qg($.value,F);return V?qn(V)?(os("applied",F),!0):(mn=F,os("applied-but-no-selection",F),!1):(mn=F,os("unresolved",F),!1)}function PA(F){var Y;const V=((Y=F==null?void 0:F.detail)==null?void 0:Y.listId)??null;za(V)}function qg(F,V){for(const Y of F||[]){if((Y.zoneKey||Y.id)===V)return Y;const ye=Y.children&&qg(Y.children,V);if(ye)return ye}return null}function SA(){const F=dl(o,{deafCount:hl});$.value=F,X=yg(F);const V={};for(const Y of o.lists||[])V[Y.id]=Y.selector;for(const Y of o.asia_lists||[])V[Y.id]=Y.selector;for(const Y of o.uncovered_lists||[])V[Y.id]=Y.selector;V.deaf={type:"affinity_bloc",rop1:"A017"};for(const Y of X)Y.selector=V[Y.id];se=de(X)}async function Yg(){if(be)try{const V=await fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=en`,{cache:"no-store"});if(!V.ok)throw new Error(`list ${V.status}`);const Y=Ta(await La(Ea(await V.json()),a));w=vg(Y),$.value=dl(o,{deafCount:hl,records:Y})}catch{}}ho(async()=>{var Ae,Be,Ke,ze,He;SA();try{await nS(r)}catch{}const F=ul(r);F&&tS(F);const V=(n==null?void 0:n.value)||((Ae=a==null?void 0:a.value)==null?void 0:Ae.tk)||"";if(!F){console.warn(`[upg-100-list] ${r} engine global is missing — refusing to substitute another engine. A page that asked for the keyless engine must not silently receive the token-gated one.`),d.value=`⚠ ${we("messages.engineNotLoaded")}`,x.value=we("messages.engineNotLoadedDetail",{engine:s?"MapLibre":"Mapbox"}),Yg();return}if(!s){if(!V){d.value="⚠ no mapbox token",x.value="No Mapbox token configured. The list and legend are unaffected.",Yg();return}F.accessToken=V}try{const Pe=!s&&p.value&&p.value.getRootNode();if(Pe instanceof ShadowRoot){const Qe=oS("mapbox");if(Qe&&!Pe.querySelector(`link[href="${Qe}"]`)){const $t=document.createElement("link");$t.rel="stylesheet",$t.href=Qe,Pe.prepend($t)}}}catch{}C=new F.Map({container:p.value,style:cl("paper",r).style||"mapbox://styles/mapbox/light-v11",center:[35,20],zoom:1.5,projection:"mercator"}),g.value=C,U=XP(((Be=p.value)==null?void 0:Be.parentElement)||null,{enabled:l.value}),typeof window<"u"&&(window.__UPG_MAP__=C),window.__UPG_SELECT__={get list(){return h.value.map(Pe=>({...Pe}))},get total(){return y.value},get count(){return v.value},get color(){return O.value},get batchMode(){return P.value},setColor:Pe=>G(Pe),setBatchMode:Pe=>L(Pe),clipboardText:()=>gS(h.value,{color:O.value}),clear:()=>ne(),toggleByProps:Pe=>{const Qe=wg(Pe,{nameMap:w});return Qe?(K(Qe),{...Qe}):null},toggleLegendRow:Pe=>{const Qe=Qo=>{for(const gt of Qo){if(gt.label===Pe)return gt;if(gt.children&>.children.length){const Ot=Qe(gt.children);if(Ot)return Ot}}return null},$t=Qe($.value);return $t?(Ee($t),{label:$t.label,zoneKeys:[...j($t)]}):null},markedLegendRows:()=>{if(typeof document>"u")return[];const Pe=document.querySelector("my-upg-100-list-map");return[...(Pe&&Pe.shadowRoot||document).querySelectorAll(".stl-row.upg-batch-row .stl-name")].map($t=>$t.textContent.trim())},highlightFeatureCount:()=>{if(!C||!W||!C.getLayer("upg-sel-fill"))return-1;const Pe=new Set,Qe=new Set,$t=new Set;for(const gt of h.value)gt.kind==="zone"?Pe.add(gt.key.slice(5)):gt.kind==="adm1"?Qe.add(gt.name):gt.kind==="adm0"&&$t.add(gt.key.slice(5));let Qo=0;for(const gt of W.features){const Ot=gt.properties||{};(Pe.has(Ot.zoneKey)||Qe.has(Ot.shapeName)||$t.has(Ot.iso3))&&Qo++}return Qo},zoneKeysForRow:Pe=>{const Qe=Qo=>{for(const gt of Qo){if(gt.label===Pe)return gt;if(gt.children&>.children.length){const Ot=Qe(gt.children);if(Ot)return Ot}}return null},$t=Qe($.value);return $t?[...j($t)]:null}};try{d.value="loading boundaries…";const Pe=je=>`${On(a.value)}/boundaries/${je}`,Qe=je=>fetch(Pe(je)).then(Ct=>{if(!Ct.ok)throw new Error(`boundary fetch ${Ct.status} ${je}`);return Ct.json()});if(!be)throw new Error("No API base configured — set window.MAP_APP_API_URL or VITE_API_BASE_URL. Failing closed (no default host).");const Qo=fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=en`).then(je=>{if(!je.ok)throw new Error(`list ${je.status}`);return je.json()}),gt={adm0:Qe("world-adm0.geojson"),adm1Chn:Qe("gb-CHN-ADM1.geojson"),adm1Ind:Qe("gb-IND-ADM1.geojson")};d.value="fetching 2106 UUPGs…";const Ot=Ta(await La(Ea(await Qo),a));w=vg(Ot),$.value=dl(o,{deafCount:hl,records:Ot});const vl=[],Ba={},{evaluate:LA}=await yt(async()=>{const{evaluate:je}=await Promise.resolve().then(()=>vi);return{evaluate:je}},void 0);for(const je of X)if(je.selector&&je.selector.type==="pg_slugs")for(const Ct of je.selector.values||[])Ct in Ba||(Ba[Ct]=je.zoneKey);else try{for(const Ct of LA(je.selector,Ot))Ct in Ba||(Ba[Ct]=je.zoneKey)}catch(Ct){console.warn("zone selector skipped",je.id,Ct&&Ct.message)}for(const je of Ot){const Ct=Number(je.latitude),kl=Number(je.longitude);!isFinite(Ct)||!isFinite(kl)||vl.push({type:"Feature",geometry:{type:"Point",coordinates:[kl,Ct]},properties:{slug:je.slug,zoneKey:Ba[je.slug]||"",name:je.name||je.slug||"",population:je.population??0,countryName:je.country_code_label||"",country:je.country_code||""}})}const CA=on({type:"FeatureCollection",features:vl});$e=()=>{if(!(C.getSource("upg")&&C.getLayer("upg-pins"))){if(C.getSource("upg")||C.addSource("upg",{type:"geojson",data:CA}),C.getLayer("upg-pins")){Wg();return}C.addLayer({id:"upg-pins",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],1,5,4,6.5,8,9],"circle-color":se,"circle-opacity":1,"circle-stroke-width":["interpolate",["linear"],["zoom"],1,1.8,8,2],"circle-stroke-color":"rgba(15,20,25,0.9)"}}),Wg()}};const Zg=()=>{try{_l()}catch(je){console.warn("early pin paint skipped",je&&je.message)}};C.isStyleLoaded()?Zg():C.once("style.load",Zg),d.value="loading boundaries…";const[TA,EA]=await Promise.all([gt.adm0,gt.adm1Chn]),RA=await gt.adm1Ind,{tapestry:MA,perZone:NA}=uS(X,{records:Ot,adm0:TA,adm1Ind:RA,adm1Chn:EA});W=on(MA),he(Ot);let wl=!0;const Zn=()=>{wl&&(wl=!1,C.off("style.load",Zn),C.off("idle",Zn),_l())};if(C.isStyleLoaded())Zn();else{C.once("style.load",Zn),C.once("idle",Zn);const je=setInterval(()=>{if(!wl||!C){clearInterval(je);return}let Ct=!1;try{Ct=C.isStyleLoaded()}catch{clearInterval(je);return}Ct&&(clearInterval(je),Zn())},120);setTimeout(()=>clearInterval(je),15e3)}const Jg=[...NA.entries()].filter(([je])=>je!=="deaf"),FA=Jg.filter(([,je])=>je>=1).length;d.value=`${W.features.length} polys · ${FA}/${Jg.length} zones · ${vl.length} pins`}catch(Pe){d.value="⚠ "+(Pe&&Pe.message?Pe.message:String(Pe))}let Y=0;const ye=()=>{const Pe=typeof document<"u"&&document.querySelector("my-upg-100-list-map"),Qe=Pe&&Pe.shadowRoot||(typeof document<"u"?document:null);if(Qe&&Qe.querySelector(".stl-rows")){so(),nt();return}Y++<40&&setTimeout(ye,250)};ye();{const Pe=(He=(ze=(Ke=p.value)==null?void 0:Ke.getRootNode)==null?void 0:ze.call(Ke))==null?void 0:He.host;if(Pe){Ga=PA,Pe.addEventListener("doxa:select-zone",Ga);const Qe=Pe.getAttribute("select-zone");Qe&&za(Qe),Yn=new MutationObserver(()=>{za(Pe.getAttribute("select-zone")||null)}),Yn.observe(Pe,{attributes:!0,attributeFilter:["select-zone"]})}}});const AA=()=>{var F,V,Y;try{return((Y=(V=(F=p.value)==null?void 0:F.getRootNode)==null?void 0:V.call(F))==null?void 0:Y.host)||null}catch{return null}};return et([$,g],()=>{qt(()=>{var V;const F=((V=AA())==null?void 0:V.getAttribute("select-zone"))||mn||null;F&&za(F)})}),Xt(()=>{var F,V,Y;if(Yn==null||Yn.disconnect(),Yn=null,Ga){const ye=(Y=(V=(F=p.value)==null?void 0:F.getRootNode)==null?void 0:V.call(F))==null?void 0:Y.host;ye==null||ye.removeEventListener("doxa:select-zone",Ga),Ga=null}if(Pt){try{Pt.disconnect()}catch{}Pt=null}if(U){try{U()}catch{}U=null}C&&(C.remove(),C=null),W=null}),(F,V)=>{var Y;return q(),oe("div",yS,[E("div",{ref_key:"mapEl",ref:p,class:"upg-map"},null,512),x.value?(q(),oe("div",$S,[E("strong",null,ce(ge(we)("messages.mapUnavailable")),1),vt(ce(x.value),1)])):ke("",!0),l.value?(q(),oe(Ge,{key:1},[V[0]||(V[0]=E("div",{class:"map-scroll-edge map-scroll-edge--left"},null,-1)),V[1]||(V[1]=E("div",{class:"map-scroll-edge map-scroll-edge--right"},null,-1))],64)):ke("",!0),g.value&&i.value?(q(),lt(KP,{key:2,ref_key:"geocoderRef",ref:Z,"map-instance":g.value,"access-token":ge(n)||((Y=ge(a))==null?void 0:Y.tk)||"","data-source-id":gl,"is-dark":f.value,placeholder:B.value,"active-context":RS,onPeopleGroupResult:pe,onAggregateResult:_,onClear:k},null,8,["map-instance","access-token","is-dark","placeholder"])):ke("",!0),g.value?(q(),lt($P,{key:3,"has-geocoder":i.value},{default:Yt(()=>[Xe(vP,{map:g.value,"is-dark":f.value},null,8,["map","is-dark"]),Xe(wP,{map:g.value,"is-dark":f.value},null,8,["map","is-dark"]),Xe(kP,{map:g.value,"is-dark":f.value},null,8,["map","is-dark"]),Xe(SP,{"map-container":p.value,"is-dark":f.value},null,8,["map-container","is-dark"]),Xe(LP,{"is-dark":f.value,onToggle:xA},null,8,["is-dark"]),Xe(fn,{"is-dark":f.value,active:P.value,class:De({"upg-batch-on":P.value}),"aria-pressed":P.value?"true":"false",title:"Batch Select",onClick:J},{default:Yt(()=>[...V[2]||(V[2]=[E("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[E("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),E("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),E("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),E("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})],-1)])]),_:1},8,["is-dark","active","class","aria-pressed"])]),_:1},8,["has-geocoder"])):ke("",!0),E("div",_S,[$.value.length?(q(),lt(dp,{key:0,nodes:$.value,tabs:D,"default-tab":xg,columns:["count","pop"],title:Le.value,"export-enabled":!0,onSelect:qn,onExport:bt},null,8,["nodes","title"])):ke("",!0)]),E("div",vS,[$.value.length?(q(),lt(yP,{key:0,"legend-type":"upg-100",nodes:$.value,tabs:D,"default-tab":xg,columns:["count","pop"],"column-label":"UPG 100",title:Le.value,"is-dark":f.value,"popup-action":"pray"},null,8,["nodes","title","is-dark"])):ke("",!0)]),E("div",wS,[ge(c)&&ge(c).selectedPeopleGroup?(q(),oe("div",{key:0,class:De(["upg-detail-panel pg-detail-root",{dark:f.value}])},[Xe(ge(t),{peopleGroup:ge(c).selectedPeopleGroup,dark:f.value,action:"pray"},null,8,["peopleGroup","dark"])],2)):ke("",!0)]),P.value?(q(),oe("div",kS,[V[3]||(V[3]=E("div",{class:"upg-hud-hint"}," Tap territories on the map or legend rows to add · tap again to remove ",-1)),v.value?(q(),oe("div",xS,[E("span",null,ce(v.value)+" territor"+ce(v.value===1?"y":"ies")+" ·",1),E("span",PS,ce(y.value)+" UUPG",1),E("span",{class:De(["upg-hud-band",{ok:y.value>=50&&y.value<=100}])},ce(y.value>=50&&y.value<=100?"✓ 50–100 band":"band 50–100"),3)])):ke("",!0),v.value?(q(),oe("div",SS,ce(h.value.map(ye=>ye.name).join(", ")),1)):ke("",!0),v.value?(q(),oe("div",AS,[E("button",{class:"upg-hud-btn make",disabled:pt.value,onClick:wA},ce(ge(we)("buttons.prayerList")),9,LS),E("button",{class:"upg-hud-btn make",disabled:pt.value,onClick:kA},ce(ge(we)("buttons.posterMap")),9,CS),E("button",{class:"upg-hud-btn clear",onClick:ne},ce(ge(we)("buttons.clearSelection")),1)])):ke("",!0),v.value?(q(),oe("div",TS,ce(A.value),1)):ke("",!0)])):ke("",!0),E("div",ES,ce(d.value),1)])}}}},Symbol.toStringTag,{value:"Module"})),NS=` +`+i}function Kn(e){return String(e??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function hS(e){return Kn(e).split(/[\s,;]+/).filter(Boolean)}function fS(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null}=e,s=[],i=new Set;for(const u of t){if(!u)continue;const c=u.slug;if(!c||i.has(c))continue;const p=Number(u.latitude),d=Number(u.longitude);if(!Number.isFinite(p)||!Number.isFinite(d))continue;const x=u.name||c;i.add(c),s.push({label:x,kind:"pg",target:{type:"pg",slug:c,lng:d,lat:p},_hay:Kn(x)})}for(const u of o){if(!u)continue;const c=u.zoneKey||u.id,p=u.label||c;c&&s.push({label:p,kind:"zone",target:{type:"zone",zoneId:c},_hay:Kn(p)})}for(const u of Object.keys(n))s.push({label:u,kind:"territory",target:{type:"territory",shapeName:u},_hay:Kn(u)});const l=r||a;for(const u of Object.keys(a)){const c=l&&l[u]||a[u]||u;s.push({label:c,kind:"territory",target:{type:"territory",shapeName:u,iso3:!0},_hay:Kn(c)})}return s}const mS={zone:0,territory:1,pg:2};function bS(e={}){const{records:t=[],leafZones:o=[],adm1Counts:n={},iso3Names:a={},countryNameMap:r=null,centroidFor:s=null}=e,i=[];for(const c of t)c&&i.push(c);const l=(c,p,d)=>!p||!Number.isFinite(p[0])||!Number.isFinite(p[1])?null:{name:c,slug:d.__synthSlug,latitude:p[1],longitude:p[0],...d};for(const c of o){if(!c)continue;const p=c.zoneKey||c.id,d=c.label||p;if(!p)continue;const x=typeof s=="function"?s(b=>b&&b.properties&&b.properties.zoneKey===p):null,$=l(d,x,{__upgKind:"zone",__zoneId:p,__synthSlug:`__zone__${p}`});$&&i.push($)}for(const c of Object.keys(n)){const p=typeof s=="function"?s(x=>x&&x.properties&&x.properties.shapeName===c):null,d=l(c,p,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});d&&i.push(d)}const u=r||a;for(const c of Object.keys(a)){const p=u&&u[c]||a[c]||c,d=typeof s=="function"?s($=>$&&$.properties&&$.properties.iso3===c):null,x=l(p,d,{__upgKind:"territory",__shapeName:c,__synthSlug:`__terr__${c}`});x&&i.push(x)}return i}function kg(e,t,o={}){const n=o.limit??8,a=hS(t);if(!a.length)return[];const r=a[0],s=[];for(const i of e){let l=!0;for(const p of a)if(!i._hay.includes(p)){l=!1;break}if(!l)continue;const u=i._hay.startsWith(r)?0:1,c=i._hay===Kn(t)?-1:0;s.push({e:i,starts:u,exact:c,kr:mS[i.kind]??9,len:i._hay.length})}return s.sort((i,l)=>i.exact-l.exact||i.starts-l.starts||i.kr-l.kr||i.len-l.len),s.slice(0,n).map(i=>i.e)}const yS={class:"upg-root"},$S={key:0,class:"upg-map-err"},_S={class:"upg-legend-desktop-slot"},vS={class:"upg-legend-mobile-slot"},wS={class:"upg-detail-desktop-slot"},kS={key:4,class:"upg-hud"},xS={key:0,class:"upg-hud-head"},PS={class:"upg-hud-total"},SS={key:1,class:"upg-hud-names"},AS={key:2,class:"upg-hud-actions"},LS=["disabled"],CS=["disabled"],TS={key:3,class:"upg-hud-flash"},ES={class:"upg-status"},gl="upg-search",xg=1,RS="people-groups",Pg=8,hl=123,MS=Object.freeze(Object.defineProperty({__proto__:null,default:{__name:"upg-100-list",setup(e){const t=Eu(()=>yt(()=>Promise.resolve().then(()=>eP),void 0)),o={lists:rp,asia_lists:sp,uncovered_lists:ip},n=Ue("mapboxToken",fe("")),a=Ue("profileConfig",fe(null)),r=YP(a),s=r==="maplibre",i=te(()=>{var F;return((F=a==null?void 0:a.value)==null?void 0:F.search)===!1?!1:r==="mapbox"}),l=te(()=>{var V;const F=(V=a.value)==null?void 0:V.edgeScrollAffordance;return F==null?!0:!(F===!1||F==="false")}),u=Ue("dataStore",null),c=Ue("uiStore",null),p=fe(null),d=fe("loading…"),x=fe(""),$=wn([]),b=fe(null),g=wn(null),f=fe(!1),m=O1("my-upg-100-list");m.theme.value="light",D1(m);const h=fe([]),y=te(()=>h.value.reduce((F,V)=>F+(Number(V.count)||0),0)),v=te(()=>h.value.length),A=fe("");let w=null;const P=fe(!1);function L(F){const V=F===void 0?!P.value:!!F;return V===P.value||(P.value=V,C&&(C.getCanvas().style.cursor=""),R()),V}function J(){L()}et([P,f],()=>{qt(()=>nt())});function K(F){if(!F)return;const V=h.value,Y=V.findIndex(ye=>ye.key===F.key);Y>=0?h.value=V.filter((ye,Ae)=>Ae!==Y):h.value=[...V,F],R(),A.value=""}const O=fe(""),I=fe("");function G(F){const V=/^#?([0-9a-fA-F]{6})$/.exec(String(F||"").trim());if(!V)return;const Y="#"+V[1].toLowerCase();O.value=O.value===Y?"":Y,R()}const Z=fe(null),D=[{id:"upg100Region",label:"Region",info:"Region — sort the UPG-100 lists by world area (Africa, India, Middle East, Deaf, …). Counts are the UUPGs and population summed across every list beneath it."},{id:"upg100Zone",label:"UPG-100 Lists",info:"UPG-100 Lists — each one is a prayer list of the unreached people groups in an area, and is what the map paints and colours. Every list prints as its own packet."}];let le=[],C=null,W=null,X=[],se=null,U=null,$e=null;const be=typeof window<"u"&&window.MAP_APP_API_URL||void 0||"",{locale:Se,t:we}=xt(),Le=te(()=>we("legend.title.upg100List")),B=te(()=>we("search.upg100Placeholder"));Lt(`.upg-root{position:absolute;inset:0;background:#0a1410;color:#e5e7eb;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}.upg-map{position:absolute;inset:0}.upg-map-err{position:absolute;left:0;right:0;top:50%;transform:translateY(-50%);z-index:1;pointer-events:none;text-align:center;padding:0 24px;font:13px/1.5 -apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;color:#9aa7b8}.upg-map-err strong{display:block;font-size:14px;color:#cbd5e1;margin-bottom:4px}.map-scroll-edge{position:absolute;top:0;bottom:0;width:40px;z-index:2;touch-action:pan-y;pointer-events:auto;background:transparent}.map-scroll-edge--left{left:0}.map-scroll-edge--right{right:0}.upg-legend-desktop-slot{--stl-top:8px}.upg-legend-mobile-slot{display:none}@media(max-width:767px){.upg-legend-mobile-slot{display:block}.upg-legend-desktop-slot{display:none}.upg-detail-desktop-slot{display:none}}.upg-status{position:absolute;bottom:10px;right:10px;z-index:5;font:10px/1 ui-monospace,monospace;color:#9aa7b8;background:rgba(10,14,21,.82);padding:6px 10px;border-radius:8px}.upg-detail-panel{position:absolute;top:60px;right:8px;bottom:10px;width:340px;max-width:calc(100vw - 16px);z-index:6;background:#fff;border-radius:12px;box-shadow:0 8px 28px rgba(0,0,0,.45);overflow:hidden;display:flex;flex-direction:column;animation:upgPanelIn .18s ease}.upg-detail-panel.dark{background:#1a1a2e}@keyframes upgPanelIn{from{transform:translateX(16px);opacity:0}to{transform:translateX(0);opacity:1}}@media(max-width:480px){.upg-detail-panel{top:auto;left:8px;right:8px;width:auto;height:55vh}}.upg-hud{position:absolute;bottom:34px;right:10px;z-index:6;min-width:150px;font:11px/1.35 ui-monospace,monospace;color:#e5e7eb;background:rgba(10,20,16,.92);border:1px solid rgba(110,231,183,.35);border-radius:10px;padding:8px 10px;box-shadow:0 4px 16px rgba(0,0,0,.4)}.upg-hud-head{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.upg-hud-total{font-size:15px;font-weight:700;color:#6ee7b7}.upg-hud-band{margin-left:auto;font-size:9px;color:#9aa7b8}.upg-hud-band.ok{color:#6ee7b7}.upg-hud-names{margin-top:5px;max-height:84px;overflow:auto;font-size:10px;color:#cbd5e1;line-height:1.45;word-break:break-word}.upg-hud-actions{display:flex;gap:6px;margin-top:7px}.upg-hud-btn{flex:1;cursor:pointer;border:1px solid rgba(110,231,183,.4);background:rgba(16,185,129,.18);color:#d1fae5;font:12px/1 ui-monospace,monospace;padding:0 10px;min-height:40px;border-radius:8px}.upg-hud-btn:hover{background:rgba(16,185,129,.32)}.upg-hud-btn.clear{background:rgba(148,163,184,.12);border-color:rgba(148,163,184,.4);color:#cbd5e1}.upg-hud-flash{margin-top:5px;font-size:9px;color:#6ee7b7;min-height:11px}.upg-hud-hint{margin-top:4px;font-size:9px;color:#64748b}.upg-hud-swatches{display:flex;gap:6px;margin-top:7px;align-items:center;flex-wrap:wrap}.upg-swatch{width:40px;height:40px;border-radius:9px;cursor:pointer;padding:0;border:1px solid rgba(255,255,255,.3)}.upg-swatch.active{outline:2px solid #fff;outline-offset:1px}.upg-hex{width:84px;min-height:40px;background:rgba(148,163,184,.12);border:1px solid rgba(148,163,184,.4);color:#cbd5e1;font:12px/1 ui-monospace,monospace;padding:0 8px;border-radius:8px}@media(max-width:480px){.upg-hud{left:8px;right:8px;min-width:0;bottom:30px;max-height:48vh;overflow:auto}}.map-toolbar .mcb.upg-batch-on{background:#10b981!important;color:#04241a!important;box-shadow:0 0 0 2px rgba(52,211,153,.45),0 1px 4px rgba(0,0,0,0.2)!important}.map-toolbar .mcb.upg-batch-on.dark{border-color:#34d399!important}.upg-batch-row{position:relative;background:rgba(16,185,129,.16)!important;opacity:1!important;box-shadow:inset 3px 0 0 0 #10b981}.upg-batch-row .stl-name{color:#065f46!important;font-weight:700}.stl-panel[data-theme="dark"] .upg-batch-row .stl-name,.upg-batch-row.dark .stl-name{color:#6ee7b7!important}.upg-batch-row .stl-dot{box-shadow:0 0 0 2px #10b981}.mapboxgl-ctrl-top-left{top:12px!important;left:8px!important;width:380px!important;max-width:380px!important;z-index:1200!important}.mapboxgl-ctrl-top-left .mapboxgl-ctrl{margin:0!important;float:none!important}.stl-panel{--stl-top:8px!important}.upg-root:has(.mapboxgl-ctrl-geocoder) .stl-panel{--stl-top:58px!important}[dir="rtl"] .upg-detail-panel{right:auto!important;left:8px!important}.dg-main{font:13px/1.3 ui-monospace,monospace}.dg-meta{margin-top:2px;font-size:11px;color:#475569;display:flex;flex-wrap:wrap;gap:8px}.dg-field strong{font-weight:700}.dg-section-header-item{padding:4px 8px;font:10px/1.2 ui-monospace,monospace;letter-spacing:.06em;text-transform:uppercase;color:#94a3b8;pointer-events:none}`);function de(F){const V=[];for(const Y of F)V.push(Y.zoneKey,pS(Y.zoneKey,Y.color));return["match",["get","zoneKey"],...V,"#9ca3af"]}function ue(){if(C.getSource("tapestry")&&C.getLayer("tapestry-fill")&&C.getLayer("tapestry-line"))return;C.getSource("tapestry")||C.addSource("tapestry",{type:"geojson",data:W});const F=f.value?.45:.3,V=f.value?.65:.45;if(C.getLayer("tapestry-fill")||C.addLayer({id:"tapestry-fill",type:"fill",source:"tapestry",paint:{"fill-color":se,"fill-opacity":["case",["==",["get","zoneKey"],"deaf"],F,V]}}),C.getLayer("tapestry-line")||C.addLayer({id:"tapestry-line",type:"line",source:"tapestry",paint:{"line-color":se,"line-width":1.2,"line-opacity":.9}}),mn){const Y=mn;qt(()=>{mn===Y&&za(Y)})}}function me(){!C||!C.getSource("tapestry")||C.getLayer("upg-sel-fill")||(C.addLayer({id:"upg-sel-fill",type:"fill",source:"tapestry",filter:["boolean",!1],paint:{"fill-color":"#f59e0b","fill-opacity":.28}}),C.addLayer({id:"upg-sel-line",type:"line",source:"tapestry",filter:["boolean",!1],paint:{"line-color":"#fbbf24","line-width":2.4,"line-opacity":.95}}))}function S(){const F=[],V=[],Y=[];for(const Ae of h.value)Ae.kind==="adm1"?F.push(Ae.name):Ae.kind==="adm0"?V.push(Ae.key.slice(5)):Ae.kind==="zone"&&Y.push(Ae.key.slice(5));const ye=[];return F.length&&ye.push(["in",["get","shapeName"],["literal",F]]),V.length&&ye.push(["in",["get","iso3"],["literal",V]]),Y.length&&ye.push(["in",["get","zoneKey"],["literal",Y]]),ye.length?ye.length===1?ye[0]:["any",...ye]:["boolean",!1]}function R(){if(nt(),!C||!C.getLayer("upg-sel-fill"))return;const F=P.value?S():["boolean",!1];C.setFilter("upg-sel-fill",F),C.setFilter("upg-sel-line",F);const V=O.value;C.setPaintProperty("upg-sel-fill","fill-color",V||"#f59e0b"),C.setPaintProperty("upg-sel-fill","fill-opacity",V?.55:.28),C.setPaintProperty("upg-sel-line","line-color",V||"#fbbf24")}let T=null,Q=!1;function ae(){if(!(!C||!C.getLayer("tapestry-fill"))){if(T)try{C.off("click","tapestry-fill",T)}catch{}T=F=>{const V=F&&F.features&&F.features[0];if(V&&P.value){const Y=wg(V.properties,{nameMap:w});if(!Y){console.warn("[batch-select] clicked feature has no shapeName/iso3",V.properties);return}Y.count==null&&console.warn("[batch-select] no UUPG count for territory",Y.name,V.properties),K(Y)}},C.on("click","tapestry-fill",T),Q||(C.on("mouseenter","tapestry-fill",()=>{C&&(C.getCanvas().style.cursor=P.value?"crosshair":"")}),C.on("mouseleave","tapestry-fill",()=>{C&&(C.getCanvas().style.cursor="")}),Q=!0)}}function ne(){h.value=[],A.value="",O.value="",I.value="",R()}function he(F){if(u&&typeof u.cacheSourceData=="function"){const V=bS({records:F,leafZones:X,adm1Counts:Qr,iso3Names:Oa,countryNameMap:w,centroidFor:Y=>{const ye=z(Y);return ye?[(ye[0][0]+ye[1][0])/2,(ye[0][1]+ye[1][1])/2]:null}});u.cacheSourceData(gl,{normalizedData:V})}le=fS({records:F,leafZones:X,adm1Counts:Qr,iso3Names:Oa,countryNameMap:w}),typeof window<"u"&&(window.__UPG_SEARCH__={size:()=>le.length,counts:()=>{const V={pg:0,zone:0,territory:0};for(const Y of le)V[Y.kind]=(V[Y.kind]||0)+1;return V},query:V=>kg(le,V,{limit:Pg}).map(Y=>({label:Y.label,kind:Y.kind,target:Y.target})),select:V=>{const Y=kg(le,V,{limit:Pg})[0];return Y?(M(Y.target),{label:Y.label,kind:Y.kind,target:Y.target}):null},feedSize:()=>{const V=u&&u.sources&&u.sources[gl];return V&&Array.isArray(V.features)&&V.features.length||0},localGeocoder:V=>{const Y=Z.value&&Z.value.geocoder,ye=Y&&Y.options&&Y.options.localGeocoder;return ye?ye(V).map(Ae=>Ae&&Ae.place_name):null}})}function pe(F){const V=F&&F.properties||{},Y=V.__upgKind;if(Y==="zone")ie(V.__zoneId);else if(Y==="territory")re(V.__shapeName);else{const ye=F&&F.geometry,Ae=ye&&Array.isArray(ye.coordinates)?ye.coordinates:null;Ae&&Number.isFinite(Ae[0])&&Number.isFinite(Ae[1])&&C&&C.flyTo({center:[Ae[0],Ae[1]],zoom:6,duration:800}),H(V.slug)}}function _(F){if(!F||!C)return;const V=new Set(F.memberIds||[]);if(!V.size)return;let Y=[];try{Y=C.querySourceFeatures("upg").filter(He=>{const Pe=He.properties||{};return V.has(Pe.slug)||V.has(Pe.id)||V.has(Pe.peopleGroupId)})}catch{return}if(!Y.length)return;let ye=180,Ae=90,Be=-180,Ke=-90,ze=!1;for(const He of Y){const Pe=He.geometry&&He.geometry.coordinates;!Array.isArray(Pe)||!Number.isFinite(Pe[0])||!Number.isFinite(Pe[1])||(Pe[0]Be&&(Be=Pe[0]),Pe[1]Ke&&(Ke=Pe[1]),ze=!0)}ze&&C.fitBounds([[ye,Ae],[Be,Ke]],{padding:60,duration:800,maxZoom:6})}function k(){qn(null),c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(null)}function M(F){!F||!C||(F.type==="pg"?(Number.isFinite(F.lng)&&Number.isFinite(F.lat)&&C.flyTo({center:[F.lng,F.lat],zoom:6,duration:800}),H(F.slug)):F.type==="zone"?ie(F.zoneId):F.type==="territory"&&re(F.shapeName))}function H(F){if(!F||!c||typeof c.selectPeopleGroup!="function")return;const V=C&&C.getSource&&C.getSource("upg"),ye=(V&&V._data&&V._data.features||[]).find(Ae=>Ae.properties&&Ae.properties.slug===F);ye&&c.selectPeopleGroup(ye)}function ie(F){if(!F||!C||!W)return;const V=z(Y=>Y.properties&&Y.properties.zoneKey===F);V&&C.fitBounds(V,{padding:40,duration:800,maxZoom:6})}function re(F){if(!F||!C||!W)return;const V=z(Y=>{const ye=Y.properties||{};return ye.shapeName===F||ye.iso3===F});V&&C.fitBounds(V,{padding:40,duration:800,maxZoom:6})}function z(F){let V=180,Y=90,ye=-180,Ae=-90,Be=!1;const Ke=ze=>{if(typeof ze[0]=="number"){const[He,Pe]=ze;Heye&&(ye=He),PeAe&&(Ae=Pe),Be=!0;return}for(const He of ze)Ke(He)};for(const ze of W.features)F(ze)&&Ke(ze.geometry.coordinates);return Be?[[V,Y],[ye,Ae]]:null}function j(F){const V=new Set,Y=ye=>{ye.children&&ye.children.length?ye.children.forEach(Y):V.add(ye.zoneKey??ye.id)};return Y(F),V}let _e=null;function Ee(F){if(![...j(F)].length)return;const Y=[],ye=ze=>{ze.children&&ze.children.length?ze.children.forEach(ye):Y.push(ze)};ye(F);const Ae=h.value,Be=new Set(Ae.filter(ze=>ze.kind==="zone").map(ze=>ze.key));if(Y.every(ze=>Be.has("zone:"+(ze.zoneKey??ze.id)))){const ze=new Set(Y.map(He=>"zone:"+(He.zoneKey??He.id)));h.value=Ae.filter(He=>!ze.has(He.key))}else{const ze=Y.filter(He=>!Be.has("zone:"+(He.zoneKey??He.id))).map(He=>({key:"zone:"+(He.zoneKey??He.id),name:He.label||He.id,count:Number(He.count)||0,kind:"zone"}));h.value=[...Ae,...ze]}R(),A.value=""}function qe(){const F=new Set;for(const V of h.value)V.kind==="zone"&&F.add(V.key.slice(5));return F}function ft(){const F=new Map,V=Y=>{const ye=j(Y);Y.label&&F.set(Y.label,ye),Y.children&&Y.children.length&&Y.children.forEach(V)};for(const Y of $.value)V(Y);return F}function nt(){if(typeof document>"u")return;const F=document.querySelector("my-upg-100-list-map"),Y=(F&&F.shadowRoot||document).querySelectorAll(".stl-row");if(!Y.length)return;if(!P.value){Y.forEach(Ke=>Ke.classList.remove("upg-batch-row"));return}const ye=qe(),Ae=ft(),Be=f.value;Y.forEach(Ke=>{const ze=Ke.querySelector(".stl-name"),He=ze?ze.textContent.trim():"",Pe=He&&Ae.get(He),Qe=!!(Pe&&Pe.size&&[...Pe].every($t=>ye.has($t)));Ke.classList.toggle("upg-batch-row",Qe),Ke.classList.toggle("dark",Qe&&Be)})}let Pt=null;function so(){if(typeof document>"u"||Pt)return;const F=document.querySelector("my-upg-100-list-map"),Y=(F&&F.shadowRoot||document).querySelector(".stl-rows");Y&&(Pt=new MutationObserver(()=>{requestAnimationFrame(()=>nt())}),Pt.observe(Y,{childList:!0,subtree:!0}))}Gt("onSemanticTreeSelect",qn),Gt("onLegendExport",bt);async function bt(F){const V=b.value;if(!V)return;if(F==="packet"){await tt(V);return}const Y=Me().find(ye=>ye.id===V)||{id:V};await N.printPoster(Y)}const N=Qd({records:F=>ee(F),lang:()=>Wn(),label:F=>(F==null?void 0:F.label)||(F==null?void 0:F.id)||"",assetsBase:()=>On(a.value),downloadPrefix:"doxa-upg-100"});et(N.exportState,F=>{if(!F){/packet/i.test(d.value)&&(d.value="");return}if(F.phase==="error"){Re(we("messages.packetFailed",{reason:F.message}),4e3);return}d.value=F.phase==="done"?"":`${F.message}…`});async function ee(F){if(!be)throw new Error("no API configured");const Y=await fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url&lang=${Wn()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const ye=Ta(await La(Ea(await Y.json()),a));let Ae;if(F.selector&&F.selector.type==="pg_slugs")Ae=new Set(F.selector.values||[]);else{const{evaluate:Be}=await yt(async()=>{const{evaluate:Ke}=await Promise.resolve().then(()=>vi);return{evaluate:Ke}},void 0);Ae=new Set(Be(F.selector,ye))}return ye.filter(Be=>Ae.has(Be.slug)).sort((Be,Ke)=>String(Be.name).localeCompare(String(Ke.name),Wn()))}async function xe(F,V){try{const Y=On(a.value),ye=await(await fetch(`${Y}/posters/${F}.html`,{cache:"force-cache"})).text(),Ae=ye.match(//);return Ae?`
${Ae[0]}
`:""}catch{return""}}function Ce(F,V,Y){F.value=V,setTimeout(()=>{F.value===V&&(F.value="")},Y)}const Re=(F,V)=>Ce(d,F,V);async function tt(F){const V=Me().find(Be=>Be.id===F);if(!V)return;const[{createPacketRenderer:Y},ye]=await Promise.all([yt(()=>Promise.resolve().then(()=>yl),void 0),yt(()=>Promise.resolve().then(()=>ts),void 0).then(Be=>Be.default||Be)]),Ae=Y({strings:ye,lang:Wn()});await N.printPacket(V,{mapSvg:await xe(F,Ae),funnel:await It()})}function Me(){return[...o.lists||[],...o.asia_lists||[],...o.uncovered_lists||[]]}async function It(){var F;try{const V=(await yt(async()=>{const{default:Be}=await Promise.resolve().then(()=>vA);return{default:Be}},void 0)).default;if(!V||!Array.isArray(V.steps)||!V.steps.length)return null;const Y=Xd(a),ye=Number(V.steps[V.steps.length-1].groups)||0;if(Y===Aa)return{...V,listCount:Me().length,listTotal:ye};let Ae=0;try{const Be=On(a.value),Ke=await fetch(`${Be}/people-groups/lists/${Y}.json`);if(Ke.ok){const ze=await Ke.json();Ae=Number((F=ze==null?void 0:ze.counts)==null?void 0:F.doxa)||(Array.isArray(ze==null?void 0:ze.slugs)?ze.slugs.length:0)}}catch{}return{...V,listTotal:Ae,listId:Y,listLabel:(Yd(Y)||{}).label||Y}}catch{return null}}const pt=fe(!1);function jt(){const F=h.value.filter(Y=>Y.kind==="zone").map(Y=>String(Y.key).replace(/^zone:/,"")),V=new Map(Me().map(Y=>[Y.id,Y]));return F.map(Y=>V.get(Y)).filter(Boolean)}async function $l(){const F=jt();if(!F.length)throw new Error("nothing selected");if(!be)throw new Error("no API configured");const Y=await fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,population,religion,image_url&lang=${Wn()}`,{cache:"no-store"});if(!Y.ok)throw new Error(`people-groups fetch failed (${Y.status})`);const ye=Ta(await La(Ea(await Y.json()),a)),{evaluate:Ae}=await yt(async()=>{const{evaluate:He}=await Promise.resolve().then(()=>vi);return{evaluate:He}},void 0),Be=new Set;for(const He of F)if(He.selector&&He.selector.type==="pg_slugs")for(const Pe of He.selector.values||[])Be.add(Pe);else for(const Pe of Ae(He.selector,ye))Be.add(Pe);const Ke=F.map(He=>He.label||He.id);return{id:"selection",label:Ke.length<=3?Ke.join(" + "):`${Ke.slice(0,2).join(" + ")} +${Ke.length-2} more`,count:Be.size,selector:{type:"pg_slugs",values:[...Be]}}}async function wA(){if(!pt.value){pt.value=!0;try{const F=await $l(),[{createPacketRenderer:V},Y]=await Promise.all([yt(()=>Promise.resolve().then(()=>yl),void 0),yt(()=>Promise.resolve().then(()=>ts),void 0).then(ze=>ze.default||ze)]),ye=V({strings:Y,lang:Wn()}),Ae=jt(),Be=Ae.length===1?await xe(Ae[0].id,ye):"",Ke=await It();await N.printPacket(F,{mapSvg:Be,funnel:Ke&&Ae.length===1?Ke:Ke?{...Ke,listCount:0}:null})}catch(F){Re(we("messages.selectionPacketFailed",{reason:String((F==null?void 0:F.message)||F).slice(0,90)}),4e3)}finally{pt.value=!1}}}async function kA(){if(!pt.value){pt.value=!0;try{const F=jt();if(!F.length)throw new Error("nothing selected");if(F.length>1){Re(we("messages.posterOneTerritory",{count:F.length}),5e3);return}await N.printPoster(F[0])}catch(F){Re(we("messages.selectionPosterFailed",{reason:String((F==null?void 0:F.message)||F).slice(0,90)}),4e3)}finally{pt.value=!1}}}function Wn(){const F=Se&&(Se.value??Se);return typeof F=="string"&&F||"en"}function qn(F){if(!C||!C.getLayer("tapestry-fill"))return!1;if(P.value)return F&&Ee(F),!0;if(!F)return _e=null,b.value=null,C.setFilter("tapestry-fill",null),C.setFilter("tapestry-line",null),C.setPaintProperty("upg-pins","circle-opacity",1),!0;_e=F;const V=[...j(F)];b.value=V.length===1?V[0]:F.id??null;const Y=["in",["get","zoneKey"],["literal",V]];C.setFilter("tapestry-fill",Y),C.setFilter("tapestry-line",Y),C.getLayer("upg-pins")&&C.setPaintProperty("upg-pins","circle-opacity",["case",["in",["get","zoneKey"],["literal",V]],.95,.05]);const ye=z(Ae=>V.includes(Ae.properties.zoneKey));return ye&&C.fitBounds(ye,{padding:40,duration:700,maxZoom:6}),!0}function _l(){C&&(typeof $e=="function"&&$e(),W&&(ue(),me(),ae(),R(),b.value&&C.getLayer("tapestry-fill")&&qn(_e)))}function xA(){C&&(f.value=!f.value,m.theme.value=f.value?"dark":"light",C.setStyle(f.value?cl("ink",r).style||"mapbox://styles/mapbox/dark-v11":cl("paper",r).style||"mapbox://styles/mapbox/light-v11"),C.once("style.load",_l))}function Wg(){!C||!C.getLayer("upg-pins")||(C.on("click","upg-pins",F=>{const V=F&&F.features&&F.features[0];V&&c&&typeof c.selectPeopleGroup=="function"&&c.selectPeopleGroup(V)}),C.on("mouseenter","upg-pins",()=>{C&&(C.getCanvas().style.cursor="pointer")}),C.on("mouseleave","upg-pins",()=>{C&&(C.getCanvas().style.cursor="")}))}let Ga=null,mn,Yn=null;function os(F,V){var Y,ye,Ae;try{const Be=(Ae=(ye=(Y=p.value)==null?void 0:Y.getRootNode)==null?void 0:ye.call(Y))==null?void 0:Ae.host;if(!Be)return;Be.setAttribute("data-doxa-select-zone-state",F),V&&Be.setAttribute("data-doxa-select-zone-applied",String(V))}catch{}}function za(F){if(!F)return qn(null),mn=void 0,os("cleared",""),!0;const V=qg($.value,F);return V?qn(V)?(os("applied",F),!0):(mn=F,os("applied-but-no-selection",F),!1):(mn=F,os("unresolved",F),!1)}function PA(F){var Y;const V=((Y=F==null?void 0:F.detail)==null?void 0:Y.listId)??null;za(V)}function qg(F,V){for(const Y of F||[]){if((Y.zoneKey||Y.id)===V)return Y;const ye=Y.children&&qg(Y.children,V);if(ye)return ye}return null}function SA(){const F=dl(o,{deafCount:hl});$.value=F,X=yg(F);const V={};for(const Y of o.lists||[])V[Y.id]=Y.selector;for(const Y of o.asia_lists||[])V[Y.id]=Y.selector;for(const Y of o.uncovered_lists||[])V[Y.id]=Y.selector;V.deaf={type:"affinity_bloc",rop1:"A017"};for(const Y of X)Y.selector=V[Y.id];se=de(X)}async function Yg(){if(be)try{const V=await fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=en`,{cache:"no-store"});if(!V.ok)throw new Error(`list ${V.status}`);const Y=Ta(await La(Ea(await V.json()),a));w=vg(Y),$.value=dl(o,{deafCount:hl,records:Y})}catch{}}ho(async()=>{var Ae,Be,Ke,ze,He;SA();try{await nS(r)}catch{}const F=ul(r);F&&tS(F);const V=(n==null?void 0:n.value)||((Ae=a==null?void 0:a.value)==null?void 0:Ae.tk)||"";if(!F){console.warn(`[upg-100-list] ${r} engine global is missing — refusing to substitute another engine. A page that asked for the keyless engine must not silently receive the token-gated one.`),d.value=`⚠ ${we("messages.engineNotLoaded")}`,x.value=we("messages.engineNotLoadedDetail",{engine:s?"MapLibre":"Mapbox"}),Yg();return}if(!s){if(!V){d.value="⚠ no mapbox token",x.value="No Mapbox token configured. The list and legend are unaffected.",Yg();return}F.accessToken=V}try{const Pe=!s&&p.value&&p.value.getRootNode();if(Pe instanceof ShadowRoot){const Qe=oS("mapbox");if(Qe&&!Pe.querySelector(`link[href="${Qe}"]`)){const $t=document.createElement("link");$t.rel="stylesheet",$t.href=Qe,Pe.prepend($t)}}}catch{}C=new F.Map({container:p.value,style:cl("paper",r).style||"mapbox://styles/mapbox/light-v11",center:[35,20],zoom:1.5,projection:"mercator"}),g.value=C,U=XP(((Be=p.value)==null?void 0:Be.parentElement)||null,{enabled:l.value}),typeof window<"u"&&(window.__UPG_MAP__=C),window.__UPG_SELECT__={get list(){return h.value.map(Pe=>({...Pe}))},get total(){return y.value},get count(){return v.value},get color(){return O.value},get batchMode(){return P.value},setColor:Pe=>G(Pe),setBatchMode:Pe=>L(Pe),clipboardText:()=>gS(h.value,{color:O.value}),clear:()=>ne(),toggleByProps:Pe=>{const Qe=wg(Pe,{nameMap:w});return Qe?(K(Qe),{...Qe}):null},toggleLegendRow:Pe=>{const Qe=Qo=>{for(const gt of Qo){if(gt.label===Pe)return gt;if(gt.children&>.children.length){const Ot=Qe(gt.children);if(Ot)return Ot}}return null},$t=Qe($.value);return $t?(Ee($t),{label:$t.label,zoneKeys:[...j($t)]}):null},markedLegendRows:()=>{if(typeof document>"u")return[];const Pe=document.querySelector("my-upg-100-list-map");return[...(Pe&&Pe.shadowRoot||document).querySelectorAll(".stl-row.upg-batch-row .stl-name")].map($t=>$t.textContent.trim())},highlightFeatureCount:()=>{if(!C||!W||!C.getLayer("upg-sel-fill"))return-1;const Pe=new Set,Qe=new Set,$t=new Set;for(const gt of h.value)gt.kind==="zone"?Pe.add(gt.key.slice(5)):gt.kind==="adm1"?Qe.add(gt.name):gt.kind==="adm0"&&$t.add(gt.key.slice(5));let Qo=0;for(const gt of W.features){const Ot=gt.properties||{};(Pe.has(Ot.zoneKey)||Qe.has(Ot.shapeName)||$t.has(Ot.iso3))&&Qo++}return Qo},zoneKeysForRow:Pe=>{const Qe=Qo=>{for(const gt of Qo){if(gt.label===Pe)return gt;if(gt.children&>.children.length){const Ot=Qe(gt.children);if(Ot)return Ot}}return null},$t=Qe($.value);return $t?[...j($t)]:null}};try{d.value="loading boundaries…";const Pe=je=>`${On(a.value)}/boundaries/${je}`,Qe=je=>fetch(Pe(je)).then(Ct=>{if(!Ct.ok)throw new Error(`boundary fetch ${Ct.status} ${je}`);return Ct.json()});if(!be)throw new Error("No API base configured — set window.MAP_APP_API_URL or VITE_API_BASE_URL. Failing closed (no default host).");const Qo=fetch(`${be}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=en`).then(je=>{if(!je.ok)throw new Error(`list ${je.status}`);return je.json()}),gt={adm0:Qe("world-adm0.geojson"),adm1Chn:Qe("gb-CHN-ADM1.geojson"),adm1Ind:Qe("gb-IND-ADM1.geojson")};d.value="fetching 2106 UUPGs…";const Ot=Ta(await La(Ea(await Qo),a));w=vg(Ot),$.value=dl(o,{deafCount:hl,records:Ot});const vl=[],Ba={},{evaluate:LA}=await yt(async()=>{const{evaluate:je}=await Promise.resolve().then(()=>vi);return{evaluate:je}},void 0);for(const je of X)if(je.selector&&je.selector.type==="pg_slugs")for(const Ct of je.selector.values||[])Ct in Ba||(Ba[Ct]=je.zoneKey);else try{for(const Ct of LA(je.selector,Ot))Ct in Ba||(Ba[Ct]=je.zoneKey)}catch(Ct){console.warn("zone selector skipped",je.id,Ct&&Ct.message)}for(const je of Ot){const Ct=Number(je.latitude),kl=Number(je.longitude);!isFinite(Ct)||!isFinite(kl)||vl.push({type:"Feature",geometry:{type:"Point",coordinates:[kl,Ct]},properties:{slug:je.slug,zoneKey:Ba[je.slug]||"",name:je.name||je.slug||"",population:je.population??0,countryName:je.country_code_label||"",country:je.country_code||""}})}const CA=on({type:"FeatureCollection",features:vl});$e=()=>{if(!(C.getSource("upg")&&C.getLayer("upg-pins"))){if(C.getSource("upg")||C.addSource("upg",{type:"geojson",data:CA}),C.getLayer("upg-pins")){Wg();return}C.addLayer({id:"upg-pins",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],1,5,4,6.5,8,9],"circle-color":se,"circle-opacity":1,"circle-stroke-width":["interpolate",["linear"],["zoom"],1,1.8,8,2],"circle-stroke-color":"rgba(15,20,25,0.9)"}}),Wg()}};const Zg=()=>{try{_l()}catch(je){console.warn("early pin paint skipped",je&&je.message)}};C.isStyleLoaded()?Zg():C.once("style.load",Zg),d.value="loading boundaries…";const[TA,EA]=await Promise.all([gt.adm0,gt.adm1Chn]),RA=await gt.adm1Ind,{tapestry:MA,perZone:NA}=uS(X,{records:Ot,adm0:TA,adm1Ind:RA,adm1Chn:EA});W=on(MA),he(Ot);let wl=!0;const Zn=()=>{wl&&(wl=!1,C.off("style.load",Zn),C.off("idle",Zn),_l())};if(C.isStyleLoaded())Zn();else{C.once("style.load",Zn),C.once("idle",Zn);const je=setInterval(()=>{if(!wl||!C){clearInterval(je);return}let Ct=!1;try{Ct=C.isStyleLoaded()}catch{clearInterval(je);return}Ct&&(clearInterval(je),Zn())},120);setTimeout(()=>clearInterval(je),15e3)}const Jg=[...NA.entries()].filter(([je])=>je!=="deaf"),FA=Jg.filter(([,je])=>je>=1).length;d.value=`${W.features.length} polys · ${FA}/${Jg.length} zones · ${vl.length} pins`}catch(Pe){d.value="⚠ "+(Pe&&Pe.message?Pe.message:String(Pe))}let Y=0;const ye=()=>{const Pe=typeof document<"u"&&document.querySelector("my-upg-100-list-map"),Qe=Pe&&Pe.shadowRoot||(typeof document<"u"?document:null);if(Qe&&Qe.querySelector(".stl-rows")){so(),nt();return}Y++<40&&setTimeout(ye,250)};ye();{const Pe=(He=(ze=(Ke=p.value)==null?void 0:Ke.getRootNode)==null?void 0:ze.call(Ke))==null?void 0:He.host;if(Pe){Ga=PA,Pe.addEventListener("doxa:select-zone",Ga);const Qe=Pe.getAttribute("select-zone");Qe&&za(Qe),Yn=new MutationObserver(()=>{za(Pe.getAttribute("select-zone")||null)}),Yn.observe(Pe,{attributes:!0,attributeFilter:["select-zone"]})}}});const AA=()=>{var F,V,Y;try{return((Y=(V=(F=p.value)==null?void 0:F.getRootNode)==null?void 0:V.call(F))==null?void 0:Y.host)||null}catch{return null}};return et([$,g],()=>{qt(()=>{var V;const F=((V=AA())==null?void 0:V.getAttribute("select-zone"))||mn||null;F&&za(F)})}),Xt(()=>{var F,V,Y;if(Yn==null||Yn.disconnect(),Yn=null,Ga){const ye=(Y=(V=(F=p.value)==null?void 0:F.getRootNode)==null?void 0:V.call(F))==null?void 0:Y.host;ye==null||ye.removeEventListener("doxa:select-zone",Ga),Ga=null}if(Pt){try{Pt.disconnect()}catch{}Pt=null}if(U){try{U()}catch{}U=null}C&&(C.remove(),C=null),W=null}),(F,V)=>{var Y;return q(),oe("div",yS,[E("div",{ref_key:"mapEl",ref:p,class:"upg-map"},null,512),x.value?(q(),oe("div",$S,[E("strong",null,ce(ge(we)("messages.mapUnavailable")),1),vt(ce(x.value),1)])):ke("",!0),l.value?(q(),oe(Ge,{key:1},[V[0]||(V[0]=E("div",{class:"map-scroll-edge map-scroll-edge--left"},null,-1)),V[1]||(V[1]=E("div",{class:"map-scroll-edge map-scroll-edge--right"},null,-1))],64)):ke("",!0),g.value&&i.value?(q(),lt(KP,{key:2,ref_key:"geocoderRef",ref:Z,"map-instance":g.value,"access-token":ge(n)||((Y=ge(a))==null?void 0:Y.tk)||"","data-source-id":gl,"is-dark":f.value,placeholder:B.value,"active-context":RS,onPeopleGroupResult:pe,onAggregateResult:_,onClear:k},null,8,["map-instance","access-token","is-dark","placeholder"])):ke("",!0),g.value?(q(),lt($P,{key:3,"has-geocoder":i.value},{default:Yt(()=>[Xe(vP,{map:g.value,"is-dark":f.value},null,8,["map","is-dark"]),Xe(wP,{map:g.value,"is-dark":f.value},null,8,["map","is-dark"]),Xe(kP,{map:g.value,"is-dark":f.value},null,8,["map","is-dark"]),Xe(SP,{"map-container":p.value,"is-dark":f.value},null,8,["map-container","is-dark"]),Xe(LP,{"is-dark":f.value,onToggle:xA},null,8,["is-dark"]),Xe(fn,{"is-dark":f.value,active:P.value,class:De({"upg-batch-on":P.value}),"aria-pressed":P.value?"true":"false",title:"Batch Select",onClick:J},{default:Yt(()=>[...V[2]||(V[2]=[E("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[E("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),E("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),E("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),E("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})],-1)])]),_:1},8,["is-dark","active","class","aria-pressed"])]),_:1},8,["has-geocoder"])):ke("",!0),E("div",_S,[$.value.length?(q(),lt(dp,{key:0,nodes:$.value,tabs:D,"default-tab":xg,columns:["count","pop"],title:Le.value,"export-enabled":!0,onSelect:qn,onExport:bt},null,8,["nodes","title"])):ke("",!0)]),E("div",vS,[$.value.length?(q(),lt(yP,{key:0,"legend-type":"upg-100",nodes:$.value,tabs:D,"default-tab":xg,columns:["count","pop"],"column-label":"UPG 100",title:Le.value,"is-dark":f.value,"popup-action":"pray"},null,8,["nodes","title","is-dark"])):ke("",!0)]),E("div",wS,[ge(c)&&ge(c).selectedPeopleGroup?(q(),oe("div",{key:0,class:De(["upg-detail-panel pg-detail-root",{dark:f.value}])},[Xe(ge(t),{peopleGroup:ge(c).selectedPeopleGroup,dark:f.value,action:"pray"},null,8,["peopleGroup","dark"])],2)):ke("",!0)]),P.value?(q(),oe("div",kS,[V[3]||(V[3]=E("div",{class:"upg-hud-hint"}," Tap territories on the map or legend rows to add · tap again to remove ",-1)),v.value?(q(),oe("div",xS,[E("span",null,ce(v.value)+" territor"+ce(v.value===1?"y":"ies")+" ·",1),E("span",PS,ce(y.value)+" UUPG",1),E("span",{class:De(["upg-hud-band",{ok:y.value>=50&&y.value<=100}])},ce(y.value>=50&&y.value<=100?"✓ 50–100 band":"band 50–100"),3)])):ke("",!0),v.value?(q(),oe("div",SS,ce(h.value.map(ye=>ye.name).join(", ")),1)):ke("",!0),v.value?(q(),oe("div",AS,[E("button",{class:"upg-hud-btn make",disabled:pt.value,onClick:wA},ce(ge(we)("buttons.prayerList")),9,LS),E("button",{class:"upg-hud-btn make",disabled:pt.value,onClick:kA},ce(ge(we)("buttons.posterMap")),9,CS),E("button",{class:"upg-hud-btn clear",onClick:ne},ce(ge(we)("buttons.clearSelection")),1)])):ke("",!0),v.value?(q(),oe("div",TS,ce(A.value),1)):ke("",!0)])):ke("",!0),E("div",ES,ce(d.value),1)])}}}},Symbol.toStringTag,{value:"Module"})),NS=` /* The column that scrolls. Vertical neighbours stack here and the user scrolls between them; scroll-snap makes each pane settle cleanly instead of stopping half-way between two views. */ diff --git a/public/dx-maps/my-upg-100-list/poster-wall/index.html b/public/dx-maps/my-upg-100-list/poster-wall/index.html index 14bbf6f4e..48d76dd44 100644 --- a/public/dx-maps/my-upg-100-list/poster-wall/index.html +++ b/public/dx-maps/my-upg-100-list/poster-wall/index.html @@ -32,7 +32,7 @@ - + - + - +