@minmaps-dev/mm-web-sdk 1.0.0-rc.23 → 1.0.0-rc.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var t=require("maplibre-gl"),e=require("pmtiles");function o(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:function(){return t[o]}})}}),e.default=t,Object.freeze(e)}var i=o(require("@turf/turf"));let n=!1;function r(o,i){const r="string"==typeof o?document.getElementById(o):o;if(!r)throw new Error("Map container not found");return function(){if(n)return;const o=new e.Protocol;t.addProtocol("pmtiles",o.tile),n=!0}(),new t.Map({container:r,style:i,center:[0,0],zoom:16,pitch:45,bearing:0,minPitch:30,maxPitch:55})}const s={ensureGeoJson(t,e){t.getSource(e)||t.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:[]}})},setData(t,e,o){const i=t.getSource(e);i?.setData?.(o)}},a="indoor-data",l="poi-data",c="unit-walls",u="route-data",d="poi-highlight-data",p="map-labels-data",f="route-active-step",h=["boundary-fill","boundary-outline","units-fill","units-wall-extrusion","units-wall-custom-extrusion","corridors-fill","corridors-outline","building-extrusion"],g=()=>{};function y(t){const e=Boolean(t?.enabled),o=function(t){const e=String(t||"").trim();return e?`[${e}]`:""}(t?.prefix||"MinuteMapsSDK");return e?{debug:(...t)=>console.debug(o,...t),log:(...t)=>console.log(o,...t),warn:(...t)=>console.warn(o,...t),error:(...t)=>console.error(o,...t)}:{debug:g,log:g,warn:g,error:g}}y({enabled:!0,prefix:"MinuteMapsSDK"});const m={applyFloor(t,e,o=1){m.updateWalls(t,e,o),m.updateIndoor(t,e,o)},updateIndoor(t,e,o=1){const n=function(t,e){if(!t)return{type:"FeatureCollection",features:[]};if(!Number.isFinite(e)||e<=0)return t;const o=(t.features||[]).map(t=>{const o=t?.properties?.featureType;if(!o||!w.has(o))return t;const n=t?.geometry?.type;if("Polygon"!==n&&"MultiPolygon"!==n)return t;try{const o=i.buffer(t,-e,{units:"feet"});return o?.geometry?{...t,geometry:o.geometry}:t}catch{return t}});return{...t,features:o}}(e.geojson,o);s.setData(t,a,n);try{const t=e?.geojson?.features||[],o={};for(const e of t){const t=e?.properties?.featureType,i=null==t?"(missing)":String(t);o[i]=(o[i]||0)+1}Object.entries(o).sort((t,e)=>e[1]-t[1]).slice(0,15)}catch{}},updateWalls(t,e,o=1){const n=function(t,e=1){const o=Math.max(Number(e)||1,.5)/2,n=t=>{try{return i.cleanCoords(t)}catch{return t}},r=t=>{const e=t?.geometry?.type;if("Polygon"!==e&&"MultiPolygon"!==e)return null;try{const e=n(t),r=i.buffer(e,-o,{units:"feet"});if(!r?.geometry)return null;const s=i.area(e),a=i.area(r);if(!Number.isFinite(s)||s<=0)return null;if(a>=s)return null;const l=i.difference(i.featureCollection([e,r]));return l?.geometry?l:null}catch{return null}},s=t=>{if(0===t.length)return null;if(1===t.length)return t[0];try{return i.union(i.featureCollection(t))}catch{return null}},a=[];let l=null;for(const e of t.features||[]){const t=e?.properties?.featureType,o=e?.geometry?.type;if("Polygon"===o||"MultiPolygon"===o)if("Boundary"!==t||l){if("Units"===t){const t=r(e);t&&a.push(t)}}else l=r(e)}const c=s(a);let u=c;if(c?.geometry&&l?.geometry)try{const t=i.difference(i.featureCollection([c,l]));t?.geometry&&(u=t)}catch{}const d=[];l?.geometry&&d.push({type:"Feature",geometry:l.geometry,properties:{featureType:"UnitWalls",wallKind:"perimeter"}});u?.geometry&&d.push({type:"Feature",geometry:u.geometry,properties:{featureType:"UnitWalls",wallKind:"interior"}});return{type:"FeatureCollection",features:d}}(e.geojson,o);s.setData(t,c,n)},boundsFromGeoJson(t){try{const[e,o,n,r]=i.bbox(t),s=Math.min(e,n),a=Math.max(e,n),l=Math.min(o,r);return[[s,l],[a,Math.max(o,r)]]}catch{return null}},selectDefaultFloor:t=>Array.isArray(t)&&0!==t.length&&(t.find(t=>t.isDefault)||t[0])||null,selectInitialFloor(t,e){if(!Array.isArray(t)||0===t.length)return null;if(null!=e){const o=t.find(t=>t.id===e);if(o)return o}return m.selectDefaultFloor(t)},async activateFloor(t,e,o){if(!t)throw new Error("activateFloor requires an initialized map");if(e?.geojson&&m.applyFloor(t,e,o.wallFeet),await o.updatePOIs(e),!e?.geojson)return void(t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom));const i=m.boundsFromGeoJson(e.geojson);if(!i)return;const n=!o.didFit;let r=n;if(!r){const[[e,o],[n,s]]=i,a=t.getBounds();r=a.getWest()>n||a.getEast()<e||a.getSouth()>s||a.getNorth()<o}r?(t.fitBounds(i,{padding:o.boundsPadding,animate:!n,duration:700,bearing:t.getBearing(),pitch:t.getPitch()}),t.once("moveend",()=>{t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom)}),o.setDidFit(!0),o.log?.("camera :: fitToFloor",{floorId:e.id,animated:!n})):(t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom),o.log?.("camera :: fit skipped (floor overlaps viewport)",{floorId:e.id}))}},w=new Set(["Restrooms","Back-of-house","Obstacles","Escalators","Stairs","Elevators"]);class b{floors=[];currentFloor=null;didFit=!1;getMap;getConfig;updatePoiSource;logFn;constructor(t){this.getMap=t.getMap,this.getConfig=t.getConfig,this.updatePoiSource=t.updatePoiSource,this.logFn=t.log}log(...t){this.logFn&&this.logFn(...t)}setFloors(t){this.floors=t}getFloors(){return[...this.floors]}getCurrentFloor(){return this.currentFloor}setDidFit(t){this.didFit=t}getDefaultFloor(){return m.selectDefaultFloor(this.floors)}getInitialFloor(){const t=this.getConfig();return m.selectInitialFloor(this.floors,t.options?.initialFloor)}async setCurrentFloor(t){const e=this.getMap();if(!e)throw new Error("Map is not initialized");this.currentFloor=t,this.log("floor :: setCurrentFloor",{id:t.id,name:t.name,geojsonFeatures:t.geojson?.features?.length??0});const o=this.getConfig(),i=o.options?.wallThickness??1,n=o.options?.boundsPadding??50,r=o.options?.minIndoorZoom??16.5;await m.activateFloor(e,t,{wallFeet:i,updatePOIs:t=>this.updatePoiSource(t),didFit:this.didFit,setDidFit:t=>{this.didFit=t},boundsPadding:n,minIndoorZoom:r,log:(t,e)=>this.log(t,e)})}}const I=y({enabled:!0,prefix:"MinuteMapsSDK"}),v=new Map,x={async getSpriteKeys(t){const e=function(t){if(!t)return;if("string"==typeof t)return t;if(Array.isArray(t)){const e=t[0];if(e&&"string"==typeof e.url)return e.url}if("object"==typeof t&&null!==t){const e=t?.url;if("string"==typeof e)return e}return}(t?.getStyle?.()?.sprite);if(!e||"function"!=typeof fetch)return new Set;const o=e.endsWith(".json")?e:`${e}.json`;if(v.has(o))return v.get(o);try{const t=await fetch(o);if(!t.ok)throw new Error(`Failed to load sprite JSON (${t.status})`);const e=await t.json(),i=new Set(Object.keys(e||{}));return v.set(o,i),i}catch(t){I.warn("sprite fetch failed",o,t);const e=new Set;return v.set(o,e),e}}};const F=y({enabled:!0,prefix:"MinuteMapsSDK amenityIcons"});async function A(t,e,o){let i;if(t.inlineSvg)i=t.inlineSvg;else{if(!t.url)throw new Error("loadSvgElement: neither url nor inlineSvg provided");{const e=await fetch(t.url,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);i=await e.text()}}let n=i;try{const t=(new DOMParser).parseFromString(i,"image/svg+xml"),r=t.documentElement;!(t.getElementsByTagName("parsererror").length>0)&&r&&"svg"===r.nodeName.toLowerCase()&&(r.hasAttribute("width")||r.setAttribute("width",String(e)),r.hasAttribute("height")||r.setAttribute("height",String(e)),o&&function(t,e){const o=[t,...Array.from(t.querySelectorAll("*"))];for(const t of o){const o=t.getAttribute("fill");"none"===o||"transparent"===o||(o||/^(path|circle|rect|polygon|polyline|ellipse|g|use|symbol)$/i.test(t.tagName))&&t.setAttribute("fill",e);const i=t.getAttribute("stroke");i&&"none"!==i&&"transparent"!==i&&t.setAttribute("stroke",e);const n=t.getAttribute("style");n&&t.setAttribute("style",n.replace(/fill:\s*(?!none|transparent)[^;]+;?/gi,`fill: ${e};`).replace(/stroke:\s*(?!none|transparent)[^;]+;?/gi,`stroke: ${e};`))}}(r,o),n=(new XMLSerializer).serializeToString(r))}catch{}const r=new Blob([n],{type:"image/svg+xml"}),s=URL.createObjectURL(r);return new Promise((t,e)=>{const o=new Image;o.onload=()=>{URL.revokeObjectURL(s),t(o)},o.onerror=t=>{URL.revokeObjectURL(s),e(t)},o.src=s})}const k={async register(t,e,o={}){if(!Array.isArray(e)||0===e.length)return;const i=o.size??64,n="object"==typeof o.badge&&null!==o.badge?o.badge:void 0,r=!1===o.badge?null:{color:n?.color??"#fdb81e",ringColor:n?.ringColor??"#FFFFFF",ringWidth:n?.ringWidth??2},s=o.iconColor??(r?"#162e51":void 0);await Promise.all(e.map(async e=>{const n=e.svg,a=n?null:function(t,e){const o=t?.uris;if(!Array.isArray(o)||0===o.length)return null;const i=t=>"image/svg+xml"===t?.mimeType||"svg-icon"===t?.resourceType,n=t=>{if(!Array.isArray(t)||0===t.length)return null;if(e){const o=t.find(t=>t?.locale===e);if(o?.uriPath)return o.uriPath}return t.find(t=>t?.uriPath)?.uriPath??null};for(const t of o){if(!i(t))continue;const e=n(t.locales);if(e)return e}for(const t of o){const e=n(t?.locales);if(e)return e}return null}(e,o.preferredLocale);if(!n&&!a)return;const l=e.iconId??`amenity-${e.id}`;if(t.hasImage(l))e.iconId=l;else try{const o=await async function(t,e,o){const i=2*e,n=await A(t,i,o.iconColor),r=document.createElement("canvas");r.width=i,r.height=i;const s=r.getContext("2d");if(!s)throw new Error("2d canvas context unavailable");if(o.badge){const t=i/2,e=i/2,r=2*o.badge.ringWidth,a=i/2-.5,l=Math.max(0,a-r);s.fillStyle=o.badge.ringColor,s.beginPath(),s.arc(t,e,a,0,2*Math.PI),s.fill(),s.fillStyle=o.badge.color,s.beginPath(),s.arc(t,e,l,0,2*Math.PI),s.fill();const c=Math.floor(1.15*l),u=(i-c)/2,d=(i-c)/2;s.drawImage(n,u,d,c,c)}else s.drawImage(n,0,0,i,i);return s.getImageData(0,0,i,i)}({url:a??void 0,inlineSvg:n??void 0},i,{iconColor:s,badge:r});t.hasImage(l)||t.addImage(l,o,{pixelRatio:2}),e.iconId=l}catch(t){F.warn("icon load failed",{amenityId:e.id,url:a,error:t?.message??String(t)})}}))}},M="poi-you-are-here-ring",S=[[16,14],[18,18],[20,24]];class P{map=null;rafId=null;startedAt=0;active=!1;start(t,e){this.active||e?.reducedMotion||(this.map=t,this.startedAt=performance.now(),this.active=!0,this.tick())}stop(){this.active=!1,null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null);const t=this.map;if(this.map=null,t)try{t.getLayer(M)&&(t.setPaintProperty(M,"circle-radius",void 0),t.setPaintProperty(M,"circle-opacity",void 0))}catch{}}tick=()=>{if(!this.active)return;const t=this.map;if(!t)return;const e=(performance.now()-this.startedAt)%2e3/2e3,o=.5-.5*Math.cos(e*Math.PI*2),i=function(t){const e=S;if(t<=e[0][0])return e[0][1];if(t>=e[e.length-1][0])return e[e.length-1][1];for(let o=1;o<e.length;o++){const[i,n]=e[o-1],[r,s]=e[o];if(t<=r)return n+(t-i)/(r-i)*(s-n)}return e[e.length-1][1]}(t.getZoom()),n=1+.55*o,r=.4-.25*o;try{t.getLayer(M)&&(t.setPaintProperty(M,"circle-radius",i*n),t.setPaintProperty(M,"circle-opacity",r))}catch{}this.rafId=requestAnimationFrame(this.tick)}}const C="units-outline-2d",T=["units-wall-extrusion","units-wall-custom-extrusion"];class z{getMap;is3dEnabled=!0;isUnits2dEnabled=!1;isFlatMode=!1;cachedExtrusionIds=null;extrusionOriginalVisibility=null;unitsExtrusionOriginalVisibility=null;unitsOutlineOriginalVisibility=null;constructor(t){this.getMap=t}onStyleData(){if(this.map){if(this.cachedExtrusionIds=null,!this.is3dEnabled){const t=this.listExtrusionLayerIds();this.setLayersVisibility(t,"none")}this.isUnits2dEnabled&&this.applyUnits2dVisibility(!0)}}set3dEnabled(t){const e=this.map;if(!e)return;const o=this.listExtrusionLayerIds();if(this.cachedExtrusionIds=o,!this.extrusionOriginalVisibility){const t={};o.forEach(o=>{try{const i=e.getLayoutProperty(o,"visibility")||"visible";t[o]=i}catch{t[o]="visible"}}),this.extrusionOriginalVisibility=t}if(t){const t=this.extrusionOriginalVisibility||{};o.forEach(o=>{const i=t[o]??"visible";try{e.getLayer(o)&&e.setLayoutProperty(o,"visibility",i)}catch{}})}else this.setLayersVisibility(o,"none");this.is3dEnabled=t,e.triggerRepaint()}toggle3d(){this.set3dEnabled(!this.is3dEnabled)}getIs3dEnabled(){return this.is3dEnabled}setUnits2dEnabled(t){const e=this.map;e&&(this.applyUnits2dVisibility(t),this.isUnits2dEnabled=t,e.triggerRepaint())}toggleUnits2d(){this.setUnits2dEnabled(!this.isUnits2dEnabled)}getIsUnits2dEnabled(){return this.isUnits2dEnabled}setFlatMode(t){this.map&&(t?(this.set3dEnabled(!1),this.setUnits2dEnabled(!0)):(this.setUnits2dEnabled(!1),this.set3dEnabled(!0)),this.isFlatMode=t)}toggleFlatMode(){this.setFlatMode(!this.isFlatMode)}getIsFlatMode(){return this.isFlatMode}applyUnits2dVisibility(t){const e=this.map;if(e){if(!this.unitsExtrusionOriginalVisibility){const t={};T.forEach(o=>{try{const i=e.getLayoutProperty(o,"visibility")||"visible";t[o]=i}catch{t[o]="visible"}}),this.unitsExtrusionOriginalVisibility=t}if(null==this.unitsOutlineOriginalVisibility)try{const t=e.getLayoutProperty(C,"visibility");this.unitsOutlineOriginalVisibility=t??"none"}catch{this.unitsOutlineOriginalVisibility="none"}if(e.getLayer(C)){const o=t?"visible":this.unitsOutlineOriginalVisibility??"none";try{e.setLayoutProperty(C,"visibility",o)}catch{}}if(t)T.forEach(t=>{if(e.getLayer(t))try{e.setLayoutProperty(t,"visibility","none")}catch{}});else{const t=this.unitsExtrusionOriginalVisibility||{};T.forEach(o=>{const i=t[o]??"visible";if(e.getLayer(o))try{e.setLayoutProperty(o,"visibility",i)}catch{}})}}}listExtrusionLayerIds(){const t=this.map;if(!t)return[];try{const e=t.getStyle(),o=e?.layers||[],i=o.filter(t=>"fill-extrusion"===t?.type).map(t=>t.id),n=Array.isArray(h)?h:[],r=[];return n.forEach(t=>{const e=o.find(e=>e.id===t);e&&"fill-extrusion"===e.type&&r.push(t)}),[...new Set([...i,...r])]}catch{return this.cachedExtrusionIds||[]}}setLayersVisibility(t,e){const o=this.map;o&&t.forEach(t=>{try{o.getLayer(t)&&o.setLayoutProperty(t,"visibility",e)}catch{}})}get map(){return this.getMap()}}function L(t,e){if(!t)return;const{center:o,zoom:i,pitch:n,bearing:r,animate:s,duration:a}=e;if(s){const e=t.getCenter(),s=o||[e.lng,e.lat],l=i??t.getZoom(),c=n??t.getPitch(),u=r??t.getBearing(),d="number"==typeof a?a:900;return void t.flyTo({center:s,zoom:l,pitch:c,bearing:u,duration:d,essential:!0})}o&&t.setCenter(o),void 0!==i&&t.setZoom(i),void 0!==n&&t.setPitch(n),void 0!==r&&t.setBearing(r)}function j(t){if(!t)return null;const e=t.getCenter(),o=(t,e=6)=>function(t,e=6){const o=Number(t.toFixed(e));return Object.is(o,-0)?0:o}(t,e);return{center:[o(e.lng),o(e.lat)],zoom:o(t.getZoom(),4),pitch:o(t.getPitch(),2),bearing:o(t.getBearing(),2)}}const E={async updatePOIs(t,e,o){const[i,n]=await Promise.all([o.getAmenities(e.id),o.getDestinations(e.id)]),r=E.buildPOIs(e,i,n,o.spriteKeys);s.setData(t,l,E.toFeatureCollection(r))},buildPOIs(t,e=[],o=[],i,n){if(!t?.id)return[];const r=t.mapId??t.id,s=[];for(const o of e||[]){if(!o.waypoints)continue;const e=o.iconId||O(o.svg,i)||void 0;for(const i of o.waypoints||[]){if(i.mapId!==r||!R(i.coordinates))continue;const[n,a]=i.coordinates,l=i.id??i._?.id;s.push({id:o.id,type:"amenity",name:o.name||"Amenity",coordinates:[n,a],iconId:e,floorId:t.id,amenityType:o.type,keywords:o.keywords||[],showLabel:!0,waypointId:l,waypoint:i})}}for(const e of o||[])if(e.waypoints)for(const o of e.waypoints||[]){if(o.mapId!==r||!R(o.coordinates))continue;const[i,n]=o.coordinates,a=o.id??o._?.id;s.push({id:e.id,type:"destination",name:e.name||"Destination",coordinates:[i,n],floorId:t.id,showLabel:!0,waypointId:a,waypoint:o})}return n&&String(n.floorId)===String(t.id)&&R(n.coordinates)&&s.push({id:"kiosk-you-are-here",type:"kiosk",name:"You are here",coordinates:n.coordinates,iconId:"YouAreHere",floorId:t.id,showLabel:!0,isYouAreHere:!0,heading:n.heading??null,waypointId:n.waypointId,waypoint:n.waypoint}),s},toFeatureCollection:t=>({type:"FeatureCollection",features:t.map(t=>{const e=t.heading;return{type:"Feature",geometry:{type:"Point",coordinates:t.coordinates},properties:{id:t.id,name:t.name,poiType:t.type,iconId:t.iconId,floorId:t.floorId,keywords:t.keywords,amenityType:t.amenityType,showLabel:!1!==t.showLabel,isYouAreHere:!0===t.isYouAreHere,heading:"number"==typeof e?e:null,hasHeading:"number"==typeof e}}})})};function B(t){return t.find(t=>t.isYouAreHere)||null}function R(t){return Array.isArray(t)&&t.length>=2}function O(t,e){if(!t||!e)return null;const o=/<svg[^>]*\bid\s*=\s*["']([^"']+)["']/i.exec(t),i=o?.[1];return i&&e.has(i)?i:null}function U(t){const e=t=>(t??"").toLowerCase(),o=e(t.name),i=(t.keywords||[]).map(t=>e(t)),n=t.extensors||{},r=e(n.type),s="kiosk"===o||o.includes("kiosk"),a=i.some(t=>t.includes("kiosk"));return s||a||"assistance"===r}class ${deps;routeAnimationFrame=null;routeAnimationStart=null;routeAnimationDurationMs=1200;routeActive=!1;routeBounds=null;lastRoutePoints=[];lastRouteFloorIds=[];constructor(t){this.deps=t}buildWayfindFeatureCollection(t){if(!t)return this.deps.warn?.("wayfind :: no result"),null;const e=H(t);if(e.length<2)return this.deps.warn?.("wayfind :: not enough coordinates to draw a route",{extractedCount:e.length}),null;const o=[];let i=null;for(const t of e){const e="number"==typeof t.mapId?t.mapId:null;i&&i.floorId===e?i.coords.push(t.coordinates):(i={floorId:e,coords:[t.coordinates]},o.push(i))}const n=[];for(let t=0;t<o.length;t++){const e=o[t];if(e.coords.length<2)continue;const i={segmentIndex:t,totalSegments:o.length};null!=e.floorId&&(i.floorId=e.floorId),n.push({type:"Feature",geometry:{type:"LineString",coordinates:e.coords},properties:i})}return 0===n.length?(this.deps.warn?.("wayfind :: every floor segment was < 2 points",{segmentCount:o.length}),null):(this.deps.log?.("wayfind :: extracted segments",{featureCount:n.length,floorIds:n.map(t=>t.properties?.floorId),pointCount:e.length}),{type:"FeatureCollection",features:n})}async wayfindBetweenWaypoints(t,e,o){const i=this.deps.getMap();if(!this.deps.getVenue()||!i)return this.deps.warn?.("wayfindBetweenWaypoints :: venue or map not ready"),null;const n={accessible:o?.accessible,avoidStairs:o?.avoidStairs};let r=null;try{r=await this.deps.computeRoute(t,e,n)}catch(t){return this.deps.warn?.("wayfind :: computeRoute failed",t),null}this.deps.log?.("wayfind :: result",r);const a=this.buildWayfindFeatureCollection(r);if(!a)return r;s.setData(i,u,a),this.routeBounds=function(t){let e=1/0,o=1/0,i=-1/0,n=-1/0,r=!1;for(const s of t.features)if("LineString"===s.geometry?.type)for(const[t,a]of s.geometry.coordinates)r=!0,t<e&&(e=t),t>i&&(i=t),a<o&&(o=a),a>n&&(n=a);return r?[[e,o],[i,n]]:null}(a),this.lastRoutePoints=H(r),this.lastRouteFloorIds=(a.features||[]).map(t=>t.properties?.floorId??null),this.deps.log?.("wayfind :: route source updated",{featureCount:a.features.length}),this.startRouteAnimation();const l=o?.centerMode??"route",c=o?.zoom??19,d=!0===this.deps.getReducedMotion?.();if("none"!==l){const t=[];for(const e of a.features)if("LineString"===e.geometry?.type&&Array.isArray(e.geometry.coordinates))for(const o of e.geometry.coordinates)t.push(o);if(t.length>=2){const e=t;if("destination"===l){const t=e[e.length-1];i.flyTo({center:t,zoom:c,pitch:45,bearing:0,animate:!d,duration:d?0:900})}else if("route"===l){const t=e.map(t=>t[0]),o=e.map(t=>t[1]),n=[[Math.min(...t),Math.min(...o)],[Math.max(...t),Math.max(...o)]];i.setMinPitch(0);const r=this.deps.getBoundsPadding();let s=null,a=0;for(const t of[1,.66,.4,.2,0])if(s=i.cameraForBounds(n,{padding:N(r,t),bearing:0}),s){a=t;break}const l=i.getContainer();this.deps.log?.("wayfind :: route fit",{requestedPadding:r,paddingScaleApplied:a,canvas:[l.clientWidth,l.clientHeight],camera:s?{zoom:s.zoom}:"no fit at any padding"}),s?i.easeTo({center:s.center,zoom:s.zoom-D,bearing:0,pitch:0,duration:d?0:800}):i.easeTo({pitch:0,bearing:0,duration:d?0:800})}}}return r}async navigateFromKioskToDestination(t){const e=this.deps.getMap(),o=this.deps.getVenue();if(!e||!o)return null;const i=this.deps.getYouAreHerePOI();if(!i||!i.waypoint)return this.deps.warn?.("navigateFromKioskToDestination :: no you-are-here waypoint available",i),null;const n=t.waypoint||t.waypoints?.[0];if(!n)return this.deps.warn?.("navigateFromKioskToDestination :: destination has no waypoint",t),null;this.deps.log?.("navigateFromKioskToDestination :: from kiosk to destination",{kioskWaypoint:i.waypoint,destWaypoint:n});const r=this.deps.getYouAreHereCoordinates()??i.waypoint?.coordinates,s=n.coordinates||n.xyz||n._?.coordinates,a=Array.isArray(s)&&s.length>=2?[Number(s[0]),Number(s[1])]:null;return r&&a?this.showRouteContext(r,a):this.deps.warn?.("navigateFromKioskToDestination :: could not derive endpoint coordinates",{fromCoords:r,rawDest:s}),this.wayfindBetweenWaypoints(i.waypoint,n,{centerMode:"route"})}getLastRoutePoints(){return this.lastRoutePoints}getLastRouteFloorIds(){return this.lastRouteFloorIds}clearRoute(){const t=this.deps.getMap();if(!t)return;this.stopRouteAnimation();if(s.setData(t,u,{type:"FeatureCollection",features:[]}),this.routeBounds=null,this.lastRoutePoints=[],this.lastRouteFloorIds=[],t.getMinPitch()<30){t.setMinPitch(30);const e=!0===this.deps.getReducedMotion?.();t.easeTo({pitch:45,duration:e?0:400})}this.deps.log?.("wayfind :: route cleared")}getActiveRouteBounds(){return this.routeActive?this.routeBounds:null}setPoiLayersVisible(t){const e=this.deps.getMap();if(!e)return;const o=t?"visible":"none";["poi-accessibility-icons","poi-destination-circles","poi-destination-labels","poi-entrance-exit-icons","poi-parking-icons","poi-other-amenity-icons"].forEach(t=>{e.getLayer(t)&&e.setLayoutProperty(t,"visibility",o)})}updateRouteEndpoints(t,e){const o=this.deps.getMap();if(!o)return;const i=o.getSource("route-endpoints");if(!i)return;const n={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{role:"source"}},{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{role:"destination"}}]};i.setData(n)}clearRouteEndpoints(){const t=this.deps.getMap();if(!t)return;const e=t.getSource("route-endpoints");if(!e)return;e.setData({type:"FeatureCollection",features:[]})}showRouteContext(t,e){this.updateRouteEndpoints(t,e)}hideRouteContext(){this.setPoiLayersVisible(!0),this.clearRouteEndpoints()}startRouteAnimation(){const t=this.deps.getMap();if(!t)return;if("undefined"==typeof window)return;if(null!=this.routeAnimationFrame&&(cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null),this.routeAnimationStart=performance.now(),this.routeActive=!0,!0===this.deps.getReducedMotion?.())return t.getLayer("route-line")&&(t.setPaintProperty("route-line","line-gradient",void 0),t.setPaintProperty("route-line","line-color","#007aff")),void(t.getLayer("route-halo")&&(t.setPaintProperty("route-halo","line-gradient",void 0),t.setPaintProperty("route-halo","line-color","#ffffff")));const e=this.deps.debug,o=t=>{const i=this.deps.getMap();if(!i||!this.routeActive||null==this.routeAnimationStart)return;const n=t-this.routeAnimationStart,r=Math.min(1,n/this.routeAnimationDurationMs),s=Math.max(.001,r);e&&this.deps.log?.("route animation frame",{t:r,clamped:s});const a=.001,l=Math.min(Math.max(s-.01,a),.998),c=Math.min(Math.max(s+.01,l+a),.999),u=["interpolate",["linear"],["line-progress"],0,"rgba(0,122,255,1.0)",l,"rgba(0,122,255,1.0)",c,"rgba(0,122,255,0.0)",1,"rgba(0,122,255,0.0)"],d=["interpolate",["linear"],["line-progress"],0,"rgba(255,255,255,0.7)",l,"rgba(255,255,255,0.7)",c,"rgba(255,255,255,0.0)",1,"rgba(255,255,255,0.0)"];i.getLayer("route-line")&&i.setPaintProperty("route-line","line-gradient",u),i.getLayer("route-halo")&&i.setPaintProperty("route-halo","line-gradient",d),this.routeAnimationFrame=r<1?requestAnimationFrame(o):null};this.routeAnimationFrame=requestAnimationFrame(o)}stopRouteAnimation(){this.routeActive=!1,null!=this.routeAnimationFrame&&"undefined"!=typeof window&&cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null,this.routeAnimationStart=null;const t=this.deps.getMap();t&&(t.getLayer("route-line")&&(t.setPaintProperty("route-line","line-gradient",void 0),t.setPaintProperty("route-line","line-color","#007aff")),t.getLayer("route-halo")&&(t.setPaintProperty("route-halo","line-gradient",void 0),t.setPaintProperty("route-halo","line-color","#ffffff")))}}const D=1;function N(t,e){return"number"==typeof t?t*e:{top:t.top*e,bottom:t.bottom*e,left:t.left*e,right:t.right*e}}function H(t){const e=[],o=t=>{if(!t)return;const o=t.coordinates||t.xyz||t._?.coordinates;if(!Array.isArray(o)||o.length<2)return;const i=Number(o[0]),n=Number(o[1]);Number.isFinite(i)&&Number.isFinite(n)&&e.push({coordinates:[i,n],mapId:"number"==typeof t.mapId?t.mapId:void 0,waypointId:"number"==typeof t.waypointId?t.waypointId:void 0,pathTypeId:"number"==typeof t.pathTypeId?t.pathTypeId:void 0,isEndpoint:!0===t.isEndpoint})};return Array.isArray(t)?t.length>0&&Array.isArray(t[0]?.points)?t[0].points.forEach(o):t.forEach(o):Array.isArray(t?.points)?t.points.forEach(o):Array.isArray(t?.path)?t.path.forEach(o):Array.isArray(t?.paths?.[0]?.points)&&t.paths[0].points.forEach(o),e}function V(t){const[e,o]=t.coordinates??[];return`${t.mapId}|${e}|${o}`}class J{getVenue;getFloors;getFloorById;logFn;constructor(t){this.getVenue=t.getVenue,this.getFloors=t.getFloors,this.getFloorById=t.getFloorById,this.logFn=t.log}get venue(){return this.getVenue()}log(...t){this.logFn&&this.logFn(...t)}loadForFloor(t){if(!t||!this.venue)return[];try{const e=this.venue.amenities?.getByMap(t.id)||[];return Array.isArray(e)?e.map(e=>{const o=e;return o.floorId=t.id,o}):[]}catch{return[]}}getAll(){return this.getFloors().flatMap(t=>this.loadForFloor(t))}getDistinct(){const t=new Map;for(const e of this.getFloors())for(const o of this.loadForFloor(e)){const e=String(o.id),i=t.get(e);if(!i){const i={id:o.id,name:o.name,svg:o.svg,uris:o.uris,iconId:o.iconId,keywords:o.keywords,type:o.type,extensors:o.extensors,waypoints:[...o.waypoints??[]]};t.set(e,i);continue}const n=new Set((i.waypoints??[]).map(V));for(const t of o.waypoints??[]){const e=V(t);n.has(e)||((i.waypoints??=[]).push(t),n.add(e))}}return Array.from(t.values())}getByFloorId(t){const e=this.getFloorById(t);return e?this.loadForFloor(e):[]}getAllKiosks(){return this.getAll().filter(t=>U(t))}getKioskForFloor(t){const e=this.getFloorById(t);if(!e)return null;return this.loadForFloor(e).find(t=>U(t))??null}logKioskForFloor(t){const e=this.getFloorById(t);if(!e)return;const o=this.getKioskForFloor(t);o?this.log("amenity :: kiosk found",{floorId:e.id,id:o.id,name:o.name,keywords:o.keywords,waypoints:o.waypoints,raw:o}):this.log("amenity :: kiosk not found on floor",{floorId:e.id})}}const K="poi-highlight-ring";class W{getMap;log;raf=null;constructor(t){this.getMap=t.getMap,this.log=t.log??(()=>{})}highlight(t){const e=this.getMap();e&&(s.setData(e,d,{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{}}]}),this.log("highlight :: set",t),this.startPulse())}clear(){this.stopPulse();const t=this.getMap();t&&s.setData(t,d,{type:"FeatureCollection",features:[]})}destroy(){this.stopPulse()}startPulse(){const t=this.getMap();if(!t||!t.getLayer(K))return;if(this.stopPulse(),"undefined"!=typeof window&&!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void this.applyRing(t,.35);const e=performance.now(),o=i=>{const n=(i-e)%1600/1600;this.applyRing(t,n),this.raf=requestAnimationFrame(o)};this.raf=requestAnimationFrame(o)}applyRing(t,e){t.getLayer(K)&&(t.setPaintProperty(K,"circle-radius",14+26*e),t.setPaintProperty(K,"circle-opacity",.45*(1-e)))}stopPulse(){null!=this.raf&&(cancelAnimationFrame(this.raf),this.raf=null)}}function Y(t){return t?`?locale=${encodeURIComponent(t)}`:""}y({enabled:!0,prefix:"MinuteMapsSDK"});class G{mode;proxyBaseUrl;direct;fetchImpl;tokenCache=null;constructor(t){const e="undefined"!=typeof window?window:globalThis,o=t.fetchImpl??e.fetch;if("function"!=typeof o)throw new Error("Fetch API is not available in this environment");this.fetchImpl=o.bind(e),this.mode=t.mode,this.proxyBaseUrl=("proxy"===t.mode?t.proxyBaseUrl:void 0)||"/api/jacs","direct"===t.mode?this.direct={host:this.normalizeHost(t.host),clientId:t.clientId,username:t.username,password:t.password}:this.direct=null}async getPolygonLayers(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/polygon-layer`,o=await this.getJson(e);return this.extractArray(o)}async getFloorMapTemplate3d(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor/${encodeURIComponent(String(t.floorId))}/map-template/3d`,o=await this.getJson(e);return this.extractArray(o)}async getFloors(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor`+Y(t.locale),o=await this.getJson(e);return this.extractArray(o)}async getVenueAll(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/all`,o=await this.getJson(e),i=o?.data||o?.result||o;if(!i||"object"!=typeof i)throw new Error("JACS venue/all response was not a JSON object");return i}async getVenue(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}`,o=await this.getJson(e),i=o?.venue||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS venue response was not a JSON object");return i}async getFloorMapGeojson(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor/${encodeURIComponent(String(t.floorId))}/map/geojson`,o=await this.getJson(e),i=o?.geojson||o?.data||o;if(!i||"FeatureCollection"!==i.type||!Array.isArray(i.features))throw new Error("JACS floor geojson did not look like a GeoJSON FeatureCollection");return i}async getBuildingFull(t){const e=new URLSearchParams;e.set("mapProfile",String(t.mapProfile??"public")),e.set("geojson",String(t.geojson??!0));const o=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/full?${e.toString()}`,i=await this.getJson(o),n=i?.data||i?.result||i;if(!n||"object"!=typeof n)throw new Error("JACS building full response was not a JSON object");return n}async getDestinations(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/destination`+Y(t.locale),o=await this.getJson(e);return this.extractArray(o)}async getAmenities(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/amenity`+Y(t.locale),o=await this.getJson(e);return this.extractArray(o)}async getBuildings(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building`,o=await this.getJson(e);return this.extractArray(o)}async getStylesheet3d(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/stylesheet/3d`,o=await this.getJson(e),i=o?.style||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS stylesheet response was not a JSON object");return i}invalidateToken(){this.tokenCache=null}async getJson(t){if("proxy"===this.mode){const e=this.proxyBaseUrl.replace(/\/+$/,""),o=t.startsWith("/")?t:`/${t}`,i=await this.fetchImpl(`${e}${o}`,{method:"GET",headers:{Accept:"application/json"}});if(!i.ok){const t=await this.safeReadText(i);throw new Error(`JACS proxy GET failed (${i.status} ${i.statusText}) :: ${t}`)}return await i.json()}const e=this.direct;if(!e)throw new Error("JacsProvider is not configured for direct mode");const o=await this.getJwtToken(),i=this.joinUrl(e.host,t),n=await this.fetchImpl(i,{method:"GET",headers:{Authorization:`Bearer ${o}`,Accept:"application/json"}});if(!n.ok){const t=await this.safeReadText(n);throw new Error(`JACS GET failed (${n.status} ${n.statusText}) :: ${t}`)}return await n.json()}extractArray(t){return(Array.isArray(t)?t:null)||(Array.isArray(t?.data)?t.data:null)||(Array.isArray(t?.items)?t.items:null)||(Array.isArray(t?.results)?t.results:null)||[]}async getJwtToken(){const t=this.direct;if(!t)throw new Error("getJwtToken should not be called in proxy mode");const e=Date.now(),o=this.tokenCache;if(o?.token&&e<o.expiresAtMs-3e4)return o.token;const i=this.joinUrl(t.host,"/auth/token"),n=new URLSearchParams;n.set("grant_type","password"),n.set("client_id",t.clientId),n.set("username",t.username),n.set("password",t.password);const r=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:n.toString()});if(!r.ok){const t=await this.safeReadText(r);throw new Error(`JACS auth failed (${r.status} ${r.statusText}) :: ${t}`)}const s=await r.json(),a=s?.access_token||s?.token||s?.jwt||s?.accessToken;if(!a)throw new Error("JACS auth response did not contain a token");const l=s?.expires_in??s?.expiresIn??s?.expires??s?.ttl,c="number"==typeof l?l:Number(l),u=Number.isFinite(c)&&c>0?c:600;return this.tokenCache={token:a,expiresAtMs:Date.now()+1e3*u},a}normalizeHost(t){return String(t||"").replace(/\/+$/,"")}joinUrl(t,e){const o=this.normalizeHost(t),i=String(e||"");return i?`${o}${i.startsWith("/")?"":"/"}${i}`:o}async safeReadText(t){try{return await t.text()}catch{return""}}}function _(t,e){return`${t}:${e}`}function q(t,e){const o=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(o*o+i*i)}function Z(t,e){for(const o of t.nodes.values())if(o.waypointId===e)return o;return null}function X(t){return`connector-${t}`}const Q={elevator:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <rect x="5" y="3" width="14" height="18" rx="1.5"/>\n <line x1="12" y1="3" x2="12" y2="21"/>\n <polyline points="8.5,8 9.75,6.5 11,8"/>\n <polyline points="13,16 14.25,17.5 15.5,16"/>\n </svg>',stairs:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <polyline points="3,21 7,21 7,17 11,17 11,13 15,13 15,9 19,9 19,5 21,5"/>\n </svg>',escalator:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="3" y1="21" x2="21" y2="5"/>\n <circle cx="6" cy="19" r="1.25"/>\n <circle cx="12" cy="13" r="1.25"/>\n <circle cx="18" cy="7" r="1.25"/>\n </svg>'};function tt(t){return"elevator"===t?"Elevator":"escalator"===t?"Escalator":"Stairs"}const et=y({enabled:!0,prefix:"MinuteMapsSDK jacs"});function ot(t){return null!=t&&"object"==typeof t?t.id:t}function it(t,e){const o=[];for(const t of e)"number"==typeof t?.id&&"number"==typeof t?.mapId&&null!=t?.x&&null!=t?.y&&o.push({id:t.id,mapId:t.mapId,status:!1!==t.status,coordinates:[Number(t.x),Number(t.y)],geo:Array.isArray(t.coordinates)?[t.coordinates[0],t.coordinates[1]]:null});const i=[];for(const e of Array.isArray(t?.paths)?t.paths:[]){const t=e?.waypoints??e?.waypointIds;"number"==typeof e?.id&&Array.isArray(t)&&t.length>=2&&t.every(t=>"number"==typeof t)&&i.push({id:e.id,pathTypeId:"number"==typeof e.pathTypeId?e.pathTypeId:0,direction:"number"==typeof e.direction?e.direction:0,status:!1!==e.status,waypointIds:t.slice(),extensors:e.extensors})}return function(t){const e=new Map,o=new Map,i=new Map,n=new Map;for(const e of t.pathTypes)i.set(e.id,e);for(const i of t.waypoints){if(!i.status)continue;const t=_(i.mapId,i.id),r={key:t,waypointId:i.id,mapId:i.mapId,pixel:[i.coordinates[0],i.coordinates[1]],geo:i.geo};e.set(t,r),o.set(t,[]);const s=n.get(i.mapId)??[];s.push(t),n.set(i.mapId,s)}const r=new Map;for(const t of e.values())r.set(t.waypointId,t.key);for(const i of t.paths){if(!i.status)continue;const t=i.waypointIds;if(Array.isArray(t)&&!(t.length<2))for(let n=1;n<t.length;n++){const s=t[n-1],a=t[n];if(s===a)continue;const l=r.get(s),c=r.get(a);if(!l||!c)continue;const u=e.get(l),d=e.get(c),p=q(u.pixel,d.pixel),f={id:i.id,fromKey:l,toKey:c,pathTypeId:i.pathTypeId,pixelLength:p,meta:i.extensors&&Object.keys(i.extensors).length?i.extensors:void 0};o.get(l).push({neighbor:c,edge:f}),0===i.direction&&o.get(c).push({neighbor:l,edge:f})}}return{nodes:e,adjacency:o,pathTypes:i,nodesByMapId:n}}({waypoints:o,paths:i,pathTypes:(Array.isArray(t?.pathTypes)?t.pathTypes:[]).filter(t=>"number"==typeof t?.id).map(t=>({id:t.id,name:t.name??"",description:t.description}))})}class nt{config;jacs;floors=[];buildingId=null;destinationsByMapId=new Map;amenitiesByMapId=new Map;mapLabelsByMapId=new Map;zonesByMapId=new Map;zonesByDestinationId=new Map;venueLike=null;wayfindingGraph=null;async init(t){this.config=t;const e=t.jacs;if(!e?.mode)throw new Error("config.jacs.mode is required");if("proxy"!==e.mode){if(!e.host)throw new Error("config.jacs.host is required (direct mode)");if(!e.auth?.clientId)throw new Error("config.jacs.auth.clientId is required (direct mode)");if(!e.auth?.username)throw new Error("config.jacs.auth.username is required (direct mode)");if(!e.auth?.password)throw new Error("config.jacs.auth.password is required (direct mode)");this.jacs=new G({mode:"direct",host:e.host,clientId:e.auth.clientId,username:e.auth.username,password:e.auth.password})}else this.jacs=new G({mode:"proxy",proxyBaseUrl:e.proxyBaseUrl||"/api/jacs"})}async loadVenue(){const t=this.config.jmap.customerId,e=this.config.jmap.venueId;if(null==t)throw new Error("config.jmap.customerId is required");if(null==e)throw new Error("config.jmap.venueId is required");const o=await this.jacs.getVenueAll({customerId:t,venueId:e}),i=Array.isArray(o?.buildings)?o.buildings:[],n=i[0],r=n?.id??n?.buildingId;if(!n||!r)throw new Error("No buildings found for this venue in /all response");this.buildingId=r;const s=Array.isArray(o?.waypoints)?o.waypoints:[],a=Array.isArray(o?.destinations)?o.destinations:[],l=Array.isArray(o?.amenities)?o.amenities:[],c=new Map;for(const t of s){const e=t?.mapId;if(null==e)continue;const o=c.get(e)??[];o.push(t),c.set(e,o)}const u=Array.isArray(n?.floors)?n.floors:[],d=n?.defaultFloorId,p=u.map(t=>{const e=t.map?.id??t.mapId;return{id:t.id,mapId:e,name:t.name??t.shortName??String(t.id),sequence:t.level??t.preference,isDefault:t.id===d,geojson:void 0,mapTemplate3d:[],_waypoints:null!=e?c.get(e)??[]:[]}});this.floors=p;const f=new Map;for(const t of p)null!=t.mapId&&f.set(t.mapId,t.id);const h=o?.venue?.coordinates,g=new Map;for(const t of u){const e=t?.map?.id??t?.mapId,o="string"==typeof t?.map?.svg?t.map.svg:"";if(null==e||!o)continue;const i=/viewBox\s*=\s*["']([^"']+)["']/i.exec(o);if(!i)continue;const n=i[1].trim().split(/\s+/).map(Number);if(4!==n.length||n.some(t=>!Number.isFinite(t)))continue;const[,,r,s]=n;r>0&&s>0&&g.set(e,{width:r,height:s})}const y=(t,e,o)=>{if(!h)return null;const i=g.get(t);if(!i)return null;return[h.topLng+e/i.width*(h.bottomLng-h.topLng),h.topLat+o/i.height*(h.bottomLat-h.topLat)]},m=new Map;for(const t of s){const e=t?.id;if(null!=e){if(!Array.isArray(t.coordinates)&&null!=t.x&&null!=t.y&&null!=t.mapId){const e=y(t.mapId,Number(t.x),Number(t.y));e&&(t.coordinates=e)}m.set(e,t)}}this.wayfindingGraph=it(o,s);let w=null;const b=this.config?.jmap?.deviceId,I=Array.isArray(o?.devices)?o.devices:[],v=t=>null==t?.id?null:s.find(e=>Array.isArray(e?.deviceIds)&&e.deviceIds.includes(t.id))??null;let x=null;null!=b&&""!==b&&(x=I.find(t=>String(t?.id)===String(b)||t?.uuid===b)??null,x||et.warn("configured kiosk deviceId not found in this venue; falling back to a placed device",{deviceId:b}));let F=v(x);if(!F){const t=I.find(t=>v(t));t&&(null!=b&&""!==b?et.warn("anchoring You-are-here to a placed device as fallback",{configured:b,using:t.name??t.id}):et.debug("no kiosk deviceId configured; anchoring to placed device",{using:t.name??t.id}),x=t,F=v(t))}if(F&&Array.isArray(F.coordinates)){const t=x?.heading,e="number"==typeof t&&Number.isFinite(t)?t:null;w={waypointId:F.id,floorId:f.get(F.mapId)??F.mapId,coordinates:F.coordinates,deviceName:x?.name,heading:e,waypoint:F}}else I.length>0&&et.warn("venue has device(s) but none are placed on a waypoint; no You-are-here anchor");const A=t=>Array.isArray(t)?t.map(t=>t&&"object"==typeof t?t:m.get(t)).filter(Boolean):[];for(const t of l)t.waypoints=A(t?.waypoints);for(const t of a)t.waypoints=A(t?.waypoints);const k=new Map;for(const t of Array.isArray(o?.pathTypes)?o.pathTypes:[]){const e=(t?.name??"").toString().toLowerCase();e&&(/elev|lift/.test(e)?k.set(t.id,"elevator"):/escalat/.test(e)?k.set(t.id,"escalator"):/stair|step/.test(e)&&k.set(t.id,"stairs"))}const M=Array.isArray(o?.paths)?o.paths:[];for(const t of M){if(!1===t?.status)continue;const e=(t?.name??"").toString().toLowerCase();let o;if(/elev|lift/.test(e)?o="elevator":/escalat/.test(e)?o="escalator":/stair|step/.test(e)&&(o="stairs"),o||"number"!=typeof t.pathTypeId||(o=k.get(t.pathTypeId)),!o)continue;const i=Array.isArray(t.waypoints)?t.waypoints:t.waypointIds;if(!Array.isArray(i)||0===i.length)continue;const n=A(i);if(0===n.length)continue;const r={id:`connector-${o}-${t.id}`,name:t.name&&String(t.name).trim()?String(t.name):tt(o),type:tt(o),svg:Q[o],iconId:X(o),keywords:[o],waypoints:n,_connector:!0};l.push(r)}this.amenitiesByMapId.clear();for(const t of l)for(const e of t?.waypoints??[]){const o=e?.mapId;if(null==o)continue;const i=f.get(o)??o,n=this.amenitiesByMapId.get(i)??[];n.push(t),this.amenitiesByMapId.set(i,n)}this.destinationsByMapId.clear();for(const t of a)for(const e of t?.waypoints??[]){const o=e?.mapId;if(null==o)continue;const i=f.get(o)??o,n=this.destinationsByMapId.get(i)??[];n.push(t),this.destinationsByMapId.set(i,n)}this.mapLabelsByMapId.clear();const S=Array.isArray(o?.mapLabels)?o.mapLabels:[],P=p.map(t=>t.id);for(const t of S){if(!1===t?.status)continue;const e=t?.name??"",o=Array.isArray(t?.instances)?t.instances:[];for(const i of o){const o=i?.mapId,n=Number(i?.xPosition),r=Number(i?.yPosition);if(null==o||!Number.isFinite(n)||!Number.isFinite(r))continue;const s=y(o,n,r);if(!s)continue;const a={id:i.id,labelId:t.id,name:e,coordinates:s,mapId:o,rotation:"number"==typeof i.rotation?i.rotation:0,allLevels:1===i?.allLevels||!0===i?.allLevels},l=a.allLevels?P:[f.get(o)??o];for(const t of l){const e=this.mapLabelsByMapId.get(t)??[];e.push(a),this.mapLabelsByMapId.set(t,e)}}}this.zonesByMapId.clear(),this.zonesByDestinationId.clear();const C=Array.isArray(o?.zones)?o.zones:[];for(const t of C){if(!1===t?.status)continue;const e=t?.mapId;if(null!=e){const o=f.get(e)??e,i=this.zonesByMapId.get(o)??[];i.push(t),this.zonesByMapId.set(o,i)}const o=Array.isArray(t?.destinationIds)?t.destinationIds:Array.isArray(t?.destinations)?t.destinations:[];for(const e of o){const o="object"==typeof e&&null!=e?e.id:e;if(null==o)continue;const i=this.zonesByDestinationId.get(o)??[];i.push(t),this.zonesByDestinationId.set(o,i)}}const T=o?.venue??{};if(this.venueLike={...T,floors:p,polygonLayers:[],destinations:{items:[...a],getByMap:t=>this.destinationsByMapId.get(ot(t))??[]},amenities:{items:[...l],getByMap:t=>this.amenitiesByMapId.get(ot(t))??[]},mapLabels:{items:[...S],getByMap:t=>this.mapLabelsByMapId.get(ot(t))??[]},zones:{items:[...C],getByMap:t=>this.zonesByMapId.get(ot(t))??[],getByDestination:t=>this.zonesByDestinationId.get(ot(t))??[]},buildings:{items:[...i],getAllFloors:()=>this.floors},styleSheet:null,kioskWaypoint:w},this.config?.jmap?.locale)try{await this.applyLocale(this.config.jmap.locale)}catch{}return this.venueLike}async applyLocale(t){if(!t)return;if(!this.venueLike)return;const e=this.config.jmap.customerId,o=this.config.jmap.venueId,i=this.buildingId;if(null!=e&&null!=o&&null!=i)try{const[n,r,s]=await Promise.all([this.jacs.getDestinations({customerId:e,venueId:o,locale:t}),this.jacs.getAmenities({customerId:e,venueId:o,locale:t}),this.jacs.getFloors({customerId:e,venueId:o,buildingId:i,locale:t})]),a=t=>{const e=new Map;for(const o of t)null!=o?.id&&e.set(o.id,o);return e},l=a(n),c=a(r),u=a(s),d=(t,e)=>{e&&(null!=e.name&&(t.name=e.name),null!=e.description&&(t.description=e.description))};for(const t of this.venueLike.destinations?.items??[])d(t,l.get(t?.id));for(const t of this.venueLike.amenities?.items??[])d(t,c.get(t?.id));for(const t of this.floors)d(t,u.get(t.id))}catch(e){throw et.warn("locale merge failed; staying on prior locale",{locale:t,e:e}),e}}async ensureFloorGeojson(t){if(t.geojson)return;const e=this.config.jmap.customerId,o=this.config.jmap.venueId;try{const i=await this.jacs.getFloorMapGeojson({customerId:e,venueId:o,buildingId:this.buildingId,floorId:t.id});t.geojson=function(t){return(t?.type?t:t?.data)??null}(i)}catch(e){et.warn("floor geojson fetch failed",{floorId:t.id,e:e})}}async preloadRemainingFloors(){const t=this.floors.filter(t=>!t.geojson);0!==t.length&&(await Promise.all(t.map(t=>this.ensureFloorGeojson(t))),et.debug("preloaded geojson for remaining floors",{count:t.length}))}async getFloors(){return this.floors}async getAmenities(t){return this.amenitiesByMapId.get(t)??[]}async getDestinations(t){return this.destinationsByMapId.get(t)??[]}getWayfindingGraph(){return this.wayfindingGraph}}function rt(t,e,o,i){if(!t.nodes.has(e)||!t.nodes.has(o))return null;if(e===o)return{keys:[e],cost:0};const n=new Map,r=new Map;n.set(e,0);const s=new st((t,e)=>t.cost-e.cost);for(s.push({key:e,cost:0});s.size()>0;){const{key:e,cost:a}=s.pop();if(e===o)break;if(a>(n.get(e)??1/0))continue;const l=t.adjacency.get(e);if(l)for(const{neighbor:t,edge:o}of l){const l=i(o);if(!Number.isFinite(l)||l<0)continue;const c=a+l;c<(n.get(t)??1/0)&&(n.set(t,c),r.set(t,e),s.push({key:t,cost:c}))}}if(!n.has(o))return null;const a=[];let l=o;for(;null!=l;)if(a.unshift(l),l=r.get(l),void 0===l&&a[0]!==e)return null;return{keys:a,cost:n.get(o)}}class st{compare;data=[];constructor(t){this.compare=t}size(){return this.data.length}push(t){this.data.push(t),this.bubbleUp(this.data.length-1)}pop(){if(0===this.data.length)return;const t=this.data[0],e=this.data.pop();return this.data.length>0&&(this.data[0]=e,this.sinkDown(0)),t}bubbleUp(t){const e=this.data[t];for(;t>0;){const o=t-1>>1;if(this.compare(e,this.data[o])>=0)break;this.data[t]=this.data[o],t=o}this.data[t]=e}sinkDown(t){const e=this.data.length,o=this.data[t];for(;;){const i=2*t+1,n=i+1;let r=-1;if(i<e&&this.compare(this.data[i],o)<0&&(r=i),n<e&&this.compare(this.data[n],-1===r?o:this.data[i])<0&&(r=n),-1===r)break;this.data[t]=this.data[r],t=r}this.data[t]=o}}const at=new Set([]),lt=new Set([]),ct=new Set([]);function ut(t){const e=Boolean(t.accessible),o=Boolean(t.avoidStairs);return t=>{const i=t.pixelLength;if(o&&dt(t))return 1/0;if(e&&function(t){return!1===t.meta?.accessible||dt(t)}(t))return 1/0;if(dt(t))return 1.5*i;if(e){if(function(t){return!!lt.has(t.pathTypeId)||!0===t.meta?.ramp}(t))return.95*i;if(function(t){return!!ct.has(t.pathTypeId)||!0===t.meta?.elevator}(t))return.95*i}return i}}function dt(t){return!!at.has(t.pathTypeId)||!0===t.meta?.stairs}function pt(t){if(!t)return null;const e=t.coordinates??t.xyz??t._?.coordinates;if(!Array.isArray(e)||e.length<2)return null;const o=Number(e[0]),i=Number(e[1]);return Number.isFinite(o)&&Number.isFinite(i)?[o,i]:null}class ft{deps;warn;constructor(t){this.deps=t,this.warn=t.warn??((t,e)=>console.warn(`[wayfinding] ${t}`,e??""))}async init(t){}async wayfindBetweenWaypoints(t){const{from:e,to:o,options:i}=t,n=this.deps.getGraph(),r=pt(e),s=pt(o);if(!n)return this.warn("graph not ready"),ht(r,s);const a=gt(n,e),l=gt(n,o);if(!a||!l)return this.warn("could not resolve start/end waypoint to a graph node",{fromId:e?.id,toId:o?.id}),ht(r,s);const c=rt(n,a.key,l.key,ut(i??{}));if(!c)return this.warn("no path found",{from:a.key,to:l.key}),ht(r,s);const u=new Map;for(let t=1;t<c.keys.length;t++){const e=c.keys[t-1],o=c.keys[t],i=(n.adjacency.get(e)??[]).find(t=>t.neighbor===o);i&&u.set(o,i.edge.pathTypeId)}const d=[],p=c.keys.length-1;for(let t=0;t<=p;t++){const e=c.keys[t],o=n.nodes.get(e);let i=o?.geo??null;0===t&&r&&(i=r),t===p&&s&&(i=s),i&&d.push({coordinates:i,mapId:o?.mapId,waypointId:o?.waypointId,pathTypeId:0===t?void 0:u.get(e),isEndpoint:0===t||t===p})}return d.length<2?(this.warn("route nodes had no projected coordinates",{keys:c.keys.length}),ht(r,s)):{points:d}}}function ht(t,e){return t&&e?{points:[{coordinates:t,isEndpoint:!0},{coordinates:e,isEndpoint:!0}]}:null}function gt(t,e){if(!e||null==e.id)return null;const o="number"==typeof e.id?e.id:Number(e.id);if(!Number.isFinite(o))return null;if("number"==typeof e.mapId){const i=t.nodes.get(_(e.mapId,o));if(i)return i}return Z(t,o)}function yt(t){const{graph:e,kiosk:o}=t;if(!e||!o?.id)return null;const n=function(t,e){if(null==e?.id)return null;const o="number"==typeof e.id?e.id:Number(e.id);if(!Number.isFinite(o))return null;if("number"==typeof e.mapId){const i=t.nodes.get(_(e.mapId,o));if(i)return i}return Z(t,o)}(e,o);if(!n)return null;const r=function(t){if(null==t)return null;if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);return Number.isFinite(e)?e:null}if("id"in t&&null!=t.id){const e="number"==typeof t.id?t.id:Number(t.id);return Number.isFinite(e)?e:null}if("waypoints"in t&&Array.isArray(t.waypoints)&&t.waypoints.length>0){const e=t.waypoints[0];if(null==e)return null;if("number"==typeof e)return e;if("string"==typeof e){const t=Number(e);return Number.isFinite(t)?t:null}if("object"==typeof e&&null!=e.id){const t="number"==typeof e.id?e.id:Number(e.id);return Number.isFinite(t)?t:null}}return null}(t.target);if(null==r)return null;const s=("object"==typeof t.target&&"mapId"in t.target&&"number"==typeof t.target.mapId?e.nodes.get(_(t.target.mapId,r)):null)??Z(e,r);if(!s)return null;const a=rt(e,n.key,s.key,t=>t.pixelLength);if(!a)return null;let l=0;for(let t=1;t<a.keys.length;t++){const o=e.nodes.get(a.keys[t-1])?.geo,n=e.nodes.get(a.keys[t])?.geo;o&&n&&(l+=i.distance(i.point(o),i.point(n),{units:"meters"}))}const c=t.options?.walkingSpeedMps??1.2,u=Math.max(1,Math.round(l/c));return{meters:Math.round(l),seconds:u,pathNodeCount:a.keys.length}}function mt(t,e,o){const{startIdx:n,endIdx:r,floorId:s}=e;if(r<=n)return[];const a=[];for(let e=n;e<r;e++){const o=t[e].coordinates,n=t[e+1].coordinates,r=i.distance(i.point(o),i.point(n),{units:"meters"}),s=i.bearing(i.point(o),i.point(n));a.push({fromIdx:e,toIdx:e+1,meters:r,bearing:s})}if(0===a.length)return[];const l=[];for(let t=0;t<a.length;t++){const e=a[t];if(0===t){l.push({startIdx:e.fromIdx,endIdx:e.toIdx,meters:e.meters,bearing:e.bearing,turnInto:null});continue}const o=l[l.length-1],i=bt(o.bearing,e.bearing);if(null==i){o.endIdx=e.toIdx,o.meters+=e.meters;const t=o.meters;o.bearing=t>0?o.bearing+wt(o.bearing,e.bearing)*(e.meters/t):e.bearing}else l.push({startIdx:e.fromIdx,endIdx:e.toIdx,meters:e.meters,bearing:e.bearing,turnInto:i})}const c=[];for(let e=0;e<l.length;e++){const i=l[e],n=Math.max(0,Math.round(i.meters)),r=0===e,a=e===l.length-1;if(r&&o.isFirstLeg)c.push({type:"depart",floorId:s,pointRange:[i.startIdx,i.endIdx],distanceMeters:n,text:xt(n,o.ctx.floorName(s??-1))});else if(i.turnInto){const e=vt(t[i.startIdx],s,o.ctx),r=n,a="uturn"===i.turnInto?"u-turn":"left"===i.turnInto?"turn-left":"turn-right";c.push({type:a,floorId:s,pointRange:[i.startIdx,i.endIdx],distanceMeters:r,landmark:e??void 0,text:At(a,e,r)})}else c.push({type:"continue",floorId:s,pointRange:[i.startIdx,i.endIdx],distanceMeters:n,text:Ft(n)});if(a&&o.isLastLeg){const e=c.pop(),n=o.ctx.destinationName;It(t,i.endIdx),c.push({type:"arrive",floorId:s,pointRange:e.pointRange,distanceMeters:e.distanceMeters,landmark:n,text:Mt(n)})}}return c}function wt(t,e){let o=(e-t+540)%360-180;return-180===o&&(o=180),o}function bt(t,e){const o=wt(t,e),i=Math.abs(o);return i<30?null:i>=150?"uturn":o<0?"left":"right"}function It(t,e){return"ahead"}function vt(t,e,o){const n=[o.destinations,o.amenities,o.mapLabels];let r=null;const s=i.point(t.coordinates);for(const t of n)if(t?.length){for(const o of t){if(!o?.name)continue;if("number"==typeof o.mapId&&null!=e&&o.mapId!==e)continue;const t=o.coordinates||o.geo;if(!t||t.length<2)continue;const n=i.distance(s,i.point(t),{units:"meters"});n>5||(!r||n<r.distance)&&(r={name:o.name,distance:n})}if(r)return r.name}return null}function xt(t,e){return e?`Head out on ${e} — walk ${t} m straight ahead`:`Walk ${t} m straight ahead`}function Ft(t){return`Continue ${t} m`}function At(t,e,o){return`${"u-turn"===t?"Make a U-turn":"turn-left"===t?"Turn left":"Turn right"}${e?` at ${e}`:""} and continue ${o} m`}function kt(t,e,o){const i="elevator"===t?"Take the elevator":"escalator"===t?"Take the escalator":"Take the stairs";return e?`${i} to ${e}`:i}function Mt(t,e){return`You've arrived${t?` — ${t}`:""}`}class St{handlers=new Map;on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){e?this.handlers.get(t)?.delete(e):this.handlers.delete(t)}emit(t,e){this.handlers.get(t)?.forEach(t=>{try{t(e)}catch{}})}}var Pt={version:8,name:"Hospital Indoor Mapping - Hybrid Style Healthcare Compliant",metadata:{description:"Accessibility-focused hospital navigation with proper healthcare standards",author:"Hospital Mapping Team",version:"7.1.0"},sprite:"http://localhost:4000/sprites/sprite",glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:{protomaps:{type:"vector",url:"pmtiles://https://jacsdevtiles-gjgbejbpdzbgcge8.z01.azurefd.net/pmtiles/base/usa.pmtiles",attribution:"© OpenStreetMap contributors"},"indoor-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"accessibility-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"unit-walls":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"route-data":{type:"geojson",data:{type:"FeatureCollection",features:[]},lineMetrics:!0},"route-endpoints":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-highlight-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"map-labels-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"route-active-step":{type:"geojson",data:{type:"FeatureCollection",features:[]}}},layers:[{id:"background",type:"background",paint:{"background-color":"#f0f0f0"}},{id:"basemap-earth",type:"fill",source:"protomaps","source-layer":"earth",paint:{"fill-color":"#EAE2D0"}},{id:"basemap-landuse-park",type:"fill",source:"protomaps","source-layer":"landuse",filter:["in",["get","kind"],["literal",["park","forest","wood","nature_reserve","grass","garden","playground","cemetery","golf_course"]]],paint:{"fill-color":"#cbe0b6","fill-opacity":["interpolate",["linear"],["zoom"],14,.95,18,.8]}},{id:"basemap-water",type:"fill",source:"protomaps","source-layer":"water",paint:{"fill-color":"#c2dbf2"}},{id:"basemap-roads-minor",type:"line",source:"protomaps","source-layer":"roads",minzoom:13,filter:["in",["get","kind"],["literal",["minor_road","path","service","other"]]],paint:{"line-color":"#FFFFFF","line-width":["interpolate",["linear"],["zoom"],13,.5,16,1.5,19,4],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"basemap-roads-major",type:"line",source:"protomaps","source-layer":"roads",minzoom:10,filter:["in",["get","kind"],["literal",["highway","major_road","medium_road"]]],paint:{"line-color":"#ecc97e","line-width":["interpolate",["linear"],["zoom"],10,.5,14,1.5,18,6],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"pattern-water",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Water"],paint:{"fill-color":"#cfe1ec","fill-opacity":.6}},{id:"pattern-grass",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Grass"],paint:{"fill-color":"#d2e0c6","fill-opacity":.5}},{id:"pattern-trees",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Trees"],paint:{"fill-color":"#cdd9c9","fill-opacity":.4}},{id:"pattern-pavement",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Pavement"],paint:{"fill-color":"#E0E0E0","fill-opacity":.6}},{id:"pattern-outdoor-terrace",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-OutdoorTerrace"],paint:{"fill-color":"#cabfb6","fill-opacity":.3}},{id:"parking-lots",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Parking-Lots"],paint:{"fill-color":"#e0e0dd","fill-opacity":.5}},{id:"parking-lots-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Parking-Lots"],paint:{"line-color":"#b0b0ad","line-width":1,"line-dasharray":[3,2]}},{id:"boundary-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#FAF3E2","fill-opacity":1}},{id:"building-roof-fill",type:"fill",source:"indoor-data",minzoom:15.8,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#162e51","fill-opacity":["interpolate",["linear"],["zoom"],15.8,0,16.5,1]}},{id:"corridors-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"fill-color":"#F0E6D1"}},{id:"accessible-routes",type:"line",source:"accessibility-data",minzoom:16.5,filter:["==",["get","accessible"],!0],paint:{"line-color":"#2E7D32","line-width":["interpolate",["linear"],["zoom"],15,2,18,3,20,4],"line-dasharray":[.5,1],"line-opacity":.7}},{id:"units-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],paint:{"fill-color":["case",["has","category"],["match",["get","category"],"healthcare","#73b3e7","surgical","#73b3e7","waiting","#73b3e7","diagnostic","#97d4ea","amenities","#97d4ea","emergency","#f2938c","retail","#fee685","fnb","#fee685","admin","#dfe1e2","staff","#dfe1e2","security","#dfe1e2","#73b3e7"],"#73b3e7"],"fill-opacity":["interpolate",["linear"],["zoom"],15,.85,17,.92,19,.95]}},{id:"units-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],layout:{visibility:"none","line-join":"round","line-cap":"round"},paint:{"line-color":"#162e51","line-opacity":.9,"line-width":["interpolate",["linear"],["zoom"],16,.8,18,1.4,20,2.2]}},{id:"backofhouse-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-color":"#e6e6e2","fill-opacity":.7}},{id:"backofhouse-pattern",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"line-color":"#c4c4c4","line-width":.5,"line-opacity":.4}},{id:"backofhouse-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#b0b1b5","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"restrooms-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-color":"#5f9070","fill-opacity":1}},{id:"restrooms-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#3f5d4a","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"obstacles-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-color":"#E8E9ED","fill-opacity":.85}},{id:"obstacles-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#B0B1B5","line-width":["interpolate",["linear"],["zoom"],16,.5,18,.9,20,1.2],"line-opacity":.9}},{id:"escalators-stairs-elevators",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-color":"#a9aeb1","fill-opacity":1}},{id:"escalators-stairs-elevators-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#6f7780","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"exits-doors",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Exits","Doors","Exit","Door"]]],paint:{"fill-color":"#cdd9c9","fill-opacity":.6}},{id:"kiosks-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Kiosks"],paint:{"fill-color":"#ffe396","fill-opacity":.7}},{id:"pattern-lounge",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Lounge"],paint:{"fill-color":"#ddd2e0","fill-opacity":.5}},{id:"pattern-indoor-foodcourt",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-IndoorFoodcourt"],paint:{"fill-color":"#f3e4c4","fill-opacity":.6}},{id:"corridors-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"line-color":"#BCAAA4","line-width":["interpolate",["linear"],["zoom"],15,.5,18,1,20,1.5]}},{id:"boundary-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"line-color":"#263238","line-width":["interpolate",["linear"],["zoom"],12,2,15,2.5,18,3,20,3.5],"line-opacity":["interpolate",["linear"],["zoom"],12,.7,17,.85,18,1]}},{id:"building-roof-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#c8a85a","line-width":["interpolate",["linear"],["zoom"],15,1.5,18,2,20,2.5],"line-opacity":.55}},{id:"interior-parking-lots",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-color":"#757575","fill-opacity":.8}},{id:"interior-parking-lots-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"line-color":"#616161","line-width":1.5}},{id:"building-extrusion",type:"fill-extrusion",source:"indoor-data",filter:["==",["get","featureType"],"Boundary"],paint:{"fill-extrusion-color":"#162e51","fill-extrusion-height":15,"fill-extrusion-base":0,"fill-extrusion-opacity":["interpolate",["linear"],["zoom"],15.8,1,16.5,0]}},{id:"units-wall-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["all",["==",["get","featureType"],"UnitWalls"],["!",["has","custom_height"]]],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,["case",["==",["get","wallKind"],"interior"],.5,1],17.5,["case",["==",["get","wallKind"],"interior"],.7,1.4],18.2,["case",["==",["get","wallKind"],"interior"],.9,1.6]],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"units-wall-custom-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["has","custom_height"],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"corridors-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],layout:{visibility:"none"},paint:{"fill-extrusion-color":"#FFF8E1","fill-extrusion-height":["step",["zoom"],0,18,3.2],"fill-extrusion-base":0,"fill-extrusion-opacity":["step",["zoom"],0,18,.85]}},{id:"backofhouse-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-extrusion-color":"#e6e6e2","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"restrooms-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-extrusion-color":"#5f9070","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.95}},{id:"obstacles-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-extrusion-color":"#E8E9ED","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,.4,17.5,.6,18.2,.8],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"escalators-stairs-elevators-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-extrusion-color":"#a9aeb1","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":.9}},{id:"interior-parking-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-extrusion-color":"#757575","fill-extrusion-height":["interpolate",["linear"],["zoom"],15,0,16,1,17,1.4,18,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.85}},{id:"route-line",type:"line",source:"route-data",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#007aff","line-width":["interpolate",["linear"],["zoom"],16.5,3,18,5,20,7],"line-opacity":.55}},{id:"route-halo",type:"line",source:"route-data",minzoom:16.5,paint:{"line-color":"white","line-width":["interpolate",["linear"],["zoom"],16.5,5,18,7,20,9],"line-opacity":.45}},{id:"route-line-active-halo",type:"line",source:"route-active-step",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#FFFFFF","line-width":["interpolate",["linear"],["zoom"],16.5,8,18,11,20,14],"line-opacity":.85}},{id:"route-line-active",type:"line",source:"route-active-step",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fdb81e","line-width":["interpolate",["linear"],["zoom"],16.5,5,18,7,20,9],"line-opacity":1}},{id:"route-endpoint-source",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"source"],paint:{"circle-radius":6,"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#007aff","circle-opacity":1}},{id:"route-endpoint-destination",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"destination"],paint:{"circle-radius":7,"circle-color":"#007aff","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":1}},{id:"poi-accessibility-icons",type:"symbol",source:"poi-data",filter:["==",["get","accessible"],!0],minzoom:16.5,layout:{"icon-image":"wheelchair-accessible","icon-size":["interpolate",["linear"],["zoom"],15,.4,17,.6,19,.8],"icon-allow-overlap":!1,"icon-padding":4}},{id:"poi-destination-circles",type:"circle",source:"poi-data",filter:["==",["get","poiType"],"destination"],minzoom:16.5,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,6,18,8,20,10],"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#162e51","circle-opacity":1}},{id:"poi-destination-labels",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"destination"],["==",["get","showLabel"],!0]],minzoom:16.5,layout:{"symbol-sort-key":0,"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16.5,18,18,20,20,23],"text-offset":[0,-.9],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-max-width":12,"text-allow-overlap":!1,"text-padding":4,"text-rotation-alignment":"viewport"},paint:{"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1}},{id:"map-labels",type:"symbol",source:"map-labels-data",minzoom:15.5,layout:{"symbol-sort-key":10,"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],15.5,13,16.5,16,18,19,20,22],"text-font":["Noto Sans Bold"],"text-letter-spacing":.04,"text-max-width":10,"text-anchor":"center","text-rotate":["get","rotation"],"text-rotation-alignment":"map","text-allow-overlap":!1,"text-padding":4},paint:{"text-color":"#3d4551","text-halo-color":"#FFFFFF","text-halo-width":1.4,"text-halo-blur":.5}},{id:"poi-entrance-exit-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","entrance",["get","keywords"]],-1],["!=",["index-of","exit",["get","keywords"]],-1],["!=",["index-of","door",["get","keywords"]],-1]]],minzoom:15,layout:{"symbol-sort-key":1,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-parking-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","parking",["get","keywords"]],-1],["!=",["index-of","park",["get","keywords"]],-1]]],minzoom:14,layout:{"symbol-sort-key":2,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-other-amenity-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["==",["index-of","entrance",["get","keywords"]],-1],["==",["index-of","exit",["get","keywords"]],-1],["==",["index-of","door",["get","keywords"]],-1],["==",["index-of","parking",["get","keywords"]],-1],["==",["index-of","park",["get","keywords"]],-1]],minzoom:16.5,layout:{"symbol-sort-key":3,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-you-are-here-heading",type:"symbol",source:"poi-data",filter:["all",["==",["get","isYouAreHere"],!0],["==",["get","hasHeading"],!0]],minzoom:16,layout:{"text-field":"▲","text-size":["interpolate",["linear"],["zoom"],16,28,18,34,20,42],"text-font":["Noto Sans Bold"],"text-anchor":"bottom","text-offset":[0,-.45],"text-rotate":["get","heading"],"text-rotation-alignment":"map","text-pitch-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#face00","text-halo-color":"#162e51","text-halo-width":2.5,"text-opacity":.9}},{id:"poi-you-are-here-ring",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,14,18,18,20,24],"circle-color":"#face00","circle-opacity":.25,"circle-pitch-alignment":"map"}},{id:"poi-you-are-here-dot",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,7,18,9,20,12],"circle-color":"#face00","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1}},{id:"poi-you-are-here",type:"symbol",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,layout:{"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,17,18,19,20,22],"text-offset":[0,-1.8],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-allow-overlap":!0,"text-ignore-placement":!0,"text-optional":!1},paint:{"text-color":"#ffffff","text-halo-color":"#162e51","text-halo-width":2.5,"text-halo-blur":.5}},{id:"poi-highlight-ring",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":14,"circle-color":"#005ea2","circle-opacity":.45,"circle-pitch-alignment":"map"}},{id:"poi-highlight-core",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":9,"circle-color":"#005ea2","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1,"circle-pitch-alignment":"map"}}]};const Ct={"#162e51":"#000000","#263238":"#000000","#c8a85a":"#ffd600","#face00":"#ffd600","#73b3e7":"#1565c0","#97d4ea":"#1976d2","#f2938c":"#c62828","#fee685":"#f9a825","#dfe1e2":"#757575","#faf3e2":"#ffffff","#f0e6d1":"#f5f5f5","#5f9070":"#2e7d32","#3f5d4a":"#1b5e20","#c4c8cb":"#616161","#a9aeb1":"#424242","#6f7780":"#212121","#e8e9ed":"#bdbdbd","#b0b1b5":"#424242","#e6e6e2":"#9e9e9e","#242930":"#000000","#b0b0ad":"#000000","#cfe1ec":"#b3e5fc","#d2e0c6":"#c8e6c9","#cdd9c9":"#a5d6a7","#e0e0e0":"#eeeeee","#cabfb6":"#bcaaa4","#ddd2e0":"#ce93d8","#f3e4c4":"#ffe082","#e0e0dd":"#bdbdbd","#b0b0ad ":"#000000","#bcaaa4":"#5d4037","#757575":"#424242","#616161":"#212121","#007aff":"#0050b3","#ffffff":"#ffffff","#005ea2":"#0050b3"};function Tt(t){if(Array.isArray(t))return t.map(Tt);if(t&&"object"==typeof t){const e={};for(const[o,i]of Object.entries(t))e[o]=Tt(i);return e}return"string"!=typeof(e=t)?e:Ct[e.toLowerCase()]??e;var e}const zt=function(){const t=structuredClone(Pt);for(const e of t.layers??[])if(e.paint&&(e.paint=Tt(e.paint)),e.paint&&"text-halo-width"in e.paint){const t=e.paint["text-halo-width"];"number"==typeof t&&(e.paint["text-halo-width"]=t+2)}return t}(),Lt=Pt;function jt(t){return"high-contrast"===t?zt:Lt}function Et(t,e,o={}){t.sources||={},t.sources[e]||(t.sources[e]={type:"geojson",data:{type:"FeatureCollection",features:[]},...o})}function Bt(t){let e=structuredClone(t.style);if(e.sprite=t.customSprite||e.sprite||t.defaultSpriteUrl,Et(e,a),Et(e,c),Et(e,l),Et(e,p),Et(e,u,{lineMetrics:!0}),Et(e,f),Et(e,"route-endpoints"),t.floorLayers)for(const o of Object.keys(t.floorLayers))Et(e,`amenity_${o}`),Et(e,`destination_${o}`),Et(e,`pathTypes_${o}`);return e}const Rt="https://demotiles.maplibre.org/styles/osm-bright-gl-style/sprite";class Ot{config;map=null;data=new nt;wayfindingProvider;events=new St;floorsApi;venue=null;spriteKeys=null;debug;logger;defaultCamera=null;viewModes;reducedMotion=!1;activeThemeName="default";currentLocale;amenityManager;wayfinding;highlightManager;youAreHerePulse=new P;static POI_CATEGORY_LAYERS=[{id:"poi-destination-circles",category:"destination"},{id:"poi-destination-labels",category:"destination"},{id:"poi-entrance-exit-icons",category:"amenity"},{id:"poi-parking-icons",category:"amenity"},{id:"poi-other-amenity-icons",category:"amenity"}];poiVisibleTypes=null;constructor(t){this.config=t,this.debug=Boolean(t.debug??t.options?.debug),this.logger=y({enabled:this.debug,prefix:"MinuteMapsSDK"}),this.viewModes=new z(()=>this.map),this.reducedMotion=Boolean(t.options?.reducedMotion),this.activeThemeName="high-contrast"===t.options?.theme?"high-contrast":"default",this.currentLocale=t.jmap?.locale,this.wayfindingProvider=new ft({getGraph:()=>this.data.getWayfindingGraph?.()??null,warn:(...t)=>this.logger.warn(...t)}),this.floorsApi=new b({getMap:()=>this.map,getConfig:()=>this.config,updatePoiSource:async t=>{const e=this.map;if(!e)return;const o=this.getAllPOIs(t),i=E.toFeatureCollection(o);s.setData(e,l,i);const n={type:"FeatureCollection",features:(this.venue?.mapLabels?.getByMap?.(t)??[]).filter(t=>Array.isArray(t?.coordinates)).map(t=>({type:"Feature",geometry:{type:"Point",coordinates:t.coordinates},properties:{name:t.name??"",rotation:"number"==typeof t.rotation?t.rotation:0,allLevels:!!t.allLevels}}))};s.setData(e,p,n)},log:(...t)=>this.logger.debug(...t)}),this.amenityManager=new J({getVenue:()=>this.venue,getFloors:()=>this.floorsApi.getFloors(),getFloorById:t=>this.floorsApi.getFloors().find(e=>e.id===t)??null,log:(...t)=>this.logger.debug(...t)}),this.wayfinding=new $({getMap:()=>this.map,getVenue:()=>this.venue,getYouAreHerePOI:t=>this.getYouAreHerePOI(t),getYouAreHereCoordinates:t=>this.getYouAreHereCoordinates(t),getBoundsPadding:()=>this.getBoundsPadding(),computeRoute:async(t,e,o)=>{const i=this.config.jmap.customerId,n=this.config.jmap.venueId;if(null==i)throw new Error("config.jmap.customerId is required");if(null==n)throw new Error("config.jmap.venueId is required");return this.wayfindingProvider.wayfindBetweenWaypoints({customerId:i,venueId:n,from:t,to:e,options:o})},getReducedMotion:()=>this.reducedMotion,log:(...t)=>this.logger.debug(...t),warn:(...t)=>this.logger.warn(...t),debug:this.debug}),this.highlightManager=new W({getMap:()=>this.map,log:(...t)=>this.logger.debug(...t)})}async init(){const{venueId:t,customerId:e}=this.config?.jmap;if(null==t||null==e)throw new Error("config.jmap.customerId and config.jmap.venueId are required");if(!this.config.container)throw new Error("config.container is required (HTMLElement or element id)");this.logger.debug("init :: starting (JACS)",{venueId:t,customerId:e});try{await this.data.init(this.config),this.logger.debug("providers :: JACS ready"),this.venue=await this.data.loadVenue(),this.logger.debug("JACS :: venue loaded",this.venue.id),this.floorsApi.setFloors(this.venue.floors),this.logger.debug("JACS :: floors loaded",{count:this.venue.floors.length});const t=Bt({style:jt("custom"===this.activeThemeName?"default":this.activeThemeName),customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Rt});this.ensureFloorLayersFromStyle(t),this.map=r(this.config.container,t),await new Promise(t=>this.map.once("load",()=>t())),this.map.on("error",t=>{const e=t?.error?.message||t?.message||t;this.logger.error("map :: error",{msg:e,sourceId:t?.sourceId,tile:t?.tile})}),this.map.on("styledata",()=>{try{this.viewModes.onStyleData()}catch{}}),this.map.on("move",()=>{if(!this.map)return;const t=j(this.map);t&&this.events.emit("cameraChange",{camera:t})}),this.ensureCoreSources(),this.spriteKeys=await x.getSpriteKeys(this.map);try{await k.register(this.map,this.venue?.amenities?.items,{iconColor:this.config.options?.amenityIconColor,badge:this.config.options?.amenityBadge})}catch(t){this.logger.warn("amenity icon registration failed",t)}const e=this.floorsApi.getInitialFloor();Boolean(e?.geojson?.features?.length)||this.applyInitialViewFromVenue(),e&&await this.setCurrentFloor(e),this.applyInitialFraming(),this.defaultCamera=j(this.map),this.youAreHerePulse.start(this.map,{reducedMotion:this.reducedMotion}),this.events.emit("ready",{venue:this.venue}),this.events.emit("floorsLoaded",{})}catch(t){throw this.logger.error("init :: failed (JACS)",t),this.events.emit("error",{error:t}),t}}on(t,e){this.events.on(t,e)}off(t,e){this.events.off(t,e)}addControl(t,e){this.map?.addControl(t,e)}setView(t){L(this.map,t)}get amenities(){return this.amenityManager}resetView(t){!function(t,e,o){if(!t||!e)return;const{center:i,zoom:n,pitch:r,bearing:s}=e,a=Boolean(o?.animate),l="number"==typeof o?.duration?o.duration:800;a?t.easeTo({center:i,zoom:n,pitch:r,bearing:s,duration:l}):t.jumpTo({center:i,zoom:n,pitch:r,bearing:s})}(this.map,this.defaultCamera,t)}refit(t){if(!this.map)return;const e=this.wayfinding.getActiveRouteBounds();if(e)return void this.fitToBounds(e,t);const o=this.getCurrentFloor();if(!o?.geojson)return;const i=m.boundsFromGeoJson(o.geojson);i&&this.fitToBounds(i,t)}fitToBounds(t,e){const o=this.map;if(o)try{o.fitBounds(t,{padding:this.getBoundsPadding(),bearing:o.getBearing(),pitch:o.getPitch(),animate:e?.animate??!0,duration:e?.duration??600,maxZoom:21})}catch(t){this.logger.warn("refit :: fitBounds failed",t)}}set3dEnabled(t){this.viewModes.set3dEnabled(t)}toggle3d(){this.viewModes.toggle3d()}getIs3dEnabled(){return this.viewModes.getIs3dEnabled()}async setTheme(t){const e=this.map;if(!e)return void this.logger.warn("setTheme :: map not initialized");const o="default"===t?"default":"high-contrast"===t?"high-contrast":"custom";if("custom"!==o&&o===this.activeThemeName)return void this.logger.debug("setTheme :: noop, theme already active",o);const i=t=>{const o=e.getSource(t);return o?._data??null},n=i(a),r=i(c),s=i(l),h=i(p),g=i(u),y=i(f),m=i("route-endpoints"),w=i(d),b=Bt({style:"custom"===o?t:jt(o),customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Rt});await new Promise((t,i)=>{const I=()=>{try{const i=(t,o)=>{if(null==o)return;const i=e.getSource(t);i?.setData&&i.setData(o)};i(a,n),i(c,r),i(l,s),i(p,h),i(u,g),i(f,y),i("route-endpoints",m),i(d,w);const b=this.getCurrentFloor();b&&this.updateRouteFloorFilter(b.id),e.off("style.load",I),this.activeThemeName=o,this.events.emit("themeChanged",{theme:o}),this.logger.debug("setTheme :: applied",o),t()}catch(t){this.logger.warn("setTheme :: restore failed",t),i(t)}};e.on("style.load",I),e.setStyle(b,{diff:!1})})}getActiveTheme(){return this.activeThemeName}setReducedMotion(t){this.reducedMotion=Boolean(t),this.reducedMotion?this.youAreHerePulse.stop():this.map&&this.youAreHerePulse.start(this.map,{reducedMotion:!1})}getReducedMotion(){return this.reducedMotion}async setLocale(t){const e=t||void 0;if(e===this.currentLocale)return void this.logger.debug("setLocale :: noop, locale already active",e);const o=this.data?.applyLocale?.bind(this.data);if("function"!=typeof o)throw new Error("Active data provider does not support runtime locale switching");if(!e)throw new Error("setLocale requires a non-empty locale code");await o(e),this.currentLocale=e;const i=this.floorsApi.getCurrentFloor();if(i&&this.map){const t=this.getAllPOIs(i),e=E.toFeatureCollection(t);s.setData(this.map,l,e)}this.events.emit("localeChanged",{locale:e}),this.logger.debug("setLocale :: applied",e)}getActiveLocale(){return this.currentLocale}setUnits2dEnabled(t){this.viewModes.setUnits2dEnabled(t)}toggleUnits2d(){this.viewModes.toggleUnits2d()}getIsUnits2dEnabled(){return this.viewModes.getIsUnits2dEnabled()}setFlatMode(t){this.viewModes.setFlatMode(t)}toggleFlatMode(){this.viewModes.toggleFlatMode()}getIsFlatMode(){return this.viewModes.getIsFlatMode()}getFloors(){return this.floorsApi.getFloors()}getCurrentFloor(){return this.floorsApi.getCurrentFloor()}getDefaultFloor(){return this.floorsApi.getDefaultFloor()}getDestinations(t){const e=t||this.getCurrentFloor();return function(t,e){if(!t||!e)return[];try{const o=t.destinations?.getByMap?.({id:e.id})||[];return Array.isArray(o)?o:[]}catch{return[]}}(this.venue,e)}getPolygonLayers(){return this.venue?.polygonLayers??[]}getFloorMapTemplate3d(t){return this.venue?.mapTemplates3d?.[String(t)]??[]}getAllPOIs(t){const e=t||this.getCurrentFloor();if(!e)return[];return function(t,e,o,i,n){return E.buildPOIs(t,e,o,i,n)}(e,this.amenityManager.getByFloorId(e.id),this.getDestinations(e),this.spriteKeys,this.venue?.kioskWaypoint)}getYouAreHerePOI(t){return B(this.getAllPOIs(t))}getYouAreHereCoordinates(t){return function(t){const e=B(t);return e?.coordinates??null}(this.getAllPOIs(t))}getKioskHeading(){const t=this.venue?.kioskWaypoint,e=t?.heading;return"number"==typeof e&&Number.isFinite(e)?e:null}getWalkTimeFromKiosk(t,e){return yt({graph:this.data.getWayfindingGraph?.()??null,kiosk:this.venue?.kioskWaypoint??null,target:t,options:e})}recenterOnKiosk(t){const e=this.map;if(!e)return;const o=this.getYouAreHereCoordinates();if(!o)return void this.logger.warn("recenterOnKiosk :: no You-Are-Here coordinates available");const i=(t?.animate??!0)&&!this.reducedMotion,n=i?t?.duration??600:0,r=!1!==t?.useHeading?this.getKioskHeading():null;L(e,{center:o,zoom:t?.zoom,pitch:t?.pitch,bearing:r??void 0,animate:i,duration:n})}searchPOIs(t,e){return function(t,e){const o=e.trim().toLowerCase();return o?t.filter(t=>{const e=t.name?.toLowerCase().includes(o),i=(t.keywords||[]).some(t=>t.toLowerCase().includes(o));return e||i}):[]}(this.getAllPOIs(e),t)}searchAllPOIs(t){const e=t?.trim();return e?this.getFloors().flatMap(t=>this.searchPOIs(e,t)):[]}async wayfindBetweenWaypoints(t,e,o){return this.wayfinding.wayfindBetweenWaypoints(t,e,o)}async navigateFromKioskToDestination(t){return this.wayfinding.navigateFromKioskToDestination(t)}async navigateFromKioskToPOI(t,e){const o=t?.waypoint;if(!o)return void this.logger.warn("navigateFromKioskToPOI :: POI has no waypoint",t);const i=this.getYouAreHerePOI()?.waypoint;if(!i)return void this.logger.warn("navigateFromKioskToPOI :: no kiosk waypoint available");const n=await this.wayfinding.wayfindBetweenWaypoints(i,o,{centerMode:"route",accessible:e?.accessible,avoidStairs:e?.avoidStairs}),r=this.wayfinding.getLastRoutePoints(),s=this.wayfinding.getLastRouteFloorIds();if(r.length>=2){const e=function(t,e){if(!Array.isArray(t)||t.length<2)return[];const o=[],i=[];{let e=0;for(;e<t.length;){const o=t[e].mapId??null;let n=e;for(;n+1<t.length&&(t[n+1].mapId??null)===o;)n++;i.push({floorId:o,startIdx:e,endIdx:n}),e=n+1}}for(let n=0;n<i.length;n++){const r=i[n],s=0===n,a=n===i.length-1,l=mt(t,r,{isFirstLeg:s,isLastLeg:a,ctx:e});if(o.push(...l),!a){const s=i[n+1],a=t[s.startIdx],l=(null!=a?.pathTypeId&&e.pathTypeKind?e.pathTypeKind(a.pathTypeId):null)??"elevator",c=null!=s.floorId?e.floorName(s.floorId):null;null!=r.floorId&&e.floorName(r.floorId);const u=kt(l,c);o.push({type:"transition",transition:l,fromFloorId:r.floorId,toFloorId:s.floorId,floorId:null,pointRange:[r.endIdx,s.startIdx],text:u})}}return o}(r,this.buildDirectionsContext(t));e.length>0&&this.writeActiveStepHighlight(e[0]),this.events.emit("routeReady",{route:{points:r,steps:e,floorIds:s}})}return n}buildDirectionsContext(t){const e=this.getFloors(),o=new Map;for(const t of e){const e=t.mapId??t.id;"number"==typeof e&&o.set(e,t.name??`Floor ${t.id}`)}const i=this.venue?.pathTypes;return{floorName:t=>o.get(t)??null,pathTypeKind:t=>{const e=(t=>{if(i instanceof Map)return(i.get(t)?.name??"").toLowerCase();if(Array.isArray(i)){const e=i.find(e=>e?.id===t);return(e?.name??"").toLowerCase()}return""})(t);return e?/elev|lift/.test(e)?"elevator":/escalat/.test(e)?"escalator":/stair|step/.test(e)?"stairs":null:null},destinations:this.venue?.destinations?.items??[],amenities:this.venue?.amenities?.items??[],mapLabels:this.venue?.mapLabels?.items??[],destinationName:t?.name}}async setActiveStep(t){if(t){if(null!=t.floorId){const e=this.getFloors().find(e=>(e.mapId??e.id)===t.floorId);e&&String(this.getCurrentFloor()?.id)!==String(e.id)&&await this.setCurrentFloor(e)}this.writeActiveStepHighlight(t)}else this.clearActiveStepHighlight()}writeActiveStepHighlight(t){const e=this.map;if(!e)return;if("transition"===t.type)return void this.clearActiveStepHighlight();const o=this.wayfinding.getLastRoutePoints(),[i,n]=t.pointRange,r=[];for(let t=i;t<=n&&t<o.length;t++)r.push(o[t].coordinates);if(r.length<2)return void this.clearActiveStepHighlight();const a={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:r},properties:{stepType:t.type,floorId:t.floorId??null}}]};s.setData(e,f,a)}clearActiveStepHighlight(){const t=this.map;t&&s.setData(t,f,{type:"FeatureCollection",features:[]})}clearRoute(){this.wayfinding.clearRoute(),this.clearActiveStepHighlight()}async highlightPOI(t){let e=null,o=null;for(const i of this.getFloors()){const n=this.getAllPOIs(i).find(e=>String(e.id)===String(t));if(n){e=n,o=i;break}}e&&o?(String(this.getCurrentFloor()?.id)!==String(o.id)&&await this.setCurrentFloor(o),this.setView({center:e.coordinates,animate:!0,duration:600}),this.highlightManager.highlight(e.coordinates)):this.logger.warn("highlightPOI :: no POI found for id",t)}clearHighlight(){this.highlightManager.clear()}setPOIFilter(t){this.poiVisibleTypes=new Set(t),this.applyPOIFilter()}clearPOIFilter(){this.poiVisibleTypes=null,this.applyPOIFilter()}applyPOIFilter(){const t=this.map;if(!t)return;const e=this.poiVisibleTypes;for(const{id:o,category:i}of Ot.POI_CATEGORY_LAYERS){if(!t.getLayer(o))continue;const n=null===e||e.has(i);t.setLayoutProperty(o,"visibility",n?"visible":"none")}}findClosestWaypoint(t,e){if(!t?.length)return null;const o=e??this.getYouAreHereCoordinates();if(!o)return t.find(t=>Array.isArray(t.coordinates)&&t.coordinates.length>=2)??null;let i=null,n=1/0;for(const e of t){const t=e.coordinates;if(!Array.isArray(t)||t.length<2)continue;const r=t[0]-o[0],s=t[1]-o[1],a=r*r+s*s;a<n&&(n=a,i=e)}return i}async highlightAmenity(t){const e=this.amenityManager.getDistinct().find(e=>String(e.id)===String(t));if(!e||!e.waypoints?.length)return void this.logger.warn("highlightAmenity :: no waypoints for amenity",t);const o=this.findClosestWaypoint(e.waypoints);if(!o||!Array.isArray(o.coordinates)||o.coordinates.length<2)return void this.logger.warn("highlightAmenity :: no usable waypoint",t);const i=this.findFloorForWaypoint(o);i&&String(this.getCurrentFloor()?.id)!==String(i.id)&&await this.setCurrentFloor(i);const n=[o.coordinates[0],o.coordinates[1]];this.setView({center:n,animate:!0,duration:600}),this.highlightManager.highlight(n)}findFloorForWaypoint(t){const e=t.mapId;return null==e?null:this.getFloors().find(t=>{const o=t.mapId??t.id;return String(o)===String(e)})??null}getCameraPosition(){return j(this.map)}getMap(){return this.map}destroy(){this.youAreHerePulse.stop(),this.highlightManager.destroy(),this.map?.remove(),this.map=null,this.floorsApi.setFloors([]),this.defaultCamera=null,this.viewModes=new z(()=>this.map)}async setCurrentFloor(t){await this.data.ensureFloorGeojson(t),await this.floorsApi.setCurrentFloor(t),this.setFloorLayerVisibility(t.id),this.updateRouteFloorFilter(t.id),this.events.emit("floorChanged",{floor:t})}updateRouteFloorFilter(t){const e=this.map;if(!e)return;const o=this.getFloors().find(e=>String(e.id)===String(t)),i=["any",["!",["has","floorId"]],["==",["get","floorId"],o?.mapId??t]];for(const t of["route-line","route-halo"])if(e.getLayer(t))try{e.setFilter(t,i)}catch{}}isReady(){return!!this.map}setFloorLayerVisibility(t){const e=this.map;if(!e)return;const o=this.venue?.styleSheet?.floorLayers;if(o)for(const[i,n]of Object.entries(o)){const o=String(i)===String(t);for(const t of n)e.getLayer(t.id)&&e.setLayoutProperty(t.id,"visibility",o?"visible":"none")}}getBoundsPadding(){const t=this.config.options?.boundsPadding??50;if("number"==typeof t||!this.map)return t;const e=this.map.getContainer();return this.clampPadding(t,e.clientWidth,e.clientHeight)}clampPadding(t,e,o){const i=(t,e,o)=>{if(!(o>0))return[t,e];const i=.8*o,n=t+e;if(n<=i)return[t,e];const r=i/n;return[t*r,e*r]},[n,r]=i(t.top,t.bottom,o),[s,a]=i(t.left,t.right,e);return{top:n,bottom:r,left:s,right:a}}getVenueBounds(){const t=this.venue?.coordinates;if(!t)return null;const{bottomLng:e,bottomLat:o,topLng:i,topLat:n}=t;if(null==e||null==o||null==i||null==n)return null;const r=Math.min(e,i),s=Math.max(e,i);return[[r,Math.min(o,n)],[s,Math.max(o,n)]]}applyInitialFraming(){const t=this.map;if(!t)return;const{initialPitch:e,initialZoom:o,minZoomBelowInitialFit:i}=this.config.options??{},n=this.getYouAreHereCoordinates();("number"==typeof e||"number"==typeof o||n)&&t.easeTo({center:n??t.getCenter(),zoom:"number"==typeof o?o:t.getZoom(),pitch:"number"==typeof e?e:t.getPitch(),bearing:t.getBearing(),duration:0}),"number"==typeof i&&t.setMinZoom(Math.max(0,t.getZoom()-i))}applyInitialViewFromVenue(){const t=this.map;if(!t)return;const e=this.getVenueBounds();if(e)try{t.resize(),t.fitBounds(e,{padding:this.getBoundsPadding(),animate:!1,duration:0,maxZoom:21})}catch(t){this.logger.warn("applyInitialViewFromVenue :: fitBounds failed",t)}}async loadAndPatchVenueStyle(){const t=this.venue?.styleSheet?.styleUrl,e=this.venue?.styleSheet?.floorLayers,o=Lt;if("sdkTemplate"===this.config.options?.styleMode)return this.logger.debug("style :: styleMode=sdkTemplate, ignoring venue styleUrl"),Bt({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Rt});if(!t)return this.logger.warn("style :: venue.styleSheet.styleUrl missing, using baseStyle"),Bt({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Rt});try{const o=await fetch(t);if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);return Bt({style:await o.json(),floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Rt})}catch(t){return this.logger.warn("style :: failed to fetch venue styleUrl, using baseStyle",t),Bt({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Rt})}}ensureFloorLayersFromStyle(t){const e=this.venue?.styleSheet?.floorLayers;if(e&&Object.keys(e).length)return;const o={};for(const e of t.layers||[]){const t=e.id||"",i=/_(\d+)$/.exec(t);if(!i)continue;const n=i[1];o[n]||=[],o[n].push({id:t})}this.venue||={},this.venue.styleSheet||={},this.venue.styleSheet.floorLayers=o}ensureCoreSources(){const t=this.map;if(!t)return;const e={type:"FeatureCollection",features:[]};s.ensureGeoJson(t,a),s.ensureGeoJson(t,c),s.ensureGeoJson(t,l),s.ensureGeoJson(t,d),t.getSource(u)||t.addSource(u,{type:"geojson",data:e,lineMetrics:!0}),t.getSource("route-endpoints")||t.addSource("route-endpoints",{type:"geojson",data:e})}}exports.MinuteMaps=Ot,exports.createMinuteMapsSDK=function(t){return new Ot(t)};
1
+ "use strict";var t=require("maplibre-gl"),e=require("pmtiles");function o(t){var e=Object.create(null);return t&&Object.keys(t).forEach(function(o){if("default"!==o){var i=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,i.get?i:{enumerable:!0,get:function(){return t[o]}})}}),e.default=t,Object.freeze(e)}var i=o(require("@turf/turf"));let n=!1;function r(o,i){const r="string"==typeof o?document.getElementById(o):o;if(!r)throw new Error("Map container not found");return function(){if(n)return;const o=new e.Protocol;t.addProtocol("pmtiles",o.tile),n=!0}(),new t.Map({container:r,style:i,center:[0,0],zoom:16,pitch:45,bearing:0,minPitch:30,maxPitch:55})}const s={ensureGeoJson(t,e){t.getSource(e)||t.addSource(e,{type:"geojson",data:{type:"FeatureCollection",features:[]}})},setData(t,e,o){const i=t.getSource(e);i?.setData?.(o)}},a="indoor-data",l="poi-data",c="unit-walls",d="route-data",u="poi-highlight-data",p="map-labels-data",f="route-active-step",h=["boundary-fill","boundary-outline","units-fill","units-wall-extrusion","units-wall-custom-extrusion","corridors-fill","corridors-outline","building-extrusion"],g=()=>{};function y(t){const e=Boolean(t?.enabled),o=function(t){const e=String(t||"").trim();return e?`[${e}]`:""}(t?.prefix||"MinuteMapsSDK");return e?{debug:(...t)=>console.debug(o,...t),log:(...t)=>console.log(o,...t),warn:(...t)=>console.warn(o,...t),error:(...t)=>console.error(o,...t)}:{debug:g,log:g,warn:g,error:g}}y({enabled:!0,prefix:"MinuteMapsSDK"});const m={applyFloor(t,e,o=1){m.updateWalls(t,e,o),m.updateIndoor(t,e,o)},updateIndoor(t,e,o=1){const n=function(t,e){if(!t)return{type:"FeatureCollection",features:[]};if(!Number.isFinite(e)||e<=0)return t;const o=(t.features||[]).map(t=>{const o=t?.properties?.featureType;if(!o||!w.has(o))return t;const n=t?.geometry?.type;if("Polygon"!==n&&"MultiPolygon"!==n)return t;try{const o=i.buffer(t,-e,{units:"feet"});return o?.geometry?{...t,geometry:o.geometry}:t}catch{return t}});return{...t,features:o}}(e.geojson,o);s.setData(t,a,n);try{const t=e?.geojson?.features||[],o={};for(const e of t){const t=e?.properties?.featureType,i=null==t?"(missing)":String(t);o[i]=(o[i]||0)+1}Object.entries(o).sort((t,e)=>e[1]-t[1]).slice(0,15)}catch{}},updateWalls(t,e,o=1){const n=function(t,e=1){const o=Math.max(Number(e)||1,.5)/2,n=t=>{try{return i.cleanCoords(t)}catch{return t}},r=t=>{const e=t?.geometry?.type;if("Polygon"!==e&&"MultiPolygon"!==e)return null;try{const e=n(t),r=i.buffer(e,-o,{units:"feet"});if(!r?.geometry)return null;const s=i.area(e),a=i.area(r);if(!Number.isFinite(s)||s<=0)return null;if(a>=s)return null;const l=i.difference(i.featureCollection([e,r]));return l?.geometry?l:null}catch{return null}},s=t=>{if(0===t.length)return null;if(1===t.length)return t[0];try{return i.union(i.featureCollection(t))}catch{return null}},a=[];let l=null;for(const e of t.features||[]){const t=e?.properties?.featureType,o=e?.geometry?.type;if("Polygon"===o||"MultiPolygon"===o)if("Boundary"!==t||l){if("Units"===t){const t=r(e);t&&a.push(t)}}else l=r(e)}const c=s(a);let d=c;if(c?.geometry&&l?.geometry)try{const t=i.difference(i.featureCollection([c,l]));t?.geometry&&(d=t)}catch{}const u=[];l?.geometry&&u.push({type:"Feature",geometry:l.geometry,properties:{featureType:"UnitWalls",wallKind:"perimeter"}});d?.geometry&&u.push({type:"Feature",geometry:d.geometry,properties:{featureType:"UnitWalls",wallKind:"interior"}});return{type:"FeatureCollection",features:u}}(e.geojson,o);s.setData(t,c,n)},boundsFromGeoJson(t){try{const[e,o,n,r]=i.bbox(t),s=Math.min(e,n),a=Math.max(e,n),l=Math.min(o,r);return[[s,l],[a,Math.max(o,r)]]}catch{return null}},selectDefaultFloor:t=>Array.isArray(t)&&0!==t.length&&(t.find(t=>t.isDefault)||t[0])||null,selectInitialFloor(t,e){if(!Array.isArray(t)||0===t.length)return null;if(null!=e){const o=t.find(t=>t.id===e);if(o)return o}return m.selectDefaultFloor(t)},async activateFloor(t,e,o){if(!t)throw new Error("activateFloor requires an initialized map");if(e?.geojson&&m.applyFloor(t,e,o.wallFeet),await o.updatePOIs(e),!e?.geojson)return void(t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom));const i=m.boundsFromGeoJson(e.geojson);if(!i)return;const n=!o.didFit;let r=n;if(!r){const[[e,o],[n,s]]=i,a=t.getBounds();r=a.getWest()>n||a.getEast()<e||a.getSouth()>s||a.getNorth()<o}r?(t.fitBounds(i,{padding:o.boundsPadding,animate:!n,duration:700,bearing:t.getBearing(),pitch:t.getPitch()}),t.once("moveend",()=>{t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom)}),o.setDidFit(!0),o.log?.("camera :: fitToFloor",{floorId:e.id,animated:!n})):(t.getZoom()<o.minIndoorZoom&&t.setZoom(o.minIndoorZoom),o.log?.("camera :: fit skipped (floor overlaps viewport)",{floorId:e.id}))}},w=new Set(["Restrooms","Back-of-house","Obstacles","Escalators","Stairs","Elevators"]);class b{floors=[];currentFloor=null;didFit=!1;getMap;getConfig;updatePoiSource;logFn;constructor(t){this.getMap=t.getMap,this.getConfig=t.getConfig,this.updatePoiSource=t.updatePoiSource,this.logFn=t.log}log(...t){this.logFn&&this.logFn(...t)}setFloors(t){this.floors=t}getFloors(){return[...this.floors]}getCurrentFloor(){return this.currentFloor}setDidFit(t){this.didFit=t}getDefaultFloor(){return m.selectDefaultFloor(this.floors)}getInitialFloor(){const t=this.getConfig();return m.selectInitialFloor(this.floors,t.options?.initialFloor)}async setCurrentFloor(t){const e=this.getMap();if(!e)throw new Error("Map is not initialized");this.currentFloor=t,this.log("floor :: setCurrentFloor",{id:t.id,name:t.name,geojsonFeatures:t.geojson?.features?.length??0});const o=this.getConfig(),i=o.options?.wallThickness??1,n=o.options?.boundsPadding??50,r=o.options?.minIndoorZoom??16.5;await m.activateFloor(e,t,{wallFeet:i,updatePOIs:t=>this.updatePoiSource(t),didFit:this.didFit,setDidFit:t=>{this.didFit=t},boundsPadding:n,minIndoorZoom:r,log:(t,e)=>this.log(t,e)})}}const I=y({enabled:!0,prefix:"MinuteMapsSDK"}),v=new Map,F={async getSpriteKeys(t){const e=function(t){if(!t)return;if("string"==typeof t)return t;if(Array.isArray(t)){const e=t[0];if(e&&"string"==typeof e.url)return e.url}if("object"==typeof t&&null!==t){const e=t?.url;if("string"==typeof e)return e}return}(t?.getStyle?.()?.sprite);if(!e||"function"!=typeof fetch)return new Set;const o=e.endsWith(".json")?e:`${e}.json`;if(v.has(o))return v.get(o);try{const t=await fetch(o);if(!t.ok)throw new Error(`Failed to load sprite JSON (${t.status})`);const e=await t.json(),i=new Set(Object.keys(e||{}));return v.set(o,i),i}catch(t){I.warn("sprite fetch failed",o,t);const e=new Set;return v.set(o,e),e}}};const x=y({enabled:!0,prefix:"MinuteMapsSDK amenityIcons"});async function A(t,e,o){let i;if(t.inlineSvg)i=t.inlineSvg;else{if(!t.url)throw new Error("loadSvgElement: neither url nor inlineSvg provided");{const e=await fetch(t.url,{mode:"cors"});if(!e.ok)throw new Error(`HTTP ${e.status}`);i=await e.text()}}let n=i;try{const t=(new DOMParser).parseFromString(i,"image/svg+xml"),r=t.documentElement;!(t.getElementsByTagName("parsererror").length>0)&&r&&"svg"===r.nodeName.toLowerCase()&&(r.hasAttribute("width")||r.setAttribute("width",String(e)),r.hasAttribute("height")||r.setAttribute("height",String(e)),o&&function(t,e){const o=t.getAttribute("fill"),i="none"===o||"transparent"===o,n=[t,...Array.from(t.querySelectorAll("*"))];for(const t of n){const o=t.getAttribute("fill");"none"===o||"transparent"===o||(o||!i&&/^(path|circle|rect|polygon|polyline|ellipse|g|use|symbol)$/i.test(t.tagName))&&t.setAttribute("fill",e);const n=t.getAttribute("stroke");n&&"none"!==n&&"transparent"!==n&&t.setAttribute("stroke",e);const r=t.getAttribute("style");r&&t.setAttribute("style",r.replace(/fill:\s*(?!none|transparent)[^;]+;?/gi,`fill: ${e};`).replace(/stroke:\s*(?!none|transparent)[^;]+;?/gi,`stroke: ${e};`))}}(r,o),n=(new XMLSerializer).serializeToString(r))}catch{}const r=new Blob([n],{type:"image/svg+xml"}),s=URL.createObjectURL(r);return new Promise((t,e)=>{const o=new Image;o.onload=()=>{URL.revokeObjectURL(s),t(o)},o.onerror=t=>{URL.revokeObjectURL(s),e(t)},o.src=s})}const k={async register(t,e,o={}){if(!Array.isArray(e)||0===e.length)return;const i=o.size??64,n="object"==typeof o.badge&&null!==o.badge?o.badge:void 0,r=!1===o.badge?null:{color:n?.color??"#fdb81e",ringColor:n?.ringColor??"#FFFFFF",ringWidth:n?.ringWidth??2},s=o.iconColor??(r?"#162e51":void 0);await Promise.all(e.map(async e=>{const n=e.svg,a=n?null:function(t,e){const o=t?.uris;if(!Array.isArray(o)||0===o.length)return null;const i=t=>"image/svg+xml"===t?.mimeType||"svg-icon"===t?.resourceType,n=t=>{if(!Array.isArray(t)||0===t.length)return null;if(e){const o=t.find(t=>t?.locale===e);if(o?.uriPath)return o.uriPath}return t.find(t=>t?.uriPath)?.uriPath??null};for(const t of o){if(!i(t))continue;const e=n(t.locales);if(e)return e}for(const t of o){const e=n(t?.locales);if(e)return e}return null}(e,o.preferredLocale);if(!n&&!a)return;const l=e.iconId??`amenity-${e.id}`;if(t.hasImage(l))e.iconId=l;else try{const o=await async function(t,e,o){const i=2*e,n=await A(t,i,o.iconColor),r=document.createElement("canvas");r.width=i,r.height=i;const s=r.getContext("2d");if(!s)throw new Error("2d canvas context unavailable");if(o.badge){const t=i/2,e=i/2,r=2*o.badge.ringWidth,a=i/2-.5,l=Math.max(0,a-r);s.fillStyle=o.badge.ringColor,s.beginPath(),s.arc(t,e,a,0,2*Math.PI),s.fill(),s.fillStyle=o.badge.color,s.beginPath(),s.arc(t,e,l,0,2*Math.PI),s.fill();const c=Math.floor(1.7*l),d=(i-c)/2,u=(i-c)/2;s.drawImage(n,d,u,c,c)}else s.drawImage(n,0,0,i,i);return s.getImageData(0,0,i,i)}({url:a??void 0,inlineSvg:n??void 0},i,{iconColor:s,badge:r});t.hasImage(l)||t.addImage(l,o,{pixelRatio:2}),e.iconId=l}catch(t){x.warn("icon load failed",{amenityId:e.id,url:a,error:t?.message??String(t)})}}))}},M="poi-you-are-here-ring",S=[[16,14],[18,18],[20,24]];class C{map=null;rafId=null;startedAt=0;active=!1;start(t,e){this.active||e?.reducedMotion||(this.map=t,this.startedAt=performance.now(),this.active=!0,this.tick())}stop(){this.active=!1,null!==this.rafId&&(cancelAnimationFrame(this.rafId),this.rafId=null);const t=this.map;if(this.map=null,t)try{t.getLayer(M)&&(t.setPaintProperty(M,"circle-radius",void 0),t.setPaintProperty(M,"circle-opacity",void 0))}catch{}}tick=()=>{if(!this.active)return;const t=this.map;if(!t)return;const e=(performance.now()-this.startedAt)%2e3/2e3,o=.5-.5*Math.cos(e*Math.PI*2),i=function(t){const e=S;if(t<=e[0][0])return e[0][1];if(t>=e[e.length-1][0])return e[e.length-1][1];for(let o=1;o<e.length;o++){const[i,n]=e[o-1],[r,s]=e[o];if(t<=r)return n+(t-i)/(r-i)*(s-n)}return e[e.length-1][1]}(t.getZoom()),n=1+.55*o,r=.4-.25*o;try{t.getLayer(M)&&(t.setPaintProperty(M,"circle-radius",i*n),t.setPaintProperty(M,"circle-opacity",r))}catch{}this.rafId=requestAnimationFrame(this.tick)}}const P="units-outline-2d",T=["units-wall-extrusion","units-wall-custom-extrusion"];class z{getMap;is3dEnabled=!0;isUnits2dEnabled=!1;isFlatMode=!1;cachedExtrusionIds=null;extrusionOriginalVisibility=null;unitsExtrusionOriginalVisibility=null;unitsOutlineOriginalVisibility=null;constructor(t){this.getMap=t}onStyleData(){if(this.map){if(this.cachedExtrusionIds=null,!this.is3dEnabled){const t=this.listExtrusionLayerIds();this.setLayersVisibility(t,"none")}this.isUnits2dEnabled&&this.applyUnits2dVisibility(!0)}}set3dEnabled(t){const e=this.map;if(!e)return;const o=this.listExtrusionLayerIds();if(this.cachedExtrusionIds=o,!this.extrusionOriginalVisibility){const t={};o.forEach(o=>{try{const i=e.getLayoutProperty(o,"visibility")||"visible";t[o]=i}catch{t[o]="visible"}}),this.extrusionOriginalVisibility=t}if(t){const t=this.extrusionOriginalVisibility||{};o.forEach(o=>{const i=t[o]??"visible";try{e.getLayer(o)&&e.setLayoutProperty(o,"visibility",i)}catch{}})}else this.setLayersVisibility(o,"none");this.is3dEnabled=t,e.triggerRepaint()}toggle3d(){this.set3dEnabled(!this.is3dEnabled)}getIs3dEnabled(){return this.is3dEnabled}setUnits2dEnabled(t){const e=this.map;e&&(this.applyUnits2dVisibility(t),this.isUnits2dEnabled=t,e.triggerRepaint())}toggleUnits2d(){this.setUnits2dEnabled(!this.isUnits2dEnabled)}getIsUnits2dEnabled(){return this.isUnits2dEnabled}setFlatMode(t){this.map&&(t?(this.set3dEnabled(!1),this.setUnits2dEnabled(!0)):(this.setUnits2dEnabled(!1),this.set3dEnabled(!0)),this.isFlatMode=t)}toggleFlatMode(){this.setFlatMode(!this.isFlatMode)}getIsFlatMode(){return this.isFlatMode}applyUnits2dVisibility(t){const e=this.map;if(e){if(!this.unitsExtrusionOriginalVisibility){const t={};T.forEach(o=>{try{const i=e.getLayoutProperty(o,"visibility")||"visible";t[o]=i}catch{t[o]="visible"}}),this.unitsExtrusionOriginalVisibility=t}if(null==this.unitsOutlineOriginalVisibility)try{const t=e.getLayoutProperty(P,"visibility");this.unitsOutlineOriginalVisibility=t??"none"}catch{this.unitsOutlineOriginalVisibility="none"}if(e.getLayer(P)){const o=t?"visible":this.unitsOutlineOriginalVisibility??"none";try{e.setLayoutProperty(P,"visibility",o)}catch{}}if(t)T.forEach(t=>{if(e.getLayer(t))try{e.setLayoutProperty(t,"visibility","none")}catch{}});else{const t=this.unitsExtrusionOriginalVisibility||{};T.forEach(o=>{const i=t[o]??"visible";if(e.getLayer(o))try{e.setLayoutProperty(o,"visibility",i)}catch{}})}}}listExtrusionLayerIds(){const t=this.map;if(!t)return[];try{const e=t.getStyle(),o=e?.layers||[],i=o.filter(t=>"fill-extrusion"===t?.type).map(t=>t.id),n=Array.isArray(h)?h:[],r=[];return n.forEach(t=>{const e=o.find(e=>e.id===t);e&&"fill-extrusion"===e.type&&r.push(t)}),[...new Set([...i,...r])]}catch{return this.cachedExtrusionIds||[]}}setLayersVisibility(t,e){const o=this.map;o&&t.forEach(t=>{try{o.getLayer(t)&&o.setLayoutProperty(t,"visibility",e)}catch{}})}get map(){return this.getMap()}}function L(t,e){if(!t)return;const{center:o,zoom:i,pitch:n,bearing:r,animate:s,duration:a}=e;if(s){const e=t.getCenter(),s=o||[e.lng,e.lat],l=i??t.getZoom(),c=n??t.getPitch(),d=r??t.getBearing(),u="number"==typeof a?a:900;return void t.flyTo({center:s,zoom:l,pitch:c,bearing:d,duration:u,essential:!0})}o&&t.setCenter(o),void 0!==i&&t.setZoom(i),void 0!==n&&t.setPitch(n),void 0!==r&&t.setBearing(r)}function j(t){if(!t)return null;const e=t.getCenter(),o=(t,e=6)=>function(t,e=6){const o=Number(t.toFixed(e));return Object.is(o,-0)?0:o}(t,e);return{center:[o(e.lng),o(e.lat)],zoom:o(t.getZoom(),4),pitch:o(t.getPitch(),2),bearing:o(t.getBearing(),2)}}const B={async updatePOIs(t,e,o){const[i,n]=await Promise.all([o.getAmenities(e.id),o.getDestinations(e.id)]),r=B.buildPOIs(e,i,n,o.spriteKeys);s.setData(t,l,B.toFeatureCollection(r))},buildPOIs(t,e=[],o=[],i,n){if(!t?.id)return[];const r=t.mapId??t.id,s=[];for(const o of e||[]){if(!o.waypoints)continue;const e=o.iconId||O(o.svg,i)||void 0;for(const i of o.waypoints||[]){if(i.mapId!==r||!R(i.coordinates))continue;const[n,a]=i.coordinates,l=i.id??i._?.id;s.push({id:o.id,type:"amenity",name:o.name||"Amenity",coordinates:[n,a],iconId:e,floorId:t.id,amenityType:o.type,keywords:o.keywords||[],showLabel:!0,waypointId:l,waypoint:i})}}for(const e of o||[])if(e.waypoints)for(const o of e.waypoints||[]){if(o.mapId!==r||!R(o.coordinates))continue;const[i,n]=o.coordinates,a=o.id??o._?.id;s.push({id:e.id,type:"destination",name:e.name||"Destination",coordinates:[i,n],floorId:t.id,showLabel:!0,waypointId:a,waypoint:o})}return n&&String(n.floorId)===String(t.id)&&R(n.coordinates)&&s.push({id:"kiosk-you-are-here",type:"kiosk",name:"You are here",coordinates:n.coordinates,iconId:"YouAreHere",floorId:t.id,showLabel:!0,isYouAreHere:!0,heading:n.heading??null,waypointId:n.waypointId,waypoint:n.waypoint}),s},toFeatureCollection:t=>({type:"FeatureCollection",features:t.map(t=>{const e=t.heading;return{type:"Feature",geometry:{type:"Point",coordinates:t.coordinates},properties:{id:t.id,name:t.name,poiType:t.type,iconId:t.iconId,floorId:t.floorId,keywords:t.keywords,amenityType:t.amenityType,showLabel:!1!==t.showLabel,isYouAreHere:!0===t.isYouAreHere,heading:"number"==typeof e?e:null,hasHeading:"number"==typeof e}}})})};function E(t){return t.find(t=>t.isYouAreHere)||null}function R(t){return Array.isArray(t)&&t.length>=2}function O(t,e){if(!t||!e)return null;const o=/<svg[^>]*\bid\s*=\s*["']([^"']+)["']/i.exec(t),i=o?.[1];return i&&e.has(i)?i:null}function U(t){const e=t=>(t??"").toLowerCase(),o=e(t.name),i=(t.keywords||[]).map(t=>e(t)),n=t.extensors||{},r=e(n.type),s="kiosk"===o||o.includes("kiosk"),a=i.some(t=>t.includes("kiosk"));return s||a||"assistance"===r}class ${deps;routeAnimationFrame=null;routeAnimationStart=null;routeAnimationDurationMs=1200;routeActive=!1;routeBounds=null;lastRoutePoints=[];lastRouteFloorIds=[];routeCoordsByFloor=new Map;constructor(t){this.deps=t}buildWayfindFeatureCollection(t){if(!t)return this.deps.warn?.("wayfind :: no result"),null;const e=H(t);if(e.length<2)return this.deps.warn?.("wayfind :: not enough coordinates to draw a route",{extractedCount:e.length}),null;const o=[];let i=null;for(const t of e){const e="number"==typeof t.mapId?t.mapId:null;i&&i.floorId===e?i.coords.push(t.coordinates):(i={floorId:e,coords:[t.coordinates]},o.push(i))}const n=[];for(let t=0;t<o.length;t++){const e=o[t];if(e.coords.length<2)continue;const i={segmentIndex:t,totalSegments:o.length};null!=e.floorId&&(i.floorId=e.floorId),n.push({type:"Feature",geometry:{type:"LineString",coordinates:e.coords},properties:i})}return 0===n.length?(this.deps.warn?.("wayfind :: every floor segment was < 2 points",{segmentCount:o.length}),null):(this.deps.log?.("wayfind :: extracted segments",{featureCount:n.length,floorIds:n.map(t=>t.properties?.floorId),pointCount:e.length}),{type:"FeatureCollection",features:n})}async wayfindBetweenWaypoints(t,e,o){const i=this.deps.getMap();if(!this.deps.getVenue()||!i)return this.deps.warn?.("wayfindBetweenWaypoints :: venue or map not ready"),null;const n={accessible:o?.accessible,avoidStairs:o?.avoidStairs};let r=null;try{r=await this.deps.computeRoute(t,e,n)}catch(t){return this.deps.warn?.("wayfind :: computeRoute failed",t),null}this.deps.log?.("wayfind :: result",r);const a=this.buildWayfindFeatureCollection(r);if(!a)return r;s.setData(i,d,a),this.routeBounds=function(t){let e=1/0,o=1/0,i=-1/0,n=-1/0,r=!1;for(const s of t.features)if("LineString"===s.geometry?.type)for(const[t,a]of s.geometry.coordinates)r=!0,t<e&&(e=t),t>i&&(i=t),a<o&&(o=a),a>n&&(n=a);return r?[[e,o],[i,n]]:null}(a),this.lastRoutePoints=H(r),this.lastRouteFloorIds=(a.features||[]).map(t=>t.properties?.floorId??null),this.routeCoordsByFloor.clear();for(const t of a.features){if("LineString"!==t.geometry?.type)continue;const e=t.geometry.coordinates;if(!Array.isArray(e)||0===e.length)continue;const o=t.properties?.floorId,i="number"==typeof o?o:null,n=this.routeCoordsByFloor.get(i);n?n.push(...e):this.routeCoordsByFloor.set(i,e.slice())}this.deps.log?.("wayfind :: route source updated",{featureCount:a.features.length}),this.startRouteAnimation();const l=o?.centerMode??"route",c=o?.zoom??19,u=!0===this.deps.getReducedMotion?.();if("destination"===l){const t=[];for(const e of a.features)if("LineString"===e.geometry?.type&&Array.isArray(e.geometry.coordinates))for(const o of e.geometry.coordinates)t.push(o);if(t.length>=2){const e=t[t.length-1];i.flyTo({center:e,zoom:c,pitch:45,bearing:0,animate:!u,duration:u?0:900})}}else"route"===l&&this.fitRouteCamera(!0);return r}refitActiveFloorRoute(t){this.routeActive&&this.fitRouteCamera(!1!==t?.animate)}hasActiveRoute(){return this.routeActive}fitRouteCamera(t){const e=this.deps.getMap();if(!e)return;const o=this.deps.getCurrentFloor?.()??null,i=o&&"number"==typeof o.mapId?Number(o.mapId):o&&"number"==typeof o.id?Number(o.id):null,n=this.routeCoordsByFloor.get(null)??[],r=null!=i?this.routeCoordsByFloor.get(i)??[]:[];let s=r.length>=2?r.concat(n):[];if(s.length<2){s=[];for(const t of this.routeCoordsByFloor.values())s.push(...t)}if(s.length<2)return;const a=s.map(t=>t[0]),l=s.map(t=>t[1]),c=[[Math.min(...a),Math.min(...l)],[Math.max(...a),Math.max(...l)]];e.setMinPitch(0);const d=this.deps.getKioskHeading?.()??0,u=this.deps.getBoundsPadding();let p=null,f=0;for(const t of[1,.66,.4,.2,0])if(p=e.cameraForBounds(c,{padding:N(u,t),bearing:d}),p){f=t;break}const h=e.getContainer();this.deps.log?.("wayfind :: route fit",{activeFloorMapId:i,scopedToActiveFloor:r.length>=2,targetBearing:d,requestedPadding:u,paddingScaleApplied:f,canvas:[h.clientWidth,h.clientHeight],camera:p?{zoom:p.zoom}:"no fit at any padding"});const g=!0===this.deps.getReducedMotion?.(),y=t&&!g?800:0;p?e.easeTo({center:p.center,zoom:p.zoom-D,bearing:d,pitch:0,duration:y}):e.easeTo({pitch:0,bearing:d,duration:y})}async navigateFromKioskToDestination(t){const e=this.deps.getMap(),o=this.deps.getVenue();if(!e||!o)return null;const i=this.deps.getYouAreHerePOI();if(!i||!i.waypoint)return this.deps.warn?.("navigateFromKioskToDestination :: no you-are-here waypoint available",i),null;const n=t.waypoint||t.waypoints?.[0];if(!n)return this.deps.warn?.("navigateFromKioskToDestination :: destination has no waypoint",t),null;this.deps.log?.("navigateFromKioskToDestination :: from kiosk to destination",{kioskWaypoint:i.waypoint,destWaypoint:n});const r=this.deps.getYouAreHereCoordinates()??i.waypoint?.coordinates,s=n.coordinates||n.xyz||n._?.coordinates,a=Array.isArray(s)&&s.length>=2?[Number(s[0]),Number(s[1])]:null;return r&&a?this.showRouteContext(r,a):this.deps.warn?.("navigateFromKioskToDestination :: could not derive endpoint coordinates",{fromCoords:r,rawDest:s}),this.wayfindBetweenWaypoints(i.waypoint,n,{centerMode:"route"})}getLastRoutePoints(){return this.lastRoutePoints}getLastRouteFloorIds(){return this.lastRouteFloorIds}clearRoute(){const t=this.deps.getMap();if(!t)return;this.stopRouteAnimation();if(s.setData(t,d,{type:"FeatureCollection",features:[]}),this.routeBounds=null,this.lastRoutePoints=[],this.lastRouteFloorIds=[],this.routeCoordsByFloor.clear(),t.getMinPitch()<30){t.setMinPitch(30);const e=!0===this.deps.getReducedMotion?.();t.easeTo({pitch:45,duration:e?0:400})}this.deps.log?.("wayfind :: route cleared")}getActiveRouteBounds(){return this.routeActive?this.routeBounds:null}setPoiLayersVisible(t){const e=this.deps.getMap();if(!e)return;const o=t?"visible":"none";["poi-accessibility-icons","poi-destination-circles","poi-destination-labels","poi-entrance-exit-icons","poi-parking-icons","poi-other-amenity-icons"].forEach(t=>{e.getLayer(t)&&e.setLayoutProperty(t,"visibility",o)})}updateRouteEndpoints(t,e){const o=this.deps.getMap();if(!o)return;const i=o.getSource("route-endpoints");if(!i)return;const n={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{role:"source"}},{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{role:"destination"}}]};i.setData(n)}clearRouteEndpoints(){const t=this.deps.getMap();if(!t)return;const e=t.getSource("route-endpoints");if(!e)return;e.setData({type:"FeatureCollection",features:[]})}showRouteContext(t,e){this.updateRouteEndpoints(t,e)}hideRouteContext(){this.setPoiLayersVisible(!0),this.clearRouteEndpoints()}startRouteAnimation(){const t=this.deps.getMap();if(!t)return;if("undefined"==typeof window)return;if(null!=this.routeAnimationFrame&&(cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null),this.routeAnimationStart=performance.now(),this.routeActive=!0,!0===this.deps.getReducedMotion?.())return t.getLayer("route-line")&&(t.setPaintProperty("route-line","line-gradient",void 0),t.setPaintProperty("route-line","line-color","#007aff")),void(t.getLayer("route-halo")&&(t.setPaintProperty("route-halo","line-gradient",void 0),t.setPaintProperty("route-halo","line-color","#ffffff")));const e=this.deps.debug,o=t=>{const i=this.deps.getMap();if(!i||!this.routeActive||null==this.routeAnimationStart)return;const n=t-this.routeAnimationStart,r=Math.min(1,n/this.routeAnimationDurationMs),s=Math.max(.001,r);e&&this.deps.log?.("route animation frame",{t:r,clamped:s});const a=.001,l=Math.min(Math.max(s-.01,a),.998),c=Math.min(Math.max(s+.01,l+a),.999),d=["interpolate",["linear"],["line-progress"],0,"rgba(0,122,255,1.0)",l,"rgba(0,122,255,1.0)",c,"rgba(0,122,255,0.0)",1,"rgba(0,122,255,0.0)"],u=["interpolate",["linear"],["line-progress"],0,"rgba(255,255,255,0.7)",l,"rgba(255,255,255,0.7)",c,"rgba(255,255,255,0.0)",1,"rgba(255,255,255,0.0)"];i.getLayer("route-line")&&i.setPaintProperty("route-line","line-gradient",d),i.getLayer("route-halo")&&i.setPaintProperty("route-halo","line-gradient",u),this.routeAnimationFrame=r<1?requestAnimationFrame(o):null};this.routeAnimationFrame=requestAnimationFrame(o)}stopRouteAnimation(){this.routeActive=!1,null!=this.routeAnimationFrame&&"undefined"!=typeof window&&cancelAnimationFrame(this.routeAnimationFrame),this.routeAnimationFrame=null,this.routeAnimationStart=null;const t=this.deps.getMap();t&&(t.getLayer("route-line")&&(t.setPaintProperty("route-line","line-gradient",void 0),t.setPaintProperty("route-line","line-color","#007aff")),t.getLayer("route-halo")&&(t.setPaintProperty("route-halo","line-gradient",void 0),t.setPaintProperty("route-halo","line-color","#ffffff")))}}const D=0;function N(t,e){return"number"==typeof t?t*e:{top:t.top*e,bottom:t.bottom*e,left:t.left*e,right:t.right*e}}function H(t){const e=[],o=t=>{if(!t)return;const o=t.coordinates||t.xyz||t._?.coordinates;if(!Array.isArray(o)||o.length<2)return;const i=Number(o[0]),n=Number(o[1]);Number.isFinite(i)&&Number.isFinite(n)&&e.push({coordinates:[i,n],mapId:"number"==typeof t.mapId?t.mapId:void 0,waypointId:"number"==typeof t.waypointId?t.waypointId:void 0,pathTypeId:"number"==typeof t.pathTypeId?t.pathTypeId:void 0,isEndpoint:!0===t.isEndpoint})};return Array.isArray(t)?t.length>0&&Array.isArray(t[0]?.points)?t[0].points.forEach(o):t.forEach(o):Array.isArray(t?.points)?t.points.forEach(o):Array.isArray(t?.path)?t.path.forEach(o):Array.isArray(t?.paths?.[0]?.points)&&t.paths[0].points.forEach(o),e}function K(t){const[e,o]=t.coordinates??[];return`${t.mapId}|${e}|${o}`}class V{getVenue;getFloors;getFloorById;logFn;constructor(t){this.getVenue=t.getVenue,this.getFloors=t.getFloors,this.getFloorById=t.getFloorById,this.logFn=t.log}get venue(){return this.getVenue()}log(...t){this.logFn&&this.logFn(...t)}loadForFloor(t){if(!t||!this.venue)return[];try{const e=this.venue.amenities?.getByMap(t.id)||[];return Array.isArray(e)?e.map(e=>{const o=e;return o.floorId=t.id,o}):[]}catch{return[]}}getAll(){return this.getFloors().flatMap(t=>this.loadForFloor(t))}getDistinct(){const t=new Map;for(const e of this.getFloors())for(const o of this.loadForFloor(e)){const e=String(o.id),i=t.get(e);if(!i){const i={id:o.id,name:o.name,svg:o.svg,uris:o.uris,iconId:o.iconId,keywords:o.keywords,type:o.type,extensors:o.extensors,waypoints:[...o.waypoints??[]]};t.set(e,i);continue}const n=new Set((i.waypoints??[]).map(K));for(const t of o.waypoints??[]){const e=K(t);n.has(e)||((i.waypoints??=[]).push(t),n.add(e))}}return Array.from(t.values())}getByFloorId(t){const e=this.getFloorById(t);return e?this.loadForFloor(e):[]}getAllKiosks(){return this.getAll().filter(t=>U(t))}getKioskForFloor(t){const e=this.getFloorById(t);if(!e)return null;return this.loadForFloor(e).find(t=>U(t))??null}logKioskForFloor(t){const e=this.getFloorById(t);if(!e)return;const o=this.getKioskForFloor(t);o?this.log("amenity :: kiosk found",{floorId:e.id,id:o.id,name:o.name,keywords:o.keywords,waypoints:o.waypoints,raw:o}):this.log("amenity :: kiosk not found on floor",{floorId:e.id})}}const J="poi-highlight-ring";class W{getMap;log;raf=null;constructor(t){this.getMap=t.getMap,this.log=t.log??(()=>{})}highlight(t){const e=this.getMap();e&&(s.setData(e,u,{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:t},properties:{}}]}),this.log("highlight :: set",t),this.startPulse())}clear(){this.stopPulse();const t=this.getMap();t&&s.setData(t,u,{type:"FeatureCollection",features:[]})}destroy(){this.stopPulse()}startPulse(){const t=this.getMap();if(!t||!t.getLayer(J))return;if(this.stopPulse(),"undefined"!=typeof window&&!0===window.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return void this.applyRing(t,.35);const e=performance.now(),o=i=>{const n=(i-e)%1600/1600;this.applyRing(t,n),this.raf=requestAnimationFrame(o)};this.raf=requestAnimationFrame(o)}applyRing(t,e){t.getLayer(J)&&(t.setPaintProperty(J,"circle-radius",14+26*e),t.setPaintProperty(J,"circle-opacity",.45*(1-e)))}stopPulse(){null!=this.raf&&(cancelAnimationFrame(this.raf),this.raf=null)}}function _(t){return t?`?locale=${encodeURIComponent(t)}`:""}y({enabled:!0,prefix:"MinuteMapsSDK"});class Y{mode;proxyBaseUrl;direct;fetchImpl;tokenCache=null;constructor(t){const e="undefined"!=typeof window?window:globalThis,o=t.fetchImpl??e.fetch;if("function"!=typeof o)throw new Error("Fetch API is not available in this environment");this.fetchImpl=o.bind(e),this.mode=t.mode,this.proxyBaseUrl=("proxy"===t.mode?t.proxyBaseUrl:void 0)||"/api/jacs","direct"===t.mode?this.direct={host:this.normalizeHost(t.host),clientId:t.clientId,username:t.username,password:t.password}:this.direct=null}async getPolygonLayers(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/polygon-layer`,o=await this.getJson(e);return this.extractArray(o)}async getFloorMapTemplate3d(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor/${encodeURIComponent(String(t.floorId))}/map-template/3d`,o=await this.getJson(e);return this.extractArray(o)}async getFloors(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor`+_(t.locale),o=await this.getJson(e);return this.extractArray(o)}async getVenueAll(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/all`,o=await this.getJson(e),i=o?.data||o?.result||o;if(!i||"object"!=typeof i)throw new Error("JACS venue/all response was not a JSON object");return i}async getVenue(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}`,o=await this.getJson(e),i=o?.venue||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS venue response was not a JSON object");return i}async getFloorMapGeojson(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/floor/${encodeURIComponent(String(t.floorId))}/map/geojson`,o=await this.getJson(e),i=o?.geojson||o?.data||o;if(!i||"FeatureCollection"!==i.type||!Array.isArray(i.features))throw new Error("JACS floor geojson did not look like a GeoJSON FeatureCollection");return i}async getBuildingFull(t){const e=new URLSearchParams;e.set("mapProfile",String(t.mapProfile??"public")),e.set("geojson",String(t.geojson??!0));const o=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/full?${e.toString()}`,i=await this.getJson(o),n=i?.data||i?.result||i;if(!n||"object"!=typeof n)throw new Error("JACS building full response was not a JSON object");return n}async getDestinations(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/destination`+_(t.locale),o=await this.getJson(e);return this.extractArray(o)}async getAmenities(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/amenity`+_(t.locale),o=await this.getJson(e);return this.extractArray(o)}async getBuildings(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building`,o=await this.getJson(e);return this.extractArray(o)}async getStylesheet3d(t){const e=`/customer/${encodeURIComponent(String(t.customerId))}/venue/${encodeURIComponent(String(t.venueId))}/building/${encodeURIComponent(String(t.buildingId))}/stylesheet/3d`,o=await this.getJson(e),i=o?.style||o?.data||o;if(!i||"object"!=typeof i)throw new Error("JACS stylesheet response was not a JSON object");return i}invalidateToken(){this.tokenCache=null}async getJson(t){if("proxy"===this.mode){const e=this.proxyBaseUrl.replace(/\/+$/,""),o=t.startsWith("/")?t:`/${t}`,i=await this.fetchImpl(`${e}${o}`,{method:"GET",headers:{Accept:"application/json"}});if(!i.ok){const t=await this.safeReadText(i);throw new Error(`JACS proxy GET failed (${i.status} ${i.statusText}) :: ${t}`)}return await i.json()}const e=this.direct;if(!e)throw new Error("JacsProvider is not configured for direct mode");const o=await this.getJwtToken(),i=this.joinUrl(e.host,t),n=await this.fetchImpl(i,{method:"GET",headers:{Authorization:`Bearer ${o}`,Accept:"application/json"}});if(!n.ok){const t=await this.safeReadText(n);throw new Error(`JACS GET failed (${n.status} ${n.statusText}) :: ${t}`)}return await n.json()}extractArray(t){return(Array.isArray(t)?t:null)||(Array.isArray(t?.data)?t.data:null)||(Array.isArray(t?.items)?t.items:null)||(Array.isArray(t?.results)?t.results:null)||[]}async getJwtToken(){const t=this.direct;if(!t)throw new Error("getJwtToken should not be called in proxy mode");const e=Date.now(),o=this.tokenCache;if(o?.token&&e<o.expiresAtMs-3e4)return o.token;const i=this.joinUrl(t.host,"/auth/token"),n=new URLSearchParams;n.set("grant_type","password"),n.set("client_id",t.clientId),n.set("username",t.username),n.set("password",t.password);const r=await this.fetchImpl(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},body:n.toString()});if(!r.ok){const t=await this.safeReadText(r);throw new Error(`JACS auth failed (${r.status} ${r.statusText}) :: ${t}`)}const s=await r.json(),a=s?.access_token||s?.token||s?.jwt||s?.accessToken;if(!a)throw new Error("JACS auth response did not contain a token");const l=s?.expires_in??s?.expiresIn??s?.expires??s?.ttl,c="number"==typeof l?l:Number(l),d=Number.isFinite(c)&&c>0?c:600;return this.tokenCache={token:a,expiresAtMs:Date.now()+1e3*d},a}normalizeHost(t){return String(t||"").replace(/\/+$/,"")}joinUrl(t,e){const o=this.normalizeHost(t),i=String(e||"");return i?`${o}${i.startsWith("/")?"":"/"}${i}`:o}async safeReadText(t){try{return await t.text()}catch{return""}}}function G(t){const e=new Map,o=new Map,i=new Map,n=new Map;for(const e of t.pathTypes)i.set(e.id,e);for(const i of t.waypoints){if(!i.status)continue;const t=q(i.mapId,i.id),r={key:t,waypointId:i.id,mapId:i.mapId,pixel:[i.coordinates[0],i.coordinates[1]],geo:i.geo};e.set(t,r),o.set(t,[]);const s=n.get(i.mapId)??[];s.push(t),n.set(i.mapId,s)}const r=new Map;for(const t of e.values())r.set(t.waypointId,t.key);const s=(t,e,i,n,r)=>{const s="boolean"==typeof t.bidirectional?t.bidirectional:0===t.direction,a=function(t,e){const o=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(o*o+i*i)}(n.pixel,r.pixel),l={id:t.id,fromKey:e,toKey:i,pathTypeId:t.pathTypeId,bidirectional:s,pixelLength:a,meta:t.extensors&&Object.keys(t.extensors).length?t.extensors:void 0};o.get(e).push({neighbor:i,edge:l}),s&&o.get(i).push({neighbor:e,edge:l})};for(const o of t.paths){if(!o.status)continue;const t=o.waypointIds;if(!Array.isArray(t)||t.length<2)continue;const i=[];for(const o of t){const t=r.get(o);if(!t)continue;const n=e.get(t);n&&i.push({key:t,node:n})}if(i.length<2)continue;const n=new Set;for(const t of i)n.add(t.node.mapId);if(n.size>1)for(let t=0;t<i.length;t++)for(let e=t+1;e<i.length;e++){const n=i[t],r=i[e];n.key!==r.key&&s(o,n.key,r.key,n.node,r.node)}else for(let t=1;t<i.length;t++){const e=i[t-1],n=i[t];e.key!==n.key&&s(o,e.key,n.key,e.node,n.node)}}return{nodes:e,adjacency:o,pathTypes:i,nodesByMapId:n}}function q(t,e){return`${t}:${e}`}function Z(t,e){for(const o of t.nodes.values())if(o.waypointId===e)return o;return null}function X(t){return`connector-${t}`}const Q={elevator:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <rect x="5" y="3" width="14" height="18" rx="1.5"/>\n <line x1="12" y1="3" x2="12" y2="21"/>\n <polyline points="8.5,8 9.75,6.5 11,8"/>\n <polyline points="13,16 14.25,17.5 15.5,16"/>\n </svg>',stairs:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <polyline points="3,21 7,21 7,17 11,17 11,13 15,13 15,9 19,9 19,5 21,5"/>\n </svg>',escalator:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n <line x1="3" y1="21" x2="21" y2="5"/>\n <circle cx="6" cy="19" r="1.25"/>\n <circle cx="12" cy="13" r="1.25"/>\n <circle cx="18" cy="7" r="1.25"/>\n </svg>'};function tt(t){return"elevator"===t?"Elevator":"escalator"===t?"Escalator":"Stairs"}const et=y({enabled:!0,prefix:"MinuteMapsSDK jacs"});function ot(t){return null!=t&&"object"==typeof t?t.id:t}class it{config;jacs;floors=[];buildingId=null;destinationsByMapId=new Map;amenitiesByMapId=new Map;mapLabelsByMapId=new Map;zonesByMapId=new Map;zonesByDestinationId=new Map;venueLike=null;wayfindingGraph=null;async init(t){this.config=t;const e=t.jacs;if(!e?.mode)throw new Error("config.jacs.mode is required");if("proxy"!==e.mode){if(!e.host)throw new Error("config.jacs.host is required (direct mode)");if(!e.auth?.clientId)throw new Error("config.jacs.auth.clientId is required (direct mode)");if(!e.auth?.username)throw new Error("config.jacs.auth.username is required (direct mode)");if(!e.auth?.password)throw new Error("config.jacs.auth.password is required (direct mode)");this.jacs=new Y({mode:"direct",host:e.host,clientId:e.auth.clientId,username:e.auth.username,password:e.auth.password})}else this.jacs=new Y({mode:"proxy",proxyBaseUrl:e.proxyBaseUrl||"/api/jacs"})}async loadVenue(){const t=this.config.jmap.customerId,e=this.config.jmap.venueId;if(null==t)throw new Error("config.jmap.customerId is required");if(null==e)throw new Error("config.jmap.venueId is required");const o=await this.jacs.getVenueAll({customerId:t,venueId:e}),i=Array.isArray(o?.buildings)?o.buildings:[],n=i[0],r=n?.id??n?.buildingId;if(!n||!r)throw new Error("No buildings found for this venue in /all response");this.buildingId=r;const s=Array.isArray(o?.waypoints)?o.waypoints:[],a=Array.isArray(o?.destinations)?o.destinations:[],l=Array.isArray(o?.amenities)?o.amenities:[],c=new Map;for(const t of s){const e=t?.mapId;if(null==e)continue;const o=c.get(e)??[];o.push(t),c.set(e,o)}const d=Array.isArray(n?.floors)?n.floors:[],u=n?.defaultFloorId,p=d.map(t=>{const e=t.map?.id??t.mapId;return{id:t.id,mapId:e,name:t.name??t.shortName??String(t.id),sequence:t.level??t.preference,isDefault:t.id===u,geojson:void 0,mapTemplate3d:[],_waypoints:null!=e?c.get(e)??[]:[]}});this.floors=p;const f=new Map;for(const t of p)null!=t.mapId&&f.set(t.mapId,t.id);const h=o?.venue?.coordinates,g=new Map;for(const t of d){const e=t?.map?.id??t?.mapId,o="string"==typeof t?.map?.svg?t.map.svg:"";if(null==e||!o)continue;const i=/viewBox\s*=\s*["']([^"']+)["']/i.exec(o);if(!i)continue;const n=i[1].trim().split(/\s+/).map(Number);if(4!==n.length||n.some(t=>!Number.isFinite(t)))continue;const[,,r,s]=n;r>0&&s>0&&g.set(e,{width:r,height:s})}const y=(t,e,o)=>{if(!h)return null;const i=g.get(t);if(!i)return null;return[h.topLng+e/i.width*(h.bottomLng-h.topLng),h.topLat+o/i.height*(h.bottomLat-h.topLat)]},m=new Map;for(const t of s){const e=t?.id;if(null!=e){if(!Array.isArray(t.coordinates)&&null!=t.x&&null!=t.y&&null!=t.mapId){const e=y(t.mapId,Number(t.x),Number(t.y));e&&(t.coordinates=e)}m.set(e,t)}}this.wayfindingGraph=function(t,e){const o=[];for(const t of e)"number"==typeof t?.id&&"number"==typeof t?.mapId&&null!=t?.x&&null!=t?.y&&o.push({id:t.id,mapId:t.mapId,status:!1!==t.status,coordinates:[Number(t.x),Number(t.y)],geo:Array.isArray(t.coordinates)?[t.coordinates[0],t.coordinates[1]]:null});const i=[];for(const e of Array.isArray(t?.paths)?t.paths:[]){const t=e?.waypoints??e?.waypointIds;if("number"==typeof e?.id&&Array.isArray(t)&&t.length>=2&&t.every(t=>"number"==typeof t)){const o="number"==typeof e.direction?e.direction:0;i.push({id:e.id,pathTypeId:"number"==typeof e.pathTypeId?e.pathTypeId:0,direction:o,bidirectional:0===o,status:!1!==e.status,waypointIds:t.slice(),extensors:e.extensors})}}return G({waypoints:o,paths:i,pathTypes:(Array.isArray(t?.pathTypes)?t.pathTypes:[]).filter(t=>"number"==typeof t?.id).map(t=>({id:t.id,name:t.name??"",description:t.description}))})}(o,s);let w=null;const b=this.config?.jmap?.deviceId,I=Array.isArray(o?.devices)?o.devices:[],v=t=>null==t?.id?null:s.find(e=>Array.isArray(e?.deviceIds)&&e.deviceIds.includes(t.id))??null;let F=null;null!=b&&""!==b&&(F=I.find(t=>String(t?.id)===String(b)||t?.uuid===b)??null,F||et.warn("configured kiosk deviceId not found in this venue; falling back to a placed device",{deviceId:b}));let x=v(F);if(!x){const t=I.find(t=>v(t));t&&(null!=b&&""!==b?et.warn("anchoring You-are-here to a placed device as fallback",{configured:b,using:t.name??t.id}):et.debug("no kiosk deviceId configured; anchoring to placed device",{using:t.name??t.id}),F=t,x=v(t))}if(x&&Array.isArray(x.coordinates)){const t=F?.heading,e="number"==typeof t&&Number.isFinite(t)?t:null;w={waypointId:x.id,floorId:f.get(x.mapId)??x.mapId,coordinates:x.coordinates,deviceName:F?.name,heading:e,waypoint:x}}else I.length>0&&et.warn("venue has device(s) but none are placed on a waypoint; no You-are-here anchor");const A=t=>Array.isArray(t)?t.map(t=>t&&"object"==typeof t?t:m.get(t)).filter(Boolean):[];for(const t of l)t.waypoints=A(t?.waypoints);for(const t of a)t.waypoints=A(t?.waypoints);const k=new Map;for(const t of Array.isArray(o?.pathTypes)?o.pathTypes:[]){const e=(t?.name??"").toString().toLowerCase();e&&(/elev|lift/.test(e)?k.set(t.id,"elevator"):/escalat/.test(e)?k.set(t.id,"escalator"):/stair|step/.test(e)&&k.set(t.id,"stairs"))}const M=Array.isArray(o?.paths)?o.paths:[];for(const t of M){if(!1===t?.status)continue;const e=(t?.name??"").toString().toLowerCase();let o;if(/elev|lift/.test(e)?o="elevator":/escalat/.test(e)?o="escalator":/stair|step/.test(e)&&(o="stairs"),o||"number"!=typeof t.pathTypeId||(o=k.get(t.pathTypeId)),!o)continue;const i=Array.isArray(t.waypoints)?t.waypoints:t.waypointIds;if(!Array.isArray(i)||0===i.length)continue;const n=A(i);if(0===n.length)continue;const r={id:`connector-${o}-${t.id}`,name:t.name&&String(t.name).trim()?String(t.name):tt(o),type:tt(o),svg:Q[o],iconId:X(o),keywords:[o],waypoints:n,_connector:!0};l.push(r)}this.amenitiesByMapId.clear();for(const t of l)for(const e of t?.waypoints??[]){const o=e?.mapId;if(null==o)continue;const i=f.get(o)??o,n=this.amenitiesByMapId.get(i)??[];n.push(t),this.amenitiesByMapId.set(i,n)}this.destinationsByMapId.clear();for(const t of a)for(const e of t?.waypoints??[]){const o=e?.mapId;if(null==o)continue;const i=f.get(o)??o,n=this.destinationsByMapId.get(i)??[];n.push(t),this.destinationsByMapId.set(i,n)}this.mapLabelsByMapId.clear();const S=Array.isArray(o?.mapLabels)?o.mapLabels:[],C=p.map(t=>t.id);for(const t of S){if(!1===t?.status)continue;const e=t?.name??"",o=Array.isArray(t?.instances)?t.instances:[];for(const i of o){const o=i?.mapId,n=Number(i?.xPosition),r=Number(i?.yPosition);if(null==o||!Number.isFinite(n)||!Number.isFinite(r))continue;const s=y(o,n,r);if(!s)continue;const a={id:i.id,labelId:t.id,name:e,coordinates:s,mapId:o,rotation:"number"==typeof i.rotation?i.rotation:0,allLevels:1===i?.allLevels||!0===i?.allLevels},l=a.allLevels?C:[f.get(o)??o];for(const t of l){const e=this.mapLabelsByMapId.get(t)??[];e.push(a),this.mapLabelsByMapId.set(t,e)}}}this.zonesByMapId.clear(),this.zonesByDestinationId.clear();const P=Array.isArray(o?.zones)?o.zones:[];for(const t of P){if(!1===t?.status)continue;const e=t?.mapId;if(null!=e){const o=f.get(e)??e,i=this.zonesByMapId.get(o)??[];i.push(t),this.zonesByMapId.set(o,i)}const o=Array.isArray(t?.destinationIds)?t.destinationIds:Array.isArray(t?.destinations)?t.destinations:[];for(const e of o){const o="object"==typeof e&&null!=e?e.id:e;if(null==o)continue;const i=this.zonesByDestinationId.get(o)??[];i.push(t),this.zonesByDestinationId.set(o,i)}}const T=o?.venue??{};if(this.venueLike={...T,floors:p,polygonLayers:[],destinations:{items:[...a],getByMap:t=>this.destinationsByMapId.get(ot(t))??[]},amenities:{items:[...l],getByMap:t=>this.amenitiesByMapId.get(ot(t))??[]},mapLabels:{items:[...S],getByMap:t=>this.mapLabelsByMapId.get(ot(t))??[]},zones:{items:[...P],getByMap:t=>this.zonesByMapId.get(ot(t))??[],getByDestination:t=>this.zonesByDestinationId.get(ot(t))??[]},buildings:{items:[...i],getAllFloors:()=>this.floors},styleSheet:null,kioskWaypoint:w},this.config?.jmap?.locale)try{await this.applyLocale(this.config.jmap.locale)}catch{}return this.venueLike}async applyLocale(t){if(!t)return;if(!this.venueLike)return;const e=this.config.jmap.customerId,o=this.config.jmap.venueId,i=this.buildingId;if(null!=e&&null!=o&&null!=i)try{const[n,r,s]=await Promise.all([this.jacs.getDestinations({customerId:e,venueId:o,locale:t}),this.jacs.getAmenities({customerId:e,venueId:o,locale:t}),this.jacs.getFloors({customerId:e,venueId:o,buildingId:i,locale:t})]),a=t=>{const e=new Map;for(const o of t)null!=o?.id&&e.set(o.id,o);return e},l=a(n),c=a(r),d=a(s),u=(t,e)=>{e&&(null!=e.name&&(t.name=e.name),null!=e.description&&(t.description=e.description))};for(const t of this.venueLike.destinations?.items??[])u(t,l.get(t?.id));for(const t of this.venueLike.amenities?.items??[])u(t,c.get(t?.id));for(const t of this.floors)u(t,d.get(t.id))}catch(e){throw et.warn("locale merge failed; staying on prior locale",{locale:t,e:e}),e}}async ensureFloorGeojson(t){if(t.geojson)return;const e=this.config.jmap.customerId,o=this.config.jmap.venueId;try{const i=await this.jacs.getFloorMapGeojson({customerId:e,venueId:o,buildingId:this.buildingId,floorId:t.id});t.geojson=function(t){return(t?.type?t:t?.data)??null}(i)}catch(e){et.warn("floor geojson fetch failed",{floorId:t.id,e:e})}}async preloadRemainingFloors(){const t=this.floors.filter(t=>!t.geojson);0!==t.length&&(await Promise.all(t.map(t=>this.ensureFloorGeojson(t))),et.debug("preloaded geojson for remaining floors",{count:t.length}))}async getFloors(){return this.floors}async getAmenities(t){return this.amenitiesByMapId.get(t)??[]}async getDestinations(t){return this.destinationsByMapId.get(t)??[]}getWayfindingGraph(){return this.wayfindingGraph}}function nt(t,e,o,i){if(!t.nodes.has(e)||!t.nodes.has(o))return null;if(e===o)return{keys:[e],cost:0};const n=new Map,r=new Map;n.set(e,0);const s=new rt((t,e)=>t.cost-e.cost);for(s.push({key:e,cost:0});s.size()>0;){const{key:e,cost:a}=s.pop();if(e===o)break;if(a>(n.get(e)??1/0))continue;const l=t.adjacency.get(e);if(l)for(const{neighbor:t,edge:o}of l){const l=i(o);if(!Number.isFinite(l)||l<0)continue;const c=a+l;c<(n.get(t)??1/0)&&(n.set(t,c),r.set(t,e),s.push({key:t,cost:c}))}}if(!n.has(o))return null;const a=[];let l=o;for(;null!=l;)if(a.unshift(l),l=r.get(l),void 0===l&&a[0]!==e)return null;return{keys:a,cost:n.get(o)}}class rt{compare;data=[];constructor(t){this.compare=t}size(){return this.data.length}push(t){this.data.push(t),this.bubbleUp(this.data.length-1)}pop(){if(0===this.data.length)return;const t=this.data[0],e=this.data.pop();return this.data.length>0&&(this.data[0]=e,this.sinkDown(0)),t}bubbleUp(t){const e=this.data[t];for(;t>0;){const o=t-1>>1;if(this.compare(e,this.data[o])>=0)break;this.data[t]=this.data[o],t=o}this.data[t]=e}sinkDown(t){const e=this.data.length,o=this.data[t];for(;;){const i=2*t+1,n=i+1;let r=-1;if(i<e&&this.compare(this.data[i],o)<0&&(r=i),n<e&&this.compare(this.data[n],-1===r?o:this.data[i])<0&&(r=n),-1===r)break;this.data[t]=this.data[r],t=r}this.data[t]=o}}const st=new Set([]),at=new Set([]),lt=new Set([]);function ct(t){const e=Boolean(t.accessible),o=Boolean(t.avoidStairs);return t=>{const i=t.pixelLength;if(o&&dt(t))return 1/0;if(e&&function(t){return!1===t.meta?.accessible||dt(t)}(t))return 1/0;if(dt(t))return 1.5*i;if(e){if(function(t){return!!at.has(t.pathTypeId)||!0===t.meta?.ramp}(t))return.95*i;if(function(t){return!!lt.has(t.pathTypeId)||!0===t.meta?.elevator}(t))return.95*i}return i}}function dt(t){return!!st.has(t.pathTypeId)||!0===t.meta?.stairs}function ut(t){if(!t)return null;const e=t.coordinates??t.xyz??t._?.coordinates;if(!Array.isArray(e)||e.length<2)return null;const o=Number(e[0]),i=Number(e[1]);return Number.isFinite(o)&&Number.isFinite(i)?[o,i]:null}class pt{deps;warn;constructor(t){this.deps=t,this.warn=t.warn??((t,e)=>console.warn(`[wayfinding] ${t}`,e??""))}async init(t){}async wayfindBetweenWaypoints(t){const{from:e,to:o,options:i}=t,n=this.deps.getGraph(),r=ut(e),s=ut(o);if(!n)return this.warn("graph not ready"),function(t,e){return t&&e?{points:[{coordinates:t,isEndpoint:!0},{coordinates:e,isEndpoint:!0}]}:null}(r,s);const a=ft(n,e),l=ft(n,o);if(!a||!l)return this.warn("could not resolve start/end waypoint to a graph node",{fromId:e?.id,toId:o?.id}),null;const c=nt(n,a.key,l.key,ct(i??{}));if(!c)return this.warn("no path found",{from:a.key,to:l.key}),null;const d=new Map;for(let t=1;t<c.keys.length;t++){const e=c.keys[t-1],o=c.keys[t],i=(n.adjacency.get(e)??[]).find(t=>t.neighbor===o);i&&d.set(o,i.edge.pathTypeId)}const u=[],p=c.keys.length-1;for(let t=0;t<=p;t++){const e=c.keys[t],o=n.nodes.get(e);let i=o?.geo??null;0===t&&r&&(i=r),t===p&&s&&(i=s),i&&u.push({coordinates:i,mapId:o?.mapId,waypointId:o?.waypointId,pathTypeId:0===t?void 0:d.get(e),isEndpoint:0===t||t===p})}return u.length<2?(this.warn("route nodes had no projected coordinates",{keys:c.keys.length}),null):{points:u}}}function ft(t,e){if(!e||null==e.id)return null;const o="number"==typeof e.id?e.id:Number(e.id);if(!Number.isFinite(o))return null;if("number"==typeof e.mapId){const i=t.nodes.get(q(e.mapId,o));if(i)return i}return Z(t,o)}function ht(t){const{graph:e,kiosk:o}=t;if(!e||!o?.id)return null;const n=function(t,e){if(null==e?.id)return null;const o="number"==typeof e.id?e.id:Number(e.id);if(!Number.isFinite(o))return null;if("number"==typeof e.mapId){const i=t.nodes.get(q(e.mapId,o));if(i)return i}return Z(t,o)}(e,o);if(!n)return null;const r=function(t){if(null==t)return null;if("number"==typeof t)return t;if("string"==typeof t){const e=Number(t);return Number.isFinite(e)?e:null}if("id"in t&&null!=t.id){const e="number"==typeof t.id?t.id:Number(t.id);return Number.isFinite(e)?e:null}if("waypoints"in t&&Array.isArray(t.waypoints)&&t.waypoints.length>0){const e=t.waypoints[0];if(null==e)return null;if("number"==typeof e)return e;if("string"==typeof e){const t=Number(e);return Number.isFinite(t)?t:null}if("object"==typeof e&&null!=e.id){const t="number"==typeof e.id?e.id:Number(e.id);return Number.isFinite(t)?t:null}}return null}(t.target);if(null==r)return null;const s=("object"==typeof t.target&&"mapId"in t.target&&"number"==typeof t.target.mapId?e.nodes.get(q(t.target.mapId,r)):null)??Z(e,r);if(!s)return null;const a=nt(e,n.key,s.key,t=>t.pixelLength);if(!a)return null;let l=0;for(let t=1;t<a.keys.length;t++){const o=e.nodes.get(a.keys[t-1])?.geo,n=e.nodes.get(a.keys[t])?.geo;o&&n&&(l+=i.distance(i.point(o),i.point(n),{units:"meters"}))}const c=t.options?.walkingSpeedMps??1.2,d=Math.max(1,Math.round(l/c));return{meters:Math.round(l),seconds:d,pathNodeCount:a.keys.length}}function gt(t,e,o){const{startIdx:n,endIdx:r,floorId:s}=e;if(r<=n)return[];const a=[];for(let e=n;e<r;e++){const o=t[e].coordinates,n=t[e+1].coordinates,r=i.distance(i.point(o),i.point(n),{units:"meters"}),s=i.bearing(i.point(o),i.point(n));a.push({fromIdx:e,toIdx:e+1,meters:r,bearing:s})}if(0===a.length)return[];const l=[];for(let t=0;t<a.length;t++){const e=a[t];if(0===t){l.push({startIdx:e.fromIdx,endIdx:e.toIdx,meters:e.meters,bearing:e.bearing,turnInto:null});continue}const o=l[l.length-1],i=mt(o.bearing,e.bearing);if(null==i){o.endIdx=e.toIdx,o.meters+=e.meters;const t=o.meters;o.bearing=t>0?o.bearing+yt(o.bearing,e.bearing)*(e.meters/t):e.bearing}else l.push({startIdx:e.fromIdx,endIdx:e.toIdx,meters:e.meters,bearing:e.bearing,turnInto:i})}const c=[];for(let e=0;e<l.length;e++){const i=l[e],n=Math.max(0,Math.round(i.meters)),r=0===e,a=e===l.length-1;if(r&&o.isFirstLeg)c.push({type:"depart",floorId:s,pointRange:[i.startIdx,i.endIdx],distanceMeters:n,text:It(n,o.ctx.floorName(s??-1))});else if(i.turnInto){const e=bt(t[i.startIdx],s,o.ctx),r=n,a="uturn"===i.turnInto?"u-turn":"left"===i.turnInto?"turn-left":"turn-right";c.push({type:a,floorId:s,pointRange:[i.startIdx,i.endIdx],distanceMeters:r,landmark:e??void 0,text:Ft(a,e,r)})}else c.push({type:"continue",floorId:s,pointRange:[i.startIdx,i.endIdx],distanceMeters:n,text:vt(n)});if(a&&o.isLastLeg){const e=c.pop(),n=o.ctx.destinationName;wt(t,i.endIdx),c.push({type:"arrive",floorId:s,pointRange:e.pointRange,distanceMeters:e.distanceMeters,landmark:n,text:At(n)})}}return c}function yt(t,e){let o=(e-t+540)%360-180;return-180===o&&(o=180),o}function mt(t,e){const o=yt(t,e),i=Math.abs(o);return i<30?null:i>=150?"uturn":o<0?"left":"right"}function wt(t,e){return"ahead"}function bt(t,e,o){const n=[o.destinations,o.amenities,o.mapLabels];let r=null;const s=i.point(t.coordinates);for(const t of n)if(t?.length){for(const o of t){if(!o?.name)continue;if("number"==typeof o.mapId&&null!=e&&o.mapId!==e)continue;const t=o.coordinates||o.geo;if(!t||t.length<2)continue;const n=i.distance(s,i.point(t),{units:"meters"});n>5||(!r||n<r.distance)&&(r={name:o.name,distance:n})}if(r)return r.name}return null}function It(t,e){return e?`Head out on ${e} — walk ${t} m straight ahead`:`Walk ${t} m straight ahead`}function vt(t){return`Continue ${t} m`}function Ft(t,e,o){return`${"u-turn"===t?"Make a U-turn":"turn-left"===t?"Turn left":"Turn right"}${e?` at ${e}`:""} and continue ${o} m`}function xt(t,e,o){const i="elevator"===t?"Take the elevator":"escalator"===t?"Take the escalator":"Take the stairs";return e?`${i} to ${e}`:i}function At(t,e){return`You've arrived${t?` — ${t}`:""}`}class kt{handlers=new Map;on(t,e){this.handlers.has(t)||this.handlers.set(t,new Set),this.handlers.get(t).add(e)}off(t,e){e?this.handlers.get(t)?.delete(e):this.handlers.delete(t)}emit(t,e){this.handlers.get(t)?.forEach(t=>{try{t(e)}catch{}})}}var Mt={version:8,name:"Hospital Indoor Mapping - Hybrid Style Healthcare Compliant",metadata:{description:"Accessibility-focused hospital navigation with proper healthcare standards",author:"Hospital Mapping Team",version:"7.1.0"},sprite:"http://localhost:4000/sprites/sprite",glyphs:"https://demotiles.maplibre.org/font/{fontstack}/{range}.pbf",sources:{protomaps:{type:"vector",url:"pmtiles://https://jacsdevtiles-gjgbejbpdzbgcge8.z01.azurefd.net/pmtiles/base/usa.pmtiles",attribution:"© OpenStreetMap contributors"},"indoor-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"accessibility-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"unit-walls":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"route-data":{type:"geojson",data:{type:"FeatureCollection",features:[]},lineMetrics:!0},"route-endpoints":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"poi-highlight-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"map-labels-data":{type:"geojson",data:{type:"FeatureCollection",features:[]}},"route-active-step":{type:"geojson",data:{type:"FeatureCollection",features:[]}}},layers:[{id:"background",type:"background",paint:{"background-color":"#f0f0f0"}},{id:"basemap-earth",type:"fill",source:"protomaps","source-layer":"earth",paint:{"fill-color":"#EAE2D0"}},{id:"basemap-landuse-park",type:"fill",source:"protomaps","source-layer":"landuse",filter:["in",["get","kind"],["literal",["park","forest","wood","nature_reserve","grass","garden","playground","cemetery","golf_course"]]],paint:{"fill-color":"#cbe0b6","fill-opacity":["interpolate",["linear"],["zoom"],14,.95,18,.8]}},{id:"basemap-water",type:"fill",source:"protomaps","source-layer":"water",paint:{"fill-color":"#c2dbf2"}},{id:"basemap-roads-minor",type:"line",source:"protomaps","source-layer":"roads",minzoom:13,filter:["in",["get","kind"],["literal",["minor_road","path","service","other"]]],paint:{"line-color":"#FFFFFF","line-width":["interpolate",["linear"],["zoom"],13,.5,16,1.5,19,4],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"basemap-roads-major",type:"line",source:"protomaps","source-layer":"roads",minzoom:10,filter:["in",["get","kind"],["literal",["highway","major_road","medium_road"]]],paint:{"line-color":"#ecc97e","line-width":["interpolate",["linear"],["zoom"],10,.5,14,1.5,18,6],"line-opacity":["interpolate",["linear"],["zoom"],14,.9,18,.5]}},{id:"pattern-water",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Water"],paint:{"fill-color":"#cfe1ec","fill-opacity":.6}},{id:"pattern-grass",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Grass"],paint:{"fill-color":"#d2e0c6","fill-opacity":.5}},{id:"pattern-trees",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Trees"],paint:{"fill-color":"#cdd9c9","fill-opacity":.4}},{id:"pattern-pavement",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Pavement"],paint:{"fill-color":"#E0E0E0","fill-opacity":.6}},{id:"pattern-outdoor-terrace",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-OutdoorTerrace"],paint:{"fill-color":"#cabfb6","fill-opacity":.3}},{id:"parking-lots",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Parking-Lots"],paint:{"fill-color":"#e0e0dd","fill-opacity":.5}},{id:"parking-lots-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Parking-Lots"],paint:{"line-color":"#b0b0ad","line-width":1,"line-dasharray":[3,2]}},{id:"boundary-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#FAF3E2","fill-opacity":1}},{id:"building-roof-fill",type:"fill",source:"indoor-data",minzoom:15.8,filter:["==",["get","featureType"],"Boundary"],paint:{"fill-color":"#162e51","fill-opacity":["interpolate",["linear"],["zoom"],15.8,0,16.5,1]}},{id:"corridors-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"fill-color":"#F0E6D1"}},{id:"accessible-routes",type:"line",source:"accessibility-data",minzoom:16.5,filter:["==",["get","accessible"],!0],paint:{"line-color":"#2E7D32","line-width":["interpolate",["linear"],["zoom"],15,2,18,3,20,4],"line-dasharray":[.5,1],"line-opacity":.7}},{id:"units-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],paint:{"fill-color":["case",["has","category"],["match",["get","category"],"healthcare","#73b3e7","surgical","#73b3e7","waiting","#73b3e7","diagnostic","#97d4ea","amenities","#97d4ea","emergency","#f2938c","retail","#fee685","fnb","#fee685","admin","#dfe1e2","staff","#dfe1e2","security","#dfe1e2","#73b3e7"],"#73b3e7"],"fill-opacity":["interpolate",["linear"],["zoom"],15,.85,17,.92,19,.95]}},{id:"units-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Units"],layout:{visibility:"none","line-join":"round","line-cap":"round"},paint:{"line-color":"#162e51","line-opacity":.9,"line-width":["interpolate",["linear"],["zoom"],16,.8,18,1.4,20,2.2]}},{id:"backofhouse-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-color":"#e6e6e2","fill-opacity":.7}},{id:"backofhouse-pattern",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"line-color":"#c4c4c4","line-width":.5,"line-opacity":.4}},{id:"backofhouse-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#b0b1b5","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"restrooms-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-color":"#5f9070","fill-opacity":1}},{id:"restrooms-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#3f5d4a","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"obstacles-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-color":"#E8E9ED","fill-opacity":.85}},{id:"obstacles-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#B0B1B5","line-width":["interpolate",["linear"],["zoom"],16,.5,18,.9,20,1.2],"line-opacity":.9}},{id:"escalators-stairs-elevators",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-color":"#a9aeb1","fill-opacity":1}},{id:"escalators-stairs-elevators-outline-2d",type:"line",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#6f7780","line-width":["interpolate",["linear"],["zoom"],16,.6,18,1,20,1.4],"line-opacity":.9}},{id:"exits-doors",type:"fill",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Exits","Doors","Exit","Door"]]],paint:{"fill-color":"#cdd9c9","fill-opacity":.6}},{id:"kiosks-fill",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Kiosks"],paint:{"fill-color":"#ffe396","fill-opacity":.7}},{id:"pattern-lounge",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-Lounge"],paint:{"fill-color":"#ddd2e0","fill-opacity":.5}},{id:"pattern-indoor-foodcourt",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Pattern-IndoorFoodcourt"],paint:{"fill-color":"#f3e4c4","fill-opacity":.6}},{id:"corridors-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],paint:{"line-color":"#BCAAA4","line-width":["interpolate",["linear"],["zoom"],15,.5,18,1,20,1.5]}},{id:"boundary-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],paint:{"line-color":"#263238","line-width":["interpolate",["linear"],["zoom"],12,2,15,2.5,18,3,20,3.5],"line-opacity":["interpolate",["linear"],["zoom"],12,.7,17,.85,18,1]}},{id:"building-roof-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Boundary"],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#c8a85a","line-width":["interpolate",["linear"],["zoom"],15,1.5,18,2,20,2.5],"line-opacity":.55}},{id:"interior-parking-lots",type:"fill",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-color":"#757575","fill-opacity":.8}},{id:"interior-parking-lots-outline",type:"line",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"line-color":"#616161","line-width":1.5}},{id:"building-extrusion",type:"fill-extrusion",source:"indoor-data",filter:["==",["get","featureType"],"Boundary"],paint:{"fill-extrusion-color":"#162e51","fill-extrusion-height":15,"fill-extrusion-base":0,"fill-extrusion-opacity":["interpolate",["linear"],["zoom"],15.8,1,16.5,0]}},{id:"units-wall-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["all",["==",["get","featureType"],"UnitWalls"],["!",["has","custom_height"]]],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,["case",["==",["get","wallKind"],"interior"],.5,1],17.5,["case",["==",["get","wallKind"],"interior"],.7,1.4],18.2,["case",["==",["get","wallKind"],"interior"],.9,1.6]],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"units-wall-custom-extrusion",type:"fill-extrusion",source:"unit-walls",minzoom:16.5,filter:["has","custom_height"],paint:{"fill-extrusion-color":"#c4c8cb","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":1}},{id:"corridors-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["any",["==",["get","featureType"],"Corridors"],["==",["get","featureType"],"Corridor"]],layout:{visibility:"none"},paint:{"fill-extrusion-color":"#FFF8E1","fill-extrusion-height":["step",["zoom"],0,18,3.2],"fill-extrusion-base":0,"fill-extrusion-opacity":["step",["zoom"],0,18,.85]}},{id:"backofhouse-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Back-of-house"],paint:{"fill-extrusion-color":"#e6e6e2","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"restrooms-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Restrooms"],paint:{"fill-extrusion-color":"#5f9070","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.95}},{id:"obstacles-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Obstacles"],paint:{"fill-extrusion-color":"#E8E9ED","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,.4,17.5,.6,18.2,.8],"fill-extrusion-base":0,"fill-extrusion-opacity":1}},{id:"escalators-stairs-elevators-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["in",["get","featureType"],["literal",["Escalators","Stairs","Elevators"]]],paint:{"fill-extrusion-color":"#a9aeb1","fill-extrusion-height":["interpolate",["linear"],["zoom"],15.5,0,16.5,1,17.5,1.4,18.2,1.6],"fill-extrusion-base":0,"fill-extrusion-vertical-gradient":!0,"fill-extrusion-opacity":.9}},{id:"interior-parking-extrusion",type:"fill-extrusion",source:"indoor-data",minzoom:16.5,filter:["==",["get","featureType"],"Interior-ParkingLots"],paint:{"fill-extrusion-color":"#757575","fill-extrusion-height":["interpolate",["linear"],["zoom"],15,0,16,1,17,1.4,18,1.6],"fill-extrusion-base":0,"fill-extrusion-opacity":.85}},{id:"route-line",type:"line",source:"route-data",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#007aff","line-width":["interpolate",["linear"],["zoom"],16.5,3,18,5,20,7],"line-opacity":.55}},{id:"route-halo",type:"line",source:"route-data",minzoom:16.5,paint:{"line-color":"white","line-width":["interpolate",["linear"],["zoom"],16.5,5,18,7,20,9],"line-opacity":.45}},{id:"route-line-active-halo",type:"line",source:"route-active-step",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#FFFFFF","line-width":["interpolate",["linear"],["zoom"],16.5,8,18,11,20,14],"line-opacity":.85}},{id:"route-line-active",type:"line",source:"route-active-step",minzoom:16.5,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fdb81e","line-width":["interpolate",["linear"],["zoom"],16.5,5,18,7,20,9],"line-opacity":1}},{id:"route-endpoint-source",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"source"],paint:{"circle-radius":6,"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#007aff","circle-opacity":1}},{id:"route-endpoint-destination",type:"circle",source:"route-endpoints",minzoom:16.5,filter:["==",["get","role"],"destination"],paint:{"circle-radius":7,"circle-color":"#007aff","circle-stroke-width":3,"circle-stroke-color":"#ffffff","circle-opacity":1}},{id:"poi-accessibility-icons",type:"symbol",source:"poi-data",filter:["==",["get","accessible"],!0],minzoom:16.5,layout:{"icon-image":"wheelchair-accessible","icon-size":["interpolate",["linear"],["zoom"],15,.4,17,.6,19,.8],"icon-allow-overlap":!1,"icon-padding":4}},{id:"poi-destination-circles",type:"circle",source:"poi-data",filter:["==",["get","poiType"],"destination"],minzoom:16.5,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,6,18,8,20,10],"circle-color":"#ffffff","circle-stroke-width":3,"circle-stroke-color":"#162e51","circle-opacity":1}},{id:"poi-destination-labels",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"destination"],["==",["get","showLabel"],!0]],minzoom:16.5,layout:{"symbol-sort-key":0,"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16.5,18,18,20,20,23],"text-offset":[0,-.9],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-max-width":12,"text-allow-overlap":!1,"text-padding":4,"text-rotation-alignment":"viewport"},paint:{"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1}},{id:"map-labels",type:"symbol",source:"map-labels-data",minzoom:15.5,layout:{"symbol-sort-key":10,"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],15.5,13,16.5,16,18,19,20,22],"text-font":["Noto Sans Bold"],"text-letter-spacing":.04,"text-max-width":10,"text-anchor":"center","text-rotate":["get","rotation"],"text-rotation-alignment":"map","text-allow-overlap":!1,"text-padding":4},paint:{"text-color":"#3d4551","text-halo-color":"#FFFFFF","text-halo-width":1.4,"text-halo-blur":.5}},{id:"poi-entrance-exit-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","entrance",["get","keywords"]],-1],["!=",["index-of","exit",["get","keywords"]],-1],["!=",["index-of","door",["get","keywords"]],-1]]],minzoom:15,layout:{"symbol-sort-key":1,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-parking-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["any",["!=",["index-of","parking",["get","keywords"]],-1],["!=",["index-of","park",["get","keywords"]],-1]]],minzoom:14,layout:{"symbol-sort-key":2,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-other-amenity-icons",type:"symbol",source:"poi-data",filter:["all",["==",["get","poiType"],"amenity"],["==",["index-of","entrance",["get","keywords"]],-1],["==",["index-of","exit",["get","keywords"]],-1],["==",["index-of","door",["get","keywords"]],-1],["==",["index-of","parking",["get","keywords"]],-1],["==",["index-of","park",["get","keywords"]],-1]],minzoom:16.5,layout:{"symbol-sort-key":3,"icon-image":["get","iconId"],"icon-size":["interpolate",["linear"],["zoom"],16.5,.5,18,.6,20,.8],"icon-allow-overlap":!1,"icon-padding":4,"icon-optional":!1,"icon-rotation-alignment":"viewport","icon-pitch-alignment":"viewport","text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,["case",["!=",["coalesce",["get","iconId"],""],""],0,17],19,["case",["!=",["coalesce",["get","iconId"],""],""],0,19],20,["case",["!=",["coalesce",["get","iconId"],""],""],0,22]],"text-offset":[0,1.3],"text-anchor":"top","text-optional":!0,"text-padding":4,"text-font":["Noto Sans Bold"],"text-rotation-alignment":"viewport"},paint:{"icon-halo-color":"#FFFFFF","icon-halo-width":1.5,"icon-halo-blur":.5,"text-color":"#242930","text-halo-color":"#FFFFFF","text-halo-width":1.5,"text-halo-blur":1,"icon-translate":[0,-20],"icon-translate-anchor":"viewport"}},{id:"poi-you-are-here-heading",type:"symbol",source:"poi-data",filter:["all",["==",["get","isYouAreHere"],!0],["==",["get","hasHeading"],!0]],minzoom:16,layout:{"text-field":"▲","text-size":["interpolate",["linear"],["zoom"],16,28,18,34,20,42],"text-font":["Noto Sans Bold"],"text-anchor":"bottom","text-offset":[0,-.45],"text-rotate":["get","heading"],"text-rotation-alignment":"map","text-pitch-alignment":"map","text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#face00","text-halo-color":"#162e51","text-halo-width":2.5,"text-opacity":.9}},{id:"poi-you-are-here-ring",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,14,18,18,20,24],"circle-color":"#face00","circle-opacity":.25,"circle-pitch-alignment":"map"}},{id:"poi-you-are-here-dot",type:"circle",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,paint:{"circle-radius":["interpolate",["linear"],["zoom"],16,7,18,9,20,12],"circle-color":"#face00","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1}},{id:"poi-you-are-here",type:"symbol",source:"poi-data",filter:["==",["get","isYouAreHere"],!0],minzoom:16,layout:{"text-field":["get","name"],"text-size":["interpolate",["linear"],["zoom"],16,17,18,19,20,22],"text-offset":[0,-1.8],"text-anchor":"bottom","text-font":["Noto Sans Bold"],"text-allow-overlap":!0,"text-ignore-placement":!0,"text-optional":!1},paint:{"text-color":"#ffffff","text-halo-color":"#162e51","text-halo-width":2.5,"text-halo-blur":.5}},{id:"poi-highlight-ring",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":14,"circle-color":"#005ea2","circle-opacity":.45,"circle-pitch-alignment":"map"}},{id:"poi-highlight-core",type:"circle",source:"poi-highlight-data",paint:{"circle-radius":9,"circle-color":"#005ea2","circle-opacity":1,"circle-stroke-color":"#ffffff","circle-stroke-width":3,"circle-stroke-opacity":1,"circle-pitch-alignment":"map"}}]};const St={"#162e51":"#000000","#263238":"#000000","#c8a85a":"#ffd600","#face00":"#ffd600","#73b3e7":"#1565c0","#97d4ea":"#1976d2","#f2938c":"#c62828","#fee685":"#f9a825","#dfe1e2":"#757575","#faf3e2":"#ffffff","#f0e6d1":"#f5f5f5","#5f9070":"#2e7d32","#3f5d4a":"#1b5e20","#c4c8cb":"#616161","#a9aeb1":"#424242","#6f7780":"#212121","#e8e9ed":"#bdbdbd","#b0b1b5":"#424242","#e6e6e2":"#9e9e9e","#242930":"#000000","#b0b0ad":"#000000","#cfe1ec":"#b3e5fc","#d2e0c6":"#c8e6c9","#cdd9c9":"#a5d6a7","#e0e0e0":"#eeeeee","#cabfb6":"#bcaaa4","#ddd2e0":"#ce93d8","#f3e4c4":"#ffe082","#e0e0dd":"#bdbdbd","#b0b0ad ":"#000000","#bcaaa4":"#5d4037","#757575":"#424242","#616161":"#212121","#007aff":"#0050b3","#ffffff":"#ffffff","#005ea2":"#0050b3"};function Ct(t){if(Array.isArray(t))return t.map(Ct);if(t&&"object"==typeof t){const e={};for(const[o,i]of Object.entries(t))e[o]=Ct(i);return e}return"string"!=typeof(e=t)?e:St[e.toLowerCase()]??e;var e}const Pt=function(){const t=structuredClone(Mt);for(const e of t.layers??[])if(e.paint&&(e.paint=Ct(e.paint)),e.paint&&"text-halo-width"in e.paint){const t=e.paint["text-halo-width"];"number"==typeof t&&(e.paint["text-halo-width"]=t+2)}return t}(),Tt=Mt;function zt(t){return"high-contrast"===t?Pt:Tt}function Lt(t,e,o={}){t.sources||={},t.sources[e]||(t.sources[e]={type:"geojson",data:{type:"FeatureCollection",features:[]},...o})}function jt(t){let e=structuredClone(t.style);if(e.sprite=t.customSprite||e.sprite||t.defaultSpriteUrl,Lt(e,a),Lt(e,c),Lt(e,l),Lt(e,p),Lt(e,d,{lineMetrics:!0}),Lt(e,f),Lt(e,"route-endpoints"),t.floorLayers)for(const o of Object.keys(t.floorLayers))Lt(e,`amenity_${o}`),Lt(e,`destination_${o}`),Lt(e,`pathTypes_${o}`);return e}const Bt="https://demotiles.maplibre.org/styles/osm-bright-gl-style/sprite";class Et{config;map=null;data=new it;wayfindingProvider;events=new kt;floorsApi;venue=null;spriteKeys=null;debug;logger;defaultCamera=null;viewModes;reducedMotion=!1;activeThemeName="default";currentLocale;amenityManager;wayfinding;highlightManager;youAreHerePulse=new C;static POI_CATEGORY_LAYERS=[{id:"poi-destination-circles",category:"destination"},{id:"poi-destination-labels",category:"destination"},{id:"poi-entrance-exit-icons",category:"amenity"},{id:"poi-parking-icons",category:"amenity"},{id:"poi-other-amenity-icons",category:"amenity"}];poiVisibleTypes=null;constructor(t){this.config=t,this.debug=Boolean(t.debug??t.options?.debug),this.logger=y({enabled:this.debug,prefix:"MinuteMapsSDK"}),this.viewModes=new z(()=>this.map),this.reducedMotion=Boolean(t.options?.reducedMotion),this.activeThemeName="high-contrast"===t.options?.theme?"high-contrast":"default",this.currentLocale=t.jmap?.locale,this.wayfindingProvider=new pt({getGraph:()=>this.data.getWayfindingGraph?.()??null,warn:(...t)=>this.logger.warn(...t)}),this.floorsApi=new b({getMap:()=>this.map,getConfig:()=>this.config,updatePoiSource:async t=>{const e=this.map;if(!e)return;const o=this.getAllPOIs(t),i=B.toFeatureCollection(o);s.setData(e,l,i);const n={type:"FeatureCollection",features:(this.venue?.mapLabels?.getByMap?.(t)??[]).filter(t=>Array.isArray(t?.coordinates)).map(t=>({type:"Feature",geometry:{type:"Point",coordinates:t.coordinates},properties:{name:t.name??"",rotation:"number"==typeof t.rotation?t.rotation:0,allLevels:!!t.allLevels}}))};s.setData(e,p,n)},log:(...t)=>this.logger.debug(...t)}),this.amenityManager=new V({getVenue:()=>this.venue,getFloors:()=>this.floorsApi.getFloors(),getFloorById:t=>this.floorsApi.getFloors().find(e=>e.id===t)??null,log:(...t)=>this.logger.debug(...t)}),this.wayfinding=new $({getMap:()=>this.map,getVenue:()=>this.venue,getYouAreHerePOI:t=>this.getYouAreHerePOI(t),getYouAreHereCoordinates:t=>this.getYouAreHereCoordinates(t),getCurrentFloor:()=>this.getCurrentFloor(),getKioskHeading:()=>this.getKioskHeading(),getBoundsPadding:()=>this.getBoundsPadding(),computeRoute:async(t,e,o)=>{const i=this.config.jmap.customerId,n=this.config.jmap.venueId;if(null==i)throw new Error("config.jmap.customerId is required");if(null==n)throw new Error("config.jmap.venueId is required");return this.wayfindingProvider.wayfindBetweenWaypoints({customerId:i,venueId:n,from:t,to:e,options:o})},getReducedMotion:()=>this.reducedMotion,log:(...t)=>this.logger.debug(...t),warn:(...t)=>this.logger.warn(...t),debug:this.debug}),this.highlightManager=new W({getMap:()=>this.map,log:(...t)=>this.logger.debug(...t)})}async init(){const{venueId:t,customerId:e}=this.config?.jmap;if(null==t||null==e)throw new Error("config.jmap.customerId and config.jmap.venueId are required");if(!this.config.container)throw new Error("config.container is required (HTMLElement or element id)");this.logger.debug("init :: starting (JACS)",{venueId:t,customerId:e});try{await this.data.init(this.config),this.logger.debug("providers :: JACS ready"),this.venue=await this.data.loadVenue(),this.logger.debug("JACS :: venue loaded",this.venue.id),this.floorsApi.setFloors(this.venue.floors),this.logger.debug("JACS :: floors loaded",{count:this.venue.floors.length});const t=jt({style:zt("custom"===this.activeThemeName?"default":this.activeThemeName),customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Bt});this.ensureFloorLayersFromStyle(t),this.map=r(this.config.container,t),await new Promise(t=>this.map.once("load",()=>t())),this.map.on("error",t=>{const e=t?.error?.message||t?.message||t;this.logger.error("map :: error",{msg:e,sourceId:t?.sourceId,tile:t?.tile})}),this.map.on("styledata",()=>{try{this.viewModes.onStyleData()}catch{}}),this.map.on("move",()=>{if(!this.map)return;const t=j(this.map);t&&this.events.emit("cameraChange",{camera:t})}),this.ensureCoreSources(),this.spriteKeys=await F.getSpriteKeys(this.map);try{await k.register(this.map,this.venue?.amenities?.items,{iconColor:this.config.options?.amenityIconColor,badge:this.config.options?.amenityBadge})}catch(t){this.logger.warn("amenity icon registration failed",t)}const e=this.floorsApi.getInitialFloor();Boolean(e?.geojson?.features?.length)||this.applyInitialViewFromVenue(),e&&await this.setCurrentFloor(e),this.applyInitialFraming(),this.defaultCamera=j(this.map),this.youAreHerePulse.start(this.map,{reducedMotion:this.reducedMotion}),this.events.emit("ready",{venue:this.venue}),this.events.emit("floorsLoaded",{})}catch(t){throw this.logger.error("init :: failed (JACS)",t),this.events.emit("error",{error:t}),t}}on(t,e){this.events.on(t,e)}off(t,e){this.events.off(t,e)}addControl(t,e){this.map?.addControl(t,e)}setView(t){L(this.map,t)}get amenities(){return this.amenityManager}resetView(t){!function(t,e,o){if(!t||!e)return;const{center:i,zoom:n,pitch:r,bearing:s}=e,a=Boolean(o?.animate),l="number"==typeof o?.duration?o.duration:800;a?t.easeTo({center:i,zoom:n,pitch:r,bearing:s,duration:l}):t.jumpTo({center:i,zoom:n,pitch:r,bearing:s})}(this.map,this.defaultCamera,t)}refit(t){if(!this.map)return;const e=this.wayfinding.getActiveRouteBounds();if(e)return void this.fitToBounds(e,t);const o=this.getCurrentFloor();if(!o?.geojson)return;const i=m.boundsFromGeoJson(o.geojson);i&&this.fitToBounds(i,t)}fitToBounds(t,e){const o=this.map;if(o)try{o.fitBounds(t,{padding:this.getBoundsPadding(),bearing:o.getBearing(),pitch:o.getPitch(),animate:e?.animate??!0,duration:e?.duration??600,maxZoom:21})}catch(t){this.logger.warn("refit :: fitBounds failed",t)}}set3dEnabled(t){this.viewModes.set3dEnabled(t)}toggle3d(){this.viewModes.toggle3d()}getIs3dEnabled(){return this.viewModes.getIs3dEnabled()}async setTheme(t){const e=this.map;if(!e)return void this.logger.warn("setTheme :: map not initialized");const o="default"===t?"default":"high-contrast"===t?"high-contrast":"custom";if("custom"!==o&&o===this.activeThemeName)return void this.logger.debug("setTheme :: noop, theme already active",o);const i=t=>{const o=e.getSource(t);return o?._data??null},n=i(a),r=i(c),s=i(l),h=i(p),g=i(d),y=i(f),m=i("route-endpoints"),w=i(u),b=jt({style:"custom"===o?t:zt(o),customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Bt});await new Promise((t,i)=>{const I=()=>{try{const i=(t,o)=>{if(null==o)return;const i=e.getSource(t);i?.setData&&i.setData(o)};i(a,n),i(c,r),i(l,s),i(p,h),i(d,g),i(f,y),i("route-endpoints",m),i(u,w);const b=this.getCurrentFloor();b&&this.updateRouteFloorFilter(b.id),e.off("style.load",I),this.activeThemeName=o,this.events.emit("themeChanged",{theme:o}),this.logger.debug("setTheme :: applied",o),t()}catch(t){this.logger.warn("setTheme :: restore failed",t),i(t)}};e.on("style.load",I),e.setStyle(b,{diff:!1})})}getActiveTheme(){return this.activeThemeName}setReducedMotion(t){this.reducedMotion=Boolean(t),this.reducedMotion?this.youAreHerePulse.stop():this.map&&this.youAreHerePulse.start(this.map,{reducedMotion:!1})}getReducedMotion(){return this.reducedMotion}async setLocale(t){const e=t||void 0;if(e===this.currentLocale)return void this.logger.debug("setLocale :: noop, locale already active",e);const o=this.data?.applyLocale?.bind(this.data);if("function"!=typeof o)throw new Error("Active data provider does not support runtime locale switching");if(!e)throw new Error("setLocale requires a non-empty locale code");await o(e),this.currentLocale=e;const i=this.floorsApi.getCurrentFloor();if(i&&this.map){const t=this.getAllPOIs(i),e=B.toFeatureCollection(t);s.setData(this.map,l,e)}this.events.emit("localeChanged",{locale:e}),this.logger.debug("setLocale :: applied",e)}getActiveLocale(){return this.currentLocale}setUnits2dEnabled(t){this.viewModes.setUnits2dEnabled(t)}toggleUnits2d(){this.viewModes.toggleUnits2d()}getIsUnits2dEnabled(){return this.viewModes.getIsUnits2dEnabled()}setFlatMode(t){this.viewModes.setFlatMode(t)}toggleFlatMode(){this.viewModes.toggleFlatMode()}getIsFlatMode(){return this.viewModes.getIsFlatMode()}getFloors(){return this.floorsApi.getFloors()}getCurrentFloor(){return this.floorsApi.getCurrentFloor()}getDefaultFloor(){return this.floorsApi.getDefaultFloor()}getDestinations(t){const e=t||this.getCurrentFloor();return function(t,e){if(!t||!e)return[];try{const o=t.destinations?.getByMap?.({id:e.id})||[];return Array.isArray(o)?o:[]}catch{return[]}}(this.venue,e)}getPolygonLayers(){return this.venue?.polygonLayers??[]}getFloorMapTemplate3d(t){return this.venue?.mapTemplates3d?.[String(t)]??[]}getAllPOIs(t){const e=t||this.getCurrentFloor();if(!e)return[];return function(t,e,o,i,n){return B.buildPOIs(t,e,o,i,n)}(e,this.amenityManager.getByFloorId(e.id),this.getDestinations(e),this.spriteKeys,this.venue?.kioskWaypoint)}getYouAreHerePOI(t){return E(this.getAllPOIs(t))}getYouAreHereCoordinates(t){return function(t){const e=E(t);return e?.coordinates??null}(this.getAllPOIs(t))}getKioskHeading(){const t=this.venue?.kioskWaypoint,e=t?.heading;return"number"==typeof e&&Number.isFinite(e)?e:null}getKioskName(){const t=this.venue?.kioskWaypoint?.deviceName;return"string"==typeof t&&t.trim().length>0?t:null}getWalkTimeFromKiosk(t,e){return ht({graph:this.data.getWayfindingGraph?.()??null,kiosk:this.venue?.kioskWaypoint??null,target:t,options:e})}recenterOnKiosk(t){const e=this.map;if(!e)return;const o=this.getYouAreHereCoordinates();if(!o)return void this.logger.warn("recenterOnKiosk :: no You-Are-Here coordinates available");const i=(t?.animate??!0)&&!this.reducedMotion,n=i?t?.duration??600:0,r=!1!==t?.useHeading?this.getKioskHeading():null;L(e,{center:o,zoom:t?.zoom,pitch:t?.pitch,bearing:r??void 0,animate:i,duration:n})}searchPOIs(t,e){return function(t,e){const o=e.trim().toLowerCase();return o?t.filter(t=>{const e=t.name?.toLowerCase().includes(o),i=(t.keywords||[]).some(t=>t.toLowerCase().includes(o));return e||i}):[]}(this.getAllPOIs(e),t)}searchAllPOIs(t){const e=t?.trim();return e?this.getFloors().flatMap(t=>this.searchPOIs(e,t)):[]}async wayfindBetweenWaypoints(t,e,o){return this.wayfinding.wayfindBetweenWaypoints(t,e,o)}async navigateFromKioskToDestination(t){return this.wayfinding.navigateFromKioskToDestination(t)}async navigateFromKioskToPOI(t,e){const o=t?.waypoint;if(!o)return this.logger.warn("navigateFromKioskToPOI :: POI has no waypoint",t),void this.events.emit("routeFailed",{error:"destination_unavailable",poi:t});const i=this.getYouAreHerePOI()?.waypoint;if(!i)return this.logger.warn("navigateFromKioskToPOI :: no kiosk waypoint available"),void this.events.emit("routeFailed",{error:"no_kiosk_anchor",poi:t});const n=await this.wayfinding.wayfindBetweenWaypoints(i,o,{centerMode:"route",accessible:e?.accessible,avoidStairs:e?.avoidStairs}),r=this.wayfinding.getLastRoutePoints(),s=this.wayfinding.getLastRouteFloorIds();if(r.length>=2){const e=function(t,e){if(!Array.isArray(t)||t.length<2)return[];const o=[],i=[];{let e=0;for(;e<t.length;){const o=t[e].mapId??null;let n=e;for(;n+1<t.length&&(t[n+1].mapId??null)===o;)n++;i.push({floorId:o,startIdx:e,endIdx:n}),e=n+1}}for(let n=0;n<i.length;n++){const r=i[n],s=0===n,a=n===i.length-1,l=gt(t,r,{isFirstLeg:s,isLastLeg:a,ctx:e});if(o.push(...l),!a){const s=i[n+1],a=t[s.startIdx],l=(null!=a?.pathTypeId&&e.pathTypeKind?e.pathTypeKind(a.pathTypeId):null)??"elevator",c=null!=s.floorId?e.floorName(s.floorId):null;null!=r.floorId&&e.floorName(r.floorId);const d=xt(l,c);o.push({type:"transition",transition:l,fromFloorId:r.floorId,toFloorId:s.floorId,floorId:null,pointRange:[r.endIdx,s.startIdx],text:d})}}return o}(r,this.buildDirectionsContext(t));e.length>0&&this.writeActiveStepHighlight(e[0]),this.events.emit("routeReady",{route:{points:r,steps:e,floorIds:s}})}else this.events.emit("routeFailed",{error:"no_route",poi:t});return n}buildDirectionsContext(t){const e=this.getFloors(),o=new Map;for(const t of e){const e=t.mapId??t.id;"number"==typeof e&&o.set(e,t.name??`Floor ${t.id}`)}const i=this.venue?.pathTypes;return{floorName:t=>o.get(t)??null,pathTypeKind:t=>{const e=(t=>{if(i instanceof Map)return(i.get(t)?.name??"").toLowerCase();if(Array.isArray(i)){const e=i.find(e=>e?.id===t);return(e?.name??"").toLowerCase()}return""})(t);return e?/elev|lift/.test(e)?"elevator":/escalat/.test(e)?"escalator":/stair|step/.test(e)?"stairs":null:null},destinations:this.venue?.destinations?.items??[],amenities:this.venue?.amenities?.items??[],mapLabels:this.venue?.mapLabels?.items??[],destinationName:t?.name}}async setActiveStep(t){if(t){if(null!=t.floorId){const e=this.getFloors().find(e=>(e.mapId??e.id)===t.floorId);e&&String(this.getCurrentFloor()?.id)!==String(e.id)&&await this.setCurrentFloor(e)}this.writeActiveStepHighlight(t)}else this.clearActiveStepHighlight()}writeActiveStepHighlight(t){const e=this.map;if(!e)return;if("transition"===t.type)return void this.clearActiveStepHighlight();const o=this.wayfinding.getLastRoutePoints(),[i,n]=t.pointRange,r=[];for(let t=i;t<=n&&t<o.length;t++)r.push(o[t].coordinates);if(r.length<2)return void this.clearActiveStepHighlight();const a={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:r},properties:{stepType:t.type,floorId:t.floorId??null}}]};s.setData(e,f,a)}clearActiveStepHighlight(){const t=this.map;t&&s.setData(t,f,{type:"FeatureCollection",features:[]})}clearRoute(){this.wayfinding.clearRoute(),this.clearActiveStepHighlight()}async highlightPOI(t){let e=null,o=null;for(const i of this.getFloors()){const n=this.getAllPOIs(i).find(e=>String(e.id)===String(t));if(n){e=n,o=i;break}}e&&o?(String(this.getCurrentFloor()?.id)!==String(o.id)&&await this.setCurrentFloor(o),this.setView({center:e.coordinates,animate:!0,duration:600}),this.highlightManager.highlight(e.coordinates)):this.logger.warn("highlightPOI :: no POI found for id",t)}clearHighlight(){this.highlightManager.clear()}setPOIFilter(t){this.poiVisibleTypes=new Set(t),this.applyPOIFilter()}clearPOIFilter(){this.poiVisibleTypes=null,this.applyPOIFilter()}applyPOIFilter(){const t=this.map;if(!t)return;const e=this.poiVisibleTypes;for(const{id:o,category:i}of Et.POI_CATEGORY_LAYERS){if(!t.getLayer(o))continue;const n=null===e||e.has(i);t.setLayoutProperty(o,"visibility",n?"visible":"none")}}findClosestWaypoint(t,e){if(!t?.length)return null;const o=e??this.getYouAreHereCoordinates();if(!o)return t.find(t=>Array.isArray(t.coordinates)&&t.coordinates.length>=2)??null;let i=null,n=1/0;for(const e of t){const t=e.coordinates;if(!Array.isArray(t)||t.length<2)continue;const r=t[0]-o[0],s=t[1]-o[1],a=r*r+s*s;a<n&&(n=a,i=e)}return i}async navigateFromKioskToClosestAmenity(t,e){const o=this.amenityManager.getDistinct().find(e=>String(e.id)===String(t));if(!o||!o.waypoints?.length)return void this.logger.warn("navigateFromKioskToClosestAmenity :: no waypoints for amenity",t);let i=null,n=1/0;for(const t of o.waypoints){if(!Array.isArray(t.coordinates)||t.coordinates.length<2)continue;const e=this.getWalkTimeFromKiosk(t);e&&e.seconds<n&&(n=e.seconds,i=t)}if(i||(i=this.findClosestWaypoint(o.waypoints)),!i||!Array.isArray(i.coordinates)||i.coordinates.length<2)return void this.logger.warn("navigateFromKioskToClosestAmenity :: no usable waypoint",t);const r=this.findFloorForWaypoint(i);r&&String(this.getCurrentFloor()?.id)!==String(r.id)&&await this.setCurrentFloor(r);const s=i.id,a=this.getAllPOIs(r??void 0).find(e=>"amenity"===e.type&&String(e.id)===String(t)&&(null==s||String(e.waypointId)===String(s)))??{id:o.id,type:"amenity",name:o.name||"Amenity",coordinates:[i.coordinates[0],i.coordinates[1]],floorId:r?.id??"",waypointId:s,waypoint:i};return this.navigateFromKioskToPOI(a,e)}async highlightAmenity(t){const e=this.amenityManager.getDistinct().find(e=>String(e.id)===String(t));if(!e||!e.waypoints?.length)return void this.logger.warn("highlightAmenity :: no waypoints for amenity",t);const o=this.findClosestWaypoint(e.waypoints);if(!o||!Array.isArray(o.coordinates)||o.coordinates.length<2)return void this.logger.warn("highlightAmenity :: no usable waypoint",t);const i=this.findFloorForWaypoint(o);i&&String(this.getCurrentFloor()?.id)!==String(i.id)&&await this.setCurrentFloor(i);const n=[o.coordinates[0],o.coordinates[1]];this.setView({center:n,animate:!0,duration:600}),this.highlightManager.highlight(n)}findFloorForWaypoint(t){const e=t.mapId;return null==e?null:this.getFloors().find(t=>{const o=t.mapId??t.id;return String(o)===String(e)})??null}getCameraPosition(){return j(this.map)}getMap(){return this.map}destroy(){this.youAreHerePulse.stop(),this.highlightManager.destroy(),this.map?.remove(),this.map=null,this.floorsApi.setFloors([]),this.defaultCamera=null,this.viewModes=new z(()=>this.map)}async setCurrentFloor(t){await this.data.ensureFloorGeojson(t),await this.floorsApi.setCurrentFloor(t),this.setFloorLayerVisibility(t.id),this.updateRouteFloorFilter(t.id),this.wayfinding.hasActiveRoute()&&this.wayfinding.refitActiveFloorRoute({animate:!0}),this.events.emit("floorChanged",{floor:t})}updateRouteFloorFilter(t){const e=this.map;if(!e)return;const o=this.getFloors().find(e=>String(e.id)===String(t)),i=["any",["!",["has","floorId"]],["==",["get","floorId"],o?.mapId??t]];for(const t of["route-line","route-halo"])if(e.getLayer(t))try{e.setFilter(t,i)}catch{}}isReady(){return!!this.map}setFloorLayerVisibility(t){const e=this.map;if(!e)return;const o=this.venue?.styleSheet?.floorLayers;if(o)for(const[i,n]of Object.entries(o)){const o=String(i)===String(t);for(const t of n)e.getLayer(t.id)&&e.setLayoutProperty(t.id,"visibility",o?"visible":"none")}}getBoundsPadding(){const t=this.config.options?.boundsPadding??50;if("number"==typeof t||!this.map)return t;const e=this.map.getContainer();return this.clampPadding(t,e.clientWidth,e.clientHeight)}clampPadding(t,e,o){const i=(t,e,o)=>{if(!(o>0))return[t,e];const i=.8*o,n=t+e;if(n<=i)return[t,e];const r=i/n;return[t*r,e*r]},[n,r]=i(t.top,t.bottom,o),[s,a]=i(t.left,t.right,e);return{top:n,bottom:r,left:s,right:a}}getVenueBounds(){const t=this.venue?.coordinates;if(!t)return null;const{bottomLng:e,bottomLat:o,topLng:i,topLat:n}=t;if(null==e||null==o||null==i||null==n)return null;const r=Math.min(e,i),s=Math.max(e,i);return[[r,Math.min(o,n)],[s,Math.max(o,n)]]}applyInitialFraming(){const t=this.map;if(!t)return;const{initialPitch:e,initialZoom:o,minZoomBelowInitialFit:i}=this.config.options??{},n=this.getYouAreHereCoordinates(),r=this.getKioskHeading();("number"==typeof e||"number"==typeof o||n||null!=r)&&t.easeTo({center:n??t.getCenter(),zoom:"number"==typeof o?o:t.getZoom(),pitch:"number"==typeof e?e:t.getPitch(),bearing:r??t.getBearing(),duration:0}),"number"==typeof i&&t.setMinZoom(Math.max(0,t.getZoom()-i))}applyInitialViewFromVenue(){const t=this.map;if(!t)return;const e=this.getVenueBounds();if(e)try{t.resize(),t.fitBounds(e,{padding:this.getBoundsPadding(),animate:!1,duration:0,maxZoom:21})}catch(t){this.logger.warn("applyInitialViewFromVenue :: fitBounds failed",t)}}async loadAndPatchVenueStyle(){const t=this.venue?.styleSheet?.styleUrl,e=this.venue?.styleSheet?.floorLayers,o=Tt;if("sdkTemplate"===this.config.options?.styleMode)return this.logger.debug("style :: styleMode=sdkTemplate, ignoring venue styleUrl"),jt({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Bt});if(!t)return this.logger.warn("style :: venue.styleSheet.styleUrl missing, using baseStyle"),jt({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Bt});try{const o=await fetch(t);if(!o.ok)throw new Error(`HTTP ${o.status} ${o.statusText}`);return jt({style:await o.json(),floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Bt})}catch(t){return this.logger.warn("style :: failed to fetch venue styleUrl, using baseStyle",t),jt({style:o,floorLayers:e,customSprite:this.config.options?.customSprite||null,defaultSpriteUrl:Bt})}}ensureFloorLayersFromStyle(t){const e=this.venue?.styleSheet?.floorLayers;if(e&&Object.keys(e).length)return;const o={};for(const e of t.layers||[]){const t=e.id||"",i=/_(\d+)$/.exec(t);if(!i)continue;const n=i[1];o[n]||=[],o[n].push({id:t})}this.venue||={},this.venue.styleSheet||={},this.venue.styleSheet.floorLayers=o}ensureCoreSources(){const t=this.map;if(!t)return;const e={type:"FeatureCollection",features:[]};s.ensureGeoJson(t,a),s.ensureGeoJson(t,c),s.ensureGeoJson(t,l),s.ensureGeoJson(t,u),t.getSource(d)||t.addSource(d,{type:"geojson",data:e,lineMetrics:!0}),t.getSource("route-endpoints")||t.addSource("route-endpoints",{type:"geojson",data:e})}}exports.MinuteMaps=Et,exports.createMinuteMapsSDK=function(t){return new Et(t)};
2
2
  //# sourceMappingURL=index.cjs.map