@mappedin/dynamic-focus 6.25.0-beta.0 → 6.27.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var it=Object.defineProperty;var rt=s=>{throw TypeError(s)};var At=(s,t,e)=>t in s?it(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t)=>it(s,"name",{value:t,configurable:!0});var E=(s,t,e)=>At(s,typeof t!="symbol"?t+"":t,e),No=(s,t,e)=>t.has(s)||rt("Cannot "+e);var o=(s,t,e)=>(No(s,t,"read from private field"),e?e.call(s):t.get(s)),c=(s,t,e)=>t.has(s)?rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),h=(s,t,e,i)=>(No(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e),g=(s,t,e)=>(No(s,t,"access private method"),e);var y={env:{NODE_ENV:"production",npm_package_version:"6.
|
|
2
|
-
${p.stack}`:p);window.rnDebug(`${s} ${r}: ${f.join(" ")}`)}},"rnDebug");return{logState:y.env.NODE_ENV==="test"?4:1,debug(...r){this.logState<=0&&(console.debug(e,...r),i("debug",r))},log(...r){this.debug(...r)},info(...r){this.logState<=1&&(console.info(e,...r),i("info",r))},warn(...r){this.logState<=2&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=3&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){let n=typeof r=="string"?Bt(r):r;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${r}"`);return}this.logState=n}}}a(Go,"createLogger");var Dt=Go();var q=Dt;var V=Go("",{prefix:"[DynamicFocus]"});var st=a((s,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Lt(s,e);if(i===void 0)return V.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:io.indoorZoomThreshold,outdoorZoomThreshold:io.outdoorZoomThreshold};let r=i+xo,n=i+ro;return e.initialVisibility==="indoor-first"&&(r=i-ro,n=i-xo),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Lt(s,t){let i=s.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),r=1/0,n;for(let f of i){let p=s.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<r&&(r=p,n=f)}if(r!==1/0)return t.debug&&n&&s.Camera.getFocusOnTransform(n,{debugColor:"blue"}),r}a(Lt,"getDefaultZoomLevel");import{Floor as qt,getMultiFloorState as Ht}from"@mappedin/mappedin-js";function nt(s,t){if(s==null||t==null)return s===t;if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}a(nt,"arraysEqual");var Ro=class Ro{_subscribers={};_abortController=new AbortController;get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let r=i?.signal;if(r?.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 r&&r.addEventListener("abort",n,{once:!0}),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(Ro,"PubSub");var vo=Ro;import{Facade as Mt,Floor as Zt,FloorStack as _t}from"@mappedin/mappedin-js";var I,so,R,w,v,k,H,K,Po=class Po{constructor(t,e){E(this,"__type","building");c(this,I);c(this,so,new Map);c(this,R,new Map);c(this,w,[]);c(this,v);c(this,k);E(this,"defaultFloor");E(this,"activeFloor");E(this,"excluded",!1);E(this,"aboveGroundFloors",[]);c(this,H);c(this,K);h(this,I,t),h(this,so,new Map(t.floors.map(r=>[r.id,r]))),h(this,R,new Map(t.floors.map(r=>[r.elevation,r]))),h(this,w,Array.from(o(this,R).values()).sort((r,n)=>r.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,h(this,v,e),this.aboveGroundFloors=o(this,w).filter(r=>r.elevation>=0)}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,v).currentFloorStack.id}get isIndoor(){let t=o(this,v).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,H)==null&&h(this,H,Math.max(...o(this,R).keys())),o(this,H)}get minElevation(){return o(this,K)==null&&h(this,K,Math.min(...o(this,R).keys())),o(this,K)}has(t){return Zt.is(t)?o(this,so).has(t.id):_t.is(t)?t.id===o(this,I).id:Mt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,R).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 r=o(this,w)[i];if(r.elevation<=t)return r}}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,k)&&(o(this,k).animation.cancel(),h(this,k,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,k)?.state||o(this,v).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:n}=t;if(o(this,v).updateState(this.facade,{visible:!0}),r!==void 0){h(this,k,{animation:o(this,v).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let f=await o(this,k).animation;if(h(this,k,void 0),f.result==="cancelled")return f}return n===!1&&o(this,v).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,I).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})}};I=new WeakMap,so=new WeakMap,R=new WeakMap,w=new WeakMap,v=new WeakMap,k=new WeakMap,H=new WeakMap,K=new WeakMap,a(Po,"Building");var wo=Po;function at(s,t,e){return s>=t?"in-range":s<=e?"out-of-range":"transition"}a(at,"getZoomState");function Oo(s,t,e){if(s.__type==="outdoors"&&"floor"in s)return s.floor;let i=s;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Oo,"getFloorToShow");function Nt(s,t,e,i){return i?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:s,state:{type:"facade",visible:!0,opacity:.2}}:{facade:s,state:{type:"facade",visible:!0,opacity:1}}}a(Nt,"getFacadeState");function xt(s,t,e){return{outdoorOpacity:"initial",floorStates:s.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(xt,"getSingleBuildingState");function lt(s,t){if(!t.includes("lock-elevation"))return"initial";for(let e of s)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(lt,"getOutdoorOpacity");function ut(s,t,e){switch(e){case"in-range":return s[0]?.canSetFloor?s[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(ut,"getSetFloorTargetFromZoomState");function dt(s){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:b,multiFloorView:d,getMultiFloorState:A,dynamicBuildingInteriors:O,isolateBelowGroundView:G,currentElevation:yo,forceInteriorsVisible:eo,getFloorStackAltitudeData:So}=s,Eo=new Map,Mo=G&&yo<0&&r==="in-range";for(let F of t){let et=e.has(F.id),To=Mo&&F.minElevation>=0,vt=To?!1:et,Zo=To?!1:Uo({building:F,currentFloor:i,inRange:r==="in-range",inFocus:et,mode:n,elevation:f,inNavigation:b.includes(F.id),dynamicBuildingInteriors:O,forceInteriorsVisible:eo}),_o=i.floorStack.id===F.id?F.activeFloor:Oo(F,n,f),wt=d?.enabled?A(F.floors,_o||F.activeFloor,p,So(F.id),{color:d?.footprintColor,spacesOpenToBelowEnabled:d?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:d?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:d?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:d?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:d?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:d?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:d?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:d?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:d?.footprintOpacity,outline:d?.footprintOutline}):xt(F.floorStack,_o||F.activeFloor,Zo),Ot=G&&yo<0&&r==="in-range",Vt=Nt(F.facade,Zo,Ot,To);Eo.set(F.id,{building:F,showIndoor:Zo,floorStackState:wt,facadeState:Vt,inFocus:vt,floorToShow:_o,isAboveGroundInIsolation:To})}return Eo}a(dt,"getBuildingStates");function ct(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(ct,"getBuildingAnimationType");function Uo(s){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:b,forceInteriorsVisible:d}=s;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(d===!0||p===!0)return!0;if(!b)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a(Uo,"shouldShowIndoor");function ht(s,t,e){return s!==t&&!e}a(ht,"shouldDeferSetFloor");var ft=["default-floor","active-floor","lock-elevation","nearest-elevation"];import{Floor as Ct,FloorStack as Gt}from"@mappedin/mappedin-js";function mt(s,t,e,i){return(s<t||s>e)&&q.warn(i),Math.min(e,Math.max(t,s))}a(mt,"clampWithWarning");function $o(s,t){return!Ct.is(s)||s?.floorStack==null||!Gt.is(t)?!1:s.floorStack.id!==t.id?(q.warn(`Floor (${s.id}) does not belong to floor stack (${t.id}).`),!1):!0}a($o,"validateFloorForStack");function jo(s,t,e,i){return mt(s,t,e,`${i} must be between ${t} and ${e}.`)}a(jo,"validateZoomThreshold");var B,Q,no,zo,Yo=class Yo{constructor(t,e){c(this,no);E(this,"__type","outdoors");c(this,B);c(this,Q);h(this,B,t),h(this,Q,e)}get id(){return o(this,B).id}get floorStack(){return o(this,B)}get floor(){return o(this,B).defaultFloor}matchesFloorStack(t){return t===o(this,B)||t===o(this,B).id}show(){g(this,no,zo).call(this,!0)}hide(){g(this,no,zo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};B=new WeakMap,Q=new WeakMap,no=new WeakSet,zo=a(function(t){for(let e of o(this,B).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(Yo,"Outdoors");var Vo=Yo;function pt(s,t){let e=s.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let r=e.find(n=>n.facade==null&&!t.has(n.id));return r||(V.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(pt,"getOutdoorFloorStack");function Rt(s,t){return`${t} ${s}`}a(Rt,"formatMessage");var Wo=class Wo extends Error{constructor(t,e=Co){super(Rt(t,e)),this.name="MappedinError"}};a(Wo,"MappedinError");var Ao=Wo;var Pt=a(s=>s,"linearEase"),Ut=a(s=>s*s,"quadEaseIn"),$t=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),jt=a(s=>1-(1-s)*(1-s),"quadEaseOut"),zt=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Yt={linear:Pt,"ease-in":Ut,"ease-out":jt,"ease-in-out":$t,"ease-out-cubic":zt};function Wt(s,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&r(s,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Wt,"getInterpolationBreakpoint");function gt(s,t,e,i="ease-in"){if(t.length!==e.length)throw new Ao("Input and output ranges must have the same number of values.");s=Math.max(t[0],Math.min(s,t[t.length-1]));let r=Wt(s,t),n=(s-t[r])/(t[r+1]-t[r]),f=typeof i=="function"?i(n):Yt[i](n);return e[r]+f*(e[r+1]-e[r])}a(gt,"interpolateMulti");var D,ao,lo,Z,uo,Ho=class Ho{constructor(t,e,i){E(this,"layers");E(this,"visible");c(this,D);c(this,ao,[]);c(this,lo,!1);c(this,Z,new Map);E(this,"interpolationFn");c(this,uo,1);this.layers=t,this.visible=e,h(this,D,i)}processLayerGroup(t,e){o(this,lo)||(this.layers.forEach(i=>{let r=t[i];r&&o(this,ao).push(...r)}),h(this,lo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:r,indoorZoomThreshold:n}=e();return gt(i,[r,n],[1,0])}))}setOpacity(t){h(this,uo,t);for(let e of o(this,ao))if(e.startsWith("img_")){let i=o(this,D).Image3D.getById(e);if(i){if(!o(this,Z).has(e)){let n=o(this,D).getState(i.image);o(this,Z).set(e,n?.opacity??1)}let r=Math.min(o(this,Z).get(e),t);o(this,D).updateState(i.image,{opacity:r})}}else{let i=o(this,D).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,Z).has(e)){let n=o(this,D).getState(i);o(this,Z).set(e,n?.opacity??1)}let r=Math.min(o(this,Z).get(e),t);o(this,D).updateState(i,{opacity:r,visible:r>0})}}get opacity(){return o(this,uo)}};D=new WeakMap,ao=new WeakMap,lo=new WeakMap,Z=new WeakMap,uo=new WeakMap,a(Ho,"LayerGroup");var Io=Ho;function qo(s,t,e){s.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let r=i.interpolationFn(t);r!=null&&(i.setOpacity(r),i.visible=r===1)}})}a(qo,"runLayerGroupInterpolations");var L,l,P,u,z,Y,S,_,W,N,T,J,co,ho,fo,M,U,X,mo,x,$,j,m,Ko,bt,Qo,Jo,Xo,yt,ot,oo,po,St,Bo,Do,Lo,go,Fo,bo,to,ko,Et,Tt,C,tt=class tt{constructor(t){c(this,m);c(this,L);c(this,l);c(this,P);c(this,u,io);c(this,z,[]);c(this,Y,new Set);c(this,S,new Map);c(this,_);c(this,W,!1);c(this,N,!1);c(this,T,0);c(this,J,0);c(this,co,[]);c(this,ho,{});c(this,fo,{});c(this,M,"transition");c(this,U,"outdoor");c(this,X,[]);c(this,mo,[]);c(this,x,!1);c(this,$,[]);c(this,j,null);E(this,"sceneUpdateQueue",Promise.resolve());E(this,"on",a((t,e)=>{o(this,L).on(t,e)},"on"));E(this,"off",a((t,e)=>{o(this,L).off(t,e)},"off"));c(this,oo,a(()=>{h(this,z,[]),o(this,Y).clear();let t=o(this,u).isolateBelowGroundView&&o(this,T)<0;for(let e of o(this,mo)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,Y).add(i.id),o(this,z).push(i)))}},"#updateBuildingsInView"));c(this,po,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;nt(e,this.focusedFacades)&&o(this,U)==="transition"&&!o(this,N)||(h(this,N,!1),h(this,mo,e),o(this,oo).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));c(this,Bo,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let r=o(this,u).isolateBelowGroundView&&o(this,T)<0;i?.excluded===!1&&!o(this,_).matchesFloorStack(t.floorStack)&&h(this,T,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,T)<0,f=r&&!n;if(e.reason==="dynamic-focus")return;let p=g(this,m,St).call(this),b=o(this,Do).call(this,t,e,f,p);if(p)return b;b.catch(d=>{V.error("setFloor override work failed after sync floor-change commit",d)})},"#setFloorHandler"));c(this,Do,a(async(t,e,i,r)=>{i&&(h(this,N,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),await o(this,C).call(this,t),!(!this.isEnabled||e.signal.aborted)&&r&&this.isEnabled&&!e.signal.aborted&&await o(this,Lo).call(this,t)},"#runFloorChangeWork"));c(this,Lo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));c(this,go,a(()=>{h(this,W,!0)},"#handleUserInteractionStart"));c(this,Fo,a(()=>{h(this,W,!1)},"#handleUserInteractionEnd"));c(this,bo,a(()=>{o(this,C).call(this)},"#handleGlobalStateChange"));c(this,to,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=at(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,M)!==i&&(h(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let r=(o(this,l).Navigation?.floors?.length??0)>0;qo(o(this,$),e,r?{forceOpacity:0}:void 0)},"#handleCameraChange"));c(this,C,a(async t=>{if(!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,r=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(b=>b.id)||[],f=o(this,l).Navigation?.floorStacks.map(b=>b.id)||[],p=new Promise(async b=>{await this.sceneUpdateQueue;let d=dt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,Y),currentFloor:e,zoomState:o(this,M),mode:o(this,u).mode,elevation:o(this,T),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:r,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Ht,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,T),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(O=>o(this,l).getFloorStackAltitudeData(O),"getFloorStackAltitudeData")}),A=[];await Promise.all(Array.from(d.values()).map(async O=>{let{building:G,showIndoor:yo,floorStackState:eo,facadeState:So,inFocus:Eo,isAboveGroundInIsolation:Mo}=O;A.push(eo);let F=ct(G,yo);if(F==="indoor")return g(this,m,Et).call(this,G,eo,So,Eo);if(F==="outdoor")return g(this,m,Tt).call(this,G,eo,So,f,Mo)})),o(this,l).Outdoor.setOpacity(lt(A,o(this,u).mode)),h(this,X,o(this,z).filter(O=>d.get(O.id)?.showIndoor===!0).map(O=>O.facade)),o(this,L).publish("focus",{facades:o(this,X)}),b()});return this.sceneUpdateQueue=p,p},"#applyBuildingStates"));h(this,L,new vo),h(this,l,t),V.setLevel(q.logState),h(this,P,o(this,l).getMapData()),h(this,T,o(this,l).currentFloor.elevation),h(this,J,o(this,l).Camera.elevation);for(let e of o(this,P).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){V.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new wo(i,o(this,l)))}g(this,m,yt).call(this),h(this,_,new Vo(pt(o(this,P),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,to)),o(this,l).on("facades-in-view-change",o(this,po)),o(this,l).on("user-interaction-start",o(this,go)),o(this,l).on("user-interaction-end",o(this,Fo)),o(this,l).on("global-state-change",o(this,bo))}enable(t){if(o(this,x)){V.warn("enable() called on an already enabled Dynamic Focus instance.");return}h(this,x,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Bo)),o(this,_).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),g(this,m,bt).call(this),o(this,to).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,x)){V.warn("disable() called on an already disabled Dynamic Focus instance.");return}h(this,x,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,x)}get isIndoor(){return o(this,U)==="indoor"}get isOutdoor(){return o(this,U)==="outdoor"}get outdoorsFloorStack(){return o(this,_).floorStack}get layers(){return o(this,co)}get layersBySpaceId(){return o(this,ho)}setIndoor(){h(this,U,"indoor"),h(this,M,"in-range"),g(this,m,Ko).call(this)}setOutdoor(){h(this,U,"outdoor"),h(this,M,"out-of-range"),g(this,m,Ko).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,r=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,T)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,b=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,d=t;if(b&&(d.indoorZoomThreshold!=null||d.outdoorZoomThreshold!=null)){V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:A,outdoorZoomThreshold:O,...G}=d;d=G}if(!p&&b?(h(this,j,()=>{if(!o(this,x))return;let A=o(this,u).indoorZoomThreshold,O=o(this,u).outdoorZoomThreshold;g(this,m,Jo).call(this),g(this,m,Xo).call(this,A,O),o(this,C).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,j))):p&&!b&&g(this,m,Qo).call(this),d.indoorZoomThreshold!=null&&(d.indoorZoomThreshold=jo(d.indoorZoomThreshold,d?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),d.outdoorZoomThreshold!=null&&(d.outdoorZoomThreshold=jo(d.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,d?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),d.mode!=null&&(d.mode=ft.includes(d.mode)?d.mode:"default-floor"),d.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=d.autoAdjustFacadeHeights),d.dynamicBuildingInteriors!=null&&d.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),d.isolateBelowGroundView!=null&&d.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),d.forceInteriorsVisible!=null&&d.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),d.showLabelsAndMarkersOnAllVisibleFloors!=null&&d.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d.cameraLiftAnimationOptions!=null&&(d={...d,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...d.cameraLiftAnimationOptions}}),h(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(d).filter(([,A])=>A!=null)))),b&&d.autoZoomThresholds!==void 0&&(g(this,m,Jo).call(this),e=!0),d.mode!=null&&d.preloadFloors&&g(this,m,ot).call(this,d.mode),e){let A=o(this,u).isolateBelowGroundView&&o(this,T)<0;n&&!A&&(h(this,N,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),o(this,C).call(this)}g(this,m,Xo).call(this,i,r),!f&&o(this,u).autoFocus&&this.focus(!1)}destroy(){this.disable(),g(this,m,Qo).call(this),o(this,l).off("facades-in-view-change",o(this,po)),o(this,l).off("camera-change",o(this,to)),o(this,l).off("user-interaction-start",o(this,go)),o(this,l).off("user-interaction-end",o(this,Fo)),o(this,l).off("global-state-change",o(this,bo)),o(this,S).forEach(t=>t.destroy()),o(this,_).destroy(),o(this,L).destroy(),h(this,$,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(ht(o(this,J),o(this,l).Camera.elevation,o(this,W)))h(this,J,o(this,l).Camera.elevation),h(this,N,!0);else{let i=ut(o(this,z),o(this,_),o(this,M)),r=i?Oo(i,o(this,u).mode,o(this,T)):void 0;r&&r.id!==o(this,l).currentFloor.id&&(e=r,o(this,l).setFloor(r,{context:"dynamic-focus"}))}await o(this,C).call(this,e)}preloadFloors(){g(this,m,ot).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!$o(e,t))return;let i=o(this,S).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,S).get(t.id),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!$o(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,C).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).get(i.id);r&&(r.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};L=new WeakMap,l=new WeakMap,P=new WeakMap,u=new WeakMap,z=new WeakMap,Y=new WeakMap,S=new WeakMap,_=new WeakMap,W=new WeakMap,N=new WeakMap,T=new WeakMap,J=new WeakMap,co=new WeakMap,ho=new WeakMap,fo=new WeakMap,M=new WeakMap,U=new WeakMap,X=new WeakMap,mo=new WeakMap,x=new WeakMap,$=new WeakMap,j=new WeakMap,m=new WeakSet,Ko=a(function(){o(this,u).autoFocus&&(o(this,W)?this.focus():h(this,N,!0)),o(this,L).publish("state-change")},"#handleViewStateChange"),bt=a(function(){h(this,$,[]);for(let e of o(this,u).dynamicLayers){let i=new Io([e],!0,o(this,l));i.processLayerGroup(o(this,fo),()=>o(this,u)),o(this,$).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;qo(o(this,$),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),Qo=a(function(){o(this,j)&&(o(this,l).off("camera-screen-offsets-change",o(this,j)),h(this,j,null))},"#unsubscribeScreenOffsets"),Jo=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:r}=st(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=r,(e.expandMinZoom??!0)&&r<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(r-ro)},"#recalcThresholds"),Xo=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,L).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),yt=a(function(){let t=o(this,P).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(r=>{e[r.name]||(e[r.name]=[]),e[r.name].push(...r.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of r.spaces)i[n]==null&&(i[n]=[]),i[n].push(r.name)}),h(this,co,t.map(({name:r})=>r)),h(this,ho,i),h(this,fo,e)},"#setupLayers"),ot=a(function(t){let e=[];for(let i of o(this,P).getByType("facade")){let r=o(this,S).get(i.floorStack.id);if(!r)continue;let n=Oo(r,t,o(this,T));n!=null&&qt.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),oo=new WeakMap,po=new WeakMap,St=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Bo=new WeakMap,Do=new WeakMap,Lo=new WeakMap,go=new WeakMap,Fo=new WeakMap,bo=new WeakMap,to=new WeakMap,ko=a(function(t,e,i,r=!1){t.forEach(n=>{if(n.floor)if(e){let p=i!==void 0&&!r?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),Et=a(async function(t,e,i,r){return g(this,m,ko).call(this,e.floorStates,!0,r,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Tt=a(async function(t,e,i,r,n){let f=n;f&&g(this,m,ko).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&g(this,m,ko).call(this,e.floorStates,Uo({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,Y).has(t.id),mode:o(this,u).mode,elevation:o(this,T),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),C=new WeakMap,a(tt,"DynamicFocus");var Ft=tt;export{a,st as b,Ft as c};
|
|
1
|
+
var it=Object.defineProperty;var rt=s=>{throw TypeError(s)};var At=(s,t,e)=>t in s?it(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t)=>it(s,"name",{value:t,configurable:!0});var E=(s,t,e)=>At(s,typeof t!="symbol"?t+"":t,e),No=(s,t,e)=>t.has(s)||rt("Cannot "+e);var o=(s,t,e)=>(No(s,t,"read from private field"),e?e.call(s):t.get(s)),c=(s,t,e)=>t.has(s)?rt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),h=(s,t,e,i)=>(No(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e),g=(s,t,e)=>(No(s,t,"access private method"),e);var y={env:{NODE_ENV:"production",npm_package_version:"6.27.0-beta.0"}};var io={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!0,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},ro=.2,xo=.4;var Co="[MappedinJS]";var kt={log:0,debug:0,info:1,warn:2,error:3,silent:4};function Bt(s){return kt[s.toLowerCase()]}a(Bt,"parseLogLevel");function Go(s="",{prefix:t=Co}={}){let e=`${t}${s?`-${s}`:""}`,i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}
|
|
2
|
+
${p.stack}`:p);window.rnDebug(`${s} ${r}: ${f.join(" ")}`)}},"rnDebug");return{logState:y.env.NODE_ENV==="test"?4:1,debug(...r){this.logState<=0&&(console.debug(e,...r),i("debug",r))},log(...r){this.debug(...r)},info(...r){this.logState<=1&&(console.info(e,...r),i("info",r))},warn(...r){this.logState<=2&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=3&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){let n=typeof r=="string"?Bt(r):r;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${r}"`);return}this.logState=n}}}a(Go,"createLogger");var Dt=Go();var H=Dt;var V=Go("",{prefix:"[DynamicFocus]"});var st=a((s,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Lt(s,e);if(i===void 0)return V.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:io.indoorZoomThreshold,outdoorZoomThreshold:io.outdoorZoomThreshold};let r=i+xo,n=i+ro;return e.initialVisibility==="indoor-first"&&(r=i-ro,n=i-xo),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Lt(s,t){let i=s.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),r=1/0,n;for(let f of i){let p=s.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<r&&(r=p,n=f)}if(r!==1/0)return t.debug&&n&&s.Camera.getFocusOnTransform(n,{debugColor:"blue"}),r}a(Lt,"getDefaultZoomLevel");import{Floor as qt,getMultiFloorState as Ht}from"@mappedin/mappedin-js";function nt(s,t){if(s==null||t==null)return s===t;if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}a(nt,"arraysEqual");var Ro=class Ro{_subscribers={};_abortController=new AbortController;get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let r=i?.signal;if(r?.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 r&&r.addEventListener("abort",n,{once:!0}),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a(Ro,"PubSub");var To=Ro;import{Facade as Mt,Floor as Zt,FloorStack as _t}from"@mappedin/mappedin-js";var I,so,R,w,T,k,K,Q,Po=class Po{constructor(t,e){E(this,"__type","building");c(this,I);c(this,so,new Map);c(this,R,new Map);c(this,w,[]);c(this,T);c(this,k);E(this,"defaultFloor");E(this,"activeFloor");E(this,"excluded",!1);E(this,"aboveGroundFloors",[]);c(this,K);c(this,Q);h(this,I,t),h(this,so,new Map(t.floors.map(r=>[r.id,r]))),h(this,R,new Map(t.floors.map(r=>[r.elevation,r]))),h(this,w,Array.from(o(this,R).values()).sort((r,n)=>r.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,h(this,T,e),this.aboveGroundFloors=o(this,w).filter(r=>r.elevation>=0)}get id(){return o(this,I).id}get name(){return o(this,I).name}get floors(){return o(this,I).floors}get floorStack(){return o(this,I)}get facade(){return o(this,I).facade}get isCurrentFloorStack(){return this.id===o(this,T).currentFloorStack.id}get isIndoor(){let t=o(this,T).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,K)==null&&h(this,K,Math.max(...o(this,R).keys())),o(this,K)}get minElevation(){return o(this,Q)==null&&h(this,Q,Math.min(...o(this,R).keys())),o(this,Q)}has(t){return Zt.is(t)?o(this,so).has(t.id):_t.is(t)?t.id===o(this,I).id:Mt.is(t)?t.id===this.facade.id:!1}getFloorByElevation(t){return o(this,R).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 r=o(this,w)[i];if(r.elevation<=t)return r}}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,k)&&(o(this,k).animation.cancel(),h(this,k,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,k)?.state||o(this,T).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:n}=t;if(o(this,T).updateState(this.facade,{visible:!0}),r!==void 0){h(this,k,{animation:o(this,T).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let f=await o(this,k).animation;if(h(this,k,void 0),f.result==="cancelled")return f}return n===!1&&o(this,T).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,I).floors.forEach(t=>{o(this,T).updateState(t,{visible:t.id===o(this,T).currentFloor.id})}),this.has(o(this,T).currentFloor)||o(this,T).updateState(this.facade,{visible:!0,opacity:1})}};I=new WeakMap,so=new WeakMap,R=new WeakMap,w=new WeakMap,T=new WeakMap,k=new WeakMap,K=new WeakMap,Q=new WeakMap,a(Po,"Building");var wo=Po;function at(s,t,e){return s>=t?"in-range":s<=e?"out-of-range":"transition"}a(at,"getZoomState");function Oo(s,t,e){if(s.__type==="outdoors"&&"floor"in s)return s.floor;let i=s;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Oo,"getFloorToShow");function Nt(s,t,e,i){return i?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:s,state:{type:"facade",visible:!0,opacity:.2}}:{facade:s,state:{type:"facade",visible:!0,opacity:1}}}a(Nt,"getFacadeState");function xt(s,t,e){return{outdoorOpacity:"initial",floorStates:s.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(xt,"getSingleBuildingState");function lt(s,t){if(!t.includes("lock-elevation"))return"initial";for(let e of s)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(lt,"getOutdoorOpacity");function ut(s,t,e){switch(e){case"in-range":return s[0]?.canSetFloor?s[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(ut,"getSetFloorTargetFromZoomState");function dt(s){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:b,multiFloorView:d,getMultiFloorState:A,dynamicBuildingInteriors:O,isolateBelowGroundView:G,currentElevation:yo,forceInteriorsVisible:eo,getFloorStackAltitudeData:So}=s,Eo=new Map,Mo=G&&yo<0&&r==="in-range";for(let F of t){let et=e.has(F.id),vo=Mo&&F.minElevation>=0,Tt=vo?!1:et,Zo=vo?!1:Uo({building:F,currentFloor:i,inRange:r==="in-range",inFocus:et,mode:n,elevation:f,inNavigation:b.includes(F.id),dynamicBuildingInteriors:O,forceInteriorsVisible:eo}),_o=i.floorStack.id===F.id?F.activeFloor:Oo(F,n,f),wt=d?.enabled?A(F.floors,_o||F.activeFloor,p,So(F.id),{color:d?.footprintColor,spacesOpenToBelowEnabled:d?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:d?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:d?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:d?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:d?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:d?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:d?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:d?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:d?.footprintOpacity,outline:d?.footprintOutline}):xt(F.floorStack,_o||F.activeFloor,Zo),Ot=G&&yo<0&&r==="in-range",Vt=Nt(F.facade,Zo,Ot,vo);Eo.set(F.id,{building:F,showIndoor:Zo,floorStackState:wt,facadeState:Vt,inFocus:Tt,floorToShow:_o,isAboveGroundInIsolation:vo})}return Eo}a(dt,"getBuildingStates");function ct(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(ct,"getBuildingAnimationType");function Uo(s){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:b,forceInteriorsVisible:d}=s;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(d===!0||p===!0)return!0;if(!b)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a(Uo,"shouldShowIndoor");function ht(s,t,e){return s!==t&&!e}a(ht,"shouldDeferSetFloor");var ft=["default-floor","active-floor","lock-elevation","nearest-elevation"];import{Floor as Ct,FloorStack as Gt}from"@mappedin/mappedin-js";function mt(s,t,e,i){return(s<t||s>e)&&H.warn(i),Math.min(e,Math.max(t,s))}a(mt,"clampWithWarning");function $o(s,t){return!Ct.is(s)||s?.floorStack==null||!Gt.is(t)?!1:s.floorStack.id!==t.id?(H.warn(`Floor (${s.id}) does not belong to floor stack (${t.id}).`),!1):!0}a($o,"validateFloorForStack");function jo(s,t,e,i){return mt(s,t,e,`${i} must be between ${t} and ${e}.`)}a(jo,"validateZoomThreshold");var B,J,no,zo,Yo=class Yo{constructor(t,e){c(this,no);E(this,"__type","outdoors");c(this,B);c(this,J);h(this,B,t),h(this,J,e)}get id(){return o(this,B).id}get floorStack(){return o(this,B)}get floor(){return o(this,B).defaultFloor}matchesFloorStack(t){return t===o(this,B)||t===o(this,B).id}show(){g(this,no,zo).call(this,!0)}hide(){g(this,no,zo).call(this,!1)}destroy(){this.matchesFloorStack(o(this,J).currentFloorStack)||this.hide()}};B=new WeakMap,J=new WeakMap,no=new WeakSet,zo=a(function(t){for(let e of o(this,B).floors)o(this,J).updateState(e,{visible:t})},"#setVisible"),a(Yo,"Outdoors");var Vo=Yo;function pt(s,t){let e=s.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let r=e.find(n=>n.facade==null&&!t.has(n.id));return r||(V.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(pt,"getOutdoorFloorStack");function Rt(s,t){return`${t} ${s}`}a(Rt,"formatMessage");var Wo=class Wo extends Error{constructor(t,e=Co){super(Rt(t,e)),this.name="MappedinError"}};a(Wo,"MappedinError");var Ao=Wo;var Pt=a(s=>s,"linearEase"),Ut=a(s=>s*s,"quadEaseIn"),$t=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),jt=a(s=>1-(1-s)*(1-s),"quadEaseOut"),zt=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Yt={linear:Pt,"ease-in":Ut,"ease-out":jt,"ease-in-out":$t,"ease-out-cubic":zt};function Wt(s,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&r(s,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Wt,"getInterpolationBreakpoint");function gt(s,t,e,i="ease-in"){if(t.length!==e.length)throw new Ao("Input and output ranges must have the same number of values.");s=Math.max(t[0],Math.min(s,t[t.length-1]));let r=Wt(s,t),n=(s-t[r])/(t[r+1]-t[r]),f=typeof i=="function"?i(n):Yt[i](n);return e[r]+f*(e[r+1]-e[r])}a(gt,"interpolateMulti");var D,ao,lo,N,uo,Ho=class Ho{constructor(t,e,i){E(this,"layers");E(this,"visible");c(this,D);c(this,ao,[]);c(this,lo,!1);c(this,N,new Map);E(this,"interpolationFn");c(this,uo,1);this.layers=t,this.visible=e,h(this,D,i)}processLayerGroup(t,e){o(this,lo)||(this.layers.forEach(i=>{let r=t[i];r&&o(this,ao).push(...r)}),h(this,lo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:r,indoorZoomThreshold:n}=e();return gt(i,[r,n],[1,0])}))}setOpacity(t){h(this,uo,t);for(let e of o(this,ao))if(e.startsWith("img_")){let i=o(this,D).Image3D.getById(e);if(i){if(!o(this,N).has(e)){let n=o(this,D).getState(i.image);o(this,N).set(e,n?.opacity??1)}let r=Math.min(o(this,N).get(e),t);o(this,D).updateState(i.image,{opacity:r})}}else{let i=o(this,D).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,N).has(e)){let n=o(this,D).getState(i);o(this,N).set(e,n?.opacity??1)}let r=Math.min(o(this,N).get(e),t);o(this,D).updateState(i,{opacity:r,visible:r>0})}}get opacity(){return o(this,uo)}};D=new WeakMap,ao=new WeakMap,lo=new WeakMap,N=new WeakMap,uo=new WeakMap,a(Ho,"LayerGroup");var Io=Ho;function qo(s,t,e){s.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let r=i.interpolationFn(t);r!=null&&(i.setOpacity(r),i.visible=r===1)}})}a(qo,"runLayerGroupInterpolations");var L,l,P,u,z,Y,S,M,W,x,v,q,co,ho,fo,Z,U,X,mo,_,$,j,m,Ko,bt,Qo,Jo,Xo,yt,ot,oo,po,St,Bo,Do,Lo,go,Fo,bo,to,ko,Et,vt,C,tt=class tt{constructor(t){c(this,m);c(this,L);c(this,l);c(this,P);c(this,u,io);c(this,z,[]);c(this,Y,new Set);c(this,S,new Map);c(this,M);c(this,W,!1);c(this,x,!1);c(this,v,0);c(this,q,0);c(this,co,[]);c(this,ho,{});c(this,fo,{});c(this,Z,"transition");c(this,U,"outdoor");c(this,X,[]);c(this,mo,[]);c(this,_,!1);c(this,$,[]);c(this,j,null);E(this,"sceneUpdateQueue",Promise.resolve());E(this,"on",a((t,e)=>{o(this,L).on(t,e)},"on"));E(this,"off",a((t,e)=>{o(this,L).off(t,e)},"off"));c(this,oo,a(()=>{h(this,z,[]),o(this,Y).clear();let t=o(this,u).isolateBelowGroundView&&o(this,v)<0;for(let e of o(this,mo)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,Y).add(i.id),o(this,z).push(i)))}},"#updateBuildingsInView"));c(this,po,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;nt(e,this.focusedFacades)&&o(this,U)==="transition"&&!o(this,x)||(h(this,x,!1),h(this,mo,e),o(this,oo).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));c(this,Bo,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let r=o(this,u).isolateBelowGroundView&&o(this,v)<0;i?.excluded===!1&&!o(this,M).matchesFloorStack(t.floorStack)&&h(this,v,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=r&&!n;if(e.reason==="dynamic-focus")return;let p=g(this,m,St).call(this),b=o(this,Do).call(this,t,e,f,p);if(p)return b;b.catch(d=>{V.error("setFloor override work failed after sync floor-change commit",d)})},"#setFloorHandler"));c(this,Do,a(async(t,e,i,r)=>{i&&(h(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),await o(this,C).call(this,t),!(!this.isEnabled||e.signal.aborted)&&r&&this.isEnabled&&!e.signal.aborted&&await o(this,Lo).call(this,t)},"#runFloorChangeWork"));c(this,Lo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));c(this,go,a(()=>{h(this,W,!0)},"#handleUserInteractionStart"));c(this,Fo,a(()=>{h(this,W,!1)},"#handleUserInteractionEnd"));c(this,bo,a(()=>{o(this,C).call(this)},"#handleGlobalStateChange"));c(this,to,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=at(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,Z)!==i&&(h(this,Z,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let r=(o(this,l).Navigation?.floors?.length??0)>0;qo(o(this,$),e,r?{forceOpacity:0}:void 0)},"#handleCameraChange"));c(this,C,a(async t=>{if(!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,r=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(b=>b.id)||[],f=o(this,l).Navigation?.floorStacks.map(b=>b.id)||[],p=new Promise(async b=>{await this.sceneUpdateQueue;let d=dt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,Y),currentFloor:e,zoomState:o(this,Z),mode:o(this,u).mode,elevation:o(this,v),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:r,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??Ht,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,v),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(O=>o(this,l).getFloorStackAltitudeData(O),"getFloorStackAltitudeData")}),A=[];await Promise.all(Array.from(d.values()).map(async O=>{let{building:G,showIndoor:yo,floorStackState:eo,facadeState:So,inFocus:Eo,isAboveGroundInIsolation:Mo}=O;A.push(eo);let F=ct(G,yo);if(F==="indoor")return g(this,m,Et).call(this,G,eo,So,Eo);if(F==="outdoor")return g(this,m,vt).call(this,G,eo,So,f,Mo)})),o(this,l).Outdoor.setOpacity(lt(A,o(this,u).mode)),h(this,X,o(this,z).filter(O=>d.get(O.id)?.showIndoor===!0).map(O=>O.facade)),o(this,L).publish("focus",{facades:o(this,X)}),b()});return this.sceneUpdateQueue=p,p},"#applyBuildingStates"));h(this,L,new To),h(this,l,t),V.setLevel(H.logState),h(this,P,o(this,l).getMapData()),h(this,v,o(this,l).currentFloor.elevation),h(this,q,o(this,l).Camera.elevation);for(let e of o(this,P).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){V.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new wo(i,o(this,l)))}g(this,m,yt).call(this),h(this,M,new Vo(pt(o(this,P),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,to)),o(this,l).on("facades-in-view-change",o(this,po)),o(this,l).on("user-interaction-start",o(this,go)),o(this,l).on("user-interaction-end",o(this,Fo)),o(this,l).on("global-state-change",o(this,bo))}enable(t){if(o(this,_)){V.warn("enable() called on an already enabled Dynamic Focus instance.");return}h(this,_,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Bo)),o(this,M).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),g(this,m,bt).call(this),o(this,to).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,_)){V.warn("disable() called on an already disabled Dynamic Focus instance.");return}h(this,_,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,_)}get isIndoor(){return o(this,U)==="indoor"}get isOutdoor(){return o(this,U)==="outdoor"}get outdoorsFloorStack(){return o(this,M).floorStack}get layers(){return o(this,co)}get layersBySpaceId(){return o(this,ho)}setIndoor(){h(this,U,"indoor"),h(this,Z,"in-range"),g(this,m,Ko).call(this)}setOutdoor(){h(this,U,"outdoor"),h(this,Z,"out-of-range"),g(this,m,Ko).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,r=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,v)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,b=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,d=t;if(b&&(d.indoorZoomThreshold!=null||d.outdoorZoomThreshold!=null)){V.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:A,outdoorZoomThreshold:O,...G}=d;d=G}if(!p&&b?(h(this,j,()=>{if(!o(this,_))return;let A=o(this,u).indoorZoomThreshold,O=o(this,u).outdoorZoomThreshold;g(this,m,Jo).call(this),g(this,m,Xo).call(this,A,O),o(this,C).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,j))):p&&!b&&g(this,m,Qo).call(this),d.indoorZoomThreshold!=null&&(d.indoorZoomThreshold=jo(d.indoorZoomThreshold,d?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),d.outdoorZoomThreshold!=null&&(d.outdoorZoomThreshold=jo(d.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,d?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),d.mode!=null&&(d.mode=ft.includes(d.mode)?d.mode:"default-floor"),d.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=d.autoAdjustFacadeHeights),d.dynamicBuildingInteriors!=null&&d.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),d.isolateBelowGroundView!=null&&d.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),d.forceInteriorsVisible!=null&&d.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),d.showLabelsAndMarkersOnAllVisibleFloors!=null&&d.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d.cameraLiftAnimationOptions!=null&&(d={...d,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...d.cameraLiftAnimationOptions}}),h(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(d).filter(([,A])=>A!=null)))),b&&d.autoZoomThresholds!==void 0&&(g(this,m,Jo).call(this),e=!0),d.mode!=null&&d.preloadFloors&&g(this,m,ot).call(this,d.mode),e){let A=o(this,u).isolateBelowGroundView&&o(this,v)<0;n&&!A&&(h(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),o(this,C).call(this)}g(this,m,Xo).call(this,i,r),o(this,_)&&!f&&o(this,u).autoFocus&&(h(this,q,o(this,l).Camera.elevation),this.focus(o(this,u).setFloorOnFocus&&o(this,M).matchesFloorStack(o(this,l).currentFloor.floorStack)))}destroy(){this.disable(),g(this,m,Qo).call(this),o(this,l).off("facades-in-view-change",o(this,po)),o(this,l).off("camera-change",o(this,to)),o(this,l).off("user-interaction-start",o(this,go)),o(this,l).off("user-interaction-end",o(this,Fo)),o(this,l).off("global-state-change",o(this,bo)),o(this,S).forEach(t=>t.destroy()),o(this,M).destroy(),o(this,L).destroy(),h(this,$,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(ht(o(this,q),o(this,l).Camera.elevation,o(this,W)))h(this,q,o(this,l).Camera.elevation),h(this,x,!0);else{let i=ut(o(this,z),o(this,M),o(this,Z)),r=i?Oo(i,o(this,u).mode,o(this,v)):void 0;r&&r.id!==o(this,l).currentFloor.id&&(e=r,o(this,l).setFloor(r,{context:"dynamic-focus"}))}await o(this,C).call(this,e)}preloadFloors(){g(this,m,ot).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!$o(e,t))return;let i=o(this,S).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,S).get(t.id),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!$o(e,t))return;let i=o(this,S).get(t.id);i&&(i.activeFloor=e,o(this,C).call(this))}exclude(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).get(i.id);r&&(r.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};L=new WeakMap,l=new WeakMap,P=new WeakMap,u=new WeakMap,z=new WeakMap,Y=new WeakMap,S=new WeakMap,M=new WeakMap,W=new WeakMap,x=new WeakMap,v=new WeakMap,q=new WeakMap,co=new WeakMap,ho=new WeakMap,fo=new WeakMap,Z=new WeakMap,U=new WeakMap,X=new WeakMap,mo=new WeakMap,_=new WeakMap,$=new WeakMap,j=new WeakMap,m=new WeakSet,Ko=a(function(){o(this,u).autoFocus&&(o(this,W)?this.focus():h(this,x,!0)),o(this,L).publish("state-change")},"#handleViewStateChange"),bt=a(function(){h(this,$,[]);for(let e of o(this,u).dynamicLayers){let i=new Io([e],!0,o(this,l));i.processLayerGroup(o(this,fo),()=>o(this,u)),o(this,$).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;qo(o(this,$),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),Qo=a(function(){o(this,j)&&(o(this,l).off("camera-screen-offsets-change",o(this,j)),h(this,j,null))},"#unsubscribeScreenOffsets"),Jo=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:r}=st(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=r,(e.expandMinZoom??!0)&&r<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(r-ro)},"#recalcThresholds"),Xo=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,L).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),yt=a(function(){let t=o(this,P).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(r=>{e[r.name]||(e[r.name]=[]),e[r.name].push(...r.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of r.spaces)i[n]==null&&(i[n]=[]),i[n].push(r.name)}),h(this,co,t.map(({name:r})=>r)),h(this,ho,i),h(this,fo,e)},"#setupLayers"),ot=a(function(t){let e=[];for(let i of o(this,P).getByType("facade")){let r=o(this,S).get(i.floorStack.id);if(!r)continue;let n=Oo(r,t,o(this,v));n!=null&&qt.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),oo=new WeakMap,po=new WeakMap,St=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Bo=new WeakMap,Do=new WeakMap,Lo=new WeakMap,go=new WeakMap,Fo=new WeakMap,bo=new WeakMap,to=new WeakMap,ko=a(function(t,e,i,r=!1){t.forEach(n=>{if(n.floor)if(e){let p=i!==void 0&&!r?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),Et=a(async function(t,e,i,r){return g(this,m,ko).call(this,e.floorStates,!0,r,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),vt=a(async function(t,e,i,r,n){let f=n;f&&g(this,m,ko).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&g(this,m,ko).call(this,e.floorStates,Uo({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,Z)==="in-range",inFocus:o(this,Y).has(t.id),mode:o(this,u).mode,elevation:o(this,v),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),C=new WeakMap,a(tt,"DynamicFocus");var Ft=tt;export{a,st as b,Ft as c};
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -99,7 +99,10 @@ type DynamicFocusState = {
|
|
|
99
99
|
*
|
|
100
100
|
* Set to `false` while the host drives the camera (e.g. a deep-link or scripted
|
|
101
101
|
* sequence) to suspend focus; flipping back to `true` re-applies the suspended
|
|
102
|
-
* scene
|
|
102
|
+
* scene. When the current floor is still the outdoor default, the deferred
|
|
103
|
+
* transition completes including setFloor (subject to `setFloorOnFocus`);
|
|
104
|
+
* otherwise only building states are re-applied and the host's floor is
|
|
105
|
+
* preserved.
|
|
103
106
|
* @default true
|
|
104
107
|
*/
|
|
105
108
|
autoFocus: boolean;
|
|
@@ -1077,9 +1080,10 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
|
|
|
1077
1080
|
* Updates the state of the Dynamic Focus controller.
|
|
1078
1081
|
*
|
|
1079
1082
|
* Flipping {@link DynamicFocusState.autoFocus} from `false` to `true` here
|
|
1080
|
-
* applies the scene that was suspended while it was off
|
|
1081
|
-
*
|
|
1082
|
-
*
|
|
1083
|
+
* applies the scene that was suspended while it was off. When the current floor
|
|
1084
|
+
* is still the outdoor default, the full transition runs, including setFloor
|
|
1085
|
+
* (SDKS-3853); when the host has committed its own floor, only states are
|
|
1086
|
+
* re-applied, preserving the host's floor choice (deep-links, SDKS-3816).
|
|
1083
1087
|
* @param incomingState - The partial state to merge into the current state.
|
|
1084
1088
|
*/
|
|
1085
1089
|
updateState(incomingState: Partial<DynamicFocusState>): void;
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as o,c as t}from"./chunk-
|
|
1
|
+
import{b as o,c as t}from"./chunk-5WRZZYT2.js";export{t as DynamicFocus,o as calculateZoomThresholds};
|
package/lib/esm/react/index.d.ts
CHANGED
|
@@ -67,7 +67,10 @@ type DynamicFocusState = {
|
|
|
67
67
|
*
|
|
68
68
|
* Set to `false` while the host drives the camera (e.g. a deep-link or scripted
|
|
69
69
|
* sequence) to suspend focus; flipping back to `true` re-applies the suspended
|
|
70
|
-
* scene
|
|
70
|
+
* scene. When the current floor is still the outdoor default, the deferred
|
|
71
|
+
* transition completes including setFloor (subject to `setFloorOnFocus`);
|
|
72
|
+
* otherwise only building states are re-applied and the host's floor is
|
|
73
|
+
* preserved.
|
|
71
74
|
* @default true
|
|
72
75
|
*/
|
|
73
76
|
autoFocus: boolean;
|
|
@@ -1045,9 +1048,10 @@ declare class DynamicFocus implements MapViewExtension<DynamicFocusState> {
|
|
|
1045
1048
|
* Updates the state of the Dynamic Focus controller.
|
|
1046
1049
|
*
|
|
1047
1050
|
* Flipping {@link DynamicFocusState.autoFocus} from `false` to `true` here
|
|
1048
|
-
* applies the scene that was suspended while it was off
|
|
1049
|
-
*
|
|
1050
|
-
*
|
|
1051
|
+
* applies the scene that was suspended while it was off. When the current floor
|
|
1052
|
+
* is still the outdoor default, the full transition runs, including setFloor
|
|
1053
|
+
* (SDKS-3853); when the host has committed its own floor, only states are
|
|
1054
|
+
* re-applied, preserving the host's floor choice (deep-links, SDKS-3816).
|
|
1051
1055
|
* @param incomingState - The partial state to merge into the current state.
|
|
1052
1056
|
*/
|
|
1053
1057
|
updateState(incomingState: Partial<DynamicFocusState>): void;
|
package/lib/esm/react/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,c as a}from"../chunk-
|
|
1
|
+
import{a as t,c as a}from"../chunk-5WRZZYT2.js";import{useCallback as y,useState as p,useMemo as F}from"react";import{useMap as l,useMapViewExtension as D}from"@mappedin/react-sdk";function d(){let[,n]=p({});return y(()=>n({}),[])}t(d,"useForceUpdate");function i(){let{mapView:n}=l(),r=d(),{register:o}=D("dynamic-focus",{onRegister:t(()=>{let e=new a(n);return e.on("state-change",r),e},"onRegister"),onDeregister:t(e=>{e.off("state-change",r),e.destroy()},"onDeregister")}),s=o();if(!s)throw new Error("DynamicFocus is not initialized");return F(()=>{let e=new WeakMap;return new Proxy(s,{get(u,m){let c=u[m];return typeof c=="function"?(e.has(c)||e.set(c,c.bind(u)),e.get(c)):c}})},[s])}t(i,"useDynamicFocus");import{useCallback as w,useEffect as E,useRef as k}from"react";function x(n,r){let o=i(),s=k(r);s.current=r;let e=w(u=>{s.current(u)},[]);E(()=>{if(o!=null)return o.on(n,e),()=>{o?.off(n,e)}},[o,n,e])}t(x,"useDynamicFocusEvent");export{i as useDynamicFocus,x as useDynamicFocusEvent};
|
package/lib/rn/index-rn.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var C=Object.defineProperty,n=(
|
|
2
|
-
${l.stack}`:l);window.rnDebug(`${e} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...t){this.logState<=0&&(console.debug(o,...t),i("debug",t))},log(...t){this.debug(...t)},info(...t){this.logState<=1&&(console.info(o,...t),i("info",t))},warn(...t){this.logState<=2&&(console.warn(o,...t),i("warn",t))},error(...t){this.logState<=3&&(console.error(o,...t),i("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){const r=typeof t=="string"?v(t):t;if(r===void 0||!(r>=0&&r<=4)){console.warn(o,`setLevel: unknown log level "${t}"`);return}this.logState=r}}}n(m,"createLogger");var Q=m(),F=m("",{prefix:"[DynamicFocus]"});import{MappedinContext as N,useEventCallback as G,createEventSetupScript as R,createEventCleanupScript as j}from"@mappedin/react-native-sdk";function S(e,s){return s.map(o=>o&&o.id&&e.getById("facade",o.id)||o)}n(S,"hydrateFacades");import{useRegisterExtension as P}from"@mappedin/react-native-sdk";var U='\n // Define require function that uses bridge.modules for external dependencies\n globalThis.require = globalThis.require || ((id) => {\n if (window.bridge?.modules?.[id]) {\n return window.bridge.modules[id];\n }\n throw new Error(\'Module not found: \' + id);\n });\n \n"use strict";var DynamicFocus=(()=>{var io=Object.defineProperty;var Bt=Object.getOwnPropertyDescriptor;var kt=Object.getOwnPropertyNames;var Lt=Object.prototype.hasOwnProperty;var ut=s=>{throw TypeError(s)};var Mt=(s,t,e)=>t in s?io(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t)=>io(s,"name",{value:t,configurable:!0}),Po=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error(\'Dynamic require of "\'+s+\'" is not supported\')});var Zt=(s,t)=>{for(var e in t)io(s,e,{get:t[e],enumerable:!0})},_t=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of kt(t))!Lt.call(s,r)&&r!==e&&io(s,r,{get:()=>t[r],enumerable:!(i=Bt(t,r))||i.enumerable});return s};var xt=s=>_t(io({},"__esModule",{value:!0}),s);var F=(s,t,e)=>Mt(s,typeof t!="symbol"?t+"":t,e),Uo=(s,t,e)=>t.has(s)||ut("Cannot "+e);var o=(s,t,e)=>(Uo(s,t,"read from private field"),e?e.call(s):t.get(s)),c=(s,t,e)=>t.has(s)?ut("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),h=(s,t,e,i)=>(Uo(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e),g=(s,t,e)=>(Uo(s,t,"access private method"),e);var Qt={};Zt(Qt,{DynamicFocus:()=>Mo,calculateZoomThresholds:()=>Do});var No=Po("@mappedin/mappedin-js");function dt(s,t){if(s==null||t==null)return s===t;if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}a(dt,"arraysEqual");var $o=class $o{constructor(){F(this,"_subscribers",{});F(this,"_abortController",new AbortController)}get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let r=i?.signal;if(r?.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 r&&r.addEventListener("abort",n,{once:!0}),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a($o,"PubSub");var wo=$o;var H=Po("@mappedin/mappedin-js");var A,ro,G,v,T,I,W,q,jo=class jo{constructor(t,e){F(this,"__type","building");c(this,A);c(this,ro,new Map);c(this,G,new Map);c(this,v,[]);c(this,T);c(this,I);F(this,"defaultFloor");F(this,"activeFloor");F(this,"excluded",!1);F(this,"aboveGroundFloors",[]);c(this,W);c(this,q);h(this,A,t),h(this,ro,new Map(t.floors.map(r=>[r.id,r]))),h(this,G,new Map(t.floors.map(r=>[r.elevation,r]))),h(this,v,Array.from(o(this,G).values()).sort((r,n)=>r.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,h(this,T,e),this.aboveGroundFloors=o(this,v).filter(r=>r.elevation>=0)}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,T).currentFloorStack.id}get isIndoor(){let t=o(this,T).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,W)==null&&h(this,W,Math.max(...o(this,G).keys())),o(this,W)}get minElevation(){return o(this,q)==null&&h(this,q,Math.min(...o(this,G).keys())),o(this,q)}has(t){return H.Floor.is(t)?o(this,ro).has(t.id):H.FloorStack.is(t)?t.id===o(this,A).id:H.Facade.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,v)[o(this,v).length-1];for(let i=o(this,v).length-1;i>=0;i--){let r=o(this,v)[i];if(r.elevation<=t)return r}}else{if(t<this.minElevation)return o(this,v)[0];for(let i of o(this,v))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,v)[o(this,v).length-1]}cancelAnimation(){o(this,I)&&(o(this,I).animation.cancel(),h(this,I,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,I)?.state||o(this,T).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:n}=t;if(o(this,T).updateState(this.facade,{visible:!0}),r!==void 0){h(this,I,{animation:o(this,T).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let f=await o(this,I).animation;if(h(this,I,void 0),f.result==="cancelled")return f}return n===!1&&o(this,T).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,A).floors.forEach(t=>{o(this,T).updateState(t,{visible:t.id===o(this,T).currentFloor.id})}),this.has(o(this,T).currentFloor)||o(this,T).updateState(this.facade,{visible:!0,opacity:1})}};A=new WeakMap,ro=new WeakMap,G=new WeakMap,v=new WeakMap,T=new WeakMap,I=new WeakMap,W=new WeakMap,q=new WeakMap,a(jo,"Building");var Oo=jo;function ct(s,t,e){return s>=t?"in-range":s<=e?"out-of-range":"transition"}a(ct,"getZoomState");function Vo(s,t,e){if(s.__type==="outdoors"&&"floor"in s)return s.floor;let i=s;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Vo,"getFloorToShow");function Nt(s,t,e,i){return i?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:s,state:{type:"facade",visible:!0,opacity:.2}}:{facade:s,state:{type:"facade",visible:!0,opacity:1}}}a(Nt,"getFacadeState");function Ct(s,t,e){return{outdoorOpacity:"initial",floorStates:s.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(Ct,"getSingleBuildingState");function ht(s,t){if(!t.includes("lock-elevation"))return"initial";for(let e of s)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(ht,"getOutdoorOpacity");function ft(s,t,e){switch(e){case"in-range":return s[0]?.canSetFloor?s[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(ft,"getSetFloorTargetFromZoomState");function mt(s){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:y,multiFloorView:d,getMultiFloorState:V,dynamicBuildingInteriors:w,isolateBelowGroundView:C,currentElevation:So,forceInteriorsVisible:eo,getFloorStackAltitudeData:Eo}=s,To=new Map,Co=C&&So<0&&r==="in-range";for(let b of t){let lt=e.has(b.id),vo=Co&&b.minElevation>=0,Vt=vo?!1:lt,Go=vo?!1:zo({building:b,currentFloor:i,inRange:r==="in-range",inFocus:lt,mode:n,elevation:f,inNavigation:y.includes(b.id),dynamicBuildingInteriors:w,forceInteriorsVisible:eo}),Ro=i.floorStack.id===b.id?b.activeFloor:Vo(b,n,f),At=d?.enabled?V(b.floors,Ro||b.activeFloor,p,Eo(b.id),{color:d?.footprintColor,spacesOpenToBelowEnabled:d?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:d?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:d?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:d?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:d?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:d?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:d?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:d?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:d?.footprintOpacity,outline:d?.footprintOutline}):Ct(b.floorStack,Ro||b.activeFloor,Go),It=C&&So<0&&r==="in-range",Dt=Nt(b.facade,Go,It,vo);To.set(b.id,{building:b,showIndoor:Go,floorStackState:At,facadeState:Dt,inFocus:Vt,floorToShow:Ro,isAboveGroundInIsolation:vo})}return To}a(mt,"getBuildingStates");function pt(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(pt,"getBuildingAnimationType");function zo(s){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:y,forceInteriorsVisible:d}=s;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(d===!0||p===!0)return!0;if(!y)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a(zo,"shouldShowIndoor");function gt(s,t,e){return s!==t&&!e}a(gt,"shouldDeferSetFloor");var Ft=["default-floor","active-floor","lock-elevation","nearest-elevation"];var Ao=Po("@mappedin/mappedin-js");var Yo="[MappedinJS]";var Gt={log:0,debug:0,info:1,warn:2,error:3,silent:4};function Rt(s){return Gt[s.toLowerCase()]}a(Rt,"parseLogLevel");function Wo(s="",{prefix:t=Yo}={}){let e=`${t}${s?`-${s}`:""}`,i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}\n${p.stack}`:p);window.rnDebug(`${s} ${r}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...r){this.logState<=0&&(console.debug(e,...r),i("debug",r))},log(...r){this.debug(...r)},info(...r){this.logState<=1&&(console.info(e,...r),i("info",r))},warn(...r){this.logState<=2&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=3&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){let n=typeof r=="string"?Rt(r):r;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${r}"`);return}this.logState=n}}}a(Wo,"createLogger");var Pt=Wo();var K=Pt;function bt(s,t,e,i){return(s<t||s>e)&&K.warn(i),Math.min(e,Math.max(t,s))}a(bt,"clampWithWarning");function qo(s,t){return!Ao.Floor.is(s)||s?.floorStack==null||!Ao.FloorStack.is(t)?!1:s.floorStack.id!==t.id?(K.warn(`Floor (${s.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(qo,"validateFloorForStack");function Ho(s,t,e,i){return bt(s,t,e,`${i} must be between ${t} and ${e}.`)}a(Ho,"validateZoomThreshold");var O=Wo("",{prefix:"[DynamicFocus]"});var D,Q,so,Ko,Qo=class Qo{constructor(t,e){c(this,so);F(this,"__type","outdoors");c(this,D);c(this,Q);h(this,D,t),h(this,Q,e)}get id(){return o(this,D).id}get floorStack(){return o(this,D)}get floor(){return o(this,D).defaultFloor}matchesFloorStack(t){return t===o(this,D)||t===o(this,D).id}show(){g(this,so,Ko).call(this,!0)}hide(){g(this,so,Ko).call(this,!1)}destroy(){this.matchesFloorStack(o(this,Q).currentFloorStack)||this.hide()}};D=new WeakMap,Q=new WeakMap,so=new WeakSet,Ko=a(function(t){for(let e of o(this,D).floors)o(this,Q).updateState(e,{visible:t})},"#setVisible"),a(Qo,"Outdoors");var Io=Qo;function yt(s,t){let e=s.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let r=e.find(n=>n.facade==null&&!t.has(n.id));return r||(O.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(yt,"getOutdoorFloorStack");var no={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!0,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},ao=.2,Jo=.4;var Do=a((s,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Ut(s,e);if(i===void 0)return O.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:no.indoorZoomThreshold,outdoorZoomThreshold:no.outdoorZoomThreshold};let r=i+Jo,n=i+ao;return e.initialVisibility==="indoor-first"&&(r=i-ao,n=i-Jo),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Ut(s,t){let i=s.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),r=1/0,n;for(let f of i){let p=s.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<r&&(r=p,n=f)}if(r!==1/0)return t.debug&&n&&s.Camera.getFocusOnTransform(n,{debugColor:"blue"}),r}a(Ut,"getDefaultZoomLevel");function $t(s,t){return`${t} ${s}`}a($t,"formatMessage");var Xo=class Xo extends Error{constructor(t,e=Yo){super($t(t,e)),this.name="MappedinError"}};a(Xo,"MappedinError");var Bo=Xo;var jt=a(s=>s,"linearEase"),zt=a(s=>s*s,"quadEaseIn"),Yt=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),Wt=a(s=>1-(1-s)*(1-s),"quadEaseOut"),qt=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Ht={linear:jt,"ease-in":zt,"ease-out":Wt,"ease-in-out":Yt,"ease-out-cubic":qt};function Kt(s,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&r(s,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Kt,"getInterpolationBreakpoint");function St(s,t,e,i="ease-in"){if(t.length!==e.length)throw new Bo("Input and output ranges must have the same number of values.");s=Math.max(t[0],Math.min(s,t[t.length-1]));let r=Kt(s,t),n=(s-t[r])/(t[r+1]-t[r]),f=typeof i=="function"?i(n):Ht[i](n);return e[r]+f*(e[r+1]-e[r])}a(St,"interpolateMulti");var B,lo,uo,M,co,tt=class tt{constructor(t,e,i){F(this,"layers");F(this,"visible");c(this,B);c(this,lo,[]);c(this,uo,!1);c(this,M,new Map);F(this,"interpolationFn");c(this,co,1);this.layers=t,this.visible=e,h(this,B,i)}processLayerGroup(t,e){o(this,uo)||(this.layers.forEach(i=>{let r=t[i];r&&o(this,lo).push(...r)}),h(this,uo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:r,indoorZoomThreshold:n}=e();return St(i,[r,n],[1,0])}))}setOpacity(t){h(this,co,t);for(let e of o(this,lo))if(e.startsWith("img_")){let i=o(this,B).Image3D.getById(e);if(i){if(!o(this,M).has(e)){let n=o(this,B).getState(i.image);o(this,M).set(e,n?.opacity??1)}let r=Math.min(o(this,M).get(e),t);o(this,B).updateState(i.image,{opacity:r})}}else{let i=o(this,B).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,M).has(e)){let n=o(this,B).getState(i);o(this,M).set(e,n?.opacity??1)}let r=Math.min(o(this,M).get(e),t);o(this,B).updateState(i,{opacity:r,visible:r>0})}}get opacity(){return o(this,co)}};B=new WeakMap,lo=new WeakMap,uo=new WeakMap,M=new WeakMap,co=new WeakMap,a(tt,"LayerGroup");var ko=tt;function ot(s,t,e){s.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let r=i.interpolationFn(t);r!=null&&(i.setOpacity(r),i.visible=r===1)}})}a(ot,"runLayerGroupInterpolations");var k,l,R,u,j,z,S,Z,Y,_,E,J,ho,fo,mo,L,P,X,po,x,U,$,m,et,Et,it,rt,st,Tt,nt,oo,go,vt,Zo,_o,xo,Fo,bo,yo,to,Lo,wt,Ot,N,at=class at{constructor(t){c(this,m);c(this,k);c(this,l);c(this,R);c(this,u,no);c(this,j,[]);c(this,z,new Set);c(this,S,new Map);c(this,Z);c(this,Y,!1);c(this,_,!1);c(this,E,0);c(this,J,0);c(this,ho,[]);c(this,fo,{});c(this,mo,{});c(this,L,"transition");c(this,P,"outdoor");c(this,X,[]);c(this,po,[]);c(this,x,!1);c(this,U,[]);c(this,$,null);F(this,"sceneUpdateQueue",Promise.resolve());F(this,"on",a((t,e)=>{o(this,k).on(t,e)},"on"));F(this,"off",a((t,e)=>{o(this,k).off(t,e)},"off"));c(this,oo,a(()=>{h(this,j,[]),o(this,z).clear();let t=o(this,u).isolateBelowGroundView&&o(this,E)<0;for(let e of o(this,po)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,z).add(i.id),o(this,j).push(i)))}},"#updateBuildingsInView"));c(this,go,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;dt(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,_)||(h(this,_,!1),h(this,po,e),o(this,oo).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));c(this,Zo,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let r=o(this,u).isolateBelowGroundView&&o(this,E)<0;i?.excluded===!1&&!o(this,Z).matchesFloorStack(t.floorStack)&&h(this,E,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,E)<0,f=r&&!n;if(e.reason==="dynamic-focus")return;let p=g(this,m,vt).call(this),y=o(this,_o).call(this,t,e,f,p);if(p)return y;y.catch(d=>{O.error("setFloor override work failed after sync floor-change commit",d)})},"#setFloorHandler"));c(this,_o,a(async(t,e,i,r)=>{i&&(h(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),await o(this,N).call(this,t),!(!this.isEnabled||e.signal.aborted)&&r&&this.isEnabled&&!e.signal.aborted&&await o(this,xo).call(this,t)},"#runFloorChangeWork"));c(this,xo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));c(this,Fo,a(()=>{h(this,Y,!0)},"#handleUserInteractionStart"));c(this,bo,a(()=>{h(this,Y,!1)},"#handleUserInteractionEnd"));c(this,yo,a(()=>{o(this,N).call(this)},"#handleGlobalStateChange"));c(this,to,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=ct(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,L)!==i&&(h(this,L,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let r=(o(this,l).Navigation?.floors?.length??0)>0;ot(o(this,U),e,r?{forceOpacity:0}:void 0)},"#handleCameraChange"));c(this,N,a(async t=>{if(!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,r=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(y=>y.id)||[],f=o(this,l).Navigation?.floorStacks.map(y=>y.id)||[],p=new Promise(async y=>{await this.sceneUpdateQueue;let d=mt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,z),currentFloor:e,zoomState:o(this,L),mode:o(this,u).mode,elevation:o(this,E),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:r,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??No.getMultiFloorState,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,E),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(w=>o(this,l).getFloorStackAltitudeData(w),"getFloorStackAltitudeData")}),V=[];await Promise.all(Array.from(d.values()).map(async w=>{let{building:C,showIndoor:So,floorStackState:eo,facadeState:Eo,inFocus:To,isAboveGroundInIsolation:Co}=w;V.push(eo);let b=pt(C,So);if(b==="indoor")return g(this,m,wt).call(this,C,eo,Eo,To);if(b==="outdoor")return g(this,m,Ot).call(this,C,eo,Eo,f,Co)})),o(this,l).Outdoor.setOpacity(ht(V,o(this,u).mode)),h(this,X,o(this,j).filter(w=>d.get(w.id)?.showIndoor===!0).map(w=>w.facade)),o(this,k).publish("focus",{facades:o(this,X)}),y()});return this.sceneUpdateQueue=p,p},"#applyBuildingStates"));h(this,k,new wo),h(this,l,t),O.setLevel(K.logState),h(this,R,o(this,l).getMapData()),h(this,E,o(this,l).currentFloor.elevation),h(this,J,o(this,l).Camera.elevation);for(let e of o(this,R).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){O.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new Oo(i,o(this,l)))}g(this,m,Tt).call(this),h(this,Z,new Io(yt(o(this,R),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,to)),o(this,l).on("facades-in-view-change",o(this,go)),o(this,l).on("user-interaction-start",o(this,Fo)),o(this,l).on("user-interaction-end",o(this,bo)),o(this,l).on("global-state-change",o(this,yo))}enable(t){if(o(this,x)){O.warn("enable() called on an already enabled Dynamic Focus instance.");return}h(this,x,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Zo)),o(this,Z).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),g(this,m,Et).call(this),o(this,to).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,x)){O.warn("disable() called on an already disabled Dynamic Focus instance.");return}h(this,x,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,x)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,Z).floorStack}get layers(){return o(this,ho)}get layersBySpaceId(){return o(this,fo)}setIndoor(){h(this,P,"indoor"),h(this,L,"in-range"),g(this,m,et).call(this)}setOutdoor(){h(this,P,"outdoor"),h(this,L,"out-of-range"),g(this,m,et).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,r=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,E)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,y=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,d=t;if(y&&(d.indoorZoomThreshold!=null||d.outdoorZoomThreshold!=null)){O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:V,outdoorZoomThreshold:w,...C}=d;d=C}if(!p&&y?(h(this,$,()=>{if(!o(this,x))return;let V=o(this,u).indoorZoomThreshold,w=o(this,u).outdoorZoomThreshold;g(this,m,rt).call(this),g(this,m,st).call(this,V,w),o(this,N).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,$))):p&&!y&&g(this,m,it).call(this),d.indoorZoomThreshold!=null&&(d.indoorZoomThreshold=Ho(d.indoorZoomThreshold,d?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),d.outdoorZoomThreshold!=null&&(d.outdoorZoomThreshold=Ho(d.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,d?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),d.mode!=null&&(d.mode=Ft.includes(d.mode)?d.mode:"default-floor"),d.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=d.autoAdjustFacadeHeights),d.dynamicBuildingInteriors!=null&&d.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),d.isolateBelowGroundView!=null&&d.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),d.forceInteriorsVisible!=null&&d.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),d.showLabelsAndMarkersOnAllVisibleFloors!=null&&d.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d.cameraLiftAnimationOptions!=null&&(d={...d,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...d.cameraLiftAnimationOptions}}),h(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(d).filter(([,V])=>V!=null)))),y&&d.autoZoomThresholds!==void 0&&(g(this,m,rt).call(this),e=!0),d.mode!=null&&d.preloadFloors&&g(this,m,nt).call(this,d.mode),e){let V=o(this,u).isolateBelowGroundView&&o(this,E)<0;n&&!V&&(h(this,_,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),o(this,N).call(this)}g(this,m,st).call(this,i,r),!f&&o(this,u).autoFocus&&this.focus(!1)}destroy(){this.disable(),g(this,m,it).call(this),o(this,l).off("facades-in-view-change",o(this,go)),o(this,l).off("camera-change",o(this,to)),o(this,l).off("user-interaction-start",o(this,Fo)),o(this,l).off("user-interaction-end",o(this,bo)),o(this,l).off("global-state-change",o(this,yo)),o(this,S).forEach(t=>t.destroy()),o(this,Z).destroy(),o(this,k).destroy(),h(this,U,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(gt(o(this,J),o(this,l).Camera.elevation,o(this,Y)))h(this,J,o(this,l).Camera.elevation),h(this,_,!0);else{let i=ft(o(this,j),o(this,Z),o(this,L)),r=i?Vo(i,o(this,u).mode,o(this,E)):void 0;r&&r.id!==o(this,l).currentFloor.id&&(e=r,o(this,l).setFloor(r,{context:"dynamic-focus"}))}await o(this,N).call(this,e)}preloadFloors(){g(this,m,nt).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!qo(e,t))return;let i=o(this,S).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,S).get(t.id),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!qo(e,t))return;let i=o(this,S).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 r=o(this,S).get(i.id);r&&(r.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};k=new WeakMap,l=new WeakMap,R=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,Z=new WeakMap,Y=new WeakMap,_=new WeakMap,E=new WeakMap,J=new WeakMap,ho=new WeakMap,fo=new WeakMap,mo=new WeakMap,L=new WeakMap,P=new WeakMap,X=new WeakMap,po=new WeakMap,x=new WeakMap,U=new WeakMap,$=new WeakMap,m=new WeakSet,et=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():h(this,_,!0)),o(this,k).publish("state-change")},"#handleViewStateChange"),Et=a(function(){h(this,U,[]);for(let e of o(this,u).dynamicLayers){let i=new ko([e],!0,o(this,l));i.processLayerGroup(o(this,mo),()=>o(this,u)),o(this,U).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;ot(o(this,U),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),it=a(function(){o(this,$)&&(o(this,l).off("camera-screen-offsets-change",o(this,$)),h(this,$,null))},"#unsubscribeScreenOffsets"),rt=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:r}=Do(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=r,(e.expandMinZoom??!0)&&r<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(r-ao)},"#recalcThresholds"),st=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,k).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),Tt=a(function(){let t=o(this,R).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(r=>{e[r.name]||(e[r.name]=[]),e[r.name].push(...r.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of r.spaces)i[n]==null&&(i[n]=[]),i[n].push(r.name)}),h(this,ho,t.map(({name:r})=>r)),h(this,fo,i),h(this,mo,e)},"#setupLayers"),nt=a(function(t){let e=[];for(let i of o(this,R).getByType("facade")){let r=o(this,S).get(i.floorStack.id);if(!r)continue;let n=Vo(r,t,o(this,E));n!=null&&No.Floor.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),oo=new WeakMap,go=new WeakMap,vt=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Zo=new WeakMap,_o=new WeakMap,xo=new WeakMap,Fo=new WeakMap,bo=new WeakMap,yo=new WeakMap,to=new WeakMap,Lo=a(function(t,e,i,r=!1){t.forEach(n=>{if(n.floor)if(e){let p=i!==void 0&&!r?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),wt=a(async function(t,e,i,r){return g(this,m,Lo).call(this,e.floorStates,!0,r,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Ot=a(async function(t,e,i,r,n){let f=n;f&&g(this,m,Lo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&g(this,m,Lo).call(this,e.floorStates,zo({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,L)==="in-range",inFocus:o(this,z).has(t.id),mode:o(this,u).mode,elevation:o(this,E),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),N=new WeakMap,a(at,"DynamicFocus");var Mo=at;return xt(Qt);})();\n\n\n// Register the extension\nif (window.bridge && window.bridge.extensions) {\n try {\n window.bridge.extensions.register({ name: \'dynamic-focus\', package: { Extension: DynamicFocus.DynamicFocus } });\n if (window.rnDebug) window.rnDebug(\'Extension: dynamic-focus registered\');\n } catch(e) {\n if (window.rnDebug) window.rnDebug(\'Failed to register dynamic-focus extension: \' + e.message);\n }\n} else {\n if (window.rnDebug) window.rnDebug(\'Bridge or extensions not available for registration\');\n}';function k(){return U}n(k,"getRegistrationScript");function g(){P({extensionName:"dynamic-focus",getRegistrationScript:k,logger:F})}n(g,"useDynamicFocusRegistration");function b(e,s){if(typeof e!="string"||e.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof s!="function")throw new Error("Callback parameter must be a function");const o=W(N),{extensions:i,mapData:t}=o;if(!t)throw new Error("Map data is not available");g();const f=(i?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",l=x(c=>{try{let u=c;e==="focus"&&c.facades&&(u={...c,facades:S(t,c.facades)}),s(u)}catch(u){F.error(`Error in dynamic focus event callback for ${String(e)}:`,u)}},[e,t,s]);G({eventKey:`dynamic-focus:${String(e)}`,callback:l,setupScript:n(()=>R({extensionName:"dynamic-focus",eventName:String(e)}),"setupScript"),cleanupScript:n(()=>j({extensionName:"dynamic-focus",eventName:String(e)}),"cleanupScript"),shouldInject:f})}n(b,"useDynamicFocusEvent");function E(){const e=L(D),{bridge:s,extensions:o,updateExtensionState:i}=e;g();const t=o["dynamic-focus"],r=t?.registrationState||"unregistered",f=r==="registered",l=t?.isEnabled||!1,[c,u]=B(t?.focusedFacades||[]),w=A(o);w.current=o,b("focus",d(h=>{const p=h.facades;u(p),i("dynamic-focus",y=>({...y,registrationState:r,focusedFacades:p}))},[r,i]));const a=d(async(h,p=[])=>{if(!s?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await s.instruct({type:"extension",payload:{name:"dynamic-focus",method:h,args:p}})},[s]),T=d(async h=>{w.current?.["dynamic-focus"]?.isEnabled||(await a("enable",[h]),i("dynamic-focus",V=>({...V,isEnabled:!0})))},[a,i]),M=d(async h=>await a("updateState",[h]),[a]),O=d(async()=>await a("getState"),[a]),I=d(async h=>await a("focus",[h]),[a]),Z=d(async()=>{await a("disable"),u([]),i("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[a,u,i]);return{isReady:f,isEnabled:l,focusedFacades:c,updateState:M,getState:O,focus:I,disable:Z,enable:T}}n(E,"useDynamicFocus");export{E as useDynamicFocus,b as useDynamicFocusEvent};
|
|
1
|
+
var C=Object.defineProperty,n=(o,s)=>C(o,"name",{value:s,configurable:!0});import{useState as B,useCallback as d,useContext as L,useRef as A}from"react";import{MappedinContext as x}from"@mappedin/react-native-sdk";import{useCallback as D,useContext as W}from"react";var _="[MappedinJS]",$={log:0,debug:0,info:1,warn:2,error:3,silent:4};function v(o){return $[o.toLowerCase()]}n(v,"parseLogLevel");function m(o="",{prefix:s=_}={}){const e=`${s}${o?`-${o}`:""}`,i=n((t,r)=>{if(typeof window<"u"&&window.rnDebug){const f=r.map(l=>l instanceof Error&&l.stack?`${l.message}
|
|
2
|
+
${l.stack}`:l);window.rnDebug(`${o} ${t}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...t){this.logState<=0&&(console.debug(e,...t),i("debug",t))},log(...t){this.debug(...t)},info(...t){this.logState<=1&&(console.info(e,...t),i("info",t))},warn(...t){this.logState<=2&&(console.warn(e,...t),i("warn",t))},error(...t){this.logState<=3&&(console.error(e,...t),i("error",t))},assert(...t){console.assert(...t)},time(t){console.time(t)},timeEnd(t){console.timeEnd(t)},setLevel(t){const r=typeof t=="string"?v(t):t;if(r===void 0||!(r>=0&&r<=4)){console.warn(e,`setLevel: unknown log level "${t}"`);return}this.logState=r}}}n(m,"createLogger");var Q=m(),F=m("",{prefix:"[DynamicFocus]"});import{MappedinContext as N,useEventCallback as G,createEventSetupScript as R,createEventCleanupScript as j}from"@mappedin/react-native-sdk";function S(o,s){return s.map(e=>e&&e.id&&o.getById("facade",e.id)||e)}n(S,"hydrateFacades");import{useRegisterExtension as P}from"@mappedin/react-native-sdk";var U='\n // Define require function that uses bridge.modules for external dependencies\n globalThis.require = globalThis.require || ((id) => {\n if (window.bridge?.modules?.[id]) {\n return window.bridge.modules[id];\n }\n throw new Error(\'Module not found: \' + id);\n });\n \n"use strict";var DynamicFocus=(()=>{var io=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var Bt=Object.getOwnPropertyNames;var Lt=Object.prototype.hasOwnProperty;var ut=s=>{throw TypeError(s)};var Mt=(s,t,e)=>t in s?io(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var a=(s,t)=>io(s,"name",{value:t,configurable:!0}),Po=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error(\'Dynamic require of "\'+s+\'" is not supported\')});var Zt=(s,t)=>{for(var e in t)io(s,e,{get:t[e],enumerable:!0})},_t=(s,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Bt(t))!Lt.call(s,r)&&r!==e&&io(s,r,{get:()=>t[r],enumerable:!(i=Dt(t,r))||i.enumerable});return s};var xt=s=>_t(io({},"__esModule",{value:!0}),s);var F=(s,t,e)=>Mt(s,typeof t!="symbol"?t+"":t,e),Uo=(s,t,e)=>t.has(s)||ut("Cannot "+e);var o=(s,t,e)=>(Uo(s,t,"read from private field"),e?e.call(s):t.get(s)),c=(s,t,e)=>t.has(s)?ut("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,e),h=(s,t,e,i)=>(Uo(s,t,"write to private field"),i?i.call(s,e):t.set(s,e),e),g=(s,t,e)=>(Uo(s,t,"access private method"),e);var Qt={};Zt(Qt,{DynamicFocus:()=>Mo,calculateZoomThresholds:()=>ko});var No=Po("@mappedin/mappedin-js");function dt(s,t){if(s==null||t==null)return s===t;if(s.length!==t.length)return!1;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return!1;return!0}a(dt,"arraysEqual");var $o=class $o{constructor(){F(this,"_subscribers",{});F(this,"_abortController",new AbortController)}get signal(){return this._abortController.signal}publish(t,e){!this._subscribers||!this._subscribers[t]||this.signal.aborted||this._subscribers[t].forEach(function(i){typeof i=="function"&&i(e)})}onAbort(t){this.signal.addEventListener("abort",()=>t(),{once:!0})}on(t,e,i){let r=i?.signal;if(r?.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 r&&r.addEventListener("abort",n,{once:!0}),n}off(t,e){if(!this._subscribers||this._subscribers[t]==null||this.signal.aborted)return;let i=this._subscribers[t].indexOf(e);i!==-1&&this._subscribers[t].splice(i,1)}destroy(){this.signal.aborted||(this._subscribers={},this._abortController.abort())}};a($o,"PubSub");var wo=$o;var K=Po("@mappedin/mappedin-js");var A,ro,G,v,T,I,q,H,jo=class jo{constructor(t,e){F(this,"__type","building");c(this,A);c(this,ro,new Map);c(this,G,new Map);c(this,v,[]);c(this,T);c(this,I);F(this,"defaultFloor");F(this,"activeFloor");F(this,"excluded",!1);F(this,"aboveGroundFloors",[]);c(this,q);c(this,H);h(this,A,t),h(this,ro,new Map(t.floors.map(r=>[r.id,r]))),h(this,G,new Map(t.floors.map(r=>[r.elevation,r]))),h(this,v,Array.from(o(this,G).values()).sort((r,n)=>r.elevation-n.elevation));let i=t.defaultFloor;if(!i)throw new Error(`Building created for floor stack "${t.id}" with no resolvable default floor`);this.defaultFloor=i,this.activeFloor=this.defaultFloor,h(this,T,e),this.aboveGroundFloors=o(this,v).filter(r=>r.elevation>=0)}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,T).currentFloorStack.id}get isIndoor(){let t=o(this,T).getState(this.facade);return this.isCurrentFloorStack||t?.visible===!1&&t?.opacity===0}get canSetFloor(){return this.isIndoor||!this.excluded}get maxElevation(){return o(this,q)==null&&h(this,q,Math.max(...o(this,G).keys())),o(this,q)}get minElevation(){return o(this,H)==null&&h(this,H,Math.min(...o(this,G).keys())),o(this,H)}has(t){return K.Floor.is(t)?o(this,ro).has(t.id):K.FloorStack.is(t)?t.id===o(this,A).id:K.Facade.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,v)[o(this,v).length-1];for(let i=o(this,v).length-1;i>=0;i--){let r=o(this,v)[i];if(r.elevation<=t)return r}}else{if(t<this.minElevation)return o(this,v)[0];for(let i of o(this,v))if(i.elevation>=t)return i}}getHighestFloor(){return o(this,v)[o(this,v).length-1]}cancelAnimation(){o(this,I)&&(o(this,I).animation.cancel(),h(this,I,void 0))}async animateFacade(t,e={duration:150}){let i=o(this,I)?.state||o(this,T).getState(this.facade);if(!i||!t||i?.opacity===t.opacity&&i?.visible===t.visible)return{result:"completed"};this.cancelAnimation();let{opacity:r,visible:n}=t;if(o(this,T).updateState(this.facade,{visible:!0}),r!==void 0){h(this,I,{animation:o(this,T).animateState(this.facade,{opacity:r},{duration:e.duration}),state:t});let f=await o(this,I).animation;if(h(this,I,void 0),f.result==="cancelled")return f}return n===!1&&o(this,T).updateState(this.facade,{visible:n}),{result:"completed"}}destroy(){this.cancelAnimation(),o(this,A).floors.forEach(t=>{o(this,T).updateState(t,{visible:t.id===o(this,T).currentFloor.id})}),this.has(o(this,T).currentFloor)||o(this,T).updateState(this.facade,{visible:!0,opacity:1})}};A=new WeakMap,ro=new WeakMap,G=new WeakMap,v=new WeakMap,T=new WeakMap,I=new WeakMap,q=new WeakMap,H=new WeakMap,a(jo,"Building");var Oo=jo;function ct(s,t,e){return s>=t?"in-range":s<=e?"out-of-range":"transition"}a(ct,"getZoomState");function Vo(s,t,e){if(s.__type==="outdoors"&&"floor"in s)return s.floor;let i=s;if(i.excluded)return i.activeFloor;switch(t){case"lock-elevation":return i.getFloorByElevation(e);case"nearest-elevation":return i.getNearestFloorByElevation(e);case"active-floor":return i.activeFloor;default:break}return i.isIndoor?i.activeFloor:i.defaultFloor}a(Vo,"getFloorToShow");function Nt(s,t,e,i){return i?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:t?{facade:s,state:{type:"facade",visible:!1,opacity:0}}:e?{facade:s,state:{type:"facade",visible:!0,opacity:.2}}:{facade:s,state:{type:"facade",visible:!0,opacity:1}}}a(Nt,"getFacadeState");function Ct(s,t,e){return{outdoorOpacity:"initial",floorStates:s.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(Ct,"getSingleBuildingState");function ht(s,t){if(!t.includes("lock-elevation"))return"initial";for(let e of s)if(typeof e.outdoorOpacity=="number"&&e.outdoorOpacity>=0&&e.outdoorOpacity<=1)return e.outdoorOpacity;return"initial"}a(ht,"getOutdoorOpacity");function ft(s,t,e){switch(e){case"in-range":return s[0]?.canSetFloor?s[0]:void 0;case"out-of-range":return t;case"transition":default:return}}a(ft,"getSetFloorTargetFromZoomState");function mt(s){let{buildings:t,inViewSet:e,currentFloor:i,zoomState:r,mode:n,elevation:f,floorIdsInNavigation:p,floorStackIdsInNavigation:y,multiFloorView:d,getMultiFloorState:V,dynamicBuildingInteriors:w,isolateBelowGroundView:C,currentElevation:So,forceInteriorsVisible:eo,getFloorStackAltitudeData:Eo}=s,To=new Map,Co=C&&So<0&&r==="in-range";for(let b of t){let lt=e.has(b.id),vo=Co&&b.minElevation>=0,Vt=vo?!1:lt,Go=vo?!1:zo({building:b,currentFloor:i,inRange:r==="in-range",inFocus:lt,mode:n,elevation:f,inNavigation:y.includes(b.id),dynamicBuildingInteriors:w,forceInteriorsVisible:eo}),Ro=i.floorStack.id===b.id?b.activeFloor:Vo(b,n,f),At=d?.enabled?V(b.floors,Ro||b.activeFloor,p,Eo(b.id),{color:d?.footprintColor,spacesOpenToBelowEnabled:d?.spacesOpenToBelowEnabled,spacesOpenToBelowVisualEffectEnabled:d?.spacesOpenToBelowVisualEffectEnabled,spacesOpenToBelowVisualEffectDarkenAmount:d?.spacesOpenToBelowVisualEffectDarkenAmount,spacesOpenToBelowVisualEffectDarkenUseDepth:d?.spacesOpenToBelowVisualEffectDarkenUseDepth,spacesOpenToBelowVisualEffectDesaturateAmount:d?.spacesOpenToBelowVisualEffectDesaturateAmount,spacesOpenToBelowVisualEffectDesaturateUseDepth:d?.spacesOpenToBelowVisualEffectDesaturateUseDepth,spacesOpenToBelowVisualEffectWashOutAmount:d?.spacesOpenToBelowVisualEffectWashOutAmount,spacesOpenToBelowVisualEffectWashOutUseDepth:d?.spacesOpenToBelowVisualEffectWashOutUseDepth,opacity:d?.footprintOpacity,outline:d?.footprintOutline}):Ct(b.floorStack,Ro||b.activeFloor,Go),It=C&&So<0&&r==="in-range",kt=Nt(b.facade,Go,It,vo);To.set(b.id,{building:b,showIndoor:Go,floorStackState:At,facadeState:kt,inFocus:Vt,floorToShow:Ro,isAboveGroundInIsolation:vo})}return To}a(mt,"getBuildingStates");function pt(s,t){return s.excluded?"none":t?"indoor":"outdoor"}a(pt,"getBuildingAnimationType");function zo(s){let{building:t,currentFloor:e,inRange:i,inFocus:r,mode:n,elevation:f,inNavigation:p,dynamicBuildingInteriors:y,forceInteriorsVisible:d}=s;if(t.id===e.floorStack.id)return!0;if(t.excluded)return!1;if(d===!0||p===!0)return!0;if(!y)return e.floorStack.type!=="Outdoor";if(!i||!r)return!1;switch(n){case"lock-elevation":return t.getFloorByElevation(f)!=null;default:break}return!0}a(zo,"shouldShowIndoor");function gt(s,t,e){return s!==t&&!e}a(gt,"shouldDeferSetFloor");var Ft=["default-floor","active-floor","lock-elevation","nearest-elevation"];var Ao=Po("@mappedin/mappedin-js");var Yo="[MappedinJS]";var Gt={log:0,debug:0,info:1,warn:2,error:3,silent:4};function Rt(s){return Gt[s.toLowerCase()]}a(Rt,"parseLogLevel");function Wo(s="",{prefix:t=Yo}={}){let e=`${t}${s?`-${s}`:""}`,i=a((r,n)=>{if(typeof window<"u"&&window.rnDebug){let f=n.map(p=>p instanceof Error&&p.stack?`${p.message}\n${p.stack}`:p);window.rnDebug(`${s} ${r}: ${f.join(" ")}`)}},"rnDebug");return{logState:1,debug(...r){this.logState<=0&&(console.debug(e,...r),i("debug",r))},log(...r){this.debug(...r)},info(...r){this.logState<=1&&(console.info(e,...r),i("info",r))},warn(...r){this.logState<=2&&(console.warn(e,...r),i("warn",r))},error(...r){this.logState<=3&&(console.error(e,...r),i("error",r))},assert(...r){console.assert(...r)},time(r){console.time(r)},timeEnd(r){console.timeEnd(r)},setLevel(r){let n=typeof r=="string"?Rt(r):r;if(n===void 0||!(n>=0&&n<=4)){console.warn(e,`setLevel: unknown log level "${r}"`);return}this.logState=n}}}a(Wo,"createLogger");var Pt=Wo();var Q=Pt;function bt(s,t,e,i){return(s<t||s>e)&&Q.warn(i),Math.min(e,Math.max(t,s))}a(bt,"clampWithWarning");function qo(s,t){return!Ao.Floor.is(s)||s?.floorStack==null||!Ao.FloorStack.is(t)?!1:s.floorStack.id!==t.id?(Q.warn(`Floor (${s.id}) does not belong to floor stack (${t.id}).`),!1):!0}a(qo,"validateFloorForStack");function Ho(s,t,e,i){return bt(s,t,e,`${i} must be between ${t} and ${e}.`)}a(Ho,"validateZoomThreshold");var O=Wo("",{prefix:"[DynamicFocus]"});var k,J,so,Ko,Qo=class Qo{constructor(t,e){c(this,so);F(this,"__type","outdoors");c(this,k);c(this,J);h(this,k,t),h(this,J,e)}get id(){return o(this,k).id}get floorStack(){return o(this,k)}get floor(){return o(this,k).defaultFloor}matchesFloorStack(t){return t===o(this,k)||t===o(this,k).id}show(){g(this,so,Ko).call(this,!0)}hide(){g(this,so,Ko).call(this,!1)}destroy(){this.matchesFloorStack(o(this,J).currentFloorStack)||this.hide()}};k=new WeakMap,J=new WeakMap,so=new WeakSet,Ko=a(function(t){for(let e of o(this,k).floors)o(this,J).updateState(e,{visible:t})},"#setVisible"),a(Qo,"Outdoors");var Io=Qo;function yt(s,t){let e=s.getByType("floor-stack"),i=e.find(n=>n.type?.toLowerCase()==="outdoor");if(i)return i;let r=e.find(n=>n.facade==null&&!t.has(n.id));return r||(O.warn("No good candidate for the outdoor floor stack was found. Using the first floor stack."),e[0])}a(yt,"getOutdoorFloorStack");var no={indoorZoomThreshold:18,outdoorZoomThreshold:17,setFloorOnFocus:!0,autoFocus:!0,indoorAnimationOptions:{duration:150},outdoorAnimationOptions:{duration:150},cameraLiftAnimationOptions:{duration:500,easing:"ease-in-out",interruptible:!0},autoAdjustFacadeHeights:!1,mode:"default-floor",preloadFloors:!0,dynamicBuildingInteriors:!0,dynamicLayers:[],isolateBelowGroundView:!1,forceInteriorsVisible:!1,showLabelsAndMarkersOnAllVisibleFloors:!1,autoZoomThresholds:!1},ao=.2,Jo=.4;var ko=a((s,t={})=>{let e={initialVisibility:t.initialVisibility??"indoor-first",debug:t.debug??!1},i=Ut(s,e);if(i===void 0)return O.error("No indoor floor stacks found. Cannot compute zoom thresholds. Set indoorZoomThreshold and outdoorZoomThreshold manually."),{indoorZoomThreshold:no.indoorZoomThreshold,outdoorZoomThreshold:no.outdoorZoomThreshold};let r=i+Jo,n=i+ao;return e.initialVisibility==="indoor-first"&&(r=i-ao,n=i-Jo),{indoorZoomThreshold:r,outdoorZoomThreshold:n}},"calculateZoomThresholds");function Ut(s,t){let i=s.getMapData().getByType("floor-stack").filter(f=>f.type!=="Outdoor"),r=1/0,n;for(let f of i){let p=s.Camera.getFocusOnTransform(f).zoomLevel??1/0;p<r&&(r=p,n=f)}if(r!==1/0)return t.debug&&n&&s.Camera.getFocusOnTransform(n,{debugColor:"blue"}),r}a(Ut,"getDefaultZoomLevel");function $t(s,t){return`${t} ${s}`}a($t,"formatMessage");var Xo=class Xo extends Error{constructor(t,e=Yo){super($t(t,e)),this.name="MappedinError"}};a(Xo,"MappedinError");var Do=Xo;var jt=a(s=>s,"linearEase"),zt=a(s=>s*s,"quadEaseIn"),Yt=a(s=>1-Math.cos(s*Math.PI/2),"easeIn"),Wt=a(s=>1-(1-s)*(1-s),"quadEaseOut"),qt=a(s=>1-Math.pow(1-s,3),"cubicEaseOut"),Ht={linear:jt,"ease-in":zt,"ease-out":Wt,"ease-in-out":Yt,"ease-out-cubic":qt};function Kt(s,t){let e=0;if(t.length<2)return e;let r=t[0]<t[1]?(n,f)=>n>f:(n,f)=>n<f;for(;e<t.length-1&&r(s,t[e+1]);)e++;return e>t.length-2?Math.max(0,t.length-2):e}a(Kt,"getInterpolationBreakpoint");function St(s,t,e,i="ease-in"){if(t.length!==e.length)throw new Do("Input and output ranges must have the same number of values.");s=Math.max(t[0],Math.min(s,t[t.length-1]));let r=Kt(s,t),n=(s-t[r])/(t[r+1]-t[r]),f=typeof i=="function"?i(n):Ht[i](n);return e[r]+f*(e[r+1]-e[r])}a(St,"interpolateMulti");var D,lo,uo,_,co,tt=class tt{constructor(t,e,i){F(this,"layers");F(this,"visible");c(this,D);c(this,lo,[]);c(this,uo,!1);c(this,_,new Map);F(this,"interpolationFn");c(this,co,1);this.layers=t,this.visible=e,h(this,D,i)}processLayerGroup(t,e){o(this,uo)||(this.layers.forEach(i=>{let r=t[i];r&&o(this,lo).push(...r)}),h(this,uo,!0),this.visible&&(this.interpolationFn=i=>{let{outdoorZoomThreshold:r,indoorZoomThreshold:n}=e();return St(i,[r,n],[1,0])}))}setOpacity(t){h(this,co,t);for(let e of o(this,lo))if(e.startsWith("img_")){let i=o(this,D).Image3D.getById(e);if(i){if(!o(this,_).has(e)){let n=o(this,D).getState(i.image);o(this,_).set(e,n?.opacity??1)}let r=Math.min(o(this,_).get(e),t);o(this,D).updateState(i.image,{opacity:r})}}else{let i=o(this,D).getMapData()?.getById("space",e);if(!i)continue;if(!o(this,_).has(e)){let n=o(this,D).getState(i);o(this,_).set(e,n?.opacity??1)}let r=Math.min(o(this,_).get(e),t);o(this,D).updateState(i,{opacity:r,visible:r>0})}}get opacity(){return o(this,co)}};D=new WeakMap,lo=new WeakMap,uo=new WeakMap,_=new WeakMap,co=new WeakMap,a(tt,"LayerGroup");var Bo=tt;function ot(s,t,e){s.forEach(i=>{if(e?.forceOpacity!==void 0){i.setOpacity(e.forceOpacity),i.visible=e.forceOpacity===1;return}if(i.interpolationFn!=null){let r=i.interpolationFn(t);r!=null&&(i.setOpacity(r),i.visible=r===1)}})}a(ot,"runLayerGroupInterpolations");var B,l,R,u,j,z,S,L,Y,x,E,W,ho,fo,mo,M,P,X,po,Z,U,$,m,et,Et,it,rt,st,Tt,nt,oo,go,vt,Zo,_o,xo,Fo,bo,yo,to,Lo,wt,Ot,N,at=class at{constructor(t){c(this,m);c(this,B);c(this,l);c(this,R);c(this,u,no);c(this,j,[]);c(this,z,new Set);c(this,S,new Map);c(this,L);c(this,Y,!1);c(this,x,!1);c(this,E,0);c(this,W,0);c(this,ho,[]);c(this,fo,{});c(this,mo,{});c(this,M,"transition");c(this,P,"outdoor");c(this,X,[]);c(this,po,[]);c(this,Z,!1);c(this,U,[]);c(this,$,null);F(this,"sceneUpdateQueue",Promise.resolve());F(this,"on",a((t,e)=>{o(this,B).on(t,e)},"on"));F(this,"off",a((t,e)=>{o(this,B).off(t,e)},"off"));c(this,oo,a(()=>{h(this,j,[]),o(this,z).clear();let t=o(this,u).isolateBelowGroundView&&o(this,E)<0;for(let e of o(this,po)){let i=o(this,S).get(e.floorStack.id);i&&(t&&i.minElevation>=0||(o(this,z).add(i.id),o(this,j).push(i)))}},"#updateBuildingsInView"));c(this,go,a(t=>{if(!this.isEnabled)return;let{facades:e}=t;dt(e,this.focusedFacades)&&o(this,P)==="transition"&&!o(this,x)||(h(this,x,!1),h(this,po,e),o(this,oo).call(this),o(this,u).autoFocus&&this.focus())},"#handleFacadesInViewChange"));c(this,Zo,a((t,e)=>{if(!this.isEnabled)return;let i=o(this,S).get(t.floorStack.id);i&&(e.reason==="dynamic-focus"&&o(this,u).mode==="active-floor"||(i.activeFloor=t));let r=o(this,u).isolateBelowGroundView&&o(this,E)<0;i?.excluded===!1&&!o(this,L).matchesFloorStack(t.floorStack)&&h(this,E,t.elevation);let n=o(this,u).isolateBelowGroundView&&o(this,E)<0,f=r&&!n;if(e.reason==="dynamic-focus")return;let p=g(this,m,vt).call(this),y=o(this,_o).call(this,t,e,f,p);if(p)return y;y.catch(d=>{O.error("setFloor override work failed after sync floor-change commit",d)})},"#setFloorHandler"));c(this,_o,a(async(t,e,i,r)=>{i&&(h(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),await o(this,N).call(this,t),!(!this.isEnabled||e.signal.aborted)&&r&&this.isEnabled&&!e.signal.aborted&&await o(this,xo).call(this,t)},"#runFloorChangeWork"));c(this,xo,a(t=>{let e=o(this,l).getFloorStackAltitudeData(t.floorStack).get(t.elevation)?.altitude;if(typeof e=="number"&&o(this,l).Camera.elevation!==e)return o(this,l).Camera.animateElevation(e,o(this,u).cameraLiftAnimationOptions)},"#liftCameraToFloorAltitude"));c(this,Fo,a(()=>{h(this,Y,!0)},"#handleUserInteractionStart"));c(this,bo,a(()=>{h(this,Y,!1)},"#handleUserInteractionEnd"));c(this,yo,a(()=>{o(this,N).call(this)},"#handleGlobalStateChange"));c(this,to,a(t=>{if(!this.isEnabled)return;let{zoomLevel:e}=t,i=ct(e,o(this,u).indoorZoomThreshold,o(this,u).outdoorZoomThreshold);o(this,M)!==i&&(h(this,M,i),i==="in-range"?this.setIndoor():i==="out-of-range"&&this.setOutdoor());let r=(o(this,l).Navigation?.floors?.length??0)>0;ot(o(this,U),e,r?{forceOpacity:0}:void 0)},"#handleCameraChange"));c(this,N,a(async t=>{if(!this.isEnabled)return;let e=t||o(this,l).currentFloor,i=o(this,l).getGlobalState().multiFloorView,r=o(this,l).options.multiFloorView?{...o(this,l).options.multiFloorView,...i}:o(this,l).options.multiFloorView,n=o(this,l).Navigation?.floors?.map(y=>y.id)||[],f=o(this,l).Navigation?.floorStacks.map(y=>y.id)||[],p=new Promise(async y=>{await this.sceneUpdateQueue;let d=mt({buildings:Array.from(o(this,S).values()),inViewSet:o(this,z),currentFloor:e,zoomState:o(this,M),mode:o(this,u).mode,elevation:o(this,E),floorIdsInNavigation:n,floorStackIdsInNavigation:f,multiFloorView:r,getMultiFloorState:o(this,u).customMultiFloorVisibilityState??No.getMultiFloorState,dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,isolateBelowGroundView:o(this,u).isolateBelowGroundView,currentElevation:o(this,E),forceInteriorsVisible:o(this,u).forceInteriorsVisible,getFloorStackAltitudeData:a(w=>o(this,l).getFloorStackAltitudeData(w),"getFloorStackAltitudeData")}),V=[];await Promise.all(Array.from(d.values()).map(async w=>{let{building:C,showIndoor:So,floorStackState:eo,facadeState:Eo,inFocus:To,isAboveGroundInIsolation:Co}=w;V.push(eo);let b=pt(C,So);if(b==="indoor")return g(this,m,wt).call(this,C,eo,Eo,To);if(b==="outdoor")return g(this,m,Ot).call(this,C,eo,Eo,f,Co)})),o(this,l).Outdoor.setOpacity(ht(V,o(this,u).mode)),h(this,X,o(this,j).filter(w=>d.get(w.id)?.showIndoor===!0).map(w=>w.facade)),o(this,B).publish("focus",{facades:o(this,X)}),y()});return this.sceneUpdateQueue=p,p},"#applyBuildingStates"));h(this,B,new wo),h(this,l,t),O.setLevel(Q.logState),h(this,R,o(this,l).getMapData()),h(this,E,o(this,l).currentFloor.elevation),h(this,W,o(this,l).Camera.elevation);for(let e of o(this,R).getByType("facade")){let{floorStack:i}=e;if(i.floors.length===0||i.defaultFloor==null){O.warn(`Skipping building for floor stack "${i.id}" because it has no floors. It will not participate in Dynamic Focus.`);continue}o(this,S).set(i.id,new Oo(i,o(this,l)))}g(this,m,Tt).call(this),h(this,L,new Io(yt(o(this,R),o(this,S)),o(this,l))),o(this,l).on("camera-change",o(this,to)),o(this,l).on("facades-in-view-change",o(this,go)),o(this,l).on("user-interaction-start",o(this,Fo)),o(this,l).on("user-interaction-end",o(this,bo)),o(this,l).on("global-state-change",o(this,yo))}enable(t){if(o(this,Z)){O.warn("enable() called on an already enabled Dynamic Focus instance.");return}h(this,Z,!0),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(o(this,Zo)),o(this,L).show();let e={...o(this,u),...t};e.autoZoomThresholds&&(t?.autoZoomThresholds&&(t.indoorZoomThreshold!=null||t.outdoorZoomThreshold!=null)&&O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled."),delete e.indoorZoomThreshold,delete e.outdoorZoomThreshold),this.updateState(e),g(this,m,Et).call(this),o(this,to).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)){O.warn("disable() called on an already disabled Dynamic Focus instance.");return}h(this,Z,!1),o(this,l).__EXPERIMENTAL__overrideSetFloorHandler(void 0)}get isEnabled(){return o(this,Z)}get isIndoor(){return o(this,P)==="indoor"}get isOutdoor(){return o(this,P)==="outdoor"}get outdoorsFloorStack(){return o(this,L).floorStack}get layers(){return o(this,ho)}get layersBySpaceId(){return o(this,fo)}setIndoor(){h(this,P,"indoor"),h(this,M,"in-range"),g(this,m,et).call(this)}setOutdoor(){h(this,P,"outdoor"),h(this,M,"out-of-range"),g(this,m,et).call(this)}get focusedFacades(){return[...o(this,X)]}getState(){return{...o(this,u)}}updateState(t){let e=!1,i=o(this,u).indoorZoomThreshold,r=o(this,u).outdoorZoomThreshold,n=o(this,u).isolateBelowGroundView&&o(this,E)<0,f=o(this,u).autoFocus,p=!!o(this,u).autoZoomThresholds,y=t.autoZoomThresholds!=null?!!t.autoZoomThresholds:p,d=t;if(y&&(d.indoorZoomThreshold!=null||d.outdoorZoomThreshold!=null)){O.warn("Manual indoorZoomThreshold/outdoorZoomThreshold values are ignored while autoZoomThresholds is enabled.");let{indoorZoomThreshold:V,outdoorZoomThreshold:w,...C}=d;d=C}if(!p&&y?(h(this,$,()=>{if(!o(this,Z))return;let V=o(this,u).indoorZoomThreshold,w=o(this,u).outdoorZoomThreshold;g(this,m,rt).call(this),g(this,m,st).call(this,V,w),o(this,N).call(this)}),o(this,l).on("camera-screen-offsets-change",o(this,$))):p&&!y&&g(this,m,it).call(this),d.indoorZoomThreshold!=null&&(d.indoorZoomThreshold=Ho(d.indoorZoomThreshold,d?.outdoorZoomThreshold??o(this,u).outdoorZoomThreshold,o(this,l).Camera.maxZoomLevel,"indoorZoomThreshold"),e=!0),d.outdoorZoomThreshold!=null&&(d.outdoorZoomThreshold=Ho(d.outdoorZoomThreshold,o(this,l).Camera.minZoomLevel,d?.indoorZoomThreshold??o(this,u).indoorZoomThreshold,"outdoorZoomThreshold"),e=!0),d.mode!=null&&(d.mode=Ft.includes(d.mode)?d.mode:"default-floor"),d.autoAdjustFacadeHeights!=null&&(o(this,u).autoAdjustFacadeHeights=d.autoAdjustFacadeHeights),d.dynamicBuildingInteriors!=null&&d.dynamicBuildingInteriors!==o(this,u).dynamicBuildingInteriors&&(e=!0),d.isolateBelowGroundView!=null&&d.isolateBelowGroundView!==o(this,u).isolateBelowGroundView&&(e=!0),d.forceInteriorsVisible!=null&&d.forceInteriorsVisible!==o(this,u).forceInteriorsVisible&&(e=!0),d.showLabelsAndMarkersOnAllVisibleFloors!=null&&d.showLabelsAndMarkersOnAllVisibleFloors!==o(this,u).showLabelsAndMarkersOnAllVisibleFloors&&(e=!0),d.cameraLiftAnimationOptions!=null&&(d={...d,cameraLiftAnimationOptions:{...o(this,u).cameraLiftAnimationOptions,...d.cameraLiftAnimationOptions}}),h(this,u,Object.assign({},o(this,u),Object.fromEntries(Object.entries(d).filter(([,V])=>V!=null)))),y&&d.autoZoomThresholds!==void 0&&(g(this,m,rt).call(this),e=!0),d.mode!=null&&d.preloadFloors&&g(this,m,nt).call(this,d.mode),e){let V=o(this,u).isolateBelowGroundView&&o(this,E)<0;n&&!V&&(h(this,x,!0),o(this,l).Camera.updateFacadesInView(),o(this,oo).call(this)),o(this,N).call(this)}g(this,m,st).call(this,i,r),o(this,Z)&&!f&&o(this,u).autoFocus&&(h(this,W,o(this,l).Camera.elevation),this.focus(o(this,u).setFloorOnFocus&&o(this,L).matchesFloorStack(o(this,l).currentFloor.floorStack)))}destroy(){this.disable(),g(this,m,it).call(this),o(this,l).off("facades-in-view-change",o(this,go)),o(this,l).off("camera-change",o(this,to)),o(this,l).off("user-interaction-start",o(this,Fo)),o(this,l).off("user-interaction-end",o(this,bo)),o(this,l).off("global-state-change",o(this,yo)),o(this,S).forEach(t=>t.destroy()),o(this,L).destroy(),o(this,B).destroy(),h(this,U,[])}async focus(t=o(this,u).setFloorOnFocus){let e;if(t)if(gt(o(this,W),o(this,l).Camera.elevation,o(this,Y)))h(this,W,o(this,l).Camera.elevation),h(this,x,!0);else{let i=ft(o(this,j),o(this,L),o(this,M)),r=i?Vo(i,o(this,u).mode,o(this,E)):void 0;r&&r.id!==o(this,l).currentFloor.id&&(e=r,o(this,l).setFloor(r,{context:"dynamic-focus"}))}await o(this,N).call(this,e)}preloadFloors(){g(this,m,nt).call(this,o(this,u).mode)}setDefaultFloorForStack(t,e){if(!qo(e,t))return;let i=o(this,S).get(t.id);i&&(i.defaultFloor=e)}resetDefaultFloorForStack(t){let e=o(this,S).get(t.id),i=t.defaultFloor;e&&i&&(e.defaultFloor=i)}getDefaultFloorForStack(t){return o(this,S).get(t.id)?.defaultFloor||t.defaultFloor||t.floors[0]}setCurrentFloorForStack(t,e){if(!qo(e,t))return;let i=o(this,S).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 r=o(this,S).get(i.id);r&&(r.excluded=!0)}}include(t){let e=Array.isArray(t)?t:[t];for(let i of e){let r=o(this,S).get(i.id);r&&(r.excluded=!1)}}getCurrentFloorForStack(t){return o(this,S).get(t.id)?.activeFloor||this.getDefaultFloorForStack(t)}};B=new WeakMap,l=new WeakMap,R=new WeakMap,u=new WeakMap,j=new WeakMap,z=new WeakMap,S=new WeakMap,L=new WeakMap,Y=new WeakMap,x=new WeakMap,E=new WeakMap,W=new WeakMap,ho=new WeakMap,fo=new WeakMap,mo=new WeakMap,M=new WeakMap,P=new WeakMap,X=new WeakMap,po=new WeakMap,Z=new WeakMap,U=new WeakMap,$=new WeakMap,m=new WeakSet,et=a(function(){o(this,u).autoFocus&&(o(this,Y)?this.focus():h(this,x,!0)),o(this,B).publish("state-change")},"#handleViewStateChange"),Et=a(function(){h(this,U,[]);for(let e of o(this,u).dynamicLayers){let i=new Bo([e],!0,o(this,l));i.processLayerGroup(o(this,mo),()=>o(this,u)),o(this,U).push(i)}let t=(o(this,l).Navigation?.floors?.length??0)>0;ot(o(this,U),o(this,l).Camera.zoomLevel,t?{forceOpacity:0}:void 0)},"#initializeLayerGroups"),it=a(function(){o(this,$)&&(o(this,l).off("camera-screen-offsets-change",o(this,$)),h(this,$,null))},"#unsubscribeScreenOffsets"),rt=a(function(){let t=o(this,u).autoZoomThresholds,e=typeof t=="object"&&t!==null?{...t}:{},{indoorZoomThreshold:i,outdoorZoomThreshold:r}=ko(o(this,l),e);o(this,u).indoorZoomThreshold=i,o(this,u).outdoorZoomThreshold=r,(e.expandMinZoom??!0)&&r<o(this,l).Camera.minZoomLevel&&o(this,l).Camera.setMinZoomLevel(r-ao)},"#recalcThresholds"),st=a(function(t,e){(o(this,u).indoorZoomThreshold!==t||o(this,u).outdoorZoomThreshold!==e)&&o(this,B).publish("zoom-threshold-change",{indoorZoomThreshold:o(this,u).indoorZoomThreshold,outdoorZoomThreshold:o(this,u).outdoorZoomThreshold})},"#publishThresholdChangeIfNeeded"),Tt=a(function(){let t=o(this,R).internal.mvf?.enterprise?.layers??[],e={},i={};t.forEach(r=>{e[r.name]||(e[r.name]=[]),e[r.name].push(...r.spaces.map(({spaceId:n})=>n));for(let{spaceId:n}of r.spaces)i[n]==null&&(i[n]=[]),i[n].push(r.name)}),h(this,ho,t.map(({name:r})=>r)),h(this,fo,i),h(this,mo,e)},"#setupLayers"),nt=a(function(t){let e=[];for(let i of o(this,R).getByType("facade")){let r=o(this,S).get(i.floorStack.id);if(!r)continue;let n=Vo(r,t,o(this,E));n!=null&&No.Floor.is(n)&&e.push(n)}o(this,l).preloadFloors(e)},"#preloadFloors"),oo=new WeakMap,go=new WeakMap,vt=a(function(){let{multiFloorView:t}=o(this,l).options;return!!t?.enabled&&!!t?.updateCameraElevationOnFloorChange},"#shouldAwaitFloorChangeCommit"),Zo=new WeakMap,_o=new WeakMap,xo=new WeakMap,Fo=new WeakMap,bo=new WeakMap,yo=new WeakMap,to=new WeakMap,Lo=a(function(t,e,i,r=!1){t.forEach(n=>{if(n.floor)if(e){let p=i!==void 0&&!r?{...n.state,labels:{...n.state.labels,enabled:n.state.labels.enabled&&i},markers:{...n.state.markers,enabled:n.state.markers.enabled&&i},occlusion:{...n.state.occlusion,enabled:n.state.occlusion.enabled&&i}}:n.state;o(this,l).updateState(n.floor,p)}else o(this,l).updateState(n.floor,{visible:!1})})},"#updateFloorVisibility"),wt=a(async function(t,e,i,r){return g(this,m,Lo).call(this,e.floorStates,!0,r,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),t.animateFacade(i.state,o(this,u).indoorAnimationOptions)},"#animateIndoorSequence"),Ot=a(async function(t,e,i,r,n){let f=n;f&&g(this,m,Lo).call(this,e.floorStates,!1,void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors);let p=await t.animateFacade(i.state,o(this,u).outdoorAnimationOptions);return p.result==="completed"&&!f&&g(this,m,Lo).call(this,e.floorStates,zo({building:t,currentFloor:o(this,l).currentFloor,inRange:o(this,M)==="in-range",inFocus:o(this,z).has(t.id),mode:o(this,u).mode,elevation:o(this,E),inNavigation:r.includes(t.floorStack.id),dynamicBuildingInteriors:o(this,u).dynamicBuildingInteriors,forceInteriorsVisible:o(this,u).forceInteriorsVisible}),void 0,o(this,u).showLabelsAndMarkersOnAllVisibleFloors),p},"#animateOutdoorSequence"),N=new WeakMap,a(at,"DynamicFocus");var Mo=at;return xt(Qt);})();\n\n\n// Register the extension\nif (window.bridge && window.bridge.extensions) {\n try {\n window.bridge.extensions.register({ name: \'dynamic-focus\', package: { Extension: DynamicFocus.DynamicFocus } });\n if (window.rnDebug) window.rnDebug(\'Extension: dynamic-focus registered\');\n } catch(e) {\n if (window.rnDebug) window.rnDebug(\'Failed to register dynamic-focus extension: \' + e.message);\n }\n} else {\n if (window.rnDebug) window.rnDebug(\'Bridge or extensions not available for registration\');\n}';function k(){return U}n(k,"getRegistrationScript");function g(){P({extensionName:"dynamic-focus",getRegistrationScript:k,logger:F})}n(g,"useDynamicFocusRegistration");function b(o,s){if(typeof o!="string"||o.length===0)throw new Error("Event parameter must be a non-empty string");if(typeof s!="function")throw new Error("Callback parameter must be a function");const e=W(N),{extensions:i,mapData:t}=e;if(!t)throw new Error("Map data is not available");g();const f=(i?.["dynamic-focus"]?.registrationState||"unregistered")==="registered",l=D(c=>{try{let u=c;o==="focus"&&c.facades&&(u={...c,facades:S(t,c.facades)}),s(u)}catch(u){F.error(`Error in dynamic focus event callback for ${String(o)}:`,u)}},[o,t,s]);G({eventKey:`dynamic-focus:${String(o)}`,callback:l,setupScript:n(()=>R({extensionName:"dynamic-focus",eventName:String(o)}),"setupScript"),cleanupScript:n(()=>j({extensionName:"dynamic-focus",eventName:String(o)}),"cleanupScript"),shouldInject:f})}n(b,"useDynamicFocusEvent");function E(){const o=L(x),{bridge:s,extensions:e,updateExtensionState:i}=o;g();const t=e["dynamic-focus"],r=t?.registrationState||"unregistered",f=r==="registered",l=t?.isEnabled||!1,[c,u]=B(t?.focusedFacades||[]),w=A(e);w.current=e,b("focus",d(h=>{const p=h.facades;u(p),i("dynamic-focus",y=>({...y,registrationState:r,focusedFacades:p}))},[r,i]));const a=d(async(h,p=[])=>{if(!s?.isReady)throw new Error("Bridge is not ready. Ensure the WebView is loaded.");return await s.instruct({type:"extension",payload:{name:"dynamic-focus",method:h,args:p}})},[s]),T=d(async h=>{w.current?.["dynamic-focus"]?.isEnabled||(await a("enable",[h]),i("dynamic-focus",V=>({...V,isEnabled:!0})))},[a,i]),M=d(async h=>await a("updateState",[h]),[a]),O=d(async()=>await a("getState"),[a]),I=d(async h=>await a("focus",[h]),[a]),Z=d(async()=>{await a("disable"),u([]),i("dynamic-focus",{registrationState:"unregistered",isEnabled:!1,focusedFacades:[]})},[a,u,i]);return{isReady:f,isEnabled:l,focusedFacades:c,updateState:M,getState:O,focus:I,disable:Z,enable:T}}n(E,"useDynamicFocus");export{E as useDynamicFocus,b as useDynamicFocusEvent};
|
package/lib/rn/types.d.ts
CHANGED
|
@@ -38,7 +38,10 @@ export type DynamicFocusState = {
|
|
|
38
38
|
*
|
|
39
39
|
* Set to `false` while the host drives the camera (e.g. a deep-link or scripted
|
|
40
40
|
* sequence) to suspend focus; flipping back to `true` re-applies the suspended
|
|
41
|
-
* scene
|
|
41
|
+
* scene. When the current floor is still the outdoor default, the deferred
|
|
42
|
+
* transition completes including setFloor (subject to `setFloorOnFocus`);
|
|
43
|
+
* otherwise only building states are re-applied and the host's floor is
|
|
44
|
+
* preserved.
|
|
42
45
|
* @default true
|
|
43
46
|
*/
|
|
44
47
|
autoFocus: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mappedin/dynamic-focus",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.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/
|
|
41
|
-
"@mappedin/
|
|
42
|
-
"@mappedin/react-sdk": "^6.
|
|
40
|
+
"@mappedin/react-sdk": "^6.27.0",
|
|
41
|
+
"@mappedin/mappedin-js": "^6.27.0",
|
|
42
|
+
"@mappedin/react-native-sdk": "^6.27.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@mappedin/react-sdk": {
|