UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

289 lines (288 loc) 10.5 kB
(function() { try { var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}; e.SENTRY_RELEASE = { id: "3.20.0" }; var t = new e.Error().stack; t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "0ec0ef68-2f20-46ee-94ed-028d46d56e5a", e._sentryDebugIdIdentifier = "sentry-dbid-0ec0ef68-2f20-46ee-94ed-028d46d56e5a"); } catch {} })(); import { C as e, _ as t, d as n, m as r, s as i, x as a } from "./i18n-B6dEf7vu.js"; import { $ as o, Ft as s, Q as c, Z as l, en as u, rt as d, s as f } from "./store-Dh-bVjb-.js"; import { n as p, t as m } from "./kiosk-record-cqqud1dq.js"; //#region src/components/Map/pointInConvexQuad.ts function h(e, t) { let n = 0; for (let r = 0; r < 4; r++) { let i = t[r], a = t[(r + 1) % 4], o = (a.x - i.x) * (e.y - i.y) - (a.y - i.y) * (e.x - i.x); if (!Number.isFinite(o)) return !1; if (o === 0) continue; let s = o > 0 ? 1 : -1; if (n === 0) n = s; else if (n !== s) return !1; } return n !== 0; } //#endregion //#region src/components/Map/visibleArea.ts function g(e) { let t = s(e.viewport.canvasToSvg({ x: 0, y: 0 })), n = s(e.viewport.canvasToSvg({ x: e.canvas.clientWidth, y: 0 })), r = s(e.viewport.canvasToSvg({ x: 0, y: e.canvas.clientHeight })), i = s(e.viewport.canvasToSvg({ x: e.canvas.clientWidth, y: e.canvas.clientHeight })), a = Math.min(t.x, n.x, r.x, i.x), o = Math.max(t.x, n.x, r.x, i.x), c = Math.min(t.y, n.y, r.y, i.y), l = Math.max(t.y, n.y, r.y, i.y); return { x: a, y: c, width: o - a, height: l - c, left: a, right: o, top: l, bottom: c, center: { x: (a + o) / 2, y: (c + l) / 2 }, corners: [ t, n, i, r ] }; } function _(e, t) { return h(t, g(e).corners); } //#endregion //#region src/components/Kiosk/KioskStore.ts var v, y, b, x, S, C; function w(e, t, n, r) { n && Object.defineProperty(e, t, { enumerable: n.enumerable, configurable: n.configurable, writable: n.writable, value: n.initializer ? n.initializer.call(r) : void 0 }); } function T(e, t, n, r, i) { var a = {}; return Object.keys(r).forEach(function(e) { a[e] = r[e]; }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = n.slice().reverse().reduce(function(n, r) { return r(e, t, n) || n; }, a), i && a.initializer !== void 0 && (a.value = a.initializer ? a.initializer.call(i) : void 0, a.initializer = void 0), a.initializer === void 0 ? (Object.defineProperty(e, t, a), null) : a; } var E = 2e4, D = new (v = r({ keepAlive: !0 }), y = r({ keepAlive: !0 }), b = r({ keepAlive: !0 }), x = class { constructor() { w(this, "savedKiosk", S, this), w(this, "statusMessages", C, this), this.statusMessageTimer = 0, this.isResettingCamera = !1, this.initialPtScale = void 0; } get kiosk() { return f.uiState.kioskData; } setKiosk(e) { f.uiState.setKioskData(e); } get renderer() { return f.rendererService.renderer; } getCameraState() { if (f.maplibreStore.showMaplibre) { var e; let t = (e = f.maplibreStore.cameraPort) == null ? void 0 : e.getCameraState(); return t ? { mapCenterLng: t.lng, mapCenterLat: t.lat, mapZoom: t.zoom, mapBearingDegrees: t.bearing, mapPitchDegrees: t.pitch } : {}; } let t = f.rendererService.getCameraState(); return t ? { mapInitialPtScale: this.initialPtScale, mapPtScale: t.ptScale, mapCenterX: t.center.x, mapCenterY: t.center.y, mapRollDegrees: t.roll, mapPitch: t.pitch } : {}; } get hasUnsavedChanges() { let e = this.savedKiosk, t = a(this.kiosk); if (!t || !e) return !!t != !!e; let n = Object.keys(e), r = Object.keys(t); if (n.length !== r.length) return !0; for (let r of n) if (!(r in t) || e[r] !== t[r]) return !0; return !1; } addStatusMessage(e) { this.statusMessages = [{ ...e, id: Date.now() }], this.startCleanupMessages(); } clearStatusMessages() { this.statusMessages = []; } startCleanupMessages() { clearTimeout(this.statusMessageTimer), this.statusMessageTimer = window.setTimeout(() => this.clearStatusMessages(), 1e3); } async resetCamera() { if (!this.isResettingCamera) { this.isResettingCamera = !0; try { if (f.maplibreStore.showMaplibre && await this.resetMaplibreCamera()) return; await this.resetRendererCamera(); } finally { this.isResettingCamera = !1; } } } async resetMaplibreCamera() { let e = await this.waitForMaplibreCameraPort(); if (!e) return !1; let t = this.kiosk; (t == null ? void 0 : t.z) != null && f.fp.activateFloor({ name: String(t.z) }); let n = p(t == null ? void 0 : t.mapCenterLng), r = p(t == null ? void 0 : t.mapCenterLat), i = p(t == null ? void 0 : t.mapZoom); return n === void 0 || r === void 0 || i === void 0 ? (e.resetPitch(), f.uiState.fitBounds(), !0) : (e.applyCameraState({ lng: n, lat: r, zoom: i, bearing: p(t == null ? void 0 : t.mapBearingDegrees), pitch: p(t == null ? void 0 : t.mapPitchDegrees) }), !0); } async waitForMaplibreCameraPort() { let { maplibreStore: t } = f; if (t.cameraPort) return t.cameraPort; try { await e(() => !!t.cameraPort || !t.showMaplibre, { timeout: E }); } catch { return null; } return t.cameraPort; } async resetRendererCamera() { let e = this.renderer; if (!e) return; let t = this.kiosk; await e.controls.resetCamera({ pan: !0, zoom: !0, roll: !0, pitch: !0 }, !0), (t == null ? void 0 : t.z) != null && f.fp.activateFloor({ name: String(t.z) }); let n = m(t); n !== void 0 && await e.controls.zoomBy(n, !0); let r = p(t == null ? void 0 : t.mapCenterX), i = p(t == null ? void 0 : t.mapCenterY); r !== void 0 && i !== void 0 && await e.controls.panTo(r, i, !0); let a = p(t == null ? void 0 : t.mapRollDegrees); a !== void 0 && await e.controls.rollTo(a, !0); } restoreData() { let e = l(); e && (this.setKiosk(e), this.savedKiosk = e, f.uiState.kiosk = !0); } handleSetupReady() { this.restoreData(), f.uiState.kiosk = !0, f.uiState.hideFreeOrDemo = !0, f.uiState.setForceDim(!0), f.searchStore.setSearchText(""), f.searchStore.setFocused(!1), this.resetCamera(); } handleClose() { this.setKiosk(null), f.uiState.setForceDim(!1), f.uiState.enableSetKioskMode(!1), f.searchStore.closeSearch(); } handleDelete() { c(), this.setKiosk(null), f.uiState.resetMapSettings(), f.uiState.resetUIScale(), this.addStatusMessage({ variant: "success", title: i("Deleted") }); } handleSave() { let e = this.renderer; if (!e) return; let t = a(this.kiosk), n = this.getCameraState(), r = { ...t, ...n }; if (!_(e, r)) { this.addStatusMessage({ variant: "error", title: i("Kiosk not visible") }); return; } this.setKiosk(r), o(r), d(r, "https://app.expofp.com/"), f.uiState.setUIScale(r.uiScale, !0), this.addStatusMessage({ variant: "success", title: i("Saved") }), this.savedKiosk = r; } delayChange(e) { requestAnimationFrame(() => e == null ? void 0 : e()); } handleChange(e) { let t = a(this.kiosk); t && (Number.isFinite(e.angle) && this.setKiosk({ ...t, heading: e.angle }), Number.isFinite(e.scale) && (this.setKiosk({ ...t, uiScale: e.scale }), this.delayChange(() => f.uiState.setUIScale(e.scale, !1))), Number.isFinite(e.percent) && this.setKiosk({ ...t, iconSizePercent: e.percent })); } setInitialPtScale(e) { if (this.initialPtScale) return; this.initialPtScale = e; let t = a(this.kiosk); t && this.setKiosk({ ...t, mapInitialPtScale: e }); } handleClick(e) { var t, n; let r = a(this.kiosk), i = f.fp.getFloors(), o = u() ? (t = (n = i.find((e) => e.active)) == null ? void 0 : n.name) == null ? null : t : null, s = f.uiState.uiScale; this.setKiosk({ ...r, x: e.x, y: e.y, z: o, uiScale: (r == null ? void 0 : r.uiScale) || s, heading: (r == null ? void 0 : r.heading) || 0, iconSizePercent: (r == null ? void 0 : r.iconSizePercent) || 100, ...this.getCameraState() }); } handleNavigationChange() { let e = a(this.kiosk); e && this.setKiosk({ ...e, ...this.getCameraState() }); } }, T(x.prototype, "kiosk", [v], Object.getOwnPropertyDescriptor(x.prototype, "kiosk"), x.prototype), T(x.prototype, "setKiosk", [n], Object.getOwnPropertyDescriptor(x.prototype, "setKiosk"), x.prototype), T(x.prototype, "renderer", [y], Object.getOwnPropertyDescriptor(x.prototype, "renderer"), x.prototype), S = T(x.prototype, "savedKiosk", [t], { configurable: !0, enumerable: !0, writable: !0, initializer: function() { return null; } }), T(x.prototype, "hasUnsavedChanges", [b], Object.getOwnPropertyDescriptor(x.prototype, "hasUnsavedChanges"), x.prototype), C = T(x.prototype, "statusMessages", [t], { configurable: !0, enumerable: !0, writable: !0, initializer: function() { return []; } }), T(x.prototype, "addStatusMessage", [n], Object.getOwnPropertyDescriptor(x.prototype, "addStatusMessage"), x.prototype), T(x.prototype, "clearStatusMessages", [n], Object.getOwnPropertyDescriptor(x.prototype, "clearStatusMessages"), x.prototype), T(x.prototype, "startCleanupMessages", [n], Object.getOwnPropertyDescriptor(x.prototype, "startCleanupMessages"), x.prototype), T(x.prototype, "resetCamera", [n], Object.getOwnPropertyDescriptor(x.prototype, "resetCamera"), x.prototype), T(x.prototype, "restoreData", [n], Object.getOwnPropertyDescriptor(x.prototype, "restoreData"), x.prototype), T(x.prototype, "handleSetupReady", [n], Object.getOwnPropertyDescriptor(x.prototype, "handleSetupReady"), x.prototype), T(x.prototype, "handleClose", [n], Object.getOwnPropertyDescriptor(x.prototype, "handleClose"), x.prototype), T(x.prototype, "handleDelete", [n], Object.getOwnPropertyDescriptor(x.prototype, "handleDelete"), x.prototype), T(x.prototype, "handleSave", [n], Object.getOwnPropertyDescriptor(x.prototype, "handleSave"), x.prototype), T(x.prototype, "handleChange", [n], Object.getOwnPropertyDescriptor(x.prototype, "handleChange"), x.prototype), T(x.prototype, "setInitialPtScale", [n], Object.getOwnPropertyDescriptor(x.prototype, "setInitialPtScale"), x.prototype), T(x.prototype, "handleClick", [n], Object.getOwnPropertyDescriptor(x.prototype, "handleClick"), x.prototype), T(x.prototype, "handleNavigationChange", [n], Object.getOwnPropertyDescriptor(x.prototype, "handleNavigationChange"), x.prototype), x)(); //#endregion export { D as t };