@zonetrix/viewer 2.10.1 → 2.10.2
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/index.js +1 -1
- package/dist/index.mjs +334 -329
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),t=require("react"),P=require("react-konva"),B=require("firebase/database"),rt=require("@zonetrix/shared");function Re(n){const[s,o]=t.useState(null),[r,h]=t.useState(!1),[d,l]=t.useState(null),v=async()=>{if(n){h(!0),l(null);try{const p=await fetch(n);if(!p.ok)throw new Error(`Failed to fetch config: ${p.statusText}`);const a=await p.json();o(a)}catch(p){const a=p instanceof Error?p:new Error("Unknown error occurred");l(a),console.error("Failed to fetch seat map config:",a)}finally{h(!1)}}};return t.useEffect(()=>{v()},[n]),{config:s,loading:r,error:d,refetch:v}}function je(n){const[s,o]=t.useState({width:0,height:0});return t.useEffect(()=>{const r=n.current;if(!r)return;const{width:h,height:d}=r.getBoundingClientRect();h>0&&d>0&&o({width:h,height:d});const l=new ResizeObserver(v=>{const p=v[0];if(!p)return;const{width:a,height:c}=p.contentRect;a>0&&c>0&&o(f=>f.width===a&&f.height===c?f:{width:a,height:c})});return l.observe(r),()=>{l.disconnect()}},[n]),s}function we(n,s){return Math.sqrt(Math.pow(s.x-n.x,2)+Math.pow(s.y-n.y,2))}function Ce(n,s){return{x:(n.x+s.x)/2,y:(n.y+s.y)/2}}function Me(n,s){const o=t.useRef(null),r=t.useRef(null),h=t.useRef(1);t.useEffect(()=>{const d=n.current;if(!d||!s.enabled)return;const l=d.container(),v=c=>{if(c.touches.length===2){c.preventDefault();const f={x:c.touches[0].clientX,y:c.touches[0].clientY},g={x:c.touches[1].clientX,y:c.touches[1].clientY};o.current=we(f,g),r.current=Ce(f,g),h.current=s.currentScale}},p=c=>{if(c.touches.length!==2)return;c.preventDefault();const f={x:c.touches[0].clientX,y:c.touches[0].clientY},g={x:c.touches[1].clientX,y:c.touches[1].clientY},m=we(f,g),w=Ce(f,g);if(o.current!==null&&r.current!==null){const R=m/o.current,E=Math.min(Math.max(s.currentScale*R,s.minScale),s.maxScale),F=l.getBoundingClientRect(),j=w.x-F.left,I=w.y-F.top,L=s.currentScale,T={x:(j-s.currentPosition.x)/L,y:(I-s.currentPosition.y)/L},V=w.x-r.current.x,W=w.y-r.current.y,q={x:j-T.x*E+V,y:I-T.y*E+W};s.onScaleChange(E,q),o.current=m,r.current=w}},a=c=>{c.touches.length<2&&(o.current=null,r.current=null)};return l.addEventListener("touchstart",v,{passive:!1}),l.addEventListener("touchmove",p,{passive:!1}),l.addEventListener("touchend",a),()=>{l.removeEventListener("touchstart",v),l.removeEventListener("touchmove",p),l.removeEventListener("touchend",a)}},[n,s])}const Ee={canvasBackground:"#1a1a1a",stageColor:"#808080",seatAvailable:"#2C2B30",seatReserved:"#FCEA00",seatSelected:"#3A7DE5",seatUnavailable:"#6b7280",seatHidden:"#4a4a4a",gridLines:"#404040",currency:"KD"},Fe=t.memo(({seat:n,state:s,colors:o,onClick:r,onMouseEnter:h,onMouseLeave:d})=>{const p={available:o.seatAvailable,reserved:o.seatReserved,selected:o.seatSelected,unavailable:o.seatUnavailable,hidden:o.seatHidden}[s],a=s==="available"||s==="selected",c=t.useCallback(()=>{a&&r(n)},[n,r,a]),f=t.useCallback(w=>{h(n,w);const R=w.target.getStage();R&&a&&(R.container().style.cursor="pointer")},[n,h,a]),g=t.useCallback(w=>{d();const R=w.target.getStage();R&&(R.container().style.cursor="grab")},[d]),m={x:n.position.x,y:n.position.y,fill:p,stroke:"#ffffff",strokeWidth:1,onClick:c,onTap:c,onMouseEnter:f,onMouseLeave:g};return n.shape==="circle"?i.jsx(P.Circle,{...m,radius:12}):i.jsx(P.Rect,{...m,width:24,height:24,offsetX:12,offsetY:12,cornerRadius:n.shape==="square"?0:4})});Fe.displayName="ViewerSeat";const ke=t.memo(({stage:n,stageColor:s})=>{const o=d=>({stage:"🎭",table:"⬜",wall:"▬",barrier:"🛡️","dj-booth":"🎵",bar:"🍷","entry-exit":"🚪",custom:"➕"})[d||"stage"]||"🎭",r=n.config.color||s,h=o(n.config.objectType);return i.jsxs(P.Group,{x:n.position.x,y:n.position.y,rotation:n.config.rotation||0,children:[i.jsx(P.Rect,{width:n.config.width,height:n.config.height,fill:r+"80",stroke:"#ffffff",strokeWidth:2,cornerRadius:10}),i.jsx(P.Text,{text:h,x:0,y:0,width:n.config.width,height:n.config.height*.4,fontSize:32,fill:"#ffffff",align:"center",verticalAlign:"middle"}),i.jsx(P.Text,{text:n.config.label,x:0,y:n.config.height*.4,width:n.config.width,height:n.config.height*.6,fontSize:20,fontStyle:"bold",fill:"#ffffff",align:"center",verticalAlign:"middle"})]})});ke.displayName="ViewerStage";const Ie=t.memo(({floors:n,currentFloorId:s,onFloorChange:o,showAllOption:r,allLabel:h,position:d,className:l})=>{const v=t.useMemo(()=>[...n].sort((g,m)=>g.order-m.order),[n]),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}}[d]},c={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"},f={...c,backgroundColor:"#3A7DE5",borderColor:"#3A7DE5"};return i.jsxs("div",{className:l,style:a,children:[r&&i.jsx("button",{type:"button",onClick:()=>o(null),style:s===null?f:c,children:h}),v.map(g=>i.jsx("button",{type:"button",onClick:()=>o(g.id),style:s===g.id?f:c,children:g.name},g.id))]})});Ie.displayName="FloorSelectorBar";const Le=t.memo(({scale:n,minScale:s,maxScale:o,onZoomIn:r,onZoomOut:h,position:d,className:l})=>{const p={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}}[d]},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"},c={...a,opacity:.4,cursor:"not-allowed"},f=n<o,g=n>s;return i.jsxs("div",{className:l,style:p,children:[i.jsx("button",{type:"button",onClick:r,disabled:!f,style:f?a:c,title:"Zoom In",children:"+"}),i.jsx("button",{type:"button",onClick:h,disabled:!g,style:g?a:c,title:"Zoom Out",children:"−"})]})});Le.displayName="ZoomControls";const De=t.memo(({visible:n,x:s,y:o,seat:r,currency:h,state:d})=>{if(!n||!r)return null;const l=r.seatNumber||(r.rowLabel&&r.columnLabel?`${r.rowLabel}-${r.columnLabel}`:"N/A"),v={position:"fixed",left:`${s+15}px`,top:`${o+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"},a={color:"#9ca3af",marginRight:"4px"},c={fontWeight:600},f={color:"#4ade80",fontWeight:600},g={fontSize:"11px",color:"#6b7280",textTransform:"capitalize",marginTop:"4px"};return i.jsx("div",{style:v,children:i.jsxs("div",{style:p,children:[r.sectionName&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:a,children:"Section:"}),i.jsx("span",{style:{...c,color:"#3b82f6"},children:r.sectionName})]}),i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:a,children:"Seat:"}),i.jsx("span",{style:c,children:l})]}),r.price!==void 0&&r.price>0&&d==="available"&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:a,children:"Price:"}),i.jsxs("span",{style:f,children:[h," ",r.price.toFixed(2)]})]}),i.jsxs("div",{style:g,children:["Status: ",d]})]})})});De.displayName="SeatTooltip";const ot=({config:n,configUrl:s,floorId:o,onFloorChange:r,reservedSeats:h=[],unavailableSeats:d=[],selectedSeats:l,myReservedSeats:v=[],onSeatSelect:p,onSeatDeselect:a,onSelectionChange:c,colorOverrides:f,showTooltip:g=!0,zoomEnabled:m=!0,className:w="",onConfigLoad:R,onError:E,showFloorSelector:F,floorSelectorPosition:j="top-left",floorSelectorClassName:I,showAllFloorsOption:L=!0,allFloorsLabel:T="All",fitToView:V=!0,fitPadding:W=40,showZoomControls:q=!0,zoomControlsPosition:fe="bottom-right",zoomControlsClassName:se,minZoom:re,maxZoom:z=3,zoomStep:A=.25,touchEnabled:ve=!0})=>{const X=t.useRef(null),O=t.useRef(null),M=je(O),[Y,he]=t.useState(new Set),[k,J]=t.useState(1),[D,U]=t.useState({x:0,y:0}),[Ne,Ae]=t.useState(null),[Xe,Ye]=t.useState(1),oe=t.useRef({width:0,height:0}),[K,me]=t.useState({visible:!1,x:0,y:0,seat:null,state:"available"}),{config:Pe,loading:We,error:Z}=Re(s),b=n||Pe,ge=o!==void 0,N=ge?o||null:Ne,ie=l!==void 0,Oe=t.useCallback(e=>{ge||Ae(e),r?.(e)},[ge,r]),pe=b?.floors||[],$e=F!==void 0?F:pe.length>1,ae=t.useMemo(()=>b?{...b.colors,...f}:{...Ee,...f},[b,f]),_=t.useMemo(()=>{if(!b)return[];let e=b.seats.filter(u=>u.state!=="hidden");return N&&(e=e.filter(u=>u.floorId===N||!u.floorId&&N==="floor_default")),e},[b,N]),ce=t.useMemo(()=>b?.stages?N?b.stages.filter(e=>e.floorId===N||!e.floorId&&N==="floor_default"):b.stages:[],[b,N]),$=t.useMemo(()=>{if(!b||_.length===0&&ce.length===0)return null;const e=12;let u=1/0,x=1/0,y=-1/0,S=-1/0;return _.forEach(C=>{u=Math.min(u,C.position.x-e),x=Math.min(x,C.position.y-e),y=Math.max(y,C.position.x+e),S=Math.max(S,C.position.y+e)}),ce.forEach(C=>{u=Math.min(u,C.position.x),x=Math.min(x,C.position.y),y=Math.max(y,C.position.x+(C.config?.width||200)),S=Math.max(S,C.position.y+(C.config?.height||100))}),{minX:u,minY:x,maxX:y,maxY:S,width:y-u,height:S-x}},[b,_,ce]);t.useEffect(()=>{if(!V||!b||!$||M.width===0||M.height===0)return;const e=Math.abs(M.width-oe.current.width),u=Math.abs(M.height-oe.current.height);if(!(oe.current.width===0)&&e<10&&u<10)return;oe.current=M;const y=M.width,S=M.height,C=y-W*2,te=S-W*2,le=C/$.width,xe=te/$.height,ue=Math.min(le,xe,z),Ze=$.minX+$.width/2,Qe=$.minY+$.height/2,et=y/2,tt=S/2,nt=et-Ze*ue,st=tt-Qe*ue;J(ue),U({x:nt,y:st}),Ye(ue)},[V,b,$,W,z,M,N]);const H=t.useMemo(()=>{const e=new Set(h),u=new Set(d),x=new Set(v);return{reserved:e,unavailable:u,myReserved:x}},[h,d,v]),be=t.useMemo(()=>l?new Set(l):null,[l]),Q=t.useCallback(e=>{const u=e.id,x=e.seatNumber||"";return H.unavailable.has(u)||H.unavailable.has(x)?"unavailable":H.reserved.has(u)||H.reserved.has(x)?"reserved":H.myReserved.has(u)||H.myReserved.has(x)||Y.has(u)?"selected":e.state},[H,Y]);t.useEffect(()=>{b&&R&&R(b)},[b,R]),t.useEffect(()=>{Z&&E&&E(Z)},[Z,E]),t.useEffect(()=>{ie&&be&&he(be)},[ie,be]);const Be=t.useCallback(e=>{const u=Q(e);if(u!=="available"&&u!=="selected")return;const x=Y.has(e.id);ie||he(y=>{const S=new Set(y);return x?S.delete(e.id):S.add(e.id),S}),x?a?.(e):(p?.(e),p||console.log("Seat selected:",e))},[Q,Y,ie,p,a]),ee=t.useMemo(()=>b?_.filter(e=>Y.has(e.id)):[],[_,Y]);t.useEffect(()=>{c?.(ee)},[ee,c]);const G=re!==void 0?re:Xe,Ve=t.useCallback(()=>{if(!m)return;const e=Math.min(k+A,z);if(e!==k){const u=M.width||b?.canvas.width||800,x=M.height||b?.canvas.height||600,y=u/2,S=x/2,C={x:(y-D.x)/k,y:(S-D.y)/k};J(e),U({x:y-C.x*e,y:S-C.y*e})}},[m,k,A,z,M,b,D]),Ue=t.useCallback(()=>{if(!m)return;const e=Math.max(k-A,G);if(e!==k){const u=M.width||b?.canvas.width||800,x=M.height||b?.canvas.height||600,y=u/2,S=x/2,C={x:(y-D.x)/k,y:(S-D.y)/k};J(e),U({x:y-C.x*e,y:S-C.y*e})}},[m,k,A,G,M,b,D]),He=t.useCallback(e=>{U({x:e.target.x(),y:e.target.y()})},[]),qe=t.useCallback(e=>{if(!m)return;e.evt.preventDefault();const u=X.current;if(!u)return;const x=u.scaleX(),y=u.getPointerPosition();if(!y)return;const S=1.1,C=e.evt.deltaY>0?x/S:x*S,te=Math.min(Math.max(C,G),z),le={x:(y.x-D.x)/x,y:(y.y-D.y)/x},xe={x:y.x-le.x*te,y:y.y-le.y*te};J(te),U(xe)},[m,D,G,z]);Me(X,{enabled:ve&&m,minScale:G,maxScale:z,currentScale:k,currentPosition:D,onScaleChange:(e,u)=>{J(e),U(u)},onPositionChange:e=>{U(e)}});const _e=t.useCallback((e,u)=>{if(!g)return;const x=u.target.getStage();if(!x)return;const y=x.getPointerPosition();if(!y)return;const S=x.container().getBoundingClientRect();me({visible:!0,x:S.left+y.x,y:S.top+y.y,seat:e,state:Q(e)})},[g,Q]),Ge=t.useCallback(()=>{me(e=>({...e,visible:!1}))},[]);if(We)return i.jsx("div",{className:`flex items-center justify-center h-full ${w}`,children:i.jsx("p",{children:"Loading seat map..."})});if(Z)return i.jsx("div",{className:`flex items-center justify-center h-full ${w}`,children:i.jsxs("p",{className:"text-red-500",children:["Error loading seat map: ",Z.message]})});if(!b)return i.jsx("div",{className:`flex items-center justify-center h-full ${w}`,children:i.jsx("p",{children:"No configuration provided"})});const Je=M.width||b.canvas.width,Ke=M.height||b.canvas.height;return i.jsxs("div",{ref:O,className:`relative ${w}`,style:{width:"100%",height:"100%"},children:[$e&&pe.length>0&&i.jsx(Ie,{floors:pe,currentFloorId:N,onFloorChange:Oe,showAllOption:L,allLabel:T,position:j,className:I}),i.jsxs(P.Stage,{ref:X,width:Je,height:Ke,scaleX:k,scaleY:k,x:D.x,y:D.y,draggable:!0,onDragEnd:He,onWheel:qe,style:{backgroundColor:b.canvas.backgroundColor,cursor:"grab"},children:[i.jsx(P.Layer,{listening:!1,children:ce.map(e=>i.jsx(ke,{stage:e,stageColor:ae.stageColor},e.id))}),i.jsx(P.Layer,{children:_.map(e=>i.jsx(Fe,{seat:e,state:Q(e),colors:ae,onClick:Be,onMouseEnter:_e,onMouseLeave:Ge},e.id))})]}),g&&i.jsx(De,{visible:K.visible,x:K.x,y:K.y,seat:K.seat,currency:ae.currency,state:K.state}),q&&m&&i.jsx(Le,{scale:k,minScale:G,maxScale:z,onZoomIn:Ve,onZoomOut:Ue,position:fe,className:se}),ee.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 (",ee.length,")"]}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:ee.map(e=>i.jsxs("div",{className:"text-sm",children:[e.seatNumber,e.price&&` - ${ae.currency} ${e.price.toFixed(2)}`]},e.id))})]})]})};let ne=null;function it(n){ne=n}function Se(){if(!ne)throw new Error("Firebase database not initialized. Call initializeFirebaseForViewer(db) first.");return ne}function de(){return ne!==null}function at(){ne=null}function ye(n,s){if(n.length!==s.length)return!1;for(let o=0;o<n.length;o++)if(n[o]!==s[o])return!1;return!0}function ct(n,s){return ye(n.myReserved,s.myReserved)&&ye(n.otherReserved,s.otherReserved)&&ye(n.unavailable,s.unavailable)}function lt(n,s){const o=[],r=[],h=[];return Object.entries(n).forEach(([d,l])=>{l&&typeof l=="object"&&l.state&&(l.state==="unavailable"?h.push(d):l.state==="reserved"&&(s&&l.userId===s?o.push(d):r.push(d)))}),{myReserved:o,otherReserved:r,unavailable:h}}function Te(n){const{seatMapId:s,currentUserId:o,enabled:r=!0,onStateChange:h,onError:d}=n,[l,v]=t.useState(null),[p,a]=t.useState(!0),[c,f]=t.useState(null),[g,m]=t.useState(null),[w,R]=t.useState([]),[E,F]=t.useState([]),[j,I]=t.useState([]),L=t.useRef(h),T=t.useRef(d),V=t.useRef(o);L.current=h,T.current=d,V.current=o;const W=t.useRef({myReserved:[],otherReserved:[],unavailable:[]}),q=t.useRef(null);return t.useEffect(()=>{if(!r||!s){a(!1);return}if(!de()){a(!1),f(new Error("Firebase not initialized. Call initializeFirebaseForViewer first."));return}const fe=Se(),se=B.ref(fe,`seat_states/${s}`);a(!0),f(null);const re=A=>{const X=A.val()||{},O=lt(X,V.current),M=W.current,Y=JSON.stringify(q.current)!==JSON.stringify(X);Y&&(v(X),q.current=X),a(!1),!ct(M,O)&&(m(Date.now()),R(O.myReserved),F(O.otherReserved),I(O.unavailable),W.current=O),Y&&L.current?.(X)},z=A=>{f(A),a(!1),T.current?.(A)};return B.onValue(se,re,z),()=>{B.off(se)}},[s,r]),{states:l,loading:p,error:c,lastUpdated:g,myReservedSeats:w,otherReservedSeats:E,unavailableSeats:j,reservedSeats:E}}function ze(n){const{seatMapId:s,enabled:o=!0,subscribeToChanges:r=!1,onConfigLoad:h,onError:d}=n,[l,v]=t.useState(null),[p,a]=t.useState(!0),[c,f]=t.useState(null),g=t.useRef(h),m=t.useRef(d);g.current=h,m.current=d;const w=t.useCallback(async()=>{if(!s)return;if(!de()){f(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")),a(!1);return}const R=Se(),E=B.ref(R,`seatmaps/${s}`);try{a(!0),f(null);const j=(await B.get(E)).val();if(j){const I=rt.fromFirebaseSeatMap(j);v(I),g.current?.(I)}else f(new Error(`Seat map ${s} not found in Firebase`))}catch(F){const j=F instanceof Error?F:new Error("Unknown error");f(j),m.current?.(j)}finally{a(!1)}},[s]);return t.useEffect(()=>{if(!o||!s){a(!1);return}if(w(),r&&de()){const R=Se(),E=B.ref(R,`seatmaps/${s}/meta/updated_at`);let F=!0,j=null;const I=L=>{if(F){F=!1,j=L.val();return}const T=L.val();L.exists()&&T!==j&&(j=T,w())};return B.onValue(E,I),()=>{B.off(E)}}},[s,o,r]),{config:l,loading:p,error:c,refetch:w}}function ut(n){const{seatMapId:s,userId:o,enabled:r=!0,subscribeToDesignChanges:h=!1,onConfigLoad:d,onStateChange:l,onError:v}=n,{config:p,loading:a,error:c,refetch:f}=ze({seatMapId:s,enabled:r,subscribeToChanges:h,onConfigLoad:d,onError:v}),{states:g,loading:m,error:w,lastUpdated:R,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:j,reservedSeats:I}=Te({seatMapId:s,currentUserId:o,enabled:r,onStateChange:l,onError:v});return{config:p,loading:a||m,error:c||w,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:j,reservedSeats:I,seatStates:g,lastUpdated:R,refetch:f}}exports.DEFAULT_COLORS=Ee;exports.SeatMapViewer=ot;exports.clearFirebaseInstance=at;exports.initializeFirebaseForViewer=it;exports.isFirebaseInitialized=de;exports.useConfigFetcher=Re;exports.useContainerSize=je;exports.useFirebaseConfig=ze;exports.useFirebaseSeatStates=Te;exports.useRealtimeSeatMap=ut;exports.useTouchGestures=Me;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),e=require("react"),O=require("react-konva"),V=require("firebase/database"),it=require("@zonetrix/shared");function Me(n){const[s,o]=e.useState(null),[r,h]=e.useState(!1),[d,c]=e.useState(null),m=async()=>{if(n){h(!0),c(null);try{const p=await fetch(n);if(!p.ok)throw new Error(`Failed to fetch config: ${p.statusText}`);const a=await p.json();o(a)}catch(p){const a=p instanceof Error?p:new Error("Unknown error occurred");c(a),console.error("Failed to fetch seat map config:",a)}finally{h(!1)}}};return e.useEffect(()=>{m()},[n]),{config:s,loading:r,error:d,refetch:m}}function Ee(n){const[s,o]=e.useState({width:0,height:0});return e.useEffect(()=>{const r=n.current;if(!r)return;const{width:h,height:d}=r.getBoundingClientRect();h>0&&d>0&&o({width:h,height:d});const c=new ResizeObserver(m=>{const p=m[0];if(!p)return;const{width:a,height:l}=p.contentRect;a>0&&l>0&&o(f=>f.width===a&&f.height===l?f:{width:a,height:l})});return c.observe(r),()=>{c.disconnect()}},[n]),s}function we(n,s){return Math.sqrt(Math.pow(s.x-n.x,2)+Math.pow(s.y-n.y,2))}function Ce(n,s){return{x:(n.x+s.x)/2,y:(n.y+s.y)/2}}function Fe(n,s){const o=e.useRef(null),r=e.useRef(null),h=e.useRef(1);e.useEffect(()=>{const d=n.current;if(!d||!s.enabled)return;const c=d.container(),m=l=>{if(l.touches.length===2){l.preventDefault();const f={x:l.touches[0].clientX,y:l.touches[0].clientY},g={x:l.touches[1].clientX,y:l.touches[1].clientY};o.current=we(f,g),r.current=Ce(f,g),h.current=s.currentScale}},p=l=>{if(l.touches.length!==2)return;l.preventDefault();const f={x:l.touches[0].clientX,y:l.touches[0].clientY},g={x:l.touches[1].clientX,y:l.touches[1].clientY},v=we(f,g),w=Ce(f,g);if(o.current!==null&&r.current!==null){const R=v/o.current,E=Math.min(Math.max(s.currentScale*R,s.minScale),s.maxScale),F=c.getBoundingClientRect(),j=w.x-F.left,k=w.y-F.top,D=s.currentScale,T={x:(j-s.currentPosition.x)/D,y:(k-s.currentPosition.y)/D},U=w.x-r.current.x,z=w.y-r.current.y,_={x:j-T.x*E+U,y:k-T.y*E+z};s.onScaleChange(E,_),o.current=v,r.current=w}},a=l=>{l.touches.length<2&&(o.current=null,r.current=null)};return c.addEventListener("touchstart",m,{passive:!1}),c.addEventListener("touchmove",p,{passive:!1}),c.addEventListener("touchend",a),()=>{c.removeEventListener("touchstart",m),c.removeEventListener("touchmove",p),c.removeEventListener("touchend",a)}},[n,s])}const ke={canvasBackground:"#1a1a1a",stageColor:"#808080",seatAvailable:"#2C2B30",seatReserved:"#FCEA00",seatSelected:"#3A7DE5",seatUnavailable:"#6b7280",seatHidden:"#4a4a4a",gridLines:"#404040",currency:"KD"},Ie=e.memo(({seat:n,state:s,colors:o,onClick:r,onMouseEnter:h,onMouseLeave:d})=>{const p={available:o.seatAvailable,reserved:o.seatReserved,selected:o.seatSelected,unavailable:o.seatUnavailable,hidden:o.seatHidden}[s],a=s==="available"||s==="selected",l=e.useCallback(()=>{a&&r(n)},[n,r,a]),f=e.useCallback(w=>{h(n,w);const R=w.target.getStage();R&&a&&(R.container().style.cursor="pointer")},[n,h,a]),g=e.useCallback(w=>{d();const R=w.target.getStage();R&&(R.container().style.cursor="grab")},[d]),v={x:n.position.x,y:n.position.y,fill:p,stroke:"#ffffff",strokeWidth:1,onClick:l,onTap:l,onMouseEnter:f,onMouseLeave:g};return n.shape==="circle"?i.jsx(O.Circle,{...v,radius:12}):i.jsx(O.Rect,{...v,width:24,height:24,offsetX:12,offsetY:12,cornerRadius:n.shape==="square"?0:4})});Ie.displayName="ViewerSeat";const De=e.memo(({stage:n,stageColor:s})=>{const o=d=>({stage:"🎭",table:"⬜",wall:"▬",barrier:"🛡️","dj-booth":"🎵",bar:"🍷","entry-exit":"🚪",custom:"➕"})[d||"stage"]||"🎭",r=n.config.color||s,h=o(n.config.objectType);return i.jsxs(O.Group,{x:n.position.x,y:n.position.y,rotation:n.config.rotation||0,children:[i.jsx(O.Rect,{width:n.config.width,height:n.config.height,fill:r+"80",stroke:"#ffffff",strokeWidth:2,cornerRadius:10}),i.jsx(O.Text,{text:h,x:0,y:0,width:n.config.width,height:n.config.height*.4,fontSize:32,fill:"#ffffff",align:"center",verticalAlign:"middle"}),i.jsx(O.Text,{text:n.config.label,x:0,y:n.config.height*.4,width:n.config.width,height:n.config.height*.6,fontSize:20,fontStyle:"bold",fill:"#ffffff",align:"center",verticalAlign:"middle"})]})});De.displayName="ViewerStage";const Le=e.memo(({floors:n,currentFloorId:s,onFloorChange:o,showAllOption:r,allLabel:h,position:d,className:c})=>{const m=e.useMemo(()=>[...n].sort((g,v)=>g.order-v.order),[n]),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}}[d]},l={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"},f={...l,backgroundColor:"#3A7DE5",borderColor:"#3A7DE5"};return i.jsxs("div",{className:c,style:a,children:[r&&i.jsx("button",{type:"button",onClick:()=>o(null),style:s===null?f:l,children:h}),m.map(g=>i.jsx("button",{type:"button",onClick:()=>o(g.id),style:s===g.id?f:l,children:g.name},g.id))]})});Le.displayName="FloorSelectorBar";const Te=e.memo(({scale:n,minScale:s,maxScale:o,onZoomIn:r,onZoomOut:h,position:d,className:c})=>{const p={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}}[d]},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"},l={...a,opacity:.4,cursor:"not-allowed"},f=n<o,g=n>s;return i.jsxs("div",{className:c,style:p,children:[i.jsx("button",{type:"button",onClick:r,disabled:!f,style:f?a:l,title:"Zoom In",children:"+"}),i.jsx("button",{type:"button",onClick:h,disabled:!g,style:g?a:l,title:"Zoom Out",children:"−"})]})});Te.displayName="ZoomControls";const ze=e.memo(({visible:n,x:s,y:o,seat:r,currency:h,state:d})=>{if(!n||!r)return null;const c=r.seatNumber||(r.rowLabel&&r.columnLabel?`${r.rowLabel}-${r.columnLabel}`:"N/A"),m={position:"fixed",left:`${s+15}px`,top:`${o+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"},a={color:"#9ca3af",marginRight:"4px"},l={fontWeight:600},f={color:"#4ade80",fontWeight:600},g={fontSize:"11px",color:"#6b7280",textTransform:"capitalize",marginTop:"4px"};return i.jsx("div",{style:m,children:i.jsxs("div",{style:p,children:[r.sectionName&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:a,children:"Section:"}),i.jsx("span",{style:{...l,color:"#3b82f6"},children:r.sectionName})]}),i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:a,children:"Seat:"}),i.jsx("span",{style:l,children:c})]}),r.price!==void 0&&r.price>0&&d==="available"&&i.jsxs("div",{style:{marginBottom:"4px"},children:[i.jsx("span",{style:a,children:"Price:"}),i.jsxs("span",{style:f,children:[h," ",r.price.toFixed(2)]})]}),i.jsxs("div",{style:g,children:["Status: ",d]})]})})});ze.displayName="SeatTooltip";const at=({config:n,configUrl:s,floorId:o,onFloorChange:r,reservedSeats:h=[],unavailableSeats:d=[],selectedSeats:c,myReservedSeats:m=[],onSeatSelect:p,onSeatDeselect:a,onSelectionChange:l,colorOverrides:f,showTooltip:g=!0,zoomEnabled:v=!0,className:w="",onConfigLoad:R,onError:E,showFloorSelector:F,floorSelectorPosition:j="top-left",floorSelectorClassName:k,showAllFloorsOption:D=!0,allFloorsLabel:T="All",fitToView:U=!0,fitPadding:z=40,showZoomControls:_=!0,zoomControlsPosition:X="bottom-right",zoomControlsClassName:G,minZoom:Z,maxZoom:N=3,zoomStep:Y=.25,touchEnabled:ve=!0})=>{const P=e.useRef(null),$=e.useRef(null),M=Ee($),[W,he]=e.useState(new Set),[I,Q]=e.useState(1),[L,H]=e.useState({x:0,y:0}),[Xe,Ye]=e.useState(null),[Pe,We]=e.useState(1),ie=e.useRef({width:0,height:0}),[ee,me]=e.useState({visible:!1,x:0,y:0,seat:null,state:"available"}),{config:Oe,loading:$e,error:te}=Me(s),b=n||Oe,ge=o!==void 0,A=ge?o||null:Xe,ae=c!==void 0,Be=e.useCallback(t=>{ge||Ye(t),r?.(t)},[ge,r]),pe=b?.floors||[],Ve=F!==void 0?F:pe.length>1,ce=e.useMemo(()=>b?{...b.colors,...f}:{...ke,...f},[b,f]),J=e.useMemo(()=>{if(!b)return[];let t=b.seats.filter(u=>u.state!=="hidden");return A&&(t=t.filter(u=>u.floorId===A||!u.floorId&&A==="floor_default")),t},[b,A]),le=e.useMemo(()=>b?.stages?A?b.stages.filter(t=>t.floorId===A||!t.floorId&&A==="floor_default"):b.stages:[],[b,A]),B=e.useMemo(()=>{if(!b||J.length===0&&le.length===0)return null;const t=12;let u=1/0,x=1/0,y=-1/0,S=-1/0;return J.forEach(C=>{u=Math.min(u,C.position.x-t),x=Math.min(x,C.position.y-t),y=Math.max(y,C.position.x+t),S=Math.max(S,C.position.y+t)}),le.forEach(C=>{u=Math.min(u,C.position.x),x=Math.min(x,C.position.y),y=Math.max(y,C.position.x+(C.config?.width||200)),S=Math.max(S,C.position.y+(C.config?.height||100))}),{minX:u,minY:x,maxX:y,maxY:S,width:y-u,height:S-x}},[b,J,le]);e.useEffect(()=>{if(!U||!b||!B||M.width===0||M.height===0)return;const t=Math.abs(M.width-ie.current.width),u=Math.abs(M.height-ie.current.height);if(!(ie.current.width===0)&&t<10&&u<10)return;ie.current=M;const y=M.width,S=M.height,C=y-z*2,re=S-z*2,ue=C/B.width,xe=re/B.height,de=Math.min(ue,xe,N),et=B.minX+B.width/2,tt=B.minY+B.height/2,nt=y/2,st=S/2,rt=nt-et*de,ot=st-tt*de;Q(de),H({x:rt,y:ot}),We(de)},[U,b,B,z,N,M,A]);const q=e.useMemo(()=>{const t=new Set(h),u=new Set(d),x=new Set(m);return{reserved:t,unavailable:u,myReserved:x}},[h,d,m]),be=e.useMemo(()=>c?new Set(c):null,[c]),ne=e.useCallback(t=>{const u=t.id,x=t.seatNumber||"";return q.unavailable.has(u)||q.unavailable.has(x)?"unavailable":q.reserved.has(u)||q.reserved.has(x)?"reserved":q.myReserved.has(u)||q.myReserved.has(x)||W.has(u)?"selected":t.state},[q,W]);e.useEffect(()=>{b&&R&&R(b)},[b,R]),e.useEffect(()=>{te&&E&&E(te)},[te,E]),e.useEffect(()=>{ae&&be&&he(be)},[ae,be]);const Ue=e.useCallback(t=>{const u=ne(t);if(u!=="available"&&u!=="selected")return;const x=W.has(t.id);ae||he(y=>{const S=new Set(y);return x?S.delete(t.id):S.add(t.id),S}),x?a?.(t):(p?.(t),p||console.log("Seat selected:",t))},[ne,W,ae,p,a]),se=e.useMemo(()=>b?J.filter(t=>W.has(t.id)):[],[J,W]);e.useEffect(()=>{l?.(se)},[se,l]);const K=Z!==void 0?Z:Pe,He=e.useCallback(()=>{if(!v)return;const t=Math.min(I+Y,N);if(t!==I){const u=M.width||b?.canvas.width||800,x=M.height||b?.canvas.height||600,y=u/2,S=x/2,C={x:(y-L.x)/I,y:(S-L.y)/I};Q(t),H({x:y-C.x*t,y:S-C.y*t})}},[v,I,Y,N,M,b,L]),qe=e.useCallback(()=>{if(!v)return;const t=Math.max(I-Y,K);if(t!==I){const u=M.width||b?.canvas.width||800,x=M.height||b?.canvas.height||600,y=u/2,S=x/2,C={x:(y-L.x)/I,y:(S-L.y)/I};Q(t),H({x:y-C.x*t,y:S-C.y*t})}},[v,I,Y,K,M,b,L]),_e=e.useCallback(t=>{H({x:t.target.x(),y:t.target.y()})},[]),Ge=e.useCallback(t=>{if(!v)return;t.evt.preventDefault();const u=P.current;if(!u)return;const x=u.scaleX(),y=u.getPointerPosition();if(!y)return;const S=1.1,C=t.evt.deltaY>0?x/S:x*S,re=Math.min(Math.max(C,K),N),ue={x:(y.x-L.x)/x,y:(y.y-L.y)/x},xe={x:y.x-ue.x*re,y:y.y-ue.y*re};Q(re),H(xe)},[v,L,K,N]);Fe(P,{enabled:ve&&v,minScale:K,maxScale:N,currentScale:I,currentPosition:L,onScaleChange:(t,u)=>{Q(t),H(u)},onPositionChange:t=>{H(t)}});const Je=e.useCallback((t,u)=>{if(!g)return;const x=u.target.getStage();if(!x)return;const y=x.getPointerPosition();if(!y)return;const S=x.container().getBoundingClientRect();me({visible:!0,x:S.left+y.x,y:S.top+y.y,seat:t,state:ne(t)})},[g,ne]),Ke=e.useCallback(()=>{me(t=>({...t,visible:!1}))},[]);if($e)return i.jsx("div",{className:`flex items-center justify-center h-full ${w}`,children:i.jsx("p",{children:"Loading seat map..."})});if(te)return i.jsx("div",{className:`flex items-center justify-center h-full ${w}`,children:i.jsxs("p",{className:"text-red-500",children:["Error loading seat map: ",te.message]})});if(!b)return i.jsx("div",{className:`flex items-center justify-center h-full ${w}`,children:i.jsx("p",{children:"No configuration provided"})});const Ze=M.width||b.canvas.width,Qe=M.height||b.canvas.height;return i.jsxs("div",{ref:$,className:`relative ${w}`,style:{width:"100%",height:"100%"},children:[Ve&&pe.length>0&&i.jsx(Le,{floors:pe,currentFloorId:A,onFloorChange:Be,showAllOption:D,allLabel:T,position:j,className:k}),i.jsxs(O.Stage,{ref:P,width:Ze,height:Qe,scaleX:I,scaleY:I,x:L.x,y:L.y,draggable:!0,onDragEnd:_e,onWheel:Ge,style:{backgroundColor:b.canvas.backgroundColor,cursor:"grab"},children:[i.jsx(O.Layer,{listening:!1,children:le.map(t=>i.jsx(De,{stage:t,stageColor:ce.stageColor},t.id))}),i.jsx(O.Layer,{children:J.map(t=>i.jsx(Ie,{seat:t,state:ne(t),colors:ce,onClick:Ue,onMouseEnter:Je,onMouseLeave:Ke},t.id))})]}),g&&i.jsx(ze,{visible:ee.visible,x:ee.x,y:ee.y,seat:ee.seat,currency:ce.currency,state:ee.state}),_&&v&&i.jsx(Te,{scale:I,minScale:K,maxScale:N,onZoomIn:He,onZoomOut:qe,position:X,className:G}),se.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 (",se.length,")"]}),i.jsx("div",{className:"max-h-48 overflow-y-auto space-y-1",children:se.map(t=>i.jsxs("div",{className:"text-sm",children:[t.seatNumber,t.price&&` - ${ce.currency} ${t.price.toFixed(2)}`]},t.id))})]})]})};let oe=null;function ct(n){oe=n}function Se(){if(!oe)throw new Error("Firebase database not initialized. Call initializeFirebaseForViewer(db) first.");return oe}function fe(){return oe!==null}function lt(){oe=null}function ye(n,s){if(n.length!==s.length)return!1;for(let o=0;o<n.length;o++)if(n[o]!==s[o])return!1;return!0}function Re(n,s){return ye(n.myReserved,s.myReserved)&&ye(n.otherReserved,s.otherReserved)&&ye(n.unavailable,s.unavailable)}function je(n,s){const o=[],r=[],h=[];return Object.entries(n).forEach(([d,c])=>{c&&typeof c=="object"&&c.state&&(c.state==="unavailable"?h.push(d):c.state==="reserved"&&(s&&c.userId===s?o.push(d):r.push(d)))}),{myReserved:o,otherReserved:r,unavailable:h}}function Ne(n){const{seatMapId:s,currentUserId:o,enabled:r=!0,onStateChange:h,onError:d}=n,[c,m]=e.useState(null),[p,a]=e.useState(!0),[l,f]=e.useState(null),[g,v]=e.useState(null),[w,R]=e.useState([]),[E,F]=e.useState([]),[j,k]=e.useState([]),D=e.useRef(h),T=e.useRef(d),U=e.useRef(o);D.current=h,T.current=d,U.current=o;const z=e.useRef({myReserved:[],otherReserved:[],unavailable:[]}),_=e.useRef(null);return e.useEffect(()=>{if(!r||!s){a(!1);return}if(!fe()){a(!1),f(new Error("Firebase not initialized. Call initializeFirebaseForViewer first."));return}const X=Se(),G=V.ref(X,`seat_states/${s}`);a(!0),f(null);const Z=Y=>{const P=Y.val()||{},$=je(P,U.current),M=z.current,W=JSON.stringify(_.current)!==JSON.stringify(P);W&&(m(P),_.current=P),a(!1),!Re(M,$)&&(v(Date.now()),R($.myReserved),F($.otherReserved),k($.unavailable),z.current=$),W&&D.current?.(P)},N=Y=>{f(Y),a(!1),T.current?.(Y)};return V.onValue(G,Z,N),()=>{V.off(G)}},[s,r]),e.useEffect(()=>{if(c){const X=je(c,o),G=z.current;!Re(G,X)&&(R(X.myReserved),F(X.otherReserved),k(X.unavailable),z.current=X,v(Date.now()))}},[o]),{states:c,loading:p,error:l,lastUpdated:g,myReservedSeats:w,otherReservedSeats:E,unavailableSeats:j,reservedSeats:E}}function Ae(n){const{seatMapId:s,enabled:o=!0,subscribeToChanges:r=!1,onConfigLoad:h,onError:d}=n,[c,m]=e.useState(null),[p,a]=e.useState(!0),[l,f]=e.useState(null),g=e.useRef(h),v=e.useRef(d);g.current=h,v.current=d;const w=e.useCallback(async()=>{if(!s)return;if(!fe()){f(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")),a(!1);return}const R=Se(),E=V.ref(R,`seatmaps/${s}`);try{a(!0),f(null);const j=(await V.get(E)).val();if(j){const k=it.fromFirebaseSeatMap(j);m(k),g.current?.(k)}else f(new Error(`Seat map ${s} not found in Firebase`))}catch(F){const j=F instanceof Error?F:new Error("Unknown error");f(j),v.current?.(j)}finally{a(!1)}},[s]);return e.useEffect(()=>{if(!o||!s){a(!1);return}if(w(),r&&fe()){const R=Se(),E=V.ref(R,`seatmaps/${s}/meta/updated_at`);let F=!0,j=null;const k=D=>{if(F){F=!1,j=D.val();return}const T=D.val();D.exists()&&T!==j&&(j=T,w())};return V.onValue(E,k),()=>{V.off(E)}}},[s,o,r]),{config:c,loading:p,error:l,refetch:w}}function ut(n){const{seatMapId:s,userId:o,enabled:r=!0,subscribeToDesignChanges:h=!1,onConfigLoad:d,onStateChange:c,onError:m}=n,{config:p,loading:a,error:l,refetch:f}=Ae({seatMapId:s,enabled:r,subscribeToChanges:h,onConfigLoad:d,onError:m}),{states:g,loading:v,error:w,lastUpdated:R,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:j,reservedSeats:k}=Ne({seatMapId:s,currentUserId:o,enabled:r,onStateChange:c,onError:m});return{config:p,loading:a||v,error:l||w,myReservedSeats:E,otherReservedSeats:F,unavailableSeats:j,reservedSeats:k,seatStates:g,lastUpdated:R,refetch:f}}exports.DEFAULT_COLORS=ke;exports.SeatMapViewer=at;exports.clearFirebaseInstance=lt;exports.initializeFirebaseForViewer=ct;exports.isFirebaseInitialized=fe;exports.useConfigFetcher=Me;exports.useContainerSize=Ee;exports.useFirebaseConfig=Ae;exports.useFirebaseSeatStates=Ne;exports.useRealtimeSeatMap=ut;exports.useTouchGestures=Fe;
|
package/dist/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as y, jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { Stage as
|
|
4
|
-
import { ref as we, onValue as
|
|
5
|
-
import { fromFirebaseSeatMap as
|
|
6
|
-
function
|
|
7
|
-
const [n, o] =
|
|
1
|
+
import { jsx as y, jsxs as D } from "react/jsx-runtime";
|
|
2
|
+
import { useState as R, useEffect as Y, useRef as T, useCallback as N, useMemo as _, memo as ce } from "react";
|
|
3
|
+
import { Stage as dt, Layer as Fe, Group as ut, Rect as Te, Text as Ie, Circle as ht } from "react-konva";
|
|
4
|
+
import { ref as we, onValue as ze, off as Ae, get as ft } from "firebase/database";
|
|
5
|
+
import { fromFirebaseSeatMap as gt } from "@zonetrix/shared";
|
|
6
|
+
function pt(t) {
|
|
7
|
+
const [n, o] = R(null), [r, u] = R(!1), [l, s] = R(null), x = async () => {
|
|
8
8
|
if (t) {
|
|
9
|
-
|
|
9
|
+
u(!0), s(null);
|
|
10
10
|
try {
|
|
11
11
|
const f = await fetch(t);
|
|
12
12
|
if (!f.ok)
|
|
@@ -15,85 +15,85 @@ function ft(t) {
|
|
|
15
15
|
o(i);
|
|
16
16
|
} catch (f) {
|
|
17
17
|
const i = f instanceof Error ? f : new Error("Unknown error occurred");
|
|
18
|
-
|
|
18
|
+
s(i), console.error("Failed to fetch seat map config:", i);
|
|
19
19
|
} finally {
|
|
20
|
-
|
|
20
|
+
u(!1);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
return
|
|
25
|
-
|
|
24
|
+
return Y(() => {
|
|
25
|
+
x();
|
|
26
26
|
}, [t]), {
|
|
27
27
|
config: n,
|
|
28
28
|
loading: r,
|
|
29
29
|
error: l,
|
|
30
|
-
refetch:
|
|
30
|
+
refetch: x
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const [n, o] =
|
|
35
|
-
return
|
|
33
|
+
function yt(t) {
|
|
34
|
+
const [n, o] = R({ width: 0, height: 0 });
|
|
35
|
+
return Y(() => {
|
|
36
36
|
const r = t.current;
|
|
37
37
|
if (!r) return;
|
|
38
|
-
const { width:
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const f =
|
|
38
|
+
const { width: u, height: l } = r.getBoundingClientRect();
|
|
39
|
+
u > 0 && l > 0 && o({ width: u, height: l });
|
|
40
|
+
const s = new ResizeObserver((x) => {
|
|
41
|
+
const f = x[0];
|
|
42
42
|
if (!f) return;
|
|
43
|
-
const { width: i, height:
|
|
44
|
-
i > 0 &&
|
|
43
|
+
const { width: i, height: a } = f.contentRect;
|
|
44
|
+
i > 0 && a > 0 && o((d) => d.width === i && d.height === a ? d : { width: i, height: a });
|
|
45
45
|
});
|
|
46
|
-
return
|
|
47
|
-
|
|
46
|
+
return s.observe(r), () => {
|
|
47
|
+
s.disconnect();
|
|
48
48
|
};
|
|
49
49
|
}, [t]), n;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
51
|
+
function De(t, n) {
|
|
52
52
|
return Math.sqrt(Math.pow(n.x - t.x, 2) + Math.pow(n.y - t.y, 2));
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function ke(t, n) {
|
|
55
55
|
return {
|
|
56
56
|
x: (t.x + n.x) / 2,
|
|
57
57
|
y: (t.y + n.y) / 2
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
const o =
|
|
62
|
-
|
|
60
|
+
function bt(t, n) {
|
|
61
|
+
const o = T(null), r = T(null), u = T(1);
|
|
62
|
+
Y(() => {
|
|
63
63
|
const l = t.current;
|
|
64
64
|
if (!l || !n.enabled) return;
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
o.current =
|
|
65
|
+
const s = l.container(), x = (a) => {
|
|
66
|
+
if (a.touches.length === 2) {
|
|
67
|
+
a.preventDefault();
|
|
68
|
+
const d = { x: a.touches[0].clientX, y: a.touches[0].clientY }, h = { x: a.touches[1].clientX, y: a.touches[1].clientY };
|
|
69
|
+
o.current = De(d, h), r.current = ke(d, h), u.current = n.currentScale;
|
|
70
70
|
}
|
|
71
|
-
}, f = (
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
const
|
|
71
|
+
}, f = (a) => {
|
|
72
|
+
if (a.touches.length !== 2) return;
|
|
73
|
+
a.preventDefault();
|
|
74
|
+
const d = { x: a.touches[0].clientX, y: a.touches[0].clientY }, h = { x: a.touches[1].clientX, y: a.touches[1].clientY }, m = De(d, h), S = ke(d, h);
|
|
75
75
|
if (o.current !== null && r.current !== null) {
|
|
76
|
-
const
|
|
77
|
-
Math.max(n.currentScale *
|
|
76
|
+
const C = m / o.current, F = Math.min(
|
|
77
|
+
Math.max(n.currentScale * C, n.minScale),
|
|
78
78
|
n.maxScale
|
|
79
|
-
), I =
|
|
79
|
+
), I = s.getBoundingClientRect(), M = S.x - I.left, L = S.y - I.top, z = n.currentScale, X = {
|
|
80
80
|
x: (M - n.currentPosition.x) / z,
|
|
81
|
-
y: (
|
|
82
|
-
},
|
|
83
|
-
x: M - X.x * F +
|
|
84
|
-
y:
|
|
81
|
+
y: (L - n.currentPosition.y) / z
|
|
82
|
+
}, q = S.x - r.current.x, j = S.y - r.current.y, Z = {
|
|
83
|
+
x: M - X.x * F + q,
|
|
84
|
+
y: L - X.y * F + j
|
|
85
85
|
};
|
|
86
|
-
n.onScaleChange(F,
|
|
86
|
+
n.onScaleChange(F, Z), o.current = m, r.current = S;
|
|
87
87
|
}
|
|
88
|
-
}, i = (
|
|
89
|
-
|
|
88
|
+
}, i = (a) => {
|
|
89
|
+
a.touches.length < 2 && (o.current = null, r.current = null);
|
|
90
90
|
};
|
|
91
|
-
return
|
|
92
|
-
|
|
91
|
+
return s.addEventListener("touchstart", x, { passive: !1 }), s.addEventListener("touchmove", f, { passive: !1 }), s.addEventListener("touchend", i), () => {
|
|
92
|
+
s.removeEventListener("touchstart", x), s.removeEventListener("touchmove", f), s.removeEventListener("touchend", i);
|
|
93
93
|
};
|
|
94
94
|
}, [t, n]);
|
|
95
95
|
}
|
|
96
|
-
const
|
|
96
|
+
const vt = {
|
|
97
97
|
canvasBackground: "#1a1a1a",
|
|
98
98
|
stageColor: "#808080",
|
|
99
99
|
seatAvailable: "#2C2B30",
|
|
@@ -103,7 +103,7 @@ const yt = {
|
|
|
103
103
|
seatHidden: "#4a4a4a",
|
|
104
104
|
gridLines: "#404040",
|
|
105
105
|
currency: "KD"
|
|
106
|
-
},
|
|
106
|
+
}, Xe = ce(({ seat: t, state: n, colors: o, onClick: r, onMouseEnter: u, onMouseLeave: l }) => {
|
|
107
107
|
const f = {
|
|
108
108
|
available: o.seatAvailable,
|
|
109
109
|
reserved: o.seatReserved,
|
|
@@ -111,37 +111,37 @@ const yt = {
|
|
|
111
111
|
unavailable: o.seatUnavailable,
|
|
112
112
|
hidden: o.seatHidden
|
|
113
113
|
// Hidden seats are filtered out, but included for type safety
|
|
114
|
-
}[n], i = n === "available" || n === "selected",
|
|
114
|
+
}[n], i = n === "available" || n === "selected", a = N(() => {
|
|
115
115
|
i && r(t);
|
|
116
|
-
}, [t, r, i]),
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
}, [t,
|
|
116
|
+
}, [t, r, i]), d = N((S) => {
|
|
117
|
+
u(t, S);
|
|
118
|
+
const C = S.target.getStage();
|
|
119
|
+
C && i && (C.container().style.cursor = "pointer");
|
|
120
|
+
}, [t, u, i]), h = N((S) => {
|
|
121
121
|
l();
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
}, [l]),
|
|
122
|
+
const C = S.target.getStage();
|
|
123
|
+
C && (C.container().style.cursor = "grab");
|
|
124
|
+
}, [l]), m = {
|
|
125
125
|
x: t.position.x,
|
|
126
126
|
y: t.position.y,
|
|
127
127
|
fill: f,
|
|
128
128
|
stroke: "#ffffff",
|
|
129
129
|
strokeWidth: 1,
|
|
130
|
-
onClick:
|
|
131
|
-
onTap:
|
|
132
|
-
onMouseEnter:
|
|
130
|
+
onClick: a,
|
|
131
|
+
onTap: a,
|
|
132
|
+
onMouseEnter: d,
|
|
133
133
|
onMouseLeave: h
|
|
134
134
|
};
|
|
135
135
|
return t.shape === "circle" ? /* @__PURE__ */ y(
|
|
136
|
-
|
|
136
|
+
ht,
|
|
137
137
|
{
|
|
138
|
-
...
|
|
138
|
+
...m,
|
|
139
139
|
radius: 12
|
|
140
140
|
}
|
|
141
141
|
) : /* @__PURE__ */ y(
|
|
142
|
-
|
|
142
|
+
Te,
|
|
143
143
|
{
|
|
144
|
-
...
|
|
144
|
+
...m,
|
|
145
145
|
width: 24,
|
|
146
146
|
height: 24,
|
|
147
147
|
offsetX: 12,
|
|
@@ -150,8 +150,8 @@ const yt = {
|
|
|
150
150
|
}
|
|
151
151
|
);
|
|
152
152
|
});
|
|
153
|
-
|
|
154
|
-
const
|
|
153
|
+
Xe.displayName = "ViewerSeat";
|
|
154
|
+
const Ye = ce(({ stage: t, stageColor: n }) => {
|
|
155
155
|
const o = (l) => ({
|
|
156
156
|
stage: "🎭",
|
|
157
157
|
table: "⬜",
|
|
@@ -161,10 +161,10 @@ const Ae = se(({ stage: t, stageColor: n }) => {
|
|
|
161
161
|
bar: "🍷",
|
|
162
162
|
"entry-exit": "🚪",
|
|
163
163
|
custom: "➕"
|
|
164
|
-
})[l || "stage"] || "🎭", r = t.config.color || n,
|
|
165
|
-
return /* @__PURE__ */
|
|
164
|
+
})[l || "stage"] || "🎭", r = t.config.color || n, u = o(t.config.objectType);
|
|
165
|
+
return /* @__PURE__ */ D(ut, { x: t.position.x, y: t.position.y, rotation: t.config.rotation || 0, children: [
|
|
166
166
|
/* @__PURE__ */ y(
|
|
167
|
-
|
|
167
|
+
Te,
|
|
168
168
|
{
|
|
169
169
|
width: t.config.width,
|
|
170
170
|
height: t.config.height,
|
|
@@ -177,7 +177,7 @@ const Ae = se(({ stage: t, stageColor: n }) => {
|
|
|
177
177
|
/* @__PURE__ */ y(
|
|
178
178
|
Ie,
|
|
179
179
|
{
|
|
180
|
-
text:
|
|
180
|
+
text: u,
|
|
181
181
|
x: 0,
|
|
182
182
|
y: 0,
|
|
183
183
|
width: t.config.width,
|
|
@@ -205,18 +205,18 @@ const Ae = se(({ stage: t, stageColor: n }) => {
|
|
|
205
205
|
)
|
|
206
206
|
] });
|
|
207
207
|
});
|
|
208
|
-
|
|
209
|
-
const
|
|
208
|
+
Ye.displayName = "ViewerStage";
|
|
209
|
+
const je = ce(({
|
|
210
210
|
floors: t,
|
|
211
211
|
currentFloorId: n,
|
|
212
212
|
onFloorChange: o,
|
|
213
213
|
showAllOption: r,
|
|
214
|
-
allLabel:
|
|
214
|
+
allLabel: u,
|
|
215
215
|
position: l,
|
|
216
|
-
className:
|
|
216
|
+
className: s
|
|
217
217
|
}) => {
|
|
218
|
-
const
|
|
219
|
-
() => [...t].sort((h,
|
|
218
|
+
const x = _(
|
|
219
|
+
() => [...t].sort((h, m) => h.order - m.order),
|
|
220
220
|
[t]
|
|
221
221
|
), i = {
|
|
222
222
|
position: "absolute",
|
|
@@ -234,7 +234,7 @@ const Xe = se(({
|
|
|
234
234
|
"bottom-left": { bottom: 0, left: 0 },
|
|
235
235
|
"bottom-right": { bottom: 0, right: 0 }
|
|
236
236
|
}[l]
|
|
237
|
-
},
|
|
237
|
+
}, a = {
|
|
238
238
|
padding: "10px 16px",
|
|
239
239
|
fontSize: "14px",
|
|
240
240
|
fontWeight: 500,
|
|
@@ -246,42 +246,42 @@ const Xe = se(({
|
|
|
246
246
|
transition: "all 0.2s ease",
|
|
247
247
|
minHeight: "44px",
|
|
248
248
|
touchAction: "manipulation"
|
|
249
|
-
},
|
|
250
|
-
...
|
|
249
|
+
}, d = {
|
|
250
|
+
...a,
|
|
251
251
|
backgroundColor: "#3A7DE5",
|
|
252
252
|
borderColor: "#3A7DE5"
|
|
253
253
|
};
|
|
254
|
-
return /* @__PURE__ */
|
|
254
|
+
return /* @__PURE__ */ D("div", { className: s, style: i, children: [
|
|
255
255
|
r && /* @__PURE__ */ y(
|
|
256
256
|
"button",
|
|
257
257
|
{
|
|
258
258
|
type: "button",
|
|
259
259
|
onClick: () => o(null),
|
|
260
|
-
style: n === null ?
|
|
261
|
-
children:
|
|
260
|
+
style: n === null ? d : a,
|
|
261
|
+
children: u
|
|
262
262
|
}
|
|
263
263
|
),
|
|
264
|
-
|
|
264
|
+
x.map((h) => /* @__PURE__ */ y(
|
|
265
265
|
"button",
|
|
266
266
|
{
|
|
267
267
|
type: "button",
|
|
268
268
|
onClick: () => o(h.id),
|
|
269
|
-
style: n === h.id ?
|
|
269
|
+
style: n === h.id ? d : a,
|
|
270
270
|
children: h.name
|
|
271
271
|
},
|
|
272
272
|
h.id
|
|
273
273
|
))
|
|
274
274
|
] });
|
|
275
275
|
});
|
|
276
|
-
|
|
277
|
-
const
|
|
276
|
+
je.displayName = "FloorSelectorBar";
|
|
277
|
+
const We = ce(({
|
|
278
278
|
scale: t,
|
|
279
279
|
minScale: n,
|
|
280
280
|
maxScale: o,
|
|
281
281
|
onZoomIn: r,
|
|
282
|
-
onZoomOut:
|
|
282
|
+
onZoomOut: u,
|
|
283
283
|
position: l,
|
|
284
|
-
className:
|
|
284
|
+
className: s
|
|
285
285
|
}) => {
|
|
286
286
|
const f = {
|
|
287
287
|
position: "absolute",
|
|
@@ -316,19 +316,19 @@ const Ye = se(({
|
|
|
316
316
|
justifyContent: "center",
|
|
317
317
|
transition: "all 0.2s ease",
|
|
318
318
|
touchAction: "manipulation"
|
|
319
|
-
},
|
|
319
|
+
}, a = {
|
|
320
320
|
...i,
|
|
321
321
|
opacity: 0.4,
|
|
322
322
|
cursor: "not-allowed"
|
|
323
|
-
},
|
|
324
|
-
return /* @__PURE__ */
|
|
323
|
+
}, d = t < o, h = t > n;
|
|
324
|
+
return /* @__PURE__ */ D("div", { className: s, style: f, children: [
|
|
325
325
|
/* @__PURE__ */ y(
|
|
326
326
|
"button",
|
|
327
327
|
{
|
|
328
328
|
type: "button",
|
|
329
329
|
onClick: r,
|
|
330
|
-
disabled: !
|
|
331
|
-
style:
|
|
330
|
+
disabled: !d,
|
|
331
|
+
style: d ? i : a,
|
|
332
332
|
title: "Zoom In",
|
|
333
333
|
children: "+"
|
|
334
334
|
}
|
|
@@ -337,26 +337,26 @@ const Ye = se(({
|
|
|
337
337
|
"button",
|
|
338
338
|
{
|
|
339
339
|
type: "button",
|
|
340
|
-
onClick:
|
|
340
|
+
onClick: u,
|
|
341
341
|
disabled: !h,
|
|
342
|
-
style: h ? i :
|
|
342
|
+
style: h ? i : a,
|
|
343
343
|
title: "Zoom Out",
|
|
344
344
|
children: "−"
|
|
345
345
|
}
|
|
346
346
|
)
|
|
347
347
|
] });
|
|
348
348
|
});
|
|
349
|
-
|
|
350
|
-
const
|
|
349
|
+
We.displayName = "ZoomControls";
|
|
350
|
+
const Pe = ce(({
|
|
351
351
|
visible: t,
|
|
352
352
|
x: n,
|
|
353
353
|
y: o,
|
|
354
354
|
seat: r,
|
|
355
|
-
currency:
|
|
355
|
+
currency: u,
|
|
356
356
|
state: l
|
|
357
357
|
}) => {
|
|
358
358
|
if (!t || !r) return null;
|
|
359
|
-
const
|
|
359
|
+
const s = r.seatNumber || (r.rowLabel && r.columnLabel ? `${r.rowLabel}-${r.columnLabel}` : "N/A"), x = {
|
|
360
360
|
position: "fixed",
|
|
361
361
|
left: `${n + 15}px`,
|
|
362
362
|
top: `${o + 15}px`,
|
|
@@ -374,9 +374,9 @@ const je = se(({
|
|
|
374
374
|
}, i = {
|
|
375
375
|
color: "#9ca3af",
|
|
376
376
|
marginRight: "4px"
|
|
377
|
-
},
|
|
377
|
+
}, a = {
|
|
378
378
|
fontWeight: 600
|
|
379
|
-
},
|
|
379
|
+
}, d = {
|
|
380
380
|
color: "#4ade80",
|
|
381
381
|
fontWeight: 600
|
|
382
382
|
}, h = {
|
|
@@ -385,186 +385,186 @@ const je = se(({
|
|
|
385
385
|
textTransform: "capitalize",
|
|
386
386
|
marginTop: "4px"
|
|
387
387
|
};
|
|
388
|
-
return /* @__PURE__ */ y("div", { style:
|
|
389
|
-
r.sectionName && /* @__PURE__ */
|
|
388
|
+
return /* @__PURE__ */ y("div", { style: x, children: /* @__PURE__ */ D("div", { style: f, children: [
|
|
389
|
+
r.sectionName && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
|
|
390
390
|
/* @__PURE__ */ y("span", { style: i, children: "Section:" }),
|
|
391
|
-
/* @__PURE__ */ y("span", { style: { ...
|
|
391
|
+
/* @__PURE__ */ y("span", { style: { ...a, color: "#3b82f6" }, children: r.sectionName })
|
|
392
392
|
] }),
|
|
393
|
-
/* @__PURE__ */
|
|
393
|
+
/* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
|
|
394
394
|
/* @__PURE__ */ y("span", { style: i, children: "Seat:" }),
|
|
395
|
-
/* @__PURE__ */ y("span", { style:
|
|
395
|
+
/* @__PURE__ */ y("span", { style: a, children: s })
|
|
396
396
|
] }),
|
|
397
|
-
r.price !== void 0 && r.price > 0 && l === "available" && /* @__PURE__ */
|
|
397
|
+
r.price !== void 0 && r.price > 0 && l === "available" && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
|
|
398
398
|
/* @__PURE__ */ y("span", { style: i, children: "Price:" }),
|
|
399
|
-
/* @__PURE__ */
|
|
400
|
-
|
|
399
|
+
/* @__PURE__ */ D("span", { style: d, children: [
|
|
400
|
+
u,
|
|
401
401
|
" ",
|
|
402
402
|
r.price.toFixed(2)
|
|
403
403
|
] })
|
|
404
404
|
] }),
|
|
405
|
-
/* @__PURE__ */
|
|
405
|
+
/* @__PURE__ */ D("div", { style: h, children: [
|
|
406
406
|
"Status: ",
|
|
407
407
|
l
|
|
408
408
|
] })
|
|
409
409
|
] }) });
|
|
410
410
|
});
|
|
411
|
-
|
|
411
|
+
Pe.displayName = "SeatTooltip";
|
|
412
412
|
const Et = ({
|
|
413
413
|
config: t,
|
|
414
414
|
configUrl: n,
|
|
415
415
|
floorId: o,
|
|
416
416
|
onFloorChange: r,
|
|
417
|
-
reservedSeats:
|
|
417
|
+
reservedSeats: u = [],
|
|
418
418
|
unavailableSeats: l = [],
|
|
419
|
-
selectedSeats:
|
|
420
|
-
myReservedSeats:
|
|
419
|
+
selectedSeats: s,
|
|
420
|
+
myReservedSeats: x = [],
|
|
421
421
|
onSeatSelect: f,
|
|
422
422
|
onSeatDeselect: i,
|
|
423
|
-
onSelectionChange:
|
|
424
|
-
colorOverrides:
|
|
423
|
+
onSelectionChange: a,
|
|
424
|
+
colorOverrides: d,
|
|
425
425
|
showTooltip: h = !0,
|
|
426
|
-
zoomEnabled:
|
|
426
|
+
zoomEnabled: m = !0,
|
|
427
427
|
className: S = "",
|
|
428
|
-
onConfigLoad:
|
|
428
|
+
onConfigLoad: C,
|
|
429
429
|
onError: F,
|
|
430
430
|
// Floor selector props
|
|
431
431
|
showFloorSelector: I,
|
|
432
432
|
floorSelectorPosition: M = "top-left",
|
|
433
|
-
floorSelectorClassName:
|
|
433
|
+
floorSelectorClassName: L,
|
|
434
434
|
showAllFloorsOption: z = !0,
|
|
435
435
|
allFloorsLabel: X = "All",
|
|
436
|
-
fitToView:
|
|
437
|
-
fitPadding:
|
|
436
|
+
fitToView: q = !0,
|
|
437
|
+
fitPadding: j = 40,
|
|
438
438
|
// Zoom controls
|
|
439
|
-
showZoomControls:
|
|
440
|
-
zoomControlsPosition:
|
|
441
|
-
zoomControlsClassName:
|
|
442
|
-
minZoom:
|
|
443
|
-
maxZoom:
|
|
444
|
-
zoomStep:
|
|
439
|
+
showZoomControls: Z = !0,
|
|
440
|
+
zoomControlsPosition: P = "bottom-right",
|
|
441
|
+
zoomControlsClassName: K,
|
|
442
|
+
minZoom: le,
|
|
443
|
+
maxZoom: $ = 3,
|
|
444
|
+
zoomStep: B = 0.25,
|
|
445
445
|
// Touch gestures
|
|
446
446
|
touchEnabled: Me = !0
|
|
447
447
|
}) => {
|
|
448
|
-
const
|
|
449
|
-
be ||
|
|
450
|
-
}, [be, r]), ve = g?.floors || [],
|
|
451
|
-
() => g ? { ...g.colors, ...
|
|
452
|
-
[g,
|
|
453
|
-
),
|
|
448
|
+
const O = T(null), V = T(null), E = yt(V), [U, ye] = R(/* @__PURE__ */ new Set()), [k, te] = R(1), [A, G] = R({ x: 0, y: 0 }), [$e, Be] = R(null), [Oe, Ue] = R(1), de = T({ width: 0, height: 0 }), [ne, Ee] = R({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: Ve, loading: He, error: re } = pt(n), g = t || Ve, be = o !== void 0, W = be ? o || null : $e, ue = s !== void 0, _e = N((e) => {
|
|
449
|
+
be || Be(e), r?.(e);
|
|
450
|
+
}, [be, r]), ve = g?.floors || [], qe = I !== void 0 ? I : ve.length > 1, he = _(
|
|
451
|
+
() => g ? { ...g.colors, ...d } : { ...vt, ...d },
|
|
452
|
+
[g, d]
|
|
453
|
+
), Q = _(() => {
|
|
454
454
|
if (!g) return [];
|
|
455
455
|
let e = g.seats.filter((c) => c.state !== "hidden");
|
|
456
|
-
return
|
|
457
|
-
(c) => c.floorId ===
|
|
456
|
+
return W && (e = e.filter(
|
|
457
|
+
(c) => c.floorId === W || !c.floorId && W === "floor_default"
|
|
458
458
|
)), e;
|
|
459
|
-
}, [g,
|
|
460
|
-
(e) => e.floorId ===
|
|
461
|
-
) : g.stages : [], [g,
|
|
462
|
-
if (!g ||
|
|
459
|
+
}, [g, W]), fe = _(() => g?.stages ? W ? g.stages.filter(
|
|
460
|
+
(e) => e.floorId === W || !e.floorId && W === "floor_default"
|
|
461
|
+
) : g.stages : [], [g, W]), H = _(() => {
|
|
462
|
+
if (!g || Q.length === 0 && fe.length === 0)
|
|
463
463
|
return null;
|
|
464
464
|
const e = 12;
|
|
465
465
|
let c = 1 / 0, p = 1 / 0, b = -1 / 0, v = -1 / 0;
|
|
466
|
-
return
|
|
466
|
+
return Q.forEach((w) => {
|
|
467
467
|
c = Math.min(c, w.position.x - e), p = Math.min(p, w.position.y - e), b = Math.max(b, w.position.x + e), v = Math.max(v, w.position.y + e);
|
|
468
|
-
}),
|
|
468
|
+
}), fe.forEach((w) => {
|
|
469
469
|
c = Math.min(c, w.position.x), p = Math.min(p, w.position.y), b = Math.max(b, w.position.x + (w.config?.width || 200)), v = Math.max(v, w.position.y + (w.config?.height || 100));
|
|
470
470
|
}), { minX: c, minY: p, maxX: b, maxY: v, width: b - c, height: v - p };
|
|
471
|
-
}, [g,
|
|
472
|
-
|
|
473
|
-
if (!
|
|
474
|
-
const e = Math.abs(E.width -
|
|
475
|
-
if (!(
|
|
476
|
-
|
|
477
|
-
const b = E.width, v = E.height, w = b -
|
|
478
|
-
|
|
479
|
-
}, [
|
|
480
|
-
const
|
|
481
|
-
const e = new Set(
|
|
471
|
+
}, [g, Q, fe]);
|
|
472
|
+
Y(() => {
|
|
473
|
+
if (!q || !g || !H || E.width === 0 || E.height === 0) return;
|
|
474
|
+
const e = Math.abs(E.width - de.current.width), c = Math.abs(E.height - de.current.height);
|
|
475
|
+
if (!(de.current.width === 0) && e < 10 && c < 10) return;
|
|
476
|
+
de.current = E;
|
|
477
|
+
const b = E.width, v = E.height, w = b - j * 2, se = v - j * 2, ge = w / H.width, xe = se / H.height, pe = Math.min(ge, xe, $), ot = H.minX + H.width / 2, it = H.minY + H.height / 2, st = b / 2, at = v / 2, ct = st - ot * pe, lt = at - it * pe;
|
|
478
|
+
te(pe), G({ x: ct, y: lt }), Ue(pe);
|
|
479
|
+
}, [q, g, H, j, $, E, W]);
|
|
480
|
+
const J = _(() => {
|
|
481
|
+
const e = new Set(u), c = new Set(l), p = new Set(x);
|
|
482
482
|
return { reserved: e, unavailable: c, myReserved: p };
|
|
483
|
-
}, [
|
|
483
|
+
}, [u, l, x]), me = _(() => s ? new Set(s) : null, [s]), oe = N((e) => {
|
|
484
484
|
const c = e.id, p = e.seatNumber || "";
|
|
485
|
-
return
|
|
486
|
-
}, [
|
|
487
|
-
|
|
488
|
-
g &&
|
|
489
|
-
}, [g,
|
|
490
|
-
|
|
491
|
-
}, [
|
|
492
|
-
|
|
493
|
-
}, [
|
|
494
|
-
const
|
|
495
|
-
const c =
|
|
485
|
+
return J.unavailable.has(c) || J.unavailable.has(p) ? "unavailable" : J.reserved.has(c) || J.reserved.has(p) ? "reserved" : J.myReserved.has(c) || J.myReserved.has(p) || U.has(c) ? "selected" : e.state;
|
|
486
|
+
}, [J, U]);
|
|
487
|
+
Y(() => {
|
|
488
|
+
g && C && C(g);
|
|
489
|
+
}, [g, C]), Y(() => {
|
|
490
|
+
re && F && F(re);
|
|
491
|
+
}, [re, F]), Y(() => {
|
|
492
|
+
ue && me && ye(me);
|
|
493
|
+
}, [ue, me]);
|
|
494
|
+
const Ge = N((e) => {
|
|
495
|
+
const c = oe(e);
|
|
496
496
|
if (c !== "available" && c !== "selected")
|
|
497
497
|
return;
|
|
498
|
-
const p =
|
|
499
|
-
|
|
498
|
+
const p = U.has(e.id);
|
|
499
|
+
ue || ye((b) => {
|
|
500
500
|
const v = new Set(b);
|
|
501
501
|
return p ? v.delete(e.id) : v.add(e.id), v;
|
|
502
502
|
}), p ? i?.(e) : (f?.(e), f || console.log("Seat selected:", e));
|
|
503
|
-
}, [
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
}, [
|
|
507
|
-
const
|
|
508
|
-
if (!
|
|
509
|
-
const e = Math.min(
|
|
510
|
-
if (e !==
|
|
503
|
+
}, [oe, U, ue, f, i]), ie = _(() => g ? Q.filter((e) => U.has(e.id)) : [], [Q, U]);
|
|
504
|
+
Y(() => {
|
|
505
|
+
a?.(ie);
|
|
506
|
+
}, [ie, a]);
|
|
507
|
+
const ee = le !== void 0 ? le : Oe, Je = N(() => {
|
|
508
|
+
if (!m) return;
|
|
509
|
+
const e = Math.min(k + B, $);
|
|
510
|
+
if (e !== k) {
|
|
511
511
|
const c = E.width || g?.canvas.width || 800, p = E.height || g?.canvas.height || 600, b = c / 2, v = p / 2, w = {
|
|
512
|
-
x: (b - A.x) /
|
|
513
|
-
y: (v - A.y) /
|
|
512
|
+
x: (b - A.x) / k,
|
|
513
|
+
y: (v - A.y) / k
|
|
514
514
|
};
|
|
515
|
-
|
|
515
|
+
te(e), G({
|
|
516
516
|
x: b - w.x * e,
|
|
517
517
|
y: v - w.y * e
|
|
518
518
|
});
|
|
519
519
|
}
|
|
520
|
-
}, [
|
|
521
|
-
if (!
|
|
522
|
-
const e = Math.max(
|
|
523
|
-
if (e !==
|
|
520
|
+
}, [m, k, B, $, E, g, A]), Ze = N(() => {
|
|
521
|
+
if (!m) return;
|
|
522
|
+
const e = Math.max(k - B, ee);
|
|
523
|
+
if (e !== k) {
|
|
524
524
|
const c = E.width || g?.canvas.width || 800, p = E.height || g?.canvas.height || 600, b = c / 2, v = p / 2, w = {
|
|
525
|
-
x: (b - A.x) /
|
|
526
|
-
y: (v - A.y) /
|
|
525
|
+
x: (b - A.x) / k,
|
|
526
|
+
y: (v - A.y) / k
|
|
527
527
|
};
|
|
528
|
-
|
|
528
|
+
te(e), G({
|
|
529
529
|
x: b - w.x * e,
|
|
530
530
|
y: v - w.y * e
|
|
531
531
|
});
|
|
532
532
|
}
|
|
533
|
-
}, [
|
|
534
|
-
|
|
533
|
+
}, [m, k, B, ee, E, g, A]), Ke = N((e) => {
|
|
534
|
+
G({
|
|
535
535
|
x: e.target.x(),
|
|
536
536
|
y: e.target.y()
|
|
537
537
|
});
|
|
538
|
-
}, []),
|
|
539
|
-
if (!
|
|
538
|
+
}, []), Qe = N((e) => {
|
|
539
|
+
if (!m) return;
|
|
540
540
|
e.evt.preventDefault();
|
|
541
|
-
const c =
|
|
541
|
+
const c = O.current;
|
|
542
542
|
if (!c) return;
|
|
543
543
|
const p = c.scaleX(), b = c.getPointerPosition();
|
|
544
544
|
if (!b) return;
|
|
545
|
-
const v = 1.1, w = e.evt.deltaY > 0 ? p / v : p * v,
|
|
545
|
+
const v = 1.1, w = e.evt.deltaY > 0 ? p / v : p * v, se = Math.min(Math.max(w, ee), $), ge = {
|
|
546
546
|
x: (b.x - A.x) / p,
|
|
547
547
|
y: (b.y - A.y) / p
|
|
548
548
|
}, xe = {
|
|
549
|
-
x: b.x -
|
|
550
|
-
y: b.y -
|
|
549
|
+
x: b.x - ge.x * se,
|
|
550
|
+
y: b.y - ge.y * se
|
|
551
551
|
};
|
|
552
|
-
|
|
553
|
-
}, [
|
|
554
|
-
|
|
555
|
-
enabled: Me &&
|
|
556
|
-
minScale:
|
|
557
|
-
maxScale:
|
|
558
|
-
currentScale:
|
|
552
|
+
te(se), G(xe);
|
|
553
|
+
}, [m, A, ee, $]);
|
|
554
|
+
bt(O, {
|
|
555
|
+
enabled: Me && m,
|
|
556
|
+
minScale: ee,
|
|
557
|
+
maxScale: $,
|
|
558
|
+
currentScale: k,
|
|
559
559
|
currentPosition: A,
|
|
560
560
|
onScaleChange: (e, c) => {
|
|
561
|
-
|
|
561
|
+
te(e), G(c);
|
|
562
562
|
},
|
|
563
563
|
onPositionChange: (e) => {
|
|
564
|
-
|
|
564
|
+
G(e);
|
|
565
565
|
}
|
|
566
566
|
});
|
|
567
|
-
const
|
|
567
|
+
const et = N((e, c) => {
|
|
568
568
|
if (!h) return;
|
|
569
569
|
const p = c.target.getStage();
|
|
570
570
|
if (!p) return;
|
|
@@ -576,72 +576,72 @@ const Et = ({
|
|
|
576
576
|
x: v.left + b.x,
|
|
577
577
|
y: v.top + b.y,
|
|
578
578
|
seat: e,
|
|
579
|
-
state:
|
|
579
|
+
state: oe(e)
|
|
580
580
|
});
|
|
581
|
-
}, [h,
|
|
581
|
+
}, [h, oe]), tt = N(() => {
|
|
582
582
|
Ee((e) => ({ ...e, visible: !1 }));
|
|
583
583
|
}, []);
|
|
584
|
-
if (
|
|
584
|
+
if (He)
|
|
585
585
|
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${S}`, children: /* @__PURE__ */ y("p", { children: "Loading seat map..." }) });
|
|
586
|
-
if (
|
|
587
|
-
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${S}`, children: /* @__PURE__ */
|
|
586
|
+
if (re)
|
|
587
|
+
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${S}`, children: /* @__PURE__ */ D("p", { className: "text-red-500", children: [
|
|
588
588
|
"Error loading seat map: ",
|
|
589
|
-
|
|
589
|
+
re.message
|
|
590
590
|
] }) });
|
|
591
591
|
if (!g)
|
|
592
592
|
return /* @__PURE__ */ y("div", { className: `flex items-center justify-center h-full ${S}`, children: /* @__PURE__ */ y("p", { children: "No configuration provided" }) });
|
|
593
|
-
const
|
|
594
|
-
return /* @__PURE__ */
|
|
593
|
+
const nt = E.width || g.canvas.width, rt = E.height || g.canvas.height;
|
|
594
|
+
return /* @__PURE__ */ D(
|
|
595
595
|
"div",
|
|
596
596
|
{
|
|
597
|
-
ref:
|
|
597
|
+
ref: V,
|
|
598
598
|
className: `relative ${S}`,
|
|
599
599
|
style: { width: "100%", height: "100%" },
|
|
600
600
|
children: [
|
|
601
|
-
|
|
602
|
-
|
|
601
|
+
qe && ve.length > 0 && /* @__PURE__ */ y(
|
|
602
|
+
je,
|
|
603
603
|
{
|
|
604
604
|
floors: ve,
|
|
605
|
-
currentFloorId:
|
|
606
|
-
onFloorChange:
|
|
605
|
+
currentFloorId: W,
|
|
606
|
+
onFloorChange: _e,
|
|
607
607
|
showAllOption: z,
|
|
608
608
|
allLabel: X,
|
|
609
609
|
position: M,
|
|
610
|
-
className:
|
|
610
|
+
className: L
|
|
611
611
|
}
|
|
612
612
|
),
|
|
613
|
-
/* @__PURE__ */
|
|
614
|
-
|
|
613
|
+
/* @__PURE__ */ D(
|
|
614
|
+
dt,
|
|
615
615
|
{
|
|
616
|
-
ref:
|
|
617
|
-
width:
|
|
618
|
-
height:
|
|
619
|
-
scaleX:
|
|
620
|
-
scaleY:
|
|
616
|
+
ref: O,
|
|
617
|
+
width: nt,
|
|
618
|
+
height: rt,
|
|
619
|
+
scaleX: k,
|
|
620
|
+
scaleY: k,
|
|
621
621
|
x: A.x,
|
|
622
622
|
y: A.y,
|
|
623
623
|
draggable: !0,
|
|
624
|
-
onDragEnd:
|
|
625
|
-
onWheel:
|
|
624
|
+
onDragEnd: Ke,
|
|
625
|
+
onWheel: Qe,
|
|
626
626
|
style: { backgroundColor: g.canvas.backgroundColor, cursor: "grab" },
|
|
627
627
|
children: [
|
|
628
|
-
/* @__PURE__ */ y(Fe, { listening: !1, children:
|
|
629
|
-
|
|
628
|
+
/* @__PURE__ */ y(Fe, { listening: !1, children: fe.map((e) => /* @__PURE__ */ y(
|
|
629
|
+
Ye,
|
|
630
630
|
{
|
|
631
631
|
stage: e,
|
|
632
|
-
stageColor:
|
|
632
|
+
stageColor: he.stageColor
|
|
633
633
|
},
|
|
634
634
|
e.id
|
|
635
635
|
)) }),
|
|
636
|
-
/* @__PURE__ */ y(Fe, { children:
|
|
637
|
-
|
|
636
|
+
/* @__PURE__ */ y(Fe, { children: Q.map((e) => /* @__PURE__ */ y(
|
|
637
|
+
Xe,
|
|
638
638
|
{
|
|
639
639
|
seat: e,
|
|
640
|
-
state:
|
|
641
|
-
colors:
|
|
642
|
-
onClick:
|
|
643
|
-
onMouseEnter:
|
|
644
|
-
onMouseLeave:
|
|
640
|
+
state: oe(e),
|
|
641
|
+
colors: he,
|
|
642
|
+
onClick: Ge,
|
|
643
|
+
onMouseEnter: et,
|
|
644
|
+
onMouseLeave: tt
|
|
645
645
|
},
|
|
646
646
|
e.id
|
|
647
647
|
)) })
|
|
@@ -649,59 +649,59 @@ const Et = ({
|
|
|
649
649
|
}
|
|
650
650
|
),
|
|
651
651
|
h && /* @__PURE__ */ y(
|
|
652
|
-
|
|
652
|
+
Pe,
|
|
653
653
|
{
|
|
654
|
-
visible:
|
|
655
|
-
x:
|
|
656
|
-
y:
|
|
657
|
-
seat:
|
|
658
|
-
currency:
|
|
659
|
-
state:
|
|
654
|
+
visible: ne.visible,
|
|
655
|
+
x: ne.x,
|
|
656
|
+
y: ne.y,
|
|
657
|
+
seat: ne.seat,
|
|
658
|
+
currency: he.currency,
|
|
659
|
+
state: ne.state
|
|
660
660
|
}
|
|
661
661
|
),
|
|
662
|
-
|
|
663
|
-
|
|
662
|
+
Z && m && /* @__PURE__ */ y(
|
|
663
|
+
We,
|
|
664
664
|
{
|
|
665
|
-
scale:
|
|
666
|
-
minScale:
|
|
667
|
-
maxScale:
|
|
668
|
-
onZoomIn:
|
|
669
|
-
onZoomOut:
|
|
670
|
-
position:
|
|
671
|
-
className:
|
|
665
|
+
scale: k,
|
|
666
|
+
minScale: ee,
|
|
667
|
+
maxScale: $,
|
|
668
|
+
onZoomIn: Je,
|
|
669
|
+
onZoomOut: Ze,
|
|
670
|
+
position: P,
|
|
671
|
+
className: K
|
|
672
672
|
}
|
|
673
673
|
),
|
|
674
|
-
|
|
675
|
-
/* @__PURE__ */
|
|
674
|
+
ie.length > 0 && /* @__PURE__ */ D("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
|
|
675
|
+
/* @__PURE__ */ D("h3", { className: "font-semibold mb-2", children: [
|
|
676
676
|
"Selected Seats (",
|
|
677
|
-
|
|
677
|
+
ie.length,
|
|
678
678
|
")"
|
|
679
679
|
] }),
|
|
680
|
-
/* @__PURE__ */ y("div", { className: "max-h-48 overflow-y-auto space-y-1", children:
|
|
680
|
+
/* @__PURE__ */ y("div", { className: "max-h-48 overflow-y-auto space-y-1", children: ie.map((e) => /* @__PURE__ */ D("div", { className: "text-sm", children: [
|
|
681
681
|
e.seatNumber,
|
|
682
|
-
e.price && ` - ${
|
|
682
|
+
e.price && ` - ${he.currency} ${e.price.toFixed(2)}`
|
|
683
683
|
] }, e.id)) })
|
|
684
684
|
] })
|
|
685
685
|
]
|
|
686
686
|
}
|
|
687
687
|
);
|
|
688
688
|
};
|
|
689
|
-
let
|
|
689
|
+
let ae = null;
|
|
690
690
|
function Ft(t) {
|
|
691
|
-
|
|
691
|
+
ae = t;
|
|
692
692
|
}
|
|
693
693
|
function Ce() {
|
|
694
|
-
if (!
|
|
694
|
+
if (!ae)
|
|
695
695
|
throw new Error(
|
|
696
696
|
"Firebase database not initialized. Call initializeFirebaseForViewer(db) first."
|
|
697
697
|
);
|
|
698
|
-
return
|
|
698
|
+
return ae;
|
|
699
699
|
}
|
|
700
700
|
function Re() {
|
|
701
|
-
return
|
|
701
|
+
return ae !== null;
|
|
702
702
|
}
|
|
703
703
|
function It() {
|
|
704
|
-
|
|
704
|
+
ae = null;
|
|
705
705
|
}
|
|
706
706
|
function Se(t, n) {
|
|
707
707
|
if (t.length !== n.length) return !1;
|
|
@@ -709,45 +709,50 @@ function Se(t, n) {
|
|
|
709
709
|
if (t[o] !== n[o]) return !1;
|
|
710
710
|
return !0;
|
|
711
711
|
}
|
|
712
|
-
function
|
|
712
|
+
function Le(t, n) {
|
|
713
713
|
return Se(t.myReserved, n.myReserved) && Se(t.otherReserved, n.otherReserved) && Se(t.unavailable, n.unavailable);
|
|
714
714
|
}
|
|
715
|
-
function
|
|
716
|
-
const o = [], r = [],
|
|
717
|
-
return Object.entries(t).forEach(([l,
|
|
718
|
-
|
|
719
|
-
}), { myReserved: o, otherReserved: r, unavailable:
|
|
715
|
+
function Ne(t, n) {
|
|
716
|
+
const o = [], r = [], u = [];
|
|
717
|
+
return Object.entries(t).forEach(([l, s]) => {
|
|
718
|
+
s && typeof s == "object" && s.state && (s.state === "unavailable" ? u.push(l) : s.state === "reserved" && (n && s.userId === n ? o.push(l) : r.push(l)));
|
|
719
|
+
}), { myReserved: o, otherReserved: r, unavailable: u };
|
|
720
720
|
}
|
|
721
721
|
function mt(t) {
|
|
722
|
-
const { seatMapId: n, currentUserId: o, enabled: r = !0, onStateChange:
|
|
723
|
-
z.current =
|
|
724
|
-
const
|
|
722
|
+
const { seatMapId: n, currentUserId: o, enabled: r = !0, onStateChange: u, onError: l } = t, [s, x] = R(null), [f, i] = R(!0), [a, d] = R(null), [h, m] = R(null), [S, C] = R([]), [F, I] = R([]), [M, L] = R([]), z = T(u), X = T(l), q = T(o);
|
|
723
|
+
z.current = u, X.current = l, q.current = o;
|
|
724
|
+
const j = T({
|
|
725
725
|
myReserved: [],
|
|
726
726
|
otherReserved: [],
|
|
727
727
|
unavailable: []
|
|
728
|
-
}),
|
|
729
|
-
return
|
|
728
|
+
}), Z = T(null);
|
|
729
|
+
return Y(() => {
|
|
730
730
|
if (!r || !n) {
|
|
731
731
|
i(!1);
|
|
732
732
|
return;
|
|
733
733
|
}
|
|
734
734
|
if (!Re()) {
|
|
735
|
-
i(!1),
|
|
735
|
+
i(!1), d(new Error("Firebase not initialized. Call initializeFirebaseForViewer first."));
|
|
736
736
|
return;
|
|
737
737
|
}
|
|
738
|
-
const
|
|
739
|
-
return i(!0),
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
}, (
|
|
743
|
-
|
|
738
|
+
const P = Ce(), K = we(P, `seat_states/${n}`);
|
|
739
|
+
return i(!0), d(null), ze(K, (B) => {
|
|
740
|
+
const O = B.val() || {}, V = Ne(O, q.current), E = j.current, U = JSON.stringify(Z.current) !== JSON.stringify(O);
|
|
741
|
+
U && (x(O), Z.current = O), i(!1), !Le(E, V) && (m(Date.now()), C(V.myReserved), I(V.otherReserved), L(V.unavailable), j.current = V), U && z.current?.(O);
|
|
742
|
+
}, (B) => {
|
|
743
|
+
d(B), i(!1), X.current?.(B);
|
|
744
744
|
}), () => {
|
|
745
|
-
|
|
745
|
+
Ae(K);
|
|
746
746
|
};
|
|
747
|
-
}, [n, r]), {
|
|
748
|
-
|
|
747
|
+
}, [n, r]), Y(() => {
|
|
748
|
+
if (s) {
|
|
749
|
+
const P = Ne(s, o), K = j.current;
|
|
750
|
+
!Le(K, P) && (C(P.myReserved), I(P.otherReserved), L(P.unavailable), j.current = P, m(Date.now()));
|
|
751
|
+
}
|
|
752
|
+
}, [o]), {
|
|
753
|
+
states: s,
|
|
749
754
|
loading: f,
|
|
750
|
-
error:
|
|
755
|
+
error: a,
|
|
751
756
|
lastUpdated: h,
|
|
752
757
|
myReservedSeats: S,
|
|
753
758
|
otherReservedSeats: F,
|
|
@@ -761,41 +766,41 @@ function xt(t) {
|
|
|
761
766
|
seatMapId: n,
|
|
762
767
|
enabled: o = !0,
|
|
763
768
|
subscribeToChanges: r = !1,
|
|
764
|
-
onConfigLoad:
|
|
769
|
+
onConfigLoad: u,
|
|
765
770
|
onError: l
|
|
766
|
-
} = t, [
|
|
767
|
-
h.current =
|
|
768
|
-
const S =
|
|
771
|
+
} = t, [s, x] = R(null), [f, i] = R(!0), [a, d] = R(null), h = T(u), m = T(l);
|
|
772
|
+
h.current = u, m.current = l;
|
|
773
|
+
const S = N(async () => {
|
|
769
774
|
if (!n) return;
|
|
770
775
|
if (!Re()) {
|
|
771
|
-
|
|
776
|
+
d(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")), i(!1);
|
|
772
777
|
return;
|
|
773
778
|
}
|
|
774
|
-
const
|
|
779
|
+
const C = Ce(), F = we(C, `seatmaps/${n}`);
|
|
775
780
|
try {
|
|
776
|
-
i(!0),
|
|
777
|
-
const M = (await
|
|
781
|
+
i(!0), d(null);
|
|
782
|
+
const M = (await ft(F)).val();
|
|
778
783
|
if (M) {
|
|
779
|
-
const
|
|
780
|
-
|
|
784
|
+
const L = gt(M);
|
|
785
|
+
x(L), h.current?.(L);
|
|
781
786
|
} else
|
|
782
|
-
|
|
787
|
+
d(new Error(`Seat map ${n} not found in Firebase`));
|
|
783
788
|
} catch (I) {
|
|
784
789
|
const M = I instanceof Error ? I : new Error("Unknown error");
|
|
785
|
-
|
|
790
|
+
d(M), m.current?.(M);
|
|
786
791
|
} finally {
|
|
787
792
|
i(!1);
|
|
788
793
|
}
|
|
789
794
|
}, [n]);
|
|
790
|
-
return
|
|
795
|
+
return Y(() => {
|
|
791
796
|
if (!o || !n) {
|
|
792
797
|
i(!1);
|
|
793
798
|
return;
|
|
794
799
|
}
|
|
795
800
|
if (S(), r && Re()) {
|
|
796
|
-
const
|
|
801
|
+
const C = Ce(), F = we(C, `seatmaps/${n}/meta/updated_at`);
|
|
797
802
|
let I = !0, M = null;
|
|
798
|
-
return
|
|
803
|
+
return ze(F, (z) => {
|
|
799
804
|
if (I) {
|
|
800
805
|
I = !1, M = z.val();
|
|
801
806
|
return;
|
|
@@ -803,75 +808,75 @@ function xt(t) {
|
|
|
803
808
|
const X = z.val();
|
|
804
809
|
z.exists() && X !== M && (M = X, S());
|
|
805
810
|
}), () => {
|
|
806
|
-
|
|
811
|
+
Ae(F);
|
|
807
812
|
};
|
|
808
813
|
}
|
|
809
814
|
}, [n, o, r]), {
|
|
810
|
-
config:
|
|
815
|
+
config: s,
|
|
811
816
|
loading: f,
|
|
812
|
-
error:
|
|
817
|
+
error: a,
|
|
813
818
|
refetch: S
|
|
814
819
|
};
|
|
815
820
|
}
|
|
816
|
-
function
|
|
821
|
+
function Dt(t) {
|
|
817
822
|
const {
|
|
818
823
|
seatMapId: n,
|
|
819
824
|
userId: o,
|
|
820
825
|
enabled: r = !0,
|
|
821
|
-
subscribeToDesignChanges:
|
|
826
|
+
subscribeToDesignChanges: u = !1,
|
|
822
827
|
onConfigLoad: l,
|
|
823
|
-
onStateChange:
|
|
824
|
-
onError:
|
|
828
|
+
onStateChange: s,
|
|
829
|
+
onError: x
|
|
825
830
|
} = t, {
|
|
826
831
|
config: f,
|
|
827
832
|
loading: i,
|
|
828
|
-
error:
|
|
829
|
-
refetch:
|
|
833
|
+
error: a,
|
|
834
|
+
refetch: d
|
|
830
835
|
} = xt({
|
|
831
836
|
seatMapId: n,
|
|
832
837
|
enabled: r,
|
|
833
|
-
subscribeToChanges:
|
|
838
|
+
subscribeToChanges: u,
|
|
834
839
|
onConfigLoad: l,
|
|
835
|
-
onError:
|
|
840
|
+
onError: x
|
|
836
841
|
}), {
|
|
837
842
|
states: h,
|
|
838
|
-
loading:
|
|
843
|
+
loading: m,
|
|
839
844
|
error: S,
|
|
840
|
-
lastUpdated:
|
|
845
|
+
lastUpdated: C,
|
|
841
846
|
myReservedSeats: F,
|
|
842
847
|
otherReservedSeats: I,
|
|
843
848
|
unavailableSeats: M,
|
|
844
|
-
reservedSeats:
|
|
849
|
+
reservedSeats: L
|
|
845
850
|
} = mt({
|
|
846
851
|
seatMapId: n,
|
|
847
852
|
currentUserId: o,
|
|
848
853
|
enabled: r,
|
|
849
|
-
onStateChange:
|
|
850
|
-
onError:
|
|
854
|
+
onStateChange: s,
|
|
855
|
+
onError: x
|
|
851
856
|
});
|
|
852
857
|
return {
|
|
853
858
|
config: f,
|
|
854
|
-
loading: i ||
|
|
855
|
-
error:
|
|
859
|
+
loading: i || m,
|
|
860
|
+
error: a || S,
|
|
856
861
|
myReservedSeats: F,
|
|
857
862
|
otherReservedSeats: I,
|
|
858
863
|
unavailableSeats: M,
|
|
859
|
-
reservedSeats:
|
|
864
|
+
reservedSeats: L,
|
|
860
865
|
seatStates: h,
|
|
861
|
-
lastUpdated:
|
|
862
|
-
refetch:
|
|
866
|
+
lastUpdated: C,
|
|
867
|
+
refetch: d
|
|
863
868
|
};
|
|
864
869
|
}
|
|
865
870
|
export {
|
|
866
|
-
|
|
871
|
+
vt as DEFAULT_COLORS,
|
|
867
872
|
Et as SeatMapViewer,
|
|
868
873
|
It as clearFirebaseInstance,
|
|
869
874
|
Ft as initializeFirebaseForViewer,
|
|
870
875
|
Re as isFirebaseInitialized,
|
|
871
|
-
|
|
872
|
-
|
|
876
|
+
pt as useConfigFetcher,
|
|
877
|
+
yt as useContainerSize,
|
|
873
878
|
xt as useFirebaseConfig,
|
|
874
879
|
mt as useFirebaseSeatStates,
|
|
875
|
-
|
|
876
|
-
|
|
880
|
+
Dt as useRealtimeSeatMap,
|
|
881
|
+
bt as useTouchGestures
|
|
877
882
|
};
|