@expofp/floorplan 3.46.0 → 3.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{Button-CJtSs2s5.js → Button-DyqVe4xL.js} +5 -5
- package/dist/browser/{CookieConsent-C4fi9Tyh.js → CookieConsent-Dne5UXwi.js} +7 -7
- package/dist/browser/{Debug-Cd610X28.js → Debug-CSY6FmRs.js} +7 -7
- package/dist/browser/{DebugTools-D9g4_7Cc.js → DebugTools-CSGF0Uqi.js} +6 -6
- package/dist/browser/{Demo-CryvOcgl.js → Demo-AI-22qbf.js} +9 -9
- package/dist/browser/{Free-CJXdChTu.js → Free-BmItczwV.js} +10 -10
- package/dist/browser/{GalleryContainer-DJEByROk.js → GalleryContainer-Do5QXu8h.js} +11 -11
- package/dist/browser/{GpsLoader-DSsG-xT8.js → GpsLoader-D6boL0AQ.js} +14 -14
- package/dist/browser/{KioskStore-DOB-av5O.js → KioskStore-DodjzUdk.js} +19 -19
- package/dist/browser/{LayerStore-CRZuLMs5.js → LayerStore-DCg-juRT.js} +289 -270
- package/dist/browser/{MaplibreAdapter-C_5hoa-Y.js → MaplibreAdapter-D838jbrB.js} +148 -148
- package/dist/browser/{ModalContainer-Ch8bqPHR.js → ModalContainer-DAh3OT88.js} +10 -10
- package/dist/browser/{PermissionNotice-CiR8SfU0.js → PermissionNotice-D9dFiy8Z.js} +6 -6
- package/dist/browser/{RouteStore-D5yYhhPl.js → RouteStore-B82dztUW.js} +342 -327
- package/dist/browser/{SetKioskMode-PiwwpWpN.js → SetKioskMode-DcQFm_UG.js} +12 -12
- package/dist/browser/{ShowKiosk-uWNhreCd.js → ShowKiosk-BnuT9vM-.js} +11 -11
- package/dist/browser/{UIState-Bi4-Ri9M.js → UIState-Dd6fvko0.js} +97 -97
- package/dist/browser/{ViewerMenuPanel-B3vtTFpG.js → ViewerMenuPanel-C3B3OmlN.js} +11 -11
- package/dist/browser/{add-debug-secret-listener-Db76vB7o.js → add-debug-secret-listener-BJu3pH2x.js} +1 -1
- package/dist/browser/{adopt-global-settings-67S2v_mo.js → adopt-global-settings-BerG23m2.js} +9 -9
- package/dist/browser/{boolean-editor-B1nYYAEd.js → boolean-editor-C1i1ID8g.js} +9 -9
- package/dist/browser/{bootIntercom-BQDnVlyT.js → bootIntercom-C3tqD4Ct.js} +2 -2
- package/dist/browser/bundle.json +87 -87
- package/dist/browser/{camera-events-dIlK_9kU.js → camera-events-DzSywgw0.js} +1 -1
- package/dist/browser/{classnames-CnT6VKND.js → classnames-CQMYVTW5.js} +2 -2
- package/dist/browser/{client-iKoOfnTw.js → client-DbQnuxsE.js} +5 -5
- package/dist/browser/{components-CEmFE-HF.js → components-CzNKFauU.js} +2211 -2160
- package/dist/browser/{create-live-plan-VYe8zgCt.js → create-live-plan-D17jzmnD.js} +505 -439
- package/dist/browser/{debug-context-SM4t83oS.js → debug-context-CLE9u3W1.js} +6 -6
- package/dist/browser/{debug-overlay-BLs-zKon.js → debug-overlay-CqyQd6Tu.js} +10 -10
- package/dist/browser/{debug-ui-COzdQWZH.js → debug-ui-CopIbPwZ.js} +6 -6
- package/dist/browser/{dist-Dxs4B_bo.js → dist-CXSdtHNF.js} +6 -6
- package/dist/browser/{dist-B-cTdqLW.js → dist-DrhAFaXl.js} +5 -5
- package/dist/browser/{dist-C7DmTDRb.js → dist-mSjAoqZa.js} +3 -3
- package/dist/browser/{efp-debug-init-B_S1vuGu.js → efp-debug-init-D3gNE8Zq.js} +3 -3
- package/dist/browser/{enum-editor-CNXjKr2S.js → enum-editor-DfEZj9xj.js} +4 -4
- package/dist/browser/{es5-DXybUgTP.js → es5-CRZbJ3RK.js} +2 -2
- package/dist/browser/{event-head-ClLbm9Br.js → event-head-C5Pqy8aE.js} +1 -1
- package/dist/browser/{event-not-found-DH79zTW9.js → event-not-found-y-baKtlx.js} +3 -3
- package/dist/browser/{event-scoped-cache-DpaRX7uc.js → event-scoped-cache-CUHa0QyF.js} +3 -3
- package/dist/browser/{expofpUrl-n296mHS4.js → expofpUrl-CUIqO5kL.js} +1 -1
- package/dist/browser/{exports-lzdhlipZ.js → exports-CnYQMV4a.js} +1 -1
- package/dist/browser/{favicon-DIM65QuL.js → favicon-DtPw8IL3.js} +1 -1
- package/dist/browser/{fetch-retry.umd-vSI4xMC_.js → fetch-retry.umd-DjnZ3Ut9.js} +2 -2
- package/dist/browser/{flex-BAVIARsK.js → flex-C5mQXGq5.js} +5 -5
- package/dist/browser/{floorplan.loader-eMUdl6jt.js → floorplan.loader-DEaS-fgT.js} +12 -12
- package/dist/browser/{floorplan.ready-1Txw5bTb.js → floorplan.ready-BOnFLVHj.js} +269 -243
- package/dist/browser/{framing-rect-BTpvle_p.js → framing-rect-BIpsCqTB.js} +426 -351
- package/dist/browser/{freeBanner-F3TTYS8Q.js → freeBanner-BQ-1hI0V.js} +2 -2
- package/dist/browser/{fuse-CaTg1KbU.js → fuse-jVBfzHic.js} +2 -2
- package/dist/browser/{i18n-C_4TK-u4.js → i18n-DlquqKCP.js} +333 -318
- package/dist/browser/index.js +33 -33
- package/dist/browser/{index.module-DRBCPeTj.js → index.module-CN0EtZcO.js} +4 -4
- package/dist/browser/{init-ui-BYGB5Nye.js → init-ui-BQ7d5hKB.js} +19 -19
- package/dist/browser/{integrateKiosk-BYXxa3GA.js → integrateKiosk-CumGPvbc.js} +6 -6
- package/dist/browser/{is-debug-D3IYeseH.js → is-debug-IkNSAGo8.js} +4 -4
- package/dist/browser/{is-own-domain-Sd0Gyaz6.js → is-own-domain-yrTLx04R.js} +1 -1
- package/dist/browser/{is-webview-DkUEFd5j.js → is-webview-DA6FLdme.js} +1 -1
- package/dist/browser/{jsx-runtime-Z0-uGdH1.js → jsx-runtime-BzLvm2y2.js} +2 -2
- package/dist/browser/{kiosk-mode-D9JdlNtc.js → kiosk-mode-zD8K_fUT.js} +3 -3
- package/dist/browser/{kiosk-record-U7MDU1j1.js → kiosk-record-Ckxa0L0B.js} +1 -1
- package/dist/browser/{kioskApi-CZmWdnyx.js → kioskApi-CG3QGuUx.js} +7 -7
- package/dist/browser/{ktx2-DBt1EdxU.js → ktx2-Dx_h97CR.js} +2 -2
- package/dist/browser/{lib-Bpc7qOXg.js → lib-5KOc2jVl.js} +3 -3
- package/dist/browser/{loadImage-Dy1_5knL.js → loadImage-iqS2KHgN.js} +1 -1
- package/dist/browser/{logDeviceInfo-DFiuu0JW.js → logDeviceInfo-DhvfxT2K.js} +9 -9
- package/dist/browser/{mobx-NvAhKUmy.js → mobx-CUFHrL57.js} +4 -4
- package/dist/browser/{mobx.module-Bv5V3v5d.js → mobx.module-BTnTbXnp.js} +1 -1
- package/dist/browser/{optional-boolean-editor-BEOwiXCN.js → optional-boolean-editor-C3k-DXeF.js} +3 -3
- package/dist/browser/{optional-enum-editor-C6KjlpRA.js → optional-enum-editor-CeY1nCnF.js} +4 -4
- package/dist/browser/{optional-string-editor-CFrCSmMd.js → optional-string-editor-DrVHjvsL.js} +4 -4
- package/dist/browser/{particles.min-C2A0DA4i.js → particles.min-BPS1Hdpf.js} +2 -2
- package/dist/browser/{react-CabZjr3N.js → react-XuvSZP7j.js} +2 -2
- package/dist/browser/{react-dom-RP6YFh3Z.js → react-dom-Cg1Pcvni.js} +3 -3
- package/dist/browser/{rolldown-runtime-fogUk23q.js → rolldown-runtime-5rOLGCTp.js} +1 -1
- package/dist/browser/{scene-DuvbPaPD.js → scene-CeKqMicD.js} +10 -10
- package/dist/browser/{scheduler-k2rbX-LJ.js → scheduler-D5sEY0Dn.js} +2 -2
- package/dist/browser/{select-DDC9fvlH.js → select-Cbv7ufJV.js} +10 -10
- package/dist/browser/{settings-BozBuwXD.js → settings-DgySPhLO.js} +2 -2
- package/dist/browser/{settings-item-D4rlEKz6.js → settings-item-e3YLYS4G.js} +6 -6
- package/dist/browser/{store-CbRrBMLs.js → store-DTvNQcN7.js} +2 -2
- package/dist/browser/{string-editor-CExhbakJ.js → string-editor-Dbv6xI9s.js} +4 -4
- package/dist/browser/{text-field-BV3Vp6cI.js → text-field-Cg5awwlh.js} +5 -5
- package/dist/browser/{theme-E8keDBEa.js → theme-BRoMMdQq.js} +8 -8
- package/dist/browser/{three.core-C_nLFu2C.js → three.core-DvpRLNmt.js} +1 -1
- package/dist/browser/{ui-CgHs1m5h.js → ui-DNMlY_VB.js} +8 -8
- package/dist/browser/{useRenderTarget-D7wRx7QW.js → useRenderTarget-C__MnkX7.js} +4 -4
- package/dist/browser/{viewport-BH6xyD06.js → viewport-DBuFXrrj.js} +3 -3
- package/dist/browser/{wayfinding-BiZuXF9Q.js → wayfinding-BUQns13Y.js} +516 -510
- package/dist/esm/components/BaseFilterModal.d.ts +4 -2
- package/dist/esm/components/BaseFilterModal.js +1 -1
- package/dist/esm/components/CategoryFilterModal.js +1 -1
- package/dist/esm/components/Map/drawing/config/booth-badge-anchor.d.ts +57 -5
- package/dist/esm/components/Map/drawing/config/booth-badge-anchor.js +1 -1
- package/dist/esm/components/Map/drawing/config/booth-fill-color.d.ts +16 -0
- package/dist/esm/components/Map/drawing/config/booth-fill-color.js +1 -0
- package/dist/esm/components/Map/drawing/config/config-booth-badge.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-bg.js +1 -1
- package/dist/esm/components/SearchButtons/SearchButton.d.ts +1 -0
- package/dist/esm/components/SearchButtons/SearchButton.js +1 -1
- package/dist/esm/floorplan.ready.js +1 -1
- package/dist/esm/services/URLFilterManager.d.ts +8 -0
- package/dist/esm/services/URLFilterManager.js +1 -1
- package/dist/esm/store/CategoryFilterStore.d.ts +33 -1
- package/dist/esm/store/CategoryFilterStore.js +1 -1
- package/dist/esm/store/RootStore.js +1 -1
- package/dist/esm/store/RouteStore.d.ts +9 -1
- package/dist/esm/store/RouteStore.js +1 -1
- package/dist/esm/store/SearchStore.js +1 -1
- package/dist/esm/store/providers/SearchShortcutProvider.js +1 -1
- package/dist/esm/store/search-buttons/SearchButtonsActions.d.ts +7 -0
- package/dist/esm/store/search-buttons/SearchButtonsActions.js +1 -1
- package/dist/esm/store/search-buttons/SearchButtonsFactory.d.ts +2 -2
- package/dist/esm/store/search-buttons/SearchButtonsFactory.js +1 -1
- package/dist/esm/store/search-buttons/SearchButtonsFilters.d.ts +2 -2
- package/dist/esm/store/search-buttons/SearchButtonsFilters.js +1 -1
- package/dist/esm/store/search-buttons/constants.d.ts +0 -3
- package/dist/esm/store/search-buttons/constants.js +1 -1
- package/dist/esm/store/search-buttons/utils.d.ts +23 -2
- package/dist/esm/store/search-buttons/utils.js +1 -1
- package/dist/esm/store/types.d.ts +5 -0
- package/dist/esm/test/store-harness.js +1 -1
- package/dist/esm/utils/filter-groups.d.ts +9 -0
- package/dist/esm/utils/filter-groups.js +1 -0
- package/dist/esm/utils/gps.d.ts +5 -1
- package/dist/esm/utils/gps.js +1 -1
- package/package.json +10 -10
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import './BaseFilterModal.scss';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import type
|
|
3
|
+
import type RootStore from '../store/RootStore.js';
|
|
4
|
+
import type { FilterGroup, FilterStore } from '../store/types.js';
|
|
3
5
|
interface BaseFilterModalProps {
|
|
4
6
|
store: FilterStore;
|
|
5
|
-
rootStore:
|
|
7
|
+
rootStore: RootStore;
|
|
6
8
|
title: string;
|
|
7
9
|
groups: FilterGroup[];
|
|
8
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as a,jsxs as p}from"react/jsx-runtime";import"./BaseFilterModal.scss";import{observer as v,useLocalStore as O}from"mobx-react-lite";import{useMemo as g,useState as u}from"react";import{filterGroups as M}from"../utils/filter-groups.js";import{t as n}from"../utils/i18n.js";import{ModalContainer as N}from"./index.js";import w from"./MultiSelectGroupsContainer.js";const E=10;export const BaseFilterModal=v(({store:e,rootStore:d,title:f,groups:i})=>{const r=O(()=>({get pendingSelectedIds(){return e.state.pendingItems.map(t=>t.id)},get totalItemsCount(){return e.state.pendingItems.length===0?e.getFilteredItems().length:d.exhibitorStore.exhibitors.filter(t=>t.categories.some(s=>e.state.pendingItems.some(l=>l.id===s.id))).length}})),[o,c]=u(""),h=g(()=>M(i,o),[i,o]),b=g(()=>i.reduce((t,s)=>t+s.items.length,0)>E,[i]),[m,I]=u({isOpen:e.state.isOpen,groups:i});(m.isOpen!==e.state.isOpen||m.groups!==i)&&(I({isOpen:e.state.isOpen,groups:i}),c(""));const S=t=>{const s=i.flatMap(l=>l.items).filter(l=>t.includes(l.id));e.setPendingItems(s)},C=()=>{e.applyFilter()},_=()=>{e.closeFilter()},y=()=>{e.clearPendingItems()},x=()=>e.state.isOpen;return p(N,{open:e.state.isOpen,title:f,onClose:_,footerLeft:[{label:n("Clear all"),onClick:y,variant:"gray",disabled:r.pendingSelectedIds.length===0}],footerRight:[{label:r.pendingSelectedIds.length>0?n("Show #{{count}}# Matching Exhibitors",{count:r.totalItemsCount}):n("Show All Exhibitors"),onClick:C,variant:"primary",withBadge:!0,disabled:!x()}],children:[b&&p("div",{className:"efp-filter-modal__search",children:[a("i",{className:"icon-search efp-filter-modal__search-icon","aria-hidden":"true"}),a("input",{type:"search",className:"efp-filter-modal__search-input",value:o,placeholder:n("Search..."),"aria-label":n("Search..."),onChange:t=>c(t.target.value)}),o&&a("button",{type:"button",className:"efp-filter-modal__search-clear","aria-label":n("Clear search"),onClick:()=>c(""),children:a("i",{className:"icon-close","aria-hidden":"true"})})]}),h.length>0?a(w,{groups:h,selectedIds:r.pendingSelectedIds,variant:"categories",onChange:S,itemCountProvider:t=>d.categoryStore.categoryById.get(Number(t.id))?.exhibitors?.length||0}):a("p",{className:"efp-filter-modal__empty",role:"status",children:n("Oops, nothing found")})]})});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as y}from"react/jsx-runtime";import{observer as S}from"mobx-react-lite";import{useEffect as F,useMemo as x}from"react";import{useURLFilters as I}from"../hooks/useURLFilters";import t from"../store";import{t as w,tIfExists as C}from"../utils/i18n";import{BaseFilterModal as E}from"./BaseFilterModal";export const CategoryFilterModal=S(()=>{const{currentFilters:a}=I(),{viewScope:g,viewsOwnSelection:p}=t.categoryFilterStore,n=g?.categoryIds??null,u=g?.title??null,d=x(()=>{const l=t.categoryStore.categories||[],s=n?l.filter(e=>n.includes(e.id)):l,r={},c=[],f=[];s.forEach(e=>{if(!e||!e.exhibitors||e.exhibitors.length===0)return;const o=(e.name||"").split("/").map(i=>i.trim());if(o.length>1){const i=o[0],h=o.slice(1).join(" / ");r[i]||(r[i]={groupName:i,items:[]},f.push(i)),r[i].items.push({id:e.id,name:h})}else c.push({id:e.id,name:e.name})});const m=[];return c.length>0&&m.push({groupName:"General",items:c,fullWidth:!0}),f.forEach(e=>{const o=r[e];o&&o.items&&o.items.length>0&&m.push(o)}),m},[t.categoryStore.categories,n]);return F(()=>{if(t.categoryFilterStore.state.isOpen&&p&&a.categories.length>0){const l=a.categories.map(s=>{const r=t.categoryStore.categories.find(c=>c.name.toLowerCase()===s.toLowerCase());return r?{id:r.id,name:r.name}:null}).filter(s=>s!==null).filter(s=>!n||n.includes(s.id));l.length>0&&t.categoryFilterStore.setPendingItems(l)}},[t.categoryFilterStore.state.isOpen,p,a.categories,n]),y(E,{store:t.categoryFilterStore,rootStore:t,title:u?C(u):w("Categories"),groups:d})});
|
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
import { Box } from '@expofp/geometry';
|
|
1
|
+
import { Box, Polygon } from '@expofp/geometry';
|
|
2
2
|
import { type RegularBooth } from '../../../../store/BoothStore.js';
|
|
3
3
|
/** What a badge's anchor search reads off its booth. */
|
|
4
4
|
export type BadgeBooth = Pick<RegularBooth, 'rect' | 'rotate'>;
|
|
5
|
+
/** What a booth's badge must fit in. */
|
|
6
|
+
export interface BadgeFootprint {
|
|
7
|
+
/** The body's shape, built once for the outline and the badge's anchor search alike. */
|
|
8
|
+
readonly geometry: BadgeGeometry;
|
|
9
|
+
/** How far the outline reaches into the body; 0 without one. */
|
|
10
|
+
readonly outlineInset: number;
|
|
11
|
+
}
|
|
12
|
+
/** A footprint's shape, as the anchor search reads it. */
|
|
13
|
+
export interface BadgeGeometry {
|
|
14
|
+
/** The booth's body (its first path) as triangles; empty without paths. */
|
|
15
|
+
readonly triangles: number[][][];
|
|
16
|
+
readonly polygon: Polygon;
|
|
17
|
+
/** The footprint's outer edge. */
|
|
18
|
+
readonly edges: FootprintEdge[];
|
|
19
|
+
readonly bbox: Box | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The badge's footprint: the booth's first path. Later paths are usually an outline drawn as a band
|
|
23
|
+
* over the body's edge, so their reach into the body comes along for the badge to keep clear of. A
|
|
24
|
+
* path that does not reach the edge is an inner element, not an outline, and is left out.
|
|
25
|
+
* @param booth - The booth.
|
|
26
|
+
* @returns The body and the outline's reach into it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getBoothBadgeFootprint(booth: Pick<RegularBooth, 'paths' | 'layer'>): BadgeFootprint;
|
|
5
29
|
/** Where a badge sits in one booth corner, and how large it may grow there. */
|
|
6
30
|
export interface BadgeFit {
|
|
7
31
|
/** The x of the badge's top-left corner on the plan, before rotation. */
|
|
@@ -26,7 +50,6 @@ export interface BadgeFit {
|
|
|
26
50
|
*/
|
|
27
51
|
export declare class BoothBadgeAnchors {
|
|
28
52
|
private readonly booth;
|
|
29
|
-
private readonly triangles;
|
|
30
53
|
private readonly border;
|
|
31
54
|
private readonly source;
|
|
32
55
|
/** The badges with corners still to work out while the page is idle, in the order queued. */
|
|
@@ -35,17 +58,20 @@ export declare class BoothBadgeAnchors {
|
|
|
35
58
|
private readonly fits;
|
|
36
59
|
/** The rotation at corner 0 the idle work counts quarter turns from. */
|
|
37
60
|
private prefetchRotation;
|
|
61
|
+
private readonly triangles;
|
|
38
62
|
private readonly polygon;
|
|
63
|
+
/** The footprint's outer edge. */
|
|
64
|
+
private readonly edges;
|
|
39
65
|
private readonly bbox;
|
|
40
66
|
/** The booth's distinct vertices in first-seen order, built on the first search. */
|
|
41
67
|
private vertices;
|
|
42
68
|
/**
|
|
43
69
|
* @param booth - The booth the badge belongs to.
|
|
44
|
-
* @param
|
|
70
|
+
* @param geometry - The booth's footprint, from {@link buildBadgeGeometry}.
|
|
45
71
|
* @param border - How far the badge stays in from the booth's edge.
|
|
46
72
|
* @param source - The badge's width and height at scale 1.
|
|
47
73
|
*/
|
|
48
|
-
constructor(booth: BadgeBooth,
|
|
74
|
+
constructor(booth: BadgeBooth, geometry: BadgeGeometry, border: number, source: {
|
|
49
75
|
readonly x: number;
|
|
50
76
|
readonly y: number;
|
|
51
77
|
});
|
|
@@ -80,12 +106,21 @@ export declare class BoothBadgeAnchors {
|
|
|
80
106
|
*/
|
|
81
107
|
private prefetchNext;
|
|
82
108
|
/**
|
|
83
|
-
* Searches a corner: the anchor,
|
|
109
|
+
* Searches a corner: the anchor, the largest scale at it, then the move off slanted sides.
|
|
84
110
|
* @param corner - The booth corner, clockwise from top-left (0).
|
|
85
111
|
* @param rotation - The badge's rotation at that corner, in radians.
|
|
86
112
|
* @returns The corner's fit.
|
|
87
113
|
*/
|
|
88
114
|
private compute;
|
|
115
|
+
/**
|
|
116
|
+
* Moves the anchor along the badge's axes where a slanted booth side comes nearer than the border
|
|
117
|
+
* to the badge's left or top side.
|
|
118
|
+
* @param anchor - The badge's anchor.
|
|
119
|
+
* @param scale - The badge's largest scale.
|
|
120
|
+
* @param rotation - The badge's rotation, in radians.
|
|
121
|
+
* @returns The moved anchor; `null` when no move is needed or it would leave the booth.
|
|
122
|
+
*/
|
|
123
|
+
private nudge;
|
|
89
124
|
/**
|
|
90
125
|
* The largest scale the booth's rect allows. At odd corners the badge's width and height lie
|
|
91
126
|
* along the booth's height and width.
|
|
@@ -115,6 +150,15 @@ export declare class BoothBadgeAnchors {
|
|
|
115
150
|
* @returns The scale; the cap itself when the booth has no footprint or the anchor lies outside.
|
|
116
151
|
*/
|
|
117
152
|
private clampScale;
|
|
153
|
+
/**
|
|
154
|
+
* Whether the badge's three corners away from the anchor lie inside the booth's footprint.
|
|
155
|
+
* @param anchorX - The badge's anchor.
|
|
156
|
+
* @param anchorY - The badge's anchor.
|
|
157
|
+
* @param scale - The badge's scale.
|
|
158
|
+
* @param rotation - The badge's rotation, in radians.
|
|
159
|
+
* @returns Whether they do.
|
|
160
|
+
*/
|
|
161
|
+
private fitsAt;
|
|
118
162
|
/**
|
|
119
163
|
* The booth's distinct vertices, in the order the triangles first name them.
|
|
120
164
|
* @returns The vertices, built once.
|
|
@@ -127,4 +171,12 @@ export declare class BoothBadgeAnchors {
|
|
|
127
171
|
* @returns The box, or `null` when there are no triangles.
|
|
128
172
|
*/
|
|
129
173
|
export declare function trianglesBoundingBox(triangles: number[][][]): Box | null;
|
|
174
|
+
/** A segment of a footprint's outer edge. */
|
|
175
|
+
export type FootprintEdge = [number[], number[]];
|
|
176
|
+
/**
|
|
177
|
+
* The shape the anchor search reads off a footprint's triangles.
|
|
178
|
+
* @param triangles - The triangles.
|
|
179
|
+
* @returns The triangles with their polygon, outer edge and bounding box.
|
|
180
|
+
*/
|
|
181
|
+
export declare function buildBadgeGeometry(triangles: number[][][]): BadgeGeometry;
|
|
130
182
|
//# sourceMappingURL=booth-badge-anchor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Box as
|
|
1
|
+
import{Box as P,pointRotate as p,Polygon as R}from"@expofp/geometry";import{getTrianglesFromFpPaths as M}from"../../../../data/svg.js";const T=.5,v=.3,w=10,$=.01,b=8,C=2,G=.01,k=8,A=4,D=50;export function getBoothBadgeFootprint(f){const[t,...s]=f.paths??[],e=f.layer?.name||"",n=t?M(t.index,e):[],i=buildBadgeGeometry(n);if(!s.length)return{geometry:i,outlineInset:0};const{polygon:c,edges:o}=i;let r=0;for(const l of s){let a=0,h=!1;for(const u of M(l.index,e))for(const[y,m]of u){const x={x:y,y:m};if(c.containsPoint(x,{areaTolerance:0})){const d=S(x,o);a=Math.max(a,d),d<=$&&(h=!0)}else h=!0}h&&(r=Math.max(r,a))}return{geometry:i,outlineInset:r}}export class BoothBadgeAnchors{static{this.idle=new Set}static{this.idleScheduled=!1}constructor(t,s,e,n){this.booth=t,this.border=e,this.source=n,this.fits=[],this.prefetchRotation=0,this.vertices=null,{triangles:this.triangles,polygon:this.polygon,edges:this.edges,bbox:this.bbox}=s}fit(t,s){let e=this.fits[t];return e||(this.fits[t]=e=this.compute(t,s),this.fits.filter(Boolean).length===4&&(this.vertices=null)),e}prefetch(t){BoothBadgeAnchors.idle.has(this)||(this.prefetchRotation=t,BoothBadgeAnchors.idle.add(this),BoothBadgeAnchors.scheduleIdle())}cancelPrefetch(){BoothBadgeAnchors.idle.delete(this)}static scheduleIdle(){BoothBadgeAnchors.idleScheduled||!BoothBadgeAnchors.idle.size||(BoothBadgeAnchors.idleScheduled=!0,typeof requestIdleCallback=="function"?requestIdleCallback(BoothBadgeAnchors.runIdle):typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>setTimeout(BoothBadgeAnchors.runSlice,0)):setTimeout(BoothBadgeAnchors.runSlice,D))}static runSlice(){const t=performance.now()+A;BoothBadgeAnchors.runIdle({timeRemaining:()=>t-performance.now()})}static runIdle(t){BoothBadgeAnchors.idleScheduled=!1;const s=performance.now()+k;try{for(const e of BoothBadgeAnchors.idle){if(t.timeRemaining()<=0||performance.now()>=s)break;let n=!1;try{n=e.prefetchNext()}finally{n||BoothBadgeAnchors.idle.delete(e)}}}finally{BoothBadgeAnchors.scheduleIdle()}}prefetchNext(){for(let t=1;t<4;t++)if(!this.fits[t])return this.fit(t,this.prefetchRotation+t*Math.PI/2),t<3;return!1}compute(t,s){const e=t===0||t===3?1:-1,n=t===0||t===1?1:-1;let i=this.findAnchor(e,n),c=this.clampScale(i.x,i.y,this.rectMaxScale(t%2===1),s);const o=(this.booth.rotate??0)+t*Math.PI/2;for(let r=0;r<C;r++){const l=this.nudge(i,c,o);if(!l)break;i=l,this.fitsAt(i.x,i.y,c,s)||(c=this.clampScale(i.x,i.y,c,s))}return{x:i.x,y:i.y,maxScale:c}}nudge(t,s,e){if(!this.triangles.length||!s)return null;const n=Math.cos(e),i=Math.sin(e),c=this.source.x*s,o=this.source.y*s,r=(y,m)=>{let x=0;for(let d=0;d<=b;d++){const g={x:t.x+y*d/b,y:t.y+m*d/b},I=S(g,this.edges),E=this.polygon.containsPoint(g);x=Math.max(x,E?this.border-I:this.border+I)}return x},l=r(-i*o,n*o),a=r(n*c,i*c),h=this.border*G;if(l<=h&&a<=h)return null;const u={x:t.x+Math.max(l,0)*n-Math.max(a,0)*i,y:t.y+Math.max(l,0)*i+Math.max(a,0)*n};return this.polygon.containsPoint(u)?u:null}rectMaxScale(t){const s=this.booth.rect.size.width,e=this.booth.rect.size.height,n=t?e:s,i=t?s:e;return Math.min(n>0?n*T/this.source.x:1/0,i>0?i*v/this.source.y:1/0)}findAnchor(t,s){const{booth:e,border:n,bbox:i}=this;if(i){const l=t>0?i.min.x:i.max.x,a=s>0?i.min.y:i.max.y,h=[];for(const[u,y]of this.distinctVertices()){const m=u+n*t,x=y+n*s,d=Math.abs(m-l)+Math.abs(x-a);d<1/0&&h.push({x:m,y:x,score:d,order:h.length})}h.sort((u,y)=>u.score-y.score||u.order-y.order);for(const u of h){const y={x:u.x,y:u.y};if(this.polygon.containsPoint(y))return y}}const c=t>0?e.rect.min.x+n:e.rect.max.x-n,o=s>0?e.rect.min.y+n:e.rect.max.y-n,r=e.rotate??0;return r?p({x:c,y:o},r,e.rect.center):{x:c,y:o}}clampScale(t,s,e,n){const{polygon:i}=this;if(!this.triangles.length)return e;const c={x:t,y:s};if(!i.containsPoint(c))return e;let o=0,r=e;for(let l=0;l<w;l++){const a=(o+r)/2;this.fitsAt(t,s,a,n)?o=a:r=a}return o}fitsAt(t,s,e,n){const{polygon:i,source:c}=this,o={x:t,y:s},r=c.x*e,l=c.y*e;return i.containsPoint(p({x:t+r,y:s},n,o))&&i.containsPoint(p({x:t,y:s+l},n,o))&&i.containsPoint(p({x:t+r,y:s+l},n,o))}distinctVertices(){if(this.vertices)return this.vertices;const t=new Set,s=[];for(const e of this.triangles)for(const n of e){const i=`${n[0]},${n[1]}`;t.has(i)||(t.add(i),s.push([n[0],n[1]]))}return this.vertices=s}}export function trianglesBoundingBox(f){if(!f.length)return null;let t=1/0,s=1/0,e=-1/0,n=-1/0;for(const i of f)for(const[c,o]of i)c<t&&(t=c),o<s&&(s=o),c>e&&(e=c),o>n&&(n=o);return P.fromMinMax({x:t,y:s},{x:e,y:n})}function L(f){const t=[],s=[];for(const e of f){const n=t.length;t.push({x:e[0][0],y:e[0][1]}),t.push({x:e[1][0],y:e[1][1]}),t.push({x:e[2][0],y:e[2][1]}),s.push([n,n+1,n+2])}return new R(t,s)}export function buildBadgeGeometry(f){return{triangles:f,polygon:L(f),edges:N(f),bbox:trianglesBoundingBox(f)}}function N(f){const t=new Map;for(const e of f)for(let n=0;n<3;n++){const i=e[n],c=e[(n+1)%3],o=`${i[0]},${i[1]}`,r=`${c[0]},${c[1]}`,l=o<r?`${o}|${r}`:`${r}|${o}`,a=t.get(l);a?a.count++:t.set(l,{edge:[i,c],count:1})}const s=[];for(const{edge:e,count:n}of t.values())n===1&&s.push(e);return s}function S(f,t){let s=1/0;for(const[[e,n],[i,c]]of t){const o=i-e,r=c-n,l=o*o+r*r,a=l?Math.max(0,Math.min(1,((f.x-e)*o+(f.y-n)*r)/l)):0;s=Math.min(s,Math.hypot(f.x-e-a*o,f.y-n-a*r))}return s}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type Booth } from '../../../../store/BoothStore';
|
|
2
|
+
/**
|
|
3
|
+
* A booth's fill by status (hold, sold, available or rebooking), before hover, selection or heatmap.
|
|
4
|
+
* @param booth - The booth.
|
|
5
|
+
* @returns A color that parses, falling back to the default booth color.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getBoothStatusColor(booth: Booth): string;
|
|
8
|
+
/**
|
|
9
|
+
* A booth's body fill at rest: its first path's own color, otherwise its status color. Later paths
|
|
10
|
+
* are usually an outline. A heatmap paints the whole booth; monochrome plans gray it, as the booth's
|
|
11
|
+
* own drawer does.
|
|
12
|
+
* @param booth - The booth.
|
|
13
|
+
* @returns The fill color.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getBoothFillColor(booth: Booth): string;
|
|
16
|
+
//# sourceMappingURL=booth-fill-color.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import n from"color";import f from"../../../../data";import{heatmapStore as u,uiState as i}from"../../../../store";import{RegularBooth as c,SpecialBooth as m}from"../../../../store/BoothStore";import{RebookingState as p}from"../../../../store/ExhibitorStore";import{rebookingStateConfig as s}from"../../../../tools/rebooking-config";import e from"../../../../tools/settings";const g=o=>{if(!o||o==="transparent"||o==="none")return!1;try{return n(o),!0}catch{return!1}};function d(o){if(o.length===0)return null;const r=o[0];return o.every(l=>l===r)?r:null}export function getBoothStatusColor(o){let r=e.colors.booths.default;if(o instanceof m)r=o.color||e.colors.booths.empty;else if(o instanceof c){if(f.isRebooking){if(!o.exhibitors?.length)return s[p.Unasked].color.primary;const l=d((o.exhibitors??[]).map(a=>a.rebookingState));return l!==null?s[l].color.primary:"#000000"}const t=e.colors.booths;o.onHold?r=o.holdColor||t.defaultHold:o.exhibitors.length||o.reserved?r=o.soldColor||t.defaultSold:r=o.availColor||t.empty}try{r==="none"&&(r=e.colors.booths.default),n(r)}catch(t){r=e.colors.booths.default,console.error("Booth: defaultColor",t)}return r}export function getBoothFillColor(o){if(i.heatmap)return u.getHeatmapColorForBooth(o).rgb().string();const r=o.paths?.[0]?.color,t=g(r)?r:getBoothStatusColor(o);return i.monochrome||i.heatmapYah?n(t).grayscale().rgb().string():t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{pointRotate as
|
|
1
|
+
import{pointRotate as M,Rect as W}from"@expofp/geometry";import{update as v}from"@expofp/renderer";import z from"color";import{reaction as T}from"mobx";import{SEPARATOR as _}from"../../../../constants";import w from"../../../../data";import{createShapeDef as Y,createTextDef as Z,createTextDefLines as Q}from"../../../../engine/defs";import{loadCustomFontsUrls as V}from"../../../../engine/fonts";import{getQuarterTurns as j,getRollValue as q}from"../../../../engine/update-def";import{boothStore as J,uiState as L}from"../../../../store";import{RegularBooth as K}from"../../../../store/BoothStore";import{getContrastTextColor as tt}from"../../../../utils/getContrastTextColor";import et from"../../../../utils/is-phone";import{BoothBadgeAnchors as ot,getBoothBadgeFootprint as nt}from"./booth-badge-anchor";import{getBoothFillColor as rt}from"./booth-fill-color.js";import{getFont as it}from"./canvases";import{isBoothBadgeEligible as st}from"./config-booth-badge-eligibility";import{getBadgeScale as at}from"./config-booth-badge-scale";import{getBadgeFontWeight as ct,getFontUrlByWeight as lt}from"./config-booth-labels";const P=15,ht=et?16:18,I=30,dt=6,mt=4,F=.8,H=I*F,U=document.createElement("canvas").getContext("2d");function gt(t){return t.length<=P?t:t.slice(0,P-1)+"\u2026"}export function createBoothBadge(t){const n=gt(t.title||t.name),e=rt(t),r=tt(z(e).hex()),a=ct(),h=it(I,a);U.font=h;const i=U.measureText(n).width,c=Math.ceil(i+dt*2),m=I+mt*2,{geometry:E,outlineInset:$}=nt(t),X=Math.max((t.borderWidth||J.borderWidth)/2,$),N=c*F,R=m*F,A=new ot(t,E,X,{x:N,y:R});let d=t.rotate??0,b=0,g=0,u=0,D=0;const O=()=>{const o=A.fit(b,d);g=o.x,u=o.y,D=o.maxScale};O();const C=(o,S)=>{const y=o/2,B=S/2,k=M({x:g+y,y:u+B},d,{x:g,y:u});return new W(k,{x:o,y:S},d,t.elevation)},G=lt(a,V()),s=Y(C(1,1),e);s.hidden=!0,s.dim=t.skipDim?0:void 0;const l=Z(Q([[n],[]],r,0,[G,G]),C(1,1),[0,0],{horizontal:"center",vertical:"center"});l.hidden=!0,l.dim=t.skipDim?0:void 0;const f={booth:t,anchor:{x:g,y:u},source:{x:N,y:R},rotation:d,maxScale:D,bg:s,text:l},p=new BoothBadgeDrawer(f);s.onScale=({pixelSize:o})=>p.layOutBg(o),l.onScale=({pixelSize:o})=>p.layOutText(o);const x=[];return x.push(T(()=>t.skipDim,o=>{s.dim=o?0:void 0,l.dim=o?0:void 0,v(s,l)})),x.push(T(()=>t.layer?.visible??!0,o=>{s.hidden=!o,l.hidden=!o,v(s,l)})),x.push(T(()=>L.mapSettings,({roll:o})=>{q(o??0)&&(A.prefetch(t.rotate??0),s.onRoll=({roll:S,pixelSize:y})=>{const B=j(S,d);if(B!==0)return d+=B*Math.PI/2,b=((b+B)%4+4)%4,O(),f.anchor.x=g,f.anchor.y=u,f.rotation=d,f.maxScale=D,p.invalidate(),[...p.layOutBg(y),...p.layOutText(y)]})},{fireImmediately:!0}),()=>A.cancelPrefetch()),{bg:s,text:l,dispose:()=>{x.forEach(o=>o()),x.length=0}}}export class BoothBadgeDrawer{constructor(n){this.placement=n,this.bgScale=NaN,this.textScale=NaN}invalidate(){this.bgScale=NaN,this.textScale=NaN}layOutBg(n){const{bg:e}=this.placement,r=this.scaleFor(n);return r===this.bgScale?[]:(this.bgScale=r,e.shape=this.rectAt(r),e.hidden=this.isHidden(),e.hidden?[]:[e])}layOutText(n){const{text:e}=this.placement,r=this.scaleFor(n);return r===this.textScale?[]:(this.textScale=r,e.lines[0].fontSize=H*r,e.bounds=this.rectAt(r),e.hidden=this.isHidden(),e.hidden?[]:[e])}scaleFor(n){return at({pixelSize:n,fontSize:ht,plateFontSize:H,maxScale:this.placement.maxScale})}rectAt(n){const{anchor:e,booth:r,source:a,rotation:h}=this.placement,i=a.x*n,c=a.y*n,m=M({x:e.x+i/2,y:e.y+c/2},h,e);return new W(m,{x:i,y:c},h,r.elevation)}isHidden(){const{booth:n}=this.placement;return!!(n.layer&&!n.layer.visible)}}export function configBoothsBadges(t,n){const e=[],r=[],a=[];for(const i of n)if(i instanceof K&&st({hideExhibitorBoothNumber:w.hideExhibitorBoothNumber,hideBoothBadges:w.hideBoothBadges,hideLogoInBooth:L.hideLogoInBooth,noLabels:i.noLabels,hasExhibitors:i.exhibitors.length>0,hasLogoInBooth:i.exhibitors.some(c=>c.logoInBooth&&c.logo)})){const{bg:c,text:m,dispose:E}=createBoothBadge(i);e.push(c),r.push(m),a.push(E)}const h=()=>{a.forEach(i=>i()),a.length=0};return e.length?{layer:{name:`${t}${_}badges`,children:[{name:`${t}${_}badgeBgs`,children:e},{name:`${t}${_}badgeTexts`,children:r}]},cleanup:h}:{layer:null,cleanup:h}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as
|
|
1
|
+
import{__decorate as f}from"tslib";import{Rect as C}from"@expofp/geometry";import{update as B}from"@expofp/renderer";import s from"color";import S from"color-interpolate";import{computed as d}from"mobx";import m from"../../../../data";import{getFpSvgJs as y}from"../../../../data/fp-payloads";import{createShapeDef as k}from"../../../../engine/defs";import D,{boothStore as I,heatmapStore as L,layersStore as u,uiState as i}from"../../../../store";import{LayersMode as P}from"../../../../store/LayerStore";import l from"../../../../tools/settings";import{planReaction as g}from"../../../../utils/plan-reactions.js";import{getBoothStatusColor as v}from"./booth-fill-color.js";import{BoothDrawerBaseWithoutPainter as w}from"./BoothDrawerBase";import{buildPathDef as x}from"./config-bg";export default function A(h){return new n(h)}export function pathToShapeDef(h,o){const e=[];for(const t of h){const r=x({index:t.index,color:t.color,unblinking:t.unblinking},o);r&&e.push(r)}return e}class n extends w{constructor(o){if(super(o),o.paths){const e=pathToShapeDef(o.paths,D.layerStore.mode!==P.Default?o.layer.name:"");o.shapes=e.map(t=>{const r=i.monochrome?s(t.color).grayscale().rgb().string():this.getBoothColor().string();return t.color==="transparent"?t.color=r:t.defaultColor=t.color,t})}else{const e=o.borderColor==="none"?0:isNaN(o.borderWidth)?I.borderWidth:o.borderWidth,t=this.booth.rect.expand(-e/2),r=this.getBoothColor().string();o.shapes=[k(new C(t.center,t.size,this.booth.rotate,this.booth.elevation),r)]}g(()=>this.booth.hover,()=>!this.booth.selected&&this.update()),g(()=>[u.layersLoaded,this.booth.skipDim,this.booth.selected,this.boothShape.selectBgAnimationPart],()=>this.update())}getShape(){return this.booth.shapes}update(){if(u.layersLoaded)for(const o of this.booth.shapes){if(o.dim=this.booth.skipDim?0:void 0,o.color&&!o.unblinking){const e=o.defaultColor?this.getBoothPathColor(o.defaultColor):this.getBoothColor();o.color=e.string()}B(o)}}get poiHighlighted(){const o=this.booth;return!o.selected&&o.poiTypeId!=null&&o.skipDim}getBoothPathColor(o){if(i.heatmap)return this.getHeatmapColor();const e=this.booth,t=l.colors.booths.selected;let r=s(this.poiHighlighted?t:o).hsl();if(e.selected){if(y().__fpSettings?.fpVer){const c=this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart),p=s(c==="none"?t:c);return i.monochrome?p.grayscale():p}const a=s(t).hsl(),b=a.lightness()*this.boothShape.selectBgAnimationPart;r=r.hue(a.hue()).lightness(b)}else e.hover&&(r=r.darken(.1));return i.monochrome&&(r=r.grayscale()),r}getHeatmapColor(){const o=this.booth,e=L.getHeatmapColorForBooth(o);if(o.selected){const t=this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart);return s(t==="none"?"#f33":t)}return o.hover?e.darken(.2).alpha(e.alpha()*1.5):e}get defaultColor(){return v(this.booth)}get selectedColorInterpolateFunc(){const o=l.colors.booths.seectedLight||(s(this.booth.labelColor||l.boothLabelColor).isLight()?"#000":"#fff"),e=i.selectedRoute?l?.colors?.booths?.wayfinding?.selected:l?.colors?.booths?.selected;return S([o,e])}getBoothColor(){const o=this.booth;if(i.heatmap)return this.getHeatmapColor();let e;o.error?e="#f33":m.isRebooking?e=this.defaultColor:o.selected?e=this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart):this.poiHighlighted?e=l.colors.booths.selected:e=this.defaultColor;let t;try{t=s(e==="none"?"#f33":e)}catch{t=s(this.defaultColor)}return(o.hover&&!o.selected||o.selected&&m.isRebooking)&&(t=t.darken(.2).alpha(t.alpha()*1.5)),(i.monochrome||i.heatmapYah)&&(t=t.grayscale()),t}}f([d({keepAlive:!0})],n.prototype,"defaultColor",null),f([d({keepAlive:!0})],n.prototype,"selectedColorInterpolateFunc",null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o,jsxs as _}from"react/jsx-runtime";import"./SearchButton.scss";import a from"classnames";import{observer as x}from"mobx-react-lite";const N=x(({id:j,label:n,icon:c,text:t,active:l,count:e,variant:s="toggle",expanded:u=!1,isDimmed:f=!1,isDisabled:i=!1,showZeroCount:h=!1,backgroundColor:r,textColor:m,onClick:p})=>{const b=e!==void 0&&(e>0||h),d=!!r;return _("button",{type:"button",style:d?{"--btn-bg-color":r,"--btn-text-color":m||"#1a1a1a"}:void 0,className:a("efp-search-button",`efp-search-button--${s}`,{"is-active":l,"is-dimmed":f,"is-disabled":i,"has-custom-color":d}),onClick:()=>{p?.(),window.__resett?.()},disabled:i,"aria-label":n,title:t?void 0:n,"aria-haspopup":s==="action"?"dialog":void 0,"aria-expanded":s==="action"?u:void 0,children:[c&&o("i",{className:a(c,"efp-search-button__icon")}),t&&o("span",{className:"efp-search-button__text",children:t}),s==="action"&&o("i",{className:"icon-chevron-down efp-search-button__chevron","aria-hidden":"true"}),b&&o("span",{className:a("efp-search-button__count",{"is-zero":e===0}),children:e})]})});export default N;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Fragment as I,jsx as x,jsxs as M}from"react/jsx-runtime";import{Box as w}from"@expofp/geometry";import{CameraSchema as R,SessionsFiltersSchema as $}from"@expofp/schema";import{optimizeWaypointOrder as V}from"@expofp/wayfinding";import{ErrorBoundary as z}from"@sentry/react";import j from"debug";import{reaction as G,runInAction as N}from"mobx";import{createRoot as O}from"react-dom/client";import{install as q}from"resize-observer";import D from"./components/Layout";import{bindBoothHitTest as Y}from"./components/Map/booth-by-xy.js";import{MAX_ROUTE_WAYPOINTS as y}from"./constants";import H from"./data";import{getFpGeo as P}from"./data/fpGeo.js";import U from"./floorplan.loader";import{shouldLoadIntercom as W}from"./intercom";import{registerPlanDisposer as S}from"./plan-lifecycle.js";import{BoundsSchema as X,POISelectorsSchema as k,ZoomToOptionsSchema as v}from"./schemas/sdk.schemas";import{applyDeclarativeConfig as K,applyParameters as Q,applyPathway as Z,initUrlRouting as J}from"./services/url-dispatch";import r,{uiState as _}from"./store";import{bindDetailsEvents as ee}from"./store/details-events";import{bindRootElement as te}from"./store/init/init-ui.js";import{findBooth as b,Route as B,separateExternalIds as F}from"./store/RouteStore";import{GaEventActions as C,initGtag as re,sendEventToGa as L,setConsentSettings as oe}from"./tools/gtag.js";import ie from"./tools/track-event.js";import{cameraToMapSettings as se,mapSettingsToCamera as ne}from"./utils/camera-map-settings";import{getStorage as A}from"./utils/entity-storage";import{getMostFrequent as ae}from"./utils/getMostFrequent";import{convertLocalToGps as he,isValidPointCoords as g}from"./utils/gps";import{getLocales as le,hasLocale as ce,setLocale as ue}from"./utils/i18n";import{mapEntity as p}from"./utils/mapEntity";const d=j("efp:api");q();export default class fe extends U{init(){re(),K(),this.ignoreQuery||J(this.offHistory),ie("load"),te(r),r.fp=this,S(ee()),Y(),oe(this.consent),L(C.Load,""),this.root=O(this.renderTarget),this.root.render(x(z,{children:x(D,{offHistory:this.offHistory,consent:this.consent})})),L(C.Rendered,""),S(G(()=>r.layerStore.layersLoaded,()=>{const t=this.renderTarget.getRootNode(),o=t instanceof ShadowRoot?t.host:this.renderTarget.parentElement;for(document.querySelectorAll(".expofp-floorplan-loader").forEach(s=>s.remove());o&&this.element.firstChild&&this.element.firstChild!==o;)this.element.removeChild(this.element.firstChild);this.resolveReady(),r.initialized||this.onInit?.(this),r.initialized=!0})),S(()=>clearTimeout(E));const e=W(H);e&&import("./intercom/bootIntercom").then(({bootIntercom:t})=>t(e)).catch(()=>{})}selectBooth(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectBooth","Parameter must be a string or an array of strings.","EFP000000");return}const t=r.boothStore.booths.filter(o=>typeof e=="string"?o.name===e||o.externalId===e:e.includes(o.name)||e.includes(o.externalId));r.selectBooth(t)}selectExhibitor(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectExhibitor","Parameter must be a string or an array of strings.","EFP000100");return}if(!e?.length){r.uiState.menu=!1,r.searchStore.resetSearchBox(),r.uiState.details=null;return}const t=r.exhibitorStore.exhibitors.filter(i=>typeof e=="string"?i.name===e||i.externalId===e:e.includes(i.name)||e.includes(i.externalId));if(!t?.length)return;if(typeof e=="string"){r.selectExhibitor(t[0]),r.moveToList([t[0]]);return}const o=t.flatMap(i=>i.booths.map(n=>n.layer)),s=ae(o.map(i=>i.description));s&&r.layerStore.updateVisibility(s,!0),r.uiState.menu=!1,r.searchStore.resetSearchBox(),r.uiState.details=null,r.uiState.list={type:"filter",items:t,query:{key:"exhibitors",value:t.map(i=>i.name).join(",")}},r.moveToList()}highlightExhibitors(e){Array.isArray(e)||a("highlightExhibitors","Parameter must be an array of strings.","EFP000200"),r.boothStore.highlightedByExternalIds=[],r.exhibitorStore.highlightedByExternalIds=[...e]}highlightBooths(e){Array.isArray(e)||a("highlightBooths","Parameter must be an array of strings.","EFP000300"),r.exhibitorStore.highlightedByExternalIds=[],r.boothStore.highlightedByExternalIds=[...e]}highlightEntities(e){Array.isArray(e)||a("highlightEntities","Parameter must be an array of strings.","EFP000400");const{boothExternalIds:t,exhibitorExternalIds:o}=F(e);r.boothStore.highlightedByExternalIds=[...t],r.exhibitorStore.highlightedByExternalIds=[...o]}selectRoute(e,t){if(Array.isArray(e)){const o=[...e],s=o.shift(),i=o.pop();if(o.length>y)throw new Error(`The maximum number of waypoints is ${y}.`);if(!s||!i){a("selectRoute","Invalid route format: When providing an array, it must include at least two points: a start and a destination.","EFP000401");return}const n=o.map(m).filter(h=>h!==null);r.routeStore.selectRoute(new B(m(s),m(i),n));return}e||a("selectRoute","At a minimum, the starting point must be passed.","EFP000402"),r.routeStore.selectRoute(new B(m(e),t?m(t):null))}getOptimizedRoutes(e){if(!Array.isArray(e))return a("getOptimizedRoutes","Parameter must be an array.","EFP000500"),[];if(e.length>y)throw new Error(`The maximum number of waypoints is ${y}.`);const t=e.map(m).filter(s=>!!s);if(!t.length)throw new Error("No booths found for the provided waypoints.");const o=new Map;for(const s of t){const i=s.layer?.name??"",n=o.get(i);n?n.push(s):o.set(i,[s])}return Array.from(o.values()).map(s=>({waypoints:V(s.map(i=>[i.name,{x:i.rect.center.x,y:i.rect.center.y}]))}))}selectCurrentPosition(e,t,o){const s=g(e.x)&&g(e.y),i=g(e.lng)&&g(e.lat);!s&&!i&&a("selectCurrentPosition","A point must be passed. Either (x,y) or (lat,lng) are required.","EFP000600"),r.routeStore.selectCurrentPosition(e,t,o),this.onCurrentPositionChanged?.(e)}setBookmarks(e){(!Array.isArray(e)||!e.length)&&a("setBookmarks","Parameter must be an array.","EFP000700"),e.forEach(t=>{const o=r.exhibitorStore.exhibitors.find(s=>s.name===t.name||s.externalId===t.externalId);o&&(o.bookmarked=t.bookmarked)})}setEntitiesBookmarks(e){if(!Array.isArray(e)||!e.length){a("setEntitiesBookmarks","Parameter must be an array.","EFP000701");return}const t=["exhibitor","event","speaker","booth"],o=e.find(n=>!n.type||!t.includes(n.type));if(o){a("setEntitiesBookmarks",`Invalid entity type: ${o.type}. Must be one of: ${t.join(", ")}.`,"EFP000702");return}const s=A("bookmarked"),i={exhibitor:{existingIds:new Set(s.exhibitors||[]),finder:n=>r.exhibitorStore.findExhibitor(n),replacer:n=>r.exhibitorStore.replaceBookmarked(n)},event:{existingIds:new Set(s.events||[]),finder:n=>r.eventStore.findByNameOrSlug(n),replacer:n=>r.eventStore.replaceBookmarked(n)},speaker:{existingIds:new Set(s.speakers||[]),finder:n=>r.speakerStore.speakers.find(h=>h.name===n||h.externalId===n||h.slug===n),replacer:n=>r.speakerStore.replaceBookmarked(n)},booth:{existingIds:new Set(s.booths||[]),finder:n=>{const h=r.boothStore.findBooth(n);return h?.exhibitors.length===0?h:void 0},replacer:n=>r.boothStore.replaceBookmarked(n)}};e.forEach(n=>{const h=i[n.type],u=n.name||n.externalId||"",l=h.finder(u);l?n.bookmarked?h.existingIds.add(l.id):h.existingIds.delete(l.id):console.warn(`Entity not found: ${n.type} with query "${u}"`)}),Object.values(i).forEach(n=>{n.replacer(Array.from(n.existingIds))})}setEntitiesVisited(e){if(!Array.isArray(e)||!e.length){a("setEntitiesVisited","Parameter must be an array.","EFP000703");return}const t=["exhibitor","event"],o=e.find(n=>!n.type||!t.includes(n.type));if(o){a("setEntitiesVisited",`Invalid entity type: ${o.type}. Must be one of: ${t.join(", ")}.`,"EFP000704");return}const s=A("visited"),i={exhibitor:{existingIds:new Set(s.exhibitors||[]),finder:n=>r.exhibitorStore.findExhibitor(n),replacer:n=>r.exhibitorStore.replaceVisited(n)},event:{existingIds:new Set(s.events||[]),finder:n=>r.eventStore.findByNameOrSlug(n),replacer:n=>r.eventStore.replaceVisited(n)}};e.forEach(n=>{const h=i[n.type],u=n.name||n.externalId||"",l=h.finder(u);l?n.visited?h.existingIds.add(l.id):h.existingIds.delete(l.id):console.warn(`Entity not found: ${n.type} with query "${u}"`)}),Object.values(i).forEach(n=>{n.replacer(Array.from(n.existingIds))})}setMarkers(e){if(!e||!Array.isArray(e.icons)||!Array.isArray(e.markers)){a("setMarkers","Invalid input.","EFP000800");return}r.routeStore.setMarkers(e)}selectMarker(e,t=!0){return typeof e!="string"&&a("selectMarker","The identifier must be passed.","EFP000900"),r.routeStore.selectMarker(e,t)}drawCircles(e){Array.isArray(e)||a("drawCircles","Invalid input.","EFP000A00"),r.uiState.debugCircles=e}checkRoutes(){r.routeStore.checkRoutes()}updateLayerVisibility(e,t){typeof e!="string"&&a("updateLayerVisibility","The layer name (string) must be passed.","EFP000B00"),t||a("updateLayerVisibility","Passing a false value to visible will have no effect.","EFP000B01"),r.layerStore.updateVisibility(e,t)}getCenterCoordinates(){return r.fp.getCenterCoordinates()}exhibitorsList(){return r.exhibitorStore.exhibitors.map(e=>p(e))}boothsList(){return r.boothStore.booths.map(e=>p(e))}categoriesList(){return r.categoryStore.categories.map(e=>p(e))}selectCategory(e){if(e==null||typeof e!="string"){r.searchStore.selectSearch();return}const t=e?.toLowerCase(),o=r.categoryStore.categories.find(({name:s,slug:i})=>s?.toLowerCase()===t||i?.toLowerCase()===t);if(!o){a("selectCategory",`Category ${e} not found.`,"EFP000C01");return}r.selectCategory(o)}select(e){if(typeof e!="string"){a("select","Parameter must be a string.","EFP001700");return}const t=e,o=t?.toLowerCase(),s=r.boothStore.booths.find(l=>l.slug?.toLowerCase()===o||l.externalId?.toLowerCase()===o||l.externalId?.toLowerCase()?.replace(/\s+/g,"")===o);if(s){setTimeout(()=>r.selectBooth(s),250);return}const i=r.eventStore.eventItems.find(l=>l.slug?.toLowerCase()===o||l.externalId?.toLowerCase()===o);if(i){r.selectEventItem(i,!0);return}const n=r.exhibitorStore.exhibitors.find(l=>l.slug?.toLowerCase()===o||l.externalId?.toLowerCase()===o);if(n){setTimeout(()=>r.clickExhibitor(n),250);return}const h=r.categoryStore.categories.find(l=>l.slug===t);if(h){r.selectCategory(h);return}const u=r.speakerStore.findBySlug(t);if(u){r.selectSpeaker(u,!0);return}t.includes("heatmap=true")||r.searchStore.selectSearch(t)}showList(e){const t={bookmarks:()=>r.selectBookmarks(),visited:()=>r.selectVisited(),sessions:()=>r.selectSessions(),exhibitors:()=>r.selectExhibitors(),speakers:()=>r.selectSpeakers(),tours:()=>r.selectTours(),language:()=>r.selectLanguage()},o=t[e];if(!o){a("showList",`Unknown list "${e}". Must be one of: ${Object.keys(t).join(", ")}.`,"EFP001800");return}o()}showSessions(e={}){d("showSessions called with filters=%O",e);const t=$.safeParse(e);if(!t.success){a("showSessions",t.error.message,"EFP001C00");return}const o=t.data,{eventStore:s,sessionsFilterStore:i}=r;N(()=>{_.details=null,r.selectSessions(),i.closeFilter(),i.setPending("selectedTracks",T(o.tracks,s.tracks,"track")),i.setPending("selectedVenues",T(o.venues,s.venues,"venue")),i.setPending("date",o.date??"all"),i.setPending("timeOfDay",o.time??"all"),i.setPending("showBookmarksOnly",o.bookmarked??!1),i.setPending("showLiveOnly",o.live??!1),i.commitFilters()})}selectTour(e){if(typeof e!="string"||!e){a("selectTour","A tour id must be passed.","EFP001900");return}const t=r.toursStore.getTourById(e);t?r.toursStore.launchTour(t,t.name,t.description):(console.warn(`Route with id "${e}" not found`),r.selectTours())}openPlanner(e={}){if(typeof e!="object"||e===null){a("openPlanner","An options object must be passed.","EFP001A00");return}const t=e.from?b(e.from):null;e.fromBookmarks?r.routePlannerStore.launchFromBookmarks(t??void 0):r.routePlannerStore.launchFromSlugs(e.items??[],t??void 0)}startBuildRoute(){r.uiState.startBuildRoute()}applyParameters(e){typeof e!="string"&&a("applyParameters","A query string must be passed.","EFP000D00"),Q(e)}getVisibility(){return r.uiState.visibility}setVisibility(e){(typeof e!="object"||!Object.keys(e).length)&&a("setVisibility","The parameter must be passed.","EFP000E00"),r.uiState.setVisibility(e)}findLocation(){r.routeStore.findLocation()}zoomIn(){r.uiState.zoomIn()}zoomOut(){r.uiState.zoomOut()}switchView(){r.maplibreStore.activateMaplibre()}setCamera(e){d("setCamera called with camera=%O",e);const t=R.safeParse(e);if(!t.success){a("setCamera",t.error.message,"EFP001B00");return}r.uiState.setMapSettings(se(t.data))}getCamera(){return ne(r.uiState.mapSettings)}zoomTo(e,t){d("zoomTo called with selectors=%O options=%O",e,t);const o=k.safeParse(e);if(!o.success){a("zoomTo",o.error.message,"EFP001600");return}const s=v.safeParse(t);if(!s.success){a("zoomTo",s.error.message,"EFP001601");return}const i=this.getBounds(e);i&&this.fitBounds(i,t)}getBounds(e){d("getBounds called with selectors=%O",e);const t=k.safeParse(e);if(!t.success){a("getBounds",t.error.message,"EFP001400");return}const o=[];if(e.booths?.forEach(i=>{let n;i.externalId?n=r.boothStore.boothByExternalId.get(i.externalId):i.name&&(n=r.boothStore.boothByName.get(i.name.toLowerCase())),n?.rect&&o.push(n.rect)}),e.exhibitors?.forEach(i=>{let n;i.externalId?n=r.exhibitorStore.exhibitorByExternalId.get(i.externalId):i.name&&(n=r.exhibitorStore.exhibitorByName.get(i.name.toLowerCase())),n?.booths?.forEach(h=>{h.rect&&o.push(h.rect)})}),o.length===0)return;const s=w.fromUnion(...o);return{leftTop:{x:s.min.x,y:s.min.y},rightBottom:{x:s.max.x,y:s.max.y}}}fitBounds(e,t){if(d("fitBounds called with bounds=%O options=%O",e,t),!e){r.uiState.fitBounds();return}const o=X.safeParse(e);if(!o.success){a("fitBounds",o.error.message,"EFP001500");return}const s=v.safeParse(t);if(!s.success){a("fitBounds",s.error.message,"EFP001501");return}const i=w.fromMinMax({x:e.leftTop.x,y:e.leftTop.y},{x:e.rightBottom.x,y:e.rightBottom.y});r.uiState.moveToRect=t?.padding?i.expand(t.padding):i}getBoothRect(e){typeof e!="string"&&a("getBoothRect","A booth name must be passed.","EFP000F00");const t=b(e)?.rect;return t?c.fromBox(t):void 0}convertToGeo(e,t){const o=P()?.properties?.config;if(!o){a("convertToGeo","The coordinates cannot be converted because the GPS configuration is not defined.","EFP001000");return}if(!e||!t){a("convertToGeo","Both coordinates must be passed.","EFP001001");return}return he(e,t,o)}getGeoConfig(){const e=P()?.properties?.config;return e?{bearing:e.bearing??0,p0:e.p0,p1:e.p1,p2:e.p2}:null}releaseResources(){r.maplibreStore.dispose(),this.root?.unmount(),super.releaseResources()}search(e){return typeof e!="string"&&a("search","A search string must be passed.","EFP001100"),r.fuzzySearchEngineStore.loadEngine().then(()=>(r.searchStore.selectSearch(e),r.uiState.fuzzySearchItems.map(t=>({item:p(t.item),score:t.score}))))}getFloors(){return r.layerStore.floors.map(e=>({name:e.name,shortName:e.shortName,description:e.description,active:e.active,disabled:e.disabled,index:e.index}))}activateFloor(e){if(!e?.name&&e?.index==null){a("activateFloor","Invalid floorId. It must contain either a name or an index.","EFP001200");return}const t=this.getFloors();if(e.name){const o=t.find(s=>s.name===e.name||s.shortName===e.name);if(!o){a("activateFloor",`Floor with name "${e.name}" not found.`,"EFP001201");return}if(o.active)return;this.updateLayerVisibility(o.name,!0);return}if(e.index!==null){const o=t.find(i=>i.index===e.index),s=o?.name;if(!s){a("activateFloor",`Floor at index ${e.index} does not exist.`,"EFP001203");return}if(o.active)return;this.updateLayerVisibility(s,!0);return}}showPathway(e,t){const{boothExternalIds:o,exhibitorExternalIds:s}=t?.length?F(t):{boothExternalIds:[],exhibitorExternalIds:[]};Z({pathwayId:e,boothIds:o,exhibitorIds:s})}showPathwayOnly(e,t){this.activateFloor({name:t}),r.layerStore.showPathWay(e),r.uiState.setPathwayOnlyMode(!0);const o=r.layerStore.findLayer(e),s=r.layerStore.findLayer(t),i=o?.rect||o?.viewbox?o:s,n=i?.viewbox??i?.rect;n&&(r.uiState.moveToRect=n.clone())}hidePathways(){this.highlightBooths([]),r.layerStore.hidePathways(),r.uiState.setPathwayOnlyMode(!1)}showSearch(){r.selectSearch("")}changeLanguage(e){const t=e?.toLowerCase?.();if(!ce(t)){a("changeLanguage",`Language "${e}" was not found. Available languages: ${le().map(o=>o.id).join(",")}`,"EFP001300");return}ue(t)}isGpsTrackingEnabled(){return r.routeStore.gpsEnabled}setGpsTrackingEnabled(e){r.routeStore.setGpsTrackingEnabled(e)}deselectCurrentPosition(){r.routeStore.selectCurrentPosition(null,!1)}deselectRoute(){r.routeStore.selectRoute(null),r.routeStore.setOnlyAccessible(!1)}reset(){this.selectBooth(""),this.selectExhibitor(""),this.selectCategory(),this.deselectCurrentPosition(),this.deselectRoute(),this.highlightEntities([]),r.uiState.kioskData&&r.resetCameraFn?r.resetCameraFn?.():this.fitBounds()}selectAccessibleRoute(e){r.routeStore.setOnlyAccessible(!0),this.selectRoute(e)}}function T(f=[],e,t){const o=new Set;for(const s of f){const i=s.toLowerCase(),n=e.find(h=>String(h.id)===s)??e.find(h=>h.externalId?.toLowerCase()===i)??e.find(h=>h.name?.toLowerCase()===i||h.slug?.toLowerCase()===i);n?o.add(n.id):console.warn(`Entity not found: ${t} with query "${s}"`)}return[...o]}function m(f){return(typeof f=="string"?b(f):r.routeStore.getNearestBooth(f))??null}let E=0;function a(f,e,t){const o=`Error calling "${f}" SDK method.`,s=`${e.endsWith(".")?e:e+"."} More information at`;let i="https://js-sdk.expofp.com/api/packages";if(t&&(i+=`#error-${t}`),console.error(`${o} ${s} ${i}`),r.fp.disableRuntimeAlerts)return;r.uiState.setGlobalErrorMessage({title:o,body:M(I,{children:[s," ",x("a",{href:i,target:"_blank",rel:"noreferrer",children:i})]})}),clearTimeout(E);const n=8e3;E=window.setTimeout(()=>{const h=async()=>{r.uiState.globalErrorMessages.length>0&&(r.uiState.popGlobalErrorMessage(),await new Promise(u=>setTimeout(u,n/2)),h())};h()},n)}class c{get h(){return Math.abs(this.y2-this.y1)}get w(){return Math.abs(this.x2-this.x1)}get cx(){return(this.x1+this.x2)/2}get cy(){return(this.y1+this.y2)/2}constructor(e,t,o,s){if(e>o){const i=e;e=o,o=i}if(t>s){const i=t;t=s,s=i}this.x1=e,this.y1=t,this.x2=o,this.y2=s}static fromBox(e){return new c(e.min.x,e.min.y,e.max.x,e.max.y)}static fromCxcywh(e,t,o,s){return new c(e-o/2,t-s/2,e+o/2,t+s/2)}contains(e){return e.x1>=this.x1&&e.x2<=this.x2&&e.y1>=this.y1&&e.y2<=this.y2}intersects(e){const t=Math.max(this.x1,e.x1),o=Math.min(this.x2,e.x2),s=Math.max(this.y1,e.y1),i=Math.min(this.y2,e.y2);return o>=t&&i>=s}getIntersection(e){const t=Math.max(this.x1,e.x1),o=Math.min(this.x2,e.x2),s=Math.max(this.y1,e.y1),i=Math.min(this.y2,e.y2);return o>=t&&i>=s?new c(t,s,o,i):new c(0,0,0,0)}getRotated90(){return c.fromCxcywh(this.cx,this.cy,this.h,this.w)}normalize(e,t){return new c(this.x1/e,this.y1/t,this.x2/e,this.y2/t)}withPadding(e,t=e){return this.w<e*2||this.h<t*2?this:c.fromCxcywh(this.cx,this.cy,this.w-e*2,this.h-t*2)}scale(e){return new c(this.x1*e,this.y1*e,this.x2*e,this.y2*e)}getArea(){return this.w*this.h}clone(){return new c(this.x1,this.y1,this.x2,this.y2)}translate(e,t){return this.x1+=e,this.x2+=e,this.y1+=t,this.y2+=t,this}equals(e){return e.x1===this.x1&&e.x2===this.x2&&e.y1===this.y1&&e.y2===this.y2}toString(){return this.x1+","+this.y1+","+this.w+","+this.h}containsPoint(e,t){return e>=this.x1&&e<=this.x2&&t>=this.y1&&t<=this.y2}}
|
|
1
|
+
import{Fragment as I,jsx as x,jsxs as M}from"react/jsx-runtime";import{Box as w}from"@expofp/geometry";import{CameraSchema as R,SessionsFiltersSchema as $}from"@expofp/schema";import{optimizeWaypointOrder as V}from"@expofp/wayfinding";import{ErrorBoundary as z}from"@sentry/react";import j from"debug";import{reaction as G,runInAction as N}from"mobx";import{createRoot as O}from"react-dom/client";import{install as q}from"resize-observer";import D from"./components/Layout";import{bindBoothHitTest as Y}from"./components/Map/booth-by-xy.js";import{MAX_ROUTE_WAYPOINTS as y}from"./constants";import H from"./data";import{getFpGeo as P}from"./data/fpGeo.js";import U from"./floorplan.loader";import{shouldLoadIntercom as W}from"./intercom";import{registerPlanDisposer as S}from"./plan-lifecycle.js";import{BoundsSchema as X,POISelectorsSchema as v,ZoomToOptionsSchema as k}from"./schemas/sdk.schemas";import{applyDeclarativeConfig as K,applyParameters as Q,applyPathway as Z,initUrlRouting as J}from"./services/url-dispatch";import r,{uiState as _}from"./store";import{bindDetailsEvents as ee}from"./store/details-events";import{bindRootElement as te}from"./store/init/init-ui.js";import{findBooth as b,Route as B,separateExternalIds as F}from"./store/RouteStore";import{GaEventActions as C,initGtag as re,sendEventToGa as L,setConsentSettings as oe}from"./tools/gtag.js";import ie from"./tools/track-event.js";import{cameraToMapSettings as se,mapSettingsToCamera as ne}from"./utils/camera-map-settings";import{getStorage as A}from"./utils/entity-storage";import{getMostFrequent as ae}from"./utils/getMostFrequent";import{convertLocalToGps as he,isCoordinate as g}from"./utils/gps";import{getLocales as le,hasLocale as ce,setLocale as ue}from"./utils/i18n";import{mapEntity as p}from"./utils/mapEntity";const d=j("efp:api");q();export default class fe extends U{init(){re(),K(),this.ignoreQuery||J(this.offHistory),ie("load"),te(r),r.fp=this,S(ee()),Y(),oe(this.consent),L(C.Load,""),this.root=O(this.renderTarget),this.root.render(x(z,{children:x(D,{offHistory:this.offHistory,consent:this.consent})})),L(C.Rendered,""),S(G(()=>r.layerStore.layersLoaded,()=>{const t=this.renderTarget.getRootNode(),o=t instanceof ShadowRoot?t.host:this.renderTarget.parentElement;for(document.querySelectorAll(".expofp-floorplan-loader").forEach(s=>s.remove());o&&this.element.firstChild&&this.element.firstChild!==o;)this.element.removeChild(this.element.firstChild);this.resolveReady(),r.initialized||this.onInit?.(this),r.initialized=!0})),S(()=>clearTimeout(E));const e=W(H);e&&import("./intercom/bootIntercom").then(({bootIntercom:t})=>t(e)).catch(()=>{})}selectBooth(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectBooth","Parameter must be a string or an array of strings.","EFP000000");return}const t=r.boothStore.booths.filter(o=>typeof e=="string"?o.name===e||o.externalId===e:e.includes(o.name)||e.includes(o.externalId));r.selectBooth(t)}selectExhibitor(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectExhibitor","Parameter must be a string or an array of strings.","EFP000100");return}if(!e?.length){r.uiState.menu=!1,r.searchStore.resetSearchBox(),r.uiState.details=null;return}const t=r.exhibitorStore.exhibitors.filter(i=>typeof e=="string"?i.name===e||i.externalId===e:e.includes(i.name)||e.includes(i.externalId));if(!t?.length)return;if(typeof e=="string"){r.selectExhibitor(t[0]),r.moveToList([t[0]]);return}const o=t.flatMap(i=>i.booths.map(n=>n.layer)),s=ae(o.map(i=>i.description));s&&r.layerStore.updateVisibility(s,!0),r.uiState.menu=!1,r.searchStore.resetSearchBox(),r.uiState.details=null,r.uiState.list={type:"filter",items:t,query:{key:"exhibitors",value:t.map(i=>i.name).join(",")}},r.moveToList()}highlightExhibitors(e){if(!Array.isArray(e)){a("highlightExhibitors","Parameter must be an array of strings.","EFP000200");return}r.boothStore.highlightedByExternalIds=[],r.exhibitorStore.highlightedByExternalIds=[...e]}highlightBooths(e){if(!Array.isArray(e)){a("highlightBooths","Parameter must be an array of strings.","EFP000300");return}r.exhibitorStore.highlightedByExternalIds=[],r.boothStore.highlightedByExternalIds=[...e]}highlightEntities(e){if(!Array.isArray(e)){a("highlightEntities","Parameter must be an array of strings.","EFP000400");return}const{boothExternalIds:t,exhibitorExternalIds:o}=F(e);r.boothStore.highlightedByExternalIds=[...t],r.exhibitorStore.highlightedByExternalIds=[...o]}selectRoute(e,t){if(Array.isArray(e)){const o=[...e],s=o.shift(),i=o.pop();if(o.length>y)throw new Error(`The maximum number of waypoints is ${y}.`);if(!s||!i){a("selectRoute","Invalid route format: When providing an array, it must include at least two points: a start and a destination.","EFP000401");return}const n=o.map(m).filter(h=>h!==null);r.routeStore.selectRoute(new B(m(s),m(i),n));return}e||a("selectRoute","At a minimum, the starting point must be passed.","EFP000402"),r.routeStore.selectRoute(new B(m(e),t?m(t):null))}getOptimizedRoutes(e){if(!Array.isArray(e))return a("getOptimizedRoutes","Parameter must be an array.","EFP000500"),[];if(e.length>y)throw new Error(`The maximum number of waypoints is ${y}.`);const t=e.map(m).filter(s=>!!s);if(!t.length)throw new Error("No booths found for the provided waypoints.");const o=new Map;for(const s of t){const i=s.layer?.name??"",n=o.get(i);n?n.push(s):o.set(i,[s])}return Array.from(o.values()).map(s=>({waypoints:V(s.map(i=>[i.name,{x:i.rect.center.x,y:i.rect.center.y}]))}))}selectCurrentPosition(e,t,o){const s=g(e.x)&&g(e.y),i=g(e.lng)&&g(e.lat);if(!s&&!i){a("selectCurrentPosition","A point must be passed. Either (x,y) or (lat,lng) are required.","EFP000600");return}r.routeStore.selectCurrentPosition(e,t,o),this.onCurrentPositionChanged?.(e)}setBookmarks(e){if(!Array.isArray(e)||!e.length){a("setBookmarks","Parameter must be an array.","EFP000700");return}e.forEach(t=>{const o=r.exhibitorStore.exhibitors.find(s=>s.name===t.name||s.externalId===t.externalId);o&&(o.bookmarked=t.bookmarked)})}setEntitiesBookmarks(e){if(!Array.isArray(e)||!e.length){a("setEntitiesBookmarks","Parameter must be an array.","EFP000701");return}const t=["exhibitor","event","speaker","booth"],o=e.find(n=>!n.type||!t.includes(n.type));if(o){a("setEntitiesBookmarks",`Invalid entity type: ${o.type}. Must be one of: ${t.join(", ")}.`,"EFP000702");return}const s=A("bookmarked"),i={exhibitor:{existingIds:new Set(s.exhibitors||[]),finder:n=>r.exhibitorStore.findExhibitor(n),replacer:n=>r.exhibitorStore.replaceBookmarked(n)},event:{existingIds:new Set(s.events||[]),finder:n=>r.eventStore.findByNameOrSlug(n),replacer:n=>r.eventStore.replaceBookmarked(n)},speaker:{existingIds:new Set(s.speakers||[]),finder:n=>r.speakerStore.speakers.find(h=>h.name===n||h.externalId===n||h.slug===n),replacer:n=>r.speakerStore.replaceBookmarked(n)},booth:{existingIds:new Set(s.booths||[]),finder:n=>{const h=r.boothStore.findBooth(n);return h?.exhibitors.length===0?h:void 0},replacer:n=>r.boothStore.replaceBookmarked(n)}};e.forEach(n=>{const h=i[n.type],u=n.name||n.externalId||"",l=h.finder(u);l?n.bookmarked?h.existingIds.add(l.id):h.existingIds.delete(l.id):console.warn(`Entity not found: ${n.type} with query "${u}"`)}),Object.values(i).forEach(n=>{n.replacer(Array.from(n.existingIds))})}setEntitiesVisited(e){if(!Array.isArray(e)||!e.length){a("setEntitiesVisited","Parameter must be an array.","EFP000703");return}const t=["exhibitor","event"],o=e.find(n=>!n.type||!t.includes(n.type));if(o){a("setEntitiesVisited",`Invalid entity type: ${o.type}. Must be one of: ${t.join(", ")}.`,"EFP000704");return}const s=A("visited"),i={exhibitor:{existingIds:new Set(s.exhibitors||[]),finder:n=>r.exhibitorStore.findExhibitor(n),replacer:n=>r.exhibitorStore.replaceVisited(n)},event:{existingIds:new Set(s.events||[]),finder:n=>r.eventStore.findByNameOrSlug(n),replacer:n=>r.eventStore.replaceVisited(n)}};e.forEach(n=>{const h=i[n.type],u=n.name||n.externalId||"",l=h.finder(u);l?n.visited?h.existingIds.add(l.id):h.existingIds.delete(l.id):console.warn(`Entity not found: ${n.type} with query "${u}"`)}),Object.values(i).forEach(n=>{n.replacer(Array.from(n.existingIds))})}setMarkers(e){if(!e||!Array.isArray(e.icons)||!Array.isArray(e.markers)){a("setMarkers","Invalid input.","EFP000800");return}r.routeStore.setMarkers(e)}selectMarker(e,t=!0){return typeof e!="string"&&a("selectMarker","The identifier must be passed.","EFP000900"),r.routeStore.selectMarker(e,t)}drawCircles(e){if(!Array.isArray(e)){a("drawCircles","Invalid input.","EFP000A00");return}r.uiState.debugCircles=e}checkRoutes(){r.routeStore.checkRoutes()}updateLayerVisibility(e,t){typeof e!="string"&&a("updateLayerVisibility","The layer name (string) must be passed.","EFP000B00"),t||a("updateLayerVisibility","Passing a false value to visible will have no effect.","EFP000B01"),r.layerStore.updateVisibility(e,t)}getCenterCoordinates(){return r.fp.getCenterCoordinates()}exhibitorsList(){return r.exhibitorStore.exhibitors.map(e=>p(e))}boothsList(){return r.boothStore.booths.map(e=>p(e))}categoriesList(){return r.categoryStore.categories.map(e=>p(e))}selectCategory(e){if(e==null||typeof e!="string"){r.searchStore.selectSearch();return}const t=e?.toLowerCase(),o=r.categoryStore.categories.find(({name:s,slug:i})=>s?.toLowerCase()===t||i?.toLowerCase()===t);if(!o){a("selectCategory",`Category ${e} not found.`,"EFP000C01");return}r.selectCategory(o)}select(e){if(typeof e!="string"){a("select","Parameter must be a string.","EFP001700");return}const t=e,o=t?.toLowerCase(),s=r.boothStore.booths.find(l=>l.slug?.toLowerCase()===o||l.externalId?.toLowerCase()===o||l.externalId?.toLowerCase()?.replace(/\s+/g,"")===o);if(s){setTimeout(()=>r.selectBooth(s),250);return}const i=r.eventStore.eventItems.find(l=>l.slug?.toLowerCase()===o||l.externalId?.toLowerCase()===o);if(i){r.selectEventItem(i,!0);return}const n=r.exhibitorStore.exhibitors.find(l=>l.slug?.toLowerCase()===o||l.externalId?.toLowerCase()===o);if(n){setTimeout(()=>r.clickExhibitor(n),250);return}const h=r.categoryStore.categories.find(l=>l.slug===t);if(h){r.selectCategory(h);return}const u=r.speakerStore.findBySlug(t);if(u){r.selectSpeaker(u,!0);return}t.includes("heatmap=true")||r.searchStore.selectSearch(t)}showList(e){const t={bookmarks:()=>r.selectBookmarks(),visited:()=>r.selectVisited(),sessions:()=>r.selectSessions(),exhibitors:()=>r.selectExhibitors(),speakers:()=>r.selectSpeakers(),tours:()=>r.selectTours(),language:()=>r.selectLanguage()},o=t[e];if(!o){a("showList",`Unknown list "${e}". Must be one of: ${Object.keys(t).join(", ")}.`,"EFP001800");return}o()}showSessions(e={}){d("showSessions called with filters=%O",e);const t=$.safeParse(e);if(!t.success){a("showSessions",t.error.message,"EFP001C00");return}const o=t.data,{eventStore:s,sessionsFilterStore:i}=r;N(()=>{_.details=null,r.selectSessions(),i.closeFilter(),i.setPending("selectedTracks",T(o.tracks,s.tracks,"track")),i.setPending("selectedVenues",T(o.venues,s.venues,"venue")),i.setPending("date",o.date??"all"),i.setPending("timeOfDay",o.time??"all"),i.setPending("showBookmarksOnly",o.bookmarked??!1),i.setPending("showLiveOnly",o.live??!1),i.commitFilters()})}selectTour(e){if(typeof e!="string"||!e){a("selectTour","A tour id must be passed.","EFP001900");return}const t=r.toursStore.getTourById(e);t?r.toursStore.launchTour(t,t.name,t.description):(console.warn(`Route with id "${e}" not found`),r.selectTours())}openPlanner(e={}){if(typeof e!="object"||e===null){a("openPlanner","An options object must be passed.","EFP001A00");return}const t=e.from?b(e.from):null;e.fromBookmarks?r.routePlannerStore.launchFromBookmarks(t??void 0):r.routePlannerStore.launchFromSlugs(e.items??[],t??void 0)}startBuildRoute(){r.uiState.startBuildRoute()}applyParameters(e){typeof e!="string"&&a("applyParameters","A query string must be passed.","EFP000D00"),Q(e)}getVisibility(){return r.uiState.visibility}setVisibility(e){(typeof e!="object"||!Object.keys(e).length)&&a("setVisibility","The parameter must be passed.","EFP000E00"),r.uiState.setVisibility(e)}findLocation(){r.routeStore.findLocation()}zoomIn(){r.uiState.zoomIn()}zoomOut(){r.uiState.zoomOut()}switchView(){r.maplibreStore.activateMaplibre()}setCamera(e){d("setCamera called with camera=%O",e);const t=R.safeParse(e);if(!t.success){a("setCamera",t.error.message,"EFP001B00");return}r.uiState.setMapSettings(se(t.data))}getCamera(){return ne(r.uiState.mapSettings)}zoomTo(e,t){d("zoomTo called with selectors=%O options=%O",e,t);const o=v.safeParse(e);if(!o.success){a("zoomTo",o.error.message,"EFP001600");return}const s=k.safeParse(t);if(!s.success){a("zoomTo",s.error.message,"EFP001601");return}const i=this.getBounds(e);i&&this.fitBounds(i,t)}getBounds(e){d("getBounds called with selectors=%O",e);const t=v.safeParse(e);if(!t.success){a("getBounds",t.error.message,"EFP001400");return}const o=[];if(e.booths?.forEach(i=>{let n;i.externalId?n=r.boothStore.boothByExternalId.get(i.externalId):i.name&&(n=r.boothStore.boothByName.get(i.name.toLowerCase())),n?.rect&&o.push(n.rect)}),e.exhibitors?.forEach(i=>{let n;i.externalId?n=r.exhibitorStore.exhibitorByExternalId.get(i.externalId):i.name&&(n=r.exhibitorStore.exhibitorByName.get(i.name.toLowerCase())),n?.booths?.forEach(h=>{h.rect&&o.push(h.rect)})}),o.length===0)return;const s=w.fromUnion(...o);return{leftTop:{x:s.min.x,y:s.min.y},rightBottom:{x:s.max.x,y:s.max.y}}}fitBounds(e,t){if(d("fitBounds called with bounds=%O options=%O",e,t),!e){r.uiState.fitBounds();return}const o=X.safeParse(e);if(!o.success){a("fitBounds",o.error.message,"EFP001500");return}const s=k.safeParse(t);if(!s.success){a("fitBounds",s.error.message,"EFP001501");return}const i=w.fromMinMax({x:e.leftTop.x,y:e.leftTop.y},{x:e.rightBottom.x,y:e.rightBottom.y});r.uiState.moveToRect=t?.padding?i.expand(t.padding):i}getBoothRect(e){if(typeof e!="string"){a("getBoothRect","A booth name must be passed.","EFP000F00");return}const t=b(e)?.rect;return t?c.fromBox(t):void 0}convertToGeo(e,t){const o=P()?.properties?.config;if(!o){a("convertToGeo","The coordinates cannot be converted because the GPS configuration is not defined.","EFP001000");return}if(!e||!t){a("convertToGeo","Both coordinates must be passed.","EFP001001");return}return he(e,t,o)}getGeoConfig(){const e=P()?.properties?.config;return e?{bearing:e.bearing??0,p0:e.p0,p1:e.p1,p2:e.p2}:null}releaseResources(){r.maplibreStore.dispose(),this.root?.unmount(),super.releaseResources()}search(e){return typeof e!="string"?(a("search","A search string must be passed.","EFP001100"),Promise.resolve([])):r.fuzzySearchEngineStore.loadEngine().then(()=>(r.searchStore.selectSearch(e),r.uiState.fuzzySearchItems.map(t=>({item:p(t.item),score:t.score}))))}getFloors(){return r.layerStore.floors.map(e=>({name:e.name,shortName:e.shortName,description:e.description,active:e.active,disabled:e.disabled,index:e.index}))}activateFloor(e){if(!e?.name&&e?.index==null){a("activateFloor","Invalid floorId. It must contain either a name or an index.","EFP001200");return}const t=this.getFloors();if(e.name){const o=t.find(s=>s.name===e.name||s.shortName===e.name);if(!o){a("activateFloor",`Floor with name "${e.name}" not found.`,"EFP001201");return}if(o.active)return;this.updateLayerVisibility(o.name,!0);return}if(e.index!==null){const o=t.find(i=>i.index===e.index),s=o?.name;if(!s){a("activateFloor",`Floor at index ${e.index} does not exist.`,"EFP001203");return}if(o.active)return;this.updateLayerVisibility(s,!0);return}}showPathway(e,t){const{boothExternalIds:o,exhibitorExternalIds:s}=t?.length?F(t):{boothExternalIds:[],exhibitorExternalIds:[]};Z({pathwayId:e,boothIds:o,exhibitorIds:s})}showPathwayOnly(e,t){this.activateFloor({name:t}),r.layerStore.showPathWay(e),r.uiState.setPathwayOnlyMode(!0);const o=r.layerStore.findLayer(e),s=r.layerStore.findLayer(t),i=o?.rect||o?.viewbox?o:s,n=i?.viewbox??i?.rect;n&&(r.uiState.moveToRect=n.clone())}hidePathways(){this.highlightBooths([]),r.layerStore.hidePathways(),r.uiState.setPathwayOnlyMode(!1)}showSearch(){r.selectSearch("")}changeLanguage(e){const t=e?.toLowerCase?.();if(!ce(t)){a("changeLanguage",`Language "${e}" was not found. Available languages: ${le().map(o=>o.id).join(",")}`,"EFP001300");return}ue(t)}isGpsTrackingEnabled(){return r.routeStore.gpsEnabled}setGpsTrackingEnabled(e){r.routeStore.setGpsTrackingEnabled(e)}deselectCurrentPosition(){r.routeStore.selectCurrentPosition(null,!1)}deselectRoute(){r.routeStore.selectRoute(null),r.routeStore.setOnlyAccessible(!1)}reset(){this.selectBooth(""),this.selectExhibitor(""),this.selectCategory(),this.deselectCurrentPosition(),this.deselectRoute(),this.highlightEntities([]),r.uiState.kioskData&&r.resetCameraFn?r.resetCameraFn?.():this.fitBounds()}selectAccessibleRoute(e){r.routeStore.setOnlyAccessible(!0),this.selectRoute(e)}}function T(f=[],e,t){const o=new Set;for(const s of f){const i=s.toLowerCase(),n=e.find(h=>String(h.id)===s)??e.find(h=>h.externalId?.toLowerCase()===i)??e.find(h=>h.name?.toLowerCase()===i||h.slug?.toLowerCase()===i);n?o.add(n.id):console.warn(`Entity not found: ${t} with query "${s}"`)}return[...o]}function m(f){return(typeof f=="string"?b(f):r.routeStore.getNearestBooth(f))??null}let E=0;function a(f,e,t){const o=`Error calling "${f}" SDK method.`,s=`${e.endsWith(".")?e:e+"."} More information at`;let i="https://js-sdk.expofp.com/api/packages";if(t&&(i+=`#error-${t}`),console.error(`${o} ${s} ${i}`),r.fp.disableRuntimeAlerts)return;r.uiState.setGlobalErrorMessage({title:o,body:M(I,{children:[s," ",x("a",{href:i,target:"_blank",rel:"noreferrer",children:i})]})}),clearTimeout(E);const n=8e3;E=window.setTimeout(()=>{const h=async()=>{r.uiState.globalErrorMessages.length>0&&(r.uiState.popGlobalErrorMessage(),await new Promise(u=>setTimeout(u,n/2)),h())};h()},n)}class c{get h(){return Math.abs(this.y2-this.y1)}get w(){return Math.abs(this.x2-this.x1)}get cx(){return(this.x1+this.x2)/2}get cy(){return(this.y1+this.y2)/2}constructor(e,t,o,s){if(e>o){const i=e;e=o,o=i}if(t>s){const i=t;t=s,s=i}this.x1=e,this.y1=t,this.x2=o,this.y2=s}static fromBox(e){return new c(e.min.x,e.min.y,e.max.x,e.max.y)}static fromCxcywh(e,t,o,s){return new c(e-o/2,t-s/2,e+o/2,t+s/2)}contains(e){return e.x1>=this.x1&&e.x2<=this.x2&&e.y1>=this.y1&&e.y2<=this.y2}intersects(e){const t=Math.max(this.x1,e.x1),o=Math.min(this.x2,e.x2),s=Math.max(this.y1,e.y1),i=Math.min(this.y2,e.y2);return o>=t&&i>=s}getIntersection(e){const t=Math.max(this.x1,e.x1),o=Math.min(this.x2,e.x2),s=Math.max(this.y1,e.y1),i=Math.min(this.y2,e.y2);return o>=t&&i>=s?new c(t,s,o,i):new c(0,0,0,0)}getRotated90(){return c.fromCxcywh(this.cx,this.cy,this.h,this.w)}normalize(e,t){return new c(this.x1/e,this.y1/t,this.x2/e,this.y2/t)}withPadding(e,t=e){return this.w<e*2||this.h<t*2?this:c.fromCxcywh(this.cx,this.cy,this.w-e*2,this.h-t*2)}scale(e){return new c(this.x1*e,this.y1*e,this.x2*e,this.y2*e)}getArea(){return this.w*this.h}clone(){return new c(this.x1,this.y1,this.x2,this.y2)}translate(e,t){return this.x1+=e,this.x2+=e,this.y1+=t,this.y2+=t,this}equals(e){return e.x1===this.x1&&e.x2===this.x2&&e.y1===this.y1&&e.y2===this.y2}toString(){return this.x1+","+this.y1+","+this.w+","+this.h}containsPoint(e,t){return e>=this.x1&&e<=this.x2&&t>=this.y1&&t<=this.y2}}
|
|
@@ -24,6 +24,14 @@ export declare class URLFilterManager {
|
|
|
24
24
|
*/
|
|
25
25
|
filterSearch(): string;
|
|
26
26
|
updateURLFromFilters(): void;
|
|
27
|
+
/**
|
|
28
|
+
* The custom search button that owns the current selection, or `null` for the
|
|
29
|
+
* built-in one. Read by both writers, so `currentFilters` — what
|
|
30
|
+
* `getCurrentFilters()` hands out — can never name an owner the address bar
|
|
31
|
+
* omits: an owner without a selection is not an owner, the same invariant
|
|
32
|
+
* `CategoryFilterStore.clearSelection()` keeps on the store side.
|
|
33
|
+
*/
|
|
34
|
+
private owningSearchButtonId;
|
|
27
35
|
setCategories(categoryNames: string[]): void;
|
|
28
36
|
setPoiType(poiTypeName: string | null): void;
|
|
29
37
|
setPoiTypes(poiTypeNames: string[]): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as
|
|
1
|
+
import{__decorate as p}from"tslib";import{getConfig as m,toQueryString as S}from"@expofp/config";import{action as c,observable as d}from"mobx";import{PREFIXES as P}from"../store/search-buttons/constants";import{getButtonConfig as I,getScopeCategoryIds as C}from"../store/search-buttons/utils";import l from"../tools/logger";import{planReaction as g}from"../utils/plan-reactions.js";import{decodeString as L,decodeStringArray as F,encodeString as w,encodeStringArray as T,toLowerCaseArray as y,toLowerCaseString as f}from"../utils/urlEncoding";import{replaceQuery as R}from"./url-sync";const h={CATEGORIES:"categories",POI_TYPE:"poiType",POI_TYPES:"poiTypes",EXHIBITORS:"exhibitors"};export class URLFilterManager{constructor(e){this.rootStore=e,this.currentFilters={categories:[],poiType:null,poiTypes:[],exhibitors:!1,searchButton:null},this.isInitialized=!1,this.setupReactions()}initialize(){this.parseURLFilters(),this.applyFiltersToStore(),this.isInitialized=!0,l.log("URLFilterManager initialized with filters:",this.currentFilters)}parseURLFilters(){const{categories:e,poiType:t,poiTypes:s,exhibitors:r,searchButton:i}=this.readRawFilters(),o=s.filter(n=>{if(!n)return!1;const a=this.rootStore.poiTypeStore.poiTypes.some(u=>u.name.toLowerCase()===n.toLowerCase());return a||l.warn(`POI type not found in data: ${n}`),a});e.length>0&&(t||o.length>0)?(l.warn("URL contains both categories and POI types. Clearing POI types."),this.currentFilters={categories:e,poiType:null,poiTypes:[],exhibitors:r,searchButton:i}):this.currentFilters={categories:e,poiType:t,poiTypes:o,exhibitors:r,searchButton:i},l.log("URLFilterManager parsed filters:",{categories:e,poiType:t,poiTypes:s,exhibitors:r}),this.validateFilters(this.currentFilters)}readRawFilters(){const e=m().filters;if(Object.keys(e).length>0)return{categories:[...e.categories??[]],poiType:e.poiType??null,poiTypes:[...e.poiTypes??[]],exhibitors:e.exhibitors??!1,searchButton:e.searchButton??null};const t=new URLSearchParams(window.location.search),s=t.get(h.CATEGORIES),r=s?F(s):[],i=t.get(h.POI_TYPE),o=i?L(i):null,n=t.get(h.POI_TYPES),a=n?F(n):[],u=t.get(h.EXHIBITORS);return{categories:r,poiType:o,poiTypes:a,exhibitors:u==="true"||u==="",searchButton:null}}applyFiltersToStore(){const{uiState:e,categoryFilterStore:t,searchButtonsStore:s}=this.rootStore,r=this.currentFilters.searchButton;if(r){const i=I(r),o=i?C(i):[];i?.type==="categories"&&o.length>0?(this.currentFilters.categories=this.currentFilters.categories.filter(n=>o.includes(this.getCategoryIdByName(n)??-1)),t.setOwner(r)):(l.warn(`URLFilterManager: unknown categories search button: ${r}`),this.currentFilters.searchButton=null)}if(this.currentFilters.categories.length>0){const i=this.currentFilters.categories.map(o=>this.rootStore.categoryStore.categories.find(n=>n.name.toLowerCase()===o.toLowerCase())).filter(o=>o!==void 0);i.length>0?(e.selectedCategoryFilters=i,t.state.selectedItems=i.map(o=>({id:o.id,name:o.name})),e.categoryFilterOpen=!0,l.log("URLFilterManager applied categories:",i.map(o=>o.name)),setTimeout(()=>{this.focusOnFilteredBooths(),this.rootStore.searchStore.setFocused(!0)},100)):l.warn("URLFilterManager: no categories found for names:",this.currentFilters.categories)}if(this.currentFilters.poiType){const i=this.rootStore.poiTypeStore.poiTypes.find(o=>o.name.toLowerCase()===this.currentFilters.poiType.toLowerCase());i?(e.selectedPoiTypeFilters=[i],s.setPoiFilterId(`${P.POI_TYPE}${i.id}`),l.log("URLFilterManager applied POI type:",i.name),setTimeout(()=>{this.focusOnFilteredBooths(),this.rootStore.searchStore.setFocused(!0)},100)):l.warn("URLFilterManager: no POI type found for name:",this.currentFilters.poiType)}if(this.currentFilters.poiTypes.length>0){const i=this.currentFilters.poiTypes.map(o=>o?this.rootStore.poiTypeStore.poiTypes.find(n=>n.name.toLowerCase()===o.toLowerCase()):null).filter(o=>o!=null);i.length>0?(e.selectedPoiTypeFilters=i,l.log("URLFilterManager applied POI types:",i.map(o=>o.name)),setTimeout(()=>{this.focusOnFilteredBooths(),this.rootStore.searchStore.setFocused(!0)},100)):(l.warn("URLFilterManager: no POI types found for names:",this.currentFilters.poiTypes),this.currentFilters.poiTypes=[])}this.currentFilters.exhibitors&&this.openExhibitorsList()}filterSearch(){const{uiState:e}=this.rootStore,t=this.owningSearchButtonId();if(t)return`?${S({filters:{searchButton:t,categories:e.selectedCategoryFilters.map(r=>r.name.toLowerCase())}})}`;const s=new URLSearchParams;if(e.selectedCategoryFilters.length>0){const r=e.selectedCategoryFilters.map(o=>o.name.toLowerCase()),i=T(r);i&&s.set(h.CATEGORIES,i)}if(e.selectedPoiTypeFilters.length>0&&e.selectedCategoryFilters.length===0)if(e.selectedPoiTypeFilters.length===1){const r=e.selectedPoiTypeFilters[0].name.toLowerCase();if(r){const i=w(r);i&&s.set(h.POI_TYPE,i)}}else{const r=e.selectedPoiTypeFilters.map(o=>o.name.toLowerCase()),i=T(r);i&&s.set(h.POI_TYPES,i)}return this.currentFilters.exhibitors&&e.selectedCategoryFilters.length===0&&e.selectedPoiTypeFilters.length===0&&s.set(h.EXHIBITORS,"true"),s.toString()?`?${s.toString()}`:""}updateURLFromFilters(){const{uiState:e}=this.rootStore;R(this.filterSearch()),this.currentFilters={categories:e.selectedCategoryFilters.length>0?e.selectedCategoryFilters.map(t=>t.name):[],poiType:e.selectedPoiTypeFilters.length===1&&e.selectedCategoryFilters.length===0?e.selectedPoiTypeFilters[0].name:null,poiTypes:e.selectedPoiTypeFilters.length>1&&e.selectedCategoryFilters.length===0?e.selectedPoiTypeFilters.map(t=>t.name):[],exhibitors:this.currentFilters.exhibitors,searchButton:this.owningSearchButtonId()}}owningSearchButtonId(){return this.rootStore.uiState.selectedCategoryFilters.length===0?null:this.rootStore.categoryFilterStore.scopeButtonId}setCategories(e){this.currentFilters.categories=y(e),this.currentFilters.poiType=null,this.isInitialized&&this.updateURLFromFilters()}setPoiType(e){this.currentFilters.poiType=f(e),this.currentFilters.poiTypes=[],this.currentFilters.categories=[],this.isInitialized&&this.updateURLFromFilters()}setPoiTypes(e){this.currentFilters.poiTypes=y(e),this.currentFilters.poiType=null,this.currentFilters.categories=[],this.isInitialized&&this.updateURLFromFilters()}clearAllFilters(){this.currentFilters={categories:[],poiType:null,poiTypes:[],exhibitors:!1,searchButton:null};const{uiState:e}=this.rootStore;e.categoryFilterOpen=!1,this.updateURLFromFilters()}getCurrentFilters(){return{...this.currentFilters}}setupReactions(){g(()=>this.rootStore.uiState.selectedCategoryFilters,e=>{if(this.isInitialized&&e.length>0){const t=y(e.map(s=>s.name));this.setCategories(t)}}),g(()=>this.rootStore.uiState.selectedPoiTypeFilters,e=>{if(this.isInitialized&&e.length>0)if(e.length===1){const t=f(e[0].name);t&&this.setPoiType(t)}else{const t=y(e.map(s=>s.name));this.setPoiTypes(t)}})}validateFilters(e){if(e.categories.length>0&&(e.poiType||e.poiTypes.length>0))return l.warn("Categories and POI types cannot be active simultaneously"),!1;if(e.poiType&&e.poiTypes.length>0)return l.warn("Both single POI type and multiple POI types cannot be active simultaneously"),!1;for(const t of e.categories)if(!this.getCategoryIdByName(t))return l.warn(`Category not found: ${t}`),!1;if(e.poiType&&!this.getPoiTypeIdByName(e.poiType))return l.warn(`POI type not found: ${e.poiType}`),!1;for(const t of e.poiTypes)if(!this.getPoiTypeIdByName(t))return l.warn(`POI type not found: ${t}`),!1;return!0}getCategoryIdByName(e){const t=this.rootStore.categoryStore.categories.find(s=>s.name.toLowerCase()===e.toLowerCase());return t?t.id:null}getPoiTypeIdByName(e){const t=this.rootStore.poiTypeStore.poiTypes.find(s=>s.name.toLowerCase()===e.toLowerCase());return t?t.id:null}focusOnFilteredBooths(){if(!this.rootStore.layerStore.layersLoaded){g(()=>this.rootStore.layerStore.layersLoaded,()=>{this.focusOnFilteredBooths()},{fireImmediately:!1});return}const{uiState:e,exhibitorStore:t,boothStore:s}=this.rootStore;let r=[];if(e.selectedCategoryFilters.length>0){const o=t.exhibitors.filter(n=>e.selectedCategoryFilters.some(a=>n.categories.some(u=>u.id===a.id)));r=s.booths.filter(n=>o.some(a=>a.id===n.exhibitors[0]?.id))}if(e.selectedPoiTypeFilters.length>0){const o=s.booths.filter(n=>e.selectedPoiTypeFilters.some(a=>n.poiTypeId===a.id));r.length>0?r=r.filter(n=>o.some(a=>a.id===n.id)):r=o}const i=r.filter(o=>o.visible);i.length>0?(e.moveToBooths=i,this.rootStore.moveToList(i)):r.length>0&&(this.rootStore.showMap(),this.rootStore.moveToList(r))}openExhibitorsList(){const{uiState:e}=this.rootStore;e.list={type:"exhibitors",text:"",focused:!1},setTimeout(()=>{this.rootStore.searchStore.setFocused(!0)},100),l.log("URLFilterManager opened exhibitors list")}}p([d],URLFilterManager.prototype,"currentFilters",void 0),p([d],URLFilterManager.prototype,"isInitialized",void 0),p([c],URLFilterManager.prototype,"initialize",null),p([c],URLFilterManager.prototype,"parseURLFilters",null),p([c],URLFilterManager.prototype,"applyFiltersToStore",null),p([c],URLFilterManager.prototype,"updateURLFromFilters",null),p([c],URLFilterManager.prototype,"setCategories",null),p([c],URLFilterManager.prototype,"setPoiType",null),p([c],URLFilterManager.prototype,"setPoiTypes",null),p([c],URLFilterManager.prototype,"clearAllFilters",null),p([c],URLFilterManager.prototype,"focusOnFilteredBooths",null),p([c],URLFilterManager.prototype,"openExhibitorsList",null);
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
import BaseFilterStore from './BaseFilterStore';
|
|
2
2
|
import { type Exhibitor } from './ExhibitorStore';
|
|
3
3
|
import { type FilterItem } from './types';
|
|
4
|
+
/** What the category modal shows: a custom button's categories, or the whole catalog. */
|
|
5
|
+
export interface CategoryScope {
|
|
6
|
+
/** The button the modal belongs to; `null` is the built-in Categories button. */
|
|
7
|
+
buttonId: string | null;
|
|
8
|
+
/** `null` shows the whole catalog. */
|
|
9
|
+
categoryIds: number[] | null;
|
|
10
|
+
title: string | null;
|
|
11
|
+
}
|
|
4
12
|
export default class CategoryFilterStore extends BaseFilterStore {
|
|
13
|
+
/** The search button that owns the applied selection; `null` is the built-in Categories button. */
|
|
14
|
+
scopeButtonId: string | null;
|
|
15
|
+
/**
|
|
16
|
+
* What the modal shows (or last showed). Opening a modal only sets this; the
|
|
17
|
+
* owner and the selection change on Apply, so a modal closed without applying
|
|
18
|
+
* leaves the applied filter, its highlight and its URL as they were.
|
|
19
|
+
*/
|
|
20
|
+
viewScope: CategoryScope | null;
|
|
5
21
|
get filteredExhibitors(): Exhibitor[];
|
|
6
22
|
get filteredBooths(): import("./BoothStore").Booth[];
|
|
7
|
-
|
|
23
|
+
/** Whether the modal shows the button that owns the applied selection. */
|
|
24
|
+
get viewsOwnSelection(): boolean;
|
|
25
|
+
openFilter(): void;
|
|
26
|
+
openFilterForButton(buttonId: string, categoryIds: number[], title: string): void;
|
|
27
|
+
setOwner(buttonId: string | null): void;
|
|
28
|
+
/** Another button's selection opens unticked: each button picks its own categories. */
|
|
29
|
+
private openScope;
|
|
30
|
+
applyFilter(): void;
|
|
31
|
+
/**
|
|
32
|
+
* Drops the category selection AND its owner, in one place. The two travel
|
|
33
|
+
* together — a scope left behind keeps its custom button highlighted (and its
|
|
34
|
+
* id in the URL) after the selection it describes is gone, and a selection
|
|
35
|
+
* left behind reappears as pre-ticked boxes the next time the modal opens.
|
|
36
|
+
* Every site that clears one clears the other by calling this; held by hand in
|
|
37
|
+
* five places, the invariant had already drifted apart in three of them.
|
|
38
|
+
*/
|
|
39
|
+
clearSelection(): void;
|
|
8
40
|
updateUIState(): void;
|
|
9
41
|
getFilteredItems(): FilterItem[];
|
|
10
42
|
getMatchingExhibitorsCount(): number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__decorate as
|
|
1
|
+
import{__decorate as o}from"tslib";import{action as s,computed as l,observable as n}from"mobx";import h from"./BaseFilterStore";const a={buttonId:null,categoryIds:null,title:null};export default class e extends h{constructor(){super(...arguments),this.scopeButtonId=null,this.viewScope=null}get filteredExhibitors(){return this.state.selectedItems.length===0?this.rootStore.exhibitorStore.exhibitors:this.rootStore.exhibitorStore.exhibitors.filter(t=>this.state.selectedItems.some(i=>t.categories.some(r=>r.id===i.id)))}get filteredBooths(){return this.rootStore.boothStore.booths.filter(t=>this.filteredExhibitors.some(i=>i.id===t.exhibitors[0]?.id))}get viewsOwnSelection(){return this.viewScope!==null&&this.viewScope.buttonId===this.scopeButtonId}openFilter(){this.openScope(a)}openFilterForButton(t,i,r){this.openScope({buttonId:t,categoryIds:i,title:r})}setOwner(t){this.scopeButtonId=t}openScope(t){this.viewScope=t,this.state.isOpen=!0,this.state.pendingItems=this.viewsOwnSelection?[...this.state.selectedItems]:[]}applyFilter(){this.setOwner(this.state.pendingItems.length>0?this.viewScope?.buttonId??null:null),super.applyFilter()}clearSelection(){this.state.selectedItems=[],this.state.pendingItems=[],this.rootStore.uiState.selectedCategoryFilters=[],this.rootStore.uiState.categoryFilterOpen=!1,this.setOwner(null)}updateUIState(){this.rootStore.uiState.menu=!1;const t=this.state.selectedItems.map(r=>this.rootStore.categoryStore.categories.find(p=>p.id===r.id)).filter(r=>r!==void 0);this.rootStore.uiState.selectedCategoryFilters=t,this.rootStore.uiState.categoryFilterOpen=!0,this.rootStore.searchStore.setFocused(!0),this.rootStore.moveToList(),this.rootStore.showMap();const i=t.map(r=>r.name);this.rootStore.urlFilterManager.setCategories(i)}getFilteredItems(){return this.rootStore.exhibitorStore.exhibitors.map(t=>({id:t.id,name:t.name}))}getMatchingExhibitorsCount(){return this.state.pendingItems.length===0?this.rootStore.exhibitorStore.exhibitors.length:this.rootStore.exhibitorStore.exhibitors.filter(t=>t.categories.some(i=>this.state.pendingItems.some(r=>r.id===i.id))).length}resetFilter(){this.clearSelection(),this.rootStore.uiState.list={type:"search",text:"",focused:!1},this.rootStore.urlFilterManager.setCategories([])}}o([n],e.prototype,"scopeButtonId",void 0),o([n.ref],e.prototype,"viewScope",void 0),o([l],e.prototype,"filteredExhibitors",null),o([l],e.prototype,"filteredBooths",null),o([l],e.prototype,"viewsOwnSelection",null),o([s],e.prototype,"openFilter",null),o([s],e.prototype,"openFilterForButton",null),o([s],e.prototype,"setOwner",null),o([s],e.prototype,"openScope",null),o([s],e.prototype,"applyFilter",null),o([s],e.prototype,"clearSelection",null),o([s],e.prototype,"resetFilter",null);
|