@seatlayer/core 0.67.12 → 0.67.13

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 (78) hide show
  1. package/dist/{categoryInventory-DEgsjxCC.d.cts → categoryInventory-BI3jJaqD.d.cts} +1 -1
  2. package/dist/{categoryInventory-C3RogGHF.d.ts → categoryInventory-CDGQe2Ag.d.ts} +1 -1
  3. package/dist/chunk-3TAVIEVO.js +1 -0
  4. package/dist/chunk-52MZJZMW.js +1 -0
  5. package/dist/chunk-5BGP7S3Q.js +1 -0
  6. package/dist/chunk-BTW7IGNT.js +1 -0
  7. package/dist/{chunk-F4GG7KDS.js → chunk-BV6FHURE.js} +1 -1
  8. package/dist/chunk-CRCGO52K.js +1 -0
  9. package/dist/{chunk-5S3OQBZJ.js → chunk-HZT2U5IY.js} +1 -1
  10. package/dist/chunk-I6DNJFRF.js +1 -0
  11. package/dist/{chunk-V7PECHME.js → chunk-QYZ3P5L6.js} +1 -1
  12. package/dist/{chunk-L35GJOTC.js → chunk-RMNTGICO.js} +1 -1
  13. package/dist/chunk-Y2J55NLS.js +1 -0
  14. package/dist/core/chart-ops/index.cjs +1 -1
  15. package/dist/core/chart-ops/index.d.cts +71 -7
  16. package/dist/core/chart-ops/index.d.ts +71 -7
  17. package/dist/core/chart-ops/index.js +1 -1
  18. package/dist/core/inventory/index.cjs +1 -1
  19. package/dist/core/inventory/index.d.cts +4 -4
  20. package/dist/core/inventory/index.d.ts +4 -4
  21. package/dist/core/inventory/index.js +1 -1
  22. package/dist/core/layout/index.cjs +1 -1
  23. package/dist/core/layout/index.d.cts +4 -4
  24. package/dist/core/layout/index.d.ts +4 -4
  25. package/dist/core/layout/index.js +1 -1
  26. package/dist/core/quality/index.d.cts +3 -3
  27. package/dist/core/quality/index.d.ts +3 -3
  28. package/dist/core/render-assets/index.d.cts +1 -1
  29. package/dist/core/render-assets/index.d.ts +1 -1
  30. package/dist/core/seatConfidence.cjs +1 -1
  31. package/dist/core/seatConfidence.d.cts +5 -3
  32. package/dist/core/seatConfidence.d.ts +5 -3
  33. package/dist/core/seatConfidence.js +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/eventConfigurations-DImP8Cd6.d.ts +130 -0
  39. package/dist/eventConfigurations-YqyHnreh.d.cts +130 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +32 -11
  42. package/dist/index.d.ts +32 -11
  43. package/dist/index.js +1 -1
  44. package/dist/{labeling-DTHo03rf.d.ts → labeling-Cb7ZwhoO.d.ts} +1 -1
  45. package/dist/{labeling-DRFC35VK.d.cts → labeling-lXzjJrgV.d.cts} +1 -1
  46. package/dist/{layout-BSb0-47G.d.ts → layout-ByBMw1t7.d.ts} +7 -3
  47. package/dist/{layout-wVlsj-_w.d.cts → layout-cZ3VfeJR.d.cts} +7 -3
  48. package/dist/{openPanorama-ALLZ6ADE.js → openPanorama-HGRYMWKC.js} +1 -1
  49. package/dist/{renderedQuality-8i9bYccr.d.cts → renderedQuality-6ta0nSPm.d.cts} +1 -1
  50. package/dist/{renderedQuality-CbHiqt1W.d.ts → renderedQuality-BJKHot_g.d.ts} +1 -1
  51. package/dist/{renderer-BxLV6zjl.d.ts → renderer-B9GavToM.d.ts} +3 -1
  52. package/dist/{renderer-DOVelTZw.d.cts → renderer-C9BLd1g2.d.cts} +3 -1
  53. package/dist/{sections-BrQV1WzI.d.ts → sections-BvZ1cQkD.d.ts} +1 -1
  54. package/dist/{sections-D2bxgVgg.d.cts → sections-ND5PRE4j.d.cts} +1 -1
  55. package/dist/{segmentedRowModel-BQYSdf7k.d.cts → segmentedRowModel-BB9MPufB.d.cts} +1 -1
  56. package/dist/{segmentedRowModel-Cl3X8SKt.d.ts → segmentedRowModel-CLKP-2ca.d.ts} +1 -1
  57. package/dist/{ticketRestrictions-D0GRRQ3i.d.cts → ticketRestrictions-CjV47RNG.d.cts} +2 -2
  58. package/dist/{ticketRestrictions-SteRFSGg.d.ts → ticketRestrictions-DUQ8wHjG.d.ts} +2 -2
  59. package/dist/{types-DmgX-iuD.d.cts → types-hv6QjPRV.d.cts} +32 -3
  60. package/dist/{types-DmgX-iuD.d.ts → types-hv6QjPRV.d.ts} +32 -3
  61. package/dist/view/panoramaDelivery.cjs +1 -1
  62. package/dist/view/panoramaDelivery.d.cts +5 -0
  63. package/dist/view/panoramaDelivery.d.ts +5 -0
  64. package/dist/view/panoramaDelivery.js +1 -1
  65. package/dist/view3d/crossfade/panorama.cjs +1 -1
  66. package/dist/view3d/crossfade/panorama.d.cts +7 -1
  67. package/dist/view3d/crossfade/panorama.d.ts +7 -1
  68. package/dist/view3d/crossfade/panorama.js +1 -1
  69. package/dist/view3d/index.cjs +30 -30
  70. package/dist/view3d/index.d.cts +27 -2
  71. package/dist/view3d/index.d.ts +27 -2
  72. package/dist/view3d/index.js +24 -24
  73. package/package.json +1 -1
  74. package/dist/chunk-EQM4FFN5.js +0 -1
  75. package/dist/chunk-IJI4WU57.js +0 -1
  76. package/dist/chunk-TTTRXXAA.js +0 -1
  77. package/dist/chunk-XHXBFFWR.js +0 -1
  78. package/dist/chunk-XPPT3OGQ.js +0 -1
