diff --git a/plugin-designs/my-upg-100-list/upg-100-list.vue b/plugin-designs/my-upg-100-list/upg-100-list.vue index 7207c0569..57479e255 100644 --- a/plugin-designs/my-upg-100-list/upg-100-list.vue +++ b/plugin-designs/my-upg-100-list/upg-100-list.vue @@ -499,7 +499,13 @@ import { resolveAssetsBase } from '@map/utils/embedBase.js' // between MapLibre and Mapbox (see openPgDetail). import { readSourceFeatures } from '@map/maps/pin-selection.js' useShadowStyles( - '.upg-root{position:absolute;inset:0;background:#0a1410;color:#e5e7eb;' + + // ★ isolation:isolate CONFINES THE MAP AREA'S LAYERS (2026-09-30), the containing layer Simple Research's and the + // country map's .rm-root already have. Without it the legend sheet's z-index 1000 competed directly with the + // gallery's round ☰ (z 15) in the shell's stacking context and painted over it on the Map view. Isolated, + // the whole map area stacks as one layer and the ☰ sits above it, sheet included, as on those maps. It is on + // the MAP root only: the poster wall's modal scrim lives in the other pane, outside this layer, and keeps + // covering the ☰ (raising the ☰ instead would have put it over that modal). + '.upg-root{position:absolute;inset:0;background:#0a1410;color:#e5e7eb;isolation:isolate;' + "font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif}" + '.upg-map{position:absolute;inset:0}' + // P3-1 graceful degrade: the map-cell error notice. Centred in the map cell and diff --git a/public/dx-maps/doxa-maps-spa/manifest.json b/public/dx-maps/doxa-maps-spa/manifest.json index 92ccf6efc..ed975b36b 100644 --- a/public/dx-maps/doxa-maps-spa/manifest.json +++ b/public/dx-maps/doxa-maps-spa/manifest.json @@ -880,7 +880,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-K7Y9dvSPtfbM2Qsv7CC6+3pqjyodFuC6WijFSDZE2rimhxzM9DtYpva12957PrcB", + "integrity": "sha384-o2/45WLYaUJVENJXKkSxvfL2SNrc7nQuznec/tqrGMn6j7KH5fLk39r7kKpz29we", "elements": [ "my-upg-100-list-map" ], @@ -903,7 +903,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n" + "script": "\n\n\n" } }, { @@ -919,8 +919,8 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n\n\n", - "scriptMapbox": "\n\n\n\n\n\n" + "script": "\n\n\n\n\n\n", + "scriptMapbox": "\n\n\n\n\n\n" } }, { @@ -936,8 +936,8 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n\n\n", - "scriptMapbox": "\n\n\n\n\n\n" + "script": "\n\n\n\n\n\n", + "scriptMapbox": "\n\n\n\n\n\n" } } ] diff --git a/public/dx-maps/manifest.json b/public/dx-maps/manifest.json index 92ccf6efc..ed975b36b 100644 --- a/public/dx-maps/manifest.json +++ b/public/dx-maps/manifest.json @@ -880,7 +880,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-K7Y9dvSPtfbM2Qsv7CC6+3pqjyodFuC6WijFSDZE2rimhxzM9DtYpva12957PrcB", + "integrity": "sha384-o2/45WLYaUJVENJXKkSxvfL2SNrc7nQuznec/tqrGMn6j7KH5fLk39r7kKpz29we", "elements": [ "my-upg-100-list-map" ], @@ -903,7 +903,7 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n" + "script": "\n\n\n" } }, { @@ -919,8 +919,8 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n\n\n", - "scriptMapbox": "\n\n\n\n\n\n" + "script": "\n\n\n\n\n\n", + "scriptMapbox": "\n\n\n\n\n\n" } }, { @@ -936,8 +936,8 @@ "scriptUrl": "./my-upg-100-list/my-upg-100-list.js", "embed": { "iframe": "", - "script": "\n\n\n\n\n\n", - "scriptMapbox": "\n\n\n\n\n\n" + "script": "\n\n\n\n\n\n", + "scriptMapbox": "\n\n\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 538cf6c44..94d71f4be 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 @@ -874,7 +874,7 @@ .geo-root, .mapboxgl-ctrl-geocoder, .maplibregl-ctrl-geocoder { transition: none !important; animation: none !important; } } `,"geocoder-skin");const{t:n,locale:r}=Kt(),i=e,s=Q(()=>/^pk\./.test(String(i.accessToken||""))),l=Q(()=>i.placeholder||(i.provider==="maplibre"&&!s.value?n("search.placeholderNoPlaces"):n("search.placeholder"))),c=o,u={"&":"&","<":"<",">":">",'"':""","'":"'"};function d(w){return String(w??"").replace(/[&<>"']/g,j=>u[j])}function p(w){return w==null?"":typeof w=="string"?w:typeof w=="object"?w.label||w.value||"":String(w)}const _={"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 f(w){const j=_[w];if(!j)return"";const D=n("search.kinds."+j);return`${d(D)}`}function h(w){var R;if(!w)return"";const j=w.place_type||[];if(j.includes("doxa-section-header"))return`
${d(((R=w.properties)==null?void 0:R.headerLabel)||w.text||"")}
`;if(j.includes("people-group")){const re=w.properties||{},he=p(re.name)||p(re.displayName)||p(w.text)||"",$e=p(re.countryName)||p(re.country)||p(re.countryIso)||"",ke=p(re.language)||p(re.primaryLanguage)||p(re.languageFamily)||"",Me=p(re.religionName)||p(re.religion)||"",je=n("search.labels.place"),Se=n("search.labels.language"),xe=n("search.labels.religion"),tt=[];return $e&&tt.push(`${d(je)} ${d($e)}`),ke&&tt.push(`${d(Se)} ${d(ke)}`),Me&&tt.push(`${d(xe)} ${d(Me)}`),`
${f("people-group")}${d(he)}
`+(tt.length?`
${tt.join("")}
`:"")}const D=j.find(re=>re.startsWith("doxa-"));if(D){const re=w.properties||{},he=d(p(re.label)||w.text||""),$e=Number(re.count)||0,ke=$e?` ${$e}`:"";return`
${f(D)}${he}${ke}
`}return`
${d(w.place_name||w.text||"")}
`}const y=at("dataStore",null),b=at("mapStore",null),m=at("uiStore",null);function k(){return b?b.selectedFamily?{kind:"family",key:b.selectedFamily}:b.selectedLanguage?{kind:"language",key:b.selectedLanguage}:null:null}const{search:$}=CP({dataStore:y,dataSourceId:i.dataSourceId||void 0,getActiveFilter:k,getActiveContext:()=>i.activeContext||null}),g=Ha(null),v=fe(null),S={mapbox:ba.mapboxGeocoderCss.url,maplibre:ba.maplibreGeocoderCss.url},A=ba.maplibreGeocoderJs.url,C=ba.mapboxGeocoderJs.url;function W(w,j){const D=S[j]||S.mapbox;if(w.querySelector(`link[href="${D}"]`))return;const R=document.createElement("link");R.rel="stylesheet",R.href=D,Tr(R,D),w.prepend(R)}async function Z(w,j){if(typeof window<"u"&&window[j]||typeof document>"u")return;const D=document.querySelector(`script[src="${w}"]`);if(D){if(window[j])return;await new Promise(R=>{D.addEventListener("load",R,{once:!0}),D.addEventListener("error",R,{once:!0})});return}await new Promise(R=>{const re=document.createElement("script");re.src=w,Tr(re,w),re.async=!0,re.addEventListener("load",R,{once:!0}),re.addEventListener("error",R,{once:!0}),document.head.appendChild(re)})}function I(w=document){let j=w.activeElement;for(;j&&j.shadowRoot&&j.shadowRoot.activeElement;)j=j.shadowRoot.activeElement;return j}function T(w){const j=w==null?void 0:w._onKeyDown;typeof j=="function"&&(w._onKeyDown=function(D){const R=I();return!R||R===D.target||typeof R.value!="string"?j.call(w,D):j.call(w,new Proxy(D,{get(re,he){if(he==="target"||he==="srcElement")return R;const $e=Reflect.get(re,he);return typeof $e=="function"?$e.bind(re):$e}}))})}async function oe(){await Z(C,"MapboxGeocoder")}async function X(){if(typeof window<"u"&&window.MaplibreGeocoder||typeof document>"u")return;const w=document.querySelector(`script[src="${A}"]`);if(w){if(window.MaplibreGeocoder)return;await new Promise(j=>{w.addEventListener("load",j,{once:!0}),w.addEventListener("error",j,{once:!0})});return}await new Promise((j,D)=>{const R=document.createElement("script");R.src=A,R.async=!1,R.addEventListener("load",j,{once:!0}),R.addEventListener("error",()=>D(new Error("[GeocoderComponent] Failed to load MapLibre geocoder")),{once:!0}),document.head.appendChild(R)})}function B(w,j){return async D=>{const R={features:[]};if(!/^pk\./.test(String(w||""))||!(D!=null&&D.query))return R;try{const re=Array.isArray(D.language)?D.language[0]:D.language||j()||"en",he=new URLSearchParams({access_token:w,autocomplete:"true",limit:String(D.limit||5)});re&&he.set("language",re);const $e=`https://api.mapbox.com/geocoding/v5/mapbox.places/${encodeURIComponent(D.query)}.json?${he.toString()}`,ke=await fetch($e);if(!ke.ok)return R;const Me=await ke.json();return Me&&Array.isArray(Me.features)?Me:R}catch{return R}}}lo(async()=>{var re,he,$e,ke,Me;const w=i.provider==="maplibre";if(w){if(await X(),typeof MaplibreGeocoder>"u"){console.error("[GeocoderComponent] MaplibreGeocoder global unavailable.");return}}else if(typeof MapboxGeocoder>"u"&&(await oe(),typeof MapboxGeocoder>"u")){console.error("[GeocoderComponent] MapboxGeocoder global unavailable.");return}const j=i.mapInstance;if(!i.standalone&&!j)return;const D=i.standalone?(he=(re=v.value)==null?void 0:re.getRootNode)==null?void 0:he.call(re):(Me=(ke=($e=j.getContainer)==null?void 0:$e.call(j))==null?void 0:ke.getRootNode)==null?void 0:Me.call(ke);D instanceof ShadowRoot&&W(D,i.provider);const R={marker:!1,flyTo:!i.standalone,trackProximity:!i.standalone,placeholder:l.value,language:r.value||"en",localGeocoder:$,limit:20,zoom:6,render:h};if(w){const je=typeof maplibregl<"u"?maplibregl:void 0,Se={forwardGeocode:B(i.accessToken,()=>r.value)};g.value=new MaplibreGeocoder(Se,{...R,maplibregl:je,showResultsWhileTyping:!0,reverseGeocode:!1})}else g.value=new MapboxGeocoder({accessToken:i.accessToken,mapboxgl,...R});if(T(g.value),g.value.on("result",je=>{var xe,tt,nt,E,z,O,ae,ue,ie,_e,be,P,x,q,L,H,V,M,K,ye,Ce,Qe,ut,$t,Ee,Re,Ie,Ye,ht,ko;const Se=je==null?void 0:je.result;Se&&((xe=Se.place_type)!=null&&xe.includes("doxa-section-header")||(b&&(b.selectedRegion=null,b.selectedResource=null,b.selectedAffinityBlock=null,b.selectedDialect=null),m&&((tt=m.setPrayerFilter)==null||tt.call(m,null),(nt=m.setEngagementFilter)==null||nt.call(m,null),(E=m.setAdoptionFilter)==null||E.call(m,null),(z=m.setReligionFilter)==null||z.call(m,null)),(O=Se.properties)!=null&&O._allDataSection&&b&&(b.selectedFamily=null,b.selectedLanguage=null),c("result",je),(ae=Se.place_type)!=null&&ae.includes("people-group")&&Se.feature?c("people-group-result",{type:"Feature",properties:Se.properties||Se.feature,geometry:Se.geometry||{type:"Point",coordinates:Se.center}}):((ue=Se.place_type)!=null&&ue.includes("doxa-country")||(ie=Se.place_type)!=null&&ie.includes("doxa-region")||(_e=Se.place_type)!=null&&_e.includes("doxa-language-family")||(be=Se.place_type)!=null&&be.includes("doxa-language")||(P=Se.place_type)!=null&&P.includes("doxa-dialect")||(x=Se.place_type)!=null&&x.includes("doxa-religion")||(q=Se.place_type)!=null&&q.includes("doxa-affinity-bloc")||(L=Se.place_type)!=null&&L.includes("doxa-cluster")||(H=Se.place_type)!=null&&H.includes("doxa-people-group"))&&c("aggregate-result",{kind:Se.place_type[0].replace(/^doxa-/,""),label:((V=Se.properties)==null?void 0:V.label)||Se.text,count:((M=Se.properties)==null?void 0:M.count)||0,memberIds:((K=Se.properties)==null?void 0:K.memberIds)||[],bounds:((ye=Se.properties)==null?void 0:ye.bounds)||null,center:Se.center,originalLabels:((Ce=Se.properties)==null?void 0:Ce.originalLabels)||null,familyDerived:((Qe=Se.properties)==null?void 0:Qe.familyDerived)||"",baseLang:((ut=Se.properties)==null?void 0:ut.baseLang)||"",dialectLabel:(($t=Se.properties)==null?void 0:$t.dialectLabel)||"",slug:((Ee=Se.properties)==null?void 0:Ee.slug)||null,id:Se.id||null,blocCode:((Re=Se.properties)==null?void 0:Re.blocCode)||"",blocLabel:((Ie=Se.properties)==null?void 0:Ie.blocLabel)||"",clusterCode:((Ye=Se.properties)==null?void 0:Ye.clusterCode)||"",clusterLabel:((ht=Se.properties)==null?void 0:ht.clusterLabel)||"",peopleGroupCode:((ko=Se.properties)==null?void 0:ko.peopleGroupCode)||"",properties:Se.properties||null})))}),g.value.on("clear",()=>c("clear")),g.value.on("error",je=>c("error",je)),i.standalone){if(v.value){const je={on(){},off(){},fire(){},getContainer:()=>v.value,getZoom:()=>0,getCenter:()=>({lng:0,lat:0}),getBounds:()=>null,flyTo(){},fitBounds(){},addControl(){},removeControl(){},hasControl:()=>!1};try{const Se=g.value.onAdd(i.mapInstance||je);Se&&v.value.appendChild(Se)}catch(Se){c("error",Se)}}}else j.addControl(g.value,"top-left"),de()});function de(){var j,D;const w=(D=(j=g.value)==null?void 0:j.container)==null?void 0:D.parentElement;w&&(w.classList.add("dg-search-band"),w.classList.toggle("dg-search-band--dark",!!i.isDark))}return pt(()=>i.isDark,()=>de()),pt(l,w=>{var R,re;const j=g.value;if(!j)return;const D=j._inputEl||((re=(R=j.container)==null?void 0:R.querySelector)==null?void 0:re.call(R,"input.mapboxgl-ctrl-geocoder--input"));D&&(D.placeholder=w,D.setAttribute("placeholder",w)),j.options&&(j.options.placeholder=w)}),pt(r,w=>{const j=g.value;j!=null&&j.options&&(j.options.language=w||"en")}),qt(()=>{var w,j;if(g.value){try{i.standalone?(j=(w=g.value).onRemove)==null||j.call(w):i.mapInstance&&i.mapInstance.removeControl(g.value)}catch{}g.value=null}}),t({geocoder:g}),(w,j)=>e.standalone?(Y(),te("div",{key:0,ref_key:"standaloneContainer",ref:v,class:"dg-standalone-geocoder"},null,512)):bn(w.$slots,"default",{},void 0,void 0,1)}},EP=["mapbox","maplibre"],MP="auto";function ff(e){return e&&typeof e=="object"&&"value"in e&&!("provider"in e)&&!("profile"in e)?e.value:e}function RP(e,{token:t}={}){const o=ff(e);return NP(o)||"maplibre"}function NP(e){const t=ff(e),o=t==null?void 0:t.provider,a=typeof location<"u"?new URLSearchParams(location.search).get("provider"):void 0,n=typeof window<"u"?window.MAP_PROVIDER:void 0,r=String(o||a||n||MP).toLowerCase().trim();return EP.includes(r)?r:""}const FP="rgba(120, 128, 134, 0.28)",mf="36px",bf=()=>{};function IP(e,t={}){const{enabled:o=!0}=t;if(!o||!e)return bf;const a=Array.from(e.querySelectorAll(".map-scroll-edge"));if(!a.length)return bf;const n=m=>m.classList.contains("map-scroll-edge--left");for(const m of a)m.style.background=`linear-gradient(${n(m)?"to right":"to left"}, ${FP} ${mf}, transparent ${mf})`,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"},i=m=>{m.style.opacity="0"},s=()=>a.find(m=>!n(m))||null,l=new Set;let c=!1,u=null;const d=()=>{for(const m of a)l.has(m)||i(m)},p=()=>{const m=s();m&&(r(m),u&&clearTimeout(u),u=setTimeout(d,250))},_=()=>p(),f=m=>{if(!(m.touches&&m.touches.length===1))return;const k=m.target;k&&k.classList&&k.classList.contains("map-scroll-edge")||p()},h=()=>{u&&clearTimeout(u),d()};e.addEventListener("wheel",_,{passive:!0}),e.addEventListener("touchmove",f,{passive:!0}),e.addEventListener("touchend",h,{passive:!0}),e.addEventListener("touchcancel",h,{passive:!0});const y=()=>{c||p()};typeof window<"u"&&window.addEventListener("scroll",y,{passive:!0});const b=[];for(const m of a){const k=()=>{l.add(m),r(m)},$=()=>{l.delete(m),i(m)},g=()=>{c=!0,r(m)},v=()=>{c=!1,i(m)};m.addEventListener("mouseenter",k),m.addEventListener("mouseleave",$),m.addEventListener("touchstart",g,{passive:!0}),m.addEventListener("touchend",v,{passive:!0}),b.push(()=>{m.removeEventListener("mouseenter",k),m.removeEventListener("mouseleave",$),m.removeEventListener("touchstart",g),m.removeEventListener("touchend",v)})}return function(){u&&(clearTimeout(u),u=null),e.removeEventListener("wheel",_),e.removeEventListener("touchmove",f),e.removeEventListener("touchend",h),e.removeEventListener("touchcancel",h),typeof window<"u"&&window.removeEventListener("scroll",y);for(const k of b)k();for(const k of a)i(k)}}const OP=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 Nc(e,t="mapbox"){if(typeof e!="string"||!e)return{style:void 0,lightPreset:void 0,paint:void 0};const o=OP[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 $f={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 DP(e){return!!e&&typeof window<"u"&&e===window.maplibregl}function zP(e){if(typeof window>"u")return!1;const t=e?[e]:[window.maplibregl,window.mapboxgl].filter(Boolean);let o=!1;for(const a of t)if(!(!a||!a.setRTLTextPlugin))try{if(DP(a)){if(a.getRTLTextPluginStatus&&a.getRTLTextPluginStatus()!=="unavailable")continue;const n=a.setRTLTextPlugin($f.maplibre,!0);n&&n.catch&&n.catch(()=>{})}else a.setRTLTextPlugin($f.mapbox,null,!0);o=!0}catch{}return o}const Rn={mapbox:{global:"mapboxgl",js:ba.mapboxGlJs.url,css:ba.mapboxGlCss.url},maplibre:{global:"maplibregl",js:ba.maplibreGlJs.url,css:ba.maplibreGlCss.url}};function Fc(e){var o;const t=((o=Rn[e])==null?void 0:o.global)||Rn.mapbox.global;return typeof window<"u"?window[t]:void 0}function _f(e){return(Rn[e]||Rn.mapbox).css||null}async function jP(e){const t=Rn[e]||Rn.mapbox;if(Fc(e)||typeof document>"u")return;if(!document.querySelector(`link[href="${t.css}"]`)){const a=document.createElement("link");a.rel="stylesheet",a.href=t.css,Tr(a,t.css),document.head.appendChild(a)}const o=document.querySelector(`script[src="${t.js}"]`);if(o){if(Fc(e))return;await new Promise(a=>{o.addEventListener("load",a,{once:!0}),o.addEventListener("error",a,{once:!0})});return}await new Promise((a,n)=>{const r=document.createElement("script");r.src=t.js,Tr(r,t.js),r.async=!1,r.addEventListener("load",a,{once:!0}),r.addEventListener("error",()=>n(new Error(`[useMapInstance] Failed to load ${e} engine script`)),{once:!0}),document.head.appendChild(r)})}async function GP(e,t){if(!e)return;const o=e.getRootNode();if(!(o instanceof ShadowRoot))return;const a=i=>new Promise(s=>setTimeout(s,i)),n=o.querySelector(`link[href="${t}"]`);if(n){if(n.sheet)return;await Promise.race([new Promise(i=>{n.addEventListener("load",i,{once:!0}),n.addEventListener("error",i,{once:!0})}),a(2e3)]);return}const r=document.createElement("link");r.rel="stylesheet",r.href=t,Tr(r,t),await Promise.race([new Promise(i=>{r.addEventListener("load",i,{once:!0}),r.addEventListener("error",i,{once:!0}),o.prepend(r)}),a(2e3)])}const BP=["country_code","wagf_region","wagf_block","primary_language","religion","imb_gsec"];function HP(e){return e==null?{value:null,label:null}:typeof e=="object"?{value:e.value??null,label:e.label??null}:{value:e,label:null}}function UP(e){if(e==null||typeof e!="object")return e;const t={...e};for(const o of BP)if(o in t){const{value:a,label:n}=HP(t[o]);t[o]=a,n!=null&&(t[`${o}_label`]=n)}return t}function Ic(e){return Array.isArray(e)?e.map(UP):[]}function Oc(e){return Array.isArray(e)?e:e&&typeof e=="object"?e.posts||e.data||e.records||e.results||e.items||[]:[]}const WP={"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 KP(e,t){const o=WP[e];return typeof o=="string"&&o?o:t}const on={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"},yf=Object.freeze(Object.defineProperty({__proto__:null,ISO3_NAME:on},Symbol.toStringTag,{value:"Module"})),Qi={"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},vf={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};function kf(e){const t={...on};for(const o of e||[]){const a=o&&o.country_code,n=o&&o.country_code_label;a&&n&&(t[a]=n)}return t}function wf(e,t={}){if(!e||typeof e!="object")return null;const o=t.nameMap||on;if(e.shapeName&&(e.listId||!e.iso3)){const a=String(e.shapeName),n=Object.prototype.hasOwnProperty.call(Qi,a)?Qi[a]:null;return{key:"adm1:"+a,name:a,count:n,kind:"adm1"}}if(e.iso3){const a=String(e.iso3),n=o[a]||on[a]||a,r=Object.prototype.hasOwnProperty.call(vf,a)?vf[a]:null;return{key:"adm0:"+a,name:n,count:r,kind:"adm0"}}return null}function VP(e,t={}){const o=Array.isArray(e)?e:[],a=o.map(l=>l.name),n=o.reduce((l,c)=>l+(Number(c.count)||0),0),r=t&&typeof t.color=="string"&&t.color?t.color:"",i=a.join(", ")+" — "+n+" UUPG"+(r?" · "+r:""),s=o.map(l=>l.name+" "+(Number(l.count)||0)).join(", ");return i+` -`+s}function Nn(e){return String(e??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function qP(e){return Nn(e).split(/[\s,;]+/).filter(Boolean)}function YP(e={}){const{records:t=[],leafZones:o=[],adm1Counts:a={},iso3Names:n={},countryNameMap:r=null}=e,i=[],s=new Set;for(const c of t){if(!c)continue;const u=c.slug;if(!u||s.has(u))continue;const d=Number(c.latitude),p=Number(c.longitude);if(!Number.isFinite(d)||!Number.isFinite(p))continue;const _=c.name||u;s.add(u),i.push({label:_,kind:"pg",target:{type:"pg",slug:u,lng:p,lat:d},_hay:Nn(_)})}for(const c of o){if(!c)continue;const u=c.zoneKey||c.id,d=c.label||u;u&&i.push({label:d,kind:"zone",target:{type:"zone",zoneId:u},_hay:Nn(d)})}for(const c of Object.keys(a))i.push({label:c,kind:"territory",target:{type:"territory",shapeName:c},_hay:Nn(c)});const l=r||n;for(const c of Object.keys(n)){const u=l&&l[c]||n[c]||c;i.push({label:u,kind:"territory",target:{type:"territory",shapeName:c,iso3:!0},_hay:Nn(u)})}return i}const ZP={zone:0,territory:1,pg:2};function JP(e={}){const{records:t=[],leafZones:o=[],adm1Counts:a={},iso3Names:n={},countryNameMap:r=null,centroidFor:i=null}=e,s=[];for(const u of t)u&&s.push(u);const l=(u,d,p)=>!d||!Number.isFinite(d[0])||!Number.isFinite(d[1])?null:{name:u,slug:p.__synthSlug,latitude:d[1],longitude:d[0],...p};for(const u of o){if(!u)continue;const d=u.zoneKey||u.id,p=u.label||d;if(!d)continue;const _=typeof i=="function"?i(h=>h&&h.properties&&h.properties.zoneKey===d):null,f=l(p,_,{__upgKind:"zone",__zoneId:d,__synthSlug:`__zone__${d}`});f&&s.push(f)}for(const u of Object.keys(a)){const d=typeof i=="function"?i(_=>_&&_.properties&&_.properties.shapeName===u):null,p=l(u,d,{__upgKind:"territory",__shapeName:u,__synthSlug:`__terr__${u}`});p&&s.push(p)}const c=r||n;for(const u of Object.keys(n)){const d=c&&c[u]||n[u]||u,p=typeof i=="function"?i(f=>f&&f.properties&&f.properties.iso3===u):null,_=l(d,p,{__upgKind:"territory",__shapeName:u,__synthSlug:`__terr__${u}`});_&&s.push(_)}return s}function xf(e,t,o={}){const a=o.limit??8,n=qP(t);if(!n.length)return[];const r=n[0],i=[];for(const s of e){let l=!0;for(const d of n)if(!s._hay.includes(d)){l=!1;break}if(!l)continue;const c=s._hay.startsWith(r)?0:1,u=s._hay===Nn(t)?-1:0;i.push({e:s,starts:c,exact:u,kr:ZP[s.kind]??9,len:s._hay.length})}return i.sort((s,l)=>s.exact-l.exact||s.starts-l.starts||s.kr-l.kr||s.len-l.len),i.slice(0,a).map(s=>s.e)}const es=new Set;function XP(e,t){var n,r;const o=e.getSource(t);if(!o)return[];let a=o._data??((r=(n=o.serialize)==null?void 0:n.call(o))==null?void 0:r.data);if(a&&typeof a=="object"&&!Array.isArray(a)){if(a.geojson!==void 0)a=a.geojson;else if(a.url!==void 0)return es.has(t)||(es.add(t),console.warn(`[pin-selection] source "${t}" is remote (url); its features cannot be read locally, so nothing can be selected from it.`)),[]}return a?Array.isArray(a==null?void 0:a.features)?a.features:(a==null?void 0:a.type)==="Feature"?[a]:(a&&typeof a=="object"&&!es.has(t)&&(es.add(t),console.warn(`[pin-selection] source "${t}": unrecognised data shape {${Object.keys(a).join(",")}} — nothing can be selected from it; this is NOT a confirmed empty source.`)),[]):[]}const QP={class:"upg-root"},eS={key:0,class:"upg-map-err"},tS={class:"upg-legend-desktop-slot"},oS={class:"upg-legend-mobile-slot"},aS={class:"upg-detail-desktop-slot"},nS=["aria-label","title"],rS={class:"upg-shown-name"},iS={key:5,class:"upg-hud"},sS={class:"upg-hud-hint"},lS={key:0,class:"upg-hud-head"},cS={class:"upg-hud-total"},uS={key:1,class:"upg-hud-names"},dS={key:2,class:"upg-hud-actions"},pS=["disabled"],gS=["disabled"],hS=["disabled"],fS={key:3,class:"upg-hud-flash"},mS={class:"upg-status"},Dc="upg-search",Pf=1,bS="people-groups",Sf=8,Af=123,$S=Object.freeze(Object.defineProperty({__proto__:null,default:{__name:"upg-100-list",setup(e){const t=Sg(()=>Pt(()=>Promise.resolve().then(()=>jx),void 0)),o=at("mapboxToken",fe("")),a=at("profileConfig",fe(null));let n=null,r=null,i=null;function s(){var F,U;return((F=a.value)==null?void 0:F.instanceId)||((U=a.value)==null?void 0:U.profile)||"upg-100-list"}const l=RP(a),c=l==="maplibre",u=Q(()=>{var F;return((F=a==null?void 0:a.value)==null?void 0:F.search)===!1?!1:l==="mapbox"}),d=Q(()=>{var U;const F=(U=a.value)==null?void 0:U.edgeScrollAffordance;return F==null?!0:!(F===!1||F==="false")}),p=at("dataStore",null),_=at("uiStore",null),f=fe(null),h=fe(""),y=fe(""),b=Ha([]),m=fe(null),k=Ha(null),$=fe(!1),g=fv("my-upg-100-list");g.theme.value="light",mv(g);const v=fe([]),S=Q(()=>v.value.reduce((F,U)=>F+(Number(U.count)||0),0)),A=Q(()=>v.value.length),C=fe("");let W=null;const Z=fe(!1);function I(F){const U=F===void 0?!Z.value:!!F;return U===Z.value||(Z.value=U,R&&(R.getCanvas().style.cursor=""),x()),U}function T(){I()}pt([Z,$],()=>{oo(()=>G())});function oe(F){if(!F)return;const U=v.value,J=U.findIndex(ge=>ge.key===F.key);J>=0?v.value=U.filter((ge,me)=>me!==J):v.value=[...U,F],x(),C.value=""}const X=fe(""),B=fe("");function de(F){const U=/^#?([0-9a-fA-F]{6})$/.exec(String(F||"").trim());if(!U)return;const J="#"+U[1].toLowerCase();X.value=X.value===J?"":J,x()}const w=fe(null),j=Q(()=>[{id:"upg100Region",label:xe("tabs.upg100Region"),info:xe("legend.tabInfo.upg100Region")},{id:"upg100Zone",label:xe("tabs.upg100Zone"),info:xe("legend.tabInfo.upg100Zone")}]);let D=[],R=null,re=null,he=[],$e=null,ke=null,Me=null;const je=typeof window<"u"&&window.MAP_APP_API_URL||void 0||"",{locale:Se,t:xe}=Kt();let tt="";pt(()=>Ut(),()=>{(h.value===""||h.value===tt)&&(h.value=tt=xe("legend.loadingData"))},{immediate:!0});function nt(F){const U={zone_affinity_A017:xe("poster.zone_deaf")},J=F?ah(F):void 0;return{deafCount:Af,...F?{records:F}:{},title:ge=>Hl(ge,U,{byCode:J,countryName:Di,locale:Ut()}),regionTitle:ge=>jl[ge]?xe(`poster.${jl[ge]}`):ge}}let E=null;function z(F){return F!==void 0&&(E=F),Gl(Pe(),nt(E))}pt(()=>Ut(),()=>{if(!b.value.length)return;b.value=z();const F=new Map(xr(b.value).map(U=>[U.id,U.label]));for(const U of he)F.has(U.id)&&(U.label=F.get(U.id));M&&K(M)});const O=Q(()=>xe("legend.title.upg100List")),ae=Q(()=>xe("legend.title.batchSelect")),ue=Q(()=>xe("search.upg100Placeholder"));eo(`.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-root{--upg-credit-floor:calc(max(min(var(--legend-sheet-h,0px),48px),var(--map-fab-clearance,0px)) + 30px)}@media(max-width:767.98px){.upg-root{--upg-credit-floor:max(min(var(--legend-sheet-h,0px),48px),var(--map-fab-clearance,0px))}}.upg-status{position:absolute;bottom:calc(var(--upg-credit-floor) + 6px);inset-inline-end:10px;z-index:1;pointer-events:none;font:10px/1 ui-monospace,monospace;color:#9aa7b8;background:rgba(10,14,21,.82);padding:6px 10px;border-radius:8px}@media(max-width:767px){.upg-status{display:none}}.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-shown{position:absolute;bottom:calc(var(--upg-credit-floor) + 12px);left:50%;transform:translateX(-50%);z-index:6;display:inline-flex;align-items:center;gap:10px;max-width:calc(100% - 120px);min-height:40px;box-sizing:border-box;padding:0 6px 0 16px;border:1px solid rgba(110,231,183,.45);border-radius:999px;background:rgba(10,20,16,.92);color:#e5e7eb;font:600 13px/1.2 system-ui,sans-serif;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,.25)}.upg-shown-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.upg-shown-x{display:inline-flex;align-items:center;justify-content:center;flex:0 0 28px;height:28px;border-radius:50%;background:rgba(255,255,255,.16);font-size:18px;line-height:1}.upg-shown:focus-visible{outline:2px solid #6ee7b7;outline-offset:2px}.upg-hud{position:absolute;bottom:calc(var(--upg-credit-floor) + 30px);inset-inline-end: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-inline-start: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:calc(var(--upg-credit-floor) + 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-legend-desktop-slot .stl-panel,.upg-root:has(.mapboxgl-ctrl-logo) .upg-legend-desktop-slot .stl-panel{max-height:calc(100% - var(--stl-top,60px) - 12px - 30px)!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 ie(F){const U=[];for(const J of F)U.push(J.zoneKey,KP(J.zoneKey,J.color));return["match",["get","zoneKey"],...U,"#9ca3af"]}function _e(){if(R.getSource("tapestry")&&R.getLayer("tapestry-fill")&&R.getLayer("tapestry-line"))return;R.getSource("tapestry")||R.addSource("tapestry",{type:"geojson",data:re});const F=$.value?.45:.3,U=$.value?.65:.45;if(R.getLayer("tapestry-fill")||R.addLayer({id:"tapestry-fill",type:"fill",source:"tapestry",paint:{"fill-color":$e,"fill-opacity":["case",["==",["get","zoneKey"],"deaf"],F,U]}}),R.getLayer("tapestry-line")||R.addLayer({id:"tapestry-line",type:"line",source:"tapestry",paint:{"line-color":$e,"line-width":1.2,"line-opacity":.9}}),Fo){const J=Fo;oo(()=>{Fo===J&&Eo(J)})}}function be(){!R||!R.getSource("tapestry")||R.getLayer("upg-sel-fill")||(R.addLayer({id:"upg-sel-fill",type:"fill",source:"tapestry",filter:["boolean",!1],paint:{"fill-color":"#f59e0b","fill-opacity":.28}}),R.addLayer({id:"upg-sel-line",type:"line",source:"tapestry",filter:["boolean",!1],paint:{"line-color":"#fbbf24","line-width":2.4,"line-opacity":.95}}))}function P(){const F=[],U=[],J=[];for(const me of v.value)me.kind==="adm1"?F.push(me.name):me.kind==="adm0"?U.push(me.key.slice(5)):me.kind==="zone"&&J.push(me.key.slice(5));const ge=[];return F.length&&ge.push(["in",["get","shapeName"],["literal",F]]),U.length&&ge.push(["in",["get","iso3"],["literal",U]]),J.length&&ge.push(["in",["get","zoneKey"],["literal",J]]),ge.length?ge.length===1?ge[0]:["any",...ge]:["boolean",!1]}function x(){if(G(),!R||!R.getLayer("upg-sel-fill"))return;const F=Z.value?P():["boolean",!1];R.setFilter("upg-sel-fill",F),R.setFilter("upg-sel-line",F);const U=X.value;R.setPaintProperty("upg-sel-fill","fill-color",U||"#f59e0b"),R.setPaintProperty("upg-sel-fill","fill-opacity",U?.55:.28),R.setPaintProperty("upg-sel-line","line-color",U||"#fbbf24")}let q=null,L=!1;function H(){if(!(!R||!R.getLayer("tapestry-fill"))){if(q)try{R.off("click","tapestry-fill",q)}catch{}q=F=>{const U=F&&F.features&&F.features[0];if(U&&Z.value){const J=wf(U.properties,{nameMap:W});if(!J){console.warn("[batch-select] clicked feature has no shapeName/iso3",U.properties);return}J.count==null&&console.warn("[batch-select] no UUPG count for territory",J.name,U.properties),oe(J)}},R.on("click","tapestry-fill",q),L||(R.on("mouseenter","tapestry-fill",()=>{R&&(R.getCanvas().style.cursor=Z.value?"crosshair":"")}),R.on("mouseleave","tapestry-fill",()=>{R&&(R.getCanvas().style.cursor="")}),L=!0)}}function V(){v.value=[],C.value="",X.value="",B.value="",x()}let M=null;function K(F){if(M=F,p&&typeof p.cacheSourceData=="function"){const U=JP({records:F,leafZones:he,adm1Counts:Qi,iso3Names:on,countryNameMap:W,centroidFor:J=>{const ge=Ie(J);return ge?[(ge[0][0]+ge[1][0])/2,(ge[0][1]+ge[1][1])/2]:null}});p.cacheSourceData(Dc,{normalizedData:U})}D=YP({records:F,leafZones:he,adm1Counts:Qi,iso3Names:on,countryNameMap:W}),typeof window<"u"&&(window.__UPG_SEARCH__={size:()=>D.length,counts:()=>{const U={pg:0,zone:0,territory:0};for(const J of D)U[J.kind]=(U[J.kind]||0)+1;return U},query:U=>xf(D,U,{limit:Sf}).map(J=>({label:J.label,kind:J.kind,target:J.target})),select:U=>{const J=xf(D,U,{limit:Sf})[0];return J?(ut(J.target),{label:J.label,kind:J.kind,target:J.target}):null},feedSize:()=>{const U=p&&p.sources&&p.sources[Dc];return U&&Array.isArray(U.features)&&U.features.length||0},localGeocoder:U=>{const J=w.value&&w.value.geocoder,ge=J&&J.options&&J.options.localGeocoder;return ge?ge(U).map(me=>me&&me.place_name):null}},n=window.__UPG_SEARCH__,(window.__UPG_SEARCHES__||(window.__UPG_SEARCHES__={}))[s()]=window.__UPG_SEARCH__)}function ye(F){const U=F&&F.properties||{},J=U.__upgKind;if(J==="zone")Ee(U.__zoneId);else if(J==="territory")Re(U.__shapeName);else{const ge=F&&F.geometry,me=ge&&Array.isArray(ge.coordinates)?ge.coordinates:null;me&&Number.isFinite(me[0])&&Number.isFinite(me[1])&&R&&R.flyTo({center:[me[0],me[1]],zoom:6,duration:800}),$t(U.slug)}}function Ce(F){if(!F||!R)return;const U=new Set(F.memberIds||[]);if(!U.size)return;let J=[];try{J=R.querySourceFeatures("upg").filter(rt=>{const Le=rt.properties||{};return U.has(Le.slug)||U.has(Le.id)||U.has(Le.peopleGroupId)})}catch{return}if(!J.length)return;let ge=180,me=90,Ke=-180,lt=-90,We=!1;for(const rt of J){const Le=rt.geometry&&rt.geometry.coordinates;!Array.isArray(Le)||!Number.isFinite(Le[0])||!Number.isFinite(Le[1])||(Le[0]Ke&&(Ke=Le[0]),Le[1]lt&&(lt=Le[1]),We=!0)}We&&R.fitBounds([[ge,me],[Ke,lt]],{padding:60,duration:800,maxZoom:6})}function Qe(){Jt(null),_&&typeof _.selectPeopleGroup=="function"&&_.selectPeopleGroup(null)}function ut(F){!F||!R||(F.type==="pg"?(Number.isFinite(F.lng)&&Number.isFinite(F.lat)&&R.flyTo({center:[F.lng,F.lat],zoom:6,duration:800}),$t(F.slug)):F.type==="zone"?Ee(F.zoneId):F.type==="territory"&&Re(F.shapeName))}function $t(F){if(!F||!_||typeof _.selectPeopleGroup!="function")return;const J=XP(R,"upg").find(ge=>ge.properties&&ge.properties.slug===F);J&&_.selectPeopleGroup(J)}function Ee(F){if(!F||!R||!re)return;const U=Ie(J=>J.properties&&J.properties.zoneKey===F);U&&R.fitBounds(U,{padding:40,duration:800,maxZoom:6})}function Re(F){if(!F||!R||!re)return;const U=Ie(J=>{const ge=J.properties||{};return ge.shapeName===F||ge.iso3===F});U&&R.fitBounds(U,{padding:40,duration:800,maxZoom:6})}function Ie(F){let U=180,J=90,ge=-180,me=-90,Ke=!1;const lt=We=>{if(typeof We[0]=="number"){const[rt,Le]=We;rtge&&(ge=rt),Leme&&(me=Le),Ke=!0;return}for(const rt of We)lt(rt)};for(const We of re.features)F(We)&<(We.geometry.coordinates);return Ke?[[U,J],[ge,me]]:null}function Ye(F){const U=new Set,J=ge=>{ge.children&&ge.children.length?ge.children.forEach(J):U.add(ge.zoneKey??ge.id)};return J(F),U}let ht=null;function ko(F){if(![...Ye(F)].length)return;const J=[],ge=We=>{We.children&&We.children.length?We.children.forEach(ge):J.push(We)};ge(F);const me=v.value,Ke=new Set(me.filter(We=>We.kind==="zone").map(We=>We.key));if(J.every(We=>Ke.has("zone:"+(We.zoneKey??We.id)))){const We=new Set(J.map(rt=>"zone:"+(rt.zoneKey??rt.id)));v.value=me.filter(rt=>!We.has(rt.key))}else{const We=J.filter(rt=>!Ke.has("zone:"+(rt.zoneKey??rt.id))).map(rt=>({key:"zone:"+(rt.zoneKey??rt.id),name:rt.label||rt.id,count:Number(rt.count)||0,kind:"zone"}));v.value=[...me,...We]}x(),C.value=""}function rn(){const F=new Set;for(const U of v.value)U.kind==="zone"&&F.add(U.key.slice(5));return F}function Rr(){const F=new Map,U=J=>{const ge=Ye(J);J.label&&F.set(J.label,ge),J.children&&J.children.length&&J.children.forEach(U)};for(const J of b.value)U(J);return F}function G(){if(typeof document>"u")return;const F=document.querySelector("my-upg-100-list-map"),J=(F&&F.shadowRoot||document).querySelectorAll(".stl-row");if(!J.length)return;if(!Z.value){J.forEach(lt=>lt.classList.remove("upg-batch-row"));return}const ge=rn(),me=Rr(),Ke=$.value;J.forEach(lt=>{const We=lt.querySelector(".stl-name"),rt=We?We.textContent.trim():"",Le=rt&&me.get(rt),it=!!(Le&&Le.size&&[...Le].every(It=>ge.has(It)));lt.classList.toggle("upg-batch-row",it),lt.classList.toggle("dark",it&&Ke)})}let ee=null;function Fe(){if(typeof document>"u"||ee)return;const F=document.querySelector("my-upg-100-list-map"),J=(F&&F.shadowRoot||document).querySelector(".stl-rows");J&&(ee=new MutationObserver(()=>{requestAnimationFrame(()=>G())}),ee.observe(J,{childList:!0,subtree:!0}))}so("onSemanticTreeSelect",Jt),so("onLegendExport",Ge),so("legendExportCards",!0);async function Ge(F){const U=m.value;if(!U)return;const[J,ge]=String(F).split(":");if(!Ne.value){Ne.value=!0,De.value=J==="packet"?"packet":J==="cards"?"cards":"poster";try{if(J==="packet"){await le(U,ge||"full");return}const me=Ze().find(Ke=>Ke.id===U)||{id:U};if(J==="cards"){const Ke=Ze().find(lt=>lt.id===U);Ke&&await Be.printCardDeck(await pe(Ke));return}await Be.printPoster(me)}finally{Ne.value=!1,De.value=""}}}const Be=Dg({t:(F,U,J)=>typeof J=="number"?xe(F,U,J):xe(F,U),records:F=>Bt(F),lang:()=>Ut(),label:F=>(F==null?void 0:F.label)||(F==null?void 0:F.id)||"",assetsBase:()=>ga(a.value),iso3Names:()=>on,sheet:(F,U)=>Ht(F,U),sets:()=>fetch(`${ga(a.value)}/tables/near-neighbors.json`).then(F=>F.ok?F.json():null).catch(()=>null),downloadPrefix:"doxa-upg-100"});let mt="";pt(Be.exportState,F=>{if(!F){mt&&h.value===mt&&(h.value=""),mt="";return}if(F.phase==="error"){mt="",ne(xe("messages.packetFailed",{reason:F.message}),4e3);return}mt=F.phase==="done"?"":`${F.message}…`,h.value=mt});const Ue=qg({apiBase:()=>je,lang:()=>Ut(),profileConfig:a,evaluate:(F,U)=>Ra(F,U)});async function Bt(F){if(!je)throw co("wall.hud.noApi","no people-groups service is configured");return Ue(F.selector)}const Ht=eh({allRecords:()=>Ue.all(),assetsBase:()=>ga(a.value),profileConfig:a});function wo(F,U,J){F.value=U,setTimeout(()=>{F.value===U&&(F.value="")},J)}const ne=(F,U)=>wo(h,F,U);async function le(F,U="full"){const J=Ze().find(me=>me.id===F);if(!J)return;const ge=await pe(J);await Be.printPacket(ge,{variant:U,funnel:await we()})}async function pe(F){try{const[{zoneTitle:U},{countryName:J},ge]=await Promise.all([Pt(()=>Promise.resolve().then(()=>sv),void 0),Pt(()=>Promise.resolve().then(()=>Kl),void 0),Oi(ga(a.value))]),me={...ge.en||{},...ge[Ut()]||{}},Ke=U(F,me,{countryName:J,locale:Ut()});return Ke?{...F,label:Ke}:F}catch{return F}}function Pe(){return Dl(Sn(a))}function ve(){const F=Pe();return[...F.lists||[],...F.asia_lists||[],...F.uncovered_lists||[]]}function Ze(){const F=ve(),U=new Set(F.map(J=>J.id));return[...F,...Q1(Pe(),{deafCount:Af}).filter(J=>!U.has(J.id))]}async function we(){var F;try{const U=(await Pt(async()=>{const{default:Ke}=await Promise.resolve().then(()=>Kf);return{default:Ke}},void 0)).default;if(!U||!Array.isArray(U.steps)||!U.steps.length)return null;const J=Sn(a),ge=Number(U.steps[U.steps.length-1].groups)||0;if(J===yr)return{...U,listCount:Ze().length,listTotal:ge};let me=0;try{const Ke=ga(a.value),lt=await fetch(`${Ke}/people-groups/lists/${J}.json`);if(lt.ok){const We=await lt.json();me=Number((F=We==null?void 0:We.counts)==null?void 0:F.doxa)||(Array.isArray(We==null?void 0:We.slugs)?We.slugs.length:0)}}catch{}return{...U,listTotal:me,listId:J,listLabel:(Cg(J)||{}).label||J}}catch{return null}}const Ne=fe(!1),De=fe("");function Oe(){const F=v.value.filter(J=>J.kind==="zone").map(J=>String(J.key).replace(/^zone:/,"")),U=new Map(Ze().map(J=>[J.id,J]));return F.map(J=>U.get(J)).filter(Boolean)}async function ze(){const F=await Oi(ga(a.value));return{...F.en||{},...F[Ut()]||{}}}function gt(F,U){return F?String(F).replace(/\{(\w+)\}/g,(J,ge)=>U[ge]!=null?String(U[ge]):J):null}function wt(){return v.value.filter(F=>F.kind==="adm0").map(F=>String(F.key).replace(/^adm0:/,"")).filter(Boolean)}function xt(){return v.value.filter(F=>F.kind==="adm1").map(F=>F.name||String(F.key).replace(/^adm1:/,""))}async function Ft(){const F=Oe(),U=wt(),J=xt();if(!F.length&&!U.length)throw J.length?co("upgMap.selectionAdm1NoData","no people-group data for {names} — select the country instead",{names:Ll(J,{locale:Ut()})}):co("upgMap.nothingSelected","nothing is selected");if(!je)throw co("wall.hud.noApi","no people-groups service is configured");const me=await fetch(`${je}/api/people-groups/list?fields=${Vg}&lang=${Ut()}`,{cache:"no-store"});if(!me.ok)throw co("wall.hud.fetchFailed","could not load the people groups ({status})",{status:me.status});const Ke=Ic(await Ni(Oc(await me.json()),a)),{evaluate:lt}=await Pt(async()=>{const{evaluate:dt}=await Promise.resolve().then(()=>Zg);return{evaluate:dt}},void 0),We=new Set;for(const dt of F)if(dt.selector&&dt.selector.type==="pg_slugs")for(const Mo of dt.selector.values||[])We.add(Mo);else for(const Mo of lt(dt.selector,Ke))We.add(Mo);if(U.length)for(const dt of lt({type:"country_codes",values:U},Ke))We.add(dt);const rt=(await Promise.all(F.map(pe))).map(dt=>dt.label||dt.id),Le=v.value.filter(dt=>dt.kind==="adm0").map(dt=>dt.name),it=[...rt,...Le],It=await ze(),_o=(dt,Mo)=>gt(It.zone_join,{a:dt,b:Mo})??`${dt} + ${Mo}`;return{id:"selection",label:it.length<=3?it.reduce(_o):gt(It.zone_join_more,{a:it.slice(0,2).reduce(_o),n:it.length-2})??`${it.slice(0,2).join(" + ")} +${it.length-2} more`,count:We.size,selector:{type:"pg_slugs",values:[...We]}}}async function To(){if(!Ne.value){Ne.value=!0,De.value="packet";try{const F=await Ft(),U=Oe(),J=U.length===1?U[0].id:null,ge=await we();await Be.printPacket({...F,mapId:J},{funnel:ge&&U.length===1?ge:ge?{...ge,listCount:0}:null})}catch(F){ne(xe("messages.selectionPacketFailed",{reason:vr(F,xe).slice(0,90)}),4e3)}finally{Ne.value=!1,De.value=""}}}async function No(){if(!Ne.value){Ne.value=!0,De.value="cards";try{await Be.printCardDeck(await Ft())}catch(F){ne(xe("upgMap.selectionCardsFailed",{reason:vr(F,xe).slice(0,90)}),4e3)}finally{Ne.value=!1,De.value=""}}}async function xo(){if(!Ne.value){Ne.value=!0,De.value="poster";try{const F=Oe();if(!F.length)throw wt().length||xt().length?co("upgMap.selectionPosterNeedsZone","posters exist per territory on the legend — use Prayer list for a map selection"):co("upgMap.nothingSelected","nothing is selected");if(F.length>1){ne(xe("messages.posterOneTerritory",{count:F.length}),5e3);return}await Be.printPoster(F[0])}catch(F){ne(xe("messages.selectionPosterFailed",{reason:vr(F,xe).slice(0,90)}),4e3)}finally{Ne.value=!1,De.value=""}}}function Ut(){const F=Se&&(Se.value??Se);return typeof F=="string"&&F||"en"}function Jt(F){if(!R||!R.getLayer("tapestry-fill"))return!1;if(Z.value)return F&&ko(F),!0;if(!F)return ht=null,m.value=null,R.setFilter("tapestry-fill",null),R.setFilter("tapestry-line",null),R.setPaintProperty("upg-pins","circle-opacity",1),!0;ht=F;const U=[...Ye(F)];m.value=U.length===1?U[0]:F.id??null;const J=["in",["get","zoneKey"],["literal",U]];R.setFilter("tapestry-fill",J),R.setFilter("tapestry-line",J),R.getLayer("upg-pins")&&R.setPaintProperty("upg-pins","circle-opacity",["case",["in",["get","zoneKey"],["literal",U]],.95,.05]);const ge=Ie(me=>U.includes(me.properties.zoneKey));return ge&&R.fitBounds(ge,{padding:40,duration:700,maxZoom:6}),!0}function bo(){R&&(typeof Me=="function"&&Me(),re&&(_e(),be(),H(),x(),m.value&&R.getLayer("tapestry-fill")&&Jt(ht)))}function jt(){R&&($.value=!$.value,g.theme.value=$.value?"dark":"light",R.setStyle($.value?Nc("ink",l).style||"mapbox://styles/mapbox/dark-v11":Nc("paper",l).style||"mapbox://styles/mapbox/light-v11"),R.once("style.load",bo))}function Dt(){!R||!R.getLayer("upg-pins-hit")||(R.on("click","upg-pins-hit",F=>{const U=F&&F.features&&F.features[0];U&&_&&typeof _.selectPeopleGroup=="function"&&_.selectPeopleGroup(U)}),R.on("mouseenter","upg-pins-hit",()=>{R&&(R.getCanvas().style.cursor="pointer")}),R.on("mouseleave","upg-pins-hit",()=>{R&&(R.getCanvas().style.cursor="")}))}let $o=null,Fo,$a=null;function Fn(F,U){var J,ge,me;try{const Ke=(me=(ge=(J=f.value)==null?void 0:J.getRootNode)==null?void 0:ge.call(J))==null?void 0:me.host;if(!Ke)return;Ke.setAttribute("data-doxa-select-zone-state",F),U&&Ke.setAttribute("data-doxa-select-zone-applied",String(U))}catch{}}function Eo(F){if(!F)return Jt(null),Fo=void 0,Fn("cleared",""),!0;const U=za(b.value,F);return U?Jt(U)?(Fo=void 0,Fn("applied",F),!0):(Fo=F,Fn("applied-but-no-selection",F),!1):(Fo=F,Fn("unresolved",F),!1)}function ss(F){var J;const U=((J=F==null?void 0:F.detail)==null?void 0:J.listId)??null;Eo(U)}function za(F,U){for(const J of F||[]){if((J.zoneKey||J.id)===U)return J;const ge=J.children&&za(J.children,U);if(ge)return ge}return null}const sn=Q(()=>{if(!m.value||Z.value)return null;const F=za(b.value,m.value);return F&&F.label||String(m.value)});function In(){Eo(null)}function Vc(){const F=Pe(),U=z(null);b.value=U,he=xr(U);const J={};for(const ge of F.lists||[])J[ge.id]=ge.selector;for(const ge of F.asia_lists||[])J[ge.id]=ge.selector;for(const ge of F.uncovered_lists||[])J[ge.id]=ge.selector;J.deaf=wr;for(const ge of he)ge.selector=J[ge.id];$e=ie(he)}async function ls(){if(je)try{const U=await fetch(`${je}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${Ut()}`,{cache:"no-store"});if(!U.ok)throw new Error(`list ${U.status}`);const J=Ic(await Ni(Oc(await U.json()),a));W=kf(J),b.value=z(J)}catch{}}lo(async()=>{var me,Ke,lt,We,rt;Vc();try{await jP(l)}catch{}const F=Fc(l);F&&zP(F);const U=(o==null?void 0:o.value)||((me=a==null?void 0:a.value)==null?void 0:me.tk)||"";if(!F){console.warn(`[upg-100-list] ${l} 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.`),h.value=`⚠ ${xe("messages.engineNotLoaded")}`,y.value=xe("messages.engineNotLoadedDetail",{engine:c?"MapLibre":"Mapbox"}),ls();return}if(!c){if(!U){h.value=`⚠ ${xe("messages.noMapboxToken")}`,y.value=xe("messages.noMapboxTokenDetail"),ls();return}F.accessToken=U}try{const Le=_f(l);Le&&await GP(f.value,Le)}catch{}try{const Le=!c&&f.value&&f.value.getRootNode();if(Le instanceof ShadowRoot){const it=_f("mapbox");if(it&&!Le.querySelector(`link[href="${it}"]`)){const It=document.createElement("link");It.rel="stylesheet",It.href=it,Le.prepend(It)}}}catch{}R=new F.Map({container:f.value,style:Nc("paper",l).style||"mapbox://styles/mapbox/light-v11",center:[35,20],zoom:1.5,projection:"mercator"}),k.value=R,ke=IP(((Ke=f.value)==null?void 0:Ke.parentElement)||null,{enabled:d.value}),typeof window<"u"&&(window.__UPG_MAP__=R,r=R,(window.__UPG_MAPS__||(window.__UPG_MAPS__={}))[s()]=R),window.__UPG_SELECT__={get list(){return v.value.map(Le=>({...Le}))},get total(){return S.value},get count(){return A.value},get color(){return X.value},get batchMode(){return Z.value},setColor:Le=>de(Le),setBatchMode:Le=>I(Le),clipboardText:()=>VP(v.value,{color:X.value}),clear:()=>V(),toggleByProps:Le=>{const it=wf(Le,{nameMap:W});return it?(oe(it),{...it}):null},toggleLegendRow:Le=>{const it=_o=>{for(const kt of _o){if(kt.label===Le||kt.id===Le)return kt;if(kt.children&&kt.children.length){const dt=it(kt.children);if(dt)return dt}}return null},It=it(b.value);return It?(ko(It),{label:It.label,zoneKeys:[...Ye(It)]}):null},markedLegendRows:()=>{if(typeof document>"u")return[];const Le=document.querySelector("my-upg-100-list-map");return[...(Le&&Le.shadowRoot||document).querySelectorAll(".stl-row.upg-batch-row .stl-name")].map(It=>It.textContent.trim())},highlightFeatureCount:()=>{if(!R||!re||!R.getLayer("upg-sel-fill"))return-1;const Le=new Set,it=new Set,It=new Set;for(const kt of v.value)kt.kind==="zone"?Le.add(kt.key.slice(5)):kt.kind==="adm1"?it.add(kt.name):kt.kind==="adm0"&&It.add(kt.key.slice(5));let _o=0;for(const kt of re.features){const dt=kt.properties||{};(Le.has(dt.zoneKey)||it.has(dt.shapeName)||It.has(dt.iso3))&&_o++}return _o},zoneKeysForRow:Le=>{const it=_o=>{for(const kt of _o){if(kt.label===Le||kt.id===Le)return kt;if(kt.children&&kt.children.length){const dt=it(kt.children);if(dt)return dt}}return null},It=it(b.value);return It?[...Ye(It)]:null}},i=window.__UPG_SELECT__,(window.__UPG_SELECTS__||(window.__UPG_SELECTS__={}))[s()]=window.__UPG_SELECT__;try{h.value=xe("messages.loadingBoundaries");const Le=st=>`${ga(a.value)}/boundaries/${st}`,it=st=>fetch(Le(st)).then(to=>{if(!to.ok)throw new Error(`boundary fetch ${to.status} ${st}`);return to.json()});if(!je)throw new Error("No API base configured — set window.MAP_APP_API_URL or VITE_API_BASE_URL. Failing closed (no default host).");const _o=fetch(`${je}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${Ut()}`).then(st=>{if(!st.ok)throw new Error(`list ${st.status}`);return st.json()}),kt={adm0:it("world-adm0-web.geojson"),adm1Chn:it("gb-CHN-ADM1.geojson"),adm1Ind:it("gb-IND-ADM1-web.geojson")};h.value=xe("messages.fetchingUupgs",{n:2106});const dt=Ic(await Ni(Oc(await _o),a));W=kf(dt),b.value=z(dt);const Mo=[],_a={},{evaluate:cs}=await Pt(async()=>{const{evaluate:st}=await Promise.resolve().then(()=>Zg);return{evaluate:st}},void 0);for(const st of he)if(st.selector&&st.selector.type==="pg_slugs")for(const to of st.selector.values||[])to in _a||(_a[to]=st.zoneKey);else try{for(const to of cs(st.selector,dt))to in _a||(_a[to]=st.zoneKey)}catch(to){console.warn("zone selector skipped",st.id,to&&to.message)}for(const st of dt){const to=Number(st.latitude),Jc=Number(st.longitude);!isFinite(to)||!isFinite(Jc)||Mo.push({type:"Feature",geometry:{type:"Point",coordinates:[Jc,to]},properties:{slug:st.slug,zoneKey:_a[st.slug]||"",name:st.name||st.slug||"",population:st.population??0,countryName:st.country_code_label||"",country:st.country_code||""}})}const Dn=Ba({type:"FeatureCollection",features:Mo});Me=()=>{R.getSource("upg")&&R.getLayer("upg-pins")&&R.getLayer("upg-pins-hit")||(R.getSource("upg")||R.addSource("upg",{type:"geojson",data:Dn}),R.getLayer("upg-pins")||R.addLayer({id:"upg-pins",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],0,2.6,2,3.2,4,4.5,6,6.5,8,9],"circle-color":$e,"circle-opacity":1,"circle-stroke-width":["interpolate",["linear"],["zoom"],0,.9,4,1.4,8,2],"circle-stroke-color":"rgba(15,20,25,0.9)"}}),R.getLayer("upg-pins-hit")||R.addLayer({id:"upg-pins-hit",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],1,5,4,6.5,8,9],"circle-stroke-width":["interpolate",["linear"],["zoom"],1,1.8,8,2],"circle-opacity":0,"circle-stroke-opacity":0}}),Dt())};const us=()=>{try{bo()}catch(st){console.warn("early pin paint skipped",st&&st.message)}};R.isStyleLoaded()?us():R.once("style.load",us),h.value=xe("messages.loadingBoundaries");const[zn,qc]=await Promise.all([kt.adm0,kt.adm1Chn]),Yc=await kt.adm1Ind,{tapestry:ds,perZone:Zc}=rv(he,{records:dt,adm0:zn,adm1Ind:Yc,adm1Chn:qc});re=Ba(ds),K(dt);let Nr=!0;const jn=()=>{Nr&&(Nr=!1,R.off("style.load",jn),R.off("idle",jn),bo())};if(R.isStyleLoaded())jn();else{R.once("style.load",jn),R.once("idle",jn);const st=setInterval(()=>{if(!Nr||!R){clearInterval(st);return}let to=!1;try{to=R.isStyleLoaded()}catch{clearInterval(st);return}to&&(clearInterval(st),jn())},120);setTimeout(()=>clearInterval(st),15e3)}const Qf=[...Zc.entries()].filter(([st])=>st!=="deaf"),z2=Qf.filter(([,st])=>st>=1).length;h.value=xe("messages.mapStatusCounts",{polys:re.features.length,zones:z2,total:Qf.length,pins:Mo.length})}catch(Le){console.warn("[upg-100-list] map data failed:",Le),h.value="⚠ "+xe("upgMap.mapDataFailed")}let J=0;const ge=()=>{const Le=typeof document<"u"&&document.querySelector("my-upg-100-list-map"),it=Le&&Le.shadowRoot||(typeof document<"u"?document:null);if(it&&it.querySelector(".stl-rows")){Fe(),G();return}J++<40&&setTimeout(ge,250)};ge();{const Le=(rt=(We=(lt=f.value)==null?void 0:lt.getRootNode)==null?void 0:We.call(lt))==null?void 0:rt.host;if(Le){$o=ss,Le.addEventListener("doxa:select-zone",$o);const it=Le.getAttribute("select-zone");it&&Eo(it),$a=new MutationObserver(()=>{Eo(Le.getAttribute("select-zone")||null)}),$a.observe(Le,{attributes:!0,attributeFilter:["select-zone"]})}}});const On=()=>{var F,U,J;try{return((J=(U=(F=f.value)==null?void 0:F.getRootNode)==null?void 0:U.call(F))==null?void 0:J.host)||null}catch{return null}};return pt([b,k],()=>{oo(()=>{var U;const F=((U=On())==null?void 0:U.getAttribute("select-zone"))||Fo||null;F&&Eo(F)})}),qt(()=>{var F,U,J;if($a==null||$a.disconnect(),$a=null,$o){const ge=(J=(U=(F=f.value)==null?void 0:F.getRootNode)==null?void 0:U.call(F))==null?void 0:J.host;ge==null||ge.removeEventListener("doxa:select-zone",$o),$o=null}if(ee){try{ee.disconnect()}catch{}ee=null}if(ke){try{ke()}catch{}ke=null}if(R&&(R.remove(),R=null),re=null,typeof window<"u"){const ge=s();try{window.__UPG_SEARCHES__&&delete window.__UPG_SEARCHES__[ge],window.__UPG_MAPS__&&delete window.__UPG_MAPS__[ge],window.__UPG_SELECTS__&&delete window.__UPG_SELECTS__[ge],window.__UPG_SEARCH__===n&&delete window.__UPG_SEARCH__,window.__UPG_MAP__===r&&delete window.__UPG_MAP__,window.__UPG_SELECT__===i&&delete window.__UPG_SELECT__}catch{}}}),(F,U)=>{var J;return Y(),te("div",QP,[N("div",{ref_key:"mapEl",ref:f,class:"upg-map"},null,512),y.value?(Y(),te("div",eS,[N("strong",null,ce(se(xe)("messages.mapUnavailable")),1),Wt(ce(y.value),1)])):Ae("",!0),d.value?(Y(),te(Xe,{key:1},[U[0]||(U[0]=N("div",{class:"map-scroll-edge map-scroll-edge--left"},null,-1)),U[1]||(U[1]=N("div",{class:"map-scroll-edge map-scroll-edge--right"},null,-1))],64)):Ae("",!0),k.value&&u.value?(Y(),St(TP,{key:2,ref_key:"geocoderRef",ref:w,"map-instance":k.value,"access-token":se(o)||((J=se(a))==null?void 0:J.tk)||"","data-source-id":Dc,"is-dark":$.value,placeholder:ue.value,"active-context":bS,onPeopleGroupResult:ye,onAggregateResult:Ce,onClear:Qe},null,8,["map-instance","access-token","is-dark","placeholder"])):Ae("",!0),k.value?(Y(),St(aP,{key:3,"has-geocoder":u.value},{default:yo(()=>[yt(rP,{map:k.value,"is-dark":$.value},null,8,["map","is-dark"]),yt(iP,{map:k.value,"is-dark":$.value},null,8,["map","is-dark"]),yt(sP,{map:k.value,"is-dark":$.value},null,8,["map","is-dark"]),yt(uP,{"map-container":f.value,"is-dark":$.value},null,8,["map-container","is-dark"]),yt(pP,{"is-dark":$.value,onToggle:jt},null,8,["is-dark"]),yt(Da,{"is-dark":$.value,active:Z.value,class:Ve({"upg-batch-on":Z.value}),"aria-pressed":Z.value?"true":"false",title:ae.value,onClick:T},{default:yo(()=>[...U[2]||(U[2]=[N("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[N("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),N("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),N("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),N("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})],-1)])]),_:1},8,["is-dark","active","class","aria-pressed","title"])]),_:1},8,["has-geocoder"])):Ae("",!0),N("div",tS,[b.value.length?(Y(),St(ph,{key:0,nodes:b.value,tabs:j.value,"default-tab":Pf,columns:["count","pop"],title:O.value,"export-enabled":!0,"export-cards":!0,onSelect:Jt,onExport:Ge},null,8,["nodes","tabs","title"])):Ae("",!0)]),N("div",oS,[b.value.length?(Y(),St(oP,{key:0,"legend-type":"upg-100",nodes:b.value,tabs:j.value,"default-tab":Pf,columns:["count","pop"],"column-label":"UPG 100",title:O.value,"is-dark":$.value,"popup-action":"pray"},null,8,["nodes","tabs","title","is-dark"])):Ae("",!0)]),N("div",aS,[se(_)&&se(_).selectedPeopleGroup?(Y(),te("div",{key:0,class:Ve(["upg-detail-panel pg-detail-root",{dark:$.value}])},[yt(se(t),{peopleGroup:se(_).selectedPeopleGroup,dark:$.value,action:"pray"},null,8,["peopleGroup","dark"])],2)):Ae("",!0)]),sn.value?(Y(),te("button",{key:4,type:"button",class:"upg-shown","aria-label":se(xe)("buttons.clearSelection")+": "+sn.value,title:se(xe)("buttons.clearSelection"),onClick:In},[N("span",rS,ce(sn.value),1),U[3]||(U[3]=N("span",{class:"upg-shown-x","aria-hidden":"true"},"×",-1))],8,nS)):Ae("",!0),Z.value?(Y(),te("div",iS,[N("div",sS,ce(se(xe)("messages.tapTerritoriesHint")),1),A.value?(Y(),te("div",lS,[N("span",null,ce(se(xe)("messages.territoriesSelected",{count:A.value}))+" ·",1),N("span",cS,ce(S.value)+" UUPG",1),N("span",{class:Ve(["upg-hud-band",{ok:S.value>=50&&S.value<=100}])},ce(S.value>=50&&S.value<=100?se(xe)("messages.bandInRange"):se(xe)("messages.bandOutOfRange")),3)])):Ae("",!0),A.value?(Y(),te("div",uS,ce(se(Ll)(v.value.map(ge=>ge.name),{locale:Ut()})),1)):Ae("",!0),A.value?(Y(),te("div",dS,[N("button",{class:Ve(["upg-hud-btn make",{"is-busy":De.value==="packet"}]),disabled:Ne.value,onClick:To},ce(De.value==="packet"?se(xe)("buttons.working"):se(xe)("buttons.prayerList")),11,pS),N("button",{class:Ve(["upg-hud-btn make",{"is-busy":De.value==="poster"}]),disabled:Ne.value,onClick:xo},ce(De.value==="poster"?se(xe)("buttons.working"):se(xe)("buttons.posterMap")),11,gS),N("button",{class:Ve(["upg-hud-btn make",{"is-busy":De.value==="cards"}]),disabled:Ne.value,onClick:No},ce(De.value==="cards"?se(xe)("buttons.working"):se(xe)("buttons.cardDeck")),11,hS),N("button",{class:"upg-hud-btn clear",onClick:V},ce(se(xe)("buttons.clearSelection")),1)])):Ae("",!0),A.value?(Y(),te("div",fS,ce(C.value),1)):Ae("",!0)])):Ae("",!0),N("div",mS,ce(h.value),1)])}}}},Symbol.toStringTag,{value:"Module"})),_S=` +`+s}function Nn(e){return String(e??"").normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().trim()}function qP(e){return Nn(e).split(/[\s,;]+/).filter(Boolean)}function YP(e={}){const{records:t=[],leafZones:o=[],adm1Counts:a={},iso3Names:n={},countryNameMap:r=null}=e,i=[],s=new Set;for(const c of t){if(!c)continue;const u=c.slug;if(!u||s.has(u))continue;const d=Number(c.latitude),p=Number(c.longitude);if(!Number.isFinite(d)||!Number.isFinite(p))continue;const _=c.name||u;s.add(u),i.push({label:_,kind:"pg",target:{type:"pg",slug:u,lng:p,lat:d},_hay:Nn(_)})}for(const c of o){if(!c)continue;const u=c.zoneKey||c.id,d=c.label||u;u&&i.push({label:d,kind:"zone",target:{type:"zone",zoneId:u},_hay:Nn(d)})}for(const c of Object.keys(a))i.push({label:c,kind:"territory",target:{type:"territory",shapeName:c},_hay:Nn(c)});const l=r||n;for(const c of Object.keys(n)){const u=l&&l[c]||n[c]||c;i.push({label:u,kind:"territory",target:{type:"territory",shapeName:c,iso3:!0},_hay:Nn(u)})}return i}const ZP={zone:0,territory:1,pg:2};function JP(e={}){const{records:t=[],leafZones:o=[],adm1Counts:a={},iso3Names:n={},countryNameMap:r=null,centroidFor:i=null}=e,s=[];for(const u of t)u&&s.push(u);const l=(u,d,p)=>!d||!Number.isFinite(d[0])||!Number.isFinite(d[1])?null:{name:u,slug:p.__synthSlug,latitude:d[1],longitude:d[0],...p};for(const u of o){if(!u)continue;const d=u.zoneKey||u.id,p=u.label||d;if(!d)continue;const _=typeof i=="function"?i(h=>h&&h.properties&&h.properties.zoneKey===d):null,f=l(p,_,{__upgKind:"zone",__zoneId:d,__synthSlug:`__zone__${d}`});f&&s.push(f)}for(const u of Object.keys(a)){const d=typeof i=="function"?i(_=>_&&_.properties&&_.properties.shapeName===u):null,p=l(u,d,{__upgKind:"territory",__shapeName:u,__synthSlug:`__terr__${u}`});p&&s.push(p)}const c=r||n;for(const u of Object.keys(n)){const d=c&&c[u]||n[u]||u,p=typeof i=="function"?i(f=>f&&f.properties&&f.properties.iso3===u):null,_=l(d,p,{__upgKind:"territory",__shapeName:u,__synthSlug:`__terr__${u}`});_&&s.push(_)}return s}function xf(e,t,o={}){const a=o.limit??8,n=qP(t);if(!n.length)return[];const r=n[0],i=[];for(const s of e){let l=!0;for(const d of n)if(!s._hay.includes(d)){l=!1;break}if(!l)continue;const c=s._hay.startsWith(r)?0:1,u=s._hay===Nn(t)?-1:0;i.push({e:s,starts:c,exact:u,kr:ZP[s.kind]??9,len:s._hay.length})}return i.sort((s,l)=>s.exact-l.exact||s.starts-l.starts||s.kr-l.kr||s.len-l.len),i.slice(0,a).map(s=>s.e)}const es=new Set;function XP(e,t){var n,r;const o=e.getSource(t);if(!o)return[];let a=o._data??((r=(n=o.serialize)==null?void 0:n.call(o))==null?void 0:r.data);if(a&&typeof a=="object"&&!Array.isArray(a)){if(a.geojson!==void 0)a=a.geojson;else if(a.url!==void 0)return es.has(t)||(es.add(t),console.warn(`[pin-selection] source "${t}" is remote (url); its features cannot be read locally, so nothing can be selected from it.`)),[]}return a?Array.isArray(a==null?void 0:a.features)?a.features:(a==null?void 0:a.type)==="Feature"?[a]:(a&&typeof a=="object"&&!es.has(t)&&(es.add(t),console.warn(`[pin-selection] source "${t}": unrecognised data shape {${Object.keys(a).join(",")}} — nothing can be selected from it; this is NOT a confirmed empty source.`)),[]):[]}const QP={class:"upg-root"},eS={key:0,class:"upg-map-err"},tS={class:"upg-legend-desktop-slot"},oS={class:"upg-legend-mobile-slot"},aS={class:"upg-detail-desktop-slot"},nS=["aria-label","title"],rS={class:"upg-shown-name"},iS={key:5,class:"upg-hud"},sS={class:"upg-hud-hint"},lS={key:0,class:"upg-hud-head"},cS={class:"upg-hud-total"},uS={key:1,class:"upg-hud-names"},dS={key:2,class:"upg-hud-actions"},pS=["disabled"],gS=["disabled"],hS=["disabled"],fS={key:3,class:"upg-hud-flash"},mS={class:"upg-status"},Dc="upg-search",Pf=1,bS="people-groups",Sf=8,Af=123,$S=Object.freeze(Object.defineProperty({__proto__:null,default:{__name:"upg-100-list",setup(e){const t=Sg(()=>Pt(()=>Promise.resolve().then(()=>jx),void 0)),o=at("mapboxToken",fe("")),a=at("profileConfig",fe(null));let n=null,r=null,i=null;function s(){var F,U;return((F=a.value)==null?void 0:F.instanceId)||((U=a.value)==null?void 0:U.profile)||"upg-100-list"}const l=RP(a),c=l==="maplibre",u=Q(()=>{var F;return((F=a==null?void 0:a.value)==null?void 0:F.search)===!1?!1:l==="mapbox"}),d=Q(()=>{var U;const F=(U=a.value)==null?void 0:U.edgeScrollAffordance;return F==null?!0:!(F===!1||F==="false")}),p=at("dataStore",null),_=at("uiStore",null),f=fe(null),h=fe(""),y=fe(""),b=Ha([]),m=fe(null),k=Ha(null),$=fe(!1),g=fv("my-upg-100-list");g.theme.value="light",mv(g);const v=fe([]),S=Q(()=>v.value.reduce((F,U)=>F+(Number(U.count)||0),0)),A=Q(()=>v.value.length),C=fe("");let W=null;const Z=fe(!1);function I(F){const U=F===void 0?!Z.value:!!F;return U===Z.value||(Z.value=U,R&&(R.getCanvas().style.cursor=""),x()),U}function T(){I()}pt([Z,$],()=>{oo(()=>G())});function oe(F){if(!F)return;const U=v.value,J=U.findIndex(ge=>ge.key===F.key);J>=0?v.value=U.filter((ge,me)=>me!==J):v.value=[...U,F],x(),C.value=""}const X=fe(""),B=fe("");function de(F){const U=/^#?([0-9a-fA-F]{6})$/.exec(String(F||"").trim());if(!U)return;const J="#"+U[1].toLowerCase();X.value=X.value===J?"":J,x()}const w=fe(null),j=Q(()=>[{id:"upg100Region",label:xe("tabs.upg100Region"),info:xe("legend.tabInfo.upg100Region")},{id:"upg100Zone",label:xe("tabs.upg100Zone"),info:xe("legend.tabInfo.upg100Zone")}]);let D=[],R=null,re=null,he=[],$e=null,ke=null,Me=null;const je=typeof window<"u"&&window.MAP_APP_API_URL||void 0||"",{locale:Se,t:xe}=Kt();let tt="";pt(()=>Ut(),()=>{(h.value===""||h.value===tt)&&(h.value=tt=xe("legend.loadingData"))},{immediate:!0});function nt(F){const U={zone_affinity_A017:xe("poster.zone_deaf")},J=F?ah(F):void 0;return{deafCount:Af,...F?{records:F}:{},title:ge=>Hl(ge,U,{byCode:J,countryName:Di,locale:Ut()}),regionTitle:ge=>jl[ge]?xe(`poster.${jl[ge]}`):ge}}let E=null;function z(F){return F!==void 0&&(E=F),Gl(Pe(),nt(E))}pt(()=>Ut(),()=>{if(!b.value.length)return;b.value=z();const F=new Map(xr(b.value).map(U=>[U.id,U.label]));for(const U of he)F.has(U.id)&&(U.label=F.get(U.id));M&&K(M)});const O=Q(()=>xe("legend.title.upg100List")),ae=Q(()=>xe("legend.title.batchSelect")),ue=Q(()=>xe("search.upg100Placeholder"));eo(`.upg-root{position:absolute;inset:0;background:#0a1410;color:#e5e7eb;isolation:isolate;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-root{--upg-credit-floor:calc(max(min(var(--legend-sheet-h,0px),48px),var(--map-fab-clearance,0px)) + 30px)}@media(max-width:767.98px){.upg-root{--upg-credit-floor:max(min(var(--legend-sheet-h,0px),48px),var(--map-fab-clearance,0px))}}.upg-status{position:absolute;bottom:calc(var(--upg-credit-floor) + 6px);inset-inline-end:10px;z-index:1;pointer-events:none;font:10px/1 ui-monospace,monospace;color:#9aa7b8;background:rgba(10,14,21,.82);padding:6px 10px;border-radius:8px}@media(max-width:767px){.upg-status{display:none}}.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-shown{position:absolute;bottom:calc(var(--upg-credit-floor) + 12px);left:50%;transform:translateX(-50%);z-index:6;display:inline-flex;align-items:center;gap:10px;max-width:calc(100% - 120px);min-height:40px;box-sizing:border-box;padding:0 6px 0 16px;border:1px solid rgba(110,231,183,.45);border-radius:999px;background:rgba(10,20,16,.92);color:#e5e7eb;font:600 13px/1.2 system-ui,sans-serif;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,.25)}.upg-shown-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.upg-shown-x{display:inline-flex;align-items:center;justify-content:center;flex:0 0 28px;height:28px;border-radius:50%;background:rgba(255,255,255,.16);font-size:18px;line-height:1}.upg-shown:focus-visible{outline:2px solid #6ee7b7;outline-offset:2px}.upg-hud{position:absolute;bottom:calc(var(--upg-credit-floor) + 30px);inset-inline-end: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-inline-start: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:calc(var(--upg-credit-floor) + 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-legend-desktop-slot .stl-panel,.upg-root:has(.mapboxgl-ctrl-logo) .upg-legend-desktop-slot .stl-panel{max-height:calc(100% - var(--stl-top,60px) - 12px - 30px)!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 ie(F){const U=[];for(const J of F)U.push(J.zoneKey,KP(J.zoneKey,J.color));return["match",["get","zoneKey"],...U,"#9ca3af"]}function _e(){if(R.getSource("tapestry")&&R.getLayer("tapestry-fill")&&R.getLayer("tapestry-line"))return;R.getSource("tapestry")||R.addSource("tapestry",{type:"geojson",data:re});const F=$.value?.45:.3,U=$.value?.65:.45;if(R.getLayer("tapestry-fill")||R.addLayer({id:"tapestry-fill",type:"fill",source:"tapestry",paint:{"fill-color":$e,"fill-opacity":["case",["==",["get","zoneKey"],"deaf"],F,U]}}),R.getLayer("tapestry-line")||R.addLayer({id:"tapestry-line",type:"line",source:"tapestry",paint:{"line-color":$e,"line-width":1.2,"line-opacity":.9}}),Fo){const J=Fo;oo(()=>{Fo===J&&Eo(J)})}}function be(){!R||!R.getSource("tapestry")||R.getLayer("upg-sel-fill")||(R.addLayer({id:"upg-sel-fill",type:"fill",source:"tapestry",filter:["boolean",!1],paint:{"fill-color":"#f59e0b","fill-opacity":.28}}),R.addLayer({id:"upg-sel-line",type:"line",source:"tapestry",filter:["boolean",!1],paint:{"line-color":"#fbbf24","line-width":2.4,"line-opacity":.95}}))}function P(){const F=[],U=[],J=[];for(const me of v.value)me.kind==="adm1"?F.push(me.name):me.kind==="adm0"?U.push(me.key.slice(5)):me.kind==="zone"&&J.push(me.key.slice(5));const ge=[];return F.length&&ge.push(["in",["get","shapeName"],["literal",F]]),U.length&&ge.push(["in",["get","iso3"],["literal",U]]),J.length&&ge.push(["in",["get","zoneKey"],["literal",J]]),ge.length?ge.length===1?ge[0]:["any",...ge]:["boolean",!1]}function x(){if(G(),!R||!R.getLayer("upg-sel-fill"))return;const F=Z.value?P():["boolean",!1];R.setFilter("upg-sel-fill",F),R.setFilter("upg-sel-line",F);const U=X.value;R.setPaintProperty("upg-sel-fill","fill-color",U||"#f59e0b"),R.setPaintProperty("upg-sel-fill","fill-opacity",U?.55:.28),R.setPaintProperty("upg-sel-line","line-color",U||"#fbbf24")}let q=null,L=!1;function H(){if(!(!R||!R.getLayer("tapestry-fill"))){if(q)try{R.off("click","tapestry-fill",q)}catch{}q=F=>{const U=F&&F.features&&F.features[0];if(U&&Z.value){const J=wf(U.properties,{nameMap:W});if(!J){console.warn("[batch-select] clicked feature has no shapeName/iso3",U.properties);return}J.count==null&&console.warn("[batch-select] no UUPG count for territory",J.name,U.properties),oe(J)}},R.on("click","tapestry-fill",q),L||(R.on("mouseenter","tapestry-fill",()=>{R&&(R.getCanvas().style.cursor=Z.value?"crosshair":"")}),R.on("mouseleave","tapestry-fill",()=>{R&&(R.getCanvas().style.cursor="")}),L=!0)}}function V(){v.value=[],C.value="",X.value="",B.value="",x()}let M=null;function K(F){if(M=F,p&&typeof p.cacheSourceData=="function"){const U=JP({records:F,leafZones:he,adm1Counts:Qi,iso3Names:on,countryNameMap:W,centroidFor:J=>{const ge=Ie(J);return ge?[(ge[0][0]+ge[1][0])/2,(ge[0][1]+ge[1][1])/2]:null}});p.cacheSourceData(Dc,{normalizedData:U})}D=YP({records:F,leafZones:he,adm1Counts:Qi,iso3Names:on,countryNameMap:W}),typeof window<"u"&&(window.__UPG_SEARCH__={size:()=>D.length,counts:()=>{const U={pg:0,zone:0,territory:0};for(const J of D)U[J.kind]=(U[J.kind]||0)+1;return U},query:U=>xf(D,U,{limit:Sf}).map(J=>({label:J.label,kind:J.kind,target:J.target})),select:U=>{const J=xf(D,U,{limit:Sf})[0];return J?(ut(J.target),{label:J.label,kind:J.kind,target:J.target}):null},feedSize:()=>{const U=p&&p.sources&&p.sources[Dc];return U&&Array.isArray(U.features)&&U.features.length||0},localGeocoder:U=>{const J=w.value&&w.value.geocoder,ge=J&&J.options&&J.options.localGeocoder;return ge?ge(U).map(me=>me&&me.place_name):null}},n=window.__UPG_SEARCH__,(window.__UPG_SEARCHES__||(window.__UPG_SEARCHES__={}))[s()]=window.__UPG_SEARCH__)}function ye(F){const U=F&&F.properties||{},J=U.__upgKind;if(J==="zone")Ee(U.__zoneId);else if(J==="territory")Re(U.__shapeName);else{const ge=F&&F.geometry,me=ge&&Array.isArray(ge.coordinates)?ge.coordinates:null;me&&Number.isFinite(me[0])&&Number.isFinite(me[1])&&R&&R.flyTo({center:[me[0],me[1]],zoom:6,duration:800}),$t(U.slug)}}function Ce(F){if(!F||!R)return;const U=new Set(F.memberIds||[]);if(!U.size)return;let J=[];try{J=R.querySourceFeatures("upg").filter(rt=>{const Le=rt.properties||{};return U.has(Le.slug)||U.has(Le.id)||U.has(Le.peopleGroupId)})}catch{return}if(!J.length)return;let ge=180,me=90,Ke=-180,lt=-90,We=!1;for(const rt of J){const Le=rt.geometry&&rt.geometry.coordinates;!Array.isArray(Le)||!Number.isFinite(Le[0])||!Number.isFinite(Le[1])||(Le[0]Ke&&(Ke=Le[0]),Le[1]lt&&(lt=Le[1]),We=!0)}We&&R.fitBounds([[ge,me],[Ke,lt]],{padding:60,duration:800,maxZoom:6})}function Qe(){Jt(null),_&&typeof _.selectPeopleGroup=="function"&&_.selectPeopleGroup(null)}function ut(F){!F||!R||(F.type==="pg"?(Number.isFinite(F.lng)&&Number.isFinite(F.lat)&&R.flyTo({center:[F.lng,F.lat],zoom:6,duration:800}),$t(F.slug)):F.type==="zone"?Ee(F.zoneId):F.type==="territory"&&Re(F.shapeName))}function $t(F){if(!F||!_||typeof _.selectPeopleGroup!="function")return;const J=XP(R,"upg").find(ge=>ge.properties&&ge.properties.slug===F);J&&_.selectPeopleGroup(J)}function Ee(F){if(!F||!R||!re)return;const U=Ie(J=>J.properties&&J.properties.zoneKey===F);U&&R.fitBounds(U,{padding:40,duration:800,maxZoom:6})}function Re(F){if(!F||!R||!re)return;const U=Ie(J=>{const ge=J.properties||{};return ge.shapeName===F||ge.iso3===F});U&&R.fitBounds(U,{padding:40,duration:800,maxZoom:6})}function Ie(F){let U=180,J=90,ge=-180,me=-90,Ke=!1;const lt=We=>{if(typeof We[0]=="number"){const[rt,Le]=We;rtge&&(ge=rt),Leme&&(me=Le),Ke=!0;return}for(const rt of We)lt(rt)};for(const We of re.features)F(We)&<(We.geometry.coordinates);return Ke?[[U,J],[ge,me]]:null}function Ye(F){const U=new Set,J=ge=>{ge.children&&ge.children.length?ge.children.forEach(J):U.add(ge.zoneKey??ge.id)};return J(F),U}let ht=null;function ko(F){if(![...Ye(F)].length)return;const J=[],ge=We=>{We.children&&We.children.length?We.children.forEach(ge):J.push(We)};ge(F);const me=v.value,Ke=new Set(me.filter(We=>We.kind==="zone").map(We=>We.key));if(J.every(We=>Ke.has("zone:"+(We.zoneKey??We.id)))){const We=new Set(J.map(rt=>"zone:"+(rt.zoneKey??rt.id)));v.value=me.filter(rt=>!We.has(rt.key))}else{const We=J.filter(rt=>!Ke.has("zone:"+(rt.zoneKey??rt.id))).map(rt=>({key:"zone:"+(rt.zoneKey??rt.id),name:rt.label||rt.id,count:Number(rt.count)||0,kind:"zone"}));v.value=[...me,...We]}x(),C.value=""}function rn(){const F=new Set;for(const U of v.value)U.kind==="zone"&&F.add(U.key.slice(5));return F}function Rr(){const F=new Map,U=J=>{const ge=Ye(J);J.label&&F.set(J.label,ge),J.children&&J.children.length&&J.children.forEach(U)};for(const J of b.value)U(J);return F}function G(){if(typeof document>"u")return;const F=document.querySelector("my-upg-100-list-map"),J=(F&&F.shadowRoot||document).querySelectorAll(".stl-row");if(!J.length)return;if(!Z.value){J.forEach(lt=>lt.classList.remove("upg-batch-row"));return}const ge=rn(),me=Rr(),Ke=$.value;J.forEach(lt=>{const We=lt.querySelector(".stl-name"),rt=We?We.textContent.trim():"",Le=rt&&me.get(rt),it=!!(Le&&Le.size&&[...Le].every(It=>ge.has(It)));lt.classList.toggle("upg-batch-row",it),lt.classList.toggle("dark",it&&Ke)})}let ee=null;function Fe(){if(typeof document>"u"||ee)return;const F=document.querySelector("my-upg-100-list-map"),J=(F&&F.shadowRoot||document).querySelector(".stl-rows");J&&(ee=new MutationObserver(()=>{requestAnimationFrame(()=>G())}),ee.observe(J,{childList:!0,subtree:!0}))}so("onSemanticTreeSelect",Jt),so("onLegendExport",Ge),so("legendExportCards",!0);async function Ge(F){const U=m.value;if(!U)return;const[J,ge]=String(F).split(":");if(!Ne.value){Ne.value=!0,De.value=J==="packet"?"packet":J==="cards"?"cards":"poster";try{if(J==="packet"){await le(U,ge||"full");return}const me=Ze().find(Ke=>Ke.id===U)||{id:U};if(J==="cards"){const Ke=Ze().find(lt=>lt.id===U);Ke&&await Be.printCardDeck(await pe(Ke));return}await Be.printPoster(me)}finally{Ne.value=!1,De.value=""}}}const Be=Dg({t:(F,U,J)=>typeof J=="number"?xe(F,U,J):xe(F,U),records:F=>Bt(F),lang:()=>Ut(),label:F=>(F==null?void 0:F.label)||(F==null?void 0:F.id)||"",assetsBase:()=>ga(a.value),iso3Names:()=>on,sheet:(F,U)=>Ht(F,U),sets:()=>fetch(`${ga(a.value)}/tables/near-neighbors.json`).then(F=>F.ok?F.json():null).catch(()=>null),downloadPrefix:"doxa-upg-100"});let mt="";pt(Be.exportState,F=>{if(!F){mt&&h.value===mt&&(h.value=""),mt="";return}if(F.phase==="error"){mt="",ne(xe("messages.packetFailed",{reason:F.message}),4e3);return}mt=F.phase==="done"?"":`${F.message}…`,h.value=mt});const Ue=qg({apiBase:()=>je,lang:()=>Ut(),profileConfig:a,evaluate:(F,U)=>Ra(F,U)});async function Bt(F){if(!je)throw co("wall.hud.noApi","no people-groups service is configured");return Ue(F.selector)}const Ht=eh({allRecords:()=>Ue.all(),assetsBase:()=>ga(a.value),profileConfig:a});function wo(F,U,J){F.value=U,setTimeout(()=>{F.value===U&&(F.value="")},J)}const ne=(F,U)=>wo(h,F,U);async function le(F,U="full"){const J=Ze().find(me=>me.id===F);if(!J)return;const ge=await pe(J);await Be.printPacket(ge,{variant:U,funnel:await we()})}async function pe(F){try{const[{zoneTitle:U},{countryName:J},ge]=await Promise.all([Pt(()=>Promise.resolve().then(()=>sv),void 0),Pt(()=>Promise.resolve().then(()=>Kl),void 0),Oi(ga(a.value))]),me={...ge.en||{},...ge[Ut()]||{}},Ke=U(F,me,{countryName:J,locale:Ut()});return Ke?{...F,label:Ke}:F}catch{return F}}function Pe(){return Dl(Sn(a))}function ve(){const F=Pe();return[...F.lists||[],...F.asia_lists||[],...F.uncovered_lists||[]]}function Ze(){const F=ve(),U=new Set(F.map(J=>J.id));return[...F,...Q1(Pe(),{deafCount:Af}).filter(J=>!U.has(J.id))]}async function we(){var F;try{const U=(await Pt(async()=>{const{default:Ke}=await Promise.resolve().then(()=>Kf);return{default:Ke}},void 0)).default;if(!U||!Array.isArray(U.steps)||!U.steps.length)return null;const J=Sn(a),ge=Number(U.steps[U.steps.length-1].groups)||0;if(J===yr)return{...U,listCount:Ze().length,listTotal:ge};let me=0;try{const Ke=ga(a.value),lt=await fetch(`${Ke}/people-groups/lists/${J}.json`);if(lt.ok){const We=await lt.json();me=Number((F=We==null?void 0:We.counts)==null?void 0:F.doxa)||(Array.isArray(We==null?void 0:We.slugs)?We.slugs.length:0)}}catch{}return{...U,listTotal:me,listId:J,listLabel:(Cg(J)||{}).label||J}}catch{return null}}const Ne=fe(!1),De=fe("");function Oe(){const F=v.value.filter(J=>J.kind==="zone").map(J=>String(J.key).replace(/^zone:/,"")),U=new Map(Ze().map(J=>[J.id,J]));return F.map(J=>U.get(J)).filter(Boolean)}async function ze(){const F=await Oi(ga(a.value));return{...F.en||{},...F[Ut()]||{}}}function gt(F,U){return F?String(F).replace(/\{(\w+)\}/g,(J,ge)=>U[ge]!=null?String(U[ge]):J):null}function wt(){return v.value.filter(F=>F.kind==="adm0").map(F=>String(F.key).replace(/^adm0:/,"")).filter(Boolean)}function xt(){return v.value.filter(F=>F.kind==="adm1").map(F=>F.name||String(F.key).replace(/^adm1:/,""))}async function Ft(){const F=Oe(),U=wt(),J=xt();if(!F.length&&!U.length)throw J.length?co("upgMap.selectionAdm1NoData","no people-group data for {names} — select the country instead",{names:Ll(J,{locale:Ut()})}):co("upgMap.nothingSelected","nothing is selected");if(!je)throw co("wall.hud.noApi","no people-groups service is configured");const me=await fetch(`${je}/api/people-groups/list?fields=${Vg}&lang=${Ut()}`,{cache:"no-store"});if(!me.ok)throw co("wall.hud.fetchFailed","could not load the people groups ({status})",{status:me.status});const Ke=Ic(await Ni(Oc(await me.json()),a)),{evaluate:lt}=await Pt(async()=>{const{evaluate:dt}=await Promise.resolve().then(()=>Zg);return{evaluate:dt}},void 0),We=new Set;for(const dt of F)if(dt.selector&&dt.selector.type==="pg_slugs")for(const Mo of dt.selector.values||[])We.add(Mo);else for(const Mo of lt(dt.selector,Ke))We.add(Mo);if(U.length)for(const dt of lt({type:"country_codes",values:U},Ke))We.add(dt);const rt=(await Promise.all(F.map(pe))).map(dt=>dt.label||dt.id),Le=v.value.filter(dt=>dt.kind==="adm0").map(dt=>dt.name),it=[...rt,...Le],It=await ze(),_o=(dt,Mo)=>gt(It.zone_join,{a:dt,b:Mo})??`${dt} + ${Mo}`;return{id:"selection",label:it.length<=3?it.reduce(_o):gt(It.zone_join_more,{a:it.slice(0,2).reduce(_o),n:it.length-2})??`${it.slice(0,2).join(" + ")} +${it.length-2} more`,count:We.size,selector:{type:"pg_slugs",values:[...We]}}}async function To(){if(!Ne.value){Ne.value=!0,De.value="packet";try{const F=await Ft(),U=Oe(),J=U.length===1?U[0].id:null,ge=await we();await Be.printPacket({...F,mapId:J},{funnel:ge&&U.length===1?ge:ge?{...ge,listCount:0}:null})}catch(F){ne(xe("messages.selectionPacketFailed",{reason:vr(F,xe).slice(0,90)}),4e3)}finally{Ne.value=!1,De.value=""}}}async function No(){if(!Ne.value){Ne.value=!0,De.value="cards";try{await Be.printCardDeck(await Ft())}catch(F){ne(xe("upgMap.selectionCardsFailed",{reason:vr(F,xe).slice(0,90)}),4e3)}finally{Ne.value=!1,De.value=""}}}async function xo(){if(!Ne.value){Ne.value=!0,De.value="poster";try{const F=Oe();if(!F.length)throw wt().length||xt().length?co("upgMap.selectionPosterNeedsZone","posters exist per territory on the legend — use Prayer list for a map selection"):co("upgMap.nothingSelected","nothing is selected");if(F.length>1){ne(xe("messages.posterOneTerritory",{count:F.length}),5e3);return}await Be.printPoster(F[0])}catch(F){ne(xe("messages.selectionPosterFailed",{reason:vr(F,xe).slice(0,90)}),4e3)}finally{Ne.value=!1,De.value=""}}}function Ut(){const F=Se&&(Se.value??Se);return typeof F=="string"&&F||"en"}function Jt(F){if(!R||!R.getLayer("tapestry-fill"))return!1;if(Z.value)return F&&ko(F),!0;if(!F)return ht=null,m.value=null,R.setFilter("tapestry-fill",null),R.setFilter("tapestry-line",null),R.setPaintProperty("upg-pins","circle-opacity",1),!0;ht=F;const U=[...Ye(F)];m.value=U.length===1?U[0]:F.id??null;const J=["in",["get","zoneKey"],["literal",U]];R.setFilter("tapestry-fill",J),R.setFilter("tapestry-line",J),R.getLayer("upg-pins")&&R.setPaintProperty("upg-pins","circle-opacity",["case",["in",["get","zoneKey"],["literal",U]],.95,.05]);const ge=Ie(me=>U.includes(me.properties.zoneKey));return ge&&R.fitBounds(ge,{padding:40,duration:700,maxZoom:6}),!0}function bo(){R&&(typeof Me=="function"&&Me(),re&&(_e(),be(),H(),x(),m.value&&R.getLayer("tapestry-fill")&&Jt(ht)))}function jt(){R&&($.value=!$.value,g.theme.value=$.value?"dark":"light",R.setStyle($.value?Nc("ink",l).style||"mapbox://styles/mapbox/dark-v11":Nc("paper",l).style||"mapbox://styles/mapbox/light-v11"),R.once("style.load",bo))}function Dt(){!R||!R.getLayer("upg-pins-hit")||(R.on("click","upg-pins-hit",F=>{const U=F&&F.features&&F.features[0];U&&_&&typeof _.selectPeopleGroup=="function"&&_.selectPeopleGroup(U)}),R.on("mouseenter","upg-pins-hit",()=>{R&&(R.getCanvas().style.cursor="pointer")}),R.on("mouseleave","upg-pins-hit",()=>{R&&(R.getCanvas().style.cursor="")}))}let $o=null,Fo,$a=null;function Fn(F,U){var J,ge,me;try{const Ke=(me=(ge=(J=f.value)==null?void 0:J.getRootNode)==null?void 0:ge.call(J))==null?void 0:me.host;if(!Ke)return;Ke.setAttribute("data-doxa-select-zone-state",F),U&&Ke.setAttribute("data-doxa-select-zone-applied",String(U))}catch{}}function Eo(F){if(!F)return Jt(null),Fo=void 0,Fn("cleared",""),!0;const U=za(b.value,F);return U?Jt(U)?(Fo=void 0,Fn("applied",F),!0):(Fo=F,Fn("applied-but-no-selection",F),!1):(Fo=F,Fn("unresolved",F),!1)}function ss(F){var J;const U=((J=F==null?void 0:F.detail)==null?void 0:J.listId)??null;Eo(U)}function za(F,U){for(const J of F||[]){if((J.zoneKey||J.id)===U)return J;const ge=J.children&&za(J.children,U);if(ge)return ge}return null}const sn=Q(()=>{if(!m.value||Z.value)return null;const F=za(b.value,m.value);return F&&F.label||String(m.value)});function In(){Eo(null)}function Vc(){const F=Pe(),U=z(null);b.value=U,he=xr(U);const J={};for(const ge of F.lists||[])J[ge.id]=ge.selector;for(const ge of F.asia_lists||[])J[ge.id]=ge.selector;for(const ge of F.uncovered_lists||[])J[ge.id]=ge.selector;J.deaf=wr;for(const ge of he)ge.selector=J[ge.id];$e=ie(he)}async function ls(){if(je)try{const U=await fetch(`${je}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${Ut()}`,{cache:"no-store"});if(!U.ok)throw new Error(`list ${U.status}`);const J=Ic(await Ni(Oc(await U.json()),a));W=kf(J),b.value=z(J)}catch{}}lo(async()=>{var me,Ke,lt,We,rt;Vc();try{await jP(l)}catch{}const F=Fc(l);F&&zP(F);const U=(o==null?void 0:o.value)||((me=a==null?void 0:a.value)==null?void 0:me.tk)||"";if(!F){console.warn(`[upg-100-list] ${l} 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.`),h.value=`⚠ ${xe("messages.engineNotLoaded")}`,y.value=xe("messages.engineNotLoadedDetail",{engine:c?"MapLibre":"Mapbox"}),ls();return}if(!c){if(!U){h.value=`⚠ ${xe("messages.noMapboxToken")}`,y.value=xe("messages.noMapboxTokenDetail"),ls();return}F.accessToken=U}try{const Le=_f(l);Le&&await GP(f.value,Le)}catch{}try{const Le=!c&&f.value&&f.value.getRootNode();if(Le instanceof ShadowRoot){const it=_f("mapbox");if(it&&!Le.querySelector(`link[href="${it}"]`)){const It=document.createElement("link");It.rel="stylesheet",It.href=it,Le.prepend(It)}}}catch{}R=new F.Map({container:f.value,style:Nc("paper",l).style||"mapbox://styles/mapbox/light-v11",center:[35,20],zoom:1.5,projection:"mercator"}),k.value=R,ke=IP(((Ke=f.value)==null?void 0:Ke.parentElement)||null,{enabled:d.value}),typeof window<"u"&&(window.__UPG_MAP__=R,r=R,(window.__UPG_MAPS__||(window.__UPG_MAPS__={}))[s()]=R),window.__UPG_SELECT__={get list(){return v.value.map(Le=>({...Le}))},get total(){return S.value},get count(){return A.value},get color(){return X.value},get batchMode(){return Z.value},setColor:Le=>de(Le),setBatchMode:Le=>I(Le),clipboardText:()=>VP(v.value,{color:X.value}),clear:()=>V(),toggleByProps:Le=>{const it=wf(Le,{nameMap:W});return it?(oe(it),{...it}):null},toggleLegendRow:Le=>{const it=_o=>{for(const kt of _o){if(kt.label===Le||kt.id===Le)return kt;if(kt.children&&kt.children.length){const dt=it(kt.children);if(dt)return dt}}return null},It=it(b.value);return It?(ko(It),{label:It.label,zoneKeys:[...Ye(It)]}):null},markedLegendRows:()=>{if(typeof document>"u")return[];const Le=document.querySelector("my-upg-100-list-map");return[...(Le&&Le.shadowRoot||document).querySelectorAll(".stl-row.upg-batch-row .stl-name")].map(It=>It.textContent.trim())},highlightFeatureCount:()=>{if(!R||!re||!R.getLayer("upg-sel-fill"))return-1;const Le=new Set,it=new Set,It=new Set;for(const kt of v.value)kt.kind==="zone"?Le.add(kt.key.slice(5)):kt.kind==="adm1"?it.add(kt.name):kt.kind==="adm0"&&It.add(kt.key.slice(5));let _o=0;for(const kt of re.features){const dt=kt.properties||{};(Le.has(dt.zoneKey)||it.has(dt.shapeName)||It.has(dt.iso3))&&_o++}return _o},zoneKeysForRow:Le=>{const it=_o=>{for(const kt of _o){if(kt.label===Le||kt.id===Le)return kt;if(kt.children&&kt.children.length){const dt=it(kt.children);if(dt)return dt}}return null},It=it(b.value);return It?[...Ye(It)]:null}},i=window.__UPG_SELECT__,(window.__UPG_SELECTS__||(window.__UPG_SELECTS__={}))[s()]=window.__UPG_SELECT__;try{h.value=xe("messages.loadingBoundaries");const Le=st=>`${ga(a.value)}/boundaries/${st}`,it=st=>fetch(Le(st)).then(to=>{if(!to.ok)throw new Error(`boundary fetch ${to.status} ${st}`);return to.json()});if(!je)throw new Error("No API base configured — set window.MAP_APP_API_URL or VITE_API_BASE_URL. Failing closed (no default host).");const _o=fetch(`${je}/api/people-groups/list?fields=slug,name,country_code,wagf_region,wagf_block,rop1,population,latitude,longitude&lang=${Ut()}`).then(st=>{if(!st.ok)throw new Error(`list ${st.status}`);return st.json()}),kt={adm0:it("world-adm0-web.geojson"),adm1Chn:it("gb-CHN-ADM1.geojson"),adm1Ind:it("gb-IND-ADM1-web.geojson")};h.value=xe("messages.fetchingUupgs",{n:2106});const dt=Ic(await Ni(Oc(await _o),a));W=kf(dt),b.value=z(dt);const Mo=[],_a={},{evaluate:cs}=await Pt(async()=>{const{evaluate:st}=await Promise.resolve().then(()=>Zg);return{evaluate:st}},void 0);for(const st of he)if(st.selector&&st.selector.type==="pg_slugs")for(const to of st.selector.values||[])to in _a||(_a[to]=st.zoneKey);else try{for(const to of cs(st.selector,dt))to in _a||(_a[to]=st.zoneKey)}catch(to){console.warn("zone selector skipped",st.id,to&&to.message)}for(const st of dt){const to=Number(st.latitude),Jc=Number(st.longitude);!isFinite(to)||!isFinite(Jc)||Mo.push({type:"Feature",geometry:{type:"Point",coordinates:[Jc,to]},properties:{slug:st.slug,zoneKey:_a[st.slug]||"",name:st.name||st.slug||"",population:st.population??0,countryName:st.country_code_label||"",country:st.country_code||""}})}const Dn=Ba({type:"FeatureCollection",features:Mo});Me=()=>{R.getSource("upg")&&R.getLayer("upg-pins")&&R.getLayer("upg-pins-hit")||(R.getSource("upg")||R.addSource("upg",{type:"geojson",data:Dn}),R.getLayer("upg-pins")||R.addLayer({id:"upg-pins",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],0,2.6,2,3.2,4,4.5,6,6.5,8,9],"circle-color":$e,"circle-opacity":1,"circle-stroke-width":["interpolate",["linear"],["zoom"],0,.9,4,1.4,8,2],"circle-stroke-color":"rgba(15,20,25,0.9)"}}),R.getLayer("upg-pins-hit")||R.addLayer({id:"upg-pins-hit",type:"circle",source:"upg",paint:{"circle-radius":["interpolate",["linear"],["zoom"],1,5,4,6.5,8,9],"circle-stroke-width":["interpolate",["linear"],["zoom"],1,1.8,8,2],"circle-opacity":0,"circle-stroke-opacity":0}}),Dt())};const us=()=>{try{bo()}catch(st){console.warn("early pin paint skipped",st&&st.message)}};R.isStyleLoaded()?us():R.once("style.load",us),h.value=xe("messages.loadingBoundaries");const[zn,qc]=await Promise.all([kt.adm0,kt.adm1Chn]),Yc=await kt.adm1Ind,{tapestry:ds,perZone:Zc}=rv(he,{records:dt,adm0:zn,adm1Ind:Yc,adm1Chn:qc});re=Ba(ds),K(dt);let Nr=!0;const jn=()=>{Nr&&(Nr=!1,R.off("style.load",jn),R.off("idle",jn),bo())};if(R.isStyleLoaded())jn();else{R.once("style.load",jn),R.once("idle",jn);const st=setInterval(()=>{if(!Nr||!R){clearInterval(st);return}let to=!1;try{to=R.isStyleLoaded()}catch{clearInterval(st);return}to&&(clearInterval(st),jn())},120);setTimeout(()=>clearInterval(st),15e3)}const Qf=[...Zc.entries()].filter(([st])=>st!=="deaf"),z2=Qf.filter(([,st])=>st>=1).length;h.value=xe("messages.mapStatusCounts",{polys:re.features.length,zones:z2,total:Qf.length,pins:Mo.length})}catch(Le){console.warn("[upg-100-list] map data failed:",Le),h.value="⚠ "+xe("upgMap.mapDataFailed")}let J=0;const ge=()=>{const Le=typeof document<"u"&&document.querySelector("my-upg-100-list-map"),it=Le&&Le.shadowRoot||(typeof document<"u"?document:null);if(it&&it.querySelector(".stl-rows")){Fe(),G();return}J++<40&&setTimeout(ge,250)};ge();{const Le=(rt=(We=(lt=f.value)==null?void 0:lt.getRootNode)==null?void 0:We.call(lt))==null?void 0:rt.host;if(Le){$o=ss,Le.addEventListener("doxa:select-zone",$o);const it=Le.getAttribute("select-zone");it&&Eo(it),$a=new MutationObserver(()=>{Eo(Le.getAttribute("select-zone")||null)}),$a.observe(Le,{attributes:!0,attributeFilter:["select-zone"]})}}});const On=()=>{var F,U,J;try{return((J=(U=(F=f.value)==null?void 0:F.getRootNode)==null?void 0:U.call(F))==null?void 0:J.host)||null}catch{return null}};return pt([b,k],()=>{oo(()=>{var U;const F=((U=On())==null?void 0:U.getAttribute("select-zone"))||Fo||null;F&&Eo(F)})}),qt(()=>{var F,U,J;if($a==null||$a.disconnect(),$a=null,$o){const ge=(J=(U=(F=f.value)==null?void 0:F.getRootNode)==null?void 0:U.call(F))==null?void 0:J.host;ge==null||ge.removeEventListener("doxa:select-zone",$o),$o=null}if(ee){try{ee.disconnect()}catch{}ee=null}if(ke){try{ke()}catch{}ke=null}if(R&&(R.remove(),R=null),re=null,typeof window<"u"){const ge=s();try{window.__UPG_SEARCHES__&&delete window.__UPG_SEARCHES__[ge],window.__UPG_MAPS__&&delete window.__UPG_MAPS__[ge],window.__UPG_SELECTS__&&delete window.__UPG_SELECTS__[ge],window.__UPG_SEARCH__===n&&delete window.__UPG_SEARCH__,window.__UPG_MAP__===r&&delete window.__UPG_MAP__,window.__UPG_SELECT__===i&&delete window.__UPG_SELECT__}catch{}}}),(F,U)=>{var J;return Y(),te("div",QP,[N("div",{ref_key:"mapEl",ref:f,class:"upg-map"},null,512),y.value?(Y(),te("div",eS,[N("strong",null,ce(se(xe)("messages.mapUnavailable")),1),Wt(ce(y.value),1)])):Ae("",!0),d.value?(Y(),te(Xe,{key:1},[U[0]||(U[0]=N("div",{class:"map-scroll-edge map-scroll-edge--left"},null,-1)),U[1]||(U[1]=N("div",{class:"map-scroll-edge map-scroll-edge--right"},null,-1))],64)):Ae("",!0),k.value&&u.value?(Y(),St(TP,{key:2,ref_key:"geocoderRef",ref:w,"map-instance":k.value,"access-token":se(o)||((J=se(a))==null?void 0:J.tk)||"","data-source-id":Dc,"is-dark":$.value,placeholder:ue.value,"active-context":bS,onPeopleGroupResult:ye,onAggregateResult:Ce,onClear:Qe},null,8,["map-instance","access-token","is-dark","placeholder"])):Ae("",!0),k.value?(Y(),St(aP,{key:3,"has-geocoder":u.value},{default:yo(()=>[yt(rP,{map:k.value,"is-dark":$.value},null,8,["map","is-dark"]),yt(iP,{map:k.value,"is-dark":$.value},null,8,["map","is-dark"]),yt(sP,{map:k.value,"is-dark":$.value},null,8,["map","is-dark"]),yt(uP,{"map-container":f.value,"is-dark":$.value},null,8,["map-container","is-dark"]),yt(pP,{"is-dark":$.value,onToggle:jt},null,8,["is-dark"]),yt(Da,{"is-dark":$.value,active:Z.value,class:Ve({"upg-batch-on":Z.value}),"aria-pressed":Z.value?"true":"false",title:ae.value,onClick:T},{default:yo(()=>[...U[2]||(U[2]=[N("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[N("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),N("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),N("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),N("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})],-1)])]),_:1},8,["is-dark","active","class","aria-pressed","title"])]),_:1},8,["has-geocoder"])):Ae("",!0),N("div",tS,[b.value.length?(Y(),St(ph,{key:0,nodes:b.value,tabs:j.value,"default-tab":Pf,columns:["count","pop"],title:O.value,"export-enabled":!0,"export-cards":!0,onSelect:Jt,onExport:Ge},null,8,["nodes","tabs","title"])):Ae("",!0)]),N("div",oS,[b.value.length?(Y(),St(oP,{key:0,"legend-type":"upg-100",nodes:b.value,tabs:j.value,"default-tab":Pf,columns:["count","pop"],"column-label":"UPG 100",title:O.value,"is-dark":$.value,"popup-action":"pray"},null,8,["nodes","tabs","title","is-dark"])):Ae("",!0)]),N("div",aS,[se(_)&&se(_).selectedPeopleGroup?(Y(),te("div",{key:0,class:Ve(["upg-detail-panel pg-detail-root",{dark:$.value}])},[yt(se(t),{peopleGroup:se(_).selectedPeopleGroup,dark:$.value,action:"pray"},null,8,["peopleGroup","dark"])],2)):Ae("",!0)]),sn.value?(Y(),te("button",{key:4,type:"button",class:"upg-shown","aria-label":se(xe)("buttons.clearSelection")+": "+sn.value,title:se(xe)("buttons.clearSelection"),onClick:In},[N("span",rS,ce(sn.value),1),U[3]||(U[3]=N("span",{class:"upg-shown-x","aria-hidden":"true"},"×",-1))],8,nS)):Ae("",!0),Z.value?(Y(),te("div",iS,[N("div",sS,ce(se(xe)("messages.tapTerritoriesHint")),1),A.value?(Y(),te("div",lS,[N("span",null,ce(se(xe)("messages.territoriesSelected",{count:A.value}))+" ·",1),N("span",cS,ce(S.value)+" UUPG",1),N("span",{class:Ve(["upg-hud-band",{ok:S.value>=50&&S.value<=100}])},ce(S.value>=50&&S.value<=100?se(xe)("messages.bandInRange"):se(xe)("messages.bandOutOfRange")),3)])):Ae("",!0),A.value?(Y(),te("div",uS,ce(se(Ll)(v.value.map(ge=>ge.name),{locale:Ut()})),1)):Ae("",!0),A.value?(Y(),te("div",dS,[N("button",{class:Ve(["upg-hud-btn make",{"is-busy":De.value==="packet"}]),disabled:Ne.value,onClick:To},ce(De.value==="packet"?se(xe)("buttons.working"):se(xe)("buttons.prayerList")),11,pS),N("button",{class:Ve(["upg-hud-btn make",{"is-busy":De.value==="poster"}]),disabled:Ne.value,onClick:xo},ce(De.value==="poster"?se(xe)("buttons.working"):se(xe)("buttons.posterMap")),11,gS),N("button",{class:Ve(["upg-hud-btn make",{"is-busy":De.value==="cards"}]),disabled:Ne.value,onClick:No},ce(De.value==="cards"?se(xe)("buttons.working"):se(xe)("buttons.cardDeck")),11,hS),N("button",{class:"upg-hud-btn clear",onClick:V},ce(se(xe)("buttons.clearSelection")),1)])):Ae("",!0),A.value?(Y(),te("div",fS,ce(C.value),1)):Ae("",!0)])):Ae("",!0),N("div",mS,ce(h.value),1)])}}}},Symbol.toStringTag,{value:"Module"})),_S=` .pane-col{ position:absolute; inset:0; overflow-y:auto; overflow-x:hidden; scroll-snap-type:y mandatory; scroll-behavior:smooth; 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 e272d05fc..f46ec83d4 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 @@ -67,7 +67,7 @@ - + - + - +