@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.93 kB
JavaScript
import{__esDecorate as h,__runInitializers as C}from"tslib";import{computed as p}from"mobx";import d from"../tools/settings";import{getColorFromGradient as x}from"../utils/color-gradient";import{BoothBase as y}from"./BoothStore";import{Category as k}from"./CategoryStore";import{EventItem as g}from"./EventStore";import{Exhibitor as m}from"./ExhibitorStore";let v=(()=>{let a=[],l;return class{static{const t=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;l=[p({keepAlive:!0})],h(this,null,l,{kind:"getter",name:"minAndMaxClicks",static:!1,private:!1,access:{has:e=>"minAndMaxClicks"in e,get:e=>e.minAndMaxClicks},metadata:t},null,a),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}rootStore=C(this,a);heatmapData={};constructor(t){this.rootStore=t}forceTrack=null;get minAndMaxClicks(){const{booths:t=[],exhibitors:e=[],yah:i=[]}=this.heatmapData,r=[...t,...e,...i];if(r.length===0)return{min:0,max:0};const c=s=>s.reduce((n,o)=>(o.viewCount>n.max&&(n.max=o.viewCount),o.viewCount<n.min&&(n.min=o.viewCount),n),{min:s[0].viewCount,max:s[0].viewCount}),{min:u,max:f}=c(r);return{min:u,max:f}}getClicksByType(t){return t instanceof k?-1:t instanceof m?this.getClicksByItem(t):t instanceof HeatmapYah?this.getClicksByItem(t):t instanceof g?0:this.getClicksByItem(t)}getClicksByItem(t){return t instanceof m?this.heatmapData?.exhibitors?.find(e=>e.id===t.id)?.viewCount||0:t instanceof y?this.heatmapData?.booths?.find(e=>e.id===t.id)?.viewCount||0:t instanceof HeatmapYah&&this.heatmapData?.yah?.find(e=>e.id===t.id)?.viewCount||0}getTotalClicksByBooth(t){let e=this.getClicksByItem(t);for(const i of t.exhibitors){const r=this.getClicksByItem(i);e+=r}return e}getColorByClicks(t){const{min:e,max:i}=this.minAndMaxClicks;return x(t,e,i,d.heatmapColors)}}})();export default v;export class HeatmapYah{id;name;viewCount;x;y;z;entity={type:"heatmap-yah"}}