@seatlayer/core 0.61.0 → 0.63.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.
Files changed (67) hide show
  1. package/dist/{categoryInventory-B-0p5PBr.d.ts → categoryInventory-C3RogGHF.d.ts} +1 -1
  2. package/dist/{categoryInventory-DjFHXtp6.d.cts → categoryInventory-DEgsjxCC.d.cts} +1 -1
  3. package/dist/{chunk-IZTHA3X2.js → chunk-DFNYIQY3.js} +1 -1
  4. package/dist/chunk-GXMGOWKB.js +1 -0
  5. package/dist/chunk-K7GN3IOW.js +1 -0
  6. package/dist/{chunk-HHM3PB66.js → chunk-LVUGIKHG.js} +1 -1
  7. package/dist/{chunk-VOJMGPDK.js → chunk-QHWOX6PN.js} +1 -1
  8. package/dist/chunk-RZLIIQDP.js +1 -0
  9. package/dist/{chunk-XU73MULJ.js → chunk-UCLIUNHN.js} +1 -1
  10. package/dist/chunk-UL5OIGIF.js +1 -0
  11. package/dist/{chunk-ATFAQDPR.js → chunk-YPVY3Z5S.js} +1 -1
  12. package/dist/core/chart-ops/index.cjs +1 -1
  13. package/dist/core/chart-ops/index.d.cts +9 -5
  14. package/dist/core/chart-ops/index.d.ts +9 -5
  15. package/dist/core/chart-ops/index.js +1 -1
  16. package/dist/core/inventory/index.cjs +1 -1
  17. package/dist/core/inventory/index.d.cts +4 -4
  18. package/dist/core/inventory/index.d.ts +4 -4
  19. package/dist/core/inventory/index.js +1 -1
  20. package/dist/core/layout/index.cjs +1 -1
  21. package/dist/core/layout/index.d.cts +4 -4
  22. package/dist/core/layout/index.d.ts +4 -4
  23. package/dist/core/layout/index.js +1 -1
  24. package/dist/core/quality/index.cjs +1 -1
  25. package/dist/core/quality/index.d.cts +12 -5
  26. package/dist/core/quality/index.d.ts +12 -5
  27. package/dist/core/quality/index.js +1 -1
  28. package/dist/core/render-assets/index.cjs +1 -1
  29. package/dist/core/render-assets/index.d.cts +88 -2
  30. package/dist/core/render-assets/index.d.ts +88 -2
  31. package/dist/core/render-assets/index.js +1 -1
  32. package/dist/core/seatConfidence.d.cts +1 -1
  33. package/dist/core/seatConfidence.d.ts +1 -1
  34. package/dist/core/sections/index.cjs +1 -1
  35. package/dist/core/sections/index.d.cts +5 -5
  36. package/dist/core/sections/index.d.ts +5 -5
  37. package/dist/core/sections/index.js +1 -1
  38. package/dist/index.cjs +1 -1
  39. package/dist/index.d.cts +34 -10
  40. package/dist/index.d.ts +34 -10
  41. package/dist/index.js +1 -1
  42. package/dist/{labeling-iVwhgoip.d.cts → labeling-DRFC35VK.d.cts} +5 -2
  43. package/dist/{labeling-BPCTQfDG.d.ts → labeling-DTHo03rf.d.ts} +5 -2
  44. package/dist/{layout-D-R46h1m.d.ts → layout-BXB8Rf4n.d.ts} +10 -4
  45. package/dist/{layout-Vk2ZGdMS.d.cts → layout-DRB0-NGc.d.cts} +10 -4
  46. package/dist/{renderedQuality-CsXNQCCH.d.ts → renderedQuality-BjSBiqkN.d.ts} +1 -1
  47. package/dist/{renderedQuality-h9RvUWMo.d.cts → renderedQuality-DK7IGCju.d.cts} +1 -1
  48. package/dist/{renderer-QnB3a1yh.d.cts → renderer-BNzVBOBW.d.cts} +11 -1
  49. package/dist/{renderer-Bo9JzqMA.d.ts → renderer-Bhc5CgOS.d.ts} +11 -1
  50. package/dist/{sections-9_Ka3i-z.d.ts → sections-BrQV1WzI.d.ts} +1 -1
  51. package/dist/{sections-Dmjtj1BQ.d.cts → sections-D2bxgVgg.d.cts} +1 -1
  52. package/dist/{segmentedRowModel-s157HmRp.d.cts → segmentedRowModel-BQYSdf7k.d.cts} +1 -1
  53. package/dist/{segmentedRowModel-CO6Jogaa.d.ts → segmentedRowModel-Cl3X8SKt.d.ts} +1 -1
  54. package/dist/{ticketRestrictions-EJTEWPGN.d.ts → ticketRestrictions-B9WkJ6YG.d.ts} +2 -2
  55. package/dist/{ticketRestrictions-DetdPbsL.d.cts → ticketRestrictions-QBvY3Zi7.d.cts} +2 -2
  56. package/dist/{types-Db9rXT14.d.cts → types-DmgX-iuD.d.cts} +48 -1
  57. package/dist/{types-Db9rXT14.d.ts → types-DmgX-iuD.d.ts} +48 -1
  58. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  59. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  60. package/dist/view3d/index.cjs +102 -38
  61. package/dist/view3d/index.d.cts +4 -2
  62. package/dist/view3d/index.d.ts +4 -2
  63. package/dist/view3d/index.js +106 -42
  64. package/package.json +1 -1
  65. package/dist/chunk-CNCFI5RT.js +0 -1
  66. package/dist/chunk-P2NJ6UO6.js +0 -1
  67. package/dist/chunk-VI2CLV3Y.js +0 -1
@@ -1,12 +1,61 @@
1
- import{a as Bn,c as Vn,d as Nn}from"../chunk-VOJMGPDK.js";import{a as zn,c as Gn,d as Hn,e as Ce,j as Un}from"../chunk-XPPT3OGQ.js";import{d as kn}from"../chunk-T2LWVOQ3.js";import{c as Ln,d as _n,e as Kt,f as On}from"../chunk-IJI4WU57.js";import{e as Cn,l as He,n as st,o as Dn,q as Pt}from"../chunk-VI3IZS2B.js";import{V as ke,W as Le,da as St,fa as In,ga as wt,ia as Tn,l as Rn,m as it,ta as Fn}from"../chunk-CNCFI5RT.js";import{d as Z,k as En,x as he,z as at}from"../chunk-CXF32VPG.js";import{Renderer as Wr}from"ogl";var be=["available","held","sold","selected","dimmed"];function ct(t){let e=be.indexOf(t);return e<0?0:e}var Xn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Yn(t){let e=.2126*t[0]+.7152*t[1]+.0722*t[2],n=.42,i=.62;return[(e+(t[0]-e)*n)*i,(e+(t[1]-e)*n)*i,(e+(t[2]-e)*n)*i]}var Zt={ground:[.07,.085,.11],tierTop:[.24,.28,.34],tierWall:[.17,.2,.25],stageTop:[.94,.7,.38],stageWall:[.48,.33,.18],decorTop:[.22,.25,.29],decorWall:[.15,.17,.2],gaTop:[.24,.28,.33],gaWall:[.16,.19,.23],boothTop:[.3,.33,.38],boothWall:[.2,.23,.27],tableTop:[.38,.34,.29],tableWall:[.24,.21,.18]},Ue={top:[.05,.06,.08],bottom:[.1,.12,.15]};function pe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function jr(){let t=typeof window<"u"&&window.devicePixelRatio||1,e=navigator.deviceMemory,n=typeof e=="number"&&e<=4?1.5:2;return Math.min(t,n)}var At=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new Wr({canvas:this.canvas,dpr:jr(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[Ue.top[0],Ue.top[1],Ue.top[2]],this.gl.clearColor(this.clearRgb[0],this.clearRgb[1],this.clearRgb[2],1),e.appendChild(this.canvas),this.lostHandler=i=>{i.preventDefault(),n.onContextLost()},this.restoredHandler=()=>n.onContextRestored(),this.canvas.addEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.addEventListener("webglcontextrestored",this.restoredHandler,!1),this.resize()}setClearColor(e){this.clearRgb=[e[0],e[1],e[2]],this.gl.clearColor(e[0],e[1],e[2],1)}get clearColor(){return this.clearRgb}resize(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||1),n=Math.max(1,this.container.clientHeight||this.canvas.clientHeight||1);return this.renderer.setSize(e,n),{width:e,height:n}}get pixelHeight(){return this.renderer.height*this.renderer.dpr}get aspect(){return this.renderer.width/Math.max(1,this.renderer.height)}dispose(){this.canvas.removeEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this.restoredHandler,!1);let e=this.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}simulateContextLossCycle(){let e=this.gl.getExtension("WEBGL_lose_context");e&&(e.loseContext(),setTimeout(()=>{e.restoreContext&&e.restoreContext()},300))}};import{Camera as qr,Vec3 as Qt}from"ogl";var ue=Math.PI/180,$t=15*ue,Jt=80*ue,Ke=.12,Wn=35,jn=1.25,Ct=class{constructor(e,n,i,o){this.fovY=Wn;this.target=new Qt;this.azimuth=-30*ue;this.polar=55*ue;this.distance=10;this.azT=-30*ue;this.polT=55*ue;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new Qt;this.panAnchor=new Qt;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new qr(e,{fov:Wn,near:.1,far:5e3,aspect:1}),this.canvas=n,this.requestRender=i,this.onGesture=o,this.onPointerDown=r=>{if(this.interactionEnabled){try{this.canvas.setPointerCapture?.(r.pointerId)}catch{}if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size===1){let a=r.button===2||r.button===1,s=r.button===0&&(r.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=a||s,this.dragging=!this.panning,this.lastX=r.clientX,this.lastY=r.clientY}else if(this.activePointers.size===2){this.dragging=!1,this.panning=!1,this.pinchDist=this.currentPinchDistance();let a=this.pinchCentroid();this.pinchCx=a.x,this.pinchCy=a.y}}},this.onPointerMove=r=>{if(!this.interactionEnabled||!this.activePointers.has(r.pointerId))return;if(this.activePointers.set(r.pointerId,{x:r.clientX,y:r.clientY}),this.activePointers.size>=2){let l=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-l)*.005)),this.fireGesture()),this.pinchDist=l;let c=this.pinchCentroid();this.panBy(c.x-this.pinchCx,c.y-this.pinchCy),this.pinchCx=c.x,this.pinchCy=c.y;return}let a=r.clientX-this.lastX,s=r.clientY-this.lastY;if(this.panning){this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&(this.panBy(a,s),this.fireGesture());return}this.dragging&&(this.lastX=r.clientX,this.lastY=r.clientY,(a!==0||s!==0)&&this.fireGesture(),this.azT-=a*.006,this.polT=Math.max($t,Math.min(Jt,this.polT-s*.006)),this.requestRender())},this.onPointerUp=r=>{this.activePointers.delete(r.pointerId);try{this.canvas.releasePointerCapture?.(r.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=r=>{r.preventDefault()},this.onWheel=r=>{if(r.preventDefault(),!this.interactionEnabled)return;let a=r.deltaMode===1?16:r.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,r.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=r=>{if(!this.interactionEnabled)return;let a=7*ue;if(r.shiftKey&&(r.key==="ArrowLeft"||r.key==="ArrowRight"||r.key==="ArrowUp"||r.key==="ArrowDown"))this.panBy(r.key==="ArrowLeft"?-32:r.key==="ArrowRight"?32:0,r.key==="ArrowUp"?-32:r.key==="ArrowDown"?32:0);else if(r.key==="ArrowLeft"||r.key==="ArrowRight")this.azT+=r.key==="ArrowLeft"?-a:a;else if(r.key==="ArrowUp"||r.key==="ArrowDown")this.polT=Math.max($t,Math.min(Jt,this.polT+(r.key==="ArrowUp"?-a:a)));else if(r.key==="+"||r.key==="=")this.dollyBy(.82);else if(r.key==="-"||r.key==="_")this.dollyBy(1.22);else return;r.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,i=0;for(let o of e)n+=o.x,i+=o.y;return{x:n/e.length,y:i/e.length}}panBy(e,n){let i=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/i,r=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-r,c=Math.cos(this.polar),h=Math.sin(this.polar),m=-r*c,d=-a*c;this.targetT.x+=(-e*s+n*m)*o,this.targetT.z+=(-e*l+n*d)*o,this.targetT.y+=n*h*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,i=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(i-e*.5,Math.min(i+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,i,o=!1,r){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*ue/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,c=Math.atan(Math.tan(s)*l);this.azT=i??-30*ue,this.polT=Math.max(15,Math.min(80,r?.polarDeg??55))*ue;let h=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=h*Math.max(1.05,Math.min(2,r?.margin??jn)),this.minDist=Math.max(2,a*.12),this.maxDist=h*4,n?(this.azimuth=this.azT,this.polar=12*ue,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,i=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let r=this.fovY*ue/2,a=i?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(r)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let l=this.fitDistance(e,r,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??jn))}fitDistance(e,n,i,o,r){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(i)),l=e.box;if(!l)return s;let c=Math.sin(r),h=-c*Math.sin(o),m=-Math.cos(r),d=-c*Math.cos(o);if(Math.abs(m)>.999)return s;let p=-d,f=h,u=Math.hypot(p,f);p/=u,f/=u;let b=-f*m,y=f*h-p*d,x=p*m,v=Math.tan(i),k=Math.tan(n),P=1;for(let M=0;M<8;M++){let F=(M&1?l.max[0]:l.min[0])-e.center[0],O=(M&2?l.max[1]:l.min[1])-e.center[1],L=(M&4?l.max[2]:l.min[2])-e.center[2],H=F*h+O*m+L*d,_=Math.abs(F*p+L*f),g=Math.abs(F*b+O*y+L*x);P=Math.max(P,_/v-H,g/k-H)}return Math.min(s,Math.max(P,a*.35))}updateClipping(e){let n=this.camera.position.x-e.center[0],i=this.camera.position.y-e.center[1],o=this.camera.position.z-e.center[2],r=Math.hypot(n,i,o),a=Math.max(1,e.radius)*1.18,s=Math.max(.05,r-a),l=Math.max(s+10,r+a);this.camera.perspective({near:s,far:l,aspect:this.camera.aspect})}update(){let e=this.azT-this.azimuth,n=this.polT-this.polar,i=this.distT-this.distance,o=this.targetT.x-this.target.x,r=this.targetT.y-this.target.y,a=this.targetT.z-this.target.z,s=Math.max(1e-4,this.distance*1e-4),l=Math.abs(e)>1e-4||Math.abs(n)>1e-4||Math.abs(i)>1e-4||Math.abs(o)>s||Math.abs(r)>s||Math.abs(a)>s;return this.azimuth+=e*Ke,this.polar+=n*Ke,this.distance+=i*Ke,this.target.x+=o*Ke,this.target.y+=r*Ke,this.target.z+=a*Ke,l&&this.applyPosition(),l}get currentDistance(){return this.distance}syncFromCamera(){let e=this.camera.position.x-this.target.x,n=this.camera.position.y-this.target.y,i=this.camera.position.z-this.target.z,o=Math.hypot(e,n,i)||1,r=Math.max($t,Math.min(Jt,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=r,this.azimuth=this.azT=Math.atan2(e,i)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),i=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,i,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var Rt=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var Ze=2.5,Kr=1.15,lt=6,Qe=10,qn=6,Kn=9.5,Zn=.9,Qn=2.2,en=30,tn=4,It=8192;var fs=Qe+tn;function $n(t,e){let n=e*1.4,i=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Ze};let o=Math.min(1,(t-n)/Math.max(.001,i-n));return{scale:1-o*.4,fade:o*.55,minPixels:Ze+o*(Kr-Ze)}}function Jn(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function eo(t,e,n,i,o){if(!(t>0)||!(e>0)||!(n>0)||!(i>0)||!(o>0))return!1;let r=Math.tan(i/2*Math.PI/180);if(!(r>0))return!1;let a=e/(n*r)*(o/2);return Math.PI*a*a/t>=64}import Zr from"earcut";import Qr from"polygon-clipping";var R=ke,$r=.002;function Jr(t,e,n){let i=Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]),o=Math.hypot(n[0]-e[0],n[1]-e[1],n[2]-e[2]),r=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]),a=Math.max(i,o,r);if(a<1e-9)return!0;let s=(i+o+r)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-o)*(s-r)))/a<$r}var Xe=class{constructor(e=16384){this.len=0;this.buf=new Float32Array(e)}push3(e,n,i){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=e,this.buf[this.len++]=n,this.buf[this.len++]=i}push1(e){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=e}grow(e){let n=this.buf.length*2;for(;n<e;)n*=2;let i=new Float32Array(n);i.set(this.buf.subarray(0,this.len)),this.buf=i}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Et=class{constructor(){this.pos=new Xe;this.nor=new Xe;this.col=new Xe;this.flr=new Xe;this.mat=new Xe;this.currentFloor=0;this.currentMaterial=0}setFloor(e){this.currentFloor=e}setMaterial(e){this.currentMaterial=e}tri(e,n,i,o,r,a=r,s=r){Jr(e,n,i)||(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(e,n,i,o,r,a,s,l=s,c=s){[...e,...n,...i].every(Number.isFinite)&&(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function ei(t,e,n){let i=e[0]-t[0],o=e[1]-t[1],r=e[2]-t[2],a=n[0]-t[0],s=n[1]-t[1],l=n[2]-t[2],c=o*l-r*s,h=r*a-i*l,m=i*s-o*a,d=Math.hypot(c,h,m)||1;return c/=d,h/=d,m/=d,[c,h,m]}function ti(t,e){let n=[...t],i=[];for(let a of t)i.push(a.x,a.y);let o=[];if(e){for(let a of e)if(!(a.length<3)){o.push(n.length);for(let s of a)n.push(s),i.push(s.x,s.y)}}let r=Zr(i,o.length?o:void 0,2);return{pts:n,tris:r}}function nn(t){return He(t)<0?[...t].reverse():t}var ni=3;function oi(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(p,f,u,b)=>Math.abs(i({x:(p.x+f.x)/2,y:(p.y+f.y)/2})-(u+b)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,h=(o+r+a)/3,m=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:l,y:c})-h)),d=(p,f,u)=>{let b=Math.abs(i({x:(p+l)/2,y:(f+c)/2})-(u+h)/2);b>m&&(m=b)};return d((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),d((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),d((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),m}function ut(t,e,n,i,o){if(o<=0)return oi(t,e,n,i);let r={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(n.x+t.x)/2,y:(n.y+t.y)/2};return Math.max(ut(t,r,s,i,o-1),ut(r,e,a,i,o-1),ut(s,a,n,i,o-1),ut(r,a,s,i,o-1))}function mt(t,e,n,i,o,r,a,s){if(a>0){let d={x:(e.x+n.x)/2,y:(e.y+n.y)/2},p={x:(n.x+i.x)/2,y:(n.y+i.y)/2},f={x:(i.x+e.x)/2,y:(i.y+e.y)/2};mt(t,e,d,f,o,r,a-1,s),mt(t,d,n,p,o,r,a-1,s),mt(t,f,p,i,o,r,a-1,s),mt(t,d,p,f,o,r,a-1,s);return}let l=[e.x*R,o(e),e.y*R],c=[n.x*R,o(n),n.y*R],h=[i.x*R,o(i),i.y*R];if(s){t.triN(l,c,h,s(e),s(n),s(i),r);return}let m=ei(l,c,h);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,h,m,r)}var ri=8;function to(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let h={x:(r.x+a.x)/2,y:(r.y+a.y)/2},m=e(h);if(Math.abs(m-(s+l)/2)>n){o(r,h,s,m,c-1),o(h,a,m,l,c-1);return}}i.push(r)};for(let r=0;r<t.length;r++){let a=t[r],s=t[(r+1)%t.length];o(a,s,e(a),e(s),ri)}return i}function Tt(t,e){if(t.length<3)return t;let n=[];for(let o of t){let r=n[n.length-1];r&&Math.hypot(o.x-r.x,o.y-r.y)<e||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<e;)n.pop();if(n.length<3)return t;let i=[];for(let o=0;o<n.length;o++){let r=i.length?i[i.length-1]:n[(o-1+n.length)%n.length],a=n[o],s=n[(o+1)%n.length],l=s.x-r.x,c=s.y-r.y,h=Math.hypot(l,c);h>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/h<e||i.push(a)}return i.length>=3?i:n}var Ft=.001*Le*.1;function ie(t,e,n,i,o,r,a,s,l=1/0,c){if(!e||e.length<3||(l===void 0&&(l=1/0),Math.abs(He(e))<1e-4))return;let h=Tt(to(Tt(nn(e),Ft),i,l),Ft),m=n?.map(M=>Tt(to(Tt(nn(M),Ft),i,l),Ft)).filter(M=>M.length>=3&&Math.abs(He(M))>=1e-4),{pts:d,tris:p}=ti(h,m),f=[r[0]*s.top,r[1]*s.top,r[2]*s.top],u=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],b=[a[0]*s.top,a[1]*s.top,a[2]*s.top],y=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<ni;x++){let M=0;for(let F=0;F<p.length;F+=3){let O=ut(d[p[F]],d[p[F+1]],d[p[F+2]],i,x);O>M&&(M=O)}if(M<=l)break}for(let M=0;M<p.length;M+=3){let F=d[p[M]],O=d[p[M+1]],L=d[p[M+2]];mt(t,F,O,L,i,f,x,c);let H=[F.x*R,o,F.y*R],_=[O.x*R,o,O.y*R],g=[L.x*R,o,L.y*R];t.tri(H,g,_,[0,-1,0],u)}let v=M=>{if(x<=0)return M;let F=1<<x,O=[];for(let L=0;L<M.length;L++){let H=M[L],_=M[(L+1)%M.length];for(let g=0;g<F;g++){let w=g/F;O.push({x:H.x+(_.x-H.x)*w,y:H.y+(_.y-H.y)*w})}}return O},k=Rn(h),P=[{ring:v(h),flip:!1}];if(m)for(let M of m)M.length>=3&&P.push({ring:v(M),flip:!0});for(let{ring:M,flip:F}of P)for(let O=0;O<M.length;O++){let L=M[O],H=M[(O+1)%M.length],_=(H.x-L.x)*R,w=(H.y-L.y)*R,E=-_,C=Math.hypot(w,E)||1;w/=C,E/=C;let N=(L.x+H.x)/2-k.x,S=(L.y+H.y)/2-k.y,I=w*N+E*S;F&&(I=-I),I<0&&(w=-w,E=-E);let T=[w,0,E],B=[L.x*R,i(L),L.y*R],A=[H.x*R,i(H),H.y*R],D=[L.x*R,o,L.y*R],V=[H.x*R,o,H.y*R];t.tri(B,A,V,T,b,b,y),t.tri(B,V,D,T,b,y,y)}}function no(t){let e=0;for(let l of t)e+=l.count;let n=new Float32Array(e*3),i=new Float32Array(e*3),o=new Float32Array(e*3),r=new Float32Array(e),a=new Float32Array(e),s=0;for(let l of t)n.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),r.set(l.floor,s),a.set(l.material,s),s+=l.count;return{position:n,normal:i,color:o,floor:r,material:a,count:e}}function Dt(t,e,n=2.5){if(e<=0||t.length<3)return t;let i=nn(t),o=i.length,r=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],h=c.x-l.x,m=c.y-l.y,d=Math.hypot(h,m)||1;r.push({x:m/d,y:-h/d})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],h=r[s],m=c.x+h.x,d=c.y+h.y,p=Math.hypot(m,d),f=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+h.x*e,l.y+h.y*e])};if(p<1e-9){f();continue}m/=p,d/=p;let u=m*c.x+d*c.y,b=1/Math.max(u,1e-6);if(!Number.isFinite(b)||b>n){f();continue}a.push([l.x+m*e*b,l.y+d*e*b])}if(a.length<3)return t;try{let s=Qr.union([[...a,a[0]]]),l=null,c=-1/0;for(let m of s){let d=Math.abs(He(m[0].map(([p,f])=>({x:p,y:f}))));d>c&&(c=d,l=m[0])}if(!l)return t;let h=l.map(([m,d])=>({x:m,y:d}));if(h.length>1){let m=h[0],d=h[h.length-1];Math.abs(m.x-d.x)<1e-9&&Math.abs(m.y-d.y)<1e-9&&h.pop()}return h.length>=3?h:t}catch{return t}}function kt(t,e,n,i,o=28){let r=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;r.push({x:t+n*Math.cos(s),y:e+i*Math.sin(s)})}return r}function dt(t,e,n,i){return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+i},{x:t,y:e+i}]}var ce={pedestal:0,pad:1,back:2,body:3,head:4},ii=.44,ai=.15,si=.3,ci=.24;function oo(t){return t===void 0||!Number.isFinite(t)||t<=0?ci:Math.min(si,Math.max(ai,t*ii))}var on=.21,li=.05,rn=.45,Lt=rn+li,ui=[{part:ce.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ce.pad,min:[-1,.36,-.95],max:[1,rn,1]},{part:ce.back,min:[-1,Lt,-1],max:[1,.92,-.72]}],mi=[{part:ce.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ce.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ce.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ce.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ce.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],di=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function ro(){let t=[],e=[],n=[],i=[],o=(C,N,S)=>{let I=n.length,[T,B,A]=C,D=[B[0]-T[0],B[1]-T[1],B[2]-T[2]],V=[A[0]-T[0],A[1]-T[1],A[2]-T[2]],U=D[1]*V[2]-D[2]*V[1],Y=D[2]*V[0]-D[0]*V[2],X=D[0]*V[1]-D[1]*V[0],j=Math.hypot(U,Y,X);j>1e-9?(U/=j,Y/=j,X/=j):[U,Y,X]=N,U*N[0]+Y*N[1]+X*N[2]<0&&(U=-U,Y=-Y,X=-X);for(let K of C)t.push(...K),e.push(U,Y,X),n.push(S);i.push(I,I+1,I+2,I,I+2,I+3)},r=C=>{for(let N of di){let S=N.c.map(I=>I.map((T,B)=>T?C.max[B]:C.min[B]));o(S,N.n,C.part)}};for(let C of ui)r(C);for(let C of mi)r(C);let a=rn,s=1.08,l=.47,c=.69,h=-.55,m=.08,d=-.48,p=.01,f=[-l,a,h],u=[l,a,h],b=[-l,a,m],y=[l,a,m],x=[-c,s,d],v=[c,s,d],k=[-c,s,p],P=[c,s,p];o([u,v,P,y],[1,0,0],ce.body),o([b,k,x,f],[-1,0,0],ce.body),o([k,P,v,x],[0,1,0],ce.body),o([f,u,y,b],[0,-1,0],ce.body),o([y,P,k,b],[0,0,1],ce.body),o([f,x,v,u],[0,0,-1],ce.body);let M=10,F=8,O=[0,1.205,-.23],L=[.42,.115,.38],H=n.length;for(let C=0;C<=F;C++){let N=Math.PI*C/F,S=Math.cos(N),I=Math.sin(N);for(let T=0;T<=M;T++){let B=Math.PI*2*T/M,A=I*Math.cos(B),D=I*Math.sin(B);t.push(O[0]+L[0]*A,O[1]+L[1]*S,O[2]+L[2]*D);let V=A/L[0],U=S/L[1],Y=D/L[2],X=Math.hypot(V,U,Y)||1;V/=X,U/=X,Y/=X,e.push(V,U,Y),n.push(ce.head)}}for(let C=0;C<F;C++)for(let N=0;N<M;N++){let S=H+C*(M+1)+N,I=S+M+1;i.push(S,I,S+1,S+1,I,I+1)}let _=new Float32Array(t),g=new Float32Array(e),w=new Float32Array(n),E=new Uint16Array(i);return{position:_,normal:g,part:w,index:E,vertexCount:n.length,indexCount:i.length}}function io(t,e,n,i){let o=new Float32Array(e),r=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,h)=>{let m=h-c;for(let d=c;d<h;d++){let[p,f]=i(d),u=p-r(d),b=f-a(d);if(m>=2){let y=Math.max(c,d-1),x=Math.min(h-1,d+1),v=r(x)-r(y),k=a(x)-a(y),P=Math.hypot(v,k);if(P>1e-6){let M=-k/P,F=v/P;M*u+F*b<0&&(M=-M,F=-F),u=M,b=F}}o[d]=u===0&&b===0?0:Math.atan2(u,b)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var Re=.22;function ao(t,e){let n=be[t];if(n!=="sold"&&n!=="held")return-1;let i=(e+1)*2654435761;return i^=i>>>15,i=Math.imul(i,2246822519),i^=i>>>13,(i>>>0)%1e5/1e5}var hi=.42;function pi(t){let e=t.length,n=new Float64Array(e);if(e<2)return n.fill(1/0),n;let i=1/0,o=1/0,r=-1/0,a=-1/0;for(let f of t)f.x<i&&(i=f.x),f.y<o&&(o=f.y),f.x>r&&(r=f.x),f.y>a&&(a=f.y);let s=Math.max(r-i,1e-6),l=Math.max(a-o,1e-6),c=Math.max(Math.sqrt(s*l/e),1e-6),h=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),d=new Map,p=(f,u)=>{let b=Math.min(h-1,Math.max(0,Math.floor((f-i)/c)));return Math.min(m-1,Math.max(0,Math.floor((u-o)/c)))*h+b};for(let f=0;f<e;f++){let u=p(t[f].x,t[f].y),b=d.get(u);b?b.push(f):d.set(u,[f])}for(let f=0;f<e;f++){let u=t[f],b=Math.min(h-1,Math.max(0,Math.floor((u.x-i)/c))),y=Math.min(m-1,Math.max(0,Math.floor((u.y-o)/c))),x=1/0;for(let v=1;v<=4;v++){for(let k=y-v;k<=y+v;k++)if(!(k<0||k>=m))for(let P=b-v;P<=b+v;P++){if(P<0||P>=h||v>1&&Math.abs(k-y)<v&&Math.abs(P-b)<v)continue;let M=d.get(k*h+P);if(M)for(let F of M){if(F===f)continue;let O=Math.hypot(t[F].x-u.x,t[F].y-u.y);O<x&&(x=O)}}if(Number.isFinite(x)&&x<=v*c)break}n[f]=x}return n}function fi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function so(t,e,n,i,o){let r=t.length,a=new Float32Array(r*3),s=new Float32Array(r),l=new Float32Array(r*3),c=new Float32Array(r),h=new Float32Array(r),m=new Float32Array(r),d=new Float32Array(r*3),p=new Map,f=pi(t);for(let u=0;u<r;u++){let b=t[u],x=(n?.seatPitchU(u)??f[u])*R;c[u]=Number.isFinite(x)?Math.max(.06,Math.min(Re,x*hi)):Re,h[u]=oo(Number.isFinite(x)?x:void 0),m[u]=b.wheelchairSpaceType==="no-seat"?0:1,a[u*3]=b.x*R,a[u*3+1]=n?n.seatDeckY(u):fi(b),a[u*3+2]=b.y*R,s[u]=ct(e?e(b):"available");let v=Z(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[u*3]=v[0],l[u*3+1]=v[1],l[u*3+2]=v[2],b.accessibility?.length){let k=Z(Cn(b.accessibility));k&&(d[u*3]=k[0],d[u*3+1]=k[1],d[u*3+2]=k[2])}p.set(b.id,u)}return{count:r,iPosition:a,iState:s,iCategory:l,iMaxRadius:c,iRing:d,idToIndex:p,iChairWidth:h,iPhysicalSeat:m,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var bi=64;function an(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=ct(a.state);t.iState[s]!==l&&(t.iState[s]=l,n.push(s))}if(!n.length)return[];n.sort((a,s)=>a-s);let i=[],o=n[0],r=n[0];for(let a=1;a<n.length;a++){let s=n[a];if(s!==r){if(s<=r+bi){r=s;continue}i.push({start:o,length:r-o+1}),o=s,r=s}}return i.push({start:o,length:r-o+1}),i}var yi=.15,xi=.9,gi=1.76,vi=.7,Mi=1.6;function Si(){return{background:{top:[...Ue.top],bottom:[...Ue.bottom]},structure:Zt,seatStates:{...Xn},seatScale:1}}function co(t){let e=Si();if(!t)return e;let n=Z(t.background);if(n){e.background={top:pe(n,xi),bottom:pe(n,gi)};let r={};for(let[a,s]of Object.entries(Zt))r[a]=he(s,n,yi);e.structure=r}let i=Z(t.selectionColor)??Z(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(Mi,Math.max(vi,o))),e}function lo(t,e){let n=[];for(let i of e)n.push(...t.seatStates[i]);return n}import po from"polygon-clipping";import wi from"earcut";var Pi=.58,uo=.01,fe=Re*1.5*Le,Ai=.5,Ci=.6;function Ri(t,e){let n=t.length,i=[];for(let a=0;a<n;a++){let s=t[Math.max(0,a-1)],l=t[Math.min(n-1,a+1)],c=l.x-s.x,h=l.y-s.y,m=Math.hypot(c,h);if(m<1e-9){i.push([0,0]);continue}c/=m,h/=m,i.push([-h,c])}let o=0;for(let a=0;a<n;a++)o+=(t[a].x-e.x)*i[a][0]+(t[a].y-e.y)*i[a][1];return o<0?i.map(([a,s])=>[-a,-s]):i}function Ii(t,e){if(t.length<2||e<=0)return[...t];let n=[...t],i=(a,s)=>{let l=s.x-a.x,c=s.y-a.y,h=Math.hypot(l,c)||1;return{x:l/h,y:c/h}},o=i(n[1],n[0]),r=i(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*e,y:n[0].y+o.y*e}),n.push({x:n[n.length-1].x+r.x*e,y:n[n.length-1].y+r.y*e}),n}var mo=Math.PI/12;function Ti(t){if(t.length<3)return[...t];let e=[...t].sort((r,a)=>r.x-a.x||r.y-a.y),n=(r,a,s)=>(a.x-r.x)*(s.y-r.y)-(a.y-r.y)*(s.x-r.x),i=r=>{let a=[];for(let s of r){for(;a.length>=2&&n(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),a},o=[...i(e),...i([...e].reverse())];return o.length>=3?o:[...t]}function fo(t,e){if(!t.length||!(e>0))return[];let n=Ti(t),i=(s,l,c,h)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let d=Math.max(1,Math.ceil(m/mo)),p=e/Math.cos(m/d/2);for(let f=0;f<=d;f++){let u=l+m*f/d;h.push({x:s.x+Math.cos(u)*p,y:s.y+Math.sin(u)*p})}};if(n.length<3){let s=0,l=0;for(let p of n)s+=p.x,l+=p.y;s/=n.length||1,l/=n.length||1;let c=0;for(let p of n)c=Math.max(c,Math.hypot(p.x-s,p.y-l));let h=[],m=Math.max(3,Math.ceil(Math.PI*2/mo)),d=(c+e)/Math.cos(Math.PI/m);for(let p=0;p<m;p++){let f=p/m*Math.PI*2;h.push({x:s+Math.cos(f)*d,y:l+Math.sin(f)*d})}return h}let o=n.length,r=[];for(let s=0;s<o;s++){let l=n[s],c=n[(s+1)%o];r.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let a=[];for(let s=0;s<o;s++)i(n[s],r[(s+o-1)%o],r[s],a);return vo(a)}function Fi(t,e,n){if(t.length===1)return Math.hypot(e-t[0].x,n-t[0].y);let i=1/0;for(let o=0;o+1<t.length;o++){let r=t[o],a=t[o+1],s=a.x-r.x,l=a.y-r.y,c=s*s+l*l,h=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;h<0?h=0:h>1&&(h=1);let m=Math.hypot(e-(r.x+h*s),n-(r.y+h*l));m<i&&(i=m)}return i}function _t(t){let e=t.map(o=>{let r=0,a=0;for(let c of o.pts)r+=c.x,a+=c.y;let s=o.pts.length||1;r/=s,a/=s;let l=0;for(let c of o.pts){let h=Math.hypot(c.x-r,c.y-a);h>l&&(l=h)}return{cx:r,cy:a,rad:l}}),n=o=>{let r=o.length;return r<=2?[...o]:[o[Math.floor(r*.25)],o[Math.floor(r*.5)],o[Math.floor(r*.75)]]},i=[];for(let o=0;o<t.length;o++){let r=n(t[o].pts),a=[],s=1/0,l=null;for(let h of r){let m=1/0;for(let d=0;d<t.length;d++){if(d===o||Math.abs(t[d].y-t[o].y)<.001)continue;let p=e[d],f=Math.hypot(h.x-p.cx,h.y-p.cy)-p.rad;if(f>=m&&f>=s)continue;let u=Fi(t[d].pts,h.x,h.y);u<m&&(m=u),t[d].depth<t[o].depth&&u<s&&(s=u,l=t[d].y)}Number.isFinite(m)&&m>0&&a.push(m)}a.sort((h,m)=>h-m);let c=a.length?a[Math.floor(a.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function bo(t,e,n,i){let o=t[e],r=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let h=o.pts[0],m=h.x-i.x,d=h.y-i.y,p=Math.hypot(m,d)||1;m/=p,d/=p;let f=Math.max(n[e].pitch,.001)*.5;return[{x:h.x+d*f,y:h.y-m*f},{x:h.x-d*f,y:h.y+m*f}]})():[];if(r.length<2)return null;let a=0,s=0;for(let h=1;h<r.length;h++){let m=Math.hypot(r[h].x-r[h-1].x,r[h].y-r[h-1].y);m>1e-6&&(a+=m,s++)}let l=s>0?a/s:0,c=Ii(r,Math.max(l*Ci,fe));return{pts:c,nrm:Ri(c,i),front:Math.max(n[e].pitch*Pi,fe),back:Math.max(n[e].pitch*Ai,fe)}}var $e=1.5,yo=.3;function sn(t,e){if(t.length<3)return t;let n=t[0],i=t[t.length-1],o=i.x-n.x,r=i.y-n.y,a=Math.hypot(o,r),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let d=t[m],p=a>1e-12?Math.abs((d.x-n.x)*r-(d.y-n.y)*o)/a:Math.hypot(d.x-n.x,d.y-n.y);p>s&&(s=p,l=m)}if(s<=e||l<0)return[n,i];let c=sn(t.slice(0,l+1),e),h=sn(t.slice(l),e);return[...c.slice(0,-1),...h]}function xo(t,e){if(t.length<4)return t;let n=sn([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function go(t,e,n){if(t.length<2)return[];let i=n??_t(t),o=new Map;for(let a=0;a<t.length;a++){let s=o.get(t[a].blockId);s?s.push(a):o.set(t[a].blockId,[a])}let r=[];for(let[,a]of o){let s=[];for(let x of a){let v=t[x].patch;v&&v.length>=3?r.push({outline:[...v],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,v)=>t[x].depth-t[v].depth);let c=s.map(x=>bo(t,x,i,e)).filter(x=>x!==null);if(!c.length)continue;let h=(x,v)=>({x:x.pts[v].x-x.nrm[v][0]*(x.front+$e),y:x.pts[v].y-x.nrm[v][1]*(x.front+$e)}),m=(x,v)=>({x:x.pts[v].x+x.nrm[v][0]*(x.back+$e),y:x.pts[v].y+x.nrm[v][1]*(x.back+$e)}),d=c[0],p=c[c.length-1],f=[];for(let x=0;x<d.pts.length;x++)f.push(h(d,x));for(let x of c)f.push(m(x,x.pts.length-1));for(let x=p.pts.length-1;x>=0;x--)f.push(m(p,x));for(let x=c.length-1;x>=0;x--)f.push(h(c[x],0));let u=vo(f),b=1/0;for(let x of s)t[x].y<b&&(b=t[x].y);if(!Number.isFinite(b))continue;if(u.length>=3&&Math.abs(He(u))>1e-6&&c.every(x=>{let v=x.pts[Math.floor(x.pts.length/2)];return st(u,v.x,v.y)})){r.push({outline:xo(u,yo),holes:[],topY:b});continue}for(let x of Ei(c))r.push({outline:x,holes:[],topY:b})}return r}function Ei(t){let e=[];for(let n of t){let i=[],o=[],r=n.front+$e,a=n.back+$e;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],h=n.nrm[l];i.push([c.x-h[0]*r,c.y-h[1]*r]),o.push([c.x+h[0]*a,c.y+h[1]*a])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=po.union(e[0],...e.slice(1)),i=[];for(let o of n){if(!o.length||o[0].length<4)continue;let r=o[0].map(([l,c])=>({x:l,y:c})),a=r[0],s=r[r.length-1];r.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&r.pop(),r.length>=3&&i.push(xo(r,yo))}return i}catch{return[]}}function vo(t){let e=[];for(let n of t){let i=e[e.length-1];i&&Math.hypot(n.x-i.x,n.y-i.y)<1e-9||e.push(n)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<1e-9;)e.pop();return e}var cn=class{constructor(e){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=e;for(let n of e)for(let i of n)i.x<this.minX&&(this.minX=i.x),i.y<this.minY&&(this.minY=i.y),i.x>this.maxX&&(this.maxX=i.x),i.y>this.maxY&&(this.maxY=i.y)}containsAll(e){for(let n of e)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let i=!0;for(let o of e)if(!st(n,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function ho(t,e,n,i,o,r){if(i.length<3)return;if(n.containsAll(i)){let c=[0,1,0],h=i[0];for(let m=1;m+1<i.length;m++){let d=i[m],p=i[m+1];t.tri([h.x*R,o,h.y*R],[d.x*R,o,d.y*R],[p.x*R,o,p.y*R],c,r)}return}let a=i.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=po.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let h=c[0],m=[],d=[];for(let f=0;f<h.length-1;f++)m.push(h[f][0],h[f][1]),d.push([h[f][0],h[f][1]]);if(d.length<3)continue;let p=wi(m,void 0,2);for(let f=0;f<p.length;f+=3){let u=d[p[f]],b=d[p[f+1]],y=d[p[f+2]];t.tri([u[0]*R,o,u[1]*R],[b[0]*R,o,b[1]*R],[y[0]*R,o,y[1]*R],l,r)}}}function Mo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??_t(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(p=>[p.x,p.y]),[r[0].x,r[0].y]]]:null,h=r&&r.length>=3?new cn([[...r]]):null,m=p=>{t.setMaterial(2),p(),t.setMaterial(0)},d=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let f=e[p];if(f.patch&&f.patch.length>=3){let P=[...f.patch],M=s[p].belowY??i;if(d(()=>{if(c&&h)ho(t,c,h,P,f.y,o.tread);else{let F=P[0];for(let O=1;O+1<P.length;O++){let L=P[O],H=P[O+1];t.tri([F.x*R,f.y,F.y*R],[L.x*R,f.y,L.y*R],[H.x*R,f.y,H.y*R],l,o.tread)}}}),f.y>M+uo){let F=0,O=0;for(let L of P)F+=L.x,O+=L.y;F/=P.length,O/=P.length,m(()=>{for(let L=0;L<P.length;L++){let H=P[L],_=P[(L+1)%P.length],g=_.x-H.x,w=_.y-H.y,E=Math.hypot(g,w);if(E<1e-6)continue;let C=w/E,N=-g/E;(H.x-F)*C+(H.y-O)*N<0&&(C=-C,N=-N);let S=[C,0,N],I=[H.x*R,f.y,H.y*R],T=[_.x*R,f.y,_.y*R],B=[H.x*R,M,H.y*R],A=[_.x*R,M,_.y*R];t.tri(I,T,A,S,o.riser),t.tri(I,A,B,S,o.riser)}})}continue}let u=bo(e,p,s,n);if(!u)continue;let{pts:b,nrm:y,front:x,back:v}=u,k=s[p].belowY??i;for(let P=0;P+1<b.length;P++){let M=b[P],F=b[P+1],O=y[P],L=y[P+1];if(Math.hypot(F.x-M.x,F.y-M.y)<1e-6||O[0]===0&&O[1]===0||L[0]===0&&L[1]===0)continue;let H=[(M.x-O[0]*x)*R,f.y,(M.y-O[1]*x)*R],_=[(F.x-L[0]*x)*R,f.y,(F.y-L[1]*x)*R],g=[(M.x+O[0]*v)*R,f.y,(M.y+O[1]*v)*R],w=[(F.x+L[0]*v)*R,f.y,(F.y+L[1]*v)*R];if(d(()=>{c&&h?ho(t,c,h,[{x:M.x-O[0]*x,y:M.y-O[1]*x},{x:F.x-L[0]*x,y:F.y-L[1]*x},{x:F.x+L[0]*v,y:F.y+L[1]*v},{x:M.x+O[0]*v,y:M.y+O[1]*v}],f.y,o.tread):(t.tri(H,_,w,l,o.tread),t.tri(H,w,g,l,o.tread))}),f.y>k+uo){let E=[H[0],k,H[2]],C=[_[0],k,_[2]],N=[-O[0],0,-O[1]];m(()=>{t.tri(H,_,C,N,o.riser),t.tri(H,C,E,N,o.riser)})}}}}import wo from"polygon-clipping";function Di(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function So(t,e){return t.filter(n=>n.type!=="shape"||Di(n,e))}function Po(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:So(i.objects,e),focal:{x:(i.focalPoint??n).x,y:(i.focalPoint??n).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:So(t.objects,e),focal:n,baseHeightM:0,index:0}]}var ki={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Dn(t)??ki}function Ao(t,e){let n=Dt(t.outline,fe),i=Je(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(i,Je(a.outline)));if(!o.length)return[n];let r=a=>{let s=a.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let a=wo.difference([r(n)],...o.map(l=>[r(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function Co(t,e){if(!e.length)return t;let n=r=>{let a=r.map(s=>[s.x,s.y]);return a.push(a[0]),a},i=e.map(r=>[n(r)]),o=[];for(let r of t){let a;try{a=wo.intersection([n(r.outline)],i.flat())}catch{o.push(r);continue}for(let s of a){if(!s.length)continue;let l=s[0].map(([c,h])=>({x:c,y:h}));if(l.length>1){let c=l[0],h=l[l.length-1];Math.abs(c.x-h.x)<1e-9&&Math.abs(c.y-h.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:r.topY})}}return o.length?o:t}var Li=.05,Ro=.05,_i=.15,ln=25;function Io(t,e,n){let i=new Map,o=new Array(e.length).fill(null),r=new Float64Array(e.length),a=new Array(e.length).fill(void 0),s=new Array(e.length).fill(void 0),l=new Map,c=[],h=new Set;for(let m=0;m<t.length;m+=1){let d=t[m];for(let p of d.objects){if(p.type==="table"&&h.add(p.id),p.type!=="section"||!p.outline||p.outline.length<3)continue;let f=Dt(p.outline,fe);l.set(p.id,{section:p,unit:d,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:p.id,floorIndex:m,box:Je(f),section:p,unit:d,outline:f})}}for(let m=0;m<e.length;m++){let d=e[m];for(let p of c){if(n&&p.floorIndex!==n[m]||d.x<p.box.minX||d.x>p.box.maxX||d.y<p.box.minY||d.y>p.box.maxY||!Fn({x:d.x,y:d.y},p.outline,p.section.holes))continue;o[m]=p.id;let f=l.get(p.id);f.hasSeats=!0;let u=d.focalPoint??p.unit.focal,b=Math.hypot(d.x-u.x,d.y-u.y);b<f.frontU&&(f.frontU=b),f.seatIndices.push(m);let y=d.rowId||`__seat-${m}`,x=f.rows.get(y);x?x.push({x:d.x,y:d.y}):f.rows.set(y,[{x:d.x,y:d.y}]);break}}for(let[m,d]of l){let p=In(d.section,{floorBaseHeightM:d.unit.baseHeightM}),f=d.unit.baseHeightM,u=p.rake>0?Math.tan(p.rake*Math.PI/180):0,b=p.rake<=.01&&p.height<=f+.001,y=d.section.surfaceKind,x=y==="flat"?!0:y==="rakedRows"&&p.rake>.01?!1:b,v=d.hasSeats?Tn(m,e,d.seatIndices,d.unit.focal):{sectionId:m,rows:[],blockCount:0},P=v.rows.length<2?Bn([...d.rows.values()].map(S=>({points:S})),d.unit.focal):null,M=1/0;if(P){if(d.hasSeats)for(let S of d.rows.values())for(let I of S){let T=P.depthAt(I.x,I.y);T<M&&(M=T)}if(!d.hasSeats||!Number.isFinite(M)){M=1/0;for(let S of d.section.outline){let I=P.depthAt(S.x,S.y);I<M&&(M=I)}}}let F=f+Li,O=Math.max(F,p.height),L=S=>{let I=Math.max(0,S-M)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},H=S=>{let I=Math.max(0,S)*ke,T=Math.min(I*u,ln);return Math.max(F,p.height+T)},_=x?[]:v.rows.map(S=>({pts:S.pts,y:H(S.blockDepth),depth:S.blockDepth,blockId:S.blockId,...h.has(S.id)?{patch:fo(S.pts,fe)}:{}})),g=_.length?_[0].y:O,w=_.map(S=>{let I=S.patch&&S.patch.length>=3?S.patch:S.pts,T=0,B=0;for(let V of I)T+=V.x,B+=V.y;let A=I.length||1;T/=A,B/=A;let D=0;for(let V of I){let U=Math.hypot(V.x-T,V.y-B);U>D&&(D=U)}return{cx:T,cy:B,rad:D}}),E=x?()=>O:_.length>=2?(S,I)=>{let T=1/0,B=g;for(let A=0;A<_.length;A++){let D=w[A];if(Math.hypot(S-D.cx,I-D.cy)-D.rad>=T)continue;let V=_[A].patch,U=V&&V.length>=3?st(V,S,I)?0:wt(V,S,I):wt(_[A].pts,S,I);U<T&&(T=U,B=_[A].y)}return B}:(S,I)=>P?L(P.depthAt(S,I)):O,C=[0,1,0],N=_.length>=2||x?()=>C:(S,I)=>{if(!P)return C;let T=P.depthAt(S,I);if(T<=M)return C;let B=(T-M)*ke;if(B*u>=ln||p.height+B*u<=F)return C;let[A,D]=P.gradientAt(S,I);if(A===0&&D===0)return C;let V=1/Math.hypot(u,1);return[-A*u*V,V,-D*u*V]};if(!x)for(let S of v.rows){let I=H(S.blockDepth);for(let T of S.seatIndices)a[T]=I}for(let S of v.rows){let I=[];for(let V=1;V<S.pts.length;V++){let U=Math.hypot(S.pts[V].x-S.pts[V-1].x,S.pts[V].y-S.pts[V-1].y);U>1e-6&&I.push(U)}I.sort((V,U)=>V-U);let T=I.length?I[Math.floor(I.length/2)]:1/0,B=1/0,A=S.pts[Math.floor(S.pts.length/2)];if(A)for(let V of v.rows){if(V===S||V.blockId!==S.blockId)continue;let U=wt(V.pts,A.x,A.y);U>1e-6&&U<B&&(B=U)}let D=Math.min(T,Math.max(B,T*.5));if(Number.isFinite(D)&&D>0)for(let V of S.seatIndices)s[V]=D}i.set(m,{sectionId:m,deckAt:E,normalAt:N,flat:x,bottomY:f,rowLevels:_,landingY:g})}for(let m=0;m<e.length;m++){let d=o[m],p=e[m];if(d){let u=a[m];r[m]=(u??i.get(d).deckAt(p.x,p.y))+_i;continue}let f=p.eyeHeightM;r[m]=Number.isFinite(f)?Math.max(0,f-St):0}return{bySection:i,seatOwner:o,seatDeckY:m=>r[m],seatPitchU:m=>s[m]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ie(t,e){if(!t)return e;let n=pe(at(t,.4),.62);return he(e,n,.72)}function To(t,e){let n=new Map;for(let r of t.categories??[])n.set(r.key,r.color);let i=new Map;for(let r of e){if(!r.sectionId)continue;let a=i.get(r.sectionId);a||(a=new Map,i.set(r.sectionId,a)),a.set(r.categoryKey,(a.get(r.categoryKey)??0)+1)}let o=new Map;for(let[r,a]of i){let s=0,l=0,c=0,h=0;for(let[m,d]of a){let p=Z(n.get(m));p&&(s+=p[0]*d,l+=p[1]*d,c+=p[2]*d,h+=d)}h>0&&o.set(r,[s/h,l/h,c/h])}return o}function Fo(t,e){return Z(t.color)??e.get(t.logicalSectionId??t.id)??null}import Oi from"polygon-clipping";function Bi(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Ot=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let i=e.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Je(e),r=this.rings.filter((l,c)=>Pt(o,this.boxes[c])&&Bi(n,this.levels[c])),a=[[i]];if(r.length)try{a=Oi.difference([i],...r).map(c=>c.map(h=>h.map(([m,d])=>[m,d])))}catch{a=[[i]]}this.rings.push([i]),this.boxes.push(o),this.levels.push(n);let s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([h,m])=>({x:h,y:m}));if(c.length>1){let h=c[0],m=c[c.length-1];Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function Vi(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let m of t)n=Math.min(n,m.x),i=Math.max(i,m.x),o=Math.min(o,m.y),r=Math.max(r,m.y);let a=(n+i)/2,s=(o+r)/2,l=e*Math.PI/180,c=Math.cos(l),h=Math.sin(l);return t.map(m=>{let d=m.x-a,p=m.y-s;return{x:a+d*c-p*h,y:s+d*h+p*c}})}function ht(t){let e=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(e=t.points),t.kind==="rect"&&t.width&&t.height&&(e=dt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;e=kt(n,i,t.width/2,t.height/2)}return e?Vi(e,t.rotation):null}function pt(t){let e=t.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},i=e==="stage"&&kn(t.stageKind)?{kind:"stage",heightM:.06}:n[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var Ni=.08;function Eo(t,e){let n=ht(t),i=pt(t),o=i.heightM;if(!n||i.kind!=="plate"&&i.kind!=="stage")return o;let r=1/0,a=1/0,s=-1/0,l=-1/0;for(let h of n)r=Math.min(r,h.x),a=Math.min(a,h.y),s=Math.max(s,h.x),l=Math.max(l,h.y);let c=o;for(let h of e)s>h.minX&&r<h.maxX&&l>h.minY&&a<h.maxY&&c<=h.topOffsetM+1e-6&&(c=h.topOffsetM+Ni);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function _e(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Do(t){if(t.length!==4)return t;let e=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),n=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return e>=n?t:[t[1],t[2],t[3],t[0]]}function ft(t,e,n){return[_e(t[0],t[1],e),_e(t[0],t[1],n),_e(t[3],t[2],n),_e(t[3],t[2],e)]}function ko(t,e,n){return[_e(t[0],t[3],e),_e(t[1],t[2],e),_e(t[1],t[2],n),_e(t[0],t[3],n)]}function Te(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var un=2.4,zi=.75,Gi=.15;function bt(t){if(t.points&&t.points.length>=3)return t.points;let{center:e,width:n,height:i,rotation:o}=t;if(!n||!i)return null;let r=(o??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=n/2,c=i/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:e.x+h*a-m*s,y:e.y+h*s+m*a}))}function Lo(t,e,n,i,o){let r=bt(e);r&&ie(t,r,void 0,()=>n+un,n,Ie(i,o.boothTop),o.boothWall,re)}function mn(t){if(t.shape==="round"){let h=t.radius;return h?kt(t.center.x,t.center.y,h,h,24):null}let{width:e,height:n,rotation:i,center:o}=t;if(!e||!n)return null;let r=(i??0)*Math.PI/180,a=Math.cos(r),s=Math.sin(r),l=e/2,c=n/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:o.x+h*a-m*s,y:o.y+h*s+m*a}))}function _o(t,e,n,i,o){let r=mn(e);r&&ie(t,r,void 0,()=>n+zi,n,Ie(i,o.tableTop),o.tableWall,re)}function Oo(t,e,n,i,o,r,a){let s=ht(e);if(!s)return;let l=e.role==="stage",c=pt(e),h=n+i;if(l&&a){let u=1/0,b=-1/0,y=1/0,x=-1/0;for(let v of s)v.x<u&&(u=v.x),v.x>b&&(b=v.x),v.y<y&&(y=v.y),v.y>x&&(x=v.y);a.push({cx:(u+b)/2*R,cz:(y+x)/2*R,y:h,halfX:Math.max((b-u)/2*R,.5),halfZ:Math.max((x-y)/2*R,.5)})}let m=Z(e.fill),d=l&&m?he(o.stageTop,pe(at(m,.18),.9),.9):Ie(m,l?o.stageTop:o.decorTop),p=e.role==="screen"?m:null,f=l?m?he(o.stageWall,pe(m,.58),.82):o.stageWall:e.role==="screen"?p?he(pe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ie(Z(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let u=Do(s);Te(t,ft(u,0,.16),h,n,d,f),Te(t,ft(u,.84,1),h,n,d,f),Te(t,u,h,Math.max(n,h-.35),d,f);return}if(c.kind==="suite"&&s.length===4){let u=s.map((x,v)=>{let k=s[(v+1)%4],P=(x.x+k.x)/2,M=(x.y+k.y)/2;return Math.hypot(P-r.x,M-r.y)}),b=u.indexOf(Math.min(...u)),y=[0,1,2,3].map(x=>s[(b+x)%4]);Te(t,ft(y,0,.08),h,n,d,f),Te(t,ft(y,.92,1),h,n,d,f),Te(t,ko(y,.88,1),h,n,d,f),Te(t,y,h,Math.max(n,h-.18),d,f);return}Te(t,s,h,n,d,f)}function dn(t){let{x:e,y:n,width:i,height:o}=t;if(!i||!o)return null;let r=e+i/2,a=n+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),h=i/2,m=o/2;return[[-h,-m],[h,-m],[h,m],[-h,m]].map(([d,p])=>({x:r+d*l-p*c,y:a+d*c+p*l}))}function Hi(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let e=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{e=atob(e)}catch{return null}else try{e=decodeURIComponent(e)}catch{}let n=e.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let i=n[1].trim();if(i==="none"||i==="transparent")return null;let o=i.match(/^url\(#([^)]+)\)$/);if(!o)return Z(i);let r=e.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!r)return null;let a=[];for(let s of r[1].matchAll(/stop-color="([^"]+)"/gi)){let l=Z(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>he(s,l,1/(c+1)),a[0]):null}function Bo(t,e,n,i){if(e.layer==="foreground")return;let o=dn(e);if(!o)return;let r=n+Gi,a=Ie(Hi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=he(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,he(a,i.decorWall,.5),re)}function Vo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Ie(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Ui=.25,Xi=1.2,Yi=.6,Wi=.45,ji=2.3,qi=Math.PI/180;function Ye(t,e,n){let i=n*qi;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function Ki(t,e){let n=e.rings[e.rings.length-1];if(!n)return!1;let i=n.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let r=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(r.length<2)continue;let a=0;for(let s of r)Math.hypot(s.x-e.centre.x,s.y-e.centre.y)>=i&&a++;if(a>=r.length/2)return!0}return!1}var Zi=24;function Qi(t,e,n,i,o,r,a,s){let l=n.binCount,c=Zi,h=ke,m=r+.02,d=[];for(let g=0;g<l;g++){let w=(n.startBin+g+.5)*e.binStepDeg,E=new Float64Array(c+1);for(let C=0;C<=c;C++){let N=i[g]+(o[g]-i[g])*C/c;E[C]=Math.max(m,Nn(e,n,w,N)-Ui)}d.push(E)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],f=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],u=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],b=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],y=(g,w)=>{let E=(n.startBin+g+.5)*e.binStepDeg,C=i[g]+(o[g]-i[g])*w/c,N=Ye(e.centre,C,E);return[N.x*h,d[g][w],N.y*h]};{let g=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let E=!1;for(let N=0;N<l;N++)for(let S=c-1;S>=0;S--)d[N][S]>d[N][S+1]&&(d[N][S]=d[N][S+1],E=!0);let C=n.closed?l:l-1;for(let N=0;N<C;N++){let S=(N+1)%l;for(let I=0;I<=c;I++){let T=d[S][I]-d[N][I];if(Math.abs(T)>1)continue;let B=i[N]+(o[N]-i[N])*I/c,A=i[S]+(o[S]-i[S])*I/c,D=Ye(e.centre,B,(n.startBin+N+.5)*e.binStepDeg),V=Ye(e.centre,A,(n.startBin+S+.5)*e.binStepDeg),U=g*Math.hypot(V.x-D.x,V.y-D.y)*h;T>U?(d[S][I]=d[N][I]+U,E=!0):-T>U&&(d[N][I]=d[S][I]+U,E=!0)}}if(!E)break}}let x=1,v=(g,w)=>{for(let E=0;E<=c;E+=4)if(Math.abs(d[g][E]-d[w][E])>x)return!0;return Math.abs(d[g][c]-d[w][c])>x},k=Math.tan(38*Math.PI/180),P=g=>(o[g]-i[g])/c*h,M=(g,w)=>d[g][w+1]-d[g][w]>k*Math.max(1e-6,P(g)),F=(g,w)=>{let E=n.closed?(g-1+l)%l:Math.max(0,g-1),C=n.closed?(g+1)%l:Math.min(l-1,g+1);Math.abs(d[E][w]-d[g][w])>x&&(E=g),Math.abs(d[C][w]-d[g][w])>x&&(C=g);let N=Math.max(0,w-1),S=Math.min(c,w+1);N<w&&M(g,N)&&(N=w),S>w&&M(g,w)&&(S=w);let I=y(E,w),T=y(C,w),B=y(g,N),A=y(g,S),D=T[0]-I[0],V=T[1]-I[1],U=T[2]-I[2],Y=A[0]-B[0],X=A[1]-B[1],j=A[2]-B[2],K=V*j-U*X,te=U*Y-D*j,ne=D*X-V*Y,Q=Math.hypot(K,te,ne);return Q>1e-12?(K/=Q,te/=Q,ne/=Q,te<0&&(K=-K,te=-te,ne=-ne),[K,te,ne]):[0,1,0]},O=(g,w)=>{let E=[g[0],r,g[2]],C=[w[0],r,w[2]],N=w[0]-g[0],S=w[2]-g[2],I=Math.hypot(N,S);if(!(I>1e-12))return;let T=[S/I,0,-N/I];t.tri(g,w,C,T,u,u,b),t.tri(g,C,E,T,u,b,b)},L=.05*Le,H=g=>o[g]-i[g]<L,_=n.closed?l:l-1;for(let g=0;g<_;g++){let w=(g+1)%l;if(H(g)||H(w))continue;if(v(g,w)){let T=(n.startBin+g+1)*e.binStepDeg,B=(X,j)=>{let K=(i[g]+i[w])/2,te=(o[g]+o[w])/2,ne=K+(te-K)*j/c,Q=Ye(e.centre,ne,T);return[Q.x*h,d[X][j],Q.y*h]};for(let X=0;X<c;X++){let j=y(g,X),K=y(g,X+1),te=B(g,X),ne=B(g,X+1),Q=F(g,X),ae=F(g,X+1);t.triN(j,te,ne,Q,Q,ae,p),t.triN(j,ne,K,Q,ae,ae,p);let Be=y(w,X),Ve=y(w,X+1),Se=B(w,X),we=B(w,X+1),Pe=F(w,X),ye=F(w,X+1);t.triN(Se,Be,Ve,Pe,Pe,ye,p),t.triN(Se,Ve,we,Pe,ye,ye,p);let xe=B(g,X),oe=B(g,X+1),qe=B(w,X+1),Fe=B(w,X),Ae=oe[0]-xe[0],Ne=oe[2]-xe[2],nt=Math.hypot(Ae,Ne);if(nt>1e-12){let me=[Ne/nt,0,-Ae/nt];t.tri(xe,oe,qe,me,u),t.tri(xe,qe,Fe,me,u)}}let A=y(g,0),D=y(w,0),V=y(w,c),U=y(g,c),Y=X=>[X[0],r,X[2]];t.tri(Y(A),Y(V),Y(D),[0,-1,0],f),t.tri(Y(A),Y(U),Y(V),[0,-1,0],f),O(A,D),O(U,V);continue}for(let T=0;T<c;T++){let B=F(g,T),A=F(w,T),D=F(w,T+1),V=F(g,T+1);if(M(g,T)||M(w,T)){let K=(oe,qe)=>{let Fe=(n.startBin+oe+.5)*e.binStepDeg,Ae=i[oe]+(o[oe]-i[oe])*(T+.5)/c,Ne=Ye(e.centre,Ae,Fe);return[Ne.x*h,qe,Ne.y*h]},te=y(g,T),ne=y(w,T),Q=K(g,d[g][T]),ae=K(w,d[w][T]);t.triN(te,ne,ae,B,A,A,p),t.triN(te,ae,Q,B,A,B,p);let Be=y(w,T+1),Ve=y(g,T+1),Se=K(g,d[g][T+1]),we=K(w,d[w][T+1]);t.triN(Se,we,Be,V,D,D,p),t.triN(Se,Be,Ve,V,D,V,p);let Pe=ae[0]-Q[0],ye=ae[2]-Q[2],xe=Math.hypot(Pe,ye);if(xe>1e-12){let oe=[-ye/xe,0,Pe/xe];t.tri(Q,ae,we,oe,u),t.tri(Q,we,Se,oe,u)}continue}let U=y(g,T),Y=y(w,T),X=y(w,T+1),j=y(g,T+1);t.triN(U,Y,X,B,A,D,p),t.triN(U,X,j,B,D,V,p)}let E=y(g,0),C=y(w,0),N=y(w,c),S=y(g,c),I=T=>[T[0],r,T[2]];t.tri(I(E),I(N),I(C),[0,-1,0],f),t.tri(I(E),I(S),I(N),[0,-1,0],f),O(E,C),O(S,N)}if(!n.closed)for(let g of[0,l-1])for(let w=0;w<c;w++)O(y(g,w),y(g,w+1))}function No(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let h of e.rings)for(let m of h.arcs){let d=new Float64Array(m.binCount),p=new Float64Array(m.binCount);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount,y=Math.max(0,m.innerR[u]-fe);d[u]=Math.max(y,a[b]+.001),p[u]=Math.max(d[u]+.001,m.outerR[u]+fe)}let f=0;for(let u=0;u<m.binCount;u++){let b=m.topLevelM[u]-i;b>f&&(f=b)}f>=Xi&&Qi(t,e,m,d,p,i,o,r);for(let u=0;u<m.binCount;u++){let b=(m.startBin+u)%e.binCount;p[u]>a[b]&&(a[b]=p[u])}}if(Ki(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Yi*Le,c=Wi*Le;for(let h of s.arcs){let m=[],d=[];for(let u=0;u<h.binCount;u++){let b=(h.startBin+u+.5)*e.binStepDeg,y=h.outerR[u]+fe+l;m.push(Ye(e.centre,y,b)),d.push(Ye(e.centre,y+c,b))}let p=-1/0;for(let u=0;u<h.binCount;u++)h.topLevelM[u]>p&&(p=h.topLevelM[u]);let f=()=>p+ji;h.closed?ie(t,d,[m.slice().reverse()],f,i,o.shellTop,o.shellWall,r):ie(t,[...d,...m.slice().reverse()],void 0,f,i,o.shellTop,o.shellWall,r)}}function zo(t,e,n,i,o,r,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Ie(i,s.tierTop);if(!o)return;let h=b=>o.deckAt(b.x,b.y),m=Ao(e,a),d=m[0]??e.outline;if(o.rowLevels.length>=2){let b=_t(o.rowLevels),y=Co(go(o.rowLevels,n.focal,b),m),x=()=>[0,1,0];for(let k of y){let P=Math.max(l,k.topY-.02);for(let M of r.subtract(k.outline,P))ie(t,M,k.holes,()=>P,l,c,s.tierWall,re,void 0,x)}y.length||ie(t,d,e.holes,()=>o.landingY,l,c,s.tierWall,re);let v={tread:[c[0]*re.top,c[1]*re.top,c[2]*re.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let k of m.length?m:[d])Mo(t,o.rowLevels,n.focal,o.landingY,v,k,b);return}let p=o.flat?1/0:Ro,f=b=>o.normalAt(b.x,b.y),u=o.flat?o.landingY:void 0;for(let b of r.subtract(d,u))ie(t,b,e.holes,h,l,c,s.tierWall,re,p,f)}function $i(t,e,n){let i=new Set;for(let a of t.objects)a.type==="section"&&i.add(a.id);let o=new Map;for(let a=0;a<e.length;a++){let s=n.seatOwner[a];if(!s||!i.has(s))continue;let l=n.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=e[a],h=o.get(s);h||(h=new Map,o.set(s,h));let m=c.rowId||`__seat-${a}`,d=h.get(m);d||(d={pts:[],levelM:0,n:0},h.set(m,d)),d.pts.push({x:c.x,y:c.y}),d.levelM+=n.seatDeckY(a),d.n++}let r=[];for(let a of t.objects){if(a.type!=="section")continue;let s=n.bySection.get(a.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(h=>!h.patch).map(h=>({pts:h.pts,levelM:h.y}));c.length>=2&&r.push({sectionId:a.id,rows:c});continue}let l=o.get(a.id);l&&r.push({sectionId:a.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return r}function Go(t,e,n,i,o){let r=$i(e,n,i);if(!r.length)return;let a=Vn(r,e.focal);a&&(t.setMaterial(0),No(t,a,{bottomY:e.baseHeightM,colors:{bandTop:pe(o.tierTop,.8),bandWall:o.tierWall,shellTop:pe(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(s=>s.type==="shape")}))}function Ho(t,e,n){return n<0?e>1?t.filter(i=>i.kind==="floor"):[...t]:t.filter(i=>i.floorIndex===void 0||i.floorIndex===n)}function Uo(t,e){let n=[...t].sort((o,r)=>o.screen.y-r.screen.y),i=[];for(let o of n){let r=i.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));r?r.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((r,a)=>({...r,screen:{...r.screen,x:Math.max(54,Math.min(e-54,r.screen.x+(a-(o.length-1)/2)*104))}})))}var Ji=1.15,ea=3.25,ta=4.5,na=.85,oa=.5,ra=.26;function Xo(t,e,n){let i=Math.max(1e-6,e),o=t/i,r=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=Ji&&a.add("zone"),o<=(r?ea:ta)&&(a.add("section"),a.add("ga")),o<=na&&(a.add("annotation"),a.add("booth")),o<=oa&&a.add("row"),o<=ra&&a.add("seat"),a}function Oe(t,e,n,i){let o=t,r=e[0],a=e[1],s=e[2],l=o[0]*r+o[4]*a+o[8]*s+o[12],c=o[1]*r+o[5]*a+o[9]*s+o[13],h=o[2]*r+o[6]*a+o[10]*s+o[14],m=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let d=l/m,p=c/m,f=h/m,u=d>=-1.05&&d<=1.05&&p>=-1.05&&p<=1.05&&f<=1;return{x:(d*.5+.5)*n,y:(1-(p*.5+.5))*i,depth:f,visible:u}}function Yo(t,e,n=e){let i=[],o=[...t].sort((r,a)=>r.screen.depth-a.screen.depth);for(let r of o){let a=!1;for(let s of i){let l=Math.abs(r.screen.x-s.screen.x),c=Math.abs(r.screen.y-s.screen.y);if(l<e&&c<n){a=!0;break}}a||i.push(r)}return i}var Wo={row:8,seat:14};function jo(t,e,n,i){let o=Math.max(1,Math.min(n,i)*.5),r=Math.min(2,Math.hypot(t.x-n/2,t.y-i/2)/o);return e*(1+1.5*r)}function qo(t,e,n,i){let o=[...t].sort((a,s)=>(s.priority??0)-(a.priority??0)||a.focus-s.focus),r=[];for(let a of o){if(r.length>=i)break;let s=!1;for(let l of r)if(Math.abs(a.screen.x-l.screen.x)<e&&Math.abs(a.screen.y-l.screen.y)<n){s=!0;break}s||r.push(a)}return r}var ia=6,aa=2.2,Ko=.1,sa=.3,ca=1.8,la=.9,ua=.55,ma=6e3;function Zo(t){let{doc:e,units:n,seats:i,surfaces:o,focal:r}=t,a=e.zones??[],s=[];if(a.length){let l=new Map;for(let h of n)for(let m of h.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let h=0;h<i.length;h++){let m=i[h],d=o.seatOwner[h],p=m.zoneId??(d?l.get(d):void 0);if(!p)continue;let f=c.get(p);f||(f={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,f)),f.n++,m.x<f.minX&&(f.minX=m.x),m.y<f.minY&&(f.minY=m.y),m.x>f.maxX&&(f.maxX=m.x),m.y>f.maxY&&(f.maxY=m.y),f.sumY+=o.seatDeckY(h)}for(let h of a){let m=c.get(h.id),d=[];for(let[p,f]of l)f===h.id&&d.push(p);if(!m||m.n===0){s.push({id:h.id,label:h.label,color:Z(h.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]});continue}s.push({id:h.id,label:h.label,color:Z(h.color),sectionIds:d,seatCount:m.n,center:[(m.minX+m.maxX)/2*R,m.sumY/m.n,(m.minY+m.maxY)/2*R],radius:.5*Math.hypot((m.maxX-m.minX)*R,(m.maxY-m.minY)*R)||1,focalWorld:[(h.focalPoint??r).x*R,1.5,(h.focalPoint??r).y*R]})}}return s}function Qo(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],h=[],m=[];for(let d of s)d.seatCount!==0&&c.push({id:`zone:${d.id}`,kind:"zone",text:d.label,anchor:[d.center[0],d.center[1]+ia,d.center[2]],color:e.zones?.find(p=>p.id===d.id)?.color});{let d=new Map,p=new Map;for(let f=0;f<i.length;f++){let u=o.seatOwner[f];if(!u)continue;let b=d.get(u);b||(b={n:0,x:0,y:0,deck:0},d.set(u,b)),b.n++,b.x+=i[f].x,b.y+=i[f].y,b.deck+=o.seatDeckY(f);let y=p.get(u);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(u,y)),i[f].x<y.minX&&(y.minX=i[f].x),i[f].x>y.maxX&&(y.maxX=i[f].x),i[f].y<y.minY&&(y.minY=i[f].y),i[f].y>y.maxY&&(y.maxY=i[f].y)}for(let f of n)for(let u of f.objects){if(u.type!=="section")continue;let b=d.get(u.id);if(!b||b.n===0)continue;let y=p.get(u.id),x=[b.x/b.n*R,b.deck/b.n,b.y/b.n*R],v=u.displayLabel||u.label||u.id;h.push({id:u.id,floorIndex:f.index,label:v,seatCount:b.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*R),focalWorld:[f.focal.x*R,f.baseHeightM+1.5,f.focal.y*R]});let k=e.floors?.[f.index]?.name?.trim().toLocaleLowerCase();n.length>1&&k===v.trim().toLocaleLowerCase()||c.push({id:`section:${u.id}`,kind:"section",text:v,anchor:[x[0],x[1]+aa,x[2]],floorIndex:f.index})}}{for(let f of n)for(let u of f.objects){if(u.type!=="gaArea")continue;let b=it(u.points);if(!b)continue;let y=u.displayLabel||u.label||u.id;c.push({id:`ga:${u.id}`,kind:"ga",text:u.capacity>0?`${y} \xB7 ${u.capacity.toLocaleString()}`:y,anchor:[b.x*R,f.baseHeightM+ca,b.y*R],floorIndex:f.index})}let d=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=Math.hypot(u.x-l.x,u.y-l.y),y=d.get(u.rowId);(!y||b>y.far)&&d.set(u.rowId,{seat:u,index:f,far:b})}for(let[f,u]of d){let b=u.seat.label?u.seat.label.lastIndexOf("-"):-1,y=b>0?u.seat.label.slice(0,b):f;y&&c.push({id:`row:${f}`,kind:"row",text:y,anchor:[u.seat.x*R,o.seatDeckY(u.index)+la,u.seat.y*R],floorIndex:a[u.index]})}let p=new Map;for(let f=0;f<i.length;f++){let u=i[f],b=u.label?u.label.lastIndexOf("-"):-1,y=p.get(u.rowId);y||(y={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:b>0?u.label.slice(0,b):u.rowId,sectionId:u.sectionId},p.set(u.rowId,y));let x=f*3,v=r.iPosition[x],k=r.iPosition[x+1],P=r.iPosition[x+2];y.n++,y.x+=v,y.y+=k,y.z+=P,y.minX=Math.min(y.minX,v),y.maxX=Math.max(y.maxX,v),y.minZ=Math.min(y.minZ,P),y.maxZ=Math.max(y.maxZ,P)}for(let[f,u]of p)m.push({id:f,label:u.label,sectionId:u.sectionId,seatCount:u.n,center:[u.x/u.n,u.y/u.n,u.z/u.n],radius:Math.max(.8,Math.hypot(u.maxX-u.minX,u.maxZ-u.minZ)*.5)});if(i.length<=ma)for(let f=0;f<i.length;f++){let u=i[f],b=u.displayLabel||u.label;b&&c.push({id:`seat:${u.id}`,kind:"seat",text:b,anchor:[u.x*R,o.seatDeckY(f)+ua,u.y*R],floorIndex:a[f]})}}for(let d of n)for(let p of d.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let f=ht(p),u=f?it(f):null;if(!u||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[u.x*R,d.baseHeightM+pt(p).heightM+Ko,u.y*R],color:p.fill,floorIndex:d.index})}else if(p.type==="text"){if(!p.text)continue;c.push({id:`text:${p.id}`,kind:"annotation",text:p.text,anchor:[p.position.x*R,d.baseHeightM+Ko,p.position.y*R],color:p.color,rotation:p.rotation,floorIndex:d.index})}else if(p.type==="booth"){let f=bt(p);if(!f)continue;let u=it(f);if(!u)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[u.x*R,d.baseHeightM+un+sa,u.y*R],floorIndex:d.index})}return{labels:c,sections:h,rows:m}}function $o(t,e){if(e.length>1)for(let n of e)t.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function Jo(t){let{doc:e,units:n,seats:i,surfaces:o,solids:r,hintedSeatFloor:a,seatFloor:s}=t,l=[];{let c=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let d=0;d<r.floor.length;d+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(r.floor[d]))),f=d*3,u=c[p];u.minX=Math.min(u.minX,r.position[f]),u.minY=Math.min(u.minY,r.position[f+1]),u.minZ=Math.min(u.minZ,r.position[f+2]),u.maxX=Math.max(u.maxX,r.position[f]),u.maxY=Math.max(u.maxY,r.position[f+1]),u.maxZ=Math.max(u.maxZ,r.position[f+2])}let h=new Map;for(let d=0;d<n.length;d++)for(let p of n[d].objects)p.type==="section"&&h.set(p.id,d);let m=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let d=0;d<i.length;d++){let p=o.seatOwner[d],f=(p!==null?h.get(p):void 0)??a[d];if(f===void 0)continue;let u=m[f],b=i[d];u.n++,b.x<u.minX&&(u.minX=b.x),b.y<u.minY&&(u.minY=b.y),b.x>u.maxX&&(u.maxX=b.x),b.y>u.maxY&&(u.maxY=b.y);let y=o.seatDeckY(d);u.sumX+=b.x*R,u.sumDeck+=y,u.sumZ+=b.y*R,u.minDeck=Math.min(u.minDeck,y),u.maxDeck=Math.max(u.maxDeck,y+1.6),s[d]=f}for(let d=0;d<n.length;d++){let p=m[d],f=e.floors?.[d],u=c[d],b=Math.min(p.n?p.minX*R:n[d].focal.x*R-1,Number.isFinite(u.minX)?u.minX:1/0),y=Math.max(p.n?p.maxX*R:n[d].focal.x*R+1,Number.isFinite(u.maxX)?u.maxX:-1/0),x=Math.min(p.n?p.minY*R:n[d].focal.y*R-1,Number.isFinite(u.minZ)?u.minZ:1/0),v=Math.max(p.n?p.maxY*R:n[d].focal.y*R+1,Number.isFinite(u.maxZ)?u.maxZ:-1/0),k=Math.min(p.n?Math.min(n[d].baseHeightM,p.minDeck):n[d].baseHeightM,Number.isFinite(u.minY)?u.minY:1/0),P=Math.max(p.n?Math.max(p.maxDeck,k+.5):k+.5,Number.isFinite(u.maxY)?u.maxY:-1/0),M=[p.n?p.sumX/p.n:(b+y)/2,p.n?p.sumDeck/p.n:(k+P)/2,p.n?p.sumZ/p.n:(x+v)/2],F=Math.max(1,.5*Math.hypot(y-b,P-k,v-x));l.push({index:d,id:f?.id??`floor-${d}`,label:f?.name??(n.length>1?`Floor ${d+1}`:"Venue"),seatCount:p.n,center:M,radius:F,box:{min:[b,k,x],max:[y,P,v]},focalWorld:[n[d].focal.x*R,n[d].baseHeightM+1.5,n[d].focal.y*R]})}}return l}function hn(t,e){let n=1/0,i=1/0,o=-1/0,r=-1/0,a=(s,l)=>{s<n&&(n=s),l<i&&(i=l),s>o&&(o=s),l>r&&(r=l)};for(let s of e)a(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let c of l.outline)a(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)a(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)a(c.x,c.y);else if(l.type==="booth"){let c=bt(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="table"){let c=mn(l);if(c)for(let h of c)a(h.x,h.y)}else if(l.type==="decorImage"){let c=dn(l);if(c)for(let h of c)a(h.x,h.y)}return Number.isFinite(n)||(n=-100,i=-100,o=100,r=100),{minX:n,minY:i,maxX:o,maxY:r}}function er(t,e,n,i,o,r){if(e.length===1){let a=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=dt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);ie(t,s,void 0,()=>0,-.4,r.ground,r.ground,re)}else{let a=e.reduce((p,f)=>f.baseHeightM<p.baseHeightM?f:p);t.setFloor(a.index);let s=n.filter((p,f)=>i[f]===a.index),l=hn([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),h=Math.max(28,Math.min(80,c*.04)),m=dt(l.minX-h,l.minY-h,l.maxX-l.minX+h*2,l.maxY-l.minY+h*2),d=a.baseHeightM-.03;ie(t,m,void 0,()=>d,d-.22,r.ground,r.ground,re)}}function tr(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,h=-1/0,m=-1/0,d=(u,b,y)=>{a=Math.min(a,u),c=Math.max(c,u),s=Math.min(s,b),h=Math.max(h,b),l=Math.min(l,y),m=Math.max(m,y)};for(let u=0;u<t.position.length;u+=3)d(t.position[u],t.position[u+1],t.position[u+2]);for(let u=0;u<e.count;u++){let b=u*3,y=e.iPosition[b],x=e.iPosition[b+1],v=e.iPosition[b+2],k=Math.max(.35,e.iMaxRadius[u]??.35);d(y-k,x,v-k),d(y+k,x+1.6,v+k)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,h=r*.16,l=o-r,m=o+r);let p=[(a+c)/2,(s+h)/2,(l+m)/2],f=Math.max(1,.5*Math.hypot(c-a,h-s,m-l));return{center:p,radius:f,minY:s,maxY:h}}function nr(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let k=0;k<t.count;k++){let P=k*3,M=t.iPosition[P],F=t.iPosition[P+2];M<a&&(a=M),M>l&&(l=M),F<s&&(s=F),F>c&&(c=F)}for(let k of e)a=Math.min(a,k.cx-k.halfX),l=Math.max(l,k.cx+k.halfX),s=Math.min(s,k.cz-k.halfZ),c=Math.max(c,k.cz+k.halfZ);let h=n.minX*R,m=n.maxX*R,d=n.minY*R,p=n.maxY*R,f=h,u=m,b=d,y=p;if(Number.isFinite(a)){let k=Math.max(2,.06*Math.hypot(l-a,c-s));f=Math.max(h,a-k),u=Math.min(m,l+k),b=Math.max(d,s-k),y=Math.min(p,c+k)}let x=Math.min(0,i),v=Math.max(o,r*.05);return{min:[f,x,b],max:[u,v,y]}}function yt(t){let{doc:e}=t,n=co(e.theme),i=n.structure,o=Po(e,t.eventConfigurationId??e.eventConfigurationId),r=t.seats,a=new Et,s=new Map;for(let g of o)for(let w of g.objects)s.set(w.id,g.index),w.type==="section"&&s.set(w.logicalSectionId??w.id,g.index);let l=r.map(g=>s.get(g.sectionId??"")??s.get(g.rowId??"")??0),c=hn(o,r);er(a,o,r,l,c,i);let h=To(e,r),m=new Map;for(let g of e.categories??[])m.set(g.key,g.color);let d=[],p=Io(o,r,l),f=new Float32Array(r.length);for(let g=0;g<o.length;g++){let w=o[g];a.setFloor(g);let E=new Ot,C=[],N=w.objects.filter(S=>S.type==="section"&&!!S.outline&&S.outline.length>=3);for(let S of w.objects)S.type==="section"?zo(a,S,w,Fo(S,h),p.bySection.get(S.id),E,N,i):S.type==="shape"?(a.setMaterial(S.role==="screen"?1:0),Oo(a,S,w.baseHeightM,Eo(S,C),i,w.focal,d),a.setMaterial(0)):S.type==="gaArea"?Vo(a,S,w.baseHeightM,Z(m.get(S.categoryKey)),i):S.type==="booth"?Lo(a,S,w.baseHeightM,Z(m.get(S.categoryKey)),i):S.type==="table"?_o(a,S,w.baseHeightM,Z(m.get(S.categoryKey)),i):S.type==="decorImage"&&Bo(a,S,w.baseHeightM,i);Go(a,w,r,p,i)}let u=o.length>1?{x:o.reduce((g,w)=>g+w.focal.x,0)/o.length,y:o.reduce((g,w)=>g+w.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},b=no([a.build()]),y=so(r,t.initialState,p,f,m),x=Zo({doc:e,units:o,seats:r,surfaces:p,focal:u}),{labels:v,sections:k,rows:P}=Qo({doc:e,units:o,seats:r,surfaces:p,seatData:y,hintedSeatFloor:l,zones:x,focal:u}),M=Jo({doc:e,units:o,seats:r,surfaces:p,solids:b,hintedSeatFloor:l,seatFloor:f});$o(v,M),y.iYaw=io(y.iPosition,r.length,g=>r[g].rowId,g=>{let w=o[f[g]]?.focal??u;return[w.x*R,w.y*R]});let F=(c.minX+c.maxX)/2*R,O=(c.minY+c.maxY)/2*R,L=.5*Math.hypot((c.maxX-c.minX)*R,(c.maxY-c.minY)*R)||10,H=tr(b,y,{cx:F,cz:O,radius:L}),_=nr(y,d,c,H.minY,H.maxY,L);return{solids:b,seats:y,bounds:{center:[(_.min[0]+_.max[0])/2,(_.min[1]+_.max[1])/2,(_.min[2]+_.max[2])/2],radius:L,groundY:0,box:_},renderBounds:{center:H.center,radius:H.radius},stateColorLUT:lo(n,be),theme:n,seatCount:r.length,focalWorld:[u.x*R,1.5,u.y*R],zones:x,stages:d,sections:k,rows:P,labels:v,floors:M}}var da=88,ha=20,pa={floor:{size:14,weight:"700",opacity:.98},zone:{size:15,weight:"600",opacity:.95},section:{size:12,weight:"500",opacity:.88},ga:{size:12,weight:"500",opacity:.88},booth:{size:11,weight:"500",opacity:.85},annotation:{size:11,weight:"400",opacity:.75},row:{size:10.5,weight:"600",opacity:.8},seat:{size:9.5,weight:"500",opacity:.72}},pn=new Set(["row","seat"]),or={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},rr={row:{x:62,y:16},seat:{x:46,y:18}},ar=Z,fn=t=>En(t);function sr(t,e){let n=fn(t),i=fn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function ir(t,e){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(t.replace(/\s/g,""));if(!n)return e;let i=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*i+e[o-1]*(1-i))}function fa(t,e=[.04,.06,.1]){let n=fn(e)<.42,i=n?"#f4f7fb":"#0b1220",o=ar(t),r=o&&sr(o,e)>=4.5?t:i;return n?{ink:r,backing:"rgba(8,12,22,.78)",border:"rgba(210,222,245,.24)"}:{ink:r,backing:"rgba(255,255,255,.84)",border:"rgba(11,18,32,.22)"}}var Bt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let i=this.root.style;i.position="absolute",i.inset="0",i.pointerEvents="none",i.overflow="hidden",n.fontFamily&&(i.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,i]of this.nodes)e.some(o=>o.id===n)||(i.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}qualityEvidence(){let e=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(i=>{let o=this.nodes.get(i.id),r=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&r&&r.width>0&&r.height>0);return{id:i.id,kind:i.kind,text:i.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&r?{screenBox:{x:r.x-e.x,y:r.y-e.y,width:r.width,height:r.height}}:{}}})}update(e,n,i,o,r,a){if(!this.labels.length)return;let s=Xo(o,r,{hasZoneLabels:this.labels.some(u=>u.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let u of this.labels){if(!s.has(u.kind))continue;let b=Oe(e,u.anchor,n,i);if(!b.visible)continue;let y=a?Math.hypot(u.anchor[0]-a[0],u.anchor[1]-a[1],u.anchor[2]-a[2]):1;l.push({label:u,screen:b,focus:jo(b,y,n,i),...this.selectedSeatLabelIds.has(u.id)?{priority:1}:{}})}let c=Uo(l.filter(u=>u.label.kind==="floor"),n),h=[...l.filter(u=>!pn.has(u.label.kind)&&u.label.kind!=="floor"),...c],m=[...Yo(h,da,ha),...["row","seat"].flatMap(u=>qo(l.filter(b=>b.label.kind===u),rr[u].x,rr[u].y,Wo[u]))],d=new Set(m.map(u=>u.label.id));for(let{label:u,screen:b}of m){let x=this.nodeFor(u).style;x.display="",x.transform=`translate(-50%, -50%) translate(${b.x.toFixed(1)}px, ${b.y.toFixed(1)}px)`}let p=m.filter(({label:u})=>!pn.has(u.kind)).sort((u,b)=>or[b.label.kind]-or[u.label.kind]||u.screen.depth-b.screen.depth||u.focus-b.focus),f=[];for(let{label:u}of p){let b=this.nodes.get(u.id);if(!b||b.style.display==="none")continue;let y=b.getBoundingClientRect();f.some(v=>y.left<v.right+3&&y.right+3>v.left&&y.top<v.bottom+3&&y.bottom+3>v.top)?b.style.display="none":f.push(y)}for(let[u,b]of this.nodes)d.has(u)||(b.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let m=n.style;m.position="absolute",m.left="0",m.top="0",m.whiteSpace="nowrap",m.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",m.display="none",this.root.appendChild(n),this.nodes.set(e.id,n)}n.textContent=e.text,n.setAttribute("data-label-kind",e.kind);let i=this.selectedSeatLabelIds.has(e.id);n.toggleAttribute("data-selected-seat",i);let o=pa[e.kind],r=n.style;r.fontSize=`${o.size}px`,r.fontWeight=i?"800":o.weight,r.opacity=i?"1":String(o.opacity);let a=fa(e.color??this.opts.ink,this.opts.backgroundRgb),s=!pn.has(e.kind);r.color=i?"#ecf8ff":a.ink,r.background=i?"rgba(10,28,45,.9)":s?a.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":s?`1px solid ${a.border}`:"",r.borderRadius=i||s?"999px":"",r.padding=i||s?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":s?"0 3px 10px rgba(0,0,0,.24)":"",r.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let l=this.opts.backgroundRgb??[.04,.06,.1],c=ar(i?"#ecf8ff":a.ink)??[1,1,1],h=i?ir("rgba(10,28,45,.9)",l):s?ir(a.backing,l):l;return n.dataset.qualityContrast=sr(c,h).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var ba=1;var ya=new Set(["floor","zone","section","ga","booth","annotation"]);function xa(t){return t.every(e=>Number.isFinite(e))}function ga(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function cr(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function We(t){return Math.round(t*1e4)/1e4}function va(t){if(t)return{box:{x:We(t.box.x),y:We(t.box.y),width:We(t.box.width),height:We(t.box.height)},horizontalFillRatio:We(t.horizontalFillRatio),verticalFillRatio:We(t.verticalFillRatio),visibleAreaRatio:We(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Me(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function bn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>ya.has(s.kind)),i=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let l=0;l<s;l+=1)ga(n[s].screenBox,n[l].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[l].id});let r=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Me("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Me("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Me("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Me("viewport-empty","The 3D viewport must have visible dimensions",t.viewport.width>1&&t.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${t.viewport.width}\xD7${t.viewport.height}`}]),Me("camera-invalid","The capture camera must have a finite physical pose",xa(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Me("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!t.scene.authoredRelief||t.scene.renderedVerticalSpanM>.05&&t.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:t.scene.projectedReliefPx,minimum:2}]),Me("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",i===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${i} expected hierarchy labels`}]),Me("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(s=>s.renderedFontPx<11).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.renderedFontPx,minimum:11}))),Me("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(s=>s.contrast<4.5).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.contrast,minimum:4.5}))),Me("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(s=>!!s);return{version:1,state:"venue3d",passed:a.length===0,resolvedRules:["rendered-3d-webgl-context","rendered-3d-stable-frame","rendered-3d-camera-pose","rendered-3d-relief-projection","rendered-3d-label-size","rendered-3d-label-contrast","rendered-3d-label-collision"],viewport:t.viewport,context:t.context,frame:t.frame,camera:t.camera,scene:t.scene,composition:{visibleLabels:e.map(({id:s,kind:l,text:c})=>({id:s,kind:l,text:c})).sort((s,l)=>s.kind.localeCompare(l.kind)||s.id.localeCompare(l.id)),framing:va(t.framing)},metrics:{minimumHierarchyFontPx:cr(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:cr(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Nt,Mesh as zt,Transform as yr}from"ogl";import{Program as je}from"ogl";var Vt=`
1
+ import{a as Un,c as Yn,d as Xn}from"../chunk-QHWOX6PN.js";import{a as Wn,c as jn,d as qn,e as Ce,j as Kn}from"../chunk-XPPT3OGQ.js";import{c as Nn,d as Gn,e as Qt,f as Hn}from"../chunk-IJI4WU57.js";import{d as zn}from"../chunk-T2LWVOQ3.js";import{e as Fn,l as He,n as st,o as Vn,q as Pt}from"../chunk-VI3IZS2B.js";import{e as On,k as Bn}from"../chunk-UL5OIGIF.js";import{W as ke,X as Le,ea as St,ga as Dn,ha as wt,ja as kn,l as En,m as it,va as Ln}from"../chunk-RZLIIQDP.js";import{d as Z,k as _n,x as he,z as at}from"../chunk-CXF32VPG.js";import{Renderer as $r}from"ogl";var be=["available","held","sold","selected","dimmed"];function ct(t){let e=be.indexOf(t);return e<0?0:e}var Zn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Qn(t){let e=.2126*t[0]+.7152*t[1]+.0722*t[2],n=.42,r=.62;return[(e+(t[0]-e)*n)*r,(e+(t[1]-e)*n)*r,(e+(t[2]-e)*n)*r]}var $t={ground:[.07,.085,.11],tierTop:[.24,.28,.34],tierWall:[.17,.2,.25],stageTop:[.94,.7,.38],stageWall:[.48,.33,.18],decorTop:[.22,.25,.29],decorWall:[.15,.17,.2],gaTop:[.24,.28,.33],gaWall:[.16,.19,.23],boothTop:[.3,.33,.38],boothWall:[.2,.23,.27],tableTop:[.38,.34,.29],tableWall:[.24,.21,.18]},Ue={top:[.05,.06,.08],bottom:[.1,.12,.15]};function pe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Jr(){let t=typeof window<"u"&&window.devicePixelRatio||1,e=navigator.deviceMemory,n=typeof e=="number"&&e<=4?1.5:2;return Math.min(t,n)}var At=class{constructor(e,n){this.clearRgb=[0,0,0];this.container=e,this.canvas=document.createElement("canvas"),this.canvas.style.display="block",this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.touchAction="none",this.canvas.tabIndex=0,this.canvas.setAttribute("role","application"),this.canvas.setAttribute("aria-label","Interactive 3D venue. Drag or use arrow keys to look around; pinch, scroll, plus or minus to zoom."),this.renderer=new $r({canvas:this.canvas,dpr:Jr(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[Ue.top[0],Ue.top[1],Ue.top[2]],this.gl.clearColor(this.clearRgb[0],this.clearRgb[1],this.clearRgb[2],1),e.appendChild(this.canvas),this.lostHandler=r=>{r.preventDefault(),n.onContextLost()},this.restoredHandler=()=>n.onContextRestored(),this.canvas.addEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.addEventListener("webglcontextrestored",this.restoredHandler,!1),this.resize()}setClearColor(e){this.clearRgb=[e[0],e[1],e[2]],this.gl.clearColor(e[0],e[1],e[2],1)}get clearColor(){return this.clearRgb}resize(){let e=Math.max(1,this.container.clientWidth||this.canvas.clientWidth||1),n=Math.max(1,this.container.clientHeight||this.canvas.clientHeight||1);return this.renderer.setSize(e,n),{width:e,height:n}}get pixelHeight(){return this.renderer.height*this.renderer.dpr}get aspect(){return this.renderer.width/Math.max(1,this.renderer.height)}dispose(){this.canvas.removeEventListener("webglcontextlost",this.lostHandler,!1),this.canvas.removeEventListener("webglcontextrestored",this.restoredHandler,!1);let e=this.gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas)}simulateContextLossCycle(){let e=this.gl.getExtension("WEBGL_lose_context");e&&(e.loseContext(),setTimeout(()=>{e.restoreContext&&e.restoreContext()},300))}};import{Camera as ei,Vec3 as Jt}from"ogl";var ue=Math.PI/180,en=15*ue,tn=80*ue,Ke=.12,$n=35,Jn=1.25,Ct=class{constructor(e,n,r,o){this.fovY=$n;this.target=new Jt;this.azimuth=-30*ue;this.polar=55*ue;this.distance=10;this.azT=-30*ue;this.polT=55*ue;this.distT=10;this.minDist=1;this.maxDist=100;this.gestureFired=!1;this.interactionEnabled=!0;this.dragging=!1;this.panning=!1;this.lastX=0;this.lastY=0;this.activePointers=new Map;this.pinchDist=0;this.pinchCx=0;this.pinchCy=0;this.targetT=new Jt;this.panAnchor=new Jt;this.panLimit=0;this.primaryDragMode="orbit";this.camera=new ei(e,{fov:$n,near:.1,far:5e3,aspect:1}),this.canvas=n,this.requestRender=r,this.onGesture=o,this.onPointerDown=i=>{if(this.interactionEnabled){try{this.canvas.setPointerCapture?.(i.pointerId)}catch{}if(this.activePointers.set(i.pointerId,{x:i.clientX,y:i.clientY}),this.activePointers.size===1){let a=i.button===2||i.button===1,s=i.button===0&&(i.shiftKey?this.primaryDragMode==="orbit":this.primaryDragMode==="pan");this.panning=a||s,this.dragging=!this.panning,this.lastX=i.clientX,this.lastY=i.clientY}else if(this.activePointers.size===2){this.dragging=!1,this.panning=!1,this.pinchDist=this.currentPinchDistance();let a=this.pinchCentroid();this.pinchCx=a.x,this.pinchCy=a.y}}},this.onPointerMove=i=>{if(!this.interactionEnabled||!this.activePointers.has(i.pointerId))return;if(this.activePointers.set(i.pointerId,{x:i.clientX,y:i.clientY}),this.activePointers.size>=2){let l=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-l)*.005)),this.fireGesture()),this.pinchDist=l;let c=this.pinchCentroid();this.panBy(c.x-this.pinchCx,c.y-this.pinchCy),this.pinchCx=c.x,this.pinchCy=c.y;return}let a=i.clientX-this.lastX,s=i.clientY-this.lastY;if(this.panning){this.lastX=i.clientX,this.lastY=i.clientY,(a!==0||s!==0)&&(this.panBy(a,s),this.fireGesture());return}this.dragging&&(this.lastX=i.clientX,this.lastY=i.clientY,(a!==0||s!==0)&&this.fireGesture(),this.azT-=a*.006,this.polT=Math.max(en,Math.min(tn,this.polT-s*.006)),this.requestRender())},this.onPointerUp=i=>{this.activePointers.delete(i.pointerId);try{this.canvas.releasePointerCapture?.(i.pointerId)}catch{}this.activePointers.size<2&&(this.pinchDist=0),this.activePointers.size===0&&(this.dragging=!1,this.panning=!1)},this.onContextMenu=i=>{i.preventDefault()},this.onWheel=i=>{if(i.preventDefault(),!this.interactionEnabled)return;let a=i.deltaMode===1?16:i.deltaMode===2?100:1,s=Math.max(-2,Math.min(2,i.deltaY*a/100));this.dollyBy(Math.exp(s*.22)),this.fireGesture()},this.onKeyDown=i=>{if(!this.interactionEnabled)return;let a=7*ue;if(i.shiftKey&&(i.key==="ArrowLeft"||i.key==="ArrowRight"||i.key==="ArrowUp"||i.key==="ArrowDown"))this.panBy(i.key==="ArrowLeft"?-32:i.key==="ArrowRight"?32:0,i.key==="ArrowUp"?-32:i.key==="ArrowDown"?32:0);else if(i.key==="ArrowLeft"||i.key==="ArrowRight")this.azT+=i.key==="ArrowLeft"?-a:a;else if(i.key==="ArrowUp"||i.key==="ArrowDown")this.polT=Math.max(en,Math.min(tn,this.polT+(i.key==="ArrowUp"?-a:a)));else if(i.key==="+"||i.key==="=")this.dollyBy(.82);else if(i.key==="-"||i.key==="_")this.dollyBy(1.22);else return;i.preventDefault(),this.fireGesture(),this.requestRender()},n.addEventListener("pointerdown",this.onPointerDown),n.addEventListener("pointermove",this.onPointerMove),n.addEventListener("pointerup",this.onPointerUp),n.addEventListener("pointercancel",this.onPointerUp),n.addEventListener("wheel",this.onWheel,{passive:!1}),n.addEventListener("keydown",this.onKeyDown),n.addEventListener("contextmenu",this.onContextMenu)}pinchCentroid(){let e=[...this.activePointers.values()];if(!e.length)return{x:0,y:0};let n=0,r=0;for(let o of e)n+=o.x,r+=o.y;return{x:n/e.length,y:r/e.length}}panBy(e,n){let r=this.canvas.clientHeight||1,o=2*this.distance*Math.tan(this.fovY*ue/2)/r,i=Math.sin(this.azimuth),a=Math.cos(this.azimuth),s=a,l=-i,c=Math.cos(this.polar),d=Math.sin(this.polar),u=-i*c,m=-a*c;this.targetT.x+=(-e*s+n*u)*o,this.targetT.z+=(-e*l+n*m)*o,this.targetT.y+=n*d*o,this.clampPan(),this.requestRender()}clampPan(){if(this.panLimit<=0)return;let e=this.panLimit,n=this.panAnchor.x,r=this.panAnchor.y,o=this.panAnchor.z;this.targetT.x=Math.max(n-e,Math.min(n+e,this.targetT.x)),this.targetT.z=Math.max(o-e,Math.min(o+e,this.targetT.z)),this.targetT.y=Math.max(r-e*.5,Math.min(r+e,this.targetT.y))}fireGesture(){this.gestureFired||(this.gestureFired=!0,this.onGesture?.())}currentPinchDistance(){let e=[...this.activePointers.values()];return e.length<2?0:Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y)}dollyBy(e){this.distT=Math.max(this.minDist,Math.min(this.maxDist,this.distT*e)),this.requestRender()}zoomBy(e){this.interactionEnabled&&(this.dollyBy(e),this.fireGesture())}setPrimaryDragMode(e){this.primaryDragMode=e}setInteractionEnabled(e){this.interactionEnabled=e,!e&&(this.activePointers.clear(),this.dragging=!1,this.panning=!1,this.pinchDist=0)}frame(e,n=!1,r,o=!1,i){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5;let a=Math.max(1,e.radius),s=this.fovY*ue/2,l=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,c=Math.atan(Math.tan(s)*l);this.azT=r??-30*ue,this.polT=Math.max(15,Math.min(80,i?.polarDeg??55))*ue;let d=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=d*Math.max(1.05,Math.min(2,i?.margin??Jn)),this.minDist=Math.max(2,a*.12),this.maxDist=d*4,n?(this.azimuth=this.azT,this.polar=12*ue,this.distance=this.distT*1.7):(this.azimuth=this.azT,this.polar=this.polT,this.distance=this.distT),this.applyPosition()}setAspect(e){this.camera.perspective({aspect:e})}frameSoft(e,n,r=!1,o){this.target.set(e.center[0],e.center[1],e.center[2]),this.targetT.copy(this.target),this.panAnchor.copy(this.target),this.panLimit=Math.max(1,e.radius)*1.5,this.syncFromCamera(),this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect});let i=this.fovY*ue/2,a=r?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,s=Math.atan(Math.tan(i)*a);this.azT=n??this.azimuth,this.polT=Math.max(15,Math.min(80,o?.polarDeg??55))*ue;let l=this.fitDistance(e,i,s,this.azT,this.polT);this.distT=l*Math.max(1.05,Math.min(2,o?.margin??Jn))}fitDistance(e,n,r,o,i){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(r)),l=e.box;if(!l)return s;let c=Math.sin(i),d=-c*Math.sin(o),u=-Math.cos(i),m=-c*Math.cos(o);if(Math.abs(u)>.999)return s;let p=-m,h=d,f=Math.hypot(p,h);p/=f,h/=f;let x=-h*u,b=h*d-p*m,y=p*u,g=Math.tan(r),F=Math.tan(n),w=1;for(let v=0;v<8;v++){let D=(v&1?l.max[0]:l.min[0])-e.center[0],L=(v&2?l.max[1]:l.min[1])-e.center[1],_=(v&4?l.max[2]:l.min[2])-e.center[2],U=D*d+L*u+_*m,B=Math.abs(D*p+_*h),S=Math.abs(D*x+L*b+_*y);w=Math.max(w,B/g-U,S/F-U)}return Math.min(s,Math.max(w,a*.35))}updateClipping(e){let n=this.camera.position.x-e.center[0],r=this.camera.position.y-e.center[1],o=this.camera.position.z-e.center[2],i=Math.hypot(n,r,o),a=Math.max(1,e.radius)*1.18,s=Math.max(.05,i-a),l=Math.max(s+10,i+a);this.camera.perspective({near:s,far:l,aspect:this.camera.aspect})}update(){let e=this.azT-this.azimuth,n=this.polT-this.polar,r=this.distT-this.distance,o=this.targetT.x-this.target.x,i=this.targetT.y-this.target.y,a=this.targetT.z-this.target.z,s=Math.max(1e-4,this.distance*1e-4),l=Math.abs(e)>1e-4||Math.abs(n)>1e-4||Math.abs(r)>1e-4||Math.abs(o)>s||Math.abs(i)>s||Math.abs(a)>s;return this.azimuth+=e*Ke,this.polar+=n*Ke,this.distance+=r*Ke,this.target.x+=o*Ke,this.target.y+=i*Ke,this.target.z+=a*Ke,l&&this.applyPosition(),l}get currentDistance(){return this.distance}syncFromCamera(){let e=this.camera.position.x-this.target.x,n=this.camera.position.y-this.target.y,r=this.camera.position.z-this.target.z,o=Math.hypot(e,n,r)||1,i=Math.max(en,Math.min(tn,Math.acos(Math.max(-1,Math.min(1,n/o)))));this.distance=this.distT=o,this.polar=this.polT=i,this.azimuth=this.azT=Math.atan2(e,r)}setTarget(e){this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target)}resumeAfterFlight(e){this.camera.perspective({fov:this.fovY,aspect:this.camera.aspect}),e&&this.target.set(e[0],e[1],e[2]),this.targetT.copy(this.target),this.syncFromCamera()}applyPosition(){let e=Math.sin(this.polar),n=this.target.x+this.distance*e*Math.sin(this.azimuth),r=this.target.y+this.distance*Math.cos(this.polar),o=this.target.z+this.distance*e*Math.cos(this.azimuth);this.camera.position.set(n,r,o),this.camera.lookAt(this.target)}dispose(){this.canvas.removeEventListener("pointerdown",this.onPointerDown),this.canvas.removeEventListener("pointermove",this.onPointerMove),this.canvas.removeEventListener("pointerup",this.onPointerUp),this.canvas.removeEventListener("pointercancel",this.onPointerUp),this.canvas.removeEventListener("wheel",this.onWheel),this.canvas.removeEventListener("keydown",this.onKeyDown),this.canvas.removeEventListener("contextmenu",this.onContextMenu),this.activePointers.clear()}};var Rt=class{constructor(e){this.rafId=0;this.running=!1;this.lastTime=0;this.fpsEma=0;this.rendered=0;this.tick=e=>{let n=this.lastTime?(e-this.lastTime)/1e3:.016666666666666666;if(this.lastTime=e,n>0){let o=1/n;this.fpsEma=this.fpsEma?this.fpsEma*.9+o*.1:o}this.rendered++,this.frame(n)?this.rafId=requestAnimationFrame(this.tick):(this.running=!1,this.rafId=0)};this.frame=e}requestRender(){this.running||(this.running=!0,this.lastTime=0,this.rafId=requestAnimationFrame(this.tick))}stats(){return{fps:this.running?Math.round(this.fpsEma):0,rendered:this.rendered,idle:!this.running}}stop(){this.rafId&&cancelAnimationFrame(this.rafId),this.rafId=0,this.running=!1}};var Ze=2.5,ti=1.15,lt=6,Qe=10,eo=6,to=9.5,no=.9,oo=2.2,nn=30,on=4,It=8192;var Ms=Qe+on;function ro(t,e){let n=e*1.4,r=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Ze};let o=Math.min(1,(t-n)/Math.max(.001,r-n));return{scale:1-o*.4,fade:o*.55,minPixels:Ze+o*(ti-Ze)}}function io(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function ao(t,e,n,r,o){if(!(t>0)||!(e>0)||!(n>0)||!(r>0)||!(o>0))return!1;let i=Math.tan(r/2*Math.PI/180);if(!(i>0))return!1;let a=e/(n*i)*(o/2);return Math.PI*a*a/t>=64}import ni from"earcut";import oi from"polygon-clipping";var I=ke,ri=.002;function ii(t,e,n){let r=Math.hypot(e[0]-t[0],e[1]-t[1],e[2]-t[2]),o=Math.hypot(n[0]-e[0],n[1]-e[1],n[2]-e[2]),i=Math.hypot(t[0]-n[0],t[1]-n[1],t[2]-n[2]),a=Math.max(r,o,i);if(a<1e-9)return!0;let s=(r+o+i)/2;return 2*Math.sqrt(Math.max(0,s*(s-r)*(s-o)*(s-i)))/a<ri}var Ye=class{constructor(e=16384){this.len=0;this.buf=new Float32Array(e)}push3(e,n,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=e,this.buf[this.len++]=n,this.buf[this.len++]=r}push1(e){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=e}grow(e){let n=this.buf.length*2;for(;n<e;)n*=2;let r=new Float32Array(n);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Et=class{constructor(){this.pos=new Ye;this.nor=new Ye;this.col=new Ye;this.flr=new Ye;this.mat=new Ye;this.currentFloor=0;this.currentMaterial=0}setFloor(e){this.currentFloor=e}setMaterial(e){this.currentMaterial=e}tri(e,n,r,o,i,a=i,s=i){ii(e,n,r)||(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(e,n,r,o,i,a,s,l=s,c=s){[...e,...n,...r].every(Number.isFinite)&&(this.pos.push3(e[0],e[1],e[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(a[0],a[1],a[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function ai(t,e,n){let r=e[0]-t[0],o=e[1]-t[1],i=e[2]-t[2],a=n[0]-t[0],s=n[1]-t[1],l=n[2]-t[2],c=o*l-i*s,d=i*a-r*l,u=r*s-o*a,m=Math.hypot(c,d,u)||1;return c/=m,d/=m,u/=m,[c,d,u]}function si(t,e){let n=[...t],r=[];for(let a of t)r.push(a.x,a.y);let o=[];if(e){for(let a of e)if(!(a.length<3)){o.push(n.length);for(let s of a)n.push(s),r.push(s.x,s.y)}}let i=ni(r,o.length?o:void 0,2);return{pts:n,tris:i}}function rn(t){return He(t)<0?[...t].reverse():t}var ci=3;function li(t,e,n,r){let o=r(t),i=r(e),a=r(n),s=(p,h,f,x)=>Math.abs(r({x:(p.x+h.x)/2,y:(p.y+h.y)/2})-(f+x)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,d=(o+i+a)/3,u=Math.max(s(t,e,o,i),s(e,n,i,a),s(n,t,a,o),Math.abs(r({x:l,y:c})-d)),m=(p,h,f)=>{let x=Math.abs(r({x:(p+l)/2,y:(h+c)/2})-(f+d)/2);x>u&&(u=x)};return m((t.x+e.x)/2,(t.y+e.y)/2,(o+i)/2),m((e.x+n.x)/2,(e.y+n.y)/2,(i+a)/2),m((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),u}function ut(t,e,n,r,o){if(o<=0)return li(t,e,n,r);let i={x:(t.x+e.x)/2,y:(t.y+e.y)/2},a={x:(e.x+n.x)/2,y:(e.y+n.y)/2},s={x:(n.x+t.x)/2,y:(n.y+t.y)/2};return Math.max(ut(t,i,s,r,o-1),ut(i,e,a,r,o-1),ut(s,a,n,r,o-1),ut(i,a,s,r,o-1))}function mt(t,e,n,r,o,i,a,s){if(a>0){let m={x:(e.x+n.x)/2,y:(e.y+n.y)/2},p={x:(n.x+r.x)/2,y:(n.y+r.y)/2},h={x:(r.x+e.x)/2,y:(r.y+e.y)/2};mt(t,e,m,h,o,i,a-1,s),mt(t,m,n,p,o,i,a-1,s),mt(t,h,p,r,o,i,a-1,s),mt(t,m,p,h,o,i,a-1,s);return}let l=[e.x*I,o(e),e.y*I],c=[n.x*I,o(n),n.y*I],d=[r.x*I,o(r),r.y*I];if(s){t.triN(l,c,d,s(e),s(n),s(r),i);return}let u=ai(l,c,d);u[1]<0&&(u=[-u[0],-u[1],-u[2]]),t.tri(l,c,d,u,i)}var ui=8;function so(t,e,n){if(!Number.isFinite(n))return t;let r=[],o=(i,a,s,l,c)=>{if(c>0){let d={x:(i.x+a.x)/2,y:(i.y+a.y)/2},u=e(d);if(Math.abs(u-(s+l)/2)>n){o(i,d,s,u,c-1),o(d,a,u,l,c-1);return}}r.push(i)};for(let i=0;i<t.length;i++){let a=t[i],s=t[(i+1)%t.length];o(a,s,e(a),e(s),ui)}return r}function Tt(t,e){if(t.length<3)return t;let n=[];for(let o of t){let i=n[n.length-1];i&&Math.hypot(o.x-i.x,o.y-i.y)<e||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<e;)n.pop();if(n.length<3)return t;let r=[];for(let o=0;o<n.length;o++){let i=r.length?r[r.length-1]:n[(o-1+n.length)%n.length],a=n[o],s=n[(o+1)%n.length],l=s.x-i.x,c=s.y-i.y,d=Math.hypot(l,c);d>e&&Math.abs((a.x-i.x)*c-(a.y-i.y)*l)/d<e||r.push(a)}return r.length>=3?r:n}var Ft=.001*Le*.1;function ae(t,e,n,r,o,i,a,s,l=1/0,c){if(!e||e.length<3||(l===void 0&&(l=1/0),Math.abs(He(e))<1e-4))return;let d=Tt(so(Tt(rn(e),Ft),r,l),Ft),u=n?.map(v=>Tt(so(Tt(rn(v),Ft),r,l),Ft)).filter(v=>v.length>=3&&Math.abs(He(v))>=1e-4),{pts:m,tris:p}=si(d,u),h=[i[0]*s.top,i[1]*s.top,i[2]*s.top],f=[i[0]*s.bottomCap,i[1]*s.bottomCap,i[2]*s.bottomCap],x=[a[0]*s.top,a[1]*s.top,a[2]*s.top],b=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],y=0;if(Number.isFinite(l))for(;y<ci;y++){let v=0;for(let D=0;D<p.length;D+=3){let L=ut(m[p[D]],m[p[D+1]],m[p[D+2]],r,y);L>v&&(v=L)}if(v<=l)break}for(let v=0;v<p.length;v+=3){let D=m[p[v]],L=m[p[v+1]],_=m[p[v+2]];mt(t,D,L,_,r,h,y,c);let U=[D.x*I,o,D.y*I],B=[L.x*I,o,L.y*I],S=[_.x*I,o,_.y*I];t.tri(U,S,B,[0,-1,0],f)}let g=v=>{if(y<=0)return v;let D=1<<y,L=[];for(let _=0;_<v.length;_++){let U=v[_],B=v[(_+1)%v.length];for(let S=0;S<D;S++){let M=S/D;L.push({x:U.x+(B.x-U.x)*M,y:U.y+(B.y-U.y)*M})}}return L},F=En(d),w=[{ring:g(d),flip:!1}];if(u)for(let v of u)v.length>=3&&w.push({ring:g(v),flip:!0});for(let{ring:v,flip:D}of w)for(let L=0;L<v.length;L++){let _=v[L],U=v[(L+1)%v.length],B=(U.x-_.x)*I,M=(U.y-_.y)*I,A=-B,R=Math.hypot(M,A)||1;M/=R,A/=R;let V=(_.x+U.x)/2-F.x,E=(_.y+U.y)/2-F.y,C=M*V+A*E;D&&(C=-C),C<0&&(M=-M,A=-A);let T=[M,0,A],z=[_.x*I,r(_),_.y*I],P=[U.x*I,r(U),U.y*I],k=[_.x*I,o,_.y*I],O=[U.x*I,o,U.y*I];t.tri(z,P,O,T,x,x,b),t.tri(z,O,k,T,x,b,b)}}function co(t){let e=0;for(let l of t)e+=l.count;let n=new Float32Array(e*3),r=new Float32Array(e*3),o=new Float32Array(e*3),i=new Float32Array(e),a=new Float32Array(e),s=0;for(let l of t)n.set(l.position,s*3),r.set(l.normal,s*3),o.set(l.color,s*3),i.set(l.floor,s),a.set(l.material,s),s+=l.count;return{position:n,normal:r,color:o,floor:i,material:a,count:e}}function Dt(t,e,n=2.5){if(e<=0||t.length<3)return t;let r=rn(t),o=r.length,i=[];for(let s=0;s<o;s++){let l=r[s],c=r[(s+1)%o],d=c.x-l.x,u=c.y-l.y,m=Math.hypot(d,u)||1;i.push({x:u/m,y:-d/m})}let a=[];for(let s=0;s<o;s++){let l=r[s],c=i[(s-1+o)%o],d=i[s],u=c.x+d.x,m=c.y+d.y,p=Math.hypot(u,m),h=()=>{a.push([l.x+c.x*e,l.y+c.y*e]),a.push([l.x+d.x*e,l.y+d.y*e])};if(p<1e-9){h();continue}u/=p,m/=p;let f=u*c.x+m*c.y,x=1/Math.max(f,1e-6);if(!Number.isFinite(x)||x>n){h();continue}a.push([l.x+u*e*x,l.y+m*e*x])}if(a.length<3)return t;try{let s=oi.union([[...a,a[0]]]),l=null,c=-1/0;for(let u of s){let m=Math.abs(He(u[0].map(([p,h])=>({x:p,y:h}))));m>c&&(c=m,l=u[0])}if(!l)return t;let d=l.map(([u,m])=>({x:u,y:m}));if(d.length>1){let u=d[0],m=d[d.length-1];Math.abs(u.x-m.x)<1e-9&&Math.abs(u.y-m.y)<1e-9&&d.pop()}return d.length>=3?d:t}catch{return t}}function kt(t,e,n,r,o=28){let i=[];for(let a=0;a<o;a++){let s=a/o*Math.PI*2;i.push({x:t+n*Math.cos(s),y:e+r*Math.sin(s)})}return i}function dt(t,e,n,r){return[{x:t,y:e},{x:t+n,y:e},{x:t+n,y:e+r},{x:t,y:e+r}]}var ee={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},mi=.44,di=.15,hi=.3,pi=.24;function lo(t){return t===void 0||!Number.isFinite(t)||t<=0?pi:Math.min(hi,Math.max(di,t*mi))}var an=.21,fi=.05,sn=.45,Lt=sn+fi,bi=[{part:ee.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ee.pad,min:[-1,.36,-.95],max:[1,sn,1]},{part:ee.back,min:[-1,Lt,-1],max:[1,.92,-.72]},{part:ee.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ee.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ee.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ee.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ee.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ee.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ee.leg,min:[.62,0,.48],max:[.82,.37,.7]}],yi=[{part:ee.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ee.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ee.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ee.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ee.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],xi=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function uo(){let t=[],e=[],n=[],r=[],o=(R,V,E)=>{let C=n.length,[T,z,P]=R,k=[z[0]-T[0],z[1]-T[1],z[2]-T[2]],O=[P[0]-T[0],P[1]-T[1],P[2]-T[2]],H=k[1]*O[2]-k[2]*O[1],X=k[2]*O[0]-k[0]*O[2],Y=k[0]*O[1]-k[1]*O[0],j=Math.hypot(H,X,Y);j>1e-9?(H/=j,X/=j,Y/=j):[H,X,Y]=V,H*V[0]+X*V[1]+Y*V[2]<0&&(H=-H,X=-X,Y=-Y);for(let K of R)t.push(...K),e.push(H,X,Y),n.push(E);r.push(C,C+1,C+2,C,C+2,C+3)},i=R=>{for(let V of xi){let E=V.c.map(C=>C.map((T,z)=>T?R.max[z]:R.min[z]));o(E,V.n,R.part)}};for(let R of bi)i(R);for(let R of yi)i(R);let a=sn,s=1.08,l=.47,c=.69,d=-.55,u=.08,m=-.48,p=.01,h=[-l,a,d],f=[l,a,d],x=[-l,a,u],b=[l,a,u],y=[-c,s,m],g=[c,s,m],F=[-c,s,p],w=[c,s,p];o([f,g,w,b],[1,0,0],ee.body),o([x,F,y,h],[-1,0,0],ee.body),o([F,w,g,y],[0,1,0],ee.body),o([h,f,b,x],[0,-1,0],ee.body),o([b,w,F,x],[0,0,1],ee.body),o([h,y,g,f],[0,0,-1],ee.body);let v=10,D=8,L=[0,1.205,-.23],_=[.42,.115,.38],U=n.length;for(let R=0;R<=D;R++){let V=Math.PI*R/D,E=Math.cos(V),C=Math.sin(V);for(let T=0;T<=v;T++){let z=Math.PI*2*T/v,P=C*Math.cos(z),k=C*Math.sin(z);t.push(L[0]+_[0]*P,L[1]+_[1]*E,L[2]+_[2]*k);let O=P/_[0],H=E/_[1],X=k/_[2],Y=Math.hypot(O,H,X)||1;O/=Y,H/=Y,X/=Y,e.push(O,H,X),n.push(ee.head)}}for(let R=0;R<D;R++)for(let V=0;V<v;V++){let E=U+R*(v+1)+V,C=E+v+1;r.push(E,C,E+1,E+1,C,C+1)}let B=new Float32Array(t),S=new Float32Array(e),M=new Float32Array(n),A=new Uint16Array(r);return{position:B,normal:S,part:M,index:A,vertexCount:n.length,indexCount:r.length}}function mo(t,e,n,r){let o=new Float32Array(e),i=c=>t[c*3],a=c=>t[c*3+2],s=0,l=(c,d)=>{let u=d-c;for(let m=c;m<d;m++){let[p,h]=r(m),f=p-i(m),x=h-a(m);if(u>=2){let b=Math.max(c,m-1),y=Math.min(d-1,m+1),g=i(y)-i(b),F=a(y)-a(b),w=Math.hypot(g,F);if(w>1e-6){let v=-F/w,D=g/w;v*f+D*x<0&&(v=-v,D=-D),f=v,x=D}}o[m]=f===0&&x===0?0:Math.atan2(f,x)}};for(let c=1;c<=e;c++)(c===e||n(c)!==n(s))&&(l(s,c),s=c);return o}var Re=.22;function ho(t,e){let n=be[t];if(n!=="sold"&&n!=="held")return-1;let r=(e+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var gi=.42;function vi(t){let e=t.length,n=new Float64Array(e);if(e<2)return n.fill(1/0),n;let r=1/0,o=1/0,i=-1/0,a=-1/0;for(let h of t)h.x<r&&(r=h.x),h.y<o&&(o=h.y),h.x>i&&(i=h.x),h.y>a&&(a=h.y);let s=Math.max(i-r,1e-6),l=Math.max(a-o,1e-6),c=Math.max(Math.sqrt(s*l/e),1e-6),d=Math.max(1,Math.ceil(s/c)+1),u=Math.max(1,Math.ceil(l/c)+1),m=new Map,p=(h,f)=>{let x=Math.min(d-1,Math.max(0,Math.floor((h-r)/c)));return Math.min(u-1,Math.max(0,Math.floor((f-o)/c)))*d+x};for(let h=0;h<e;h++){let f=p(t[h].x,t[h].y),x=m.get(f);x?x.push(h):m.set(f,[h])}for(let h=0;h<e;h++){let f=t[h],x=Math.min(d-1,Math.max(0,Math.floor((f.x-r)/c))),b=Math.min(u-1,Math.max(0,Math.floor((f.y-o)/c))),y=1/0;for(let g=1;g<=4;g++){for(let F=b-g;F<=b+g;F++)if(!(F<0||F>=u))for(let w=x-g;w<=x+g;w++){if(w<0||w>=d||g>1&&Math.abs(F-b)<g&&Math.abs(w-x)<g)continue;let v=m.get(F*d+w);if(v)for(let D of v){if(D===h)continue;let L=Math.hypot(t[D].x-f.x,t[D].y-f.y);L<y&&(y=L)}}if(Number.isFinite(y)&&y<=g*c)break}n[h]=y}return n}function Mi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function po(t,e,n,r,o,i){let a=t.length,s=new Float32Array(a*3),l=new Float32Array(a),c=new Float32Array(a*3),d=new Float32Array(a),u=new Float32Array(a),m=new Float32Array(a),p=new Float32Array(a),h=new Float32Array(a*3),f=new Map,x=vi(t);for(let b=0;b<a;b++){let y=t[b],F=(n?.seatPitchU(b)??x[b])*I;d[b]=Number.isFinite(F)?Math.max(.06,Math.min(Re,F*gi)):Re,u[b]=lo(Number.isFinite(F)?F:void 0);let w=Bn(y.glyph,{seatGlyph:i?.get(y.categoryKey)});m[b]=On.indexOf(w),p[b]=y.wheelchairSpaceType==="no-seat"?0:1,s[b*3]=y.x*I,s[b*3+1]=n?n.seatDeckY(b):Mi(y),s[b*3+2]=y.y*I,l[b]=ct(e?e(y):"available");let v=Z(o?.get(y.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[b*3]=v[0],c[b*3+1]=v[1],c[b*3+2]=v[2],y.accessibility?.length){let D=Z(Fn(y.accessibility));D&&(h[b*3]=D[0],h[b*3+1]=D[1],h[b*3+2]=D[2])}f.set(y.id,b)}return{count:a,iPosition:s,iState:l,iCategory:c,iMaxRadius:d,iRing:h,idToIndex:f,iChairWidth:u,iGlyph:m,iPhysicalSeat:p,iFloor:r??new Float32Array(a),iYaw:new Float32Array(a)}}var Si=64;function cn(t,e){let n=[];for(let a of e){let s=t.idToIndex.get(a.seatId);if(s===void 0)continue;let l=ct(a.state);t.iState[s]!==l&&(t.iState[s]=l,n.push(s))}if(!n.length)return[];n.sort((a,s)=>a-s);let r=[],o=n[0],i=n[0];for(let a=1;a<n.length;a++){let s=n[a];if(s!==i){if(s<=i+Si){i=s;continue}r.push({start:o,length:i-o+1}),o=s,i=s}}return r.push({start:o,length:i-o+1}),r}var wi=.15,Pi=.9,Ai=1.76,Ci=.7,Ri=1.6;function Ii(){return{background:{top:[...Ue.top],bottom:[...Ue.bottom]},structure:$t,seatStates:{...Zn},seatScale:1}}function fo(t){let e=Ii();if(!t)return e;let n=Z(t.background);if(n){e.background={top:pe(n,Pi),bottom:pe(n,Ai)};let i={};for(let[a,s]of Object.entries($t))i[a]=he(s,n,wi);e.structure=i}let r=Z(t.selectionColor)??Z(t.accent);r&&(e.seatStates={...e.seatStates,selected:r});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(Ri,Math.max(Ci,o))),e}function bo(t,e){let n=[];for(let r of e)n.push(...t.seatStates[r]);return n}import vo from"polygon-clipping";import Ti from"earcut";var Fi=.58,yo=.01,fe=Re*1.5*Le,Ei=.5,Di=.6;function ki(t,e){let n=t.length,r=[];for(let a=0;a<n;a++){let s=t[Math.max(0,a-1)],l=t[Math.min(n-1,a+1)],c=l.x-s.x,d=l.y-s.y,u=Math.hypot(c,d);if(u<1e-9){r.push([0,0]);continue}c/=u,d/=u,r.push([-d,c])}let o=0;for(let a=0;a<n;a++)o+=(t[a].x-e.x)*r[a][0]+(t[a].y-e.y)*r[a][1];return o<0?r.map(([a,s])=>[-a,-s]):r}function Li(t,e){if(t.length<2||e<=0)return[...t];let n=[...t],r=(a,s)=>{let l=s.x-a.x,c=s.y-a.y,d=Math.hypot(l,c)||1;return{x:l/d,y:c/d}},o=r(n[1],n[0]),i=r(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*e,y:n[0].y+o.y*e}),n.push({x:n[n.length-1].x+i.x*e,y:n[n.length-1].y+i.y*e}),n}var xo=Math.PI/12;function _i(t){if(t.length<3)return[...t];let e=[...t].sort((i,a)=>i.x-a.x||i.y-a.y),n=(i,a,s)=>(a.x-i.x)*(s.y-i.y)-(a.y-i.y)*(s.x-i.x),r=i=>{let a=[];for(let s of i){for(;a.length>=2&&n(a[a.length-2],a[a.length-1],s)<=0;)a.pop();a.push(s)}return a.pop(),a},o=[...r(e),...r([...e].reverse())];return o.length>=3?o:[...t]}function Mo(t,e){if(!t.length||!(e>0))return[];let n=_i(t),r=(s,l,c,d)=>{let u=c-l;for(;u<0;)u+=Math.PI*2;for(;u>Math.PI*2;)u-=Math.PI*2;let m=Math.max(1,Math.ceil(u/xo)),p=e/Math.cos(u/m/2);for(let h=0;h<=m;h++){let f=l+u*h/m;d.push({x:s.x+Math.cos(f)*p,y:s.y+Math.sin(f)*p})}};if(n.length<3){let s=0,l=0;for(let p of n)s+=p.x,l+=p.y;s/=n.length||1,l/=n.length||1;let c=0;for(let p of n)c=Math.max(c,Math.hypot(p.x-s,p.y-l));let d=[],u=Math.max(3,Math.ceil(Math.PI*2/xo)),m=(c+e)/Math.cos(Math.PI/u);for(let p=0;p<u;p++){let h=p/u*Math.PI*2;d.push({x:s+Math.cos(h)*m,y:l+Math.sin(h)*m})}return d}let o=n.length,i=[];for(let s=0;s<o;s++){let l=n[s],c=n[(s+1)%o];i.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let a=[];for(let s=0;s<o;s++)r(n[s],i[(s+o-1)%o],i[s],a);return Co(a)}function Oi(t,e,n){if(t.length===1)return Math.hypot(e-t[0].x,n-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let i=t[o],a=t[o+1],s=a.x-i.x,l=a.y-i.y,c=s*s+l*l,d=c>1e-12?((e-i.x)*s+(n-i.y)*l)/c:0;d<0?d=0:d>1&&(d=1);let u=Math.hypot(e-(i.x+d*s),n-(i.y+d*l));u<r&&(r=u)}return r}function _t(t){let e=t.map(o=>{let i=0,a=0;for(let c of o.pts)i+=c.x,a+=c.y;let s=o.pts.length||1;i/=s,a/=s;let l=0;for(let c of o.pts){let d=Math.hypot(c.x-i,c.y-a);d>l&&(l=d)}return{cx:i,cy:a,rad:l}}),n=o=>{let i=o.length;return i<=2?[...o]:[o[Math.floor(i*.25)],o[Math.floor(i*.5)],o[Math.floor(i*.75)]]},r=[];for(let o=0;o<t.length;o++){let i=n(t[o].pts),a=[],s=1/0,l=null;for(let d of i){let u=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let p=e[m],h=Math.hypot(d.x-p.cx,d.y-p.cy)-p.rad;if(h>=u&&h>=s)continue;let f=Oi(t[m].pts,d.x,d.y);f<u&&(u=f),t[m].depth<t[o].depth&&f<s&&(s=f,l=t[m].y)}Number.isFinite(u)&&u>0&&a.push(u)}a.sort((d,u)=>d-u);let c=a.length?a[Math.floor(a.length/2)]:1;r.push({pitch:c,belowY:l})}return r}function So(t,e,n,r){let o=t[e],i=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let d=o.pts[0],u=d.x-r.x,m=d.y-r.y,p=Math.hypot(u,m)||1;u/=p,m/=p;let h=Math.max(n[e].pitch,.001)*.5;return[{x:d.x+m*h,y:d.y-u*h},{x:d.x-m*h,y:d.y+u*h}]})():[];if(i.length<2)return null;let a=0,s=0;for(let d=1;d<i.length;d++){let u=Math.hypot(i[d].x-i[d-1].x,i[d].y-i[d-1].y);u>1e-6&&(a+=u,s++)}let l=s>0?a/s:0,c=Li(i,Math.max(l*Di,fe));return{pts:c,nrm:ki(c,r),front:Math.max(n[e].pitch*Fi,fe),back:Math.max(n[e].pitch*Ei,fe)}}var $e=1.5,wo=.3;function ln(t,e){if(t.length<3)return t;let n=t[0],r=t[t.length-1],o=r.x-n.x,i=r.y-n.y,a=Math.hypot(o,i),s=-1,l=-1;for(let u=1;u<t.length-1;u++){let m=t[u],p=a>1e-12?Math.abs((m.x-n.x)*i-(m.y-n.y)*o)/a:Math.hypot(m.x-n.x,m.y-n.y);p>s&&(s=p,l=u)}if(s<=e||l<0)return[n,r];let c=ln(t.slice(0,l+1),e),d=ln(t.slice(l),e);return[...c.slice(0,-1),...d]}function Po(t,e){if(t.length<4)return t;let n=ln([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function Ao(t,e,n){if(t.length<2)return[];let r=n??_t(t),o=new Map;for(let a=0;a<t.length;a++){let s=o.get(t[a].blockId);s?s.push(a):o.set(t[a].blockId,[a])}let i=[];for(let[,a]of o){let s=[];for(let y of a){let g=t[y].patch;g&&g.length>=3?i.push({outline:[...g],holes:[],topY:t[y].y}):s.push(y)}if(!s.length)continue;s.sort((y,g)=>t[y].depth-t[g].depth);let c=s.map(y=>So(t,y,r,e)).filter(y=>y!==null);if(!c.length)continue;let d=(y,g)=>({x:y.pts[g].x-y.nrm[g][0]*(y.front+$e),y:y.pts[g].y-y.nrm[g][1]*(y.front+$e)}),u=(y,g)=>({x:y.pts[g].x+y.nrm[g][0]*(y.back+$e),y:y.pts[g].y+y.nrm[g][1]*(y.back+$e)}),m=c[0],p=c[c.length-1],h=[];for(let y=0;y<m.pts.length;y++)h.push(d(m,y));for(let y of c)h.push(u(y,y.pts.length-1));for(let y=p.pts.length-1;y>=0;y--)h.push(u(p,y));for(let y=c.length-1;y>=0;y--)h.push(d(c[y],0));let f=Co(h),x=1/0;for(let y of s)t[y].y<x&&(x=t[y].y);if(!Number.isFinite(x))continue;if(f.length>=3&&Math.abs(He(f))>1e-6&&c.every(y=>{let g=y.pts[Math.floor(y.pts.length/2)];return st(f,g.x,g.y)})){i.push({outline:Po(f,wo),holes:[],topY:x});continue}for(let y of Bi(c))i.push({outline:y,holes:[],topY:x})}return i}function Bi(t){let e=[];for(let n of t){let r=[],o=[],i=n.front+$e,a=n.back+$e;for(let l=0;l<n.pts.length;l++){let c=n.pts[l],d=n.nrm[l];r.push([c.x-d[0]*i,c.y-d[1]*i]),o.push([c.x+d[0]*a,c.y+d[1]*a])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=vo.union(e[0],...e.slice(1)),r=[];for(let o of n){if(!o.length||o[0].length<4)continue;let i=o[0].map(([l,c])=>({x:l,y:c})),a=i[0],s=i[i.length-1];i.length>1&&Math.abs(a.x-s.x)<1e-9&&Math.abs(a.y-s.y)<1e-9&&i.pop(),i.length>=3&&r.push(Po(i,wo))}return r}catch{return[]}}function Co(t){let e=[];for(let n of t){let r=e[e.length-1];r&&Math.hypot(n.x-r.x,n.y-r.y)<1e-9||e.push(n)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<1e-9;)e.pop();return e}var un=class{constructor(e){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=e;for(let n of e)for(let r of n)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(e){for(let n of e)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let r=!0;for(let o of e)if(!st(n,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function go(t,e,n,r,o,i){if(r.length<3)return;if(n.containsAll(r)){let c=[0,1,0],d=r[0];for(let u=1;u+1<r.length;u++){let m=r[u],p=r[u+1];t.tri([d.x*I,o,d.y*I],[m.x*I,o,m.y*I],[p.x*I,o,p.y*I],c,i)}return}let a=r.map(c=>[c.x,c.y]);a.push(a[0]);let s;try{s=vo.intersection([a],e)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let d=c[0],u=[],m=[];for(let h=0;h<d.length-1;h++)u.push(d[h][0],d[h][1]),m.push([d[h][0],d[h][1]]);if(m.length<3)continue;let p=Ti(u,void 0,2);for(let h=0;h<p.length;h+=3){let f=m[p[h]],x=m[p[h+1]],b=m[p[h+2]];t.tri([f[0]*I,o,f[1]*I],[x[0]*I,o,x[1]*I],[b[0]*I,o,b[1]*I],l,i)}}}function Ro(t,e,n,r,o,i,a){if(e.length<2)return;let s=a??_t(e),l=[0,1,0],c=i&&i.length>=3?[[...i.map(p=>[p.x,p.y]),[i[0].x,i[0].y]]]:null,d=i&&i.length>=3?new un([[...i]]):null,u=p=>{t.setMaterial(2),p(),t.setMaterial(0)},m=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let h=e[p];if(h.patch&&h.patch.length>=3){let w=[...h.patch],v=s[p].belowY??r;if(m(()=>{if(c&&d)go(t,c,d,w,h.y,o.tread);else{let D=w[0];for(let L=1;L+1<w.length;L++){let _=w[L],U=w[L+1];t.tri([D.x*I,h.y,D.y*I],[_.x*I,h.y,_.y*I],[U.x*I,h.y,U.y*I],l,o.tread)}}}),h.y>v+yo){let D=0,L=0;for(let _ of w)D+=_.x,L+=_.y;D/=w.length,L/=w.length,u(()=>{for(let _=0;_<w.length;_++){let U=w[_],B=w[(_+1)%w.length],S=B.x-U.x,M=B.y-U.y,A=Math.hypot(S,M);if(A<1e-6)continue;let R=M/A,V=-S/A;(U.x-D)*R+(U.y-L)*V<0&&(R=-R,V=-V);let E=[R,0,V],C=[U.x*I,h.y,U.y*I],T=[B.x*I,h.y,B.y*I],z=[U.x*I,v,U.y*I],P=[B.x*I,v,B.y*I];t.tri(C,T,P,E,o.riser),t.tri(C,P,z,E,o.riser)}})}continue}let f=So(e,p,s,n);if(!f)continue;let{pts:x,nrm:b,front:y,back:g}=f,F=s[p].belowY??r;for(let w=0;w+1<x.length;w++){let v=x[w],D=x[w+1],L=b[w],_=b[w+1];if(Math.hypot(D.x-v.x,D.y-v.y)<1e-6||L[0]===0&&L[1]===0||_[0]===0&&_[1]===0)continue;let U=[(v.x-L[0]*y)*I,h.y,(v.y-L[1]*y)*I],B=[(D.x-_[0]*y)*I,h.y,(D.y-_[1]*y)*I],S=[(v.x+L[0]*g)*I,h.y,(v.y+L[1]*g)*I],M=[(D.x+_[0]*g)*I,h.y,(D.y+_[1]*g)*I];if(m(()=>{c&&d?go(t,c,d,[{x:v.x-L[0]*y,y:v.y-L[1]*y},{x:D.x-_[0]*y,y:D.y-_[1]*y},{x:D.x+_[0]*g,y:D.y+_[1]*g},{x:v.x+L[0]*g,y:v.y+L[1]*g}],h.y,o.tread):(t.tri(U,B,M,l,o.tread),t.tri(U,M,S,l,o.tread))}),h.y>F+yo){let A=[U[0],F,U[2]],R=[B[0],F,B[2]],V=[-L[0],0,-L[1]];u(()=>{t.tri(U,B,R,V,o.riser),t.tri(U,R,A,V,o.riser)})}}}}import To from"polygon-clipping";function Vi(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function Io(t,e){return t.filter(n=>n.type!=="shape"||Vi(n,e))}function Fo(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:Io(r.objects,e),focal:{x:(r.focalPoint??n).x,y:(r.focalPoint??n).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:Io(t.objects,e),focal:n,baseHeightM:0,index:0}]}var zi={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Vn(t)??zi}function Eo(t,e){let n=Dt(t.outline,fe),r=Je(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(r,Je(a.outline)));if(!o.length)return[n];let i=a=>{let s=a.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let a=To.difference([i(n)],...o.map(l=>[i(l.outline)])),s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([d,u])=>({x:d,y:u}));if(c.length>1){let d=c[0],u=c[c.length-1];Math.abs(d.x-u.x)<1e-9&&Math.abs(d.y-u.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[n]}catch{return[n]}}function Do(t,e){if(!e.length)return t;let n=i=>{let a=i.map(s=>[s.x,s.y]);return a.push(a[0]),a},r=e.map(i=>[n(i)]),o=[];for(let i of t){let a;try{a=To.intersection([n(i.outline)],r.flat())}catch{o.push(i);continue}for(let s of a){if(!s.length)continue;let l=s[0].map(([c,d])=>({x:c,y:d}));if(l.length>1){let c=l[0],d=l[l.length-1];Math.abs(c.x-d.x)<1e-9&&Math.abs(c.y-d.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:i.topY})}}return o.length?o:t}var Ni=.05,ko=.05,Gi=.15,mn=25;function Lo(t,e,n){let r=new Map,o=new Array(e.length).fill(null),i=new Float64Array(e.length),a=new Array(e.length).fill(void 0),s=new Array(e.length).fill(void 0),l=new Map,c=[],d=new Set;for(let u=0;u<t.length;u+=1){let m=t[u];for(let p of m.objects){if(p.type==="table"&&d.add(p.id),p.type!=="section"||!p.outline||p.outline.length<3)continue;let h=Dt(p.outline,fe);l.set(p.id,{section:p,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:p.id,floorIndex:u,box:Je(h),section:p,unit:m,outline:h})}}for(let u=0;u<e.length;u++){let m=e[u];for(let p of c){if(n&&p.floorIndex!==n[u]||m.x<p.box.minX||m.x>p.box.maxX||m.y<p.box.minY||m.y>p.box.maxY||!Ln({x:m.x,y:m.y},p.outline,p.section.holes))continue;o[u]=p.id;let h=l.get(p.id);h.hasSeats=!0;let f=m.focalPoint??p.unit.focal,x=Math.hypot(m.x-f.x,m.y-f.y);x<h.frontU&&(h.frontU=x),h.seatIndices.push(u);let b=m.rowId||`__seat-${u}`,y=h.rows.get(b);y?y.push({x:m.x,y:m.y}):h.rows.set(b,[{x:m.x,y:m.y}]);break}}for(let[u,m]of l){let p=Dn(m.section,{floorBaseHeightM:m.unit.baseHeightM}),h=m.unit.baseHeightM,f=p.rake>0?Math.tan(p.rake*Math.PI/180):0,x=p.rake<=.01&&p.height<=h+.001,b=m.section.surfaceKind,y=b==="flat"?!0:b==="rakedRows"&&p.rake>.01?!1:x,g=m.hasSeats?kn(u,e,m.seatIndices,m.unit.focal):{sectionId:u,rows:[],blockCount:0},w=g.rows.length<2?Un([...m.rows.values()].map(E=>({points:E})),m.unit.focal):null,v=1/0;if(w){if(m.hasSeats)for(let E of m.rows.values())for(let C of E){let T=w.depthAt(C.x,C.y);T<v&&(v=T)}if(!m.hasSeats||!Number.isFinite(v)){v=1/0;for(let E of m.section.outline){let C=w.depthAt(E.x,E.y);C<v&&(v=C)}}}let D=h+Ni,L=Math.max(D,p.height),_=E=>{let C=Math.max(0,E-v)*ke,T=Math.min(C*f,mn);return Math.max(D,p.height+T)},U=E=>{let C=Math.max(0,E)*ke,T=Math.min(C*f,mn);return Math.max(D,p.height+T)},B=y?[]:g.rows.map(E=>({pts:E.pts,y:U(E.blockDepth),depth:E.blockDepth,blockId:E.blockId,...d.has(E.id)?{patch:Mo(E.pts,fe)}:{}})),S=B.length?B[0].y:L,M=B.map(E=>{let C=E.patch&&E.patch.length>=3?E.patch:E.pts,T=0,z=0;for(let O of C)T+=O.x,z+=O.y;let P=C.length||1;T/=P,z/=P;let k=0;for(let O of C){let H=Math.hypot(O.x-T,O.y-z);H>k&&(k=H)}return{cx:T,cy:z,rad:k}}),A=y?()=>L:B.length>=2?(E,C)=>{let T=1/0,z=S;for(let P=0;P<B.length;P++){let k=M[P];if(Math.hypot(E-k.cx,C-k.cy)-k.rad>=T)continue;let O=B[P].patch,H=O&&O.length>=3?st(O,E,C)?0:wt(O,E,C):wt(B[P].pts,E,C);H<T&&(T=H,z=B[P].y)}return z}:(E,C)=>w?_(w.depthAt(E,C)):L,R=[0,1,0],V=B.length>=2||y?()=>R:(E,C)=>{if(!w)return R;let T=w.depthAt(E,C);if(T<=v)return R;let z=(T-v)*ke;if(z*f>=mn||p.height+z*f<=D)return R;let[P,k]=w.gradientAt(E,C);if(P===0&&k===0)return R;let O=1/Math.hypot(f,1);return[-P*f*O,O,-k*f*O]};if(!y)for(let E of g.rows){let C=U(E.blockDepth);for(let T of E.seatIndices)a[T]=C}for(let E of g.rows){let C=[];for(let O=1;O<E.pts.length;O++){let H=Math.hypot(E.pts[O].x-E.pts[O-1].x,E.pts[O].y-E.pts[O-1].y);H>1e-6&&C.push(H)}C.sort((O,H)=>O-H);let T=C.length?C[Math.floor(C.length/2)]:1/0,z=1/0,P=E.pts[Math.floor(E.pts.length/2)];if(P)for(let O of g.rows){if(O===E||O.blockId!==E.blockId)continue;let H=wt(O.pts,P.x,P.y);H>1e-6&&H<z&&(z=H)}let k=Math.min(T,Math.max(z,T*.5));if(Number.isFinite(k)&&k>0)for(let O of E.seatIndices)s[O]=k}r.set(u,{sectionId:u,deckAt:A,normalAt:V,flat:y,bottomY:h,rowLevels:B,landingY:S})}for(let u=0;u<e.length;u++){let m=o[u],p=e[u];if(m){let f=a[u];i[u]=(f??r.get(m).deckAt(p.x,p.y))+Gi;continue}let h=p.eyeHeightM;i[u]=Number.isFinite(h)?Math.max(0,h-St):0}return{bySection:r,seatOwner:o,seatDeckY:u=>i[u],seatPitchU:u=>s[u]}}var ie={top:1,wallBottom:.5,bottomCap:.4};function Ie(t,e){if(!t)return e;let n=pe(at(t,.4),.62);return he(e,n,.72)}function _o(t,e){let n=new Map;for(let i of t.categories??[])n.set(i.key,i.color);let r=new Map;for(let i of e){if(!i.sectionId)continue;let a=r.get(i.sectionId);a||(a=new Map,r.set(i.sectionId,a)),a.set(i.categoryKey,(a.get(i.categoryKey)??0)+1)}let o=new Map;for(let[i,a]of r){let s=0,l=0,c=0,d=0;for(let[u,m]of a){let p=Z(n.get(u));p&&(s+=p[0]*m,l+=p[1]*m,c+=p[2]*m,d+=m)}d>0&&o.set(i,[s/d,l/d,c/d])}return o}function Oo(t,e){return Z(t.color)??e.get(t.logicalSectionId??t.id)??null}import Hi from"polygon-clipping";function Ui(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Ot=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let r=e.map(l=>[l.x,l.y]);if(r.length<3)return[];r.push(r[0]);let o=Je(e),i=this.rings.filter((l,c)=>Pt(o,this.boxes[c])&&Ui(n,this.levels[c])),a=[[r]];if(i.length)try{a=Hi.difference([r],...i).map(c=>c.map(d=>d.map(([u,m])=>[u,m])))}catch{a=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(n);let s=[];for(let l of a){if(!l.length)continue;let c=l[0].map(([d,u])=>({x:d,y:u}));if(c.length>1){let d=c[0],u=c[c.length-1];Math.abs(d.x-u.x)<1e-9&&Math.abs(d.y-u.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function Yi(t,e){if(!e)return t;let n=1/0,r=-1/0,o=1/0,i=-1/0;for(let u of t)n=Math.min(n,u.x),r=Math.max(r,u.x),o=Math.min(o,u.y),i=Math.max(i,u.y);let a=(n+r)/2,s=(o+i)/2,l=e*Math.PI/180,c=Math.cos(l),d=Math.sin(l);return t.map(u=>{let m=u.x-a,p=u.y-s;return{x:a+m*c-p*d,y:s+m*d+p*c}})}function ht(t){let e=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(e=t.points),t.kind==="rect"&&t.width&&t.height&&(e=dt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let n=(t.x??0)+t.width/2,r=(t.y??0)+t.height/2;e=kt(n,r,t.width/2,t.height/2)}return e?Yi(e,t.rotation):null}function pt(t){let e=t.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},r=e==="stage"&&zn(t.stageKind)?{kind:"stage",heightM:.06}:n[e]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var Xi=.08;function Bo(t,e){let n=ht(t),r=pt(t),o=r.heightM;if(!n||r.kind!=="plate"&&r.kind!=="stage")return o;let i=1/0,a=1/0,s=-1/0,l=-1/0;for(let d of n)i=Math.min(i,d.x),a=Math.min(a,d.y),s=Math.max(s,d.x),l=Math.max(l,d.y);let c=o;for(let d of e)s>d.minX&&i<d.maxX&&l>d.minY&&a<d.maxY&&c<=d.topOffsetM+1e-6&&(c=d.topOffsetM+Xi);return e.push({minX:i,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function _e(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function Vo(t){if(t.length!==4)return t;let e=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),n=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return e>=n?t:[t[1],t[2],t[3],t[0]]}function ft(t,e,n){return[_e(t[0],t[1],e),_e(t[0],t[1],n),_e(t[3],t[2],n),_e(t[3],t[2],e)]}function zo(t,e,n){return[_e(t[0],t[3],e),_e(t[1],t[2],e),_e(t[1],t[2],n),_e(t[0],t[3],n)]}function Te(t,e,n,r,o,i){ae(t,e,void 0,()=>n,r,o,i,ie)}var dn=2.4,Wi=.75,ji=.15;function bt(t){if(t.points&&t.points.length>=3)return t.points;let{center:e,width:n,height:r,rotation:o}=t;if(!n||!r)return null;let i=(o??0)*Math.PI/180,a=Math.cos(i),s=Math.sin(i),l=n/2,c=r/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([d,u])=>({x:e.x+d*a-u*s,y:e.y+d*s+u*a}))}function No(t,e,n,r,o){let i=bt(e);i&&ae(t,i,void 0,()=>n+dn,n,Ie(r,o.boothTop),o.boothWall,ie)}function hn(t){if(t.shape==="round"){let d=t.radius;return d?kt(t.center.x,t.center.y,d,d,24):null}let{width:e,height:n,rotation:r,center:o}=t;if(!e||!n)return null;let i=(r??0)*Math.PI/180,a=Math.cos(i),s=Math.sin(i),l=e/2,c=n/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([d,u])=>({x:o.x+d*a-u*s,y:o.y+d*s+u*a}))}function Go(t,e,n,r,o){let i=hn(e);i&&ae(t,i,void 0,()=>n+Wi,n,Ie(r,o.tableTop),o.tableWall,ie)}function Ho(t,e,n,r,o,i,a){let s=ht(e);if(!s)return;let l=e.role==="stage",c=pt(e),d=n+r;if(l&&a){let f=1/0,x=-1/0,b=1/0,y=-1/0;for(let g of s)g.x<f&&(f=g.x),g.x>x&&(x=g.x),g.y<b&&(b=g.y),g.y>y&&(y=g.y);a.push({cx:(f+x)/2*I,cz:(b+y)/2*I,y:d,halfX:Math.max((x-f)/2*I,.5),halfZ:Math.max((y-b)/2*I,.5)})}let u=Z(e.fill),m=l&&u?he(o.stageTop,pe(at(u,.18),.9),.9):Ie(u,l?o.stageTop:o.decorTop),p=e.role==="screen"?u:null,h=l?u?he(o.stageWall,pe(u,.58),.82):o.stageWall:e.role==="screen"?p?he(pe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ie(Z(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let f=Vo(s);Te(t,ft(f,0,.16),d,n,m,h),Te(t,ft(f,.84,1),d,n,m,h),Te(t,f,d,Math.max(n,d-.35),m,h);return}if(c.kind==="suite"&&s.length===4){let f=s.map((y,g)=>{let F=s[(g+1)%4],w=(y.x+F.x)/2,v=(y.y+F.y)/2;return Math.hypot(w-i.x,v-i.y)}),x=f.indexOf(Math.min(...f)),b=[0,1,2,3].map(y=>s[(x+y)%4]);Te(t,ft(b,0,.08),d,n,m,h),Te(t,ft(b,.92,1),d,n,m,h),Te(t,zo(b,.88,1),d,n,m,h),Te(t,b,d,Math.max(n,d-.18),m,h);return}Te(t,s,d,n,m,h)}function pn(t){let{x:e,y:n,width:r,height:o}=t;if(!r||!o)return null;let i=e+r/2,a=n+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),d=r/2,u=o/2;return[[-d,-u],[d,-u],[d,u],[-d,u]].map(([m,p])=>({x:i+m*l-p*c,y:a+m*c+p*l}))}function qi(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let e=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{e=atob(e)}catch{return null}else try{e=decodeURIComponent(e)}catch{}let n=e.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let r=n[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return Z(r);let i=e.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let a=[];for(let s of i[1].matchAll(/stop-color="([^"]+)"/gi)){let l=Z(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>he(s,l,1/(c+1)),a[0]):null}function Uo(t,e,n,r){if(e.layer==="foreground")return;let o=pn(e);if(!o)return;let i=n+ji,a=Ie(qi(e.href),r.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=he(r.ground,a,s)),ae(t,o,void 0,()=>i,n,a,he(a,r.decorWall,.5),ie)}function Yo(t,e,n,r,o){if(!e.points||e.points.length<3)return;let i=Ie(r,o.gaTop);ae(t,e.points,e.holes,()=>n+.15,n,i,o.gaWall,ie)}var Ki=.25,Zi=1.2,Qi=.6,$i=.45,Ji=2.3,ea=Math.PI/180;function Xe(t,e,n){let r=n*ea;return{x:t.x+e*Math.sin(r),y:t.y+e*Math.cos(r)}}function ta(t,e){let n=e.rings[e.rings.length-1];if(!n)return!1;let r=n.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let i=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(i.length<2)continue;let a=0;for(let s of i)Math.hypot(s.x-e.centre.x,s.y-e.centre.y)>=r&&a++;if(a>=i.length/2)return!0}return!1}var na=24;function oa(t,e,n,r,o,i,a,s){let l=n.binCount,c=na,d=ke,u=i+.02,m=[];for(let S=0;S<l;S++){let M=(n.startBin+S+.5)*e.binStepDeg,A=new Float64Array(c+1);for(let R=0;R<=c;R++){let V=r[S]+(o[S]-r[S])*R/c;A[R]=Math.max(u,Xn(e,n,M,V)-Ki)}m.push(A)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],h=[a.bandTop[0]*s.bottomCap,a.bandTop[1]*s.bottomCap,a.bandTop[2]*s.bottomCap],f=[a.bandWall[0]*s.top,a.bandWall[1]*s.top,a.bandWall[2]*s.top],x=[a.bandWall[0]*s.wallBottom,a.bandWall[1]*s.wallBottom,a.bandWall[2]*s.wallBottom],b=(S,M)=>{let A=(n.startBin+S+.5)*e.binStepDeg,R=r[S]+(o[S]-r[S])*M/c,V=Xe(e.centre,R,A);return[V.x*d,m[S][M],V.y*d]};{let S=Math.tan(12*Math.PI/180);for(let M=0;M<6;M++){let A=!1;for(let V=0;V<l;V++)for(let E=c-1;E>=0;E--)m[V][E]>m[V][E+1]&&(m[V][E]=m[V][E+1],A=!0);let R=n.closed?l:l-1;for(let V=0;V<R;V++){let E=(V+1)%l;for(let C=0;C<=c;C++){let T=m[E][C]-m[V][C];if(Math.abs(T)>1)continue;let z=r[V]+(o[V]-r[V])*C/c,P=r[E]+(o[E]-r[E])*C/c,k=Xe(e.centre,z,(n.startBin+V+.5)*e.binStepDeg),O=Xe(e.centre,P,(n.startBin+E+.5)*e.binStepDeg),H=S*Math.hypot(O.x-k.x,O.y-k.y)*d;T>H?(m[E][C]=m[V][C]+H,A=!0):-T>H&&(m[V][C]=m[E][C]+H,A=!0)}}if(!A)break}}let y=1,g=(S,M)=>{for(let A=0;A<=c;A+=4)if(Math.abs(m[S][A]-m[M][A])>y)return!0;return Math.abs(m[S][c]-m[M][c])>y},F=Math.tan(38*Math.PI/180),w=S=>(o[S]-r[S])/c*d,v=(S,M)=>m[S][M+1]-m[S][M]>F*Math.max(1e-6,w(S)),D=(S,M)=>{let A=n.closed?(S-1+l)%l:Math.max(0,S-1),R=n.closed?(S+1)%l:Math.min(l-1,S+1);Math.abs(m[A][M]-m[S][M])>y&&(A=S),Math.abs(m[R][M]-m[S][M])>y&&(R=S);let V=Math.max(0,M-1),E=Math.min(c,M+1);V<M&&v(S,V)&&(V=M),E>M&&v(S,M)&&(E=M);let C=b(A,M),T=b(R,M),z=b(S,V),P=b(S,E),k=T[0]-C[0],O=T[1]-C[1],H=T[2]-C[2],X=P[0]-z[0],Y=P[1]-z[1],j=P[2]-z[2],K=O*j-H*Y,ne=H*X-k*j,oe=k*Y-O*X,Q=Math.hypot(K,ne,oe);return Q>1e-12?(K/=Q,ne/=Q,oe/=Q,ne<0&&(K=-K,ne=-ne,oe=-oe),[K,ne,oe]):[0,1,0]},L=(S,M)=>{let A=[S[0],i,S[2]],R=[M[0],i,M[2]],V=M[0]-S[0],E=M[2]-S[2],C=Math.hypot(V,E);if(!(C>1e-12))return;let T=[E/C,0,-V/C];t.tri(S,M,R,T,f,f,x),t.tri(S,R,A,T,f,x,x)},_=.05*Le,U=S=>o[S]-r[S]<_,B=n.closed?l:l-1;for(let S=0;S<B;S++){let M=(S+1)%l;if(U(S)||U(M))continue;if(g(S,M)){let T=(n.startBin+S+1)*e.binStepDeg,z=(Y,j)=>{let K=(r[S]+r[M])/2,ne=(o[S]+o[M])/2,oe=K+(ne-K)*j/c,Q=Xe(e.centre,oe,T);return[Q.x*d,m[Y][j],Q.y*d]};for(let Y=0;Y<c;Y++){let j=b(S,Y),K=b(S,Y+1),ne=z(S,Y),oe=z(S,Y+1),Q=D(S,Y),se=D(S,Y+1);t.triN(j,ne,oe,Q,Q,se,p),t.triN(j,oe,K,Q,se,se,p);let Be=b(M,Y),Ve=b(M,Y+1),Se=z(M,Y),we=z(M,Y+1),Pe=D(M,Y),ye=D(M,Y+1);t.triN(Se,Be,Ve,Pe,Pe,ye,p),t.triN(Se,Ve,we,Pe,ye,ye,p);let xe=z(S,Y),re=z(S,Y+1),qe=z(M,Y+1),Fe=z(M,Y),Ae=re[0]-xe[0],ze=re[2]-xe[2],nt=Math.hypot(Ae,ze);if(nt>1e-12){let me=[ze/nt,0,-Ae/nt];t.tri(xe,re,qe,me,f),t.tri(xe,qe,Fe,me,f)}}let P=b(S,0),k=b(M,0),O=b(M,c),H=b(S,c),X=Y=>[Y[0],i,Y[2]];t.tri(X(P),X(O),X(k),[0,-1,0],h),t.tri(X(P),X(H),X(O),[0,-1,0],h),L(P,k),L(H,O);continue}for(let T=0;T<c;T++){let z=D(S,T),P=D(M,T),k=D(M,T+1),O=D(S,T+1);if(v(S,T)||v(M,T)){let K=(re,qe)=>{let Fe=(n.startBin+re+.5)*e.binStepDeg,Ae=r[re]+(o[re]-r[re])*(T+.5)/c,ze=Xe(e.centre,Ae,Fe);return[ze.x*d,qe,ze.y*d]},ne=b(S,T),oe=b(M,T),Q=K(S,m[S][T]),se=K(M,m[M][T]);t.triN(ne,oe,se,z,P,P,p),t.triN(ne,se,Q,z,P,z,p);let Be=b(M,T+1),Ve=b(S,T+1),Se=K(S,m[S][T+1]),we=K(M,m[M][T+1]);t.triN(Se,we,Be,O,k,k,p),t.triN(Se,Be,Ve,O,k,O,p);let Pe=se[0]-Q[0],ye=se[2]-Q[2],xe=Math.hypot(Pe,ye);if(xe>1e-12){let re=[-ye/xe,0,Pe/xe];t.tri(Q,se,we,re,f),t.tri(Q,we,Se,re,f)}continue}let H=b(S,T),X=b(M,T),Y=b(M,T+1),j=b(S,T+1);t.triN(H,X,Y,z,P,k,p),t.triN(H,Y,j,z,k,O,p)}let A=b(S,0),R=b(M,0),V=b(M,c),E=b(S,c),C=T=>[T[0],i,T[2]];t.tri(C(A),C(V),C(R),[0,-1,0],h),t.tri(C(A),C(E),C(V),[0,-1,0],h),L(A,R),L(E,V)}if(!n.closed)for(let S of[0,l-1])for(let M=0;M<c;M++)L(b(S,M),b(S,M+1))}function Xo(t,e,n){let{bottomY:r,colors:o,ao:i}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let d of e.rings)for(let u of d.arcs){let m=new Float64Array(u.binCount),p=new Float64Array(u.binCount);for(let f=0;f<u.binCount;f++){let x=(u.startBin+f)%e.binCount,b=Math.max(0,u.innerR[f]-fe);m[f]=Math.max(b,a[x]+.001),p[f]=Math.max(m[f]+.001,u.outerR[f]+fe)}let h=0;for(let f=0;f<u.binCount;f++){let x=u.topLevelM[f]-r;x>h&&(h=x)}h>=Zi&&oa(t,e,u,m,p,r,o,i);for(let f=0;f<u.binCount;f++){let x=(u.startBin+f)%e.binCount;p[f]>a[x]&&(a[x]=p[f])}}if(ta(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Qi*Le,c=$i*Le;for(let d of s.arcs){let u=[],m=[];for(let f=0;f<d.binCount;f++){let x=(d.startBin+f+.5)*e.binStepDeg,b=d.outerR[f]+fe+l;u.push(Xe(e.centre,b,x)),m.push(Xe(e.centre,b+c,x))}let p=-1/0;for(let f=0;f<d.binCount;f++)d.topLevelM[f]>p&&(p=d.topLevelM[f]);let h=()=>p+Ji;d.closed?ae(t,m,[u.slice().reverse()],h,r,o.shellTop,o.shellWall,i):ae(t,[...m,...u.slice().reverse()],void 0,h,r,o.shellTop,o.shellWall,i)}}function Wo(t,e,n,r,o,i,a,s){if(!e.outline||e.outline.length<3)return;let l=n.baseHeightM,c=Ie(r,s.tierTop);if(!o)return;let d=x=>o.deckAt(x.x,x.y),u=Eo(e,a),m=u[0]??e.outline;if(o.rowLevels.length>=2){let x=_t(o.rowLevels),b=Do(Ao(o.rowLevels,n.focal,x),u),y=()=>[0,1,0];for(let F of b){let w=Math.max(l,F.topY-.02);for(let v of i.subtract(F.outline,w))ae(t,v,F.holes,()=>w,l,c,s.tierWall,ie,void 0,y)}b.length||ae(t,m,e.holes,()=>o.landingY,l,c,s.tierWall,ie);let g={tread:[c[0]*ie.top,c[1]*ie.top,c[2]*ie.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let F of u.length?u:[m])Ro(t,o.rowLevels,n.focal,o.landingY,g,F,x);return}let p=o.flat?1/0:ko,h=x=>o.normalAt(x.x,x.y),f=o.flat?o.landingY:void 0;for(let x of i.subtract(m,f))ae(t,x,e.holes,d,l,c,s.tierWall,ie,p,h)}function ra(t,e,n){let r=new Set;for(let a of t.objects)a.type==="section"&&r.add(a.id);let o=new Map;for(let a=0;a<e.length;a++){let s=n.seatOwner[a];if(!s||!r.has(s))continue;let l=n.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=e[a],d=o.get(s);d||(d=new Map,o.set(s,d));let u=c.rowId||`__seat-${a}`,m=d.get(u);m||(m={pts:[],levelM:0,n:0},d.set(u,m)),m.pts.push({x:c.x,y:c.y}),m.levelM+=n.seatDeckY(a),m.n++}let i=[];for(let a of t.objects){if(a.type!=="section")continue;let s=n.bySection.get(a.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(d=>!d.patch).map(d=>({pts:d.pts,levelM:d.y}));c.length>=2&&i.push({sectionId:a.id,rows:c});continue}let l=o.get(a.id);l&&i.push({sectionId:a.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return i}function jo(t,e,n,r,o){let i=ra(e,n,r);if(!i.length)return;let a=Yn(i,e.focal);a&&(t.setMaterial(0),Xo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:pe(o.tierTop,.8),bandWall:o.tierWall,shellTop:pe(o.tierWall,1.15),shellWall:o.tierWall},ao:ie,shapes:e.objects.filter(s=>s.type==="shape")}))}function qo(t,e,n){return n<0?e>1?t.filter(r=>r.kind==="floor"):[...t]:t.filter(r=>r.floorIndex===void 0||r.floorIndex===n)}function Ko(t,e){let n=[...t].sort((o,i)=>o.screen.y-i.screen.y),r=[];for(let o of n){let i=r.find(a=>a.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));i?i.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((i,a)=>({...i,screen:{...i.screen,x:Math.max(54,Math.min(e-54,i.screen.x+(a-(o.length-1)/2)*104))}})))}var ia=1.15,aa=3.25,sa=4.5,ca=.85,la=.5,ua=.26;function Zo(t,e,n){let r=Math.max(1e-6,e),o=t/r,i=n?.hasZoneLabels??!0,a=new Set;return o>=.75&&a.add("floor"),o>=ia&&a.add("zone"),o<=(i?aa:sa)&&(a.add("section"),a.add("ga")),o<=ca&&(a.add("annotation"),a.add("booth")),o<=la&&a.add("row"),o<=ua&&a.add("seat"),a}function Oe(t,e,n,r){let o=t,i=e[0],a=e[1],s=e[2],l=o[0]*i+o[4]*a+o[8]*s+o[12],c=o[1]*i+o[5]*a+o[9]*s+o[13],d=o[2]*i+o[6]*a+o[10]*s+o[14],u=o[3]*i+o[7]*a+o[11]*s+o[15];if(!(u>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=l/u,p=c/u,h=d/u,f=m>=-1.05&&m<=1.05&&p>=-1.05&&p<=1.05&&h<=1;return{x:(m*.5+.5)*n,y:(1-(p*.5+.5))*r,depth:h,visible:f}}function Qo(t,e,n=e){let r=[],o=[...t].sort((i,a)=>i.screen.depth-a.screen.depth);for(let i of o){let a=!1;for(let s of r)if(fn(i,s,e,n)){a=!0;break}a||r.push(i)}return r}var ma=6;function fn(t,e,n,r){let o=Math.abs(t.screen.x-e.screen.x),i=Math.abs(t.screen.y-e.screen.y),a=t.halfWidth!=null&&e.halfWidth!=null?Math.max(n,t.halfWidth+e.halfWidth+ma):n;return o<a&&i<r}function $o(t,e,n){return t.length*e*.58+(n?14:0)}var bn={row:8,seat:14};function Jo(t,e,n,r){let o=Math.max(1,Math.min(n,r)*.5),i=Math.min(2,Math.hypot(t.x-n/2,t.y-r/2)/o);return e*(1+1.5*i)}function yn(t,e,n,r,o=[]){let i=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),a=[];for(let s of i){if(a.length>=r)break;let l=!1;for(let c of o)if(fn(s,c,e,n)){l=!0;break}if(!l){for(let c of a)if(fn(s,c,e,n)){l=!0;break}}l||a.push(s)}return a}var da=6,ha=2.2,er=.1,pa=.3,fa=1.8,ba=.9,ya=.55,xa=6e3;function tr(t){let{doc:e,units:n,seats:r,surfaces:o,focal:i}=t,a=e.zones??[],s=[];if(a.length){let l=new Map;for(let d of n)for(let u of d.objects)u.type==="section"&&u.zone&&l.set(u.id,u.zone);let c=new Map;for(let d=0;d<r.length;d++){let u=r[d],m=o.seatOwner[d],p=u.zoneId??(m?l.get(m):void 0);if(!p)continue;let h=c.get(p);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,h)),h.n++,u.x<h.minX&&(h.minX=u.x),u.y<h.minY&&(h.minY=u.y),u.x>h.maxX&&(h.maxX=u.x),u.y>h.maxY&&(h.maxY=u.y),h.sumY+=o.seatDeckY(d)}for(let d of a){let u=c.get(d.id),m=[];for(let[p,h]of l)h===d.id&&m.push(p);if(!u||u.n===0){s.push({id:d.id,label:d.label,color:Z(d.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(d.focalPoint??i).x*I,1.5,(d.focalPoint??i).y*I]});continue}s.push({id:d.id,label:d.label,color:Z(d.color),sectionIds:m,seatCount:u.n,center:[(u.minX+u.maxX)/2*I,u.sumY/u.n,(u.minY+u.maxY)/2*I],radius:.5*Math.hypot((u.maxX-u.minX)*I,(u.maxY-u.minY)*I)||1,focalWorld:[(d.focalPoint??i).x*I,1.5,(d.focalPoint??i).y*I]})}}return s}function nr(t){let{doc:e,units:n,seats:r,surfaces:o,seatData:i,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],d=[],u=[];for(let m of s)m.seatCount!==0&&c.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+da,m.center[2]],color:e.zones?.find(p=>p.id===m.id)?.color});{let m=new Map,p=new Map;for(let h=0;h<r.length;h++){let f=o.seatOwner[h];if(!f)continue;let x=m.get(f);x||(x={n:0,x:0,y:0,deck:0},m.set(f,x)),x.n++,x.x+=r[h].x,x.y+=r[h].y,x.deck+=o.seatDeckY(h);let b=p.get(f);b||(b={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(f,b)),r[h].x<b.minX&&(b.minX=r[h].x),r[h].x>b.maxX&&(b.maxX=r[h].x),r[h].y<b.minY&&(b.minY=r[h].y),r[h].y>b.maxY&&(b.maxY=r[h].y)}for(let h of n)for(let f of h.objects){if(f.type!=="section")continue;let x=m.get(f.id);if(!x||x.n===0)continue;let b=p.get(f.id),y=[x.x/x.n*I,x.deck/x.n,x.y/x.n*I],g=f.displayLabel||f.label||f.id;d.push({id:f.id,floorIndex:h.index,label:g,seatCount:x.n,center:y,radius:Math.max(1,Math.hypot(b.maxX-b.minX,b.maxY-b.minY)*.5*I),focalWorld:[h.focal.x*I,h.baseHeightM+1.5,h.focal.y*I]});let F=e.floors?.[h.index]?.name?.trim().toLocaleLowerCase();n.length>1&&F===g.trim().toLocaleLowerCase()||c.push({id:`section:${f.id}`,kind:"section",text:g,anchor:[y[0],y[1]+ha,y[2]],floorIndex:h.index})}}{for(let h of n)for(let f of h.objects){if(f.type!=="gaArea")continue;let x=it(f.points);if(!x)continue;let b=f.displayLabel||f.label||f.id;c.push({id:`ga:${f.id}`,kind:"ga",text:f.capacity>0?`${b} \xB7 ${f.capacity.toLocaleString()}`:b,anchor:[x.x*I,h.baseHeightM+fa,x.y*I],floorIndex:h.index})}let m=new Map;for(let h=0;h<r.length;h++){let f=r[h],x=Math.hypot(f.x-l.x,f.y-l.y),b=m.get(f.rowId);(!b||x>b.far)&&m.set(f.rowId,{seat:f,index:h,far:x})}for(let[h,f]of m){let x=f.seat.label?f.seat.label.lastIndexOf("-"):-1,b=x>0?f.seat.label.slice(0,x):h;b&&c.push({id:`row:${h}`,kind:"row",text:b,anchor:[f.seat.x*I,o.seatDeckY(f.index)+ba,f.seat.y*I],floorIndex:a[f.index]})}let p=new Map;for(let h=0;h<r.length;h++){let f=r[h],x=f.label?f.label.lastIndexOf("-"):-1,b=p.get(f.rowId);b||(b={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:x>0?f.label.slice(0,x):f.rowId,sectionId:f.sectionId},p.set(f.rowId,b));let y=h*3,g=i.iPosition[y],F=i.iPosition[y+1],w=i.iPosition[y+2];b.n++,b.x+=g,b.y+=F,b.z+=w,b.minX=Math.min(b.minX,g),b.maxX=Math.max(b.maxX,g),b.minZ=Math.min(b.minZ,w),b.maxZ=Math.max(b.maxZ,w)}for(let[h,f]of p)u.push({id:h,label:f.label,sectionId:f.sectionId,seatCount:f.n,center:[f.x/f.n,f.y/f.n,f.z/f.n],radius:Math.max(.8,Math.hypot(f.maxX-f.minX,f.maxZ-f.minZ)*.5)});if(r.length<=xa)for(let h=0;h<r.length;h++){let f=r[h],x=f.displayLabel||f.label;x&&c.push({id:`seat:${f.id}`,kind:"seat",text:x,anchor:[f.x*I,o.seatDeckY(h)+ya,f.y*I],floorIndex:a[h]})}}for(let m of n)for(let p of m.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let h=ht(p),f=h?it(h):null;if(!f||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[f.x*I,m.baseHeightM+pt(p).heightM+er,f.y*I],color:p.fill,floorIndex:m.index})}else if(p.type==="text"){if(!p.text)continue;c.push({id:`text:${p.id}`,kind:"annotation",text:p.text,anchor:[p.position.x*I,m.baseHeightM+er,p.position.y*I],color:p.color,rotation:p.rotation,floorIndex:m.index})}else if(p.type==="booth"){let h=bt(p);if(!h)continue;let f=it(h);if(!f)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[f.x*I,m.baseHeightM+dn+pa,f.y*I],floorIndex:m.index})}return{labels:c,sections:d,rows:u}}function or(t,e){if(e.length>1)for(let n of e)t.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function rr(t){let{doc:e,units:n,seats:r,surfaces:o,solids:i,hintedSeatFloor:a,seatFloor:s}=t,l=[];{let c=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<i.floor.length;m+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(i.floor[m]))),h=m*3,f=c[p];f.minX=Math.min(f.minX,i.position[h]),f.minY=Math.min(f.minY,i.position[h+1]),f.minZ=Math.min(f.minZ,i.position[h+2]),f.maxX=Math.max(f.maxX,i.position[h]),f.maxY=Math.max(f.maxY,i.position[h+1]),f.maxZ=Math.max(f.maxZ,i.position[h+2])}let d=new Map;for(let m=0;m<n.length;m++)for(let p of n[m].objects)p.type==="section"&&d.set(p.id,m);let u=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let m=0;m<r.length;m++){let p=o.seatOwner[m],h=(p!==null?d.get(p):void 0)??a[m];if(h===void 0)continue;let f=u[h],x=r[m];f.n++,x.x<f.minX&&(f.minX=x.x),x.y<f.minY&&(f.minY=x.y),x.x>f.maxX&&(f.maxX=x.x),x.y>f.maxY&&(f.maxY=x.y);let b=o.seatDeckY(m);f.sumX+=x.x*I,f.sumDeck+=b,f.sumZ+=x.y*I,f.minDeck=Math.min(f.minDeck,b),f.maxDeck=Math.max(f.maxDeck,b+1.6),s[m]=h}for(let m=0;m<n.length;m++){let p=u[m],h=e.floors?.[m],f=c[m],x=Math.min(p.n?p.minX*I:n[m].focal.x*I-1,Number.isFinite(f.minX)?f.minX:1/0),b=Math.max(p.n?p.maxX*I:n[m].focal.x*I+1,Number.isFinite(f.maxX)?f.maxX:-1/0),y=Math.min(p.n?p.minY*I:n[m].focal.y*I-1,Number.isFinite(f.minZ)?f.minZ:1/0),g=Math.max(p.n?p.maxY*I:n[m].focal.y*I+1,Number.isFinite(f.maxZ)?f.maxZ:-1/0),F=Math.min(p.n?Math.min(n[m].baseHeightM,p.minDeck):n[m].baseHeightM,Number.isFinite(f.minY)?f.minY:1/0),w=Math.max(p.n?Math.max(p.maxDeck,F+.5):F+.5,Number.isFinite(f.maxY)?f.maxY:-1/0),v=[p.n?p.sumX/p.n:(x+b)/2,p.n?p.sumDeck/p.n:(F+w)/2,p.n?p.sumZ/p.n:(y+g)/2],D=Math.max(1,.5*Math.hypot(b-x,w-F,g-y));l.push({index:m,id:h?.id??`floor-${m}`,label:h?.name??(n.length>1?`Floor ${m+1}`:"Venue"),seatCount:p.n,center:v,radius:D,box:{min:[x,F,y],max:[b,w,g]},focalWorld:[n[m].focal.x*I,n[m].baseHeightM+1.5,n[m].focal.y*I]})}}return l}function xn(t,e){let n=1/0,r=1/0,o=-1/0,i=-1/0,a=(s,l)=>{s<n&&(n=s),l<r&&(r=l),s>o&&(o=s),l>i&&(i=l)};for(let s of e)a(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let c of l.outline)a(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)a(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)a(c.x,c.y);else if(l.type==="booth"){let c=bt(l);if(c)for(let d of c)a(d.x,d.y)}else if(l.type==="table"){let c=hn(l);if(c)for(let d of c)a(d.x,d.y)}else if(l.type==="decorImage"){let c=pn(l);if(c)for(let d of c)a(d.x,d.y)}return Number.isFinite(n)||(n=-100,r=-100,o=100,i=100),{minX:n,minY:r,maxX:o,maxY:i}}function ir(t,e,n,r,o,i){if(e.length===1){let a=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=dt(o.minX-a,o.minY-a,o.maxX-o.minX+a*2,o.maxY-o.minY+a*2);ae(t,s,void 0,()=>0,-.4,i.ground,i.ground,ie)}else{let a=e.reduce((p,h)=>h.baseHeightM<p.baseHeightM?h:p);t.setFloor(a.index);let s=n.filter((p,h)=>r[h]===a.index),l=xn([a],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),d=Math.max(28,Math.min(80,c*.04)),u=dt(l.minX-d,l.minY-d,l.maxX-l.minX+d*2,l.maxY-l.minY+d*2),m=a.baseHeightM-.03;ae(t,u,void 0,()=>m,m-.22,i.ground,i.ground,ie)}}function ar(t,e,n){let{cx:r,cz:o,radius:i}=n,a=1/0,s=1/0,l=1/0,c=-1/0,d=-1/0,u=-1/0,m=(f,x,b)=>{a=Math.min(a,f),c=Math.max(c,f),s=Math.min(s,x),d=Math.max(d,x),l=Math.min(l,b),u=Math.max(u,b)};for(let f=0;f<t.position.length;f+=3)m(t.position[f],t.position[f+1],t.position[f+2]);for(let f=0;f<e.count;f++){let x=f*3,b=e.iPosition[x],y=e.iPosition[x+1],g=e.iPosition[x+2],F=Math.max(.35,e.iMaxRadius[f]??.35);m(b-F,y,g-F),m(b+F,y+1.6,g+F)}Number.isFinite(a)||(a=r-i,c=r+i,s=0,d=i*.16,l=o-i,u=o+i);let p=[(a+c)/2,(s+d)/2,(l+u)/2],h=Math.max(1,.5*Math.hypot(c-a,d-s,u-l));return{center:p,radius:h,minY:s,maxY:d}}function sr(t,e,n,r,o,i){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let F=0;F<t.count;F++){let w=F*3,v=t.iPosition[w],D=t.iPosition[w+2];v<a&&(a=v),v>l&&(l=v),D<s&&(s=D),D>c&&(c=D)}for(let F of e)a=Math.min(a,F.cx-F.halfX),l=Math.max(l,F.cx+F.halfX),s=Math.min(s,F.cz-F.halfZ),c=Math.max(c,F.cz+F.halfZ);let d=n.minX*I,u=n.maxX*I,m=n.minY*I,p=n.maxY*I,h=d,f=u,x=m,b=p;if(Number.isFinite(a)){let F=Math.max(2,.06*Math.hypot(l-a,c-s));h=Math.max(d,a-F),f=Math.min(u,l+F),x=Math.max(m,s-F),b=Math.min(p,c+F)}let y=Math.min(0,r),g=Math.max(o,i*.05);return{min:[h,y,x],max:[f,g,b]}}function yt(t){let{doc:e}=t,n=fo(e.theme),r=n.structure,o=Fo(e,t.eventConfigurationId??e.eventConfigurationId),i=t.seats,a=new Et,s=new Map;for(let M of o)for(let A of M.objects)s.set(A.id,M.index),A.type==="section"&&s.set(A.logicalSectionId??A.id,M.index);let l=i.map(M=>s.get(M.sectionId??"")??s.get(M.rowId??"")??0),c=xn(o,i);ir(a,o,i,l,c,r);let d=_o(e,i),u=new Map,m=new Map;for(let M of e.categories??[])u.set(M.key,M.color),M.seatGlyph&&m.set(M.key,M.seatGlyph);let p=[],h=Lo(o,i,l),f=new Float32Array(i.length);for(let M=0;M<o.length;M++){let A=o[M];a.setFloor(M);let R=new Ot,V=[],E=A.objects.filter(C=>C.type==="section"&&!!C.outline&&C.outline.length>=3);for(let C of A.objects)C.type==="section"?Wo(a,C,A,Oo(C,d),h.bySection.get(C.id),R,E,r):C.type==="shape"?(a.setMaterial(C.role==="screen"?1:0),Ho(a,C,A.baseHeightM,Bo(C,V),r,A.focal,p),a.setMaterial(0)):C.type==="gaArea"?Yo(a,C,A.baseHeightM,Z(u.get(C.categoryKey)),r):C.type==="booth"?No(a,C,A.baseHeightM,Z(u.get(C.categoryKey)),r):C.type==="table"?Go(a,C,A.baseHeightM,Z(u.get(C.categoryKey)),r):C.type==="decorImage"&&Uo(a,C,A.baseHeightM,r);jo(a,A,i,h,r)}let x=o.length>1?{x:o.reduce((M,A)=>M+A.focal.x,0)/o.length,y:o.reduce((M,A)=>M+A.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},b=co([a.build()]),y=po(i,t.initialState,h,f,u,m),g=tr({doc:e,units:o,seats:i,surfaces:h,focal:x}),{labels:F,sections:w,rows:v}=nr({doc:e,units:o,seats:i,surfaces:h,seatData:y,hintedSeatFloor:l,zones:g,focal:x}),D=rr({doc:e,units:o,seats:i,surfaces:h,solids:b,hintedSeatFloor:l,seatFloor:f});or(F,D),y.iYaw=mo(y.iPosition,i.length,M=>i[M].rowId,M=>{let A=o[f[M]]?.focal??x;return[A.x*I,A.y*I]});let L=(c.minX+c.maxX)/2*I,_=(c.minY+c.maxY)/2*I,U=.5*Math.hypot((c.maxX-c.minX)*I,(c.maxY-c.minY)*I)||10,B=ar(b,y,{cx:L,cz:_,radius:U}),S=sr(y,p,c,B.minY,B.maxY,U);return{solids:b,seats:y,bounds:{center:[(S.min[0]+S.max[0])/2,(S.min[1]+S.max[1])/2,(S.min[2]+S.max[2])/2],radius:U,groundY:0,box:S},renderBounds:{center:B.center,radius:B.radius},stateColorLUT:bo(n,be),theme:n,seatCount:i.length,focalWorld:[x.x*I,1.5,x.y*I],zones:g,stages:p,sections:w,rows:v,labels:F,floors:D}}var ga=88,va=20,cr={floor:{size:14,weight:"700",opacity:.98},zone:{size:15,weight:"600",opacity:.95},section:{size:12,weight:"500",opacity:.88},ga:{size:12,weight:"500",opacity:.88},booth:{size:11,weight:"500",opacity:.85},annotation:{size:11,weight:"400",opacity:.75},row:{size:10.5,weight:"600",opacity:.8},seat:{size:9.5,weight:"500",opacity:.72}},Bt=new Set(["row","seat"]),lr={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},Vt={row:{x:62,y:16},seat:{x:46,y:18}},mr=Z,gn=t=>_n(t);function dr(t,e){let n=gn(t),r=gn(e);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function ur(t,e){let n=/rgba\((\d+),(\d+),(\d+),([\d.]+)\)/.exec(t.replace(/\s/g,""));if(!n)return e;let r=Math.max(0,Math.min(1,Number(n[4])));return[1,2,3].map(o=>Number(n[o])/255*r+e[o-1]*(1-r))}function Ma(t,e=[.04,.06,.1]){let n=gn(e)<.42,r=n?"#f4f7fb":"#0b1220",o=mr(t),i=o&&dr(o,e)>=4.5?t:r;return n?{ink:i,backing:"rgba(8,12,22,.78)",border:"rgba(210,222,245,.24)"}:{ink:i,backing:"rgba(255,255,255,.84)",border:"rgba(11,18,32,.22)"}}var zt=class{constructor(e,n={}){this.nodes=new Map;this.labels=[];this.forcedDense=!1;this.selectedSeatLabelIds=new Set;this.opts=n,this.root=document.createElement("div"),this.root.setAttribute("data-view3d-labels","");let r=this.root.style;r.position="absolute",r.inset="0",r.pointerEvents="none",r.overflow="hidden",n.fontFamily&&(r.fontFamily=n.fontFamily),e.appendChild(this.root)}setVisible(e){this.root.style.visibility=e?"":"hidden"}setLabels(e){this.labels=e;for(let[n,r]of this.nodes)e.some(o=>o.id===n)||(r.remove(),this.nodes.delete(n))}setForcedDense(e){this.forcedDense=e}setSelectedSeatIds(e){this.selectedSeatLabelIds=new Set(Array.from(e,n=>`seat:${n}`))}qualityEvidence(){let e=this.root.getBoundingClientRect(),n=this.root.style.visibility!=="hidden";return this.labels.map(r=>{let o=this.nodes.get(r.id),i=o?.getBoundingClientRect(),a=!!(n&&o&&o.style.display!=="none"&&i&&i.width>0&&i.height>0);return{id:r.id,kind:r.kind,text:r.text,visible:a,renderedFontPx:o&&Number.parseFloat(o.style.fontSize)||0,contrast:o?Number(o.dataset.qualityContrast??0):0,...a&&i?{screenBox:{x:i.x-e.x,y:i.y-e.y,width:i.width,height:i.height}}:{}}})}update(e,n,r,o,i,a){if(!this.labels.length)return;let s=Zo(o,i,{hasZoneLabels:this.labels.some(y=>y.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let y of this.labels){if(!s.has(y.kind))continue;let g=Oe(e,y.anchor,n,r);if(!g.visible)continue;let F=a?Math.hypot(y.anchor[0]-a[0],y.anchor[1]-a[1],y.anchor[2]-a[2]):1;l.push({label:y,screen:g,focus:Jo(g,F,n,r),halfWidth:$o(y.text,cr[y.kind].size,!Bt.has(y.kind))/2,...this.selectedSeatLabelIds.has(y.id)?{priority:1}:{}})}let c=Ko(l.filter(y=>y.label.kind==="floor"),n),d=[...l.filter(y=>!Bt.has(y.label.kind)&&y.label.kind!=="floor"),...c],u=Qo(d,ga,va),m=yn(l.filter(y=>y.label.kind==="row"),Vt.row.x,Vt.row.y,bn.row,u),p=yn(l.filter(y=>y.label.kind==="seat"),Vt.seat.x,Vt.seat.y,bn.seat,[...u,...m]),h=[...u,...m,...p],f=new Set(h.map(y=>y.label.id));for(let{label:y,screen:g}of h){let w=this.nodeFor(y).style;w.display="",w.transform=`translate(-50%, -50%) translate(${g.x.toFixed(1)}px, ${g.y.toFixed(1)}px)`}let x=h.filter(({label:y})=>!Bt.has(y.kind)).sort((y,g)=>lr[g.label.kind]-lr[y.label.kind]||y.screen.depth-g.screen.depth||y.focus-g.focus),b=[];for(let{label:y}of x){let g=this.nodes.get(y.id);if(!g||g.style.display==="none")continue;let F=g.getBoundingClientRect();b.some(v=>F.left<v.right+3&&F.right+3>v.left&&F.top<v.bottom+3&&F.bottom+3>v.top)?g.style.display="none":b.push(F)}for(let[y,g]of this.nodes)f.has(y)||(g.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let u=n.style;u.position="absolute",u.left="0",u.top="0",u.whiteSpace="nowrap",u.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",u.display="none",this.root.appendChild(n),this.nodes.set(e.id,n)}n.textContent=e.text,n.setAttribute("data-label-kind",e.kind);let r=this.selectedSeatLabelIds.has(e.id);n.toggleAttribute("data-selected-seat",r);let o=cr[e.kind],i=n.style;i.fontSize=`${o.size}px`,i.fontWeight=r?"800":o.weight,i.opacity=r?"1":String(o.opacity);let a=Ma(e.color??this.opts.ink,this.opts.backgroundRgb),s=!Bt.has(e.kind);i.color=r?"#ecf8ff":a.ink,i.background=r?"rgba(10,28,45,.9)":s?a.backing:"",i.border=r?"1px solid rgba(89,199,255,.92)":s?`1px solid ${a.border}`:"",i.borderRadius=r||s?"999px":"",i.padding=r||s?"3px 7px":"",i.boxShadow=r?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":s?"0 3px 10px rgba(0,0,0,.24)":"",i.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let l=this.opts.backgroundRgb??[.04,.06,.1],c=mr(r?"#ecf8ff":a.ink)??[1,1,1],d=r?ur("rgba(10,28,45,.9)",l):s?ur(a.backing,l):l;return n.dataset.qualityContrast=dr(c,d).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(i.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var Sa=1;var wa=new Set(["floor","zone","section","ga","booth","annotation"]);function Pa(t){return t.every(e=>Number.isFinite(e))}function Aa(t,e){return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y}function hr(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function We(t){return Math.round(t*1e4)/1e4}function Ca(t){if(t)return{box:{x:We(t.box.x),y:We(t.box.y),width:We(t.box.width),height:We(t.box.height)},horizontalFillRatio:We(t.horizontalFillRatio),verticalFillRatio:We(t.verticalFillRatio),visibleAreaRatio:We(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Me(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function vn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>wa.has(s.kind)),r=t.scene.floorCount>1?t.scene.floorCount:t.scene.zoneCount||t.scene.sectionCount,o=[];for(let s=0;s<n.length;s+=1)for(let l=0;l<s;l+=1)Aa(n[s].screenBox,n[l].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[l].id});let i=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Me("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Me("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Me("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Me("viewport-empty","The 3D viewport must have visible dimensions",t.viewport.width>1&&t.viewport.height>1?[]:[{primaryId:"viewport",primaryLabel:`${t.viewport.width}\xD7${t.viewport.height}`}]),Me("camera-invalid","The capture camera must have a finite physical pose",Pa(i)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Me("authored-relief-not-visible","Authored 3D height or rake must produce visible screen-space relief",!t.scene.authoredRelief||t.scene.renderedVerticalSpanM>.05&&t.scene.projectedReliefPx>=2?[]:[{primaryId:"scene",primaryLabel:"authored relief",measured:t.scene.projectedReliefPx,minimum:2}]),Me("hierarchy-label-missing","A venue with authored hierarchy must show at least one structural label",r===0||n.length>0?[]:[{primaryId:"labels",primaryLabel:`${r} expected hierarchy labels`}]),Me("hierarchy-label-undersized","Visible 3D hierarchy labels must remain readable",n.filter(s=>s.renderedFontPx<11).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.renderedFontPx,minimum:11}))),Me("hierarchy-label-contrast-low","Visible 3D hierarchy labels must meet text contrast",n.filter(s=>s.contrast<4.5).map(s=>({primaryId:s.id,primaryLabel:s.text,measured:s.contrast,minimum:4.5}))),Me("hierarchy-label-collision","Visible 3D hierarchy labels must not overlap",o)].filter(s=>!!s);return{version:1,state:"venue3d",passed:a.length===0,resolvedRules:["rendered-3d-webgl-context","rendered-3d-stable-frame","rendered-3d-camera-pose","rendered-3d-relief-projection","rendered-3d-label-size","rendered-3d-label-contrast","rendered-3d-label-collision"],viewport:t.viewport,context:t.context,frame:t.frame,camera:t.camera,scene:t.scene,composition:{visibleLabels:e.map(({id:s,kind:l,text:c})=>({id:s,kind:l,text:c})).sort((s,l)=>s.kind.localeCompare(l.kind)||s.id.localeCompare(l.id)),framing:Ca(t.framing)},metrics:{minimumHierarchyFontPx:hr(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:hr(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Gt,Mesh as Ht,Transform as wr}from"ogl";import{Program as je}from"ogl";var Nt=`
2
2
  float chairWeight(float depth) {
3
3
  return 1.0 - smoothstep(uChairFull, uChairNone, depth);
4
- }`,lr=`
4
+ }`,pr=`
5
5
  float occupantWeight(float depth) {
6
- float nearWeight = smoothstep(${Zn.toFixed(1)}, ${Qn.toFixed(1)}, depth);
7
- float farWeight = 1.0 - smoothstep(${qn.toFixed(1)}, ${Kn.toFixed(1)}, depth);
6
+ float nearWeight = smoothstep(${no.toFixed(1)}, ${oo.toFixed(1)}, depth);
7
+ float farWeight = 1.0 - smoothstep(${eo.toFixed(1)}, ${to.toFixed(1)}, depth);
8
8
  return nearWeight * farWeight;
9
- }`,Ma=`#version 300 es
9
+ }`,fr=`
10
+ float glyphEq(float glyph, float expected) {
11
+ return 1.0 - step(0.25, abs(glyph - expected));
12
+ }
13
+
14
+ float glyphBackRake(float glyph) {
15
+ if (glyphEq(glyph, 5.0) > 0.5) return 1.55;
16
+ if (glyphEq(glyph, 3.0) > 0.5) return 0.55;
17
+ if (glyphEq(glyph, 2.0) > 0.5) return 0.72;
18
+ return 1.0;
19
+ }
20
+
21
+ vec3 glyphChairPosition(vec3 p, float partId, float glyph) {
22
+ float generic = max(glyphEq(glyph, 0.0), glyphEq(glyph, 1.0));
23
+ float dining = glyphEq(glyph, 2.0);
24
+ float folding = glyphEq(glyph, 3.0);
25
+ float armchair = glyphEq(glyph, 4.0);
26
+ float recliner = glyphEq(glyph, 5.0);
27
+ float stool = glyphEq(glyph, 6.0);
28
+ float bench = glyphEq(glyph, 7.0);
29
+
30
+ if (partId < 0.5) {
31
+ if (max(max(generic, armchair), max(recliner, stool)) < 0.5) return vec3(0.0);
32
+ if (stool > 0.5) p.y *= 1.46;
33
+ } else if (partId < 1.5) {
34
+ if (dining > 0.5) { p.x *= 0.86; p.z *= 0.78; }
35
+ else if (folding > 0.5) { p.x *= 0.92; p.z *= 0.72; p.y = 0.405 + (p.y - 0.405) * 0.55; }
36
+ else if (armchair > 0.5) { p.z *= 1.08; }
37
+ else if (recliner > 0.5) { p.z *= 1.15; }
38
+ else if (stool > 0.5) { p.xz *= 0.76; p.y += 0.16; }
39
+ else if (bench > 0.5) { p.x *= 1.10; p.z *= 0.82; }
40
+ } else if (partId < 2.5) {
41
+ if (stool > 0.5) return vec3(0.0);
42
+ if (dining > 0.5) { p.x *= 0.78; p.y = 0.45 + (p.y - 0.45) * 0.82; }
43
+ else if (folding > 0.5) { p.x *= 0.90; p.y = 0.45 + (p.y - 0.45) * 0.72; }
44
+ else if (bench > 0.5) { p.x *= 1.10; p.y = 0.45 + (p.y - 0.45) * 0.62; }
45
+ } else if (partId < 3.5) {
46
+ if (max(armchair, recliner) < 0.5) return vec3(0.0);
47
+ if (recliner > 0.5) p.z *= 1.12;
48
+ } else if (partId < 4.5) {
49
+ if (recliner < 0.5) return vec3(0.0);
50
+ } else if (partId < 5.5) {
51
+ if (max(max(dining, folding), bench) < 0.5) return vec3(0.0);
52
+ if (folding > 0.5) p.x *= 0.88;
53
+ if (bench > 0.5) p.x *= 1.10;
54
+ } else if (partId > 9.5 && stool > 0.5) {
55
+ p.y += 0.16;
56
+ }
57
+ return p;
58
+ }`,Ra=`#version 300 es
10
59
  precision highp float;
11
60
  in vec3 position;
12
61
  in vec3 normal;
@@ -42,7 +91,7 @@ void main() {
42
91
  vNormalWorld = normalize(mat3(modelMatrix) * normal);
43
92
  vColor = color;
44
93
  gl_Position = projectionMatrix * mv;
45
- }`,Sa=`#version 300 es
94
+ }`,Ia=`#version 300 es
46
95
  precision highp float;
47
96
  in vec3 vColor;
48
97
  in vec3 vNormalWorld;
@@ -109,7 +158,7 @@ void main() {
109
158
  + vec3(0.20, 0.10, 0.34) * focalHalo;
110
159
  base = mix(base, display, poweredDisplay * verticalFace * 0.92);
111
160
  fragColor = vec4(base, 1.0);
112
- }`,wa=`#version 300 es
161
+ }`,Ta=`#version 300 es
113
162
  precision highp float;
114
163
  in vec2 position; // quad corner in [-1,1]
115
164
  in vec3 iOffset; // per-instance world position
@@ -135,7 +184,7 @@ out float vDim;
135
184
  out float vDotWeight; // 1 = the dot IS this seat, 0 = the chair has taken over
136
185
  out float vPhysicalSeat;
137
186
  out float vPixelRadius;
138
- ${Vt}
187
+ ${Nt}
139
188
  void main() {
140
189
  vec4 mv = modelViewMatrix * vec4(iOffset, 1.0);
141
190
  float depth = max(-mv.z, 0.001);
@@ -168,7 +217,7 @@ void main() {
168
217
  vPhysicalSeat = iPhysicalSeat;
169
218
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
170
219
  gl_Position = projectionMatrix * mv;
171
- }`,Pa=`#version 300 es
220
+ }`,Fa=`#version 300 es
172
221
  precision highp float;
173
222
  in vec2 vUv;
174
223
  in vec3 vColor;
@@ -226,11 +275,11 @@ void main() {
226
275
  alpha *= vDotWeight;
227
276
  if (alpha <= 0.0) discard;
228
277
  fragColor = vec4(c, alpha);
229
- }`,Aa=`#version 300 es
278
+ }`,Ea=`#version 300 es
230
279
  precision highp float;
231
280
  in vec3 position; // local: x/z in units of the seat radius, y in METRES
232
281
  in vec3 normal;
233
- in float part; // 0 = pedestal, 1 = pad, 2 = back, 3 = body, 4 = head
282
+ in float part; // 0..5 furniture modules, 10 body, 11 head
234
283
  in vec3 iOffset; // per-instance world deck point (identical to the dot's)
235
284
  in vec3 iColor; // per-instance state colour
236
285
  in float iRadius; // per-instance horizontal half-width, world metres
@@ -239,6 +288,7 @@ in vec3 iRing; // accommodation ring colour; (0,0,0) = not accessible
239
288
  in float iFloor;
240
289
  in float iSeed; // <0 = seat is empty; else per-person hash in [0,1)
241
290
  in float iPhysicalSeat;// 1 = chair; 0 = empty wheelchair bay
291
+ in float iGlyph; // stable SEAT_GLYPH_ORDER index
242
292
  uniform mat4 modelViewMatrix;
243
293
  uniform mat4 projectionMatrix;
244
294
  uniform float uChairFull;
@@ -256,8 +306,9 @@ out vec3 vRing;
256
306
  out float vDim;
257
307
  out float vOccupant; // 1 = this vertex belongs to a person, not to the chair
258
308
  out vec3 vOccupantTint;
259
- ${Vt}
260
- ${lr}
309
+ ${Nt}
310
+ ${pr}
311
+ ${fr}
261
312
  void main() {
262
313
  vec4 anchor = modelViewMatrix * vec4(iOffset, 1.0);
263
314
  float viewDepth = -anchor.z;
@@ -270,16 +321,17 @@ void main() {
270
321
  // chairs, but nobody gets a short one (people are the same height at every
271
322
  // seat pitch).
272
323
  vec3 p = position;
273
- // The occupant. Parts 3 and 4 are a person; everything below is furniture.
324
+ // The occupant. Parts 10 and 11 are a person; lower ids are furniture modules.
274
325
  //
275
326
  // One instanced mesh draws both an empty seat and a taken one, because the
276
327
  // alternative \u2014 a second geometry and a second draw call gathered per frame \u2014
277
328
  // would double the near-field cost to show what is already known per instance.
278
329
  // An unoccupied seat collapses its person to a point at the seat, which the
279
330
  // rasteriser discards, exactly as the chair itself collapses at w=0.
280
- float occupant = step(2.5, part);
331
+ float occupant = step(9.5, part);
281
332
  float taken = step(0.0, iSeed);
282
333
  vOccupant = occupant;
334
+ p = glyphChairPosition(p, part, iGlyph);
283
335
  if (iPhysicalSeat < 0.5) {
284
336
  p = vec3(0.0); // sellable space, but no physical chair/person
285
337
  } else if (occupant > 0.5) {
@@ -296,6 +348,7 @@ void main() {
296
348
  p *= occupantWeight(depth);
297
349
  }
298
350
  }
351
+ float localHeight = p.y;
299
352
  p.xz *= iRadius;
300
353
  // 2. Lean the back. Done here rather than in the base mesh so the lean is a
301
354
  // real angle in METRES \u2014 baked into the mesh it would scale with the seat's
@@ -304,7 +357,8 @@ void main() {
304
357
  // Only the BACK panel rakes. The old test (part > 1.5) meant "the back", and
305
358
  // now also catches the occupant \u2014 leaning a person by the panel's rule would
306
359
  // translate their head backwards by a rake measured from the panel's base.
307
- float rake = (part > 1.5 && part < 2.5) ? max(p.y - uBackBase, 0.0) * uBackRake : 0.0;
360
+ float resolvedRake = uBackRake * glyphBackRake(iGlyph);
361
+ float rake = (part > 1.5 && part < 2.5) ? max(p.y - uBackBase, 0.0) * resolvedRake : 0.0;
308
362
  p.z -= rake;
309
363
  // 3. Scale-in. At w=0 the chair is a point at the seat, under a dot at full
310
364
  // opacity \u2014 which is what makes the handover invisible. sqrt front-loads
@@ -318,7 +372,7 @@ void main() {
318
372
  // unchanged; and the rake is a shear, whose normal transform adds a y term.
319
373
  // Skipping either lights the raked back as though it were still vertical.
320
374
  vec3 n = vec3(normal.x / iRadius, normal.y, normal.z / iRadius);
321
- if (part > 1.5 && part < 2.5) n.y += uBackRake * n.z;
375
+ if (part > 1.5 && part < 2.5) n.y += resolvedRake * n.z;
322
376
  n = normalize(n);
323
377
  vec3 rn = vec3(n.x * c + n.z * s, n.y, -n.x * s + n.z * c);
324
378
  vec4 mv = modelViewMatrix * vec4(iOffset + rp, 1.0);
@@ -334,13 +388,13 @@ void main() {
334
388
  float t = fract(iSeed * 3.71);
335
389
  vec3 clothes = mix(vec3(0.18, 0.22, 0.30), vec3(0.42, 0.29, 0.34), t);
336
390
  vec3 skin = mix(vec3(0.52, 0.38, 0.29), vec3(0.86, 0.70, 0.58), fract(iSeed * 11.3));
337
- vOccupantTint = (part > 3.5) ? skin : clothes;
391
+ vOccupantTint = (part > 10.5) ? skin : clothes;
338
392
  vPart = part;
339
- vHeight = position.y;
393
+ vHeight = localHeight;
340
394
  vRing = iRing;
341
395
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
342
396
  gl_Position = projectionMatrix * mv;
343
- }`,Ca=`#version 300 es
397
+ }`,Da=`#version 300 es
344
398
  precision highp float;
345
399
  in vec3 vColor;
346
400
  in vec3 vNormalWorld;
@@ -367,16 +421,21 @@ void main() {
367
421
  vec3 tint = vColor;
368
422
  if (vOccupant > 0.5) tint = vOccupantTint;
369
423
  // The accommodation ring, kept legible once the dot (which drew it) is gone:
370
- // an accessible seat's PEDESTAL is painted in the ring colour, so the marker
424
+ // an accessible seat's support is painted in the ring colour, so the marker
371
425
  // survives to close range instead of vanishing exactly when the buyer arrives.
372
426
  float ringMask = step(0.001, dot(vRing, vRing));
373
- if (vPart < 0.5 && ringMask > 0.5) tint = vRing;
374
- // Pad brightest, back a step below it, pedestal darkest. Three untextured
375
- // boxes only read as one object if they are separated tonally \u2014 with a single
376
- // flat colour the chair silhouettes as a crate.
427
+ float supportPart = max(1.0 - step(0.5, vPart),
428
+ step(4.5, vPart) * (1.0 - step(5.5, vPart)));
429
+ if (supportPart > 0.5 && ringMask > 0.5) tint = vRing;
430
+ // Tonal separation keeps the modular silhouettes readable without textures.
377
431
  // A person is lit as a person, not as upholstery: no part shading, and less
378
432
  // of the pad's sheen, so a head does not read as a polished box.
379
- float partShade = vOccupant > 0.5 ? 0.95 : (vPart < 0.5 ? 0.50 : (vPart < 1.5 ? 1.10 : 0.80));
433
+ float furnitureShade = vPart < 0.5 ? 0.50
434
+ : (vPart < 1.5 ? 1.10
435
+ : (vPart < 2.5 ? 0.80
436
+ : (vPart < 3.5 ? 0.72
437
+ : (vPart < 4.5 ? 0.90 : 0.55))));
438
+ float partShade = vOccupant > 0.5 ? 0.95 : furnitureShade;
380
439
  // Cheap vertical occlusion: a chair is in a dense row, so the closer a surface
381
440
  // sits to the deck the less sky it can actually see. This is the depth cue \u2014
382
441
  // without it the pad top, the back and the deck all resolve to the same flat
@@ -390,14 +449,14 @@ void main() {
390
449
  // which is what stops a block of them merging into one mass up close.
391
450
  base += vec3(0.26, 0.31, 0.38) * fres * 0.55;
392
451
  fragColor = vec4(base, 1.0);
393
- }`,Ra=`#version 300 es
452
+ }`,ka=`#version 300 es
394
453
  precision highp float;
395
454
  in vec2 position;
396
455
  out vec2 vUv;
397
456
  void main() {
398
457
  vUv = position * 0.5 + 0.5;
399
458
  gl_Position = vec4(position, 0.999, 1.0);
400
- }`,Ia=`#version 300 es
459
+ }`,La=`#version 300 es
401
460
  precision highp float;
402
461
  in vec2 vUv;
403
462
  uniform vec3 uTop;
@@ -408,7 +467,7 @@ void main() {
408
467
  vec2 c = vUv - 0.5;
409
468
  float vig = 1.0 - dot(c, c) * 0.85; // soft vignette
410
469
  fragColor = vec4(col * vig, 1.0);
411
- }`,Ta=`#version 300 es
470
+ }`,_a=`#version 300 es
412
471
  precision highp float;
413
472
  in vec2 position;
414
473
  in vec3 iOffset;
@@ -429,7 +488,7 @@ out float vPhysicalSeat;
429
488
  out float vDotWeight;
430
489
  out float vHidden;
431
490
  flat out vec3 vPick;
432
- ${Vt}
491
+ ${Nt}
433
492
  void main() {
434
493
  int id = gl_InstanceID + 1; // 0 reserved for no-hit
435
494
  vPick = vec3(float(id & 255), float((id >> 8) & 255), float((id >> 16) & 255)) / 255.0;
@@ -445,7 +504,7 @@ void main() {
445
504
  vPhysicalSeat = iPhysicalSeat;
446
505
  vHidden = (uFocusFloor > -0.5 && abs(iFloor - uFocusFloor) > 0.5) ? 1.0 : 0.0;
447
506
  gl_Position = projectionMatrix * mv;
448
- }`,Fa=`#version 300 es
507
+ }`,Oa=`#version 300 es
449
508
  precision highp float;
450
509
  in vec2 vUv;
451
510
  in float vPhysicalSeat;
@@ -459,7 +518,7 @@ void main() {
459
518
  float d = mix(max(abs(vUv.x), abs(vUv.y)), length(vUv), vPhysicalSeat);
460
519
  if (d > 1.0) discard; // hit-mask matches chair/bay shape
461
520
  fragColor = vec4(vPick, 1.0);
462
- }`,Ea=`#version 300 es
521
+ }`,Ba=`#version 300 es
463
522
  precision highp float;
464
523
  in vec3 position;
465
524
  in float part;
@@ -468,6 +527,7 @@ in float iRadius;
468
527
  in float iYaw;
469
528
  in float iSeed;
470
529
  in float iPhysicalSeat;
530
+ in float iGlyph;
471
531
  in float iPickIndex;
472
532
  in float iFloor;
473
533
  uniform mat4 modelViewMatrix;
@@ -479,8 +539,9 @@ uniform float uBackBase;
479
539
  uniform float uFocusFloor;
480
540
  flat out vec3 vPick;
481
541
  out float vHidden;
482
- ${Vt}
483
- ${lr}
542
+ ${Nt}
543
+ ${pr}
544
+ ${fr}
484
545
  void main() {
485
546
  int id = int(iPickIndex + 0.5); // already global index + 1
486
547
  vPick = vec3(float(id & 255), float((id >> 8) & 255), float((id >> 16) & 255)) / 255.0;
@@ -490,8 +551,9 @@ void main() {
490
551
  float depth = max(viewDepth, 0.001);
491
552
  float w = viewDepth > 0.05 ? chairWeight(depth) : 0.0;
492
553
  vec3 p = position;
493
- float occupant = step(2.5, part);
554
+ float occupant = step(9.5, part);
494
555
  float taken = step(0.0, iSeed);
556
+ p = glyphChairPosition(p, part, iGlyph);
495
557
  if (iPhysicalSeat < 0.5) {
496
558
  p = vec3(0.0);
497
559
  } else if (occupant > 0.5) {
@@ -504,13 +566,15 @@ void main() {
504
566
  }
505
567
  }
506
568
  p.xz *= iRadius;
507
- float rake = (part > 1.5 && part < 2.5) ? max(p.y - uBackBase, 0.0) * uBackRake : 0.0;
569
+ float rake = (part > 1.5 && part < 2.5)
570
+ ? max(p.y - uBackBase, 0.0) * uBackRake * glyphBackRake(iGlyph)
571
+ : 0.0;
508
572
  p.z -= rake;
509
573
  p *= sqrt(w);
510
574
  float c = cos(iYaw), s = sin(iYaw);
511
575
  vec3 rp = vec3(p.x * c + p.z * s, p.y, -p.x * s + p.z * c);
512
576
  gl_Position = projectionMatrix * modelViewMatrix * vec4(iOffset + rp, 1.0);
513
- }`,Da=`#version 300 es
577
+ }`,Va=`#version 300 es
514
578
  precision highp float;
515
579
  flat in vec3 vPick;
516
580
  in float vHidden;
@@ -518,7 +582,7 @@ out vec4 fragColor;
518
582
  void main() {
519
583
  if (vHidden > 0.5) discard;
520
584
  fragColor = vec4(vPick, 1.0);
521
- }`,ka=`#version 300 es
585
+ }`,za=`#version 300 es
522
586
  precision highp float;
523
587
  in vec3 position;
524
588
  in float floorIndex;
@@ -529,14 +593,14 @@ out float vHidden;
529
593
  void main() {
530
594
  vHidden = (uFocusFloor > -0.5 && abs(floorIndex - uFocusFloor) > 0.5) ? 1.0 : 0.0;
531
595
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
532
- }`,La=`#version 300 es
596
+ }`,Na=`#version 300 es
533
597
  precision highp float;
534
598
  in float vHidden;
535
599
  out vec4 fragColor;
536
600
  void main() {
537
601
  if (vHidden > 0.5) discard;
538
602
  fragColor = vec4(0.0, 0.0, 0.0, 1.0);
539
- }`;function ur(t){return new je(t,{vertex:Ta,fragment:Fa,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Re},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uChairFull:{value:lt},uChairNone:{value:Qe},uFocusFloor:{value:-1}}})}function mr(t){return new je(t,{vertex:Ea,fragment:Da,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:lt},uChairNone:{value:Qe},uBackRake:{value:on},uBackBase:{value:Lt},uFocusFloor:{value:-1}}})}function dr(t){return new je(t,{vertex:ka,fragment:La,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function hr(t){return new je(t,{vertex:Ma,fragment:Sa,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function pr(t){return new je(t,{vertex:wa,fragment:Pa,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Re},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:lt},uChairNone:{value:Qe}}})}function fr(t){return new je(t,{vertex:Aa,fragment:Ca,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:lt},uChairNone:{value:Qe},uBackRake:{value:on},uBackBase:{value:Lt},uFocusFloor:{value:-1}}})}function br(t,e,n){return new je(t,{vertex:Ra,fragment:Ia,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function xr(t,e,n,i,o,r){for(let a=n;a<n+i;a++){let l=r&&e[a]===0?null:o[e[a]]??o[0];t[a*3]=l?l[0]:r[a*3],t[a*3+1]=l?l[1]:r[a*3+1],t[a*3+2]=l?l[2]:r[a*3+2]}}var _a=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Oa=new Float32Array([-1,-1,3,-1,-1,3]);function gr(t,e){let n=new yr,i=new yr,o=new Nt(t,{position:{size:2,data:Oa}}),r=br(t,e.theme.background.top,e.theme.background.bottom),a=new zt(t,{geometry:o,program:r});a.frustumCulled=!1,a.setParent(i);let s=new Nt(t,{position:{size:3,data:e.solids.position},normal:{size:3,data:e.solids.normal},color:{size:3,data:e.solids.color},floorIndex:{size:1,data:e.solids.floor},materialIndex:{size:1,data:e.solids.material}}),l=hr(t),c=new zt(t,{geometry:s,program:l});c.frustumCulled=!1,c.setParent(n);let h=pr(t),m=new Float32Array(e.seats.count*3),d=be.map(I=>e.theme.seatStates[I]);xr(m,e.seats.iState,0,e.seats.count,d,e.seats.iCategory);let p=new Nt(t,{position:{size:2,data:_a},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:m,instanced:1},iMaxRadius:{size:1,data:e.seats.iMaxRadius,instanced:1},iPhysicalSeat:{size:1,data:e.seats.iPhysicalSeat,instanced:1},iRing:{size:3,data:e.seats.iRing,instanced:1},iFloor:{size:1,data:e.seats.iFloor,instanced:1}}),f=new zt(t,{geometry:p,program:h});f.frustumCulled=!1,e.seats.count>0&&f.setParent(n);let u=p.attributes.iColor,b=ro(),y=fr(t),x=It,v=new Float32Array(x*3),k=new Float32Array(x*3),P=new Float32Array(x),M=new Float32Array(x),F=new Float32Array(x*3),O=new Float32Array(x),L=new Float32Array(x),H=new Float32Array(x),_=new Float32Array(x),g=new Nt(t,{position:{size:3,data:b.position},normal:{size:3,data:b.normal},part:{size:1,data:b.part},index:{data:b.index},iOffset:{size:3,data:v,instanced:1},iColor:{size:3,data:k,instanced:1},iRadius:{size:1,data:P,instanced:1},iYaw:{size:1,data:M,instanced:1},iRing:{size:3,data:F,instanced:1},iFloor:{size:1,data:O,instanced:1},iPhysicalSeat:{size:1,data:L,instanced:1},iSeed:{size:1,data:_,instanced:1},iPickIndex:{size:1,data:H,instanced:1}}),w=new zt(t,{geometry:g,program:y});w.frustumCulled=!1;let E=0,C=new Int32Array(0),N=()=>{let I=e.seats;for(let T=0;T<E;T++){let B=C[T];_[T]=ao(I.iState[B],B);let D=I.iCategory&&I.iState[B]===0?null:d[I.iState[B]]??d[0];if(D)k[T*3]=D[0],k[T*3+1]=D[1],k[T*3+2]=D[2];else{let V=Yn([I.iCategory[B*3],I.iCategory[B*3+1],I.iCategory[B*3+2]]);k[T*3]=V[0],k[T*3+1]=V[1],k[T*3+2]=V[2]}}g.attributes.iColor.needsUpdate=!0,g.attributes.iSeed.needsUpdate=!0},S={main:n,background:i,seatProgram:h,solidProgram:l,chairProgram:y,seatGeometry:p,chairGeometry:g,solidGeometry:s,drawCalls:3,setNearSeats(I,T){let B=Math.min(T,x);if(C=I,E=B,B===0){w.parent&&w.setParent(null),g.instancedCount=0,S.drawCalls=3;return}let A=e.seats;for(let D=0;D<B;D++){let V=I[D];v[D*3]=A.iPosition[V*3],v[D*3+1]=A.iPosition[V*3+1],v[D*3+2]=A.iPosition[V*3+2],P[D]=A.iChairWidth[V],M[D]=A.iYaw[V],F[D*3]=A.iRing[V*3],F[D*3+1]=A.iRing[V*3+1],F[D*3+2]=A.iRing[V*3+2],O[D]=A.iFloor[V],L[D]=A.iPhysicalSeat[V],H[D]=V+1}N(),g.attributes.iOffset.needsUpdate=!0,g.attributes.iRadius.needsUpdate=!0,g.attributes.iYaw.needsUpdate=!0,g.attributes.iRing.needsUpdate=!0,g.attributes.iFloor.needsUpdate=!0,g.attributes.iPhysicalSeat.needsUpdate=!0,g.attributes.iSeed.needsUpdate=!0,g.attributes.iPickIndex.needsUpdate=!0,g.instancedCount=B,w.parent||w.setParent(n),S.drawCalls=4},nearSeatCount(){return E},uploadSeatStateRuns(I){if(!I.length)return;E&&N();for(let B of I)xr(m,e.seats.iState,B.start,B.length,d,e.seats.iCategory);let T=u.buffer;if(!T){u.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,T);for(let B of I){let A=m.subarray(B.start*3,(B.start+B.length)*3);t.bufferSubData(t.ARRAY_BUFFER,B.start*3*Float32Array.BYTES_PER_ELEMENT,A)}},dispose(){o.remove(),r.remove(),s.remove(),l.remove(),p.remove(),h.remove(),g.remove(),y.remove()}};return S}import{Mesh as yn,RenderTarget as Va,Transform as xn}from"ogl";function Ba(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function vr(t,e,n,i,o,r){let a=-1,s=1/0;for(let l=0;l<n;l++)for(let c=0;c<e;c++){let h=(l*e+c)*4,m=Ba(t[h],t[h+1],t[h+2]);if(m<0||m>=r)continue;let d=c-i,p=l-o,f=d*d+p*p;f<s&&(s=f,a=m)}return a}function Mr(t,e,n,i,o,r){let a=t-n.left,s=e-n.top,l=Math.round(a*i),c=Math.round((n.height-s)*i);return{x:Math.max(0,Math.min(o-1,l)),y:Math.max(0,Math.min(r-1,c))}}var Na=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Gt=class{constructor(e,n,i,o,r){this.seatScene=new xn;this.chairScene=new xn;this.solidScene=new xn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=r,this.seatProg=ur(this.gl),this.chairProg=mr(this.gl),this.depthProg=dr(this.gl);let a=new yn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new yn(this.gl,{geometry:i,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let l=new yn(this.gl,{geometry:o,program:this.depthProg});l.frustumCulled=!1,l.setParent(this.solidScene)}setRestoreClear(e){this.restoreClear=[e[0],e[1],e[2]]}syncFromSeatProgram(e){for(let i of Na)this.seatProg.uniforms[i].value=e.uniforms[i].value;let n=e.uniforms.uFocusFloor.value;this.seatProg.uniforms.uFocusFloor.value=n,this.chairProg.uniforms.uFocusFloor.value=n,this.depthProg.uniforms.uFocusFloor.value=n}ensureTarget(){let e=this.gl.drawingBufferWidth,n=this.gl.drawingBufferHeight;return this.target&&(this.target.width!==e||this.target.height!==n)&&this.destroyTarget(),this.target||(this.target=new Va(this.gl,{width:e,height:n,depth:!0})),this.target}destroyTarget(){if(!this.target)return;let e=this.gl;this.target.buffer&&e.deleteFramebuffer(this.target.buffer);for(let n of this.target.textures??[])n.texture&&e.deleteTexture(n.texture);this.target.depthBuffer&&e.deleteRenderbuffer(this.target.depthBuffer),this.target=null}pick(e,n,i,o){let r=this.gl,a=this.ensureTarget(),s=r.drawingBufferWidth,l=r.drawingBufferHeight,c=Math.max(0,n-o),h=Math.max(0,i-o),m=Math.max(1,Math.min(s,n+o+1)-c),d=Math.max(1,Math.min(l,i+o+1)-h);r.enable(r.SCISSOR_TEST),r.scissor(c,h,m,d);let[p,f,u]=this.restoreClear;r.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:e,target:a,clear:!0}),this.renderer.render({scene:this.seatScene,camera:e,target:a,clear:!1}),this.renderer.render({scene:this.chairScene,camera:e,target:a,clear:!1}),r.clearColor(p,f,u,1),r.disable(r.SCISSOR_TEST);let b=new Uint8Array(m*d*4);return this.renderer.bindFramebuffer(a),r.readPixels(c,h,m,d,r.RGBA,r.UNSIGNED_BYTE,b),this.renderer.bindFramebuffer(),vr(b,m,d,n-c,i-h,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function Sr(t,e){let n=[];for(let i of e)t.has(i.seatId)?t.set(i.seatId,ct(i.state)):n.push(i);return n}function wr(t,e,n){let i=new Set;for(let a of e)(t.has(a)||n(a)!==void 0)&&i.add(a);let o=new Map(t),r=[];for(let[a,s]of t)i.has(a)||(r.push({seatId:a,state:be[s]??"available"}),o.delete(a));for(let a of i){if(o.has(a))continue;let s=n(a);s!==void 0&&(o.set(a,s),r.push({seatId:a,state:"selected"}))}return{updates:r,next:o}}import{Quat as xt,Vec3 as Ha}from"ogl";function za(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Pr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Ga(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Ar(t){let e=Math.hypot(t[0],t[1],t[2]);return e>1e-6?[t[0]/e,t[1]/e,t[2]/e]:[0,0,0]}function gn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function vn(t,e){return Math.max(0,Math.min(1,t+e))}function Cr(t,e){let n=t.length;if(n===0)return[0,0,0];if(n===1)return[...t[0]];let i=Math.max(0,Math.min(1,e)),o=n-1,r=Math.floor(i*o);r>=o&&(r=o-1);let a=i*o-r,s=t[Math.max(0,r-1)],l=t[r],c=t[r+1],h=t[Math.min(n-1,r+2)],m=a*a,d=m*a,p=[0,0,0];for(let f=0;f<3;f++)p[f]=.5*(2*l[f]+(-s[f]+c[f])*a+(2*s[f]-5*l[f]+4*c[f]-h[f])*m+(-s[f]+3*l[f]-3*c[f]+h[f])*d);return p}function Mn(t,e,n,i,o){let r=Ar(za(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let a=Pr(Pr(e,Ga(r,2.5)),[0,1.5,0]),s=[e[0]-i[0],0,e[2]-i[2]],l=Ar(s);l[0]===0&&l[2]===0&&(l=[r[0],0,r[2]]);let c=Math.max(1,o),h=[i[0]+l[0]*c*1.3,i[1]+c*.75,i[2]+l[2]*c*1.3];return{waypoints:[t,h,a],finalPos:a}}function Sn(t,e,n=35,i=28){let o=gn(e),r=Cr(t,o),a=gn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*a,eased:o}}function Tr(t,e,n){let i=t.position.clone(),o=new xt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Ha(n[0],n[1],n[2]));let r=new xt().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var Ht=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new xt;this.endQuat=new xt;this.outQuat=new xt;this.startTime=0;this.duration=2500;this.endFov=28;this.resolveFn=null;this.camera=e}start(e,n,i,o=2500,r=28){return this.settle(),this.waypoints=e,this.startQuat.copy(n),this.endQuat.copy(i),this.duration=o,this.endFov=r,this.startTime=performance.now(),this.active=!0,new Promise(a=>{this.resolveFn=a})}update(e){if(!this.active)return!1;let n=Math.min(1,(e-this.startTime)/this.duration),{pos:i,fov:o,eased:r}=Sn(this.waypoints,n,35,this.endFov);return this.camera.position.set(i[0],i[1],i[2]),this.outQuat.copy(this.startQuat).slerp(this.endQuat,vn(r,.15)),this.camera.quaternion.copy(this.outQuat),this.camera.fov=o,this.camera.updateProjectionMatrix(),n>=1?(this.settle(),!1):!0}cancel(){this.settle()}settle(){this.active=!1;let e=this.resolveFn;this.resolveFn=null,e&&e()}};var Ua=1.02,Xa=1.5;function Fr(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+Ua;return{eye:[t[0],o,t[2]],focal:[e.x*R,n+Xa,e.y*R]}}import{Geometry as Ya,Mesh as Wa,Program as ja,Texture as qa}from"ogl";var Ka=64,Za=32,Qa=500;function $a(t=Ka,e=Za,n=Qa){let i=t+1,o=e+1,r=i*o,a=new Float32Array(r*3),s=new Float32Array(r*2);for(let h=0;h<o;h++){let m=h/e,d=m*Math.PI,p=Math.sin(d),f=Math.cos(d);for(let u=0;u<i;u++){let b=u/t,y=(b-.5)*Math.PI*2,x=h*i+u;a[x*3]=n*p*Math.sin(y),a[x*3+1]=n*f,a[x*3+2]=-n*p*Math.cos(y),s[x*2]=b,s[x*2+1]=m}}let l=new Uint16Array(t*e*6),c=0;for(let h=0;h<e;h++)for(let m=0;m<t;m++){let d=h*i+m,p=d+i;l[c++]=d,l[c++]=p,l[c++]=d+1,l[c++]=d+1,l[c++]=p,l[c++]=p+1}return{position:a,uv:s,index:l}}function Er(t,e){let n=t*Math.PI/180,i=e*Math.PI/180,o=Math.cos(i);return[o*Math.sin(n),Math.sin(i),-o*Math.cos(n)]}var Ja=`#version 300 es
603
+ }`;function br(t){return new je(t,{vertex:_a,fragment:Oa,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Re},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uChairFull:{value:lt},uChairNone:{value:Qe},uFocusFloor:{value:-1}}})}function yr(t){return new je(t,{vertex:Ba,fragment:Va,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:lt},uChairNone:{value:Qe},uBackRake:{value:an},uBackBase:{value:Lt},uFocusFloor:{value:-1}}})}function xr(t){return new je(t,{vertex:za,fragment:Na,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function gr(t){return new je(t,{vertex:Ra,fragment:Ia,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function vr(t){return new je(t,{vertex:Ta,fragment:Fa,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Re},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:lt},uChairNone:{value:Qe}}})}function Mr(t){return new je(t,{vertex:Ea,fragment:Da,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:lt},uChairNone:{value:Qe},uBackRake:{value:an},uBackBase:{value:Lt},uFocusFloor:{value:-1}}})}function Sr(t,e,n){return new je(t,{vertex:ka,fragment:La,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function Pr(t,e,n,r,o,i){for(let a=n;a<n+r;a++){let l=i&&e[a]===0?null:o[e[a]]??o[0];t[a*3]=l?l[0]:i[a*3],t[a*3+1]=l?l[1]:i[a*3+1],t[a*3+2]=l?l[2]:i[a*3+2]}}var Ga=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Ha=new Float32Array([-1,-1,3,-1,-1,3]);function Ar(t,e){let n=new wr,r=new wr,o=new Gt(t,{position:{size:2,data:Ha}}),i=Sr(t,e.theme.background.top,e.theme.background.bottom),a=new Ht(t,{geometry:o,program:i});a.frustumCulled=!1,a.setParent(r);let s=new Gt(t,{position:{size:3,data:e.solids.position},normal:{size:3,data:e.solids.normal},color:{size:3,data:e.solids.color},floorIndex:{size:1,data:e.solids.floor},materialIndex:{size:1,data:e.solids.material}}),l=gr(t),c=new Ht(t,{geometry:s,program:l});c.frustumCulled=!1,c.setParent(n);let d=vr(t),u=new Float32Array(e.seats.count*3),m=be.map(T=>e.theme.seatStates[T]);Pr(u,e.seats.iState,0,e.seats.count,m,e.seats.iCategory);let p=new Gt(t,{position:{size:2,data:Ga},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:u,instanced:1},iMaxRadius:{size:1,data:e.seats.iMaxRadius,instanced:1},iPhysicalSeat:{size:1,data:e.seats.iPhysicalSeat,instanced:1},iRing:{size:3,data:e.seats.iRing,instanced:1},iFloor:{size:1,data:e.seats.iFloor,instanced:1}}),h=new Ht(t,{geometry:p,program:d});h.frustumCulled=!1,e.seats.count>0&&h.setParent(n);let f=p.attributes.iColor,x=uo(),b=Mr(t),y=It,g=new Float32Array(y*3),F=new Float32Array(y*3),w=new Float32Array(y),v=new Float32Array(y),D=new Float32Array(y),L=new Float32Array(y*3),_=new Float32Array(y),U=new Float32Array(y),B=new Float32Array(y),S=new Float32Array(y),M=new Gt(t,{position:{size:3,data:x.position},normal:{size:3,data:x.normal},part:{size:1,data:x.part},index:{data:x.index},iOffset:{size:3,data:g,instanced:1},iColor:{size:3,data:F,instanced:1},iRadius:{size:1,data:w,instanced:1},iYaw:{size:1,data:v,instanced:1},iGlyph:{size:1,data:D,instanced:1},iRing:{size:3,data:L,instanced:1},iFloor:{size:1,data:_,instanced:1},iPhysicalSeat:{size:1,data:U,instanced:1},iSeed:{size:1,data:S,instanced:1},iPickIndex:{size:1,data:B,instanced:1}}),A=new Ht(t,{geometry:M,program:b});A.frustumCulled=!1;let R=0,V=new Int32Array(0),E=()=>{let T=e.seats;for(let z=0;z<R;z++){let P=V[z];S[z]=ho(T.iState[P],P);let O=T.iCategory&&T.iState[P]===0?null:m[T.iState[P]]??m[0];if(O)F[z*3]=O[0],F[z*3+1]=O[1],F[z*3+2]=O[2];else{let H=Qn([T.iCategory[P*3],T.iCategory[P*3+1],T.iCategory[P*3+2]]);F[z*3]=H[0],F[z*3+1]=H[1],F[z*3+2]=H[2]}}M.attributes.iColor.needsUpdate=!0,M.attributes.iSeed.needsUpdate=!0},C={main:n,background:r,seatProgram:d,solidProgram:l,chairProgram:b,seatGeometry:p,chairGeometry:M,solidGeometry:s,drawCalls:3,setNearSeats(T,z){let P=Math.min(z,y);if(V=T,R=P,P===0){A.parent&&A.setParent(null),M.instancedCount=0,C.drawCalls=3;return}let k=e.seats;for(let O=0;O<P;O++){let H=T[O];g[O*3]=k.iPosition[H*3],g[O*3+1]=k.iPosition[H*3+1],g[O*3+2]=k.iPosition[H*3+2],w[O]=k.iChairWidth[H],v[O]=k.iYaw[H],D[O]=k.iGlyph[H],L[O*3]=k.iRing[H*3],L[O*3+1]=k.iRing[H*3+1],L[O*3+2]=k.iRing[H*3+2],_[O]=k.iFloor[H],U[O]=k.iPhysicalSeat[H],B[O]=H+1}E(),M.attributes.iOffset.needsUpdate=!0,M.attributes.iRadius.needsUpdate=!0,M.attributes.iYaw.needsUpdate=!0,M.attributes.iGlyph.needsUpdate=!0,M.attributes.iRing.needsUpdate=!0,M.attributes.iFloor.needsUpdate=!0,M.attributes.iPhysicalSeat.needsUpdate=!0,M.attributes.iSeed.needsUpdate=!0,M.attributes.iPickIndex.needsUpdate=!0,M.instancedCount=P,A.parent||A.setParent(n),C.drawCalls=4},nearSeatCount(){return R},uploadSeatStateRuns(T){if(!T.length)return;R&&E();for(let P of T)Pr(u,e.seats.iState,P.start,P.length,m,e.seats.iCategory);let z=f.buffer;if(!z){f.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,z);for(let P of T){let k=u.subarray(P.start*3,(P.start+P.length)*3);t.bufferSubData(t.ARRAY_BUFFER,P.start*3*Float32Array.BYTES_PER_ELEMENT,k)}},dispose(){o.remove(),i.remove(),s.remove(),l.remove(),p.remove(),d.remove(),M.remove(),b.remove()}};return C}import{Mesh as Mn,RenderTarget as Ya,Transform as Sn}from"ogl";function Ua(t,e,n){let r=t+(e<<8)+(n<<16);return r===0?-1:r-1}function Cr(t,e,n,r,o,i){let a=-1,s=1/0;for(let l=0;l<n;l++)for(let c=0;c<e;c++){let d=(l*e+c)*4,u=Ua(t[d],t[d+1],t[d+2]);if(u<0||u>=i)continue;let m=c-r,p=l-o,h=m*m+p*p;h<s&&(s=h,a=u)}return a}function Rr(t,e,n,r,o,i){let a=t-n.left,s=e-n.top,l=Math.round(a*r),c=Math.round((n.height-s)*r);return{x:Math.max(0,Math.min(o-1,l)),y:Math.max(0,Math.min(i-1,c))}}var Xa=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Ut=class{constructor(e,n,r,o,i){this.seatScene=new Sn;this.chairScene=new Sn;this.solidScene=new Sn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=i,this.seatProg=br(this.gl),this.chairProg=yr(this.gl),this.depthProg=xr(this.gl);let a=new Mn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new Mn(this.gl,{geometry:r,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let l=new Mn(this.gl,{geometry:o,program:this.depthProg});l.frustumCulled=!1,l.setParent(this.solidScene)}setRestoreClear(e){this.restoreClear=[e[0],e[1],e[2]]}syncFromSeatProgram(e){for(let r of Xa)this.seatProg.uniforms[r].value=e.uniforms[r].value;let n=e.uniforms.uFocusFloor.value;this.seatProg.uniforms.uFocusFloor.value=n,this.chairProg.uniforms.uFocusFloor.value=n,this.depthProg.uniforms.uFocusFloor.value=n}ensureTarget(){let e=this.gl.drawingBufferWidth,n=this.gl.drawingBufferHeight;return this.target&&(this.target.width!==e||this.target.height!==n)&&this.destroyTarget(),this.target||(this.target=new Ya(this.gl,{width:e,height:n,depth:!0})),this.target}destroyTarget(){if(!this.target)return;let e=this.gl;this.target.buffer&&e.deleteFramebuffer(this.target.buffer);for(let n of this.target.textures??[])n.texture&&e.deleteTexture(n.texture);this.target.depthBuffer&&e.deleteRenderbuffer(this.target.depthBuffer),this.target=null}pick(e,n,r,o){let i=this.gl,a=this.ensureTarget(),s=i.drawingBufferWidth,l=i.drawingBufferHeight,c=Math.max(0,n-o),d=Math.max(0,r-o),u=Math.max(1,Math.min(s,n+o+1)-c),m=Math.max(1,Math.min(l,r+o+1)-d);i.enable(i.SCISSOR_TEST),i.scissor(c,d,u,m);let[p,h,f]=this.restoreClear;i.clearColor(0,0,0,1),this.renderer.render({scene:this.solidScene,camera:e,target:a,clear:!0}),this.renderer.render({scene:this.seatScene,camera:e,target:a,clear:!1}),this.renderer.render({scene:this.chairScene,camera:e,target:a,clear:!1}),i.clearColor(p,h,f,1),i.disable(i.SCISSOR_TEST);let x=new Uint8Array(u*m*4);return this.renderer.bindFramebuffer(a),i.readPixels(c,d,u,m,i.RGBA,i.UNSIGNED_BYTE,x),this.renderer.bindFramebuffer(),Cr(x,u,m,n-c,r-d,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function Ir(t,e){let n=[];for(let r of e)t.has(r.seatId)?t.set(r.seatId,ct(r.state)):n.push(r);return n}function Tr(t,e,n){let r=new Set;for(let a of e)(t.has(a)||n(a)!==void 0)&&r.add(a);let o=new Map(t),i=[];for(let[a,s]of t)r.has(a)||(i.push({seatId:a,state:be[s]??"available"}),o.delete(a));for(let a of r){if(o.has(a))continue;let s=n(a);s!==void 0&&(o.set(a,s),i.push({seatId:a,state:"selected"}))}return{updates:i,next:o}}import{Quat as xt,Vec3 as qa}from"ogl";function Wa(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Fr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function ja(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Er(t){let e=Math.hypot(t[0],t[1],t[2]);return e>1e-6?[t[0]/e,t[1]/e,t[2]/e]:[0,0,0]}function wn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function Pn(t,e){return Math.max(0,Math.min(1,t+e))}function Dr(t,e){let n=t.length;if(n===0)return[0,0,0];if(n===1)return[...t[0]];let r=Math.max(0,Math.min(1,e)),o=n-1,i=Math.floor(r*o);i>=o&&(i=o-1);let a=r*o-i,s=t[Math.max(0,i-1)],l=t[i],c=t[i+1],d=t[Math.min(n-1,i+2)],u=a*a,m=u*a,p=[0,0,0];for(let h=0;h<3;h++)p[h]=.5*(2*l[h]+(-s[h]+c[h])*a+(2*s[h]-5*l[h]+4*c[h]-d[h])*u+(-s[h]+3*l[h]-3*c[h]+d[h])*m);return p}function An(t,e,n,r,o){let i=Er(Wa(e,n));i[0]===0&&i[1]===0&&i[2]===0&&(i=[0,0,1]);let a=Fr(Fr(e,ja(i,2.5)),[0,1.5,0]),s=[e[0]-r[0],0,e[2]-r[2]],l=Er(s);l[0]===0&&l[2]===0&&(l=[i[0],0,i[2]]);let c=Math.max(1,o),d=[r[0]+l[0]*c*1.3,r[1]+c*.75,r[2]+l[2]*c*1.3];return{waypoints:[t,d,a],finalPos:a}}function Cn(t,e,n=35,r=28){let o=wn(e),i=Dr(t,o),a=wn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:i,fov:n+(r-n)*a,eased:o}}function _r(t,e,n){let r=t.position.clone(),o=new xt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new qa(n[0],n[1],n[2]));let i=new xt().copy(t.quaternion);return t.position.copy(r),t.quaternion.copy(o),i}var Yt=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new xt;this.endQuat=new xt;this.outQuat=new xt;this.startTime=0;this.duration=2500;this.endFov=28;this.resolveFn=null;this.camera=e}start(e,n,r,o=2500,i=28){return this.settle(),this.waypoints=e,this.startQuat.copy(n),this.endQuat.copy(r),this.duration=o,this.endFov=i,this.startTime=performance.now(),this.active=!0,new Promise(a=>{this.resolveFn=a})}update(e){if(!this.active)return!1;let n=Math.min(1,(e-this.startTime)/this.duration),{pos:r,fov:o,eased:i}=Cn(this.waypoints,n,35,this.endFov);return this.camera.position.set(r[0],r[1],r[2]),this.outQuat.copy(this.startQuat).slerp(this.endQuat,Pn(i,.15)),this.camera.quaternion.copy(this.outQuat),this.camera.fov=o,this.camera.updateProjectionMatrix(),n>=1?(this.settle(),!1):!0}cancel(){this.settle()}settle(){this.active=!1;let e=this.resolveFn;this.resolveFn=null,e&&e()}};var Ka=1.02,Za=1.5;function Or(t,e,n=0,r){let o=Number.isFinite(r)?n+r:t[1]+Ka;return{eye:[t[0],o,t[2]],focal:[e.x*I,n+Za,e.y*I]}}import{Geometry as Qa,Mesh as $a,Program as Ja,Texture as es}from"ogl";var ts=64,ns=32,os=500;function rs(t=ts,e=ns,n=os){let r=t+1,o=e+1,i=r*o,a=new Float32Array(i*3),s=new Float32Array(i*2);for(let d=0;d<o;d++){let u=d/e,m=u*Math.PI,p=Math.sin(m),h=Math.cos(m);for(let f=0;f<r;f++){let x=f/t,b=(x-.5)*Math.PI*2,y=d*r+f;a[y*3]=n*p*Math.sin(b),a[y*3+1]=n*h,a[y*3+2]=-n*p*Math.cos(b),s[y*2]=x,s[y*2+1]=u}}let l=new Uint16Array(t*e*6),c=0;for(let d=0;d<e;d++)for(let u=0;u<t;u++){let m=d*r+u,p=m+r;l[c++]=m,l[c++]=p,l[c++]=m+1,l[c++]=m+1,l[c++]=p,l[c++]=p+1}return{position:a,uv:s,index:l}}function Br(t,e){let n=t*Math.PI/180,r=e*Math.PI/180,o=Math.cos(r);return[o*Math.sin(n),Math.sin(r),-o*Math.cos(n)]}var is=`#version 300 es
540
604
  precision highp float;
541
605
  in vec3 position;
542
606
  in vec2 uv;
@@ -546,7 +610,7 @@ out vec2 vUv;
546
610
  void main() {
547
611
  vUv = uv;
548
612
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
549
- }`,es=`#version 300 es
613
+ }`,as=`#version 300 es
550
614
  precision highp float;
551
615
  in vec2 vUv;
552
616
  uniform sampler2D uPano;
@@ -555,4 +619,4 @@ out vec4 fragColor;
555
619
  void main() {
556
620
  vec3 rgb = texture(uPano, vUv).rgb;
557
621
  fragColor = vec4(rgb, uOpacity);
558
- }`;function Dr(t,e){let{position:n,uv:i,index:o}=$a(),r=new Ya(t,{position:{size:3,data:n},uv:{size:2,data:i},index:{data:o}}),a=new qa(t,{image:e,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,generateMipmaps:!0,flipY:!1}),s=new ja(t,{vertex:Ja,fragment:es,uniforms:{uPano:{value:a},uOpacity:{value:0}},transparent:!0,depthTest:!1,depthWrite:!1}),l=new Wa(t,{geometry:r,program:s});return{mesh:l,setOpacity(c){s.uniforms.uOpacity.value=Math.max(0,Math.min(1,c))},setImage(c){a.image=c,a.needsUpdate=!0},dispose(){l.setParent(null),r.remove(),a.texture&&t.deleteTexture(a.texture),s.remove()}}}var kr=.15;async function Lr(t,e,n,i={}){let o=i.fadeMs??400,r=e?.initialBearingDeg??0,a=Math.max(-Ce,Math.min(Ce,e?.initialPitchDeg??0)),s=Gn,l=!1,c=new AbortController,h=()=>c.abort();i.signal?.addEventListener("abort",h,{once:!0});let m=()=>{},d=[n.camera.position.x,n.camera.position.y,n.camera.position.z];if(!e&&n.cameraOriginWorld&&n.camera.position.set(n.cameraOriginWorld[0],n.cameraOriginWorld[1],n.cameraOriginWorld[2]),!e&&n.focalWorld){let A=n.camera.position,D=n.focalWorld[0]-A.x,V=n.focalWorld[1]-A.y,U=n.focalWorld[2]-A.z,Y=Math.hypot(D,U);Y>.001&&(r=Math.atan2(D,-U)*180/Math.PI,a=Math.max(-Ce,Math.min(Ce,Math.atan2(V,Y)*180/Math.PI)))}let p=null;if(e){let A=n.gl.getParameter(n.gl.MAX_TEXTURE_SIZE),D=_n(e,Ln(A)),V;try{let U=e.resolveUrl?await e.resolveUrl(D.initialUrl):D.initialUrl;if(!U)throw new Error("panorama_asset_unavailable");V=await Kt(U,c.signal)}catch{return i.signal?.removeEventListener("abort",h),null}try{p=Dr(n.gl,V)}catch{return c.abort(),i.signal?.removeEventListener("abort",h),null}p.mesh.renderOrder=999,p.mesh.setParent(n.scene),D.upgradeUrl&&(m=On(()=>{(e.resolveUrl?e.resolveUrl(D.upgradeUrl):Promise.resolve(D.upgradeUrl)).then(Y=>!Y||c.signal.aborted?null:Kt(Y,c.signal)).then(Y=>{Y&&(l||c.signal.aborted||(p?.setImage(Y),n.requestRender()))}).catch(()=>{})}))}let f=n.camera.fov;n.camera.perspective({fov:s,aspect:n.camera.aspect});let u=n.camera.quaternion.slice(),b=()=>{let A=n.camera.position;p?.mesh.position.set(A.x,A.y,A.z);let[D,V,U]=Er(r,a);n.camera.lookAt([A.x+D,A.y+V,A.z+U]),n.requestRender()};b();let y=document.createElement("div"),x=document.activeElement instanceof HTMLElement?document.activeElement:null;y.setAttribute("role","dialog"),y.setAttribute("aria-modal","true"),y.setAttribute("aria-label",i.seatLabel?`View from ${i.seatLabel}`:"View from seat"),y.tabIndex=-1,Object.assign(y.style,{position:"absolute",inset:"0",zIndex:"10",cursor:"grab",touchAction:"none"});let v=document.createElement("button");if(v.type="button",v.setAttribute("aria-label","Close"),v.textContent="\u2715",Object.assign(v.style,{position:"absolute",top:"12px",right:"12px",zIndex:"2",width:"44px",height:"44px",borderRadius:"999px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.25)",background:"rgba(8,12,18,0.6)",color:"#e6edf3",fontSize:"15px",lineHeight:"1"}),y.appendChild(v),i.disclosure){let A=document.createElement("div");A.textContent=`${i.disclosurePrefix??"360\xB0 panorama"} \xB7 ${i.disclosure}`,Object.assign(A.style,{position:"absolute",top:"12px",left:"12px",zIndex:"2",maxWidth:"calc(100% - 88px)",padding:"8px 11px",borderRadius:"999px",overflow:"hidden",color:"#dce6f8",background:"rgba(8,12,18,0.68)",font:"600 11px/1.2 ui-sans-serif, system-ui, sans-serif",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",backdropFilter:"blur(6px)"}),y.appendChild(A)}let k=document.createElement("div");k.textContent="Drag to look \xB7 pinch or scroll to zoom \xB7 Esc to close",Object.assign(k.style,{position:"absolute",bottom:"12px",left:"0",right:"0",textAlign:"center",color:"rgba(230,237,243,0.7)",font:"12px ui-sans-serif, system-ui, sans-serif",pointerEvents:"none"}),y.appendChild(k),t.appendChild(y),v.focus({preventScroll:!0});let P=!1,M=0,F=0,O=0,L=new Map,H=()=>{let[A,D]=[...L.values()];return A&&D?Math.hypot(A.x-D.x,A.y-D.y):0},_=A=>{let D=Hn(A);D!==s&&(s=D,n.camera.perspective({fov:s,aspect:n.camera.aspect}),b())},g=A=>{A.target!==v&&(L.set(A.pointerId,{x:A.clientX,y:A.clientY}),P=L.size===1,M=A.clientX,F=A.clientY,L.size===2&&(O=H()),y.setPointerCapture?.(A.pointerId),y.style.cursor="grabbing")},w=A=>{if(L.has(A.pointerId)){if(L.set(A.pointerId,{x:A.clientX,y:A.clientY}),L.size>=2){let D=H();O>0&&D>0&&_(s*(O/D)),O=D,P=!1;return}P&&(r+=(A.clientX-M)*kr,a=Math.max(-Ce,Math.min(Ce,a+(A.clientY-F)*kr)),M=A.clientX,F=A.clientY,b())}},E=A=>{L.delete(A.pointerId),O=L.size===2?H():0;let D=L.values().next().value;P=L.size===1,D?(M=D.x,F=D.y):y.style.cursor="grab";try{y.releasePointerCapture?.(A.pointerId)}catch{}},C=A=>{A.preventDefault(),_(s+A.deltaY*.04)};y.addEventListener("pointerdown",g),y.addEventListener("pointermove",w),y.addEventListener("pointerup",E),y.addEventListener("pointercancel",E),y.addEventListener("wheel",C,{passive:!1});let N=A=>{if(!l){if(A.key==="Tab"){A.preventDefault(),v.focus({preventScroll:!0});return}if(A.key==="Escape"){A.stopPropagation(),B.close();return}if(A.key==="ArrowLeft"||A.key==="ArrowRight")r+=A.key==="ArrowLeft"?-4:4;else if(A.key==="ArrowUp"||A.key==="ArrowDown")a=Math.max(-Ce,Math.min(Ce,a+(A.key==="ArrowUp"?4:-4)));else if(A.key==="+"||A.key==="="){_(s-5),A.preventDefault();return}else if(A.key==="-"){_(s+5),A.preventDefault();return}else return;A.preventDefault(),b()}};window.addEventListener("keydown",N);let S=0,I=(A,D)=>{if(!p){D?.();return}let V=A===1?0:1,U=performance.now(),Y=()=>{if(l)return;let X=o<=0?1:Math.min(1,(performance.now()-U)/o);p?.setOpacity(V+(A-V)*X),n.requestRender(),X<1?S=requestAnimationFrame(Y):D?.()};S=requestAnimationFrame(Y)};I(1);let T=()=>{l||(l=!0,m(),c.abort(),i.signal?.removeEventListener("abort",h),cancelAnimationFrame(S),y.removeEventListener("pointerdown",g),y.removeEventListener("pointermove",w),y.removeEventListener("pointerup",E),y.removeEventListener("pointercancel",E),y.removeEventListener("wheel",C),window.removeEventListener("keydown",N),y.remove(),x?.isConnected&&x.focus({preventScroll:!0}),p?.dispose(),n.camera.position.set(d[0],d[1],d[2]),n.camera.perspective({fov:f,aspect:n.camera.aspect}),n.camera.quaternion.set(u[0],u[1],u[2],u[3]),n.requestRender())},B={close(){if(l)return;let A=()=>{T(),i.onClose?.()};cancelAnimationFrame(S),I(0,A)},dispose:T};return v.addEventListener("click",()=>B.close()),B}function _r(t){let{container:e,model:n,opts:i,analytics:o,orbit:r,loop:a,seatsById:s,ensureSeatView:l,resolvedSeatViewPose:c,gpu:h,gl:m,isContextLost:d,isDisposed:p,flightGen:f,setPanorama:u,getLoadAbort:b,setLoadAbort:y,setPanoramaSphereVisible:x,setFrozen:v,raisePanoramaLayer:k,restorePanoramaLayer:P,getOverviewChip:M,labelOverlay:F,reducedMotion:O,removeArriveChip:L,showArriveChip:H}=t;return async(_,g,w)=>{b()?.abort();let E=new AbortController;y(E);let C=n.seats.idToIndex.get(_);if(C===void 0){r.syncFromCamera();return}let N=s.get(_)?.label??_,S=c(_,C),I=l(_);if(!I){E.abort(),b()===E&&y(null),r.syncFromCamera();return}v(!0),a.stop();let T;try{T=await I}catch{if(b()===E&&y(null),o.panoramaFailed(_,"source"),!p()&&w===f()){v(!1),r.resumeAfterFlight(S.focal),a.requestRender();let j=H(_,w,!0);requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus())}return}if(p()||w!==f()){E.abort(),b()===E&&y(null);return}L();let B=M(),A=()=>{E.abort(),b()===E&&y(null),u(null),x(!1),P(),B.style.display="",F.setVisible(!i.arriveAtSeatEye),v(!1),o.panoramaClosed(),r.resumeAfterFlight(S.focal),a.requestRender();let j=H(_,f());requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus())},D=T.generated===!0,V=zn(T);k(),x(!D),B.style.display="none";let U=O()?0:g,Y=h(),X=Y&&!d()?await Lr(e,D?null:T,{gl:m,scene:Y.main,camera:r.camera,requestRender:()=>a.requestRender(),cameraOriginWorld:D?S.eye:void 0,focalWorld:S.focal},{fadeMs:U,seatLabel:N,disclosure:V,disclosurePrefix:D?"Live seat-eye view":"360\xB0 panorama",onClose:A,signal:E.signal}):null;if(p()||w!==f()){E.abort(),x(!1),b()===E&&y(null),X?.dispose(),B.style.display="",P();return}if(X)r.syncFromCamera(),F.setVisible(!1),v(!1),a.requestRender(),u(X);else if(D){P(),B.style.display="",v(!1),r.resumeAfterFlight(S.focal),a.requestRender(),u(null),x(!1),o.panoramaFailed(_,"mount");let j=H(_,f(),!0);requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus()),b()===E&&y(null);return}else x(!1),o.panoramaFallback(_),u(Un(e,T,{fadeMs:U,seatLabel:N,disclosure:V,onClose:A,signal:E.signal}));o.panoramaOpened()}}var Or=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),Ut=class{constructor(e){this.orbitLatched=!1;this.panoramaOpenedAt=0;this.cb=e}emit(e,n){if(this.cb)try{this.cb(e,n)}catch{}}opened(e,n,i,o){this.emit("3d_opened",{seats:e,hasHeights:n,...i===void 0?{}:{buildMs:Math.round(i)},...o===void 0?{}:{prepSource:o}})}orbitEngaged(){this.orbitLatched||(this.orbitLatched=!0,this.emit("3d_orbit_engaged"))}seatPicked(e,n){this.emit("3d_seat_picked",{seatId:e,sectionId:n})}cinematicPlayed(e){this.emit("3d_cinematic_played",{durationMs:e,reducedMotion:!1})}cinematicSkipped(){this.emit("3d_cinematic_skipped",{reducedMotion:!0})}cinematicCancelled(){this.emit("3d_cinematic_cancelled")}panoramaOpened(){this.panoramaOpenedAt=Or(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(Or()-this.panoramaOpenedAt):0;this.panoramaOpenedAt=0,this.emit("3d_panorama_closed",{viewMs:e})}panoramaFailed(e,n){this.emit("3d_panorama_failed",{seatId:e,phase:n})}panoramaFallback(e){this.emit("3d_panorama_fallback",{seatId:e})}contextLost(){this.emit("3d_context_lost")}contextRestored(){this.emit("3d_context_restored")}};function Br(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function Vr(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:a}=t,s=null,l=()=>{if(!s)return;let m=a();Object.assign(s.style,m?{left:"12px",right:"12px",bottom:"70px",transform:"none",justifyContent:"center"}:{left:"50%",right:"auto",bottom:"18px",transform:"translateX(-50%)",justifyContent:"initial"})},c=()=>{s?.remove(),s=null};return{show:(m,d,p=!1)=>{if(c(),t.isDisposed())return null;let f=document.createElement("div");f.setAttribute("role","group"),Object.assign(f.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let u=o.get(m),b=u?.sectionId?n.sections.find(O=>O.id===u.sectionId):void 0,y=u?.label??m;f.setAttribute("aria-label",`Explore views near ${b?.label?`${b.label}, `:""}seat ${y}`);let x=document.createElement("span");x.textContent=["Live 3D seat view",b?.label,y].filter(Boolean).join(" \xB7 "),Object.assign(x.style,{maxWidth:"min(320px, calc(100vw - 32px))",padding:"5px 10px",borderRadius:"999px",overflow:"hidden",color:"#d9e3f5",background:"rgba(12,18,32,0.72)",font:"600 11px/1.2 inherit",textOverflow:"ellipsis",whiteSpace:"nowrap",backdropFilter:"blur(6px)"}),f.appendChild(x);let v=document.createElement("div");Object.assign(v.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),f.appendChild(v);let k=u?.rowId?r.get(u.rowId):void 0,P=k?.indexOf(m)??-1,M=P>=0?[k?.[P-1],k?.[P+1]]:[void 0,void 0],F=(O,L,H,_=!1)=>{let g=document.createElement("button");g.type="button",g.textContent=O,g.setAttribute("aria-label",L),Object.assign(g.style,{minHeight:"44px",padding:_?"10px 16px":"10px",borderRadius:"999px",background:"rgba(12,18,32,0.78)",color:"#eef1f8",border:"1px solid rgba(150,165,205,0.4)",backdropFilter:"blur(6px)",font:"600 13px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"}),_||(g.style.minWidth="44px"),_&&(g.dataset.panoramaTrigger=""),g.addEventListener("click",H),v.appendChild(g)};if(M[0]){let O=o.get(M[0])?.label??M[0];F("\u2039",`View previous seat ${O}`,()=>{t.flyToSeat(M[0])})}if(i.getSeatView){let O=i.seatViewActionLabel?.(m)??"Open 360\xB0 panorama";F(p?`\u21BB Retry ${O}`:`\u25C9 ${O}`,`${p?"Retry":O} from seat ${y}`,()=>{if(t.isDisposed()||d!==t.flightGen()){c();return}c(),t.openPanorama(m,400,d)},!0)}if(M[1]){let O=o.get(M[1])?.label??M[1];F("\u203A",`View next seat ${O}`,()=>{t.flyToSeat(M[1])})}return v.childElementCount?(e.appendChild(f),s=f,l(),f):null},remove:c,layout:l}}function Nr(t){let{container:e,orbit:n,isNarrow:i}=t,o=document.createElement("div"),r=!1;o.className="sl-3d-navigation-controls",Object.assign(o.style,{position:"absolute",right:"14px",bottom:"14px",display:"flex",zIndex:"4",flexDirection:"column",alignItems:"flex-end",gap:"7px"});let a=document.createElement("div");a.setAttribute("role","group"),a.setAttribute("aria-label","3D drag mode"),Object.assign(a.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let s=document.createElement("div");s.setAttribute("role","group"),s.setAttribute("aria-label","3D view controls"),Object.assign(s.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let l=document.createElement("button");l.type="button",l.textContent="\u21BB",l.setAttribute("aria-label","Drag to rotate the 3D venue"),l.dataset.tooltip="Rotate venue";let c=document.createElement("button");c.type="button",c.textContent="\u2725",c.setAttribute("aria-label","Drag to move the 3D venue left, right, up or down"),c.dataset.tooltip="Move venue";let h=document.createElement("button");h.type="button",h.textContent="\u2212",h.setAttribute("aria-label","Zoom out of the 3D venue"),h.dataset.tooltip="Zoom out";let m=document.createElement("button");m.type="button",m.textContent="+",m.setAttribute("aria-label","Zoom into the 3D venue"),m.dataset.tooltip="Zoom in";for(let u of[l,c,h,m])u.className="sl-3d-icon-control",Object.assign(u.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",border:"1px solid rgba(150,165,205,0.35)",borderRadius:"999px",color:"#c9d4ea",background:"rgba(12,18,32,0.82)",font:"600 17px/1 inherit",backdropFilter:"blur(6px)",cursor:"pointer",whiteSpace:"nowrap"});a.append(l,c),s.append(m,h);let d=u=>{n.setPrimaryDragMode(u);let b=u==="orbit";l.setAttribute("aria-pressed",String(b)),c.setAttribute("aria-pressed",String(!b)),l.style.background=b?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",c.style.background=b?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=b?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};l.addEventListener("click",()=>d("orbit")),c.addEventListener("click",()=>d("pan")),h.addEventListener("click",()=>n.zoomBy(1.22)),m.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),d("orbit"),e.appendChild(o);let p=()=>{let u=i();o.style.display=r?"none":"flex",o.style.right=u?"12px":"14px",o.style.bottom=u?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",a.style.display=u?"none":"flex",m.style.display=u?"none":"",h.style.display=u?"none":""};return p(),{element:o,utilityControls:s,setNavigationMode:d,setSeatViewLocked:u=>{r=u,n.setInteractionEnabled(!u),p()},seatViewLocked:()=>r,layout:p}}function zr(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:a,analytics:s,seatIdByIndex:l,sectionIdBySeatId:c,tapSlop:h,tapMs:m,cancelFlight:d,focusSectionCamera:p,setSelection:f,ensureSeatView:u}=t,b=0,y=0,x=0,v=-1,k=!1,P=!1,M=_=>{t.seatViewLocked()||v===-1&&(v=_.pointerId,b=_.clientX,y=_.clientY,x=performance.now(),k=!1,P=a.active,a.active&&(s.cinematicCancelled(),d(),r.onViewTargetChange?.(null)))},F=_=>{_.pointerId===v&&Math.hypot(_.clientX-b,_.clientY-y)>h&&(k=!0)},O=(_,g,w,E,C)=>{let N=e.canvas.getBoundingClientRect(),S=e.canvas.clientWidth||N.width||1,I=e.canvas.clientHeight||N.height||1,T=_-N.left,B=g-N.top,A=E*E,D=-1,V=A,U=1/0;for(let Y of o){if(w&&Y.sectionId!==w)continue;let X=i.seats.idToIndex.get(Y.id);if(X===void 0)continue;if(C){let ae=Math.round(i.seats.iState[X]??0);if(ae!==0&&ae!==3)continue}let j=X*3,K=Oe(n.camera.projectionViewMatrix,[i.seats.iPosition[j],i.seats.iPosition[j+1]+.55,i.seats.iPosition[j+2]],S,I);if(!K.visible)continue;let te=K.x-T,ne=K.y-B,Q=te*te+ne*ne;(Q<V||Math.abs(Q-V)<1&&K.depth<U)&&(D=X,V=Q,U=K.depth)}return D},L=(_,g)=>{let w=t.gpu(),E=t.pick();if(!w||!E)return-1;E.syncFromSeatProgram(w.seatProgram);let C=e.canvas.getBoundingClientRect(),N=e.renderer.dpr,{x:S,y:I}=Mr(_,g,C,N,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),T=Math.max(2,Math.round(8*N));return E.pick(n.camera,S,I,T)};return{onDown:M,onMove:F,onUp:_=>{if(_.pointerId!==v)return;let g=!k&&performance.now()-x<m;if(v=-1,P){P=!1;return}let w=t.gpu(),E=t.pick();if(!g||!w||!E)return;let C=L(_.clientX,_.clientY);if(t.focusedSectionId()&&C>=0){let I=l[C],T=I?c.get(I):void 0;if(T&&T!==t.focusedSectionId()&&p(T))return}if(t.focusedSectionId()&&C<0&&(C=O(_.clientX,_.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&C<0){let I=O(_.clientX,_.clientY,null,72,!1),T=I>=0?l[I]:void 0,B=T?c.get(T):void 0;if(B&&B!==t.focusedSectionId()&&p(B))return}if(!t.focusedSectionId()){C<0&&(C=O(_.clientX,_.clientY,null,42,!1));let I=C>=0?l[C]:void 0,T=I?c.get(I):void 0;if(T&&p(T))return}if(C<0||C>=l.length){t.selection().size&&(f([]),r.onViewTargetChange?.(null));return}let N=l[C],S=be[Math.round(i.seats.iState[C]??0)]??"available";if(S!=="available"&&S!=="selected"){r.onSeatInspect?.(N,S);return}if(t.selection().has(N)&&t.selection().size===1){f([]),r.onViewTargetChange?.(null);return}f([N]),u(N),s.seatPicked(N,c.get(N)),r.onSeatPick?.(N)}}}var Xt=class{constructor(e,n){this.minX=0;this.minZ=0;this.cell=1;this.cols=1;this.rows=1;this.cellStart=null;this.cellItems=null;this.iPosition=e,this.count=n}ensureGrid(){if(this.cellStart||this.count===0)return;let e=this.iPosition,n=1/0,i=1/0,o=-1/0,r=-1/0;for(let p=0;p<this.count;p++){let f=e[p*3],u=e[p*3+2];f<n&&(n=f),f>o&&(o=f),u<i&&(i=u),u>r&&(r=u)}let a=Math.max(o-n,.001),s=Math.max(r-i,.001);this.cell=Math.max(Math.sqrt(a*s*4/this.count),.25),this.cols=Math.max(1,Math.ceil(a/this.cell)+1),this.rows=Math.max(1,Math.ceil(s/this.cell)+1),this.minX=n,this.minZ=i;let l=this.cols*this.rows,c=new Int32Array(l+1),h=p=>{let f=Math.min(this.cols-1,Math.max(0,Math.floor((e[p*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[p*3+2]-i)/this.cell)))*this.cols+f};for(let p=0;p<this.count;p++)c[h(p)+1]++;for(let p=0;p<l;p++)c[p+1]+=c[p];let m=new Int32Array(this.count),d=c.slice(0,l);for(let p=0;p<this.count;p++)m[d[h(p)]++]=p;this.cellStart=c,this.cellItems=m}gather(e,n,i,o){this.ensureGrid();let r=this.cellStart,a=this.cellItems;if(!r||!a)return 0;let s=o.length,l=i*i,c=Math.floor((e-this.minX)/this.cell),h=Math.floor((n-this.minZ)/this.cell),m=Math.ceil(i/this.cell)+1,d=this.iPosition,p=0;for(let f=0;f<=m&&p<s;f++){let u=h-f,b=h+f,y=c-f,x=c+f;for(let v=u;v<=b&&p<s;v++){if(v<0||v>=this.rows)continue;let k=v===u||v===b;for(let P=y;P<=x&&p<s;P++){if(!k&&P!==y&&P!==x){P=x-1;continue}if(P<0||P>=this.cols)continue;let M=v*this.cols+P;for(let F=r[M],O=r[M+1];F<O&&p<s;F++){let L=a[F],H=d[L*3]-e,_=d[L*3+2]-n;H*H+_*_<=l&&(o[p++]=L)}}}}return p}};var Yt=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(It);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new Xt(e.model.seats.iPosition,e.model.seats.count)}forceRegather(){this.lastGatherX=1/0}setDetailEnabled(e){let n=this.ctx.gpu();e||(this.detailVisible=!1),this.lastGatherX=1/0,this.lastGatherZ=1/0,!e&&n?.nearSeatCount()&&n.setNearSeats(this.nearBuf,0)}update(e){let{model:n}=this.ctx,i=this.ctx.gpu();if(!i)return;if(!e){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let o=this.ctx.orbit().camera.position;if(Math.hypot(o.x-this.lastGatherX,o.z-this.lastGatherZ)<tn)return;if(this.lastGatherX=o.x,this.lastGatherZ=o.z,Math.hypot(o.x-n.bounds.center[0],o.z-n.bounds.center[2])-n.bounds.radius>en){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,en,this.nearBuf);s===0&&i.nearSeatCount()===0||i.setNearSeats(this.nearBuf,s)}ease(e,n,i){let o=1-Math.exp(-e*9),r=1-Math.exp(-e*20);this.seatDetailMix+=(n-this.seatDetailMix)*(n>this.seatDetailMix?o:r),this.structureDetailMix+=(i-this.structureDetailMix)*(i>this.structureDetailMix?o:r),Math.abs(n-this.seatDetailMix)<.01&&(this.seatDetailMix=n),Math.abs(i-this.structureDetailMix)<.01&&(this.structureDetailMix=i)}};import{Quat as ts,Vec3 as ns}from"ogl";function Gr(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:a,loop:s,labelOverlay:l,stageAzimuth:c,overviewFraming:h}=t,m=0,d=-1,p=(P,M,F=28)=>{o.camera.position.set(P[0],P[1],P[2]),o.camera.lookAt(new ns(M[0],M[1],M[2])),o.camera.fov=F,o.camera.updateProjectionMatrix()},f=document.createElement("button");f.className="sl-3d-overview-control sl-3d-icon-control",f.type="button",f.textContent="\u2302",f.setAttribute("aria-label","Fit the active level or whole venue in view"),f.dataset.tooltip="Fit view",Object.assign(f.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",borderRadius:"999px",background:"rgba(12,18,32,0.72)",color:"#c9d4ea",border:"1px solid rgba(150,165,205,0.35)",backdropFilter:"blur(6px)",font:"600 11px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"});let u=()=>{f.textContent="\u2302"};u();let b=P=>{d=P;let M=t.gpu();M&&(M.seatProgram.uniforms.uFocusFloor.value=P,M.solidProgram.uniforms.uFocusFloor.value=P,M.chairProgram.uniforms.uFocusFloor.value=P),t.showSectionSeatLabels(null)},y=()=>{if(t.isDisposed())return;i.onViewTargetChange?.(null),i.onSectionFocusChange?.(null),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),a.panoramaClosed()),t.setPanoramaSphereVisible(!1),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.restorePanoramaLayer(),f.style.display="",l.setVisible(!0),t.setFrozen(!1);let P=d>=0?n.floors[d]:null;if(t.setNearFieldDetailEnabled(!!P),t.setSeatViewLocked(!1),x(),t.removeArriveChip(),t.setNavigationMode("orbit"),P){let M=P.focalWorld[0]-P.center[0],F=P.focalWorld[2]-P.center[2],O=Math.hypot(M,F)>P.radius*.12?Math.atan2(M,F):c,L={center:P.center,radius:P.radius,box:P.box},H={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(L,!1,O,!1,H):o.frameSoft(L,O,!1,H)}else t.reducedMotion()?o.frame(n.bounds,!1,c,i.portraitOverviewCrop===!0,h):o.frameSoft(n.bounds,c,i.portraitOverviewCrop===!0,h);t.showSectionSeatLabels(null),s.requestRender()},x=()=>{m++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},v=P=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let M=n.seats.idToIndex.get(P);if(M===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(P),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),t.setPanoramaSphereVisible(!1),f.style.display="",t.restorePanoramaLayer()),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.setFrozen(!1),t.setSeatViewLocked(!1);let F=++m;t.removeArriveChip();let{eye:O,focal:L}=t.resolvedSeatViewPose(P,M),H=[o.camera.position.x,o.camera.position.y,o.camera.position.z],_=Mn(H,O,L,n.bounds.center,n.bounds.radius),g=i.arriveAtSeatEye?O:_.finalPos,w=i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,E=[_.waypoints[0],_.waypoints[1],g];if(l.setVisible(!1),t.reducedMotion())return p(g,L,w),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),t.showArriveChip(P,F),Promise.resolve();let C=new ts().copy(o.camera.quaternion),N=Tr(o.camera,g,L);return s.requestRender(),r.start(E,C,N,2500,w).then(()=>{t.isDisposed()||F!==m||(a.cinematicPlayed(2500),o.resumeAfterFlight(L),t.setSeatViewLocked(i.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(P,F))})},k=P=>{let M=n.sections.find(H=>H.id===P);if(!M||M.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&d!==M.floorIndex&&b(M.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(P);let F=M.focalWorld[0]-M.center[0],O=M.focalWorld[2]-M.center[2],L=Math.hypot(F,O)>M.radius*.12?Math.atan2(F,O):void 0;return o.frame({center:M.center,radius:Math.max(5,M.radius*.5)},!1,L),i.onSectionFocusChange?.(P),s.requestRender(),!0};return f.addEventListener("click",y),{overviewChip:f,layoutOverviewChip:u,flightGen:()=>m,focusedFloor:()=>d,applyFloorFocus:b,placeCameraFinal:p,cancelFlight:x,focusOverview:y,flyToSeat:v,focusSectionCamera:k}}function Hr(t){let e=performance.now();return{model:yt(t),buildMs:performance.now()-e,source:"main"}}function os(t){return typeof Worker>"u"?Promise.resolve(Hr(t)):new Promise(e=>{let n=new Worker(new URL("./scene/scene.worker.ts",import.meta.url),{type:"module"}),i=!1,o=s=>{i||(i=!0,clearTimeout(a),n.terminate(),e(s))},r=()=>o(Hr(t)),a=window.setTimeout(r,15e3);n.onerror=r,n.onmessage=s=>{o({model:s.data.model,buildMs:s.data.buildMs,source:"worker"})},n.postMessage(t)})}var rs=Math.PI/180,is=6,as=500;function Gu(t,e,n={}){let i=performance.now(),o=e.prepared?.model??yt(e),r=new Ut(n.onAnalytics),a=new Array(o.seats.count);for(let[z,G]of o.seats.idToIndex)a[G]=z;let s=new Map(e.seats.map(z=>[z.id,z])),l=new Map;for(let z of e.seats){if(!z.rowId)continue;let G=l.get(z.rowId);G?G.push(z.id):l.set(z.rowId,[z.id])}let c=new Map;for(let z of e.seats)c.set(z.id,z.sectionId);let h=e.doc.floors?.some(G=>(G.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(G=>G.objects)??e.doc.objects).some(G=>G.type==="section"&&((G.height??0)>0||(G.rake??0)>0)),m=null,d=null,p=!1,f=!1,u=!1,b=new Map,y=null,x=null,v=null,k=new Map,P=null,M=()=>{v===null&&(v=t.style.zIndex,t.style.zIndex="20")},F=()=>{v!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=v),v=null)},O=!1,L=()=>O?me.focusedFloor():-1,H=()=>{m=gr(E.gl,o),d=new Gt(E.renderer,m.seatGeometry,m.chairGeometry,m.solidGeometry,o.seats.count),E.setClearColor(o.theme.background.top),d.setRestoreClear(o.theme.background.top),m.seatProgram.uniforms.uSeatRadius.value=Re*o.theme.seatScale,m.seatProgram.uniforms.uFocusFloor.value=L(),m.solidProgram.uniforms.uFocusFloor.value=L(),m.chairProgram.uniforms.uFocusFloor.value=L(),g.forceRegather()},_=!1,g=new Yt({model:o,orbit:()=>C,gpu:()=>m}),w=z=>g.setDetailEnabled(z),E=new At(t,{onContextLost:()=>{u||r.contextLost(),p=!0,j.stop(),m=null,d=null},onContextRestored:()=>{H(),p=!1,u||r.contextRestored(),j.requestRender()}}),C=new Ct(E.gl,E.canvas,()=>j.requestRender(),()=>r.orbitEngaged());C.setAspect(E.aspect);let N=(e.doc.floors?.flatMap(z=>z.objects)??e.doc.objects).some(z=>z.type==="section"&&z.physical3dProvenance?.surfaceKind?.status==="inferred"),S=(()=>{if(N&&o.stages.length===0)return;let z=o.focalWorld[0]-o.bounds.center[0],G=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(z,G)>o.bounds.radius*.12?Math.atan2(z,G):void 0})(),I=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,T=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;C.frame(o.bounds,!T&&n.skipInitialOverviewAnimation!==!0,S,n.portraitOverviewCrop===!0,I);let B=new Ht(C.camera),A=Br(t),D=new Bt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),V=o.labels,U=()=>Ho(V,o.floors.length,L());D.setLabels(U());let Y=null,X=z=>{if(Y=z,D.setForcedDense(!!z),!z){D.setLabels(U());return}let G=e.seats.filter(q=>q.sectionId===z),W=new Set(G.map(q=>q.id)),$=new Set(G.map(q=>q.rowId)),ee=new Set(b.keys()),J=new Set(G.filter(q=>ee.has(q.id)).map(q=>q.id)),se=U().filter(q=>q.kind!=="row"&&q.kind!=="seat"||(q.kind==="row"?$.has(q.id.slice(4)):W.has(q.id.slice(5))&&(J.size===0||J.has(q.id.slice(5)))));if(o.seatCount<=6e3&&J.size===0){D.setLabels(se);return}let le=J.size?G.filter(q=>J.has(q.id)):G,ze=new Set(le.map(q=>`seat:${q.id}`)),De=le.flatMap(q=>{let de=o.seats.idToIndex.get(q.id);if(de===void 0)return[];let ge=de*3;return[{id:`seat:${q.id}`,kind:"seat",text:q.displayLabel||q.label,anchor:[o.seats.iPosition[ge],o.seats.iPosition[ge+1]+(ee.has(q.id)?1.05:.55),o.seats.iPosition[ge+2]]}]});D.setLabels([...se.filter(q=>!ze.has(q.id)),...De])};H();let j=new Rt(z=>{if(p||!m||f)return!1;let W=B.active?B.update(performance.now()):C.update(),$=L()>=0?o.floors[L()]:null,ee=$?.radius??o.bounds.radius,J=$n(C.currentDistance,ee),se=_?{center:[C.camera.position.x,C.camera.position.y,C.camera.position.z],radius:520}:o.renderBounds;C.updateClipping(se);let le=$?.center??o.renderBounds.center,ze=$?.radius??o.renderBounds.radius,De=(ve,rt)=>Math.hypot(C.camera.position.x-ve[0],C.camera.position.y-ve[1],C.camera.position.z-ve[2])<=rt*(g.detailVisible?1.8:1.55),q=De(le,ze);if(!q&&Y){let ve=o.sections.find(rt=>rt.id===Y);ve&&(q=De(ve.center,Math.max(12,ve.radius*2)))}g.detailVisible=q;let de=m.seatProgram.uniforms;de.uSeatScale.value=J.scale,de.uSeatFade.value=J.fade;let ge=!!$&&Jn($.seatCount,E.canvas.clientWidth||1,E.canvas.clientHeight||1),gt=eo(o.seats.count,ee,C.currentDistance,C.camera.fov,E.canvas.clientHeight||1),ot=g.detailVisible||ge||gt?1:0,vt=g.detailVisible||L()>=0||o.floors.length>1?1:0;return g.ease(z,ot,vt),de.uSeatDetail.value=g.seatDetailMix,m.solidProgram.uniforms.uStructureDetail.value=g.structureDetailMix,de.uMinPixels.value=J.minPixels,de.uPixelToWorld.value=2*Math.tan(C.camera.fov*rs/2)/Math.max(1,E.pixelHeight),g.update(g.detailVisible),E.renderer.render({scene:m.background,clear:!0}),E.renderer.render({scene:m.main,camera:C.camera,clear:!1}),D.update(C.camera.projectionViewMatrix,E.canvas.clientWidth||1,E.canvas.clientHeight||1,C.currentDistance,ee,[C.camera.position.x,C.camera.position.y,C.camera.position.z]),W||g.seatDetailMix!==ot||g.structureDetailMix!==vt}),K=typeof ResizeObserver<"u"?new ResizeObserver(()=>jt.resize()):null;K?.observe(t);let te=z=>{let G=ee=>{let J=o.seats.idToIndex.get(ee);return J===void 0?void 0:o.seats.iState[J]},{updates:W,next:$}=wr(b,z,G);if(b=$,D.setSelectedSeatIds(b.keys()),Y&&X(Y),W.length){let ee=an(o.seats,W);m&&m.uploadSeatStateRuns(ee),j.requestRender()}},ne=()=>P!==null?P:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Q=8,ae=z=>{if(!n.getSeatView)return null;let G=k.get(z);if(!G)for(G=Promise.resolve(n.getSeatView(z)),k.set(z,G),G.catch(()=>{k.get(z)===G&&k.delete(z)});k.size>Q;){let W=k.keys().next().value;if(W===void 0)break;k.delete(W)}return G},Be=(z,G)=>{let W=s.get(z),$=Math.max(0,Math.round(o.seats.iFloor[G]??0)),ee=e.doc.floors?.[$],J=o.floors[$],se=ee?.focalPoint??e.doc.focalPoint,le=J?{x:J.focalWorld[0]/R,y:J.focalWorld[2]/R}:se,ze=W?.focalPoint?{x:W.focalPoint.x+le.x-se.x,y:W.focalPoint.y+le.y-se.y}:le,De=[o.seats.iPosition[G*3],o.seats.iPosition[G*3+1],o.seats.iPosition[G*3+2]];return Fr(De,ze,ee?.baseHeightM??0,W?.eyeHeightM)},Ve=()=>(t.clientWidth||E.canvas.clientWidth)<=520,Se,we=Vr({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:l,isNarrow:Ve,isDisposed:()=>u,flightGen:()=>me.flightGen(),flyToSeat:z=>Pn(z),openPanorama:(z,G,W)=>Se(z,G,W)}),Pe=we.show,ye=we.remove,xe=we.layout,oe=Nr({container:t,orbit:C,isNarrow:Ve}),qe=oe.element,Fe=oe.setNavigationMode,Ae=oe.setSeatViewLocked,Ne=oe.layout,nt=oe.utilityControls,me=Gr({container:t,model:o,opts:n,orbit:C,cinematic:B,analytics:r,loop:j,labelOverlay:D,stageAzimuth:S,overviewFraming:I,gpu:()=>m,isDisposed:()=>u,panorama:()=>y,setPanorama:z=>{y=z},setPanoramaSphereVisible:z=>{_=z},panoramaLoadAbort:()=>x,setPanoramaLoadAbort:z=>{x=z},setFrozen:z=>{f=z},restorePanoramaLayer:F,reducedMotion:ne,resolvedSeatViewPose:Be,showSectionSeatLabels:X,setNearFieldDetailEnabled:w,setSeatViewLocked:Ae,setNavigationMode:Fe,showArriveChip:Pe,removeArriveChip:ye});O=!0;let Wt=me.overviewChip,Ur=me.layoutOverviewChip,Xr=me.applyFloorFocus,Yr=me.focusOverview,wn=me.cancelFlight,Pn=me.flyToSeat,An=me.focusSectionCamera;nt.appendChild(Wt),Se=_r({container:t,model:o,opts:n,analytics:r,orbit:C,loop:j,seatsById:s,ensureSeatView:ae,resolvedSeatViewPose:Be,gpu:()=>m,gl:E.gl,isContextLost:()=>p,isDisposed:()=>u,flightGen:()=>me.flightGen(),setPanorama:z=>{y=z},getLoadAbort:()=>x,setLoadAbort:z=>{x=z},setPanoramaSphereVisible:z=>{_=z},setFrozen:z=>{f=z},raisePanoramaLayer:M,restorePanoramaLayer:F,getOverviewChip:()=>Wt,labelOverlay:D,reducedMotion:ne,removeArriveChip:ye,showArriveChip:Pe});let Ee=zr({glctx:E,orbit:C,model:o,seats:e.seats,opts:n,cinematic:B,analytics:r,seatIdByIndex:a,sectionIdBySeatId:c,tapSlop:is,tapMs:as,gpu:()=>m,pick:()=>d,seatViewLocked:()=>oe.seatViewLocked(),focusedSectionId:()=>Y,selection:()=>b,cancelFlight:wn,focusSectionCamera:An,setSelection:te,ensureSeatView:ae});E.canvas.addEventListener("pointerdown",Ee.onDown),E.canvas.addEventListener("pointermove",Ee.onMove),E.canvas.addEventListener("pointerup",Ee.onUp),E.canvas.addEventListener("pointercancel",Ee.onUp),j.requestRender();let jt={setAvailability(z){let G=Sr(b,z),W=an(o.seats,G);W.length&&m&&m.uploadSeatStateRuns(W),j.requestRender()},setSelection:te,flyToSeat:Pn,focusOverview:Yr,resize(){let{width:z,height:G}=E.resize();C.setAspect(z/Math.max(1,G)),xe(),Ne(),Ur(),j.requestRender()},stats(){return{...j.stats(),drawCalls:m?m.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let z=j.stats(),G=E.canvas.clientWidth||1,W=E.canvas.clientHeight||1,$=o.bounds.center,ee=Oe(C.camera.projectionViewMatrix,[$[0],o.bounds.box.min[1],$[2]],G,W),J=Oe(C.camera.projectionViewMatrix,[$[0],o.bounds.box.max[1],$[2]],G,W),se=o.bounds.box,le=[se.min[0],se.max[0]].flatMap(q=>[se.min[1],se.max[1]].flatMap(de=>[se.min[2],se.max[2]].map(ge=>Oe(C.camera.projectionViewMatrix,[q,de,ge],G,W)))).filter(q=>Number.isFinite(q.x)&&Number.isFinite(q.y)&&Number.isFinite(q.depth)),ze=le.length?(()=>{let q=Math.min(...le.map(Ge=>Ge.x)),de=Math.max(...le.map(Ge=>Ge.x)),ge=Math.min(...le.map(Ge=>Ge.y)),gt=Math.max(...le.map(Ge=>Ge.y)),ot=Math.max(0,q),vt=Math.min(G,de),ve=Math.max(0,ge),rt=Math.min(W,gt),Mt=Math.max(0,vt-ot),qt=Math.max(0,rt-ve);return{box:{x:ot,y:ve,width:Mt,height:qt},horizontalFillRatio:Mt/G,verticalFillRatio:qt/W,visibleAreaRatio:Mt*qt/(G*W),clippedEdges:[...ge<0?["top"]:[],...de>G?["right"]:[],...gt>W?["bottom"]:[],...q<0?["left"]:[]]}})():void 0,De=String(E.gl.getParameter(E.gl.VERSION)??"");return{viewport:{width:G,height:W},context:{webgl2:/webgl\s*2/i.test(De),lost:p},frame:{rendered:z.rendered,idle:z.idle},camera:{position:[C.camera.position.x,C.camera.position.y,C.camera.position.z],distance:C.currentDistance,verticalFovDeg:C.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:h,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:ee.visible&&J.visible?Math.abs(ee.y-J.y):0},labels:D.qualityEvidence(),framing:ze}},getQualityReport(){return bn(jt.getQualityEvidence())},loseContextForTest(){E.simulateContextLossCycle()},floors(){return o.floors},focusFloor(z){if(z!==null&&!o.floors.some(W=>W.index===z))return!1;let G=z??-1;if(w(z!==null),Ae(!1),Xr(G),Fe("orbit"),z===null)B.cancel(),ne()?C.frame(o.bounds,!1,S,n.portraitOverviewCrop===!0,I):C.frameSoft(o.bounds,S,n.portraitOverviewCrop===!0,I);else{let W=o.floors[z];if(W.seatCount>0){B.cancel();let $=W.focalWorld[0]-W.center[0],ee=W.focalWorld[2]-W.center[2],J=Math.hypot($,ee)>W.radius*.12?Math.atan2($,ee):S;C.frame({center:W.center,radius:W.radius,box:W.box},!1,J,!1,{polarDeg:58,margin:1.12})}}return j.requestRender(),!0},zones(){return o.zones},focusZone(z){let G=o.zones.find(J=>J.id===z);if(!G||G.seatCount===0)return!1;w(!1),Ae(!1),B.cancel(),Fe("orbit"),X(null),n.onSectionFocusChange?.(null);let W=G.focalWorld[0]-G.center[0],$=G.focalWorld[2]-G.center[2],ee=Math.hypot(W,$)>G.radius*.12?Math.atan2(W,$):void 0;return C.frame({center:G.center,radius:G.radius*1.25},!1,ee),j.requestRender(),!0},sections(){return o.sections},focusSection(z){return An(z)},rows(z){return z?o.rows.filter(G=>G.sectionId===z):o.rows},seatsInRow(z){return e.seats.filter(G=>G.rowId===z).map(G=>({id:G.id,label:G.displayLabel||G.label}))},focusRow(z){let G=o.rows.find(W=>W.id===z);return!G||G.seatCount===0?!1:(w(!0),Ae(!1),B.cancel(),Fe("pan"),G.sectionId&&(X(G.sectionId),n.onSectionFocusChange?.(G.sectionId)),C.frame({center:G.center,radius:Math.max(2.5,G.radius*.65)}),j.requestRender(),!0)},setReducedMotionForTest(z){P=z},dispose(){u=!0,ye(),Wt.remove(),qe.remove(),wn(),j.stop(),D.dispose(),K?.disconnect(),y&&(y.dispose(),y=null),F(),A(),E.canvas.removeEventListener("pointerdown",Ee.onDown),E.canvas.removeEventListener("pointermove",Ee.onMove),E.canvas.removeEventListener("pointerup",Ee.onUp),E.canvas.removeEventListener("pointercancel",Ee.onUp),C.dispose(),d&&d.dispose(),m&&m.dispose(),m=null,d=null,E.dispose()}};return r.opened(o.seatCount,h,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),jt}export{ba as VENUE3D_QUALITY_REPORT_VERSION,yt as buildSceneModel,bn as inspectVenue3DQualityEvidence,Gu as mountVenue3D,os as prepareVenue3D};
622
+ }`;function Vr(t,e){let{position:n,uv:r,index:o}=rs(),i=new Qa(t,{position:{size:3,data:n},uv:{size:2,data:r},index:{data:o}}),a=new es(t,{image:e,wrapS:t.CLAMP_TO_EDGE,wrapT:t.CLAMP_TO_EDGE,generateMipmaps:!0,flipY:!1}),s=new Ja(t,{vertex:is,fragment:as,uniforms:{uPano:{value:a},uOpacity:{value:0}},transparent:!0,depthTest:!1,depthWrite:!1}),l=new $a(t,{geometry:i,program:s});return{mesh:l,setOpacity(c){s.uniforms.uOpacity.value=Math.max(0,Math.min(1,c))},setImage(c){a.image=c,a.needsUpdate=!0},dispose(){l.setParent(null),i.remove(),a.texture&&t.deleteTexture(a.texture),s.remove()}}}var zr=.15;async function Nr(t,e,n,r={}){let o=r.fadeMs??400,i=e?.initialBearingDeg??0,a=Math.max(-Ce,Math.min(Ce,e?.initialPitchDeg??0)),s=jn,l=!1,c=new AbortController,d=()=>c.abort();r.signal?.addEventListener("abort",d,{once:!0});let u=()=>{},m=[n.camera.position.x,n.camera.position.y,n.camera.position.z];if(!e&&n.cameraOriginWorld&&n.camera.position.set(n.cameraOriginWorld[0],n.cameraOriginWorld[1],n.cameraOriginWorld[2]),!e&&n.focalWorld){let P=n.camera.position,k=n.focalWorld[0]-P.x,O=n.focalWorld[1]-P.y,H=n.focalWorld[2]-P.z,X=Math.hypot(k,H);X>.001&&(i=Math.atan2(k,-H)*180/Math.PI,a=Math.max(-Ce,Math.min(Ce,Math.atan2(O,X)*180/Math.PI)))}let p=null;if(e){let P=n.gl.getParameter(n.gl.MAX_TEXTURE_SIZE),k=Gn(e,Nn(P)),O;try{let H=e.resolveUrl?await e.resolveUrl(k.initialUrl):k.initialUrl;if(!H)throw new Error("panorama_asset_unavailable");O=await Qt(H,c.signal)}catch{return r.signal?.removeEventListener("abort",d),null}try{p=Vr(n.gl,O)}catch{return c.abort(),r.signal?.removeEventListener("abort",d),null}p.mesh.renderOrder=999,p.mesh.setParent(n.scene),k.upgradeUrl&&(u=Hn(()=>{(e.resolveUrl?e.resolveUrl(k.upgradeUrl):Promise.resolve(k.upgradeUrl)).then(X=>!X||c.signal.aborted?null:Qt(X,c.signal)).then(X=>{X&&(l||c.signal.aborted||(p?.setImage(X),n.requestRender()))}).catch(()=>{})}))}let h=n.camera.fov;n.camera.perspective({fov:s,aspect:n.camera.aspect});let f=n.camera.quaternion.slice(),x=()=>{let P=n.camera.position;p?.mesh.position.set(P.x,P.y,P.z);let[k,O,H]=Br(i,a);n.camera.lookAt([P.x+k,P.y+O,P.z+H]),n.requestRender()};x();let b=document.createElement("div"),y=document.activeElement instanceof HTMLElement?document.activeElement:null;b.setAttribute("role","dialog"),b.setAttribute("aria-modal","true"),b.setAttribute("aria-label",r.seatLabel?`View from ${r.seatLabel}`:"View from seat"),b.tabIndex=-1,Object.assign(b.style,{position:"absolute",inset:"0",zIndex:"10",cursor:"grab",touchAction:"none"});let g=document.createElement("button");if(g.type="button",g.setAttribute("aria-label","Close"),g.textContent="\u2715",Object.assign(g.style,{position:"absolute",top:"12px",right:"12px",zIndex:"2",width:"44px",height:"44px",borderRadius:"999px",cursor:"pointer",border:"1px solid rgba(255,255,255,0.25)",background:"rgba(8,12,18,0.6)",color:"#e6edf3",fontSize:"15px",lineHeight:"1"}),b.appendChild(g),r.disclosure){let P=document.createElement("div");P.textContent=`${r.disclosurePrefix??"360\xB0 panorama"} \xB7 ${r.disclosure}`,Object.assign(P.style,{position:"absolute",top:"12px",left:"12px",zIndex:"2",maxWidth:"calc(100% - 88px)",padding:"8px 11px",borderRadius:"999px",overflow:"hidden",color:"#dce6f8",background:"rgba(8,12,18,0.68)",font:"600 11px/1.2 ui-sans-serif, system-ui, sans-serif",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",backdropFilter:"blur(6px)"}),b.appendChild(P)}let F=document.createElement("div");F.textContent="Drag to look \xB7 pinch or scroll to zoom \xB7 Esc to close",Object.assign(F.style,{position:"absolute",bottom:"12px",left:"0",right:"0",textAlign:"center",color:"rgba(230,237,243,0.7)",font:"12px ui-sans-serif, system-ui, sans-serif",pointerEvents:"none"}),b.appendChild(F),t.appendChild(b),g.focus({preventScroll:!0});let w=!1,v=0,D=0,L=0,_=new Map,U=()=>{let[P,k]=[..._.values()];return P&&k?Math.hypot(P.x-k.x,P.y-k.y):0},B=P=>{let k=qn(P);k!==s&&(s=k,n.camera.perspective({fov:s,aspect:n.camera.aspect}),x())},S=P=>{P.target!==g&&(_.set(P.pointerId,{x:P.clientX,y:P.clientY}),w=_.size===1,v=P.clientX,D=P.clientY,_.size===2&&(L=U()),b.setPointerCapture?.(P.pointerId),b.style.cursor="grabbing")},M=P=>{if(_.has(P.pointerId)){if(_.set(P.pointerId,{x:P.clientX,y:P.clientY}),_.size>=2){let k=U();L>0&&k>0&&B(s*(L/k)),L=k,w=!1;return}w&&(i+=(P.clientX-v)*zr,a=Math.max(-Ce,Math.min(Ce,a+(P.clientY-D)*zr)),v=P.clientX,D=P.clientY,x())}},A=P=>{_.delete(P.pointerId),L=_.size===2?U():0;let k=_.values().next().value;w=_.size===1,k?(v=k.x,D=k.y):b.style.cursor="grab";try{b.releasePointerCapture?.(P.pointerId)}catch{}},R=P=>{P.preventDefault(),B(s+P.deltaY*.04)};b.addEventListener("pointerdown",S),b.addEventListener("pointermove",M),b.addEventListener("pointerup",A),b.addEventListener("pointercancel",A),b.addEventListener("wheel",R,{passive:!1});let V=P=>{if(!l){if(P.key==="Tab"){P.preventDefault(),g.focus({preventScroll:!0});return}if(P.key==="Escape"){P.stopPropagation(),z.close();return}if(P.key==="ArrowLeft"||P.key==="ArrowRight")i+=P.key==="ArrowLeft"?-4:4;else if(P.key==="ArrowUp"||P.key==="ArrowDown")a=Math.max(-Ce,Math.min(Ce,a+(P.key==="ArrowUp"?4:-4)));else if(P.key==="+"||P.key==="="){B(s-5),P.preventDefault();return}else if(P.key==="-"){B(s+5),P.preventDefault();return}else return;P.preventDefault(),x()}};window.addEventListener("keydown",V);let E=0,C=(P,k)=>{if(!p){k?.();return}let O=P===1?0:1,H=performance.now(),X=()=>{if(l)return;let Y=o<=0?1:Math.min(1,(performance.now()-H)/o);p?.setOpacity(O+(P-O)*Y),n.requestRender(),Y<1?E=requestAnimationFrame(X):k?.()};E=requestAnimationFrame(X)};C(1);let T=()=>{l||(l=!0,u(),c.abort(),r.signal?.removeEventListener("abort",d),cancelAnimationFrame(E),b.removeEventListener("pointerdown",S),b.removeEventListener("pointermove",M),b.removeEventListener("pointerup",A),b.removeEventListener("pointercancel",A),b.removeEventListener("wheel",R),window.removeEventListener("keydown",V),b.remove(),y?.isConnected&&y.focus({preventScroll:!0}),p?.dispose(),n.camera.position.set(m[0],m[1],m[2]),n.camera.perspective({fov:h,aspect:n.camera.aspect}),n.camera.quaternion.set(f[0],f[1],f[2],f[3]),n.requestRender())},z={close(){if(l)return;let P=()=>{T(),r.onClose?.()};cancelAnimationFrame(E),C(0,P)},dispose:T};return g.addEventListener("click",()=>z.close()),z}function Gr(t){let{container:e,model:n,opts:r,analytics:o,orbit:i,loop:a,seatsById:s,ensureSeatView:l,resolvedSeatViewPose:c,gpu:d,gl:u,isContextLost:m,isDisposed:p,flightGen:h,setPanorama:f,getLoadAbort:x,setLoadAbort:b,setPanoramaSphereVisible:y,setFrozen:g,raisePanoramaLayer:F,restorePanoramaLayer:w,getOverviewChip:v,labelOverlay:D,reducedMotion:L,removeArriveChip:_,showArriveChip:U}=t;return async(B,S,M)=>{x()?.abort();let A=new AbortController;b(A);let R=n.seats.idToIndex.get(B);if(R===void 0){i.syncFromCamera();return}let V=s.get(B)?.label??B,E=c(B,R),C=l(B);if(!C){A.abort(),x()===A&&b(null),i.syncFromCamera();return}g(!0),a.stop();let T;try{T=await C}catch{if(x()===A&&b(null),o.panoramaFailed(B,"source"),!p()&&M===h()){g(!1),i.resumeAfterFlight(E.focal),a.requestRender();let j=U(B,M,!0);requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus())}return}if(p()||M!==h()){A.abort(),x()===A&&b(null);return}_();let z=v(),P=()=>{A.abort(),x()===A&&b(null),f(null),y(!1),w(),z.style.display="",D.setVisible(!r.arriveAtSeatEye),g(!1),o.panoramaClosed(),i.resumeAfterFlight(E.focal),a.requestRender();let j=U(B,h());requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus())},k=T.generated===!0,O=Wn(T);F(),y(!k),z.style.display="none";let H=L()?0:S,X=d(),Y=X&&!m()?await Nr(e,k?null:T,{gl:u,scene:X.main,camera:i.camera,requestRender:()=>a.requestRender(),cameraOriginWorld:k?E.eye:void 0,focalWorld:E.focal},{fadeMs:H,seatLabel:V,disclosure:O,disclosurePrefix:k?"Live seat-eye view":"360\xB0 panorama",onClose:P,signal:A.signal}):null;if(p()||M!==h()){A.abort(),y(!1),x()===A&&b(null),Y?.dispose(),z.style.display="",w();return}if(Y)i.syncFromCamera(),D.setVisible(!1),g(!1),a.requestRender(),f(Y);else if(k){w(),z.style.display="",g(!1),i.resumeAfterFlight(E.focal),a.requestRender(),f(null),y(!1),o.panoramaFailed(B,"mount");let j=U(B,h(),!0);requestAnimationFrame(()=>j?.querySelector("[data-panorama-trigger]")?.focus()),x()===A&&b(null);return}else y(!1),o.panoramaFallback(B),f(Kn(e,T,{fadeMs:H,seatLabel:V,disclosure:O,onClose:P,signal:A.signal}));o.panoramaOpened()}}var Hr=()=>typeof performance<"u"&&performance.now?performance.now():Date.now(),Xt=class{constructor(e){this.orbitLatched=!1;this.panoramaOpenedAt=0;this.cb=e}emit(e,n){if(this.cb)try{this.cb(e,n)}catch{}}opened(e,n,r,o){this.emit("3d_opened",{seats:e,hasHeights:n,...r===void 0?{}:{buildMs:Math.round(r)},...o===void 0?{}:{prepSource:o}})}orbitEngaged(){this.orbitLatched||(this.orbitLatched=!0,this.emit("3d_orbit_engaged"))}seatPicked(e,n){this.emit("3d_seat_picked",{seatId:e,sectionId:n})}cinematicPlayed(e){this.emit("3d_cinematic_played",{durationMs:e,reducedMotion:!1})}cinematicSkipped(){this.emit("3d_cinematic_skipped",{reducedMotion:!0})}cinematicCancelled(){this.emit("3d_cinematic_cancelled")}panoramaOpened(){this.panoramaOpenedAt=Hr(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(Hr()-this.panoramaOpenedAt):0;this.panoramaOpenedAt=0,this.emit("3d_panorama_closed",{viewMs:e})}panoramaFailed(e,n){this.emit("3d_panorama_failed",{seatId:e,phase:n})}panoramaFallback(e){this.emit("3d_panorama_fallback",{seatId:e})}contextLost(){this.emit("3d_context_lost")}contextRestored(){this.emit("3d_context_restored")}};function Ur(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function Yr(t){let{container:e,model:n,opts:r,expandedSeatById:o,seatIdsByRow:i,isNarrow:a}=t,s=null,l=()=>{if(!s)return;let u=a();Object.assign(s.style,u?{left:"12px",right:"12px",bottom:"70px",transform:"none",justifyContent:"center"}:{left:"50%",right:"auto",bottom:"18px",transform:"translateX(-50%)",justifyContent:"initial"})},c=()=>{s?.remove(),s=null};return{show:(u,m,p=!1)=>{if(c(),t.isDisposed())return null;let h=document.createElement("div");h.setAttribute("role","group"),Object.assign(h.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let f=o.get(u),x=f?.sectionId?n.sections.find(L=>L.id===f.sectionId):void 0,b=f?.label??u;h.setAttribute("aria-label",`Explore views near ${x?.label?`${x.label}, `:""}seat ${b}`);let y=document.createElement("span");y.textContent=["Live 3D seat view",x?.label,b].filter(Boolean).join(" \xB7 "),Object.assign(y.style,{maxWidth:"min(320px, calc(100vw - 32px))",padding:"5px 10px",borderRadius:"999px",overflow:"hidden",color:"#d9e3f5",background:"rgba(12,18,32,0.72)",font:"600 11px/1.2 inherit",textOverflow:"ellipsis",whiteSpace:"nowrap",backdropFilter:"blur(6px)"}),h.appendChild(y);let g=document.createElement("div");Object.assign(g.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),h.appendChild(g);let F=f?.rowId?i.get(f.rowId):void 0,w=F?.indexOf(u)??-1,v=w>=0?[F?.[w-1],F?.[w+1]]:[void 0,void 0],D=(L,_,U,B=!1)=>{let S=document.createElement("button");S.type="button",S.textContent=L,S.setAttribute("aria-label",_),Object.assign(S.style,{minHeight:"44px",padding:B?"10px 16px":"10px",borderRadius:"999px",background:"rgba(12,18,32,0.78)",color:"#eef1f8",border:"1px solid rgba(150,165,205,0.4)",backdropFilter:"blur(6px)",font:"600 13px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"}),B||(S.style.minWidth="44px"),B&&(S.dataset.panoramaTrigger=""),S.addEventListener("click",U),g.appendChild(S)};if(v[0]){let L=o.get(v[0])?.label??v[0];D("\u2039",`View previous seat ${L}`,()=>{t.flyToSeat(v[0])})}if(r.getSeatView){let L=r.seatViewActionLabel?.(u)??"Open 360\xB0 panorama";D(p?`\u21BB Retry ${L}`:`\u25C9 ${L}`,`${p?"Retry":L} from seat ${b}`,()=>{if(t.isDisposed()||m!==t.flightGen()){c();return}c(),t.openPanorama(u,400,m)},!0)}if(v[1]){let L=o.get(v[1])?.label??v[1];D("\u203A",`View next seat ${L}`,()=>{t.flyToSeat(v[1])})}return g.childElementCount?(e.appendChild(h),s=h,l(),h):null},remove:c,layout:l}}function Xr(t){let{container:e,orbit:n,isNarrow:r}=t,o=document.createElement("div"),i=!1;o.className="sl-3d-navigation-controls",Object.assign(o.style,{position:"absolute",right:"14px",bottom:"14px",display:"flex",zIndex:"4",flexDirection:"column",alignItems:"flex-end",gap:"7px"});let a=document.createElement("div");a.setAttribute("role","group"),a.setAttribute("aria-label","3D drag mode"),Object.assign(a.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let s=document.createElement("div");s.setAttribute("role","group"),s.setAttribute("aria-label","3D view controls"),Object.assign(s.style,{display:"flex",flexDirection:"column",gap:"6px",alignItems:"flex-end"});let l=document.createElement("button");l.type="button",l.textContent="\u21BB",l.setAttribute("aria-label","Drag to rotate the 3D venue"),l.dataset.tooltip="Rotate venue";let c=document.createElement("button");c.type="button",c.textContent="\u2725",c.setAttribute("aria-label","Drag to move the 3D venue left, right, up or down"),c.dataset.tooltip="Move venue";let d=document.createElement("button");d.type="button",d.textContent="\u2212",d.setAttribute("aria-label","Zoom out of the 3D venue"),d.dataset.tooltip="Zoom out";let u=document.createElement("button");u.type="button",u.textContent="+",u.setAttribute("aria-label","Zoom into the 3D venue"),u.dataset.tooltip="Zoom in";for(let f of[l,c,d,u])f.className="sl-3d-icon-control",Object.assign(f.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",border:"1px solid rgba(150,165,205,0.35)",borderRadius:"999px",color:"#c9d4ea",background:"rgba(12,18,32,0.82)",font:"600 17px/1 inherit",backdropFilter:"blur(6px)",cursor:"pointer",whiteSpace:"nowrap"});a.append(l,c),s.append(u,d);let m=f=>{n.setPrimaryDragMode(f);let x=f==="orbit";l.setAttribute("aria-pressed",String(x)),c.setAttribute("aria-pressed",String(!x)),l.style.background=x?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",c.style.background=x?"rgba(12,18,32,0.82)":"rgba(96,110,150,0.68)",o.title=x?"Drag to rotate \xB7 Shift-drag to move":"Drag to move \xB7 Shift-drag to rotate"};l.addEventListener("click",()=>m("orbit")),c.addEventListener("click",()=>m("pan")),d.addEventListener("click",()=>n.zoomBy(1.22)),u.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),m("orbit"),e.appendChild(o);let p=()=>{let f=r();o.style.display=i?"none":"flex",o.style.right=f?"12px":"14px",o.style.bottom=f?"calc(env(safe-area-inset-bottom, 0px) + 76px)":"14px",a.style.display=f?"none":"flex",u.style.display=f?"none":"",d.style.display=f?"none":""};return p(),{element:o,utilityControls:s,setNavigationMode:m,setSeatViewLocked:f=>{i=f,n.setInteractionEnabled(!f),p()},seatViewLocked:()=>i,layout:p}}function Wr(t){let{glctx:e,orbit:n,model:r,seats:o,opts:i,cinematic:a,analytics:s,seatIdByIndex:l,sectionIdBySeatId:c,tapSlop:d,tapMs:u,cancelFlight:m,focusSectionCamera:p,setSelection:h,ensureSeatView:f}=t,x=0,b=0,y=0,g=-1,F=!1,w=!1,v=B=>{t.seatViewLocked()||g===-1&&(g=B.pointerId,x=B.clientX,b=B.clientY,y=performance.now(),F=!1,w=a.active,a.active&&(s.cinematicCancelled(),m(),i.onViewTargetChange?.(null)))},D=B=>{B.pointerId===g&&Math.hypot(B.clientX-x,B.clientY-b)>d&&(F=!0)},L=(B,S,M,A,R)=>{let V=e.canvas.getBoundingClientRect(),E=e.canvas.clientWidth||V.width||1,C=e.canvas.clientHeight||V.height||1,T=B-V.left,z=S-V.top,P=A*A,k=-1,O=P,H=1/0;for(let X of o){if(M&&X.sectionId!==M)continue;let Y=r.seats.idToIndex.get(X.id);if(Y===void 0)continue;if(R){let se=Math.round(r.seats.iState[Y]??0);if(se!==0&&se!==3)continue}let j=Y*3,K=Oe(n.camera.projectionViewMatrix,[r.seats.iPosition[j],r.seats.iPosition[j+1]+.55,r.seats.iPosition[j+2]],E,C);if(!K.visible)continue;let ne=K.x-T,oe=K.y-z,Q=ne*ne+oe*oe;(Q<O||Math.abs(Q-O)<1&&K.depth<H)&&(k=Y,O=Q,H=K.depth)}return k},_=(B,S)=>{let M=t.gpu(),A=t.pick();if(!M||!A)return-1;A.syncFromSeatProgram(M.seatProgram);let R=e.canvas.getBoundingClientRect(),V=e.renderer.dpr,{x:E,y:C}=Rr(B,S,R,V,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),T=Math.max(2,Math.round(8*V));return A.pick(n.camera,E,C,T)};return{onDown:v,onMove:D,onUp:B=>{if(B.pointerId!==g)return;let S=!F&&performance.now()-y<u;if(g=-1,w){w=!1;return}let M=t.gpu(),A=t.pick();if(!S||!M||!A)return;let R=_(B.clientX,B.clientY);if(t.focusedSectionId()&&R>=0){let C=l[R],T=C?c.get(C):void 0;if(T&&T!==t.focusedSectionId()&&p(T))return}if(t.focusedSectionId()&&R<0&&(R=L(B.clientX,B.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&R<0){let C=L(B.clientX,B.clientY,null,72,!1),T=C>=0?l[C]:void 0,z=T?c.get(T):void 0;if(z&&z!==t.focusedSectionId()&&p(z))return}if(!t.focusedSectionId()){R<0&&(R=L(B.clientX,B.clientY,null,42,!1));let C=R>=0?l[R]:void 0,T=C?c.get(C):void 0;if(T&&p(T))return}if(R<0||R>=l.length){t.selection().size&&(h([]),i.onViewTargetChange?.(null));return}let V=l[R],E=be[Math.round(r.seats.iState[R]??0)]??"available";if(E!=="available"&&E!=="selected"){i.onSeatInspect?.(V,E);return}if(t.selection().has(V)&&t.selection().size===1){h([]),i.onViewTargetChange?.(null);return}h([V]),f(V),s.seatPicked(V,c.get(V)),i.onSeatPick?.(V)}}}var Wt=class{constructor(e,n){this.minX=0;this.minZ=0;this.cell=1;this.cols=1;this.rows=1;this.cellStart=null;this.cellItems=null;this.iPosition=e,this.count=n}ensureGrid(){if(this.cellStart||this.count===0)return;let e=this.iPosition,n=1/0,r=1/0,o=-1/0,i=-1/0;for(let p=0;p<this.count;p++){let h=e[p*3],f=e[p*3+2];h<n&&(n=h),h>o&&(o=h),f<r&&(r=f),f>i&&(i=f)}let a=Math.max(o-n,.001),s=Math.max(i-r,.001);this.cell=Math.max(Math.sqrt(a*s*4/this.count),.25),this.cols=Math.max(1,Math.ceil(a/this.cell)+1),this.rows=Math.max(1,Math.ceil(s/this.cell)+1),this.minX=n,this.minZ=r;let l=this.cols*this.rows,c=new Int32Array(l+1),d=p=>{let h=Math.min(this.cols-1,Math.max(0,Math.floor((e[p*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[p*3+2]-r)/this.cell)))*this.cols+h};for(let p=0;p<this.count;p++)c[d(p)+1]++;for(let p=0;p<l;p++)c[p+1]+=c[p];let u=new Int32Array(this.count),m=c.slice(0,l);for(let p=0;p<this.count;p++)u[m[d(p)]++]=p;this.cellStart=c,this.cellItems=u}gather(e,n,r,o){this.ensureGrid();let i=this.cellStart,a=this.cellItems;if(!i||!a)return 0;let s=o.length,l=r*r,c=Math.floor((e-this.minX)/this.cell),d=Math.floor((n-this.minZ)/this.cell),u=Math.ceil(r/this.cell)+1,m=this.iPosition,p=0;for(let h=0;h<=u&&p<s;h++){let f=d-h,x=d+h,b=c-h,y=c+h;for(let g=f;g<=x&&p<s;g++){if(g<0||g>=this.rows)continue;let F=g===f||g===x;for(let w=b;w<=y&&p<s;w++){if(!F&&w!==b&&w!==y){w=y-1;continue}if(w<0||w>=this.cols)continue;let v=g*this.cols+w;for(let D=i[v],L=i[v+1];D<L&&p<s;D++){let _=a[D],U=m[_*3]-e,B=m[_*3+2]-n;U*U+B*B<=l&&(o[p++]=_)}}}}return p}};var jt=class{constructor(e){this.ctx=e;this.detailVisible=!1;this.seatDetailMix=0;this.structureDetailMix=0;this.nearBuf=new Int32Array(It);this.lastGatherX=1/0;this.lastGatherZ=1/0;this.nearIndex=new Wt(e.model.seats.iPosition,e.model.seats.count)}forceRegather(){this.lastGatherX=1/0}setDetailEnabled(e){let n=this.ctx.gpu();e||(this.detailVisible=!1),this.lastGatherX=1/0,this.lastGatherZ=1/0,!e&&n?.nearSeatCount()&&n.setNearSeats(this.nearBuf,0)}update(e){let{model:n}=this.ctx,r=this.ctx.gpu();if(!r)return;if(!e){r.nearSeatCount()&&r.setNearSeats(this.nearBuf,0);return}let o=this.ctx.orbit().camera.position;if(Math.hypot(o.x-this.lastGatherX,o.z-this.lastGatherZ)<on)return;if(this.lastGatherX=o.x,this.lastGatherZ=o.z,Math.hypot(o.x-n.bounds.center[0],o.z-n.bounds.center[2])-n.bounds.radius>nn){r.nearSeatCount()&&r.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,nn,this.nearBuf);s===0&&r.nearSeatCount()===0||r.setNearSeats(this.nearBuf,s)}ease(e,n,r){let o=1-Math.exp(-e*9),i=1-Math.exp(-e*20);this.seatDetailMix+=(n-this.seatDetailMix)*(n>this.seatDetailMix?o:i),this.structureDetailMix+=(r-this.structureDetailMix)*(r>this.structureDetailMix?o:i),Math.abs(n-this.seatDetailMix)<.01&&(this.seatDetailMix=n),Math.abs(r-this.structureDetailMix)<.01&&(this.structureDetailMix=r)}};import{Quat as ss,Vec3 as cs}from"ogl";function jr(t){let{container:e,model:n,opts:r,orbit:o,cinematic:i,analytics:a,loop:s,labelOverlay:l,stageAzimuth:c,overviewFraming:d}=t,u=0,m=-1,p=(w,v,D=28)=>{o.camera.position.set(w[0],w[1],w[2]),o.camera.lookAt(new cs(v[0],v[1],v[2])),o.camera.fov=D,o.camera.updateProjectionMatrix()},h=document.createElement("button");h.className="sl-3d-overview-control sl-3d-icon-control",h.type="button",h.textContent="\u2302",h.setAttribute("aria-label","Fit the active level or whole venue in view"),h.dataset.tooltip="Fit view",Object.assign(h.style,{width:"44px",minWidth:"44px",minHeight:"44px",padding:"9px",borderRadius:"999px",background:"rgba(12,18,32,0.72)",color:"#c9d4ea",border:"1px solid rgba(150,165,205,0.35)",backdropFilter:"blur(6px)",font:"600 11px/1 inherit",cursor:"pointer",whiteSpace:"nowrap"});let f=()=>{h.textContent="\u2302"};f();let x=w=>{m=w;let v=t.gpu();v&&(v.seatProgram.uniforms.uFocusFloor.value=w,v.solidProgram.uniforms.uFocusFloor.value=w,v.chairProgram.uniforms.uFocusFloor.value=w),t.showSectionSeatLabels(null)},b=()=>{if(t.isDisposed())return;r.onViewTargetChange?.(null),r.onSectionFocusChange?.(null),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),a.panoramaClosed()),t.setPanoramaSphereVisible(!1),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.restorePanoramaLayer(),h.style.display="",l.setVisible(!0),t.setFrozen(!1);let w=m>=0?n.floors[m]:null;if(t.setNearFieldDetailEnabled(!!w),t.setSeatViewLocked(!1),y(),t.removeArriveChip(),t.setNavigationMode("orbit"),w){let v=w.focalWorld[0]-w.center[0],D=w.focalWorld[2]-w.center[2],L=Math.hypot(v,D)>w.radius*.12?Math.atan2(v,D):c,_={center:w.center,radius:w.radius,box:w.box},U={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(_,!1,L,!1,U):o.frameSoft(_,L,!1,U)}else t.reducedMotion()?o.frame(n.bounds,!1,c,r.portraitOverviewCrop===!0,d):o.frameSoft(n.bounds,c,r.portraitOverviewCrop===!0,d);t.showSectionSeatLabels(null),s.requestRender()},y=()=>{u++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),i.active&&(i.cancel(),o.resumeAfterFlight(n.focalWorld))},g=w=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let v=n.seats.idToIndex.get(w);if(v===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),r.onViewTargetChange?.(w),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),t.setPanoramaSphereVisible(!1),h.style.display="",t.restorePanoramaLayer()),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.setFrozen(!1),t.setSeatViewLocked(!1);let D=++u;t.removeArriveChip();let{eye:L,focal:_}=t.resolvedSeatViewPose(w,v),U=[o.camera.position.x,o.camera.position.y,o.camera.position.z],B=An(U,L,_,n.bounds.center,n.bounds.radius),S=r.arriveAtSeatEye?L:B.finalPos,M=r.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,A=[B.waypoints[0],B.waypoints[1],S];if(l.setVisible(!1),t.reducedMotion())return p(S,_,M),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(r.arriveAtSeatEye===!0),t.showArriveChip(w,D),Promise.resolve();let R=new ss().copy(o.camera.quaternion),V=_r(o.camera,S,_);return s.requestRender(),i.start(A,R,V,2500,M).then(()=>{t.isDisposed()||D!==u||(a.cinematicPlayed(2500),o.resumeAfterFlight(_),t.setSeatViewLocked(r.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(w,D))})},F=w=>{let v=n.sections.find(U=>U.id===w);if(!v||v.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),i.cancel(),t.removeArriveChip(),n.floors.length>1&&m!==v.floorIndex&&x(v.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(w);let D=v.focalWorld[0]-v.center[0],L=v.focalWorld[2]-v.center[2],_=Math.hypot(D,L)>v.radius*.12?Math.atan2(D,L):void 0;return o.frame({center:v.center,radius:Math.max(5,v.radius*.5)},!1,_),r.onSectionFocusChange?.(w),s.requestRender(),!0};return h.addEventListener("click",b),{overviewChip:h,layoutOverviewChip:f,flightGen:()=>u,focusedFloor:()=>m,applyFloorFocus:x,placeCameraFinal:p,cancelFlight:y,focusOverview:b,flyToSeat:g,focusSectionCamera:F}}function qr(t){let e=performance.now();return{model:yt(t),buildMs:performance.now()-e,source:"main"}}function ls(t){return typeof Worker>"u"?Promise.resolve(qr(t)):new Promise(e=>{let n=new Worker(new URL("./scene/scene.worker.ts",import.meta.url),{type:"module"}),r=!1,o=s=>{r||(r=!0,clearTimeout(a),n.terminate(),e(s))},i=()=>o(qr(t)),a=window.setTimeout(i,15e3);n.onerror=i,n.onmessage=s=>{o({model:s.data.model,buildMs:s.data.buildMs,source:"worker"})},n.postMessage(t)})}var us=Math.PI/180,ms=6,ds=500;function qu(t,e,n={}){let r=performance.now(),o=e.prepared?.model??yt(e),i=new Xt(n.onAnalytics),a=new Array(o.seats.count);for(let[N,G]of o.seats.idToIndex)a[G]=N;let s=new Map(e.seats.map(N=>[N.id,N])),l=new Map;for(let N of e.seats){if(!N.rowId)continue;let G=l.get(N.rowId);G?G.push(N.id):l.set(N.rowId,[N.id])}let c=new Map;for(let N of e.seats)c.set(N.id,N.sectionId);let d=e.doc.floors?.some(G=>(G.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(G=>G.objects)??e.doc.objects).some(G=>G.type==="section"&&((G.height??0)>0||(G.rake??0)>0)),u=null,m=null,p=!1,h=!1,f=!1,x=new Map,b=null,y=null,g=null,F=new Map,w=null,v=()=>{g===null&&(g=t.style.zIndex,t.style.zIndex="20")},D=()=>{g!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=g),g=null)},L=!1,_=()=>L?me.focusedFloor():-1,U=()=>{u=Ar(A.gl,o),m=new Ut(A.renderer,u.seatGeometry,u.chairGeometry,u.solidGeometry,o.seats.count),A.setClearColor(o.theme.background.top),m.setRestoreClear(o.theme.background.top),u.seatProgram.uniforms.uSeatRadius.value=Re*o.theme.seatScale,u.seatProgram.uniforms.uFocusFloor.value=_(),u.solidProgram.uniforms.uFocusFloor.value=_(),u.chairProgram.uniforms.uFocusFloor.value=_(),S.forceRegather()},B=!1,S=new jt({model:o,orbit:()=>R,gpu:()=>u}),M=N=>S.setDetailEnabled(N),A=new At(t,{onContextLost:()=>{f||i.contextLost(),p=!0,j.stop(),u=null,m=null},onContextRestored:()=>{U(),p=!1,f||i.contextRestored(),j.requestRender()}}),R=new Ct(A.gl,A.canvas,()=>j.requestRender(),()=>i.orbitEngaged());R.setAspect(A.aspect);let V=(e.doc.floors?.flatMap(N=>N.objects)??e.doc.objects).some(N=>N.type==="section"&&N.physical3dProvenance?.surfaceKind?.status==="inferred"),E=(()=>{if(V&&o.stages.length===0)return;let N=o.focalWorld[0]-o.bounds.center[0],G=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(N,G)>o.bounds.radius*.12?Math.atan2(N,G):void 0})(),C=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,T=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;R.frame(o.bounds,!T&&n.skipInitialOverviewAnimation!==!0,E,n.portraitOverviewCrop===!0,C);let z=new Yt(R.camera),P=Ur(t),k=new zt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),O=o.labels,H=()=>qo(O,o.floors.length,_());k.setLabels(H());let X=null,Y=N=>{if(X=N,k.setForcedDense(!!N),!N){k.setLabels(H());return}let G=e.seats.filter(q=>q.sectionId===N),W=new Set(G.map(q=>q.id)),$=new Set(G.map(q=>q.rowId)),te=new Set(x.keys()),J=new Set(G.filter(q=>te.has(q.id)).map(q=>q.id)),ce=H().filter(q=>q.kind!=="row"&&q.kind!=="seat"||(q.kind==="row"?$.has(q.id.slice(4)):W.has(q.id.slice(5))&&(J.size===0||J.has(q.id.slice(5)))));if(o.seatCount<=6e3&&J.size===0){k.setLabels(ce);return}let le=J.size?G.filter(q=>J.has(q.id)):G,Ne=new Set(le.map(q=>`seat:${q.id}`)),De=le.flatMap(q=>{let de=o.seats.idToIndex.get(q.id);if(de===void 0)return[];let ge=de*3;return[{id:`seat:${q.id}`,kind:"seat",text:q.displayLabel||q.label,anchor:[o.seats.iPosition[ge],o.seats.iPosition[ge+1]+(te.has(q.id)?1.05:.55),o.seats.iPosition[ge+2]]}]});k.setLabels([...ce.filter(q=>!Ne.has(q.id)),...De])};U();let j=new Rt(N=>{if(p||!u||h)return!1;let W=z.active?z.update(performance.now()):R.update(),$=_()>=0?o.floors[_()]:null,te=$?.radius??o.bounds.radius,J=ro(R.currentDistance,te),ce=B?{center:[R.camera.position.x,R.camera.position.y,R.camera.position.z],radius:520}:o.renderBounds;R.updateClipping(ce);let le=$?.center??o.renderBounds.center,Ne=$?.radius??o.renderBounds.radius,De=(ve,rt)=>Math.hypot(R.camera.position.x-ve[0],R.camera.position.y-ve[1],R.camera.position.z-ve[2])<=rt*(S.detailVisible?1.8:1.55),q=De(le,Ne);if(!q&&X){let ve=o.sections.find(rt=>rt.id===X);ve&&(q=De(ve.center,Math.max(12,ve.radius*2)))}S.detailVisible=q;let de=u.seatProgram.uniforms;de.uSeatScale.value=J.scale,de.uSeatFade.value=J.fade;let ge=!!$&&io($.seatCount,A.canvas.clientWidth||1,A.canvas.clientHeight||1),gt=ao(o.seats.count,te,R.currentDistance,R.camera.fov,A.canvas.clientHeight||1),ot=S.detailVisible||ge||gt?1:0,vt=S.detailVisible||_()>=0||o.floors.length>1?1:0;return S.ease(N,ot,vt),de.uSeatDetail.value=S.seatDetailMix,u.solidProgram.uniforms.uStructureDetail.value=S.structureDetailMix,de.uMinPixels.value=J.minPixels,de.uPixelToWorld.value=2*Math.tan(R.camera.fov*us/2)/Math.max(1,A.pixelHeight),S.update(S.detailVisible),A.renderer.render({scene:u.background,clear:!0}),A.renderer.render({scene:u.main,camera:R.camera,clear:!1}),k.update(R.camera.projectionViewMatrix,A.canvas.clientWidth||1,A.canvas.clientHeight||1,R.currentDistance,te,[R.camera.position.x,R.camera.position.y,R.camera.position.z]),W||S.seatDetailMix!==ot||S.structureDetailMix!==vt}),K=typeof ResizeObserver<"u"?new ResizeObserver(()=>Kt.resize()):null;K?.observe(t);let ne=N=>{let G=te=>{let J=o.seats.idToIndex.get(te);return J===void 0?void 0:o.seats.iState[J]},{updates:W,next:$}=Tr(x,N,G);if(x=$,k.setSelectedSeatIds(x.keys()),X&&Y(X),W.length){let te=cn(o.seats,W);u&&u.uploadSeatStateRuns(te),j.requestRender()}},oe=()=>w!==null?w:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Q=8,se=N=>{if(!n.getSeatView)return null;let G=F.get(N);if(!G)for(G=Promise.resolve(n.getSeatView(N)),F.set(N,G),G.catch(()=>{F.get(N)===G&&F.delete(N)});F.size>Q;){let W=F.keys().next().value;if(W===void 0)break;F.delete(W)}return G},Be=(N,G)=>{let W=s.get(N),$=Math.max(0,Math.round(o.seats.iFloor[G]??0)),te=e.doc.floors?.[$],J=o.floors[$],ce=te?.focalPoint??e.doc.focalPoint,le=J?{x:J.focalWorld[0]/I,y:J.focalWorld[2]/I}:ce,Ne=W?.focalPoint?{x:W.focalPoint.x+le.x-ce.x,y:W.focalPoint.y+le.y-ce.y}:le,De=[o.seats.iPosition[G*3],o.seats.iPosition[G*3+1],o.seats.iPosition[G*3+2]];return Or(De,Ne,te?.baseHeightM??0,W?.eyeHeightM)},Ve=()=>(t.clientWidth||A.canvas.clientWidth)<=520,Se,we=Yr({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:l,isNarrow:Ve,isDisposed:()=>f,flightGen:()=>me.flightGen(),flyToSeat:N=>In(N),openPanorama:(N,G,W)=>Se(N,G,W)}),Pe=we.show,ye=we.remove,xe=we.layout,re=Xr({container:t,orbit:R,isNarrow:Ve}),qe=re.element,Fe=re.setNavigationMode,Ae=re.setSeatViewLocked,ze=re.layout,nt=re.utilityControls,me=jr({container:t,model:o,opts:n,orbit:R,cinematic:z,analytics:i,loop:j,labelOverlay:k,stageAzimuth:E,overviewFraming:C,gpu:()=>u,isDisposed:()=>f,panorama:()=>b,setPanorama:N=>{b=N},setPanoramaSphereVisible:N=>{B=N},panoramaLoadAbort:()=>y,setPanoramaLoadAbort:N=>{y=N},setFrozen:N=>{h=N},restorePanoramaLayer:D,reducedMotion:oe,resolvedSeatViewPose:Be,showSectionSeatLabels:Y,setNearFieldDetailEnabled:M,setSeatViewLocked:Ae,setNavigationMode:Fe,showArriveChip:Pe,removeArriveChip:ye});L=!0;let qt=me.overviewChip,Kr=me.layoutOverviewChip,Zr=me.applyFloorFocus,Qr=me.focusOverview,Rn=me.cancelFlight,In=me.flyToSeat,Tn=me.focusSectionCamera;nt.appendChild(qt),Se=Gr({container:t,model:o,opts:n,analytics:i,orbit:R,loop:j,seatsById:s,ensureSeatView:se,resolvedSeatViewPose:Be,gpu:()=>u,gl:A.gl,isContextLost:()=>p,isDisposed:()=>f,flightGen:()=>me.flightGen(),setPanorama:N=>{b=N},getLoadAbort:()=>y,setLoadAbort:N=>{y=N},setPanoramaSphereVisible:N=>{B=N},setFrozen:N=>{h=N},raisePanoramaLayer:v,restorePanoramaLayer:D,getOverviewChip:()=>qt,labelOverlay:k,reducedMotion:oe,removeArriveChip:ye,showArriveChip:Pe});let Ee=Wr({glctx:A,orbit:R,model:o,seats:e.seats,opts:n,cinematic:z,analytics:i,seatIdByIndex:a,sectionIdBySeatId:c,tapSlop:ms,tapMs:ds,gpu:()=>u,pick:()=>m,seatViewLocked:()=>re.seatViewLocked(),focusedSectionId:()=>X,selection:()=>x,cancelFlight:Rn,focusSectionCamera:Tn,setSelection:ne,ensureSeatView:se});A.canvas.addEventListener("pointerdown",Ee.onDown),A.canvas.addEventListener("pointermove",Ee.onMove),A.canvas.addEventListener("pointerup",Ee.onUp),A.canvas.addEventListener("pointercancel",Ee.onUp),j.requestRender();let Kt={setAvailability(N){let G=Ir(x,N),W=cn(o.seats,G);W.length&&u&&u.uploadSeatStateRuns(W),j.requestRender()},setSelection:ne,flyToSeat:In,focusOverview:Qr,resize(){let{width:N,height:G}=A.resize();R.setAspect(N/Math.max(1,G)),xe(),ze(),Kr(),j.requestRender()},stats(){return{...j.stats(),drawCalls:u?u.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let N=j.stats(),G=A.canvas.clientWidth||1,W=A.canvas.clientHeight||1,$=o.bounds.center,te=Oe(R.camera.projectionViewMatrix,[$[0],o.bounds.box.min[1],$[2]],G,W),J=Oe(R.camera.projectionViewMatrix,[$[0],o.bounds.box.max[1],$[2]],G,W),ce=o.bounds.box,le=[ce.min[0],ce.max[0]].flatMap(q=>[ce.min[1],ce.max[1]].flatMap(de=>[ce.min[2],ce.max[2]].map(ge=>Oe(R.camera.projectionViewMatrix,[q,de,ge],G,W)))).filter(q=>Number.isFinite(q.x)&&Number.isFinite(q.y)&&Number.isFinite(q.depth)),Ne=le.length?(()=>{let q=Math.min(...le.map(Ge=>Ge.x)),de=Math.max(...le.map(Ge=>Ge.x)),ge=Math.min(...le.map(Ge=>Ge.y)),gt=Math.max(...le.map(Ge=>Ge.y)),ot=Math.max(0,q),vt=Math.min(G,de),ve=Math.max(0,ge),rt=Math.min(W,gt),Mt=Math.max(0,vt-ot),Zt=Math.max(0,rt-ve);return{box:{x:ot,y:ve,width:Mt,height:Zt},horizontalFillRatio:Mt/G,verticalFillRatio:Zt/W,visibleAreaRatio:Mt*Zt/(G*W),clippedEdges:[...ge<0?["top"]:[],...de>G?["right"]:[],...gt>W?["bottom"]:[],...q<0?["left"]:[]]}})():void 0,De=String(A.gl.getParameter(A.gl.VERSION)??"");return{viewport:{width:G,height:W},context:{webgl2:/webgl\s*2/i.test(De),lost:p},frame:{rendered:N.rendered,idle:N.idle},camera:{position:[R.camera.position.x,R.camera.position.y,R.camera.position.z],distance:R.currentDistance,verticalFovDeg:R.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:d,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:te.visible&&J.visible?Math.abs(te.y-J.y):0},labels:k.qualityEvidence(),framing:Ne}},getQualityReport(){return vn(Kt.getQualityEvidence())},loseContextForTest(){A.simulateContextLossCycle()},floors(){return o.floors},focusFloor(N){if(N!==null&&!o.floors.some(W=>W.index===N))return!1;let G=N??-1;if(M(N!==null),Ae(!1),Zr(G),Fe("orbit"),N===null)z.cancel(),oe()?R.frame(o.bounds,!1,E,n.portraitOverviewCrop===!0,C):R.frameSoft(o.bounds,E,n.portraitOverviewCrop===!0,C);else{let W=o.floors[N];if(W.seatCount>0){z.cancel();let $=W.focalWorld[0]-W.center[0],te=W.focalWorld[2]-W.center[2],J=Math.hypot($,te)>W.radius*.12?Math.atan2($,te):E;R.frame({center:W.center,radius:W.radius,box:W.box},!1,J,!1,{polarDeg:58,margin:1.12})}}return j.requestRender(),!0},zones(){return o.zones},focusZone(N){let G=o.zones.find(J=>J.id===N);if(!G||G.seatCount===0)return!1;M(!1),Ae(!1),z.cancel(),Fe("orbit"),Y(null),n.onSectionFocusChange?.(null);let W=G.focalWorld[0]-G.center[0],$=G.focalWorld[2]-G.center[2],te=Math.hypot(W,$)>G.radius*.12?Math.atan2(W,$):void 0;return R.frame({center:G.center,radius:G.radius*1.25},!1,te),j.requestRender(),!0},sections(){return o.sections},focusSection(N){return Tn(N)},rows(N){return N?o.rows.filter(G=>G.sectionId===N):o.rows},seatsInRow(N){return e.seats.filter(G=>G.rowId===N).map(G=>({id:G.id,label:G.displayLabel||G.label}))},focusRow(N){let G=o.rows.find(W=>W.id===N);return!G||G.seatCount===0?!1:(M(!0),Ae(!1),z.cancel(),Fe("pan"),G.sectionId&&(Y(G.sectionId),n.onSectionFocusChange?.(G.sectionId)),R.frame({center:G.center,radius:Math.max(2.5,G.radius*.65)}),j.requestRender(),!0)},setReducedMotionForTest(N){w=N},dispose(){f=!0,ye(),qt.remove(),qe.remove(),Rn(),j.stop(),k.dispose(),K?.disconnect(),b&&(b.dispose(),b=null),D(),P(),A.canvas.removeEventListener("pointerdown",Ee.onDown),A.canvas.removeEventListener("pointermove",Ee.onMove),A.canvas.removeEventListener("pointerup",Ee.onUp),A.canvas.removeEventListener("pointercancel",Ee.onUp),R.dispose(),m&&m.dispose(),u&&u.dispose(),u=null,m=null,A.dispose()}};return i.opened(o.seatCount,d,e.prepared?.buildMs??performance.now()-r,e.prepared?.source??"inline"),Kt}export{Sa as VENUE3D_QUALITY_REPORT_VERSION,yt as buildSceneModel,vn as inspectVenue3DQualityEvidence,qu as mountVenue3D,ls as prepareVenue3D};