@mappedin/dynamic-focus 6.13.0-beta.0 → 6.14.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.
- package/lib/esm/chunk-I4AEDPQV.js +1 -0
- package/lib/esm/index.d.ts +107 -81
- package/lib/esm/index.js +1 -1
- package/lib/esm/react/index.d.ts +107 -81
- package/lib/esm/react/index.js +1 -1
- package/lib/rn/index-rn.js +5 -5
- package/lib/rn/types.d.ts +5 -0
- package/package.json +4 -4
- package/lib/esm/chunk-DMFERG3B.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var zt=Object.defineProperty,bo=Object.defineProperties;var Fo=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols;var yo=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable;var Wt=n=>{throw TypeError(n)};var Mt=(n,t,e)=>t in n?zt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e,C=(n,t)=>{for(var e in t||(t={}))yo.call(t,e)&&Mt(n,e,t[e]);if(Ht)for(var e of Ht(t))So.call(t,e)&&Mt(n,e,t[e]);return n},at=(n,t)=>bo(n,Fo(t)),a=(n,t)=>zt(n,"name",{value:t,configurable:!0});var p=(n,t,e)=>Mt(n,typeof t!="symbol"?t+"":t,e),Tt=(n,t,e)=>t.has(n)||Wt("Cannot "+e);var o=(n,t,e)=>(Tt(n,t,"read from private field"),e?e.call(n):t.get(n)),d=(n,t,e)=>t.has(n)?Wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,e),c=(n,t,e,i)=>(Tt(n,t,"write to private field"),i?i.call(n,e):t.set(n,e),e),E=(n,t,e)=>(Tt(n,t,"access private method"),e);var S={env:{NODE_ENV:"production",npm_package_version:"6.14.0-beta.0"}};import{Floor as Go,getMultiFloorState as Zo}from"@mappedin/mappedin-js";function Kt(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(Kt,"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 St=xt;import{Facade as vo,Floor as wo,FloorStack as Io}from"@mappedin/mappedin-js";var A,lt,G,I,v,V,K,Q,Dt=class Dt{constructor(t,e){p(this,"__type","building");d(this,A);d(this,lt,new Map);d(this,G,new Map);d(this,I,[]);d(this,v);d(this,V);p(this,"defaultFloor");p(this,"activeFloor");p(this,"excluded",!1);p(this,"floorsAltitudesMap",new Map);p(this,"aboveGroundFloors",[]);d(this,K);d(this,Q);var s;c(this,A,t),c(this,lt,new Map(t.floors.map(r=>[r.id,r]))),c(this,G,new Map(t.floors.map(r=>[r.elevation,r]))),c(this,I,Array.from(o(this,G).values()).sort((r,u)=>r.elevation-u.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,c(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,effectiveHeight:f.height})}}get id(){return o(this,A).id}get name(){return o(this,A).name}get floors(){return o(this,A).floors}get floorStack(){return o(this,A)}get facade(){return o(this,A).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,K)==null&&c(this,K,Math.max(...o(this,G).keys())),o(this,K)}get minElevation(){return o(this,Q)==null&&c(this,Q,Math.min(...o(this,G).keys())),o(this,Q)}has(t){return wo.is(t)?o(this,lt).has(t.id):Io.is(t)?t.id===o(this,A).id:vo.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,G).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,V)&&(o(this,V).animation.cancel(),c(this,V,void 0))}async animateFacade(t,e={duration:150}){var u;let i=((u=o(this,V))==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){c(this,V,{animation:o(this,v).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let f=await o(this,V).animation;if(c(this,V,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,A).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})}};A=new WeakMap,lt=new WeakMap,G=new WeakMap,I=new WeakMap,v=new WeakMap,V=new WeakMap,K=new WeakMap,Q=new WeakMap,a(Dt,"Building");var Et=Dt;function Qt(n,t,e){return n>=t?"in-range":n<=e?"out-of-range":"transition"}a(Qt,"getZoomState");function vt(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(vt,"getFloorToShow");function ko(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(ko,"getFacadeState");function Ao(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(Ao,"getSingleBuildingState");function Xt(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(Xt,"getOutdoorOpacity");function Jt(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(Jt,"getSetFloorTargetFromZoomState");function to(n){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:r,elevation:u,floorIdsInNavigation:f,floorStackIdsInNavigation:g,multiFloorView:m,getMultiFloorState:B,dynamicBuildingInteriors:j,isolateBelowGroundView:nt,currentElevation:rt,forceInteriorsVisible:$}=n,x=new Map,Bt=nt&&rt<0&&s==="in-range";for(let F of t){let st=e.has(F.id),z=Bt&&F.minElevation>=0,Vt=z?!1:st,W=z?!1:_t({building:F,currentFloor:i,inRange:s==="in-range",inFocus:st,mode:r,elevation:u,inNavigation:g.includes(F.id),dynamicBuildingInteriors:j,forceInteriorsVisible:$}),Ot=i.floorStack.id===F.id?F.activeFloor:vt(F,r,u),mo=m!=null&&m.enabled?B(F.floors,Ot||F.activeFloor,m==null?void 0:m.floorGap,f,F.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}):Ao(F.floorStack,Ot||F.activeFloor,W),po=nt&&rt<0&&s==="in-range",go=ko(F.facade,W,po,z);x.set(F.id,{building:F,showIndoor:W,floorStackState:mo,facadeState:go,inFocus:Vt,floorToShow:Ot,isAboveGroundInIsolation:z})}return x}a(to,"getBuildingStates");function oo(n,t){return n.excluded?"none":t?"indoor":"outdoor"}a(oo,"getBuildingAnimationType");function _t(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(_t,"shouldShowIndoor");function eo(n,t,e){return n!==t&&!e}a(eo,"shouldDeferSetFloor");var io=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Vo,FloorStack as Oo}from"@mappedin/mappedin-js";var Lt="[MappedinJS]";function Nt(n="",{prefix:t=Lt}={}){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(Nt,"createLogger");var Bo=Nt();var X=Bo;function no(n,t,e,i){return(n<t||n>e)&&X.warn(i),Math.min(e,Math.max(t,n))}a(no,"clampWithWarning");function Ct(n,t){return!Vo.is(n)||(n==null?void 0:n.floorStack)==null||!Oo.is(t)?!1:n.floorStack.id!==t.id?(X.warn("Floor (".concat(n.id,") does not belong to floor stack (").concat(t.id,").")),!1):!0}a(Ct,"validateFloorForStack");function Gt(n,t,e,i){return no(n,t,e,"".concat(i," must be between ").concat(t," and ").concat(e,"."))}a(Gt,"validateZoomThreshold");var J=Nt("",{prefix:"[DynamicFocus]"});var O,tt,ut,Zt,Pt=class Pt{constructor(t,e){d(this,ut);p(this,"__type","outdoors");d(this,O);d(this,tt);c(this,O,t),c(this,tt,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,Zt).call(this,!0)}hide(){E(this,ut,Zt).call(this,!1)}destroy(){this.matchesFloorStack(o(this,tt).currentFloorStack)||this.hide()}};O=new WeakMap,tt=new WeakMap,ut=new WeakSet,Zt=a(function(t){for(let e of o(this,O).floors)o(this,tt).updateState(e,{visible:t})},"#setVisible"),a(Pt,"Outdoors");var wt=Pt;function ro(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||(J.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(ro,"getOutdoorFloorStack");var so={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},we=.2,Ie=.4;function Mo(n,t){return"".concat(t," ").concat(n)}a(Mo,"formatMessage");var Rt=class Rt extends Error{constructor(t,e=Lt){super(Mo(t,e)),this.name="MappedinError"}};a(Rt,"MappedinError");var It=Rt;var To=a(n=>n,"linearEase"),xo=a(n=>n*n,"quadEaseIn"),Do=a(n=>1-Math.cos(n*Math.PI/2),"easeIn"),_o=a(n=>1-(1-n)*(1-n),"quadEaseOut"),Lo=a(n=>1-Math.pow(1-n,3),"cubicEaseOut"),No={linear:To,"ease-in":xo,"ease-out":_o,"ease-in-out":Do,"ease-out-cubic":Lo};function Co(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(Co,"getInterpolationBreakpoint");function ao(n,t,e,i="ease-in"){if(t.length!==e.length)throw new It("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=Co(n,t),r=(n-t[s])/(t[s+1]-t[s]),u=typeof i=="function"?i(r):No[i](r);return e[s]+u*(e[s+1]-e[s])}a(ao,"interpolateMulti");var M,ct,dt,D,ht,jt=class jt{constructor(t,e,i){p(this,"layers");p(this,"visible");d(this,M);d(this,ct,[]);d(this,dt,!1);d(this,D,new Map);p(this,"interpolationFn");d(this,ht,1);this.layers=t,this.visible=e,c(this,M,i)}processLayerGroup(t,e,i){if(!o(this,dt)&&(this.layers.forEach(s=>{let r=t[s];r&&o(this,ct).push(...r)}),c(this,dt,!0),this.visible)){let s=[e,i],r=[1,0];this.interpolationFn=u=>ao(u,s,r)}}setOpacity(t){var e,i,s;c(this,ht,t);for(let r of o(this,ct))if(r.startsWith("img_")){let u=o(this,M).Image3D.getById(r);if(u){let f=o(this,M).getState(u.image);o(this,D).has(r)||o(this,D).set(r,(e=f==null?void 0:f.opacity)!=null?e:1);let g=Math.min(o(this,D).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,D).has(r)||o(this,D).set(r,(s=f==null?void 0:f.opacity)!=null?s:1);let g=Math.min(o(this,D).get(r),t);o(this,M).updateState(u,{opacity:g,visible:g>0})}}get opacity(){return o(this,ht)}};M=new WeakMap,ct=new WeakMap,dt=new WeakMap,D=new WeakMap,ht=new WeakMap,a(jt,"LayerGroup");var kt=jt;function Ut(n,t){n.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Ut,"runLayerGroupInterpolations");var k,l,Z,h,Y,q,y,_,H,L,w,ot,ft,mt,pt,T,P,et,R,U,b,$t,uo,co,Yt,gt,bt,Ft,yt,it,At,ho,fo,N,qt=class qt{constructor(t){d(this,b);d(this,k);d(this,l);d(this,Z);d(this,h,so);d(this,Y,[]);d(this,q,new Set);d(this,y,new Map);d(this,_);d(this,H,!1);d(this,L,!1);d(this,w,0);d(this,ot,0);d(this,ft,[]);d(this,mt,{});d(this,pt,{});d(this,T,"transition");d(this,P,"outdoor");d(this,et,[]);d(this,R,!1);d(this,U,[]);p(this,"sceneUpdateQueue",Promise.resolve());p(this,"on",a((t,e)=>{o(this,k).on(t,e)},"on"));p(this,"off",a((t,e)=>{o(this,k).off(t,e)},"off"));d(this,gt,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Kt(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,L))return;c(this,L,!1),c(this,Y,[]),o(this,q).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,q).add(r.id),o(this,Y).push(r)}}o(this,h).autoFocus&&this.focus()},"#handleFacadesInViewChange"));d(this,bt,a(async t=>{var f,g,m,B;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,_).matchesFloorStack(e.floorStack)&&c(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?(c(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,h).autoFocus||(await o(this,N).call(this,e),o(this,k).publish("focus",{facades:this.focusedFacades}))):(await o(this,N).call(this,e),o(this,k).publish("focus",{facades:this.focusedFacades})));let j=(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)&&((B=o(this,l).options.multiFloorView)!=null&&B.updateCameraElevationOnFloorChange)&&o(this,l).Camera.elevation!==j&&o(this,l).Camera.animateElevation(j,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));d(this,Ft,a(()=>{c(this,H,!0)},"#handleUserInteractionStart"));d(this,yt,a(()=>{c(this,H,!1)},"#handleUserInteractionEnd"));d(this,it,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Qt(e,o(this,h).indoorZoomThreshold,o(this,h).outdoorZoomThreshold);o(this,T)!==i&&(c(this,T,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Ut(o(this,U),e)},"#handleCameraChange"));d(this,N,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(B=>B.id))||[],r=((m=o(this,l).Navigation)==null?void 0:m.floorStacks.map(B=>B.id))||[],u=new Promise(async B=>{var rt;await this.sceneUpdateQueue;let j=to({buildings:Array.from(o(this,y).values()),inViewSet:o(this,q),currentFloor:e,zoomState:o(this,T),mode:o(this,h).mode,elevation:o(this,w),floorIdsInNavigation:s,floorStackIdsInNavigation:r,multiFloorView:i,getMultiFloorState:(rt=o(this,h).customMultiFloorVisibilityState)!=null?rt:Zo,dynamicBuildingInteriors:o(this,h).dynamicBuildingInteriors,isolateBelowGroundView:o(this,h).isolateBelowGroundView,currentElevation:o(this,w),forceInteriorsVisible:o(this,h).forceInteriorsVisible}),nt=[];await Promise.all(Array.from(j.values()).map(async $=>{let{building:x,showIndoor:Bt,floorStackState:F,facadeState:st,inFocus:z,isAboveGroundInIsolation:Vt}=$;nt.push(F);let W=oo(x,Bt);if(W==="indoor")return E(this,b,ho).call(this,x,F,st,z);if(W==="outdoor")return E(this,b,fo).call(this,x,F,st,r,Vt)})),o(this,l).Outdoor.setOpacity(Xt(nt,o(this,h).mode)),c(this,et,o(this,Y).filter($=>{var x;return((x=j.get($.id))==null?void 0:x.showIndoor)===!0}).map($=>$.facade)),o(this,k).publish("focus",{facades:o(this,et)}),B()});return this.sceneUpdateQueue=u,u},"#applyBuildingStates"));c(this,k,new St),c(this,l,t),J.setLevel(X.logState),c(this,Z,o(this,l).getMapData()),c(this,w,o(this,l).currentFloor.elevation),c(this,ot,o(this,l).Camera.elevation);for(let e of o(this,Z).getByType("facade"))o(this,y).set(e.floorStack.id,new Et(e.floorStack,o(this,l)));E(this,b,co).call(this),c(this,_,new wt(ro(o(this,Z),o(this,y)),o(this,l))),o(this,l).on("floor-change-start",o(this,bt)),o(this,l).on("camera-change",o(this,it)),o(this,l).on("facades-in-view-change",o(this,gt)),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,R)){J.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,R,!0),o(this,l).manualFloorVisibility=!0,o(this,_).show(),this.updateState(C(C({},o(this,h)),t)),E(this,b,uo).call(this),o(this,it).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,R)){J.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,R,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,R)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,_).floorStack}get layers(){return o(this,ft)}get layersBySpaceId(){return o(this,mt)}setIndoor(){c(this,P,"indoor"),c(this,T,"in-range"),E(this,b,$t).call(this)}setOutdoor(){c(this,P,"outdoor"),c(this,T,"out-of-range"),E(this,b,$t).call(this)}get focusedFacades(){return[...o(this,et)]}getState(){return C({},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=Gt(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=Gt(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=io.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),c(this,h,Object.assign({},o(this,h),Object.fromEntries(Object.entries(t).filter(([,u])=>u!=null)))),t.mode!=null&&t.preloadFloors&&E(this,b,Yt).call(this,t.mode),e){let u=o(this,h).isolateBelowGroundView&&o(this,w)<0;i&&!u?(c(this,L,!0),o(this,l).Camera.updateFacadesInView(),o(this,h).autoFocus||o(this,N).call(this)):o(this,N).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,bt)),o(this,l).off("camera-change",o(this,it)),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,_).destroy(),o(this,k).destroy(),c(this,U,[])}async focus(t=o(this,h).setFloorOnFocus){if(t)if(eo(o(this,ot),o(this,l).Camera.elevation,o(this,H)))c(this,ot,o(this,l).Camera.elevation),c(this,L,!0);else{let e=Jt(o(this,Y),o(this,_),o(this,T)),i=e?vt(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,N).call(this),o(this,k).publish("focus",{facades:this.focusedFacades})}preloadFloors(){E(this,b,Yt).call(this,o(this,h).mode)}setDefaultFloorForStack(t,e){if(!Ct(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(!Ct(e,t))return;let i=o(this,y).get(t.id);i&&(i.activeFloor=e,o(this,N).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)}};k=new WeakMap,l=new WeakMap,Z=new WeakMap,h=new WeakMap,Y=new WeakMap,q=new WeakMap,y=new WeakMap,_=new WeakMap,H=new WeakMap,L=new WeakMap,w=new WeakMap,ot=new WeakMap,ft=new WeakMap,mt=new WeakMap,pt=new WeakMap,T=new WeakMap,P=new WeakMap,et=new WeakMap,R=new WeakMap,U=new WeakMap,b=new WeakSet,$t=a(function(){o(this,h).autoFocus&&(o(this,H)?this.focus():c(this,L,!0)),o(this,k).publish("state-change")},"#handleViewStateChange"),uo=a(function(){c(this,U,[]);for(let t of o(this,h).dynamicLayers){let e=new kt([t],!0,o(this,l));e.processLayerGroup(o(this,pt),o(this,h).outdoorZoomThreshold,o(this,h).indoorZoomThreshold),o(this,U).push(e)}Ut(o(this,U),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),co=a(function(){var s,r,u;let t=(u=(r=(s=o(this,Z).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)}),c(this,ft,t.map(({name:f})=>f)),c(this,mt,i),c(this,pt,e)},"#setupLayers"),Yt=a(function(t){o(this,l).preloadFloors(o(this,Z).getByType("facade").map(e=>vt(o(this,y).get(e.floorStack.id),t,o(this,w))).filter(e=>e!=null&&Go.is(e)))},"#preloadFloors"),gt=new WeakMap,bt=new WeakMap,Ft=new WeakMap,yt=new WeakMap,it=new WeakMap,At=a(function(t,e,i,s=!1){t.forEach(r=>{if(r.floor)if(e){let f=i!==void 0&&!s?at(C({},r.state),{labels:at(C({},r.state.labels),{enabled:r.state.labels.enabled&&i}),markers:at(C({},r.state.markers),{enabled:r.state.markers.enabled&&i}),occlusion:at(C({},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"),ho=a(async function(t,e,i,s){return E(this,b,At).call(this,e.floorStates,!0,s,o(this,h).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,h).indoorAnimationOptions)},"#animateIndoorSequence"),fo=a(async function(t,e,i,s,r){let u=r;u&&E(this,b,At).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,b,At).call(this,e.floorStates,_t({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,T)==="in-range",inFocus:o(this,q).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"),N=new WeakMap,a(qt,"DynamicFocus");var lo=qt;export{a,we as b,Ie as c,lo as d};
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ type DynamicFocusEventPayload<EventName extends keyof DynamicFocusEvents> = Dyna
|
|
|
132
132
|
data: null;
|
|
133
133
|
} ? DynamicFocusEvents[EventName]['data'] : DynamicFocusEvents[EventName];
|
|
134
134
|
//#endregion
|
|
135
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
135
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/primitive.d.ts
|
|
136
136
|
/**
|
|
137
137
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
138
138
|
|
|
@@ -140,7 +140,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
140
140
|
*/
|
|
141
141
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
142
142
|
//#endregion
|
|
143
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
143
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/is-any.d.ts
|
|
144
144
|
/**
|
|
145
145
|
Returns a boolean for whether the given type is `any`.
|
|
146
146
|
|
|
@@ -155,8 +155,8 @@ import type {IsAny} from 'type-fest';
|
|
|
155
155
|
const typedObject = {a: 1, b: 2} as const;
|
|
156
156
|
const anyObject: any = {a: 1, b: 2};
|
|
157
157
|
|
|
158
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(
|
|
159
|
-
return
|
|
158
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
159
|
+
return object[key];
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
const typedA = get(typedObject, 'a');
|
|
@@ -171,7 +171,7 @@ const anyA = get(anyObject, 'a');
|
|
|
171
171
|
*/
|
|
172
172
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
173
173
|
//#endregion
|
|
174
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
174
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
175
175
|
/**
|
|
176
176
|
Returns a boolean for whether the given key is an optional key of type.
|
|
177
177
|
|
|
@@ -181,17 +181,17 @@ This is useful when writing utility types or schema validators that need to diff
|
|
|
181
181
|
```
|
|
182
182
|
import type {IsOptionalKeyOf} from 'type-fest';
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
type User = {
|
|
185
185
|
name: string;
|
|
186
186
|
surname: string;
|
|
187
187
|
|
|
188
188
|
luckyNumber?: number;
|
|
189
|
-
}
|
|
189
|
+
};
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
type Admin = {
|
|
192
192
|
name: string;
|
|
193
193
|
surname?: string;
|
|
194
|
-
}
|
|
194
|
+
};
|
|
195
195
|
|
|
196
196
|
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
197
197
|
//=> true
|
|
@@ -214,7 +214,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
214
214
|
*/
|
|
215
215
|
type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
|
|
216
216
|
//#endregion
|
|
217
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
217
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
218
218
|
/**
|
|
219
219
|
Extract all optional keys from the given type.
|
|
220
220
|
|
|
@@ -224,12 +224,12 @@ This is useful when you want to create a new type that contains different type v
|
|
|
224
224
|
```
|
|
225
225
|
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
type User = {
|
|
228
228
|
name: string;
|
|
229
229
|
surname: string;
|
|
230
230
|
|
|
231
231
|
luckyNumber?: number;
|
|
232
|
-
}
|
|
232
|
+
};
|
|
233
233
|
|
|
234
234
|
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
235
235
|
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
@@ -237,12 +237,12 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
|
|
|
237
237
|
};
|
|
238
238
|
|
|
239
239
|
const update1: UpdateOperation<User> = {
|
|
240
|
-
name: 'Alice'
|
|
240
|
+
name: 'Alice',
|
|
241
241
|
};
|
|
242
242
|
|
|
243
243
|
const update2: UpdateOperation<User> = {
|
|
244
244
|
name: 'Bob',
|
|
245
|
-
luckyNumber: REMOVE_FIELD
|
|
245
|
+
luckyNumber: REMOVE_FIELD,
|
|
246
246
|
};
|
|
247
247
|
```
|
|
248
248
|
|
|
@@ -252,7 +252,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
252
252
|
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
253
253
|
: never;
|
|
254
254
|
//#endregion
|
|
255
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
255
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/required-keys-of.d.ts
|
|
256
256
|
/**
|
|
257
257
|
Extract all required keys from the given type.
|
|
258
258
|
|
|
@@ -262,17 +262,23 @@ This is useful when you want to create a new type that contains different type v
|
|
|
262
262
|
```
|
|
263
263
|
import type {RequiredKeysOf} from 'type-fest';
|
|
264
264
|
|
|
265
|
-
declare function createValidation<
|
|
265
|
+
declare function createValidation<
|
|
266
|
+
Entity extends object,
|
|
267
|
+
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
268
|
+
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
266
269
|
|
|
267
|
-
|
|
270
|
+
type User = {
|
|
268
271
|
name: string;
|
|
269
272
|
surname: string;
|
|
270
|
-
|
|
271
273
|
luckyNumber?: number;
|
|
272
|
-
}
|
|
274
|
+
};
|
|
273
275
|
|
|
274
276
|
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
275
277
|
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
278
|
+
|
|
279
|
+
// @ts-expect-error
|
|
280
|
+
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
281
|
+
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
276
282
|
```
|
|
277
283
|
|
|
278
284
|
@category Utilities
|
|
@@ -280,7 +286,7 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
280
286
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
281
287
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
282
288
|
//#endregion
|
|
283
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
289
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/is-never.d.ts
|
|
284
290
|
/**
|
|
285
291
|
Returns a boolean for whether the given type is `never`.
|
|
286
292
|
|
|
@@ -294,29 +300,41 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
294
300
|
```
|
|
295
301
|
import type {IsNever, And} from 'type-fest';
|
|
296
302
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
303
|
+
type A = IsNever<never>;
|
|
304
|
+
//=> true
|
|
305
|
+
|
|
306
|
+
type B = IsNever<any>;
|
|
307
|
+
//=> false
|
|
308
|
+
|
|
309
|
+
type C = IsNever<unknown>;
|
|
310
|
+
//=> false
|
|
311
|
+
|
|
312
|
+
type D = IsNever<never[]>;
|
|
313
|
+
//=> false
|
|
314
|
+
|
|
315
|
+
type E = IsNever<object>;
|
|
316
|
+
//=> false
|
|
317
|
+
|
|
318
|
+
type F = IsNever<string>;
|
|
319
|
+
//=> false
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
@example
|
|
323
|
+
```
|
|
324
|
+
import type {IsNever} from 'type-fest';
|
|
314
325
|
|
|
315
|
-
|
|
326
|
+
type IsTrue<T> = T extends true ? true : false;
|
|
327
|
+
|
|
328
|
+
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
329
|
+
type A = IsTrue<never>;
|
|
316
330
|
//=> never
|
|
317
331
|
|
|
318
|
-
|
|
319
|
-
|
|
332
|
+
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
333
|
+
type IsTrueFixed<T> =
|
|
334
|
+
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
335
|
+
|
|
336
|
+
type B = IsTrueFixed<never>;
|
|
337
|
+
//=> false
|
|
320
338
|
```
|
|
321
339
|
|
|
322
340
|
@category Type Guard
|
|
@@ -324,7 +342,7 @@ endIfEqual('abc', '123');
|
|
|
324
342
|
*/
|
|
325
343
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
326
344
|
//#endregion
|
|
327
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
345
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/if.d.ts
|
|
328
346
|
/**
|
|
329
347
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
330
348
|
|
|
@@ -337,7 +355,7 @@ Note:
|
|
|
337
355
|
|
|
338
356
|
@example
|
|
339
357
|
```
|
|
340
|
-
import {If} from 'type-fest';
|
|
358
|
+
import type {If} from 'type-fest';
|
|
341
359
|
|
|
342
360
|
type A = If<true, 'yes', 'no'>;
|
|
343
361
|
//=> 'yes'
|
|
@@ -357,7 +375,7 @@ type E = If<never, 'yes', 'no'>;
|
|
|
357
375
|
|
|
358
376
|
@example
|
|
359
377
|
```
|
|
360
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
378
|
+
import type {If, IsAny, IsNever} from 'type-fest';
|
|
361
379
|
|
|
362
380
|
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
363
381
|
//=> 'not any'
|
|
@@ -368,7 +386,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
|
368
386
|
|
|
369
387
|
@example
|
|
370
388
|
```
|
|
371
|
-
import {If, IsEqual} from 'type-fest';
|
|
389
|
+
import type {If, IsEqual} from 'type-fest';
|
|
372
390
|
|
|
373
391
|
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
374
392
|
|
|
@@ -419,7 +437,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
419
437
|
*/
|
|
420
438
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
421
439
|
//#endregion
|
|
422
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
440
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/internal/type.d.ts
|
|
423
441
|
/**
|
|
424
442
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
425
443
|
*/
|
|
@@ -437,7 +455,7 @@ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T
|
|
|
437
455
|
(...arguments_: infer B): unknown;
|
|
438
456
|
} ? B extends A ? A extends B ? false : true : true : false;
|
|
439
457
|
//#endregion
|
|
440
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
458
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/simplify.d.ts
|
|
441
459
|
/**
|
|
442
460
|
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
443
461
|
|
|
@@ -483,10 +501,11 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
483
501
|
const someType: SomeType = literal;
|
|
484
502
|
const someInterface: SomeInterface = literal;
|
|
485
503
|
|
|
486
|
-
function fn(object: Record<string, unknown>): void
|
|
504
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
487
505
|
|
|
488
506
|
fn(literal); // Good: literal object type is sealed
|
|
489
507
|
fn(someType); // Good: type is sealed
|
|
508
|
+
// @ts-expect-error
|
|
490
509
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
491
510
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
492
511
|
```
|
|
@@ -497,7 +516,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
497
516
|
*/
|
|
498
517
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
499
518
|
//#endregion
|
|
500
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
519
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
501
520
|
/**
|
|
502
521
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
503
522
|
|
|
@@ -515,8 +534,9 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
515
534
|
```
|
|
516
535
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
517
536
|
|
|
537
|
+
// @ts-expect-error
|
|
518
538
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
519
|
-
//
|
|
539
|
+
// TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
520
540
|
```
|
|
521
541
|
|
|
522
542
|
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
@@ -525,19 +545,21 @@ Instead of causing a type error like the above, you can also use a [conditional
|
|
|
525
545
|
type Indexed = {} extends Record<string, unknown>
|
|
526
546
|
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
527
547
|
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
528
|
-
|
|
548
|
+
|
|
549
|
+
type IndexedResult = Indexed;
|
|
550
|
+
//=> '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
529
551
|
|
|
530
552
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
531
|
-
?
|
|
532
|
-
:
|
|
533
|
-
|
|
553
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
554
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
555
|
+
|
|
556
|
+
type KeyedResult = Keyed;
|
|
557
|
+
//=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
534
558
|
```
|
|
535
559
|
|
|
536
560
|
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
537
561
|
|
|
538
562
|
```
|
|
539
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
540
|
-
|
|
541
563
|
type OmitIndexSignature<ObjectType> = {
|
|
542
564
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
543
565
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -547,14 +569,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
547
569
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
548
570
|
|
|
549
571
|
```
|
|
550
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
551
|
-
|
|
552
572
|
type OmitIndexSignature<ObjectType> = {
|
|
553
573
|
[KeyType in keyof ObjectType
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
574
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
575
|
+
as {} extends Record<KeyType, unknown>
|
|
576
|
+
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
577
|
+
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
558
578
|
]: ObjectType[KeyType];
|
|
559
579
|
};
|
|
560
580
|
```
|
|
@@ -565,24 +585,24 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
565
585
|
```
|
|
566
586
|
import type {OmitIndexSignature} from 'type-fest';
|
|
567
587
|
|
|
568
|
-
|
|
588
|
+
type Example = {
|
|
569
589
|
// These index signatures will be removed.
|
|
570
|
-
[x: string]: any
|
|
571
|
-
[x: number]: any
|
|
572
|
-
[x: symbol]: any
|
|
573
|
-
[x: `head-${string}`]: string
|
|
574
|
-
[x: `${string}-tail`]: string
|
|
575
|
-
[x: `head-${string}-tail`]: string
|
|
576
|
-
[x: `${bigint}`]: string
|
|
577
|
-
[x: `embedded-${number}`]: string
|
|
590
|
+
[x: string]: any;
|
|
591
|
+
[x: number]: any;
|
|
592
|
+
[x: symbol]: any;
|
|
593
|
+
[x: `head-${string}`]: string;
|
|
594
|
+
[x: `${string}-tail`]: string;
|
|
595
|
+
[x: `head-${string}-tail`]: string;
|
|
596
|
+
[x: `${bigint}`]: string;
|
|
597
|
+
[x: `embedded-${number}`]: string;
|
|
578
598
|
|
|
579
599
|
// These explicitly defined keys will remain.
|
|
580
600
|
foo: 'bar';
|
|
581
601
|
qux?: 'baz';
|
|
582
|
-
}
|
|
602
|
+
};
|
|
583
603
|
|
|
584
604
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
585
|
-
|
|
605
|
+
//=> {foo: 'bar'; qux?: 'baz'}
|
|
586
606
|
```
|
|
587
607
|
|
|
588
608
|
@see {@link PickIndexSignature}
|
|
@@ -590,7 +610,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
590
610
|
*/
|
|
591
611
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
592
612
|
//#endregion
|
|
593
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
613
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
594
614
|
/**
|
|
595
615
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
596
616
|
|
|
@@ -638,9 +658,9 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
638
658
|
*/
|
|
639
659
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
640
660
|
//#endregion
|
|
641
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
661
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/merge.d.ts
|
|
642
662
|
// Merges two objects without worrying about index signatures.
|
|
643
|
-
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source
|
|
663
|
+
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
644
664
|
|
|
645
665
|
/**
|
|
646
666
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
@@ -649,12 +669,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
649
669
|
```
|
|
650
670
|
import type {Merge} from 'type-fest';
|
|
651
671
|
|
|
652
|
-
|
|
672
|
+
type Foo = {
|
|
653
673
|
[x: string]: unknown;
|
|
654
674
|
[x: number]: unknown;
|
|
655
675
|
foo: string;
|
|
656
676
|
bar: symbol;
|
|
657
|
-
}
|
|
677
|
+
};
|
|
658
678
|
|
|
659
679
|
type Bar = {
|
|
660
680
|
[x: number]: number;
|
|
@@ -664,7 +684,7 @@ type Bar = {
|
|
|
664
684
|
};
|
|
665
685
|
|
|
666
686
|
export type FooBar = Merge<Foo, Bar>;
|
|
667
|
-
|
|
687
|
+
//=> {
|
|
668
688
|
// [x: string]: unknown;
|
|
669
689
|
// [x: number]: number;
|
|
670
690
|
// [x: symbol]: unknown;
|
|
@@ -674,11 +694,17 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
674
694
|
// }
|
|
675
695
|
```
|
|
676
696
|
|
|
697
|
+
Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
|
|
698
|
+
|
|
699
|
+
@see {@link ObjectMerge}
|
|
677
700
|
@category Object
|
|
678
701
|
*/
|
|
679
|
-
type Merge<Destination, Source> =
|
|
702
|
+
type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
|
|
703
|
+
? Source extends unknown // For distributing `Source`
|
|
704
|
+
? Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>> : never // Should never happen
|
|
705
|
+
: never;
|
|
680
706
|
//#endregion
|
|
681
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
707
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/internal/object.d.ts
|
|
682
708
|
|
|
683
709
|
/**
|
|
684
710
|
Merges user specified options with default options.
|
|
@@ -734,7 +760,7 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
734
760
|
*/
|
|
735
761
|
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
736
762
|
//#endregion
|
|
737
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
763
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/partial-deep.d.ts
|
|
738
764
|
/**
|
|
739
765
|
@see {@link PartialDeep}
|
|
740
766
|
*/
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as f,b as u,c as y,d as F}from"./chunk-I4AEDPQV.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.d.ts
CHANGED
|
@@ -132,7 +132,7 @@ type DynamicFocusEventPayload<EventName extends keyof DynamicFocusEvents> = Dyna
|
|
|
132
132
|
data: null;
|
|
133
133
|
} ? DynamicFocusEvents[EventName]['data'] : DynamicFocusEvents[EventName];
|
|
134
134
|
//#endregion
|
|
135
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
135
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/primitive.d.ts
|
|
136
136
|
/**
|
|
137
137
|
Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
|
|
138
138
|
|
|
@@ -140,7 +140,7 @@ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/
|
|
|
140
140
|
*/
|
|
141
141
|
type Primitive = null | undefined | string | number | boolean | symbol | bigint;
|
|
142
142
|
//#endregion
|
|
143
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
143
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/is-any.d.ts
|
|
144
144
|
/**
|
|
145
145
|
Returns a boolean for whether the given type is `any`.
|
|
146
146
|
|
|
@@ -155,8 +155,8 @@ import type {IsAny} from 'type-fest';
|
|
|
155
155
|
const typedObject = {a: 1, b: 2} as const;
|
|
156
156
|
const anyObject: any = {a: 1, b: 2};
|
|
157
157
|
|
|
158
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(
|
|
159
|
-
return
|
|
158
|
+
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
159
|
+
return object[key];
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
const typedA = get(typedObject, 'a');
|
|
@@ -171,7 +171,7 @@ const anyA = get(anyObject, 'a');
|
|
|
171
171
|
*/
|
|
172
172
|
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
173
173
|
//#endregion
|
|
174
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
174
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
175
175
|
/**
|
|
176
176
|
Returns a boolean for whether the given key is an optional key of type.
|
|
177
177
|
|
|
@@ -181,17 +181,17 @@ This is useful when writing utility types or schema validators that need to diff
|
|
|
181
181
|
```
|
|
182
182
|
import type {IsOptionalKeyOf} from 'type-fest';
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
type User = {
|
|
185
185
|
name: string;
|
|
186
186
|
surname: string;
|
|
187
187
|
|
|
188
188
|
luckyNumber?: number;
|
|
189
|
-
}
|
|
189
|
+
};
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
type Admin = {
|
|
192
192
|
name: string;
|
|
193
193
|
surname?: string;
|
|
194
|
-
}
|
|
194
|
+
};
|
|
195
195
|
|
|
196
196
|
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
197
197
|
//=> true
|
|
@@ -214,7 +214,7 @@ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
|
214
214
|
*/
|
|
215
215
|
type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
|
|
216
216
|
//#endregion
|
|
217
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
217
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
218
218
|
/**
|
|
219
219
|
Extract all optional keys from the given type.
|
|
220
220
|
|
|
@@ -224,12 +224,12 @@ This is useful when you want to create a new type that contains different type v
|
|
|
224
224
|
```
|
|
225
225
|
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
226
226
|
|
|
227
|
-
|
|
227
|
+
type User = {
|
|
228
228
|
name: string;
|
|
229
229
|
surname: string;
|
|
230
230
|
|
|
231
231
|
luckyNumber?: number;
|
|
232
|
-
}
|
|
232
|
+
};
|
|
233
233
|
|
|
234
234
|
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
235
235
|
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
@@ -237,12 +237,12 @@ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKe
|
|
|
237
237
|
};
|
|
238
238
|
|
|
239
239
|
const update1: UpdateOperation<User> = {
|
|
240
|
-
name: 'Alice'
|
|
240
|
+
name: 'Alice',
|
|
241
241
|
};
|
|
242
242
|
|
|
243
243
|
const update2: UpdateOperation<User> = {
|
|
244
244
|
name: 'Bob',
|
|
245
|
-
luckyNumber: REMOVE_FIELD
|
|
245
|
+
luckyNumber: REMOVE_FIELD,
|
|
246
246
|
};
|
|
247
247
|
```
|
|
248
248
|
|
|
@@ -252,7 +252,7 @@ type OptionalKeysOf<Type extends object> = Type extends unknown // For distribut
|
|
|
252
252
|
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
253
253
|
: never;
|
|
254
254
|
//#endregion
|
|
255
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
255
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/required-keys-of.d.ts
|
|
256
256
|
/**
|
|
257
257
|
Extract all required keys from the given type.
|
|
258
258
|
|
|
@@ -262,17 +262,23 @@ This is useful when you want to create a new type that contains different type v
|
|
|
262
262
|
```
|
|
263
263
|
import type {RequiredKeysOf} from 'type-fest';
|
|
264
264
|
|
|
265
|
-
declare function createValidation<
|
|
265
|
+
declare function createValidation<
|
|
266
|
+
Entity extends object,
|
|
267
|
+
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
268
|
+
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
266
269
|
|
|
267
|
-
|
|
270
|
+
type User = {
|
|
268
271
|
name: string;
|
|
269
272
|
surname: string;
|
|
270
|
-
|
|
271
273
|
luckyNumber?: number;
|
|
272
|
-
}
|
|
274
|
+
};
|
|
273
275
|
|
|
274
276
|
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
275
277
|
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
278
|
+
|
|
279
|
+
// @ts-expect-error
|
|
280
|
+
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
281
|
+
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
276
282
|
```
|
|
277
283
|
|
|
278
284
|
@category Utilities
|
|
@@ -280,7 +286,7 @@ const validator2 = createValidation<User>('surname', value => value.length < 25)
|
|
|
280
286
|
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
281
287
|
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
282
288
|
//#endregion
|
|
283
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
289
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/is-never.d.ts
|
|
284
290
|
/**
|
|
285
291
|
Returns a boolean for whether the given type is `never`.
|
|
286
292
|
|
|
@@ -294,29 +300,41 @@ Useful in type utilities, such as checking if something does not occur.
|
|
|
294
300
|
```
|
|
295
301
|
import type {IsNever, And} from 'type-fest';
|
|
296
302
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
303
|
+
type A = IsNever<never>;
|
|
304
|
+
//=> true
|
|
305
|
+
|
|
306
|
+
type B = IsNever<any>;
|
|
307
|
+
//=> false
|
|
308
|
+
|
|
309
|
+
type C = IsNever<unknown>;
|
|
310
|
+
//=> false
|
|
311
|
+
|
|
312
|
+
type D = IsNever<never[]>;
|
|
313
|
+
//=> false
|
|
314
|
+
|
|
315
|
+
type E = IsNever<object>;
|
|
316
|
+
//=> false
|
|
317
|
+
|
|
318
|
+
type F = IsNever<string>;
|
|
319
|
+
//=> false
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
@example
|
|
323
|
+
```
|
|
324
|
+
import type {IsNever} from 'type-fest';
|
|
314
325
|
|
|
315
|
-
|
|
326
|
+
type IsTrue<T> = T extends true ? true : false;
|
|
327
|
+
|
|
328
|
+
// When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
|
|
329
|
+
type A = IsTrue<never>;
|
|
316
330
|
//=> never
|
|
317
331
|
|
|
318
|
-
|
|
319
|
-
|
|
332
|
+
// If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
|
|
333
|
+
type IsTrueFixed<T> =
|
|
334
|
+
IsNever<T> extends true ? false : T extends true ? true : false;
|
|
335
|
+
|
|
336
|
+
type B = IsTrueFixed<never>;
|
|
337
|
+
//=> false
|
|
320
338
|
```
|
|
321
339
|
|
|
322
340
|
@category Type Guard
|
|
@@ -324,7 +342,7 @@ endIfEqual('abc', '123');
|
|
|
324
342
|
*/
|
|
325
343
|
type IsNever<T> = [T] extends [never] ? true : false;
|
|
326
344
|
//#endregion
|
|
327
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
345
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/if.d.ts
|
|
328
346
|
/**
|
|
329
347
|
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
330
348
|
|
|
@@ -337,7 +355,7 @@ Note:
|
|
|
337
355
|
|
|
338
356
|
@example
|
|
339
357
|
```
|
|
340
|
-
import {If} from 'type-fest';
|
|
358
|
+
import type {If} from 'type-fest';
|
|
341
359
|
|
|
342
360
|
type A = If<true, 'yes', 'no'>;
|
|
343
361
|
//=> 'yes'
|
|
@@ -357,7 +375,7 @@ type E = If<never, 'yes', 'no'>;
|
|
|
357
375
|
|
|
358
376
|
@example
|
|
359
377
|
```
|
|
360
|
-
import {If, IsAny, IsNever} from 'type-fest';
|
|
378
|
+
import type {If, IsAny, IsNever} from 'type-fest';
|
|
361
379
|
|
|
362
380
|
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
363
381
|
//=> 'not any'
|
|
@@ -368,7 +386,7 @@ type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
|
368
386
|
|
|
369
387
|
@example
|
|
370
388
|
```
|
|
371
|
-
import {If, IsEqual} from 'type-fest';
|
|
389
|
+
import type {If, IsEqual} from 'type-fest';
|
|
372
390
|
|
|
373
391
|
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
374
392
|
|
|
@@ -419,7 +437,7 @@ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
|
419
437
|
*/
|
|
420
438
|
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
421
439
|
//#endregion
|
|
422
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
440
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/internal/type.d.ts
|
|
423
441
|
/**
|
|
424
442
|
Matches any primitive, `void`, `Date`, or `RegExp` value.
|
|
425
443
|
*/
|
|
@@ -437,7 +455,7 @@ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T
|
|
|
437
455
|
(...arguments_: infer B): unknown;
|
|
438
456
|
} ? B extends A ? A extends B ? false : true : true : false;
|
|
439
457
|
//#endregion
|
|
440
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
458
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/simplify.d.ts
|
|
441
459
|
/**
|
|
442
460
|
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
443
461
|
|
|
@@ -483,10 +501,11 @@ const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
|
483
501
|
const someType: SomeType = literal;
|
|
484
502
|
const someInterface: SomeInterface = literal;
|
|
485
503
|
|
|
486
|
-
function fn(object: Record<string, unknown>): void
|
|
504
|
+
declare function fn(object: Record<string, unknown>): void;
|
|
487
505
|
|
|
488
506
|
fn(literal); // Good: literal object type is sealed
|
|
489
507
|
fn(someType); // Good: type is sealed
|
|
508
|
+
// @ts-expect-error
|
|
490
509
|
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
491
510
|
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
492
511
|
```
|
|
@@ -497,7 +516,7 @@ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface`
|
|
|
497
516
|
*/
|
|
498
517
|
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
499
518
|
//#endregion
|
|
500
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
519
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
501
520
|
/**
|
|
502
521
|
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
503
522
|
|
|
@@ -515,8 +534,9 @@ It relies on the fact that an empty object (`{}`) is assignable to an object wit
|
|
|
515
534
|
```
|
|
516
535
|
const indexed: Record<string, unknown> = {}; // Allowed
|
|
517
536
|
|
|
537
|
+
// @ts-expect-error
|
|
518
538
|
const keyed: Record<'foo', unknown> = {}; // Error
|
|
519
|
-
//
|
|
539
|
+
// TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
520
540
|
```
|
|
521
541
|
|
|
522
542
|
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
@@ -525,19 +545,21 @@ Instead of causing a type error like the above, you can also use a [conditional
|
|
|
525
545
|
type Indexed = {} extends Record<string, unknown>
|
|
526
546
|
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
527
547
|
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
528
|
-
|
|
548
|
+
|
|
549
|
+
type IndexedResult = Indexed;
|
|
550
|
+
//=> '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
529
551
|
|
|
530
552
|
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
531
|
-
?
|
|
532
|
-
:
|
|
533
|
-
|
|
553
|
+
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
554
|
+
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
555
|
+
|
|
556
|
+
type KeyedResult = Keyed;
|
|
557
|
+
//=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
534
558
|
```
|
|
535
559
|
|
|
536
560
|
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
537
561
|
|
|
538
562
|
```
|
|
539
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
540
|
-
|
|
541
563
|
type OmitIndexSignature<ObjectType> = {
|
|
542
564
|
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
543
565
|
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
@@ -547,14 +569,12 @@ type OmitIndexSignature<ObjectType> = {
|
|
|
547
569
|
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
548
570
|
|
|
549
571
|
```
|
|
550
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
551
|
-
|
|
552
572
|
type OmitIndexSignature<ObjectType> = {
|
|
553
573
|
[KeyType in keyof ObjectType
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
574
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
575
|
+
as {} extends Record<KeyType, unknown>
|
|
576
|
+
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
577
|
+
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
558
578
|
]: ObjectType[KeyType];
|
|
559
579
|
};
|
|
560
580
|
```
|
|
@@ -565,24 +585,24 @@ If `{}` is assignable, it means that `KeyType` is an index signature and we want
|
|
|
565
585
|
```
|
|
566
586
|
import type {OmitIndexSignature} from 'type-fest';
|
|
567
587
|
|
|
568
|
-
|
|
588
|
+
type Example = {
|
|
569
589
|
// These index signatures will be removed.
|
|
570
|
-
[x: string]: any
|
|
571
|
-
[x: number]: any
|
|
572
|
-
[x: symbol]: any
|
|
573
|
-
[x: `head-${string}`]: string
|
|
574
|
-
[x: `${string}-tail`]: string
|
|
575
|
-
[x: `head-${string}-tail`]: string
|
|
576
|
-
[x: `${bigint}`]: string
|
|
577
|
-
[x: `embedded-${number}`]: string
|
|
590
|
+
[x: string]: any;
|
|
591
|
+
[x: number]: any;
|
|
592
|
+
[x: symbol]: any;
|
|
593
|
+
[x: `head-${string}`]: string;
|
|
594
|
+
[x: `${string}-tail`]: string;
|
|
595
|
+
[x: `head-${string}-tail`]: string;
|
|
596
|
+
[x: `${bigint}`]: string;
|
|
597
|
+
[x: `embedded-${number}`]: string;
|
|
578
598
|
|
|
579
599
|
// These explicitly defined keys will remain.
|
|
580
600
|
foo: 'bar';
|
|
581
601
|
qux?: 'baz';
|
|
582
|
-
}
|
|
602
|
+
};
|
|
583
603
|
|
|
584
604
|
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
585
|
-
|
|
605
|
+
//=> {foo: 'bar'; qux?: 'baz'}
|
|
586
606
|
```
|
|
587
607
|
|
|
588
608
|
@see {@link PickIndexSignature}
|
|
@@ -590,7 +610,7 @@ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
|
590
610
|
*/
|
|
591
611
|
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
592
612
|
//#endregion
|
|
593
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
613
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
594
614
|
/**
|
|
595
615
|
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
596
616
|
|
|
@@ -638,9 +658,9 @@ type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
|
638
658
|
*/
|
|
639
659
|
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
640
660
|
//#endregion
|
|
641
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
661
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/merge.d.ts
|
|
642
662
|
// Merges two objects without worrying about index signatures.
|
|
643
|
-
type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source
|
|
663
|
+
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
644
664
|
|
|
645
665
|
/**
|
|
646
666
|
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
@@ -649,12 +669,12 @@ Merge two types into a new type. Keys of the second type overrides keys of the f
|
|
|
649
669
|
```
|
|
650
670
|
import type {Merge} from 'type-fest';
|
|
651
671
|
|
|
652
|
-
|
|
672
|
+
type Foo = {
|
|
653
673
|
[x: string]: unknown;
|
|
654
674
|
[x: number]: unknown;
|
|
655
675
|
foo: string;
|
|
656
676
|
bar: symbol;
|
|
657
|
-
}
|
|
677
|
+
};
|
|
658
678
|
|
|
659
679
|
type Bar = {
|
|
660
680
|
[x: number]: number;
|
|
@@ -664,7 +684,7 @@ type Bar = {
|
|
|
664
684
|
};
|
|
665
685
|
|
|
666
686
|
export type FooBar = Merge<Foo, Bar>;
|
|
667
|
-
|
|
687
|
+
//=> {
|
|
668
688
|
// [x: string]: unknown;
|
|
669
689
|
// [x: number]: number;
|
|
670
690
|
// [x: symbol]: unknown;
|
|
@@ -674,11 +694,17 @@ export type FooBar = Merge<Foo, Bar>;
|
|
|
674
694
|
// }
|
|
675
695
|
```
|
|
676
696
|
|
|
697
|
+
Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
|
|
698
|
+
|
|
699
|
+
@see {@link ObjectMerge}
|
|
677
700
|
@category Object
|
|
678
701
|
*/
|
|
679
|
-
type Merge<Destination, Source> =
|
|
702
|
+
type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
|
|
703
|
+
? Source extends unknown // For distributing `Source`
|
|
704
|
+
? Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>> : never // Should never happen
|
|
705
|
+
: never;
|
|
680
706
|
//#endregion
|
|
681
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
707
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/internal/object.d.ts
|
|
682
708
|
|
|
683
709
|
/**
|
|
684
710
|
Merges user specified options with default options.
|
|
@@ -734,7 +760,7 @@ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOp
|
|
|
734
760
|
*/
|
|
735
761
|
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
|
|
736
762
|
//#endregion
|
|
737
|
-
//#region ../../node_modules/.pnpm/type-fest@5.2
|
|
763
|
+
//#region ../../node_modules/.pnpm/type-fest@5.4.2/node_modules/type-fest/source/partial-deep.d.ts
|
|
738
764
|
/**
|
|
739
765
|
@see {@link PartialDeep}
|
|
740
766
|
*/
|
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-I4AEDPQV.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/lib/rn/index-rn.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
${a.stack}`:a);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(o,...t),
|
|
1
|
+
var B=Object.defineProperty,l=(e,i)=>B(e,"name",{value:i,configurable:!0});import{useState as V,useCallback as h,useContext as A,useRef as T}from"react";import{MappedinContext as L}from"@mappedin/react-native-sdk";import{useCallback as _,useContext as W}from"react";var D="[MappedinJS]";function g(e="",{prefix:i=D}={}){const o=`${i}${e?`-${e}`:""}`,s=l((t,c)=>{if(typeof window<"u"&&window.rnDebug){const f=c.map(a=>a instanceof Error&&a.stack?`${a.message}
|
|
2
|
+
${a.stack}`:a);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:0,log(...t){this.logState<=0&&(console.log(o,...t),s("log",t))},warn(...t){this.logState<=1&&(console.warn(o,...t),s("warn",t))},error(...t){this.logState<=2&&(console.error(o,...t),s("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){0<=t&&t<=3&&(this.logState=t)}}}l(g,"createLogger");var U=g(),F=g("",{prefix:"[DynamicFocus]"});import{MappedinContext as Z,useEventCallback as G,createEventSetupScript as N,createEventCleanupScript as $}from"@mappedin/react-native-sdk";function v(e,i){return i.map(o=>o&&o.id&&e.getById("facade",o.id)||o)}l(v,"hydrateFacades");import{useRegisterExtension as R}from"@mappedin/react-native-sdk";var j=`
|
|
3
3
|
// Define require function that uses bridge.modules for external dependencies
|
|
4
4
|
globalThis.require = globalThis.require || ((id) => {
|
|
5
5
|
if (window.bridge?.modules?.[id]) {
|
|
@@ -8,8 +8,8 @@ ${a.stack}`:a);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{l
|
|
|
8
8
|
throw new Error('Module not found: ' + id);
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
"use strict";var DynamicFocus=(()=>{var tt=Object.defineProperty;var yo=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var Eo=Object.prototype.hasOwnProperty;var Kt=r=>{throw TypeError(r)};var vo=(r,t,e)=>t in r?tt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>tt(r,"name",{value:t,configurable:!0}),
|
|
12
|
-
\${f.stack}\`:f);window.rnDebug(\`\${r} \${n}: \${h.join(" ")}\`)}},"rnDebug");return{logState: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)}}}a(Lt,"createLogger");var ko=Lt();var z=ko;function no(r,t,e,i){return(r<t||r>e)&&z.warn(i),Math.min(e,Math.max(t,r))}a(no,"clampWithWarning");function _t(r,t){return!St.Floor.is(r)||r?.floorStack==null||!St.FloorStack.is(t)?!1:r.floorStack.id!==t.id?(z.warn(\`Floor (\${r.id}) does not belong to floor stack (\${t.id}).\`),!1):!0}a(_t,"validateFloorForStack");function Nt(r,t,e,i){return no(r,t,e,\`\${i} must be between \${t} and \${e}.\`)}a(Nt,"validateZoomThreshold");var H=Lt("",{prefix:"[DynamicFocus]"});var T,W,et,Ct,Zt=class Zt{constructor(t,e){u(this,et);m(this,"__type","outdoors");u(this,T);u(this,W);c(this,T,t),c(this,W,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(){y(this,et,Ct).call(this,!0)}hide(){y(this,et,Ct).call(this,!1)}destroy(){this.matchesFloorStack(o(this,W).currentFloorStack)||this.hide()}};T=new WeakMap,W=new WeakMap,et=new WeakSet,Ct=a(function(t){for(let e of o(this,T).floors)o(this,W).updateState(e,{visible:t})},"#setVisible"),a(Zt,"Outdoors");var Et=Zt;function so(r,t){let e=r.getByType("floor-stack"),i=e.find(h=>h.type?.toLowerCase()==="outdoor"),n=r.getByType("enterprise-venue")?.defaultFloor;if(n){let h=r.getById("floor",n);if(h)return h.floorStack}if(i)return i;let s=e.find(h=>h.facade==null&&!t.has(h.id));return s||(H.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},Gt=.2,Rt=.4;function Bo(r,t){return\`\${t} \${r}\`}a(Bo,"formatMessage");var Pt=class Pt extends Error{constructor(t,e=Dt){super(Bo(t,e)),this.name="MappedinError"}};a(Pt,"MappedinError");var vt=Pt;var Mo=a(r=>r,"linearEase"),Ao=a(r=>r*r,"quadEaseIn"),xo=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Do=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Lo=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),_o={linear:Mo,"ease-in":Ao,"ease-out":Do,"ease-in-out":xo,"ease-out-cubic":Lo};function No(r,t){let e=0;if(t.length<2)return e;let n=t[0]<t[1]?(s,h)=>s>h:(s,h)=>s<h;for(;e<t.length-1&&n(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(No,"getInterpolationBreakpoint");function lo(r,t,e,i="ease-in"){if(t.length!==e.length)throw new vt("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),s=(r-t[n])/(t[n+1]-t[n]),h=typeof i=="function"?i(s):_o[i](s);return e[n]+h*(e[n+1]-e[n])}a(lo,"interpolateMulti");var I,it,rt,B,nt,jt=class jt{constructor(t,e,i){m(this,"layers");m(this,"visible");u(this,I);u(this,it,[]);u(this,rt,!1);u(this,B,new Map);m(this,"interpolationFn");u(this,nt,1);this.layers=t,this.visible=e,c(this,I,i)}processLayerGroup(t,e,i){if(!o(this,rt)&&(this.layers.forEach(n=>{let s=t[n];s&&o(this,it).push(...s)}),c(this,rt,!0),this.visible)){let n=[e,i],s=[1,0];this.interpolationFn=h=>lo(h,n,s)}}setOpacity(t){c(this,nt,t);for(let e of o(this,it))if(e.startsWith("img_")){let i=o(this,I).Image3D.getById(e);if(i){let n=o(this,I).getState(i.image);o(this,B).has(e)||o(this,B).set(e,n?.opacity??1);let s=Math.min(o(this,B).get(e),t);o(this,I).updateState(i.image,{opacity:s})}}else{let i=o(this,I).getMapData()?.getById("space",e);if(!i)continue;let n=o(this,I).getState(i);o(this,B).has(e)||o(this,B).set(e,n?.opacity??1);let s=Math.min(o(this,B).get(e),t);o(this,I).updateState(i,{opacity:s,visible:s>0})}}get opacity(){return o(this,nt)}};I=new WeakMap,it=new WeakMap,rt=new WeakMap,B=new WeakMap,nt=new WeakMap,a(jt,"LayerGroup");var wt=jt;function Ut(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Ut,"runLayerGroupInterpolations");var w,l,x,d,C,Z,g,M,G,R,V,K,st,at,lt,k,D,Q,L,_,p,$t,uo,co,Yt,ut,ct,dt,ht,X,qt,ho,fo,P,zt=class zt{constructor(t){u(this,p);u(this,w);u(this,l);u(this,x);u(this,d,ao);u(this,C,[]);u(this,Z,new Set);u(this,g,new Map);u(this,M);u(this,G,!1);u(this,R,!1);u(this,V,0);u(this,K,0);u(this,st,[]);u(this,at,{});u(this,lt,{});u(this,k,"transition");u(this,D,"outdoor");u(this,Q,[]);u(this,L,!1);u(this,_,[]);m(this,"sceneUpdateQueue",Promise.resolve());m(this,"on",a((t,e)=>{o(this,w).on(t,e)},"on"));m(this,"off",a((t,e)=>{o(this,w).off(t,e)},"off"));u(this,ut,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Qt(e,this.focusedFacades)&&o(this,D)==="transition"&&!o(this,R))return;c(this,R,!1),c(this,C,[]),o(this,Z).clear();let i=o(this,d).isolateBelowGroundView&&o(this,V)<0;if(e.length>0)for(let n of e){let s=o(this,g).get(n.floorStack.id);if(s){if(i&&s.minElevation>=0)continue;o(this,Z).add(s.id),o(this,C).push(s)}}o(this,d).autoFocus&&this.focus()},"#handleFacadesInViewChange"));u(this,ct,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,g).get(e.floorStack.id);if(i&&(i.activeFloor=e),i?.excluded===!1&&!o(this,M).matchesFloorStack(e.floorStack)&&c(this,V,e.elevation),o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,P).call(this,e),o(this,w).publish("focus",{facades:this.focusedFacades}));let n=i?.floorsAltitudesMap.get(e.elevation)?.altitude??0;o(this,l).options.multiFloorView!=null&&o(this,l).options.multiFloorView?.enabled&&o(this,l).options.multiFloorView?.updateCameraElevationOnFloorChange&&o(this,l).Camera.elevation!==n&&o(this,l).Camera.animateElevation(n,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));u(this,dt,a(()=>{c(this,G,!0)},"#handleUserInteractionStart"));u(this,ht,a(()=>{c(this,G,!1)},"#handleUserInteractionEnd"));u(this,X,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Xt(e,o(this,d).indoorZoomThreshold,o(this,d).outdoorZoomThreshold);o(this,k)!==i&&(c(this,k,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Ut(o(this,_),e)},"#handleCameraChange"));u(this,P,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(f=>f.id)||[],s=o(this,l).Navigation?.floorStacks.map(f=>f.id)||[],h=new Promise(async f=>{await this.sceneUpdateQueue;let U=oo({buildings:Array.from(o(this,g).values()),inViewSet:o(this,Z),currentFloor:e,zoomState:o(this,k),mode:o(this,d).mode,elevation:o(this,V),floorIdsInNavigation:n,floorStackIdsInNavigation:s,multiFloorView:i,getMultiFloorState:o(this,d).customMultiFloorVisibilityState??Ot.getMultiFloorState,dynamicBuildingInteriors:o(this,d).dynamicBuildingInteriors,isolateBelowGroundView:o(this,d).isolateBelowGroundView,currentElevation:o(this,V),forceInteriorsVisible:o(this,d).forceInteriorsVisible}),E=[];await Promise.all(Array.from(U.values()).map(async N=>{let{building:J,showIndoor:ft,floorStackState:j,facadeState:mt,inFocus:pt}=N;E.push(j);let gt=eo(J,ft);if(gt==="indoor")return y(this,p,ho).call(this,J,j,mt,pt);if(gt==="outdoor")return y(this,p,fo).call(this,J,j,mt,s)})),o(this,l).Outdoor.setOpacity(Jt(E,o(this,d).mode)),c(this,Q,o(this,C).filter(N=>U.get(N.id)?.showIndoor===!0).map(N=>N.facade)),o(this,w).publish("focus",{facades:o(this,Q)}),f()});return this.sceneUpdateQueue=h,h},"#applyBuildingStates"));c(this,w,new Ft),c(this,l,t),H.setLevel(z.logState),c(this,x,o(this,l).getMapData()),c(this,V,o(this,l).currentFloor.elevation),c(this,K,o(this,l).Camera.elevation);for(let e of o(this,x).getByType("facade"))o(this,g).set(e.floorStack.id,new bt(e.floorStack,o(this,l)));y(this,p,co).call(this),c(this,M,new Et(so(o(this,x),o(this,g)),o(this,l))),o(this,l).on("floor-change-start",o(this,ct)),o(this,l).on("camera-change",o(this,X)),o(this,l).on("facades-in-view-change",o(this,ut)),o(this,l).on("user-interaction-start",o(this,dt)),o(this,l).on("user-interaction-end",o(this,ht))}enable(t){if(o(this,L)){H.warn("enable() called on an already enabled Dynamic Focus instance.");return}c(this,L,!0),o(this,l).manualFloorVisibility=!0,o(this,M).show(),this.updateState({...o(this,d),...t}),y(this,p,uo).call(this),o(this,X).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,L)){H.warn("disable() called on an already disabled Dynamic Focus instance.");return}c(this,L,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,L)}get isIndoor(){return o(this,D)==="indoor"}get isOutdoor(){return o(this,D)==="outdoor"}get outdoorsFloorStack(){return o(this,M).floorStack}get layers(){return o(this,st)}get layersBySpaceId(){return o(this,at)}setIndoor(){c(this,D,"indoor"),c(this,k,"in-range"),y(this,p,$t).call(this)}setOutdoor(){c(this,D,"outdoor"),c(this,k,"out-of-range"),y(this,p,$t).call(this)}get focusedFacades(){return[...o(this,Q)]}getState(){return{...o(this,d)}}updateState(t){let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Nt(t.indoorZoomThreshold,t?.outdoorZoomThreshold??o(this,d).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Nt(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,t?.indoorZoomThreshold??o(this,d).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=ro.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,d).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,d).dynamicBuildingInteriors&&(e=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,d).isolateBelowGroundView&&(e=!0),t.forceInteriorsVisible!=null&&t.forceInteriorsVisible!==o(this,d).forceInteriorsVisible&&(e=!0),t.showLabelsAndMarkersOnAllVisibleFloors!=null&&t.showLabelsAndMarkersOnAllVisibleFloors!==o(this,d).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),c(this,d,Object.assign({},o(this,d),Object.fromEntries(Object.entries(t).filter(([,i])=>i!=null)))),t.mode!=null&&t.preloadFloors&&y(this,p,Yt).call(this,t.mode),e&&o(this,P).call(this)}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,ut)),o(this,l).off("floor-change-start",o(this,ct)),o(this,l).off("camera-change",o(this,X)),o(this,l).off("user-interaction-start",o(this,dt)),o(this,l).off("user-interaction-end",o(this,ht)),o(this,g).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,w).destroy(),c(this,_,[])}async focus(t=o(this,d).setFloorOnFocus){if(t)if(io(o(this,K),o(this,l).Camera.elevation,o(this,G)))c(this,K,o(this,l).Camera.elevation),c(this,R,!0);else{let e=to(o(this,C),o(this,M),o(this,k)),i=e?yt(e,o(this,d).mode,o(this,V)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,P).call(this),o(this,w).publish("focus",{facades:this.focusedFacades})}preloadFloors(){y(this,p,Yt).call(this,o(this,d).mode)}setDefaultFloorForStack(t,e){if(!_t(e,t))return;let i=o(this,g).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,g).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,g).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!_t(e,t))return;let i=o(this,g).get(t.id);i&&(i.activeFloor=e,o(this,P).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,g).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,g).get(i.id);n&&(n.excluded=!1)}}getCurrentFloorForStack(t){return o(this,g).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};w=new WeakMap,l=new WeakMap,x=new WeakMap,d=new WeakMap,C=new WeakMap,Z=new WeakMap,g=new WeakMap,M=new WeakMap,G=new WeakMap,R=new WeakMap,V=new WeakMap,K=new WeakMap,st=new WeakMap,at=new WeakMap,lt=new WeakMap,k=new WeakMap,D=new WeakMap,Q=new WeakMap,L=new WeakMap,_=new WeakMap,p=new WeakSet,$t=a(function(){o(this,d).autoFocus&&(o(this,G)?this.focus():c(this,R,!0)),o(this,w).publish("state-change")},"#handleViewStateChange"),uo=a(function(){c(this,_,[]);for(let t of o(this,d).dynamicLayers){let e=new wt([t],!0,o(this,l));e.processLayerGroup(o(this,lt),o(this,d).outdoorZoomThreshold,o(this,d).indoorZoomThreshold),o(this,_).push(e)}Ut(o(this,_),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),co=a(function(){let t=o(this,x).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(n=>{e[n.name]||(e[n.name]=[]),e[n.name].push(...n.spaces.map(({spaceId:s})=>s));for(let{spaceId:s}of n.spaces)i[s]==null&&(i[s]=[]),i[s].push(n.name)}),c(this,st,t.map(({name:n})=>n)),c(this,at,i),c(this,lt,e)},"#setupLayers"),Yt=a(function(t){o(this,l).preloadFloors(o(this,x).getByType("facade").map(e=>yt(o(this,g).get(e.floorStack.id),t,o(this,V))).filter(e=>e!=null&&Ot.Floor.is(e)))},"#preloadFloors"),ut=new WeakMap,ct=new WeakMap,dt=new WeakMap,ht=new WeakMap,X=new WeakMap,qt=a(function(t,e,i,n=!1){t.forEach(s=>{if(s.floor)if(e){let f=i!==void 0&&!n?{...s.state,labels:{...s.state.labels,enabled:s.state.labels.enabled&&i},markers:{...s.state.markers,enabled:s.state.markers.enabled&&i},occlusion:{...s.state.occlusion,enabled:s.state.occlusion.enabled&&i}}:s.state;o(this,l).updateState(s.floor,f)}else o(this,l).updateState(s.floor,{visible:!1})})},"#updateFloorVisibility"),ho=a(async function(t,e,i,n){return y(this,p,qt).call(this,e.floorStates,!0,n,o(this,d).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,d).indoorAnimationOptions)},"#animateIndoorSequence"),fo=a(async function(t,e,i,n){let s=await t.animateFacade(i.state,o(this,d).outdoorAnimationOptions);return s.result==="completed"&&y(this,p,qt).call(this,e.floorStates,xt({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,k)==="in-range",inFocus:o(this,Z).has(t.id),mode:o(this,d).mode,elevation:o(this,V),inNavigation:n.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,d).dynamicBuildingInteriors,forceInteriorsVisible:o(this,d).forceInteriorsVisible}),void 0,o(this,d).showLabelsAndMarkersOnAllVisibleFloors),s},"#animateOutdoorSequence"),P=new WeakMap,a(zt,"DynamicFocus");var Vt=zt;var mo=a((r,t)=>{let e={initialVisibility:t.initialVisibility??"outdoor-first",layersBySpaceId:t.layersBySpaceId??{},focusLayers:t.focusLayers??[],defaultFloor:t.defaultFloor??r.currentFloor},i=Co(r,e),n=i+Rt,s=i+Gt;return e.initialVisibility==="indoor-first"&&(n=i-Gt,s=i-Rt),{indoorZoomThreshold:n,outdoorZoomThreshold:s}},"calculateZoomThresholds");function Co(r,t){let e=r.getMapData().getByType("space"),i=t.focusLayers.length?e.filter(h=>{let f=t.layersBySpaceId[h.id]?.[0];return typeof f=="string"&&h.floor.id===t.defaultFloor?.id&&t.focusLayers?.indexOf(f)!==-1}):void 0,n=r.Camera.getFocusOnTransform(t.defaultFloor,{}).zoomLevel??0;return(i?.length?r.Camera.getFocusOnTransform(i,{}).zoomLevel:void 0)??n}a(Co,"getDefaultZoomLevel");return Oo(Zo);})();
|
|
11
|
+
"use strict";var DynamicFocus=(()=>{var tt=Object.defineProperty;var yo=Object.getOwnPropertyDescriptor;var So=Object.getOwnPropertyNames;var Eo=Object.prototype.hasOwnProperty;var Kt=r=>{throw TypeError(r)};var vo=(r,t,e)=>t in r?tt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var a=(r,t)=>tt(r,"name",{value:t,configurable:!0}),At=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var wo=(r,t)=>{for(var e in t)tt(r,e,{get:t[e],enumerable:!0})},Io=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of So(t))!Eo.call(r,n)&&n!==e&&tt(r,n,{get:()=>t[n],enumerable:!(i=yo(t,n))||i.enumerable});return r};var Vo=r=>Io(tt({},"__esModule",{value:!0}),r);var m=(r,t,e)=>vo(r,typeof t!="symbol"?t+"":t,e),Mt=(r,t,e)=>t.has(r)||Kt("Cannot "+e);var o=(r,t,e)=>(Mt(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?Kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),u=(r,t,e,i)=>(Mt(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),b=(r,t,e)=>(Mt(r,t,"access private method"),e);var Zo={};wo(Zo,{DynamicFocus:()=>Vt,calculateZoomThresholds:()=>mo});var Ot=At("@mappedin/mappedin-js");function Qt(r,t){if(r==null||t==null)return r===t;if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}a(Qt,"arraysEqual");var xt=class xt{constructor(){m(this,"_subscribers",{});m(this,"_abortController",new AbortController);m(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?.signal;if(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 s=a(()=>this.off(t,e),"cleanup");return n&&n.addEventListener("abort",s,{once:!0}),this._cleanupFunctions.push(s),s}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 Ft=xt;var Y=At("@mappedin/mappedin-js");var I,ot,L,E,y,V,z,$,Dt=class Dt{constructor(t,e){m(this,"__type","building");c(this,I);c(this,ot,new Map);c(this,L,new Map);c(this,E,[]);c(this,y);c(this,V);m(this,"defaultFloor");m(this,"activeFloor");m(this,"excluded",!1);m(this,"floorsAltitudesMap",new Map);m(this,"aboveGroundFloors",[]);c(this,z);c(this,$);u(this,I,t),u(this,ot,new Map(t.floors.map(n=>[n.id,n]))),u(this,L,new Map(t.floors.map(n=>[n.elevation,n]))),u(this,E,Array.from(o(this,L).values()).sort((n,s)=>n.elevation-s.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,u(this,y,e),this.aboveGroundFloors=o(this,E).filter(n=>n.elevation>=0);let i=t.facade?.spaces.map(n=>o(this,y).getState(n)).sort((n,s)=>n.altitude-s.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let n in this.aboveGroundFloors){let s=this.aboveGroundFloors[n],h=i[n];this.floorsAltitudesMap.set(s.elevation,{altitude:h.altitude,effectiveHeight:h.height})}}get id(){return o(this,I).id}get name(){return o(this,I).name}get floors(){return o(this,I).floors}get floorStack(){return o(this,I)}get facade(){return o(this,I).facade}get isCurrentFloorStack(){return this.id===o(this,y).currentFloorStack.id}get isIndoor(){let t=o(this,y).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,z)==null&&u(this,z,Math.max(...o(this,L).keys())),o(this,z)}get minElevation(){return o(this,$)==null&&u(this,$,Math.min(...o(this,L).keys())),o(this,$)}has(t){return Y.Floor.is(t)?o(this,ot).has(t.id):Y.FloorStack.is(t)?t.id===o(this,I).id:Y.Facade.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,L).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,E)[o(this,E).length-1];for(let i=o(this,E).length-1;i>=0;i--){let n=o(this,E)[i];if(n.elevation<=t)return n}}else{if(t<this.minElevation)return o(this,E)[0];for(let i of o(this,E))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,E)[o(this,E).length-1]}cancelAnimation(){o(this,V)&&(o(this,V).animation.cancel(),u(this,V,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,V)?.state||o(this,y).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:n,visible:s}=t;if(o(this,y).updateState(this.facade,{visible:!0}),n!==void 0){u(this,V,{animation:o(this,y).animateState(this.facade,{opacity:n},{duration:e.duration}),state:t});let h=await o(this,V).animation;if(u(this,V,void 0),h.result==="cancelled")return h}return s===!1&&o(this,y).updateState(this.facade,{visible:s}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,I).floors.forEach(t=>{o(this,y).updateState(t,{visible:t.id===o(this,y).currentFloor.id})}),this.has(o(this,y).currentFloor)||o(this,y).updateState(this.facade,{visible:!0,opacity:1})}};I=new WeakMap,ot=new WeakMap,L=new WeakMap,E=new WeakMap,y=new WeakMap,V=new WeakMap,z=new WeakMap,$=new WeakMap,a(Dt,"Building");var bt=Dt;function Xt(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(Xt,"getZoomState");function yt(r,t,e){if(r.__type==="outdoors"&&"floor"in r)return r.floor;let i=r;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(yt,"getFloorToShow");function Oo(r,t,e,i){return i?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:r,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:r,state:{type:"facade",visible:!0,opacity:.2}}:{facade:r,state:{type:"facade",visible:!0,opacity:1}}}a(Oo,"getFacadeState");function To(r,t,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(i=>{let s=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:s,geometry:{visible:s},labels:{enabled:s},markers:{enabled:s},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(To,"getSingleBuildingState");function Jt(r,t){if(!t.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(Jt,"getOutdoorOpacity");function to(r,t,e){switch(e){case"in-range":return r[0]?.canSetFloor?r[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(to,"getSetFloorTargetFromZoomState");function oo(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:n,mode:s,elevation:h,floorIdsInNavigation:f,floorStackIdsInNavigation:k,multiFloorView:v,getMultiFloorState:G,dynamicBuildingInteriors:J,isolateBelowGroundView:ft,currentElevation:j,forceInteriorsVisible:mt}=r,pt=new Map,Tt=ft&&j<0&&n==="in-range";for(let g of t){let Wt=e.has(g.id),gt=Tt&&g.minElevation>=0,po=gt?!1:Wt,Bt=gt?!1:Lt({building:g,currentFloor:i,inRange:n==="in-range",inFocus:Wt,mode:s,elevation:h,inNavigation:k.includes(g.id),dynamicBuildingInteriors:J,forceInteriorsVisible:mt}),kt=i.floorStack.id===g.id?g.activeFloor:yt(g,s,h),go=v?.enabled?G(g.floors,kt||g.activeFloor,v?.floorGap,f,g.floorsAltitudesMap,{color:v?.footprintColor,spacesOpenToBelowEnabled:v?.spacesOpenToBelowEnabled,__EXPERIMENTAL_darkenSpacesExposedToAbove:v?.__EXPERIMENTAL_darkenSpacesExposedToAbove,opacity:v?.footprintOpacity,outline:v?.footprintOutline}):To(g.floorStack,kt||g.activeFloor,Bt),Fo=ft&&j<0&&n==="in-range",bo=Oo(g.facade,Bt,Fo,gt);pt.set(g.id,{building:g,showIndoor:Bt,floorStackState:go,facadeState:bo,inFocus:po,floorToShow:kt,isAboveGroundInIsolation:gt})}return pt}a(oo,"getBuildingStates");function eo(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(eo,"getBuildingAnimationType");function Lt(r){let{building:t,currentFloor:e,inRange:i,inFocus:n,mode:s,elevation:h,inNavigation:f,dynamicBuildingInteriors:k,forceInteriorsVisible:v}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(v===!0||f===!0)return!0;if(!k)return e.floorStack.type!=="Outdoor";if(!i||!n)return!1;switch(s){case"lock-elevation":return t.getFloorByElevation(h)!=null;default:break}return!0}a(Lt,"shouldShowIndoor");function io(r,t,e){return r!==t&&!e}a(io,"shouldDeferSetFloor");var ro=["default-floor","lock-elevation","nearest-elevation"];var St=At("@mappedin/mappedin-js");var _t="[MappedinJS]";function Nt(r="",{prefix:t=_t}={}){let e=\`\${t}\${r?\`-\${r}\`:""}\`,i=a((n,s)=>{if(typeof window<"u"&&window.rnDebug){let h=s.map(f=>f instanceof Error&&f.stack?\`\${f.message}
|
|
12
|
+
\${f.stack}\`:f);window.rnDebug(\`\${r} \${n}: \${h.join(" ")}\`)}},"rnDebug");return{logState: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)}}}a(Nt,"createLogger");var Bo=Nt();var q=Bo;function no(r,t,e,i){return(r<t||r>e)&&q.warn(i),Math.min(e,Math.max(t,r))}a(no,"clampWithWarning");function Ct(r,t){return!St.Floor.is(r)||r?.floorStack==null||!St.FloorStack.is(t)?!1:r.floorStack.id!==t.id?(q.warn(\`Floor (\${r.id}) does not belong to floor stack (\${t.id}).\`),!1):!0}a(Ct,"validateFloorForStack");function Zt(r,t,e,i){return no(r,t,e,\`\${i} must be between \${t} and \${e}.\`)}a(Zt,"validateZoomThreshold");var H=Nt("",{prefix:"[DynamicFocus]"});var O,W,et,Gt,Rt=class Rt{constructor(t,e){c(this,et);m(this,"__type","outdoors");c(this,O);c(this,W);u(this,O,t),u(this,W,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(){b(this,et,Gt).call(this,!0)}hide(){b(this,et,Gt).call(this,!1)}destroy(){this.matchesFloorStack(o(this,W).currentFloorStack)||this.hide()}};O=new WeakMap,W=new WeakMap,et=new WeakSet,Gt=a(function(t){for(let e of o(this,O).floors)o(this,W).updateState(e,{visible:t})},"#setVisible"),a(Rt,"Outdoors");var Et=Rt;function so(r,t){let e=r.getByType("floor-stack"),i=e.find(s=>s.type?.toLowerCase()==="outdoor");if(i)return i;let n=e.find(s=>s.facade==null&&!t.has(s.id));return n||(H.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},Pt=.2,Ut=.4;function ko(r,t){return\`\${t} \${r}\`}a(ko,"formatMessage");var jt=class jt extends Error{constructor(t,e=_t){super(ko(t,e)),this.name="MappedinError"}};a(jt,"MappedinError");var vt=jt;var Ao=a(r=>r,"linearEase"),Mo=a(r=>r*r,"quadEaseIn"),xo=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),Do=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Lo=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),_o={linear:Ao,"ease-in":Mo,"ease-out":Do,"ease-in-out":xo,"ease-out-cubic":Lo};function No(r,t){let e=0;if(t.length<2)return e;let n=t[0]<t[1]?(s,h)=>s>h:(s,h)=>s<h;for(;e<t.length-1&&n(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(No,"getInterpolationBreakpoint");function lo(r,t,e,i="ease-in"){if(t.length!==e.length)throw new vt("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),s=(r-t[n])/(t[n+1]-t[n]),h=typeof i=="function"?i(s):_o[i](s);return e[n]+h*(e[n+1]-e[n])}a(lo,"interpolateMulti");var T,it,rt,A,nt,$t=class $t{constructor(t,e,i){m(this,"layers");m(this,"visible");c(this,T);c(this,it,[]);c(this,rt,!1);c(this,A,new Map);m(this,"interpolationFn");c(this,nt,1);this.layers=t,this.visible=e,u(this,T,i)}processLayerGroup(t,e,i){if(!o(this,rt)&&(this.layers.forEach(n=>{let s=t[n];s&&o(this,it).push(...s)}),u(this,rt,!0),this.visible)){let n=[e,i],s=[1,0];this.interpolationFn=h=>lo(h,n,s)}}setOpacity(t){u(this,nt,t);for(let e of o(this,it))if(e.startsWith("img_")){let i=o(this,T).Image3D.getById(e);if(i){let n=o(this,T).getState(i.image);o(this,A).has(e)||o(this,A).set(e,n?.opacity??1);let s=Math.min(o(this,A).get(e),t);o(this,T).updateState(i.image,{opacity:s})}}else{let i=o(this,T).getMapData()?.getById("space",e);if(!i)continue;let n=o(this,T).getState(i);o(this,A).has(e)||o(this,A).set(e,n?.opacity??1);let s=Math.min(o(this,A).get(e),t);o(this,T).updateState(i,{opacity:s,visible:s>0})}}get opacity(){return o(this,nt)}};T=new WeakMap,it=new WeakMap,rt=new WeakMap,A=new WeakMap,nt=new WeakMap,a($t,"LayerGroup");var wt=$t;function zt(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(zt,"runLayerGroupInterpolations");var w,l,_,d,R,P,F,M,U,x,S,K,st,at,lt,B,N,Q,C,Z,p,Yt,uo,co,qt,ut,ct,dt,ht,X,It,ho,fo,D,Ht=class Ht{constructor(t){c(this,p);c(this,w);c(this,l);c(this,_);c(this,d,ao);c(this,R,[]);c(this,P,new Set);c(this,F,new Map);c(this,M);c(this,U,!1);c(this,x,!1);c(this,S,0);c(this,K,0);c(this,st,[]);c(this,at,{});c(this,lt,{});c(this,B,"transition");c(this,N,"outdoor");c(this,Q,[]);c(this,C,!1);c(this,Z,[]);m(this,"sceneUpdateQueue",Promise.resolve());m(this,"on",a((t,e)=>{o(this,w).on(t,e)},"on"));m(this,"off",a((t,e)=>{o(this,w).off(t,e)},"off"));c(this,ut,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Qt(e,this.focusedFacades)&&o(this,N)==="transition"&&!o(this,x))return;u(this,x,!1),u(this,R,[]),o(this,P).clear();let i=o(this,d).isolateBelowGroundView&&o(this,S)<0;if(e.length>0)for(let n of e){let s=o(this,F).get(n.floorStack.id);if(s){if(i&&s.minElevation>=0)continue;o(this,P).add(s.id),o(this,R).push(s)}}o(this,d).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,ct,a(async t=>{if(!this.isEnabled)return;let{floor:e}=t,i=o(this,F).get(e.floorStack.id);i&&(i.activeFloor=e);let n=o(this,d).isolateBelowGroundView&&o(this,S)<0;i?.excluded===!1&&!o(this,M).matchesFloorStack(e.floorStack)&&u(this,S,e.elevation);let s=o(this,d).isolateBelowGroundView&&o(this,S)<0,h=n&&!s;if(o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(h?(u(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,d).autoFocus||(await o(this,D).call(this,e),o(this,w).publish("focus",{facades:this.focusedFacades}))):(await o(this,D).call(this,e),o(this,w).publish("focus",{facades:this.focusedFacades})));let f=i?.floorsAltitudesMap.get(e.elevation)?.altitude??0;o(this,l).options.multiFloorView!=null&&o(this,l).options.multiFloorView?.enabled&&o(this,l).options.multiFloorView?.updateCameraElevationOnFloorChange&&o(this,l).Camera.elevation!==f&&o(this,l).Camera.animateElevation(f,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,dt,a(()=>{u(this,U,!0)},"#handleUserInteractionStart"));c(this,ht,a(()=>{u(this,U,!1)},"#handleUserInteractionEnd"));c(this,X,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Xt(e,o(this,d).indoorZoomThreshold,o(this,d).outdoorZoomThreshold);o(this,B)!==i&&(u(this,B,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),zt(o(this,Z),e)},"#handleCameraChange"));c(this,D,a(async t=>{if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(f=>f.id)||[],s=o(this,l).Navigation?.floorStacks.map(f=>f.id)||[],h=new Promise(async f=>{await this.sceneUpdateQueue;let k=oo({buildings:Array.from(o(this,F).values()),inViewSet:o(this,P),currentFloor:e,zoomState:o(this,B),mode:o(this,d).mode,elevation:o(this,S),floorIdsInNavigation:n,floorStackIdsInNavigation:s,multiFloorView:i,getMultiFloorState:o(this,d).customMultiFloorVisibilityState??Ot.getMultiFloorState,dynamicBuildingInteriors:o(this,d).dynamicBuildingInteriors,isolateBelowGroundView:o(this,d).isolateBelowGroundView,currentElevation:o(this,S),forceInteriorsVisible:o(this,d).forceInteriorsVisible}),v=[];await Promise.all(Array.from(k.values()).map(async G=>{let{building:J,showIndoor:ft,floorStackState:j,facadeState:mt,inFocus:pt,isAboveGroundInIsolation:Tt}=G;v.push(j);let g=eo(J,ft);if(g==="indoor")return b(this,p,ho).call(this,J,j,mt,pt);if(g==="outdoor")return b(this,p,fo).call(this,J,j,mt,s,Tt)})),o(this,l).Outdoor.setOpacity(Jt(v,o(this,d).mode)),u(this,Q,o(this,R).filter(G=>k.get(G.id)?.showIndoor===!0).map(G=>G.facade)),o(this,w).publish("focus",{facades:o(this,Q)}),f()});return this.sceneUpdateQueue=h,h},"#applyBuildingStates"));u(this,w,new Ft),u(this,l,t),H.setLevel(q.logState),u(this,_,o(this,l).getMapData()),u(this,S,o(this,l).currentFloor.elevation),u(this,K,o(this,l).Camera.elevation);for(let e of o(this,_).getByType("facade"))o(this,F).set(e.floorStack.id,new bt(e.floorStack,o(this,l)));b(this,p,co).call(this),u(this,M,new Et(so(o(this,_),o(this,F)),o(this,l))),o(this,l).on("floor-change-start",o(this,ct)),o(this,l).on("camera-change",o(this,X)),o(this,l).on("facades-in-view-change",o(this,ut)),o(this,l).on("user-interaction-start",o(this,dt)),o(this,l).on("user-interaction-end",o(this,ht))}enable(t){if(o(this,C)){H.warn("enable() called on an already enabled Dynamic Focus instance.");return}u(this,C,!0),o(this,l).manualFloorVisibility=!0,o(this,M).show(),this.updateState({...o(this,d),...t}),b(this,p,uo).call(this),o(this,X).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,C)){H.warn("disable() called on an already disabled Dynamic Focus instance.");return}u(this,C,!1),o(this,l).manualFloorVisibility=!1}get isEnabled(){return o(this,C)}get isIndoor(){return o(this,N)==="indoor"}get isOutdoor(){return o(this,N)==="outdoor"}get outdoorsFloorStack(){return o(this,M).floorStack}get layers(){return o(this,st)}get layersBySpaceId(){return o(this,at)}setIndoor(){u(this,N,"indoor"),u(this,B,"in-range"),b(this,p,Yt).call(this)}setOutdoor(){u(this,N,"outdoor"),u(this,B,"out-of-range"),b(this,p,Yt).call(this)}get focusedFacades(){return[...o(this,Q)]}getState(){return{...o(this,d)}}updateState(t){let e=!1,i=o(this,d).isolateBelowGroundView&&o(this,S)<0;if(t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Zt(t.indoorZoomThreshold,t?.outdoorZoomThreshold??o(this,d).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Zt(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,t?.indoorZoomThreshold??o(this,d).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=ro.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,d).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,d).dynamicBuildingInteriors&&(e=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,d).isolateBelowGroundView&&(e=!0),t.forceInteriorsVisible!=null&&t.forceInteriorsVisible!==o(this,d).forceInteriorsVisible&&(e=!0),t.showLabelsAndMarkersOnAllVisibleFloors!=null&&t.showLabelsAndMarkersOnAllVisibleFloors!==o(this,d).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),u(this,d,Object.assign({},o(this,d),Object.fromEntries(Object.entries(t).filter(([,n])=>n!=null)))),t.mode!=null&&t.preloadFloors&&b(this,p,qt).call(this,t.mode),e){let n=o(this,d).isolateBelowGroundView&&o(this,S)<0;i&&!n?(u(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,d).autoFocus||o(this,D).call(this)):o(this,D).call(this)}}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,ut)),o(this,l).off("floor-change-start",o(this,ct)),o(this,l).off("camera-change",o(this,X)),o(this,l).off("user-interaction-start",o(this,dt)),o(this,l).off("user-interaction-end",o(this,ht)),o(this,F).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,w).destroy(),u(this,Z,[])}async focus(t=o(this,d).setFloorOnFocus){if(t)if(io(o(this,K),o(this,l).Camera.elevation,o(this,U)))u(this,K,o(this,l).Camera.elevation),u(this,x,!0);else{let e=to(o(this,R),o(this,M),o(this,B)),i=e?yt(e,o(this,d).mode,o(this,S)):void 0;i&&i.id!==o(this,l).currentFloor.id&&o(this,l).setFloor(i,{context:"dynamic-focus"})}await o(this,D).call(this),o(this,w).publish("focus",{facades:this.focusedFacades})}preloadFloors(){b(this,p,qt).call(this,o(this,d).mode)}setDefaultFloorForStack(t,e){if(!Ct(e,t))return;let i=o(this,F).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,F).get(t.id);e&&(e.defaultFloor=t.defaultFloor)}getDefaultFloorForStack(t){return o(this,F).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!Ct(e,t))return;let i=o(this,F).get(t.id);i&&(i.activeFloor=e,o(this,D).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let n=o(this,F).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,F).get(i.id);n&&(n.excluded=!1)}}getCurrentFloorForStack(t){return o(this,F).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};w=new WeakMap,l=new WeakMap,_=new WeakMap,d=new WeakMap,R=new WeakMap,P=new WeakMap,F=new WeakMap,M=new WeakMap,U=new WeakMap,x=new WeakMap,S=new WeakMap,K=new WeakMap,st=new WeakMap,at=new WeakMap,lt=new WeakMap,B=new WeakMap,N=new WeakMap,Q=new WeakMap,C=new WeakMap,Z=new WeakMap,p=new WeakSet,Yt=a(function(){o(this,d).autoFocus&&(o(this,U)?this.focus():u(this,x,!0)),o(this,w).publish("state-change")},"#handleViewStateChange"),uo=a(function(){u(this,Z,[]);for(let t of o(this,d).dynamicLayers){let e=new wt([t],!0,o(this,l));e.processLayerGroup(o(this,lt),o(this,d).outdoorZoomThreshold,o(this,d).indoorZoomThreshold),o(this,Z).push(e)}zt(o(this,Z),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),co=a(function(){let t=o(this,_).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(n=>{e[n.name]||(e[n.name]=[]),e[n.name].push(...n.spaces.map(({spaceId:s})=>s));for(let{spaceId:s}of n.spaces)i[s]==null&&(i[s]=[]),i[s].push(n.name)}),u(this,st,t.map(({name:n})=>n)),u(this,at,i),u(this,lt,e)},"#setupLayers"),qt=a(function(t){o(this,l).preloadFloors(o(this,_).getByType("facade").map(e=>yt(o(this,F).get(e.floorStack.id),t,o(this,S))).filter(e=>e!=null&&Ot.Floor.is(e)))},"#preloadFloors"),ut=new WeakMap,ct=new WeakMap,dt=new WeakMap,ht=new WeakMap,X=new WeakMap,It=a(function(t,e,i,n=!1){t.forEach(s=>{if(s.floor)if(e){let f=i!==void 0&&!n?{...s.state,labels:{...s.state.labels,enabled:s.state.labels.enabled&&i},markers:{...s.state.markers,enabled:s.state.markers.enabled&&i},occlusion:{...s.state.occlusion,enabled:s.state.occlusion.enabled&&i}}:s.state;o(this,l).updateState(s.floor,f)}else o(this,l).updateState(s.floor,{visible:!1})})},"#updateFloorVisibility"),ho=a(async function(t,e,i,n){return b(this,p,It).call(this,e.floorStates,!0,n,o(this,d).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,d).indoorAnimationOptions)},"#animateIndoorSequence"),fo=a(async function(t,e,i,n,s){let h=s;h&&b(this,p,It).call(this,e.floorStates,!1,void 0,o(this,d).showLabelsAndMarkersOnAllVisibleFloors);let f=await t.animateFacade(i.state,o(this,d).outdoorAnimationOptions);return f.result==="completed"&&!h&&b(this,p,It).call(this,e.floorStates,Lt({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,B)==="in-range",inFocus:o(this,P).has(t.id),mode:o(this,d).mode,elevation:o(this,S),inNavigation:n.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,d).dynamicBuildingInteriors,forceInteriorsVisible:o(this,d).forceInteriorsVisible}),void 0,o(this,d).showLabelsAndMarkersOnAllVisibleFloors),f},"#animateOutdoorSequence"),D=new WeakMap,a(Ht,"DynamicFocus");var Vt=Ht;var mo=a((r,t)=>{let e={initialVisibility:t.initialVisibility??"outdoor-first",layersBySpaceId:t.layersBySpaceId??{},focusLayers:t.focusLayers??[],defaultFloor:t.defaultFloor??r.currentFloor},i=Co(r,e),n=i+Ut,s=i+Pt;return e.initialVisibility==="indoor-first"&&(n=i-Pt,s=i-Ut),{indoorZoomThreshold:n,outdoorZoomThreshold:s}},"calculateZoomThresholds");function Co(r,t){let e=r.getMapData();if(t.focusLayers.length){let h=e.getByType("space").filter(f=>{let k=t.layersBySpaceId[f.id]?.[0];return typeof k=="string"&&f.floor.id===t.defaultFloor?.id&&t.focusLayers.indexOf(k)!==-1});if(h.length){let f=r.Camera.getFocusOnTransform(h,{}).zoomLevel;if(f!==void 0)return f}}let i=e.getByType("floor-stack"),n=1/0;for(let s of i)for(let h of s.floors){let f=r.Camera.getFocusOnTransform(h,{}).zoomLevel??1/0;f<n&&(n=f)}return n!==1/0?n:r.Camera.getFocusOnTransform(t.defaultFloor,{}).zoomLevel??0}a(Co,"getDefaultZoomLevel");return Vo(Zo);})();
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
// Register the extension
|
|
@@ -22,4 +22,4 @@ if (window.bridge && window.bridge.extensions) {
|
|
|
22
22
|
}
|
|
23
23
|
} else {
|
|
24
24
|
if (window.rnDebug) window.rnDebug('Bridge or extensions not available for registration');
|
|
25
|
-
}`;function S(){return
|
|
25
|
+
}`;function S(){return j}l(S,"getRegistrationScript");function m(){R({extensionName:"dynamic-focus",getRegistrationScript:S,logger:F})}l(m,"useDynamicFocusRegistration");function b(e,i){if(typeof e!="string"||e.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof i!="function")throw new Error("Callback parameter must be a function");const o=W(Z),{extensions:s,mapData:t}=o;if(!t)throw new Error("Map data is not available");m();const f=(s?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",a=_(d=>{try{let u=d;e==="focus"&&d.facades&&(u={...d,facades:v(t,d.facades)}),i(u)}catch(u){F.error(`Error in dynamic focus event callback for ${String(e)}:`,u)}},[e,t,i]);G({eventKey:`dynamic-focus:${String(e)}`,callback:a,setupScript:l(()=>N({extensionName:"dynamic-focus",eventName:String(e)}),"setupScript"),cleanupScript:l(()=>$({extensionName:"dynamic-focus",eventName:String(e)}),"cleanupScript"),shouldInject:f})}l(b,"useDynamicFocusEvent");function k(){const e=A(L),{bridge:i,extensions:o,updateExtensionState:s}=e;m();const t=o["dynamic-focus"],c=t?.registrationState||"unregistered",f=c==="registered",a=t?.isEnabled||!1,[d,u]=V(t?.focusedFacades||[]),y=T(o);y.current=o,b("focus",h(n=>{const p=n.facades;u(p),s("dynamic-focus",w=>({...w,registrationState:c,focusedFacades:p}))},[c,s]));const r=h(async(n,p=[])=>{if(!i?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await i.instruct({type:"extension",payload:{name:"dynamic-focus",method:n,args:p}})},[i]),M=h(async n=>{y.current?.["dynamic-focus"]?.isEnabled||(await r("enable",[n]),s("dynamic-focus",C=>({...C,isEnabled:!0})))},[r,s]),E=h(async n=>await r("updateState",[n]),[r]),I=h(async()=>await r("getState"),[r]),x=h(async n=>await r("focus",[n]),[r]),O=h(async()=>{await r("disable"),u([]),s("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[r,u,s]);return{isReady:f,isEnabled:a,focusedFacades:d,updateState:E,getState:I,focus:x,disable:O,enable:M}}l(k,"useDynamicFocus");export{k as useDynamicFocus,b as useDynamicFocusEvent};
|
package/lib/rn/types.d.ts
CHANGED
|
@@ -147,6 +147,11 @@ export type BuildingState = {
|
|
|
147
147
|
inFocus: boolean;
|
|
148
148
|
floorToShow: Floor | undefined;
|
|
149
149
|
facadeState: BuildingFacadeState;
|
|
150
|
+
/**
|
|
151
|
+
* True when viewing below ground and this building is above ground only.
|
|
152
|
+
* Used to skip animations and hide the building immediately.
|
|
153
|
+
*/
|
|
154
|
+
isAboveGroundInIsolation: boolean;
|
|
150
155
|
};
|
|
151
156
|
export type ZoomState = 'in-range' | 'out-of-range' | 'transition';
|
|
152
157
|
export type ViewState = 'indoor' | 'outdoor' | 'transition';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/dynamic-focus",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.14.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-sdk": "^6.
|
|
42
|
-
"@mappedin/react-
|
|
40
|
+
"@mappedin/mappedin-js": "^6.14.0",
|
|
41
|
+
"@mappedin/react-native-sdk": "^6.14.0",
|
|
42
|
+
"@mappedin/react-sdk": "^6.14.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@mappedin/react-sdk": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var zt=Object.defineProperty,bo=Object.defineProperties;var Fo=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols;var yo=Object.prototype.hasOwnProperty,So=Object.prototype.propertyIsEnumerable;var Wt=r=>{throw TypeError(r)};var Ot=(r,t,e)=>t in r?zt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_=(r,t)=>{for(var e in t||(t={}))yo.call(t,e)&&Ot(r,e,t[e]);if(Ht)for(var e of Ht(t))So.call(t,e)&&Ot(r,e,t[e]);return r},rt=(r,t)=>bo(r,Fo(t)),a=(r,t)=>zt(r,"name",{value:t,configurable:!0});var g=(r,t,e)=>Ot(r,typeof t!="symbol"?t+"":t,e),Tt=(r,t,e)=>t.has(r)||Wt("Cannot "+e);var o=(r,t,e)=>(Tt(r,t,"read from private field"),e?e.call(r):t.get(r)),c=(r,t,e)=>t.has(r)?Wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),d=(r,t,e,i)=>(Tt(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),v=(r,t,e)=>(Tt(r,t,"access private method"),e);var S={env:{NODE_ENV:"production",npm_package_version:"6.13.0-beta.0"}};import{Floor as Zo,getMultiFloorState as Go}from"@mappedin/mappedin-js";function Kt(r,t){if(r==null||t==null)return r===t;if(r.length!==t.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}a(Kt,"arraysEqual");var Vt=class Vt{constructor(){g(this,"_subscribers",{});g(this,"_abortController",new AbortController);g(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 n=a(()=>this.off(t,e),"cleanup");return s&&s.addEventListener("abort",n,{once:!0}),this._cleanupFunctions.push(n),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){if(!this.signal.aborted){for(let t of this._cleanupFunctions)t();this._cleanupFunctions=[],this._subscribers={},this._abortController.abort()}}};a(Vt,"PubSub");var St=Vt;import{Facade as vo,Floor as wo,FloorStack as ko}from"@mappedin/mappedin-js";var k,nt,L,w,E,B,H,z,xt=class xt{constructor(t,e){g(this,"__type","building");c(this,k);c(this,nt,new Map);c(this,L,new Map);c(this,w,[]);c(this,E);c(this,B);g(this,"defaultFloor");g(this,"activeFloor");g(this,"excluded",!1);g(this,"floorsAltitudesMap",new Map);g(this,"aboveGroundFloors",[]);c(this,H);c(this,z);var s;d(this,k,t),d(this,nt,new Map(t.floors.map(n=>[n.id,n]))),d(this,L,new Map(t.floors.map(n=>[n.elevation,n]))),d(this,w,Array.from(o(this,L).values()).sort((n,h)=>n.elevation-h.elevation)),this.defaultFloor=t.defaultFloor,this.activeFloor=this.defaultFloor,d(this,E,e),this.aboveGroundFloors=o(this,w).filter(n=>n.elevation>=0);let i=(s=t.facade)==null?void 0:s.spaces.map(n=>o(this,E).getState(n)).sort((n,h)=>n.altitude-h.altitude);if(i&&i.length===this.aboveGroundFloors.length)for(let n in this.aboveGroundFloors){let h=this.aboveGroundFloors[n],u=i[n];this.floorsAltitudesMap.set(h.elevation,{altitude:u.altitude,effectiveHeight:u.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,E).currentFloorStack.id}get isIndoor(){let t=o(this,E).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,H)==null&&d(this,H,Math.max(...o(this,L).keys())),o(this,H)}get minElevation(){return o(this,z)==null&&d(this,z,Math.min(...o(this,L).keys())),o(this,z)}has(t){return wo.is(t)?o(this,nt).has(t.id):ko.is(t)?t.id===o(this,k).id:vo.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,L).get(t)}getNearestFloorByElevation(t){let e=this.getFloorByElevation(t);if(e)return e;if(t>=0){if(t>this.maxElevation)return o(this,w)[o(this,w).length-1];for(let i=o(this,w).length-1;i>=0;i--){let s=o(this,w)[i];if(s.elevation<=t)return s}}else{if(t<this.minElevation)return o(this,w)[0];for(let i of o(this,w))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,w)[o(this,w).length-1]}cancelAnimation(){o(this,B)&&(o(this,B).animation.cancel(),d(this,B,void 0))}async animateFacade(t,e={duration:150}){var h;let i=((h=o(this,B))==null?void 0:h.state)||o(this,E).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:n}=t;if(o(this,E).updateState(this.facade,{visible:!0}),s!==void 0){d(this,B,{animation:o(this,E).animateState(this.facade,{opacity:s},{duration:e.duration}),state:t});let u=await o(this,B).animation;if(d(this,B,void 0),u.result==="cancelled")return u}return n===!1&&o(this,E).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,k).floors.forEach(t=>{o(this,E).updateState(t,{visible:t.id===o(this,E).currentFloor.id})}),this.has(o(this,E).currentFloor)||o(this,E).updateState(this.facade,{visible:!0,opacity:1})}};k=new WeakMap,nt=new WeakMap,L=new WeakMap,w=new WeakMap,E=new WeakMap,B=new WeakMap,H=new WeakMap,z=new WeakMap,a(xt,"Building");var Et=xt;function Qt(r,t,e){return r>=t?"in-range":r<=e?"out-of-range":"transition"}a(Qt,"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}a(vt,"getFloorToShow");function Io(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}}}a(Io,"getFacadeState");function Ao(r,t,e){return{outdoorOpacity:"initial",floorStates:r.floors.map(i=>{let n=i.id===t.id&&e;return{floor:i,state:{type:"floor",visible:n,geometry:{visible:n},labels:{enabled:n},markers:{enabled:n},footprint:{visible:!1},occlusion:{enabled:!1}}}})}}a(Ao,"getSingleBuildingState");function Xt(r,t){if(!t.includes("lock-elevation"))return"initial";for(let e of r)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(Xt,"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}}a(Jt,"getSetFloorTargetFromZoomState");function to(r){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:s,mode:n,elevation:h,floorIdsInNavigation:u,floorStackIdsInNavigation:p,multiFloorView:m,getMultiFloorState:P,dynamicBuildingInteriors:bt,isolateBelowGroundView:ot,currentElevation:et,forceInteriorsVisible:R}=r,V=new Map,At=ot&&et<0;for(let b of t){let it=e.has(b.id),Ft=At&&b.minElevation>=0,yt=Ft?!1:it,Bt=Ft?!1:Dt({building:b,currentFloor:i,inRange:s==="in-range",inFocus:it,mode:n,elevation:h,inNavigation:p.includes(b.id),dynamicBuildingInteriors:bt,forceInteriorsVisible:R}),Mt=i.floorStack.id===b.id?b.activeFloor:vt(b,n,h),mo=m!=null&&m.enabled?P(b.floors,Mt||b.activeFloor,m==null?void 0:m.floorGap,u,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}):Ao(b.floorStack,Mt||b.activeFloor,Bt),po=ot&&et<0&&s==="in-range",go=Io(b.facade,Bt,po);V.set(b.id,{building:b,showIndoor:Bt,floorStackState:mo,facadeState:go,inFocus:yt,floorToShow:Mt})}return V}a(to,"getBuildingStates");function oo(r,t){return r.excluded?"none":t?"indoor":"outdoor"}a(oo,"getBuildingAnimationType");function Dt(r){let{building:t,currentFloor:e,inRange:i,inFocus:s,mode:n,elevation:h,inNavigation:u,dynamicBuildingInteriors:p,forceInteriorsVisible:m}=r;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(m===!0||u===!0)return!0;if(!p)return e.floorStack.type!=="Outdoor";if(!i||!s)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(h)!=null;default:break}return!0}a(Dt,"shouldShowIndoor");function eo(r,t,e){return r!==t&&!e}a(eo,"shouldDeferSetFloor");var io=["default-floor","lock-elevation","nearest-elevation"];import{Floor as Mo,FloorStack as Oo}from"@mappedin/mappedin-js";var _t="[MappedinJS]";function Lt(r="",{prefix:t=_t}={}){let e="".concat(t).concat(r?"-".concat(r):""),i=a((s,n)=>{if(typeof window<"u"&&window.rnDebug){let h=n.map(u=>u instanceof Error&&u.stack?"".concat(u.message,"\n").concat(u.stack):u);window.rnDebug("".concat(r," ").concat(s,": ").concat(h.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(Lt,"createLogger");var Bo=Lt();var W=Bo;function ro(r,t,e,i){return(r<t||r>e)&&W.warn(i),Math.min(e,Math.max(t,r))}a(ro,"clampWithWarning");function Nt(r,t){return!Mo.is(r)||(r==null?void 0:r.floorStack)==null||!Oo.is(t)?!1:r.floorStack.id!==t.id?(W.warn("Floor (".concat(r.id,") does not belong to floor stack (").concat(t.id,").")),!1):!0}a(Nt,"validateFloorForStack");function Ct(r,t,e,i){return ro(r,t,e,"".concat(i," must be between ").concat(t," and ").concat(e,"."))}a(Ct,"validateZoomThreshold");var K=Lt("",{prefix:"[DynamicFocus]"});var M,Q,st,Zt,Gt=class Gt{constructor(t,e){c(this,st);g(this,"__type","outdoors");c(this,M);c(this,Q);d(this,M,t),d(this,Q,e)}get id(){return o(this,M).id}get floorStack(){return o(this,M)}get floor(){return o(this,M).defaultFloor}matchesFloorStack(t){return t===o(this,M)||t===o(this,M).id}show(){v(this,st,Zt).call(this,!0)}hide(){v(this,st,Zt).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};M=new WeakMap,Q=new WeakMap,st=new WeakSet,Zt=a(function(t){for(let e of o(this,M).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(Gt,"Outdoors");var wt=Gt;function no(r,t){var h;let e=r.getByType("floor-stack"),i=e.find(u=>{var p;return((p=u.type)==null?void 0:p.toLowerCase())==="outdoor"}),s=(h=r.getByType("enterprise-venue"))==null?void 0:h.defaultFloor;if(s){let u=r.getById("floor",s);if(u)return u.floorStack}if(i)return i;let n=e.find(u=>u.facade==null&&!t.has(u.id));return n||(K.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(no,"getOutdoorFloorStack");var so={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},we=.2,ke=.4;function To(r,t){return"".concat(t," ").concat(r)}a(To,"formatMessage");var Pt=class Pt extends Error{constructor(t,e=_t){super(To(t,e)),this.name="MappedinError"}};a(Pt,"MappedinError");var kt=Pt;var Vo=a(r=>r,"linearEase"),xo=a(r=>r*r,"quadEaseIn"),Do=a(r=>1-Math.cos(r*Math.PI/2),"easeIn"),_o=a(r=>1-(1-r)*(1-r),"quadEaseOut"),Lo=a(r=>1-Math.pow(1-r,3),"cubicEaseOut"),No={linear:Vo,"ease-in":xo,"ease-out":_o,"ease-in-out":Do,"ease-out-cubic":Lo};function Co(r,t){let e=0;if(t.length<2)return e;let s=t[0]<t[1]?(n,h)=>n>h:(n,h)=>n<h;for(;e<t.length-1&&s(r,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Co,"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 s=Co(r,t),n=(r-t[s])/(t[s+1]-t[s]),h=typeof i=="function"?i(n):No[i](n);return e[s]+h*(e[s+1]-e[s])}a(ao,"interpolateMulti");var O,at,lt,x,ut,Ut=class Ut{constructor(t,e,i){g(this,"layers");g(this,"visible");c(this,O);c(this,at,[]);c(this,lt,!1);c(this,x,new Map);g(this,"interpolationFn");c(this,ut,1);this.layers=t,this.visible=e,d(this,O,i)}processLayerGroup(t,e,i){if(!o(this,lt)&&(this.layers.forEach(s=>{let n=t[s];n&&o(this,at).push(...n)}),d(this,lt,!0),this.visible)){let s=[e,i],n=[1,0];this.interpolationFn=h=>ao(h,s,n)}}setOpacity(t){var e,i,s;d(this,ut,t);for(let n of o(this,at))if(n.startsWith("img_")){let h=o(this,O).Image3D.getById(n);if(h){let u=o(this,O).getState(h.image);o(this,x).has(n)||o(this,x).set(n,(e=u==null?void 0:u.opacity)!=null?e:1);let p=Math.min(o(this,x).get(n),t);o(this,O).updateState(h.image,{opacity:p})}}else{let h=(i=o(this,O).getMapData())==null?void 0:i.getById("space",n);if(!h)continue;let u=o(this,O).getState(h);o(this,x).has(n)||o(this,x).set(n,(s=u==null?void 0:u.opacity)!=null?s:1);let p=Math.min(o(this,x).get(n),t);o(this,O).updateState(h,{opacity:p,visible:p>0})}}get opacity(){return o(this,ut)}};O=new WeakMap,at=new WeakMap,lt=new WeakMap,x=new WeakMap,ut=new WeakMap,a(Ut,"LayerGroup");var It=Ut;function Rt(r,t){r.forEach(e=>{if(e.interpolationFn!=null){let i=e.interpolationFn(t);i!=null&&(e.setOpacity(i),e.visible=i===1)}})}a(Rt,"runLayerGroupInterpolations");var I,l,N,f,U,j,y,D,$,Y,A,X,ct,dt,ht,T,C,J,Z,G,F,jt,uo,co,$t,ft,mt,pt,gt,tt,Yt,ho,fo,q,qt=class qt{constructor(t){c(this,F);c(this,I);c(this,l);c(this,N);c(this,f,so);c(this,U,[]);c(this,j,new Set);c(this,y,new Map);c(this,D);c(this,$,!1);c(this,Y,!1);c(this,A,0);c(this,X,0);c(this,ct,[]);c(this,dt,{});c(this,ht,{});c(this,T,"transition");c(this,C,"outdoor");c(this,J,[]);c(this,Z,!1);c(this,G,[]);g(this,"sceneUpdateQueue",Promise.resolve());g(this,"on",a((t,e)=>{o(this,I).on(t,e)},"on"));g(this,"off",a((t,e)=>{o(this,I).off(t,e)},"off"));c(this,ft,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;if(Kt(e,this.focusedFacades)&&o(this,C)==="transition"&&!o(this,Y))return;d(this,Y,!1),d(this,U,[]),o(this,j).clear();let i=o(this,f).isolateBelowGroundView&&o(this,A)<0;if(e.length>0)for(let s of e){let n=o(this,y).get(s.floorStack.id);if(n){if(i&&n.minElevation>=0)continue;o(this,j).add(n.id),o(this,U).push(n)}}o(this,f).autoFocus&&this.focus()},"#handleFacadesInViewChange"));c(this,mt,a(async t=>{var s,n,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,D).matchesFloorStack(e.floorStack)&&d(this,A,e.elevation),o(this,l).manualFloorVisibility===!0){t.reason!=="dynamic-focus"&&(await o(this,q).call(this,e),o(this,I).publish("focus",{facades:this.focusedFacades}));let p=(n=(s=i==null?void 0:i.floorsAltitudesMap.get(e.elevation))==null?void 0:s.altitude)!=null?n: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!==p&&o(this,l).Camera.animateElevation(p,{duration:750,easing:"ease-in-out"})}},"#handleFloorChangeStart"));c(this,pt,a(()=>{d(this,$,!0)},"#handleUserInteractionStart"));c(this,gt,a(()=>{d(this,$,!1)},"#handleUserInteractionEnd"));c(this,tt,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=Qt(e,o(this,f).indoorZoomThreshold,o(this,f).outdoorZoomThreshold);o(this,T)!==i&&(d(this,T,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor()),Rt(o(this,G),e)},"#handleCameraChange"));c(this,q,a(async t=>{var u,p,m;if(o(this,l).manualFloorVisibility!==!0||!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).options.multiFloorView,s=((p=(u=o(this,l).Navigation)==null?void 0:u.floors)==null?void 0:p.map(P=>P.id))||[],n=((m=o(this,l).Navigation)==null?void 0:m.floorStacks.map(P=>P.id))||[],h=new Promise(async P=>{var et;await this.sceneUpdateQueue;let bt=to({buildings:Array.from(o(this,y).values()),inViewSet:o(this,j),currentFloor:e,zoomState:o(this,T),mode:o(this,f).mode,elevation:o(this,A),floorIdsInNavigation:s,floorStackIdsInNavigation:n,multiFloorView:i,getMultiFloorState:(et=o(this,f).customMultiFloorVisibilityState)!=null?et:Go,dynamicBuildingInteriors:o(this,f).dynamicBuildingInteriors,isolateBelowGroundView:o(this,f).isolateBelowGroundView,currentElevation:o(this,A),forceInteriorsVisible:o(this,f).forceInteriorsVisible}),ot=[];await Promise.all(Array.from(bt.values()).map(async R=>{let{building:V,showIndoor:At,floorStackState:b,facadeState:it,inFocus:Ft}=R;ot.push(b);let yt=oo(V,At);if(yt==="indoor")return v(this,F,ho).call(this,V,b,it,Ft);if(yt==="outdoor")return v(this,F,fo).call(this,V,b,it,n)})),o(this,l).Outdoor.setOpacity(Xt(ot,o(this,f).mode)),d(this,J,o(this,U).filter(R=>{var V;return((V=bt.get(R.id))==null?void 0:V.showIndoor)===!0}).map(R=>R.facade)),o(this,I).publish("focus",{facades:o(this,J)}),P()});return this.sceneUpdateQueue=h,h},"#applyBuildingStates"));d(this,I,new St),d(this,l,t),K.setLevel(W.logState),d(this,N,o(this,l).getMapData()),d(this,A,o(this,l).currentFloor.elevation),d(this,X,o(this,l).Camera.elevation);for(let e of o(this,N).getByType("facade"))o(this,y).set(e.floorStack.id,new Et(e.floorStack,o(this,l)));v(this,F,co).call(this),d(this,D,new wt(no(o(this,N),o(this,y)),o(this,l))),o(this,l).on("floor-change-start",o(this,mt)),o(this,l).on("camera-change",o(this,tt)),o(this,l).on("facades-in-view-change",o(this,ft)),o(this,l).on("user-interaction-start",o(this,pt)),o(this,l).on("user-interaction-end",o(this,gt))}enable(t){if(o(this,Z)){K.warn("enable() called on an already enabled Dynamic Focus instance.");return}d(this,Z,!0),o(this,l).manualFloorVisibility=!0,o(this,D).show(),this.updateState(_(_({},o(this,f)),t)),v(this,F,uo).call(this),o(this,tt).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)){K.warn("disable() called on an already disabled Dynamic Focus instance.");return}d(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,D).floorStack}get layers(){return o(this,ct)}get layersBySpaceId(){return o(this,dt)}setIndoor(){d(this,C,"indoor"),d(this,T,"in-range"),v(this,F,jt).call(this)}setOutdoor(){d(this,C,"outdoor"),d(this,T,"out-of-range"),v(this,F,jt).call(this)}get focusedFacades(){return[...o(this,J)]}getState(){return _({},o(this,f))}updateState(t){var i,s;let e=!1;t.indoorZoomThreshold!=null&&(t.indoorZoomThreshold=Ct(t.indoorZoomThreshold,(i=t==null?void 0:t.outdoorZoomThreshold)!=null?i:o(this,f).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),t.outdoorZoomThreshold!=null&&(t.outdoorZoomThreshold=Ct(t.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,(s=t==null?void 0:t.indoorZoomThreshold)!=null?s:o(this,f).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),t.mode!=null&&(t.mode=io.includes(t.mode)?t.mode:"default-floor"),t.autoAdjustFacadeHeights!=null&&(o(this,f).autoAdjustFacadeHeights=t.autoAdjustFacadeHeights),t.dynamicBuildingInteriors!=null&&t.dynamicBuildingInteriors!==o(this,f).dynamicBuildingInteriors&&(e=!0),t.isolateBelowGroundView!=null&&t.isolateBelowGroundView!==o(this,f).isolateBelowGroundView&&(e=!0),t.forceInteriorsVisible!=null&&t.forceInteriorsVisible!==o(this,f).forceInteriorsVisible&&(e=!0),t.showLabelsAndMarkersOnAllVisibleFloors!=null&&t.showLabelsAndMarkersOnAllVisibleFloors!==o(this,f).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d(this,f,Object.assign({},o(this,f),Object.fromEntries(Object.entries(t).filter(([,n])=>n!=null)))),t.mode!=null&&t.preloadFloors&&v(this,F,$t).call(this,t.mode),e&&o(this,q).call(this)}destroy(){this.disable(),o(this,l).off("facades-in-view-change",o(this,ft)),o(this,l).off("floor-change-start",o(this,mt)),o(this,l).off("camera-change",o(this,tt)),o(this,l).off("user-interaction-start",o(this,pt)),o(this,l).off("user-interaction-end",o(this,gt)),o(this,y).forEach(t=>t.destroy()),o(this,D).destroy(),o(this,I).destroy(),d(this,G,[])}async focus(t=o(this,f).setFloorOnFocus){if(t)if(eo(o(this,X),o(this,l).Camera.elevation,o(this,$)))d(this,X,o(this,l).Camera.elevation),d(this,Y,!0);else{let e=Jt(o(this,U),o(this,D),o(this,T)),i=e?vt(e,o(this,f).mode,o(this,A)):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,I).publish("focus",{facades:this.focusedFacades})}preloadFloors(){v(this,F,$t).call(this,o(this,f).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 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)}};I=new WeakMap,l=new WeakMap,N=new WeakMap,f=new WeakMap,U=new WeakMap,j=new WeakMap,y=new WeakMap,D=new WeakMap,$=new WeakMap,Y=new WeakMap,A=new WeakMap,X=new WeakMap,ct=new WeakMap,dt=new WeakMap,ht=new WeakMap,T=new WeakMap,C=new WeakMap,J=new WeakMap,Z=new WeakMap,G=new WeakMap,F=new WeakSet,jt=a(function(){o(this,f).autoFocus&&(o(this,$)?this.focus():d(this,Y,!0)),o(this,I).publish("state-change")},"#handleViewStateChange"),uo=a(function(){d(this,G,[]);for(let t of o(this,f).dynamicLayers){let e=new It([t],!0,o(this,l));e.processLayerGroup(o(this,ht),o(this,f).outdoorZoomThreshold,o(this,f).indoorZoomThreshold),o(this,G).push(e)}Rt(o(this,G),o(this,l).Camera.zoomLevel)},"#initializeLayerGroups"),co=a(function(){var s,n,h;let t=(h=(n=(s=o(this,N).internal.mvf)==null?void 0:s.enterprise)==null?void 0:n.layers)!=null?h:[],e={},i={};t.forEach(u=>{e[u.name]||(e[u.name]=[]),e[u.name].push(...u.spaces.map(({spaceId:p})=>p));for(let{spaceId:p}of u.spaces)i[p]==null&&(i[p]=[]),i[p].push(u.name)}),d(this,ct,t.map(({name:u})=>u)),d(this,dt,i),d(this,ht,e)},"#setupLayers"),$t=a(function(t){o(this,l).preloadFloors(o(this,N).getByType("facade").map(e=>vt(o(this,y).get(e.floorStack.id),t,o(this,A))).filter(e=>e!=null&&Zo.is(e)))},"#preloadFloors"),ft=new WeakMap,mt=new WeakMap,pt=new WeakMap,gt=new WeakMap,tt=new WeakMap,Yt=a(function(t,e,i,s=!1){t.forEach(n=>{if(n.floor)if(e){let u=i!==void 0&&!s?rt(_({},n.state),{labels:rt(_({},n.state.labels),{enabled:n.state.labels.enabled&&i}),markers:rt(_({},n.state.markers),{enabled:n.state.markers.enabled&&i}),occlusion:rt(_({},n.state.occlusion),{enabled:n.state.occlusion.enabled&&i})}):n.state;o(this,l).updateState(n.floor,u)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),ho=a(async function(t,e,i,s){return v(this,F,Yt).call(this,e.floorStates,!0,s,o(this,f).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,f).indoorAnimationOptions)},"#animateIndoorSequence"),fo=a(async function(t,e,i,s){let n=await t.animateFacade(i.state,o(this,f).outdoorAnimationOptions);return n.result==="completed"&&v(this,F,Yt).call(this,e.floorStates,Dt({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,T)==="in-range",inFocus:o(this,j).has(t.id),mode:o(this,f).mode,elevation:o(this,A),inNavigation:s.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,f).dynamicBuildingInteriors,forceInteriorsVisible:o(this,f).forceInteriorsVisible}),void 0,o(this,f).showLabelsAndMarkersOnAllVisibleFloors),n},"#animateOutdoorSequence"),q=new WeakMap,a(qt,"DynamicFocus");var lo=qt;export{a,we as b,ke as c,lo as d};
|