@zonetrix/viewer 2.11.2 → 2.13.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/README.md +13 -2
- package/dist/components/SeatMapViewer.d.ts +4 -4
- package/dist/index.d.ts +3 -7
- package/dist/index.js +1 -1
- package/dist/index.mjs +515 -727
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -129,7 +129,7 @@ function BookingApp() {
|
|
|
129
129
|
| `showZoomControls` | `boolean` | No | Show zoom +/- buttons (default: true) |
|
|
130
130
|
| `zoomControlsPosition` | `string` | No | Position: 'top-left' \| 'top-right' \| 'bottom-left' \| 'bottom-right' (default: 'bottom-right') |
|
|
131
131
|
| `zoomControlsClassName` | `string` | No | Custom CSS class for zoom controls |
|
|
132
|
-
| `minZoom` | `number` | No | Minimum zoom level. If not set,
|
|
132
|
+
| `minZoom` | `number` | No | Minimum zoom level. If not set, defaults to 50% of fit-to-view scale for comfortable breathing room (default: undefined) |
|
|
133
133
|
| `maxZoom` | `number` | No | Maximum zoom level (default: 3) |
|
|
134
134
|
| `zoomStep` | `number` | No | Zoom increment per click (default: 0.25) |
|
|
135
135
|
|
|
@@ -597,7 +597,7 @@ function RobustViewer() {
|
|
|
597
597
|
|
|
598
598
|
### 9. Custom Minimum Zoom
|
|
599
599
|
|
|
600
|
-
By default, users
|
|
600
|
+
By default, users can zoom out to 50% of the "fit to screen" level, providing comfortable breathing room around all content. To customize this behavior:
|
|
601
601
|
|
|
602
602
|
```tsx
|
|
603
603
|
import { SeatMapViewer } from '@zonetrix/viewer';
|
|
@@ -624,6 +624,17 @@ function BirdEyeView() {
|
|
|
624
624
|
/>
|
|
625
625
|
);
|
|
626
626
|
}
|
|
627
|
+
|
|
628
|
+
// Restrict zoom out to fit-to-screen scale (legacy behavior)
|
|
629
|
+
function RestrictedZoom() {
|
|
630
|
+
return (
|
|
631
|
+
<SeatMapViewer
|
|
632
|
+
config={venueConfig}
|
|
633
|
+
minZoom={1.0} // Set explicitly to match fit scale
|
|
634
|
+
onSeatSelect={(seat) => handleSelection(seat)}
|
|
635
|
+
/>
|
|
636
|
+
);
|
|
637
|
+
}
|
|
627
638
|
```
|
|
628
639
|
|
|
629
640
|
**Note**: Very low minZoom values (< 0.1) may impact rendering performance with large seat maps.
|
|
@@ -33,12 +33,12 @@ export interface SeatMapViewerProps {
|
|
|
33
33
|
/**
|
|
34
34
|
* Minimum zoom level.
|
|
35
35
|
*
|
|
36
|
-
* When undefined (default), users
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* When undefined (default), users can zoom out to 50% of the "fit to screen"
|
|
37
|
+
* scale, providing comfortable breathing room around all content. When set,
|
|
38
|
+
* this value becomes the absolute minimum zoom level.
|
|
39
39
|
*
|
|
40
40
|
* Examples:
|
|
41
|
-
* - undefined: Default behavior, minimum is fit-to-screen scale
|
|
41
|
+
* - undefined: Default behavior, minimum is 50% of fit-to-screen scale
|
|
42
42
|
* - 0.1: Allow zooming out to 10% of original size
|
|
43
43
|
* - 0.25: Allow zooming out to 25% of original size
|
|
44
44
|
* - 1.0: Prevent zooming out below 100% (actual size)
|
package/dist/index.d.ts
CHANGED
|
@@ -5,10 +5,6 @@ export { DEFAULT_COLORS } from './types';
|
|
|
5
5
|
export { useConfigFetcher } from './hooks/useConfigFetcher';
|
|
6
6
|
export { useContainerSize } from './hooks/useContainerSize';
|
|
7
7
|
export { useTouchGestures } from './hooks/useTouchGestures';
|
|
8
|
-
export { useFirebaseSeatStates } from '
|
|
9
|
-
export type { UseFirebaseSeatStatesOptions, UseFirebaseSeatStatesResult, } from '
|
|
10
|
-
export {
|
|
11
|
-
export type { UseFirebaseConfigOptions, UseFirebaseConfigResult, } from './hooks/useFirebaseConfig';
|
|
12
|
-
export { useRealtimeSeatMap } from './hooks/useRealtimeSeatMap';
|
|
13
|
-
export type { UseRealtimeSeatMapOptions, UseRealtimeSeatMapResult, } from './hooks/useRealtimeSeatMap';
|
|
14
|
-
export { initializeFirebaseForViewer, isFirebaseInitialized, clearFirebaseInstance, } from './firebase/client';
|
|
8
|
+
export { useFirebaseSeatStates, useFirebaseConfig, useRealtimeSeatMap, } from '@zonetrix/shared';
|
|
9
|
+
export type { UseFirebaseSeatStatesOptions, UseFirebaseSeatStatesResult, UseFirebaseConfigOptions, UseFirebaseConfigResult, UseRealtimeSeatMapOptions, UseRealtimeSeatMapResult, } from '@zonetrix/shared';
|
|
10
|
+
export { initializeFirebaseForViewer, getFirebaseDatabase, isFirebaseInitialized, clearFirebaseInstance, } from '@zonetrix/shared';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),n=require("react"),N=require("react-konva"),A=require("firebase/database"),lt=require("@zonetrix/shared");function Ee(s){const[i,t]=n.useState(null),[r,h]=n.useState(!1),[u,c]=n.useState(null),S=n.useCallback(async()=>{if(s){h(!0),c(null);try{const f=await fetch(s);if(!f.ok)throw new Error(`Failed to fetch config: ${f.statusText}`);const a=await f.json();t(a)}catch(f){const a=f instanceof Error?f:new Error("Unknown error occurred");c(a),console.error("Failed to fetch seat map config:",a)}finally{h(!1)}}},[s]);return n.useEffect(()=>{S()},[S]),{config:i,loading:r,error:u,refetch:S}}function Fe(s){const[i,t]=n.useState({width:0,height:0});return n.useEffect(()=>{const r=s.current;if(!r)return;const{width:h,height:u}=r.getBoundingClientRect();h>0&&u>0&&t({width:h,height:u});const c=new ResizeObserver(S=>{const f=S[0];if(!f)return;const{width:a,height:b}=f.contentRect;a>0&&b>0&&t(m=>m.width===a&&m.height===b?m:{width:a,height:b})});return c.observe(r),()=>{c.disconnect()}},[s]),i}function Me(s,i){return Math.sqrt(Math.pow(i.x-s.x,2)+Math.pow(i.y-s.y,2))}function je(s,i){return{x:(s.x+i.x)/2,y:(s.y+i.y)/2}}function ke(s,i){const t=n.useRef(null),r=n.useRef(null),h=n.useRef(1),{enabled:u,minScale:c,maxScale:S,currentScale:f,currentPosition:a,onScaleChange:b}=i;n.useEffect(()=>{const m=s.current;if(!m||!u)return;const g=m.container(),C=p=>{if(p.touches.length===2){p.preventDefault();const F={x:p.touches[0].clientX,y:p.touches[0].clientY},R={x:p.touches[1].clientX,y:p.touches[1].clientY};t.current=Me(F,R),r.current=je(F,R),h.current=f}},y=p=>{if(p.touches.length!==2)return;p.preventDefault();const F={x:p.touches[0].clientX,y:p.touches[0].clientY},R={x:p.touches[1].clientX,y:p.touches[1].clientY},k=Me(F,R),E=je(F,R);if(t.current!==null&&r.current!==null){const I=k/t.current,T=Math.min(Math.max(f*I,c),S),W=g.getBoundingClientRect(),Y=E.x-W.left,ne=E.y-W.top,se=f,re={x:(Y-a.x)/se,y:(ne-a.y)/se},oe=E.x-r.current.x,P=E.y-r.current.y,U={x:Y-re.x*T+oe,y:ne-re.y*T+P};b(T,U),t.current=k,r.current=E}},j=p=>{p.touches.length<2&&(t.current=null,r.current=null)};return g.addEventListener("touchstart",C,{passive:!1}),g.addEventListener("touchmove",y,{passive:!1}),g.addEventListener("touchend",j),()=>{g.removeEventListener("touchstart",C),g.removeEventListener("touchmove",y),g.removeEventListener("touchend",j)}},[s,u,c,S,f,a,b])}const Ie={canvasBackground:"#1a1a1a",stageColor:"#808080",seatAvailable:"#2C2B30",seatReserved:"#FCEA00",seatSelected:"#3A7DE5",seatUnavailable:"#6b7280",seatHidden:"#4a4a4a",gridLines:"#404040",currency:"KD"},Le=n.memo(({seat:s,state:i,colors:t,onClick:r,onMouseEnter:h,onMouseLeave:u})=>{const f={available:t.seatAvailable,reserved:t.seatReserved,selected:t.seatSelected,unavailable:t.seatUnavailable,hidden:t.seatHidden}[i],a=i==="available"||i==="selected",b=n.useCallback(()=>{a&&r(s)},[s,r,a]),m=n.useCallback(y=>{h(s,y);const j=y.target.getStage();j&&a&&(j.container().style.cursor="pointer")},[s,h,a]),g=n.useCallback(y=>{u();const j=y.target.getStage();j&&(j.container().style.cursor="grab")},[u]),C={x:s.position.x,y:s.position.y,fill:f,stroke:"#ffffff",strokeWidth:1,onClick:b,onTap:b,onMouseEnter:m,onMouseLeave:g};return s.shape==="circle"?o.jsx(N.Circle,{...C,radius:12}):o.jsx(N.Rect,{...C,width:24,height:24,offsetX:12,offsetY:12,cornerRadius:s.shape==="square"?0:4})});Le.displayName="ViewerSeat";const Te=n.memo(({stage:s,stageColor:i})=>{const t=s.config,r=t.shape||"rectangle",h=t.showLabel!==!1,u=t.color||i,c=t.width/t.height,S=c<.5,f=c>2;let a;S?a=t.width*.25:f?a=t.height*.35:a=Math.min(t.width,t.height)*.25;const b=t.label?.length||6,C=t.width*.85/b*1.5,y=Math.max(10,Math.min(24,Math.min(a,C))),j=4,p=Math.max(20,t.width-j*2),F=(t.width-p)/2,R={fill:u+"80",stroke:"#ffffff",strokeWidth:2,perfectDrawEnabled:!1,hitStrokeWidth:0},k=()=>{switch(r){case"circle":{const E=Math.min(t.width,t.height)/2;return o.jsx(N.Circle,{x:t.width/2,y:t.height/2,radius:E,...R})}case"triangle":{const E=Math.min(t.width,t.height)/2;return o.jsx(N.RegularPolygon,{x:t.width/2,y:t.height/2,sides:3,radius:E,rotation:-90,...R})}case"arrow":{const E=t.width/24,I=t.height/24,T=`M${9*E},${18*I} v${-8*I} H${5*E} l${7*E},${-7*I} l${7*E},${7*I} h${-4*E} v${8*I} Z`;return o.jsx(N.Path,{data:T,...R})}default:return o.jsx(N.Rect,{width:t.width,height:t.height,cornerRadius:10,...R})}};return o.jsxs(N.Group,{x:s.position.x,y:s.position.y,rotation:t.rotation||0,children:[k(),h&&o.jsx(N.Text,{text:t.label,x:F,y:j,width:p,height:t.height-j*2,fontSize:y,fontStyle:"bold",fill:"#ffffff",align:"center",verticalAlign:"middle",wrap:"word",ellipsis:!0})]})});Te.displayName="ViewerStage";const ze=n.memo(({text:s})=>o.jsx(N.Text,{x:s.position.x,y:s.position.y,text:s.config.text,fontSize:s.config.fontSize,fill:s.config.color,rotation:s.config.rotation||0,listening:!1}));ze.displayName="ViewerText";const De=n.memo(({floors:s,currentFloorId:i,onFloorChange:t,showAllOption:r,allLabel:h,position:u,className:c})=>{const S=n.useMemo(()=>[...s].sort((g,C)=>g.order-C.order),[s]),a={position:"absolute",display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[u]},b={padding:"10px 16px",fontSize:"14px",fontWeight:500,border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",transition:"all 0.2s ease",minHeight:"44px",touchAction:"manipulation"},m={...b,backgroundColor:"#3A7DE5",borderColor:"#3A7DE5"};return o.jsxs("div",{className:c,style:a,children:[r&&o.jsx("button",{type:"button",onClick:()=>t(null),style:i===null?m:b,children:h}),S.map(g=>o.jsx("button",{type:"button",onClick:()=>t(g.id),style:i===g.id?m:b,children:g.name},g.id))]})});De.displayName="FloorSelectorBar";const Ne=n.memo(({scale:s,minScale:i,maxScale:t,onZoomIn:r,onZoomOut:h,position:u,className:c})=>{const f={position:"absolute",display:"flex",flexDirection:"column",gap:"4px",padding:"8px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[u]},a={width:"44px",height:"44px",minWidth:"44px",minHeight:"44px",fontSize:"22px",fontWeight:"bold",border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",touchAction:"manipulation"},b={...a,opacity:.4,cursor:"not-allowed"},m=s<t,g=s>i;return o.jsxs("div",{className:c,style:f,children:[o.jsx("button",{type:"button",onClick:r,disabled:!m,style:m?a:b,title:"Zoom In",children:"+"}),o.jsx("button",{type:"button",onClick:h,disabled:!g,style:g?a:b,title:"Zoom Out",children:"−"})]})});Ne.displayName="ZoomControls";const $e=n.memo(({visible:s,x:i,y:t,seat:r,currency:h,state:u})=>{if(!s||!r)return null;const c=r.seatNumber||(r.rowLabel&&r.columnLabel?`${r.rowLabel}-${r.columnLabel}`:"N/A"),S={position:"fixed",left:`${i+15}px`,top:`${t+15}px`,zIndex:1e3,pointerEvents:"none"},f={backgroundColor:"rgba(26, 26, 26, 0.95)",color:"#fff",border:"1px solid #444",borderRadius:"8px",padding:"8px 12px",fontSize:"13px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",minWidth:"140px"},a={color:"#9ca3af",marginRight:"4px"},b={fontWeight:600},m={color:"#4ade80",fontWeight:600},g={fontSize:"11px",color:"#6b7280",textTransform:"capitalize",marginTop:"4px"};return o.jsx("div",{style:S,children:o.jsxs("div",{style:f,children:[r.sectionName&&o.jsxs("div",{style:{marginBottom:"4px"},children:[o.jsx("span",{style:a,children:"Section:"}),o.jsx("span",{style:{...b,color:"#3b82f6"},children:r.sectionName})]}),o.jsxs("div",{style:{marginBottom:"4px"},children:[o.jsx("span",{style:a,children:"Seat:"}),o.jsx("span",{style:b,children:c})]}),r.price!==void 0&&r.price>0&&u==="available"&&o.jsxs("div",{style:{marginBottom:"4px"},children:[o.jsx("span",{style:a,children:"Price:"}),o.jsxs("span",{style:m,children:[h," ",r.price.toFixed(2)]})]}),o.jsxs("div",{style:g,children:["Status: ",u]})]})})});$e.displayName="SeatTooltip";const ut=({config:s,configUrl:i,floorId:t,onFloorChange:r,reservedSeats:h=[],otherReservedSeats:u,unavailableSeats:c=[],selectedSeats:S,myReservedSeats:f=[],onSeatSelect:a,onSeatDeselect:b,onSelectionChange:m,colorOverrides:g,showTooltip:C=!0,zoomEnabled:y=!0,className:j="",onConfigLoad:p,onError:F,showFloorSelector:R,floorSelectorPosition:k="top-left",floorSelectorClassName:E,showAllFloorsOption:I=!0,allFloorsLabel:T="All",fitToView:W=!0,fitPadding:Y=40,showZoomControls:ne=!0,zoomControlsPosition:se="bottom-right",zoomControlsClassName:re,minZoom:oe,maxZoom:P=3,zoomStep:U=.25,touchEnabled:Xe=!0})=>{const ve=u!==void 0?u:h,ge=n.useRef(null),we=n.useRef(null),L=Fe(we),[H,Ce]=n.useState(new Set),[z,Z]=n.useState(1),[$,O]=n.useState({x:0,y:0}),[Ae,Ye]=n.useState(null),[Be,Ve]=n.useState(1),ie=n.useRef({width:0,height:0}),[K,Re]=n.useState({visible:!1,x:0,y:0,seat:null,state:"available"}),{config:Ue,loading:He,error:J}=Ee(i),d=s||Ue,pe=t!==void 0,D=pe?t||null:Ae,ae=S!==void 0,Oe=n.useCallback(e=>{pe||Ye(e),r?.(e)},[pe,r]),xe=d?.floors||[],qe=R!==void 0?R:xe.length>1,ce=n.useMemo(()=>d?{...d.colors,...g}:{...Ie,...g},[d,g]),q=n.useMemo(()=>{if(!d)return[];let e=d.seats.filter(l=>l.state!=="hidden");return D&&(e=e.filter(l=>l.floorId===D||!l.floorId&&D==="floor_default")),e},[d,D]),le=n.useMemo(()=>d?.stages?D?d.stages.filter(e=>e.floorId===D||!e.floorId&&D==="floor_default"):d.stages:[],[d,D]),ue=n.useMemo(()=>d?.texts?D?d.texts.filter(e=>e.floorId===D||!e.floorId&&D==="floor_default"):d.texts:[],[d,D]),X=n.useMemo(()=>{if(!d||q.length===0&&le.length===0&&ue.length===0)return null;const e=12;let l=1/0,x=1/0,v=-1/0,M=-1/0;return q.forEach(w=>{l=Math.min(l,w.position.x-e),x=Math.min(x,w.position.y-e),v=Math.max(v,w.position.x+e),M=Math.max(M,w.position.y+e)}),le.forEach(w=>{l=Math.min(l,w.position.x),x=Math.min(x,w.position.y),v=Math.max(v,w.position.x+(w.config?.width||200)),M=Math.max(M,w.position.y+(w.config?.height||100))}),ue.forEach(w=>{const V=w.config.text.length*w.config.fontSize*.6,G=w.config.fontSize;l=Math.min(l,w.position.x),x=Math.min(x,w.position.y),v=Math.max(v,w.position.x+V),M=Math.max(M,w.position.y+G)}),{minX:l,minY:x,maxX:v,maxY:M,width:v-l,height:M-x}},[d,q,le,ue]);n.useEffect(()=>{if(!W||!d||!X||L.width===0||L.height===0)return;const e=Math.abs(L.width-ie.current.width),l=Math.abs(L.height-ie.current.height);if(!(ie.current.width===0)&&e<10&&l<10)return;ie.current=L;const v=L.width,M=L.height,w=v-Y*2,V=M-Y*2,G=w/X.width,Se=V/X.height,de=Math.min(G,Se,P),st=X.minX+X.width/2,rt=X.minY+X.height/2,ot=v/2,it=M/2,at=ot-st*de,ct=it-rt*de;Z(de),O({x:at,y:ct}),Ve(de)},[W,d,X,Y,P,L,D]);const B=n.useMemo(()=>{const e=new Set(ve),l=new Set(c),x=new Set(f);return{reserved:e,unavailable:l,myReserved:x}},[ve,c,f]),be=n.useMemo(()=>S?new Set(S):null,[S]),Q=n.useCallback(e=>{const l=e.id,x=e.seatNumber||"";return B.unavailable.has(l)||B.unavailable.has(x)?"unavailable":B.reserved.has(l)||B.reserved.has(x)?"reserved":B.myReserved.has(l)||B.myReserved.has(x)||H.has(l)?"selected":e.state},[B,H]);n.useEffect(()=>{d&&p&&p(d)},[d,p]),n.useEffect(()=>{J&&F&&F(J)},[J,F]),n.useEffect(()=>{ae&&be&&Ce(be)},[ae,be]);const _e=n.useCallback(e=>{const l=Q(e);if(l!=="available"&&l!=="selected")return;const x=H.has(e.id);ae||Ce(v=>{const M=new Set(v);return x?M.delete(e.id):M.add(e.id),M}),x?b?.(e):(a?.(e),a||console.log("Seat selected:",e))},[Q,H,ae,a,b]),ee=n.useMemo(()=>d?q.filter(e=>H.has(e.id)):[],[d,q,H]);n.useEffect(()=>{m?.(ee)},[ee,m]);const _=oe!==void 0?oe:Be,Ge=n.useCallback(()=>{if(!y)return;const e=Math.min(z+U,P);if(e!==z){const l=L.width||d?.canvas.width||800,x=L.height||d?.canvas.height||600,v=l/2,M=x/2,w={x:(v-$.x)/z,y:(M-$.y)/z};Z(e),O({x:v-w.x*e,y:M-w.y*e})}},[y,z,U,P,L,d,$]),Ze=n.useCallback(()=>{if(!y)return;const e=Math.max(z-U,_);if(e!==z){const l=L.width||d?.canvas.width||800,x=L.height||d?.canvas.height||600,v=l/2,M=x/2,w={x:(v-$.x)/z,y:(M-$.y)/z};Z(e),O({x:v-w.x*e,y:M-w.y*e})}},[y,z,U,_,L,d,$]),Ke=n.useCallback(e=>{O({x:e.target.x(),y:e.target.y()})},[]),Je=n.useCallback(e=>{if(!y)return;e.evt.preventDefault();const l=ge.current;if(!l)return;const x=l.scaleX(),v=l.getPointerPosition();if(!v)return;const M=1.1,w=e.evt.deltaY>0?x/M:x*M,V=Math.min(Math.max(w,_),P),G={x:(v.x-$.x)/x,y:(v.y-$.y)/x},Se={x:v.x-G.x*V,y:v.y-G.y*V};Z(V),O(Se)},[y,$,_,P]);ke(ge,{enabled:Xe&&y,minScale:_,maxScale:P,currentScale:z,currentPosition:$,onScaleChange:(e,l)=>{Z(e),O(l)}});const Qe=n.useCallback((e,l)=>{if(!C)return;const x=l.target.getStage();if(!x)return;const v=x.getPointerPosition();if(!v)return;const M=x.container().getBoundingClientRect();Re({visible:!0,x:M.left+v.x,y:M.top+v.y,seat:e,state:Q(e)})},[C,Q]),et=n.useCallback(()=>{Re(e=>({...e,visible:!1}))},[]);if(He)return o.jsx("div",{className:`flex items-center justify-center h-full ${j}`,children:o.jsx("p",{children:"Loading seat map..."})});if(J)return o.jsx("div",{className:`flex items-center justify-center h-full ${j}`,children:o.jsxs("p",{className:"text-red-500",children:["Error loading seat map: ",J.message]})});if(!d)return o.jsx("div",{className:`flex items-center justify-center h-full ${j}`,children:o.jsx("p",{children:"No configuration provided"})});const tt=L.width||d.canvas.width,nt=L.height||d.canvas.height;return o.jsxs("div",{ref:we,className:`relative ${j}`,style:{width:"100%",height:"100%"},children:[qe&&xe.length>0&&o.jsx(De,{floors:xe,currentFloorId:D,onFloorChange:Oe,showAllOption:I,allLabel:T,position:k,className:E}),o.jsxs(N.Stage,{ref:ge,width:tt,height:nt,scaleX:z,scaleY:z,x:$.x,y:$.y,draggable:!0,onDragEnd:Ke,onWheel:Je,style:{backgroundColor:d.canvas.backgroundColor,cursor:"grab"},children:[o.jsx(N.Layer,{listening:!1,children:le.map(e=>o.jsx(Te,{stage:e,stageColor:ce.stageColor},e.id))}),o.jsx(N.Layer,{listening:!1,children:ue.map(e=>o.jsx(ze,{text:e},e.id))}),o.jsx(N.Layer,{children:q.map(e=>o.jsx(Le,{seat:e,state:Q(e),colors:ce,onClick:_e,onMouseEnter:Qe,onMouseLeave:et},e.id))})]}),C&&o.jsx($e,{visible:K.visible,x:K.x,y:K.y,seat:K.seat,currency:ce.currency,state:K.state}),ne&&y&&o.jsx(Ne,{scale:z,minScale:_,maxScale:P,onZoomIn:Ge,onZoomOut:Ze,position:se,className:re}),ee.length>0&&o.jsxs("div",{className:"absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg",children:[o.jsxs("h3",{className:"font-semibold mb-2",children:["Selected Seats (",ee.length,")"]}),o.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:ee.map(e=>o.jsxs("div",{className:"text-sm",children:[e.seatNumber,e.price&&` - ${ce.currency} ${e.price.toFixed(2)}`]},e.id))})]})]})};let te=null;function dt(s){te=s}function ye(){if(!te)throw new Error("Firebase database not initialized. Call initializeFirebaseForViewer(db) first.");return te}function fe(){return te!==null}function ht(){te=null}function me(s,i){if(s.length!==i.length)return!1;const t=[...s].sort(),r=[...i].sort();return t.every((h,u)=>h===r[u])}function ft(s,i){const t=[],r=[],h=[];return Object.entries(s).forEach(([u,c])=>{c&&typeof c=="object"&&c.state&&(c.state==="unavailable"?h.push(u):c.state==="reserved"&&(i&&c.userId===i?t.push(u):r.push(u)))}),{myReserved:t.sort(),otherReserved:r.sort(),unavailable:h.sort()}}const he={states:null,loading:!0,error:null,lastUpdated:null,myReservedSeats:[],otherReservedSeats:[],unavailableSeats:[]};function We(s){const{seatMapId:i,currentUserId:t,enabled:r=!0,onStateChange:h,onError:u}=s,c=n.useRef({...he}),S=n.useRef(h),f=n.useRef(u),a=n.useRef(t);S.current=h,f.current=u,a.current=t;const b=n.useCallback(y=>{if(!r||!i)return(c.current.loading!==!1||c.current.states!==null)&&(c.current={...he,loading:!1},y()),()=>{};if(!fe()){const k="Firebase not initialized. Call initializeFirebaseForViewer first.";return c.current.error?.message!==k&&(c.current={...he,loading:!1,error:new Error(k)},y()),()=>{}}const j=ye(),p=A.ref(j,`seatmaps/${i}/seat_states`),F=k=>{const I=k.val()||{},T=ft(I,a.current),W=c.current;(W.loading||!me(W.myReservedSeats,T.myReserved)||!me(W.otherReservedSeats,T.otherReserved)||!me(W.unavailableSeats,T.unavailable))&&(c.current={states:I,loading:!1,error:null,lastUpdated:Date.now(),myReservedSeats:T.myReserved,otherReservedSeats:T.otherReserved,unavailableSeats:T.unavailable},S.current?.(I),y())},R=k=>{c.current={...c.current,loading:!1,error:k},f.current?.(k),y()};return A.onValue(p,F,R),()=>{A.off(p)}},[i,r]),m=n.useCallback(()=>c.current,[]),g=n.useCallback(()=>he,[]),C=n.useSyncExternalStore(b,m,g);return{states:C.states,loading:C.loading,error:C.error,lastUpdated:C.lastUpdated,myReservedSeats:C.myReservedSeats,otherReservedSeats:C.otherReservedSeats,unavailableSeats:C.unavailableSeats,reservedSeats:C.otherReservedSeats}}function Pe(s){const{seatMapId:i,enabled:t=!0,subscribeToChanges:r=!1,onConfigLoad:h,onError:u}=s,[c,S]=n.useState(null),[f,a]=n.useState(!0),[b,m]=n.useState(null),g=n.useRef(h),C=n.useRef(u);g.current=h,C.current=u;const y=n.useCallback(async()=>{if(!i)return;if(!fe()){m(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")),a(!1);return}const j=ye(),p=A.ref(j,`seatmaps/${i}`);try{a(!0),m(null);const R=(await A.get(p)).val();if(R){const k=lt.fromFirebaseSeatMap(R);S(k),g.current?.(k)}else m(new Error(`Seat map ${i} not found in Firebase`))}catch(F){const R=F instanceof Error?F:new Error("Unknown error");m(R),C.current?.(R)}finally{a(!1)}},[i]);return n.useEffect(()=>{if(!t||!i){a(!1);return}if(y(),r&&fe()){const j=ye(),p=A.ref(j,`seatmaps/${i}/meta/updated_at`);let F=!0,R=null;const k=E=>{if(F){F=!1,R=E.val();return}const I=E.val();E.exists()&&I!==R&&(R=I,y())};return A.onValue(p,k),()=>{A.off(p)}}},[i,t,r]),{config:c,loading:f,error:b,refetch:y}}function gt(s){const{seatMapId:i,userId:t,enabled:r=!0,subscribeToDesignChanges:h=!1,onConfigLoad:u,onStateChange:c,onError:S}=s,{config:f,loading:a,error:b,refetch:m}=Pe({seatMapId:i,enabled:r,subscribeToChanges:h,onConfigLoad:u,onError:S}),{states:g,loading:C,error:y,lastUpdated:j,myReservedSeats:p,otherReservedSeats:F,unavailableSeats:R,reservedSeats:k}=We({seatMapId:i,currentUserId:t,enabled:r,onStateChange:c,onError:S});return{config:f,loading:a||C,error:b||y,myReservedSeats:p,otherReservedSeats:F,unavailableSeats:R,reservedSeats:k,seatStates:g,lastUpdated:j,refetch:m}}exports.DEFAULT_COLORS=Ie;exports.SeatMapViewer=ut;exports.clearFirebaseInstance=ht;exports.initializeFirebaseForViewer=dt;exports.isFirebaseInitialized=fe;exports.useConfigFetcher=Ee;exports.useContainerSize=Fe;exports.useFirebaseConfig=Pe;exports.useFirebaseSeatStates=We;exports.useRealtimeSeatMap=gt;exports.useTouchGestures=ke;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),n=require("react"),T=require("react-konva"),O=require("@zonetrix/shared");function Ce(o){const[f,t]=n.useState(null),[a,w]=n.useState(!1),[b,g]=n.useState(null),y=n.useCallback(async()=>{if(o){w(!0),g(null);try{const p=await fetch(o);if(!p.ok)throw new Error(`Failed to fetch config: ${p.statusText}`);const l=await p.json();t(l)}catch(p){const l=p instanceof Error?p:new Error("Unknown error occurred");g(l),console.error("Failed to fetch seat map config:",l)}finally{w(!1)}}},[o]);return n.useEffect(()=>{y()},[y]),{config:f,loading:a,error:b,refetch:y}}function je(o){const[f,t]=n.useState({width:0,height:0});return n.useEffect(()=>{const a=o.current;if(!a)return;const{width:w,height:b}=a.getBoundingClientRect();w>0&&b>0&&t({width:w,height:b});const g=new ResizeObserver(y=>{const p=y[0];if(!p)return;const{width:l,height:x}=p.contentRect;l>0&&x>0&&t(m=>m.width===l&&m.height===x?m:{width:l,height:x})});return g.observe(a),()=>{g.disconnect()}},[o]),f}function ve(o,f){return Math.sqrt(Math.pow(f.x-o.x,2)+Math.pow(f.y-o.y,2))}function we(o,f){return{x:(o.x+f.x)/2,y:(o.y+f.y)/2}}function Me(o,f){const t=n.useRef(null),a=n.useRef(null),w=n.useRef(1),{enabled:b,minScale:g,maxScale:y,currentScale:p,currentPosition:l,onScaleChange:x}=f;n.useEffect(()=>{const m=o.current;if(!m||!b)return;const d=m.container(),k=S=>{if(S.touches.length===2){S.preventDefault();const P={x:S.touches[0].clientX,y:S.touches[0].clientY},E={x:S.touches[1].clientX,y:S.touches[1].clientY};t.current=ve(P,E),a.current=we(P,E),w.current=p}},v=S=>{if(S.touches.length!==2)return;S.preventDefault();const P={x:S.touches[0].clientX,y:S.touches[0].clientY},E={x:S.touches[1].clientX,y:S.touches[1].clientY},Y=ve(P,E),M=we(P,E);if(t.current!==null&&a.current!==null){const $=Y/t.current,z=Math.min(Math.max(p*$,g),y),_=d.getBoundingClientRect(),A=M.x-_.left,ee=M.y-_.top,te=p,ne={x:(A-l.x)/te,y:(ee-l.y)/te},ie=M.x-a.current.x,L=M.y-a.current.y,B={x:A-ne.x*z+ie,y:ee-ne.y*z+L};x(z,B),t.current=Y,a.current=M}},C=S=>{S.touches.length<2&&(t.current=null,a.current=null)};return d.addEventListener("touchstart",k,{passive:!1}),d.addEventListener("touchmove",v,{passive:!1}),d.addEventListener("touchend",C),()=>{d.removeEventListener("touchstart",k),d.removeEventListener("touchmove",v),d.removeEventListener("touchend",C)}},[o,b,g,y,p,l,x])}const ke={canvasBackground:"#1a1a1a",stageColor:"#808080",seatAvailable:"#2C2B30",seatReserved:"#FCEA00",seatSelected:"#3A7DE5",seatUnavailable:"#6b7280",seatHidden:"#4a4a4a",gridLines:"#404040",currency:"KD"},Fe=n.memo(({seat:o,state:f,colors:t,onClick:a,onMouseEnter:w,onMouseLeave:b})=>{const g=(o.size||24)/2,p={available:t.seatAvailable,reserved:t.seatReserved,selected:t.seatSelected,unavailable:t.seatUnavailable,hidden:t.seatHidden}[f],l=f==="available"||f==="selected",x=n.useCallback(()=>{l&&a(o)},[o,a,l]),m=n.useCallback(v=>{w(o,v);const C=v.target.getStage();C&&l&&(C.container().style.cursor="pointer")},[o,w,l]),d=n.useCallback(v=>{b();const C=v.target.getStage();C&&(C.container().style.cursor="grab")},[b]),k={x:o.position.x,y:o.position.y,fill:p,stroke:"#ffffff",strokeWidth:1,onClick:x,onTap:x,onMouseEnter:m,onMouseLeave:d};return o.shape==="circle"?i.jsx(T.Circle,{...k,radius:g}):i.jsx(T.Rect,{...k,width:g*2,height:g*2,offsetX:g,offsetY:g,cornerRadius:o.shape==="square"?0:4})});Fe.displayName="ViewerSeat";const Re=n.memo(({stage:o,stageColor:f})=>{const t=o.config,a=t.shape||"rectangle",w=t.showLabel!==!1,b=t.color||f,g=t.width/t.height,y=g<.5,p=g>2;let l;y?l=t.width*.25:p?l=t.height*.35:l=Math.min(t.width,t.height)*.25;const x=t.label?.length||6,k=t.width*.85/x*1.5,v=Math.max(10,Math.min(24,Math.min(l,k))),C=4,S=Math.max(20,t.width-C*2),P=(t.width-S)/2,E={fill:b+"80",stroke:"#ffffff",strokeWidth:2,perfectDrawEnabled:!1,hitStrokeWidth:0},Y=()=>{switch(a){case"circle":{const M=Math.min(t.width,t.height)/2;return i.jsx(T.Circle,{x:t.width/2,y:t.height/2,radius:M,...E})}case"triangle":{const M=Math.min(t.width,t.height)/2;return i.jsx(T.RegularPolygon,{x:t.width/2,y:t.height/2,sides:3,radius:M,rotation:-90,...E})}case"arrow":{const M=t.width/24,$=t.height/24,z=`M${9*M},${18*$} v${-8*$} H${5*M} l${7*M},${-7*$} l${7*M},${7*$} h${-4*M} v${8*$} Z`;return i.jsx(T.Path,{data:z,...E})}default:return i.jsx(T.Rect,{width:t.width,height:t.height,cornerRadius:10,...E})}};return i.jsxs(T.Group,{x:o.position.x,y:o.position.y,rotation:t.rotation||0,children:[Y(),w&&i.jsx(T.Text,{text:t.label,x:P,y:C,width:S,height:t.height-C*2,fontSize:v,fontStyle:"bold",fill:"#ffffff",align:"center",verticalAlign:"middle",wrap:"word",ellipsis:!0})]})});Re.displayName="ViewerStage";const Ie=n.memo(({text:o})=>i.jsx(T.Text,{x:o.position.x,y:o.position.y,text:o.config.text,fontSize:o.config.fontSize,fill:o.config.color,rotation:o.config.rotation||0,listening:!1}));Ie.displayName="ViewerText";const Ee=n.memo(({floors:o,currentFloorId:f,onFloorChange:t,showAllOption:a,allLabel:w,position:b,className:g})=>{const y=n.useMemo(()=>[...o].sort((d,k)=>d.order-k.order),[o]),l={position:"absolute",display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[b]},x={padding:"10px 16px",fontSize:"14px",fontWeight:500,border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",transition:"all 0.2s ease",minHeight:"44px",touchAction:"manipulation"},m={...x,backgroundColor:"#3A7DE5",borderColor:"#3A7DE5"};return i.jsxs("div",{className:g,style:l,children:[a&&i.jsx("button",{type:"button",onClick:()=>t(null),style:f===null?m:x,children:w}),y.map(d=>i.jsx("button",{type:"button",onClick:()=>t(d.id),style:f===d.id?m:x,children:d.name},d.id))]})});Ee.displayName="FloorSelectorBar";const Te=n.memo(({scale:o,minScale:f,maxScale:t,fitScale:a,onZoomIn:w,onZoomOut:b,onFitToScreen:g,position:y,className:p})=>{const x={position:"absolute",display:"flex",flexDirection:"column",gap:"4px",padding:"8px",backgroundColor:"rgba(26, 26, 26, 0.95)",borderRadius:"8px",margin:"12px",zIndex:10,...{"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0}}[y]},m={width:"44px",height:"44px",minWidth:"44px",minHeight:"44px",fontSize:"22px",fontWeight:"bold",border:"1px solid #444",borderRadius:"6px",backgroundColor:"transparent",color:"#fff",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",touchAction:"manipulation"},d={...m,opacity:.4,cursor:"not-allowed"},k=o<t,v=o>f,C=Math.abs(o-a)<.01;return i.jsxs("div",{className:p,style:x,children:[i.jsx("button",{type:"button",onClick:w,disabled:!k,style:k?m:d,title:"Zoom In","aria-label":"Zoom In",children:"+"}),i.jsx("button",{type:"button",onClick:g,disabled:C,style:C?d:m,title:"Fit to Screen","aria-label":"Fit to Screen",children:"⤢"}),i.jsx("button",{type:"button",onClick:b,disabled:!v,style:v?m:d,title:"Zoom Out","aria-label":"Zoom Out",children:"−"})]})});Te.displayName="ZoomControls";const De=n.memo(({visible:o,x:f,y:t,seat:a,currency:w,state:b})=>{if(!o||!a)return null;const g=a.seatNumber||(a.rowLabel&&a.columnLabel?`${a.rowLabel}-${a.columnLabel}`:"N/A"),y={position:"fixed",left:`${f+15}px`,top:`${t+15}px`,zIndex:1e3,pointerEvents:"none"},p={backgroundColor:"rgba(26, 26, 26, 0.95)",color:"#fff",border:"1px solid #444",borderRadius:"8px",padding:"8px 12px",fontSize:"13px",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.3)",minWidth:"140px"},l={color:"#9ca3af",marginRight:"4px"},x={fontWeight:600},m={color:"#4ade80",fontWeight:600},d={fontSize:"11px",color:"#6b7280",textTransform:"capitalize",marginTop:"4px"};return i.jsx("div",{style:y,children:i.jsxs("div",{style:p,children:[a.sectionName&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Section:"}),i.jsx("span",{style:{...x,color:"#3b82f6"},children:a.sectionName})]}),i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Seat:"}),i.jsx("span",{style:x,children:g})]}),a.price!==void 0&&a.price>0&&b==="available"&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:l,children:"Price:"}),i.jsxs("span",{style:m,children:[w," ",a.price.toFixed(2)]})]}),i.jsxs("div",{style:d,children:["Status: ",b]})]})})});De.displayName="SeatTooltip";const et=({config:o,configUrl:f,floorId:t,onFloorChange:a,reservedSeats:w=[],otherReservedSeats:b,unavailableSeats:g=[],selectedSeats:y,myReservedSeats:p=[],onSeatSelect:l,onSeatDeselect:x,onSelectionChange:m,colorOverrides:d,showTooltip:k=!0,zoomEnabled:v=!0,className:C="",onConfigLoad:S,onError:P,showFloorSelector:E,floorSelectorPosition:Y="top-left",floorSelectorClassName:M,showAllFloorsOption:$=!0,allFloorsLabel:z="All",fitToView:_=!0,fitPadding:A=40,showZoomControls:ee=!0,zoomControlsPosition:te="bottom-right",zoomControlsClassName:ne,minZoom:ie,maxZoom:L=3,zoomStep:B=.25,touchEnabled:Pe=!0})=>{const xe=b!==void 0?b:w,ue=n.useRef(null),be=n.useRef(null),j=je(be),[H,ye]=n.useState(new Set),[R,G]=n.useState(1),[D,V]=n.useState({x:0,y:0}),[Le,Ne]=n.useState(null),[me,We]=n.useState(1),oe=n.useRef({width:0,height:0}),[U,Se]=n.useState({visible:!1,x:0,y:0,seat:null,state:"available"}),{config:$e,loading:ze,error:K}=Ce(f),c=o||$e,he=t!==void 0,I=he?t||null:Le,se=y!==void 0,Xe=n.useCallback(e=>{he||Ne(e),a?.(e)},[he,a]),de=c?.floors||[],Oe=E!==void 0?E:de.length>1,re=n.useMemo(()=>c?{...c.colors,...d}:{...ke,...d},[c,d]),q=n.useMemo(()=>{if(!c)return[];let e=c.seats.filter(s=>s.state!=="hidden");return I&&(e=e.filter(s=>s.floorId===I||!s.floorId&&I==="floor_default")),e},[c,I]),ae=n.useMemo(()=>c?.stages?I?c.stages.filter(e=>e.floorId===I||!e.floorId&&I==="floor_default"):c.stages:[],[c,I]),ce=n.useMemo(()=>c?.texts?I?c.texts.filter(e=>e.floorId===I||!e.floorId&&I==="floor_default"):c.texts:[],[c,I]),N=n.useMemo(()=>{if(!c||q.length===0&&ae.length===0&&ce.length===0)return null;let e=1/0,s=1/0,u=-1/0,h=-1/0;return q.forEach(r=>{const F=(r.size||24)/2;e=Math.min(e,r.position.x-F),s=Math.min(s,r.position.y-F),u=Math.max(u,r.position.x+F),h=Math.max(h,r.position.y+F)}),ae.forEach(r=>{e=Math.min(e,r.position.x),s=Math.min(s,r.position.y),u=Math.max(u,r.position.x+(r.config?.width||200)),h=Math.max(h,r.position.y+(r.config?.height||100))}),ce.forEach(r=>{const F=r.config.text.length*r.config.fontSize*.6,W=r.config.fontSize;e=Math.min(e,r.position.x),s=Math.min(s,r.position.y),u=Math.max(u,r.position.x+F),h=Math.max(h,r.position.y+W)}),{minX:e,minY:s,maxX:u,maxY:h,width:u-e,height:h-s}},[c,q,ae,ce]),fe=n.useCallback(()=>{if(!c||!N||j.width===0||j.height===0)return;const e=j.width,s=j.height,u=e-A*2,h=s-A*2,r=u/N.width,F=h/N.height,W=Math.min(r,F,L),le=N.minX+N.width/2,pe=N.minY+N.height/2,Ue=e/2,Ke=s/2,Je=Ue-le*W,Qe=Ke-pe*W;G(W),V({x:Je,y:Qe}),We(W)},[c,N,j,A,L]);n.useEffect(()=>{if(!_||!c||!N||j.width===0||j.height===0)return;const e=Math.abs(j.width-oe.current.width),s=Math.abs(j.height-oe.current.height);!(oe.current.width===0)&&e<10&&s<10||(oe.current=j,fe())},[_,c,N,j,I,fe]);const X=n.useMemo(()=>{const e=new Set(xe),s=new Set(g),u=new Set(p);return{reserved:e,unavailable:s,myReserved:u}},[xe,g,p]),ge=n.useMemo(()=>y?new Set(y):null,[y]),J=n.useCallback(e=>{const s=e.id,u=e.seatNumber||"";return X.unavailable.has(s)||X.unavailable.has(u)?"unavailable":X.reserved.has(s)||X.reserved.has(u)?"reserved":X.myReserved.has(s)||X.myReserved.has(u)||H.has(s)?"selected":e.state},[X,H]);n.useEffect(()=>{c&&S&&S(c)},[c,S]),n.useEffect(()=>{K&&P&&P(K)},[K,P]),n.useEffect(()=>{se&&ge&&ye(ge)},[se,ge]);const Ye=n.useCallback(e=>{const s=J(e);if(s!=="available"&&s!=="selected")return;const u=H.has(e.id);se||ye(h=>{const r=new Set(h);return u?r.delete(e.id):r.add(e.id),r}),u?x?.(e):(l?.(e),l||console.log("Seat selected:",e))},[J,H,se,l,x]),Q=n.useMemo(()=>c?q.filter(e=>H.has(e.id)):[],[c,q,H]);n.useEffect(()=>{m?.(Q)},[Q,m]);const Z=ie!==void 0?ie:me*.5,Ae=n.useCallback(()=>{if(!v)return;const e=Math.min(R+B,L);if(e!==R){const s=j.width||c?.canvas.width||800,u=j.height||c?.canvas.height||600,h=s/2,r=u/2,F={x:(h-D.x)/R,y:(r-D.y)/R};G(e),V({x:h-F.x*e,y:r-F.y*e})}},[v,R,B,L,j,c,D]),Be=n.useCallback(()=>{if(!v)return;const e=Math.max(R-B,Z);if(e!==R){const s=j.width||c?.canvas.width||800,u=j.height||c?.canvas.height||600,h=s/2,r=u/2,F={x:(h-D.x)/R,y:(r-D.y)/R};G(e),V({x:h-F.x*e,y:r-F.y*e})}},[v,R,B,Z,j,c,D]),He=n.useCallback(e=>{V({x:e.target.x(),y:e.target.y()})},[]),Ve=n.useCallback(e=>{if(!v)return;e.evt.preventDefault();const s=ue.current;if(!s)return;const u=s.scaleX(),h=s.getPointerPosition();if(!h)return;const r=1.1,F=e.evt.deltaY>0?u/r:u*r,W=Math.min(Math.max(F,Z),L),le={x:(h.x-D.x)/u,y:(h.y-D.y)/u},pe={x:h.x-le.x*W,y:h.y-le.y*W};G(W),V(pe)},[v,D,Z,L]);Me(ue,{enabled:Pe&&v,minScale:Z,maxScale:L,currentScale:R,currentPosition:D,onScaleChange:(e,s)=>{G(e),V(s)}});const qe=n.useCallback((e,s)=>{if(!k)return;const u=s.target.getStage();if(!u)return;const h=u.getPointerPosition();if(!h)return;const r=u.container().getBoundingClientRect();Se({visible:!0,x:r.left+h.x,y:r.top+h.y,seat:e,state:J(e)})},[k,J]),Ze=n.useCallback(()=>{Se(e=>({...e,visible:!1}))},[]);if(ze)return i.jsx("div",{className:`flex items-center justify-center h-full ${C}`,children:i.jsx("p",{children:"Loading seat map..."})});if(K)return i.jsx("div",{className:`flex items-center justify-center h-full ${C}`,children:i.jsxs("p",{className:"text-red-500",children:["Error loading seat map: ",K.message]})});if(!c)return i.jsx("div",{className:`flex items-center justify-center h-full ${C}`,children:i.jsx("p",{children:"No configuration provided"})});const _e=j.width||c.canvas.width,Ge=j.height||c.canvas.height;return i.jsxs("div",{ref:be,className:`relative ${C}`,style:{width:"100%",height:"100%"},children:[Oe&&de.length>0&&i.jsx(Ee,{floors:de,currentFloorId:I,onFloorChange:Xe,showAllOption:$,allLabel:z,position:Y,className:M}),i.jsxs(T.Stage,{ref:ue,width:_e,height:Ge,scaleX:R,scaleY:R,x:D.x,y:D.y,draggable:!0,onDragEnd:He,onWheel:Ve,style:{backgroundColor:c.canvas.backgroundColor,cursor:"grab"},children:[i.jsx(T.Layer,{listening:!1,children:ae.map(e=>i.jsx(Re,{stage:e,stageColor:re.stageColor},e.id))}),i.jsx(T.Layer,{listening:!1,children:ce.map(e=>i.jsx(Ie,{text:e},e.id))}),i.jsx(T.Layer,{children:q.map(e=>i.jsx(Fe,{seat:e,state:J(e),colors:re,onClick:Ye,onMouseEnter:qe,onMouseLeave:Ze},e.id))})]}),k&&i.jsx(De,{visible:U.visible,x:U.x,y:U.y,seat:U.seat,currency:re.currency,state:U.state}),ee&&v&&i.jsx(Te,{scale:R,minScale:Z,maxScale:L,fitScale:me,onZoomIn:Ae,onZoomOut:Be,onFitToScreen:fe,position:te,className:ne}),Q.length>0&&i.jsxs("div",{className:"absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg",children:[i.jsxs("h3",{className:"font-semibold mb-2",children:["Selected Seats (",Q.length,")"]}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:Q.map(e=>i.jsxs("div",{className:"text-sm",children:[e.seatNumber,e.price&&` - ${re.currency} ${e.price.toFixed(2)}`]},e.id))})]})]})};Object.defineProperty(exports,"clearFirebaseInstance",{enumerable:!0,get:()=>O.clearFirebaseInstance});Object.defineProperty(exports,"getFirebaseDatabase",{enumerable:!0,get:()=>O.getFirebaseDatabase});Object.defineProperty(exports,"initializeFirebaseForViewer",{enumerable:!0,get:()=>O.initializeFirebaseForViewer});Object.defineProperty(exports,"isFirebaseInitialized",{enumerable:!0,get:()=>O.isFirebaseInitialized});Object.defineProperty(exports,"useFirebaseConfig",{enumerable:!0,get:()=>O.useFirebaseConfig});Object.defineProperty(exports,"useFirebaseSeatStates",{enumerable:!0,get:()=>O.useFirebaseSeatStates});Object.defineProperty(exports,"useRealtimeSeatMap",{enumerable:!0,get:()=>O.useRealtimeSeatMap});exports.DEFAULT_COLORS=ke;exports.SeatMapViewer=et;exports.useConfigFetcher=Ce;exports.useContainerSize=je;exports.useTouchGestures=Me;
|