@seatlayer/core 0.97.0 → 0.98.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{C as f,F as d}from"../../chunk-NGZXKXOY.js";import"../../chunk-2P72QUJR.js";import"../../chunk-OLGPAFXW.js";import"../../chunk-QJXSZT3H.js";import"../../chunk-ASIIXY5M.js";import"../../chunk-M5VINTGE.js";import"../../chunk-P4C24CIZ.js";import"../../chunk-IW7QZIMF.js";import"../../chunk-Z43H6AWN.js";import"../../chunk-4N5CHKHD.js";import"../../chunk-TQN2VWQO.js";import"../../chunk-5BMXWOE7.js";import"../../chunk-FLMKHAUT.js";import{Va as i}from"../../chunk-VAI2VDQR.js";import"../../chunk-5ITK5236.js";import"../../chunk-JBOTRSMY.js";import"../../chunk-CRCGO52K.js";function p(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(t=>t.buffer)}var c=self;c.onmessage=e=>{let s=performance.now(),t=!e.data.seats,r=e.data.seats??i(e.data.doc),{input:u,estimate:a}=d({doc:e.data.doc,seats:r,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),o=f(u),n=p(o);a&&n.push(a.eyeHeightM.buffer,a.focal.buffer),c.postMessage({model:o,buildMs:performance.now()-s,...t?{seats:r}:{},...a?{estimate:a}:{}},n)};
1
+ import{C as f,F as d}from"../../chunk-2MXDWZQ4.js";import"../../chunk-2P72QUJR.js";import"../../chunk-OLGPAFXW.js";import"../../chunk-QJXSZT3H.js";import"../../chunk-ASIIXY5M.js";import"../../chunk-M5VINTGE.js";import"../../chunk-P4C24CIZ.js";import"../../chunk-IW7QZIMF.js";import"../../chunk-Z43H6AWN.js";import"../../chunk-4N5CHKHD.js";import"../../chunk-TQN2VWQO.js";import"../../chunk-5BMXWOE7.js";import"../../chunk-FLMKHAUT.js";import{Va as i}from"../../chunk-VAI2VDQR.js";import"../../chunk-5ITK5236.js";import"../../chunk-JBOTRSMY.js";import"../../chunk-CRCGO52K.js";function p(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(t=>t.buffer)}var c=self;c.onmessage=e=>{let s=performance.now(),t=!e.data.seats,r=e.data.seats??i(e.data.doc),{input:u,estimate:a}=d({doc:e.data.doc,seats:r,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),o=f(u),n=p(o);a&&n.push(a.eyeHeightM.buffer,a.focal.buffer),c.postMessage({model:o,buildMs:performance.now()-s,...t?{seats:r}:{},...a?{estimate:a}:{}},n)};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seatlayer/core",
3
- "version": "0.97.0",
3
+ "version": "0.98.0",
4
4
  "description": "SeatLayer's seat map rendering engine — the seating chart runtime behind @seatlayer/js and the React, Vue, and Angular SDKs.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
@@ -1 +0,0 @@
1
- import{a as ge,c as Me,d as Se}from"./chunk-OLGPAFXW.js";import{a as de}from"./chunk-QJXSZT3H.js";import{v as Pe}from"./chunk-ASIIXY5M.js";import{a as xe,c as jt,d as mt,f as ht,i as be}from"./chunk-P4C24CIZ.js";import{f as re}from"./chunk-Z43H6AWN.js";import{e as ye,l as pe}from"./chunk-4N5CHKHD.js";import{B as se,C as qt,Ma as At,Va as un,ba as et,ca as xt,j as ie,la as cn,na as Xt,oa as ln,qa as ae,sa as Ht,ta as ce,ua as le,wa as Cn,xa as ue,ya as fe}from"./chunk-VAI2VDQR.js";import{A as _t,D as he,b as me,d as ot,y as rt}from"./chunk-JBOTRSMY.js";import fr from"earcut";import Re from"polygon-clipping";var g=et,mr=.002;function hr(t,n,e){let i=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),r=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),a=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),o=Math.max(i,r,a);if(o<1e-9)return!0;let s=(i+r+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-r)*(s-a)))/o<mr}var Dt=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,i){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=n,this.buf[this.len++]=e,this.buf[this.len++]=i}push1(n){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=n}grow(n){let e=this.buf.length*2;for(;e<n;)e*=2;let i=new Float32Array(e);i.set(this.buf.subarray(0,this.len)),this.buf=i}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},hn=class{constructor(){this.pos=new Dt;this.nor=new Dt;this.col=new Dt;this.flr=new Dt;this.mat=new Dt;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,i,r,a,o=a,s=a){hr(n,e,i)||(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(o[0],o[1],o[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(n,e,i,r,a,o,s,u=s,c=s){[...n,...e,...i].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(i[0],i[1],i[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(u[0],u[1],u[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 yr(t,n,e){let i=n[0]-t[0],r=n[1]-t[1],a=n[2]-t[2],o=e[0]-t[0],s=e[1]-t[1],u=e[2]-t[2],c=r*u-a*s,l=a*o-i*u,f=i*s-r*o,m=Math.hypot(c,l,f)||1;return c/=m,l/=m,f/=m,[c,l,f]}function pr(t,n){let e=[...t],i=[];for(let o of t)i.push(o.x,o.y);let r=[];if(n){for(let o of n)if(!(o.length<3)){r.push(e.length);for(let s of o)e.push(s),i.push(s.x,s.y)}}let a=fr(i,r.length?r:void 0,2);return{pts:e,tris:a}}function wt(t){return mt(t)<0?[...t].reverse():t}var dr=3;function xr(t,n,e,i){let r=i(t),a=i(n),o=i(e),s=(y,h,p,b)=>Math.abs(i({x:(y.x+h.x)/2,y:(y.y+h.y)/2})-(p+b)/2),u=(t.x+n.x+e.x)/3,c=(t.y+n.y+e.y)/3,l=(r+a+o)/3,f=Math.max(s(t,n,r,a),s(n,e,a,o),s(e,t,o,r),Math.abs(i({x:u,y:c})-l)),m=(y,h,p)=>{let b=Math.abs(i({x:(y+u)/2,y:(h+c)/2})-(p+l)/2);b>f&&(f=b)};return m((t.x+n.x)/2,(t.y+n.y)/2,(r+a)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(a+o)/2),m((e.x+t.x)/2,(e.y+t.y)/2,(o+r)/2),f}function $t(t,n,e,i,r){if(r<=0)return xr(t,n,e,i);let a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},o={x:(n.x+e.x)/2,y:(n.y+e.y)/2},s={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max($t(t,a,s,i,r-1),$t(a,n,o,i,r-1),$t(s,o,e,i,r-1),$t(a,o,s,i,r-1))}function Qt(t,n,e,i,r,a,o,s){if(o>0){let m={x:(n.x+e.x)/2,y:(n.y+e.y)/2},y={x:(e.x+i.x)/2,y:(e.y+i.y)/2},h={x:(i.x+n.x)/2,y:(i.y+n.y)/2};Qt(t,n,m,h,r,a,o-1,s),Qt(t,m,e,y,r,a,o-1,s),Qt(t,h,y,i,r,a,o-1,s),Qt(t,m,y,h,r,a,o-1,s);return}let u=[n.x*g,r(n),n.y*g],c=[e.x*g,r(e),e.y*g],l=[i.x*g,r(i),i.y*g];if(s){t.triN(u,c,l,s(n),s(e),s(i),a);return}let f=yr(u,c,l);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(u,c,l,f,a)}var br=8;function Ie(t,n,e){if(!Number.isFinite(e))return t;let i=[],r=(a,o,s,u,c)=>{if(c>0){let l={x:(a.x+o.x)/2,y:(a.y+o.y)/2},f=n(l);if(Math.abs(f-(s+u)/2)>e){r(a,l,s,f,c-1),r(l,o,f,u,c-1);return}}i.push(a)};for(let a=0;a<t.length;a++){let o=t[a],s=t[(a+1)%t.length];r(o,s,n(o),n(s),br)}return i}function fn(t,n){if(t.length<3)return t;let e=[];for(let r of t){let a=e[e.length-1];a&&Math.hypot(r.x-a.x,r.y-a.y)<n||e.push(r)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let i=[];for(let r=0;r<e.length;r++){let a=i.length?i[i.length-1]:e[(r-1+e.length)%e.length],o=e[r],s=e[(r+1)%e.length],u=s.x-a.x,c=s.y-a.y,l=Math.hypot(u,c);l>n&&Math.abs((o.x-a.x)*c-(o.y-a.y)*u)/l<n||i.push(o)}return i.length>=3?i:e}var mn=.001*xt*.1;function K(t,n,e,i,r,a,o,s,u=1/0,c){if(!n||n.length<3||(u===void 0&&(u=1/0),Math.abs(mt(n))<1e-4))return;let l=fn(Ie(fn(wt(n),mn),i,u),mn),f=e?.map(R=>fn(Ie(fn(wt(R),mn),i,u),mn)).filter(R=>R.length>=3&&Math.abs(mt(R))>=1e-4),{pts:m,tris:y}=pr(l,f),h=[a[0]*s.top,a[1]*s.top,a[2]*s.top],p=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],b=[o[0]*s.top,o[1]*s.top,o[2]*s.top],x=[o[0]*s.wallBottom,o[1]*s.wallBottom,o[2]*s.wallBottom],d=0;if(Number.isFinite(u))for(;d<dr;d++){let R=0;for(let w=0;w<y.length;w+=3){let I=$t(m[y[w]],m[y[w+1]],m[y[w+2]],i,d);I>R&&(R=I)}if(R<=u)break}for(let R=0;R<y.length;R+=3){let w=m[y[R]],I=m[y[R+1]],P=m[y[R+2]];Qt(t,w,I,P,i,h,d,c);let _=[w.x*g,r,w.y*g],T=[I.x*g,r,I.y*g],k=[P.x*g,r,P.y*g];t.tri(_,k,T,[0,-1,0],p)}let M=R=>{if(d<=0)return R;let w=1<<d,I=[];for(let P=0;P<R.length;P++){let _=R[P],T=R[(P+1)%R.length];for(let k=0;k<w;k++){let X=k/w;I.push({x:_.x+(T.x-_.x)*X,y:_.y+(T.y-_.y)*X})}}return I},S=se(l),A=[{ring:M(l),flip:!1}];if(f)for(let R of f)R.length>=3&&A.push({ring:M(R),flip:!0});for(let{ring:R,flip:w}of A)for(let I=0;I<R.length;I++){let P=R[I],_=R[(I+1)%R.length],T=(_.x-P.x)*g,X=(_.y-P.y)*g,B=-T,E=Math.hypot(X,B)||1;X/=E,B/=E;let O=(P.x+_.x)/2-S.x,D=(P.y+_.y)/2-S.y,C=X*O+B*D;w&&(C=-C),C<0&&(X=-X,B=-B);let F=[X,0,B],v=[P.x*g,i(P),P.y*g],G=[_.x*g,i(_),_.y*g],j=[P.x*g,r,P.y*g],U=[_.x*g,r,_.y*g];t.tri(v,G,U,F,b,b,x),t.tri(v,U,j,F,b,x,x)}}function Ae(t){let n=0;for(let u of t)n+=u.count;let e=new Float32Array(n*3),i=new Float32Array(n*3),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),s=0;for(let u of t)e.set(u.position,s*3),i.set(u.normal,s*3),r.set(u.color,s*3),a.set(u.floor,s),o.set(u.material,s),s+=u.count;return{position:e,normal:i,color:r,floor:a,material:o,count:n}}function Mt(t,n,e=2.5){if(n<=0||t.length<3)return t;let i=wt(t),r=i.length,a=[];for(let s=0;s<r;s++){let u=i[s],c=i[(s+1)%r],l=c.x-u.x,f=c.y-u.y,m=Math.hypot(l,f)||1;a.push({x:f/m,y:-l/m})}let o=[];for(let s=0;s<r;s++){let u=i[s],c=a[(s-1+r)%r],l=a[s],f=c.x+l.x,m=c.y+l.y,y=Math.hypot(f,m),h=()=>{o.push([u.x+c.x*n,u.y+c.y*n]),o.push([u.x+l.x*n,u.y+l.y*n])};if(y<1e-9){h();continue}f/=y,m/=y;let p=f*c.x+m*c.y,b=1/Math.max(p,1e-6);if(!Number.isFinite(b)||b>e){h();continue}o.push([u.x+f*n*b,u.y+m*n*b])}if(o.length<3)return t;try{let s=Re.union([[...o,o[0]]]),u=null,c=-1/0;for(let f of s){let m=Math.abs(mt(f[0].map(([y,h])=>({x:y,y:h}))));m>c&&(c=m,u=f[0])}if(!u)return t;let l=u.map(([f,m])=>({x:f,y:m}));if(l.length>1){let f=l[0],m=l[l.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&l.pop()}return l.length>=3?l:t}catch{return t}}function Lt(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let i=wt(t),r=i.length,a=[];for(let u=0;u<r;u++){let c=i[u],l=i[(u+1)%r],f=Math.hypot(l.x-c.x,l.y-c.y)||1;a.push({x:-(l.y-c.y)/f,y:(l.x-c.x)/f})}let o=[],s=[];for(let u=0;u<r;u++){let c=i[u],l=a[(u-1+r)%r],f=a[u],m=l.x+f.x,y=l.y+f.y,h=Math.hypot(m,y),p=h<1e-9?1/0:1/Math.max(m/h*l.x+y/h*l.y,1e-6);if(!Number.isFinite(p)||p>e){o.push({x:c.x+l.x*n,y:c.y+l.y*n},{x:c.x+f.x*n,y:c.y+f.y*n}),s.push(u,u);continue}m/=h,y/=h,o.push({x:c.x+m*n*p,y:c.y+y*n*p}),s.push(u)}for(let u=0;u<o.length;u++){let c=(u+1)%o.length,l=s[u],f=s[c];if(f!==(l+1)%r)continue;let m=i[l],y=i[f];if((o[c].x-o[u].x)*(y.x-m.x)+(o[c].y-o[u].y)*(y.y-m.y)<=0)return[]}try{let u=Re.intersection([[...o.map(h=>[h.x,h.y]),[o[0].x,o[0].y]]],[[...i.map(h=>[h.x,h.y]),[i[0].x,i[0].y]]]),c=null,l=0;for(let h of u){let p=Math.abs(mt(h[0].map(([b,x])=>({x:b,y:x}))));p>l&&(l=p,c=h[0])}if(!c)return[];let f=c.map(([h,p])=>({x:h,y:p})),m=f[0],y=f[f.length-1];return f.length>1&&Math.abs(m.x-y.x)<1e-9&&Math.abs(m.y-y.y)<1e-9&&f.pop(),f.length>=3?wt(f):[]}catch{return[]}}function yn(t,n,e,i,r=28){let a=[];for(let o=0;o<r;o++){let s=o/r*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+i*Math.sin(s)})}return a}function Jt(t,n,e,i){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+i},{x:t,y:n+i}]}var tn=["available","held","sold","selected","dimmed"];function On(t){let n=tn.indexOf(t);return n<0?0:n}var _e={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Ta(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.78,i=.86;return[(n+(t[0]-n)*e)*i,(n+(t[1]-n)*e)*i,(n+(t[2]-n)*e)*i]}var kn={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]},Fn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function z(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}var st={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},gr=.44,Mr=.15,Sr=.3,Pr=.24;function Ee(t){return t===void 0||!Number.isFinite(t)||t<=0?Pr:Math.min(Sr,Math.max(Mr,t*gr))}var Oa=.21,Ir=.05,vn=.45,Rr=vn+Ir,Ar=.92,we=.66,_r=1.205,wr=-.23,Er=.38,Br=[{part:st.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:st.pad,min:[-1,.36,-.95],max:[1,vn,1]},{part:st.back,min:[-1,Rr,-1],max:[1,Ar,-.72]},{part:st.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:st.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:st.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:st.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:st.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:st.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:st.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Tr=[{part:st.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:st.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:st.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:st.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:st.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Cr=[{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 ka(){let t=[],n=[],e=[],i=[],r=(O,D,C)=>{let F=e.length,[v,G,j]=O,U=[G[0]-v[0],G[1]-v[1],G[2]-v[2]],H=[j[0]-v[0],j[1]-v[1],j[2]-v[2]],W=U[1]*H[2]-U[2]*H[1],nt=U[2]*H[0]-U[0]*H[2],$=U[0]*H[1]-U[1]*H[0],Q=Math.hypot(W,nt,$);Q>1e-9?(W/=Q,nt/=Q,$/=Q):[W,nt,$]=D,W*D[0]+nt*D[1]+$*D[2]<0&&(W=-W,nt=-nt,$=-$);for(let N of O)t.push(...N),n.push(W,nt,$),e.push(C);i.push(F,F+1,F+2,F,F+2,F+3)},a=O=>{for(let D of Cr){let C=D.c.map(F=>F.map((v,G)=>v?O.max[G]:O.min[G]));r(C,D.n,O.part)}},o=(O,D)=>{let[C,F,v]=D?[0,1,2]:[0,2,1],G=O.min[C],j=O.max[C],U=O.min[F],H=O.max[F],W=(j-G)*.1,nt=(H-U)*.1,$=D?[[G+W,U],[j-W,U],[j,U+nt],[j*.94,H-(H-U)*.23],[j*we,H],[G*we,H],[G*.94,H-(H-U)*.23],[G,U+nt]]:[[G+W,U],[j-W,U],[j,U+nt],[j,H-nt],[j-W,H],[G+W,H],[G,H-nt],[G,U+nt]],Q=(L,Z,J)=>{let q=[0,0,0];return q[C]=L,q[F]=Z,q[v]=J,q},N=[O.min[v],O.max[v]].map(L=>$.map(([Z,J])=>Q(Z,J,L)));for(let L=0;L<$.length;L++){let Z=(L+1)%$.length,J=[0,0,0];J[C]=($[L][0]+$[Z][0])/2-(G+j)/2,J[F]=($[L][1]+$[Z][1])/2-(U+H)/2,r([N[0][L],N[0][Z],N[1][Z],N[1][L]],J,O.part)}for(let L=0;L<2;L++){let Z=[0,0,0];Z[v]=L?1:-1;let J=N[L];for(let q=1;q<J.length-1;q++){let ct=e.length;for(let it of[J[0],J[q],J[q+1]])t.push(...it),n.push(...Z),e.push(O.part);i.push(ct,ct+1,ct+2)}}};for(let O of Br)O.part===st.pad||O.part===st.back?o(O,O.part===st.back):a(O);for(let O of Tr)a(O);let s=vn,u=1.08,c=.47,l=.69,f=-.55,m=.08,y=-.48,h=.01,p=[-c,s,f],b=[c,s,f],x=[-c,s,m],d=[c,s,m],M=[-l,u,y],S=[l,u,y],A=[-l,u,h],R=[l,u,h];r([b,S,R,d],[1,0,0],st.body),r([x,A,M,p],[-1,0,0],st.body),r([A,R,S,M],[0,1,0],st.body),r([p,b,d,x],[0,-1,0],st.body),r([d,R,A,x],[0,0,1],st.body),r([p,M,S,b],[0,0,-1],st.body);let w=10,I=8,P=[0,_r,wr],_=[.42,.115,Er],T=e.length;for(let O=0;O<=I;O++){let D=Math.PI*O/I,C=Math.cos(D),F=Math.sin(D);for(let v=0;v<=w;v++){let G=Math.PI*2*v/w,j=F*Math.cos(G),U=F*Math.sin(G);t.push(P[0]+_[0]*j,P[1]+_[1]*C,P[2]+_[2]*U);let H=j/_[0],W=C/_[1],nt=U/_[2],$=Math.hypot(H,W,nt)||1;H/=$,W/=$,nt/=$,n.push(H,W,nt),e.push(st.head)}}for(let O=0;O<I;O++)for(let D=0;D<w;D++){let C=T+O*(w+1)+D,F=C+w+1;i.push(C,F,C+1,C+1,F,F+1)}let k=new Float32Array(t),X=new Float32Array(n),B=new Float32Array(e),E=new Uint16Array(i);return{position:k,normal:X,part:B,index:E,vertexCount:e.length,indexCount:i.length}}function Be(t,n,e,i){let r=new Float32Array(n),a=c=>t[c*3],o=c=>t[c*3+2],s=0,u=(c,l)=>{let f=l-c;for(let m=c;m<l;m++){let[y,h]=i(m),p=y-a(m),b=h-o(m);if(f>=2){let x=Math.max(c,m-1),d=Math.min(l-1,m+1),M=a(d)-a(x),S=o(d)-o(x),A=Math.hypot(M,S);if(A>1e-6){let R=-S/A,w=M/A;R*p+w*b<0&&(R=-R,w=-w),p=R,b=w}}r[m]=p===0&&b===0?0:Math.atan2(p,b)}};for(let c=1;c<=n;c++)(c===n||e(c)!==e(s))&&(u(s,c),s=c);return r}var pn=.22;function ja(t,n){let e=tn[t];if(e!=="sold"&&e!=="held")return-1;let i=(n+1)*2654435761;return i^=i>>>15,i=Math.imul(i,2246822519),i^=i>>>13,(i>>>0)%1e5/1e5}var Or=.42;function kr(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let i=1/0,r=1/0,a=-1/0,o=-1/0;for(let h of t)h.x<i&&(i=h.x),h.y<r&&(r=h.y),h.x>a&&(a=h.x),h.y>o&&(o=h.y);let s=Math.max(a-i,1e-6),u=Math.max(o-r,1e-6),c=Math.max(Math.sqrt(s*u/n),1e-6),l=Math.max(1,Math.ceil(s/c)+1),f=Math.max(1,Math.ceil(u/c)+1),m=new Map,y=(h,p)=>{let b=Math.min(l-1,Math.max(0,Math.floor((h-i)/c)));return Math.min(f-1,Math.max(0,Math.floor((p-r)/c)))*l+b};for(let h=0;h<n;h++){let p=y(t[h].x,t[h].y),b=m.get(p);b?b.push(h):m.set(p,[h])}for(let h=0;h<n;h++){let p=t[h],b=Math.min(l-1,Math.max(0,Math.floor((p.x-i)/c))),x=Math.min(f-1,Math.max(0,Math.floor((p.y-r)/c))),d=1/0;for(let M=1;M<=4;M++){for(let S=x-M;S<=x+M;S++)if(!(S<0||S>=f))for(let A=b-M;A<=b+M;A++){if(A<0||A>=l||M>1&&Math.abs(S-x)<M&&Math.abs(A-b)<M)continue;let R=m.get(S*l+A);if(R)for(let w of R){if(w===h)continue;let I=Math.hypot(t[w].x-p.x,t[w].y-p.y);I<d&&(d=I)}}if(Number.isFinite(d)&&d<=M*c)break}e[h]=d}return e}function Fr(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-cn):0}function Te(t,n,e,i,r,a){let o=t.length,s=new Float32Array(o*3),u=new Float32Array(o),c=new Float32Array(o*3),l=new Float32Array(o),f=new Float32Array(o),m=new Float32Array(o),y=new Float32Array(o),h=new Float32Array(o*3),p=new Map,b=kr(t);for(let x=0;x<o;x++){let d=t[x],S=(e?.seatPitchU(x)??b[x])*g;l[x]=Number.isFinite(S)?Math.max(.06,Math.min(pn,S*Or)):pn,f[x]=Ee(Number.isFinite(S)?S:void 0);let A=pe(d.glyph,{seatGlyph:a?.get(d.categoryKey)});m[x]=ye.indexOf(A),y[x]=d.wheelchairSpaceType==="no-seat"?0:1,s[x*3]=d.x*g,s[x*3+1]=e?e.seatDeckY(x):Fr(d),s[x*3+2]=d.y*g,u[x]=On(n?n(d):"available");let R=ot(r?.get(d.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[x*3]=R[0],c[x*3+1]=R[1],c[x*3+2]=R[2],d.accessibility?.length){let w=ot(re(d.accessibility));w&&(h[x*3]=w[0],h[x*3+1]=w[1],h[x*3+2]=w[2])}p.set(d.id,x)}return{count:o,iPosition:s,iState:u,iCategory:c,iMaxRadius:l,iRing:h,idToIndex:p,iChairWidth:f,iGlyph:m,iPhysicalSeat:y,iFloor:i??new Float32Array(o),iSection:new Float32Array(o).fill(-1),iYaw:new Float32Array(o)}}var vr=64;function Ua(t,n){let e=[];for(let o of n){let s=t.idToIndex.get(o.seatId);if(s===void 0)continue;let u=On(o.state);t.iState[s]!==u&&(t.iState[s]=u,e.push(s))}if(!e.length)return[];e.sort((o,s)=>o-s);let i=[],r=e[0],a=e[0];for(let o=1;o<e.length;o++){let s=e[o];if(s!==a){if(s<=a+vr){a=s;continue}i.push({start:r,length:a-r+1}),r=s,a=s}}return i.push({start:r,length:a-r+1}),i}import Kr from"polygon-clipping";var V={top:1,wallBottom:.58,bottomCap:.4};function kt(t,n){if(!t)return n;let e=z(_t(t,.4),.62);return rt(n,e,.22)}function Ce(t,n){return t?rt(n,z(_t(t,.08),.9),.82):n}function Oe(t,n){let e=new Map;for(let a of t.categories??[])e.set(a.key,a.color);let i=new Map;for(let a of n){if(!a.sectionId)continue;let o=i.get(a.sectionId);o||(o=new Map,i.set(a.sectionId,o)),o.set(a.categoryKey,(o.get(a.categoryKey)??0)+1)}let r=new Map;for(let[a,o]of i){let s=0,u=0,c=0,l=0;for(let[f,m]of o){let y=ot(e.get(f));y&&(s+=y[0]*m,u+=y[1]*m,c+=y[2]*m,l+=m)}l>0&&r.set(a,[s/l,u/l,c/l])}return r}function ke(t,n){return ot(t.color)??n.get(t.logicalSectionId??t.id)??null}import Ve from"polygon-clipping";import Le from"polygon-clipping";import Dr from"earcut";var Lr=.58,Fe=.01,bt=pn*1.5*xt,Gr=.5,Nr=.6;function Xr(t,n){let e=t.length,i=[];for(let o=0;o<e;o++){let s=t[Math.max(0,o-1)],u=t[Math.min(e-1,o+1)],c=u.x-s.x,l=u.y-s.y,f=Math.hypot(c,l);if(f<1e-9){i.push([0,0]);continue}c/=f,l/=f,i.push([-l,c])}let r=0;for(let o=0;o<e;o++)r+=(t[o].x-n.x)*i[o][0]+(t[o].y-n.y)*i[o][1];return r<0?i.map(([o,s])=>[-o,-s]):i}function Hr(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],i=(o,s)=>{let u=s.x-o.x,c=s.y-o.y,l=Math.hypot(u,c)||1;return{x:u/l,y:c/l}},r=i(e[1],e[0]),a=i(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+r.x*n,y:e[0].y+r.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var ve=Math.PI/12;function jr(t){if(t.length<3)return[...t];let n=[...t].sort((a,o)=>a.x-o.x||a.y-o.y),e=(a,o,s)=>(o.x-a.x)*(s.y-a.y)-(o.y-a.y)*(s.x-a.x),i=a=>{let o=[];for(let s of a){for(;o.length>=2&&e(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}return o.pop(),o},r=[...i(n),...i([...n].reverse())];return r.length>=3?r:[...t]}function Ge(t,n){if(!t.length||!(n>0))return[];let e=jr(t),i=(s,u,c,l)=>{let f=c-u;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/ve)),y=n/Math.cos(f/m/2);for(let h=0;h<=m;h++){let p=u+f*h/m;l.push({x:s.x+Math.cos(p)*y,y:s.y+Math.sin(p)*y})}};if(e.length<3){let s=0,u=0;for(let y of e)s+=y.x,u+=y.y;s/=e.length||1,u/=e.length||1;let c=0;for(let y of e)c=Math.max(c,Math.hypot(y.x-s,y.y-u));let l=[],f=Math.max(3,Math.ceil(Math.PI*2/ve)),m=(c+n)/Math.cos(Math.PI/f);for(let y=0;y<f;y++){let h=y/f*Math.PI*2;l.push({x:s+Math.cos(h)*m,y:u+Math.sin(h)*m})}return l}let r=e.length,a=[];for(let s=0;s<r;s++){let u=e[s],c=e[(s+1)%r];a.push(Math.atan2(-(c.x-u.x),c.y-u.y))}let o=[];for(let s=0;s<r;s++)i(e[s],a[(s+r-1)%r],a[s],o);return Ue(o)}function Ur(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let i=1/0;for(let r=0;r+1<t.length;r++){let a=t[r],o=t[r+1],s=o.x-a.x,u=o.y-a.y,c=s*s+u*u,l=c>1e-12?((n-a.x)*s+(e-a.y)*u)/c:0;l<0?l=0:l>1&&(l=1);let f=Math.hypot(n-(a.x+l*s),e-(a.y+l*u));f<i&&(i=f)}return i}function dn(t){let n=t.map(r=>{let a=0,o=0;for(let c of r.pts)a+=c.x,o+=c.y;let s=r.pts.length||1;a/=s,o/=s;let u=0;for(let c of r.pts){let l=Math.hypot(c.x-a,c.y-o);l>u&&(u=l)}return{cx:a,cy:o,rad:u}}),e=r=>{let a=r.length;return a<=2?[...r]:[r[Math.floor(a*.25)],r[Math.floor(a*.5)],r[Math.floor(a*.75)]]},i=[];for(let r=0;r<t.length;r++){let a=e(t[r].pts),o=[],s=1/0,u=null;for(let l of a){let f=1/0;for(let m=0;m<t.length;m++){if(m===r||Math.abs(t[m].y-t[r].y)<.001)continue;let y=n[m],h=Math.hypot(l.x-y.cx,l.y-y.cy)-y.rad;if(h>=f&&h>=s)continue;let p=Ur(t[m].pts,l.x,l.y);p<f&&(f=p),t[m].depth<t[r].depth&&p<s&&(s=p,u=t[m].y)}Number.isFinite(f)&&f>0&&o.push(f)}o.sort((l,f)=>l-f);let c=o.length?o[Math.floor(o.length/2)]:1;i.push({pitch:c,belowY:u})}return i}function Ne(t,n,e,i){let r=t[n],a=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let l=r.pts[0],f=l.x-i.x,m=l.y-i.y,y=Math.hypot(f,m)||1;f/=y,m/=y;let h=Math.max(e[n].pitch,.001)*.5;return[{x:l.x+m*h,y:l.y-f*h},{x:l.x-m*h,y:l.y+f*h}]})():[];if(a.length<2)return null;let o=0,s=0;for(let l=1;l<a.length;l++){let f=Math.hypot(a[l].x-a[l-1].x,a[l].y-a[l-1].y);f>1e-6&&(o+=f,s++)}let u=s>0?o/s:0,c=Hr(a,Math.max(u*Nr,bt));return{pts:c,nrm:Xr(c,i),front:Math.max(e[n].pitch*Lr,bt),back:Math.max(e[n].pitch*Gr,bt)}}var Ut=1.5,Xe=.3;function Dn(t,n){if(t.length<3)return t;let e=t[0],i=t[t.length-1],r=i.x-e.x,a=i.y-e.y,o=Math.hypot(r,a),s=-1,u=-1;for(let f=1;f<t.length-1;f++){let m=t[f],y=o>1e-12?Math.abs((m.x-e.x)*a-(m.y-e.y)*r)/o:Math.hypot(m.x-e.x,m.y-e.y);y>s&&(s=y,u=f)}if(s<=n||u<0)return[e,i];let c=Dn(t.slice(0,u+1),n),l=Dn(t.slice(u),n);return[...c.slice(0,-1),...l]}function He(t,n){if(t.length<4)return t;let e=Dn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function Yr(t){let n=t.map((i,r)=>{let a=t[(r+1)%t.length];return{a:i,b:a,i:r,minX:Math.min(i.x,a.x),maxX:Math.max(i.x,a.x),minY:Math.min(i.y,a.y),maxY:Math.max(i.y,a.y)}}).sort((i,r)=>i.minX-r.minX),e=(i,r,a)=>(r.x-i.x)*(a.y-i.y)-(r.y-i.y)*(a.x-i.x);for(let i=0;i<n.length;i++){let r=n[i];for(let a=i+1;a<n.length&&n[a].minX<=r.maxX;a++){let o=n[a];if(!(Math.abs(r.i-o.i)===1||Math.abs(r.i-o.i)===t.length-1||r.maxY<o.minY||o.maxY<r.minY)&&e(r.a,r.b,o.a)*e(r.a,r.b,o.b)<=0&&e(o.a,o.b,r.a)*e(o.a,o.b,r.b)<=0)return!0}}return!1}function je(t,n,e){if(t.length<2)return[];let i=e??dn(t),r=new Map;for(let o=0;o<t.length;o++){let s=r.get(t[o].blockId);s?s.push(o):r.set(t[o].blockId,[o])}let a=[];for(let[,o]of r){let s=[];for(let d of o){let M=t[d].patch;M&&M.length>=3?a.push({outline:[...M],holes:[],topY:t[d].y}):s.push(d)}if(!s.length)continue;s.sort((d,M)=>t[d].depth-t[M].depth);let c=s.map(d=>Ne(t,d,i,n)).filter(d=>d!==null);if(!c.length)continue;let l=(d,M)=>({x:d.pts[M].x-d.nrm[M][0]*(d.front+Ut),y:d.pts[M].y-d.nrm[M][1]*(d.front+Ut)}),f=(d,M)=>({x:d.pts[M].x+d.nrm[M][0]*(d.back+Ut),y:d.pts[M].y+d.nrm[M][1]*(d.back+Ut)}),m=c[0],y=c[c.length-1],h=[];for(let d=0;d<m.pts.length;d++)h.push(l(m,d));for(let d of c)h.push(f(d,d.pts.length-1));for(let d=y.pts.length-1;d>=0;d--)h.push(f(y,d));for(let d=c.length-1;d>=0;d--)h.push(l(c[d],0));let p=Ue(h),b=1/0;for(let d of s)t[d].y<b&&(b=t[d].y);if(!Number.isFinite(b))continue;if(p.length>=3&&Math.abs(mt(p))>1e-6&&c.every(d=>{let M=d.pts[Math.floor(d.pts.length/2)];return ht(p,M.x,M.y)})&&!Yr(p)){a.push({outline:He(p,Xe),holes:[],topY:b});continue}for(let d of Wr(c))a.push({outline:d,holes:[],topY:b})}return a}function Wr(t){let n=[];for(let e of t){let i=[],r=[],a=e.front+Ut,o=e.back+Ut;for(let u=0;u<e.pts.length;u++){let c=e.pts[u],l=e.nrm[u];i.push([c.x-l[0]*a,c.y-l[1]*a]),r.push([c.x+l[0]*o,c.y+l[1]*o])}let s=[...i,...r.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=Le.union(n[0],...n.slice(1)),i=[];for(let r of e){if(!r.length||r[0].length<4)continue;let a=r[0].map(([u,c])=>({x:u,y:c})),o=a[0],s=a[a.length-1];a.length>1&&Math.abs(o.x-s.x)<1e-9&&Math.abs(o.y-s.y)<1e-9&&a.pop(),a.length>=3&&i.push(He(a,Xe))}return i}catch{return[]}}function Ue(t){let n=[];for(let e of t){let i=n[n.length-1];i&&Math.hypot(e.x-i.x,e.y-i.y)<1e-9||n.push(e)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<1e-9;)n.pop();return n}var Ln=class{constructor(n){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=n;for(let e of n)for(let i of e)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(n){for(let e of n)if(e.x<this.minX||e.x>this.maxX||e.y<this.minY||e.y>this.maxY)return!1;for(let e of this.rings){let i=!0;for(let r of n)if(!ht(e,r.x,r.y)){i=!1;break}if(i)return!0}return!1}};function De(t,n,e,i,r,a){if(i.length<3)return;if(e.containsAll(i)){let c=[0,1,0],l=i[0];for(let f=1;f+1<i.length;f++){let m=i[f],y=i[f+1];t.tri([l.x*g,r,l.y*g],[m.x*g,r,m.y*g],[y.x*g,r,y.y*g],c,a)}return}let o=i.map(c=>[c.x,c.y]);o.push(o[0]);let s;try{s=Le.intersection([o],n)}catch{return}let u=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let l=c[0],f=[],m=[];for(let h=0;h<l.length-1;h++)f.push(l[h][0],l[h][1]),m.push([l[h][0],l[h][1]]);if(m.length<3)continue;let y=Dr(f,void 0,2);for(let h=0;h<y.length;h+=3){let p=m[y[h]],b=m[y[h+1]],x=m[y[h+2]];t.tri([p[0]*g,r,p[1]*g],[b[0]*g,r,b[1]*g],[x[0]*g,r,x[1]*g],u,a)}}}function Ye(t,n,e,i,r,a,o){if(n.length<2)return;let s=o??dn(n),u=[0,1,0],c=a&&a.length>=3?[[...a.map(y=>[y.x,y.y]),[a[0].x,a[0].y]]]:null,l=a&&a.length>=3?new Ln([[...a]]):null,f=y=>{t.setMaterial(2),y(),t.setMaterial(0)},m=y=>{t.setMaterial(3),y(),t.setMaterial(0)};for(let y=0;y<n.length;y++){let h=n[y];if(h.patch&&h.patch.length>=3){let A=[...h.patch],R=s[y].belowY??i;if(m(()=>{if(c&&l)De(t,c,l,A,h.y,r.tread);else{let w=A[0];for(let I=1;I+1<A.length;I++){let P=A[I],_=A[I+1];t.tri([w.x*g,h.y,w.y*g],[P.x*g,h.y,P.y*g],[_.x*g,h.y,_.y*g],u,r.tread)}}}),h.y>R+Fe){let w=0,I=0;for(let P of A)w+=P.x,I+=P.y;w/=A.length,I/=A.length,f(()=>{for(let P=0;P<A.length;P++){let _=A[P],T=A[(P+1)%A.length],k=T.x-_.x,X=T.y-_.y,B=Math.hypot(k,X);if(B<1e-6)continue;let E=X/B,O=-k/B;(_.x-w)*E+(_.y-I)*O<0&&(E=-E,O=-O);let D=[E,0,O],C=[_.x*g,h.y,_.y*g],F=[T.x*g,h.y,T.y*g],v=[_.x*g,R,_.y*g],G=[T.x*g,R,T.y*g];t.tri(C,F,G,D,r.riser),t.tri(C,G,v,D,r.riser)}})}continue}let p=Ne(n,y,s,e);if(!p)continue;let{pts:b,nrm:x,front:d,back:M}=p,S=s[y].belowY??i;for(let A=0;A+1<b.length;A++){let R=b[A],w=b[A+1],I=x[A],P=x[A+1];if(Math.hypot(w.x-R.x,w.y-R.y)<1e-6||I[0]===0&&I[1]===0||P[0]===0&&P[1]===0)continue;let _=[(R.x-I[0]*d)*g,h.y,(R.y-I[1]*d)*g],T=[(w.x-P[0]*d)*g,h.y,(w.y-P[1]*d)*g],k=[(R.x+I[0]*M)*g,h.y,(R.y+I[1]*M)*g],X=[(w.x+P[0]*M)*g,h.y,(w.y+P[1]*M)*g];if(m(()=>{c&&l?De(t,c,l,[{x:R.x-I[0]*d,y:R.y-I[1]*d},{x:w.x-P[0]*d,y:w.y-P[1]*d},{x:w.x+P[0]*M,y:w.y+P[1]*M},{x:R.x+I[0]*M,y:R.y+I[1]*M}],h.y,r.tread):(t.tri(_,T,X,u,r.tread),t.tri(_,X,k,u,r.tread))}),h.y>S+Fe){let B=[_[0],S,_[2]],E=[T[0],S,T[2]],O=[-I[0],0,-I[1]];f(()=>{t.tri(_,T,E,O,r.riser),t.tri(_,E,B,O,r.riser)})}}}}function Vr(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function We(t,n){return t.filter(e=>e.type!=="shape"||Vr(e,n))}function ze(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,r)=>({objects:We(i.objects,n),focal:{x:(i.focalPoint??e).x,y:(i.focalPoint??e).y},baseHeightM:i.baseHeightM??0,index:r})):[{objects:We(t.objects,n),focal:e,baseHeightM:0,index:0}]}var zr={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Tt(t){return xe(t)??zr}function Ke(t,n){let e=Mt(t.outline,bt),i=Tt(e),r=n.filter(o=>o!==t&&o.outline&&o.outline.length>=3&&jt(i,Tt(o.outline)));if(!r.length)return[e];let a=o=>{let s=o.map(u=>[u.x,u.y]);return s.push(s[0]),s};try{let o=Ve.difference([a(e)],...r.map(u=>[a(u.outline)])),s=[];for(let u of o){if(!u.length)continue;let c=u[0].map(([l,f])=>({x:l,y:f}));if(c.length>1){let l=c[0],f=c[c.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[e]}catch{return[e]}}function Ze(t,n){if(!n.length)return t;let e=a=>{let o=a.map(s=>[s.x,s.y]);return o.push(o[0]),o},i=n.map(a=>[e(a)]),r=[];for(let a of t){let o;try{o=Ve.intersection([e(a.outline)],i.flat())}catch{r.push(a);continue}for(let s of o){if(!s.length)continue;let u=s[0].map(([c,l])=>({x:c,y:l}));if(u.length>1){let c=u[0],l=u[u.length-1];Math.abs(c.x-l.x)<1e-9&&Math.abs(c.y-l.y)<1e-9&&u.pop()}u.length>=3&&r.push({outline:u,holes:[],topY:a.topY})}}return r.length?r:t}function Zr(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var xn=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let i=n.map(u=>[u.x,u.y]);if(i.length<3)return[];i.push(i[0]);let r=Tt(n),a=this.rings.filter((u,c)=>jt(r,this.boxes[c])&&Zr(e,this.levels[c])),o=[[i]];if(a.length)try{o=Kr.difference([i],...a).map(c=>c.map(l=>l.map(([f,m])=>[f,m])))}catch{o=[[i]]}this.rings.push([i]),this.boxes.push(r),this.levels.push(e);let s=[];for(let u of o){if(!u.length)continue;let c=u[0].map(([l,f])=>({x:l,y:f}));if(c.length>1){let l=c[0],f=c[c.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function bn(t,n){if(!n)return t;let e=1/0,i=-1/0,r=1/0,a=-1/0;for(let f of t)e=Math.min(e,f.x),i=Math.max(i,f.x),r=Math.min(r,f.y),a=Math.max(a,f.y);let o=(e+i)/2,s=(r+a)/2,u=n*Math.PI/180,c=Math.cos(u),l=Math.sin(u);return t.map(f=>{let m=f.x-o,y=f.y-s;return{x:o+m*c-y*l,y:s+m*l+y*c}})}function at(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3&&(n=t.points),t.kind==="rect"&&t.width&&t.height&&(n=Jt(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let e=(t.x??0)+t.width/2,i=(t.y??0)+t.height/2;n=yn(e,i,t.width/2,t.height/2)}return n?bn(n,t.rotation):null}function St(t){let n=t.role??"",e={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=n==="stage"&&ue(t.stageKind)?{kind:"stage",heightM:t.stageKind==="ring-boxing"?le:.06}:e[n]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var qr=.08,$r=30,Qr=.015;function Jr(t,n){let e=!1;for(let i=0,r=n.length-1;i<n.length;r=i++){let a=n[i],o=n[r];a.y>t.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(e=!e)}return e}function qe(t,n){let e=at(t)??(t.points?.length?bn(t.points,t.rotation):null),i=St(t),a=!t.role&&i.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(mt(e))*et**2>=$r?Qr:i.heightM;if(!e)return{topOffsetM:a,supportOffsetM:0};if(i.kind!=="plate"&&i.kind!=="stage")return{topOffsetM:a,supportOffsetM:0};let o=1/0,s=1/0,u=-1/0,c=-1/0;for(let y of e)o=Math.min(o,y.x),s=Math.min(s,y.y),u=Math.max(u,y.x),c=Math.max(c,y.y);let l=a,f=0,m=1e-6*Math.max(1,u-o,c-s);for(let y of n)u>y.minX&&o<y.maxX&&c>y.minY&&s<y.maxY&&l<=y.topOffsetM+1e-6&&(l=y.topOffsetM+qr),o>=y.minX-m&&u<=y.maxX+m&&s>=y.minY-m&&c<=y.maxY+m&&(!y.poly||e.every(b=>Jr(b,y.poly)||ti(b,y.poly,m)))&&(f=Math.max(f,y.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:o,minY:s,maxX:u,maxY:c,topOffsetM:l,poly:e}),{topOffsetM:l,supportOffsetM:Math.min(f,l)}}function ti(t,n,e){for(let i=0,r=n.length-1;i<n.length;r=i++){let a=n[r],o=n[i],s=o.x-a.x,u=o.y-a.y,c=s*s+u*u,l=c?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/c)):0;if(Math.hypot(t.x-(a.x+l*s),t.y-(a.y+l*u))<=e)return!0}return!1}function Ft(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function yt(t){if(t.length!==4)return t;let n=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),e=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return n>=e?t:[t[1],t[2],t[3],t[0]]}function ut(t,n,e){return[Ft(t[0],t[1],n),Ft(t[0],t[1],e),Ft(t[3],t[2],e),Ft(t[3],t[2],n)]}function nn(t,n,e){return[Ft(t[0],t[3],n),Ft(t[1],t[2],n),Ft(t[1],t[2],e),Ft(t[0],t[3],e)]}function tt(t,n,e,i,r,a){K(t,n,void 0,()=>e,i,r,a,V)}var ni=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"]];function ei(t){if(!t)return null;for(let[n,e]of ni)if(n.test(t))return e;return null}var Je="auto-rows-";function to(t){return t.id.startsWith(Je)&&!t.label}var oi=1.15,ri=.09,ii=6,si=34,ai=.35,ci=6,li=.35,ui=.75,fi=12,mi=2.5,hi=40,$e=[18,24],yi=.8,pi=.6,di=5,xi=.3,no=.4,bi=2,gi=400,Mi=2.6,Si=1.6,Pi=6e3,Ii=.6,Ri="#c3c7cd",Qe=300,Ai=240;function _i(t,n,e,i){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let r=Nn([...n]),a=new Set;for(let l of i)a.add(Math.floor(Math.atan2(l.y-r.y,l.x-r.x)*180/Math.PI/10));if(a.size*10<Ai)return null;let{h:o,s,l:u}=he(me(t.fill));return o<70/360||o>170/360||s<.2||u<.08||u>.75||e.some(l=>l!==t&&l.type==="shape"&&at(l)?.some(f=>jn(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var wi="Estimated from the drawing; confirm with the venue.",eo=t=>{if(!t.length)return null;let n=[...t].sort((i,r)=>i-r),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2},Nn=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),Xn=t=>{let n=0;for(let e=0;e<t.length;e++){let i=t[e],r=t[(e+1)%t.length];n+=i.x*r.y-r.x*i.y}return Math.abs(n)/2};function Ei(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function Hn(t){let n=new Map;for(let e of t){let i=n.get(e.rowId);i?i.push(e):n.set(e.rowId,[e])}return n}function jn(t,n){let e=!1;for(let i=0,r=n.length-1;i<n.length;r=i++){let a=n[i],o=n[r];a.y>t.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(e=!e)}return e}function Un(t,n){let e=n[0],i=1/0;for(let r=0;r<n.length;r++){let a=n[r],o=n[(r+1)%n.length],s=o.x-a.x,u=o.y-a.y,c=s*s+u*u,l=c>0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/c)):0,f={x:a.x+s*l,y:a.y+u*l},m=Math.hypot(t.x-f.x,t.y-f.y);m<i&&(i=m,e=f)}return e}function oo(t,n){let e=0,i=0;for(let r of t.values()){if(r.length<3)continue;let a=r[0],o=r[r.length-1],s=o.x-a.x,u=o.y-a.y,c=Math.hypot(s,u);if(c<1e-6)continue;let l={x:(a.x+o.x)/2,y:(a.y+o.y)/2},f=Un(l,n),m=f.x-l.x,y=f.y-l.y,h=Math.hypot(m,y);h<1e-6||(i+=Math.abs((-u*m+s*y)/(c*h))*r.length,e+=r.length)}return e?i/e:0}function Bi(t,n,e){let i=t.filter(p=>p.type==="shape"),r=i.find(p=>p.role==="stage");if(r){let p=at(r);return p?{shape:r,centre:Nn(p),outline:p,inferred:!1}:null}if(!e.length)return null;let a=1/0,o=-1/0,s=1/0,u=-1/0;for(let p of e)a=Math.min(a,p.x),o=Math.max(o,p.x),s=Math.min(s,p.y),u=Math.max(u,p.y);let c=(o-a)*(u-s),l=[];for(let p of i){if(p.role)continue;let b=at(p);if(!b)continue;let x=Xn(b);if(x*et*et<6||x>c)continue;let d=Math.min(...b.map(P=>P.x)),M=Math.max(...b.map(P=>P.x)),S=Math.min(...b.map(P=>P.y)),A=Math.max(...b.map(P=>P.y)),R=0;for(let P of e)P.x>d&&P.x<M&&P.y>S&&P.y<A&&jn(P,b)&&R++;if(R>e.length*.05)continue;let w=Nn(b),I=oo(n,b);I>=yi&&l.push({shape:p,centre:w,outline:b,score:I,area:x,box:[d,S,M,A]})}let f=(p,b)=>b!==p&&b.area>p.area&&p.box[0]>=b.box[0]-1e-6&&p.box[1]>=b.box[1]-1e-6&&p.box[2]<=b.box[2]+1e-6&&p.box[3]<=b.box[3]+1e-6,m=l.filter(p=>!l.some(b=>f(p,b))),y=Math.max(0,...m.map(p=>p.score)),h=m.filter(p=>p.score>=y-.03).sort((p,b)=>b.area-p.area)[0]??null;return h?{shape:h.shape,centre:h.centre,outline:h.outline,inferred:!0}:null}function Ti(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let i=Un(t,e);return Math.hypot(t.x-i.x,t.y-i.y)}function ro(t){let n=[...t].sort((a,o)=>a.x-o.x||a.y-o.y);if(n.length<3)return n;let e=(a,o,s)=>(o.x-a.x)*(s.y-a.y)-(o.y-a.y)*(s.x-a.x),i=[];for(let a of n){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}let r=[];for(let a=n.length-1;a>=0;a--){let o=n[a];for(;r.length>=2&&e(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return[...i.slice(0,-1),...r.slice(0,-1)]}function Ci(t){if(!t.length||t.length>Pi)return[];let n=[...Hn(t).values()],e=n.map((s,u)=>u),i=s=>e[s]===s?s:e[s]=i(e[s]),r=Si/et,a=n.map(s=>({minX:Math.min(...s.map(u=>u.x))-r,maxX:Math.max(...s.map(u=>u.x))+r,minY:Math.min(...s.map(u=>u.y))-r,maxY:Math.max(...s.map(u=>u.y))+r}));for(let s=0;s<n.length;s++)for(let u=s+1;u<n.length;u++){let c=a[s],l=a[u];if(c.maxX<l.minX||l.maxX<c.minX||c.maxY<l.minY||l.maxY<c.minY)continue;n[s].some(m=>n[u].some(y=>Math.hypot(m.x-y.x,m.y-y.y)<=r))&&(e[i(s)]=i(u))}let o=new Map;return n.forEach((s,u)=>{let c=i(u),l=o.get(c);l?l.push(...s):o.set(c,[...s])}),[...o.values()].filter(s=>new Set(s.map(u=>u.rowId)).size>=2)}function Oi(t,n,e){if(!n.length)return null;let i=n.filter(I=>e.tableIds.has(I.rowId)||I.kind==="booth").length>n.length/2,r=Hn(n),a=!e.outline||oo(r,e.outline)>=pi,o=0,s=0;for(let I of r.values()){if(I.length<2)continue;let P=I[0],_=I[I.length-1],T=_.x-P.x,k=_.y-P.y,X=Math.hypot(T,k);if(X<1e-6)continue;let B={x:(P.x+_.x)/2,y:(P.y+_.y)/2},E=a?e.outline?Un(B,e.outline):e.focal:e.middle,O=-k/X,D=T/X;O*(E.x-B.x)+D*(E.y-B.y)<0&&(O=-O,D=-D),o+=O*I.length,s+=D*I.length}let u={x:n.reduce((I,P)=>I+P.x,0)/n.length,y:n.reduce((I,P)=>I+P.y,0)/n.length};if(Math.hypot(o,s)<1e-9){let I=a?e.focal:e.middle;o=I.x-u.x,s=I.y-u.y}let c=Math.hypot(o,s)||1,l={x:o/c,y:s/c},f=I=>-(I.x*l.x+I.y*l.y),m=I=>-I.x*l.y+I.y*l.x,y=1/0,h=-1/0,p=1/0,b=-1/0,x=1/0,d=new Map;for(let I of n){let P=f(I),_=m(I);y=Math.min(y,P),h=Math.max(h,P),p=Math.min(p,_),b=Math.max(b,_),a&&(x=Math.min(x,Ti(I,e.focal,e.outline)));let T=I.logicalRowId??I.rowId,k=d.get(T);k?k.push(P):d.set(T,[P])}a||(x=Math.max(0,y-f(e.middle)));let M=[...d.values()].map(I=>eo(I)).sort((I,P)=>I-P),S=[];if(!i)for(let I of M)S.length&&I-S[S.length-1]<li/et||S.push(I);let A=Ei(t),R=Xt(t,{floorBaseHeightM:e.baseHeightM}),w={id:t.id,section:t,authored:A,plane:e,facing:l,facesAction:a,hull:ro(n),sample:n.filter((I,P)=>P%Math.ceil(n.length/gi)===0),frontD:y,backD:h,latMin:p,latMax:b,frontDistance:x,rowDepths:S,rowCount:S.length,level:0,height:R.height,rake:A?R.rake:0,backHeight:0};return w.backHeight=w.height+(h-y)*et*Math.tan(w.rake*Math.PI/180),w}function ki(t,n,e,i){if(t.length<2)return 0;let r=Math.max(1,n*et),a=e+oi-i,o=0,s=0;for(let c=1;c<t.length;c++){let l=Math.max(ui,(t[c]-t[c-1])*et),f=(a+ri)*(r+l)/r;o+=f-a,s+=l,a=f,r+=l}let u=Math.atan(o/s)*180/Math.PI;return Math.round(Math.max(ii,Math.min(si,u))*10)/10}function Fi(t,n){if(t.facing.x*n.facing.x+t.facing.y*n.facing.y<xi)return null;let e=-1/0,i=1/0,r=-1/0;for(let f of n.hull){e=Math.max(e,-(f.x*t.facing.x+f.y*t.facing.y));let m=-f.x*t.facing.y+f.y*t.facing.x;i=Math.min(i,m),r=Math.max(r,m)}if(Math.min(t.latMax,r)-Math.max(t.latMin,i)<no*(t.latMax-t.latMin))return null;let o=bi/et,s=new Map,u=new Map;for(let f of t.sample){let m=Math.floor((-f.x*t.facing.y+f.y*t.facing.x)/o),y=-(f.x*t.facing.x+f.y*t.facing.y);s.set(m,Math.min(s.get(m)??1/0,y))}for(let f of n.sample){let m=Math.floor((-f.x*t.facing.y+f.y*t.facing.x)/o),y=-(f.x*t.facing.x+f.y*t.facing.y);u.set(m,Math.max(u.get(m)??-1/0,y))}let c=[];for(let[f,m]of s){let y=u.get(f);y!==void 0&&c.push(m-y)}let l=c.length?eo(c):t.frontD-e;return l<-1/et?null:l}function vi(t,n){if(n.plane.floorIndex>=t.plane.floorIndex)return!1;let e=-1/0,i=1/0,r=1/0,a=-1/0;for(let u of n.hull){let c=-(u.x*t.facing.x+u.y*t.facing.y);e=Math.max(e,c),i=Math.min(i,c);let l=-u.x*t.facing.y+u.y*t.facing.x;r=Math.min(r,l),a=Math.max(a,l)}let o=Math.min(t.latMax,a)-Math.max(t.latMin,r),s=Math.min(t.backD,e)-Math.max(t.frontD,i);return o>no*(t.latMax-t.latMin)&&s>1/et}function Di(t){let n=new Map,e=[...t].sort((o,s)=>o.plane.floorIndex-s.plane.floorIndex||o.frontDistance-s.frontDistance),i=[],r=new Map,a=o=>{if(o.plane.floorIndex===0||o.plane.baseHeightM>0)return o.plane.baseHeightM;let s=r.get(o.plane.floorIndex-1);return s===void 0?o.plane.baseHeightM:s+Pe};for(let o of e){if(!o.authored){let u=a(o),c;for(let f of i){if(f.plane.floorIndex>o.plane.floorIndex)continue;if(vi(o,f)){let h=f.backHeight+Mi;h>u&&(u=h,c=f);continue}let m=Fi(o,f);if(m==null)continue;let y=f.backHeight+ai+Math.min(ci,Math.max(0,m)*et)*Math.tan(f.rake*Math.PI/180);y>u&&(u=y,c=f)}o.height=Math.round(Math.min(u,o.plane.baseHeightM+hi)*100)/100;let l=!c&&o.height>o.plane.baseHeightM;if(o.level=c?c.level+1:l?1:0,o.rake=ki(o.rowDepths,o.frontDistance,o.height,o.plane.focalHeightM),!o.facesAction&&o.rowCount<di)o.rake=0;else if(!c&&!l){let f=Math.max(1e-6,(o.backD-o.frontD)*et);o.rake=Math.min(o.rake,fi,Math.round(Math.atan(mi/f)*1800/Math.PI)/10)}else o.rowCount>=2&&(o.rake=Math.max(o.rake,$e[Math.min(o.level,$e.length)-1]));o.backHeight=o.height+(o.backD-o.frontD)*et*Math.tan(o.rake*Math.PI/180),n.set(o.id,c?.id)}let s=o.plane.floorIndex;r.set(s,Math.min(r.get(s)??1/0,o.height)),i.push(o)}return n}var Gn=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function io(t,n={x:0,y:-40}){let e=un(t),i=new Map;for(let h of e){if(!h.sectionId)continue;let p=i.get(h.sectionId);p?p.push(h):i.set(h.sectionId,[h])}let r={focalInferred:!1,confident:!1,sections:[]},a=t.floors?.length?t.floors.map((h,p)=>({objects:h.objects,floorIndex:p,floorId:h.id,baseHeightM:h.baseHeightM??0,focal:h.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],o=new Set(a.flatMap(h=>h.objects.filter(p=>p.type==="table").map(p=>p.id))),s=[],u,c=new Set,l=a.map(h=>{let p=_=>!t.floors?.length||_.floorId===h.floorId,b=Ci(e.filter(_=>!_.sectionId&&_.kind!=="booth"&&!o.has(_.rowId)&&p(_))),x=[];for(let _ of b){let T=Mt(wt(ro(_)),Ii/et);if(e.some(X=>!p(X)&&jn(X,T)))continue;let k=`${Je}${h.floorIndex}-${x.length}`;c.add(k),i.set(k,_),x.push({type:"section",id:k,label:"",color:Ri,outline:T})}let d=x.length?{...h,objects:[...h.objects,...x]}:h,M=new Set(d.objects.filter(_=>_.type==="section").map(_=>_.logicalSectionId??_.id)),S=[...i.entries()].filter(([_])=>M.has(_)).flatMap(([,_])=>_),A=Bi(d.objects,Hn(S),S),R=d.focal;(A||d.focal&&!Gn(d.focal,n))&&(r.confident=!0),A&&(r.stage??={id:A.shape.id,inferred:A.inferred,...d.floorId?{floorId:d.floorId}:{}},(A.inferred||Gn(d.focal,n))&&(R=A.centre,r.focalInferred=!0));let w=A&&(!A.inferred||Xn(A.outline)*et*et<=Qe),I=A?void 0:u,P={tableIds:o,floorIndex:d.floorIndex,floorId:d.floorId,baseHeightM:d.baseHeightM,focal:I?.focal??R,outline:A?.outline??I?.outline,focalHeightM:I?.focalHeightM??d.baseHeightM+(A&&w?St({...A.shape,role:"stage"}).heightM:0),middle:S.length?{x:S.reduce((_,T)=>_+T.x,0)/S.length,y:S.reduce((_,T)=>_+T.y,0)/S.length}:R};for(let _ of d.objects){if(_.type!=="section")continue;let T=Oi(_,i.get(_.logicalSectionId??_.id)??[],P);T&&s.push(T)}return P.outline&&(u=P),Gn(d.focal,P.focal)||(r.focal??=[]).push({...d.floorId?{floorId:d.floorId}:{},point:{...P.focal}}),{unit:d,plane:P,stage:A,planeSeats:S}}),f=Di(s),m=new Map(s.filter(h=>!h.authored).map(h=>[h.id,h])),y=l.map(({unit:h,plane:p,stage:b,planeSeats:x})=>h.objects.map(d=>{let M=d.type==="shape"&&!d.role&&d.id!==b?.shape.id?ei(d.label):null;if(M&&d.type==="shape")return(r.roles??=[]).push({id:d.id,...p.floorId?{floorId:p.floorId}:{},role:M}),{...d,role:M};let S=b?.inferred&&d.id===b.shape.id&&d.type==="shape"?_i(d,b.outline,h.objects,x):null;if(S&&d.type==="shape")return r.stage?.id===d.id&&(r.stage.field=S),{...d,role:"stage",stageKind:S};if(b?.inferred&&d.id===b.shape.id&&d.type==="shape"&&Xn(b.outline)*et*et<=Qe)return r.stage?.id===d.id&&(r.stage.deck=!0),{...d,role:"stage"};let A=d.type==="section"?m.get(d.id):void 0;if(!A||d.type!=="section")return d;let R=A.rowCount>=2&&A.rake>0;c.has(A.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:A.id,floorId:p.floorId,surfaceKind:R?"rakedRows":"flat",height:A.height,rake:A.rake,stackedOn:f.get(A.id)});let w={status:"inferred",source:"public-2d-topology",note:wi};return{...d,height:A.height,rake:A.rake,surfaceKind:R?"rakedRows":"flat",physical3dProvenance:{height:w,rake:w,surfaceKind:w}}}));if(t.floors?.length){let h=t.floors.map((p,b)=>({...p,objects:y[b],focalPoint:l[b].plane.focal}));return{doc:{...t,floors:h,objects:h[0].objects,focalPoint:h[0].focalPoint},report:r}}return{doc:{...t,objects:y[0],focalPoint:l[0].plane.focal},report:r}}function Ic(t,n,e){return e<0?n>1?t.filter(i=>i.kind==="floor"):[...t]:t.filter(i=>i.floorIndex===void 0||i.floorIndex===e)}function Rc(t,n){let e=[...t].sort((r,a)=>r.screen.y-a.screen.y),i=[];for(let r of e){let a=i.find(o=>o.some(s=>Math.abs(s.screen.x-r.screen.x)<104&&Math.abs(s.screen.y-r.screen.y)<34));a?a.push(r):i.push([r])}return i.flatMap(r=>r.length<2?r:r.map((a,o)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(o-(r.length-1)/2)*104))}})))}var Li=1.15,Gi=2.75,Ni=4.5,Xi=.85,Hi=.5,ji=.26;function Ac(t,n,e){let i=Math.max(1e-6,n),r=t/i,a=e?.hasZoneLabels??!0,o=new Set;return r>=.75&&o.add("floor"),r>=Li&&o.add("zone"),r<=(a?Gi:Ni)&&(o.add("section"),o.add("ga")),r<=Xi&&(o.add("annotation"),o.add("booth")),r<=Hi&&o.add("row"),r<=ji&&o.add("seat"),o}function _c(t,n,e,i,r,a=6){let o=a+n,s=i-a-n,u=a+e,c=r-a-e;return{...t,x:o>s?i/2:Math.max(o,Math.min(s,t.x)),y:u>c?r/2:Math.max(u,Math.min(c,t.y))}}function wc(t,n,e,i){let r=t,a=n[0],o=n[1],s=n[2],u=r[0]*a+r[4]*o+r[8]*s+r[12],c=r[1]*a+r[5]*o+r[9]*s+r[13],l=r[2]*a+r[6]*o+r[10]*s+r[14],f=r[3]*a+r[7]*o+r[11]*s+r[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=u/f,y=c/f,h=l/f,p=m>=-1.05&&m<=1.05&&y>=-1.05&&y<=1.05&&h<=1;return{x:(m*.5+.5)*e,y:(1-(y*.5+.5))*i,depth:h,visible:p}}function Ec(t,n,e=n){let i=[],r=[...t].sort((a,o)=>a.screen.depth-o.screen.depth);for(let a of r){let o=!1;for(let s of i)if(Yn(a,s,n,e)){o=!0;break}o||i.push(a)}return i}var Ui=6;function Yn(t,n,e,i){let r=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),o=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+Ui):e;return r<o&&a<i}function Bc(t,n,e){return t.length*n*.58+(e?14:0)}var Yi={row:8,seat:14};function Tc(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:Yi}function Cc(t,n,e,i){let r=Math.max(1,Math.min(e,i)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-i/2)/r);return n*(1+1.5*a)}function Oc(t,n,e,i,r=[]){let a=[...t].sort((s,u)=>(u.priority??0)-(s.priority??0)||s.focus-u.focus),o=[];for(let s of a){if(o.length>=i)break;let u=!1;for(let c of r)if(Yn(s,c,n,e)){u=!0;break}if(!u){for(let c of o)if(Yn(s,c,n,e)){u=!0;break}}u||o.push(s)}return o}function kc(t,n,e,i){let r=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15];return r<=0||!(e>0)?0:e*Math.hypot(t[0],t[4],t[8])*i/(2*r)}function Yt(t,n,e){if(t.length!==4||e<=n)return null;let i=yt(t),r=Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*g,a=Math.hypot(i[3].x-i[0].x,i[3].y-i[0].y)*g;if(r<1e-6||a<1e-6)return null;let o=Math.min(.22/r,.16),s=Math.min(.28,(e-n)*.13),u=Math.min(.065/a,.2);return{quad:i,side:o,face:u,opening:ut(i,o,1-o),openingTop:e-s}}function Wn(t,n,e){if(t.length!==4||e-n<=.2)return null;let i=yt(t),r=Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*g;if(r<=1e-6)return null;let a=Math.min(.14,(e-n)*.08,r*.08),o=a/r,s=ut(i,o,1-o);return{quad:i,side:o,trim:a,inner:s,panel:nn(s,.15,.85),bottom:n+a,top:e-a}}function so(t,n,e,i){let r=Wn(t,n,e);if(!r)return;let{panel:a}=r,o=(d,M)=>({x:(d.x+M.x)/2,y:(d.y+M.y)/2}),s=o(a[0],a[1]),u=o(a[3],a[2]),c=Math.hypot(s.x-i.x,s.y-i.y)<=Math.hypot(u.x-i.x,u.y-i.y),[l,f]=c?[a[0],a[1]]:[a[3],a[2]],m=c?{x:s.x-u.x,y:s.y-u.y}:{x:u.x-s.x,y:u.y-s.y},y=Math.hypot(m.x,m.y);if(y<1e-6)return;-(f.y-l.y)*m.x+(f.x-l.x)*m.y<0&&([l,f]=[f,l]);let h=Math.min(.006,y*g*.05),p=m.x/y*h,b=m.y/y*h,x=(d,M)=>[d.x*g+p,M,d.y*g+b];return[x(l,r.bottom),x(f,r.bottom),x(l,r.top),x(f,r.top)]}import Wi from"polygon-clipping";function Ct(t,n,e,i,r,a,o,s={}){let u=Tt(n),c=s.ao??V,l=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let b=at(p);if(!b||b.length!==4||!jt(u,Tt(b)))return[];let x=s.portalBase??e,d=Yt(b,x,x+St(p).heightM);if(!d)return[];let M=Math.min(i,d.openingTop);return M<=e?[]:[{poly:d.opening,height:M}]});if(!l.length)return!1;let f=p=>p.map(b=>[b.x,b.y]),m=[f(n),...(s.holes??[]).map(f)],y=[e,...new Set(l.map(p=>p.height)),i].sort((p,b)=>p-b),h=[];try{for(let p=1;p<y.length;p++){let b=y[p-1],x=y[p];if(x-b<1e-6)continue;let d=l.filter(S=>S.height>b+1e-6).map(S=>[f(S.poly)]),M=d.length?Wi.difference(m,...d):[m];h.push({low:b,high:x,polys:M})}}catch{return!1}for(let p of h)for(let b of p.polys){let[x,...d]=b.map(S=>S.map(([A,R])=>({x:A,y:R}))),M=S=>c.wallBottom+(c.top-c.wallBottom)*(S-e)/(i-e);K(t,x,d,()=>p.high,p.low,a,o,{...c,top:M(p.high),wallBottom:M(p.low)})}return!0}function ao(t,n,e,i,r,a,o){let s=i-e;if(s<=0)return;let u=s<1.5?[[e,i,1]]:[[e,e+Math.min(.9,s*.18),.82],[e+Math.min(.9,s*.18),i-.1,1],[i-.1,i,1.1]],c=l=>V.wallBottom+(V.top-V.wallBottom)*(l-e)/s;for(let[l,f,m]of u){let y={...V,top:c(f),wallBottom:c(l)},h=z(a,m),p=z(o,m);Ct(t,n,l,f,r,h,p,{portalBase:e,ao:y})||K(t,n,void 0,()=>f,l,h,p,y)}}function en(t,n,e){let i=ot(n.stroke?.color),r=n.stroke?.width??0;if(!i||!Number.isFinite(r)||r<=0)return;let a=n.kind==="line"||n.kind==="polyline",o=a?bn(n.points??[],n.rotation):at(n);if(!o||o.length<2)return;let s=a?o.length-1:o.length,u=r*.5;for(let c=0;c<s;c++){let l=o[c],f=o[(c+1)%o.length],m=Math.hypot(f.x-l.x,f.y-l.y);if(m<1e-6)continue;let y=-(f.y-l.y)/m*u,h=(f.x-l.x)/m*u,p=[(l.x+y)*g,e,(l.y+h)*g],b=[(f.x+y)*g,e,(f.y+h)*g],x=[(f.x-y)*g,e,(f.y-h)*g],d=[(l.x-y)*g,e,(l.y-h)*g];t.tri(p,b,x,[0,1,0],i),t.tri(p,x,d,[0,1,0],i)}}function co(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var Wt=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function gn(t,n,e,i){let[r,a,o,s]=n?t:[t[3],t[2],t[1],t[0]];return[Wt(r,s,e),Wt(a,o,e),Wt(a,o,i),Wt(r,s,i)]}function lo(t,n,e,i,r,a,o,s,u=!1){if(e.length!==4||r-i<.4)return!1;let c=I=>u?Math.min(I,r):I,l=yt(e),f=Math.hypot(l[3].x-l[0].x,l[3].y-l[0].y)*g;if(f<.4)return!1;let m=Wt(l[0],l[1],.5),y=Wt(l[3],l[2],.5),h=Math.hypot(m.x-s.x,m.y-s.y)<=Math.hypot(y.x-s.x,y.y-s.y),p=rt(o,[.92,.9,.86],.35),b=z(a,.72),x=r-i;if(n==="restroom"){let I=Math.min(.18,x*.08);return tt(t,l,r-I,i,o,a),tt(t,l,r,r-I,p,p),!0}let d=i+Math.min(1.1,x),M=n==="coat"?1:Math.min(.5,.75/f),S=gn(l,h,0,M);if(tt(t,S,d-.05,i,b,a),tt(t,S,d,d-.05,p,p),n==="coat"||f<1.2)return!0;if(n==="bar"){let I=gn(l,h,Math.max(M+.2,1-.45/f),1),P=c(i+Math.max(Math.min(2.2,x*2),d-i+.6));return tt(t,I,P,i,o,b),!0}let A=gn(l,h,Math.max(M+.25,.55),1),R=c(i+Math.max(2.6,d-i+1.4));if(R-.14<=d)return!0;tt(t,A,R-.14,i,o,a),tt(t,l,R,R-.14,p,b);let w=Math.min(.08,.1/Math.max(.1,Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y)*g));for(let[I,P]of[[0,w],[1-w,1]])tt(t,gn(ut(l,I,P),h,0,Math.min(.08,.1/f)),R-.14,d,b,b);return!0}var vt=.06,Vi=.05,fo=.05,uo=.15,Vn=25;function mo(t,n,e){let i=new Map,r=new Array(n.length).fill(null),a=new Float64Array(n.length),o=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),u=new Map,c=[],l=new Set;for(let m=0;m<t.length;m+=1){let y=t[m];for(let h of y.objects){if(h.type==="table"&&l.add(h.id),h.type!=="section"||!h.outline||h.outline.length<3)continue;let p=Mt(h.outline,bt);u.set(h.id,{section:h,unit:y,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:h.id,floorIndex:m,box:Tt(p),section:h,unit:y,outline:p})}}let f=new Map;for(let m of c){let y=f.get(m.floorIndex);y?y.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<n.length;m++){let y=n[m],h=e?f.get(e[m])??[]:c,p=y.sectionId?h.find(x=>x.id===y.sectionId)??h.find(x=>x.section.logicalSectionId===y.sectionId&&At({x:y.x,y:y.y},x.outline,x.section.holes)):void 0,b=p?[p]:h;for(let x of b){if(e&&x.floorIndex!==e[m]||!p&&(y.x<x.box.minX||y.x>x.box.maxX||y.y<x.box.minY||y.y>x.box.maxY||!At({x:y.x,y:y.y},x.outline,x.section.holes)))continue;r[m]=x.id;let d=u.get(x.id);d.hasSeats=!0;let M=y.focalPoint??x.unit.focal,S=Math.hypot(y.x-M.x,y.y-M.y);S<d.frontU&&(d.frontU=S),d.seatIndices.push(m);let A=y.rowId||`__seat-${m}`,R=d.rows.get(A);R?R.push({x:y.x,y:y.y}):d.rows.set(A,[{x:y.x,y:y.y}]);break}}for(let[m,y]of u){let h=Xt(y.section,{floorBaseHeightM:y.unit.baseHeightM}),p=y.unit.baseHeightM,b=h.rake>0?Math.tan(h.rake*Math.PI/180):0,x=h.rake<=.01&&h.height<=p+.001,d=y.section.surfaceKind,M=d==="flat"?!0:d==="rakedRows"&&h.rake>.01?!1:x,S=y.hasSeats?ae(m,n,y.seatIndices,y.unit.focal):{sectionId:m,rows:[],blockCount:0},R=S.rows.length<2?ge([...y.rows.values()].map(C=>({points:C})),y.unit.focal):null,w=1/0;if(R){if(y.hasSeats)for(let C of y.rows.values())for(let F of C){let v=R.depthAt(F.x,F.y);v<w&&(w=v)}if(!y.hasSeats||!Number.isFinite(w)){w=1/0;for(let C of y.section.outline){let F=R.depthAt(C.x,C.y);F<w&&(w=F)}}}let I=p+Vi,P=Math.max(I,h.height),_=C=>{let F=Math.max(0,C-w)*et,v=Math.min(F*b,Vn);return Math.max(I,h.height+v)},T=C=>{let F=Math.max(0,C)*et,v=Math.min(F*b,Vn);return Math.max(I,h.height+v)},k=M?[]:S.rows.map(C=>({pts:C.pts,y:T(C.blockDepth),depth:C.blockDepth,blockId:C.blockId,...l.has(C.id)?{patch:Ge(C.pts,bt)}:{}})),X=k.length?k[0].y:P,B=k.map(C=>{let F=C.patch&&C.patch.length>=3?C.patch:C.pts,v=0,G=0;for(let H of F)v+=H.x,G+=H.y;let j=F.length||1;v/=j,G/=j;let U=0;for(let H of F){let W=Math.hypot(H.x-v,H.y-G);W>U&&(U=W)}return{cx:v,cy:G,rad:U}}),E=M?()=>P:k.length>=2?(C,F)=>{let v=1/0,G=X;for(let j=0;j<k.length;j++){let U=B[j];if(Math.hypot(C-U.cx,F-U.cy)-U.rad>=v)continue;let H=k[j].patch,W=H&&H.length>=3?ht(H,C,F)?0:ln(H,C,F):ln(k[j].pts,C,F);W<v&&(v=W,G=k[j].y)}return G}:(C,F)=>R?_(R.depthAt(C,F)):P,O=[0,1,0],D=k.length>=2||M?()=>O:(C,F)=>{if(!R)return O;let v=R.depthAt(C,F);if(v<=w)return O;let G=(v-w)*et;if(G*b>=Vn||h.height+G*b<=I)return O;let[j,U]=R.gradientAt(C,F);if(j===0&&U===0)return O;let H=1/Math.hypot(b,1);return[-j*b*H,H,-U*b*H]};if(!M)for(let C of S.rows){let F=T(C.blockDepth);for(let v of C.seatIndices)o[v]=F}for(let C of S.rows){let F=[];for(let H=1;H<C.pts.length;H++){let W=Math.hypot(C.pts[H].x-C.pts[H-1].x,C.pts[H].y-C.pts[H-1].y);W>1e-6&&F.push(W)}F.sort((H,W)=>H-W);let v=F.length?F[Math.floor(F.length/2)]:1/0,G=1/0,j=C.pts[Math.floor(C.pts.length/2)];if(j)for(let H of S.rows){if(H===C||H.blockId!==C.blockId)continue;let W=ln(H.pts,j.x,j.y);W>1e-6&&W<G&&(G=W)}let U=Math.min(v,Math.max(G,v*.5));if(Number.isFinite(U)&&U>0)for(let H of C.seatIndices)s[H]=U}i.set(m,{sectionId:m,deckAt:E,normalAt:D,flat:M,bottomY:p,rowLevels:k,landingY:X})}for(let m=0;m<n.length;m++){let y=r[m],h=n[m];if(y){let x=o[m];a[m]=(x??i.get(y).deckAt(h.x,h.y))+uo;continue}let p=h.eyeHeightM,b=Number.isFinite(p)?Math.max(0,p-cn):0;a[m]=h.kind==="booth"?b+vt+uo:b}return{bySection:i,seatOwner:r,seatDeckY:m=>a[m],seatPitchU:m=>s[m]}}var zi=[.12,.38,.16],Ki=[.72,.62,.45],Zi=[.88,.93,.96],ho=[.95,.95,.94],qi=[.66,.29,.22],zn={length:20.12,width:3.05},$i=.14,Qi=9.76,Ot=[.93,.94,.95],Mn=[.1,.11,.13],Ji=[.45,.85,1.25],ts=1.45,yo=.012,po=.004,ns=1.07,es=.15;function zt(t,n,e,i,r,a){t.setMaterial(a),K(t,n,e?[e.slice().reverse()]:void 0,()=>i,i-.004,r,r,V)}var xo=(t,n)=>Lt(t,n/g);function bo(t,n,e){let i=n.x-t.x,r=n.y-t.y,a=Math.hypot(i,r);if(a<1e-9)return null;let o=-r/a*e,s=i/a*e;return[{x:t.x+o,y:t.y+s},{x:n.x+o,y:n.y+s},{x:n.x-o,y:n.y-s},{x:t.x-o,y:t.y-s}]}function os(t,n,e,i){let r=n.map(a=>[a.x*g,e,a.y*g]);t.tri(r[0],r[1],r[2],[0,1,0],i),t.tri(r[0],r[2],r[3],[0,1,0],i)}function Sn(t,n,e,i,r,a){let o=e/g,s=[{x:n.x-o,y:n.y-o},{x:n.x+o,y:n.y-o},{x:n.x+o,y:n.y+o},{x:n.x-o,y:n.y+o}];K(t,s,void 0,()=>r,i,a,z(a,.85),V)}function Vt(t,n,e,i,r,a,o){let s=bo(n,e,i/g);s&&K(t,s,void 0,()=>a,r,o,z(o,.85),V)}function Pn(t){let n=yt(t),e={x:(n[0].x+n[2].x)/2,y:(n[0].y+n[2].y)/2},i=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y)||1,r=Math.hypot(n[3].x-n[0].x,n[3].y-n[0].y)||1,a={x:(n[1].x-n[0].x)/i,y:(n[1].y-n[0].y)/i},o={x:(n[3].x-n[0].x)/r,y:(n[3].y-n[0].y)/r};return{at:(u,c)=>({x:e.x+(a.x*u+o.x*c)/g,y:e.y+(a.y*u+o.y*c)/g}),lengthM:i*g,widthM:r*g}}function go(t,n,e){let i=fe(n);if(!i.length)return;let r=1/0,a=-1/0,o=1/0,s=-1/0;for(let M of n.points??[])r=Math.min(r,M.x),a=Math.max(a,M.x),o=Math.min(o,M.y),s=Math.max(s,M.y);let u=(n.rotation??0)*Math.PI/180,c=Math.cos(u),l=Math.sin(u),f=(r+a)/2,m=(o+s)/2,y=M=>u?{x:f+(M.x-f)*c-(M.y-m)*l,y:m+(M.x-f)*l+(M.y-m)*c}:M,h=Math.min(a-r,s-o)*g,p=Math.max(.04,Math.min(.3,h*.004))/g,b=0;t.setMaterial(0);for(let M of i){if(!M.fill)continue;let S=M.points.map(y);zt(t,S,null,e+yo+b*po,ot(M.fill)??Ot,0),b++}let x=i.filter(M=>!(M.fill&&M.ink===M.fill)),d=[...new Set(x.map(M=>M.ink??Cn))];for(let M of d){let S=e+yo+b++*po,A=ot(M)??Ot;for(let R of x){if((R.ink??Cn)!==M)continue;let w=R.points.map(y),I=R.closed?w.length:w.length-1;for(let P=0;P<I;P++){let _=bo(w[P],w[(P+1)%w.length],p);_&&os(t,_,S,A)}}}}function Mo(t,n,e,i,r){if(n.length<3)return!1;let a=i+.006,o=r??zi;if(e==="oval-cricket"){let s=n.reduce((A,R)=>A+R.x,0)/n.length,u=n.reduce((A,R)=>A+R.y,0)/n.length,c=A=>n.map(R=>({x:s+(R.x-s)*A,y:u+(R.y-u)*A})),l=8;for(let A=0;A<l;A++){let R=c(1-A/l),w=A===l-1?null:c(1-(A+1)/l);zt(t,R,w,a,z(o,A%2?1.04:.96),4)}let f=n[0];for(let A of n)Math.hypot(A.x-s,A.y-u)>Math.hypot(f.x-s,f.y-u)&&(f=A);let m=Math.hypot(f.x-s,f.y-u)||1,y=(f.x-s)/m,h=(f.y-u)/m,p=-h,b=y,x=Math.min(1,2*m*g*$i/zn.length),d=zn.length*x/2/g,M=zn.width*x/2/g,S=[[-d,-M],[d,-M],[d,M],[-d,M]].map(([A,R])=>({x:s+y*A+p*R,y:u+h*A+b*R}));return zt(t,S,null,a+.004,Ki,0),t.setMaterial(0),!0}if(e==="rink-hockey"){let s=xo(n,es);return zt(t,s,null,a,Zi,0),t.setMaterial(0),K(t,n,[s.slice().reverse()],()=>i+ns,i,ho,z(ho,.9),V),!0}if(e==="ring-boxing"&&n.length===4){let{at:s}=Pn(n),u=[s(-3.05,-3.05),s(3.05,-3.05),s(3.05,3.05),s(-3.05,3.05)],c=[[.77,.19,.19],Ot,[.17,.42,.69],Ot];t.setMaterial(0),u.forEach((l,f)=>Sn(t,l,.07,i,i+ts,c[f]));for(let l of Ji)for(let f=0;f<4;f++)Vt(t,u[f],u[(f+1)%4],.025,i+l-.025,i+l+.025,Ot);return!0}if(e==="court-tennis"&&n.length===4){let{at:s}=Pn(n);t.setMaterial(0),Vt(t,s(0,-6.4),s(0,6.4),.015,i,i+.95,Mn),Vt(t,s(0,-6.4),s(0,6.4),.03,i+.95,i+1,Ot);for(let u of[-1,1])Sn(t,s(0,u*6.4),.05,i,i+1.07,Mn);return!0}if(e==="court-basketball"&&n.length===4){let{at:s,lengthM:u}=Pn(n),c=Math.min(14,u/2-.5);t.setMaterial(0);for(let l of[-1,1]){let f=s(l*(c+1.2),0),m=s(l*(c-1.2),0);Sn(t,f,.12,i,i+3.4,Mn),Vt(t,f,m,.06,i+3.25,i+3.4,Mn),Vt(t,s(l*(c-1.2),-.9),s(l*(c-1.2),.9),.03,i+2.9,i+3.95,Ot)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:s,lengthM:u}=Pn(n),c=u*(50/120);t.setMaterial(0);for(let l of[-1,1]){for(let f of[-2.8,2.8])Sn(t,s(l*c,f),.07,i,i+12,Ot);Vt(t,s(l*c,-2.8),s(l*c,2.8),.06,i+2.94,i+3.06,Ot)}return!0}if(e==="track-athletics"){let s=xo(n,Qi);return s.length<3?!1:(zt(t,n,s,a,qi,0),zt(t,s,null,a,o,4),t.setMaterial(0),!0)}return!1}var rs=.012,An=2.4,is=1,ss=.75,as=.15;function Et(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:i,rotation:r}=t;if(!e||!i)return null;let a=(r??0)*Math.PI/180,o=Math.cos(a),s=Math.sin(a),u=e/2,c=i/2;return[[-u,-c],[u,-c],[u,c],[-u,c]].map(([l,f])=>({x:n.x+l*o-f*s,y:n.y+l*s+f*o}))}function _o(t,n,e,i,r,a,o=!1){let s=Et(n);if(s){if(o){let u=kt(i,r.boothTop),c=wt([...s]);K(t,Mt(c,cs/g),[c.slice().reverse()],()=>e+.03,e,u,z(u,.8),V);return}if(!(!n.points&&a&&us(t,s,e,i,a))){if(!n.points&&a&&s.length===4){ls(t,s,e,i,a);return}K(t,s,void 0,()=>e+An,e,kt(i,r.boothTop),r.boothWall,V)}}}var Kn=1.1,So=[.9,.9,.88],cs=.1,In=[.87,.87,.85],Po=.08;function wo(t,n){let e=u=>({x:(t[u].x+t[(u+1)%4].x)/2,y:(t[u].y+t[(u+1)%4].y)/2}),i=0,r=1/0;for(let u=0;u<4;u++){let c=e(u),l=Math.hypot(c.x-n.x,c.y-n.y);l<r&&(r=l,i=u)}let a=[0,1,2,3].map(u=>t[(i+u)%4]),o=(u,c,l)=>({x:u.x+(c.x-u.x)*l,y:u.y+(c.y-u.y)*l});return{q:a,part:(u,c,l,f)=>{let m=o(a[0],a[1],u),y=o(a[0],a[1],c),h=o(a[3],a[2],u),p=o(a[3],a[2],c);return[o(m,h,l),o(y,p,l),o(y,p,f),o(m,h,f)]},depthM:Math.hypot(a[3].x-a[0].x,a[3].y-a[0].y)*g,widthM:Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y)*g}}function ls(t,n,e,i,r){let{q:a,part:o}=wo(n,r),s=i??[.35,.42,.55],u=rt(s,[.78,.78,.77],.62),c=rt(s,[.95,.95,.94],.45);tt(t,a,e+vt,e,u,z(u,.8)),tt(t,o(.05,.95,.72,.98),e+Kn-.05,e+vt,c,z(c,.8)),tt(t,o(.03,.97,.7,1),e+Kn,e+Kn-.05,So,z(So,.9))}function us(t,n,e,i,r){if(n.length!==4)return!1;let{q:a,part:o,depthM:s,widthM:u}=wo(n,r);if(s<1||u<1)return!1;let c=i??[.35,.42,.55],l=rt(c,[.78,.78,.77],.62),f=e+An,m=Po/u,y=Po/s;tt(t,a,e+vt,e,l,z(l,.8)),tt(t,o(0,1,1-y,1),f,e+vt,In,z(In,.9));for(let[b,x]of[[0,m],[1-m,1]])tt(t,o(b,x,0,1-y),f,e+vt,In,z(In,.9));tt(t,o(m,1-m,0,Math.min(.5,.06/s)),f,f-.3,c,z(c,.85));let h=Math.min(.4,.6/u),p=Math.min(.12,.3/s);return tt(t,o(.5-h,.5+h,.72-p,.72+p),e+is,e+vt,rt(c,[.95,.95,.94],.7),z(c,.75)),!0}function _n(t){if(t.shape==="round"){let l=t.radius;return l?yn(t.center.x,t.center.y,l,l,24):null}let{width:n,height:e,rotation:i,center:r}=t;if(!n||!e)return null;let a=(i??0)*Math.PI/180,o=Math.cos(a),s=Math.sin(a),u=n/2,c=e/2;return[[-u,-c],[u,-c],[u,c],[-u,c]].map(([l,f])=>({x:r.x+l*o-f*s,y:r.y+l*s+f*o}))}function Eo(t,n,e,i,r,a=!0){let o=_n(n);if(!o)return;let s=o.reduce((m,y)=>m+y.x,0)/o.length,u=o.reduce((m,y)=>m+y.y,0)/o.length,c=m=>o.map(y=>({x:s+(y.x-s)*m,y:u+(y.y-u)*m})),l=a&&i?kt(i,r.tableTop):fs,f=e+ss;K(t,o,void 0,()=>f,e+ms,l,z(l,.86),V),K(t,c(.12),void 0,()=>f+.12,f,Io,z(Io,.8),V)}var fs=[.93,.92,.89],Io=[.78,.66,.42],ms=.25;function Bo(t,n,e,i,r,a,o,s,u=[]){let c=at(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!c){en(t,n,e+i+rs);return}let f=s?s.kind==="stage":n.role==="stage",m=s?s.kind==="screen":n.role==="screen",y=s?{kind:f?"stage":"solid",heightM:s.topY-s.baseY}:St(n),h=s?.baseY??e,p=s?.topY??e+i;if(f&&o){let I=1/0,P=-1/0,_=1/0,T=-1/0;for(let k of c)k.x<I&&(I=k.x),k.x>P&&(P=k.x),k.y<_&&(_=k.y),k.y>T&&(T=k.y);o.push({cx:(I+P)/2*g,cz:(_+T)/2*g,y:p,halfX:Math.max((P-I)/2*g,.5),halfZ:Math.max((T-_)/2*g,.5)})}let b=ot(n.fill),x=n.role==="wall"||n.role==="entrance"||n.role==="exit",d=x?b?z(_t(b,.12),.95):r.tierTop:f&&b?rt(r.stageTop,z(_t(b,.18),.9),.9):!n.role&&b?b:kt(b,f?r.stageTop:r.decorTop),M=m?b:null,S=x?b?z(_t(b,.12),.85):r.tierWall:f?b?rt(r.stageWall,z(b,.58),.82):r.stageWall:m?M?rt(z(M,1.42),[.24,.46,.82],.08):[.24,.46,.82]:kt(ot(n.fill),r.decorWall);if(n.role==="wall"&&!s){ao(t,c,h,p,u,d,S),en(t,n,p+.012);return}if(m&&c.length===4&&p-h>.2){let I=Wn(c,h,p);if(!I)return;let{quad:P,side:_,trim:T,inner:k,panel:X}=I,B=[.12,.15,.18];for(let[E,O]of[[0,_],[1-_,1]])tt(t,ut(P,E,O),p,h,B,B);tt(t,k,h+T,h,B,B),tt(t,k,p,p-T,B,B),tt(t,X,p-T,h+T,S,S),en(t,n,p+.012);return}let A=b?z(_t(b,.15),.82):S,R=b?z(_t(b,.1),1.02):d;if(co(n.role)&&!s&&lo(t,n.role,c,h,p,A,R,a,n.heightM!==void 0))return;if((n.role==="sound"||s?.kind==="sound_desk")&&c.length===4&&p-h>.3){let I=yt(c),P=Math.hypot(I[1].x-I[0].x,I[1].y-I[0].y)*g,_=Math.min(.12,.09/Math.max(P,.001)),T=[.18,.21,.24],k=p-Math.min(.12,(p-h)*.15);for(let[X,B]of[[0,_],[1-_,1]])tt(t,ut(I,X,B),k,h,T,T);tt(t,I,p,k,d,T);return}if(n.role==="rail"&&c.length===4&&p>h){let I=yt(c),P=Math.hypot(I[1].x-I[0].x,I[1].y-I[0].y)*g,_=Math.max(1,Math.min(128,Math.ceil(P/1.4))),T=Math.min(.08,.055/Math.max(.055,P)),k=[.58,.64,.66];for(let X=0;X<=_;X++){let B=X/_,E=Math.min(1-T,Math.max(0,B-T/2));tt(t,ut(I,E,E+T),p,h,k,z(k,.8))}for(let X of[.52,1]){let B=h+(p-h)*X;tt(t,I,B,Math.max(h,B-.055),k,z(k,.8))}return}if(n.role==="goal"&&c.length===4){let I=yt(c),P=Math.hypot(I[1].x-I[0].x,I[1].y-I[0].y)*g,_=Math.min(.12,.1/Math.max(.1,P)),T=[.9,.94,.94];for(let[k,X]of[[0,_],[1-_,1]])tt(t,ut(I,k,X),Math.max(h,p-.1),h,T,T);tt(t,I,p,Math.max(h,p-.1),T,T);return}if(y.kind==="portal"&&c.length===4){let I=Yt(c,h,p);if(!I)return;let{quad:P,side:_,face:T,openingTop:k}=I;for(let[X,B,E]of[[0,T,1],[T,1-T,.67],[1-T,1,1]]){let O=nn(P,X,B),D=z(d,E),C=z(S,E);for(let[F,v]of[[0,_],[1-_,1]])tt(t,ut(O,F,v),k,h,D,C);tt(t,O,p,k,D,C)}return}if(y.kind==="suite"&&c.length===4){let I=c.map((T,k)=>{let X=c[(k+1)%4],B=(T.x+X.x)/2,E=(T.y+X.y)/2;return Math.hypot(B-a.x,E-a.y)}),P=I.indexOf(Math.min(...I)),_=[0,1,2,3].map(T=>c[(P+T)%4]);tt(t,ut(_,0,.08),p,h,d,S),tt(t,ut(_,.92,1),p,h,d,S),tt(t,nn(_,.88,1),p,h,d,S),tt(t,_,p,Math.max(h,p-.18),d,S);return}if(f&&!n.stageKind?.startsWith("pitch-")&&p-h>.12){let I=p-Math.min(.06,(p-h)*.15);tt(t,c,I,h,d,S),tt(t,c,p,I,d,rt(d,S,.2))}else tt(t,c,p,h,d,S);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&c.length===4){t.setMaterial(4);let I=yt(c);for(let P=0;P<12;P++){let _=ut(I,P/12,(P+1)/12),T=z(b??[.12,.38,.16],P%2?1.035:.965),k=_.map(X=>[X.x*g,p+.006,X.y*g]);t.tri(k[0],k[1],k[2],[0,1,0],T),t.tri(k[0],k[2],k[3],[0,1,0],T)}}n.stageKind&&n.stageKind!=="pitch-football"&&Mo(t,c,n.stageKind,p,b),f&&Ht(n.stageKind)&&go(t,n,p),t.setMaterial(m?1:0),en(t,n,p+.012)}function wn(t){let{x:n,y:e,width:i,height:r}=t;if(!i||!r)return null;let a=n+i/2,o=e+r/2,s=(t.rotation??0)*Math.PI/180,u=Math.cos(s),c=Math.sin(s),l=i/2,f=r/2;return[[-l,-f],[l,-f],[l,f],[-l,f]].map(([m,y])=>({x:a+m*u-y*c,y:o+m*c+y*u}))}function hs(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let i=e[1].trim();if(i==="none"||i==="transparent")return null;let r=i.match(/^url\(#([^)]+)\)$/);if(!r)return ot(i);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let o=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let u=ot(s[1].trim());u&&o.push(u)}return o.length?o.reduce((s,u,c)=>rt(s,u,1/(c+1)),o[0]):null}function To(t,n,e,i){if(n.layer==="foreground")return;let r=wn(n);if(!r)return;let a=e+as,o=kt(hs(n.href),i.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(o=rt(i.ground,o,s)),K(t,r,void 0,()=>a,e,o,rt(o,i.decorWall,.5),V)}function Co(t,n,e,i,r){if(!n.points||n.points.length<3)return;let a=kt(i,r.gaTop);K(t,n.points,n.holes,()=>e+Ro,e,a,r.gaWall,V),ds(t,n.points,e+Ro)}var Ro=.15,Rn=[.72,.74,.76],Zn=1.1,Ao=.12,qn=.05,ys=.06,ps=2.4;function ds(t,n,e){let i=wt([...n]),r=Lt(i,Ao/g),a=Lt(i,(Ao+qn)/g);if(r.length<3||a.length<3)return;for(let s of[e+Zn,e+Zn*.5])K(t,r,[a.slice().reverse()],()=>s,s-qn,Rn,z(Rn,.85),V);let o=ys/2/g;for(let s=0;s<r.length;s++){let u=r[s],c=r[(s+1)%r.length],l=Math.hypot(c.x-u.x,c.y-u.y)*g,f=Math.max(1,Math.round(l/ps));for(let m=0;m<f;m++){let y=m/f,h=u.x+(c.x-u.x)*y,p=u.y+(c.y-u.y)*y,b=[{x:h-o,y:p-o},{x:h+o,y:p-o},{x:h+o,y:p+o},{x:h-o,y:p+o}];K(t,b,void 0,()=>e+Zn-qn,e,Rn,z(Rn,.8),V)}}}var xs=6,bs=2.2,Oo=.1,gs=.3,Ms=1.8,Ss=.9,Ps=.55,Is=6e3;function Fo(t){let{doc:n,units:e,seats:i,surfaces:r,focal:a}=t,o=n.zones??[],s=[];if(o.length){let u=new Map;for(let l of e)for(let f of l.objects)f.type==="section"&&f.zone&&u.set(f.id,f.zone);let c=new Map;for(let l=0;l<i.length;l++){let f=i[l],m=r.seatOwner[l],y=f.zoneId??(m?u.get(m):void 0);if(!y)continue;let h=c.get(y);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(y,h)),h.n++,f.x<h.minX&&(h.minX=f.x),f.y<h.minY&&(h.minY=f.y),f.x>h.maxX&&(h.maxX=f.x),f.y>h.maxY&&(h.maxY=f.y),h.sumY+=r.seatDeckY(l)}for(let l of o){let f=c.get(l.id),m=[];for(let[y,h]of u)h===l.id&&m.push(y);if(!f||f.n===0){s.push({id:l.id,label:l.label,color:ot(l.color),sectionIds:m,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(l.focalPoint??a).x*g,1.5,(l.focalPoint??a).y*g]});continue}s.push({id:l.id,label:l.label,color:ot(l.color),sectionIds:m,seatCount:f.n,center:[(f.minX+f.maxX)/2*g,f.sumY/f.n,(f.minY+f.maxY)/2*g],radius:.5*Math.hypot((f.maxX-f.minX)*g,(f.maxY-f.minY)*g)||1,focalWorld:[(l.focalPoint??a).x*g,1.5,(l.focalPoint??a).y*g]})}}return s}function vo(t){let{doc:n,units:e,seats:i,surfaces:r,seatData:a,hintedSeatFloor:o,zones:s,focal:u}=t,c=[],l=[],f=[];for(let m of s)m.seatCount!==0&&c.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+xs,m.center[2]],color:n.zones?.find(y=>y.id===m.id)?.color});{let m=new Map,y=new Map;for(let h=0;h<i.length;h++){let p=r.seatOwner[h];if(!p)continue;let b=m.get(p);b||(b={n:0,x:0,y:0,deck:0},m.set(p,b)),b.n++,b.x+=i[h].x,b.y+=i[h].y,b.deck+=r.seatDeckY(h);let x=y.get(p);x||(x={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},y.set(p,x)),x.minDeck=Math.min(x.minDeck,r.seatDeckY(h)),x.maxDeck=Math.max(x.maxDeck,r.seatDeckY(h)),i[h].x<x.minX&&(x.minX=i[h].x),i[h].x>x.maxX&&(x.maxX=i[h].x),i[h].y<x.minY&&(x.minY=i[h].y),i[h].y>x.maxY&&(x.maxY=i[h].y)}for(let h of e)for(let p of h.objects){if(p.type!=="section"||to(p))continue;let b=m.get(p.id);if(!b||b.n===0)continue;let x=y.get(p.id),d=[b.x/b.n*g,b.deck/b.n,b.y/b.n*g],M=p.displayLabel||p.label||p.id;l.push({id:p.id,floorIndex:h.index,label:M,seatCount:b.n,center:d,radius:Math.max(1,Math.hypot(x.maxX-x.minX,x.maxY-x.minY)*.5*g),box:{min:[x.minX*g-.4,x.minDeck,x.minY*g-.4],max:[x.maxX*g+.4,x.maxDeck+1,x.maxY*g+.4]},focalWorld:[h.focal.x*g,h.baseHeightM+1.5,h.focal.y*g]});let S=n.floors?.[h.index]?.name?.trim().toLocaleLowerCase();e.length>1&&S===M.trim().toLocaleLowerCase()||c.push({id:`section:${p.id}`,kind:"section",text:M,anchor:[d[0],d[1]+bs,d[2]],floorIndex:h.index})}}{for(let b of e)for(let x of b.objects){if(x.type!=="gaArea")continue;let d=qt(x.points);if(!d)continue;let M=x.displayLabel||x.label||x.id;c.push({id:`ga:${x.id}`,kind:"ga",text:x.capacity>0?`${M} \xB7 ${x.capacity.toLocaleString()}`:M,anchor:[d.x*g,b.baseHeightM+Ms,d.y*g],floorIndex:b.index})}let m=new Map,y=new Map;for(let b of e)for(let x of b.objects)if(x.type==="section"&&m.set(x.id,x.displayLabel||x.label||x.id),x.type==="row"){let d=x.displayLabel?.trim()||x.segmentedRow?.displayLabel?.trim();d&&y.set(x.id,d)}let h=new Map;for(let b=0;b<i.length;b++){let x=i[b],d=Math.hypot(x.x-u.x,x.y-u.y),M=h.get(x.rowId);(!M||d>M.far)&&h.set(x.rowId,{seat:x,index:b,far:d})}for(let[b,x]of h){let d=r.seatOwner[x.index]??x.seat.sectionId,M=ko(x.seat.label,b,m.get(d??""),y.get(b));M&&c.push({id:`row:${b}`,kind:"row",text:M,anchor:[x.seat.x*g,r.seatDeckY(x.index)+Ss,x.seat.y*g],floorIndex:o[x.index]})}let p=new Map;for(let b=0;b<i.length;b++){let x=i[b],d=p.get(x.rowId);d||(d={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:ko(x.label,x.rowId,m.get(r.seatOwner[b]??x.sectionId??""),y.get(x.rowId)),sectionId:r.seatOwner[b]??x.sectionId},p.set(x.rowId,d));let M=b*3,S=a.iPosition[M],A=a.iPosition[M+1],R=a.iPosition[M+2];d.n++,d.x+=S,d.y+=A,d.z+=R,d.minX=Math.min(d.minX,S),d.maxX=Math.max(d.maxX,S),d.minZ=Math.min(d.minZ,R),d.maxZ=Math.max(d.maxZ,R)}for(let[b,x]of p)f.push({id:b,label:x.label,sectionId:x.sectionId,seatCount:x.n,center:[x.x/x.n,x.y/x.n,x.z/x.n],radius:Math.max(.8,Math.hypot(x.maxX-x.minX,x.maxZ-x.minZ)*.5)});if(i.length<=Is)for(let b=0;b<i.length;b++){let x=i[b],d=Rs(x.displayLabel||x.label);d&&c.push({id:`seat:${x.id}`,kind:"seat",seatWidthM:a.iChairWidth[b]*2,text:d,anchor:[x.x*g,r.seatDeckY(b)+Ps,x.y*g],floorIndex:o[b]})}}for(let m of e)for(let y of m.objects)if(y.type==="shape"&&y.role&&["entrance","exit","screen","suite","obstruction"].includes(y.role)){let h=at(y),p=h?qt(h):null;if(!p||!y.label)continue;c.push({id:`architecture:${y.id}`,kind:"annotation",text:y.label,anchor:[p.x*g,m.baseHeightM+St(y).heightM+Oo,p.y*g],color:y.fill,floorIndex:m.index})}else if(y.type==="text"){if(!y.text)continue;c.push({id:`text:${y.id}`,kind:"annotation",text:y.text,anchor:[y.position.x*g,m.baseHeightM+Oo,y.position.y*g],color:y.color,rotation:y.rotation,floorIndex:m.index})}else if(y.type==="booth"){let h=Et(y);if(!h)continue;let p=qt(h);if(!p)continue;c.push({id:`booth:${y.id}`,kind:"booth",text:y.displayLabel||y.label||y.id,anchor:[p.x*g,m.baseHeightM+An+gs,p.y*g],floorIndex:m.index})}return{labels:c,sections:l,rows:f}}function Do(t,n){if(n.length>1)for(let e of n)t.push({id:`floor:${e.id}`,kind:"floor",text:e.label,anchor:[e.center[0],e.box.max[1]+1.2,e.center[2]],floorIndex:e.index})}function Rs(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function ko(t,n,e,i){if(i?.trim())return i.trim();let r=t?t.lastIndexOf("-"):-1,a=r>0?t.slice(0,r):n;return a&&de(a,e)}var on=3,Gt=.38,rn=.24;function As(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],i=t[t.length-1],r=(e.x-n.x)*g,a=(e.y-n.y)*g,o=(i.x-n.x)*g,s=(i.y-n.y)*g,u=2*(r*s-a*o);if(Math.abs(u)<1e-7)return null;let c=r*r+a*a,l=o*o+s*s,f=(c*s-l*a)/u+n.x*g,m=(r*l-o*c)/u+n.y*g,y=Math.hypot(n.x*g-f,n.y*g-m);return y<1||y>200||!Number.isFinite(y)||t.some(h=>Math.abs(Math.hypot(h.x*g-f,h.y*g-m)-y)>.03)?null:{x:f,z:m,radius:y}}function Lo(t){let n=[],e=new Map,i=(u,c)=>`${Math.floor(u/on)},${Math.floor(c/on)}`;for(let u of t)for(let c of u.rows){for(let f of c.pts){let m=f.x*g,y=f.y*g,h=i(m,y),p=e.get(h)??[];p.push({x:m,z:y,y:c.y,floor:u.floorIndex}),e.set(h,p)}if(c.patch||c.pts.length<2)continue;let l=As(c.pts);for(let f of[0,c.pts.length-1]){let m=c.pts[f],y=c.pts[f===0?1:f-1],h=m.x-y.x,p=m.y-y.y,b=Math.hypot(h,p);b<1e-6||n.push({sectionId:u.sectionId,floorIndex:u.floorIndex,curve:l,row:c,point:m,x:m.x*g,z:m.y*g,dx:h/b,dz:p/b})}}let r=new Map;n.forEach((u,c)=>{let l=i(u.x,u.z),f=r.get(l)??[];f.push(c),r.set(l,f)});let a=(u,c)=>{let l=Math.floor(u/on),f=Math.floor(c/on);return[-1,0,1].flatMap(m=>[-1,0,1].map(y=>`${l+m},${f+y}`))},o=new Map;n.forEach((u,c)=>{let l=-1,f=1/0,m=!1;for(let y of a(u.x,u.z))for(let h of r.get(y)??[]){let p=n[h];if(u.sectionId===p.sectionId&&u.row.blockId===p.row.blockId||u.floorIndex!==p.floorIndex||Math.abs(u.row.y-p.row.y)>.05)continue;let b=p.x-u.x,x=p.z-u.z,d=Math.hypot(b,x);if(d<Gt*2+.45||d>on)continue;let M=u.curve&&p.curve&&Math.hypot(u.curve.x-p.curve.x,u.curve.z-p.curve.z)<=.05&&Math.abs(u.curve.radius-p.curve.radius)<=.05,S=Math.min((b*u.dx+x*u.dz)/d,(-b*p.dx-x*p.dz)/d);(M?S<.8:S<.98)||!M&&(Math.abs(b*u.dz-x*u.dx)>.15||Math.abs(b*p.dz-x*p.dx)>.15)||(d<f-.02?(l=h,f=d,m=!1):Math.abs(d-f)<=.02&&(m=!0))}l>=0&&!m&&o.set(c,l)});let s=[];for(let[u,c]of o){if(u>=c||o.get(c)!==u)continue;let l=n[u],f=n[c],m=Math.hypot(f.x-l.x,f.z-l.z),y=(f.x-l.x)/m,h=(f.z-l.z)/m,p=!1;for(let x of a((l.x+f.x)/2,(l.z+f.z)/2))for(let d of e.get(x)??[]){if(d.floor!==l.floorIndex||Math.abs(d.y-l.row.y)>.75)continue;let M=(d.x-l.x)*y+(d.z-l.z)*h,S=Math.abs((d.x-l.x)*h-(d.z-l.z)*y);M>.01&&M<m-.01&&S<rn+Gt&&(p=!0)}if(p)continue;let b=(x,d)=>({x:(l.x+y*x-h*d)/g,y:(l.z+h*x+y*d)/g});s.push({sections:[l.sectionId,f.sectionId],blocks:[l.row.blockId,f.row.blockId],floorIndex:l.floorIndex,ends:[l.point,f.point],clearWidthM:m-2*Gt,heightM:(l.row.y+f.row.y)/2,outline:[b(Gt,-rn),b(m-Gt,-rn),b(m-Gt,rn),b(Gt,rn)]})}return s}var _s=.15,ws=.9,Es=1.76;function Bs(){return{background:{top:[...Fn.top],bottom:[...Fn.bottom]},structure:kn,seatStates:{..._e},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function Ts(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55?{deck:"#a8ada9",fascia:"#69777c",shell:"#8d9ca0",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function Go(t){let n=Bs();t??={};let e=ot(t.background);if(e){n.background={top:z(e,ws),bottom:z(e,Es)};let s={};for(let[c,l]of Object.entries(kn))s[c]=rt(l,e,_s);e[0]*.2126+e[1]*.7152+e[2]*.0722>.55&&(s.ground=z(e,.86)),n.structure=s}let i=ot(t.selectionColor)??ot(t.accent);i&&(n.seatStates={...n.seatStates,selected:i});let r=t.seatScale;typeof r=="number"&&Number.isFinite(r)&&(n.seatScale=be(r));let a=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([,s])=>s!=null)),o={...Ts(e),...a};if(o){let s=ot(o.deck),u=ot(o.fascia);s&&(n.structure={...n.structure,tierTop:s,gaTop:s}),u&&(n.structure={...n.structure,tierWall:u,gaWall:u}),n.materials.seat=ot(o.seat),n.materials.shell=ot(o.shell),typeof o.roughness=="number"&&Number.isFinite(o.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,o.roughness)))}return n}function No(t,n){let e=[];for(let i of n)e.push(...t.seatStates[i]);return e}var $n=.6,Xo=3,Cs=.25;function Os(t,n){if(ht(n,t.x,t.y))return 0;let e=1/0;for(let i=0,r=n.length-1;i<n.length;r=i++){let a=n[r],o=n[i],s=o.x-a.x,u=o.y-a.y,c=s*s+u*u||1,l=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/c));e=Math.min(e,Math.hypot(t.x-(a.x+l*s),t.y-(a.y+l*u)))}return e}function Ho(t,n){let e=t.map(o=>({booth:o,ring:Et(o)})).filter(o=>!!o.ring&&o.ring.length===4&&!o.booth.points),i=e.map(({ring:o})=>({minX:Math.min(...o.map(s=>s.x)),maxX:Math.max(...o.map(s=>s.x)),minY:Math.min(...o.map(s=>s.y)),maxY:Math.max(...o.map(s=>s.y))})),r=(Xo+$n)/g,a=new Map;return e.forEach(({booth:o,ring:s},u)=>{let c={x:s.reduce((y,h)=>y+h.x,0)/4,y:s.reduce((y,h)=>y+h.y,0)/4},l=[0,1,2,3].map(y=>{let h=s[y],p=s[(y+1)%4],b={x:(h.x+p.x)/2,y:(h.y+p.y)/2},x=b.x-c.x,d=b.y-c.y,M=Math.hypot(x,d)||1,S={x:b.x+x/M*$n/g,y:b.y+d/M*$n/g},A=Xo/g;return i.forEach((R,w)=>{w===u||S.x<R.minX-r||S.x>R.maxX+r||S.y<R.minY-r||S.y>R.maxY+r||(A=Math.min(A,Os(S,e[w].ring)))}),{open:A*g,toward:{x:b.x+x/M*10/g,y:b.y+d/M*10/g},focal:Math.hypot(b.x-n.x,b.y-n.y)}}),f=Math.max(...l.map(y=>y.open)),m=l.filter(y=>y.open>=f-Cs).sort((y,h)=>y.focal-h.focal)[0];a.set(o.id,m.toward)}),a}import ks from"polygon-clipping";var Fs=.45,vs=1500,Ds=200;function jo(t,n){if(t.role!=="stage"||Ht(t.stageKind))return t;let e=at(t);if(!e||e.length<3||Math.abs(mt(e))*g*g>vs)return t;let i=n.filter(o=>ht(e,o.x,o.y));if(!i.length||i.length>Ds)return t;let r=Fs/g,a=i.map(o=>[[[o.x-r,o.y-r],[o.x+r,o.y-r],[o.x+r,o.y+r],[o.x-r,o.y+r],[o.x-r,o.y-r]]]);try{let o=ks.difference([[...e.map(c=>[c.x,c.y]),[e[0].x,e[0].y]]],...a),s=null,u=0;for(let c of o){let l=c[0].slice(0,-1).map(([m,y])=>({x:m,y})),f=Math.abs(mt(l));f>u&&(u=f,s=l)}return!s||s.length<3?t:{...t,kind:"polygon",points:s,rotation:0}}catch{return t}}function Qn(t,n,e,i,r,a,o,s,u,c=[],l=r){if(n.length!==e.length||n.length<2||a-r<1.5)return;let f=(p,b,x)=>{Ct(t,p,b,x,c,o,s,{portalBase:l,ao:u})||K(t,p,void 0,()=>x,b,o,s,u)},m=(p,b,x)=>({x:p.x+(b.x-p.x)*x,y:p.y+(b.y-p.y)*x}),y=i?n.length:n.length-1,h=0;for(let p=0;p<y;p++){let b=(p+1)%n.length,x=Math.hypot(e[b].x-e[p].x,e[b].y-e[p].y)*et;if(x<1e-5)continue;let d=(R,w)=>[m(n[p],n[b],R),m(n[p],n[b],w),m(e[p],e[b],w),m(e[p],e[b],R)];f(d(0,1),r,r+.95),f(d(0,1),a-.22,a);let M=Math.ceil((h-.32)/6)*6,S=!1,A=!1;for(let R=M;R<h+x;R+=6){let w=Math.max(0,(R-h)/x),I=Math.min(1,(R+.32-h)/x);I<=w||(f(d(w,I),r+.95,a-.22),S||=w<1e-6,A||=I>1-1e-6)}if(!i&&(p===0&&!S||p===y-1&&!A)){let R=Math.min(1,.32/x);f(d(p===0?0:1-R,p===0?R:1),r+.95,a-.22)}h+=x}}var sn=.65;function Uo(t,n){let e=1/0;for(let i of n)for(let r=0;r<i.length;r++){let a=i[r],o=i[(r+1)%i.length],s=o.x-a.x,u=o.y-a.y,c=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*u)/(s*s+u*u||1)));e=Math.min(e,Math.hypot(t.x-a.x-c*s,t.y-a.y-c*u))}return e}var Yo=.01;function Wo(t,n,e,i,r,a,o,s=[],u=!0){if(i-r<=1e-5)return;let c=i-r>=3,l=c?i-sn:r;t.setMaterial(5);let f=c?[]:s.filter(S=>{if(S.role!=="entrance"&&S.role!=="exit")return!1;let A=at(S);if(!A)return!1;let R=Yt(A,r,r+St(S).heightM);return R!==null&&R.openingTop<=i-.12});if((!f.length||!Ct(t,n,l,i,f,a,o,{holes:e,portalBase:r}))&&K(t,n,e,()=>i,l,a,o,V,void 0,()=>[0,1,0]),!c){t.setMaterial(0);return}let m=6/g,y=.22/g,h=s.flatMap(S=>{if(S.role!=="entrance"&&S.role!=="exit")return[];let A=at(S);return A?.length?[{minX:Math.min(...A.map(R=>R.x)),maxX:Math.max(...A.map(R=>R.x)),minY:Math.min(...A.map(R=>R.y)),maxY:Math.max(...A.map(R=>R.y))}]:[]}),p=Math.min(...n.map(S=>S.x)),b=Math.max(...n.map(S=>S.x)),x=Math.min(...n.map(S=>S.y)),d=Math.max(...n.map(S=>S.y));for(let S=p+m/2;S<b;S+=m)for(let A=x+m/2;A<d;A+=m){if(h.some(w=>S+y>=w.minX&&S-y<=w.maxX&&A+y>=w.minY&&A-y<=w.maxY))continue;let R=[{x:S-y,y:A-y},{x:S+y,y:A-y},{x:S+y,y:A+y},{x:S-y,y:A+y}];!At({x:S,y:A},n,e)||Uo({x:S,y:A},[n,...e??[]])<y*Math.SQRT2+(u?Jn/g:0)||K(t,R,void 0,()=>l,r,a,o,V)}let M=Lt(n,Jn/g);if(u&&M.length>=3){let S=s.filter(w=>{if(w.role!=="entrance"&&w.role!=="exit")return!1;let I=at(w);return!!I&&I.some(P=>!At(P,n,void 0)||Uo(P,[n])<=Jn/g)}),A=[M.slice().reverse()],R=r-Yo;(!S.length||!Ct(t,n,R,l,S,a,o,{holes:A,portalBase:r+Yo}))&&K(t,n,A,()=>l,R,a,o,V)}t.setMaterial(0)}var Jn=.25;var Ls=.02,Gs=.25,Ns=1.2,Xs=.6,Hs=.45,js=2.3,Us=Math.PI/180,Vo=.005;function Bt(t,n,e){let i=e*Us;return{x:t.x+n*Math.sin(i),y:t.y+n*Math.cos(i)}}function Ys(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let i=e.outerRMedian*.85;for(let r of t){if(r.role!=="wall")continue;let a=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(a.length<2)continue;let o=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=i&&o++;if(o>=a.length/2)return!0}return!1}var Ws=24,Vs=.01;function zs(t,n,e,i,r,a,o,s,u){let c=e.binCount,l=Ws,f=et,m=a+.02,y=a-Vs,h=[];for(let B=0;B<c;B++){let E=(e.startBin+B+.5)*n.binStepDeg,O=new Float64Array(l+1);for(let D=0;D<=l;D++){let C=i[B]+(r[B]-i[B])*D/l;O[D]=Math.max(m,Se(n,e,E,C)-Gs)}h.push(O)}if(u){let B=0;for(let E=0;E+1<c;E++)for(let O=0;O<l;O++){let D=Bt(n.centre,i[E]+(r[E]-i[E])*O/l,(e.startBin+E+.5)*n.binStepDeg),C=Bt(n.centre,i[E+1]+(r[E+1]-i[E+1])*(O+1)/l,(e.startBin+E+1.5)*n.binStepDeg);B=Math.max(B,Math.hypot(C.x-D.x,C.y-D.y))}for(let E=0;E<c;E++){let O=(e.startBin+E+.5)*n.binStepDeg;for(let D=0;D<=l;D++){let C=Bt(n.centre,i[E]+(r[E]-i[E])*D/l,O),F=u(C.x,C.y,B*1.01);F!==null&&(h[E][D]=Math.min(h[E][D],Math.max(y+Vo,F-Vo)))}}}let p=[o.bandTop[0]*s.top,o.bandTop[1]*s.top,o.bandTop[2]*s.top],b=[o.bandTop[0]*s.bottomCap,o.bandTop[1]*s.bottomCap,o.bandTop[2]*s.bottomCap],x=[o.bandWall[0]*s.top,o.bandWall[1]*s.top,o.bandWall[2]*s.top],d=[o.bandWall[0]*s.wallBottom,o.bandWall[1]*s.wallBottom,o.bandWall[2]*s.wallBottom],M=(B,E)=>{let O=(e.startBin+B+.5)*n.binStepDeg,D=i[B]+(r[B]-i[B])*E/l,C=Bt(n.centre,D,O);return[C.x*f,h[B][E],C.y*f]};{let B=Math.tan(12*Math.PI/180);for(let E=0;E<6;E++){let O=!1;for(let C=0;C<c;C++)for(let F=l-1;F>=0;F--)h[C][F]>h[C][F+1]&&(h[C][F]=h[C][F+1],O=!0);let D=e.closed?c:c-1;for(let C=0;C<D;C++){let F=(C+1)%c;for(let v=0;v<=l;v++){let G=h[F][v]-h[C][v];if(Math.abs(G)>1)continue;let j=i[C]+(r[C]-i[C])*v/l,U=i[F]+(r[F]-i[F])*v/l,H=Bt(n.centre,j,(e.startBin+C+.5)*n.binStepDeg),W=Bt(n.centre,U,(e.startBin+F+.5)*n.binStepDeg),nt=B*Math.hypot(W.x-H.x,W.y-H.y)*f;G>nt?(h[F][v]=h[C][v]+nt,O=!0):-G>nt&&(h[C][v]=h[F][v]+nt,O=!0)}}if(!O)break}}let S=1,A=(B,E)=>{for(let O=0;O<=l;O+=4)if(Math.abs(h[B][O]-h[E][O])>S)return!0;return Math.abs(h[B][l]-h[E][l])>S},R=Math.tan(38*Math.PI/180),w=B=>(r[B]-i[B])/l*f,I=(B,E)=>h[B][E+1]-h[B][E]>R*Math.max(1e-6,w(B)),P=(B,E)=>{let O=e.closed?(B-1+c)%c:Math.max(0,B-1),D=e.closed?(B+1)%c:Math.min(c-1,B+1);Math.abs(h[O][E]-h[B][E])>S&&(O=B),Math.abs(h[D][E]-h[B][E])>S&&(D=B);let C=Math.max(0,E-1),F=Math.min(l,E+1);C<E&&I(B,C)&&(C=E),F>E&&I(B,E)&&(F=E);let v=M(O,E),G=M(D,E),j=M(B,C),U=M(B,F),H=G[0]-v[0],W=G[1]-v[1],nt=G[2]-v[2],$=U[0]-j[0],Q=U[1]-j[1],N=U[2]-j[2],L=W*N-nt*Q,Z=nt*$-H*N,J=H*Q-W*$,q=Math.hypot(L,Z,J);return q>1e-12?(L/=q,Z/=q,J/=q,Z<0&&(L=-L,Z=-Z,J=-J),[L,Z,J]):[0,1,0]},_=(B,E,O=!1)=>{let D=O&&Math.min(B[1],E[1])-a>=3,C=[B[0],D?B[1]-sn:y,B[2]],F=[E[0],D?E[1]-sn:y,E[2]],v=E[0]-B[0],G=E[2]-B[2],j=Math.hypot(v,G);if(!(j>1e-12))return;let U=[G/j,0,-v/j];t.tri(B,E,F,U,x,x,d),t.tri(B,F,C,U,x,d,d)},T=.05*xt,k=B=>r[B]-i[B]<T,X=e.closed?c:c-1;for(let B=0;B<X;B++){let E=(B+1)%c;if(k(B)||k(E))continue;if(A(B,E)){let G=(e.startBin+B+1)*n.binStepDeg,j=(Q,N)=>{let L=(i[B]+i[E])/2,Z=(r[B]+r[E])/2,J=L+(Z-L)*N/l,q=Bt(n.centre,J,G);return[q.x*f,h[Q][N],q.y*f]};for(let Q=0;Q<l;Q++){let N=M(B,Q),L=M(B,Q+1),Z=j(B,Q),J=j(B,Q+1),q=P(B,Q),ct=P(B,Q+1);t.triN(N,Z,J,q,q,ct,p),t.triN(N,J,L,q,ct,ct,p);let it=M(E,Q),Y=M(E,Q+1),lt=j(E,Q),Pt=j(E,Q+1),It=P(E,Q),Rt=P(E,Q+1);t.triN(lt,it,Y,It,It,Rt,p),t.triN(lt,Y,Pt,It,Rt,Rt,p);let gt=j(B,Q),ft=j(B,Q+1),Nt=j(E,Q+1),Bn=j(E,Q),an=ft[0]-gt[0],Zt=ft[2]-gt[2],Tn=Math.hypot(an,Zt);if(Tn>1e-12){let oe=[Zt/Tn,0,-an/Tn];t.tri(gt,ft,Nt,oe,x),t.tri(gt,Nt,Bn,oe,x)}}let U=M(B,0),H=M(E,0),W=M(E,l),nt=M(B,l),$=Q=>[Q[0],y,Q[2]];Math.min(U[1],H[1])-a<3&&(t.tri($(U),$(W),$(H),[0,-1,0],b),t.tri($(U),$(nt),$(W),[0,-1,0],b)),_(U,H,!0),_(nt,W,!0);continue}for(let G=0;G<l;G++){let j=P(B,G),U=P(E,G),H=P(E,G+1),W=P(B,G+1);if(I(B,G)||I(E,G)){let L=(ft,Nt)=>{let Bn=(e.startBin+ft+.5)*n.binStepDeg,an=i[ft]+(r[ft]-i[ft])*(G+.5)/l,Zt=Bt(n.centre,an,Bn);return[Zt.x*f,Nt,Zt.y*f]},Z=M(B,G),J=M(E,G),q=L(B,h[B][G]),ct=L(E,h[E][G]);t.triN(Z,J,ct,j,U,U,p),t.triN(Z,ct,q,j,U,j,p);let it=M(E,G+1),Y=M(B,G+1),lt=L(B,h[B][G+1]),Pt=L(E,h[E][G+1]);t.triN(lt,Pt,it,W,H,H,p),t.triN(lt,it,Y,W,H,W,p);let It=ct[0]-q[0],Rt=ct[2]-q[2],gt=Math.hypot(It,Rt);if(gt>1e-12){let ft=[-Rt/gt,0,It/gt];t.tri(q,ct,Pt,ft,x),t.tri(q,Pt,lt,ft,x)}continue}let nt=M(B,G),$=M(E,G),Q=M(E,G+1),N=M(B,G+1);t.triN(nt,$,Q,j,U,H,p),t.triN(nt,Q,N,j,H,W,p)}let O=M(B,0),D=M(E,0),C=M(E,l),F=M(B,l),v=G=>[G[0],y,G[2]];Math.min(O[1],D[1])-a<3&&(t.tri(v(O),v(C),v(D),[0,-1,0],b),t.tri(v(O),v(F),v(C),[0,-1,0],b)),_(O,D,!0),_(F,C,!0)}if(!e.closed)for(let B of[0,c-1])for(let E=0;E<l;E++)_(M(B,E),M(B,E+1))}function zo(t,n,e){let{bottomY:i,colors:r,ao:a}=e,o=new Float64Array(n.binCount).fill(-1/0);for(let l of n.rings)for(let f of l.arcs){let m=new Float64Array(f.binCount),y=new Float64Array(f.binCount);for(let p=0;p<f.binCount;p++){let b=(f.startBin+p)%n.binCount,x=Math.max(0,f.innerR[p]-bt);m[p]=Math.max(x,o[b]+.001),y[p]=Math.max(m[p]+.001,f.outerR[p]+bt)}let h=0;for(let p=0;p<f.binCount;p++){let b=f.topLevelM[p]-i;b>h&&(h=b)}h>=Ns&&zs(t,n,f,m,y,i,r,a,e.standTopNear);for(let p=0;p<f.binCount;p++){let b=(f.startBin+p)%n.binCount;y[p]>o[b]&&(o[b]=y[p])}}if(e.deriveShell===!1||Ys(e.shapes,n))return;let s=n.rings[n.rings.length-1],u=Xs*xt,c=Hs*xt;for(let l of s.arcs){let f=[],m=[];for(let P=0;P<l.binCount;P++){let _=(l.startBin+P+.5)*n.binStepDeg,T=l.outerR[P]+bt+u;f.push(Bt(n.centre,T,_)),m.push(Bt(n.centre,T+c,_))}let y=-1/0;for(let P=0;P<l.binCount;P++)l.topLevelM[P]>y&&(y=l.topLevelM[P]);let h=y+js,p=l.closed?m:[...m,...f.slice().reverse()],b=l.closed?[f.slice().reverse()]:void 0,x=rt(r.shellWall,[.66,.71,.72],.62),d=(P,_,T,k,X)=>{let B=Math.abs(k-y)<1e-6?k-Ls:k;Ct(t,P,T,B,e.shapes,r.shellTop,X,{holes:_,portalBase:i,ao:a})||K(t,P,_,()=>B,T,r.shellTop,X,a)},M=Math.max(1,Math.ceil((y-i)/4.5)),S=(y-i)/M,A=new Set,R=e.tierFrontLevels??n.rings.map(P=>{let _=P.arcs.flatMap(T=>Array.from(T.frontLevelM)).filter(Number.isFinite).sort((T,k)=>T-k);return _[Math.floor(_.length/2)]});for(let P of R)Number.isFinite(P)&&P-i>=3&&P<y&&A.add(Math.max(0,Math.min(M-1,Math.floor((P-i)/S))));let w=Math.min(...R.filter(P=>Number.isFinite(P)&&P-i>=3&&P<y));for(let P=0;P<M;P++)i+(P+1)*S<=w-sn&&Number.isFinite(w)&&A.add(P);for(let P=0;P<M;P++){let _=i+(y-i)*P/M,T=i+(y-i)*(P+1)/M;A.has(P)&&T-_>=3.2?(d(p,b,_,_+.45,x),Qn(t,f,m,l.closed,_+.45,T-.16,r.shellTop,x,a,e.shapes,i)):d(p,b,_,T-.16,x),d(p,b,T-.16,T,z(x,.62))}Qn(t,f,m,l.closed,y,h,r.shellTop,x,a,e.shapes,i);let I=8;for(let P=1;P<m.length;P++){if(I+=Math.hypot(m[P].x-m[P-1].x,m[P].y-m[P-1].y)*et,I<8)continue;I=0;let _=m[P],T=m[P-1],k=_.x-T.x,X=_.y-T.y,B=Math.max(1,Math.hypot(k,X)),E=k/B*.16*xt,O=X/B*.16*xt,D=Math.max(1,Math.hypot(_.x-n.centre.x,_.y-n.centre.y)),C=(_.x-n.centre.x)/D*.24*xt,F=(_.y-n.centre.y)/D*.24*xt,v=[{x:_.x-E,y:_.y-O},{x:_.x+E,y:_.y+O},{x:_.x+E+C,y:_.y+O+F},{x:_.x-E+C,y:_.y-O+F}];d(v,void 0,i,y,z(x,1.12))}}}function Ko(t,n,e,i){let r=new Map;for(let s of n){let u=r.get(s.blockId);(!u||s.depth<u.depth)&&r.set(s.blockId,s)}let a=[.68,.72,.72],o=[.48,.55,.57];for(let s of r.values()){if(s.y-i<2.5||s.pts.length<2)continue;let u=s.pts.map(l=>{let f=l.x-e.x,m=l.y-e.y,y=Math.max(1,Math.hypot(f,m));return{x:l.x-f/y*.65/g,y:l.y-m/y*.65/g}}),c=2;for(let l=1;l<u.length;l++){let f=u[l-1],m=u[l],y=m.x-f.x,h=m.y-f.y,p=Math.hypot(y,h);if(p<1e-5||p*g>2)continue;let b=x=>{let d=-h/p*x/g/2,M=y/p*x/g/2;return[{x:f.x+d,y:f.y+M},{x:m.x+d,y:m.y+M},{x:m.x-d,y:m.y-M},{x:f.x-d,y:f.y-M}]};K(t,b(.22),void 0,()=>s.y-.06,s.y-.56,a,a,V);for(let x of[.5,.95])K(t,b(.045),void 0,()=>s.y+x,s.y+x-.045,o,o,V);if(c+=p*g,c>=1.8||l===u.length-1){c=0;let x=.028/g,d=[{x:f.x-x,y:f.y-x},{x:f.x+x,y:f.y-x},{x:f.x+x,y:f.y+x},{x:f.x-x,y:f.y+x}];K(t,d,void 0,()=>s.y+.95-.045,s.y-.06,o,o,V)}}}}function Zo(t,n,e,i,r){let a=[.67,.71,.68];for(let o=0;o<n.length;o++){let s=n[o];if(!(s.pts.length<2))for(let u of[0,s.pts.length-1]){let c=s.pts[u],l=s.pts[u===0?1:u-1],f=c.x-l.x,m=c.y-l.y,y=Math.hypot(f,m);if(y<1e-5)continue;f/=y,m/=y;let h=1/0;for(let I=0;I<e.length;I++){let P=e[I],_=e[(I+1)%e.length],T=_.x-P.x,k=_.y-P.y,X=f*k-m*T;if(Math.abs(X)<1e-8)continue;let B=P.x-c.x,E=P.y-c.y,O=(B*k-E*T)/X,D=(B*m-E*f)/X;O>0&&D>=0&&D<=1&&(h=Math.min(h,O))}let p=.3/g,b=h-.04/g;if(!Number.isFinite(h)||h*g>2||b-p<.12/g)continue;let x=.27/g,d=[{x:c.x+f*p-m*x,y:c.y+m*p+f*x},{x:c.x+f*b-m*x,y:c.y+m*b+f*x},{x:c.x+f*b+m*x,y:c.y+m*b-f*x},{x:c.x+f*p+m*x,y:c.y+m*p-f*x}];if(!d.every(I=>ht(e,I.x,I.y)))continue;let M=r?.[o]?.belowY,S=M==null?0:s.y-M,A=!!i&&S>.03&&S<=.65;if(A&&i){let I=(P,_)=>Math.hypot((P.x+_.x)/2-i.x,(P.y+_.y)/2-i.y);I(d[0],d[1])>I(d[3],d[2])&&(d=[d[3],d[2],d[1],d[0]])}let R=A?Math.ceil((S-1e-8)/.2):1,w=(I,P,_)=>({x:I.x+(P.x-I.x)*_,y:I.y+(P.y-I.y)*_});for(let I=0;I<R;I++){let P=I/R,_=(I+1)/R,T=[w(d[0],d[3],P),w(d[1],d[2],P),w(d[1],d[2],_),w(d[0],d[3],_)],k=s.y+.008-(A?S*(1-_):0);if(K(t,T,void 0,()=>k,k-(A?S/R+.1:.16),a,[.43,.47,.46],V),!A)continue;let X=Math.hypot(T[3].x-T[0].x,T[3].y-T[0].y)*g,B=Math.min(.04/X,.25),E=w(T[0],T[3],B),O=w(T[1],T[2],B),D=F=>[F.x*g,k+.004,F.y*g],C=[.66,.59,.39];t.tri(D(T[0]),D(T[1]),D(O),[0,1,0],C),t.tri(D(T[0]),D(O),D(E),[0,1,0],C)}}}}function qo(t,n,e,i,r,a,o,s,u=!1){if(!n.outline||n.outline.length<3)return;let c=e.baseHeightM,l=e.objects.filter(d=>d.type==="shape"&&(d.role==="entrance"||d.role==="exit")),f=Ce(i,s.tierTop);if(!r)return;let m=d=>r.deckAt(d.x,d.y),y=Ke(n,o),h=y[0]??n.outline;if(r.rowLevels.length>=2){let d=dn(r.rowLevels),M=Ze(je(r.rowLevels,e.focal,d),y);for(let A of M){let R=Math.max(c,A.topY-$o);for(let w of a.subtract(A.outline,R))Wo(t,w,A.holes,R,c,s.tierTop,s.tierWall,l,!u)}M.length||K(t,h,n.holes,()=>r.landingY,c,f,s.tierWall,V);let S={tread:[f[0]*V.top,f[1]*V.top,f[2]*V.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let A of y.length?y:[h])Ye(t,r.rowLevels,e.focal,r.landingY,S,A,d);Ko(t,r.rowLevels,e.focal,c),Zo(t,r.rowLevels,n.outline,e.focal,d);return}let p=r.flat?1/0:fo,b=d=>r.normalAt(d.x,d.y),x=r.flat?r.landingY:void 0;for(let d of a.subtract(h,x))K(t,d,n.holes,m,c,f,s.tierWall,V,p,b)}function Ks(t,n,e){let i=new Set;for(let o of t.objects)o.type==="section"&&i.add(o.id);let r=new Map;for(let o=0;o<n.length;o++){let s=e.seatOwner[o];if(!s||!i.has(s))continue;let u=e.bySection.get(s);if(u&&u.rowLevels.length>=2)continue;let c=n[o];if(c.kind==="booth")continue;let l=r.get(s);l||(l=new Map,r.set(s,l));let f=c.rowId||`__seat-${o}`,m=l.get(f);m||(m={pts:[],levelM:0,n:0},l.set(f,m)),m.pts.push({x:c.x,y:c.y}),m.levelM+=e.seatDeckY(o),m.n++}let a=[];for(let o of t.objects){if(o.type!=="section")continue;let s=e.bySection.get(o.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));c.length>=2&&a.push({sectionId:o.id,rows:c});continue}let u=r.get(o.id);u&&a.push({sectionId:o.id,rows:[...u.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return a}function Zs(t,n){let e=1/0;for(let i=0;i<n.length;i++){let r=n[i],a=n[(i+1)%n.length],o=a.x-r.x,s=a.y-r.y,u=Math.max(0,Math.min(1,((t.x-r.x)*o+(t.y-r.y)*s)/(o*o+s*s||1)));e=Math.min(e,Math.hypot(t.x-r.x-u*o,t.y-r.y-u*s))}return e}var $o=.02;function qs(t,n){let e=t.objects.filter(i=>i.type==="section"&&!!i.outline&&i.outline.length>=3).flatMap(i=>{let r=n.bySection.get(i.id);if(!r)return[];let a=1/0,o=-1/0,s=1/0,u=-1/0;for(let l of i.outline)l.x<a&&(a=l.x),l.x>o&&(o=l.x),l.y<s&&(s=l.y),l.y>u&&(u=l.y);let c=r.landingY;for(let l of r.rowLevels)c=Math.min(c,l.y-$o);return[{outline:i.outline,holes:i.holes,surface:r,floorTop:c,minX:a,maxX:o,minY:s,maxY:u}]});return(i,r,a)=>{let o=null;for(let s of e){if(i<s.minX-a||i>s.maxX+a||r<s.minY-a||r>s.maxY+a)continue;let u={x:i,y:r};if(!At(u,s.outline,s.holes)&&Zs(u,s.outline)>a)continue;let c=Math.min(s.surface.deckAt(i,r),s.floorTop);(o===null||c<o)&&(o=c)}return o}}var $s=3,Qs=.4;function Qo(t,n,e,i,r,a,o=!0){let s=Ks(n,e,i);if(s.length<$s)return;let u=Me(s,n.focal);if(!u)return;let c=Math.max(0,...u.rings.map(l=>l.arcs.reduce((f,m)=>f+m.binCount,0)))/u.binCount;t.setMaterial(5),zo(t,u,{bottomY:n.baseHeightM,tierFrontLevels:s.map(l=>Math.min(...l.rows.map(f=>f.levelM))),colors:{bandTop:z(r.tierTop,.8),bandWall:r.tierWall,shellTop:a??z(r.tierWall,1.15),shellWall:a??r.tierWall},ao:V,shapes:n.objects.filter(l=>l.type==="shape"),deriveShell:o&&c>=Qs,standTopNear:qs(n,i)}),t.setMaterial(0)}function Jo(t){let{doc:n,units:e,seats:i,surfaces:r,solids:a,hintedSeatFloor:o,seatFloor:s}=t,u=[];{let c=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<a.floor.length;m+=1){let y=Math.max(0,Math.min(e.length-1,Math.round(a.floor[m]))),h=m*3,p=c[y];p.minX=Math.min(p.minX,a.position[h]),p.minY=Math.min(p.minY,a.position[h+1]),p.minZ=Math.min(p.minZ,a.position[h+2]),p.maxX=Math.max(p.maxX,a.position[h]),p.maxY=Math.max(p.maxY,a.position[h+1]),p.maxZ=Math.max(p.maxZ,a.position[h+2])}let l=new Map;for(let m=0;m<e.length;m++)for(let y of e[m].objects)y.type==="section"&&l.set(y.id,m);let f=e.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<i.length;m++){let y=r.seatOwner[m],h=(y!==null?l.get(y):void 0)??o[m];if(h===void 0)continue;let p=f[h],b=i[m];p.n++,b.x<p.minX&&(p.minX=b.x),b.y<p.minY&&(p.minY=b.y),b.x>p.maxX&&(p.maxX=b.x),b.y>p.maxY&&(p.maxY=b.y);let x=r.seatDeckY(m);p.sumX+=b.x*g,p.sumDeck+=x,p.sumZ+=b.y*g,p.minDeck=Math.min(p.minDeck,x),p.maxDeck=Math.max(p.maxDeck,x+1.6),s[m]=h}for(let m=0;m<e.length;m++){let y=f[m],h=n.floors?.[m],p=c[m],b=Math.min(y.n?y.minX*g:e[m].focal.x*g-1,Number.isFinite(p.minX)?p.minX:1/0),x=Math.max(y.n?y.maxX*g:e[m].focal.x*g+1,Number.isFinite(p.maxX)?p.maxX:-1/0),d=Math.min(y.n?y.minY*g:e[m].focal.y*g-1,Number.isFinite(p.minZ)?p.minZ:1/0),M=Math.max(y.n?y.maxY*g:e[m].focal.y*g+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),S=Math.min(y.n?Math.min(e[m].baseHeightM,y.minDeck):e[m].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),A=Math.max(y.n?Math.max(y.maxDeck,S+.5):S+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),R=[y.n?y.sumX/y.n:(b+x)/2,y.n?y.sumDeck/y.n:(S+A)/2,y.n?y.sumZ/y.n:(d+M)/2],w=Math.max(1,.5*Math.hypot(x-b,A-S,M-d));u.push({index:m,id:h?.id??`floor-${m}`,label:h?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:y.n,center:R,radius:w,box:{min:[b,S,d],max:[x,A,M]},focalWorld:[e[m].focal.x*g,e[m].baseHeightM+1.5,e[m].focal.y*g]})}}return u}function te(t){if(t.length<3)return t.map(a=>({...a}));let n=[...t].sort((a,o)=>a.x-o.x||a.y-o.y),e=(a,o,s)=>(o.x-a.x)*(s.y-a.y)-(o.y-a.y)*(s.x-a.x),i=a=>{let o=[];for(let s of a){for(;o.length>=2&&e(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}return o.pop(),o},r=[...i(n),...i([...n].reverse())];return r.length>=3?r.map(a=>({...a})):n.map(a=>({...a}))}function ne(t,n){let e=1/0,i=1/0,r=-1/0,a=-1/0,o=(s,u)=>{s<e&&(e=s),u<i&&(i=u),s>r&&(r=s),u>a&&(a=u)};for(let s of n)o(s.x,s.y);for(let s of t)for(let u of s.objects)if(u.type==="section")for(let c of u.outline)o(c.x,c.y);else if(u.type==="shape"&&u.points)for(let c of u.points)o(c.x,c.y);else if(u.type==="gaArea")for(let c of u.points)o(c.x,c.y);else if(u.type==="booth"){let c=Et(u);if(c)for(let l of c)o(l.x,l.y)}else if(u.type==="table"){let c=_n(u);if(c)for(let l of c)o(l.x,l.y)}else if(u.type==="decorImage"){let c=wn(u);if(c)for(let l of c)o(l.x,l.y)}return Number.isFinite(e)||(e=-100,i=-100,r=100,a=100),{minX:e,minY:i,maxX:r,maxY:a}}function rr(t,n,e,i,r,a,o){if(n.length===1){let s=e.map(m=>({x:m.x,y:m.y}));for(let m of n[0].objects)m.type==="section"?s.push(...m.outline):m.type==="shape"?s.push(...at(m)??m.points??[]):m.type==="gaArea"?s.push(...m.points):m.type==="booth"?s.push(...Et(m)??[]):m.type==="table"?s.push(..._n(m)??[]):m.type==="decorImage"&&s.push(...wn(m)??[]);if(or(t,n[0],e,s,a))return!1;if(o&&nr(t,n[0].baseHeightM,s,a,o))return!0;let u=te(s),c=(r.minX+r.maxX)/2,l=(r.minY+r.maxY)/2,f=u.length>=3?u.map(m=>{let y=m.x-c,h=m.y-l,p=Math.max(1,Math.hypot(y,h));return{x:m.x+y/p*80,y:m.y+h/p*80}}):Jt(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return K(t,f,void 0,()=>-.04,-.22,a.ground,a.ground,V),!1}else{let s=n.reduce((b,x)=>x.baseHeightM<b.baseHeightM?x:b);t.setFloor(s.index);let u={...s,objects:n.flatMap(b=>b.objects)},c=e.map(b=>({x:b.x,y:b.y}));for(let b of u.objects)b.type==="section"&&c.push(...b.outline);if(or(t,u,e,c,a))return!1;if(o&&nr(t,s.baseHeightM,c,a,o))return!0;let l=e.filter((b,x)=>i[x]===s.index),f=ne([s],l),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),y=Math.max(28,Math.min(80,m*.04)),h=Jt(f.minX-y,f.minY-y,f.maxX-f.minX+y*2,f.maxY-f.minY+y*2),p=s.baseHeightM-.03;return K(t,h,void 0,()=>p,p-.22,a.ground,a.ground,V),!1}}function ee(t,n,e,i){let{cx:r,cz:a,radius:o}=e,s=1/0,u=1/0,c=1/0,l=-1/0,f=-1/0,m=-1/0,y=(b,x,d)=>{s=Math.min(s,b),l=Math.max(l,b),u=Math.min(u,x),f=Math.max(f,x),c=Math.min(c,d),m=Math.max(m,d)};for(let b=0;b<t.position.length;b+=3){let x=b/3;i&&x>=i[0]&&x<i[1]||y(t.position[b],t.position[b+1],t.position[b+2])}for(let b=0;b<n.count;b++){let x=b*3,d=n.iPosition[x],M=n.iPosition[x+1],S=n.iPosition[x+2],A=Math.max(.35,n.iMaxRadius[b]??.35);y(d-A,M,S-A),y(d+A,M+1.6,S+A)}Number.isFinite(s)||(s=r-o,l=r+o,u=0,f=o*.16,c=a-o,m=a+o);let h=[(s+l)/2,(u+f)/2,(c+m)/2],p=Math.max(1,.5*Math.hypot(l-s,f-u,m-c));return{center:h,radius:p,minY:u,maxY:f}}function ir(t,n,e,i,r,a){let o=1/0,s=1/0,u=-1/0,c=-1/0;for(let S=0;S<t.count;S++){let A=S*3,R=t.iPosition[A],w=t.iPosition[A+2];R<o&&(o=R),R>u&&(u=R),w<s&&(s=w),w>c&&(c=w)}for(let S of n)o=Math.min(o,S.cx-S.halfX),u=Math.max(u,S.cx+S.halfX),s=Math.min(s,S.cz-S.halfZ),c=Math.max(c,S.cz+S.halfZ);let l=e.minX*g,f=e.maxX*g,m=e.minY*g,y=e.maxY*g,h=l,p=f,b=m,x=y;if(Number.isFinite(o)){let S=Math.max(2,.06*Math.hypot(u-o,c-s));h=Math.max(l,o-S),p=Math.min(f,u+S),b=Math.max(m,s-S),x=Math.min(y,c+S)}let d=Math.min(0,i),M=Math.max(r,a*.05);return{min:[h,d,b],max:[p,M,x]}}var tr=12,Js=.6,ta=40;function nr(t,n,e,i,r){let a=te([...e]);if(a.length<3)return!1;let o=1/0,s=1/0,u=-1/0,c=-1/0;for(let S of a)o=Math.min(o,S.x),u=Math.max(u,S.x),s=Math.min(s,S.y),c=Math.max(c,S.y);let l=Math.hypot(u-o,c-s)*g,f=Mt(a,tr/g,1.2),m=Math.max(ta,l*Js),y=Mt(a,(tr+m)/g,1.2);if(f.length!==y.length)return!1;let h=rt(i.ground,[.78,.76,.72],.35),p=rt(i.ground,[.56,.62,.52],.3);K(t,f,void 0,()=>n-.04,n-.22,h,h,V);let b=n-.05,x=f.map(S=>[S.x*g,b,S.y*g]),d=y.map(S=>[S.x*g,b,S.y*g]),M=[0,1,0];for(let S=0;S<x.length;S++){let A=(S+1)%x.length;t.tri(x[S],d[A],d[S],M,p,r,r),t.tri(x[S],x[A],d[A],M,p,p,r)}return!0}var na=3e3,ea=20,er=1.5,oa=1.2,ra=.25;function or(t,n,e,i,r){if(!e.length||e.length>na||i.length<3)return!1;for(let P of n.objects){if(P.type==="shape"&&ce(P.stageKind))return!1;if(P.type==="section"){let{height:_}=Xt(P,{floorBaseHeightM:n.baseHeightM});if(_-n.baseHeightM>ea)return!1}}let a=0,o=0;for(let P of i)a+=P.x,o+=P.y;a/=i.length,o/=i.length;let s=0,u=0,c=0;for(let P of i){let _=P.x-a,T=P.y-o;s+=_*_,u+=T*T,c+=_*T}let l=.5*Math.atan2(2*c,s-u),f=Math.cos(l),m=Math.sin(l),y=-m,h=f,p=1/0,b=-1/0,x=1/0,d=-1/0;for(let P of i){let _=(P.x-a)*f+(P.y-o)*m,T=(P.x-a)*y+(P.y-o)*h;p=Math.min(p,_),b=Math.max(b,_),x=Math.min(x,T),d=Math.max(d,T)}let M=P=>[[p-P,x-P],[b+P,x-P],[b+P,d+P],[p-P,d+P]].map(([_,T])=>({x:a+f*_+y*T,y:o+m*_+h*T})),S=M(er/g),A=M((er+ra)/g),R=n.baseHeightM,w=rt(r.ground,[.62,.55,.47],.4),I=rt(r.ground,[.86,.86,.84],.55);return K(t,A,void 0,()=>R-.04,R-.22,w,w,V),K(t,A,[S.slice().reverse()],()=>R+oa,R-.04,rt(I,[1,1,1],.2),I,V),!0}function sr(t,n,e){let i=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return i();let r=ie(n);if(!r.ok||r.value.id!==t)return i();let a=new Map;for(let f of e)for(let m of f.objects)m.type==="shape"&&a.set(m.id,{shape:m,unit:f});let o=new Set,s=new Set,u=new Map((n.overlay.productionElements??[]).map(f=>{let m=f.runtimeContentImageUrl;return[f.id,typeof m=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(m)?m:void 0]})),c=[];for(let f of r.value.overlay.productionElements??[]){let m=a.get(f.objectId),y=m?at(m.shape):null,h=f.baseElevationM??0;if(!m||!y||y.length<3||!f.id||o.has(f.id)||s.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(h)||h<-10||h>100)return i();o.add(f.id),s.add(f.objectId);let p=y.map(I=>I.x*g),b=y.map(I=>I.y*g),x=m.unit.baseHeightM+h,d=Math.min(...p),M=Math.max(...p),S=Math.min(...b),A=Math.max(...b),R,w=u.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&w&&(R=so(y,x,x+f.heightM,m.unit.focal),!R))if(M-d>=A-S){let I=Math.abs(S-m.unit.focal.y*g)<=Math.abs(A-m.unit.focal.y*g)?S-.006:A+.006;R=[[d,x,I],[M,x,I],[d,x+f.heightM,I],[M,x+f.heightM,I]]}else{let I=Math.abs(d-m.unit.focal.x*g)<=Math.abs(M-m.unit.focal.x*g)?d-.006:M+.006;R=[[I,x,S],[I,x,A],[I,x+f.heightM,S],[I,x+f.heightM,A]]}c.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:x,topY:x+f.heightM,bounds:{min:[d,x,S],max:[M,x+f.heightM,A]},occlusion:f.occlusion,...w?{contentImageUrl:w}:{},...R?{contentPlane:R}:{}})}let l=c.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(l.map(f=>[f.objectId,f])),elements:l}}var ar=[.13,.14,.17],Kt=[.4,.43,.47],ia=.18,sa=.02,aa=2.4,ca=1500,la=240;function cr(t,n,e,i){let r=n.stageKind??"";if(Ht(r)||r==="round"||!i.length)return;let a=at(n);if(!a||a.length<3)return;let o={x:a.reduce((E,O)=>E+O.x,0)/a.length,y:a.reduce((E,O)=>E+O.y,0)/a.length},s=0,u=0,c=new Set;for(let E of i)s+=E.x,u+=E.y,c.add(Math.floor(Math.atan2(E.y-o.y,E.x-o.x)*180/Math.PI/10));if(c.size*10>la)return;let l=o.x-s/i.length,f=o.y-u/i.length,m=Math.hypot(l,f);if(m<1e-6)return;let y=l/m,h=f/m,p=-h,b=y,x=-1/0,d=1/0,M=1/0,S=-1/0;for(let E of a){let O=(E.x-o.x)*y+(E.y-o.y)*h,D=(E.x-o.x)*p+(E.y-o.y)*b;x=Math.max(x,O),d=Math.min(d,O),M=Math.min(M,D),S=Math.max(S,D)}let A=(S-M)*g,R=(x-d)*g;if(A<3||R<1.5||A*R>ca)return;let w=ia/g,I=(E,O)=>({x:o.x+y*E+p*O,y:o.y+h*E+b*O}),P=(E,O,D,C)=>[I(E,D),I(E,C),I(O,C),I(O,D)],_=e+Math.max(3.5,Math.min(8,A*.35)),T=e+Math.min(aa,_-e-1),k=.2/g,X=d+Math.min(R*.25,1.5)/g,B=sa/g;K(t,P(x-2*w+B,x-w-B,M+w+k,S-w-k),void 0,()=>T,e,ar,ar,V);for(let[E,O]of[[M+w,M+w+k],[S-w-k,S-w]])K(t,P(x-2*w,x-w,E,O),void 0,()=>_+.3,e,Kt,Kt,V),K(t,P(X+k,x-2*w,E,O),void 0,()=>_+.3,_,Kt,Kt,V);K(t,P(X,X+k,M+w,S-w),void 0,()=>_+.3,_,Kt,Kt,V)}function dt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function pt(t){return Array.isArray(t)?t:[]}function ua(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!dt(e))continue;let i=dt(e.extensions)?e.extensions:null;if(i&&Object.prototype.hasOwnProperty.call(i,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function En(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function fa(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function ma(t,n){let e=new Array(16).fill(0);for(let i=0;i<4;i++)for(let r=0;r<4;r++)for(let a=0;a<4;a++)e[i*4+r]+=t[a*4+r]*n[i*4+a];return e}function ha(t){let n=En(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:En(t.translation,3),i=t.rotation===void 0?[0,0,0,1]:En(t.rotation,4),r=t.scale===void 0?[1,1,1]:En(t.scale,3);if(!e||!i||!r)return null;let[a,o,s,u]=i,c=Math.hypot(a,o,s,u);if(!(c>1e-8))return null;let l=a/c,f=o/c,m=s/c,y=u/c,h=l+l,p=f+f,b=m+m,x=l*h,d=l*p,M=l*b,S=f*p,A=f*b,R=m*b,w=y*h,I=y*p,P=y*b;return[(1-(S+R))*r[0],(d+P)*r[0],(M-I)*r[0],0,(d-P)*r[1],(1-(x+R))*r[1],(A+w)*r[1],0,(M+I)*r[2],(A-w)*r[2],(1-(x+S))*r[2],0,e[0],e[1],e[2],1]}function ya(t,n,e,i){return[t[0]*n+t[4]*e+t[8]*i+t[12],t[1]*n+t[5]*e+t[9]*i+t[13],t[2]*n+t[6]*e+t[10]*i+t[14]]}function pa(t){let n=t[0],e=t[4],i=t[8],r=t[1],a=t[5],o=t[9],s=t[2],u=t[6],c=t[10],l=a*c-o*u,f=o*s-r*c,m=r*u-a*s,y=n*l+e*f+i*m;if(Math.abs(y)<1e-12)return null;let h=1/y;return[l*h,f*h,m*h,(i*u-e*c)*h,(n*c-i*s)*h,(e*s-n*u)*h,(e*o-i*a)*h,(i*r-n*o)*h,(n*a-e*r)*h]}function lr(t,n,e,i){let r=t[0]*n+t[1]*e+t[2]*i,a=t[3]*n+t[4]*e+t[5]*i,o=t[6]*n+t[7]*e+t[8]*i,s=Math.hypot(r,a,o)||1;return r/=s,a/=s,o/=s,[r,a,o]}function da(t){if(t.byteLength<20||t.byteLength>8388608)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==t.byteLength)return null;let e=12,i=null,r=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),o=n.getUint32(e+4,!0);if(e+=8,a%4!==0||e+a>t.byteLength)return null;let s=t.subarray(e,e+a);if(o===1313821514&&!i)try{let u=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!dt(u))return null;i=u}catch{return null}else if(o===5130562&&!r)r=s;else return null;e+=a}return e===t.byteLength&&i&&r?{json:i,bin:r}:null}function xa(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function ba(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function ga(t,n,e){return e===5120?t.getInt8(n):e===5121?t.getUint8(n):e===5122?t.getInt16(n,!0):e===5123?t.getUint16(n,!0):e===5125?t.getUint32(n,!0):t.getFloat32(n,!0)}function Ma(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=da(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:i,bin:r}=e;if(!dt(i.asset)||i.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=pt(i.extensionsUsed).filter(S=>typeof S=="string");if(a.includes("KHR_draco_mesh_compression")||ua(i))return{ok:!1,issue:"draco_not_allowed"};if(a.length||pt(i.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(pt(i.images).length||pt(i.textures).length)return{ok:!1,issue:"external_resource"};let o=pt(i.buffers);if(o.length!==1||!dt(o[0])||o[0].uri!==void 0||typeof o[0].byteLength!="number"||!Number.isInteger(o[0].byteLength)||o[0].byteLength<0||o[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let s=pt(i.accessors),u=pt(i.bufferViews),c=pt(i.meshes),l=pt(i.nodes),f=pt(i.scenes),m=typeof i.scene=="number"?i.scene:0;if(!dt(f[m]))return{ok:!1,issue:"unsupported_glb"};let y=new DataView(r.buffer,r.byteOffset,r.byteLength),h=(S,A,R)=>{if(typeof S!="number"||!Number.isInteger(S)||!dt(s[S]))return null;let w=s[S];if(w.type!==A||w.sparse!==void 0||w.normalized===!0||typeof w.count!="number"||!Number.isInteger(w.count)||w.count<1||typeof w.componentType!="number"||!R.includes(w.componentType)||typeof w.bufferView!="number")return null;let I=u[w.bufferView];if(!dt(I)||I.buffer!==0||typeof I.byteLength!="number"||!Number.isInteger(I.byteLength)||I.byteLength<0)return null;let P=ba(w.type),_=xa(w.componentType),T=typeof I.byteStride=="number"?I.byteStride:P*_,k=typeof I.byteOffset=="number"?I.byteOffset:0,X=typeof w.byteOffset=="number"?w.byteOffset:0,B=k+X,E=X+(w.count-1)*T+P*_;if(!Number.isInteger(T)||!Number.isInteger(k)||!Number.isInteger(X)||T<P*_||k<0||X<0||k+I.byteLength>r.byteLength||E>I.byteLength)return null;let O=[];for(let D=0;D<w.count;D++){let C=[];for(let F=0;F<P;F++){let v=ga(y,B+D*T+F*_,w.componentType);if(!Number.isFinite(v))return null;C.push(v)}O.push(C)}return O},p=[],b=[],x=0,d=new Set,M=(S,A)=>{if(typeof S!="number"||!Number.isInteger(S)||!dt(l[S])||d.has(S))return!1;d.add(S);let R=l[S],w=ha(R);if(!w)return!1;let I=ma(A,w),P=pa(I);if(!P)return!1;if(R.mesh!==void 0){if(typeof R.mesh!="number")return!1;let _=c[R.mesh];if(!dt(_))return!1;for(let T of pt(_.primitives)){if(!dt(T)||T.mode!==void 0&&T.mode!==4||!dt(T.attributes))return!1;let k=h(T.attributes.POSITION,"VEC3",[5126]),X=T.attributes.NORMAL===void 0?null:h(T.attributes.NORMAL,"VEC3",[5126]);if(!k||T.attributes.NORMAL!==void 0&&!X)return!1;let B=k.length;if(T.indices!==void 0){let O=typeof T.indices=="number"?s[T.indices]:null;B=dt(O)?O.count:void 0}if(typeof B!="number"||!Number.isInteger(B)||B%3!==0||(x+=B/3,x>1e5))return!1;let E=T.indices===void 0?k.map((O,D)=>[D]):h(T.indices,"SCALAR",[5121,5123,5125]);if(!E||E.length%3!==0||E.length!==B)return!1;for(let O=0;O<E.length;O+=3){let D=[E[O][0],E[O+1][0],E[O+2][0]];if(D.some(v=>!Number.isInteger(v)||v<0||v>=k.length))return!1;let C=D.map(v=>ya(I,...k[v])),F=null;if(!X){let v=C[1][0]-C[0][0],G=C[1][1]-C[0][1],j=C[1][2]-C[0][2],U=C[2][0]-C[0][0],H=C[2][1]-C[0][1],W=C[2][2]-C[0][2];F=lr([1,0,0,0,1,0,0,0,1],G*W-j*H,j*U-v*W,v*H-G*U)}for(let v=0;v<3;v++)p.push(...C[v]),b.push(...X?lr(P,...X[D[v]]):F)}}}for(let _ of pt(R.children))if(!M(_,I))return!1;return d.delete(S),!0};for(let S of pt(f[m].nodes))if(!M(S,fa()))return{ok:!1,issue:x>1e5?"triangle_limit":"unsupported_glb"};return!x||p.length!==x*9||b.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:x,position:new Float32Array(p),normal:new Float32Array(b)}}function ur(t){try{return Ma(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function Yf(t){let{doc:n}=t,e=Go(n.theme),i=e.structure,r=ze(n,t.eventConfigurationId??n.eventConfigurationId),a=sr(t.eventConfigurationId,t.eventConfiguration,r),o=t.seats,s=new hn,u=null;if(t.registeredShellGlb){let N=ur(t.registeredShellGlb);if(N.ok){let L=N.position.length/3,Z=new Float32Array(N.position.length),J=e.materials.shell??i.tierWall;for(let q=0;q<L;q++){let ct=N.normal[q*3+1],it=ct<-.25?.4:.62+.38*Math.max(0,ct);Z[q*3]=J[0]*it,Z[q*3+1]=J[1]*it,Z[q*3+2]=J[2]*it}u={position:N.position,normal:N.normal,color:Z,floor:new Float32Array(L).fill(-2),material:new Float32Array(L),count:L}}}let c=new Map;for(let N of r)for(let L of N.objects)c.set(L.id,N.index),L.type==="section"&&c.set(L.logicalSectionId??L.id,N.index);let l=o.map(N=>c.get(N.sectionId??"")??c.get(N.rowId??"")??0),f=ne(r,o),m=s.vertexCount,h=rr(s,r,o,l,f,i,rt(e.background.top,e.background.bottom,.5))?s.vertexCount:m,p=Oe(n,o),b=new Map,x=new Map;for(let N of n.categories??[])b.set(N.key,N.color),N.seatGlyph&&x.set(N.key,N.seatGlyph);let d=[],M=mo(r,o,l),S=new Map;o.forEach((N,L)=>{let Z=M.seatDeckY(L);Number.isFinite(Z)&&S.set(N.rowId,Math.min(S.get(N.rowId)??1/0,Z))});let A=new Float32Array(o.length),R=[],w=new Map((n.floors??[]).map((N,L)=>[N.id,L])),I=r.map(()=>[]);for(let N of o){let L=N.floorId?w.get(N.floorId)??0:0;I[Math.min(L,I.length-1)]?.push(N)}let P=(N,L)=>{if(!L||L.length<3)return!1;let Z=Math.min(...L.map(it=>it.x)),J=Math.max(...L.map(it=>it.x)),q=Math.min(...L.map(it=>it.y)),ct=Math.max(...L.map(it=>it.y));for(let it=0;it<N;it++)for(let Y of I[it])if(!(Y.x<Z||Y.x>J||Y.y<q||Y.y>ct)&&At(Y,L,void 0))return!0;return!1},_=null,T=N=>r.length===1?o:o.filter((L,Z)=>l[Z]===N),k=(N,L)=>{let Z=Et(N);if(!Z)return!1;let J=1/0,q=1/0,ct=-1/0,it=-1/0;for(let Y of Z)J=Math.min(J,Y.x),ct=Math.max(ct,Y.x),q=Math.min(q,Y.y),it=Math.max(it,Y.y);return o.some((Y,lt)=>Y.kind!=="booth"&&(r.length===1||l[lt]===L)&&Y.x>J&&Y.x<ct&&Y.y>q&&Y.y<it&&ht(Z,Y.x,Y.y))};for(let N=0;N<r.length;N++){let L=r[N];s.setFloor(N);let Z=new xn,J=[],q=L.objects.filter(Y=>Y.type==="shape"&&(Y.role==="entrance"||Y.role==="exit")),ct=L.objects.filter(Y=>Y.type==="section"&&!!Y.outline&&Y.outline.length>=3),it=Ho(L.objects.filter(Y=>Y.type==="booth"),L.focal);for(let Y of L.objects)if(Y.type==="section"){let lt=s.vertexCount;qo(s,Y,L,ke(Y,p),M.bySection.get(Y.id),Z,ct,i,N>0&&P(N,Y.outline));let Pt=s.vertexCount-lt;Pt>0&&R.push({sectionId:Y.id,start:lt,count:Pt})}else if(Y.type==="shape"){let lt=a.byObjectId.get(Y.id),Pt=d.length;s.setMaterial((lt?.kind??Y.role)==="screen"?1:0);let It=Y.role==="stage"&&!lt?jo(Y,T(N)):Y,Rt=qe(It,J);if(Bo(s,It,L.baseHeightM+Rt.supportOffsetM,Rt.topOffsetM-Rt.supportOffsetM,i,L.focal,d,lt,q),s.setMaterial(0),Y.role==="stage"&&!lt&&d.length>Pt&&(_??N)===N){_=N;let gt=n.floors?.[N]?.id,ft=r.length>1&&gt?o.filter(Nt=>Nt.floorId===gt):o;cr(s,It,d[d.length-1].y,ft)}}else Y.type==="gaArea"?Co(s,Y,L.baseHeightM,ot(b.get(Y.categoryKey)),i):Y.type==="booth"?_o(s,Y,L.baseHeightM,ot(b.get(Y.categoryKey)),i,it.get(Y.id)??L.focal,k(Y,N)):Y.type==="table"?Eo(s,Y,Math.max(L.baseHeightM,S.get(Y.id)??L.baseHeightM),ot(Y.fill??n.theme?.decorFill??"#232c40"),i,!!(Y.fill??n.theme?.decorFill)):Y.type==="decorImage"&&To(s,Y,L.baseHeightM,i);Qo(s,L,o,M,i,e.materials.shell,!u)}let X=r.length>1?{x:r.reduce((N,L)=>N+L.focal.x,0)/r.length,y:r.reduce((N,L)=>N+L.focal.y,0)/r.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},B=Ae(u?[s.build(),u]:[s.build()]),E=Te(o,t.initialState,M,A,b,x),O=Fo({doc:n,units:r,seats:o,surfaces:M,focal:X}),{labels:D,sections:C,rows:F}=vo({doc:n,units:r,seats:o,surfaces:M,seatData:E,hintedSeatFloor:l,zones:O,focal:X}),v=new Map(C.map((N,L)=>[N.id,L]));M.seatOwner.forEach((N,L)=>{E.iSection[L]=N?v.get(N)??-1:-1});let G=Jo({doc:n,units:r,seats:o,surfaces:M,solids:B,hintedSeatFloor:l,seatFloor:A});Do(D,G),E.iYaw=Be(E.iPosition,o.length,N=>o[N].rowId,N=>{let L=r[A[N]]?.focal??X;return[L.x*g,L.y*g]});let j=(f.minX+f.maxX)/2*g,U=(f.minY+f.maxY)/2*g,H=.5*Math.hypot((f.maxX-f.minX)*g,(f.maxY-f.minY)*g)||10,W=ee(B,E,{cx:j,cz:U,radius:H},[m,h]),nt=ee(B,E,{cx:j,cz:U,radius:H}),$=ir(E,d,f,W.minY,W.maxY,H);return{sharedAisles:Lo(r.flatMap(N=>N.objects.flatMap(L=>{if(L.type!=="section")return[];let Z=M.bySection.get(L.id);return Z?[{sectionId:L.id,floorIndex:N.index,rows:Z.rowLevels}]:[]}))),solids:B,sectionSolidRanges:R,seats:E,seatSectionIds:M.seatOwner,bounds:{center:[($.min[0]+$.max[0])/2,($.min[1]+$.max[1])/2,($.min[2]+$.max[2])/2],radius:H,groundY:0,box:$},renderBounds:{center:W.center,radius:W.radius},clipBounds:{center:nt.center,radius:nt.radius},stateColorLUT:No(e,tn),theme:e,seatCount:o.length,focalWorld:[X.x*g,1.5,X.y*g],zones:O,stages:d,productionElements:a.elements,sections:C,rows:F,labels:D,floors:G}}function Sa(t,n){let{doc:e,report:i}=io(t),r=i.confident&&(i.sections.length>0||!!i.looseRowBlocks);if(!r&&!i.roles?.length)return null;if(!r){let u=new Map(i.roles.map(y=>[y.id,y.role])),c=y=>y.map(h=>h.type==="shape"&&u.has(h.id)?{...h,role:u.get(h.id)}:h),l=t.floors?.map(y=>({...y,objects:c(y.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((y,h)=>{y.eyeHeightM!==void 0&&(f[h]=y.eyeHeightM),y.focalPoint&&(m[h*2]=y.focalPoint.x,m[h*2+1]=y.focalPoint.y)}),{doc:{...t,objects:l?.[0]?.objects??c(t.objects),...l?{floors:l}:{}},report:i,eyeHeightM:f,focal:m}}let a=new Map(un(e).map(u=>[u.id,u])),o=new Float64Array(n.length).fill(Number.NaN),s=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((u,c)=>{let l=a.get(u.id)??u;l.eyeHeightM!==void 0&&(o[c]=l.eyeHeightM),l.focalPoint&&(s[c*2]=l.focalPoint.x,s[c*2+1]=l.focalPoint.y)}),{doc:e,report:i,eyeHeightM:o,focal:s}}function Pa(t,n){return t.map((e,i)=>{let r=n.eyeHeightM[i],a=n.focal[i*2],o=n.focal[i*2+1],s={...e};return Number.isNaN(r)?delete s.eyeHeightM:s.eyeHeightM=r,Number.isNaN(a)?delete s.focalPoint:s.focalPoint={x:a,y:o},s})}function Kf(t){let n=t.estimate===!1?null:Sa(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:Pa(t.seats,n)},estimate:n}:{input:t}}export{Oa as a,Rr as b,Ar as c,we as d,_r as e,ka as f,tn as g,On as h,Ta as i,Fn as j,g as k,pn as l,ja as m,Ua as n,io as o,Ic as p,Rc as q,Ac as r,_c as s,wc as t,Ec as u,Yn as v,Bc as w,Tc as x,Cc as y,Oc as z,kc as A,Rs as B,Yf as C,Sa as D,Pa as E,Kf as F};