UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 1.84 kB
import{Rect as W}from"@expofp/geometry";import{SEPARATOR as s}from"../../../../constants";import{createImageDef as w}from"../../../../renderer";import A,{boothStore as E,uiState as H}from"../../../../store";import T from"../../../../tools/settings";import{loadImagesInBatchesById as U}from"../../../../utils/loadImagesInBatches";import _ from"./config-booth-bg";import z from"./config-booth-bookmark";import C from"./config-booth-border";import K from"./config-booth-labels";import P from"./config-booth-labels-special";import{createBoothImg as Z,getImageLayerName as j,mapBoothsLogos as q}from"./loadBoothsImages";export const BOOTHS_CHUNK_SIZE=350;export default function F(n,$,I){return(h=>{const t=$,p=[],m=[],l=[],f=[],b=[],g=j(t),d={name:g,children:[]};for(const o of h){const r=_(n,o)?.getShape();r&&p.push(...r);const a=K(n,o)?.getShape();a&&m.push(...a);const c=P(n,o)?.getShape();if(c&&l.push(...c),!T.borderless){const e=C(n,o)?.getShape();e&&f.push(e)}const i=z(n,o)?.getShape();i&&b.push(i)}const y=m.filter(o=>o.lines),k=l.filter(o=>o.lines),S=m.filter(o=>o.source),D=l.filter(o=>o.source);if(!H.hideLogoInBooth){const o=q(h);n.onLayerImages(g,async()=>{const r=await U(o,BOOTHS_CHUNK_SIZE),a=[];for(const[c,i]of r){const e=A.boothStore.boothById.get(c);if(!e)continue;const{bounds:x,htmlImage:R}=Z(e,i),u=w(R,x),N=e.borderWidth||E.borderWidth,L=e.rect.expand(-N),O=new W(L.center,L.size,e.rotate);e.shapes.push(u),a.push({shape:u,parentRect:O})}return{layer:d,children:a}})}let B=[];return h.length&&(B=[{name:`${t}${s}boothBackground`,children:p,interactive:!0},{name:`${t}${s}labels`,children:y},{name:`${t}${s}specialLabels`,children:k},{name:`${t}${s}bots`,children:S},{name:`${t}${s}specialDots`,children:D},d,{name:`${t}${s}boothsBookmark`,children:b},{name:`${t}${s}boothBorder`,children:f}]),{name:t,children:B}})(I)}