@mappedin/dynamic-focus 6.8.0-beta.0 → 6.9.1-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.
@@ -1 +1 @@
1
- var Ht=Object.defineProperty,po=Object.defineProperties;var go=Object.getOwnPropertyDescriptors;var qt=Object.getOwnPropertySymbols;var Fo=Object.prototype.hasOwnProperty,yo=Object.prototype.propertyIsEnumerable;var zt=r=>{throw TypeError(r)};var Vt=(r,t,e)=>t in r?Ht(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_=(r,t)=>{for(var e in t||(t={}))Fo.call(t,e)&&Vt(r,e,t[e]);if(qt)for(var e of qt(t))yo.call(t,e)&&Vt(r,e,t[e]);return r},at=(r,t)=>po(r,go(t)),s=(r,t)=>Ht(r,"name",{value:t,configurable:!0});var p=(r,t,e)=>Vt(r,typeof t!="symbol"?t+"":t,e),Mt=(r,t,e)=>t.has(r)||zt("Cannot "+e);var o=(r,t,e)=>(Mt(r,t,"read from private field"),e?e.call(r):t.get(r)),d=(r,t,e)=>t.has(r)?zt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>(Mt(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),E=(r,t,e)=>(Mt(r,t,"access private method"),e);var b={env:{NODE_ENV:"production",npm_package_version:"6.8.0-beta.0"}};import{Floor as Lo,getMultiFloorState as Co}from"@mappedin/mappedin-js";function Wt(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}s(Wt,"arraysEqual");var xt=class xt{constructor(){p(this,"_subscribers",{});p(this,"_abortController",new AbortController);p(this,"_cleanupFunctions",[])}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 n=i==null?void 0:i.signal;if(n!=null&&n.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let a=s(()=>this.off(t,e),"cleanup");return n&&n.addEventListener("abort",a,{once:!0}),this._cleanupFunctions.push(a),a}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(){if(!this.signal.aborted){for(let t of this._cleanupFunctions)t();this._cleanupFunctions=[],this._subscribers={},this._abortController.abort()}}};s(xt,"PubSub");var St=xt;import{Facade as So,Floor as Eo,FloorStack as vo}from"@mappedin/mappedin-js";var w,st,N,v,S,I,W,K,Ot=class Ot{constructor(t,e){p(this,"__type","building");d(this,w);d(this,st,new Map);d(this,N,new Map);d(this,v,[]);d(this,S);d(this,I);p(this,"defaultFloor");p(this,"activeFloor");p(this,"excluded",!1);p(this,"floorsAltitudesMap",new Map);p(this,"aboveGroundFloors",[]);d(this,W);d(this,K);var n;c(this,w,t),c(this,st,new Map(t.floors.map(a=>[a.id,a]))),c(this,N,new Map(t.floors.map(a=>[a.elevation,a]))),c(this,v,Array.from(o(this,N).values()).sort((a,h)=>a.elevation-h.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,c(this,S,e),this.aboveGroundFloors=o(this,v).filter(a=>a.elevation>=0);let i=(n=t.facade)==null?void 0:n.spaces.map(a=>o(this,S).getState(a)).sort((a,h)=>a.altitude-h.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let a in this.aboveGroundFloors){let h=this.aboveGroundFloors[a],u=i[a];this.floorsAltitudesMap.set(h.elevation,{altitude:u.altitude,effectiveHeight:u.height})}}get id(){return o(this,w).id}get name(){return o(this,w).name}get floors(){return o(this,w).floors}get floorStack(){return o(this,w)}get facade(){return o(this,w).facade}get isCurrentFloorStack(){return this.id===o(this,S).currentFloorStack.id}get isIndoor(){let t=o(this,S).getState(this.facade);return this.isCurrentFloorStack||(t==null?void 0:t.visible)===!1&&(t==null?void 0:t.opacity)===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,W)==null&&c(this,W,Math.max(...o(this,N).keys())),o(this,W)}get minElevation(){return o(this,K)==null&&c(this,K,Math.min(...o(this,N).keys())),o(this,K)}has(t){return Eo.is(t)?o(this,st).has(t.id):vo.is(t)?t.id===o(this,w).id:So.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,v)[o(this,v).length-1];for(let i=o(this,v).length-1;i>=0;i--){let n=o(this,v)[i];if(n.elevation<=t)return n}}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,I)&&(o(this,I).animation.cancel(),c(this,I,void 0))}async animateFacade(t,e={duration:150}){var h;let i=((h=o(this,I))==null?void 0:h.state)||o(this,S).getState(this.facade);if(!i||!t||(i==null?void 0:i.opacity)===t.opacity&&(i==null?void 0:i.visible)===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:n,visible:a}=t;if(o(this,S).updateState(this.facade,{visible:!0}),n!==void 0){c(this,I,{animation:o(this,S).animateState(this.facade,{opacity:n},{duration:e.duration}),state:t});let u=await o(this,I).animation;if(c(this,I,void 0),u.result==="cancelled")return u}return a===!1&&o(this,S).updateState(this.facade,{visible:a}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,w).floors.forEach(t=>{o(this,S).updateState(t,{visible:t.id===o(this,S).currentFloor.id})}),this.has(o(this,S).currentFloor)||o(this,S).updateState(this.facade,{visible:!0,opacity:1})}};w=new WeakMap,st=new WeakMap,N=new WeakMap,v=new WeakMap,S=new WeakMap,I=new WeakMap,W=new WeakMap,K=new WeakMap,s(Ot,"Building");var Et=Ot;function Kt(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}s(Kt,"getZoomState");function vt(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}s(vt,"getFloorToShow");function wo(r,t,e){return 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}}}s(wo,"getFacadeState");function ko(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}}}})}}s(ko,"getSingleBuildingState");function Qt(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"}s(Qt,"getOutdoorOpacity");function Jt(r,t,e){var i;switch(e){case"in-range":return(i=r[0])!=null&&i.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}s(Jt,"getSetFloorTargetFromZoomState");function Xt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:n,mode:a,elevation:h,floorIdsInNavigation:u,floorStackIdsInNavigation:f,multiFloorView:P,getMultiFloorState:R,dynamicBuildingInteriors:bt,isolateBelowGroundView:it,currentElevation:rt}=r,A=new Map,D=it&&rt<0;for(let F of t){let H=e.has(F.id),nt=D&&F.minElevation>=0,It=nt?!1:H,z=nt?!1:At({building:F,currentFloor:i,inRange:n==="in-range",inFocus:H,mode:a,elevation:h,inNavigation:f.includes(F.id),dynamicBuildingInteriors:bt}),Tt=i.floorStack.id===F.id?F.activeFloor:vt(F,a,h),mo=P.enabled?R(F.floors,Tt||F.activeFloor,P==null?void 0:P.floorGap,u,F.floorsAltitudesMap):ko(F.floorStack,Tt||F.activeFloor,z),fo=wo(F.facade,z,it&&rt<0);A.set(F.id,{building:F,showIndoor:z,floorStackState:mo,facadeState:fo,inFocus:It,floorToShow:Tt})}return A}s(Xt,"getBuildingStates");function to(r,t){return r.excluded?"none":t?"indoor":"outdoor"}s(to,"getBuildingAnimationType");function At(r){let{building:t,currentFloor:e,inRange:i,inFocus:n,mode:a,elevation:h,inNavigation:u,dynamicBuildingInteriors:f}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(u===!0)return!0;if(!f)return e.floorStack.type!=="Outdoor";if(!i||!n)return!1;switch(a){case"lock-elevation":return t.getFloorByElevation(h)!=null;default:break}return!0}s(At,"shouldShowIndoor");function oo(r,t,e){return r!==t&&!e}s(oo,"shouldDeferSetFloor");var eo=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Io,FloorStack as To}from"@mappedin/mappedin-js";var Dt="[MappedinJS]";function _t(r="",{prefix:t=Dt}={}){let e="".concat(t).concat(r?"-".concat(r):""),i=s((n,a)=>{if(typeof window<"u"&&window.rnDebug){let h=a.map(u=>u instanceof Error&&u.stack?"".concat(u.message,"\n").concat(u.stack):u);window.rnDebug("".concat(r," ").concat(n,": ").concat(h.join(" ")))}},"rnDebug");return{logState:b.env.NODE_ENV==="test"?3:0,log(...n){this.logState<=0&&(console.log(e,...n),i("log",n))},warn(...n){this.logState<=1&&(console.warn(e,...n),i("warn",n))},error(...n){this.logState<=2&&(console.error(e,...n),i("error",n))},assert(...n){console.assert(...n)},time(n){console.time(n)},timeEnd(n){console.timeEnd(n)},setLevel(n){0<=n&&n<=3&&(this.logState=n)}}}s(_t,"createLogger");var Bo=_t();var Q=Bo;function io(r,t,e,i){return(r<t||r>e)&&Q.warn(i),Math.min(e,Math.max(t,r))}s(io,"clampWithWarning");function Nt(r,t){return!Io.is(r)||(r==null?void 0:r.floorStack)==null||!To.is(t)?!1:r.floorStack.id!==t.id?(Q.warn("Floor (".concat(r.id,") does not belong to floor stack (").concat(t.id,").")),!1):!0}s(Nt,"validateFloorForStack");function Lt(r,t,e,i){return io(r,t,e,"".concat(i," must be between ").concat(t," and ").concat(e,"."))}s(Lt,"validateZoomThreshold");var J=_t("",{prefix:"[DynamicFocus]"});var T,X,lt,Ct,Zt=class Zt{constructor(t,e){d(this,lt);p(this,"__type","outdoors");d(this,T);d(this,X);c(this,T,t),c(this,X,e)}get id(){return o(this,T).id}get floorStack(){return o(this,T)}get floor(){return o(this,T).defaultFloor}matchesFloorStack(t){return t===o(this,T)||t===o(this,T).id}show(){E(this,lt,Ct).call(this,!0)}hide(){E(this,lt,Ct).call(this,!1)}destroy(){this.matchesFloorStack(o(this,X).currentFloorStack)||this.hide()}};T=new WeakMap,X=new WeakMap,lt=new WeakSet,Ct=s(function(t){for(let e of o(this,T).floors)o(this,X).updateState(e,{visible:t})},"#setVisible"),s(Zt,"Outdoors");var wt=Zt;function ro(r,t){var h;let e=r.getByType("floor-stack"),i=e.find(u=>{var f;return((f=u.type)==null?void 0:f.toLowerCase())==="outdoor"}),n=(h=r.getByType("enterprise-venue"))==null?void 0:h.defaultFloor;if(n){let u=r.getById("floor",n);if(u)return u.floorStack}if(i)return i;let a=e.find(u=>u.facade==null&&!t.has(u.id));return a||(J.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}s(ro,"getOutdoorFloorStack");import{getMultiFloorState as Vo}from"@mappedin/mappedin-js";var no={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,customMultiFloorVisibilityState:Vo,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1},ve=.2,we=.4;function Mo(r,t){return"".concat(t," ").concat(r)}s(Mo,"formatMessage");var Gt=class Gt extends Error{constructor(t,e=Dt){super(Mo(t,e)),this.name="MappedinError"}};s(Gt,"MappedinError");var kt=Gt;var xo=s(r=>r,"linearEase"),Oo=s(r=>r*r,"quadEaseIn"),Ao=s(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Do=s(r=>1-(1-r)*(1-r),"quadEaseOut"),_o={linear:xo,"ease-in":Oo,"ease-out":Do,"ease-in-out":Ao};function No(r,t){let e=0;if(t.length<2)return e;let n=t[0]<t[1]?(a,h)=>a>h:(a,h)=>a<h;for(;e<t.length-1&&n(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}s(No,"getInterpolationBreakpoint");function ao(r,t,e,i="ease-in"){if(t.length!==e.length)throw new kt("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let n=No(r,t),a=(r-t[n])/(t[n+1]-t[n]),h=typeof i=="function"?i(a):_o[i](a);return e[n]+h*(e[n+1]-e[n])}s(ao,"interpolateMulti");var V,ut,dt,x,ct,Rt=class Rt{constructor(t,e,i){p(this,"layers");p(this,"visible");d(this,V);d(this,ut,[]);d(this,dt,!1);d(this,x,new Map);p(this,"interpolationFn");d(this,ct,1);this.layers=t,this.visible=e,c(this,V,i)}processLayerGroup(t,e,i){if(!o(this,dt)&&(this.layers.forEach(n=>{let a=t[n];a&&o(this,ut).push(...a)}),c(this,dt,!0),this.visible)){let n=[e,i],a=[1,0];this.interpolationFn=h=>ao(h,n,a)}}setOpacity(t){var e,i,n;c(this,ct,t);for(let a of o(this,ut))if(a.startsWith("img_")){let h=o(this,V).Image3D.getById(a);if(h){let u=o(this,V).getState(h.image);o(this,x).has(a)||o(this,x).set(a,(e=u==null?void 0:u.opacity)!=null?e:1);let f=Math.min(o(this,x).get(a),t);o(this,V).updateState(h.image,{opacity:f})}}else{let h=(i=o(this,V).getMapData())==null?void 0:i.getById("space",a);if(!h)continue;let u=o(this,V).getState(h);o(this,x).has(a)||o(this,x).set(a,(n=u==null?void 0:u.opacity)!=null?n:1);let f=Math.min(o(this,x).get(a),t);o(this,V).updateState(h,{opacity:f,visible:f>0})}}get opacity(){return o(this,ct)}};V=new WeakMap,ut=new WeakMap,dt=new WeakMap,x=new WeakMap,ct=new WeakMap,s(Rt,"LayerGroup");var Bt=Rt;function Pt(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}s(Pt,"runLayerGroupInterpolations");var k,l,L,m,j,U,y,O,$,Y,B,tt,ht,mt,ft,M,C,ot,Z,G,g,jt,lo,uo,Ut,pt,gt,Ft,yt,et,$t,co,ho,q,Yt=class Yt{constructor(t){d(this,g);d(this,k);d(this,l);d(this,L);d(this,m,no);d(this,j,[]);d(this,U,new Set);d(this,y,new Map);d(this,O);d(this,$,!1);d(this,Y,!1);d(this,B,0);d(this,tt,0);d(this,ht,[]);d(this,mt,{});d(this,ft,{});d(this,M,"transition");d(this,C,"outdoor");d(this,ot,[]);d(this,Z,!1);d(this,G,[]);p(this,"sceneUpdateQueue",Promise.resolve());p(this,"on",s((t,e)=>{o(this,k).on(t,e)},"on"));p(this,"off",s((t,e)=>{o(this,k).off(t,e)},"off"));d(this,pt,s(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Wt(e,this.focusedFacades)&&o(this,C)==="transition"&&!o(this,Y))return;c(this,Y,!1),c(this,j,[]),o(this,U).clear();let i=o(this,m).isolateBelowGroundView&&o(this,B)<0;if(e.length>0)for(let n of e){let a=o(this,y).get(n.floorStack.id);if(a){if(i&&a.minElevation>=0)continue;o(this,U).add(a.id),o(this,j).push(a)}}o(this,m).autoFocus&&this.focus()},"#handleFacadesInViewChange"));d(this,gt,s(async t=>{var n,a,h,u;if(!this.isEnabled)return;let{floor:e}=t,i=o(this,y).get(e.floorStack.id);if(i&&(i.activeFloor=e),(i==null?void 0:i.excluded)===!1&&!o(this,O).matchesFloorStack(e.floorStack)&&c(this,B,e.elevation),o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,q).call(this,e),o(this,k).publish("focus",{facades:this.focusedFacades}));let f=(a=(n=i==null?void 0:i.floorsAltitudesMap.get(e.elevation))==null?void 0:n.altitude)!=null?a:0;o(this,l).options.multiFloorView!=null&&((h=o(this,l).options.multiFloorView)!=null&&h.enabled)&&((u=o(this,l).options.multiFloorView)!=null&&u.updateCameraElevationOnFloorChange)&&o(this,l).Camera.elevation!==f&&o(this,l).Camera.animateElevation(f,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));d(this,Ft,s(()=>{c(this,$,!0)},"#handleUserInteractionStart"));d(this,yt,s(()=>{c(this,$,!1)},"#handleUserInteractionEnd"));d(this,et,s(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Kt(e,o(this,m).indoorZoomThreshold,o(this,m).outdoorZoomThreshold);o(this,M)!==i&&(c(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Pt(o(this,G),e)},"#handleCameraChange"));d(this,q,s(async t=>{var u,f,P;if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).options.multiFloorView,n=((f=(u=o(this,l).Navigation)==null?void 0:u.floors)==null?void 0:f.map(R=>R.id))||[],a=((P=o(this,l).Navigation)==null?void 0:P.floorStacks.map(R=>R.id))||[],h=new Promise(async R=>{var rt;await this.sceneUpdateQueue;let bt=Xt({buildings:Array.from(o(this,y).values()),inViewSet:o(this,U),currentFloor:e,zoomState:o(this,M),mode:o(this,m).mode,elevation:o(this,B),floorIdsInNavigation:n,floorStackIdsInNavigation:a,multiFloorView:i,getMultiFloorState:(rt=o(this,m).customMultiFloorVisibilityState)!=null?rt:Co,dynamicBuildingInteriors:o(this,m).dynamicBuildingInteriors,isolateBelowGroundView:o(this,m).isolateBelowGroundView,currentElevation:o(this,B)}),it=[];await Promise.all(Array.from(bt.values()).map(async A=>{let{building:D,showIndoor:F,floorStackState:H,facadeState:nt,inFocus:It}=A;it.push(H);let z=to(D,F);if(z==="indoor")return E(this,g,co).call(this,D,H,nt,It);if(z==="outdoor")return E(this,g,ho).call(this,D,H,nt,a)})),o(this,l).Outdoor.setOpacity(Qt(it,o(this,m).mode)),c(this,ot,o(this,j).filter(A=>{var D;return((D=bt.get(A.id))==null?void 0:D.showIndoor)===!0}).map(A=>A.facade)),o(this,k).publish("focus",{facades:o(this,ot)}),R()});return this.sceneUpdateQueue=h,h},"#applyBuildingStates"));c(this,k,new St),c(this,l,t),J.setLevel(Q.logState),c(this,L,o(this,l).getMapData()),c(this,B,o(this,l).currentFloor.elevation),c(this,tt,o(this,l).Camera.elevation);for(let e of o(this,L).getByType("facade"))o(this,y).set(e.floorStack.id,new Et(e.floorStack,o(this,l)));E(this,g,uo).call(this),c(this,O,new wt(ro(o(this,L),o(this,y)),o(this,l))),o(this,l).on("floor-change-start",o(this,gt)),o(this,l).on("camera-change",o(this,et)),o(this,l).on("facades-in-view-change",o(this,pt)),o(this,l).on("user-interaction-start",o(this,Ft)),o(this,l).on("user-interaction-end",o(this,yt))}enable(t){if(o(this,Z)){J.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,Z,!0),o(this,l).manualFloorVisibility=!0,o(this,O).show(),this.updateState(_(_({},o(this,m)),t)),E(this,g,lo).call(this),o(this,et).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,Z)){J.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,Z,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,Z)}get isIndoor(){return o(this,C)==="indoor"}get isOutdoor(){return o(this,C)==="outdoor"}get outdoorsFloorStack(){return o(this,O).floorStack}get layers(){return o(this,ht)}get layersBySpaceId(){return o(this,mt)}setIndoor(){c(this,C,"indoor"),c(this,M,"in-range"),E(this,g,jt).call(this)}setOutdoor(){c(this,C,"outdoor"),c(this,M,"out-of-range"),E(this,g,jt).call(this)}get focusedFacades(){return[...o(this,ot)]}getState(){return _({},o(this,m))}updateState(t){var i,n;let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Lt(t.indoorZoomThreshold,(i=t==null?void 0:t.outdoorZoomThreshold)!=null?i:o(this,m).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Lt(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,(n=t==null?void 0:t.indoorZoomThreshold)!=null?n:o(this,m).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=eo.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,m).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,m).dynamicBuildingInteriors&&(e=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,m).isolateBelowGroundView&&(e=!0),c(this,m,Object.assign({},o(this,m),Object.fromEntries(Object.entries(t).filter(([,a])=>a!=null)))),t.mode!=null&&t.preloadFloors&&E(this,g,Ut).call(this,t.mode),e&&o(this,q).call(this)}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,pt)),o(this,l).off("floor-change-start",o(this,gt)),o(this,l).off("camera-change",o(this,et)),o(this,l).off("user-interaction-start",o(this,Ft)),o(this,l).off("user-interaction-end",o(this,yt)),o(this,y).forEach(t=>t.destroy()),o(this,O).destroy(),o(this,k).destroy(),c(this,G,[])}async focus(t=o(this,m).setFloorOnFocus){if(t)if(oo(o(this,tt),o(this,l).Camera.elevation,o(this,$)))c(this,tt,o(this,l).Camera.elevation),c(this,Y,!0);else{let e=Jt(o(this,j),o(this,O),o(this,M)),i=e?vt(e,o(this,m).mode,o(this,B)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,q).call(this),o(this,k).publish("focus",{facades:this.focusedFacades})}preloadFloors(){E(this,g,Ut).call(this,o(this,m).mode)}setDefaultFloorForStack(t,e){if(!Nt(e,t))return;let i=o(this,y).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,y).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){var e;return((e=o(this,y).get(t.id))==null?void 0:e.defaultFloor)||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Nt(e,t))return;let i=o(this,y).get(t.id);i&&(i.activeFloor=e,o(this,q).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,y).get(i.id);n&&(n.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,y).get(i.id);n&&(n.excluded=!1)}}getCurrentFloorForStack(t){var e;return((e=o(this,y).get(t.id))==null?void 0:e.activeFloor)||this.getDefaultFloorForStack(t)}};k=new WeakMap,l=new WeakMap,L=new WeakMap,m=new WeakMap,j=new WeakMap,U=new WeakMap,y=new WeakMap,O=new WeakMap,$=new WeakMap,Y=new WeakMap,B=new WeakMap,tt=new WeakMap,ht=new WeakMap,mt=new WeakMap,ft=new WeakMap,M=new WeakMap,C=new WeakMap,ot=new WeakMap,Z=new WeakMap,G=new WeakMap,g=new WeakSet,jt=s(function(){o(this,m).autoFocus&&(o(this,$)?this.focus():c(this,Y,!0)),o(this,k).publish("state-change")},"#handleViewStateChange"),lo=s(function(){c(this,G,[]);for(let t of o(this,m).dynamicLayers){let e=new Bt([t],!0,o(this,l));e.processLayerGroup(o(this,ft),o(this,m).outdoorZoomThreshold,o(this,m).indoorZoomThreshold),o(this,G).push(e)}Pt(o(this,G),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),uo=s(function(){var n,a,h;let t=(h=(a=(n=o(this,L).internal.mvf)==null?void 0:n.enterprise)==null?void 0:a.layers)!=null?h:[],e={},i={};t.forEach(u=>{e[u.name]||(e[u.name]=[]),e[u.name].push(...u.spaces.map(({spaceId:f})=>f));for(let{spaceId:f}of u.spaces)i[f]==null&&(i[f]=[]),i[f].push(u.name)}),c(this,ht,t.map(({name:u})=>u)),c(this,mt,i),c(this,ft,e)},"#setupLayers"),Ut=s(function(t){o(this,l).preloadFloors(o(this,L).getByType("facade").map(e=>vt(o(this,y).get(e.floorStack.id),t,o(this,B))).filter(e=>e!=null&&Lo.is(e)))},"#preloadFloors"),pt=new WeakMap,gt=new WeakMap,Ft=new WeakMap,yt=new WeakMap,et=new WeakMap,$t=s(function(t,e,i){t.forEach(n=>{if(n.floor)if(e){let a=i!==void 0?at(_({},n.state),{labels:at(_({},n.state.labels),{enabled:n.state.labels.enabled&&i}),markers:at(_({},n.state.markers),{enabled:n.state.markers.enabled&&i}),occlusion:at(_({},n.state.occlusion),{enabled:n.state.occlusion.enabled&&i})}):n.state;o(this,l).updateState(n.floor,a)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),co=s(async function(t,e,i,n){return E(this,g,$t).call(this,e.floorStates,!0,n),t.animateFacade(i.state,o(this,m).indoorAnimationOptions)},"#animateIndoorSequence"),ho=s(async function(t,e,i,n){let a=await t.animateFacade(i.state,o(this,m).outdoorAnimationOptions);return a.result==="completed"&&E(this,g,$t).call(this,e.floorStates,At({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,U).has(t.id),mode:o(this,m).mode,elevation:o(this,B),inNavigation:n.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,m).dynamicBuildingInteriors})),a},"#animateOutdoorSequence"),q=new WeakMap,s(Yt,"DynamicFocus");var so=Yt;export{s as a,ve as b,we as c,so as d};
1
+ var Ht=Object.defineProperty,po=Object.defineProperties;var go=Object.getOwnPropertyDescriptors;var qt=Object.getOwnPropertySymbols;var Fo=Object.prototype.hasOwnProperty,yo=Object.prototype.propertyIsEnumerable;var zt=r=>{throw TypeError(r)};var Vt=(r,t,e)=>t in r?Ht(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_=(r,t)=>{for(var e in t||(t={}))Fo.call(t,e)&&Vt(r,e,t[e]);if(qt)for(var e of qt(t))yo.call(t,e)&&Vt(r,e,t[e]);return r},at=(r,t)=>po(r,go(t)),s=(r,t)=>Ht(r,"name",{value:t,configurable:!0});var p=(r,t,e)=>Vt(r,typeof t!="symbol"?t+"":t,e),Mt=(r,t,e)=>t.has(r)||zt("Cannot "+e);var o=(r,t,e)=>(Mt(r,t,"read from private field"),e?e.call(r):t.get(r)),d=(r,t,e)=>t.has(r)?zt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),c=(r,t,e,i)=>(Mt(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),E=(r,t,e)=>(Mt(r,t,"access private method"),e);var b={env:{NODE_ENV:"production",npm_package_version:"6.9.1-beta.0"}};import{Floor as Lo,getMultiFloorState as Co}from"@mappedin/mappedin-js";function Wt(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}s(Wt,"arraysEqual");var xt=class xt{constructor(){p(this,"_subscribers",{});p(this,"_abortController",new AbortController);p(this,"_cleanupFunctions",[])}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 n=i==null?void 0:i.signal;if(n!=null&&n.aborted||this._abortController&&this._abortController.signal.aborted)return()=>{};this._subscribers||(this._subscribers={}),this._subscribers[t]=this._subscribers[t]||[],this._subscribers[t].push(e);let a=s(()=>this.off(t,e),"cleanup");return n&&n.addEventListener("abort",a,{once:!0}),this._cleanupFunctions.push(a),a}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(){if(!this.signal.aborted){for(let t of this._cleanupFunctions)t();this._cleanupFunctions=[],this._subscribers={},this._abortController.abort()}}};s(xt,"PubSub");var St=xt;import{Facade as So,Floor as Eo,FloorStack as vo}from"@mappedin/mappedin-js";var w,st,N,v,S,I,W,K,Ot=class Ot{constructor(t,e){p(this,"__type","building");d(this,w);d(this,st,new Map);d(this,N,new Map);d(this,v,[]);d(this,S);d(this,I);p(this,"defaultFloor");p(this,"activeFloor");p(this,"excluded",!1);p(this,"floorsAltitudesMap",new Map);p(this,"aboveGroundFloors",[]);d(this,W);d(this,K);var n;c(this,w,t),c(this,st,new Map(t.floors.map(a=>[a.id,a]))),c(this,N,new Map(t.floors.map(a=>[a.elevation,a]))),c(this,v,Array.from(o(this,N).values()).sort((a,h)=>a.elevation-h.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,c(this,S,e),this.aboveGroundFloors=o(this,v).filter(a=>a.elevation>=0);let i=(n=t.facade)==null?void 0:n.spaces.map(a=>o(this,S).getState(a)).sort((a,h)=>a.altitude-h.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let a in this.aboveGroundFloors){let h=this.aboveGroundFloors[a],u=i[a];this.floorsAltitudesMap.set(h.elevation,{altitude:u.altitude,effectiveHeight:u.height})}}get id(){return o(this,w).id}get name(){return o(this,w).name}get floors(){return o(this,w).floors}get floorStack(){return o(this,w)}get facade(){return o(this,w).facade}get isCurrentFloorStack(){return this.id===o(this,S).currentFloorStack.id}get isIndoor(){let t=o(this,S).getState(this.facade);return this.isCurrentFloorStack||(t==null?void 0:t.visible)===!1&&(t==null?void 0:t.opacity)===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,W)==null&&c(this,W,Math.max(...o(this,N).keys())),o(this,W)}get minElevation(){return o(this,K)==null&&c(this,K,Math.min(...o(this,N).keys())),o(this,K)}has(t){return Eo.is(t)?o(this,st).has(t.id):vo.is(t)?t.id===o(this,w).id:So.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,v)[o(this,v).length-1];for(let i=o(this,v).length-1;i>=0;i--){let n=o(this,v)[i];if(n.elevation<=t)return n}}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,I)&&(o(this,I).animation.cancel(),c(this,I,void 0))}async animateFacade(t,e={duration:150}){var h;let i=((h=o(this,I))==null?void 0:h.state)||o(this,S).getState(this.facade);if(!i||!t||(i==null?void 0:i.opacity)===t.opacity&&(i==null?void 0:i.visible)===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:n,visible:a}=t;if(o(this,S).updateState(this.facade,{visible:!0}),n!==void 0){c(this,I,{animation:o(this,S).animateState(this.facade,{opacity:n},{duration:e.duration}),state:t});let u=await o(this,I).animation;if(c(this,I,void 0),u.result==="cancelled")return u}return a===!1&&o(this,S).updateState(this.facade,{visible:a}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,w).floors.forEach(t=>{o(this,S).updateState(t,{visible:t.id===o(this,S).currentFloor.id})}),this.has(o(this,S).currentFloor)||o(this,S).updateState(this.facade,{visible:!0,opacity:1})}};w=new WeakMap,st=new WeakMap,N=new WeakMap,v=new WeakMap,S=new WeakMap,I=new WeakMap,W=new WeakMap,K=new WeakMap,s(Ot,"Building");var Et=Ot;function Kt(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}s(Kt,"getZoomState");function vt(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}s(vt,"getFloorToShow");function wo(r,t,e){return 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}}}s(wo,"getFacadeState");function ko(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}}}})}}s(ko,"getSingleBuildingState");function Qt(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"}s(Qt,"getOutdoorOpacity");function Jt(r,t,e){var i;switch(e){case"in-range":return(i=r[0])!=null&&i.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}s(Jt,"getSetFloorTargetFromZoomState");function Xt(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:n,mode:a,elevation:h,floorIdsInNavigation:u,floorStackIdsInNavigation:f,multiFloorView:P,getMultiFloorState:R,dynamicBuildingInteriors:bt,isolateBelowGroundView:it,currentElevation:rt}=r,A=new Map,D=it&&rt<0;for(let F of t){let H=e.has(F.id),nt=D&&F.minElevation>=0,It=nt?!1:H,z=nt?!1:At({building:F,currentFloor:i,inRange:n==="in-range",inFocus:H,mode:a,elevation:h,inNavigation:f.includes(F.id),dynamicBuildingInteriors:bt}),Tt=i.floorStack.id===F.id?F.activeFloor:vt(F,a,h),mo=P.enabled?R(F.floors,Tt||F.activeFloor,P==null?void 0:P.floorGap,u,F.floorsAltitudesMap):ko(F.floorStack,Tt||F.activeFloor,z),fo=wo(F.facade,z,it&&rt<0);A.set(F.id,{building:F,showIndoor:z,floorStackState:mo,facadeState:fo,inFocus:It,floorToShow:Tt})}return A}s(Xt,"getBuildingStates");function to(r,t){return r.excluded?"none":t?"indoor":"outdoor"}s(to,"getBuildingAnimationType");function At(r){let{building:t,currentFloor:e,inRange:i,inFocus:n,mode:a,elevation:h,inNavigation:u,dynamicBuildingInteriors:f}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(u===!0)return!0;if(!f)return e.floorStack.type!=="Outdoor";if(!i||!n)return!1;switch(a){case"lock-elevation":return t.getFloorByElevation(h)!=null;default:break}return!0}s(At,"shouldShowIndoor");function oo(r,t,e){return r!==t&&!e}s(oo,"shouldDeferSetFloor");var eo=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Io,FloorStack as To}from"@mappedin/mappedin-js";var Dt="[MappedinJS]";function _t(r="",{prefix:t=Dt}={}){let e="".concat(t).concat(r?"-".concat(r):""),i=s((n,a)=>{if(typeof window<"u"&&window.rnDebug){let h=a.map(u=>u instanceof Error&&u.stack?"".concat(u.message,"\n").concat(u.stack):u);window.rnDebug("".concat(r," ").concat(n,": ").concat(h.join(" ")))}},"rnDebug");return{logState:b.env.NODE_ENV==="test"?3:0,log(...n){this.logState<=0&&(console.log(e,...n),i("log",n))},warn(...n){this.logState<=1&&(console.warn(e,...n),i("warn",n))},error(...n){this.logState<=2&&(console.error(e,...n),i("error",n))},assert(...n){console.assert(...n)},time(n){console.time(n)},timeEnd(n){console.timeEnd(n)},setLevel(n){0<=n&&n<=3&&(this.logState=n)}}}s(_t,"createLogger");var Bo=_t();var Q=Bo;function io(r,t,e,i){return(r<t||r>e)&&Q.warn(i),Math.min(e,Math.max(t,r))}s(io,"clampWithWarning");function Nt(r,t){return!Io.is(r)||(r==null?void 0:r.floorStack)==null||!To.is(t)?!1:r.floorStack.id!==t.id?(Q.warn("Floor (".concat(r.id,") does not belong to floor stack (").concat(t.id,").")),!1):!0}s(Nt,"validateFloorForStack");function Lt(r,t,e,i){return io(r,t,e,"".concat(i," must be between ").concat(t," and ").concat(e,"."))}s(Lt,"validateZoomThreshold");var J=_t("",{prefix:"[DynamicFocus]"});var T,X,lt,Ct,Zt=class Zt{constructor(t,e){d(this,lt);p(this,"__type","outdoors");d(this,T);d(this,X);c(this,T,t),c(this,X,e)}get id(){return o(this,T).id}get floorStack(){return o(this,T)}get floor(){return o(this,T).defaultFloor}matchesFloorStack(t){return t===o(this,T)||t===o(this,T).id}show(){E(this,lt,Ct).call(this,!0)}hide(){E(this,lt,Ct).call(this,!1)}destroy(){this.matchesFloorStack(o(this,X).currentFloorStack)||this.hide()}};T=new WeakMap,X=new WeakMap,lt=new WeakSet,Ct=s(function(t){for(let e of o(this,T).floors)o(this,X).updateState(e,{visible:t})},"#setVisible"),s(Zt,"Outdoors");var wt=Zt;function ro(r,t){var h;let e=r.getByType("floor-stack"),i=e.find(u=>{var f;return((f=u.type)==null?void 0:f.toLowerCase())==="outdoor"}),n=(h=r.getByType("enterprise-venue"))==null?void 0:h.defaultFloor;if(n){let u=r.getById("floor",n);if(u)return u.floorStack}if(i)return i;let a=e.find(u=>u.facade==null&&!t.has(u.id));return a||(J.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}s(ro,"getOutdoorFloorStack");import{getMultiFloorState as Vo}from"@mappedin/mappedin-js";var no={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!1,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,customMultiFloorVisibilityState:Vo,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1},ve=.2,we=.4;function Mo(r,t){return"".concat(t," ").concat(r)}s(Mo,"formatMessage");var Gt=class Gt extends Error{constructor(t,e=Dt){super(Mo(t,e)),this.name="MappedinError"}};s(Gt,"MappedinError");var kt=Gt;var xo=s(r=>r,"linearEase"),Oo=s(r=>r*r,"quadEaseIn"),Ao=s(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Do=s(r=>1-(1-r)*(1-r),"quadEaseOut"),_o={linear:xo,"ease-in":Oo,"ease-out":Do,"ease-in-out":Ao};function No(r,t){let e=0;if(t.length<2)return e;let n=t[0]<t[1]?(a,h)=>a>h:(a,h)=>a<h;for(;e<t.length-1&&n(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}s(No,"getInterpolationBreakpoint");function ao(r,t,e,i="ease-in"){if(t.length!==e.length)throw new kt("Input and output ranges must have the same number of values.");r=Math.max(t[0],Math.min(r,t[t.length-1]));let n=No(r,t),a=(r-t[n])/(t[n+1]-t[n]),h=typeof i=="function"?i(a):_o[i](a);return e[n]+h*(e[n+1]-e[n])}s(ao,"interpolateMulti");var V,ut,dt,x,ct,Rt=class Rt{constructor(t,e,i){p(this,"layers");p(this,"visible");d(this,V);d(this,ut,[]);d(this,dt,!1);d(this,x,new Map);p(this,"interpolationFn");d(this,ct,1);this.layers=t,this.visible=e,c(this,V,i)}processLayerGroup(t,e,i){if(!o(this,dt)&&(this.layers.forEach(n=>{let a=t[n];a&&o(this,ut).push(...a)}),c(this,dt,!0),this.visible)){let n=[e,i],a=[1,0];this.interpolationFn=h=>ao(h,n,a)}}setOpacity(t){var e,i,n;c(this,ct,t);for(let a of o(this,ut))if(a.startsWith("img_")){let h=o(this,V).Image3D.getById(a);if(h){let u=o(this,V).getState(h.image);o(this,x).has(a)||o(this,x).set(a,(e=u==null?void 0:u.opacity)!=null?e:1);let f=Math.min(o(this,x).get(a),t);o(this,V).updateState(h.image,{opacity:f})}}else{let h=(i=o(this,V).getMapData())==null?void 0:i.getById("space",a);if(!h)continue;let u=o(this,V).getState(h);o(this,x).has(a)||o(this,x).set(a,(n=u==null?void 0:u.opacity)!=null?n:1);let f=Math.min(o(this,x).get(a),t);o(this,V).updateState(h,{opacity:f,visible:f>0})}}get opacity(){return o(this,ct)}};V=new WeakMap,ut=new WeakMap,dt=new WeakMap,x=new WeakMap,ct=new WeakMap,s(Rt,"LayerGroup");var Bt=Rt;function Pt(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}s(Pt,"runLayerGroupInterpolations");var k,l,L,m,j,U,y,O,$,Y,B,tt,ht,mt,ft,M,C,ot,Z,G,g,jt,lo,uo,Ut,pt,gt,Ft,yt,et,$t,co,ho,q,Yt=class Yt{constructor(t){d(this,g);d(this,k);d(this,l);d(this,L);d(this,m,no);d(this,j,[]);d(this,U,new Set);d(this,y,new Map);d(this,O);d(this,$,!1);d(this,Y,!1);d(this,B,0);d(this,tt,0);d(this,ht,[]);d(this,mt,{});d(this,ft,{});d(this,M,"transition");d(this,C,"outdoor");d(this,ot,[]);d(this,Z,!1);d(this,G,[]);p(this,"sceneUpdateQueue",Promise.resolve());p(this,"on",s((t,e)=>{o(this,k).on(t,e)},"on"));p(this,"off",s((t,e)=>{o(this,k).off(t,e)},"off"));d(this,pt,s(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Wt(e,this.focusedFacades)&&o(this,C)==="transition"&&!o(this,Y))return;c(this,Y,!1),c(this,j,[]),o(this,U).clear();let i=o(this,m).isolateBelowGroundView&&o(this,B)<0;if(e.length>0)for(let n of e){let a=o(this,y).get(n.floorStack.id);if(a){if(i&&a.minElevation>=0)continue;o(this,U).add(a.id),o(this,j).push(a)}}o(this,m).autoFocus&&this.focus()},"#handleFacadesInViewChange"));d(this,gt,s(async t=>{var n,a,h,u;if(!this.isEnabled)return;let{floor:e}=t,i=o(this,y).get(e.floorStack.id);if(i&&(i.activeFloor=e),(i==null?void 0:i.excluded)===!1&&!o(this,O).matchesFloorStack(e.floorStack)&&c(this,B,e.elevation),o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,q).call(this,e),o(this,k).publish("focus",{facades:this.focusedFacades}));let f=(a=(n=i==null?void 0:i.floorsAltitudesMap.get(e.elevation))==null?void 0:n.altitude)!=null?a:0;o(this,l).options.multiFloorView!=null&&((h=o(this,l).options.multiFloorView)!=null&&h.enabled)&&((u=o(this,l).options.multiFloorView)!=null&&u.updateCameraElevationOnFloorChange)&&o(this,l).Camera.elevation!==f&&o(this,l).Camera.animateElevation(f,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));d(this,Ft,s(()=>{c(this,$,!0)},"#handleUserInteractionStart"));d(this,yt,s(()=>{c(this,$,!1)},"#handleUserInteractionEnd"));d(this,et,s(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Kt(e,o(this,m).indoorZoomThreshold,o(this,m).outdoorZoomThreshold);o(this,M)!==i&&(c(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Pt(o(this,G),e)},"#handleCameraChange"));d(this,q,s(async t=>{var u,f,P;if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).options.multiFloorView,n=((f=(u=o(this,l).Navigation)==null?void 0:u.floors)==null?void 0:f.map(R=>R.id))||[],a=((P=o(this,l).Navigation)==null?void 0:P.floorStacks.map(R=>R.id))||[],h=new Promise(async R=>{var rt;await this.sceneUpdateQueue;let bt=Xt({buildings:Array.from(o(this,y).values()),inViewSet:o(this,U),currentFloor:e,zoomState:o(this,M),mode:o(this,m).mode,elevation:o(this,B),floorIdsInNavigation:n,floorStackIdsInNavigation:a,multiFloorView:i,getMultiFloorState:(rt=o(this,m).customMultiFloorVisibilityState)!=null?rt:Co,dynamicBuildingInteriors:o(this,m).dynamicBuildingInteriors,isolateBelowGroundView:o(this,m).isolateBelowGroundView,currentElevation:o(this,B)}),it=[];await Promise.all(Array.from(bt.values()).map(async A=>{let{building:D,showIndoor:F,floorStackState:H,facadeState:nt,inFocus:It}=A;it.push(H);let z=to(D,F);if(z==="indoor")return E(this,g,co).call(this,D,H,nt,It);if(z==="outdoor")return E(this,g,ho).call(this,D,H,nt,a)})),o(this,l).Outdoor.setOpacity(Qt(it,o(this,m).mode)),c(this,ot,o(this,j).filter(A=>{var D;return((D=bt.get(A.id))==null?void 0:D.showIndoor)===!0}).map(A=>A.facade)),o(this,k).publish("focus",{facades:o(this,ot)}),R()});return this.sceneUpdateQueue=h,h},"#applyBuildingStates"));c(this,k,new St),c(this,l,t),J.setLevel(Q.logState),c(this,L,o(this,l).getMapData()),c(this,B,o(this,l).currentFloor.elevation),c(this,tt,o(this,l).Camera.elevation);for(let e of o(this,L).getByType("facade"))o(this,y).set(e.floorStack.id,new Et(e.floorStack,o(this,l)));E(this,g,uo).call(this),c(this,O,new wt(ro(o(this,L),o(this,y)),o(this,l))),o(this,l).on("floor-change-start",o(this,gt)),o(this,l).on("camera-change",o(this,et)),o(this,l).on("facades-in-view-change",o(this,pt)),o(this,l).on("user-interaction-start",o(this,Ft)),o(this,l).on("user-interaction-end",o(this,yt))}enable(t){if(o(this,Z)){J.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,Z,!0),o(this,l).manualFloorVisibility=!0,o(this,O).show(),this.updateState(_(_({},o(this,m)),t)),E(this,g,lo).call(this),o(this,et).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,Z)){J.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,Z,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,Z)}get isIndoor(){return o(this,C)==="indoor"}get isOutdoor(){return o(this,C)==="outdoor"}get outdoorsFloorStack(){return o(this,O).floorStack}get layers(){return o(this,ht)}get layersBySpaceId(){return o(this,mt)}setIndoor(){c(this,C,"indoor"),c(this,M,"in-range"),E(this,g,jt).call(this)}setOutdoor(){c(this,C,"outdoor"),c(this,M,"out-of-range"),E(this,g,jt).call(this)}get focusedFacades(){return[...o(this,ot)]}getState(){return _({},o(this,m))}updateState(t){var i,n;let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Lt(t.indoorZoomThreshold,(i=t==null?void 0:t.outdoorZoomThreshold)!=null?i:o(this,m).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Lt(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,(n=t==null?void 0:t.indoorZoomThreshold)!=null?n:o(this,m).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=eo.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,m).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,m).dynamicBuildingInteriors&&(e=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,m).isolateBelowGroundView&&(e=!0),c(this,m,Object.assign({},o(this,m),Object.fromEntries(Object.entries(t).filter(([,a])=>a!=null)))),t.mode!=null&&t.preloadFloors&&E(this,g,Ut).call(this,t.mode),e&&o(this,q).call(this)}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,pt)),o(this,l).off("floor-change-start",o(this,gt)),o(this,l).off("camera-change",o(this,et)),o(this,l).off("user-interaction-start",o(this,Ft)),o(this,l).off("user-interaction-end",o(this,yt)),o(this,y).forEach(t=>t.destroy()),o(this,O).destroy(),o(this,k).destroy(),c(this,G,[])}async focus(t=o(this,m).setFloorOnFocus){if(t)if(oo(o(this,tt),o(this,l).Camera.elevation,o(this,$)))c(this,tt,o(this,l).Camera.elevation),c(this,Y,!0);else{let e=Jt(o(this,j),o(this,O),o(this,M)),i=e?vt(e,o(this,m).mode,o(this,B)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,q).call(this),o(this,k).publish("focus",{facades:this.focusedFacades})}preloadFloors(){E(this,g,Ut).call(this,o(this,m).mode)}setDefaultFloorForStack(t,e){if(!Nt(e,t))return;let i=o(this,y).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,y).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){var e;return((e=o(this,y).get(t.id))==null?void 0:e.defaultFloor)||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Nt(e,t))return;let i=o(this,y).get(t.id);i&&(i.activeFloor=e,o(this,q).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,y).get(i.id);n&&(n.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,y).get(i.id);n&&(n.excluded=!1)}}getCurrentFloorForStack(t){var e;return((e=o(this,y).get(t.id))==null?void 0:e.activeFloor)||this.getDefaultFloorForStack(t)}};k=new WeakMap,l=new WeakMap,L=new WeakMap,m=new WeakMap,j=new WeakMap,U=new WeakMap,y=new WeakMap,O=new WeakMap,$=new WeakMap,Y=new WeakMap,B=new WeakMap,tt=new WeakMap,ht=new WeakMap,mt=new WeakMap,ft=new WeakMap,M=new WeakMap,C=new WeakMap,ot=new WeakMap,Z=new WeakMap,G=new WeakMap,g=new WeakSet,jt=s(function(){o(this,m).autoFocus&&(o(this,$)?this.focus():c(this,Y,!0)),o(this,k).publish("state-change")},"#handleViewStateChange"),lo=s(function(){c(this,G,[]);for(let t of o(this,m).dynamicLayers){let e=new Bt([t],!0,o(this,l));e.processLayerGroup(o(this,ft),o(this,m).outdoorZoomThreshold,o(this,m).indoorZoomThreshold),o(this,G).push(e)}Pt(o(this,G),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),uo=s(function(){var n,a,h;let t=(h=(a=(n=o(this,L).internal.mvf)==null?void 0:n.enterprise)==null?void 0:a.layers)!=null?h:[],e={},i={};t.forEach(u=>{e[u.name]||(e[u.name]=[]),e[u.name].push(...u.spaces.map(({spaceId:f})=>f));for(let{spaceId:f}of u.spaces)i[f]==null&&(i[f]=[]),i[f].push(u.name)}),c(this,ht,t.map(({name:u})=>u)),c(this,mt,i),c(this,ft,e)},"#setupLayers"),Ut=s(function(t){o(this,l).preloadFloors(o(this,L).getByType("facade").map(e=>vt(o(this,y).get(e.floorStack.id),t,o(this,B))).filter(e=>e!=null&&Lo.is(e)))},"#preloadFloors"),pt=new WeakMap,gt=new WeakMap,Ft=new WeakMap,yt=new WeakMap,et=new WeakMap,$t=s(function(t,e,i){t.forEach(n=>{if(n.floor)if(e){let a=i!==void 0?at(_({},n.state),{labels:at(_({},n.state.labels),{enabled:n.state.labels.enabled&&i}),markers:at(_({},n.state.markers),{enabled:n.state.markers.enabled&&i}),occlusion:at(_({},n.state.occlusion),{enabled:n.state.occlusion.enabled&&i})}):n.state;o(this,l).updateState(n.floor,a)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),co=s(async function(t,e,i,n){return E(this,g,$t).call(this,e.floorStates,!0,n),t.animateFacade(i.state,o(this,m).indoorAnimationOptions)},"#animateIndoorSequence"),ho=s(async function(t,e,i,n){let a=await t.animateFacade(i.state,o(this,m).outdoorAnimationOptions);return a.result==="completed"&&E(this,g,$t).call(this,e.floorStates,At({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,U).has(t.id),mode:o(this,m).mode,elevation:o(this,B),inNavigation:n.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,m).dynamicBuildingInteriors})),a},"#animateOutdoorSequence"),q=new WeakMap,s(Yt,"DynamicFocus");var so=Yt;export{s as a,ve as b,we as c,so as d};
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{a as d,b as u,c as y,d as F}from"./chunk-3F4KOXHZ.js";var p=d((t,o)=>{var l,i,s,a;let n={initialVisibility:(l=o.initialVisibility)!=null?l:"outdoor-first",layersBySpaceId:(i=o.layersBySpaceId)!=null?i:{},focusLayers:(s=o.focusLayers)!=null?s:[],defaultFloor:(a=o.defaultFloor)!=null?a:t.currentFloor},e=O(t,n),c=e+y,r=e+u;return n.initialVisibility==="indoor-first"&&(c=e-u,r=e-y),{indoorZoomThreshold:c,outdoorZoomThreshold:r}},"calculateZoomThresholds");function O(t,o){var l;let n=t.getMapData().getByType("space"),e=o.focusLayers.length?n.filter(i=>{var a,f,m;let s=(a=o.layersBySpaceId[i.id])==null?void 0:a[0];return typeof s=="string"&&i.floor.id===((f=o.defaultFloor)==null?void 0:f.id)&&((m=o.focusLayers)==null?void 0:m.indexOf(s))!==-1}):void 0,c=(l=t.Camera.getFocusOnTransform(o.defaultFloor,{}).zoomLevel)!=null?l:0,r=e!=null&&e.length?t.Camera.getFocusOnTransform(e,{}).zoomLevel:void 0;return r!=null?r:c}d(O,"getDefaultZoomLevel");export{F as DynamicFocus,p as calculateZoomThresholds};
1
+ import{a as d,b as u,c as y,d as F}from"./chunk-Z5WTQ5AT.js";var p=d((t,o)=>{var l,i,s,a;let n={initialVisibility:(l=o.initialVisibility)!=null?l:"outdoor-first",layersBySpaceId:(i=o.layersBySpaceId)!=null?i:{},focusLayers:(s=o.focusLayers)!=null?s:[],defaultFloor:(a=o.defaultFloor)!=null?a:t.currentFloor},e=O(t,n),c=e+y,r=e+u;return n.initialVisibility==="indoor-first"&&(c=e-u,r=e-y),{indoorZoomThreshold:c,outdoorZoomThreshold:r}},"calculateZoomThresholds");function O(t,o){var l;let n=t.getMapData().getByType("space"),e=o.focusLayers.length?n.filter(i=>{var a,f,m;let s=(a=o.layersBySpaceId[i.id])==null?void 0:a[0];return typeof s=="string"&&i.floor.id===((f=o.defaultFloor)==null?void 0:f.id)&&((m=o.focusLayers)==null?void 0:m.indexOf(s))!==-1}):void 0,c=(l=t.Camera.getFocusOnTransform(o.defaultFloor,{}).zoomLevel)!=null?l:0,r=e!=null&&e.length?t.Camera.getFocusOnTransform(e,{}).zoomLevel:void 0;return r!=null?r:c}d(O,"getDefaultZoomLevel");export{F as DynamicFocus,p as calculateZoomThresholds};
@@ -1 +1 @@
1
- import{a as t,d as a}from"../chunk-3F4KOXHZ.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,d as a}from"../chunk-Z5WTQ5AT.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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mappedin/dynamic-focus",
3
- "version": "6.8.0-beta.0",
3
+ "version": "6.9.1-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.8.0",
41
- "@mappedin/react-native-sdk": "^6.8.0",
42
- "@mappedin/react-sdk": "^6.8.0"
40
+ "@mappedin/mappedin-js": "^6.9.1",
41
+ "@mappedin/react-sdk": "^6.9.1",
42
+ "@mappedin/react-native-sdk": "^6.9.1"
43
43
  },
44
44
  "peerDependenciesMeta": {
45
45
  "@mappedin/react-sdk": {