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