UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 2.63 kB
import{__decorate as t}from"tslib";import{action as o,computed as l,observable as a}from"mobx";import r from"../data";import{fpGeo as n}from"../data/fpGeo";const d=import.meta.env?.VITE_EXPOFP_DISABLE_3D_TOGGLE!=="false";function s(){return typeof window>"u"||window.navigator.onLine}export default class e{constructor(i){this.mapViewMode="floorplan",this.maplibreSelected=!1,this.isOnline=s(),this.cameraPortBox=a.box(null,{deep:!1}),this.handleOnline=()=>this.setOnline(!0),this.handleOffline=()=>this.setOnline(!1),this.rootStore=i,this.mapViewMode=this.getInitialViewMode(),this.maplibreSelected=this.mapViewMode!=="floorplan",typeof window<"u"&&(window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline))}dispose(){typeof window>"u"||(window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline))}setOnline(i){this.isOnline=i}get cameraPort(){return this.cameraPortBox.get()}setCameraPort(i){this.cameraPortBox.set(i)}clearCameraPortIfCurrent(i){this.cameraPortBox.get()===i&&this.cameraPortBox.set(null)}activateMaplibre(){this.maplibreEnabled&&(this.mapViewMode=r.allow3dView&&this.mapViewMode!=="map3d"?"map3d":"map2d",this.maplibreSelected=!0)}deactivateMaplibre(){this.mapViewMode="floorplan",this.maplibreSelected=!1}get hideModeSwitchButton(){return!this.maplibreEnabled||!r.allow3dView||d||r.hideModeSwitchButton}get maplibreEnabled(){const i=this.rootStore.fp?.maplibre??window.__efpMaplibre,p=!!i?.offline&&(!!i.style||!!i.styleUrl);return this.useMaplibreMap&&!!n?.properties?.config&&(this.isOnline||p)}get useMaplibreMap(){return r.enableExperimentalMaplibre??n?.properties?.config?.type==="maplibre"}get showMaplibre(){return this.maplibreEnabled&&(this.mapViewMode==="map2d"||this.mapViewMode==="map3d")}get isMap3d(){return this.maplibreEnabled&&this.mapViewMode==="map3d"}getInitialViewMode(){return this.maplibreEnabled?r.allow3dView&&!r.hide3dMapDefault?"map3d":"map2d":"floorplan"}}t([a],e.prototype,"mapViewMode",void 0),t([a],e.prototype,"maplibreSelected",void 0),t([a],e.prototype,"isOnline",void 0),t([o],e.prototype,"setOnline",null),t([o],e.prototype,"setCameraPort",null),t([o],e.prototype,"clearCameraPortIfCurrent",null),t([o],e.prototype,"activateMaplibre",null),t([o],e.prototype,"deactivateMaplibre",null),t([l({keepAlive:!0})],e.prototype,"hideModeSwitchButton",null),t([l({keepAlive:!0})],e.prototype,"maplibreEnabled",null),t([l({keepAlive:!0})],e.prototype,"useMaplibreMap",null),t([l({keepAlive:!0})],e.prototype,"showMaplibre",null),t([l({keepAlive:!0})],e.prototype,"isMap3d",null);