@@ -1,12 +1,12 @@
1
- import{a as Gn,c as Hn,d as Un}from"../chunk-F4GG7KDS.js";import{d as zn}from"../chunk-T2LWVOQ3.js";import{e as Dn,l as Ge,n as at,o as Nn,q as Pt}from"../chunk-VI3IZS2B.js";import{e as On,k as Vn}from"../chunk-UL5OIGIF.js";import{W as ke,X as _e,ea as St,ga as _n,ha as wt,ja as Ln,l as kn,m as rt,va as Qt}from"../chunk-XHXBFFWR.js";import{d as Q,k as Bn,x as pe,z as it}from"../chunk-CXF32VPG.js";import{Renderer as Hr}from"ogl";var ye=["available","held","sold","selected","dimmed"];function st(t){let e=ye.indexOf(t);return e<0?0:e}var Yn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Xn(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 $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]},He={top:[.05,.06,.08],bottom:[.1,.12,.15]};function fe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Ur(){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 Hr({canvas:this.canvas,dpr:Ur(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[He.top[0],He.top[1],He.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 Yr,Vec3 as Jt}from"ogl";var ue=Math.PI/180,en=15*ue,tn=80*ue,qe=.12,Wn=35,jn=1.25,Ct=class{constructor(e,n,i,o){this.fovY=Wn;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 Yr(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(en,Math.min(tn,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(en,Math.min(tn,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),d=Math.sin(this.polar),h=-r*c,u=-a*c;this.targetT.x+=(-e*s+n*h)*o,this.targetT.z+=(-e*l+n*u)*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,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 d=this.fitDistance(e,s,c,this.azT,this.polT);this.distT=d*Math.max(1.05,Math.min(2,r?.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,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),d=-c*Math.sin(o),h=-Math.cos(r),u=-c*Math.cos(o);if(Math.abs(h)>.999)return s;let p=-u,m=d,f=Math.hypot(p,m);p/=f,m/=f;let x=-m*h,y=m*d-p*u,b=p*h,S=Math.tan(i),C=Math.tan(n),P=1;for(let v=0;v<8;v++){let T=(v&1?l.max[0]:l.min[0])-e.center[0],E=(v&2?l.max[1]:l.min[1])-e.center[1],L=(v&4?l.max[2]:l.min[2])-e.center[2],G=T*d+E*h+L*u,N=Math.abs(T*p+L*m),g=Math.abs(T*x+E*y+L*b);P=Math.max(P,N/S-G,g/C-G)}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*qe,this.polar+=n*qe,this.distance+=i*qe,this.target.x+=o*qe,this.target.y+=r*qe,this.target.z+=a*qe,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(en,Math.min(tn,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,Xr=1.15,ct=6,Qe=10,Kn=6,qn=9.5,Zn=.9,Qn=2.2,nn=30,on=4,It=8192;var ts=Qe+on;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*(Xr-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 Wr from"earcut";import jr from"polygon-clipping";var A=ke,Kr=.002;function qr(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<Kr}var Ue=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 Ue;this.nor=new Ue;this.col=new Ue;this.flr=new Ue;this.mat=new Ue;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){qr(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 Zr(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,d=r*a-i*l,h=i*s-o*a,u=Math.hypot(c,d,h)||1;return c/=u,d/=u,h/=u,[c,d,h]}function Qr(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=Wr(i,o.length?o:void 0,2);return{pts:n,tris:r}}function rn(t){return Ge(t)<0?[...t].reverse():t}var $r=3;function Jr(t,e,n,i){let o=i(t),r=i(e),a=i(n),s=(p,m,f,x)=>Math.abs(i({x:(p.x+m.x)/2,y:(p.y+m.y)/2})-(f+x)/2),l=(t.x+e.x+n.x)/3,c=(t.y+e.y+n.y)/3,d=(o+r+a)/3,h=Math.max(s(t,e,o,r),s(e,n,r,a),s(n,t,a,o),Math.abs(i({x:l,y:c})-d)),u=(p,m,f)=>{let x=Math.abs(i({x:(p+l)/2,y:(m+c)/2})-(f+d)/2);x>h&&(h=x)};return u((t.x+e.x)/2,(t.y+e.y)/2,(o+r)/2),u((e.x+n.x)/2,(e.y+n.y)/2,(r+a)/2),u((n.x+t.x)/2,(n.y+t.y)/2,(a+o)/2),h}function lt(t,e,n,i,o){if(o<=0)return Jr(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(lt(t,r,s,i,o-1),lt(r,e,a,i,o-1),lt(s,a,n,i,o-1),lt(r,a,s,i,o-1))}function ut(t,e,n,i,o,r,a,s){if(a>0){let u={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},m={x:(i.x+e.x)/2,y:(i.y+e.y)/2};ut(t,e,u,m,o,r,a-1,s),ut(t,u,n,p,o,r,a-1,s),ut(t,m,p,i,o,r,a-1,s),ut(t,u,p,m,o,r,a-1,s);return}let l=[e.x*A,o(e),e.y*A],c=[n.x*A,o(n),n.y*A],d=[i.x*A,o(i),i.y*A];if(s){t.triN(l,c,d,s(e),s(n),s(i),r);return}let h=Zr(l,c,d);h[1]<0&&(h=[-h[0],-h[1],-h[2]]),t.tri(l,c,d,h,r)}var ei=8;function to(t,e,n){if(!Number.isFinite(n))return t;let i=[],o=(r,a,s,l,c)=>{if(c>0){let d={x:(r.x+a.x)/2,y:(r.y+a.y)/2},h=e(d);if(Math.abs(h-(s+l)/2)>n){o(r,d,s,h,c-1),o(d,a,h,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),ei)}return i}function Ft(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,d=Math.hypot(l,c);d>e&&Math.abs((a.x-r.x)*c-(a.y-r.y)*l)/d<e||i.push(a)}return i.length>=3?i:n}var Tt=.001*_e*.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(Ge(e))<1e-4))return;let d=Ft(to(Ft(rn(e),Tt),i,l),Tt),h=n?.map(v=>Ft(to(Ft(rn(v),Tt),i,l),Tt)).filter(v=>v.length>=3&&Math.abs(Ge(v))>=1e-4),{pts:u,tris:p}=Qr(d,h),m=[r[0]*s.top,r[1]*s.top,r[2]*s.top],f=[r[0]*s.bottomCap,r[1]*s.bottomCap,r[2]*s.bottomCap],x=[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],b=0;if(Number.isFinite(l))for(;b<$r;b++){let v=0;for(let T=0;T<p.length;T+=3){let E=lt(u[p[T]],u[p[T+1]],u[p[T+2]],i,b);E>v&&(v=E)}if(v<=l)break}for(let v=0;v<p.length;v+=3){let T=u[p[v]],E=u[p[v+1]],L=u[p[v+2]];ut(t,T,E,L,i,m,b,c);let G=[T.x*A,o,T.y*A],N=[E.x*A,o,E.y*A],g=[L.x*A,o,L.y*A];t.tri(G,g,N,[0,-1,0],f)}let S=v=>{if(b<=0)return v;let T=1<<b,E=[];for(let L=0;L<v.length;L++){let G=v[L],N=v[(L+1)%v.length];for(let g=0;g<T;g++){let M=g/T;E.push({x:G.x+(N.x-G.x)*M,y:G.y+(N.y-G.y)*M})}}return E},C=kn(d),P=[{ring:S(d),flip:!1}];if(h)for(let v of h)v.length>=3&&P.push({ring:S(v),flip:!0});for(let{ring:v,flip:T}of P)for(let E=0;E<v.length;E++){let L=v[E],G=v[(E+1)%v.length],N=(G.x-L.x)*A,M=(G.y-L.y)*A,F=-N,I=Math.hypot(M,F)||1;M/=I,F/=I;let k=(L.x+G.x)/2-C.x,U=(L.y+G.y)/2-C.y,w=M*k+F*U;T&&(w=-w),w<0&&(M=-M,F=-F);let R=[M,0,F],_=[L.x*A,i(L),L.y*A],H=[G.x*A,i(G),G.y*A],V=[L.x*A,o,L.y*A],z=[G.x*A,o,G.y*A];t.tri(_,H,z,R,x,x,y),t.tri(_,z,V,R,x,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=rn(t),o=i.length,r=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],d=c.x-l.x,h=c.y-l.y,u=Math.hypot(d,h)||1;r.push({x:h/u,y:-d/u})}let a=[];for(let s=0;s<o;s++){let l=i[s],c=r[(s-1+o)%o],d=r[s],h=c.x+d.x,u=c.y+d.y,p=Math.hypot(h,u),m=()=>{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){m();continue}h/=p,u/=p;let f=h*c.x+u*c.y,x=1/Math.max(f,1e-6);if(!Number.isFinite(x)||x>n){m();continue}a.push([l.x+h*e*x,l.y+u*e*x])}if(a.length<3)return t;try{let s=jr.union([[...a,a[0]]]),l=null,c=-1/0;for(let h of s){let u=Math.abs(Ge(h[0].map(([p,m])=>({x:p,y:m}))));u>c&&(c=u,l=h[0])}if(!l)return t;let d=l.map(([h,u])=>({x:h,y:u}));if(d.length>1){let h=d[0],u=d[d.length-1];Math.abs(h.x-u.x)<1e-9&&Math.abs(h.y-u.y)<1e-9&&d.pop()}return d.length>=3?d: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 mt(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 te={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},ti=.44,ni=.15,oi=.3,ri=.24;function oo(t){return t===void 0||!Number.isFinite(t)||t<=0?ri:Math.min(oi,Math.max(ni,t*ti))}var an=.21,ii=.05,sn=.45,_t=sn+ii,ai=[{part:te.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:te.pad,min:[-1,.36,-.95],max:[1,sn,1]},{part:te.back,min:[-1,_t,-1],max:[1,.92,-.72]},{part:te.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:te.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:te.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:te.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:te.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:te.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:te.leg,min:[.62,0,.48],max:[.82,.37,.7]}],si=[{part:te.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:te.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:te.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:te.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:te.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],ci=[{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=(I,k,U)=>{let w=n.length,[R,_,H]=I,V=[_[0]-R[0],_[1]-R[1],_[2]-R[2]],z=[H[0]-R[0],H[1]-R[1],H[2]-R[2]],O=V[1]*z[2]-V[2]*z[1],W=V[2]*z[0]-V[0]*z[2],Y=V[0]*z[1]-V[1]*z[0],K=Math.hypot(O,W,Y);K>1e-9?(O/=K,W/=K,Y/=K):[O,W,Y]=k,O*k[0]+W*k[1]+Y*k[2]<0&&(O=-O,W=-W,Y=-Y);for(let q of I)t.push(...q),e.push(O,W,Y),n.push(U);i.push(w,w+1,w+2,w,w+2,w+3)},r=I=>{for(let k of ci){let U=k.c.map(w=>w.map((R,_)=>R?I.max[_]:I.min[_]));o(U,k.n,I.part)}};for(let I of ai)r(I);for(let I of si)r(I);let a=sn,s=1.08,l=.47,c=.69,d=-.55,h=.08,u=-.48,p=.01,m=[-l,a,d],f=[l,a,d],x=[-l,a,h],y=[l,a,h],b=[-c,s,u],S=[c,s,u],C=[-c,s,p],P=[c,s,p];o([f,S,P,y],[1,0,0],te.body),o([x,C,b,m],[-1,0,0],te.body),o([C,P,S,b],[0,1,0],te.body),o([m,f,y,x],[0,-1,0],te.body),o([y,P,C,x],[0,0,1],te.body),o([m,b,S,f],[0,0,-1],te.body);let v=10,T=8,E=[0,1.205,-.23],L=[.42,.115,.38],G=n.length;for(let I=0;I<=T;I++){let k=Math.PI*I/T,U=Math.cos(k),w=Math.sin(k);for(let R=0;R<=v;R++){let _=Math.PI*2*R/v,H=w*Math.cos(_),V=w*Math.sin(_);t.push(E[0]+L[0]*H,E[1]+L[1]*U,E[2]+L[2]*V);let z=H/L[0],O=U/L[1],W=V/L[2],Y=Math.hypot(z,O,W)||1;z/=Y,O/=Y,W/=Y,e.push(z,O,W),n.push(te.head)}}for(let I=0;I<T;I++)for(let k=0;k<v;k++){let U=G+I*(v+1)+k,w=U+v+1;i.push(U,w,U+1,U+1,w,w+1)}let N=new Float32Array(t),g=new Float32Array(e),M=new Float32Array(n),F=new Uint16Array(i);return{position:N,normal:g,part:M,index:F,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,d)=>{let h=d-c;for(let u=c;u<d;u++){let[p,m]=i(u),f=p-r(u),x=m-a(u);if(h>=2){let y=Math.max(c,u-1),b=Math.min(d-1,u+1),S=r(b)-r(y),C=a(b)-a(y),P=Math.hypot(S,C);if(P>1e-6){let v=-C/P,T=S/P;v*f+T*x<0&&(v=-v,T=-T),f=v,x=T}}o[u]=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 Ae=.22;function ao(t,e){let n=ye[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 li=.42;function ui(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 m of t)m.x<i&&(i=m.x),m.y<o&&(o=m.y),m.x>r&&(r=m.x),m.y>a&&(a=m.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),d=Math.max(1,Math.ceil(s/c)+1),h=Math.max(1,Math.ceil(l/c)+1),u=new Map,p=(m,f)=>{let x=Math.min(d-1,Math.max(0,Math.floor((m-i)/c)));return Math.min(h-1,Math.max(0,Math.floor((f-o)/c)))*d+x};for(let m=0;m<e;m++){let f=p(t[m].x,t[m].y),x=u.get(f);x?x.push(m):u.set(f,[m])}for(let m=0;m<e;m++){let f=t[m],x=Math.min(d-1,Math.max(0,Math.floor((f.x-i)/c))),y=Math.min(h-1,Math.max(0,Math.floor((f.y-o)/c))),b=1/0;for(let S=1;S<=4;S++){for(let C=y-S;C<=y+S;C++)if(!(C<0||C>=h))for(let P=x-S;P<=x+S;P++){if(P<0||P>=d||S>1&&Math.abs(C-y)<S&&Math.abs(P-x)<S)continue;let v=u.get(C*d+P);if(v)for(let T of v){if(T===m)continue;let E=Math.hypot(t[T].x-f.x,t[T].y-f.y);E<b&&(b=E)}}if(Number.isFinite(b)&&b<=S*c)break}n[m]=b}return n}function mi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function so(t,e,n,i,o,r){let a=t.length,s=new Float32Array(a*3),l=new Float32Array(a),c=new Float32Array(a*3),d=new Float32Array(a),h=new Float32Array(a),u=new Float32Array(a),p=new Float32Array(a),m=new Float32Array(a*3),f=new Map,x=ui(t);for(let y=0;y<a;y++){let b=t[y],C=(n?.seatPitchU(y)??x[y])*A;d[y]=Number.isFinite(C)?Math.max(.06,Math.min(Ae,C*li)):Ae,h[y]=oo(Number.isFinite(C)?C:void 0);let P=Vn(b.glyph,{seatGlyph:r?.get(b.categoryKey)});u[y]=On.indexOf(P),p[y]=b.wheelchairSpaceType==="no-seat"?0:1,s[y*3]=b.x*A,s[y*3+1]=n?n.seatDeckY(y):mi(b),s[y*3+2]=b.y*A,l[y]=st(e?e(b):"available");let v=Q(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[y*3]=v[0],c[y*3+1]=v[1],c[y*3+2]=v[2],b.accessibility?.length){let T=Q(Dn(b.accessibility));T&&(m[y*3]=T[0],m[y*3+1]=T[1],m[y*3+2]=T[2])}f.set(b.id,y)}return{count:a,iPosition:s,iState:l,iCategory:c,iMaxRadius:d,iRing:m,idToIndex:f,iChairWidth:h,iGlyph:u,iPhysicalSeat:p,iFloor:i??new Float32Array(a),iYaw:new Float32Array(a)}}var di=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=st(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+di){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 hi=.15,pi=.9,fi=1.76,bi=.7,yi=1.6;function xi(){return{background:{top:[...He.top],bottom:[...He.bottom]},structure:$t,seatStates:{...Yn},seatScale:1}}function co(t){let e=xi();if(!t)return e;let n=Q(t.background);if(n){e.background={top:fe(n,pi),bottom:fe(n,fi)};let r={};for(let[a,s]of Object.entries($t))r[a]=pe(s,n,hi);e.structure=r}let i=Q(t.selectionColor)??Q(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(yi,Math.max(bi,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 gi from"earcut";var vi=.58,uo=.01,be=Ae*1.5*_e,Mi=.5,Si=.6;function wi(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,d=l.y-s.y,h=Math.hypot(c,d);if(h<1e-9){i.push([0,0]);continue}c/=h,d/=h,i.push([-d,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 Pi(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,d=Math.hypot(l,c)||1;return{x:l/d,y:c/d}},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 Ai(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=Ai(t),i=(s,l,c,d)=>{let h=c-l;for(;h<0;)h+=Math.PI*2;for(;h>Math.PI*2;)h-=Math.PI*2;let u=Math.max(1,Math.ceil(h/mo)),p=e/Math.cos(h/u/2);for(let m=0;m<=u;m++){let f=l+h*m/u;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=[],h=Math.max(3,Math.ceil(Math.PI*2/mo)),u=(c+e)/Math.cos(Math.PI/h);for(let p=0;p<h;p++){let m=p/h*Math.PI*2;d.push({x:s+Math.cos(m)*u,y:l+Math.sin(m)*u})}return d}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 Ci(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,d=c>1e-12?((e-r.x)*s+(n-r.y)*l)/c:0;d<0?d=0:d>1&&(d=1);let h=Math.hypot(e-(r.x+d*s),n-(r.y+d*l));h<i&&(i=h)}return i}function Lt(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 d=Math.hypot(c.x-r,c.y-a);d>l&&(l=d)}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 d of r){let h=1/0;for(let u=0;u<t.length;u++){if(u===o||Math.abs(t[u].y-t[o].y)<.001)continue;let p=e[u],m=Math.hypot(d.x-p.cx,d.y-p.cy)-p.rad;if(m>=h&&m>=s)continue;let f=Ci(t[u].pts,d.x,d.y);f<h&&(h=f),t[u].depth<t[o].depth&&f<s&&(s=f,l=t[u].y)}Number.isFinite(h)&&h>0&&a.push(h)}a.sort((d,h)=>d-h);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 d=o.pts[0],h=d.x-i.x,u=d.y-i.y,p=Math.hypot(h,u)||1;h/=p,u/=p;let m=Math.max(n[e].pitch,.001)*.5;return[{x:d.x+u*m,y:d.y-h*m},{x:d.x-u*m,y:d.y+h*m}]})():[];if(r.length<2)return null;let a=0,s=0;for(let d=1;d<r.length;d++){let h=Math.hypot(r[d].x-r[d-1].x,r[d].y-r[d-1].y);h>1e-6&&(a+=h,s++)}let l=s>0?a/s:0,c=Pi(r,Math.max(l*Si,be));return{pts:c,nrm:wi(c,i),front:Math.max(n[e].pitch*vi,be),back:Math.max(n[e].pitch*Mi,be)}}var $e=1.5,yo=.3;function ln(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 h=1;h<t.length-1;h++){let u=t[h],p=a>1e-12?Math.abs((u.x-n.x)*r-(u.y-n.y)*o)/a:Math.hypot(u.x-n.x,u.y-n.y);p>s&&(s=p,l=h)}if(s<=e||l<0)return[n,i];let c=ln(t.slice(0,l+1),e),d=ln(t.slice(l),e);return[...c.slice(0,-1),...d]}function xo(t,e){if(t.length<4)return t;let n=ln([...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??Lt(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 b of a){let S=t[b].patch;S&&S.length>=3?r.push({outline:[...S],holes:[],topY:t[b].y}):s.push(b)}if(!s.length)continue;s.sort((b,S)=>t[b].depth-t[S].depth);let c=s.map(b=>bo(t,b,i,e)).filter(b=>b!==null);if(!c.length)continue;let d=(b,S)=>({x:b.pts[S].x-b.nrm[S][0]*(b.front+$e),y:b.pts[S].y-b.nrm[S][1]*(b.front+$e)}),h=(b,S)=>({x:b.pts[S].x+b.nrm[S][0]*(b.back+$e),y:b.pts[S].y+b.nrm[S][1]*(b.back+$e)}),u=c[0],p=c[c.length-1],m=[];for(let b=0;b<u.pts.length;b++)m.push(d(u,b));for(let b of c)m.push(h(b,b.pts.length-1));for(let b=p.pts.length-1;b>=0;b--)m.push(h(p,b));for(let b=c.length-1;b>=0;b--)m.push(d(c[b],0));let f=vo(m),x=1/0;for(let b of s)t[b].y<x&&(x=t[b].y);if(!Number.isFinite(x))continue;if(f.length>=3&&Math.abs(Ge(f))>1e-6&&c.every(b=>{let S=b.pts[Math.floor(b.pts.length/2)];return at(f,S.x,S.y)})){r.push({outline:xo(f,yo),holes:[],topY:x});continue}for(let b of Ri(c))r.push({outline:b,holes:[],topY:x})}return r}function Ri(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],d=n.nrm[l];i.push([c.x-d[0]*r,c.y-d[1]*r]),o.push([c.x+d[0]*a,c.y+d[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 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 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(!at(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],d=i[0];for(let h=1;h+1<i.length;h++){let u=i[h],p=i[h+1];t.tri([d.x*A,o,d.y*A],[u.x*A,o,u.y*A],[p.x*A,o,p.y*A],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 d=c[0],h=[],u=[];for(let m=0;m<d.length-1;m++)h.push(d[m][0],d[m][1]),u.push([d[m][0],d[m][1]]);if(u.length<3)continue;let p=gi(h,void 0,2);for(let m=0;m<p.length;m+=3){let f=u[p[m]],x=u[p[m+1]],y=u[p[m+2]];t.tri([f[0]*A,o,f[1]*A],[x[0]*A,o,x[1]*A],[y[0]*A,o,y[1]*A],l,r)}}}function Mo(t,e,n,i,o,r,a){if(e.length<2)return;let s=a??Lt(e),l=[0,1,0],c=r&&r.length>=3?[[...r.map(p=>[p.x,p.y]),[r[0].x,r[0].y]]]:null,d=r&&r.length>=3?new un([[...r]]):null,h=p=>{t.setMaterial(2),p(),t.setMaterial(0)},u=p=>{t.setMaterial(3),p(),t.setMaterial(0)};for(let p=0;p<e.length;p++){let m=e[p];if(m.patch&&m.patch.length>=3){let P=[...m.patch],v=s[p].belowY??i;if(u(()=>{if(c&&d)ho(t,c,d,P,m.y,o.tread);else{let T=P[0];for(let E=1;E+1<P.length;E++){let L=P[E],G=P[E+1];t.tri([T.x*A,m.y,T.y*A],[L.x*A,m.y,L.y*A],[G.x*A,m.y,G.y*A],l,o.tread)}}}),m.y>v+uo){let T=0,E=0;for(let L of P)T+=L.x,E+=L.y;T/=P.length,E/=P.length,h(()=>{for(let L=0;L<P.length;L++){let G=P[L],N=P[(L+1)%P.length],g=N.x-G.x,M=N.y-G.y,F=Math.hypot(g,M);if(F<1e-6)continue;let I=M/F,k=-g/F;(G.x-T)*I+(G.y-E)*k<0&&(I=-I,k=-k);let U=[I,0,k],w=[G.x*A,m.y,G.y*A],R=[N.x*A,m.y,N.y*A],_=[G.x*A,v,G.y*A],H=[N.x*A,v,N.y*A];t.tri(w,R,H,U,o.riser),t.tri(w,H,_,U,o.riser)}})}continue}let f=bo(e,p,s,n);if(!f)continue;let{pts:x,nrm:y,front:b,back:S}=f,C=s[p].belowY??i;for(let P=0;P+1<x.length;P++){let v=x[P],T=x[P+1],E=y[P],L=y[P+1];if(Math.hypot(T.x-v.x,T.y-v.y)<1e-6||E[0]===0&&E[1]===0||L[0]===0&&L[1]===0)continue;let G=[(v.x-E[0]*b)*A,m.y,(v.y-E[1]*b)*A],N=[(T.x-L[0]*b)*A,m.y,(T.y-L[1]*b)*A],g=[(v.x+E[0]*S)*A,m.y,(v.y+E[1]*S)*A],M=[(T.x+L[0]*S)*A,m.y,(T.y+L[1]*S)*A];if(u(()=>{c&&d?ho(t,c,d,[{x:v.x-E[0]*b,y:v.y-E[1]*b},{x:T.x-L[0]*b,y:T.y-L[1]*b},{x:T.x+L[0]*S,y:T.y+L[1]*S},{x:v.x+E[0]*S,y:v.y+E[1]*S}],m.y,o.tread):(t.tri(G,N,M,l,o.tread),t.tri(G,M,g,l,o.tread))}),m.y>C+uo){let F=[G[0],C,G[2]],I=[N[0],C,N[2]],k=[-E[0],0,-E[1]];h(()=>{t.tri(G,N,I,k,o.riser),t.tri(G,I,F,k,o.riser)})}}}}import wo from"polygon-clipping";function Ii(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function So(t,e){return t.filter(n=>n.type!=="shape"||Ii(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 Fi={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Je(t){return Nn(t)??Fi}function Ao(t,e){let n=Dt(t.outline,be),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(([d,h])=>({x:d,y:h}));if(c.length>1){let d=c[0],h=c[c.length-1];Math.abs(d.x-h.x)<1e-9&&Math.abs(d.y-h.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,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:r.topY})}}return o.length?o:t}var Ti=.05,Ro=.05,Ei=.15,mn=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=[],d=new Set;for(let u=0;u<t.length;u+=1){let p=t[u];for(let m of p.objects){if(m.type==="table"&&d.add(m.id),m.type!=="section"||!m.outline||m.outline.length<3)continue;let f=Dt(m.outline,be);l.set(m.id,{section:m,unit:p,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:m.id,floorIndex:u,box:Je(f),section:m,unit:p,outline:f})}}let h=new Map;for(let u of c){let p=h.get(u.floorIndex);p?p.push(u):h.set(u.floorIndex,[u])}for(let u=0;u<e.length;u++){let p=e[u],m=n?h.get(n[u])??[]:c,f=p.sectionId?m.find(y=>y.id===p.sectionId)??m.find(y=>y.section.logicalSectionId===p.sectionId&&Qt({x:p.x,y:p.y},y.outline,y.section.holes)):void 0,x=f?[f]:m;for(let y of x){if(n&&y.floorIndex!==n[u]||!f&&(p.x<y.box.minX||p.x>y.box.maxX||p.y<y.box.minY||p.y>y.box.maxY||!Qt({x:p.x,y:p.y},y.outline,y.section.holes)))continue;o[u]=y.id;let b=l.get(y.id);b.hasSeats=!0;let S=p.focalPoint??y.unit.focal,C=Math.hypot(p.x-S.x,p.y-S.y);C<b.frontU&&(b.frontU=C),b.seatIndices.push(u);let P=p.rowId||`__seat-${u}`,v=b.rows.get(P);v?v.push({x:p.x,y:p.y}):b.rows.set(P,[{x:p.x,y:p.y}]);break}}for(let[u,p]of l){let m=_n(p.section,{floorBaseHeightM:p.unit.baseHeightM}),f=p.unit.baseHeightM,x=m.rake>0?Math.tan(m.rake*Math.PI/180):0,y=m.rake<=.01&&m.height<=f+.001,b=p.section.surfaceKind,S=b==="flat"?!0:b==="rakedRows"&&m.rake>.01?!1:y,C=p.hasSeats?Ln(u,e,p.seatIndices,p.unit.focal):{sectionId:u,rows:[],blockCount:0},v=C.rows.length<2?Gn([...p.rows.values()].map(w=>({points:w})),p.unit.focal):null,T=1/0;if(v){if(p.hasSeats)for(let w of p.rows.values())for(let R of w){let _=v.depthAt(R.x,R.y);_<T&&(T=_)}if(!p.hasSeats||!Number.isFinite(T)){T=1/0;for(let w of p.section.outline){let R=v.depthAt(w.x,w.y);R<T&&(T=R)}}}let E=f+Ti,L=Math.max(E,m.height),G=w=>{let R=Math.max(0,w-T)*ke,_=Math.min(R*x,mn);return Math.max(E,m.height+_)},N=w=>{let R=Math.max(0,w)*ke,_=Math.min(R*x,mn);return Math.max(E,m.height+_)},g=S?[]:C.rows.map(w=>({pts:w.pts,y:N(w.blockDepth),depth:w.blockDepth,blockId:w.blockId,...d.has(w.id)?{patch:fo(w.pts,be)}:{}})),M=g.length?g[0].y:L,F=g.map(w=>{let R=w.patch&&w.patch.length>=3?w.patch:w.pts,_=0,H=0;for(let O of R)_+=O.x,H+=O.y;let V=R.length||1;_/=V,H/=V;let z=0;for(let O of R){let W=Math.hypot(O.x-_,O.y-H);W>z&&(z=W)}return{cx:_,cy:H,rad:z}}),I=S?()=>L:g.length>=2?(w,R)=>{let _=1/0,H=M;for(let V=0;V<g.length;V++){let z=F[V];if(Math.hypot(w-z.cx,R-z.cy)-z.rad>=_)continue;let O=g[V].patch,W=O&&O.length>=3?at(O,w,R)?0:wt(O,w,R):wt(g[V].pts,w,R);W<_&&(_=W,H=g[V].y)}return H}:(w,R)=>v?G(v.depthAt(w,R)):L,k=[0,1,0],U=g.length>=2||S?()=>k:(w,R)=>{if(!v)return k;let _=v.depthAt(w,R);if(_<=T)return k;let H=(_-T)*ke;if(H*x>=mn||m.height+H*x<=E)return k;let[V,z]=v.gradientAt(w,R);if(V===0&&z===0)return k;let O=1/Math.hypot(x,1);return[-V*x*O,O,-z*x*O]};if(!S)for(let w of C.rows){let R=N(w.blockDepth);for(let _ of w.seatIndices)a[_]=R}for(let w of C.rows){let R=[];for(let O=1;O<w.pts.length;O++){let W=Math.hypot(w.pts[O].x-w.pts[O-1].x,w.pts[O].y-w.pts[O-1].y);W>1e-6&&R.push(W)}R.sort((O,W)=>O-W);let _=R.length?R[Math.floor(R.length/2)]:1/0,H=1/0,V=w.pts[Math.floor(w.pts.length/2)];if(V)for(let O of C.rows){if(O===w||O.blockId!==w.blockId)continue;let W=wt(O.pts,V.x,V.y);W>1e-6&&W<H&&(H=W)}let z=Math.min(_,Math.max(H,_*.5));if(Number.isFinite(z)&&z>0)for(let O of w.seatIndices)s[O]=z}i.set(u,{sectionId:u,deckAt:I,normalAt:U,flat:S,bottomY:f,rowLevels:g,landingY:M})}for(let u=0;u<e.length;u++){let p=o[u],m=e[u];if(p){let x=a[u];r[u]=(x??i.get(p).deckAt(m.x,m.y))+Ei;continue}let f=m.eyeHeightM;r[u]=Number.isFinite(f)?Math.max(0,f-St):0}return{bySection:i,seatOwner:o,seatDeckY:u=>r[u],seatPitchU:u=>s[u]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ce(t,e){if(!t)return e;let n=fe(it(t,.4),.62);return pe(e,n,.72)}function Fo(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,d=0;for(let[h,u]of a){let p=Q(n.get(h));p&&(s+=p[0]*u,l+=p[1]*u,c+=p[2]*u,d+=u)}d>0&&o.set(r,[s/d,l/d,c/d])}return o}function To(t,e){return Q(t.color)??e.get(t.logicalSectionId??t.id)??null}import Di from"polygon-clipping";function ki(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Bt=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])&&ki(n,this.levels[c])),a=[[i]];if(r.length)try{a=Di.difference([i],...r).map(c=>c.map(d=>d.map(([h,u])=>[h,u])))}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(([d,h])=>({x:d,y:h}));if(c.length>1){let d=c[0],h=c[c.length-1];Math.abs(d.x-h.x)<1e-9&&Math.abs(d.y-h.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function _i(t,e){if(!e)return t;let n=1/0,i=-1/0,o=1/0,r=-1/0;for(let h of t)n=Math.min(n,h.x),i=Math.max(i,h.x),o=Math.min(o,h.y),r=Math.max(r,h.y);let a=(n+i)/2,s=(o+r)/2,l=e*Math.PI/180,c=Math.cos(l),d=Math.sin(l);return t.map(h=>{let u=h.x-a,p=h.y-s;return{x:a+u*c-p*d,y:s+u*d+p*c}})}function dt(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=mt(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?_i(e,t.rotation):null}function ht(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"&&zn(t.stageKind)?{kind:"stage",heightM:.06}:n[e]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var Li=.08;function Eo(t,e){let n=dt(t),i=ht(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 d of n)r=Math.min(r,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&&r<d.maxX&&l>d.minY&&a<d.maxY&&c<=d.topOffsetM+1e-6&&(c=d.topOffsetM+Li);return e.push({minX:r,minY:a,maxX:s,maxY:l,topOffsetM:c}),c}function Le(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 pt(t,e,n){return[Le(t[0],t[1],e),Le(t[0],t[1],n),Le(t[3],t[2],n),Le(t[3],t[2],e)]}function ko(t,e,n){return[Le(t[0],t[3],e),Le(t[1],t[2],e),Le(t[1],t[2],n),Le(t[0],t[3],n)]}function Re(t,e,n,i,o,r){ie(t,e,void 0,()=>n,i,o,r,re)}var dn=2.4,Bi=.75,Oi=.15;function ft(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(([d,h])=>({x:e.x+d*a-h*s,y:e.y+d*s+h*a}))}function _o(t,e,n,i,o){let r=ft(e);r&&ie(t,r,void 0,()=>n+dn,n,Ce(i,o.boothTop),o.boothWall,re)}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: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(([d,h])=>({x:o.x+d*a-h*s,y:o.y+d*s+h*a}))}function Lo(t,e,n,i,o){let r=hn(e);r&&ie(t,r,void 0,()=>n+Bi,n,Ce(i,o.tableTop),o.tableWall,re)}function Bo(t,e,n,i,o,r,a){let s=dt(e);if(!s)return;let l=e.role==="stage",c=ht(e),d=n+i;if(l&&a){let f=1/0,x=-1/0,y=1/0,b=-1/0;for(let S of s)S.x<f&&(f=S.x),S.x>x&&(x=S.x),S.y<y&&(y=S.y),S.y>b&&(b=S.y);a.push({cx:(f+x)/2*A,cz:(y+b)/2*A,y:d,halfX:Math.max((x-f)/2*A,.5),halfZ:Math.max((b-y)/2*A,.5)})}let h=Q(e.fill),u=l&&h?pe(o.stageTop,fe(it(h,.18),.9),.9):Ce(h,l?o.stageTop:o.decorTop),p=e.role==="screen"?h:null,m=l?h?pe(o.stageWall,fe(h,.58),.82):o.stageWall:e.role==="screen"?p?pe(fe(p,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ce(Q(e.fill),o.decorWall);if(c.kind==="portal"&&s.length===4){let f=Do(s);Re(t,pt(f,0,.16),d,n,u,m),Re(t,pt(f,.84,1),d,n,u,m),Re(t,f,d,Math.max(n,d-.35),u,m);return}if(c.kind==="suite"&&s.length===4){let f=s.map((b,S)=>{let C=s[(S+1)%4],P=(b.x+C.x)/2,v=(b.y+C.y)/2;return Math.hypot(P-r.x,v-r.y)}),x=f.indexOf(Math.min(...f)),y=[0,1,2,3].map(b=>s[(x+b)%4]);Re(t,pt(y,0,.08),d,n,u,m),Re(t,pt(y,.92,1),d,n,u,m),Re(t,ko(y,.88,1),d,n,u,m),Re(t,y,d,Math.max(n,d-.18),u,m);return}Re(t,s,d,n,u,m)}function pn(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),d=i/2,h=o/2;return[[-d,-h],[d,-h],[d,h],[-d,h]].map(([u,p])=>({x:r+u*l-p*c,y:a+u*c+p*l}))}function Vi(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 Q(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=Q(s[1].trim());l&&a.push(l)}return a.length?a.reduce((s,l,c)=>pe(s,l,1/(c+1)),a[0]):null}function Oo(t,e,n,i){if(e.layer==="foreground")return;let o=pn(e);if(!o)return;let r=n+Oi,a=Ce(Vi(e.href),i.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=pe(i.ground,a,s)),ie(t,o,void 0,()=>r,n,a,pe(a,i.decorWall,.5),re)}function Vo(t,e,n,i,o){if(!e.points||e.points.length<3)return;let r=Ce(i,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,r,o.gaWall,re)}var Ni=.25,zi=1.2,Gi=.6,Hi=.45,Ui=2.3,Yi=Math.PI/180;function Ye(t,e,n){let i=n*Yi;return{x:t.x+e*Math.sin(i),y:t.y+e*Math.cos(i)}}function Xi(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 Wi=24;function ji(t,e,n,i,o,r,a,s){let l=n.binCount,c=Wi,d=ke,h=r+.02,u=[];for(let g=0;g<l;g++){let M=(n.startBin+g+.5)*e.binStepDeg,F=new Float64Array(c+1);for(let I=0;I<=c;I++){let k=i[g]+(o[g]-i[g])*I/c;F[I]=Math.max(h,Un(e,n,M,k)-Ni)}u.push(F)}let p=[a.bandTop[0]*s.top,a.bandTop[1]*s.top,a.bandTop[2]*s.top],m=[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],y=(g,M)=>{let F=(n.startBin+g+.5)*e.binStepDeg,I=i[g]+(o[g]-i[g])*M/c,k=Ye(e.centre,I,F);return[k.x*d,u[g][M],k.y*d]};{let g=Math.tan(12*Math.PI/180);for(let M=0;M<6;M++){let F=!1;for(let k=0;k<l;k++)for(let U=c-1;U>=0;U--)u[k][U]>u[k][U+1]&&(u[k][U]=u[k][U+1],F=!0);let I=n.closed?l:l-1;for(let k=0;k<I;k++){let U=(k+1)%l;for(let w=0;w<=c;w++){let R=u[U][w]-u[k][w];if(Math.abs(R)>1)continue;let _=i[k]+(o[k]-i[k])*w/c,H=i[U]+(o[U]-i[U])*w/c,V=Ye(e.centre,_,(n.startBin+k+.5)*e.binStepDeg),z=Ye(e.centre,H,(n.startBin+U+.5)*e.binStepDeg),O=g*Math.hypot(z.x-V.x,z.y-V.y)*d;R>O?(u[U][w]=u[k][w]+O,F=!0):-R>O&&(u[k][w]=u[U][w]+O,F=!0)}}if(!F)break}}let b=1,S=(g,M)=>{for(let F=0;F<=c;F+=4)if(Math.abs(u[g][F]-u[M][F])>b)return!0;return Math.abs(u[g][c]-u[M][c])>b},C=Math.tan(38*Math.PI/180),P=g=>(o[g]-i[g])/c*d,v=(g,M)=>u[g][M+1]-u[g][M]>C*Math.max(1e-6,P(g)),T=(g,M)=>{let F=n.closed?(g-1+l)%l:Math.max(0,g-1),I=n.closed?(g+1)%l:Math.min(l-1,g+1);Math.abs(u[F][M]-u[g][M])>b&&(F=g),Math.abs(u[I][M]-u[g][M])>b&&(I=g);let k=Math.max(0,M-1),U=Math.min(c,M+1);k<M&&v(g,k)&&(k=M),U>M&&v(g,M)&&(U=M);let w=y(F,M),R=y(I,M),_=y(g,k),H=y(g,U),V=R[0]-w[0],z=R[1]-w[1],O=R[2]-w[2],W=H[0]-_[0],Y=H[1]-_[1],K=H[2]-_[2],q=z*K-O*Y,ne=O*W-V*K,oe=V*Y-z*W,$=Math.hypot(q,ne,oe);return $>1e-12?(q/=$,ne/=$,oe/=$,ne<0&&(q=-q,ne=-ne,oe=-oe),[q,ne,oe]):[0,1,0]},E=(g,M)=>{let F=[g[0],r,g[2]],I=[M[0],r,M[2]],k=M[0]-g[0],U=M[2]-g[2],w=Math.hypot(k,U);if(!(w>1e-12))return;let R=[U/w,0,-k/w];t.tri(g,M,I,R,f,f,x),t.tri(g,I,F,R,f,x,x)},L=.05*_e,G=g=>o[g]-i[g]<L,N=n.closed?l:l-1;for(let g=0;g<N;g++){let M=(g+1)%l;if(G(g)||G(M))continue;if(S(g,M)){let R=(n.startBin+g+1)*e.binStepDeg,_=(Y,K)=>{let q=(i[g]+i[M])/2,ne=(o[g]+o[M])/2,oe=q+(ne-q)*K/c,$=Ye(e.centre,oe,R);return[$.x*d,u[Y][K],$.y*d]};for(let Y=0;Y<c;Y++){let K=y(g,Y),q=y(g,Y+1),ne=_(g,Y),oe=_(g,Y+1),$=T(g,Y),ae=T(g,Y+1);t.triN(K,ne,oe,$,$,ae,p),t.triN(K,oe,q,$,ae,ae,p);let Oe=y(M,Y),Ve=y(M,Y+1),xe=_(M,Y),Ie=_(M,Y+1),Fe=T(M,Y),ge=T(M,Y+1);t.triN(xe,Oe,Ve,Fe,Fe,ge,p),t.triN(xe,Ve,Ie,Fe,ge,ge,p);let he=_(g,Y),se=_(g,Y+1),je=_(M,Y+1),ve=_(M,Y),Ke=se[0]-he[0],Me=se[2]-he[2],Te=Math.hypot(Ke,Me);if(Te>1e-12){let xt=[Me/Te,0,-Ke/Te];t.tri(he,se,je,xt,f),t.tri(he,je,ve,xt,f)}}let H=y(g,0),V=y(M,0),z=y(M,c),O=y(g,c),W=Y=>[Y[0],r,Y[2]];t.tri(W(H),W(z),W(V),[0,-1,0],m),t.tri(W(H),W(O),W(z),[0,-1,0],m),E(H,V),E(O,z);continue}for(let R=0;R<c;R++){let _=T(g,R),H=T(M,R),V=T(M,R+1),z=T(g,R+1);if(v(g,R)||v(M,R)){let q=(se,je)=>{let ve=(n.startBin+se+.5)*e.binStepDeg,Ke=i[se]+(o[se]-i[se])*(R+.5)/c,Me=Ye(e.centre,Ke,ve);return[Me.x*d,je,Me.y*d]},ne=y(g,R),oe=y(M,R),$=q(g,u[g][R]),ae=q(M,u[M][R]);t.triN(ne,oe,ae,_,H,H,p),t.triN(ne,ae,$,_,H,_,p);let Oe=y(M,R+1),Ve=y(g,R+1),xe=q(g,u[g][R+1]),Ie=q(M,u[M][R+1]);t.triN(xe,Ie,Oe,z,V,V,p),t.triN(xe,Oe,Ve,z,V,z,p);let Fe=ae[0]-$[0],ge=ae[2]-$[2],he=Math.hypot(Fe,ge);if(he>1e-12){let se=[-ge/he,0,Fe/he];t.tri($,ae,Ie,se,f),t.tri($,Ie,xe,se,f)}continue}let O=y(g,R),W=y(M,R),Y=y(M,R+1),K=y(g,R+1);t.triN(O,W,Y,_,H,V,p),t.triN(O,Y,K,_,V,z,p)}let F=y(g,0),I=y(M,0),k=y(M,c),U=y(g,c),w=R=>[R[0],r,R[2]];t.tri(w(F),w(k),w(I),[0,-1,0],m),t.tri(w(F),w(U),w(k),[0,-1,0],m),E(F,I),E(U,k)}if(!n.closed)for(let g of[0,l-1])for(let M=0;M<c;M++)E(y(g,M),y(g,M+1))}function No(t,e,n){let{bottomY:i,colors:o,ao:r}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let d of e.rings)for(let h of d.arcs){let u=new Float64Array(h.binCount),p=new Float64Array(h.binCount);for(let f=0;f<h.binCount;f++){let x=(h.startBin+f)%e.binCount,y=Math.max(0,h.innerR[f]-be);u[f]=Math.max(y,a[x]+.001),p[f]=Math.max(u[f]+.001,h.outerR[f]+be)}let m=0;for(let f=0;f<h.binCount;f++){let x=h.topLevelM[f]-i;x>m&&(m=x)}m>=zi&&ji(t,e,h,u,p,i,o,r);for(let f=0;f<h.binCount;f++){let x=(h.startBin+f)%e.binCount;p[f]>a[x]&&(a[x]=p[f])}}if(Xi(n.shapes,e))return;let s=e.rings[e.rings.length-1],l=Gi*_e,c=Hi*_e;for(let d of s.arcs){let h=[],u=[];for(let f=0;f<d.binCount;f++){let x=(d.startBin+f+.5)*e.binStepDeg,y=d.outerR[f]+be+l;h.push(Ye(e.centre,y,x)),u.push(Ye(e.centre,y+c,x))}let p=-1/0;for(let f=0;f<d.binCount;f++)d.topLevelM[f]>p&&(p=d.topLevelM[f]);let m=()=>p+Ui;d.closed?ie(t,u,[h.slice().reverse()],m,i,o.shellTop,o.shellWall,r):ie(t,[...u,...h.slice().reverse()],void 0,m,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=Ce(i,s.tierTop);if(!o)return;let d=x=>o.deckAt(x.x,x.y),h=Ao(e,a),u=h[0]??e.outline;if(o.rowLevels.length>=2){let x=Lt(o.rowLevels),y=Co(go(o.rowLevels,n.focal,x),h),b=()=>[0,1,0];for(let C of y){let P=Math.max(l,C.topY-.02);for(let v of r.subtract(C.outline,P))ie(t,v,C.holes,()=>P,l,c,s.tierWall,re,void 0,b)}y.length||ie(t,u,e.holes,()=>o.landingY,l,c,s.tierWall,re);let S={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 C of h.length?h:[u])Mo(t,o.rowLevels,n.focal,o.landingY,S,C,x);return}let p=o.flat?1/0:Ro,m=x=>o.normalAt(x.x,x.y),f=o.flat?o.landingY:void 0;for(let x of r.subtract(u,f))ie(t,x,e.holes,d,l,c,s.tierWall,re,p,m)}function Ki(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],d=o.get(s);d||(d=new Map,o.set(s,d));let h=c.rowId||`__seat-${a}`,u=d.get(h);u||(u={pts:[],levelM:0,n:0},d.set(h,u)),u.pts.push({x:c.x,y:c.y}),u.levelM+=n.seatDeckY(a),u.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(d=>!d.patch).map(d=>({pts:d.pts,levelM:d.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=Ki(e,n,i);if(!r.length)return;let a=Hn(r,e.focal);a&&(t.setMaterial(0),No(t,a,{bottomY:e.baseHeightM,colors:{bandTop:fe(o.tierTop,.8),bandWall:o.tierWall,shellTop:fe(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 qi=1.15,Zi=3.25,Qi=4.5,$i=.85,Ji=.5,ea=.26;function Yo(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>=qi&&a.add("zone"),o<=(r?Zi:Qi)&&(a.add("section"),a.add("ga")),o<=$i&&(a.add("annotation"),a.add("booth")),o<=Ji&&a.add("row"),o<=ea&&a.add("seat"),a}function Be(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],d=o[2]*r+o[6]*a+o[10]*s+o[14],h=o[3]*r+o[7]*a+o[11]*s+o[15];if(!(h>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let u=l/h,p=c/h,m=d/h,f=u>=-1.05&&u<=1.05&&p>=-1.05&&p<=1.05&&m<=1;return{x:(u*.5+.5)*n,y:(1-(p*.5+.5))*i,depth:m,visible:f}}function Xo(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)if(fn(r,s,e,n)){a=!0;break}a||i.push(r)}return i}var ta=6;function fn(t,e,n,i){let o=Math.abs(t.screen.x-e.screen.x),r=Math.abs(t.screen.y-e.screen.y),a=t.halfWidth!=null&&e.halfWidth!=null?Math.max(n,t.halfWidth+e.halfWidth+ta):n;return o<a&&r<i}function Wo(t,e,n){return t.length*e*.58+(n?14:0)}var bn={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 yn(t,e,n,i,o=[]){let r=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),a=[];for(let s of r){if(a.length>=i)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 na=6,oa=2.2,Ko=.1,ra=.3,ia=1.8,aa=.9,sa=.55,ca=6e3;function qo(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 d of n)for(let h of d.objects)h.type==="section"&&h.zone&&l.set(h.id,h.zone);let c=new Map;for(let d=0;d<i.length;d++){let h=i[d],u=o.seatOwner[d],p=h.zoneId??(u?l.get(u):void 0);if(!p)continue;let m=c.get(p);m||(m={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(p,m)),m.n++,h.x<m.minX&&(m.minX=h.x),h.y<m.minY&&(m.minY=h.y),h.x>m.maxX&&(m.maxX=h.x),h.y>m.maxY&&(m.maxY=h.y),m.sumY+=o.seatDeckY(d)}for(let d of a){let h=c.get(d.id),u=[];for(let[p,m]of l)m===d.id&&u.push(p);if(!h||h.n===0){s.push({id:d.id,label:d.label,color:Q(d.color),sectionIds:u,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(d.focalPoint??r).x*A,1.5,(d.focalPoint??r).y*A]});continue}s.push({id:d.id,label:d.label,color:Q(d.color),sectionIds:u,seatCount:h.n,center:[(h.minX+h.maxX)/2*A,h.sumY/h.n,(h.minY+h.maxY)/2*A],radius:.5*Math.hypot((h.maxX-h.minX)*A,(h.maxY-h.minY)*A)||1,focalWorld:[(d.focalPoint??r).x*A,1.5,(d.focalPoint??r).y*A]})}}return s}function Zo(t){let{doc:e,units:n,seats:i,surfaces:o,seatData:r,hintedSeatFloor:a,zones:s,focal:l}=t,c=[],d=[],h=[];for(let u of s)u.seatCount!==0&&c.push({id:`zone:${u.id}`,kind:"zone",text:u.label,anchor:[u.center[0],u.center[1]+na,u.center[2]],color:e.zones?.find(p=>p.id===u.id)?.color});{let u=new Map,p=new Map;for(let m=0;m<i.length;m++){let f=o.seatOwner[m];if(!f)continue;let x=u.get(f);x||(x={n:0,x:0,y:0,deck:0},u.set(f,x)),x.n++,x.x+=i[m].x,x.y+=i[m].y,x.deck+=o.seatDeckY(m);let y=p.get(f);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},p.set(f,y)),i[m].x<y.minX&&(y.minX=i[m].x),i[m].x>y.maxX&&(y.maxX=i[m].x),i[m].y<y.minY&&(y.minY=i[m].y),i[m].y>y.maxY&&(y.maxY=i[m].y)}for(let m of n)for(let f of m.objects){if(f.type!=="section")continue;let x=u.get(f.id);if(!x||x.n===0)continue;let y=p.get(f.id),b=[x.x/x.n*A,x.deck/x.n,x.y/x.n*A],S=f.displayLabel||f.label||f.id;d.push({id:f.id,floorIndex:m.index,label:S,seatCount:x.n,center:b,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*A),focalWorld:[m.focal.x*A,m.baseHeightM+1.5,m.focal.y*A]});let C=e.floors?.[m.index]?.name?.trim().toLocaleLowerCase();n.length>1&&C===S.trim().toLocaleLowerCase()||c.push({id:`section:${f.id}`,kind:"section",text:S,anchor:[b[0],b[1]+oa,b[2]],floorIndex:m.index})}}{for(let m of n)for(let f of m.objects){if(f.type!=="gaArea")continue;let x=rt(f.points);if(!x)continue;let y=f.displayLabel||f.label||f.id;c.push({id:`ga:${f.id}`,kind:"ga",text:f.capacity>0?`${y} \xB7 ${f.capacity.toLocaleString()}`:y,anchor:[x.x*A,m.baseHeightM+ia,x.y*A],floorIndex:m.index})}let u=new Map;for(let m=0;m<i.length;m++){let f=i[m],x=Math.hypot(f.x-l.x,f.y-l.y),y=u.get(f.rowId);(!y||x>y.far)&&u.set(f.rowId,{seat:f,index:m,far:x})}for(let[m,f]of u){let x=f.seat.label?f.seat.label.lastIndexOf("-"):-1,y=x>0?f.seat.label.slice(0,x):m;y&&c.push({id:`row:${m}`,kind:"row",text:y,anchor:[f.seat.x*A,o.seatDeckY(f.index)+aa,f.seat.y*A],floorIndex:a[f.index]})}let p=new Map;for(let m=0;m<i.length;m++){let f=i[m],x=f.label?f.label.lastIndexOf("-"):-1,y=p.get(f.rowId);y||(y={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,y));let b=m*3,S=r.iPosition[b],C=r.iPosition[b+1],P=r.iPosition[b+2];y.n++,y.x+=S,y.y+=C,y.z+=P,y.minX=Math.min(y.minX,S),y.maxX=Math.max(y.maxX,S),y.minZ=Math.min(y.minZ,P),y.maxZ=Math.max(y.maxZ,P)}for(let[m,f]of p)h.push({id:m,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(i.length<=ca)for(let m=0;m<i.length;m++){let f=i[m],x=f.displayLabel||f.label;x&&c.push({id:`seat:${f.id}`,kind:"seat",text:x,anchor:[f.x*A,o.seatDeckY(m)+sa,f.y*A],floorIndex:a[m]})}}for(let u of n)for(let p of u.objects)if(p.type==="shape"&&p.role&&["entrance","exit","screen","suite","obstruction"].includes(p.role)){let m=dt(p),f=m?rt(m):null;if(!f||!p.label)continue;c.push({id:`architecture:${p.id}`,kind:"annotation",text:p.label,anchor:[f.x*A,u.baseHeightM+ht(p).heightM+Ko,f.y*A],color:p.fill,floorIndex:u.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*A,u.baseHeightM+Ko,p.position.y*A],color:p.color,rotation:p.rotation,floorIndex:u.index})}else if(p.type==="booth"){let m=ft(p);if(!m)continue;let f=rt(m);if(!f)continue;c.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[f.x*A,u.baseHeightM+dn+ra,f.y*A],floorIndex:u.index})}return{labels:c,sections:d,rows:h}}function Qo(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 $o(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 u=0;u<r.floor.length;u+=1){let p=Math.max(0,Math.min(n.length-1,Math.round(r.floor[u]))),m=u*3,f=c[p];f.minX=Math.min(f.minX,r.position[m]),f.minY=Math.min(f.minY,r.position[m+1]),f.minZ=Math.min(f.minZ,r.position[m+2]),f.maxX=Math.max(f.maxX,r.position[m]),f.maxY=Math.max(f.maxY,r.position[m+1]),f.maxZ=Math.max(f.maxZ,r.position[m+2])}let d=new Map;for(let u=0;u<n.length;u++)for(let p of n[u].objects)p.type==="section"&&d.set(p.id,u);let h=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 u=0;u<i.length;u++){let p=o.seatOwner[u],m=(p!==null?d.get(p):void 0)??a[u];if(m===void 0)continue;let f=h[m],x=i[u];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 y=o.seatDeckY(u);f.sumX+=x.x*A,f.sumDeck+=y,f.sumZ+=x.y*A,f.minDeck=Math.min(f.minDeck,y),f.maxDeck=Math.max(f.maxDeck,y+1.6),s[u]=m}for(let u=0;u<n.length;u++){let p=h[u],m=e.floors?.[u],f=c[u],x=Math.min(p.n?p.minX*A:n[u].focal.x*A-1,Number.isFinite(f.minX)?f.minX:1/0),y=Math.max(p.n?p.maxX*A:n[u].focal.x*A+1,Number.isFinite(f.maxX)?f.maxX:-1/0),b=Math.min(p.n?p.minY*A:n[u].focal.y*A-1,Number.isFinite(f.minZ)?f.minZ:1/0),S=Math.max(p.n?p.maxY*A:n[u].focal.y*A+1,Number.isFinite(f.maxZ)?f.maxZ:-1/0),C=Math.min(p.n?Math.min(n[u].baseHeightM,p.minDeck):n[u].baseHeightM,Number.isFinite(f.minY)?f.minY:1/0),P=Math.max(p.n?Math.max(p.maxDeck,C+.5):C+.5,Number.isFinite(f.maxY)?f.maxY:-1/0),v=[p.n?p.sumX/p.n:(x+y)/2,p.n?p.sumDeck/p.n:(C+P)/2,p.n?p.sumZ/p.n:(b+S)/2],T=Math.max(1,.5*Math.hypot(y-x,P-C,S-b));l.push({index:u,id:m?.id??`floor-${u}`,label:m?.name??(n.length>1?`Floor ${u+1}`:"Venue"),seatCount:p.n,center:v,radius:T,box:{min:[x,C,b],max:[y,P,S]},focalWorld:[n[u].focal.x*A,n[u].baseHeightM+1.5,n[u].focal.y*A]})}}return l}function xn(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=ft(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,i=-100,o=100,r=100),{minX:n,minY:i,maxX:o,maxY:r}}function Jo(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=mt(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,m)=>m.baseHeightM<p.baseHeightM?m:p);t.setFloor(a.index);let s=n.filter((p,m)=>i[m]===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)),h=mt(l.minX-d,l.minY-d,l.maxX-l.minX+d*2,l.maxY-l.minY+d*2),u=a.baseHeightM-.03;ie(t,h,void 0,()=>u,u-.22,r.ground,r.ground,re)}}function er(t,e,n){let{cx:i,cz:o,radius:r}=n,a=1/0,s=1/0,l=1/0,c=-1/0,d=-1/0,h=-1/0,u=(f,x,y)=>{a=Math.min(a,f),c=Math.max(c,f),s=Math.min(s,x),d=Math.max(d,x),l=Math.min(l,y),h=Math.max(h,y)};for(let f=0;f<t.position.length;f+=3)u(t.position[f],t.position[f+1],t.position[f+2]);for(let f=0;f<e.count;f++){let x=f*3,y=e.iPosition[x],b=e.iPosition[x+1],S=e.iPosition[x+2],C=Math.max(.35,e.iMaxRadius[f]??.35);u(y-C,b,S-C),u(y+C,b+1.6,S+C)}Number.isFinite(a)||(a=i-r,c=i+r,s=0,d=r*.16,l=o-r,h=o+r);let p=[(a+c)/2,(s+d)/2,(l+h)/2],m=Math.max(1,.5*Math.hypot(c-a,d-s,h-l));return{center:p,radius:m,minY:s,maxY:d}}function tr(t,e,n,i,o,r){let a=1/0,s=1/0,l=-1/0,c=-1/0;for(let C=0;C<t.count;C++){let P=C*3,v=t.iPosition[P],T=t.iPosition[P+2];v<a&&(a=v),v>l&&(l=v),T<s&&(s=T),T>c&&(c=T)}for(let C of e)a=Math.min(a,C.cx-C.halfX),l=Math.max(l,C.cx+C.halfX),s=Math.min(s,C.cz-C.halfZ),c=Math.max(c,C.cz+C.halfZ);let d=n.minX*A,h=n.maxX*A,u=n.minY*A,p=n.maxY*A,m=d,f=h,x=u,y=p;if(Number.isFinite(a)){let C=Math.max(2,.06*Math.hypot(l-a,c-s));m=Math.max(d,a-C),f=Math.min(h,l+C),x=Math.max(u,s-C),y=Math.min(p,c+C)}let b=Math.min(0,i),S=Math.max(o,r*.05);return{min:[m,b,x],max:[f,S,y]}}function bt(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 M of o)for(let F of M.objects)s.set(F.id,M.index),F.type==="section"&&s.set(F.logicalSectionId??F.id,M.index);let l=r.map(M=>s.get(M.sectionId??"")??s.get(M.rowId??"")??0),c=xn(o,r);Jo(a,o,r,l,c,i);let d=Fo(e,r),h=new Map,u=new Map;for(let M of e.categories??[])h.set(M.key,M.color),M.seatGlyph&&u.set(M.key,M.seatGlyph);let p=[],m=Io(o,r,l),f=new Float32Array(r.length);for(let M=0;M<o.length;M++){let F=o[M];a.setFloor(M);let I=new Bt,k=[],U=F.objects.filter(w=>w.type==="section"&&!!w.outline&&w.outline.length>=3);for(let w of F.objects)w.type==="section"?zo(a,w,F,To(w,d),m.bySection.get(w.id),I,U,i):w.type==="shape"?(a.setMaterial(w.role==="screen"?1:0),Bo(a,w,F.baseHeightM,Eo(w,k),i,F.focal,p),a.setMaterial(0)):w.type==="gaArea"?Vo(a,w,F.baseHeightM,Q(h.get(w.categoryKey)),i):w.type==="booth"?_o(a,w,F.baseHeightM,Q(h.get(w.categoryKey)),i):w.type==="table"?Lo(a,w,F.baseHeightM,Q(h.get(w.categoryKey)),i):w.type==="decorImage"&&Oo(a,w,F.baseHeightM,i);Go(a,F,r,m,i)}let x=o.length>1?{x:o.reduce((M,F)=>M+F.focal.x,0)/o.length,y:o.reduce((M,F)=>M+F.focal.y,0)/o.length}:e.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},y=no([a.build()]),b=so(r,t.initialState,m,f,h,u),S=qo({doc:e,units:o,seats:r,surfaces:m,focal:x}),{labels:C,sections:P,rows:v}=Zo({doc:e,units:o,seats:r,surfaces:m,seatData:b,hintedSeatFloor:l,zones:S,focal:x}),T=$o({doc:e,units:o,seats:r,surfaces:m,solids:y,hintedSeatFloor:l,seatFloor:f});Qo(C,T),b.iYaw=io(b.iPosition,r.length,M=>r[M].rowId,M=>{let F=o[f[M]]?.focal??x;return[F.x*A,F.y*A]});let E=(c.minX+c.maxX)/2*A,L=(c.minY+c.maxY)/2*A,G=.5*Math.hypot((c.maxX-c.minX)*A,(c.maxY-c.minY)*A)||10,N=er(y,b,{cx:E,cz:L,radius:G}),g=tr(b,p,c,N.minY,N.maxY,G);return{solids:y,seats:b,bounds:{center:[(g.min[0]+g.max[0])/2,(g.min[1]+g.max[1])/2,(g.min[2]+g.max[2])/2],radius:G,groundY:0,box:g},renderBounds:{center:N.center,radius:N.radius},stateColorLUT:lo(n,ye),theme:n,seatCount:r.length,focalWorld:[x.x*A,1.5,x.y*A],zones:S,stages:p,sections:P,rows:v,labels:C,floors:T}}var la=88,ua=20,nr={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}},Ot=new Set(["row","seat"]),or={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},Vt={row:{x:62,y:16},seat:{x:46,y:18}},rr=Q,gn=t=>Bn(t);function ir(t,e){let n=gn(t),i=gn(e);return(Math.max(n,i)+.05)/(Math.min(n,i)+.05)}function vn(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 ma(t,e=[.04,.06,.1],n=!0){let i=gn(e)<.42,o=i?"#f4f7fb":"#0b1220",r=i?"rgba(8,12,22,.78)":"rgba(255,255,255,.84)",a=n?vn(r,e):e,s=rr(t),l=n?7:4.5,c=s&&ir(s,a)>=l?t:o;return i?{ink:c,backing:r,border:"rgba(210,222,245,.24)"}:{ink:c,backing:r,border:"rgba(11,18,32,.22)"}}var Nt=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=Yo(o,r,{hasZoneLabels:this.labels.some(b=>b.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let l=[];for(let b of this.labels){if(!s.has(b.kind))continue;let S=Be(e,b.anchor,n,i);if(!S.visible)continue;let C=a?Math.hypot(b.anchor[0]-a[0],b.anchor[1]-a[1],b.anchor[2]-a[2]):1;l.push({label:b,screen:S,focus:jo(S,C,n,i),halfWidth:Wo(b.text,nr[b.kind].size,!Ot.has(b.kind))/2,...this.selectedSeatLabelIds.has(b.id)?{priority:1}:{}})}let c=Uo(l.filter(b=>b.label.kind==="floor"),n),d=[...l.filter(b=>!Ot.has(b.label.kind)&&b.label.kind!=="floor"),...c],h=Xo(d,la,ua),u=yn(l.filter(b=>b.label.kind==="row"),Vt.row.x,Vt.row.y,bn.row,h),p=yn(l.filter(b=>b.label.kind==="seat"),Vt.seat.x,Vt.seat.y,bn.seat,[...h,...u]),m=[...h,...u,...p],f=new Set(m.map(b=>b.label.id));for(let{label:b,screen:S}of m){let P=this.nodeFor(b).style;P.display="",P.transform=`translate(-50%, -50%) translate(${S.x.toFixed(1)}px, ${S.y.toFixed(1)}px)`}let x=m.filter(({label:b})=>!Ot.has(b.kind)).sort((b,S)=>or[S.label.kind]-or[b.label.kind]||b.screen.depth-S.screen.depth||b.focus-S.focus),y=[];for(let{label:b}of x){let S=this.nodes.get(b.id);if(!S||S.style.display==="none")continue;let C=S.getBoundingClientRect();y.some(v=>C.left<v.right+3&&C.right+3>v.left&&C.top<v.bottom+3&&C.bottom+3>v.top)?S.style.display="none":y.push(C)}for(let[b,S]of this.nodes)f.has(b)||(S.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let h=n.style;h.position="absolute",h.left="0",h.top="0",h.whiteSpace="nowrap",h.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",h.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=nr[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=!Ot.has(e.kind),s=ma(e.color??this.opts.ink,this.opts.backgroundRgb,a);r.color=i?"#ecf8ff":s.ink,r.background=i?"rgba(10,28,45,.9)":a?s.backing:"",r.border=i?"1px solid rgba(89,199,255,.92)":a?`1px solid ${s.border}`:"",r.borderRadius=i||a?"999px":"",r.padding=i||a?"3px 7px":"",r.boxShadow=i?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":a?"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=rr(i?"#ecf8ff":s.ink)??[1,1,1],d=i?vn("rgba(10,28,45,.9)",l):a?vn(s.backing,l):l;return n.dataset.qualityContrast=ir(c,d).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(r.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var da=1;var ha=new Set(["floor","zone","section","ga","booth","annotation"]);function pa(t){return t.every(e=>Number.isFinite(e))}function fa(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 ar(t){return t.length?Math.round(Math.min(...t)*100)/100:null}function Xe(t){return Math.round(t*1e4)/1e4}function ba(t){if(t)return{box:{x:Xe(t.box.x),y:Xe(t.box.y),width:Xe(t.box.width),height:Xe(t.box.height)},horizontalFillRatio:Xe(t.horizontalFillRatio),verticalFillRatio:Xe(t.verticalFillRatio),visibleAreaRatio:Xe(t.visibleAreaRatio),clippedEdges:[...t.clippedEdges]}}function Pe(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function Mn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>ha.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)fa(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=[Pe("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Pe("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Pe("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Pe("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}`}]),Pe("camera-invalid","The capture camera must have a finite physical pose",pa(r)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Pe("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}]),Pe("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`}]),Pe("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}))),Pe("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}))),Pe("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:ba(t.framing)},metrics:{minimumHierarchyFontPx:ar(n.map(s=>s.renderedFontPx)),minimumHierarchyContrast:ar(n.map(s=>s.contrast)),projectedReliefPx:Math.round(t.scene.projectedReliefPx*100)/100},findings:a}}import{Geometry as Gt,Mesh as Ht,Transform as br}from"ogl";import{Program as We}from"ogl";var zt=`
1
+ import{a as Hn,c as Un,d as Yn}from"../chunk-BV6FHURE.js";import{c as kn}from"../chunk-3TAVIEVO.js";import{d as Gn}from"../chunk-T2LWVOQ3.js";import{e as Dn,l as Ge,n as st,o as zn,q as Pt}from"../chunk-VI3IZS2B.js";import{e as Vn,k as Nn}from"../chunk-UL5OIGIF.js";import{W as ke,X as _e,ea as St,ga as Ln,ha as wt,ja as Bn,l as _n,m as it,va as Qt}from"../chunk-I6DNJFRF.js";import{d as Q,k as On,x as pe,z as at}from"../chunk-CXF32VPG.js";import"../chunk-CRCGO52K.js";import{Renderer as Yr}from"ogl";var ye=["available","held","sold","selected","dimmed"];function ct(t){let e=ye.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 Wn(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]},He={top:[.05,.06,.08],bottom:[.1,.12,.15]};function fe(t,e){return[Math.min(1,t[0]*e),Math.min(1,t[1]*e),Math.min(1,t[2]*e)]}function Xr(){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 Ct=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 Yr({canvas:this.canvas,dpr:Xr(),alpha:!1,antialias:!1,depth:!0,stencil:!1,powerPreference:"high-performance",webgl:2}),this.gl=this.renderer.gl,this.clearRgb=[He.top[0],He.top[1],He.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 Wr,Vec3 as Jt}from"ogl";var ue=Math.PI/180,en=15*ue,tn=80*ue,Ze=.12,jn=35,Kn=1.25,At=class{constructor(e,n,r,o){this.fovY=jn;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 Wr(e,{fov:jn,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 c=this.currentPinchDistance();this.pinchDist>0&&(this.dollyBy(Math.exp((this.pinchDist-c)*.005)),this.fireGesture()),this.pinchDist=c;let l=this.pinchCentroid();this.panBy(l.x-this.pinchCx,l.y-this.pinchCy),this.pinchCx=l.x,this.pinchCy=l.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,c=-i,l=Math.cos(this.polar),u=Math.sin(this.polar),p=-i*l,m=-a*l;this.targetT.x+=(-e*s+n*p)*o,this.targetT.z+=(-e*c+n*m)*o,this.targetT.y+=n*u*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,c=o?Math.max(.82,this.camera.aspect||1):this.camera.aspect||1,l=Math.atan(Math.tan(s)*c);this.azT=r??-30*ue,this.polT=Math.max(15,Math.min(80,i?.polarDeg??55))*ue;let u=this.fitDistance(e,s,l,this.azT,this.polT);this.distT=u*Math.max(1.05,Math.min(2,i?.margin??Kn)),this.minDist=Math.max(2,a*.12),this.maxDist=u*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 c=this.fitDistance(e,i,s,this.azT,this.polT);this.distT=c*Math.max(1.05,Math.min(2,o?.margin??Kn))}fitDistance(e,n,r,o,i){let a=Math.max(1,e.radius),s=Math.max(a/Math.tan(n),a/Math.tan(r)),c=e.box;if(!c)return s;let l=Math.sin(i),u=-l*Math.sin(o),p=-Math.cos(i),m=-l*Math.cos(o);if(Math.abs(p)>.999)return s;let d=-m,h=u,f=Math.hypot(d,h);d/=f,h/=f;let x=-h*p,y=h*u-d*m,b=d*p,M=Math.tan(r),C=Math.tan(n),P=1;for(let g=0;g<8;g++){let T=(g&1?c.max[0]:c.min[0])-e.center[0],E=(g&2?c.max[1]:c.min[1])-e.center[1],L=(g&4?c.max[2]:c.min[2])-e.center[2],G=T*u+E*p+L*m,N=Math.abs(T*d+L*h),v=Math.abs(T*x+E*y+L*b);P=Math.max(P,N/M-G,v/C-G)}return Math.min(s,Math.max(P,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),c=Math.max(s+10,i+a);this.camera.perspective({near:s,far:c,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),c=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*Ze,this.polar+=n*Ze,this.distance+=r*Ze,this.target.x+=o*Ze,this.target.y+=i*Ze,this.target.z+=a*Ze,c&&this.applyPosition(),c}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 Qe=2.5,jr=1.15,lt=6,$e=10,qn=6,Zn=9.5,Qn=.9,$n=2.2,nn=30,on=4,It=8192;var os=$e+on;function Jn(t,e){let n=e*1.4,r=e*3.2;if(t<=n)return{scale:1,fade:0,minPixels:Qe};let o=Math.min(1,(t-n)/Math.max(.001,r-n));return{scale:1-o*.4,fade:o*.55,minPixels:Qe+o*(jr-Qe)}}function eo(t,e,n){return!(t>0)||!(e>0)||!(n>0)?!1:e*n/t>=64}function to(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 Kr from"earcut";import qr from"polygon-clipping";var R=ke,Zr=.002;function Qr(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<Zr}var Ue=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 Ue;this.nor=new Ue;this.col=new Ue;this.flr=new Ue;this.mat=new Ue;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){Qr(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,c=s,l=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(c[0],c[1],c[2]),this.col.push3(l[0],l[1],l[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 $r(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],c=n[2]-t[2],l=o*c-i*s,u=i*a-r*c,p=r*s-o*a,m=Math.hypot(l,u,p)||1;return l/=m,u/=m,p/=m,[l,u,p]}function Jr(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=Kr(r,o.length?o:void 0,2);return{pts:n,tris:i}}function rn(t){return Ge(t)<0?[...t].reverse():t}var ei=3;function ti(t,e,n,r){let o=r(t),i=r(e),a=r(n),s=(d,h,f,x)=>Math.abs(r({x:(d.x+h.x)/2,y:(d.y+h.y)/2})-(f+x)/2),c=(t.x+e.x+n.x)/3,l=(t.y+e.y+n.y)/3,u=(o+i+a)/3,p=Math.max(s(t,e,o,i),s(e,n,i,a),s(n,t,a,o),Math.abs(r({x:c,y:l})-u)),m=(d,h,f)=>{let x=Math.abs(r({x:(d+c)/2,y:(h+l)/2})-(f+u)/2);x>p&&(p=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),p}function ut(t,e,n,r,o){if(o<=0)return ti(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},d={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,d,o,i,a-1,s),mt(t,h,d,r,o,i,a-1,s),mt(t,m,d,h,o,i,a-1,s);return}let c=[e.x*R,o(e),e.y*R],l=[n.x*R,o(n),n.y*R],u=[r.x*R,o(r),r.y*R];if(s){t.triN(c,l,u,s(e),s(n),s(r),i);return}let p=$r(c,l,u);p[1]<0&&(p=[-p[0],-p[1],-p[2]]),t.tri(c,l,u,p,i)}var ni=8;function no(t,e,n){if(!Number.isFinite(n))return t;let r=[],o=(i,a,s,c,l)=>{if(l>0){let u={x:(i.x+a.x)/2,y:(i.y+a.y)/2},p=e(u);if(Math.abs(p-(s+c)/2)>n){o(i,u,s,p,l-1),o(u,a,p,c,l-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),ni)}return r}function Ft(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],c=s.x-i.x,l=s.y-i.y,u=Math.hypot(c,l);u>e&&Math.abs((a.x-i.x)*l-(a.y-i.y)*c)/u<e||r.push(a)}return r.length>=3?r:n}var Tt=.001*_e*.1;function ie(t,e,n,r,o,i,a,s,c=1/0,l){if(!e||e.length<3||(c===void 0&&(c=1/0),Math.abs(Ge(e))<1e-4))return;let u=Ft(no(Ft(rn(e),Tt),r,c),Tt),p=n?.map(g=>Ft(no(Ft(rn(g),Tt),r,c),Tt)).filter(g=>g.length>=3&&Math.abs(Ge(g))>=1e-4),{pts:m,tris:d}=Jr(u,p),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],y=[a[0]*s.wallBottom,a[1]*s.wallBottom,a[2]*s.wallBottom],b=0;if(Number.isFinite(c))for(;b<ei;b++){let g=0;for(let T=0;T<d.length;T+=3){let E=ut(m[d[T]],m[d[T+1]],m[d[T+2]],r,b);E>g&&(g=E)}if(g<=c)break}for(let g=0;g<d.length;g+=3){let T=m[d[g]],E=m[d[g+1]],L=m[d[g+2]];mt(t,T,E,L,r,h,b,l);let G=[T.x*R,o,T.y*R],N=[E.x*R,o,E.y*R],v=[L.x*R,o,L.y*R];t.tri(G,v,N,[0,-1,0],f)}let M=g=>{if(b<=0)return g;let T=1<<b,E=[];for(let L=0;L<g.length;L++){let G=g[L],N=g[(L+1)%g.length];for(let v=0;v<T;v++){let A=v/T;E.push({x:G.x+(N.x-G.x)*A,y:G.y+(N.y-G.y)*A})}}return E},C=_n(u),P=[{ring:M(u),flip:!1}];if(p)for(let g of p)g.length>=3&&P.push({ring:M(g),flip:!0});for(let{ring:g,flip:T}of P)for(let E=0;E<g.length;E++){let L=g[E],G=g[(E+1)%g.length],N=(G.x-L.x)*R,A=(G.y-L.y)*R,F=-N,w=Math.hypot(A,F)||1;A/=w,F/=w;let _=(L.x+G.x)/2-C.x,U=(L.y+G.y)/2-C.y,I=A*_+F*U;T&&(I=-I),I<0&&(A=-A,F=-F);let S=[A,0,F],D=[L.x*R,r(L),L.y*R],H=[G.x*R,r(G),G.y*R],V=[L.x*R,o,L.y*R],z=[G.x*R,o,G.y*R];t.tri(D,H,z,S,x,x,y),t.tri(D,z,V,S,x,y,y)}}function oo(t){let e=0;for(let c of t)e+=c.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 c of t)n.set(c.position,s*3),r.set(c.normal,s*3),o.set(c.color,s*3),i.set(c.floor,s),a.set(c.material,s),s+=c.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 c=r[s],l=r[(s+1)%o],u=l.x-c.x,p=l.y-c.y,m=Math.hypot(u,p)||1;i.push({x:p/m,y:-u/m})}let a=[];for(let s=0;s<o;s++){let c=r[s],l=i[(s-1+o)%o],u=i[s],p=l.x+u.x,m=l.y+u.y,d=Math.hypot(p,m),h=()=>{a.push([c.x+l.x*e,c.y+l.y*e]),a.push([c.x+u.x*e,c.y+u.y*e])};if(d<1e-9){h();continue}p/=d,m/=d;let f=p*l.x+m*l.y,x=1/Math.max(f,1e-6);if(!Number.isFinite(x)||x>n){h();continue}a.push([c.x+p*e*x,c.y+m*e*x])}if(a.length<3)return t;try{let s=qr.union([[...a,a[0]]]),c=null,l=-1/0;for(let p of s){let m=Math.abs(Ge(p[0].map(([d,h])=>({x:d,y:h}))));m>l&&(l=m,c=p[0])}if(!c)return t;let u=c.map(([p,m])=>({x:p,y:m}));if(u.length>1){let p=u[0],m=u[u.length-1];Math.abs(p.x-m.x)<1e-9&&Math.abs(p.y-m.y)<1e-9&&u.pop()}return u.length>=3?u: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 te={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},oi=.44,ri=.15,ii=.3,ai=.24;function ro(t){return t===void 0||!Number.isFinite(t)||t<=0?ai:Math.min(ii,Math.max(ri,t*oi))}var an=.21,si=.05,sn=.45,_t=sn+si,ci=[{part:te.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:te.pad,min:[-1,.36,-.95],max:[1,sn,1]},{part:te.back,min:[-1,_t,-1],max:[1,.92,-.72]},{part:te.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:te.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:te.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:te.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:te.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:te.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:te.leg,min:[.62,0,.48],max:[.82,.37,.7]}],li=[{part:te.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:te.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:te.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:te.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:te.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],ui=[{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 io(){let t=[],e=[],n=[],r=[],o=(w,_,U)=>{let I=n.length,[S,D,H]=w,V=[D[0]-S[0],D[1]-S[1],D[2]-S[2]],z=[H[0]-S[0],H[1]-S[1],H[2]-S[2]],O=V[1]*z[2]-V[2]*z[1],W=V[2]*z[0]-V[0]*z[2],Y=V[0]*z[1]-V[1]*z[0],K=Math.hypot(O,W,Y);K>1e-9?(O/=K,W/=K,Y/=K):[O,W,Y]=_,O*_[0]+W*_[1]+Y*_[2]<0&&(O=-O,W=-W,Y=-Y);for(let q of w)t.push(...q),e.push(O,W,Y),n.push(U);r.push(I,I+1,I+2,I,I+2,I+3)},i=w=>{for(let _ of ui){let U=_.c.map(I=>I.map((S,D)=>S?w.max[D]:w.min[D]));o(U,_.n,w.part)}};for(let w of ci)i(w);for(let w of li)i(w);let a=sn,s=1.08,c=.47,l=.69,u=-.55,p=.08,m=-.48,d=.01,h=[-c,a,u],f=[c,a,u],x=[-c,a,p],y=[c,a,p],b=[-l,s,m],M=[l,s,m],C=[-l,s,d],P=[l,s,d];o([f,M,P,y],[1,0,0],te.body),o([x,C,b,h],[-1,0,0],te.body),o([C,P,M,b],[0,1,0],te.body),o([h,f,y,x],[0,-1,0],te.body),o([y,P,C,x],[0,0,1],te.body),o([h,b,M,f],[0,0,-1],te.body);let g=10,T=8,E=[0,1.205,-.23],L=[.42,.115,.38],G=n.length;for(let w=0;w<=T;w++){let _=Math.PI*w/T,U=Math.cos(_),I=Math.sin(_);for(let S=0;S<=g;S++){let D=Math.PI*2*S/g,H=I*Math.cos(D),V=I*Math.sin(D);t.push(E[0]+L[0]*H,E[1]+L[1]*U,E[2]+L[2]*V);let z=H/L[0],O=U/L[1],W=V/L[2],Y=Math.hypot(z,O,W)||1;z/=Y,O/=Y,W/=Y,e.push(z,O,W),n.push(te.head)}}for(let w=0;w<T;w++)for(let _=0;_<g;_++){let U=G+w*(g+1)+_,I=U+g+1;r.push(U,I,U+1,U+1,I,I+1)}let N=new Float32Array(t),v=new Float32Array(e),A=new Float32Array(n),F=new Uint16Array(r);return{position:N,normal:v,part:A,index:F,vertexCount:n.length,indexCount:r.length}}function ao(t,e,n,r){let o=new Float32Array(e),i=l=>t[l*3],a=l=>t[l*3+2],s=0,c=(l,u)=>{let p=u-l;for(let m=l;m<u;m++){let[d,h]=r(m),f=d-i(m),x=h-a(m);if(p>=2){let y=Math.max(l,m-1),b=Math.min(u-1,m+1),M=i(b)-i(y),C=a(b)-a(y),P=Math.hypot(M,C);if(P>1e-6){let g=-C/P,T=M/P;g*f+T*x<0&&(g=-g,T=-T),f=g,x=T}}o[m]=f===0&&x===0?0:Math.atan2(f,x)}};for(let l=1;l<=e;l++)(l===e||n(l)!==n(s))&&(c(s,l),s=l);return o}var Ce=.22;function so(t,e){let n=ye[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 mi=.42;function di(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),c=Math.max(a-o,1e-6),l=Math.max(Math.sqrt(s*c/e),1e-6),u=Math.max(1,Math.ceil(s/l)+1),p=Math.max(1,Math.ceil(c/l)+1),m=new Map,d=(h,f)=>{let x=Math.min(u-1,Math.max(0,Math.floor((h-r)/l)));return Math.min(p-1,Math.max(0,Math.floor((f-o)/l)))*u+x};for(let h=0;h<e;h++){let f=d(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(u-1,Math.max(0,Math.floor((f.x-r)/l))),y=Math.min(p-1,Math.max(0,Math.floor((f.y-o)/l))),b=1/0;for(let M=1;M<=4;M++){for(let C=y-M;C<=y+M;C++)if(!(C<0||C>=p))for(let P=x-M;P<=x+M;P++){if(P<0||P>=u||M>1&&Math.abs(C-y)<M&&Math.abs(P-x)<M)continue;let g=m.get(C*u+P);if(g)for(let T of g){if(T===h)continue;let E=Math.hypot(t[T].x-f.x,t[T].y-f.y);E<b&&(b=E)}}if(Number.isFinite(b)&&b<=M*l)break}n[h]=b}return n}function hi(t){let e=t.eyeHeightM;return Number.isFinite(e)?Math.max(0,e-St):0}function co(t,e,n,r,o,i){let a=t.length,s=new Float32Array(a*3),c=new Float32Array(a),l=new Float32Array(a*3),u=new Float32Array(a),p=new Float32Array(a),m=new Float32Array(a),d=new Float32Array(a),h=new Float32Array(a*3),f=new Map,x=di(t);for(let y=0;y<a;y++){let b=t[y],C=(n?.seatPitchU(y)??x[y])*R;u[y]=Number.isFinite(C)?Math.max(.06,Math.min(Ce,C*mi)):Ce,p[y]=ro(Number.isFinite(C)?C:void 0);let P=Nn(b.glyph,{seatGlyph:i?.get(b.categoryKey)});m[y]=Vn.indexOf(P),d[y]=b.wheelchairSpaceType==="no-seat"?0:1,s[y*3]=b.x*R,s[y*3+1]=n?n.seatDeckY(y):hi(b),s[y*3+2]=b.y*R,c[y]=ct(e?e(b):"available");let g=Q(o?.get(b.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[y*3]=g[0],l[y*3+1]=g[1],l[y*3+2]=g[2],b.accessibility?.length){let T=Q(Dn(b.accessibility));T&&(h[y*3]=T[0],h[y*3+1]=T[1],h[y*3+2]=T[2])}f.set(b.id,y)}return{count:a,iPosition:s,iState:c,iCategory:l,iMaxRadius:u,iRing:h,idToIndex:f,iChairWidth:p,iGlyph:m,iPhysicalSeat:d,iFloor:r??new Float32Array(a),iYaw:new Float32Array(a)}}var pi=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 c=ct(a.state);t.iState[s]!==c&&(t.iState[s]=c,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+pi){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 fi=.15,bi=.9,yi=1.76,xi=.7,gi=1.6;function vi(){return{background:{top:[...He.top],bottom:[...He.bottom]},structure:$t,seatStates:{...Xn},seatScale:1}}function lo(t){let e=vi();if(!t)return e;let n=Q(t.background);if(n){e.background={top:fe(n,bi),bottom:fe(n,yi)};let i={};for(let[a,s]of Object.entries($t))i[a]=pe(s,n,fi);e.structure=i}let r=Q(t.selectionColor)??Q(t.accent);r&&(e.seatStates={...e.seatStates,selected:r});let o=t.seatScale;return typeof o=="number"&&Number.isFinite(o)&&(e.seatScale=Math.min(gi,Math.max(xi,o))),e}function uo(t,e){let n=[];for(let r of e)n.push(...t.seatStates[r]);return n}import fo from"polygon-clipping";import Mi from"earcut";var Si=.58,mo=.01,be=Ce*1.5*_e,wi=.5,Pi=.6;function Ci(t,e){let n=t.length,r=[];for(let a=0;a<n;a++){let s=t[Math.max(0,a-1)],c=t[Math.min(n-1,a+1)],l=c.x-s.x,u=c.y-s.y,p=Math.hypot(l,u);if(p<1e-9){r.push([0,0]);continue}l/=p,u/=p,r.push([-u,l])}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 Ai(t,e){if(t.length<2||e<=0)return[...t];let n=[...t],r=(a,s)=>{let c=s.x-a.x,l=s.y-a.y,u=Math.hypot(c,l)||1;return{x:c/u,y:l/u}},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 ho=Math.PI/12;function Ri(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 bo(t,e){if(!t.length||!(e>0))return[];let n=Ri(t),r=(s,c,l,u)=>{let p=l-c;for(;p<0;)p+=Math.PI*2;for(;p>Math.PI*2;)p-=Math.PI*2;let m=Math.max(1,Math.ceil(p/ho)),d=e/Math.cos(p/m/2);for(let h=0;h<=m;h++){let f=c+p*h/m;u.push({x:s.x+Math.cos(f)*d,y:s.y+Math.sin(f)*d})}};if(n.length<3){let s=0,c=0;for(let d of n)s+=d.x,c+=d.y;s/=n.length||1,c/=n.length||1;let l=0;for(let d of n)l=Math.max(l,Math.hypot(d.x-s,d.y-c));let u=[],p=Math.max(3,Math.ceil(Math.PI*2/ho)),m=(l+e)/Math.cos(Math.PI/p);for(let d=0;d<p;d++){let h=d/p*Math.PI*2;u.push({x:s+Math.cos(h)*m,y:c+Math.sin(h)*m})}return u}let o=n.length,i=[];for(let s=0;s<o;s++){let c=n[s],l=n[(s+1)%o];i.push(Math.atan2(-(l.x-c.x),l.y-c.y))}let a=[];for(let s=0;s<o;s++)r(n[s],i[(s+o-1)%o],i[s],a);return Mo(a)}function Ii(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,c=a.y-i.y,l=s*s+c*c,u=l>1e-12?((e-i.x)*s+(n-i.y)*c)/l:0;u<0?u=0:u>1&&(u=1);let p=Math.hypot(e-(i.x+u*s),n-(i.y+u*c));p<r&&(r=p)}return r}function Lt(t){let e=t.map(o=>{let i=0,a=0;for(let l of o.pts)i+=l.x,a+=l.y;let s=o.pts.length||1;i/=s,a/=s;let c=0;for(let l of o.pts){let u=Math.hypot(l.x-i,l.y-a);u>c&&(c=u)}return{cx:i,cy:a,rad:c}}),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,c=null;for(let u of i){let p=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let d=e[m],h=Math.hypot(u.x-d.cx,u.y-d.cy)-d.rad;if(h>=p&&h>=s)continue;let f=Ii(t[m].pts,u.x,u.y);f<p&&(p=f),t[m].depth<t[o].depth&&f<s&&(s=f,c=t[m].y)}Number.isFinite(p)&&p>0&&a.push(p)}a.sort((u,p)=>u-p);let l=a.length?a[Math.floor(a.length/2)]:1;r.push({pitch:l,belowY:c})}return r}function yo(t,e,n,r){let o=t[e],i=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let u=o.pts[0],p=u.x-r.x,m=u.y-r.y,d=Math.hypot(p,m)||1;p/=d,m/=d;let h=Math.max(n[e].pitch,.001)*.5;return[{x:u.x+m*h,y:u.y-p*h},{x:u.x-m*h,y:u.y+p*h}]})():[];if(i.length<2)return null;let a=0,s=0;for(let u=1;u<i.length;u++){let p=Math.hypot(i[u].x-i[u-1].x,i[u].y-i[u-1].y);p>1e-6&&(a+=p,s++)}let c=s>0?a/s:0,l=Ai(i,Math.max(c*Pi,be));return{pts:l,nrm:Ci(l,r),front:Math.max(n[e].pitch*Si,be),back:Math.max(n[e].pitch*wi,be)}}var Je=1.5,xo=.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,c=-1;for(let p=1;p<t.length-1;p++){let m=t[p],d=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);d>s&&(s=d,c=p)}if(s<=e||c<0)return[n,r];let l=ln(t.slice(0,c+1),e),u=ln(t.slice(c),e);return[...l.slice(0,-1),...u]}function go(t,e){if(t.length<4)return t;let n=ln([...t,t[0]],e);return n.pop(),n.length>=3?n:t}function vo(t,e,n){if(t.length<2)return[];let r=n??Lt(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 b of a){let M=t[b].patch;M&&M.length>=3?i.push({outline:[...M],holes:[],topY:t[b].y}):s.push(b)}if(!s.length)continue;s.sort((b,M)=>t[b].depth-t[M].depth);let l=s.map(b=>yo(t,b,r,e)).filter(b=>b!==null);if(!l.length)continue;let u=(b,M)=>({x:b.pts[M].x-b.nrm[M][0]*(b.front+Je),y:b.pts[M].y-b.nrm[M][1]*(b.front+Je)}),p=(b,M)=>({x:b.pts[M].x+b.nrm[M][0]*(b.back+Je),y:b.pts[M].y+b.nrm[M][1]*(b.back+Je)}),m=l[0],d=l[l.length-1],h=[];for(let b=0;b<m.pts.length;b++)h.push(u(m,b));for(let b of l)h.push(p(b,b.pts.length-1));for(let b=d.pts.length-1;b>=0;b--)h.push(p(d,b));for(let b=l.length-1;b>=0;b--)h.push(u(l[b],0));let f=Mo(h),x=1/0;for(let b of s)t[b].y<x&&(x=t[b].y);if(!Number.isFinite(x))continue;if(f.length>=3&&Math.abs(Ge(f))>1e-6&&l.every(b=>{let M=b.pts[Math.floor(b.pts.length/2)];return st(f,M.x,M.y)})){i.push({outline:go(f,xo),holes:[],topY:x});continue}for(let b of Fi(l))i.push({outline:b,holes:[],topY:x})}return i}function Fi(t){let e=[];for(let n of t){let r=[],o=[],i=n.front+Je,a=n.back+Je;for(let c=0;c<n.pts.length;c++){let l=n.pts[c],u=n.nrm[c];r.push([l.x-u[0]*i,l.y-u[1]*i]),o.push([l.x+u[0]*a,l.y+u[1]*a])}let s=[...r,...o.reverse()];s.length<3||(s.push(s[0]),e.push([s]))}if(!e.length)return[];try{let n=fo.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(([c,l])=>({x:c,y:l})),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(go(i,xo))}return r}catch{return[]}}function Mo(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 po(t,e,n,r,o,i){if(r.length<3)return;if(n.containsAll(r)){let l=[0,1,0],u=r[0];for(let p=1;p+1<r.length;p++){let m=r[p],d=r[p+1];t.tri([u.x*R,o,u.y*R],[m.x*R,o,m.y*R],[d.x*R,o,d.y*R],l,i)}return}let a=r.map(l=>[l.x,l.y]);a.push(a[0]);let s;try{s=fo.intersection([a],e)}catch{return}let c=[0,1,0];for(let l of s){if(!l.length||l[0].length<4)continue;let u=l[0],p=[],m=[];for(let h=0;h<u.length-1;h++)p.push(u[h][0],u[h][1]),m.push([u[h][0],u[h][1]]);if(m.length<3)continue;let d=Mi(p,void 0,2);for(let h=0;h<d.length;h+=3){let f=m[d[h]],x=m[d[h+1]],y=m[d[h+2]];t.tri([f[0]*R,o,f[1]*R],[x[0]*R,o,x[1]*R],[y[0]*R,o,y[1]*R],c,i)}}}function So(t,e,n,r,o,i,a){if(e.length<2)return;let s=a??Lt(e),c=[0,1,0],l=i&&i.length>=3?[[...i.map(d=>[d.x,d.y]),[i[0].x,i[0].y]]]:null,u=i&&i.length>=3?new un([[...i]]):null,p=d=>{t.setMaterial(2),d(),t.setMaterial(0)},m=d=>{t.setMaterial(3),d(),t.setMaterial(0)};for(let d=0;d<e.length;d++){let h=e[d];if(h.patch&&h.patch.length>=3){let P=[...h.patch],g=s[d].belowY??r;if(m(()=>{if(l&&u)po(t,l,u,P,h.y,o.tread);else{let T=P[0];for(let E=1;E+1<P.length;E++){let L=P[E],G=P[E+1];t.tri([T.x*R,h.y,T.y*R],[L.x*R,h.y,L.y*R],[G.x*R,h.y,G.y*R],c,o.tread)}}}),h.y>g+mo){let T=0,E=0;for(let L of P)T+=L.x,E+=L.y;T/=P.length,E/=P.length,p(()=>{for(let L=0;L<P.length;L++){let G=P[L],N=P[(L+1)%P.length],v=N.x-G.x,A=N.y-G.y,F=Math.hypot(v,A);if(F<1e-6)continue;let w=A/F,_=-v/F;(G.x-T)*w+(G.y-E)*_<0&&(w=-w,_=-_);let U=[w,0,_],I=[G.x*R,h.y,G.y*R],S=[N.x*R,h.y,N.y*R],D=[G.x*R,g,G.y*R],H=[N.x*R,g,N.y*R];t.tri(I,S,H,U,o.riser),t.tri(I,H,D,U,o.riser)}})}continue}let f=yo(e,d,s,n);if(!f)continue;let{pts:x,nrm:y,front:b,back:M}=f,C=s[d].belowY??r;for(let P=0;P+1<x.length;P++){let g=x[P],T=x[P+1],E=y[P],L=y[P+1];if(Math.hypot(T.x-g.x,T.y-g.y)<1e-6||E[0]===0&&E[1]===0||L[0]===0&&L[1]===0)continue;let G=[(g.x-E[0]*b)*R,h.y,(g.y-E[1]*b)*R],N=[(T.x-L[0]*b)*R,h.y,(T.y-L[1]*b)*R],v=[(g.x+E[0]*M)*R,h.y,(g.y+E[1]*M)*R],A=[(T.x+L[0]*M)*R,h.y,(T.y+L[1]*M)*R];if(m(()=>{l&&u?po(t,l,u,[{x:g.x-E[0]*b,y:g.y-E[1]*b},{x:T.x-L[0]*b,y:T.y-L[1]*b},{x:T.x+L[0]*M,y:T.y+L[1]*M},{x:g.x+E[0]*M,y:g.y+E[1]*M}],h.y,o.tread):(t.tri(G,N,A,c,o.tread),t.tri(G,A,v,c,o.tread))}),h.y>C+mo){let F=[G[0],C,G[2]],w=[N[0],C,N[2]],_=[-E[0],0,-E[1]];p(()=>{t.tri(G,N,w,_,o.riser),t.tri(G,w,F,_,o.riser)})}}}}import Po from"polygon-clipping";function Ti(t,e){let n=t.eventConfigurationIds;return!n?.length||!!e&&n.includes(e)}function wo(t,e){return t.filter(n=>n.type!=="shape"||Ti(n,e))}function Co(t,e){let n=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:wo(r.objects,e),focal:{x:(r.focalPoint??n).x,y:(r.focalPoint??n).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:wo(t.objects,e),focal:n,baseHeightM:0,index:0}]}var Ei={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function et(t){return zn(t)??Ei}function Ao(t,e){let n=Dt(t.outline,be),r=et(n),o=e.filter(a=>a!==t&&a.outline&&a.outline.length>=3&&Pt(r,et(a.outline)));if(!o.length)return[n];let i=a=>{let s=a.map(c=>[c.x,c.y]);return s.push(s[0]),s};try{let a=Po.difference([i(n)],...o.map(c=>[i(c.outline)])),s=[];for(let c of a){if(!c.length)continue;let l=c[0].map(([u,p])=>({x:u,y:p}));if(l.length>1){let u=l[0],p=l[l.length-1];Math.abs(u.x-p.x)<1e-9&&Math.abs(u.y-p.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s.length?s:[n]}catch{return[n]}}function Ro(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=Po.intersection([n(i.outline)],r.flat())}catch{o.push(i);continue}for(let s of a){if(!s.length)continue;let c=s[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&o.push({outline:c,holes:[],topY:i.topY})}}return o.length?o:t}var Di=.05,Io=.05,ki=.15,mn=25;function Fo(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),c=new Map,l=[],u=new Set;for(let m=0;m<t.length;m+=1){let d=t[m];for(let h of d.objects){if(h.type==="table"&&u.add(h.id),h.type!=="section"||!h.outline||h.outline.length<3)continue;let f=Dt(h.outline,be);c.set(h.id,{section:h,unit:d,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:h.id,floorIndex:m,box:et(f),section:h,unit:d,outline:f})}}let p=new Map;for(let m of l){let d=p.get(m.floorIndex);d?d.push(m):p.set(m.floorIndex,[m])}for(let m=0;m<e.length;m++){let d=e[m],h=n?p.get(n[m])??[]:l,f=d.sectionId?h.find(y=>y.id===d.sectionId)??h.find(y=>y.section.logicalSectionId===d.sectionId&&Qt({x:d.x,y:d.y},y.outline,y.section.holes)):void 0,x=f?[f]:h;for(let y of x){if(n&&y.floorIndex!==n[m]||!f&&(d.x<y.box.minX||d.x>y.box.maxX||d.y<y.box.minY||d.y>y.box.maxY||!Qt({x:d.x,y:d.y},y.outline,y.section.holes)))continue;o[m]=y.id;let b=c.get(y.id);b.hasSeats=!0;let M=d.focalPoint??y.unit.focal,C=Math.hypot(d.x-M.x,d.y-M.y);C<b.frontU&&(b.frontU=C),b.seatIndices.push(m);let P=d.rowId||`__seat-${m}`,g=b.rows.get(P);g?g.push({x:d.x,y:d.y}):b.rows.set(P,[{x:d.x,y:d.y}]);break}}for(let[m,d]of c){let h=Ln(d.section,{floorBaseHeightM:d.unit.baseHeightM}),f=d.unit.baseHeightM,x=h.rake>0?Math.tan(h.rake*Math.PI/180):0,y=h.rake<=.01&&h.height<=f+.001,b=d.section.surfaceKind,M=b==="flat"?!0:b==="rakedRows"&&h.rake>.01?!1:y,C=d.hasSeats?Bn(m,e,d.seatIndices,d.unit.focal):{sectionId:m,rows:[],blockCount:0},g=C.rows.length<2?Hn([...d.rows.values()].map(I=>({points:I})),d.unit.focal):null,T=1/0;if(g){if(d.hasSeats)for(let I of d.rows.values())for(let S of I){let D=g.depthAt(S.x,S.y);D<T&&(T=D)}if(!d.hasSeats||!Number.isFinite(T)){T=1/0;for(let I of d.section.outline){let S=g.depthAt(I.x,I.y);S<T&&(T=S)}}}let E=f+Di,L=Math.max(E,h.height),G=I=>{let S=Math.max(0,I-T)*ke,D=Math.min(S*x,mn);return Math.max(E,h.height+D)},N=I=>{let S=Math.max(0,I)*ke,D=Math.min(S*x,mn);return Math.max(E,h.height+D)},v=M?[]:C.rows.map(I=>({pts:I.pts,y:N(I.blockDepth),depth:I.blockDepth,blockId:I.blockId,...u.has(I.id)?{patch:bo(I.pts,be)}:{}})),A=v.length?v[0].y:L,F=v.map(I=>{let S=I.patch&&I.patch.length>=3?I.patch:I.pts,D=0,H=0;for(let O of S)D+=O.x,H+=O.y;let V=S.length||1;D/=V,H/=V;let z=0;for(let O of S){let W=Math.hypot(O.x-D,O.y-H);W>z&&(z=W)}return{cx:D,cy:H,rad:z}}),w=M?()=>L:v.length>=2?(I,S)=>{let D=1/0,H=A;for(let V=0;V<v.length;V++){let z=F[V];if(Math.hypot(I-z.cx,S-z.cy)-z.rad>=D)continue;let O=v[V].patch,W=O&&O.length>=3?st(O,I,S)?0:wt(O,I,S):wt(v[V].pts,I,S);W<D&&(D=W,H=v[V].y)}return H}:(I,S)=>g?G(g.depthAt(I,S)):L,_=[0,1,0],U=v.length>=2||M?()=>_:(I,S)=>{if(!g)return _;let D=g.depthAt(I,S);if(D<=T)return _;let H=(D-T)*ke;if(H*x>=mn||h.height+H*x<=E)return _;let[V,z]=g.gradientAt(I,S);if(V===0&&z===0)return _;let O=1/Math.hypot(x,1);return[-V*x*O,O,-z*x*O]};if(!M)for(let I of C.rows){let S=N(I.blockDepth);for(let D of I.seatIndices)a[D]=S}for(let I of C.rows){let S=[];for(let O=1;O<I.pts.length;O++){let W=Math.hypot(I.pts[O].x-I.pts[O-1].x,I.pts[O].y-I.pts[O-1].y);W>1e-6&&S.push(W)}S.sort((O,W)=>O-W);let D=S.length?S[Math.floor(S.length/2)]:1/0,H=1/0,V=I.pts[Math.floor(I.pts.length/2)];if(V)for(let O of C.rows){if(O===I||O.blockId!==I.blockId)continue;let W=wt(O.pts,V.x,V.y);W>1e-6&&W<H&&(H=W)}let z=Math.min(D,Math.max(H,D*.5));if(Number.isFinite(z)&&z>0)for(let O of I.seatIndices)s[O]=z}r.set(m,{sectionId:m,deckAt:w,normalAt:U,flat:M,bottomY:f,rowLevels:v,landingY:A})}for(let m=0;m<e.length;m++){let d=o[m],h=e[m];if(d){let x=a[m];i[m]=(x??r.get(d).deckAt(h.x,h.y))+ki;continue}let f=h.eyeHeightM;i[m]=Number.isFinite(f)?Math.max(0,f-St):0}return{bySection:r,seatOwner:o,seatDeckY:m=>i[m],seatPitchU:m=>s[m]}}var re={top:1,wallBottom:.5,bottomCap:.4};function Ae(t,e){if(!t)return e;let n=fe(at(t,.4),.62);return pe(e,n,.72)}function To(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,c=0,l=0,u=0;for(let[p,m]of a){let d=Q(n.get(p));d&&(s+=d[0]*m,c+=d[1]*m,l+=d[2]*m,u+=m)}u>0&&o.set(i,[s/u,c/u,l/u])}return o}function Eo(t,e){return Q(t.color)??e.get(t.logicalSectionId??t.id)??null}import _i from"polygon-clipping";function Li(t,e){return t===void 0||e===void 0?!0:Math.abs(t-e)<.001}var Bt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(e,n){let r=e.map(c=>[c.x,c.y]);if(r.length<3)return[];r.push(r[0]);let o=et(e),i=this.rings.filter((c,l)=>Pt(o,this.boxes[l])&&Li(n,this.levels[l])),a=[[r]];if(i.length)try{a=_i.difference([r],...i).map(l=>l.map(u=>u.map(([p,m])=>[p,m])))}catch{a=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(n);let s=[];for(let c of a){if(!c.length)continue;let l=c[0].map(([u,p])=>({x:u,y:p}));if(l.length>1){let u=l[0],p=l[l.length-1];Math.abs(u.x-p.x)<1e-9&&Math.abs(u.y-p.y)<1e-9&&l.pop()}l.length>=3&&s.push(l)}return s}};function Bi(t,e){if(!e)return t;let n=1/0,r=-1/0,o=1/0,i=-1/0;for(let p of t)n=Math.min(n,p.x),r=Math.max(r,p.x),o=Math.min(o,p.y),i=Math.max(i,p.y);let a=(n+r)/2,s=(o+i)/2,c=e*Math.PI/180,l=Math.cos(c),u=Math.sin(c);return t.map(p=>{let m=p.x-a,d=p.y-s;return{x:a+m*l-d*u,y:s+m*u+d*l}})}function Ye(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?Bi(e,t.rotation):null}function ht(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"&&Gn(t.stageKind)?{kind:"stage",heightM:.06}:n[e]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var Oi=.08;function Do(t,e){let n=Ye(t),r=ht(t),o=r.heightM;if(!n||r.kind!=="plate"&&r.kind!=="stage")return o;let i=1/0,a=1/0,s=-1/0,c=-1/0;for(let u of n)i=Math.min(i,u.x),a=Math.min(a,u.y),s=Math.max(s,u.x),c=Math.max(c,u.y);let l=o;for(let u of e)s>u.minX&&i<u.maxX&&c>u.minY&&a<u.maxY&&l<=u.topOffsetM+1e-6&&(l=u.topOffsetM+Oi);return e.push({minX:i,minY:a,maxX:s,maxY:c,topOffsetM:l}),l}function Le(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function ko(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 pt(t,e,n){return[Le(t[0],t[1],e),Le(t[0],t[1],n),Le(t[3],t[2],n),Le(t[3],t[2],e)]}function _o(t,e,n){return[Le(t[0],t[3],e),Le(t[1],t[2],e),Le(t[1],t[2],n),Le(t[0],t[3],n)]}function Re(t,e,n,r,o,i){ie(t,e,void 0,()=>n,r,o,i,re)}var dn=2.4,Vi=.75,Ni=.15;function ft(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),c=n/2,l=r/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,p])=>({x:e.x+u*a-p*s,y:e.y+u*s+p*a}))}function Lo(t,e,n,r,o){let i=ft(e);i&&ie(t,i,void 0,()=>n+dn,n,Ae(r,o.boothTop),o.boothWall,re)}function hn(t){if(t.shape==="round"){let u=t.radius;return u?kt(t.center.x,t.center.y,u,u,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),c=e/2,l=n/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,p])=>({x:o.x+u*a-p*s,y:o.y+u*s+p*a}))}function Bo(t,e,n,r,o){let i=hn(e);i&&ie(t,i,void 0,()=>n+Vi,n,Ae(r,o.tableTop),o.tableWall,re)}function Oo(t,e,n,r,o,i,a,s){let c=Ye(e);if(!c)return;let l=s?s.kind==="stage":e.role==="stage",u=s?s.kind==="screen":e.role==="screen",p=s?{kind:l?"stage":"solid",heightM:s.topY-s.baseY}:ht(e),m=s?.baseY??n,d=s?.topY??n+r;if(l&&a){let b=1/0,M=-1/0,C=1/0,P=-1/0;for(let g of c)g.x<b&&(b=g.x),g.x>M&&(M=g.x),g.y<C&&(C=g.y),g.y>P&&(P=g.y);a.push({cx:(b+M)/2*R,cz:(C+P)/2*R,y:d,halfX:Math.max((M-b)/2*R,.5),halfZ:Math.max((P-C)/2*R,.5)})}let h=Q(e.fill),f=l&&h?pe(o.stageTop,fe(at(h,.18),.9),.9):Ae(h,l?o.stageTop:o.decorTop),x=u?h:null,y=l?h?pe(o.stageWall,fe(h,.58),.82):o.stageWall:u?x?pe(fe(x,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Ae(Q(e.fill),o.decorWall);if(p.kind==="portal"&&c.length===4){let b=ko(c);Re(t,pt(b,0,.16),d,m,f,y),Re(t,pt(b,.84,1),d,m,f,y),Re(t,b,d,Math.max(m,d-.35),f,y);return}if(p.kind==="suite"&&c.length===4){let b=c.map((P,g)=>{let T=c[(g+1)%4],E=(P.x+T.x)/2,L=(P.y+T.y)/2;return Math.hypot(E-i.x,L-i.y)}),M=b.indexOf(Math.min(...b)),C=[0,1,2,3].map(P=>c[(M+P)%4]);Re(t,pt(C,0,.08),d,m,f,y),Re(t,pt(C,.92,1),d,m,f,y),Re(t,_o(C,.88,1),d,m,f,y),Re(t,C,d,Math.max(m,d-.18),f,y);return}Re(t,c,d,m,f,y)}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,c=Math.cos(s),l=Math.sin(s),u=r/2,p=o/2;return[[-u,-p],[u,-p],[u,p],[-u,p]].map(([m,d])=>({x:i+m*c-d*l,y:a+m*l+d*c}))}function zi(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 Q(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 c=Q(s[1].trim());c&&a.push(c)}return a.length?a.reduce((s,c,l)=>pe(s,c,1/(l+1)),a[0]):null}function Vo(t,e,n,r){if(e.layer==="foreground")return;let o=pn(e);if(!o)return;let i=n+Ni,a=Ae(zi(e.href),r.decorTop),s=Math.max(0,Math.min(1,e.opacity??1));s<1&&(a=pe(r.ground,a,s)),ie(t,o,void 0,()=>i,n,a,pe(a,r.decorWall,.5),re)}function No(t,e,n,r,o){if(!e.points||e.points.length<3)return;let i=Ae(r,o.gaTop);ie(t,e.points,e.holes,()=>n+.15,n,i,o.gaWall,re)}var Gi=.25,Hi=1.2,Ui=.6,Yi=.45,Xi=2.3,Wi=Math.PI/180;function Xe(t,e,n){let r=n*Wi;return{x:t.x+e*Math.sin(r),y:t.y+e*Math.cos(r)}}function ji(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 Ki=24;function qi(t,e,n,r,o,i,a,s){let c=n.binCount,l=Ki,u=ke,p=i+.02,m=[];for(let v=0;v<c;v++){let A=(n.startBin+v+.5)*e.binStepDeg,F=new Float64Array(l+1);for(let w=0;w<=l;w++){let _=r[v]+(o[v]-r[v])*w/l;F[w]=Math.max(p,Yn(e,n,A,_)-Gi)}m.push(F)}let d=[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],y=(v,A)=>{let F=(n.startBin+v+.5)*e.binStepDeg,w=r[v]+(o[v]-r[v])*A/l,_=Xe(e.centre,w,F);return[_.x*u,m[v][A],_.y*u]};{let v=Math.tan(12*Math.PI/180);for(let A=0;A<6;A++){let F=!1;for(let _=0;_<c;_++)for(let U=l-1;U>=0;U--)m[_][U]>m[_][U+1]&&(m[_][U]=m[_][U+1],F=!0);let w=n.closed?c:c-1;for(let _=0;_<w;_++){let U=(_+1)%c;for(let I=0;I<=l;I++){let S=m[U][I]-m[_][I];if(Math.abs(S)>1)continue;let D=r[_]+(o[_]-r[_])*I/l,H=r[U]+(o[U]-r[U])*I/l,V=Xe(e.centre,D,(n.startBin+_+.5)*e.binStepDeg),z=Xe(e.centre,H,(n.startBin+U+.5)*e.binStepDeg),O=v*Math.hypot(z.x-V.x,z.y-V.y)*u;S>O?(m[U][I]=m[_][I]+O,F=!0):-S>O&&(m[_][I]=m[U][I]+O,F=!0)}}if(!F)break}}let b=1,M=(v,A)=>{for(let F=0;F<=l;F+=4)if(Math.abs(m[v][F]-m[A][F])>b)return!0;return Math.abs(m[v][l]-m[A][l])>b},C=Math.tan(38*Math.PI/180),P=v=>(o[v]-r[v])/l*u,g=(v,A)=>m[v][A+1]-m[v][A]>C*Math.max(1e-6,P(v)),T=(v,A)=>{let F=n.closed?(v-1+c)%c:Math.max(0,v-1),w=n.closed?(v+1)%c:Math.min(c-1,v+1);Math.abs(m[F][A]-m[v][A])>b&&(F=v),Math.abs(m[w][A]-m[v][A])>b&&(w=v);let _=Math.max(0,A-1),U=Math.min(l,A+1);_<A&&g(v,_)&&(_=A),U>A&&g(v,A)&&(U=A);let I=y(F,A),S=y(w,A),D=y(v,_),H=y(v,U),V=S[0]-I[0],z=S[1]-I[1],O=S[2]-I[2],W=H[0]-D[0],Y=H[1]-D[1],K=H[2]-D[2],q=z*K-O*Y,ne=O*W-V*K,oe=V*Y-z*W,$=Math.hypot(q,ne,oe);return $>1e-12?(q/=$,ne/=$,oe/=$,ne<0&&(q=-q,ne=-ne,oe=-oe),[q,ne,oe]):[0,1,0]},E=(v,A)=>{let F=[v[0],i,v[2]],w=[A[0],i,A[2]],_=A[0]-v[0],U=A[2]-v[2],I=Math.hypot(_,U);if(!(I>1e-12))return;let S=[U/I,0,-_/I];t.tri(v,A,w,S,f,f,x),t.tri(v,w,F,S,f,x,x)},L=.05*_e,G=v=>o[v]-r[v]<L,N=n.closed?c:c-1;for(let v=0;v<N;v++){let A=(v+1)%c;if(G(v)||G(A))continue;if(M(v,A)){let S=(n.startBin+v+1)*e.binStepDeg,D=(Y,K)=>{let q=(r[v]+r[A])/2,ne=(o[v]+o[A])/2,oe=q+(ne-q)*K/l,$=Xe(e.centre,oe,S);return[$.x*u,m[Y][K],$.y*u]};for(let Y=0;Y<l;Y++){let K=y(v,Y),q=y(v,Y+1),ne=D(v,Y),oe=D(v,Y+1),$=T(v,Y),ae=T(v,Y+1);t.triN(K,ne,oe,$,$,ae,d),t.triN(K,oe,q,$,ae,ae,d);let Oe=y(A,Y),Ve=y(A,Y+1),xe=D(A,Y),Ie=D(A,Y+1),Fe=T(A,Y),ge=T(A,Y+1);t.triN(xe,Oe,Ve,Fe,Fe,ge,d),t.triN(xe,Ve,Ie,Fe,ge,ge,d);let he=D(v,Y),se=D(v,Y+1),Ke=D(A,Y+1),ve=D(A,Y),qe=se[0]-he[0],Me=se[2]-he[2],Te=Math.hypot(qe,Me);if(Te>1e-12){let xt=[Me/Te,0,-qe/Te];t.tri(he,se,Ke,xt,f),t.tri(he,Ke,ve,xt,f)}}let H=y(v,0),V=y(A,0),z=y(A,l),O=y(v,l),W=Y=>[Y[0],i,Y[2]];t.tri(W(H),W(z),W(V),[0,-1,0],h),t.tri(W(H),W(O),W(z),[0,-1,0],h),E(H,V),E(O,z);continue}for(let S=0;S<l;S++){let D=T(v,S),H=T(A,S),V=T(A,S+1),z=T(v,S+1);if(g(v,S)||g(A,S)){let q=(se,Ke)=>{let ve=(n.startBin+se+.5)*e.binStepDeg,qe=r[se]+(o[se]-r[se])*(S+.5)/l,Me=Xe(e.centre,qe,ve);return[Me.x*u,Ke,Me.y*u]},ne=y(v,S),oe=y(A,S),$=q(v,m[v][S]),ae=q(A,m[A][S]);t.triN(ne,oe,ae,D,H,H,d),t.triN(ne,ae,$,D,H,D,d);let Oe=y(A,S+1),Ve=y(v,S+1),xe=q(v,m[v][S+1]),Ie=q(A,m[A][S+1]);t.triN(xe,Ie,Oe,z,V,V,d),t.triN(xe,Oe,Ve,z,V,z,d);let Fe=ae[0]-$[0],ge=ae[2]-$[2],he=Math.hypot(Fe,ge);if(he>1e-12){let se=[-ge/he,0,Fe/he];t.tri($,ae,Ie,se,f),t.tri($,Ie,xe,se,f)}continue}let O=y(v,S),W=y(A,S),Y=y(A,S+1),K=y(v,S+1);t.triN(O,W,Y,D,H,V,d),t.triN(O,Y,K,D,V,z,d)}let F=y(v,0),w=y(A,0),_=y(A,l),U=y(v,l),I=S=>[S[0],i,S[2]];t.tri(I(F),I(_),I(w),[0,-1,0],h),t.tri(I(F),I(U),I(_),[0,-1,0],h),E(F,w),E(U,_)}if(!n.closed)for(let v of[0,c-1])for(let A=0;A<l;A++)E(y(v,A),y(v,A+1))}function zo(t,e,n){let{bottomY:r,colors:o,ao:i}=n,a=new Float64Array(e.binCount).fill(-1/0);for(let u of e.rings)for(let p of u.arcs){let m=new Float64Array(p.binCount),d=new Float64Array(p.binCount);for(let f=0;f<p.binCount;f++){let x=(p.startBin+f)%e.binCount,y=Math.max(0,p.innerR[f]-be);m[f]=Math.max(y,a[x]+.001),d[f]=Math.max(m[f]+.001,p.outerR[f]+be)}let h=0;for(let f=0;f<p.binCount;f++){let x=p.topLevelM[f]-r;x>h&&(h=x)}h>=Hi&&qi(t,e,p,m,d,r,o,i);for(let f=0;f<p.binCount;f++){let x=(p.startBin+f)%e.binCount;d[f]>a[x]&&(a[x]=d[f])}}if(ji(n.shapes,e))return;let s=e.rings[e.rings.length-1],c=Ui*_e,l=Yi*_e;for(let u of s.arcs){let p=[],m=[];for(let f=0;f<u.binCount;f++){let x=(u.startBin+f+.5)*e.binStepDeg,y=u.outerR[f]+be+c;p.push(Xe(e.centre,y,x)),m.push(Xe(e.centre,y+l,x))}let d=-1/0;for(let f=0;f<u.binCount;f++)u.topLevelM[f]>d&&(d=u.topLevelM[f]);let h=()=>d+Xi;u.closed?ie(t,m,[p.slice().reverse()],h,r,o.shellTop,o.shellWall,i):ie(t,[...m,...p.slice().reverse()],void 0,h,r,o.shellTop,o.shellWall,i)}}function Go(t,e,n,r,o,i,a,s){if(!e.outline||e.outline.length<3)return;let c=n.baseHeightM,l=Ae(r,s.tierTop);if(!o)return;let u=x=>o.deckAt(x.x,x.y),p=Ao(e,a),m=p[0]??e.outline;if(o.rowLevels.length>=2){let x=Lt(o.rowLevels),y=Ro(vo(o.rowLevels,n.focal,x),p),b=()=>[0,1,0];for(let C of y){let P=Math.max(c,C.topY-.02);for(let g of i.subtract(C.outline,P))ie(t,g,C.holes,()=>P,c,l,s.tierWall,re,void 0,b)}y.length||ie(t,m,e.holes,()=>o.landingY,c,l,s.tierWall,re);let M={tread:[l[0]*re.top,l[1]*re.top,l[2]*re.top],riser:[l[0]*.72,l[1]*.72,l[2]*.72]};for(let C of p.length?p:[m])So(t,o.rowLevels,n.focal,o.landingY,M,C,x);return}let d=o.flat?1/0:Io,h=x=>o.normalAt(x.x,x.y),f=o.flat?o.landingY:void 0;for(let x of i.subtract(m,f))ie(t,x,e.holes,u,c,l,s.tierWall,re,d,h)}function Zi(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 c=n.bySection.get(s);if(c&&c.rowLevels.length>=2)continue;let l=e[a],u=o.get(s);u||(u=new Map,o.set(s,u));let p=l.rowId||`__seat-${a}`,m=u.get(p);m||(m={pts:[],levelM:0,n:0},u.set(p,m)),m.pts.push({x:l.x,y:l.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 l=s.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));l.length>=2&&i.push({sectionId:a.id,rows:l});continue}let c=o.get(a.id);c&&i.push({sectionId:a.id,rows:[...c.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return i}function Ho(t,e,n,r,o){let i=Zi(e,n,r);if(!i.length)return;let a=Un(i,e.focal);a&&(t.setMaterial(0),zo(t,a,{bottomY:e.baseHeightM,colors:{bandTop:fe(o.tierTop,.8),bandWall:o.tierWall,shellTop:fe(o.tierWall,1.15),shellWall:o.tierWall},ao:re,shapes:e.objects.filter(s=>s.type==="shape")}))}function Uo(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 Yo(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 Qi=1.15,$i=3.25,Ji=4.5,ea=.85,ta=.5,na=.26;function Xo(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>=Qi&&a.add("zone"),o<=(i?$i:Ji)&&(a.add("section"),a.add("ga")),o<=ea&&(a.add("annotation"),a.add("booth")),o<=ta&&a.add("row"),o<=na&&a.add("seat"),a}function Be(t,e,n,r){let o=t,i=e[0],a=e[1],s=e[2],c=o[0]*i+o[4]*a+o[8]*s+o[12],l=o[1]*i+o[5]*a+o[9]*s+o[13],u=o[2]*i+o[6]*a+o[10]*s+o[14],p=o[3]*i+o[7]*a+o[11]*s+o[15];if(!(p>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=c/p,d=l/p,h=u/p,f=m>=-1.05&&m<=1.05&&d>=-1.05&&d<=1.05&&h<=1;return{x:(m*.5+.5)*n,y:(1-(d*.5+.5))*r,depth:h,visible:f}}function Wo(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 oa=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+oa):n;return o<a&&i<r}function jo(t,e,n){return t.length*e*.58+(n?14:0)}var bn={row:8,seat:14};function Ko(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,c)=>(c.priority??0)-(s.priority??0)||s.focus-c.focus),a=[];for(let s of i){if(a.length>=r)break;let c=!1;for(let l of o)if(fn(s,l,e,n)){c=!0;break}if(!c){for(let l of a)if(fn(s,l,e,n)){c=!0;break}}c||a.push(s)}return a}var ra=6,ia=2.2,qo=.1,aa=.3,sa=1.8,ca=.9,la=.55,ua=6e3;function Zo(t){let{doc:e,units:n,seats:r,surfaces:o,focal:i}=t,a=e.zones??[],s=[];if(a.length){let c=new Map;for(let u of n)for(let p of u.objects)p.type==="section"&&p.zone&&c.set(p.id,p.zone);let l=new Map;for(let u=0;u<r.length;u++){let p=r[u],m=o.seatOwner[u],d=p.zoneId??(m?c.get(m):void 0);if(!d)continue;let h=l.get(d);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(d,h)),h.n++,p.x<h.minX&&(h.minX=p.x),p.y<h.minY&&(h.minY=p.y),p.x>h.maxX&&(h.maxX=p.x),p.y>h.maxY&&(h.maxY=p.y),h.sumY+=o.seatDeckY(u)}for(let u of a){let p=l.get(u.id),m=[];for(let[d,h]of c)h===u.id&&m.push(d);if(!p||p.n===0){s.push({id:u.id,label:u.label,color:Q(u.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(u.focalPoint??i).x*R,1.5,(u.focalPoint??i).y*R]});continue}s.push({id:u.id,label:u.label,color:Q(u.color),sectionIds:m,seatCount:p.n,center:[(p.minX+p.maxX)/2*R,p.sumY/p.n,(p.minY+p.maxY)/2*R],radius:.5*Math.hypot((p.maxX-p.minX)*R,(p.maxY-p.minY)*R)||1,focalWorld:[(u.focalPoint??i).x*R,1.5,(u.focalPoint??i).y*R]})}}return s}function Qo(t){let{doc:e,units:n,seats:r,surfaces:o,seatData:i,hintedSeatFloor:a,zones:s,focal:c}=t,l=[],u=[],p=[];for(let m of s)m.seatCount!==0&&l.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+ra,m.center[2]],color:e.zones?.find(d=>d.id===m.id)?.color});{let m=new Map,d=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 y=d.get(f);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},d.set(f,y)),r[h].x<y.minX&&(y.minX=r[h].x),r[h].x>y.maxX&&(y.maxX=r[h].x),r[h].y<y.minY&&(y.minY=r[h].y),r[h].y>y.maxY&&(y.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 y=d.get(f.id),b=[x.x/x.n*R,x.deck/x.n,x.y/x.n*R],M=f.displayLabel||f.label||f.id;u.push({id:f.id,floorIndex:h.index,label:M,seatCount:x.n,center:b,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*R),focalWorld:[h.focal.x*R,h.baseHeightM+1.5,h.focal.y*R]});let C=e.floors?.[h.index]?.name?.trim().toLocaleLowerCase();n.length>1&&C===M.trim().toLocaleLowerCase()||l.push({id:`section:${f.id}`,kind:"section",text:M,anchor:[b[0],b[1]+ia,b[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 y=f.displayLabel||f.label||f.id;l.push({id:`ga:${f.id}`,kind:"ga",text:f.capacity>0?`${y} \xB7 ${f.capacity.toLocaleString()}`:y,anchor:[x.x*R,h.baseHeightM+sa,x.y*R],floorIndex:h.index})}let m=new Map;for(let h=0;h<r.length;h++){let f=r[h],x=Math.hypot(f.x-c.x,f.y-c.y),y=m.get(f.rowId);(!y||x>y.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,y=x>0?f.seat.label.slice(0,x):h;y&&l.push({id:`row:${h}`,kind:"row",text:y,anchor:[f.seat.x*R,o.seatDeckY(f.index)+ca,f.seat.y*R],floorIndex:a[f.index]})}let d=new Map;for(let h=0;h<r.length;h++){let f=r[h],x=f.label?f.label.lastIndexOf("-"):-1,y=d.get(f.rowId);y||(y={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},d.set(f.rowId,y));let b=h*3,M=i.iPosition[b],C=i.iPosition[b+1],P=i.iPosition[b+2];y.n++,y.x+=M,y.y+=C,y.z+=P,y.minX=Math.min(y.minX,M),y.maxX=Math.max(y.maxX,M),y.minZ=Math.min(y.minZ,P),y.maxZ=Math.max(y.maxZ,P)}for(let[h,f]of d)p.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<=ua)for(let h=0;h<r.length;h++){let f=r[h],x=f.displayLabel||f.label;x&&l.push({id:`seat:${f.id}`,kind:"seat",text:x,anchor:[f.x*R,o.seatDeckY(h)+la,f.y*R],floorIndex:a[h]})}}for(let m of n)for(let d of m.objects)if(d.type==="shape"&&d.role&&["entrance","exit","screen","suite","obstruction"].includes(d.role)){let h=Ye(d),f=h?it(h):null;if(!f||!d.label)continue;l.push({id:`architecture:${d.id}`,kind:"annotation",text:d.label,anchor:[f.x*R,m.baseHeightM+ht(d).heightM+qo,f.y*R],color:d.fill,floorIndex:m.index})}else if(d.type==="text"){if(!d.text)continue;l.push({id:`text:${d.id}`,kind:"annotation",text:d.text,anchor:[d.position.x*R,m.baseHeightM+qo,d.position.y*R],color:d.color,rotation:d.rotation,floorIndex:m.index})}else if(d.type==="booth"){let h=ft(d);if(!h)continue;let f=it(h);if(!f)continue;l.push({id:`booth:${d.id}`,kind:"booth",text:d.displayLabel||d.label||d.id,anchor:[f.x*R,m.baseHeightM+dn+aa,f.y*R],floorIndex:m.index})}return{labels:l,sections:u,rows:p}}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:r,surfaces:o,solids:i,hintedSeatFloor:a,seatFloor:s}=t,c=[];{let l=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 d=Math.max(0,Math.min(n.length-1,Math.round(i.floor[m]))),h=m*3,f=l[d];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 u=new Map;for(let m=0;m<n.length;m++)for(let d of n[m].objects)d.type==="section"&&u.set(d.id,m);let p=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 d=o.seatOwner[m],h=(d!==null?u.get(d):void 0)??a[m];if(h===void 0)continue;let f=p[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 y=o.seatDeckY(m);f.sumX+=x.x*R,f.sumDeck+=y,f.sumZ+=x.y*R,f.minDeck=Math.min(f.minDeck,y),f.maxDeck=Math.max(f.maxDeck,y+1.6),s[m]=h}for(let m=0;m<n.length;m++){let d=p[m],h=e.floors?.[m],f=l[m],x=Math.min(d.n?d.minX*R:n[m].focal.x*R-1,Number.isFinite(f.minX)?f.minX:1/0),y=Math.max(d.n?d.maxX*R:n[m].focal.x*R+1,Number.isFinite(f.maxX)?f.maxX:-1/0),b=Math.min(d.n?d.minY*R:n[m].focal.y*R-1,Number.isFinite(f.minZ)?f.minZ:1/0),M=Math.max(d.n?d.maxY*R:n[m].focal.y*R+1,Number.isFinite(f.maxZ)?f.maxZ:-1/0),C=Math.min(d.n?Math.min(n[m].baseHeightM,d.minDeck):n[m].baseHeightM,Number.isFinite(f.minY)?f.minY:1/0),P=Math.max(d.n?Math.max(d.maxDeck,C+.5):C+.5,Number.isFinite(f.maxY)?f.maxY:-1/0),g=[d.n?d.sumX/d.n:(x+y)/2,d.n?d.sumDeck/d.n:(C+P)/2,d.n?d.sumZ/d.n:(b+M)/2],T=Math.max(1,.5*Math.hypot(y-x,P-C,M-b));c.push({index:m,id:h?.id??`floor-${m}`,label:h?.name??(n.length>1?`Floor ${m+1}`:"Venue"),seatCount:d.n,center:g,radius:T,box:{min:[x,C,b],max:[y,P,M]},focalWorld:[n[m].focal.x*R,n[m].baseHeightM+1.5,n[m].focal.y*R]})}}return c}function xn(t,e){let n=1/0,r=1/0,o=-1/0,i=-1/0,a=(s,c)=>{s<n&&(n=s),c<r&&(r=c),s>o&&(o=s),c>i&&(i=c)};for(let s of e)a(s.x,s.y);for(let s of t)for(let c of s.objects)if(c.type==="section")for(let l of c.outline)a(l.x,l.y);else if(c.type==="shape"&&c.points)for(let l of c.points)a(l.x,l.y);else if(c.type==="gaArea")for(let l of c.points)a(l.x,l.y);else if(c.type==="booth"){let l=ft(c);if(l)for(let u of l)a(u.x,u.y)}else if(c.type==="table"){let l=hn(c);if(l)for(let u of l)a(u.x,u.y)}else if(c.type==="decorImage"){let l=pn(c);if(l)for(let u of l)a(u.x,u.y)}return Number.isFinite(n)||(n=-100,r=-100,o=100,i=100),{minX:n,minY:r,maxX:o,maxY:i}}function er(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);ie(t,s,void 0,()=>0,-.4,i.ground,i.ground,re)}else{let a=e.reduce((d,h)=>h.baseHeightM<d.baseHeightM?h:d);t.setFloor(a.index);let s=n.filter((d,h)=>r[h]===a.index),c=xn([a],s),l=Math.hypot(c.maxX-c.minX,c.maxY-c.minY),u=Math.max(28,Math.min(80,l*.04)),p=dt(c.minX-u,c.minY-u,c.maxX-c.minX+u*2,c.maxY-c.minY+u*2),m=a.baseHeightM-.03;ie(t,p,void 0,()=>m,m-.22,i.ground,i.ground,re)}}function tr(t,e,n){let{cx:r,cz:o,radius:i}=n,a=1/0,s=1/0,c=1/0,l=-1/0,u=-1/0,p=-1/0,m=(f,x,y)=>{a=Math.min(a,f),l=Math.max(l,f),s=Math.min(s,x),u=Math.max(u,x),c=Math.min(c,y),p=Math.max(p,y)};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,y=e.iPosition[x],b=e.iPosition[x+1],M=e.iPosition[x+2],C=Math.max(.35,e.iMaxRadius[f]??.35);m(y-C,b,M-C),m(y+C,b+1.6,M+C)}Number.isFinite(a)||(a=r-i,l=r+i,s=0,u=i*.16,c=o-i,p=o+i);let d=[(a+l)/2,(s+u)/2,(c+p)/2],h=Math.max(1,.5*Math.hypot(l-a,u-s,p-c));return{center:d,radius:h,minY:s,maxY:u}}function nr(t,e,n,r,o,i){let a=1/0,s=1/0,c=-1/0,l=-1/0;for(let C=0;C<t.count;C++){let P=C*3,g=t.iPosition[P],T=t.iPosition[P+2];g<a&&(a=g),g>c&&(c=g),T<s&&(s=T),T>l&&(l=T)}for(let C of e)a=Math.min(a,C.cx-C.halfX),c=Math.max(c,C.cx+C.halfX),s=Math.min(s,C.cz-C.halfZ),l=Math.max(l,C.cz+C.halfZ);let u=n.minX*R,p=n.maxX*R,m=n.minY*R,d=n.maxY*R,h=u,f=p,x=m,y=d;if(Number.isFinite(a)){let C=Math.max(2,.06*Math.hypot(c-a,l-s));h=Math.max(u,a-C),f=Math.min(p,c+C),x=Math.max(m,s-C),y=Math.min(d,l+C)}let b=Math.min(0,r),M=Math.max(o,i*.05);return{min:[h,b,x],max:[f,M,y]}}function or(t,e,n){let r=()=>({byObjectId:new Map,elements:[]});if(!e||!t)return r();let o=kn(e);if(!o.ok||o.value.id!==t)return r();let i=new Map;for(let u of n)for(let p of u.objects)p.type==="shape"&&i.set(p.id,{shape:p,unit:u});let a=new Set,s=new Set,c=[];for(let u of o.value.overlay.productionElements??[]){let p=i.get(u.objectId),m=p?Ye(p.shape):null,d=u.baseElevationM??0;if(!p||!m||m.length<3||!u.id||a.has(u.id)||s.has(u.objectId)||!Number.isFinite(u.heightM)||u.heightM<.05||u.heightM>50||!Number.isFinite(d)||d<-10||d>100)return r();a.add(u.id),s.add(u.objectId);let h=m.map(y=>y.x*R),f=m.map(y=>y.y*R),x=p.unit.baseHeightM+d;c.push({id:u.id,objectId:u.objectId,kind:u.kind,floorIndex:p.unit.index,baseY:x,topY:x+u.heightM,bounds:{min:[Math.min(...h),x,Math.min(...f)],max:[Math.max(...h),x+u.heightM,Math.max(...f)]},occlusion:u.occlusion})}let l=c.sort((u,p)=>u.id.localeCompare(p.id));return{byObjectId:new Map(l.map(u=>[u.objectId,u])),elements:l}}function bt(t){let{doc:e}=t,n=lo(e.theme),r=n.structure,o=Co(e,t.eventConfigurationId??e.eventConfigurationId),i=or(t.eventConfigurationId,t.eventConfiguration,o),a=t.seats,s=new Et,c=new Map;for(let F of o)for(let w of F.objects)c.set(w.id,F.index),w.type==="section"&&c.set(w.logicalSectionId??w.id,F.index);let l=a.map(F=>c.get(F.sectionId??"")??c.get(F.rowId??"")??0),u=xn(o,a);er(s,o,a,l,u,r);let p=To(e,a),m=new Map,d=new Map;for(let F of e.categories??[])m.set(F.key,F.color),F.seatGlyph&&d.set(F.key,F.seatGlyph);let h=[],f=Fo(o,a,l),x=new Float32Array(a.length);for(let F=0;F<o.length;F++){let w=o[F];s.setFloor(F);let _=new Bt,U=[],I=w.objects.filter(S=>S.type==="section"&&!!S.outline&&S.outline.length>=3);for(let S of w.objects)if(S.type==="section")Go(s,S,w,Eo(S,p),f.bySection.get(S.id),_,I,r);else if(S.type==="shape"){let D=i.byObjectId.get(S.id);s.setMaterial((D?.kind??S.role)==="screen"?1:0),Oo(s,S,w.baseHeightM,Do(S,U),r,w.focal,h,D),s.setMaterial(0)}else S.type==="gaArea"?No(s,S,w.baseHeightM,Q(m.get(S.categoryKey)),r):S.type==="booth"?Lo(s,S,w.baseHeightM,Q(m.get(S.categoryKey)),r):S.type==="table"?Bo(s,S,w.baseHeightM,Q(m.get(S.categoryKey)),r):S.type==="decorImage"&&Vo(s,S,w.baseHeightM,r);Ho(s,w,a,f,r)}let y=o.length>1?{x:o.reduce((F,w)=>F+w.focal.x,0)/o.length,y:o.reduce((F,w)=>F+w.focal.y,0)/o.length}:e.focalPoint??{x:(u.minX+u.maxX)/2,y:(u.minY+u.maxY)/2},b=oo([s.build()]),M=co(a,t.initialState,f,x,m,d),C=Zo({doc:e,units:o,seats:a,surfaces:f,focal:y}),{labels:P,sections:g,rows:T}=Qo({doc:e,units:o,seats:a,surfaces:f,seatData:M,hintedSeatFloor:l,zones:C,focal:y}),E=Jo({doc:e,units:o,seats:a,surfaces:f,solids:b,hintedSeatFloor:l,seatFloor:x});$o(P,E),M.iYaw=ao(M.iPosition,a.length,F=>a[F].rowId,F=>{let w=o[x[F]]?.focal??y;return[w.x*R,w.y*R]});let L=(u.minX+u.maxX)/2*R,G=(u.minY+u.maxY)/2*R,N=.5*Math.hypot((u.maxX-u.minX)*R,(u.maxY-u.minY)*R)||10,v=tr(b,M,{cx:L,cz:G,radius:N}),A=nr(M,h,u,v.minY,v.maxY,N);return{solids:b,seats:M,bounds:{center:[(A.min[0]+A.max[0])/2,(A.min[1]+A.max[1])/2,(A.min[2]+A.max[2])/2],radius:N,groundY:0,box:A},renderBounds:{center:v.center,radius:v.radius},stateColorLUT:uo(n,ye),theme:n,seatCount:a.length,focalWorld:[y.x*R,1.5,y.y*R],zones:C,stages:h,productionElements:i.elements,sections:g,rows:T,labels:P,floors:E}}var ma=88,da=20,rr={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}},Ot=new Set(["row","seat"]),ir={floor:5,zone:4,section:3,ga:3,booth:2,annotation:1},Vt={row:{x:62,y:16},seat:{x:46,y:18}},ar=Q,gn=t=>On(t);function sr(t,e){let n=gn(t),r=gn(e);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function vn(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 ha(t,e=[.04,.06,.1],n=!0){let r=gn(e)<.42,o=r?"#f4f7fb":"#0b1220",i=r?"rgba(8,12,22,.78)":"rgba(255,255,255,.84)",a=n?vn(i,e):e,s=ar(t),c=n?7:4.5,l=s&&sr(s,a)>=c?t:o;return r?{ink:l,backing:i,border:"rgba(210,222,245,.24)"}:{ink:l,backing:i,border:"rgba(11,18,32,.22)"}}var Nt=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=Xo(o,i,{hasZoneLabels:this.labels.some(b=>b.kind==="zone")});this.forcedDense&&(s.add("row"),s.add("seat"));let c=[];for(let b of this.labels){if(!s.has(b.kind))continue;let M=Be(e,b.anchor,n,r);if(!M.visible)continue;let C=a?Math.hypot(b.anchor[0]-a[0],b.anchor[1]-a[1],b.anchor[2]-a[2]):1;c.push({label:b,screen:M,focus:Ko(M,C,n,r),halfWidth:jo(b.text,rr[b.kind].size,!Ot.has(b.kind))/2,...this.selectedSeatLabelIds.has(b.id)?{priority:1}:{}})}let l=Yo(c.filter(b=>b.label.kind==="floor"),n),u=[...c.filter(b=>!Ot.has(b.label.kind)&&b.label.kind!=="floor"),...l],p=Wo(u,ma,da),m=yn(c.filter(b=>b.label.kind==="row"),Vt.row.x,Vt.row.y,bn.row,p),d=yn(c.filter(b=>b.label.kind==="seat"),Vt.seat.x,Vt.seat.y,bn.seat,[...p,...m]),h=[...p,...m,...d],f=new Set(h.map(b=>b.label.id));for(let{label:b,screen:M}of h){let P=this.nodeFor(b).style;P.display="",P.transform=`translate(-50%, -50%) translate(${M.x.toFixed(1)}px, ${M.y.toFixed(1)}px)`}let x=h.filter(({label:b})=>!Ot.has(b.kind)).sort((b,M)=>ir[M.label.kind]-ir[b.label.kind]||b.screen.depth-M.screen.depth||b.focus-M.focus),y=[];for(let{label:b}of x){let M=this.nodes.get(b.id);if(!M||M.style.display==="none")continue;let C=M.getBoundingClientRect();y.some(g=>C.left<g.right+3&&C.right+3>g.left&&C.top<g.bottom+3&&C.bottom+3>g.top)?M.style.display="none":y.push(C)}for(let[b,M]of this.nodes)f.has(b)||(M.style.display="none")}nodeFor(e){let n=this.nodes.get(e.id);if(!n){n=document.createElement("div");let p=n.style;p.position="absolute",p.left="0",p.top="0",p.whiteSpace="nowrap",p.textShadow="0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(0,0,0,0.55)",p.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=rr[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=!Ot.has(e.kind),s=ha(e.color??this.opts.ink,this.opts.backgroundRgb,a);i.color=r?"#ecf8ff":s.ink,i.background=r?"rgba(10,28,45,.9)":a?s.backing:"",i.border=r?"1px solid rgba(89,199,255,.92)":a?`1px solid ${s.border}`:"",i.borderRadius=r||a?"999px":"",i.padding=r||a?"3px 7px":"",i.boxShadow=r?"0 0 0 2px rgba(41,176,255,.18), 0 5px 14px rgba(0,0,0,.35)":a?"0 3px 10px rgba(0,0,0,.24)":"",i.letterSpacing=e.kind==="zone"||e.kind==="floor"?"0.08em":"0.02em";let c=this.opts.backgroundRgb??[.04,.06,.1],l=ar(r?"#ecf8ff":s.ink)??[1,1,1],u=r?vn("rgba(10,28,45,.9)",c):a?vn(s.backing,c):c;return n.dataset.qualityContrast=sr(l,u).toFixed(3),(e.kind==="zone"||e.kind==="floor")&&(i.textTransform="uppercase"),n}dispose(){this.root.remove(),this.nodes.clear()}};var pa=1;var fa=new Set(["floor","zone","section","ga","booth","annotation"]);function ba(t){return t.every(e=>Number.isFinite(e))}function ya(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 xa(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 Pe(t,e,n){return n.length?{code:t,message:e,count:n.length,samples:n.slice(0,20)}:null}function Mn(t){let e=t.labels.filter(s=>s.visible&&s.screenBox),n=e.filter(s=>fa.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 c=0;c<s;c+=1)ya(n[s].screenBox,n[c].screenBox)&&o.push({primaryId:n[s].id,primaryLabel:n[s].text,secondaryId:n[c].id});let i=[...t.camera.position,t.camera.distance,t.camera.verticalFovDeg],a=[Pe("webgl2-unavailable","The venue scene must render through WebGL2",t.context.webgl2?[]:[{primaryId:"renderer",primaryLabel:"WebGL2"}]),Pe("context-lost","The WebGL context must be live at capture",t.context.lost?[{primaryId:"renderer",primaryLabel:"context lost"}]:[]),Pe("frame-not-stable","The captured 3D frame must be rendered and parked",t.frame.rendered>0&&t.frame.idle?[]:[{primaryId:"renderer",primaryLabel:"unstable frame"}]),Pe("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}`}]),Pe("camera-invalid","The capture camera must have a finite physical pose",ba(i)&&t.camera.distance>0&&t.camera.verticalFovDeg>0&&t.camera.verticalFovDeg<180?[]:[{primaryId:"camera",primaryLabel:"invalid pose"}]),Pe("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}]),Pe("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`}]),Pe("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}))),Pe("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}))),Pe("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:c,text:l})=>({id:s,kind:c,text:l})).sort((s,c)=>s.kind.localeCompare(c.kind)||s.id.localeCompare(c.id)),framing:xa(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 Gt,Mesh as Ht,Transform as xr}from"ogl";import{Program as je}from"ogl";var zt=`
2
2
  float chairWeight(float depth) {
3
3
  return 1.0 - smoothstep(uChairFull, uChairNone, depth);
4
- }`,sr=`
4
+ }`,lr=`
5
5
  float occupantWeight(float depth) {
6
- float nearWeight = smoothstep(${Zn.toFixed(1)}, ${Qn.toFixed(1)}, depth);
7
- float farWeight = 1.0 - smoothstep(${Kn.toFixed(1)}, ${qn.toFixed(1)}, depth);
6
+ float nearWeight = smoothstep(${Qn.toFixed(1)}, ${$n.toFixed(1)}, depth);
7
+ float farWeight = 1.0 - smoothstep(${qn.toFixed(1)}, ${Zn.toFixed(1)}, depth);
8
8
  return nearWeight * farWeight;
9
- }`,cr=`
9
+ }`,ur=`
10
10
  float glyphEq(float glyph, float expected) {
11
11
  return 1.0 - step(0.25, abs(glyph - expected));
12
12
  }
@@ -55,7 +55,7 @@ vec3 glyphChairPosition(vec3 p, float partId, float glyph) {
55
55
  p.y += 0.16;
56
56
  }
57
57
  return p;
58
- }`,ya=`#version 300 es
58
+ }`,ga=`#version 300 es
59
59
  precision highp float;
60
60
  in vec3 position;
61
61
  in vec3 normal;
@@ -91,7 +91,7 @@ void main() {
91
91
  vNormalWorld = normalize(mat3(modelMatrix) * normal);
92
92
  vColor = color;
93
93
  gl_Position = projectionMatrix * mv;
94
- }`,xa=`#version 300 es
94
+ }`,va=`#version 300 es
95
95
  precision highp float;
96
96
  in vec3 vColor;
97
97
  in vec3 vNormalWorld;
@@ -158,7 +158,7 @@ void main() {
158
158
  + vec3(0.20, 0.10, 0.34) * focalHalo;
159
159
  base = mix(base, display, poweredDisplay * verticalFace * 0.92);
160
160
  fragColor = vec4(base, 1.0);
161
- }`,ga=`#version 300 es
161
+ }`,Ma=`#version 300 es
162
162
  precision highp float;
163
163
  in vec2 position; // quad corner in [-1,1]
164
164
  in vec3 iOffset; // per-instance world position
@@ -217,7 +217,7 @@ void main() {
217
217
  vPhysicalSeat = iPhysicalSeat;
218
218
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
219
219
  gl_Position = projectionMatrix * mv;
220
- }`,va=`#version 300 es
220
+ }`,Sa=`#version 300 es
221
221
  precision highp float;
222
222
  in vec2 vUv;
223
223
  in vec3 vColor;
@@ -275,7 +275,7 @@ void main() {
275
275
  alpha *= vDotWeight;
276
276
  if (alpha <= 0.0) discard;
277
277
  fragColor = vec4(c, alpha);
278
- }`,Ma=`#version 300 es
278
+ }`,wa=`#version 300 es
279
279
  precision highp float;
280
280
  in vec3 position; // local: x/z in units of the seat radius, y in METRES
281
281
  in vec3 normal;
@@ -307,8 +307,8 @@ out float vDim;
307
307
  out float vOccupant; // 1 = this vertex belongs to a person, not to the chair
308
308
  out vec3 vOccupantTint;
309
309
  ${zt}
310
- ${sr}
311
- ${cr}
310
+ ${lr}
311
+ ${ur}
312
312
  void main() {
313
313
  vec4 anchor = modelViewMatrix * vec4(iOffset, 1.0);
314
314
  float viewDepth = -anchor.z;
@@ -394,7 +394,7 @@ void main() {
394
394
  vRing = iRing;
395
395
  vDim = (uFocusFloor < -0.5 || abs(iFloor - uFocusFloor) < 0.5) ? 0.0 : 1.0;
396
396
  gl_Position = projectionMatrix * mv;
397
- }`,Sa=`#version 300 es
397
+ }`,Pa=`#version 300 es
398
398
  precision highp float;
399
399
  in vec3 vColor;
400
400
  in vec3 vNormalWorld;
@@ -449,14 +449,14 @@ void main() {
449
449
  // which is what stops a block of them merging into one mass up close.
450
450
  base += vec3(0.26, 0.31, 0.38) * fres * 0.55;
451
451
  fragColor = vec4(base, 1.0);
452
- }`,wa=`#version 300 es
452
+ }`,Ca=`#version 300 es
453
453
  precision highp float;
454
454
  in vec2 position;
455
455
  out vec2 vUv;
456
456
  void main() {
457
457
  vUv = position * 0.5 + 0.5;
458
458
  gl_Position = vec4(position, 0.999, 1.0);
459
- }`,Pa=`#version 300 es
459
+ }`,Aa=`#version 300 es
460
460
  precision highp float;
461
461
  in vec2 vUv;
462
462
  uniform vec3 uTop;
@@ -467,7 +467,7 @@ void main() {
467
467
  vec2 c = vUv - 0.5;
468
468
  float vig = 1.0 - dot(c, c) * 0.85; // soft vignette
469
469
  fragColor = vec4(col * vig, 1.0);
470
- }`,Aa=`#version 300 es
470
+ }`,Ra=`#version 300 es
471
471
  precision highp float;
472
472
  in vec2 position;
473
473
  in vec3 iOffset;
@@ -504,7 +504,7 @@ void main() {
504
504
  vPhysicalSeat = iPhysicalSeat;
505
505
  vHidden = (uFocusFloor > -0.5 && abs(iFloor - uFocusFloor) > 0.5) ? 1.0 : 0.0;
506
506
  gl_Position = projectionMatrix * mv;
507
- }`,Ca=`#version 300 es
507
+ }`,Ia=`#version 300 es
508
508
  precision highp float;
509
509
  in vec2 vUv;
510
510
  in float vPhysicalSeat;
@@ -518,7 +518,7 @@ void main() {
518
518
  float d = mix(max(abs(vUv.x), abs(vUv.y)), length(vUv), vPhysicalSeat);
519
519
  if (d > 1.0) discard; // hit-mask matches chair/bay shape
520
520
  fragColor = vec4(vPick, 1.0);
521
- }`,Ra=`#version 300 es
521
+ }`,Fa=`#version 300 es
522
522
  precision highp float;
523
523
  in vec3 position;
524
524
  in float part;
@@ -540,8 +540,8 @@ uniform float uFocusFloor;
540
540
  flat out vec3 vPick;
541
541
  out float vHidden;
542
542
  ${zt}
543
- ${sr}
544
- ${cr}
543
+ ${lr}
544
+ ${ur}
545
545
  void main() {
546
546
  int id = int(iPickIndex + 0.5); // already global index + 1
547
547
  vPick = vec3(float(id & 255), float((id >> 8) & 255), float((id >> 16) & 255)) / 255.0;
@@ -574,7 +574,7 @@ void main() {
574
574
  float c = cos(iYaw), s = sin(iYaw);
575
575
  vec3 rp = vec3(p.x * c + p.z * s, p.y, -p.x * s + p.z * c);
576
576
  gl_Position = projectionMatrix * modelViewMatrix * vec4(iOffset + rp, 1.0);
577
- }`,Ia=`#version 300 es
577
+ }`,Ta=`#version 300 es
578
578
  precision highp float;
579
579
  flat in vec3 vPick;
580
580
  in float vHidden;
@@ -582,7 +582,7 @@ out vec4 fragColor;
582
582
  void main() {
583
583
  if (vHidden > 0.5) discard;
584
584
  fragColor = vec4(vPick, 1.0);
585
- }`,Fa=`#version 300 es
585
+ }`,Ea=`#version 300 es
586
586
  precision highp float;
587
587
  in vec3 position;
588
588
  in float floorIndex;
@@ -593,11 +593,11 @@ out float vHidden;
593
593
  void main() {
594
594
  vHidden = (uFocusFloor > -0.5 && abs(floorIndex - uFocusFloor) > 0.5) ? 1.0 : 0.0;
595
595
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
596
- }`,Ta=`#version 300 es
596
+ }`,Da=`#version 300 es
597
597
  precision highp float;
598
598
  in float vHidden;
599
599
  out vec4 fragColor;
600
600
  void main() {
601
601
  if (vHidden > 0.5) discard;
602
602
  fragColor = vec4(0.0, 0.0, 0.0, 1.0);
603
- }`;function lr(t){return new We(t,{vertex:Aa,fragment:Ca,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Ae},uSeatScale:{value:1},uMinPixels:{value:Ze},uPixelToWorld:{value:.002},uChairFull:{value:ct},uChairNone:{value:Qe},uFocusFloor:{value:-1}}})}function ur(t){return new We(t,{vertex:Ra,fragment:Ia,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:ct},uChairNone:{value:Qe},uBackRake:{value:an},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function mr(t){return new We(t,{vertex:Fa,fragment:Ta,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function dr(t){return new We(t,{vertex:ya,fragment:xa,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function hr(t){return new We(t,{vertex:ga,fragment:va,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Ae},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:ct},uChairNone:{value:Qe}}})}function pr(t){return new We(t,{vertex:Ma,fragment:Sa,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:ct},uChairNone:{value:Qe},uBackRake:{value:an},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function fr(t,e,n){return new We(t,{vertex:wa,fragment:Pa,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function yr(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 Ea=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),Da=new Float32Array([-1,-1,3,-1,-1,3]);function xr(t,e){let n=new br,i=new br,o=new Gt(t,{position:{size:2,data:Da}}),r=fr(t,e.theme.background.top,e.theme.background.bottom),a=new Ht(t,{geometry:o,program:r});a.frustumCulled=!1,a.setParent(i);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=dr(t),c=new Ht(t,{geometry:s,program:l});c.frustumCulled=!1,c.setParent(n);let d=hr(t),h=new Float32Array(e.seats.count*3),u=ye.map(R=>e.theme.seatStates[R]);yr(h,e.seats.iState,0,e.seats.count,u,e.seats.iCategory);let p=new Gt(t,{position:{size:2,data:Ea},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:h,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}}),m=new Ht(t,{geometry:p,program:d});m.frustumCulled=!1,e.seats.count>0&&m.setParent(n);let f=p.attributes.iColor,x=ro(),y=pr(t),b=It,S=new Float32Array(b*3),C=new Float32Array(b*3),P=new Float32Array(b),v=new Float32Array(b),T=new Float32Array(b),E=new Float32Array(b*3),L=new Float32Array(b),G=new Float32Array(b),N=new Float32Array(b),g=new Float32Array(b),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:S,instanced:1},iColor:{size:3,data:C,instanced:1},iRadius:{size:1,data:P,instanced:1},iYaw:{size:1,data:v,instanced:1},iGlyph:{size:1,data:T,instanced:1},iRing:{size:3,data:E,instanced:1},iFloor:{size:1,data:L,instanced:1},iPhysicalSeat:{size:1,data:G,instanced:1},iSeed:{size:1,data:g,instanced:1},iPickIndex:{size:1,data:N,instanced:1}}),F=new Ht(t,{geometry:M,program:y});F.frustumCulled=!1;let I=0,k=new Int32Array(0),U=()=>{let R=e.seats;for(let _=0;_<I;_++){let H=k[_];g[_]=ao(R.iState[H],H);let z=R.iCategory&&R.iState[H]===0?null:u[R.iState[H]]??u[0];if(z)C[_*3]=z[0],C[_*3+1]=z[1],C[_*3+2]=z[2];else{let O=Xn([R.iCategory[H*3],R.iCategory[H*3+1],R.iCategory[H*3+2]]);C[_*3]=O[0],C[_*3+1]=O[1],C[_*3+2]=O[2]}}M.attributes.iColor.needsUpdate=!0,M.attributes.iSeed.needsUpdate=!0},w={main:n,background:i,seatProgram:d,solidProgram:l,chairProgram:y,seatGeometry:p,chairGeometry:M,solidGeometry:s,drawCalls:3,setNearSeats(R,_){let H=Math.min(_,b);if(k=R,I=H,H===0){F.parent&&F.setParent(null),M.instancedCount=0,w.drawCalls=3;return}let V=e.seats;for(let z=0;z<H;z++){let O=R[z];S[z*3]=V.iPosition[O*3],S[z*3+1]=V.iPosition[O*3+1],S[z*3+2]=V.iPosition[O*3+2],P[z]=V.iChairWidth[O],v[z]=V.iYaw[O],T[z]=V.iGlyph[O],E[z*3]=V.iRing[O*3],E[z*3+1]=V.iRing[O*3+1],E[z*3+2]=V.iRing[O*3+2],L[z]=V.iFloor[O],G[z]=V.iPhysicalSeat[O],N[z]=O+1}U(),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=H,F.parent||F.setParent(n),w.drawCalls=4},nearSeatCount(){return I},uploadSeatStateRuns(R){if(!R.length)return;I&&U();for(let H of R)yr(h,e.seats.iState,H.start,H.length,u,e.seats.iCategory);let _=f.buffer;if(!_){f.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,_);for(let H of R){let V=h.subarray(H.start*3,(H.start+H.length)*3);t.bufferSubData(t.ARRAY_BUFFER,H.start*3*Float32Array.BYTES_PER_ELEMENT,V)}},dispose(){o.remove(),r.remove(),s.remove(),l.remove(),p.remove(),d.remove(),M.remove(),y.remove()}};return w}import{Mesh as Sn,RenderTarget as _a,Transform as wn}from"ogl";function ka(t,e,n){let i=t+(e<<8)+(n<<16);return i===0?-1:i-1}function gr(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 d=(l*e+c)*4,h=ka(t[d],t[d+1],t[d+2]);if(h<0||h>=r)continue;let u=c-i,p=l-o,m=u*u+p*p;m<s&&(s=m,a=h)}return a}function vr(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 La=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Ut=class{constructor(e,n,i,o,r){this.seatScene=new wn;this.chairScene=new wn;this.solidScene=new wn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=r,this.seatProg=lr(this.gl),this.chairProg=ur(this.gl),this.depthProg=mr(this.gl);let a=new Sn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new Sn(this.gl,{geometry:i,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let l=new Sn(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 La)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 _a(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),d=Math.max(0,i-o),h=Math.max(1,Math.min(s,n+o+1)-c),u=Math.max(1,Math.min(l,i+o+1)-d);r.enable(r.SCISSOR_TEST),r.scissor(c,d,h,u);let[p,m,f]=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,m,f,1),r.disable(r.SCISSOR_TEST);let x=new Uint8Array(h*u*4);return this.renderer.bindFramebuffer(a),r.readPixels(c,d,h,u,r.RGBA,r.UNSIGNED_BYTE,x),this.renderer.bindFramebuffer(),gr(x,h,u,n-c,i-d,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function Mr(t,e){let n=[];for(let i of e)t.has(i.seatId)?t.set(i.seatId,st(i.state)):n.push(i);return n}function Sr(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:ye[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 yt,Vec3 as Va}from"ogl";function Ba(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function wr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Oa(t,e){return[t[0]*e,t[1]*e,t[2]*e]}function Pr(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 Pn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function An(t,e){return Math.max(0,Math.min(1,t+e))}function Ar(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],d=t[Math.min(n-1,r+2)],h=a*a,u=h*a,p=[0,0,0];for(let m=0;m<3;m++)p[m]=.5*(2*l[m]+(-s[m]+c[m])*a+(2*s[m]-5*l[m]+4*c[m]-d[m])*h+(-s[m]+3*l[m]-3*c[m]+d[m])*u);return p}function Cn(t,e,n,i,o){let r=Pr(Ba(e,n));r[0]===0&&r[1]===0&&r[2]===0&&(r=[0,0,1]);let a=wr(wr(e,Oa(r,2.5)),[0,1.5,0]),s=[e[0]-i[0],0,e[2]-i[2]],l=Pr(s);l[0]===0&&l[2]===0&&(l=[r[0],0,r[2]]);let c=Math.max(1,o),d=[i[0]+l[0]*c*1.3,i[1]+c*.75,i[2]+l[2]*c*1.3];return{waypoints:[t,d,a],finalPos:a}}function Rn(t,e,n=35,i=28){let o=Pn(e),r=Ar(t,o),a=Pn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:r,fov:n+(i-n)*a,eased:o}}function Ir(t,e,n){let i=t.position.clone(),o=new yt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new Va(n[0],n[1],n[2]));let r=new yt().copy(t.quaternion);return t.position.copy(i),t.quaternion.copy(o),r}var Yt=class{constructor(e){this.active=!1;this.waypoints=[];this.startQuat=new yt;this.endQuat=new yt;this.outQuat=new yt;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}=Rn(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,An(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 Na=1.02,za=1.5;function Fr(t,e,n=0,i){let o=Number.isFinite(i)?n+i:t[1]+Na;return{eye:[t[0],o,t[2]],focal:[e.x*A,n+za,e.y*A]}}var In=null;function Tr(){return In??=import("../openPanorama-ALLZ6ADE.js").catch(t=>{throw In=null,t}),In}var Er=()=>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,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=Er(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(Er()-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 Dr(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function kr(t){let{container:e,model:n,opts:i,expandedSeatById:o,seatIdsByRow:r,isNarrow:a}=t,s=null,l=()=>{if(!s)return;let h=a();Object.assign(s.style,h?{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:(h,u,p=!1)=>{if(c(),t.isDisposed())return null;let m=document.createElement("div");m.setAttribute("role","group"),Object.assign(m.style,{position:"absolute",display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",zIndex:"4"});let f=o.get(h),x=f?.sectionId?n.sections.find(E=>E.id===f.sectionId):void 0,y=f?.label??h;m.setAttribute("aria-label",`Explore views near ${x?.label?`${x.label}, `:""}seat ${y}`);let b=document.createElement("span");b.textContent=["Live 3D seat view",x?.label,y].filter(Boolean).join(" \xB7 "),Object.assign(b.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)"}),m.appendChild(b);let S=document.createElement("div");Object.assign(S.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),m.appendChild(S);let C=f?.rowId?r.get(f.rowId):void 0,P=C?.indexOf(h)??-1,v=P>=0?[C?.[P-1],C?.[P+1]]:[void 0,void 0],T=(E,L,G,N=!1)=>{let g=document.createElement("button");g.type="button",g.textContent=E,g.setAttribute("aria-label",L),Object.assign(g.style,{minHeight:"44px",padding:N?"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"}),N||(g.style.minWidth="44px"),N&&(g.dataset.panoramaTrigger=""),g.addEventListener("click",G),S.appendChild(g)};if(v[0]){let E=o.get(v[0])?.label??v[0];T("\u2039",`View previous seat ${E}`,()=>{t.flyToSeat(v[0])})}if(i.getSeatView){let E=i.seatViewActionLabel?.(h)??"Open 360\xB0 panorama";T(p?`\u21BB Retry ${E}`:`\u25C9 ${E}`,`${p?"Retry":E} from seat ${y}`,()=>{if(t.isDisposed()||u!==t.flightGen()){c();return}c(),t.openPanorama(h,400,u)},!0)}if(v[1]){let E=o.get(v[1])?.label??v[1];T("\u203A",`View next seat ${E}`,()=>{t.flyToSeat(v[1])})}return S.childElementCount?(e.appendChild(m),s=m,l(),m):null},remove:c,layout:l}}function _r(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 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 h=document.createElement("button");h.type="button",h.textContent="+",h.setAttribute("aria-label","Zoom into the 3D venue"),h.dataset.tooltip="Zoom in";for(let f of[l,c,d,h])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(h,d);let u=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",()=>u("orbit")),c.addEventListener("click",()=>u("pan")),d.addEventListener("click",()=>n.zoomBy(1.22)),h.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),u("orbit"),e.appendChild(o);let p=()=>{let f=i();o.style.display=r?"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",h.style.display=f?"none":"",d.style.display=f?"none":""};return p(),{element:o,utilityControls:s,setNavigationMode:u,setSeatViewLocked:f=>{r=f,n.setInteractionEnabled(!f),p()},seatViewLocked:()=>r,layout:p}}function Lr(t){let{glctx:e,orbit:n,model:i,seats:o,opts:r,cinematic:a,analytics:s,seatIdByIndex:l,sectionIdBySeatId:c,tapSlop:d,tapMs:h,cancelFlight:u,focusSectionCamera:p,setSelection:m,ensureSeatView:f}=t,x=0,y=0,b=0,S=-1,C=!1,P=!1,v=N=>{t.seatViewLocked()||S===-1&&(S=N.pointerId,x=N.clientX,y=N.clientY,b=performance.now(),C=!1,P=a.active,a.active&&(s.cinematicCancelled(),u(),r.onViewTargetChange?.(null)))},T=N=>{N.pointerId===S&&Math.hypot(N.clientX-x,N.clientY-y)>d&&(C=!0)},E=(N,g,M,F,I)=>{let k=e.canvas.getBoundingClientRect(),U=e.canvas.clientWidth||k.width||1,w=e.canvas.clientHeight||k.height||1,R=N-k.left,_=g-k.top,H=F*F,V=-1,z=H,O=1/0;for(let W of o){if(M&&W.sectionId!==M)continue;let Y=i.seats.idToIndex.get(W.id);if(Y===void 0)continue;if(I){let ae=Math.round(i.seats.iState[Y]??0);if(ae!==0&&ae!==3)continue}let K=Y*3,q=Be(n.camera.projectionViewMatrix,[i.seats.iPosition[K],i.seats.iPosition[K+1]+.55,i.seats.iPosition[K+2]],U,w);if(!q.visible)continue;let ne=q.x-R,oe=q.y-_,$=ne*ne+oe*oe;($<z||Math.abs($-z)<1&&q.depth<O)&&(V=Y,z=$,O=q.depth)}return V},L=(N,g)=>{let M=t.gpu(),F=t.pick();if(!M||!F)return-1;F.syncFromSeatProgram(M.seatProgram);let I=e.canvas.getBoundingClientRect(),k=e.renderer.dpr,{x:U,y:w}=vr(N,g,I,k,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),R=Math.max(2,Math.round(8*k));return F.pick(n.camera,U,w,R)};return{onDown:v,onMove:T,onUp:N=>{if(N.pointerId!==S)return;let g=!C&&performance.now()-b<h;if(S=-1,P){P=!1;return}let M=t.gpu(),F=t.pick();if(!g||!M||!F)return;let I=L(N.clientX,N.clientY);if(t.focusedSectionId()&&I>=0){let w=l[I],R=w?c.get(w):void 0;if(R&&R!==t.focusedSectionId()&&p(R))return}if(t.focusedSectionId()&&I<0&&(I=E(N.clientX,N.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&I<0){let w=E(N.clientX,N.clientY,null,72,!1),R=w>=0?l[w]:void 0,_=R?c.get(R):void 0;if(_&&_!==t.focusedSectionId()&&p(_))return}if(!t.focusedSectionId()){I<0&&(I=E(N.clientX,N.clientY,null,42,!1));let w=I>=0?l[I]:void 0,R=w?c.get(w):void 0;if(R&&p(R))return}if(I<0||I>=l.length){t.selection().size&&(m([]),r.onViewTargetChange?.(null));return}let k=l[I],U=ye[Math.round(i.seats.iState[I]??0)]??"available";if(U!=="available"&&U!=="selected"){r.onSeatInspect?.(k,U);return}if(t.selection().has(k)&&t.selection().size===1){m([]),r.onViewTargetChange?.(null);return}m([k]),f(k),s.seatPicked(k,c.get(k)),r.onSeatPick?.(k)}}}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,i=1/0,o=-1/0,r=-1/0;for(let p=0;p<this.count;p++){let m=e[p*3],f=e[p*3+2];m<n&&(n=m),m>o&&(o=m),f<i&&(i=f),f>r&&(r=f)}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),d=p=>{let m=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+m};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 h=new Int32Array(this.count),u=c.slice(0,l);for(let p=0;p<this.count;p++)h[u[d(p)]++]=p;this.cellStart=c,this.cellItems=h}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),d=Math.floor((n-this.minZ)/this.cell),h=Math.ceil(i/this.cell)+1,u=this.iPosition,p=0;for(let m=0;m<=h&&p<s;m++){let f=d-m,x=d+m,y=c-m,b=c+m;for(let S=f;S<=x&&p<s;S++){if(S<0||S>=this.rows)continue;let C=S===f||S===x;for(let P=y;P<=b&&p<s;P++){if(!C&&P!==y&&P!==b){P=b-1;continue}if(P<0||P>=this.cols)continue;let v=S*this.cols+P;for(let T=r[v],E=r[v+1];T<E&&p<s;T++){let L=a[T],G=u[L*3]-e,N=u[L*3+2]-n;G*G+N*N<=l&&(o[p++]=L)}}}}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,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)<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){i.nearSeatCount()&&i.setNearSeats(this.nearBuf,0);return}let s=this.nearIndex.gather(o.x,o.z,nn,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 Ga,Vec3 as Ha}from"ogl";function Br(t){let{container:e,model:n,opts:i,orbit:o,cinematic:r,analytics:a,loop:s,labelOverlay:l,stageAzimuth:c,overviewFraming:d}=t,h=0,u=-1,p=(P,v,T=28)=>{o.camera.position.set(P[0],P[1],P[2]),o.camera.lookAt(new Ha(v[0],v[1],v[2])),o.camera.fov=T,o.camera.updateProjectionMatrix()},m=document.createElement("button");m.className="sl-3d-overview-control sl-3d-icon-control",m.type="button",m.textContent="\u2302",m.setAttribute("aria-label","Fit the active level or whole venue in view"),m.dataset.tooltip="Fit view",Object.assign(m.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=()=>{m.textContent="\u2302"};f();let x=P=>{u=P;let v=t.gpu();v&&(v.seatProgram.uniforms.uFocusFloor.value=P,v.solidProgram.uniforms.uFocusFloor.value=P,v.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(),m.style.display="",l.setVisible(!0),t.setFrozen(!1);let P=u>=0?n.floors[u]:null;if(t.setNearFieldDetailEnabled(!!P),t.setSeatViewLocked(!1),b(),t.removeArriveChip(),t.setNavigationMode("orbit"),P){let v=P.focalWorld[0]-P.center[0],T=P.focalWorld[2]-P.center[2],E=Math.hypot(v,T)>P.radius*.12?Math.atan2(v,T):c,L={center:P.center,radius:P.radius,box:P.box},G={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(L,!1,E,!1,G):o.frameSoft(L,E,!1,G)}else t.reducedMotion()?o.frame(n.bounds,!1,c,i.portraitOverviewCrop===!0,d):o.frameSoft(n.bounds,c,i.portraitOverviewCrop===!0,d);t.showSectionSeatLabels(null),s.requestRender()},b=()=>{h++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),r.active&&(r.cancel(),o.resumeAfterFlight(n.focalWorld))},S=P=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let v=n.seats.idToIndex.get(P);if(v===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),i.onViewTargetChange?.(P),t.panorama()&&(t.panorama().dispose(),t.setPanorama(null),t.setPanoramaSphereVisible(!1),m.style.display="",t.restorePanoramaLayer()),t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),t.setFrozen(!1),t.setSeatViewLocked(!1);let T=++h;t.removeArriveChip();let{eye:E,focal:L}=t.resolvedSeatViewPose(P,v),G=[o.camera.position.x,o.camera.position.y,o.camera.position.z],N=Cn(G,E,L,n.bounds.center,n.bounds.radius),g=i.arriveAtSeatEye?E:N.finalPos,M=i.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,F=[N.waypoints[0],N.waypoints[1],g];if(l.setVisible(!1),t.reducedMotion())return p(g,L,M),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(i.arriveAtSeatEye===!0),t.showArriveChip(P,T),Promise.resolve();let I=new Ga().copy(o.camera.quaternion),k=Ir(o.camera,g,L);return s.requestRender(),r.start(F,I,k,2500,M).then(()=>{t.isDisposed()||T!==h||(a.cinematicPlayed(2500),o.resumeAfterFlight(L),t.setSeatViewLocked(i.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(P,T))})},C=P=>{let v=n.sections.find(G=>G.id===P);if(!v||v.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),r.cancel(),t.removeArriveChip(),n.floors.length>1&&u!==v.floorIndex&&x(v.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(P);let T=v.focalWorld[0]-v.center[0],E=v.focalWorld[2]-v.center[2],L=Math.hypot(T,E)>v.radius*.12?Math.atan2(T,E):void 0;return o.frame({center:v.center,radius:Math.max(5,v.radius*.5)},!1,L),i.onSectionFocusChange?.(P),s.requestRender(),!0};return m.addEventListener("click",y),{overviewChip:m,layoutOverviewChip:f,flightGen:()=>h,focusedFloor:()=>u,applyFloorFocus:x,placeCameraFinal:p,cancelFlight:b,focusOverview:y,flyToSeat:S,focusSectionCamera:C}}function Or(t){let e=performance.now();return{model:bt(t),buildMs:performance.now()-e,source:"main"}}function Ua(t){return typeof Worker>"u"?Promise.resolve(Or(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(Or(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 Ya=Math.PI/180,Xa=6,Wa=500;function vu(t,e,n={}){let i=performance.now(),o=e.prepared?.model??bt(e),r=new Xt(n.onAnalytics),a=new Array(o.seats.count);for(let[D,B]of o.seats.idToIndex)a[B]=D;let s=new Map(e.seats.map(D=>[D.id,D])),l=new Map;for(let D of e.seats){if(!D.rowId)continue;let B=l.get(D.rowId);B?B.push(D.id):l.set(D.rowId,[D.id])}let c=new Map;for(let D of e.seats)c.set(D.id,D.sectionId);let d=e.doc.floors?.some(B=>(B.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(B=>B.objects)??e.doc.objects).some(B=>B.type==="section"&&((B.height??0)>0||(B.rake??0)>0)),h=null,u=null,p=!1,m=!1,f=!1,x=new Map,y=null,b=null,S=null,C=new Map,P=null,v=()=>{S===null&&(S=t.style.zIndex,t.style.zIndex="20")},T=()=>{S!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=S),S=null)},E=!1,L=()=>E?me.focusedFloor():-1,G=()=>{h=xr(F.gl,o),u=new Ut(F.renderer,h.seatGeometry,h.chairGeometry,h.solidGeometry,o.seats.count),F.setClearColor(o.theme.background.top),u.setRestoreClear(o.theme.background.top),h.seatProgram.uniforms.uSeatRadius.value=Ae*o.theme.seatScale,h.seatProgram.uniforms.uFocusFloor.value=L(),h.solidProgram.uniforms.uFocusFloor.value=L(),h.chairProgram.uniforms.uFocusFloor.value=L(),g.forceRegather()},N=!1,g=new jt({model:o,orbit:()=>I,gpu:()=>h}),M=D=>g.setDetailEnabled(D),F=new At(t,{onContextLost:()=>{f||r.contextLost(),p=!0,K.stop(),h=null,u=null},onContextRestored:()=>{G(),p=!1,f||r.contextRestored(),K.requestRender()}}),I=new Ct(F.gl,F.canvas,()=>K.requestRender(),()=>r.orbitEngaged());I.setAspect(F.aspect);let k=(e.doc.floors?.flatMap(D=>D.objects)??e.doc.objects).some(D=>D.type==="section"&&D.physical3dProvenance?.surfaceKind?.status==="inferred"),U=(()=>{if(k&&o.stages.length===0)return;let D=o.focalWorld[0]-o.bounds.center[0],B=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(D,B)>o.bounds.radius*.12?Math.atan2(D,B):void 0})(),w=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,R=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;I.frame(o.bounds,!R&&n.skipInitialOverviewAnimation!==!0,U,n.portraitOverviewCrop===!0,w);let _=new Yt(I.camera),H=Dr(t),V=new Nt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),z=o.labels,O=()=>Ho(z,o.floors.length,L());V.setLabels(O());let W=null,Y=D=>{if(W=D,V.setForcedDense(!!D),!D){V.setLabels(O());return}let B=e.seats.filter(j=>j.sectionId===D),X=new Set(B.map(j=>j.id)),Z=new Set(B.map(j=>j.rowId)),J=new Set(x.keys()),ee=new Set(B.filter(j=>J.has(j.id)).map(j=>j.id)),ce=O().filter(j=>j.kind!=="row"&&j.kind!=="seat"||(j.kind==="row"?Z.has(j.id.slice(4)):X.has(j.id.slice(5))&&(ee.size===0||ee.has(j.id.slice(5)))));if(o.seatCount<=6e3&&ee.size===0){V.setLabels(ce);return}let le=ee.size?B.filter(j=>ee.has(j.id)):B,Ne=new Set(le.map(j=>`seat:${j.id}`)),De=le.flatMap(j=>{let de=o.seats.idToIndex.get(j.id);if(de===void 0)return[];let Se=de*3;return[{id:`seat:${j.id}`,kind:"seat",text:j.displayLabel||j.label,anchor:[o.seats.iPosition[Se],o.seats.iPosition[Se+1]+(J.has(j.id)?1.05:.55),o.seats.iPosition[Se+2]]}]});V.setLabels([...ce.filter(j=>!Ne.has(j.id)),...De])};G();let K=new Rt(D=>{if(p||!h||m)return!1;let X=_.active?_.update(performance.now()):I.update(),Z=L()>=0?o.floors[L()]:null,J=Z?.radius??o.bounds.radius,ee=$n(I.currentDistance,J),ce=N?{center:[I.camera.position.x,I.camera.position.y,I.camera.position.z],radius:520}:o.renderBounds;I.updateClipping(ce);let le=Z?.center??o.renderBounds.center,Ne=Z?.radius??o.renderBounds.radius,De=(we,ot)=>Math.hypot(I.camera.position.x-we[0],I.camera.position.y-we[1],I.camera.position.z-we[2])<=ot*(g.detailVisible?1.8:1.55),j=De(le,Ne);if(!j&&W){let we=o.sections.find(ot=>ot.id===W);we&&(j=De(we.center,Math.max(12,we.radius*2)))}g.detailVisible=j;let de=h.seatProgram.uniforms;de.uSeatScale.value=ee.scale,de.uSeatFade.value=ee.fade;let Se=!!Z&&Jn(Z.seatCount,F.canvas.clientWidth||1,F.canvas.clientHeight||1),gt=eo(o.seats.count,J,I.currentDistance,I.camera.fov,F.canvas.clientHeight||1),nt=g.detailVisible||Se||gt?1:0,vt=g.detailVisible||L()>=0||o.floors.length>1?1:0;return g.ease(D,nt,vt),de.uSeatDetail.value=g.seatDetailMix,h.solidProgram.uniforms.uStructureDetail.value=g.structureDetailMix,de.uMinPixels.value=ee.minPixels,de.uPixelToWorld.value=2*Math.tan(I.camera.fov*Ya/2)/Math.max(1,F.pixelHeight),g.update(g.detailVisible),F.renderer.render({scene:h.background,clear:!0}),F.renderer.render({scene:h.main,camera:I.camera,clear:!1}),V.update(I.camera.projectionViewMatrix,F.canvas.clientWidth||1,F.canvas.clientHeight||1,I.currentDistance,J,[I.camera.position.x,I.camera.position.y,I.camera.position.z]),X||g.seatDetailMix!==nt||g.structureDetailMix!==vt}),q=typeof ResizeObserver<"u"?new ResizeObserver(()=>qt.resize()):null;q?.observe(t);let ne=D=>{let B=J=>{let ee=o.seats.idToIndex.get(J);return ee===void 0?void 0:o.seats.iState[ee]},{updates:X,next:Z}=Sr(x,D,B);if(x=Z,V.setSelectedSeatIds(x.keys()),W&&Y(W),X.length){let J=cn(o.seats,X);h&&h.uploadSeatStateRuns(J),K.requestRender()}},oe=()=>P!==null?P:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,$=8,ae=D=>{if(!n.getSeatView)return null;let B=C.get(D);if(!B)for(B=Promise.resolve(n.getSeatView(D)),C.set(D,B),B.catch(()=>{C.get(D)===B&&C.delete(D)});C.size>$;){let X=C.keys().next().value;if(X===void 0)break;C.delete(X)}return B},Oe=(D,B)=>{let X=s.get(D),Z=Math.max(0,Math.round(o.seats.iFloor[B]??0)),J=e.doc.floors?.[Z],ee=o.floors[Z],ce=J?.focalPoint??e.doc.focalPoint,le=ee?{x:ee.focalWorld[0]/A,y:ee.focalWorld[2]/A}:ce,Ne=X?.focalPoint?{x:X.focalPoint.x+le.x-ce.x,y:X.focalPoint.y+le.y-ce.y}:le,De=[o.seats.iPosition[B*3],o.seats.iPosition[B*3+1],o.seats.iPosition[B*3+2]];return Fr(De,Ne,J?.baseHeightM??0,X?.eyeHeightM)},Ve=()=>(t.clientWidth||F.canvas.clientWidth)<=520,xe=null,Ie=null,Fe=async(D,B,X)=>{if(!n.getSeatView||f||X!==me.flightGen())return;let Z;try{Z=await Tr()}catch{if(r.panoramaFailed(D,"mount"),!f&&X===me.flightGen()){let J=he(D,X,!0);requestAnimationFrame(()=>J?.querySelector("[data-panorama-trigger]")?.focus())}return}if(!(f||X!==me.flightGen()||!xe))return Ie??=Z.createOpenPanorama(xe),Ie(D,B,X)},ge=kr({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:l,isNarrow:Ve,isDisposed:()=>f,flightGen:()=>me.flightGen(),flyToSeat:D=>Tn(D),openPanorama:(D,B,X)=>Fe(D,B,X)}),he=ge.show,se=ge.remove,je=ge.layout,ve=_r({container:t,orbit:I,isNarrow:Ve}),Ke=ve.element,Me=ve.setNavigationMode,Te=ve.setSeatViewLocked,xt=ve.layout,Vr=ve.utilityControls,me=Br({container:t,model:o,opts:n,orbit:I,cinematic:_,analytics:r,loop:K,labelOverlay:V,stageAzimuth:U,overviewFraming:w,gpu:()=>h,isDisposed:()=>f,panorama:()=>y,setPanorama:D=>{y=D},setPanoramaSphereVisible:D=>{N=D},panoramaLoadAbort:()=>b,setPanoramaLoadAbort:D=>{b=D},setFrozen:D=>{m=D},restorePanoramaLayer:T,reducedMotion:oe,resolvedSeatViewPose:Oe,showSectionSeatLabels:Y,setNearFieldDetailEnabled:M,setSeatViewLocked:Te,setNavigationMode:Me,showArriveChip:he,removeArriveChip:se});E=!0;let Kt=me.overviewChip,Nr=me.layoutOverviewChip,zr=me.applyFloorFocus,Gr=me.focusOverview,Fn=me.cancelFlight,Tn=me.flyToSeat,En=me.focusSectionCamera;Vr.appendChild(Kt),xe={container:t,model:o,opts:n,analytics:r,orbit:I,loop:K,seatsById:s,ensureSeatView:ae,resolvedSeatViewPose:Oe,gpu:()=>h,gl:F.gl,isContextLost:()=>p,isDisposed:()=>f,flightGen:()=>me.flightGen(),setPanorama:D=>{y=D},getLoadAbort:()=>b,setLoadAbort:D=>{b=D},setPanoramaSphereVisible:D=>{N=D},setFrozen:D=>{m=D},raisePanoramaLayer:v,restorePanoramaLayer:T,getOverviewChip:()=>Kt,labelOverlay:V,reducedMotion:oe,removeArriveChip:se,showArriveChip:he};let Ee=Lr({glctx:F,orbit:I,model:o,seats:e.seats,opts:n,cinematic:_,analytics:r,seatIdByIndex:a,sectionIdBySeatId:c,tapSlop:Xa,tapMs:Wa,gpu:()=>h,pick:()=>u,seatViewLocked:()=>ve.seatViewLocked(),focusedSectionId:()=>W,selection:()=>x,cancelFlight:Fn,focusSectionCamera:En,setSelection:ne,ensureSeatView:ae});F.canvas.addEventListener("pointerdown",Ee.onDown),F.canvas.addEventListener("pointermove",Ee.onMove),F.canvas.addEventListener("pointerup",Ee.onUp),F.canvas.addEventListener("pointercancel",Ee.onUp),K.requestRender();let qt={setAvailability(D){let B=Mr(x,D),X=cn(o.seats,B);X.length&&h&&h.uploadSeatStateRuns(X),K.requestRender()},setSelection:ne,flyToSeat:Tn,focusOverview:Gr,resize(){let{width:D,height:B}=F.resize();I.setAspect(D/Math.max(1,B)),je(),xt(),Nr(),K.requestRender()},stats(){return{...K.stats(),drawCalls:h?h.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let D=K.stats(),B=F.canvas.clientWidth||1,X=F.canvas.clientHeight||1,Z=o.bounds.center,J=Be(I.camera.projectionViewMatrix,[Z[0],o.bounds.box.min[1],Z[2]],B,X),ee=Be(I.camera.projectionViewMatrix,[Z[0],o.bounds.box.max[1],Z[2]],B,X),ce=o.bounds.box,le=[ce.min[0],ce.max[0]].flatMap(j=>[ce.min[1],ce.max[1]].flatMap(de=>[ce.min[2],ce.max[2]].map(Se=>Be(I.camera.projectionViewMatrix,[j,de,Se],B,X)))).filter(j=>Number.isFinite(j.x)&&Number.isFinite(j.y)&&Number.isFinite(j.depth)),Ne=le.length?(()=>{let j=Math.min(...le.map(ze=>ze.x)),de=Math.max(...le.map(ze=>ze.x)),Se=Math.min(...le.map(ze=>ze.y)),gt=Math.max(...le.map(ze=>ze.y)),nt=Math.max(0,j),vt=Math.min(B,de),we=Math.max(0,Se),ot=Math.min(X,gt),Mt=Math.max(0,vt-nt),Zt=Math.max(0,ot-we);return{box:{x:nt,y:we,width:Mt,height:Zt},horizontalFillRatio:Mt/B,verticalFillRatio:Zt/X,visibleAreaRatio:Mt*Zt/(B*X),clippedEdges:[...Se<0?["top"]:[],...de>B?["right"]:[],...gt>X?["bottom"]:[],...j<0?["left"]:[]]}})():void 0,De=String(F.gl.getParameter(F.gl.VERSION)??"");return{viewport:{width:B,height:X},context:{webgl2:/webgl\s*2/i.test(De),lost:p},frame:{rendered:D.rendered,idle:D.idle},camera:{position:[I.camera.position.x,I.camera.position.y,I.camera.position.z],distance:I.currentDistance,verticalFovDeg:I.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:J.visible&&ee.visible?Math.abs(J.y-ee.y):0},labels:V.qualityEvidence(),framing:Ne}},getQualityReport(){return Mn(qt.getQualityEvidence())},loseContextForTest(){F.simulateContextLossCycle()},floors(){return o.floors},focusFloor(D){if(D!==null&&!o.floors.some(X=>X.index===D))return!1;let B=D??-1;if(M(D!==null),Te(!1),zr(B),Me("orbit"),D===null)_.cancel(),oe()?I.frame(o.bounds,!1,U,n.portraitOverviewCrop===!0,w):I.frameSoft(o.bounds,U,n.portraitOverviewCrop===!0,w);else{let X=o.floors[D];if(X.seatCount>0){_.cancel();let Z=X.focalWorld[0]-X.center[0],J=X.focalWorld[2]-X.center[2],ee=Math.hypot(Z,J)>X.radius*.12?Math.atan2(Z,J):U;I.frame({center:X.center,radius:X.radius,box:X.box},!1,ee,!1,{polarDeg:58,margin:1.12})}}return K.requestRender(),!0},zones(){return o.zones},focusZone(D){let B=o.zones.find(ee=>ee.id===D);if(!B||B.seatCount===0)return!1;M(!1),Te(!1),_.cancel(),Me("orbit"),Y(null),n.onSectionFocusChange?.(null);let X=B.focalWorld[0]-B.center[0],Z=B.focalWorld[2]-B.center[2],J=Math.hypot(X,Z)>B.radius*.12?Math.atan2(X,Z):void 0;return I.frame({center:B.center,radius:B.radius*1.25},!1,J),K.requestRender(),!0},sections(){return o.sections},focusSection(D){return En(D)},rows(D){return D?o.rows.filter(B=>B.sectionId===D):o.rows},seatsInRow(D){return e.seats.filter(B=>B.rowId===D).map(B=>({id:B.id,label:B.displayLabel||B.label}))},focusRow(D){let B=o.rows.find(X=>X.id===D);return!B||B.seatCount===0?!1:(M(!0),Te(!1),_.cancel(),Me("pan"),B.sectionId&&(Y(B.sectionId),n.onSectionFocusChange?.(B.sectionId)),I.frame({center:B.center,radius:Math.max(2.5,B.radius*.65)}),K.requestRender(),!0)},setReducedMotionForTest(D){P=D},dispose(){f=!0,se(),Kt.remove(),Ke.remove(),Fn(),K.stop(),V.dispose(),q?.disconnect(),y&&(y.dispose(),y=null),T(),H(),F.canvas.removeEventListener("pointerdown",Ee.onDown),F.canvas.removeEventListener("pointermove",Ee.onMove),F.canvas.removeEventListener("pointerup",Ee.onUp),F.canvas.removeEventListener("pointercancel",Ee.onUp),I.dispose(),u&&u.dispose(),h&&h.dispose(),h=null,u=null,F.dispose()}};return r.opened(o.seatCount,d,e.prepared?.buildMs??performance.now()-i,e.prepared?.source??"inline"),qt}export{da as VENUE3D_QUALITY_REPORT_VERSION,bt as buildSceneModel,Mn as inspectVenue3DQualityEvidence,vu as mountVenue3D,Ua as prepareVenue3D};
603
+ }`;function mr(t){return new je(t,{vertex:Ra,fragment:Ia,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uSeatRadius:{value:Ce},uSeatScale:{value:1},uMinPixels:{value:Qe},uPixelToWorld:{value:.002},uChairFull:{value:lt},uChairNone:{value:$e},uFocusFloor:{value:-1}}})}function dr(t){return new je(t,{vertex:Fa,fragment:Ta,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uChairFull:{value:lt},uChairNone:{value:$e},uBackRake:{value:an},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function hr(t){return new je(t,{vertex:Ea,fragment:Da,transparent:!1,depthTest:!0,depthWrite:!0,cullFace:!1,uniforms:{uFocusFloor:{value:-1}}})}function pr(t){return new je(t,{vertex:ga,fragment:va,cullFace:!1,depthTest:!0,depthWrite:!0,uniforms:{uKeyDir:{value:new Float32Array([.38,.86,.34])},uFocusFloor:{value:-1},uStructureDetail:{value:0}}})}function fr(t){return new je(t,{vertex:Ma,fragment:Sa,transparent:!0,depthTest:!0,depthWrite:!1,cullFace:!1,uniforms:{uSeatRadius:{value:Ce},uSeatScale:{value:1},uMinPixels:{value:Qe},uPixelToWorld:{value:.002},uSeatFade:{value:0},uSeatDetail:{value:0},uFocusFloor:{value:-1},uFadeColor:{value:new Float32Array([.32,.37,.43])},uChairFull:{value:lt},uChairNone:{value:$e}}})}function br(t){return new je(t,{vertex:wa,fragment:Pa,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:$e},uBackRake:{value:an},uBackBase:{value:_t},uFocusFloor:{value:-1}}})}function yr(t,e,n){return new je(t,{vertex:Ca,fragment:Aa,depthTest:!1,depthWrite:!1,cullFace:!1,uniforms:{uTop:{value:new Float32Array(e)},uBottom:{value:new Float32Array(n)}}})}function gr(t,e,n,r,o,i){for(let a=n;a<n+r;a++){let c=i&&e[a]===0?null:o[e[a]]??o[0];t[a*3]=c?c[0]:i[a*3],t[a*3+1]=c?c[1]:i[a*3+1],t[a*3+2]=c?c[2]:i[a*3+2]}}var ka=new Float32Array([-1,-1,1,-1,1,1,-1,-1,1,1,-1,1]),_a=new Float32Array([-1,-1,3,-1,-1,3]);function vr(t,e){let n=new xr,r=new xr,o=new Gt(t,{position:{size:2,data:_a}}),i=yr(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}}),c=pr(t),l=new Ht(t,{geometry:s,program:c});l.frustumCulled=!1,l.setParent(n);let u=fr(t),p=new Float32Array(e.seats.count*3),m=ye.map(S=>e.theme.seatStates[S]);gr(p,e.seats.iState,0,e.seats.count,m,e.seats.iCategory);let d=new Gt(t,{position:{size:2,data:ka},iOffset:{size:3,data:e.seats.iPosition,instanced:1},iColor:{size:3,data:p,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:d,program:u});h.frustumCulled=!1,e.seats.count>0&&h.setParent(n);let f=d.attributes.iColor,x=io(),y=br(t),b=It,M=new Float32Array(b*3),C=new Float32Array(b*3),P=new Float32Array(b),g=new Float32Array(b),T=new Float32Array(b),E=new Float32Array(b*3),L=new Float32Array(b),G=new Float32Array(b),N=new Float32Array(b),v=new Float32Array(b),A=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:M,instanced:1},iColor:{size:3,data:C,instanced:1},iRadius:{size:1,data:P,instanced:1},iYaw:{size:1,data:g,instanced:1},iGlyph:{size:1,data:T,instanced:1},iRing:{size:3,data:E,instanced:1},iFloor:{size:1,data:L,instanced:1},iPhysicalSeat:{size:1,data:G,instanced:1},iSeed:{size:1,data:v,instanced:1},iPickIndex:{size:1,data:N,instanced:1}}),F=new Ht(t,{geometry:A,program:y});F.frustumCulled=!1;let w=0,_=new Int32Array(0),U=()=>{let S=e.seats;for(let D=0;D<w;D++){let H=_[D];v[D]=so(S.iState[H],H);let z=S.iCategory&&S.iState[H]===0?null:m[S.iState[H]]??m[0];if(z)C[D*3]=z[0],C[D*3+1]=z[1],C[D*3+2]=z[2];else{let O=Wn([S.iCategory[H*3],S.iCategory[H*3+1],S.iCategory[H*3+2]]);C[D*3]=O[0],C[D*3+1]=O[1],C[D*3+2]=O[2]}}A.attributes.iColor.needsUpdate=!0,A.attributes.iSeed.needsUpdate=!0},I={main:n,background:r,seatProgram:u,solidProgram:c,chairProgram:y,seatGeometry:d,chairGeometry:A,solidGeometry:s,drawCalls:3,setNearSeats(S,D){let H=Math.min(D,b);if(_=S,w=H,H===0){F.parent&&F.setParent(null),A.instancedCount=0,I.drawCalls=3;return}let V=e.seats;for(let z=0;z<H;z++){let O=S[z];M[z*3]=V.iPosition[O*3],M[z*3+1]=V.iPosition[O*3+1],M[z*3+2]=V.iPosition[O*3+2],P[z]=V.iChairWidth[O],g[z]=V.iYaw[O],T[z]=V.iGlyph[O],E[z*3]=V.iRing[O*3],E[z*3+1]=V.iRing[O*3+1],E[z*3+2]=V.iRing[O*3+2],L[z]=V.iFloor[O],G[z]=V.iPhysicalSeat[O],N[z]=O+1}U(),A.attributes.iOffset.needsUpdate=!0,A.attributes.iRadius.needsUpdate=!0,A.attributes.iYaw.needsUpdate=!0,A.attributes.iGlyph.needsUpdate=!0,A.attributes.iRing.needsUpdate=!0,A.attributes.iFloor.needsUpdate=!0,A.attributes.iPhysicalSeat.needsUpdate=!0,A.attributes.iSeed.needsUpdate=!0,A.attributes.iPickIndex.needsUpdate=!0,A.instancedCount=H,F.parent||F.setParent(n),I.drawCalls=4},nearSeatCount(){return w},uploadSeatStateRuns(S){if(!S.length)return;w&&U();for(let H of S)gr(p,e.seats.iState,H.start,H.length,m,e.seats.iCategory);let D=f.buffer;if(!D){f.needsUpdate=!0;return}t.bindBuffer(t.ARRAY_BUFFER,D);for(let H of S){let V=p.subarray(H.start*3,(H.start+H.length)*3);t.bufferSubData(t.ARRAY_BUFFER,H.start*3*Float32Array.BYTES_PER_ELEMENT,V)}},dispose(){o.remove(),i.remove(),s.remove(),c.remove(),d.remove(),u.remove(),A.remove(),y.remove()}};return I}import{Mesh as Sn,RenderTarget as Ba,Transform as wn}from"ogl";function La(t,e,n){let r=t+(e<<8)+(n<<16);return r===0?-1:r-1}function Mr(t,e,n,r,o,i){let a=-1,s=1/0;for(let c=0;c<n;c++)for(let l=0;l<e;l++){let u=(c*e+l)*4,p=La(t[u],t[u+1],t[u+2]);if(p<0||p>=i)continue;let m=l-r,d=c-o,h=m*m+d*d;h<s&&(s=h,a=p)}return a}function Sr(t,e,n,r,o,i){let a=t-n.left,s=e-n.top,c=Math.round(a*r),l=Math.round((n.height-s)*r);return{x:Math.max(0,Math.min(o-1,c)),y:Math.max(0,Math.min(i-1,l))}}var Oa=["uSeatRadius","uSeatScale","uMinPixels","uPixelToWorld"],Ut=class{constructor(e,n,r,o,i){this.seatScene=new wn;this.chairScene=new wn;this.solidScene=new wn;this.target=null;this.restoreClear=[0,0,0];this.renderer=e,this.gl=e.gl,this.maxIndex=i,this.seatProg=mr(this.gl),this.chairProg=dr(this.gl),this.depthProg=hr(this.gl);let a=new Sn(this.gl,{geometry:n,program:this.seatProg});a.frustumCulled=!1,a.setParent(this.seatScene);let s=new Sn(this.gl,{geometry:r,program:this.chairProg});s.frustumCulled=!1,s.setParent(this.chairScene);let c=new Sn(this.gl,{geometry:o,program:this.depthProg});c.frustumCulled=!1,c.setParent(this.solidScene)}setRestoreClear(e){this.restoreClear=[e[0],e[1],e[2]]}syncFromSeatProgram(e){for(let r of Oa)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 Ba(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,c=i.drawingBufferHeight,l=Math.max(0,n-o),u=Math.max(0,r-o),p=Math.max(1,Math.min(s,n+o+1)-l),m=Math.max(1,Math.min(c,r+o+1)-u);i.enable(i.SCISSOR_TEST),i.scissor(l,u,p,m);let[d,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(d,h,f,1),i.disable(i.SCISSOR_TEST);let x=new Uint8Array(p*m*4);return this.renderer.bindFramebuffer(a),i.readPixels(l,u,p,m,i.RGBA,i.UNSIGNED_BYTE,x),this.renderer.bindFramebuffer(),Mr(x,p,m,n-l,r-u,this.maxIndex)}dispose(){this.destroyTarget(),this.seatProg.remove(),this.chairProg.remove(),this.depthProg.remove()}};function wr(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 Pr(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:ye[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 yt,Vec3 as za}from"ogl";function Va(t,e){return[t[0]-e[0],t[1]-e[1],t[2]-e[2]]}function Cr(t,e){return[t[0]+e[0],t[1]+e[1],t[2]+e[2]]}function Na(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 Pn(t){let e=Math.max(0,Math.min(1,t));return e*e*e*(e*(e*6-15)+10)}function Cn(t,e){return Math.max(0,Math.min(1,t+e))}function Rr(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)],c=t[i],l=t[i+1],u=t[Math.min(n-1,i+2)],p=a*a,m=p*a,d=[0,0,0];for(let h=0;h<3;h++)d[h]=.5*(2*c[h]+(-s[h]+l[h])*a+(2*s[h]-5*c[h]+4*l[h]-u[h])*p+(-s[h]+3*c[h]-3*l[h]+u[h])*m);return d}function An(t,e,n,r,o){let i=Ar(Va(e,n));i[0]===0&&i[1]===0&&i[2]===0&&(i=[0,0,1]);let a=Cr(Cr(e,Na(i,2.5)),[0,1.5,0]),s=[e[0]-r[0],0,e[2]-r[2]],c=Ar(s);c[0]===0&&c[2]===0&&(c=[i[0],0,i[2]]);let l=Math.max(1,o),u=[r[0]+c[0]*l*1.3,r[1]+l*.75,r[2]+c[2]*l*1.3];return{waypoints:[t,u,a],finalPos:a}}function Rn(t,e,n=35,r=28){let o=Pn(e),i=Rr(t,o),a=Pn(Math.max(0,Math.min(1,(e-.66)/.34)));return{pos:i,fov:n+(r-n)*a,eased:o}}function Tr(t,e,n){let r=t.position.clone(),o=new yt().copy(t.quaternion);t.position.set(e[0],e[1],e[2]),t.lookAt(new za(n[0],n[1],n[2]));let i=new yt().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 yt;this.endQuat=new yt;this.outQuat=new yt;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}=Rn(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,Cn(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 Ga=1.02,Ha=1.5;function Er(t,e,n=0,r){let o=Number.isFinite(r)?n+r:t[1]+Ga;return{eye:[t[0],o,t[2]],focal:[e.x*R,n+Ha,e.y*R]}}var In=null;function Dr(){return In??=import("../openPanorama-HGRYMWKC.js").catch(t=>{throw In=null,t}),In}var kr=()=>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=kr(),this.emit("3d_panorama_opened")}panoramaClosed(){let e=this.panoramaOpenedAt?Math.round(kr()-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 _r(t){let e=t.style.position;return getComputedStyle(t).position!=="static"?()=>{}:(t.style.position="relative",()=>{t.style.position==="relative"&&(t.style.position=e)})}function Lr(t){let{container:e,model:n,opts:r,expandedSeatById:o,seatIdsByRow:i,isNarrow:a}=t,s=null,c=()=>{if(!s)return;let p=a();Object.assign(s.style,p?{left:"12px",right:"12px",bottom:"70px",transform:"none",justifyContent:"center"}:{left:"50%",right:"auto",bottom:"18px",transform:"translateX(-50%)",justifyContent:"initial"})},l=()=>{s?.remove(),s=null};return{show:(p,m,d=!1)=>{if(l(),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(p),x=f?.sectionId?n.sections.find(E=>E.id===f.sectionId):void 0,y=f?.label??p;h.setAttribute("aria-label",`Explore views near ${x?.label?`${x.label}, `:""}seat ${y}`);let b=document.createElement("span");b.textContent=["Live 3D seat view",x?.label,y].filter(Boolean).join(" \xB7 "),Object.assign(b.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(b);let M=document.createElement("div");Object.assign(M.style,{display:"flex",alignItems:"center",justifyContent:"center",gap:"6px"}),h.appendChild(M);let C=f?.rowId?i.get(f.rowId):void 0,P=C?.indexOf(p)??-1,g=P>=0?[C?.[P-1],C?.[P+1]]:[void 0,void 0],T=(E,L,G,N=!1)=>{let v=document.createElement("button");v.type="button",v.textContent=E,v.setAttribute("aria-label",L),Object.assign(v.style,{minHeight:"44px",padding:N?"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"}),N||(v.style.minWidth="44px"),N&&(v.dataset.panoramaTrigger=""),v.addEventListener("click",G),M.appendChild(v)};if(g[0]){let E=o.get(g[0])?.label??g[0];T("\u2039",`View previous seat ${E}`,()=>{t.flyToSeat(g[0])})}if(r.getSeatView){let E=r.seatViewActionLabel?.(p)??"Open 360\xB0 panorama";T(d?`\u21BB Retry ${E}`:`\u25C9 ${E}`,`${d?"Retry":E} from seat ${y}`,()=>{if(t.isDisposed()||m!==t.flightGen()){l();return}l(),t.openPanorama(p,400,m)},!0)}if(g[1]){let E=o.get(g[1])?.label??g[1];T("\u203A",`View next seat ${E}`,()=>{t.flyToSeat(g[1])})}return M.childElementCount?(e.appendChild(h),s=h,c(),h):null},remove:l,layout:c}}function Br(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 c=document.createElement("button");c.type="button",c.textContent="\u21BB",c.setAttribute("aria-label","Drag to rotate the 3D venue"),c.dataset.tooltip="Rotate venue";let l=document.createElement("button");l.type="button",l.textContent="\u2725",l.setAttribute("aria-label","Drag to move the 3D venue left, right, up or down"),l.dataset.tooltip="Move venue";let u=document.createElement("button");u.type="button",u.textContent="\u2212",u.setAttribute("aria-label","Zoom out of the 3D venue"),u.dataset.tooltip="Zoom out";let p=document.createElement("button");p.type="button",p.textContent="+",p.setAttribute("aria-label","Zoom into the 3D venue"),p.dataset.tooltip="Zoom in";for(let f of[c,l,u,p])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(c,l),s.append(p,u);let m=f=>{n.setPrimaryDragMode(f);let x=f==="orbit";c.setAttribute("aria-pressed",String(x)),l.setAttribute("aria-pressed",String(!x)),c.style.background=x?"rgba(96,110,150,0.68)":"rgba(12,18,32,0.82)",l.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"};c.addEventListener("click",()=>m("orbit")),l.addEventListener("click",()=>m("pan")),u.addEventListener("click",()=>n.zoomBy(1.22)),p.addEventListener("click",()=>n.zoomBy(.82)),o.append(a,s),m("orbit"),e.appendChild(o);let d=()=>{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",p.style.display=f?"none":"",u.style.display=f?"none":""};return d(),{element:o,utilityControls:s,setNavigationMode:m,setSeatViewLocked:f=>{i=f,n.setInteractionEnabled(!f),d()},seatViewLocked:()=>i,layout:d}}function Or(t){let{glctx:e,orbit:n,model:r,seats:o,opts:i,cinematic:a,analytics:s,seatIdByIndex:c,sectionIdBySeatId:l,tapSlop:u,tapMs:p,cancelFlight:m,focusSectionCamera:d,setSelection:h,ensureSeatView:f}=t,x=0,y=0,b=0,M=-1,C=!1,P=!1,g=N=>{t.seatViewLocked()||M===-1&&(M=N.pointerId,x=N.clientX,y=N.clientY,b=performance.now(),C=!1,P=a.active,a.active&&(s.cinematicCancelled(),m(),i.onViewTargetChange?.(null)))},T=N=>{N.pointerId===M&&Math.hypot(N.clientX-x,N.clientY-y)>u&&(C=!0)},E=(N,v,A,F,w)=>{let _=e.canvas.getBoundingClientRect(),U=e.canvas.clientWidth||_.width||1,I=e.canvas.clientHeight||_.height||1,S=N-_.left,D=v-_.top,H=F*F,V=-1,z=H,O=1/0;for(let W of o){if(A&&W.sectionId!==A)continue;let Y=r.seats.idToIndex.get(W.id);if(Y===void 0)continue;if(w){let ae=Math.round(r.seats.iState[Y]??0);if(ae!==0&&ae!==3)continue}let K=Y*3,q=Be(n.camera.projectionViewMatrix,[r.seats.iPosition[K],r.seats.iPosition[K+1]+.55,r.seats.iPosition[K+2]],U,I);if(!q.visible)continue;let ne=q.x-S,oe=q.y-D,$=ne*ne+oe*oe;($<z||Math.abs($-z)<1&&q.depth<O)&&(V=Y,z=$,O=q.depth)}return V},L=(N,v)=>{let A=t.gpu(),F=t.pick();if(!A||!F)return-1;F.syncFromSeatProgram(A.seatProgram);let w=e.canvas.getBoundingClientRect(),_=e.renderer.dpr,{x:U,y:I}=Sr(N,v,w,_,e.gl.drawingBufferWidth,e.gl.drawingBufferHeight),S=Math.max(2,Math.round(8*_));return F.pick(n.camera,U,I,S)};return{onDown:g,onMove:T,onUp:N=>{if(N.pointerId!==M)return;let v=!C&&performance.now()-b<p;if(M=-1,P){P=!1;return}let A=t.gpu(),F=t.pick();if(!v||!A||!F)return;let w=L(N.clientX,N.clientY);if(t.focusedSectionId()&&w>=0){let I=c[w],S=I?l.get(I):void 0;if(S&&S!==t.focusedSectionId()&&d(S))return}if(t.focusedSectionId()&&w<0&&(w=E(N.clientX,N.clientY,t.focusedSectionId(),44,!1)),t.focusedSectionId()&&w<0){let I=E(N.clientX,N.clientY,null,72,!1),S=I>=0?c[I]:void 0,D=S?l.get(S):void 0;if(D&&D!==t.focusedSectionId()&&d(D))return}if(!t.focusedSectionId()){w<0&&(w=E(N.clientX,N.clientY,null,42,!1));let I=w>=0?c[w]:void 0,S=I?l.get(I):void 0;if(S&&d(S))return}if(w<0||w>=c.length){t.selection().size&&(h([]),i.onViewTargetChange?.(null));return}let _=c[w],U=ye[Math.round(r.seats.iState[w]??0)]??"available";if(U!=="available"&&U!=="selected"){i.onSeatInspect?.(_,U);return}if(t.selection().has(_)&&t.selection().size===1){h([]),i.onViewTargetChange?.(null);return}h([_]),f(_),s.seatPicked(_,l.get(_)),i.onSeatPick?.(_)}}}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 d=0;d<this.count;d++){let h=e[d*3],f=e[d*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 c=this.cols*this.rows,l=new Int32Array(c+1),u=d=>{let h=Math.min(this.cols-1,Math.max(0,Math.floor((e[d*3]-n)/this.cell)));return Math.min(this.rows-1,Math.max(0,Math.floor((e[d*3+2]-r)/this.cell)))*this.cols+h};for(let d=0;d<this.count;d++)l[u(d)+1]++;for(let d=0;d<c;d++)l[d+1]+=l[d];let p=new Int32Array(this.count),m=l.slice(0,c);for(let d=0;d<this.count;d++)p[m[u(d)]++]=d;this.cellStart=l,this.cellItems=p}gather(e,n,r,o){this.ensureGrid();let i=this.cellStart,a=this.cellItems;if(!i||!a)return 0;let s=o.length,c=r*r,l=Math.floor((e-this.minX)/this.cell),u=Math.floor((n-this.minZ)/this.cell),p=Math.ceil(r/this.cell)+1,m=this.iPosition,d=0;for(let h=0;h<=p&&d<s;h++){let f=u-h,x=u+h,y=l-h,b=l+h;for(let M=f;M<=x&&d<s;M++){if(M<0||M>=this.rows)continue;let C=M===f||M===x;for(let P=y;P<=b&&d<s;P++){if(!C&&P!==y&&P!==b){P=b-1;continue}if(P<0||P>=this.cols)continue;let g=M*this.cols+P;for(let T=i[g],E=i[g+1];T<E&&d<s;T++){let L=a[T],G=m[L*3]-e,N=m[L*3+2]-n;G*G+N*N<=c&&(o[d++]=L)}}}}return d}};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 Ua,Vec3 as Ya}from"ogl";function Vr(t){let{container:e,model:n,opts:r,orbit:o,cinematic:i,analytics:a,loop:s,labelOverlay:c,stageAzimuth:l,overviewFraming:u}=t,p=0,m=-1,d=(P,g,T=28)=>{o.camera.position.set(P[0],P[1],P[2]),o.camera.lookAt(new Ya(g[0],g[1],g[2])),o.camera.fov=T,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=P=>{m=P;let g=t.gpu();g&&(g.seatProgram.uniforms.uFocusFloor.value=P,g.solidProgram.uniforms.uFocusFloor.value=P,g.chairProgram.uniforms.uFocusFloor.value=P),t.showSectionSeatLabels(null)},y=()=>{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="",c.setVisible(!0),t.setFrozen(!1);let P=m>=0?n.floors[m]:null;if(t.setNearFieldDetailEnabled(!!P),t.setSeatViewLocked(!1),b(),t.removeArriveChip(),t.setNavigationMode("orbit"),P){let g=P.focalWorld[0]-P.center[0],T=P.focalWorld[2]-P.center[2],E=Math.hypot(g,T)>P.radius*.12?Math.atan2(g,T):l,L={center:P.center,radius:P.radius,box:P.box},G={polarDeg:58,margin:1.12};t.reducedMotion()?o.frame(L,!1,E,!1,G):o.frameSoft(L,E,!1,G)}else t.reducedMotion()?o.frame(n.bounds,!1,l,r.portraitOverviewCrop===!0,u):o.frameSoft(n.bounds,l,r.portraitOverviewCrop===!0,u);t.showSectionSeatLabels(null),s.requestRender()},b=()=>{p++,t.panoramaLoadAbort()?.abort(),t.setPanoramaLoadAbort(null),i.active&&(i.cancel(),o.resumeAfterFlight(n.focalWorld))},M=P=>{if(t.isDisposed()||!t.gpu())return Promise.resolve();let g=n.seats.idToIndex.get(P);if(g===void 0)return Promise.resolve();t.setNearFieldDetailEnabled(!0),r.onViewTargetChange?.(P),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 T=++p;t.removeArriveChip();let{eye:E,focal:L}=t.resolvedSeatViewPose(P,g),G=[o.camera.position.x,o.camera.position.y,o.camera.position.z],N=An(G,E,L,n.bounds.center,n.bounds.radius),v=r.arriveAtSeatEye?E:N.finalPos,A=r.arriveAtSeatEye?e.clientWidth/Math.max(1,e.clientHeight)<.7?90:65:28,F=[N.waypoints[0],N.waypoints[1],v];if(c.setVisible(!1),t.reducedMotion())return d(v,L,A),s.requestRender(),a.cinematicSkipped(),t.isDisposed()||o.syncFromCamera(),t.setSeatViewLocked(r.arriveAtSeatEye===!0),t.showArriveChip(P,T),Promise.resolve();let w=new Ua().copy(o.camera.quaternion),_=Tr(o.camera,v,L);return s.requestRender(),i.start(F,w,_,2500,A).then(()=>{t.isDisposed()||T!==p||(a.cinematicPlayed(2500),o.resumeAfterFlight(L),t.setSeatViewLocked(r.arriveAtSeatEye===!0),s.requestRender(),t.showArriveChip(P,T))})},C=P=>{let g=n.sections.find(G=>G.id===P);if(!g||g.seatCount===0)return!1;t.setNearFieldDetailEnabled(!0),t.setSeatViewLocked(!1),i.cancel(),t.removeArriveChip(),n.floors.length>1&&m!==g.floorIndex&&x(g.floorIndex),t.setNavigationMode("pan"),t.showSectionSeatLabels(P);let T=g.focalWorld[0]-g.center[0],E=g.focalWorld[2]-g.center[2],L=Math.hypot(T,E)>g.radius*.12?Math.atan2(T,E):void 0;return o.frame({center:g.center,radius:Math.max(5,g.radius*.5)},!1,L),r.onSectionFocusChange?.(P),s.requestRender(),!0};return h.addEventListener("click",y),{overviewChip:h,layoutOverviewChip:f,flightGen:()=>p,focusedFloor:()=>m,applyFloorFocus:x,placeCameraFinal:d,cancelFlight:b,focusOverview:y,flyToSeat:M,focusSectionCamera:C}}function Nr(t){let e=performance.now();return{model:bt(t),buildMs:performance.now()-e,source:"main"}}function Xa(t){return typeof Worker>"u"?Promise.resolve(Nr(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(Nr(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 Wa=Math.PI/180,ja=6,Ka=500;function Ru(t,e,n={}){let r=performance.now(),o=e.prepared?.model??bt(e),i=new Xt(n.onAnalytics),a=new Array(o.seats.count);for(let[k,B]of o.seats.idToIndex)a[B]=k;let s=new Map(e.seats.map(k=>[k.id,k])),c=new Map;for(let k of e.seats){if(!k.rowId)continue;let B=c.get(k.rowId);B?B.push(k.id):c.set(k.rowId,[k.id])}let l=new Map;for(let k of e.seats)l.set(k.id,k.sectionId);let u=e.doc.floors?.some(B=>(B.baseHeightM??0)>0)?!0:(e.doc.floors?.flatMap(B=>B.objects)??e.doc.objects).some(B=>B.type==="section"&&((B.height??0)>0||(B.rake??0)>0)),p=null,m=null,d=!1,h=!1,f=!1,x=new Map,y=null,b=null,M=null,C=new Map,P=null,g=()=>{M===null&&(M=t.style.zIndex,t.style.zIndex="20")},T=()=>{M!==null&&(t.style.zIndex==="20"&&(t.style.zIndex=M),M=null)},E=!1,L=()=>E?me.focusedFloor():-1,G=()=>{p=vr(F.gl,o),m=new Ut(F.renderer,p.seatGeometry,p.chairGeometry,p.solidGeometry,o.seats.count),F.setClearColor(o.theme.background.top),m.setRestoreClear(o.theme.background.top),p.seatProgram.uniforms.uSeatRadius.value=Ce*o.theme.seatScale,p.seatProgram.uniforms.uFocusFloor.value=L(),p.solidProgram.uniforms.uFocusFloor.value=L(),p.chairProgram.uniforms.uFocusFloor.value=L(),v.forceRegather()},N=!1,v=new jt({model:o,orbit:()=>w,gpu:()=>p}),A=k=>v.setDetailEnabled(k),F=new Ct(t,{onContextLost:()=>{f||i.contextLost(),d=!0,K.stop(),p=null,m=null},onContextRestored:()=>{G(),d=!1,f||i.contextRestored(),K.requestRender()}}),w=new At(F.gl,F.canvas,()=>K.requestRender(),()=>i.orbitEngaged());w.setAspect(F.aspect);let _=(e.doc.floors?.flatMap(k=>k.objects)??e.doc.objects).some(k=>k.type==="section"&&k.physical3dProvenance?.surfaceKind?.status==="inferred"),U=(()=>{if(_&&o.stages.length===0)return;let k=o.focalWorld[0]-o.bounds.center[0],B=o.focalWorld[2]-o.bounds.center[2];return Math.hypot(k,B)>o.bounds.radius*.12?Math.atan2(k,B):void 0})(),I=o.floors.length>1?{polarDeg:48,margin:1.1}:void 0,S=typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;w.frame(o.bounds,!S&&n.skipInitialOverviewAnimation!==!0,U,n.portraitOverviewCrop===!0,I);let D=new Yt(w.camera),H=_r(t),V=new Nt(t,{fontFamily:e.doc.theme?.fontFamily,ink:e.doc.theme?.textColor,backgroundRgb:o.theme.background.top}),z=o.labels,O=()=>Uo(z,o.floors.length,L());V.setLabels(O());let W=null,Y=k=>{if(W=k,V.setForcedDense(!!k),!k){V.setLabels(O());return}let B=e.seats.filter(j=>j.sectionId===k),X=new Set(B.map(j=>j.id)),Z=new Set(B.map(j=>j.rowId)),J=new Set(x.keys()),ee=new Set(B.filter(j=>J.has(j.id)).map(j=>j.id)),ce=O().filter(j=>j.kind!=="row"&&j.kind!=="seat"||(j.kind==="row"?Z.has(j.id.slice(4)):X.has(j.id.slice(5))&&(ee.size===0||ee.has(j.id.slice(5)))));if(o.seatCount<=6e3&&ee.size===0){V.setLabels(ce);return}let le=ee.size?B.filter(j=>ee.has(j.id)):B,Ne=new Set(le.map(j=>`seat:${j.id}`)),De=le.flatMap(j=>{let de=o.seats.idToIndex.get(j.id);if(de===void 0)return[];let Se=de*3;return[{id:`seat:${j.id}`,kind:"seat",text:j.displayLabel||j.label,anchor:[o.seats.iPosition[Se],o.seats.iPosition[Se+1]+(J.has(j.id)?1.05:.55),o.seats.iPosition[Se+2]]}]});V.setLabels([...ce.filter(j=>!Ne.has(j.id)),...De])};G();let K=new Rt(k=>{if(d||!p||h)return!1;let X=D.active?D.update(performance.now()):w.update(),Z=L()>=0?o.floors[L()]:null,J=Z?.radius??o.bounds.radius,ee=Jn(w.currentDistance,J),ce=N?{center:[w.camera.position.x,w.camera.position.y,w.camera.position.z],radius:520}:o.renderBounds;w.updateClipping(ce);let le=Z?.center??o.renderBounds.center,Ne=Z?.radius??o.renderBounds.radius,De=(we,rt)=>Math.hypot(w.camera.position.x-we[0],w.camera.position.y-we[1],w.camera.position.z-we[2])<=rt*(v.detailVisible?1.8:1.55),j=De(le,Ne);if(!j&&W){let we=o.sections.find(rt=>rt.id===W);we&&(j=De(we.center,Math.max(12,we.radius*2)))}v.detailVisible=j;let de=p.seatProgram.uniforms;de.uSeatScale.value=ee.scale,de.uSeatFade.value=ee.fade;let Se=!!Z&&eo(Z.seatCount,F.canvas.clientWidth||1,F.canvas.clientHeight||1),gt=to(o.seats.count,J,w.currentDistance,w.camera.fov,F.canvas.clientHeight||1),ot=v.detailVisible||Se||gt?1:0,vt=v.detailVisible||L()>=0||o.floors.length>1?1:0;return v.ease(k,ot,vt),de.uSeatDetail.value=v.seatDetailMix,p.solidProgram.uniforms.uStructureDetail.value=v.structureDetailMix,de.uMinPixels.value=ee.minPixels,de.uPixelToWorld.value=2*Math.tan(w.camera.fov*Wa/2)/Math.max(1,F.pixelHeight),v.update(v.detailVisible),F.renderer.render({scene:p.background,clear:!0}),F.renderer.render({scene:p.main,camera:w.camera,clear:!1}),V.update(w.camera.projectionViewMatrix,F.canvas.clientWidth||1,F.canvas.clientHeight||1,w.currentDistance,J,[w.camera.position.x,w.camera.position.y,w.camera.position.z]),X||v.seatDetailMix!==ot||v.structureDetailMix!==vt}),q=typeof ResizeObserver<"u"?new ResizeObserver(()=>qt.resize()):null;q?.observe(t);let ne=k=>{let B=J=>{let ee=o.seats.idToIndex.get(J);return ee===void 0?void 0:o.seats.iState[ee]},{updates:X,next:Z}=Pr(x,k,B);if(x=Z,V.setSelectedSeatIds(x.keys()),W&&Y(W),X.length){let J=cn(o.seats,X);p&&p.uploadSeatStateRuns(J),K.requestRender()}},oe=()=>P!==null?P:typeof window<"u"&&!!window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,$=8,ae=k=>{if(!n.getSeatView)return null;let B=C.get(k);if(!B)for(B=Promise.resolve(n.getSeatView(k)),C.set(k,B),B.catch(()=>{C.get(k)===B&&C.delete(k)});C.size>$;){let X=C.keys().next().value;if(X===void 0)break;C.delete(X)}return B},Oe=(k,B)=>{let X=s.get(k),Z=Math.max(0,Math.round(o.seats.iFloor[B]??0)),J=e.doc.floors?.[Z],ee=o.floors[Z],ce=J?.focalPoint??e.doc.focalPoint,le=ee?{x:ee.focalWorld[0]/R,y:ee.focalWorld[2]/R}:ce,Ne=X?.focalPoint?{x:X.focalPoint.x+le.x-ce.x,y:X.focalPoint.y+le.y-ce.y}:le,De=[o.seats.iPosition[B*3],o.seats.iPosition[B*3+1],o.seats.iPosition[B*3+2]];return Er(De,Ne,J?.baseHeightM??0,X?.eyeHeightM)},Ve=()=>(t.clientWidth||F.canvas.clientWidth)<=520,xe=null,Ie=null,Fe=async(k,B,X)=>{if(!n.getSeatView||f||X!==me.flightGen())return;let Z;try{Z=await Dr()}catch{if(i.panoramaFailed(k,"mount"),!f&&X===me.flightGen()){let J=he(k,X,!0);requestAnimationFrame(()=>J?.querySelector("[data-panorama-trigger]")?.focus())}return}if(!(f||X!==me.flightGen()||!xe))return Ie??=Z.createOpenPanorama(xe),Ie(k,B,X)},ge=Lr({container:t,model:o,opts:n,expandedSeatById:s,seatIdsByRow:c,isNarrow:Ve,isDisposed:()=>f,flightGen:()=>me.flightGen(),flyToSeat:k=>Tn(k),openPanorama:(k,B,X)=>Fe(k,B,X)}),he=ge.show,se=ge.remove,Ke=ge.layout,ve=Br({container:t,orbit:w,isNarrow:Ve}),qe=ve.element,Me=ve.setNavigationMode,Te=ve.setSeatViewLocked,xt=ve.layout,zr=ve.utilityControls,me=Vr({container:t,model:o,opts:n,orbit:w,cinematic:D,analytics:i,loop:K,labelOverlay:V,stageAzimuth:U,overviewFraming:I,gpu:()=>p,isDisposed:()=>f,panorama:()=>y,setPanorama:k=>{y=k},setPanoramaSphereVisible:k=>{N=k},panoramaLoadAbort:()=>b,setPanoramaLoadAbort:k=>{b=k},setFrozen:k=>{h=k},restorePanoramaLayer:T,reducedMotion:oe,resolvedSeatViewPose:Oe,showSectionSeatLabels:Y,setNearFieldDetailEnabled:A,setSeatViewLocked:Te,setNavigationMode:Me,showArriveChip:he,removeArriveChip:se});E=!0;let Kt=me.overviewChip,Gr=me.layoutOverviewChip,Hr=me.applyFloorFocus,Ur=me.focusOverview,Fn=me.cancelFlight,Tn=me.flyToSeat,En=me.focusSectionCamera;zr.appendChild(Kt),xe={container:t,model:o,opts:n,analytics:i,orbit:w,loop:K,seatsById:s,ensureSeatView:ae,resolvedSeatViewPose:Oe,gpu:()=>p,gl:F.gl,isContextLost:()=>d,isDisposed:()=>f,flightGen:()=>me.flightGen(),setPanorama:k=>{y=k},getLoadAbort:()=>b,setLoadAbort:k=>{b=k},setPanoramaSphereVisible:k=>{N=k},setFrozen:k=>{h=k},raisePanoramaLayer:g,restorePanoramaLayer:T,getOverviewChip:()=>Kt,labelOverlay:V,reducedMotion:oe,removeArriveChip:se,showArriveChip:he};let Ee=Or({glctx:F,orbit:w,model:o,seats:e.seats,opts:n,cinematic:D,analytics:i,seatIdByIndex:a,sectionIdBySeatId:l,tapSlop:ja,tapMs:Ka,gpu:()=>p,pick:()=>m,seatViewLocked:()=>ve.seatViewLocked(),focusedSectionId:()=>W,selection:()=>x,cancelFlight:Fn,focusSectionCamera:En,setSelection:ne,ensureSeatView:ae});F.canvas.addEventListener("pointerdown",Ee.onDown),F.canvas.addEventListener("pointermove",Ee.onMove),F.canvas.addEventListener("pointerup",Ee.onUp),F.canvas.addEventListener("pointercancel",Ee.onUp),K.requestRender();let qt={setAvailability(k){let B=wr(x,k),X=cn(o.seats,B);X.length&&p&&p.uploadSeatStateRuns(X),K.requestRender()},setSelection:ne,flyToSeat:Tn,focusOverview:Ur,resize(){let{width:k,height:B}=F.resize();w.setAspect(k/Math.max(1,B)),Ke(),xt(),Gr(),K.requestRender()},stats(){return{...K.stats(),drawCalls:p?p.drawCalls:0,seatCount:o.seatCount}},getQualityEvidence(){let k=K.stats(),B=F.canvas.clientWidth||1,X=F.canvas.clientHeight||1,Z=o.bounds.center,J=Be(w.camera.projectionViewMatrix,[Z[0],o.bounds.box.min[1],Z[2]],B,X),ee=Be(w.camera.projectionViewMatrix,[Z[0],o.bounds.box.max[1],Z[2]],B,X),ce=o.bounds.box,le=[ce.min[0],ce.max[0]].flatMap(j=>[ce.min[1],ce.max[1]].flatMap(de=>[ce.min[2],ce.max[2]].map(Se=>Be(w.camera.projectionViewMatrix,[j,de,Se],B,X)))).filter(j=>Number.isFinite(j.x)&&Number.isFinite(j.y)&&Number.isFinite(j.depth)),Ne=le.length?(()=>{let j=Math.min(...le.map(ze=>ze.x)),de=Math.max(...le.map(ze=>ze.x)),Se=Math.min(...le.map(ze=>ze.y)),gt=Math.max(...le.map(ze=>ze.y)),ot=Math.max(0,j),vt=Math.min(B,de),we=Math.max(0,Se),rt=Math.min(X,gt),Mt=Math.max(0,vt-ot),Zt=Math.max(0,rt-we);return{box:{x:ot,y:we,width:Mt,height:Zt},horizontalFillRatio:Mt/B,verticalFillRatio:Zt/X,visibleAreaRatio:Mt*Zt/(B*X),clippedEdges:[...Se<0?["top"]:[],...de>B?["right"]:[],...gt>X?["bottom"]:[],...j<0?["left"]:[]]}})():void 0,De=String(F.gl.getParameter(F.gl.VERSION)??"");return{viewport:{width:B,height:X},context:{webgl2:/webgl\s*2/i.test(De),lost:d},frame:{rendered:k.rendered,idle:k.idle},camera:{position:[w.camera.position.x,w.camera.position.y,w.camera.position.z],distance:w.currentDistance,verticalFovDeg:w.fovY},scene:{seatCount:o.seatCount,floorCount:o.floors.length,zoneCount:o.zones.length,sectionCount:o.sections.length,authoredRelief:u,renderedVerticalSpanM:Math.max(0,o.bounds.box.max[1]-o.bounds.box.min[1]),projectedReliefPx:J.visible&&ee.visible?Math.abs(J.y-ee.y):0},labels:V.qualityEvidence(),framing:Ne}},getQualityReport(){return Mn(qt.getQualityEvidence())},loseContextForTest(){F.simulateContextLossCycle()},floors(){return o.floors},focusFloor(k){if(k!==null&&!o.floors.some(X=>X.index===k))return!1;let B=k??-1;if(A(k!==null),Te(!1),Hr(B),Me("orbit"),k===null)D.cancel(),oe()?w.frame(o.bounds,!1,U,n.portraitOverviewCrop===!0,I):w.frameSoft(o.bounds,U,n.portraitOverviewCrop===!0,I);else{let X=o.floors[k];if(X.seatCount>0){D.cancel();let Z=X.focalWorld[0]-X.center[0],J=X.focalWorld[2]-X.center[2],ee=Math.hypot(Z,J)>X.radius*.12?Math.atan2(Z,J):U;w.frame({center:X.center,radius:X.radius,box:X.box},!1,ee,!1,{polarDeg:58,margin:1.12})}}return K.requestRender(),!0},zones(){return o.zones},focusZone(k){let B=o.zones.find(ee=>ee.id===k);if(!B||B.seatCount===0)return!1;A(!1),Te(!1),D.cancel(),Me("orbit"),Y(null),n.onSectionFocusChange?.(null);let X=B.focalWorld[0]-B.center[0],Z=B.focalWorld[2]-B.center[2],J=Math.hypot(X,Z)>B.radius*.12?Math.atan2(X,Z):void 0;return w.frame({center:B.center,radius:B.radius*1.25},!1,J),K.requestRender(),!0},sections(){return o.sections},focusSection(k){return En(k)},rows(k){return k?o.rows.filter(B=>B.sectionId===k):o.rows},seatsInRow(k){return e.seats.filter(B=>B.rowId===k).map(B=>({id:B.id,label:B.displayLabel||B.label}))},focusRow(k){let B=o.rows.find(X=>X.id===k);return!B||B.seatCount===0?!1:(A(!0),Te(!1),D.cancel(),Me("pan"),B.sectionId&&(Y(B.sectionId),n.onSectionFocusChange?.(B.sectionId)),w.frame({center:B.center,radius:Math.max(2.5,B.radius*.65)}),K.requestRender(),!0)},setReducedMotionForTest(k){P=k},dispose(){f=!0,se(),Kt.remove(),qe.remove(),Fn(),K.stop(),V.dispose(),q?.disconnect(),y&&(y.dispose(),y=null),T(),H(),F.canvas.removeEventListener("pointerdown",Ee.onDown),F.canvas.removeEventListener("pointermove",Ee.onMove),F.canvas.removeEventListener("pointerup",Ee.onUp),F.canvas.removeEventListener("pointercancel",Ee.onUp),w.dispose(),m&&m.dispose(),p&&p.dispose(),p=null,m=null,F.dispose()}};return i.opened(o.seatCount,u,e.prepared?.buildMs??performance.now()-r,e.prepared?.source??"inline"),qt}export{pa as VENUE3D_QUALITY_REPORT_VERSION,bt as buildSceneModel,Mn as inspectVenue3DQualityEvidence,Ru as mountVenue3D,Xa as prepareVenue3D};