@mappedin/dynamic-focus 6.18.0-beta.0 → 6.19.0-beta.0

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.
@@ -0,0 +1,2 @@
1
+ var Xo=Object.defineProperty;var ot=r=>{throw TypeError(r)};var Tt=(r,t,e)=>t in r?Xo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>Xo(r,"name",{value:t,configurable:!0});var y=(r,t,e)=>Tt(r,typeof t!="symbol"?t+"":t,e),Mo=(r,t,e)=>t.has(r)||ot("Cannot "+e);var o=(r,t,e)=>(Mo(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?ot("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,i)=>(Mo(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Mo(r,t,"access private method"),e);var S={env:{NODE_ENV:"production",npm_package_version:"6.19.0-beta.0"}};var eo={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},io=.2,Zo=.4;var xo="[MappedinJS]";function Lo(r="",{prefix:t=xo}={}){let e=`${t}${r?`-${r}`:""}`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(m=>m instanceof Error&&m.stack?`${m.message}
2
+ ${m.stack}`:m);window.rnDebug(`${r} ${s}: ${f.join(" ")}`)}},"rnDebug");return{logState:S.env.NODE_ENV==="test"?3:0,log(...s){this.logState<=0&&(console.log(e,...s),i("log",s))},warn(...s){this.logState<=1&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=2&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){0<=s&&s<=3&&(this.logState=s)}}}a(Lo,"createLogger");var vt=Lo();var W=vt;var k=Lo("",{prefix:"[DynamicFocus]"});var tt=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Ot(r,e);if(i===void 0)return k.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:eo.indoorZoomThreshold,outdoorZoomThreshold:eo.outdoorZoomThreshold};let s=i+Zo,n=i+io;return e.initialVisibility==="indoor-first"&&(s=i-io,n=i-Zo),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Ot(r,t){let i=r.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),s=1/0,n;for(let f of i){let m=r.Camera.getFocusOnTransform(f).zoomLevel??1/0;m<s&&(s=m,n=f)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a(Ot,"getDefaultZoomLevel");import{Floor as Rt,getMultiFloorState as Ut}from"@mappedin/mappedin-js";function et(r,t){if(r==null||t==null)return r===t;if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}a(et,"arraysEqual");var _o=class _o{_subscribers={};_abortController=new AbortController;get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let s=i?.signal;if(s?.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let n=a(()=>{this.off(t,e)},"cleanup");return s&&s.addEventListener("abort",n,{once:!0}),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(_o,"PubSub");var To=_o;import{Facade as Vt,Floor as It,FloorStack as Bt}from"@mappedin/mappedin-js";var I,so,C,v,T,A,H,K,No=class No{constructor(t,e){y(this,"__type","building");c(this,I);c(this,so,new Map);c(this,C,new Map);c(this,v,[]);c(this,T);c(this,A);y(this,"defaultFloor");y(this,"activeFloor");y(this,"excluded",!1);y(this,"floorsAltitudesMap",new Map);y(this,"aboveGroundFloors",[]);c(this,H);c(this,K);d(this,I,t),d(this,so,new Map(t.floors.map(s=>[s.id,s]))),d(this,C,new Map(t.floors.map(s=>[s.elevation,s]))),d(this,v,Array.from(o(this,C).values()).sort((s,n)=>s.elevation-n.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,d(this,T,e),this.aboveGroundFloors=o(this,v).filter(s=>s.elevation>=0);let i=t.facade?.spaces.map(s=>o(this,T).getState(s)).sort((s,n)=>s.altitude-n.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let s in this.aboveGroundFloors){let n=this.aboveGroundFloors[s],f=i[s];this.floorsAltitudesMap.set(n.elevation,{altitude:f.altitude,visualHeight:f.height})}}get id(){return o(this,I).id}get name(){return o(this,I).name}get floors(){return o(this,I).floors}get floorStack(){return o(this,I)}get facade(){return o(this,I).facade}get isCurrentFloorStack(){return this.id===o(this,T).currentFloorStack.id}get isIndoor(){let t=o(this,T).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,H)==null&&d(this,H,Math.max(...o(this,C).keys())),o(this,H)}get minElevation(){return o(this,K)==null&&d(this,K,Math.min(...o(this,C).keys())),o(this,K)}has(t){return It.is(t)?o(this,so).has(t.id):Bt.is(t)?t.id===o(this,I).id:Vt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,C).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,v)[o(this,v).length-1];for(let i=o(this,v).length-1;i>=0;i--){let s=o(this,v)[i];if(s.elevation<=t)return s}}else{if(t<this.minElevation)return o(this,v)[0];for(let i of o(this,v))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,v)[o(this,v).length-1]}cancelAnimation(){o(this,A)&&(o(this,A).animation.cancel(),d(this,A,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,A)?.state||o(this,T).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:s,visible:n}=t;if(o(this,T).updateState(this.facade,{visible:!0}),s!==void 0){d(this,A,{animation:o(this,T).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let f=await o(this,A).animation;if(d(this,A,void 0),f.result==="cancelled")return f}return n===!1&&o(this,T).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,I).floors.forEach(t=>{o(this,T).updateState(t,{visible:t.id===o(this,T).currentFloor.id})}),this.has(o(this,T).currentFloor)||o(this,T).updateState(this.facade,{visible:!0,opacity:1})}};I=new WeakMap,so=new WeakMap,C=new WeakMap,v=new WeakMap,T=new WeakMap,A=new WeakMap,H=new WeakMap,K=new WeakMap,a(No,"Building");var wo=No;function it(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(it,"getZoomState");function vo(r,t,e){if(r.__type==="outdoors"&&"floor"in r)return r.floor;let i=r;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(vo,"getFloorToShow");function kt(r,t,e,i){return i?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:r,state:{type:"facade",visible:!0,opacity:.2}}:{facade:r,state:{type:"facade",visible:!0,opacity:1}}}a(kt,"getFacadeState");function At(r,t,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(i=>{let n=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(At,"getSingleBuildingState");function st(r,t){if(!t.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(st,"getOutdoorOpacity");function rt(r,t,e){switch(e){case"in-range":return r[0]?.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(rt,"getSetFloorTargetFromZoomState");function nt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:f,floorIdsInNavigation:m,floorStackIdsInNavigation:h,multiFloorView:g,getMultiFloorState:j,dynamicBuildingInteriors:V,isolateBelowGroundView:q,currentElevation:bo,forceInteriorsVisible:to,getFloorStackAltitudeData:yo}=r,So=new Map,ko=q&&bo<0&&s==="in-range";for(let b of t){let Jo=e.has(b.id),Eo=ko&&b.minElevation>=0,bt=Eo?!1:Jo,Ao=Eo?!1:Co({building:b,currentFloor:i,inRange:s==="in-range",inFocus:Jo,mode:n,elevation:f,inNavigation:h.includes(b.id),dynamicBuildingInteriors:V,forceInteriorsVisible:to}),Do=i.floorStack.id===b.id?b.activeFloor:vo(b,n,f),yt=g?.enabled?j(b.floors,Do||b.activeFloor,m,yo?.(b.id)??b.floorsAltitudesMap,{color:g?.footprintColor,spacesOpenToBelowEnabled:g?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:g?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:g?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:g?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:g?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:g?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:g?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:g?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:g?.footprintOpacity,outline:g?.footprintOutline}):At(b.floorStack,Do||b.activeFloor,Ao),St=q&&bo<0&&s==="in-range",Et=kt(b.facade,Ao,St,Eo);So.set(b.id,{building:b,showIndoor:Ao,floorStackState:yt,facadeState:Et,inFocus:bt,floorToShow:Do,isAboveGroundInIsolation:Eo})}return So}a(nt,"getBuildingStates");function at(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(at,"getBuildingAnimationType");function Co(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:f,inNavigation:m,dynamicBuildingInteriors:h,forceInteriorsVisible:g}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(g===!0||m===!0)return!0;if(!h)return e.floorStack.type!=="Outdoor";if(!i||!s)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a(Co,"shouldShowIndoor");function lt(r,t,e){return r!==t&&!e}a(lt,"shouldDeferSetFloor");var ut=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Dt,FloorStack as Mt}from"@mappedin/mappedin-js";function dt(r,t,e,i){return(r<t||r>e)&&W.warn(i),Math.min(e,Math.max(t,r))}a(dt,"clampWithWarning");function Go(r,t){return!Dt.is(r)||r?.floorStack==null||!Mt.is(t)?!1:r.floorStack.id!==t.id?(W.warn(`Floor (${r.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(Go,"validateFloorForStack");function Po(r,t,e,i){return dt(r,t,e,`${i} must be between ${t} and ${e}.`)}a(Po,"validateZoomThreshold");var D,Q,ro,Ro,Uo=class Uo{constructor(t,e){c(this,ro);y(this,"__type","outdoors");c(this,D);c(this,Q);d(this,D,t),d(this,Q,e)}get id(){return o(this,D).id}get floorStack(){return o(this,D)}get floor(){return o(this,D).defaultFloor}matchesFloorStack(t){return t===o(this,D)||t===o(this,D).id}show(){F(this,ro,Ro).call(this,!0)}hide(){F(this,ro,Ro).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};D=new WeakMap,Q=new WeakMap,ro=new WeakSet,Ro=a(function(t){for(let e of o(this,D).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(Uo,"Outdoors");var Oo=Uo;function ct(r,t){let e=r.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let s=e.find(n=>n.facade==null&&!t.has(n.id));return s||(k.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(ct,"getOutdoorFloorStack");function Zt(r,t){return`${t} ${r}`}a(Zt,"formatMessage");var jo=class jo extends Error{constructor(t,e=xo){super(Zt(t,e)),this.name="MappedinError"}};a(jo,"MappedinError");var Vo=jo;var xt=a(r=>r,"linearEase"),Lt=a(r=>r*r,"quadEaseIn"),_t=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Nt=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Ct=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Gt={linear:xt,"ease-in":Lt,"ease-out":Nt,"ease-in-out":_t,"ease-out-cubic":Ct};function Pt(r,t){let e=0;if(t.length<2)return e;let s=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&s(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Pt,"getInterpolationBreakpoint");function ht(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Vo("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let s=Pt(r,t),n=(r-t[s])/(t[s+1]-t[s]),f=typeof i=="function"?i(n):Gt[i](n);return e[s]+f*(e[s+1]-e[s])}a(ht,"interpolateMulti");var M,no,ao,x,lo,$o=class $o{constructor(t,e,i){y(this,"layers");y(this,"visible");c(this,M);c(this,no,[]);c(this,ao,!1);c(this,x,new Map);y(this,"interpolationFn");c(this,lo,1);this.layers=t,this.visible=e,d(this,M,i)}processLayerGroup(t,e){o(this,ao)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,no).push(...s)}),d(this,ao,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return ht(i,[s,n],[1,0])}))}setOpacity(t){d(this,lo,t);for(let e of o(this,no))if(e.startsWith("img_")){let i=o(this,M).Image3D.getById(e);if(i){let s=o(this,M).getState(i.image);o(this,x).has(e)||o(this,x).set(e,s?.opacity??1);let n=Math.min(o(this,x).get(e),t);o(this,M).updateState(i.image,{opacity:n})}}else{let i=o(this,M).getMapData()?.getById("space",e);if(!i)continue;let s=o(this,M).getState(i);o(this,x).has(e)||o(this,x).set(e,s?.opacity??1);let n=Math.min(o(this,x).get(e),t);o(this,M).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return o(this,lo)}};M=new WeakMap,no=new WeakMap,ao=new WeakMap,x=new WeakMap,lo=new WeakMap,a($o,"LayerGroup");var Io=$o;function zo(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(zo,"runLayerGroupInterpolations");var O,l,G,u,z,$,E,L,Y,_,w,J,uo,co,ho,Z,P,X,N,R,U,p,Yo,mt,qo,Wo,Ho,pt,Ko,fo,mo,po,go,Fo,oo,Bo,gt,Ft,B,Qo=class Qo{constructor(t){c(this,p);c(this,O);c(this,l);c(this,G);c(this,u,eo);c(this,z,[]);c(this,$,new Set);c(this,E,new Map);c(this,L);c(this,Y,!1);c(this,_,!1);c(this,w,0);c(this,J,0);c(this,uo,[]);c(this,co,{});c(this,ho,{});c(this,Z,"transition");c(this,P,"outdoor");c(this,X,[]);c(this,N,!1);c(this,R,[]);c(this,U,null);y(this,"sceneUpdateQueue",Promise.resolve());y(this,"on",a((t,e)=>{o(this,O).on(t,e)},"on"));y(this,"off",a((t,e)=>{o(this,O).off(t,e)},"off"));c(this,fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(et(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,_))return;d(this,_,!1),d(this,z,[]),o(this,$).clear();let i=o(this,u).isolateBelowGroundView&&o(this,w)<0;if(e.length>0)for(let s of e){let n=o(this,E).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,$).add(n.id),o(this,z).push(n)}}o(this,u).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,mo,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,E).get(e.floorStack.id);i&&(i.activeFloor=e);let s=o(this,u).isolateBelowGroundView&&o(this,w)<0;i?.excluded===!1&&!o(this,L).matchesFloorStack(e.floorStack)&&d(this,w,e.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,w)<0,f=s&&!n;if(o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(f?(d(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||(await o(this,B).call(this,e),o(this,O).publish("focus",{facades:this.focusedFacades}))):(await o(this,B).call(this,e),o(this,O).publish("focus",{facades:this.focusedFacades})));let m=i?.floorsAltitudesMap.get(e.elevation)?.altitude??0;o(this,l).options.multiFloorView!=null&&o(this,l).options.multiFloorView?.enabled&&o(this,l).options.multiFloorView?.updateCameraElevationOnFloorChange&&o(this,l).Camera.elevation!==m&&o(this,l).Camera.animateElevation(m,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,po,a(()=>{d(this,Y,!0)},"#handleUserInteractionStart"));c(this,go,a(()=>{d(this,Y,!1)},"#handleUserInteractionEnd"));c(this,Fo,a(()=>{o(this,B).call(this)},"#handleGlobalStateChange"));c(this,oo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=it(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,Z)!==i&&(d(this,Z,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),zo(o(this,R),e)},"#handleCameraChange"));c(this,B,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,s=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(h=>h.id)||[],f=o(this,l).Navigation?.floorStacks.map(h=>h.id)||[],m=new Promise(async h=>{await this.sceneUpdateQueue;let g=nt({buildings:Array.from(o(this,E).values()),inViewSet:o(this,$),currentFloor:e,zoomState:o(this,Z),mode:o(this,u).mode,elevation:o(this,w),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Ut,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,w),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(V=>o(this,l).getFloorStackAltitudeData(V),"getFloorStackAltitudeData")}),j=[];await Promise.all(Array.from(g.values()).map(async V=>{let{building:q,showIndoor:bo,floorStackState:to,facadeState:yo,inFocus:So,isAboveGroundInIsolation:ko}=V;j.push(to);let b=at(q,bo);if(b==="indoor")return F(this,p,gt).call(this,q,to,yo,So);if(b==="outdoor")return F(this,p,Ft).call(this,q,to,yo,f,ko)})),o(this,l).Outdoor.setOpacity(st(j,o(this,u).mode)),d(this,X,o(this,z).filter(V=>g.get(V.id)?.showIndoor===!0).map(V=>V.facade)),o(this,O).publish("focus",{facades:o(this,X)}),h()});return this.sceneUpdateQueue=m,m},"#applyBuildingStates"));d(this,O,new To),d(this,l,t),k.setLevel(W.logState),d(this,G,o(this,l).getMapData()),d(this,w,o(this,l).currentFloor.elevation),d(this,J,o(this,l).Camera.elevation);for(let e of o(this,G).getByType("facade"))o(this,E).set(e.floorStack.id,new wo(e.floorStack,o(this,l)));F(this,p,pt).call(this),d(this,L,new Oo(ct(o(this,G),o(this,E)),o(this,l))),o(this,l).on("floor-change-start",o(this,mo)),o(this,l).on("camera-change",o(this,oo)),o(this,l).on("facades-in-view-change",o(this,fo)),o(this,l).on("user-interaction-start",o(this,po)),o(this,l).on("user-interaction-end",o(this,go)),o(this,l).on("global-state-change",o(this,Fo))}enable(t){if(o(this,N)){k.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,N,!0),o(this,l).manualFloorVisibility=!0,o(this,L).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&k.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,p,mt).call(this),o(this,oo).call(this,{zoomLevel:o(this,l).Camera.zoomLevel,center:o(this,l).Camera.center,bearing:o(this,l).Camera.bearing,pitch:o(this,l).Camera.pitch}),o(this,l).Camera.updateFacadesInView()}disable(){if(!o(this,N)){k.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(this,N,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,N)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,L).floorStack}get layers(){return o(this,uo)}get layersBySpaceId(){return o(this,co)}setIndoor(){d(this,P,"indoor"),d(this,Z,"in-range"),F(this,p,Yo).call(this)}setOutdoor(){d(this,P,"outdoor"),d(this,Z,"out-of-range"),F(this,p,Yo).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,s=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,w)<0,f=!!o(this,u).autoZoomThresholds,m=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:f,h=t;if(m&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){k.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:j,...V}=h;h=V}if(!f&&m?(d(this,U,()=>{if(!o(this,N))return;let g=o(this,u).indoorZoomThreshold,j=o(this,u).outdoorZoomThreshold;F(this,p,Wo).call(this),F(this,p,Ho).call(this,g,j),o(this,B).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,U))):f&&!m&&F(this,p,qo).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=Po(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=Po(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=ut.includes(h.mode)?h.mode:"default-floor"),h.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=h.autoAdjustFacadeHeights),h.dynamicBuildingInteriors!=null&&h.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),h.isolateBelowGroundView!=null&&h.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),h.forceInteriorsVisible!=null&&h.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),h.showLabelsAndMarkersOnAllVisibleFloors!=null&&h.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),m&&h.autoZoomThresholds!==void 0&&(F(this,p,Wo).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,p,Ko).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,w)<0;n&&!g?(d(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||o(this,B).call(this)):o(this,B).call(this)}F(this,p,Ho).call(this,i,s)}destroy(){this.disable(),F(this,p,qo).call(this),o(this,l).off("facades-in-view-change",o(this,fo)),o(this,l).off("floor-change-start",o(this,mo)),o(this,l).off("camera-change",o(this,oo)),o(this,l).off("user-interaction-start",o(this,po)),o(this,l).off("user-interaction-end",o(this,go)),o(this,l).off("global-state-change",o(this,Fo)),o(this,E).forEach(t=>t.destroy()),o(this,L).destroy(),o(this,O).destroy(),d(this,R,[])}async focus(t=o(this,u).setFloorOnFocus){if(t)if(lt(o(this,J),o(this,l).Camera.elevation,o(this,Y)))d(this,J,o(this,l).Camera.elevation),d(this,_,!0);else{let e=rt(o(this,z),o(this,L),o(this,Z)),i=e?vo(e,o(this,u).mode,o(this,w)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,B).call(this),o(this,O).publish("focus",{facades:this.focusedFacades})}preloadFloors(){F(this,p,Ko).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!Go(e,t))return;let i=o(this,E).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,E).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,E).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Go(e,t))return;let i=o(this,E).get(t.id);i&&(i.activeFloor=e,o(this,B).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,E).get(i.id);s&&(s.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,E).get(i.id);s&&(s.excluded=!1)}}getCurrentFloorForStack(t){return o(this,E).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};O=new WeakMap,l=new WeakMap,G=new WeakMap,u=new WeakMap,z=new WeakMap,$=new WeakMap,E=new WeakMap,L=new WeakMap,Y=new WeakMap,_=new WeakMap,w=new WeakMap,J=new WeakMap,uo=new WeakMap,co=new WeakMap,ho=new WeakMap,Z=new WeakMap,P=new WeakMap,X=new WeakMap,N=new WeakMap,R=new WeakMap,U=new WeakMap,p=new WeakSet,Yo=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():d(this,_,!0)),o(this,O).publish("state-change")},"#handleViewStateChange"),mt=a(function(){d(this,R,[]);for(let t of o(this,u).dynamicLayers){let e=new Io([t],!0,o(this,l));e.processLayerGroup(o(this,ho),()=>o(this,u)),o(this,R).push(e)}zo(o(this,R),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),qo=a(function(){o(this,U)&&(o(this,l).off("camera-screen-offsets-change",o(this,U)),d(this,U,null))},"#unsubscribeScreenOffsets"),Wo=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=tt(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=s,(e.expandMinZoom??!0)&&s<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(s-io)},"#recalcThresholds"),Ho=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,O).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),pt=a(function(){let t=o(this,G).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(s=>{e[s.name]||(e[s.name]=[]),e[s.name].push(...s.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of s.spaces)i[n]==null&&(i[n]=[]),i[n].push(s.name)}),d(this,uo,t.map(({name:s})=>s)),d(this,co,i),d(this,ho,e)},"#setupLayers"),Ko=a(function(t){o(this,l).preloadFloors(o(this,G).getByType("facade").map(e=>vo(o(this,E).get(e.floorStack.id),t,o(this,w))).filter(e=>e!=null&&Rt.is(e)))},"#preloadFloors"),fo=new WeakMap,mo=new WeakMap,po=new WeakMap,go=new WeakMap,Fo=new WeakMap,oo=new WeakMap,Bo=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let m=i!==void 0&&!s?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,m)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),gt=a(async function(t,e,i,s){return F(this,p,Bo).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Ft=a(async function(t,e,i,s,n){let f=n;f&&F(this,p,Bo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let m=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return m.result==="completed"&&!f&&F(this,p,Bo).call(this,e.floorStates,Co({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,Z)==="in-range",inFocus:o(this,$).has(t.id),mode:o(this,u).mode,elevation:o(this,w),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),m},"#animateOutdoorSequence"),B=new WeakMap,a(Qo,"DynamicFocus");var ft=Qo;export{a,tt as b,ft as c};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{b as o,c as t}from"./chunk-KEEP2NKS.js";export{t as DynamicFocus,o as calculateZoomThresholds};
1
+ import{b as o,c as t}from"./chunk-FOQNAZDG.js";export{t as DynamicFocus,o as calculateZoomThresholds};
@@ -1 +1 @@
1
- import{a as t,c as a}from"../chunk-KEEP2NKS.js";import{useCallback as y,useState as p,useMemo as F}from"react";import{useMap as l,useMapViewExtension as D}from"@mappedin/react-sdk";function d(){let[,n]=p({});return y(()=>n({}),[])}t(d,"useForceUpdate");function i(){let{mapView:n}=l(),r=d(),{register:o}=D("dynamic-focus",{onRegister:t(()=>{let e=new a(n);return e.on("state-change",r),e},"onRegister"),onDeregister:t(e=>{e.off("state-change",r),e.destroy()},"onDeregister")}),s=o();if(!s)throw new Error("DynamicFocus is not initialized");return F(()=>{let e=new WeakMap;return new Proxy(s,{get(u,m){let c=u[m];return typeof c=="function"?(e.has(c)||e.set(c,c.bind(u)),e.get(c)):c}})},[s])}t(i,"useDynamicFocus");import{useCallback as w,useEffect as E,useRef as k}from"react";function x(n,r){let o=i(),s=k(r);s.current=r;let e=w(u=>{s.current(u)},[]);E(()=>{if(o!=null)return o.on(n,e),()=>{o!=null&&o.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
1
+ import{a as t,c as a}from"../chunk-FOQNAZDG.js";import{useCallback as y,useState as p,useMemo as F}from"react";import{useMap as l,useMapViewExtension as D}from"@mappedin/react-sdk";function d(){let[,n]=p({});return y(()=>n({}),[])}t(d,"useForceUpdate");function i(){let{mapView:n}=l(),r=d(),{register:o}=D("dynamic-focus",{onRegister:t(()=>{let e=new a(n);return e.on("state-change",r),e},"onRegister"),onDeregister:t(e=>{e.off("state-change",r),e.destroy()},"onDeregister")}),s=o();if(!s)throw new Error("DynamicFocus is not initialized");return F(()=>{let e=new WeakMap;return new Proxy(s,{get(u,m){let c=u[m];return typeof c=="function"?(e.has(c)||e.set(c,c.bind(u)),e.get(c)):c}})},[s])}t(i,"useDynamicFocus");import{useCallback as w,useEffect as E,useRef as k}from"react";function x(n,r){let o=i(),s=k(r);s.current=r;let e=w(u=>{s.current(u)},[]);E(()=>{if(o!=null)return o.on(n,e),()=>{o?.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
@@ -1,5 +1,5 @@
1
- var Z=Object.defineProperty,l=(e,i)=>Z(e,"name",{value:i,configurable:!0});import{useState as B,useCallback as u,useContext as x,useRef as C}from"react";import{MappedinContext as D}from"@mappedin/react-native-sdk";import{useCallback as A,useContext as W}from"react";var L="[MappedinJS]";function p(e="",{prefix:i=L}={}){const o=`${i}${e?`-${e}`:""}`,s=l((t,c)=>{if(typeof window<"u"&&window.rnDebug){const f=c.map(a=>a instanceof Error&&a.stack?`${a.message}
2
- ${a.stack}`:a);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(o,...t),s("log",t))},warn(...t){this.logState<=1&&(console.warn(o,...t),s("warn",t))},error(...t){this.logState<=2&&(console.error(o,...t),s("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){0<=t&&t<=3&&(this.logState=t)}}}l(p,"createLogger");var z=p(),F=p("",{prefix:"[DynamicFocus]"});import{MappedinContext as _,useEventCallback as G,createEventSetupScript as N,createEventCleanupScript as $}from"@mappedin/react-native-sdk";function v(e,i){return i.map(o=>o&&o.id&&e.getById("facade",o.id)||o)}l(v,"hydrateFacades");import{useRegisterExtension as j}from"@mappedin/react-native-sdk";var R=`
1
+ var I=Object.defineProperty,l=(o,i)=>I(o,"name",{value:i,configurable:!0});import{useState as B,useCallback as u,useContext as x,useRef as C}from"react";import{MappedinContext as D}from"@mappedin/react-native-sdk";import{useCallback as A,useContext as W}from"react";var L="[MappedinJS]";function p(o="",{prefix:i=L}={}){const e=`${i}${o?`-${o}`:""}`,s=l((t,d)=>{if(typeof window<"u"&&window.rnDebug){const f=d.map(a=>a instanceof Error&&a.stack?`${a.message}
2
+ ${a.stack}`:a);window.rnDebug(`${o} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(e,...t),s("log",t))},warn(...t){this.logState<=1&&(console.warn(e,...t),s("warn",t))},error(...t){this.logState<=2&&(console.error(e,...t),s("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){0<=t&&t<=3&&(this.logState=t)}}}l(p,"createLogger");var z=p(),F=p("",{prefix:"[DynamicFocus]"});import{MappedinContext as _,useEventCallback as G,createEventSetupScript as N,createEventCleanupScript as $}from"@mappedin/react-native-sdk";function v(o,i){return i.map(e=>e&&e.id&&o.getById("facade",e.id)||e)}l(v,"hydrateFacades");import{useRegisterExtension as R}from"@mappedin/react-native-sdk";var j=`
3
3
  // Define require function that uses bridge.modules for external dependencies
4
4
  globalThis.require = globalThis.require || ((id) => {
5
5
  if (window.bridge?.modules?.[id]) {
@@ -8,8 +8,8 @@ ${a.stack}`:a);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{l
8
8
  throw new Error('Module not found: ' + id);
9
9
  });
10
10
 
11
- "use strict";var DynamicFocus=(()=>{var et=Object.defineProperty;var Oo=Object.getOwnPropertyDescriptor;var Vo=Object.getOwnPropertyNames;var Io=Object.prototype.hasOwnProperty;var so=r=>{throw TypeError(r)};var Bo=(r,o,e)=>o in r?et(r,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[o]=e;var a=(r,o)=>et(r,"name",{value:o,configurable:!0}),_t=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(o,e)=>(typeof require<"u"?require:o)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var Ao=(r,o)=>{for(var e in o)et(r,e,{get:o[e],enumerable:!0})},ko=(r,o,e,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of Vo(o))!Io.call(r,s)&&s!==e&&et(r,s,{get:()=>o[s],enumerable:!(i=Oo(o,s))||i.enumerable});return r};var Do=r=>ko(et({},"__esModule",{value:!0}),r);var b=(r,o,e)=>Bo(r,typeof o!="symbol"?o+"":o,e),Nt=(r,o,e)=>o.has(r)||so("Cannot "+e);var t=(r,o,e)=>(Nt(r,o,"read from private field"),e?e.call(r):o.get(r)),c=(r,o,e)=>o.has(r)?so("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(r):o.set(r,e),d=(r,o,e,i)=>(Nt(r,o,"write to private field"),i?i.call(r,e):o.set(r,e),e),F=(r,o,e)=>(Nt(r,o,"access private method"),e);var zo={};Ao(zo,{DynamicFocus:()=>Dt,calculateZoomThresholds:()=>It});var Mt=_t("@mappedin/mappedin-js");function ro(r,o){if(r==null||o==null)return r===o;if(r.length!==o.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==o[e])return!1;return!0}a(ro,"arraysEqual");var Ct=class Ct{constructor(){b(this,"_subscribers",{});b(this,"_abortController",new AbortController)}get signal(){return this._abortController.signal}publish(o,e){!this._subscribers||!this._subscribers[o]||this.signal.aborted||this._subscribers[o].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(o){this.signal.addEventListener("abort",()=>o(),{once:!0})}on(o,e,i){let s=i?.signal;if(s?.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[o]=this._subscribers[o]||[],this._subscribers[o].push(e);let n=a(()=>{this.off(o,e)},"cleanup");return s&&s.addEventListener("abort",n,{once:!0}),n}off(o,e){if(!this._subscribers||this._subscribers[o]==null||this.signal.aborted)return;let i=this._subscribers[o].indexOf(e);i!==-1&&this._subscribers[o].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(Ct,"PubSub");var Tt=Ct;var H=_t("@mappedin/mappedin-js");var V,it,N,w,E,B,q,W,Gt=class Gt{constructor(o,e){b(this,"__type","building");c(this,V);c(this,it,new Map);c(this,N,new Map);c(this,w,[]);c(this,E);c(this,B);b(this,"defaultFloor");b(this,"activeFloor");b(this,"excluded",!1);b(this,"floorsAltitudesMap",new Map);b(this,"aboveGroundFloors",[]);c(this,q);c(this,W);d(this,V,o),d(this,it,new Map(o.floors.map(s=>[s.id,s]))),d(this,N,new Map(o.floors.map(s=>[s.elevation,s]))),d(this,w,Array.from(t(this,N).values()).sort((s,n)=>s.elevation-n.elevation)),this.defaultFloor=o.defaultFloor,this.activeFloor=this.defaultFloor,d(this,E,e),this.aboveGroundFloors=t(this,w).filter(s=>s.elevation>=0);let i=o.facade?.spaces.map(s=>t(this,E).getState(s)).sort((s,n)=>s.altitude-n.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let s in this.aboveGroundFloors){let n=this.aboveGroundFloors[s],f=i[s];this.floorsAltitudesMap.set(n.elevation,{altitude:f.altitude,visualHeight:f.height})}}get id(){return t(this,V).id}get name(){return t(this,V).name}get floors(){return t(this,V).floors}get floorStack(){return t(this,V)}get facade(){return t(this,V).facade}get isCurrentFloorStack(){return this.id===t(this,E).currentFloorStack.id}get isIndoor(){let o=t(this,E).getState(this.facade);return this.isCurrentFloorStack||o?.visible===!1&&o?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return t(this,q)==null&&d(this,q,Math.max(...t(this,N).keys())),t(this,q)}get minElevation(){return t(this,W)==null&&d(this,W,Math.min(...t(this,N).keys())),t(this,W)}has(o){return H.Floor.is(o)?t(this,it).has(o.id):H.FloorStack.is(o)?o.id===t(this,V).id:H.Facade.is(o)?o.id===this.facade.id:!1}getFloorByElevation(o){return t(this,N).get(o)}getNearestFloorByElevation(o){let e=this.getFloorByElevation(o);if(e)return e;if(o>=0){if(o>this.maxElevation)return t(this,w)[t(this,w).length-1];for(let i=t(this,w).length-1;i>=0;i--){let s=t(this,w)[i];if(s.elevation<=o)return s}}else{if(o<this.minElevation)return t(this,w)[0];for(let i of t(this,w))if(i.elevation>=o)return i}}getHighestFloor(){return t(this,w)[t(this,w).length-1]}cancelAnimation(){t(this,B)&&(t(this,B).animation.cancel(),d(this,B,void 0))}async animateFacade(o,e={duration:150}){let i=t(this,B)?.state||t(this,E).getState(this.facade);if(!i||!o||i?.opacity===o.opacity&&i?.visible===o.visible)return{result:"completed"};this.cancelAnimation();let{opacity:s,visible:n}=o;if(t(this,E).updateState(this.facade,{visible:!0}),s!==void 0){d(this,B,{animation:t(this,E).animateState(this.facade,{opacity:s},{duration:e.duration}),state:o});let f=await t(this,B).animation;if(d(this,B,void 0),f.result==="cancelled")return f}return n===!1&&t(this,E).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),t(this,V).floors.forEach(o=>{t(this,E).updateState(o,{visible:o.id===t(this,E).currentFloor.id})}),this.has(t(this,E).currentFloor)||t(this,E).updateState(this.facade,{visible:!0,opacity:1})}};V=new WeakMap,it=new WeakMap,N=new WeakMap,w=new WeakMap,E=new WeakMap,B=new WeakMap,q=new WeakMap,W=new WeakMap,a(Gt,"Building");var wt=Gt;function no(r,o,e){return r>=o?"in-range":r<=e?"out-of-range":"transition"}a(no,"getZoomState");function vt(r,o,e){if(r.__type==="outdoors"&&"floor"in r)return r.floor;let i=r;if(i.excluded)return i.activeFloor;switch(o){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(vt,"getFloorToShow");function Mo(r,o,e,i){return i?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:o?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:r,state:{type:"facade",visible:!0,opacity:.2}}:{facade:r,state:{type:"facade",visible:!0,opacity:1}}}a(Mo,"getFacadeState");function xo(r,o,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(i=>{let n=i.id===o.id&&e;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(xo,"getSingleBuildingState");function ao(r,o){if(!o.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(ao,"getOutdoorOpacity");function lo(r,o,e){switch(e){case"in-range":return r[0]?.canSetFloor?r[0]:void 0;case"out-of-range":return o;case"transition":default:return}}a(lo,"getSetFloorTargetFromZoomState");function uo(r){let{buildings:o,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:f,floorIdsInNavigation:m,floorStackIdsInNavigation:h,multiFloorView:g,getMultiFloorState:U,dynamicBuildingInteriors:O,isolateBelowGroundView:Y,currentElevation:bt,forceInteriorsVisible:ot,getFloorStackAltitudeData:yt}=r,St=new Map,xt=Y&&bt<0&&s==="in-range";for(let y of o){let io=e.has(y.id),Et=xt&&y.minElevation>=0,Eo=Et?!1:io,Zt=Et?!1:Pt({building:y,currentFloor:i,inRange:s==="in-range",inFocus:io,mode:n,elevation:f,inNavigation:h.includes(y.id),dynamicBuildingInteriors:O,forceInteriorsVisible:ot}),Lt=i.floorStack.id===y.id?y.activeFloor:vt(y,n,f),To=g?.enabled?U(y.floors,Lt||y.activeFloor,m,yt?.(y.id)??y.floorsAltitudesMap,{color:g?.footprintColor,spacesOpenToBelowEnabled:g?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:g?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:g?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:g?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:g?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:g?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:g?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:g?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:g?.footprintOpacity,outline:g?.footprintOutline}):xo(y.floorStack,Lt||y.activeFloor,Zt),wo=Y&&bt<0&&s==="in-range",vo=Mo(y.facade,Zt,wo,Et);St.set(y.id,{building:y,showIndoor:Zt,floorStackState:To,facadeState:vo,inFocus:Eo,floorToShow:Lt,isAboveGroundInIsolation:Et})}return St}a(uo,"getBuildingStates");function co(r,o){return r.excluded?"none":o?"indoor":"outdoor"}a(co,"getBuildingAnimationType");function Pt(r){let{building:o,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:f,inNavigation:m,dynamicBuildingInteriors:h,forceInteriorsVisible:g}=r;if(o.id===e.floorStack.id)return!0;if(o.excluded)return!1;if(g===!0||m===!0)return!0;if(!h)return e.floorStack.type!=="Outdoor";if(!i||!s)return!1;switch(n){case"lock-elevation":return o.getFloorByElevation(f)!=null;default:break}return!0}a(Pt,"shouldShowIndoor");function ho(r,o,e){return r!==o&&!e}a(ho,"shouldDeferSetFloor");var fo=["default-floor","lock-elevation","nearest-elevation"];var Ot=_t("@mappedin/mappedin-js");var Rt="[MappedinJS]";function Ut(r="",{prefix:o=Rt}={}){let e=\`\${o}\${r?\`-\${r}\`:""}\`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(m=>m instanceof Error&&m.stack?\`\${m.message}
12
- \${m.stack}\`:m);window.rnDebug(\`\${r} \${s}: \${f.join(" ")}\`)}},"rnDebug");return{logState:0,log(...s){this.logState<=0&&(console.log(e,...s),i("log",s))},warn(...s){this.logState<=1&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=2&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){0<=s&&s<=3&&(this.logState=s)}}}a(Ut,"createLogger");var Zo=Ut();var K=Zo;function mo(r,o,e,i){return(r<o||r>e)&&K.warn(i),Math.min(e,Math.max(o,r))}a(mo,"clampWithWarning");function jt(r,o){return!Ot.Floor.is(r)||r?.floorStack==null||!Ot.FloorStack.is(o)?!1:r.floorStack.id!==o.id?(K.warn(\`Floor (\${r.id}) does not belong to floor stack (\${o.id}).\`),!1):!0}a(jt,"validateFloorForStack");function zt(r,o,e,i){return mo(r,o,e,\`\${i} must be between \${o} and \${e}.\`)}a(zt,"validateZoomThreshold");var M=Ut("",{prefix:"[DynamicFocus]"});var A,Q,st,$t,Yt=class Yt{constructor(o,e){c(this,st);b(this,"__type","outdoors");c(this,A);c(this,Q);d(this,A,o),d(this,Q,e)}get id(){return t(this,A).id}get floorStack(){return t(this,A)}get floor(){return t(this,A).defaultFloor}matchesFloorStack(o){return o===t(this,A)||o===t(this,A).id}show(){F(this,st,$t).call(this,!0)}hide(){F(this,st,$t).call(this,!1)}destroy(){this.matchesFloorStack(t(this,Q).currentFloorStack)||this.hide()}};A=new WeakMap,Q=new WeakMap,st=new WeakSet,$t=a(function(o){for(let e of t(this,A).floors)t(this,Q).updateState(e,{visible:o})},"#setVisible"),a(Yt,"Outdoors");var Vt=Yt;function po(r,o){let e=r.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let s=e.find(n=>n.facade==null&&!o.has(n.id));return s||(M.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(po,"getOutdoorFloorStack");var rt={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},nt=.2,qt=.4;var It=a((r,o={})=>{let e={initialVisibility:o.initialVisibility??"indoor-first",debug:o.debug??!1},i=Lo(r,e);if(i===void 0)return M.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:rt.indoorZoomThreshold,outdoorZoomThreshold:rt.outdoorZoomThreshold};let s=i+qt,n=i+nt;return e.initialVisibility==="indoor-first"&&(s=i-nt,n=i-qt),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Lo(r,o){let i=r.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),s=1/0,n;for(let f of i){let m=r.Camera.getFocusOnTransform(f).zoomLevel??1/0;m<s&&(s=m,n=f)}if(s!==1/0)return o.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a(Lo,"getDefaultZoomLevel");function _o(r,o){return\`\${o} \${r}\`}a(_o,"formatMessage");var Wt=class Wt extends Error{constructor(o,e=Rt){super(_o(o,e)),this.name="MappedinError"}};a(Wt,"MappedinError");var Bt=Wt;var No=a(r=>r,"linearEase"),Co=a(r=>r*r,"quadEaseIn"),Go=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Po=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Ro=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Uo={linear:No,"ease-in":Co,"ease-out":Po,"ease-in-out":Go,"ease-out-cubic":Ro};function jo(r,o){let e=0;if(o.length<2)return e;let s=o[0]<o[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<o.length-1&&s(r,o[e+1]);)e++;return e>o.length-2?Math.max(0,o.length-2):e}a(jo,"getInterpolationBreakpoint");function go(r,o,e,i="ease-in"){if(o.length!==e.length)throw new Bt("Input and output ranges must have the same number of values.");r=Math.max(o[0],Math.min(r,o[o.length-1]));let s=jo(r,o),n=(r-o[s])/(o[s+1]-o[s]),f=typeof i=="function"?i(n):Uo[i](n);return e[s]+f*(e[s+1]-e[s])}a(go,"interpolateMulti");var k,at,lt,x,ut,Kt=class Kt{constructor(o,e,i){b(this,"layers");b(this,"visible");c(this,k);c(this,at,[]);c(this,lt,!1);c(this,x,new Map);b(this,"interpolationFn");c(this,ut,1);this.layers=o,this.visible=e,d(this,k,i)}processLayerGroup(o,e){t(this,lt)||(this.layers.forEach(i=>{let s=o[i];s&&t(this,at).push(...s)}),d(this,lt,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return go(i,[s,n],[1,0])}))}setOpacity(o){d(this,ut,o);for(let e of t(this,at))if(e.startsWith("img_")){let i=t(this,k).Image3D.getById(e);if(i){let s=t(this,k).getState(i.image);t(this,x).has(e)||t(this,x).set(e,s?.opacity??1);let n=Math.min(t(this,x).get(e),o);t(this,k).updateState(i.image,{opacity:n})}}else{let i=t(this,k).getMapData()?.getById("space",e);if(!i)continue;let s=t(this,k).getState(i);t(this,x).has(e)||t(this,x).set(e,s?.opacity??1);let n=Math.min(t(this,x).get(e),o);t(this,k).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return t(this,ut)}};k=new WeakMap,at=new WeakMap,lt=new WeakMap,x=new WeakMap,ut=new WeakMap,a(Kt,"LayerGroup");var At=Kt;function Ht(r,o){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(o);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Ht,"runLayerGroupInterpolations");var v,l,C,u,j,z,S,Z,$,L,T,J,dt,ct,ht,D,G,X,_,P,R,p,Qt,Fo,Jt,Xt,to,bo,oo,ft,mt,pt,gt,Ft,tt,kt,yo,So,I,eo=class eo{constructor(o){c(this,p);c(this,v);c(this,l);c(this,C);c(this,u,rt);c(this,j,[]);c(this,z,new Set);c(this,S,new Map);c(this,Z);c(this,$,!1);c(this,L,!1);c(this,T,0);c(this,J,0);c(this,dt,[]);c(this,ct,{});c(this,ht,{});c(this,D,"transition");c(this,G,"outdoor");c(this,X,[]);c(this,_,!1);c(this,P,[]);c(this,R,null);b(this,"sceneUpdateQueue",Promise.resolve());b(this,"on",a((o,e)=>{t(this,v).on(o,e)},"on"));b(this,"off",a((o,e)=>{t(this,v).off(o,e)},"off"));c(this,ft,a(o=>{if(!this.isEnabled)return;let{facades:e}=o;if(ro(e,this.focusedFacades)&&t(this,G)==="transition"&&!t(this,L))return;d(this,L,!1),d(this,j,[]),t(this,z).clear();let i=t(this,u).isolateBelowGroundView&&t(this,T)<0;if(e.length>0)for(let s of e){let n=t(this,S).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;t(this,z).add(n.id),t(this,j).push(n)}}t(this,u).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,mt,a(async o=>{if(!this.isEnabled)return;let{floor:e}=o,i=t(this,S).get(e.floorStack.id);i&&(i.activeFloor=e);let s=t(this,u).isolateBelowGroundView&&t(this,T)<0;i?.excluded===!1&&!t(this,Z).matchesFloorStack(e.floorStack)&&d(this,T,e.elevation);let n=t(this,u).isolateBelowGroundView&&t(this,T)<0,f=s&&!n;if(t(this,l).manualFloorVisibility===!0){o.reason!=="dynamic-focus"&&(f?(d(this,L,!0),t(this,l).Camera.updateFacadesInView(),t(this,u).autoFocus||(await t(this,I).call(this,e),t(this,v).publish("focus",{facades:this.focusedFacades}))):(await t(this,I).call(this,e),t(this,v).publish("focus",{facades:this.focusedFacades})));let m=i?.floorsAltitudesMap.get(e.elevation)?.altitude??0;t(this,l).options.multiFloorView!=null&&t(this,l).options.multiFloorView?.enabled&&t(this,l).options.multiFloorView?.updateCameraElevationOnFloorChange&&t(this,l).Camera.elevation!==m&&t(this,l).Camera.animateElevation(m,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,pt,a(()=>{d(this,$,!0)},"#handleUserInteractionStart"));c(this,gt,a(()=>{d(this,$,!1)},"#handleUserInteractionEnd"));c(this,Ft,a(()=>{t(this,I).call(this)},"#handleGlobalStateChange"));c(this,tt,a(o=>{if(!this.isEnabled)return;let{zoomLevel:e}=o,i=no(e,t(this,u).indoorZoomThreshold,t(this,u).outdoorZoomThreshold);t(this,D)!==i&&(d(this,D,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Ht(t(this,P),e)},"#handleCameraChange"));c(this,I,a(async o=>{if(t(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=o||t(this,l).currentFloor,i=t(this,l).getGlobalState().multiFloorView,s=t(this,l).options.multiFloorView?{...t(this,l).options.multiFloorView,...i}:t(this,l).options.multiFloorView,n=t(this,l).Navigation?.floors?.map(h=>h.id)||[],f=t(this,l).Navigation?.floorStacks.map(h=>h.id)||[],m=new Promise(async h=>{await this.sceneUpdateQueue;let g=uo({buildings:Array.from(t(this,S).values()),inViewSet:t(this,z),currentFloor:e,zoomState:t(this,D),mode:t(this,u).mode,elevation:t(this,T),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:s,getMultiFloorState:t(this,u).customMultiFloorVisibilityState??Mt.getMultiFloorState,dynamicBuildingInteriors:t(this,u).dynamicBuildingInteriors,isolateBelowGroundView:t(this,u).isolateBelowGroundView,currentElevation:t(this,T),forceInteriorsVisible:t(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(O=>t(this,l).getFloorStackAltitudeData(O),"getFloorStackAltitudeData")}),U=[];await Promise.all(Array.from(g.values()).map(async O=>{let{building:Y,showIndoor:bt,floorStackState:ot,facadeState:yt,inFocus:St,isAboveGroundInIsolation:xt}=O;U.push(ot);let y=co(Y,bt);if(y==="indoor")return F(this,p,yo).call(this,Y,ot,yt,St);if(y==="outdoor")return F(this,p,So).call(this,Y,ot,yt,f,xt)})),t(this,l).Outdoor.setOpacity(ao(U,t(this,u).mode)),d(this,X,t(this,j).filter(O=>g.get(O.id)?.showIndoor===!0).map(O=>O.facade)),t(this,v).publish("focus",{facades:t(this,X)}),h()});return this.sceneUpdateQueue=m,m},"#applyBuildingStates"));d(this,v,new Tt),d(this,l,o),M.setLevel(K.logState),d(this,C,t(this,l).getMapData()),d(this,T,t(this,l).currentFloor.elevation),d(this,J,t(this,l).Camera.elevation);for(let e of t(this,C).getByType("facade"))t(this,S).set(e.floorStack.id,new wt(e.floorStack,t(this,l)));F(this,p,bo).call(this),d(this,Z,new Vt(po(t(this,C),t(this,S)),t(this,l))),t(this,l).on("floor-change-start",t(this,mt)),t(this,l).on("camera-change",t(this,tt)),t(this,l).on("facades-in-view-change",t(this,ft)),t(this,l).on("user-interaction-start",t(this,pt)),t(this,l).on("user-interaction-end",t(this,gt)),t(this,l).on("global-state-change",t(this,Ft))}enable(o){if(t(this,_)){M.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,_,!0),t(this,l).manualFloorVisibility=!0,t(this,Z).show(),this.updateState({...t(this,u),...o}),F(this,p,Fo).call(this),t(this,tt).call(this,{zoomLevel:t(this,l).Camera.zoomLevel,center:t(this,l).Camera.center,bearing:t(this,l).Camera.bearing,pitch:t(this,l).Camera.pitch}),t(this,l).Camera.updateFacadesInView()}disable(){if(!t(this,_)){M.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(this,_,!1),t(this,l).manualFloorVisibility=!1}get isEnabled(){return t(this,_)}get isIndoor(){return t(this,G)==="indoor"}get isOutdoor(){return t(this,G)==="outdoor"}get outdoorsFloorStack(){return t(this,Z).floorStack}get layers(){return t(this,dt)}get layersBySpaceId(){return t(this,ct)}setIndoor(){d(this,G,"indoor"),d(this,D,"in-range"),F(this,p,Qt).call(this)}setOutdoor(){d(this,G,"outdoor"),d(this,D,"out-of-range"),F(this,p,Qt).call(this)}get focusedFacades(){return[...t(this,X)]}getState(){return{...t(this,u)}}updateState(o){let e=!1,i=t(this,u).indoorZoomThreshold,s=t(this,u).outdoorZoomThreshold,n=t(this,u).isolateBelowGroundView&&t(this,T)<0,f=!!t(this,u).autoZoomThresholds,m=o.autoZoomThresholds!=null?!!o.autoZoomThresholds:f,h=o;if(m&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){M.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:U,...O}=h;h=O}if(!f&&m?(d(this,R,()=>{if(!t(this,_))return;let g=t(this,u).indoorZoomThreshold,U=t(this,u).outdoorZoomThreshold;F(this,p,Xt).call(this),F(this,p,to).call(this,g,U),t(this,I).call(this)}),t(this,l).on("camera-screen-offsets-change",t(this,R))):f&&!m&&F(this,p,Jt).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=zt(h.indoorZoomThreshold,h?.outdoorZoomThreshold??t(this,u).outdoorZoomThreshold,t(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=zt(h.outdoorZoomThreshold,t(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??t(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=fo.includes(h.mode)?h.mode:"default-floor"),h.autoAdjustFacadeHeights!=null&&(t(this,u).autoAdjustFacadeHeights=h.autoAdjustFacadeHeights),h.dynamicBuildingInteriors!=null&&h.dynamicBuildingInteriors!==t(this,u).dynamicBuildingInteriors&&(e=!0),h.isolateBelowGroundView!=null&&h.isolateBelowGroundView!==t(this,u).isolateBelowGroundView&&(e=!0),h.forceInteriorsVisible!=null&&h.forceInteriorsVisible!==t(this,u).forceInteriorsVisible&&(e=!0),h.showLabelsAndMarkersOnAllVisibleFloors!=null&&h.showLabelsAndMarkersOnAllVisibleFloors!==t(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d(this,u,Object.assign({},t(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),m&&h.autoZoomThresholds!==void 0&&(F(this,p,Xt).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,p,oo).call(this,h.mode),e){let g=t(this,u).isolateBelowGroundView&&t(this,T)<0;n&&!g?(d(this,L,!0),t(this,l).Camera.updateFacadesInView(),t(this,u).autoFocus||t(this,I).call(this)):t(this,I).call(this)}F(this,p,to).call(this,i,s)}destroy(){this.disable(),F(this,p,Jt).call(this),t(this,l).off("facades-in-view-change",t(this,ft)),t(this,l).off("floor-change-start",t(this,mt)),t(this,l).off("camera-change",t(this,tt)),t(this,l).off("user-interaction-start",t(this,pt)),t(this,l).off("user-interaction-end",t(this,gt)),t(this,l).off("global-state-change",t(this,Ft)),t(this,S).forEach(o=>o.destroy()),t(this,Z).destroy(),t(this,v).destroy(),d(this,P,[])}async focus(o=t(this,u).setFloorOnFocus){if(o)if(ho(t(this,J),t(this,l).Camera.elevation,t(this,$)))d(this,J,t(this,l).Camera.elevation),d(this,L,!0);else{let e=lo(t(this,j),t(this,Z),t(this,D)),i=e?vt(e,t(this,u).mode,t(this,T)):void 0;i&&i.id!==t(this,l).currentFloor.id&&t(this,l).setFloor(i,{context:"dynamic-focus"})}await t(this,I).call(this),t(this,v).publish("focus",{facades:this.focusedFacades})}preloadFloors(){F(this,p,oo).call(this,t(this,u).mode)}setDefaultFloorForStack(o,e){if(!jt(e,o))return;let i=t(this,S).get(o.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(o){let e=t(this,S).get(o.id);e&&(e.defaultFloor=o.defaultFloor)}getDefaultFloorForStack(o){return t(this,S).get(o.id)?.defaultFloor||o.defaultFloor||o.floors[0]}setCurrentFloorForStack(o,e){if(!jt(e,o))return;let i=t(this,S).get(o.id);i&&(i.activeFloor=e,t(this,I).call(this))}exclude(o){let e=Array.isArray(o)?o:[o];for(let i of e){let s=t(this,S).get(i.id);s&&(s.excluded=!0)}}include(o){let e=Array.isArray(o)?o:[o];for(let i of e){let s=t(this,S).get(i.id);s&&(s.excluded=!1)}}getCurrentFloorForStack(o){return t(this,S).get(o.id)?.activeFloor||this.getDefaultFloorForStack(o)}};v=new WeakMap,l=new WeakMap,C=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,Z=new WeakMap,$=new WeakMap,L=new WeakMap,T=new WeakMap,J=new WeakMap,dt=new WeakMap,ct=new WeakMap,ht=new WeakMap,D=new WeakMap,G=new WeakMap,X=new WeakMap,_=new WeakMap,P=new WeakMap,R=new WeakMap,p=new WeakSet,Qt=a(function(){t(this,u).autoFocus&&(t(this,$)?this.focus():d(this,L,!0)),t(this,v).publish("state-change")},"#handleViewStateChange"),Fo=a(function(){d(this,P,[]);for(let o of t(this,u).dynamicLayers){let e=new At([o],!0,t(this,l));e.processLayerGroup(t(this,ht),()=>t(this,u)),t(this,P).push(e)}Ht(t(this,P),t(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),Jt=a(function(){t(this,R)&&(t(this,l).off("camera-screen-offsets-change",t(this,R)),d(this,R,null))},"#unsubscribeScreenOffsets"),Xt=a(function(){let o=t(this,u).autoZoomThresholds,e=typeof o=="object"&&o!==null?{...o}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=It(t(this,l),e);t(this,u).indoorZoomThreshold=i,t(this,u).outdoorZoomThreshold=s,(e.expandMinZoom??!0)&&s<t(this,l).Camera.minZoomLevel&&t(this,l).Camera.setMinZoomLevel(s-nt)},"#recalcThresholds"),to=a(function(o,e){(t(this,u).indoorZoomThreshold!==o||t(this,u).outdoorZoomThreshold!==e)&&t(this,v).publish("zoom-threshold-change",{indoorZoomThreshold:t(this,u).indoorZoomThreshold,outdoorZoomThreshold:t(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),bo=a(function(){let o=t(this,C).internal.mvf?.enterprise?.layers??[],e={},i={};o.forEach(s=>{e[s.name]||(e[s.name]=[]),e[s.name].push(...s.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of s.spaces)i[n]==null&&(i[n]=[]),i[n].push(s.name)}),d(this,dt,o.map(({name:s})=>s)),d(this,ct,i),d(this,ht,e)},"#setupLayers"),oo=a(function(o){t(this,l).preloadFloors(t(this,C).getByType("facade").map(e=>vt(t(this,S).get(e.floorStack.id),o,t(this,T))).filter(e=>e!=null&&Mt.Floor.is(e)))},"#preloadFloors"),ft=new WeakMap,mt=new WeakMap,pt=new WeakMap,gt=new WeakMap,Ft=new WeakMap,tt=new WeakMap,kt=a(function(o,e,i,s=!1){o.forEach(n=>{if(n.floor)if(e){let m=i!==void 0&&!s?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;t(this,l).updateState(n.floor,m)}else t(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),yo=a(async function(o,e,i,s){return F(this,p,kt).call(this,e.floorStates,!0,s,t(this,u).showLabelsAndMarkersOnAllVisibleFloors),o.animateFacade(i.state,t(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),So=a(async function(o,e,i,s,n){let f=n;f&&F(this,p,kt).call(this,e.floorStates,!1,void 0,t(this,u).showLabelsAndMarkersOnAllVisibleFloors);let m=await o.animateFacade(i.state,t(this,u).outdoorAnimationOptions);return m.result==="completed"&&!f&&F(this,p,kt).call(this,e.floorStates,Pt({building:o,currentFloor:t(this,l).currentFloor,inRange:t(this,D)==="in-range",inFocus:t(this,z).has(o.id),mode:t(this,u).mode,elevation:t(this,T),inNavigation:s.includes(o.floorStack.id),dynamicBuildingInteriors:t(this,u).dynamicBuildingInteriors,forceInteriorsVisible:t(this,u).forceInteriorsVisible}),void 0,t(this,u).showLabelsAndMarkersOnAllVisibleFloors),m},"#animateOutdoorSequence"),I=new WeakMap,a(eo,"DynamicFocus");var Dt=eo;return Do(zo);})();
11
+ "use strict";var DynamicFocus=(()=>{var eo=Object.defineProperty;var Ot=Object.getOwnPropertyDescriptor;var Vt=Object.getOwnPropertyNames;var It=Object.prototype.hasOwnProperty;var rt=r=>{throw TypeError(r)};var Bt=(r,t,e)=>t in r?eo(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>eo(r,"name",{value:t,configurable:!0}),No=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var At=(r,t)=>{for(var e in t)eo(r,e,{get:t[e],enumerable:!0})},Dt=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Vt(t))!It.call(r,s)&&s!==e&&eo(r,s,{get:()=>t[s],enumerable:!(i=Ot(t,s))||i.enumerable});return r};var kt=r=>Dt(eo({},"__esModule",{value:!0}),r);var b=(r,t,e)=>Bt(r,typeof t!="symbol"?t+"":t,e),Co=(r,t,e)=>t.has(r)||rt("Cannot "+e);var o=(r,t,e)=>(Co(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,i)=>(Co(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),F=(r,t,e)=>(Co(r,t,"access private method"),e);var zt={};At(zt,{DynamicFocus:()=>Mo,calculateZoomThresholds:()=>Bo});var Zo=No("@mappedin/mappedin-js");function nt(r,t){if(r==null||t==null)return r===t;if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}a(nt,"arraysEqual");var Go=class Go{constructor(){b(this,"_subscribers",{});b(this,"_abortController",new AbortController)}get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let s=i?.signal;if(s?.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let n=a(()=>{this.off(t,e)},"cleanup");return s&&s.addEventListener("abort",n,{once:!0}),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(Go,"PubSub");var wo=Go;var H=No("@mappedin/mappedin-js");var V,io,N,w,E,B,q,W,Po=class Po{constructor(t,e){b(this,"__type","building");c(this,V);c(this,io,new Map);c(this,N,new Map);c(this,w,[]);c(this,E);c(this,B);b(this,"defaultFloor");b(this,"activeFloor");b(this,"excluded",!1);b(this,"floorsAltitudesMap",new Map);b(this,"aboveGroundFloors",[]);c(this,q);c(this,W);d(this,V,t),d(this,io,new Map(t.floors.map(s=>[s.id,s]))),d(this,N,new Map(t.floors.map(s=>[s.elevation,s]))),d(this,w,Array.from(o(this,N).values()).sort((s,n)=>s.elevation-n.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,d(this,E,e),this.aboveGroundFloors=o(this,w).filter(s=>s.elevation>=0);let i=t.facade?.spaces.map(s=>o(this,E).getState(s)).sort((s,n)=>s.altitude-n.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let s in this.aboveGroundFloors){let n=this.aboveGroundFloors[s],m=i[s];this.floorsAltitudesMap.set(n.elevation,{altitude:m.altitude,visualHeight:m.height})}}get id(){return o(this,V).id}get name(){return o(this,V).name}get floors(){return o(this,V).floors}get floorStack(){return o(this,V)}get facade(){return o(this,V).facade}get isCurrentFloorStack(){return this.id===o(this,E).currentFloorStack.id}get isIndoor(){let t=o(this,E).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,q)==null&&d(this,q,Math.max(...o(this,N).keys())),o(this,q)}get minElevation(){return o(this,W)==null&&d(this,W,Math.min(...o(this,N).keys())),o(this,W)}has(t){return H.Floor.is(t)?o(this,io).has(t.id):H.FloorStack.is(t)?t.id===o(this,V).id:H.Facade.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,N).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,w)[o(this,w).length-1];for(let i=o(this,w).length-1;i>=0;i--){let s=o(this,w)[i];if(s.elevation<=t)return s}}else{if(t<this.minElevation)return o(this,w)[0];for(let i of o(this,w))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,w)[o(this,w).length-1]}cancelAnimation(){o(this,B)&&(o(this,B).animation.cancel(),d(this,B,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,B)?.state||o(this,E).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:s,visible:n}=t;if(o(this,E).updateState(this.facade,{visible:!0}),s!==void 0){d(this,B,{animation:o(this,E).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let m=await o(this,B).animation;if(d(this,B,void 0),m.result==="cancelled")return m}return n===!1&&o(this,E).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,V).floors.forEach(t=>{o(this,E).updateState(t,{visible:t.id===o(this,E).currentFloor.id})}),this.has(o(this,E).currentFloor)||o(this,E).updateState(this.facade,{visible:!0,opacity:1})}};V=new WeakMap,io=new WeakMap,N=new WeakMap,w=new WeakMap,E=new WeakMap,B=new WeakMap,q=new WeakMap,W=new WeakMap,a(Po,"Building");var vo=Po;function at(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(at,"getZoomState");function Oo(r,t,e){if(r.__type==="outdoors"&&"floor"in r)return r.floor;let i=r;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Oo,"getFloorToShow");function Mt(r,t,e,i){return i?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:r,state:{type:"facade",visible:!0,opacity:.2}}:{facade:r,state:{type:"facade",visible:!0,opacity:1}}}a(Mt,"getFacadeState");function Zt(r,t,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(i=>{let n=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(Zt,"getSingleBuildingState");function lt(r,t){if(!t.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(lt,"getOutdoorOpacity");function ut(r,t,e){switch(e){case"in-range":return r[0]?.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(ut,"getSetFloorTargetFromZoomState");function dt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:m,floorIdsInNavigation:f,floorStackIdsInNavigation:h,multiFloorView:g,getMultiFloorState:U,dynamicBuildingInteriors:O,isolateBelowGroundView:Y,currentElevation:yo,forceInteriorsVisible:to,getFloorStackAltitudeData:So}=r,Eo=new Map,xo=Y&&yo<0&&s==="in-range";for(let y of t){let st=e.has(y.id),To=xo&&y.minElevation>=0,Et=To?!1:st,Lo=To?!1:Ro({building:y,currentFloor:i,inRange:s==="in-range",inFocus:st,mode:n,elevation:m,inNavigation:h.includes(y.id),dynamicBuildingInteriors:O,forceInteriorsVisible:to}),_o=i.floorStack.id===y.id?y.activeFloor:Oo(y,n,m),Tt=g?.enabled?U(y.floors,_o||y.activeFloor,f,So?.(y.id)??y.floorsAltitudesMap,{color:g?.footprintColor,spacesOpenToBelowEnabled:g?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:g?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:g?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:g?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:g?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:g?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:g?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:g?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:g?.footprintOpacity,outline:g?.footprintOutline}):Zt(y.floorStack,_o||y.activeFloor,Lo),wt=Y&&yo<0&&s==="in-range",vt=Mt(y.facade,Lo,wt,To);Eo.set(y.id,{building:y,showIndoor:Lo,floorStackState:Tt,facadeState:vt,inFocus:Et,floorToShow:_o,isAboveGroundInIsolation:To})}return Eo}a(dt,"getBuildingStates");function ct(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(ct,"getBuildingAnimationType");function Ro(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:m,inNavigation:f,dynamicBuildingInteriors:h,forceInteriorsVisible:g}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(g===!0||f===!0)return!0;if(!h)return e.floorStack.type!=="Outdoor";if(!i||!s)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(m)!=null;default:break}return!0}a(Ro,"shouldShowIndoor");function ht(r,t,e){return r!==t&&!e}a(ht,"shouldDeferSetFloor");var mt=["default-floor","lock-elevation","nearest-elevation"];var Vo=No("@mappedin/mappedin-js");var Uo="[MappedinJS]";function jo(r="",{prefix:t=Uo}={}){let e=\`\${t}\${r?\`-\${r}\`:""}\`,i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let m=n.map(f=>f instanceof Error&&f.stack?\`\${f.message}
12
+ \${f.stack}\`:f);window.rnDebug(\`\${r} \${s}: \${m.join(" ")}\`)}},"rnDebug");return{logState:0,log(...s){this.logState<=0&&(console.log(e,...s),i("log",s))},warn(...s){this.logState<=1&&(console.warn(e,...s),i("warn",s))},error(...s){this.logState<=2&&(console.error(e,...s),i("error",s))},assert(...s){console.assert(...s)},time(s){console.time(s)},timeEnd(s){console.timeEnd(s)},setLevel(s){0<=s&&s<=3&&(this.logState=s)}}}a(jo,"createLogger");var xt=jo();var K=xt;function ft(r,t,e,i){return(r<t||r>e)&&K.warn(i),Math.min(e,Math.max(t,r))}a(ft,"clampWithWarning");function zo(r,t){return!Vo.Floor.is(r)||r?.floorStack==null||!Vo.FloorStack.is(t)?!1:r.floorStack.id!==t.id?(K.warn(\`Floor (\${r.id}) does not belong to floor stack (\${t.id}).\`),!1):!0}a(zo,"validateFloorForStack");function $o(r,t,e,i){return ft(r,t,e,\`\${i} must be between \${t} and \${e}.\`)}a($o,"validateZoomThreshold");var A=jo("",{prefix:"[DynamicFocus]"});var D,Q,so,Yo,qo=class qo{constructor(t,e){c(this,so);b(this,"__type","outdoors");c(this,D);c(this,Q);d(this,D,t),d(this,Q,e)}get id(){return o(this,D).id}get floorStack(){return o(this,D)}get floor(){return o(this,D).defaultFloor}matchesFloorStack(t){return t===o(this,D)||t===o(this,D).id}show(){F(this,so,Yo).call(this,!0)}hide(){F(this,so,Yo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};D=new WeakMap,Q=new WeakMap,so=new WeakSet,Yo=a(function(t){for(let e of o(this,D).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(qo,"Outdoors");var Io=qo;function pt(r,t){let e=r.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let s=e.find(n=>n.facade==null&&!t.has(n.id));return s||(A.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(pt,"getOutdoorFloorStack");var ro={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},no=.2,Wo=.4;var Bo=a((r,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Lt(r,e);if(i===void 0)return A.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:ro.indoorZoomThreshold,outdoorZoomThreshold:ro.outdoorZoomThreshold};let s=i+Wo,n=i+no;return e.initialVisibility==="indoor-first"&&(s=i-no,n=i-Wo),{indoorZoomThreshold:s,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Lt(r,t){let i=r.getMapData().getByType("floor-stack").filter(m=>m.type!=="Outdoor"),s=1/0,n;for(let m of i){let f=r.Camera.getFocusOnTransform(m).zoomLevel??1/0;f<s&&(s=f,n=m)}if(s!==1/0)return t.debug&&n&&r.Camera.getFocusOnTransform(n,{debugColor:"blue"}),s}a(Lt,"getDefaultZoomLevel");function _t(r,t){return\`\${t} \${r}\`}a(_t,"formatMessage");var Ho=class Ho extends Error{constructor(t,e=Uo){super(_t(t,e)),this.name="MappedinError"}};a(Ho,"MappedinError");var Ao=Ho;var Nt=a(r=>r,"linearEase"),Ct=a(r=>r*r,"quadEaseIn"),Gt=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Pt=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Rt=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),Ut={linear:Nt,"ease-in":Ct,"ease-out":Pt,"ease-in-out":Gt,"ease-out-cubic":Rt};function jt(r,t){let e=0;if(t.length<2)return e;let s=t[0]<t[1]?(n,m)=>n>m:(n,m)=>n<m;for(;e<t.length-1&&s(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(jt,"getInterpolationBreakpoint");function gt(r,t,e,i="ease-in"){if(t.length!==e.length)throw new Ao("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let s=jt(r,t),n=(r-t[s])/(t[s+1]-t[s]),m=typeof i=="function"?i(n):Ut[i](n);return e[s]+m*(e[s+1]-e[s])}a(gt,"interpolateMulti");var k,ao,lo,Z,uo,Qo=class Qo{constructor(t,e,i){b(this,"layers");b(this,"visible");c(this,k);c(this,ao,[]);c(this,lo,!1);c(this,Z,new Map);b(this,"interpolationFn");c(this,uo,1);this.layers=t,this.visible=e,d(this,k,i)}processLayerGroup(t,e){o(this,lo)||(this.layers.forEach(i=>{let s=t[i];s&&o(this,ao).push(...s)}),d(this,lo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:s,indoorZoomThreshold:n}=e();return gt(i,[s,n],[1,0])}))}setOpacity(t){d(this,uo,t);for(let e of o(this,ao))if(e.startsWith("img_")){let i=o(this,k).Image3D.getById(e);if(i){let s=o(this,k).getState(i.image);o(this,Z).has(e)||o(this,Z).set(e,s?.opacity??1);let n=Math.min(o(this,Z).get(e),t);o(this,k).updateState(i.image,{opacity:n})}}else{let i=o(this,k).getMapData()?.getById("space",e);if(!i)continue;let s=o(this,k).getState(i);o(this,Z).has(e)||o(this,Z).set(e,s?.opacity??1);let n=Math.min(o(this,Z).get(e),t);o(this,k).updateState(i,{opacity:n,visible:n>0})}}get opacity(){return o(this,uo)}};k=new WeakMap,ao=new WeakMap,lo=new WeakMap,Z=new WeakMap,uo=new WeakMap,a(Qo,"LayerGroup");var Do=Qo;function Ko(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Ko,"runLayerGroupInterpolations");var v,l,C,u,j,z,S,x,$,L,T,J,co,ho,mo,M,G,X,_,P,R,p,Jo,Ft,Xo,ot,tt,bt,et,fo,po,go,Fo,bo,oo,ko,yt,St,I,it=class it{constructor(t){c(this,p);c(this,v);c(this,l);c(this,C);c(this,u,ro);c(this,j,[]);c(this,z,new Set);c(this,S,new Map);c(this,x);c(this,$,!1);c(this,L,!1);c(this,T,0);c(this,J,0);c(this,co,[]);c(this,ho,{});c(this,mo,{});c(this,M,"transition");c(this,G,"outdoor");c(this,X,[]);c(this,_,!1);c(this,P,[]);c(this,R,null);b(this,"sceneUpdateQueue",Promise.resolve());b(this,"on",a((t,e)=>{o(this,v).on(t,e)},"on"));b(this,"off",a((t,e)=>{o(this,v).off(t,e)},"off"));c(this,fo,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(nt(e,this.focusedFacades)&&o(this,G)==="transition"&&!o(this,L))return;d(this,L,!1),d(this,j,[]),o(this,z).clear();let i=o(this,u).isolateBelowGroundView&&o(this,T)<0;if(e.length>0)for(let s of e){let n=o(this,S).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,z).add(n.id),o(this,j).push(n)}}o(this,u).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,po,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,S).get(e.floorStack.id);i&&(i.activeFloor=e);let s=o(this,u).isolateBelowGroundView&&o(this,T)<0;i?.excluded===!1&&!o(this,x).matchesFloorStack(e.floorStack)&&d(this,T,e.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,T)<0,m=s&&!n;if(o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(m?(d(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||(await o(this,I).call(this,e),o(this,v).publish("focus",{facades:this.focusedFacades}))):(await o(this,I).call(this,e),o(this,v).publish("focus",{facades:this.focusedFacades})));let f=i?.floorsAltitudesMap.get(e.elevation)?.altitude??0;o(this,l).options.multiFloorView!=null&&o(this,l).options.multiFloorView?.enabled&&o(this,l).options.multiFloorView?.updateCameraElevationOnFloorChange&&o(this,l).Camera.elevation!==f&&o(this,l).Camera.animateElevation(f,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,go,a(()=>{d(this,$,!0)},"#handleUserInteractionStart"));c(this,Fo,a(()=>{d(this,$,!1)},"#handleUserInteractionEnd"));c(this,bo,a(()=>{o(this,I).call(this)},"#handleGlobalStateChange"));c(this,oo,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=at(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,M)!==i&&(d(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Ko(o(this,P),e)},"#handleCameraChange"));c(this,I,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,s=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(h=>h.id)||[],m=o(this,l).Navigation?.floorStacks.map(h=>h.id)||[],f=new Promise(async h=>{await this.sceneUpdateQueue;let g=dt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,z),currentFloor:e,zoomState:o(this,M),mode:o(this,u).mode,elevation:o(this,T),floorIdsInNavigation:n,floorStackIdsInNavigation:m,multiFloorView:s,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Zo.getMultiFloorState,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,T),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(O=>o(this,l).getFloorStackAltitudeData(O),"getFloorStackAltitudeData")}),U=[];await Promise.all(Array.from(g.values()).map(async O=>{let{building:Y,showIndoor:yo,floorStackState:to,facadeState:So,inFocus:Eo,isAboveGroundInIsolation:xo}=O;U.push(to);let y=ct(Y,yo);if(y==="indoor")return F(this,p,yt).call(this,Y,to,So,Eo);if(y==="outdoor")return F(this,p,St).call(this,Y,to,So,m,xo)})),o(this,l).Outdoor.setOpacity(lt(U,o(this,u).mode)),d(this,X,o(this,j).filter(O=>g.get(O.id)?.showIndoor===!0).map(O=>O.facade)),o(this,v).publish("focus",{facades:o(this,X)}),h()});return this.sceneUpdateQueue=f,f},"#applyBuildingStates"));d(this,v,new wo),d(this,l,t),A.setLevel(K.logState),d(this,C,o(this,l).getMapData()),d(this,T,o(this,l).currentFloor.elevation),d(this,J,o(this,l).Camera.elevation);for(let e of o(this,C).getByType("facade"))o(this,S).set(e.floorStack.id,new vo(e.floorStack,o(this,l)));F(this,p,bt).call(this),d(this,x,new Io(pt(o(this,C),o(this,S)),o(this,l))),o(this,l).on("floor-change-start",o(this,po)),o(this,l).on("camera-change",o(this,oo)),o(this,l).on("facades-in-view-change",o(this,fo)),o(this,l).on("user-interaction-start",o(this,go)),o(this,l).on("user-interaction-end",o(this,Fo)),o(this,l).on("global-state-change",o(this,bo))}enable(t){if(o(this,_)){A.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,_,!0),o(this,l).manualFloorVisibility=!0,o(this,x).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&A.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),F(this,p,Ft).call(this),o(this,oo).call(this,{zoomLevel:o(this,l).Camera.zoomLevel,center:o(this,l).Camera.center,bearing:o(this,l).Camera.bearing,pitch:o(this,l).Camera.pitch}),o(this,l).Camera.updateFacadesInView()}disable(){if(!o(this,_)){A.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(this,_,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,_)}get isIndoor(){return o(this,G)==="indoor"}get isOutdoor(){return o(this,G)==="outdoor"}get outdoorsFloorStack(){return o(this,x).floorStack}get layers(){return o(this,co)}get layersBySpaceId(){return o(this,ho)}setIndoor(){d(this,G,"indoor"),d(this,M,"in-range"),F(this,p,Jo).call(this)}setOutdoor(){d(this,G,"outdoor"),d(this,M,"out-of-range"),F(this,p,Jo).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,s=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,T)<0,m=!!o(this,u).autoZoomThresholds,f=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:m,h=t;if(f&&(h.indoorZoomThreshold!=null||h.outdoorZoomThreshold!=null)){A.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:g,outdoorZoomThreshold:U,...O}=h;h=O}if(!m&&f?(d(this,R,()=>{if(!o(this,_))return;let g=o(this,u).indoorZoomThreshold,U=o(this,u).outdoorZoomThreshold;F(this,p,ot).call(this),F(this,p,tt).call(this,g,U),o(this,I).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,R))):m&&!f&&F(this,p,Xo).call(this),h.indoorZoomThreshold!=null&&(h.indoorZoomThreshold=$o(h.indoorZoomThreshold,h?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),h.outdoorZoomThreshold!=null&&(h.outdoorZoomThreshold=$o(h.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,h?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),h.mode!=null&&(h.mode=mt.includes(h.mode)?h.mode:"default-floor"),h.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=h.autoAdjustFacadeHeights),h.dynamicBuildingInteriors!=null&&h.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),h.isolateBelowGroundView!=null&&h.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),h.forceInteriorsVisible!=null&&h.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),h.showLabelsAndMarkersOnAllVisibleFloors!=null&&h.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(h).filter(([,g])=>g!=null)))),f&&h.autoZoomThresholds!==void 0&&(F(this,p,ot).call(this),e=!0),h.mode!=null&&h.preloadFloors&&F(this,p,et).call(this,h.mode),e){let g=o(this,u).isolateBelowGroundView&&o(this,T)<0;n&&!g?(d(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,u).autoFocus||o(this,I).call(this)):o(this,I).call(this)}F(this,p,tt).call(this,i,s)}destroy(){this.disable(),F(this,p,Xo).call(this),o(this,l).off("facades-in-view-change",o(this,fo)),o(this,l).off("floor-change-start",o(this,po)),o(this,l).off("camera-change",o(this,oo)),o(this,l).off("user-interaction-start",o(this,go)),o(this,l).off("user-interaction-end",o(this,Fo)),o(this,l).off("global-state-change",o(this,bo)),o(this,S).forEach(t=>t.destroy()),o(this,x).destroy(),o(this,v).destroy(),d(this,P,[])}async focus(t=o(this,u).setFloorOnFocus){if(t)if(ht(o(this,J),o(this,l).Camera.elevation,o(this,$)))d(this,J,o(this,l).Camera.elevation),d(this,L,!0);else{let e=ut(o(this,j),o(this,x),o(this,M)),i=e?Oo(e,o(this,u).mode,o(this,T)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,I).call(this),o(this,v).publish("focus",{facades:this.focusedFacades})}preloadFloors(){F(this,p,et).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!zo(e,t))return;let i=o(this,S).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,S).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!zo(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,I).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,S).get(i.id);s&&(s.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let s=o(this,S).get(i.id);s&&(s.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};v=new WeakMap,l=new WeakMap,C=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,x=new WeakMap,$=new WeakMap,L=new WeakMap,T=new WeakMap,J=new WeakMap,co=new WeakMap,ho=new WeakMap,mo=new WeakMap,M=new WeakMap,G=new WeakMap,X=new WeakMap,_=new WeakMap,P=new WeakMap,R=new WeakMap,p=new WeakSet,Jo=a(function(){o(this,u).autoFocus&&(o(this,$)?this.focus():d(this,L,!0)),o(this,v).publish("state-change")},"#handleViewStateChange"),Ft=a(function(){d(this,P,[]);for(let t of o(this,u).dynamicLayers){let e=new Do([t],!0,o(this,l));e.processLayerGroup(o(this,mo),()=>o(this,u)),o(this,P).push(e)}Ko(o(this,P),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),Xo=a(function(){o(this,R)&&(o(this,l).off("camera-screen-offsets-change",o(this,R)),d(this,R,null))},"#unsubscribeScreenOffsets"),ot=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:s}=Bo(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=s,(e.expandMinZoom??!0)&&s<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(s-no)},"#recalcThresholds"),tt=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,v).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),bt=a(function(){let t=o(this,C).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(s=>{e[s.name]||(e[s.name]=[]),e[s.name].push(...s.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of s.spaces)i[n]==null&&(i[n]=[]),i[n].push(s.name)}),d(this,co,t.map(({name:s})=>s)),d(this,ho,i),d(this,mo,e)},"#setupLayers"),et=a(function(t){o(this,l).preloadFloors(o(this,C).getByType("facade").map(e=>Oo(o(this,S).get(e.floorStack.id),t,o(this,T))).filter(e=>e!=null&&Zo.Floor.is(e)))},"#preloadFloors"),fo=new WeakMap,po=new WeakMap,go=new WeakMap,Fo=new WeakMap,bo=new WeakMap,oo=new WeakMap,ko=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let f=i!==void 0&&!s?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,f)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),yt=a(async function(t,e,i,s){return F(this,p,ko).call(this,e.floorStates,!0,s,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),St=a(async function(t,e,i,s,n){let m=n;m&&F(this,p,ko).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let f=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return f.result==="completed"&&!m&&F(this,p,ko).call(this,e.floorStates,Ro({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,z).has(t.id),mode:o(this,u).mode,elevation:o(this,T),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),f},"#animateOutdoorSequence"),I=new WeakMap,a(it,"DynamicFocus");var Mo=it;return kt(zt);})();
13
13
 
14
14
 
15
15
  // Register the extension
@@ -22,4 +22,4 @@ if (window.bridge && window.bridge.extensions) {
22
22
  }
23
23
  } else {
24
24
  if (window.rnDebug) window.rnDebug('Bridge or extensions not available for registration');
25
- }`;function S(){return R}l(S,"getRegistrationScript");function g(){j({extensionName:"dynamic-focus",getRegistrationScript:S,logger:F})}l(g,"useDynamicFocusRegistration");function b(e,i){if(typeof e!="string"||e.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof i!="function")throw new Error("Callback parameter must be a function");const o=W(_),{extensions:s,mapData:t}=o;if(!t)throw new Error("Map data is not available");g();const f=(s?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",a=A(d=>{try{let h=d;e==="focus"&&d.facades&&(h={...d,facades:v(t,d.facades)}),i(h)}catch(h){F.error(`Error in dynamic focus event callback for ${String(e)}:`,h)}},[e,t,i]);G({eventKey:`dynamic-focus:${String(e)}`,callback:a,setupScript:l(()=>N({extensionName:"dynamic-focus",eventName:String(e)}),"setupScript"),cleanupScript:l(()=>$({extensionName:"dynamic-focus",eventName:String(e)}),"cleanupScript"),shouldInject:f})}l(b,"useDynamicFocusEvent");function k(){const e=x(D),{bridge:i,extensions:o,updateExtensionState:s}=e;g();const t=o["dynamic-focus"],c=t?.registrationState||"unregistered",f=c==="registered",a=t?.isEnabled||!1,[d,h]=B(t?.focusedFacades||[]),w=C(o);w.current=o,b("focus",u(n=>{const m=n.facades;h(m),s("dynamic-focus",y=>({...y,registrationState:c,focusedFacades:m}))},[c,s]));const r=u(async(n,m=[])=>{if(!i?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await i.instruct({type:"extension",payload:{name:"dynamic-focus",method:n,args:m}})},[i]),E=u(async n=>{w.current?.["dynamic-focus"]?.isEnabled||(await r("enable",[n]),s("dynamic-focus",V=>({...V,isEnabled:!0})))},[r,s]),M=u(async n=>await r("updateState",[n]),[r]),T=u(async()=>await r("getState"),[r]),O=u(async n=>await r("focus",[n]),[r]),I=u(async()=>{await r("disable"),h([]),s("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[r,h,s]);return{isReady:f,isEnabled:a,focusedFacades:d,updateState:M,getState:T,focus:O,disable:I,enable:E}}l(k,"useDynamicFocus");export{k as useDynamicFocus,b as useDynamicFocusEvent};
25
+ }`;function S(){return j}l(S,"getRegistrationScript");function g(){R({extensionName:"dynamic-focus",getRegistrationScript:S,logger:F})}l(g,"useDynamicFocusRegistration");function b(o,i){if(typeof o!="string"||o.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof i!="function")throw new Error("Callback parameter must be a function");const e=W(_),{extensions:s,mapData:t}=e;if(!t)throw new Error("Map data is not available");g();const f=(s?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",a=A(c=>{try{let h=c;o==="focus"&&c.facades&&(h={...c,facades:v(t,c.facades)}),i(h)}catch(h){F.error(`Error in dynamic focus event callback for ${String(o)}:`,h)}},[o,t,i]);G({eventKey:`dynamic-focus:${String(o)}`,callback:a,setupScript:l(()=>N({extensionName:"dynamic-focus",eventName:String(o)}),"setupScript"),cleanupScript:l(()=>$({extensionName:"dynamic-focus",eventName:String(o)}),"cleanupScript"),shouldInject:f})}l(b,"useDynamicFocusEvent");function k(){const o=x(D),{bridge:i,extensions:e,updateExtensionState:s}=o;g();const t=e["dynamic-focus"],d=t?.registrationState||"unregistered",f=d==="registered",a=t?.isEnabled||!1,[c,h]=B(t?.focusedFacades||[]),w=C(e);w.current=e,b("focus",u(n=>{const m=n.facades;h(m),s("dynamic-focus",y=>({...y,registrationState:d,focusedFacades:m}))},[d,s]));const r=u(async(n,m=[])=>{if(!i?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await i.instruct({type:"extension",payload:{name:"dynamic-focus",method:n,args:m}})},[i]),E=u(async n=>{w.current?.["dynamic-focus"]?.isEnabled||(await r("enable",[n]),s("dynamic-focus",V=>({...V,isEnabled:!0})))},[r,s]),T=u(async n=>await r("updateState",[n]),[r]),M=u(async()=>await r("getState"),[r]),O=u(async n=>await r("focus",[n]),[r]),Z=u(async()=>{await r("disable"),h([]),s("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[r,h,s]);return{isReady:f,isEnabled:a,focusedFacades:c,updateState:T,getState:M,focus:O,disable:Z,enable:E}}l(k,"useDynamicFocus");export{k as useDynamicFocus,b as useDynamicFocusEvent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/dynamic-focus",
3
- "version": "6.18.0-beta.0",
3
+ "version": "6.19.0-beta.0",
4
4
  "homepage": "https://developer.mappedin.com/",
5
5
  "private": false,
6
6
  "main": "lib/esm/index.js",
@@ -37,9 +37,9 @@
37
37
  "license": "SEE LICENSE IN LICENSE.txt",
38
38
  "peerDependencies": {
39
39
  "react": ">=16.8.0",
40
- "@mappedin/mappedin-js": "^6.18.0",
41
- "@mappedin/react-native-sdk": "^6.18.0",
42
- "@mappedin/react-sdk": "^6.18.0"
40
+ "@mappedin/react-native-sdk": "^6.19.0",
41
+ "@mappedin/react-sdk": "^6.19.0",
42
+ "@mappedin/mappedin-js": "^6.19.0"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@mappedin/react-sdk": {
@@ -1 +0,0 @@
1
- var so=Object.defineProperty,Ao=Object.defineProperties;var Do=Object.getOwnPropertyDescriptors;var It=Object.getOwnPropertySymbols;var ro=Object.prototype.hasOwnProperty,no=Object.prototype.propertyIsEnumerable;var ao=s=>{throw TypeError(s)};var Nt=(s,o,e)=>o in s?so(s,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[o]=e,k=(s,o)=>{for(var e in o||(o={}))ro.call(o,e)&&Nt(s,e,o[e]);if(It)for(var e of It(o))no.call(o,e)&&Nt(s,e,o[e]);return s},lt=(s,o)=>Ao(s,Do(o)),a=(s,o)=>so(s,"name",{value:o,configurable:!0});var lo=(s,o)=>{var e={};for(var i in s)ro.call(s,i)&&o.indexOf(i)<0&&(e[i]=s[i]);if(s!=null&&It)for(var i of It(s))o.indexOf(i)<0&&no.call(s,i)&&(e[i]=s[i]);return e};var F=(s,o,e)=>Nt(s,typeof o!="symbol"?o+"":o,e),Ct=(s,o,e)=>o.has(s)||ao("Cannot "+e);var t=(s,o,e)=>(Ct(s,o,"read from private field"),e?e.call(s):o.get(s)),m=(s,o,e)=>o.has(s)?ao("Cannot add the same private member more than once"):o instanceof WeakSet?o.add(s):o.set(s,e),f=(s,o,e,i)=>(Ct(s,o,"write to private field"),i?i.call(s,e):o.set(s,e),e),b=(s,o,e)=>(Ct(s,o,"access private method"),e);var S={env:{NODE_ENV:"production",npm_package_version:"6.18.0-beta.0"}};var ut={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},dt=.2,Gt=.4;var Pt="[MappedinJS]";function Rt(s="",{prefix:o=Pt}={}){let e="".concat(o).concat(s?"-".concat(s):""),i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let h=n.map(d=>d instanceof Error&&d.stack?"".concat(d.message,"\n").concat(d.stack):d);window.rnDebug("".concat(s," ").concat(r,": ").concat(h.join(" ")))}},"rnDebug");return{logState:S.env.NODE_ENV==="test"?3:0,log(...r){this.logState<=0&&(console.log(e,...r),i("log",r))},warn(...r){this.logState<=1&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=2&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){0<=r&&r<=3&&(this.logState=r)}}}a(Rt,"createLogger");var xo=Rt();var tt=xo;var C=Rt("",{prefix:"[DynamicFocus]"});var uo=a((s,o={})=>{var h,d;let e={initialVisibility:(h=o.initialVisibility)!=null?h:"indoor-first",debug:(d=o.debug)!=null?d:!1},i=Zo(s,e);if(i===void 0)return C.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:ut.indoorZoomThreshold,outdoorZoomThreshold:ut.outdoorZoomThreshold};let r=i+Gt,n=i+dt;return e.initialVisibility==="indoor-first"&&(r=i-dt,n=i-Gt),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Zo(s,o){var h;let i=s.getMapData().getByType("floor-stack").filter(d=>d.type!=="Outdoor"),r=1/0,n;for(let d of i){let u=(h=s.Camera.getFocusOnTransform(d).zoomLevel)!=null?h:1/0;u<r&&(r=u,n=d)}if(r!==1/0)return o.debug&&n&&s.Camera.getFocusOnTransform(n,{debugColor:"blue"}),r}a(Zo,"getDefaultZoomLevel");import{Floor as Ko,getMultiFloorState as Qo}from"@mappedin/mappedin-js";function co(s,o){if(s==null||o==null)return s===o;if(s.length!==o.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==o[e])return!1;return!0}a(co,"arraysEqual");var Ut=class Ut{constructor(){F(this,"_subscribers",{});F(this,"_abortController",new AbortController)}get signal(){return this._abortController.signal}publish(o,e){!this._subscribers||!this._subscribers[o]||this.signal.aborted||this._subscribers[o].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(o){this.signal.addEventListener("abort",()=>o(),{once:!0})}on(o,e,i){let r=i==null?void 0:i.signal;if(r!=null&&r.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[o]=this._subscribers[o]||[],this._subscribers[o].push(e);let n=a(()=>{this.off(o,e)},"cleanup");return r&&r.addEventListener("abort",n,{once:!0}),n}off(o,e){if(!this._subscribers||this._subscribers[o]==null||this.signal.aborted)return;let i=this._subscribers[o].indexOf(e);i!==-1&&this._subscribers[o].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(Ut,"PubSub");var Bt=Ut;import{Facade as Lo,Floor as _o,FloorStack as No}from"@mappedin/mappedin-js";var A,ct,z,w,T,x,ot,et,jt=class jt{constructor(o,e){F(this,"__type","building");m(this,A);m(this,ct,new Map);m(this,z,new Map);m(this,w,[]);m(this,T);m(this,x);F(this,"defaultFloor");F(this,"activeFloor");F(this,"excluded",!1);F(this,"floorsAltitudesMap",new Map);F(this,"aboveGroundFloors",[]);m(this,ot);m(this,et);var r;f(this,A,o),f(this,ct,new Map(o.floors.map(n=>[n.id,n]))),f(this,z,new Map(o.floors.map(n=>[n.elevation,n]))),f(this,w,Array.from(t(this,z).values()).sort((n,h)=>n.elevation-h.elevation)),this.defaultFloor=o.defaultFloor,this.activeFloor=this.defaultFloor,f(this,T,e),this.aboveGroundFloors=t(this,w).filter(n=>n.elevation>=0);let i=(r=o.facade)==null?void 0:r.spaces.map(n=>t(this,T).getState(n)).sort((n,h)=>n.altitude-h.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let n in this.aboveGroundFloors){let h=this.aboveGroundFloors[n],d=i[n];this.floorsAltitudesMap.set(h.elevation,{altitude:d.altitude,visualHeight:d.height})}}get id(){return t(this,A).id}get name(){return t(this,A).name}get floors(){return t(this,A).floors}get floorStack(){return t(this,A)}get facade(){return t(this,A).facade}get isCurrentFloorStack(){return this.id===t(this,T).currentFloorStack.id}get isIndoor(){let o=t(this,T).getState(this.facade);return this.isCurrentFloorStack||(o==null?void 0:o.visible)===!1&&(o==null?void 0:o.opacity)===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return t(this,ot)==null&&f(this,ot,Math.max(...t(this,z).keys())),t(this,ot)}get minElevation(){return t(this,et)==null&&f(this,et,Math.min(...t(this,z).keys())),t(this,et)}has(o){return _o.is(o)?t(this,ct).has(o.id):No.is(o)?o.id===t(this,A).id:Lo.is(o)?o.id===this.facade.id:!1}getFloorByElevation(o){return t(this,z).get(o)}getNearestFloorByElevation(o){let e=this.getFloorByElevation(o);if(e)return e;if(o>=0){if(o>this.maxElevation)return t(this,w)[t(this,w).length-1];for(let i=t(this,w).length-1;i>=0;i--){let r=t(this,w)[i];if(r.elevation<=o)return r}}else{if(o<this.minElevation)return t(this,w)[0];for(let i of t(this,w))if(i.elevation>=o)return i}}getHighestFloor(){return t(this,w)[t(this,w).length-1]}cancelAnimation(){t(this,x)&&(t(this,x).animation.cancel(),f(this,x,void 0))}async animateFacade(o,e={duration:150}){var h;let i=((h=t(this,x))==null?void 0:h.state)||t(this,T).getState(this.facade);if(!i||!o||(i==null?void 0:i.opacity)===o.opacity&&(i==null?void 0:i.visible)===o.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:n}=o;if(t(this,T).updateState(this.facade,{visible:!0}),r!==void 0){f(this,x,{animation:t(this,T).animateState(this.facade,{opacity:r},{duration:e.duration}),state:o});let d=await t(this,x).animation;if(f(this,x,void 0),d.result==="cancelled")return d}return n===!1&&t(this,T).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),t(this,A).floors.forEach(o=>{t(this,T).updateState(o,{visible:o.id===t(this,T).currentFloor.id})}),this.has(t(this,T).currentFloor)||t(this,T).updateState(this.facade,{visible:!0,opacity:1})}};A=new WeakMap,ct=new WeakMap,z=new WeakMap,w=new WeakMap,T=new WeakMap,x=new WeakMap,ot=new WeakMap,et=new WeakMap,a(jt,"Building");var Vt=jt;function ho(s,o,e){return s>=o?"in-range":s<=e?"out-of-range":"transition"}a(ho,"getZoomState");function kt(s,o,e){if(s.__type==="outdoors"&&"floor"in s)return s.floor;let i=s;if(i.excluded)return i.activeFloor;switch(o){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(kt,"getFloorToShow");function Co(s,o,e,i){return i?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:o?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:s,state:{type:"facade",visible:!0,opacity:.2}}:{facade:s,state:{type:"facade",visible:!0,opacity:1}}}a(Co,"getFacadeState");function Go(s,o,e){return{outdoorOpacity:"initial",floorStates:s.floors.map(i=>{let n=i.id===o.id&&e;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(Go,"getSingleBuildingState");function fo(s,o){if(!o.includes("lock-elevation"))return"initial";for(let e of s)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(fo,"getOutdoorOpacity");function mo(s,o,e){var i;switch(e){case"in-range":return(i=s[0])!=null&&i.canSetFloor?s[0]:void 0;case"out-of-range":return o;case"transition":default:return}}a(mo,"getSetFloorTargetFromZoomState");function po(s){var J;let{buildings:o,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:h,floorIdsInNavigation:d,floorStackIdsInNavigation:u,multiFloorView:p,getMultiFloorState:M,dynamicBuildingInteriors:O,isolateBelowGroundView:B,currentElevation:j,forceInteriorsVisible:at,getFloorStackAltitudeData:V}=s,N=new Map,Zt=B&&j<0&&r==="in-range";for(let y of o){let Ot=e.has(y.id),X=Zt&&y.minElevation>=0,wt=X?!1:Ot,Lt=X?!1:zt({building:y,currentFloor:i,inRange:r==="in-range",inFocus:Ot,mode:n,elevation:h,inNavigation:u.includes(y.id),dynamicBuildingInteriors:O,forceInteriorsVisible:at}),_t=i.floorStack.id===y.id?y.activeFloor:kt(y,n,h),Bo=p!=null&&p.enabled?M(y.floors,_t||y.activeFloor,d,(J=V==null?void 0:V(y.id))!=null?J:y.floorsAltitudesMap,{color:p==null?void 0:p.footprintColor,spacesOpenToBelowEnabled:p==null?void 0:p.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:p==null?void 0:p.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:p==null?void 0:p.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:p==null?void 0:p.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:p==null?void 0:p.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:p==null?void 0:p.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:p==null?void 0:p.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:p==null?void 0:p.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:p==null?void 0:p.footprintOpacity,outline:p==null?void 0:p.footprintOutline}):Go(y.floorStack,_t||y.activeFloor,Lt),Vo=B&&j<0&&r==="in-range",ko=Co(y.facade,Lt,Vo,X);N.set(y.id,{building:y,showIndoor:Lt,floorStackState:Bo,facadeState:ko,inFocus:wt,floorToShow:_t,isAboveGroundInIsolation:X})}return N}a(po,"getBuildingStates");function go(s,o){return s.excluded?"none":o?"indoor":"outdoor"}a(go,"getBuildingAnimationType");function zt(s){let{building:o,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:h,inNavigation:d,dynamicBuildingInteriors:u,forceInteriorsVisible:p}=s;if(o.id===e.floorStack.id)return!0;if(o.excluded)return!1;if(p===!0||d===!0)return!0;if(!u)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return o.getFloorByElevation(h)!=null;default:break}return!0}a(zt,"shouldShowIndoor");function bo(s,o,e){return s!==o&&!e}a(bo,"shouldDeferSetFloor");var Fo=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Po,FloorStack as Ro}from"@mappedin/mappedin-js";function yo(s,o,e,i){return(s<o||s>e)&&tt.warn(i),Math.min(e,Math.max(o,s))}a(yo,"clampWithWarning");function $t(s,o){return!Po.is(s)||(s==null?void 0:s.floorStack)==null||!Ro.is(o)?!1:s.floorStack.id!==o.id?(tt.warn("Floor (".concat(s.id,") does not belong to floor stack (").concat(o.id,").")),!1):!0}a($t,"validateFloorForStack");function Yt(s,o,e,i){return yo(s,o,e,"".concat(i," must be between ").concat(o," and ").concat(e,"."))}a(Yt,"validateZoomThreshold");var Z,it,ht,qt,Wt=class Wt{constructor(o,e){m(this,ht);F(this,"__type","outdoors");m(this,Z);m(this,it);f(this,Z,o),f(this,it,e)}get id(){return t(this,Z).id}get floorStack(){return t(this,Z)}get floor(){return t(this,Z).defaultFloor}matchesFloorStack(o){return o===t(this,Z)||o===t(this,Z).id}show(){b(this,ht,qt).call(this,!0)}hide(){b(this,ht,qt).call(this,!1)}destroy(){this.matchesFloorStack(t(this,it).currentFloorStack)||this.hide()}};Z=new WeakMap,it=new WeakMap,ht=new WeakSet,qt=a(function(o){for(let e of t(this,Z).floors)t(this,it).updateState(e,{visible:o})},"#setVisible"),a(Wt,"Outdoors");var At=Wt;function So(s,o){let e=s.getByType("floor-stack"),i=e.find(n=>{var h;return((h=n.type)==null?void 0:h.toLowerCase())==="outdoor"});if(i)return i;let r=e.find(n=>n.facade==null&&!o.has(n.id));return r||(C.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(So,"getOutdoorFloorStack");function Uo(s,o){return"".concat(o," ").concat(s)}a(Uo,"formatMessage");var Ht=class Ht extends Error{constructor(o,e=Pt){super(Uo(o,e)),this.name="MappedinError"}};a(Ht,"MappedinError");var Dt=Ht;var jo=a(s=>s,"linearEase"),zo=a(s=>s*s,"quadEaseIn"),$o=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),Yo=a(s=>1-(1-s)*(1-s),"quadEaseOut"),qo=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Wo={linear:jo,"ease-in":zo,"ease-out":Yo,"ease-in-out":$o,"ease-out-cubic":qo};function Ho(s,o){let e=0;if(o.length<2)return e;let r=o[0]<o[1]?(n,h)=>n>h:(n,h)=>n<h;for(;e<o.length-1&&r(s,o[e+1]);)e++;return e>o.length-2?Math.max(0,o.length-2):e}a(Ho,"getInterpolationBreakpoint");function Eo(s,o,e,i="ease-in"){if(o.length!==e.length)throw new Dt("Input and output ranges must have the same number of values.");s=Math.max(o[0],Math.min(s,o[o.length-1]));let r=Ho(s,o),n=(s-o[r])/(o[r+1]-o[r]),h=typeof i=="function"?i(n):Wo[i](n);return e[r]+h*(e[r+1]-e[r])}a(Eo,"interpolateMulti");var L,ft,mt,G,pt,Qt=class Qt{constructor(o,e,i){F(this,"layers");F(this,"visible");m(this,L);m(this,ft,[]);m(this,mt,!1);m(this,G,new Map);F(this,"interpolationFn");m(this,pt,1);this.layers=o,this.visible=e,f(this,L,i)}processLayerGroup(o,e){t(this,mt)||(this.layers.forEach(i=>{let r=o[i];r&&t(this,ft).push(...r)}),f(this,mt,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:r,indoorZoomThreshold:n}=e();return Eo(i,[r,n],[1,0])}))}setOpacity(o){var e,i,r;f(this,pt,o);for(let n of t(this,ft))if(n.startsWith("img_")){let h=t(this,L).Image3D.getById(n);if(h){let d=t(this,L).getState(h.image);t(this,G).has(n)||t(this,G).set(n,(e=d==null?void 0:d.opacity)!=null?e:1);let u=Math.min(t(this,G).get(n),o);t(this,L).updateState(h.image,{opacity:u})}}else{let h=(i=t(this,L).getMapData())==null?void 0:i.getById("space",n);if(!h)continue;let d=t(this,L).getState(h);t(this,G).has(n)||t(this,G).set(n,(r=d==null?void 0:d.opacity)!=null?r:1);let u=Math.min(t(this,G).get(n),o);t(this,L).updateState(h,{opacity:u,visible:u>0})}}get opacity(){return t(this,pt)}};L=new WeakMap,ft=new WeakMap,mt=new WeakMap,G=new WeakMap,pt=new WeakMap,a(Qt,"LayerGroup");var Mt=Qt;function Kt(s,o){s.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(o);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Kt,"runLayerGroupInterpolations");var I,l,$,c,H,K,E,P,Q,R,v,st,gt,bt,Ft,_,Y,rt,U,q,W,g,Jt,vo,Xt,to,oo,Oo,eo,yt,St,Et,Tt,vt,nt,xt,wo,Io,D,io=class io{constructor(o){m(this,g);m(this,I);m(this,l);m(this,$);m(this,c,ut);m(this,H,[]);m(this,K,new Set);m(this,E,new Map);m(this,P);m(this,Q,!1);m(this,R,!1);m(this,v,0);m(this,st,0);m(this,gt,[]);m(this,bt,{});m(this,Ft,{});m(this,_,"transition");m(this,Y,"outdoor");m(this,rt,[]);m(this,U,!1);m(this,q,[]);m(this,W,null);F(this,"sceneUpdateQueue",Promise.resolve());F(this,"on",a((o,e)=>{t(this,I).on(o,e)},"on"));F(this,"off",a((o,e)=>{t(this,I).off(o,e)},"off"));m(this,yt,a(o=>{if(!this.isEnabled)return;let{facades:e}=o;if(co(e,this.focusedFacades)&&t(this,Y)==="transition"&&!t(this,R))return;f(this,R,!1),f(this,H,[]),t(this,K).clear();let i=t(this,c).isolateBelowGroundView&&t(this,v)<0;if(e.length>0)for(let r of e){let n=t(this,E).get(r.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;t(this,K).add(n.id),t(this,H).push(n)}}t(this,c).autoFocus&&this.focus()},"#handleFacadesInViewChange"));m(this,St,a(async o=>{var d,u,p,M;if(!this.isEnabled)return;let{floor:e}=o,i=t(this,E).get(e.floorStack.id);i&&(i.activeFloor=e);let r=t(this,c).isolateBelowGroundView&&t(this,v)<0;(i==null?void 0:i.excluded)===!1&&!t(this,P).matchesFloorStack(e.floorStack)&&f(this,v,e.elevation);let n=t(this,c).isolateBelowGroundView&&t(this,v)<0,h=r&&!n;if(t(this,l).manualFloorVisibility===!0){o.reason!=="dynamic-focus"&&(h?(f(this,R,!0),t(this,l).Camera.updateFacadesInView(),t(this,c).autoFocus||(await t(this,D).call(this,e),t(this,I).publish("focus",{facades:this.focusedFacades}))):(await t(this,D).call(this,e),t(this,I).publish("focus",{facades:this.focusedFacades})));let O=(u=(d=i==null?void 0:i.floorsAltitudesMap.get(e.elevation))==null?void 0:d.altitude)!=null?u:0;t(this,l).options.multiFloorView!=null&&((p=t(this,l).options.multiFloorView)!=null&&p.enabled)&&((M=t(this,l).options.multiFloorView)!=null&&M.updateCameraElevationOnFloorChange)&&t(this,l).Camera.elevation!==O&&t(this,l).Camera.animateElevation(O,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));m(this,Et,a(()=>{f(this,Q,!0)},"#handleUserInteractionStart"));m(this,Tt,a(()=>{f(this,Q,!1)},"#handleUserInteractionEnd"));m(this,vt,a(()=>{t(this,D).call(this)},"#handleGlobalStateChange"));m(this,nt,a(o=>{if(!this.isEnabled)return;let{zoomLevel:e}=o,i=ho(e,t(this,c).indoorZoomThreshold,t(this,c).outdoorZoomThreshold);t(this,_)!==i&&(f(this,_,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Kt(t(this,q),e)},"#handleCameraChange"));m(this,D,a(async o=>{var u,p,M;if(t(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=o||t(this,l).currentFloor,i=t(this,l).getGlobalState().multiFloorView,r=t(this,l).options.multiFloorView?k(k({},t(this,l).options.multiFloorView),i):t(this,l).options.multiFloorView,n=((p=(u=t(this,l).Navigation)==null?void 0:u.floors)==null?void 0:p.map(O=>O.id))||[],h=((M=t(this,l).Navigation)==null?void 0:M.floorStacks.map(O=>O.id))||[],d=new Promise(async O=>{var at;await this.sceneUpdateQueue;let B=po({buildings:Array.from(t(this,E).values()),inViewSet:t(this,K),currentFloor:e,zoomState:t(this,_),mode:t(this,c).mode,elevation:t(this,v),floorIdsInNavigation:n,floorStackIdsInNavigation:h,multiFloorView:r,getMultiFloorState:(at=t(this,c).customMultiFloorVisibilityState)!=null?at:Qo,dynamicBuildingInteriors:t(this,c).dynamicBuildingInteriors,isolateBelowGroundView:t(this,c).isolateBelowGroundView,currentElevation:t(this,v),forceInteriorsVisible:t(this,c).forceInteriorsVisible,getFloorStackAltitudeData:a(V=>t(this,l).getFloorStackAltitudeData(V),"getFloorStackAltitudeData")}),j=[];await Promise.all(Array.from(B.values()).map(async V=>{let{building:N,showIndoor:Zt,floorStackState:J,facadeState:y,inFocus:Ot,isAboveGroundInIsolation:X}=V;j.push(J);let wt=go(N,Zt);if(wt==="indoor")return b(this,g,wo).call(this,N,J,y,Ot);if(wt==="outdoor")return b(this,g,Io).call(this,N,J,y,h,X)})),t(this,l).Outdoor.setOpacity(fo(j,t(this,c).mode)),f(this,rt,t(this,H).filter(V=>{var N;return((N=B.get(V.id))==null?void 0:N.showIndoor)===!0}).map(V=>V.facade)),t(this,I).publish("focus",{facades:t(this,rt)}),O()});return this.sceneUpdateQueue=d,d},"#applyBuildingStates"));f(this,I,new Bt),f(this,l,o),C.setLevel(tt.logState),f(this,$,t(this,l).getMapData()),f(this,v,t(this,l).currentFloor.elevation),f(this,st,t(this,l).Camera.elevation);for(let e of t(this,$).getByType("facade"))t(this,E).set(e.floorStack.id,new Vt(e.floorStack,t(this,l)));b(this,g,Oo).call(this),f(this,P,new At(So(t(this,$),t(this,E)),t(this,l))),t(this,l).on("floor-change-start",t(this,St)),t(this,l).on("camera-change",t(this,nt)),t(this,l).on("facades-in-view-change",t(this,yt)),t(this,l).on("user-interaction-start",t(this,Et)),t(this,l).on("user-interaction-end",t(this,Tt)),t(this,l).on("global-state-change",t(this,vt))}enable(o){if(t(this,U)){C.warn("enable() called on an already enabled Dynamic Focus instance.");return}f(this,U,!0),t(this,l).manualFloorVisibility=!0,t(this,P).show(),this.updateState(k(k({},t(this,c)),o)),b(this,g,vo).call(this),t(this,nt).call(this,{zoomLevel:t(this,l).Camera.zoomLevel,center:t(this,l).Camera.center,bearing:t(this,l).Camera.bearing,pitch:t(this,l).Camera.pitch}),t(this,l).Camera.updateFacadesInView()}disable(){if(!t(this,U)){C.warn("disable() called on an already disabled Dynamic Focus instance.");return}f(this,U,!1),t(this,l).manualFloorVisibility=!1}get isEnabled(){return t(this,U)}get isIndoor(){return t(this,Y)==="indoor"}get isOutdoor(){return t(this,Y)==="outdoor"}get outdoorsFloorStack(){return t(this,P).floorStack}get layers(){return t(this,gt)}get layersBySpaceId(){return t(this,bt)}setIndoor(){f(this,Y,"indoor"),f(this,_,"in-range"),b(this,g,Jt).call(this)}setOutdoor(){f(this,Y,"outdoor"),f(this,_,"out-of-range"),b(this,g,Jt).call(this)}get focusedFacades(){return[...t(this,rt)]}getState(){return k({},t(this,c))}updateState(o){var M,O;let e=!1,i=t(this,c).indoorZoomThreshold,r=t(this,c).outdoorZoomThreshold,n=t(this,c).isolateBelowGroundView&&t(this,v)<0,h=!!t(this,c).autoZoomThresholds,d=o.autoZoomThresholds!=null?!!o.autoZoomThresholds:h,u=o;if(d&&(u.indoorZoomThreshold!=null||u.outdoorZoomThreshold!=null)){C.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let p=u,{indoorZoomThreshold:B,outdoorZoomThreshold:j}=p;u=lo(p,["indoorZoomThreshold","outdoorZoomThreshold"])}if(!h&&d?(f(this,W,()=>{if(!t(this,U))return;let B=t(this,c).indoorZoomThreshold,j=t(this,c).outdoorZoomThreshold;b(this,g,to).call(this),b(this,g,oo).call(this,B,j),t(this,D).call(this)}),t(this,l).on("camera-screen-offsets-change",t(this,W))):h&&!d&&b(this,g,Xt).call(this),u.indoorZoomThreshold!=null&&(u.indoorZoomThreshold=Yt(u.indoorZoomThreshold,(M=u==null?void 0:u.outdoorZoomThreshold)!=null?M:t(this,c).outdoorZoomThreshold,t(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),u.outdoorZoomThreshold!=null&&(u.outdoorZoomThreshold=Yt(u.outdoorZoomThreshold,t(this,l).Camera.minZoomLevel,(O=u==null?void 0:u.indoorZoomThreshold)!=null?O:t(this,c).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),u.mode!=null&&(u.mode=Fo.includes(u.mode)?u.mode:"default-floor"),u.autoAdjustFacadeHeights!=null&&(t(this,c).autoAdjustFacadeHeights=u.autoAdjustFacadeHeights),u.dynamicBuildingInteriors!=null&&u.dynamicBuildingInteriors!==t(this,c).dynamicBuildingInteriors&&(e=!0),u.isolateBelowGroundView!=null&&u.isolateBelowGroundView!==t(this,c).isolateBelowGroundView&&(e=!0),u.forceInteriorsVisible!=null&&u.forceInteriorsVisible!==t(this,c).forceInteriorsVisible&&(e=!0),u.showLabelsAndMarkersOnAllVisibleFloors!=null&&u.showLabelsAndMarkersOnAllVisibleFloors!==t(this,c).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),f(this,c,Object.assign({},t(this,c),Object.fromEntries(Object.entries(u).filter(([,B])=>B!=null)))),d&&u.autoZoomThresholds!==void 0&&(b(this,g,to).call(this),e=!0),u.mode!=null&&u.preloadFloors&&b(this,g,eo).call(this,u.mode),e){let B=t(this,c).isolateBelowGroundView&&t(this,v)<0;n&&!B?(f(this,R,!0),t(this,l).Camera.updateFacadesInView(),t(this,c).autoFocus||t(this,D).call(this)):t(this,D).call(this)}b(this,g,oo).call(this,i,r)}destroy(){this.disable(),b(this,g,Xt).call(this),t(this,l).off("facades-in-view-change",t(this,yt)),t(this,l).off("floor-change-start",t(this,St)),t(this,l).off("camera-change",t(this,nt)),t(this,l).off("user-interaction-start",t(this,Et)),t(this,l).off("user-interaction-end",t(this,Tt)),t(this,l).off("global-state-change",t(this,vt)),t(this,E).forEach(o=>o.destroy()),t(this,P).destroy(),t(this,I).destroy(),f(this,q,[])}async focus(o=t(this,c).setFloorOnFocus){if(o)if(bo(t(this,st),t(this,l).Camera.elevation,t(this,Q)))f(this,st,t(this,l).Camera.elevation),f(this,R,!0);else{let e=mo(t(this,H),t(this,P),t(this,_)),i=e?kt(e,t(this,c).mode,t(this,v)):void 0;i&&i.id!==t(this,l).currentFloor.id&&t(this,l).setFloor(i,{context:"dynamic-focus"})}await t(this,D).call(this),t(this,I).publish("focus",{facades:this.focusedFacades})}preloadFloors(){b(this,g,eo).call(this,t(this,c).mode)}setDefaultFloorForStack(o,e){if(!$t(e,o))return;let i=t(this,E).get(o.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(o){let e=t(this,E).get(o.id);e&&(e.defaultFloor=o.defaultFloor)}getDefaultFloorForStack(o){var e;return((e=t(this,E).get(o.id))==null?void 0:e.defaultFloor)||o.defaultFloor||o.floors[0]}setCurrentFloorForStack(o,e){if(!$t(e,o))return;let i=t(this,E).get(o.id);i&&(i.activeFloor=e,t(this,D).call(this))}exclude(o){let e=Array.isArray(o)?o:[o];for(let i of e){let r=t(this,E).get(i.id);r&&(r.excluded=!0)}}include(o){let e=Array.isArray(o)?o:[o];for(let i of e){let r=t(this,E).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(o){var e;return((e=t(this,E).get(o.id))==null?void 0:e.activeFloor)||this.getDefaultFloorForStack(o)}};I=new WeakMap,l=new WeakMap,$=new WeakMap,c=new WeakMap,H=new WeakMap,K=new WeakMap,E=new WeakMap,P=new WeakMap,Q=new WeakMap,R=new WeakMap,v=new WeakMap,st=new WeakMap,gt=new WeakMap,bt=new WeakMap,Ft=new WeakMap,_=new WeakMap,Y=new WeakMap,rt=new WeakMap,U=new WeakMap,q=new WeakMap,W=new WeakMap,g=new WeakSet,Jt=a(function(){t(this,c).autoFocus&&(t(this,Q)?this.focus():f(this,R,!0)),t(this,I).publish("state-change")},"#handleViewStateChange"),vo=a(function(){f(this,q,[]);for(let o of t(this,c).dynamicLayers){let e=new Mt([o],!0,t(this,l));e.processLayerGroup(t(this,Ft),()=>t(this,c)),t(this,q).push(e)}Kt(t(this,q),t(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),Xt=a(function(){t(this,W)&&(t(this,l).off("camera-screen-offsets-change",t(this,W)),f(this,W,null))},"#unsubscribeScreenOffsets"),to=a(function(){var n;let o=t(this,c).autoZoomThresholds,e=typeof o=="object"&&o!==null?k({},o):{},{indoorZoomThreshold:i,outdoorZoomThreshold:r}=uo(t(this,l),e);t(this,c).indoorZoomThreshold=i,t(this,c).outdoorZoomThreshold=r,((n=e.expandMinZoom)==null||n)&&r<t(this,l).Camera.minZoomLevel&&t(this,l).Camera.setMinZoomLevel(r-dt)},"#recalcThresholds"),oo=a(function(o,e){(t(this,c).indoorZoomThreshold!==o||t(this,c).outdoorZoomThreshold!==e)&&t(this,I).publish("zoom-threshold-change",{indoorZoomThreshold:t(this,c).indoorZoomThreshold,outdoorZoomThreshold:t(this,c).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),Oo=a(function(){var r,n,h;let o=(h=(n=(r=t(this,$).internal.mvf)==null?void 0:r.enterprise)==null?void 0:n.layers)!=null?h:[],e={},i={};o.forEach(d=>{e[d.name]||(e[d.name]=[]),e[d.name].push(...d.spaces.map(({spaceId:u})=>u));for(let{spaceId:u}of d.spaces)i[u]==null&&(i[u]=[]),i[u].push(d.name)}),f(this,gt,o.map(({name:d})=>d)),f(this,bt,i),f(this,Ft,e)},"#setupLayers"),eo=a(function(o){t(this,l).preloadFloors(t(this,$).getByType("facade").map(e=>kt(t(this,E).get(e.floorStack.id),o,t(this,v))).filter(e=>e!=null&&Ko.is(e)))},"#preloadFloors"),yt=new WeakMap,St=new WeakMap,Et=new WeakMap,Tt=new WeakMap,vt=new WeakMap,nt=new WeakMap,xt=a(function(o,e,i,r=!1){o.forEach(n=>{if(n.floor)if(e){let d=i!==void 0&&!r?lt(k({},n.state),{labels:lt(k({},n.state.labels),{enabled:n.state.labels.enabled&&i}),markers:lt(k({},n.state.markers),{enabled:n.state.markers.enabled&&i}),occlusion:lt(k({},n.state.occlusion),{enabled:n.state.occlusion.enabled&&i})}):n.state;t(this,l).updateState(n.floor,d)}else t(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),wo=a(async function(o,e,i,r){return b(this,g,xt).call(this,e.floorStates,!0,r,t(this,c).showLabelsAndMarkersOnAllVisibleFloors),o.animateFacade(i.state,t(this,c).indoorAnimationOptions)},"#animateIndoorSequence"),Io=a(async function(o,e,i,r,n){let h=n;h&&b(this,g,xt).call(this,e.floorStates,!1,void 0,t(this,c).showLabelsAndMarkersOnAllVisibleFloors);let d=await o.animateFacade(i.state,t(this,c).outdoorAnimationOptions);return d.result==="completed"&&!h&&b(this,g,xt).call(this,e.floorStates,zt({building:o,currentFloor:t(this,l).currentFloor,inRange:t(this,_)==="in-range",inFocus:t(this,K).has(o.id),mode:t(this,c).mode,elevation:t(this,v),inNavigation:r.includes(o.floorStack.id),dynamicBuildingInteriors:t(this,c).dynamicBuildingInteriors,forceInteriorsVisible:t(this,c).forceInteriorsVisible}),void 0,t(this,c).showLabelsAndMarkersOnAllVisibleFloors),d},"#animateOutdoorSequence"),D=new WeakMap,a(io,"DynamicFocus");var To=io;export{a,uo as b,To as c};