@seatlayer/core 0.72.0 → 0.72.1

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{a as Pn,c as An,d as In}from"./chunk-KPSJDH3N.js";import{c as bn}from"./chunk-ALE2T36W.js";import{d as Rn}from"./chunk-BLPBTW6I.js";import{f as hn,p as xn,r as Xt,s as ft,u as It,x as Sn}from"./chunk-YW2WGLRM.js";import{e as gn,k as Mn}from"./chunk-UL5OIGIF.js";import{W as ut,X as lt,ea as Gt,ga as dn,ha as Dt,ja as yn,l as pn,m as Pt,va as qt}from"./chunk-KCFEFP6H.js";import{A as At,d as H,y as nt}from"./chunk-JBOTRSMY.js";import Re from"earcut";import Pe from"polygon-clipping";var g=ut,Ae=.002;function Ie(t,n,e){let i=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=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]),r=Math.max(i,o,a);if(r<1e-9)return!0;let s=(i+o+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-o)*(s-a)))/r<Ae}var ht=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)}},Yt=class{constructor(){this.pos=new ht;this.nor=new ht;this.col=new ht;this.flr=new ht;this.mat=new ht;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,i,o,a,r=a,s=a){Ie(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(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(r[0],r[1],r[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,o,a,r,s,l=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(o[0],o[1],o[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function we(t,n,e){let i=n[0]-t[0],o=n[1]-t[1],a=n[2]-t[2],r=e[0]-t[0],s=e[1]-t[1],l=e[2]-t[2],c=o*l-a*s,f=a*r-i*l,m=i*s-o*r,u=Math.hypot(c,f,m)||1;return c/=u,f/=u,m/=u,[c,f,m]}function Te(t,n){let e=[...t],i=[];for(let r of t)i.push(r.x,r.y);let o=[];if(n){for(let r of n)if(!(r.length<3)){o.push(e.length);for(let s of r)e.push(s),i.push(s.x,s.y)}}let a=Re(i,o.length?o:void 0,2);return{pts:e,tris:a}}function Jt(t){return ft(t)<0?[...t].reverse():t}var _e=3;function Be(t,n,e,i){let o=i(t),a=i(n),r=i(e),s=(h,b,p,y)=>Math.abs(i({x:(h.x+b.x)/2,y:(h.y+b.y)/2})-(p+y)/2),l=(t.x+n.x+e.x)/3,c=(t.y+n.y+e.y)/3,f=(o+a+r)/3,m=Math.max(s(t,n,o,a),s(n,e,a,r),s(e,t,r,o),Math.abs(i({x:l,y:c})-f)),u=(h,b,p)=>{let y=Math.abs(i({x:(h+l)/2,y:(b+c)/2})-(p+f)/2);y>m&&(m=y)};return u((t.x+n.x)/2,(t.y+n.y)/2,(o+a)/2),u((n.x+e.x)/2,(n.y+e.y)/2,(a+r)/2),u((e.x+t.x)/2,(e.y+t.y)/2,(r+o)/2),m}function wt(t,n,e,i,o){if(o<=0)return Be(t,n,e,i);let a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},r={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(wt(t,a,s,i,o-1),wt(a,n,r,i,o-1),wt(s,r,e,i,o-1),wt(a,r,s,i,o-1))}function Tt(t,n,e,i,o,a,r,s){if(r>0){let u={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+i.x)/2,y:(e.y+i.y)/2},b={x:(i.x+n.x)/2,y:(i.y+n.y)/2};Tt(t,n,u,b,o,a,r-1,s),Tt(t,u,e,h,o,a,r-1,s),Tt(t,b,h,i,o,a,r-1,s),Tt(t,u,h,b,o,a,r-1,s);return}let l=[n.x*g,o(n),n.y*g],c=[e.x*g,o(e),e.y*g],f=[i.x*g,o(i),i.y*g];if(s){t.triN(l,c,f,s(n),s(e),s(i),a);return}let m=we(l,c,f);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,f,m,a)}var Fe=8;function wn(t,n,e){if(!Number.isFinite(e))return t;let i=[],o=(a,r,s,l,c)=>{if(c>0){let f={x:(a.x+r.x)/2,y:(a.y+r.y)/2},m=n(f);if(Math.abs(m-(s+l)/2)>e){o(a,f,s,m,c-1),o(f,r,m,l,c-1);return}}i.push(a)};for(let a=0;a<t.length;a++){let r=t[a],s=t[(a+1)%t.length];o(r,s,n(r),n(s),Fe)}return i}function Nt(t,n){if(t.length<3)return t;let e=[];for(let o of t){let a=e[e.length-1];a&&Math.hypot(o.x-a.x,o.y-a.y)<n||e.push(o)}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 o=0;o<e.length;o++){let a=i.length?i[i.length-1]:e[(o-1+e.length)%e.length],r=e[o],s=e[(o+1)%e.length],l=s.x-a.x,c=s.y-a.y,f=Math.hypot(l,c);f>n&&Math.abs((r.x-a.x)*c-(r.y-a.y)*l)/f<n||i.push(r)}return i.length>=3?i:e}var Ut=.001*lt*.1;function K(t,n,e,i,o,a,r,s,l=1/0,c){if(!n||n.length<3||(l===void 0&&(l=1/0),Math.abs(ft(n))<1e-4))return;let f=Nt(wn(Nt(Jt(n),Ut),i,l),Ut),m=e?.map(P=>Nt(wn(Nt(Jt(P),Ut),i,l),Ut)).filter(P=>P.length>=3&&Math.abs(ft(P))>=1e-4),{pts:u,tris:h}=Te(f,m),b=[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],y=[r[0]*s.top,r[1]*s.top,r[2]*s.top],d=[r[0]*s.wallBottom,r[1]*s.wallBottom,r[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<_e;x++){let P=0;for(let A=0;A<h.length;A+=3){let E=wt(u[h[A]],u[h[A+1]],u[h[A+2]],i,x);E>P&&(P=E)}if(P<=l)break}for(let P=0;P<h.length;P+=3){let A=u[h[P]],E=u[h[P+1]],v=u[h[P+2]];Tt(t,A,E,v,i,b,x,c);let G=[A.x*g,o,A.y*g],X=[E.x*g,o,E.y*g],M=[v.x*g,o,v.y*g];t.tri(G,M,X,[0,-1,0],p)}let T=P=>{if(x<=0)return P;let A=1<<x,E=[];for(let v=0;v<P.length;v++){let G=P[v],X=P[(v+1)%P.length];for(let M=0;M<A;M++){let B=M/A;E.push({x:G.x+(X.x-G.x)*B,y:G.y+(X.y-G.y)*B})}}return E},S=pn(f),C=[{ring:T(f),flip:!1}];if(m)for(let P of m)P.length>=3&&C.push({ring:T(P),flip:!0});for(let{ring:P,flip:A}of C)for(let E=0;E<P.length;E++){let v=P[E],G=P[(E+1)%P.length],X=(G.x-v.x)*g,B=(G.y-v.y)*g,O=-X,F=Math.hypot(B,O)||1;B/=F,O/=F;let I=(v.x+G.x)/2-S.x,k=(v.y+G.y)/2-S.y,R=B*I+O*k;A&&(R=-R),R<0&&(B=-B,O=-O);let _=[B,0,O],w=[v.x*g,i(v),v.y*g],D=[G.x*g,i(G),G.y*g],N=[v.x*g,o,v.y*g],U=[G.x*g,o,G.y*g];t.tri(w,D,U,_,y,y,d),t.tri(w,U,N,_,y,d,d)}}function Tn(t){let n=0;for(let l of t)n+=l.count;let e=new Float32Array(n*3),i=new Float32Array(n*3),o=new Float32Array(n*3),a=new Float32Array(n),r=new Float32Array(n),s=0;for(let l of t)e.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),a.set(l.floor,s),r.set(l.material,s),s+=l.count;return{position:e,normal:i,color:o,floor:a,material:r,count:n}}function jt(t,n,e=2.5){if(n<=0||t.length<3)return t;let i=Jt(t),o=i.length,a=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],f=c.x-l.x,m=c.y-l.y,u=Math.hypot(f,m)||1;a.push({x:m/u,y:-f/u})}let r=[];for(let s=0;s<o;s++){let l=i[s],c=a[(s-1+o)%o],f=a[s],m=c.x+f.x,u=c.y+f.y,h=Math.hypot(m,u),b=()=>{r.push([l.x+c.x*n,l.y+c.y*n]),r.push([l.x+f.x*n,l.y+f.y*n])};if(h<1e-9){b();continue}m/=h,u/=h;let p=m*c.x+u*c.y,y=1/Math.max(p,1e-6);if(!Number.isFinite(y)||y>e){b();continue}r.push([l.x+m*n*y,l.y+u*n*y])}if(r.length<3)return t;try{let s=Pe.union([[...r,r[0]]]),l=null,c=-1/0;for(let m of s){let u=Math.abs(ft(m[0].map(([h,b])=>({x:h,y:b}))));u>c&&(c=u,l=m[0])}if(!l)return t;let f=l.map(([m,u])=>({x:m,y:u}));if(f.length>1){let m=f[0],u=f[f.length-1];Math.abs(m.x-u.x)<1e-9&&Math.abs(m.y-u.y)<1e-9&&f.pop()}return f.length>=3?f:t}catch{return t}}function Ht(t,n,e,i,o=28){let a=[];for(let r=0;r<o;r++){let s=r/o*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+i*Math.sin(s)})}return a}function _t(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 Bt=["available","held","sold","selected","dimmed"];function Qt(t){let n=Bt.indexOf(t);return n<0?0:n}var _n={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function rr(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.42,i=.62;return[(n+(t[0]-n)*e)*i,(n+(t[1]-n)*e)*i,(n+(t[2]-n)*e)*i]}var tn={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]},nn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function et(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}var V={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Ee=.44,Ce=.15,ve=.3,ke=.24;function Bn(t){return t===void 0||!Number.isFinite(t)||t<=0?ke:Math.min(ve,Math.max(Ce,t*Ee))}var sr=.21,Oe=.05,en=.45,Le=en+Oe,Ge=[{part:V.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:V.pad,min:[-1,.36,-.95],max:[1,en,1]},{part:V.back,min:[-1,Le,-1],max:[1,.92,-.72]},{part:V.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:V.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:V.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:V.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:V.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:V.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:V.leg,min:[.62,0,.48],max:[.82,.37,.7]}],De=[{part:V.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:V.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:V.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:V.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:V.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Xe=[{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 ar(){let t=[],n=[],e=[],i=[],o=(F,I,k)=>{let R=e.length,[_,w,D]=F,N=[w[0]-_[0],w[1]-_[1],w[2]-_[2]],U=[D[0]-_[0],D[1]-_[1],D[2]-_[2]],L=N[1]*U[2]-N[2]*U[1],Y=N[2]*U[0]-N[0]*U[2],j=N[0]*U[1]-N[1]*U[0],$=Math.hypot(L,Y,j);$>1e-9?(L/=$,Y/=$,j/=$):[L,Y,j]=I,L*I[0]+Y*I[1]+j*I[2]<0&&(L=-L,Y=-Y,j=-j);for(let z of F)t.push(...z),n.push(L,Y,j),e.push(k);i.push(R,R+1,R+2,R,R+2,R+3)},a=F=>{for(let I of Xe){let k=I.c.map(R=>R.map((_,w)=>_?F.max[w]:F.min[w]));o(k,I.n,F.part)}};for(let F of Ge)a(F);for(let F of De)a(F);let r=en,s=1.08,l=.47,c=.69,f=-.55,m=.08,u=-.48,h=.01,b=[-l,r,f],p=[l,r,f],y=[-l,r,m],d=[l,r,m],x=[-c,s,u],T=[c,s,u],S=[-c,s,h],C=[c,s,h];o([p,T,C,d],[1,0,0],V.body),o([y,S,x,b],[-1,0,0],V.body),o([S,C,T,x],[0,1,0],V.body),o([b,p,d,y],[0,-1,0],V.body),o([d,C,S,y],[0,0,1],V.body),o([b,x,T,p],[0,0,-1],V.body);let P=10,A=8,E=[0,1.205,-.23],v=[.42,.115,.38],G=e.length;for(let F=0;F<=A;F++){let I=Math.PI*F/A,k=Math.cos(I),R=Math.sin(I);for(let _=0;_<=P;_++){let w=Math.PI*2*_/P,D=R*Math.cos(w),N=R*Math.sin(w);t.push(E[0]+v[0]*D,E[1]+v[1]*k,E[2]+v[2]*N);let U=D/v[0],L=k/v[1],Y=N/v[2],j=Math.hypot(U,L,Y)||1;U/=j,L/=j,Y/=j,n.push(U,L,Y),e.push(V.head)}}for(let F=0;F<A;F++)for(let I=0;I<P;I++){let k=G+F*(P+1)+I,R=k+P+1;i.push(k,R,k+1,k+1,R,R+1)}let X=new Float32Array(t),M=new Float32Array(n),B=new Float32Array(e),O=new Uint16Array(i);return{position:X,normal:M,part:B,index:O,vertexCount:e.length,indexCount:i.length}}function Fn(t,n,e,i){let o=new Float32Array(n),a=c=>t[c*3],r=c=>t[c*3+2],s=0,l=(c,f)=>{let m=f-c;for(let u=c;u<f;u++){let[h,b]=i(u),p=h-a(u),y=b-r(u);if(m>=2){let d=Math.max(c,u-1),x=Math.min(f-1,u+1),T=a(x)-a(d),S=r(x)-r(d),C=Math.hypot(T,S);if(C>1e-6){let P=-S/C,A=T/C;P*p+A*y<0&&(P=-P,A=-A),p=P,y=A}}o[u]=p===0&&y===0?0:Math.atan2(p,y)}};for(let c=1;c<=n;c++)(c===n||e(c)!==e(s))&&(l(s,c),s=c);return o}var Vt=.22;function dr(t,n){let e=Bt[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 Ne=.42;function Ue(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let i=1/0,o=1/0,a=-1/0,r=-1/0;for(let b of t)b.x<i&&(i=b.x),b.y<o&&(o=b.y),b.x>a&&(a=b.x),b.y>r&&(r=b.y);let s=Math.max(a-i,1e-6),l=Math.max(r-o,1e-6),c=Math.max(Math.sqrt(s*l/n),1e-6),f=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),u=new Map,h=(b,p)=>{let y=Math.min(f-1,Math.max(0,Math.floor((b-i)/c)));return Math.min(m-1,Math.max(0,Math.floor((p-o)/c)))*f+y};for(let b=0;b<n;b++){let p=h(t[b].x,t[b].y),y=u.get(p);y?y.push(b):u.set(p,[b])}for(let b=0;b<n;b++){let p=t[b],y=Math.min(f-1,Math.max(0,Math.floor((p.x-i)/c))),d=Math.min(m-1,Math.max(0,Math.floor((p.y-o)/c))),x=1/0;for(let T=1;T<=4;T++){for(let S=d-T;S<=d+T;S++)if(!(S<0||S>=m))for(let C=y-T;C<=y+T;C++){if(C<0||C>=f||T>1&&Math.abs(S-d)<T&&Math.abs(C-y)<T)continue;let P=u.get(S*f+C);if(P)for(let A of P){if(A===b)continue;let E=Math.hypot(t[A].x-p.x,t[A].y-p.y);E<x&&(x=E)}}if(Number.isFinite(x)&&x<=T*c)break}e[b]=x}return e}function Ye(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-Gt):0}function En(t,n,e,i,o,a){let r=t.length,s=new Float32Array(r*3),l=new Float32Array(r),c=new Float32Array(r*3),f=new Float32Array(r),m=new Float32Array(r),u=new Float32Array(r),h=new Float32Array(r),b=new Float32Array(r*3),p=new Map,y=Ue(t);for(let d=0;d<r;d++){let x=t[d],S=(e?.seatPitchU(d)??y[d])*g;f[d]=Number.isFinite(S)?Math.max(.06,Math.min(Vt,S*Ne)):Vt,m[d]=Bn(Number.isFinite(S)?S:void 0);let C=Mn(x.glyph,{seatGlyph:a?.get(x.categoryKey)});u[d]=gn.indexOf(C),h[d]=x.wheelchairSpaceType==="no-seat"?0:1,s[d*3]=x.x*g,s[d*3+1]=e?e.seatDeckY(d):Ye(x),s[d*3+2]=x.y*g,l[d]=Qt(n?n(x):"available");let P=H(o?.get(x.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[d*3]=P[0],c[d*3+1]=P[1],c[d*3+2]=P[2],x.accessibility?.length){let A=H(hn(x.accessibility));A&&(b[d*3]=A[0],b[d*3+1]=A[1],b[d*3+2]=A[2])}p.set(x.id,d)}return{count:r,iPosition:s,iState:l,iCategory:c,iMaxRadius:f,iRing:b,idToIndex:p,iChairWidth:m,iGlyph:u,iPhysicalSeat:h,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var je=64;function yr(t,n){let e=[];for(let r of n){let s=t.idToIndex.get(r.seatId);if(s===void 0)continue;let l=Qt(r.state);t.iState[s]!==l&&(t.iState[s]=l,e.push(s))}if(!e.length)return[];e.sort((r,s)=>r-s);let i=[],o=e[0],a=e[0];for(let r=1;r<e.length;r++){let s=e[r];if(s!==a){if(s<=a+je){a=s;continue}i.push({start:o,length:a-o+1}),o=s,a=s}}return i.push({start:o,length:a-o+1}),i}function Mr(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 Sr(t,n){let e=[...t].sort((o,a)=>o.screen.y-a.screen.y),i=[];for(let o of e){let a=i.find(r=>r.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));a?a.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((a,r)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(r-(o.length-1)/2)*104))}})))}var He=1.15,Ve=2.75,We=4.5,ze=.85,Ze=.5,Ke=.26;function Rr(t,n,e){let i=Math.max(1e-6,n),o=t/i,a=e?.hasZoneLabels??!0,r=new Set;return o>=.75&&r.add("floor"),o>=He&&r.add("zone"),o<=(a?Ve:We)&&(r.add("section"),r.add("ga")),o<=ze&&(r.add("annotation"),r.add("booth")),o<=Ze&&r.add("row"),o<=Ke&&r.add("seat"),r}function Pr(t,n,e,i,o,a=6){let r=a+n,s=i-a-n,l=a+e,c=o-a-e;return{...t,x:r>s?i/2:Math.max(r,Math.min(s,t.x)),y:l>c?o/2:Math.max(l,Math.min(c,t.y))}}function Ar(t,n,e,i){let o=t,a=n[0],r=n[1],s=n[2],l=o[0]*a+o[4]*r+o[8]*s+o[12],c=o[1]*a+o[5]*r+o[9]*s+o[13],f=o[2]*a+o[6]*r+o[10]*s+o[14],m=o[3]*a+o[7]*r+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let u=l/m,h=c/m,b=f/m,p=u>=-1.05&&u<=1.05&&h>=-1.05&&h<=1.05&&b<=1;return{x:(u*.5+.5)*e,y:(1-(h*.5+.5))*i,depth:b,visible:p}}function Ir(t,n,e=n){let i=[],o=[...t].sort((a,r)=>a.screen.depth-r.screen.depth);for(let a of o){let r=!1;for(let s of i)if(on(a,s,n,e)){r=!0;break}r||i.push(a)}return i}var $e=6;function on(t,n,e,i){let o=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),r=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+$e):e;return o<r&&a<i}function wr(t,n,e){return t.length*n*.58+(e?14:0)}var qe={row:8,seat:14};function Tr(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:qe}function _r(t,n,e,i){let o=Math.max(1,Math.min(e,i)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-i/2)/o);return n*(1+1.5*a)}function Br(t,n,e,i,o=[]){let a=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),r=[];for(let s of a){if(r.length>=i)break;let l=!1;for(let c of o)if(on(s,c,n,e)){l=!0;break}if(!l){for(let c of r)if(on(s,c,n,e)){l=!0;break}}l||r.push(s)}return r}var Je=.15,Qe=.9,to=1.76;function no(){return{background:{top:[...nn.top],bottom:[...nn.bottom]},structure:tn,seatStates:{..._n},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function Cn(t){let n=no();if(!t)return n;let e=H(t.background);if(e){n.background={top:et(e,Qe),bottom:et(e,to)};let r={};for(let[s,l]of Object.entries(tn))r[s]=nt(l,e,Je);n.structure=r}let i=H(t.selectionColor)??H(t.accent);i&&(n.seatStates={...n.seatStates,selected:i});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=Sn(o));let a=t.venue3d;if(a){let r=H(a.deck),s=H(a.fascia);r&&(n.structure={...n.structure,tierTop:r,gaTop:r}),s&&(n.structure={...n.structure,tierWall:s,gaWall:s}),n.materials.seat=H(a.seat),n.materials.shell=H(a.shell),typeof a.roughness=="number"&&Number.isFinite(a.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,a.roughness)))}return n}function vn(t,n){let e=[];for(let i of n)e.push(...t.seatStates[i]);return e}import Gn from"polygon-clipping";import eo from"earcut";var oo=.58,kn=.01,ot=Vt*1.5*lt,ro=.5,io=.6;function so(t,n){let e=t.length,i=[];for(let r=0;r<e;r++){let s=t[Math.max(0,r-1)],l=t[Math.min(e-1,r+1)],c=l.x-s.x,f=l.y-s.y,m=Math.hypot(c,f);if(m<1e-9){i.push([0,0]);continue}c/=m,f/=m,i.push([-f,c])}let o=0;for(let r=0;r<e;r++)o+=(t[r].x-n.x)*i[r][0]+(t[r].y-n.y)*i[r][1];return o<0?i.map(([r,s])=>[-r,-s]):i}function ao(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],i=(r,s)=>{let l=s.x-r.x,c=s.y-r.y,f=Math.hypot(l,c)||1;return{x:l/f,y:c/f}},o=i(e[1],e[0]),a=i(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var On=Math.PI/12;function co(t){if(t.length<3)return[...t];let n=[...t].sort((a,r)=>a.x-r.x||a.y-r.y),e=(a,r,s)=>(r.x-a.x)*(s.y-a.y)-(r.y-a.y)*(s.x-a.x),i=a=>{let r=[];for(let s of a){for(;r.length>=2&&e(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return r.pop(),r},o=[...i(n),...i([...n].reverse())];return o.length>=3?o:[...t]}function Dn(t,n){if(!t.length||!(n>0))return[];let e=co(t),i=(s,l,c,f)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let u=Math.max(1,Math.ceil(m/On)),h=n/Math.cos(m/u/2);for(let b=0;b<=u;b++){let p=l+m*b/u;f.push({x:s.x+Math.cos(p)*h,y:s.y+Math.sin(p)*h})}};if(e.length<3){let s=0,l=0;for(let h of e)s+=h.x,l+=h.y;s/=e.length||1,l/=e.length||1;let c=0;for(let h of e)c=Math.max(c,Math.hypot(h.x-s,h.y-l));let f=[],m=Math.max(3,Math.ceil(Math.PI*2/On)),u=(c+n)/Math.cos(Math.PI/m);for(let h=0;h<m;h++){let b=h/m*Math.PI*2;f.push({x:s+Math.cos(b)*u,y:l+Math.sin(b)*u})}return f}let o=e.length,a=[];for(let s=0;s<o;s++){let l=e[s],c=e[(s+1)%o];a.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let r=[];for(let s=0;s<o;s++)i(e[s],a[(s+o-1)%o],a[s],r);return jn(r)}function uo(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let i=1/0;for(let o=0;o+1<t.length;o++){let a=t[o],r=t[o+1],s=r.x-a.x,l=r.y-a.y,c=s*s+l*l,f=c>1e-12?((n-a.x)*s+(e-a.y)*l)/c:0;f<0?f=0:f>1&&(f=1);let m=Math.hypot(n-(a.x+f*s),e-(a.y+f*l));m<i&&(i=m)}return i}function Wt(t){let n=t.map(o=>{let a=0,r=0;for(let c of o.pts)a+=c.x,r+=c.y;let s=o.pts.length||1;a/=s,r/=s;let l=0;for(let c of o.pts){let f=Math.hypot(c.x-a,c.y-r);f>l&&(l=f)}return{cx:a,cy:r,rad:l}}),e=o=>{let a=o.length;return a<=2?[...o]:[o[Math.floor(a*.25)],o[Math.floor(a*.5)],o[Math.floor(a*.75)]]},i=[];for(let o=0;o<t.length;o++){let a=e(t[o].pts),r=[],s=1/0,l=null;for(let f of a){let m=1/0;for(let u=0;u<t.length;u++){if(u===o||Math.abs(t[u].y-t[o].y)<.001)continue;let h=n[u],b=Math.hypot(f.x-h.cx,f.y-h.cy)-h.rad;if(b>=m&&b>=s)continue;let p=uo(t[u].pts,f.x,f.y);p<m&&(m=p),t[u].depth<t[o].depth&&p<s&&(s=p,l=t[u].y)}Number.isFinite(m)&&m>0&&r.push(m)}r.sort((f,m)=>f-m);let c=r.length?r[Math.floor(r.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function Xn(t,n,e,i){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let f=o.pts[0],m=f.x-i.x,u=f.y-i.y,h=Math.hypot(m,u)||1;m/=h,u/=h;let b=Math.max(e[n].pitch,.001)*.5;return[{x:f.x+u*b,y:f.y-m*b},{x:f.x-u*b,y:f.y+m*b}]})():[];if(a.length<2)return null;let r=0,s=0;for(let f=1;f<a.length;f++){let m=Math.hypot(a[f].x-a[f-1].x,a[f].y-a[f-1].y);m>1e-6&&(r+=m,s++)}let l=s>0?r/s:0,c=ao(a,Math.max(l*io,ot));return{pts:c,nrm:so(c,i),front:Math.max(e[n].pitch*oo,ot),back:Math.max(e[n].pitch*ro,ot)}}var gt=1.5,Nn=.3;function rn(t,n){if(t.length<3)return t;let e=t[0],i=t[t.length-1],o=i.x-e.x,a=i.y-e.y,r=Math.hypot(o,a),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let u=t[m],h=r>1e-12?Math.abs((u.x-e.x)*a-(u.y-e.y)*o)/r:Math.hypot(u.x-e.x,u.y-e.y);h>s&&(s=h,l=m)}if(s<=n||l<0)return[e,i];let c=rn(t.slice(0,l+1),n),f=rn(t.slice(l),n);return[...c.slice(0,-1),...f]}function Un(t,n){if(t.length<4)return t;let e=rn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function Yn(t,n,e){if(t.length<2)return[];let i=e??Wt(t),o=new Map;for(let r=0;r<t.length;r++){let s=o.get(t[r].blockId);s?s.push(r):o.set(t[r].blockId,[r])}let a=[];for(let[,r]of o){let s=[];for(let x of r){let T=t[x].patch;T&&T.length>=3?a.push({outline:[...T],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,T)=>t[x].depth-t[T].depth);let c=s.map(x=>Xn(t,x,i,n)).filter(x=>x!==null);if(!c.length)continue;let f=(x,T)=>({x:x.pts[T].x-x.nrm[T][0]*(x.front+gt),y:x.pts[T].y-x.nrm[T][1]*(x.front+gt)}),m=(x,T)=>({x:x.pts[T].x+x.nrm[T][0]*(x.back+gt),y:x.pts[T].y+x.nrm[T][1]*(x.back+gt)}),u=c[0],h=c[c.length-1],b=[];for(let x=0;x<u.pts.length;x++)b.push(f(u,x));for(let x of c)b.push(m(x,x.pts.length-1));for(let x=h.pts.length-1;x>=0;x--)b.push(m(h,x));for(let x=c.length-1;x>=0;x--)b.push(f(c[x],0));let p=jn(b),y=1/0;for(let x of s)t[x].y<y&&(y=t[x].y);if(!Number.isFinite(y))continue;if(p.length>=3&&Math.abs(ft(p))>1e-6&&c.every(x=>{let T=x.pts[Math.floor(x.pts.length/2)];return It(p,T.x,T.y)})){a.push({outline:Un(p,Nn),holes:[],topY:y});continue}for(let x of lo(c))a.push({outline:x,holes:[],topY:y})}return a}function lo(t){let n=[];for(let e of t){let i=[],o=[],a=e.front+gt,r=e.back+gt;for(let l=0;l<e.pts.length;l++){let c=e.pts[l],f=e.nrm[l];i.push([c.x-f[0]*a,c.y-f[1]*a]),o.push([c.x+f[0]*r,c.y+f[1]*r])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=Gn.union(n[0],...n.slice(1)),i=[];for(let o of e){if(!o.length||o[0].length<4)continue;let a=o[0].map(([l,c])=>({x:l,y:c})),r=a[0],s=a[a.length-1];a.length>1&&Math.abs(r.x-s.x)<1e-9&&Math.abs(r.y-s.y)<1e-9&&a.pop(),a.length>=3&&i.push(Un(a,Nn))}return i}catch{return[]}}function jn(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 sn=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 o of n)if(!It(e,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function Ln(t,n,e,i,o,a){if(i.length<3)return;if(e.containsAll(i)){let c=[0,1,0],f=i[0];for(let m=1;m+1<i.length;m++){let u=i[m],h=i[m+1];t.tri([f.x*g,o,f.y*g],[u.x*g,o,u.y*g],[h.x*g,o,h.y*g],c,a)}return}let r=i.map(c=>[c.x,c.y]);r.push(r[0]);let s;try{s=Gn.intersection([r],n)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let f=c[0],m=[],u=[];for(let b=0;b<f.length-1;b++)m.push(f[b][0],f[b][1]),u.push([f[b][0],f[b][1]]);if(u.length<3)continue;let h=eo(m,void 0,2);for(let b=0;b<h.length;b+=3){let p=u[h[b]],y=u[h[b+1]],d=u[h[b+2]];t.tri([p[0]*g,o,p[1]*g],[y[0]*g,o,y[1]*g],[d[0]*g,o,d[1]*g],l,a)}}}function Hn(t,n,e,i,o,a,r){if(n.length<2)return;let s=r??Wt(n),l=[0,1,0],c=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,f=a&&a.length>=3?new sn([[...a]]):null,m=h=>{t.setMaterial(2),h(),t.setMaterial(0)},u=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let b=n[h];if(b.patch&&b.patch.length>=3){let C=[...b.patch],P=s[h].belowY??i;if(u(()=>{if(c&&f)Ln(t,c,f,C,b.y,o.tread);else{let A=C[0];for(let E=1;E+1<C.length;E++){let v=C[E],G=C[E+1];t.tri([A.x*g,b.y,A.y*g],[v.x*g,b.y,v.y*g],[G.x*g,b.y,G.y*g],l,o.tread)}}}),b.y>P+kn){let A=0,E=0;for(let v of C)A+=v.x,E+=v.y;A/=C.length,E/=C.length,m(()=>{for(let v=0;v<C.length;v++){let G=C[v],X=C[(v+1)%C.length],M=X.x-G.x,B=X.y-G.y,O=Math.hypot(M,B);if(O<1e-6)continue;let F=B/O,I=-M/O;(G.x-A)*F+(G.y-E)*I<0&&(F=-F,I=-I);let k=[F,0,I],R=[G.x*g,b.y,G.y*g],_=[X.x*g,b.y,X.y*g],w=[G.x*g,P,G.y*g],D=[X.x*g,P,X.y*g];t.tri(R,_,D,k,o.riser),t.tri(R,D,w,k,o.riser)}})}continue}let p=Xn(n,h,s,e);if(!p)continue;let{pts:y,nrm:d,front:x,back:T}=p,S=s[h].belowY??i;for(let C=0;C+1<y.length;C++){let P=y[C],A=y[C+1],E=d[C],v=d[C+1];if(Math.hypot(A.x-P.x,A.y-P.y)<1e-6||E[0]===0&&E[1]===0||v[0]===0&&v[1]===0)continue;let G=[(P.x-E[0]*x)*g,b.y,(P.y-E[1]*x)*g],X=[(A.x-v[0]*x)*g,b.y,(A.y-v[1]*x)*g],M=[(P.x+E[0]*T)*g,b.y,(P.y+E[1]*T)*g],B=[(A.x+v[0]*T)*g,b.y,(A.y+v[1]*T)*g];if(u(()=>{c&&f?Ln(t,c,f,[{x:P.x-E[0]*x,y:P.y-E[1]*x},{x:A.x-v[0]*x,y:A.y-v[1]*x},{x:A.x+v[0]*T,y:A.y+v[1]*T},{x:P.x+E[0]*T,y:P.y+E[1]*T}],b.y,o.tread):(t.tri(G,X,B,l,o.tread),t.tri(G,B,M,l,o.tread))}),b.y>S+kn){let O=[G[0],S,G[2]],F=[X[0],S,X[2]],I=[-E[0],0,-E[1]];m(()=>{t.tri(G,X,F,I,o.riser),t.tri(G,F,O,I,o.riser)})}}}}import Wn from"polygon-clipping";function mo(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Vn(t,n){return t.filter(e=>e.type!=="shape"||mo(e,n))}function zn(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:Vn(i.objects,n),focal:{x:(i.focalPoint??e).x,y:(i.focalPoint??e).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:Vn(t.objects,n),focal:e,baseHeightM:0,index:0}]}var fo={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Mt(t){return xn(t)??fo}function Zn(t,n){let e=jt(t.outline,ot),i=Mt(e),o=n.filter(r=>r!==t&&r.outline&&r.outline.length>=3&&Xt(i,Mt(r.outline)));if(!o.length)return[e];let a=r=>{let s=r.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let r=Wn.difference([a(e)],...o.map(l=>[a(l.outline)])),s=[];for(let l of r){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[e]}catch{return[e]}}function Kn(t,n){if(!n.length)return t;let e=a=>{let r=a.map(s=>[s.x,s.y]);return r.push(r[0]),r},i=n.map(a=>[e(a)]),o=[];for(let a of t){let r;try{r=Wn.intersection([e(a.outline)],i.flat())}catch{o.push(a);continue}for(let s of r){if(!s.length)continue;let l=s[0].map(([c,f])=>({x:c,y:f}));if(l.length>1){let c=l[0],f=l[l.length-1];Math.abs(c.x-f.x)<1e-9&&Math.abs(c.y-f.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:a.topY})}}return o.length?o:t}var ho=.05,$n=.05,bo=.15,an=25;function qn(t,n,e){let i=new Map,o=new Array(n.length).fill(null),a=new Float64Array(n.length),r=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),l=new Map,c=[],f=new Set;for(let u=0;u<t.length;u+=1){let h=t[u];for(let b of h.objects){if(b.type==="table"&&f.add(b.id),b.type!=="section"||!b.outline||b.outline.length<3)continue;let p=jt(b.outline,ot);l.set(b.id,{section:b,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:b.id,floorIndex:u,box:Mt(p),section:b,unit:h,outline:p})}}let m=new Map;for(let u of c){let h=m.get(u.floorIndex);h?h.push(u):m.set(u.floorIndex,[u])}for(let u=0;u<n.length;u++){let h=n[u],b=e?m.get(e[u])??[]:c,p=h.sectionId?b.find(d=>d.id===h.sectionId)??b.find(d=>d.section.logicalSectionId===h.sectionId&&qt({x:h.x,y:h.y},d.outline,d.section.holes)):void 0,y=p?[p]:b;for(let d of y){if(e&&d.floorIndex!==e[u]||!p&&(h.x<d.box.minX||h.x>d.box.maxX||h.y<d.box.minY||h.y>d.box.maxY||!qt({x:h.x,y:h.y},d.outline,d.section.holes)))continue;o[u]=d.id;let x=l.get(d.id);x.hasSeats=!0;let T=h.focalPoint??d.unit.focal,S=Math.hypot(h.x-T.x,h.y-T.y);S<x.frontU&&(x.frontU=S),x.seatIndices.push(u);let C=h.rowId||`__seat-${u}`,P=x.rows.get(C);P?P.push({x:h.x,y:h.y}):x.rows.set(C,[{x:h.x,y:h.y}]);break}}for(let[u,h]of l){let b=dn(h.section,{floorBaseHeightM:h.unit.baseHeightM}),p=h.unit.baseHeightM,y=b.rake>0?Math.tan(b.rake*Math.PI/180):0,d=b.rake<=.01&&b.height<=p+.001,x=h.section.surfaceKind,T=x==="flat"?!0:x==="rakedRows"&&b.rake>.01?!1:d,S=h.hasSeats?yn(u,n,h.seatIndices,h.unit.focal):{sectionId:u,rows:[],blockCount:0},P=S.rows.length<2?Pn([...h.rows.values()].map(R=>({points:R})),h.unit.focal):null,A=1/0;if(P){if(h.hasSeats)for(let R of h.rows.values())for(let _ of R){let w=P.depthAt(_.x,_.y);w<A&&(A=w)}if(!h.hasSeats||!Number.isFinite(A)){A=1/0;for(let R of h.section.outline){let _=P.depthAt(R.x,R.y);_<A&&(A=_)}}}let E=p+ho,v=Math.max(E,b.height),G=R=>{let _=Math.max(0,R-A)*ut,w=Math.min(_*y,an);return Math.max(E,b.height+w)},X=R=>{let _=Math.max(0,R)*ut,w=Math.min(_*y,an);return Math.max(E,b.height+w)},M=T?[]:S.rows.map(R=>({pts:R.pts,y:X(R.blockDepth),depth:R.blockDepth,blockId:R.blockId,...f.has(R.id)?{patch:Dn(R.pts,ot)}:{}})),B=M.length?M[0].y:v,O=M.map(R=>{let _=R.patch&&R.patch.length>=3?R.patch:R.pts,w=0,D=0;for(let L of _)w+=L.x,D+=L.y;let N=_.length||1;w/=N,D/=N;let U=0;for(let L of _){let Y=Math.hypot(L.x-w,L.y-D);Y>U&&(U=Y)}return{cx:w,cy:D,rad:U}}),F=T?()=>v:M.length>=2?(R,_)=>{let w=1/0,D=B;for(let N=0;N<M.length;N++){let U=O[N];if(Math.hypot(R-U.cx,_-U.cy)-U.rad>=w)continue;let L=M[N].patch,Y=L&&L.length>=3?It(L,R,_)?0:Dt(L,R,_):Dt(M[N].pts,R,_);Y<w&&(w=Y,D=M[N].y)}return D}:(R,_)=>P?G(P.depthAt(R,_)):v,I=[0,1,0],k=M.length>=2||T?()=>I:(R,_)=>{if(!P)return I;let w=P.depthAt(R,_);if(w<=A)return I;let D=(w-A)*ut;if(D*y>=an||b.height+D*y<=E)return I;let[N,U]=P.gradientAt(R,_);if(N===0&&U===0)return I;let L=1/Math.hypot(y,1);return[-N*y*L,L,-U*y*L]};if(!T)for(let R of S.rows){let _=X(R.blockDepth);for(let w of R.seatIndices)r[w]=_}for(let R of S.rows){let _=[];for(let L=1;L<R.pts.length;L++){let Y=Math.hypot(R.pts[L].x-R.pts[L-1].x,R.pts[L].y-R.pts[L-1].y);Y>1e-6&&_.push(Y)}_.sort((L,Y)=>L-Y);let w=_.length?_[Math.floor(_.length/2)]:1/0,D=1/0,N=R.pts[Math.floor(R.pts.length/2)];if(N)for(let L of S.rows){if(L===R||L.blockId!==R.blockId)continue;let Y=Dt(L.pts,N.x,N.y);Y>1e-6&&Y<D&&(D=Y)}let U=Math.min(w,Math.max(D,w*.5));if(Number.isFinite(U)&&U>0)for(let L of R.seatIndices)s[L]=U}i.set(u,{sectionId:u,deckAt:F,normalAt:k,flat:T,bottomY:p,rowLevels:M,landingY:B})}for(let u=0;u<n.length;u++){let h=o[u],b=n[u];if(h){let y=r[u];a[u]=(y??i.get(h).deckAt(b.x,b.y))+bo;continue}let p=b.eyeHeightM;a[u]=Number.isFinite(p)?Math.max(0,p-Gt):0}return{bySection:i,seatOwner:o,seatDeckY:u=>a[u],seatPitchU:u=>s[u]}}var W={top:1,wallBottom:.5,bottomCap:.4};function st(t,n){if(!t)return n;let e=et(At(t,.4),.62);return nt(n,e,.72)}function Jn(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 r=i.get(a.sectionId);r||(r=new Map,i.set(a.sectionId,r)),r.set(a.categoryKey,(r.get(a.categoryKey)??0)+1)}let o=new Map;for(let[a,r]of i){let s=0,l=0,c=0,f=0;for(let[m,u]of r){let h=H(e.get(m));h&&(s+=h[0]*u,l+=h[1]*u,c+=h[2]*u,f+=u)}f>0&&o.set(a,[s/f,l/f,c/f])}return o}function Qn(t,n){return H(t.color)??n.get(t.logicalSectionId??t.id)??null}import po from"polygon-clipping";function yo(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var zt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let i=n.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Mt(n),a=this.rings.filter((l,c)=>Xt(o,this.boxes[c])&&yo(e,this.levels[c])),r=[[i]];if(a.length)try{r=po.difference([i],...a).map(c=>c.map(f=>f.map(([m,u])=>[m,u])))}catch{r=[[i]]}this.rings.push([i]),this.boxes.push(o),this.levels.push(e);let s=[];for(let l of r){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function xo(t,n){if(!n)return t;let e=1/0,i=-1/0,o=1/0,a=-1/0;for(let m of t)e=Math.min(e,m.x),i=Math.max(i,m.x),o=Math.min(o,m.y),a=Math.max(a,m.y);let r=(e+i)/2,s=(o+a)/2,l=n*Math.PI/180,c=Math.cos(l),f=Math.sin(l);return t.map(m=>{let u=m.x-r,h=m.y-s;return{x:r+u*c-h*f,y:s+u*f+h*c}})}function bt(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=_t(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=Ht(e,i,t.width/2,t.height/2)}return n?xo(n,t.rotation):null}function Ft(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"&&Rn(t.stageKind)?{kind:"stage",heightM:.06}:e[n]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var go=.08;function te(t,n){let e=bt(t),i=Ft(t),o=i.heightM;if(!e||i.kind!=="plate"&&i.kind!=="stage")return o;let a=1/0,r=1/0,s=-1/0,l=-1/0;for(let f of e)a=Math.min(a,f.x),r=Math.min(r,f.y),s=Math.max(s,f.x),l=Math.max(l,f.y);let c=o;for(let f of n)s>f.minX&&a<f.maxX&&l>f.minY&&r<f.maxY&&c<=f.topOffsetM+1e-6&&(c=f.topOffsetM+go);return n.push({minX:a,minY:r,maxX:s,maxY:l,topOffsetM:c}),c}function mt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function ne(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 Et(t,n,e){return[mt(t[0],t[1],n),mt(t[0],t[1],e),mt(t[3],t[2],e),mt(t[3],t[2],n)]}function ee(t,n,e){return[mt(t[0],t[3],n),mt(t[1],t[2],n),mt(t[1],t[2],e),mt(t[0],t[3],e)]}function at(t,n,e,i,o,a){K(t,n,void 0,()=>e,i,o,a,W)}var cn=2.4,Mo=.75,So=.15;function Ct(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:i,rotation:o}=t;if(!e||!i)return null;let a=(o??0)*Math.PI/180,r=Math.cos(a),s=Math.sin(a),l=e/2,c=i/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:n.x+f*r-m*s,y:n.y+f*s+m*r}))}function oe(t,n,e,i,o){let a=Ct(n);a&&K(t,a,void 0,()=>e+cn,e,st(i,o.boothTop),o.boothWall,W)}function un(t){if(t.shape==="round"){let f=t.radius;return f?Ht(t.center.x,t.center.y,f,f,24):null}let{width:n,height:e,rotation:i,center:o}=t;if(!n||!e)return null;let a=(i??0)*Math.PI/180,r=Math.cos(a),s=Math.sin(a),l=n/2,c=e/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:o.x+f*r-m*s,y:o.y+f*s+m*r}))}function re(t,n,e,i,o){let a=un(n);a&&K(t,a,void 0,()=>e+Mo,e,st(i,o.tableTop),o.tableWall,W)}function ie(t,n,e,i,o,a,r,s){let l=bt(n);if(!l)return;let c=s?s.kind==="stage":n.role==="stage",f=s?s.kind==="screen":n.role==="screen",m=s?{kind:c?"stage":"solid",heightM:s.topY-s.baseY}:Ft(n),u=s?.baseY??e,h=s?.topY??e+i;if(c&&r){let x=1/0,T=-1/0,S=1/0,C=-1/0;for(let P of l)P.x<x&&(x=P.x),P.x>T&&(T=P.x),P.y<S&&(S=P.y),P.y>C&&(C=P.y);r.push({cx:(x+T)/2*g,cz:(S+C)/2*g,y:h,halfX:Math.max((T-x)/2*g,.5),halfZ:Math.max((C-S)/2*g,.5)})}let b=H(n.fill),p=c&&b?nt(o.stageTop,et(At(b,.18),.9),.9):st(b,c?o.stageTop:o.decorTop),y=f?b:null,d=c?b?nt(o.stageWall,et(b,.58),.82):o.stageWall:f?y?nt(et(y,1.42),[.24,.46,.82],.08):[.24,.46,.82]:st(H(n.fill),o.decorWall);if(m.kind==="portal"&&l.length===4){let x=ne(l);at(t,Et(x,0,.16),h,u,p,d),at(t,Et(x,.84,1),h,u,p,d),at(t,x,h,Math.max(u,h-.35),p,d);return}if(m.kind==="suite"&&l.length===4){let x=l.map((C,P)=>{let A=l[(P+1)%4],E=(C.x+A.x)/2,v=(C.y+A.y)/2;return Math.hypot(E-a.x,v-a.y)}),T=x.indexOf(Math.min(...x)),S=[0,1,2,3].map(C=>l[(T+C)%4]);at(t,Et(S,0,.08),h,u,p,d),at(t,Et(S,.92,1),h,u,p,d),at(t,ee(S,.88,1),h,u,p,d),at(t,S,h,Math.max(u,h-.18),p,d);return}at(t,l,h,u,p,d)}function ln(t){let{x:n,y:e,width:i,height:o}=t;if(!i||!o)return null;let a=n+i/2,r=e+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),f=i/2,m=o/2;return[[-f,-m],[f,-m],[f,m],[-f,m]].map(([u,h])=>({x:a+u*l-h*c,y:r+u*c+h*l}))}function Ro(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 o=i.match(/^url\(#([^)]+)\)$/);if(!o)return H(i);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let r=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let l=H(s[1].trim());l&&r.push(l)}return r.length?r.reduce((s,l,c)=>nt(s,l,1/(c+1)),r[0]):null}function se(t,n,e,i){if(n.layer==="foreground")return;let o=ln(n);if(!o)return;let a=e+So,r=st(Ro(n.href),i.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(r=nt(i.ground,r,s)),K(t,o,void 0,()=>a,e,r,nt(r,i.decorWall,.5),W)}function ae(t,n,e,i,o){if(!n.points||n.points.length<3)return;let a=st(i,o.gaTop);K(t,n.points,n.holes,()=>e+.15,e,a,o.gaWall,W)}var Po=.25,Ao=1.2,Io=.6,wo=.45,To=2.3,_o=Math.PI/180;function pt(t,n,e){let i=e*_o;return{x:t.x+n*Math.sin(i),y:t.y+n*Math.cos(i)}}function Bo(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let i=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let a=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(a.length<2)continue;let r=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=i&&r++;if(r>=a.length/2)return!0}return!1}var Fo=24;function Eo(t,n,e,i,o,a,r,s){let l=e.binCount,c=Fo,f=ut,m=a+.02,u=[];for(let M=0;M<l;M++){let B=(e.startBin+M+.5)*n.binStepDeg,O=new Float64Array(c+1);for(let F=0;F<=c;F++){let I=i[M]+(o[M]-i[M])*F/c;O[F]=Math.max(m,In(n,e,B,I)-Po)}u.push(O)}let h=[r.bandTop[0]*s.top,r.bandTop[1]*s.top,r.bandTop[2]*s.top],b=[r.bandTop[0]*s.bottomCap,r.bandTop[1]*s.bottomCap,r.bandTop[2]*s.bottomCap],p=[r.bandWall[0]*s.top,r.bandWall[1]*s.top,r.bandWall[2]*s.top],y=[r.bandWall[0]*s.wallBottom,r.bandWall[1]*s.wallBottom,r.bandWall[2]*s.wallBottom],d=(M,B)=>{let O=(e.startBin+M+.5)*n.binStepDeg,F=i[M]+(o[M]-i[M])*B/c,I=pt(n.centre,F,O);return[I.x*f,u[M][B],I.y*f]};{let M=Math.tan(12*Math.PI/180);for(let B=0;B<6;B++){let O=!1;for(let I=0;I<l;I++)for(let k=c-1;k>=0;k--)u[I][k]>u[I][k+1]&&(u[I][k]=u[I][k+1],O=!0);let F=e.closed?l:l-1;for(let I=0;I<F;I++){let k=(I+1)%l;for(let R=0;R<=c;R++){let _=u[k][R]-u[I][R];if(Math.abs(_)>1)continue;let w=i[I]+(o[I]-i[I])*R/c,D=i[k]+(o[k]-i[k])*R/c,N=pt(n.centre,w,(e.startBin+I+.5)*n.binStepDeg),U=pt(n.centre,D,(e.startBin+k+.5)*n.binStepDeg),L=M*Math.hypot(U.x-N.x,U.y-N.y)*f;_>L?(u[k][R]=u[I][R]+L,O=!0):-_>L&&(u[I][R]=u[k][R]+L,O=!0)}}if(!O)break}}let x=1,T=(M,B)=>{for(let O=0;O<=c;O+=4)if(Math.abs(u[M][O]-u[B][O])>x)return!0;return Math.abs(u[M][c]-u[B][c])>x},S=Math.tan(38*Math.PI/180),C=M=>(o[M]-i[M])/c*f,P=(M,B)=>u[M][B+1]-u[M][B]>S*Math.max(1e-6,C(M)),A=(M,B)=>{let O=e.closed?(M-1+l)%l:Math.max(0,M-1),F=e.closed?(M+1)%l:Math.min(l-1,M+1);Math.abs(u[O][B]-u[M][B])>x&&(O=M),Math.abs(u[F][B]-u[M][B])>x&&(F=M);let I=Math.max(0,B-1),k=Math.min(c,B+1);I<B&&P(M,I)&&(I=B),k>B&&P(M,B)&&(k=B);let R=d(O,B),_=d(F,B),w=d(M,I),D=d(M,k),N=_[0]-R[0],U=_[1]-R[1],L=_[2]-R[2],Y=D[0]-w[0],j=D[1]-w[1],$=D[2]-w[2],z=U*$-L*j,q=L*Y-N*$,tt=N*j-U*Y,Z=Math.hypot(z,q,tt);return Z>1e-12?(z/=Z,q/=Z,tt/=Z,q<0&&(z=-z,q=-q,tt=-tt),[z,q,tt]):[0,1,0]},E=(M,B)=>{let O=[M[0],a,M[2]],F=[B[0],a,B[2]],I=B[0]-M[0],k=B[2]-M[2],R=Math.hypot(I,k);if(!(R>1e-12))return;let _=[k/R,0,-I/R];t.tri(M,B,F,_,p,p,y),t.tri(M,F,O,_,p,y,y)},v=.05*lt,G=M=>o[M]-i[M]<v,X=e.closed?l:l-1;for(let M=0;M<X;M++){let B=(M+1)%l;if(G(M)||G(B))continue;if(T(M,B)){let _=(e.startBin+M+1)*n.binStepDeg,w=(j,$)=>{let z=(i[M]+i[B])/2,q=(o[M]+o[B])/2,tt=z+(q-z)*$/c,Z=pt(n.centre,tt,_);return[Z.x*f,u[j][$],Z.y*f]};for(let j=0;j<c;j++){let $=d(M,j),z=d(M,j+1),q=w(M,j),tt=w(M,j+1),Z=A(M,j),it=A(M,j+1);t.triN($,q,tt,Z,Z,it,h),t.triN($,tt,z,Z,it,it,h);let vt=d(B,j),kt=d(B,j+1),dt=w(B,j),St=w(B,j+1),yt=A(B,j),xt=A(B,j+1);t.triN(dt,vt,kt,yt,yt,xt,h),t.triN(dt,kt,St,yt,xt,xt,h);let ct=w(M,j),rt=w(M,j+1),Ot=w(B,j+1),Kt=w(B,j),Lt=rt[0]-ct[0],Rt=rt[2]-ct[2],$t=Math.hypot(Lt,Rt);if($t>1e-12){let fn=[Rt/$t,0,-Lt/$t];t.tri(ct,rt,Ot,fn,p),t.tri(ct,Ot,Kt,fn,p)}}let D=d(M,0),N=d(B,0),U=d(B,c),L=d(M,c),Y=j=>[j[0],a,j[2]];t.tri(Y(D),Y(U),Y(N),[0,-1,0],b),t.tri(Y(D),Y(L),Y(U),[0,-1,0],b),E(D,N),E(L,U);continue}for(let _=0;_<c;_++){let w=A(M,_),D=A(B,_),N=A(B,_+1),U=A(M,_+1);if(P(M,_)||P(B,_)){let z=(rt,Ot)=>{let Kt=(e.startBin+rt+.5)*n.binStepDeg,Lt=i[rt]+(o[rt]-i[rt])*(_+.5)/c,Rt=pt(n.centre,Lt,Kt);return[Rt.x*f,Ot,Rt.y*f]},q=d(M,_),tt=d(B,_),Z=z(M,u[M][_]),it=z(B,u[B][_]);t.triN(q,tt,it,w,D,D,h),t.triN(q,it,Z,w,D,w,h);let vt=d(B,_+1),kt=d(M,_+1),dt=z(M,u[M][_+1]),St=z(B,u[B][_+1]);t.triN(dt,St,vt,U,N,N,h),t.triN(dt,vt,kt,U,N,U,h);let yt=it[0]-Z[0],xt=it[2]-Z[2],ct=Math.hypot(yt,xt);if(ct>1e-12){let rt=[-xt/ct,0,yt/ct];t.tri(Z,it,St,rt,p),t.tri(Z,St,dt,rt,p)}continue}let L=d(M,_),Y=d(B,_),j=d(B,_+1),$=d(M,_+1);t.triN(L,Y,j,w,D,N,h),t.triN(L,j,$,w,N,U,h)}let O=d(M,0),F=d(B,0),I=d(B,c),k=d(M,c),R=_=>[_[0],a,_[2]];t.tri(R(O),R(I),R(F),[0,-1,0],b),t.tri(R(O),R(k),R(I),[0,-1,0],b),E(O,F),E(k,I)}if(!e.closed)for(let M of[0,l-1])for(let B=0;B<c;B++)E(d(M,B),d(M,B+1))}function ce(t,n,e){let{bottomY:i,colors:o,ao:a}=e,r=new Float64Array(n.binCount).fill(-1/0);for(let f of n.rings)for(let m of f.arcs){let u=new Float64Array(m.binCount),h=new Float64Array(m.binCount);for(let p=0;p<m.binCount;p++){let y=(m.startBin+p)%n.binCount,d=Math.max(0,m.innerR[p]-ot);u[p]=Math.max(d,r[y]+.001),h[p]=Math.max(u[p]+.001,m.outerR[p]+ot)}let b=0;for(let p=0;p<m.binCount;p++){let y=m.topLevelM[p]-i;y>b&&(b=y)}b>=Ao&&Eo(t,n,m,u,h,i,o,a);for(let p=0;p<m.binCount;p++){let y=(m.startBin+p)%n.binCount;h[p]>r[y]&&(r[y]=h[p])}}if(e.deriveShell===!1||Bo(e.shapes,n))return;let s=n.rings[n.rings.length-1],l=Io*lt,c=wo*lt;for(let f of s.arcs){let m=[],u=[];for(let p=0;p<f.binCount;p++){let y=(f.startBin+p+.5)*n.binStepDeg,d=f.outerR[p]+ot+l;m.push(pt(n.centre,d,y)),u.push(pt(n.centre,d+c,y))}let h=-1/0;for(let p=0;p<f.binCount;p++)f.topLevelM[p]>h&&(h=f.topLevelM[p]);let b=()=>h+To;f.closed?K(t,u,[m.slice().reverse()],b,i,o.shellTop,o.shellWall,a):K(t,[...u,...m.slice().reverse()],void 0,b,i,o.shellTop,o.shellWall,a)}}function ue(t,n,e,i,o,a,r,s){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,c=st(i,s.tierTop);if(!o)return;let f=y=>o.deckAt(y.x,y.y),m=Zn(n,r),u=m[0]??n.outline;if(o.rowLevels.length>=2){let y=Wt(o.rowLevels),d=Kn(Yn(o.rowLevels,e.focal,y),m),x=()=>[0,1,0];for(let S of d){let C=Math.max(l,S.topY-.02);for(let P of a.subtract(S.outline,C))K(t,P,S.holes,()=>C,l,c,s.tierWall,W,void 0,x)}d.length||K(t,u,n.holes,()=>o.landingY,l,c,s.tierWall,W);let T={tread:[c[0]*W.top,c[1]*W.top,c[2]*W.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let S of m.length?m:[u])Hn(t,o.rowLevels,e.focal,o.landingY,T,S,y);return}let h=o.flat?1/0:$n,b=y=>o.normalAt(y.x,y.y),p=o.flat?o.landingY:void 0;for(let y of a.subtract(u,p))K(t,y,n.holes,f,l,c,s.tierWall,W,h,b)}function Co(t,n,e){let i=new Set;for(let r of t.objects)r.type==="section"&&i.add(r.id);let o=new Map;for(let r=0;r<n.length;r++){let s=e.seatOwner[r];if(!s||!i.has(s))continue;let l=e.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=n[r],f=o.get(s);f||(f=new Map,o.set(s,f));let m=c.rowId||`__seat-${r}`,u=f.get(m);u||(u={pts:[],levelM:0,n:0},f.set(m,u)),u.pts.push({x:c.x,y:c.y}),u.levelM+=e.seatDeckY(r),u.n++}let a=[];for(let r of t.objects){if(r.type!=="section")continue;let s=e.bySection.get(r.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(f=>!f.patch).map(f=>({pts:f.pts,levelM:f.y}));c.length>=2&&a.push({sectionId:r.id,rows:c});continue}let l=o.get(r.id);l&&a.push({sectionId:r.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return a}function le(t,n,e,i,o,a,r=!0){let s=Co(n,e,i);if(!s.length)return;let l=An(s,n.focal);l&&(t.setMaterial(0),ce(t,l,{bottomY:n.baseHeightM,colors:{bandTop:et(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??et(o.tierWall,1.15),shellWall:a??o.tierWall},ao:W,shapes:n.objects.filter(c=>c.type==="shape"),deriveShell:r}))}var vo=6,ko=2.2,me=.1,Oo=.3,Lo=1.8,Go=.9,Do=.55,Xo=6e3;function fe(t){let{doc:n,units:e,seats:i,surfaces:o,focal:a}=t,r=n.zones??[],s=[];if(r.length){let l=new Map;for(let f of e)for(let m of f.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let f=0;f<i.length;f++){let m=i[f],u=o.seatOwner[f],h=m.zoneId??(u?l.get(u):void 0);if(!h)continue;let b=c.get(h);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(h,b)),b.n++,m.x<b.minX&&(b.minX=m.x),m.y<b.minY&&(b.minY=m.y),m.x>b.maxX&&(b.maxX=m.x),m.y>b.maxY&&(b.maxY=m.y),b.sumY+=o.seatDeckY(f)}for(let f of r){let m=c.get(f.id),u=[];for(let[h,b]of l)b===f.id&&u.push(h);if(!m||m.n===0){s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]});continue}s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:m.n,center:[(m.minX+m.maxX)/2*g,m.sumY/m.n,(m.minY+m.maxY)/2*g],radius:.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||1,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]})}}return s}function he(t){let{doc:n,units:e,seats:i,surfaces:o,seatData:a,hintedSeatFloor:r,zones:s,focal:l}=t,c=[],f=[],m=[];for(let u of s)u.seatCount!==0&&c.push({id:`zone:${u.id}`,kind:"zone",text:u.label,anchor:[u.center[0],u.center[1]+vo,u.center[2]],color:n.zones?.find(h=>h.id===u.id)?.color});{let u=new Map,h=new Map;for(let b=0;b<i.length;b++){let p=o.seatOwner[b];if(!p)continue;let y=u.get(p);y||(y={n:0,x:0,y:0,deck:0},u.set(p,y)),y.n++,y.x+=i[b].x,y.y+=i[b].y,y.deck+=o.seatDeckY(b);let d=h.get(p);d||(d={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},h.set(p,d)),i[b].x<d.minX&&(d.minX=i[b].x),i[b].x>d.maxX&&(d.maxX=i[b].x),i[b].y<d.minY&&(d.minY=i[b].y),i[b].y>d.maxY&&(d.maxY=i[b].y)}for(let b of e)for(let p of b.objects){if(p.type!=="section")continue;let y=u.get(p.id);if(!y||y.n===0)continue;let d=h.get(p.id),x=[y.x/y.n*g,y.deck/y.n,y.y/y.n*g],T=p.displayLabel||p.label||p.id;f.push({id:p.id,floorIndex:b.index,label:T,seatCount:y.n,center:x,radius:Math.max(1,Math.hypot(d.maxX-d.minX,d.maxY-d.minY)*.5*g),focalWorld:[b.focal.x*g,b.baseHeightM+1.5,b.focal.y*g]});let S=n.floors?.[b.index]?.name?.trim().toLocaleLowerCase();e.length>1&&S===T.trim().toLocaleLowerCase()||c.push({id:`section:${p.id}`,kind:"section",text:T,anchor:[x[0],x[1]+ko,x[2]],floorIndex:b.index})}}{for(let b of e)for(let p of b.objects){if(p.type!=="gaArea")continue;let y=Pt(p.points);if(!y)continue;let d=p.displayLabel||p.label||p.id;c.push({id:`ga:${p.id}`,kind:"ga",text:p.capacity>0?`${d} \xB7 ${p.capacity.toLocaleString()}`:d,anchor:[y.x*g,b.baseHeightM+Lo,y.y*g],floorIndex:b.index})}let u=new Map;for(let b=0;b<i.length;b++){let p=i[b],y=Math.hypot(p.x-l.x,p.y-l.y),d=u.get(p.rowId);(!d||y>d.far)&&u.set(p.rowId,{seat:p,index:b,far:y})}for(let[b,p]of u){let y=p.seat.label?p.seat.label.lastIndexOf("-"):-1,d=y>0?p.seat.label.slice(0,y):b;d&&c.push({id:`row:${b}`,kind:"row",text:d,anchor:[p.seat.x*g,o.seatDeckY(p.index)+Go,p.seat.y*g],floorIndex:r[p.index]})}let h=new Map;for(let b=0;b<i.length;b++){let p=i[b],y=p.label?p.label.lastIndexOf("-"):-1,d=h.get(p.rowId);d||(d={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?p.label.slice(0,y):p.rowId,sectionId:p.sectionId},h.set(p.rowId,d));let x=b*3,T=a.iPosition[x],S=a.iPosition[x+1],C=a.iPosition[x+2];d.n++,d.x+=T,d.y+=S,d.z+=C,d.minX=Math.min(d.minX,T),d.maxX=Math.max(d.maxX,T),d.minZ=Math.min(d.minZ,C),d.maxZ=Math.max(d.maxZ,C)}for(let[b,p]of h)m.push({id:b,label:p.label,sectionId:p.sectionId,seatCount:p.n,center:[p.x/p.n,p.y/p.n,p.z/p.n],radius:Math.max(.8,Math.hypot(p.maxX-p.minX,p.maxZ-p.minZ)*.5)});if(i.length<=Xo)for(let b=0;b<i.length;b++){let p=i[b],y=p.displayLabel||p.label;y&&c.push({id:`seat:${p.id}`,kind:"seat",text:y,anchor:[p.x*g,o.seatDeckY(b)+Do,p.y*g],floorIndex:r[b]})}}for(let u of e)for(let h of u.objects)if(h.type==="shape"&&h.role&&["entrance","exit","screen","suite","obstruction"].includes(h.role)){let b=bt(h),p=b?Pt(b):null;if(!p||!h.label)continue;c.push({id:`architecture:${h.id}`,kind:"annotation",text:h.label,anchor:[p.x*g,u.baseHeightM+Ft(h).heightM+me,p.y*g],color:h.fill,floorIndex:u.index})}else if(h.type==="text"){if(!h.text)continue;c.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*g,u.baseHeightM+me,h.position.y*g],color:h.color,rotation:h.rotation,floorIndex:u.index})}else if(h.type==="booth"){let b=Ct(h);if(!b)continue;let p=Pt(b);if(!p)continue;c.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[p.x*g,u.baseHeightM+cn+Oo,p.y*g],floorIndex:u.index})}return{labels:c,sections:f,rows:m}}function be(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 pe(t){let{doc:n,units:e,seats:i,surfaces:o,solids:a,hintedSeatFloor:r,seatFloor:s}=t,l=[];{let c=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let u=0;u<a.floor.length;u+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(a.floor[u]))),b=u*3,p=c[h];p.minX=Math.min(p.minX,a.position[b]),p.minY=Math.min(p.minY,a.position[b+1]),p.minZ=Math.min(p.minZ,a.position[b+2]),p.maxX=Math.max(p.maxX,a.position[b]),p.maxY=Math.max(p.maxY,a.position[b+1]),p.maxZ=Math.max(p.maxZ,a.position[b+2])}let f=new Map;for(let u=0;u<e.length;u++)for(let h of e[u].objects)h.type==="section"&&f.set(h.id,u);let m=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 u=0;u<i.length;u++){let h=o.seatOwner[u],b=(h!==null?f.get(h):void 0)??r[u];if(b===void 0)continue;let p=m[b],y=i[u];p.n++,y.x<p.minX&&(p.minX=y.x),y.y<p.minY&&(p.minY=y.y),y.x>p.maxX&&(p.maxX=y.x),y.y>p.maxY&&(p.maxY=y.y);let d=o.seatDeckY(u);p.sumX+=y.x*g,p.sumDeck+=d,p.sumZ+=y.y*g,p.minDeck=Math.min(p.minDeck,d),p.maxDeck=Math.max(p.maxDeck,d+1.6),s[u]=b}for(let u=0;u<e.length;u++){let h=m[u],b=n.floors?.[u],p=c[u],y=Math.min(h.n?h.minX*g:e[u].focal.x*g-1,Number.isFinite(p.minX)?p.minX:1/0),d=Math.max(h.n?h.maxX*g:e[u].focal.x*g+1,Number.isFinite(p.maxX)?p.maxX:-1/0),x=Math.min(h.n?h.minY*g:e[u].focal.y*g-1,Number.isFinite(p.minZ)?p.minZ:1/0),T=Math.max(h.n?h.maxY*g:e[u].focal.y*g+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),S=Math.min(h.n?Math.min(e[u].baseHeightM,h.minDeck):e[u].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),C=Math.max(h.n?Math.max(h.maxDeck,S+.5):S+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),P=[h.n?h.sumX/h.n:(y+d)/2,h.n?h.sumDeck/h.n:(S+C)/2,h.n?h.sumZ/h.n:(x+T)/2],A=Math.max(1,.5*Math.hypot(d-y,C-S,T-x));l.push({index:u,id:b?.id??`floor-${u}`,label:b?.name??(e.length>1?`Floor ${u+1}`:"Venue"),seatCount:h.n,center:P,radius:A,box:{min:[y,S,x],max:[d,C,T]},focalWorld:[e[u].focal.x*g,e[u].baseHeightM+1.5,e[u].focal.y*g]})}}return l}function mn(t,n){let e=1/0,i=1/0,o=-1/0,a=-1/0,r=(s,l)=>{s<e&&(e=s),l<i&&(i=l),s>o&&(o=s),l>a&&(a=l)};for(let s of n)r(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let c of l.outline)r(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)r(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)r(c.x,c.y);else if(l.type==="booth"){let c=Ct(l);if(c)for(let f of c)r(f.x,f.y)}else if(l.type==="table"){let c=un(l);if(c)for(let f of c)r(f.x,f.y)}else if(l.type==="decorImage"){let c=ln(l);if(c)for(let f of c)r(f.x,f.y)}return Number.isFinite(e)||(e=-100,i=-100,o=100,a=100),{minX:e,minY:i,maxX:o,maxY:a}}function de(t,n,e,i,o,a){if(n.length===1){let r=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=_t(o.minX-r,o.minY-r,o.maxX-o.minX+r*2,o.maxY-o.minY+r*2);K(t,s,void 0,()=>0,-.4,a.ground,a.ground,W)}else{let r=n.reduce((h,b)=>b.baseHeightM<h.baseHeightM?b:h);t.setFloor(r.index);let s=e.filter((h,b)=>i[b]===r.index),l=mn([r],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),f=Math.max(28,Math.min(80,c*.04)),m=_t(l.minX-f,l.minY-f,l.maxX-l.minX+f*2,l.maxY-l.minY+f*2),u=r.baseHeightM-.03;K(t,m,void 0,()=>u,u-.22,a.ground,a.ground,W)}}function ye(t,n,e){let{cx:i,cz:o,radius:a}=e,r=1/0,s=1/0,l=1/0,c=-1/0,f=-1/0,m=-1/0,u=(p,y,d)=>{r=Math.min(r,p),c=Math.max(c,p),s=Math.min(s,y),f=Math.max(f,y),l=Math.min(l,d),m=Math.max(m,d)};for(let p=0;p<t.position.length;p+=3)u(t.position[p],t.position[p+1],t.position[p+2]);for(let p=0;p<n.count;p++){let y=p*3,d=n.iPosition[y],x=n.iPosition[y+1],T=n.iPosition[y+2],S=Math.max(.35,n.iMaxRadius[p]??.35);u(d-S,x,T-S),u(d+S,x+1.6,T+S)}Number.isFinite(r)||(r=i-a,c=i+a,s=0,f=a*.16,l=o-a,m=o+a);let h=[(r+c)/2,(s+f)/2,(l+m)/2],b=Math.max(1,.5*Math.hypot(c-r,f-s,m-l));return{center:h,radius:b,minY:s,maxY:f}}function xe(t,n,e,i,o,a){let r=1/0,s=1/0,l=-1/0,c=-1/0;for(let S=0;S<t.count;S++){let C=S*3,P=t.iPosition[C],A=t.iPosition[C+2];P<r&&(r=P),P>l&&(l=P),A<s&&(s=A),A>c&&(c=A)}for(let S of n)r=Math.min(r,S.cx-S.halfX),l=Math.max(l,S.cx+S.halfX),s=Math.min(s,S.cz-S.halfZ),c=Math.max(c,S.cz+S.halfZ);let f=e.minX*g,m=e.maxX*g,u=e.minY*g,h=e.maxY*g,b=f,p=m,y=u,d=h;if(Number.isFinite(r)){let S=Math.max(2,.06*Math.hypot(l-r,c-s));b=Math.max(f,r-S),p=Math.min(m,l+S),y=Math.max(u,s-S),d=Math.min(h,c+S)}let x=Math.min(0,i),T=Math.max(o,a*.05);return{min:[b,x,y],max:[p,T,d]}}function ge(t,n,e){let i=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return i();let o=bn(n);if(!o.ok||o.value.id!==t)return i();let a=new Map;for(let m of e)for(let u of m.objects)u.type==="shape"&&a.set(u.id,{shape:u,unit:m});let r=new Set,s=new Set,l=new Map((n.overlay.productionElements??[]).map(m=>{let u=m.runtimeContentImageUrl;return[m.id,typeof u=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(u)?u:void 0]})),c=[];for(let m of o.value.overlay.productionElements??[]){let u=a.get(m.objectId),h=u?bt(u.shape):null,b=m.baseElevationM??0;if(!u||!h||h.length<3||!m.id||r.has(m.id)||s.has(m.objectId)||!Number.isFinite(m.heightM)||m.heightM<.05||m.heightM>50||!Number.isFinite(b)||b<-10||b>100)return i();r.add(m.id),s.add(m.objectId);let p=h.map(E=>E.x*g),y=h.map(E=>E.y*g),d=u.unit.baseHeightM+b,x=Math.min(...p),T=Math.max(...p),S=Math.min(...y),C=Math.max(...y),P,A=l.get(m.id)??m.contentImageUrl;if(m.kind==="screen"&&A)if(T-x>=C-S){let E=Math.abs(S-u.unit.focal.y*g)<=Math.abs(C-u.unit.focal.y*g)?S-.006:C+.006;P=[[x,d,E],[T,d,E],[x,d+m.heightM,E],[T,d+m.heightM,E]]}else{let E=Math.abs(x-u.unit.focal.x*g)<=Math.abs(T-u.unit.focal.x*g)?x-.006:T+.006;P=[[E,d,S],[E,d,C],[E,d+m.heightM,S],[E,d+m.heightM,C]]}c.push({id:m.id,objectId:m.objectId,kind:m.kind,floorIndex:u.unit.index,baseY:d,topY:d+m.heightM,bounds:{min:[x,d,S],max:[T,d+m.heightM,C]},occlusion:m.occlusion,...A?{contentImageUrl:A}:{},...P?{contentPlane:P}:{}})}let f=c.sort((m,u)=>m.id.localeCompare(u.id));return{byObjectId:new Map(f.map(m=>[m.objectId,m])),elements:f}}function Q(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function J(t){return Array.isArray(t)?t:[]}function No(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Q(e))continue;let i=Q(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 Zt(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Uo(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Yo(t,n){let e=new Array(16).fill(0);for(let i=0;i<4;i++)for(let o=0;o<4;o++)for(let a=0;a<4;a++)e[i*4+o]+=t[a*4+o]*n[i*4+a];return e}function jo(t){let n=Zt(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Zt(t.translation,3),i=t.rotation===void 0?[0,0,0,1]:Zt(t.rotation,4),o=t.scale===void 0?[1,1,1]:Zt(t.scale,3);if(!e||!i||!o)return null;let[a,r,s,l]=i,c=Math.hypot(a,r,s,l);if(!(c>1e-8))return null;let f=a/c,m=r/c,u=s/c,h=l/c,b=f+f,p=m+m,y=u+u,d=f*b,x=f*p,T=f*y,S=m*p,C=m*y,P=u*y,A=h*b,E=h*p,v=h*y;return[(1-(S+P))*o[0],(x+v)*o[0],(T-E)*o[0],0,(x-v)*o[1],(1-(d+P))*o[1],(C+A)*o[1],0,(T+E)*o[2],(C-A)*o[2],(1-(d+S))*o[2],0,e[0],e[1],e[2],1]}function Ho(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 Vo(t){let n=t[0],e=t[4],i=t[8],o=t[1],a=t[5],r=t[9],s=t[2],l=t[6],c=t[10],f=a*c-r*l,m=r*s-o*c,u=o*l-a*s,h=n*f+e*m+i*u;if(Math.abs(h)<1e-12)return null;let b=1/h;return[f*b,m*b,u*b,(i*l-e*c)*b,(n*c-i*s)*b,(e*s-n*l)*b,(e*r-i*a)*b,(i*o-n*r)*b,(n*a-e*o)*b]}function Me(t,n,e,i){let o=t[0]*n+t[1]*e+t[2]*i,a=t[3]*n+t[4]*e+t[5]*i,r=t[6]*n+t[7]*e+t[8]*i,s=Math.hypot(o,a,r)||1;return o/=s,a/=s,r/=s,[o,a,r]}function Wo(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,o=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),r=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(r===1313821514&&!i)try{let l=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!Q(l))return null;i=l}catch{return null}else if(r===5130562&&!o)o=s;else return null;e+=a}return e===t.byteLength&&i&&o?{json:i,bin:o}:null}function zo(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function Zo(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Ko(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 $o(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Wo(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:i,bin:o}=e;if(!Q(i.asset)||i.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=J(i.extensionsUsed).filter(S=>typeof S=="string");if(a.includes("KHR_draco_mesh_compression")||No(i))return{ok:!1,issue:"draco_not_allowed"};if(a.length||J(i.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(J(i.images).length||J(i.textures).length)return{ok:!1,issue:"external_resource"};let r=J(i.buffers);if(r.length!==1||!Q(r[0])||r[0].uri!==void 0||typeof r[0].byteLength!="number"||!Number.isInteger(r[0].byteLength)||r[0].byteLength<0||r[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let s=J(i.accessors),l=J(i.bufferViews),c=J(i.meshes),f=J(i.nodes),m=J(i.scenes),u=typeof i.scene=="number"?i.scene:0;if(!Q(m[u]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),b=(S,C,P)=>{if(typeof S!="number"||!Number.isInteger(S)||!Q(s[S]))return null;let A=s[S];if(A.type!==C||A.sparse!==void 0||A.normalized===!0||typeof A.count!="number"||!Number.isInteger(A.count)||A.count<1||typeof A.componentType!="number"||!P.includes(A.componentType)||typeof A.bufferView!="number")return null;let E=l[A.bufferView];if(!Q(E)||E.buffer!==0||typeof E.byteLength!="number"||!Number.isInteger(E.byteLength)||E.byteLength<0)return null;let v=Zo(A.type),G=zo(A.componentType),X=typeof E.byteStride=="number"?E.byteStride:v*G,M=typeof E.byteOffset=="number"?E.byteOffset:0,B=typeof A.byteOffset=="number"?A.byteOffset:0,O=M+B,F=B+(A.count-1)*X+v*G;if(!Number.isInteger(X)||!Number.isInteger(M)||!Number.isInteger(B)||X<v*G||M<0||B<0||M+E.byteLength>o.byteLength||F>E.byteLength)return null;let I=[];for(let k=0;k<A.count;k++){let R=[];for(let _=0;_<v;_++){let w=Ko(h,O+k*X+_*G,A.componentType);if(!Number.isFinite(w))return null;R.push(w)}I.push(R)}return I},p=[],y=[],d=0,x=new Set,T=(S,C)=>{if(typeof S!="number"||!Number.isInteger(S)||!Q(f[S])||x.has(S))return!1;x.add(S);let P=f[S],A=jo(P);if(!A)return!1;let E=Yo(C,A),v=Vo(E);if(!v)return!1;if(P.mesh!==void 0){if(typeof P.mesh!="number")return!1;let G=c[P.mesh];if(!Q(G))return!1;for(let X of J(G.primitives)){if(!Q(X)||X.mode!==void 0&&X.mode!==4||!Q(X.attributes))return!1;let M=b(X.attributes.POSITION,"VEC3",[5126]),B=X.attributes.NORMAL===void 0?null:b(X.attributes.NORMAL,"VEC3",[5126]);if(!M||X.attributes.NORMAL!==void 0&&!B)return!1;let O=M.length;if(X.indices!==void 0){let I=typeof X.indices=="number"?s[X.indices]:null;O=Q(I)?I.count:void 0}if(typeof O!="number"||!Number.isInteger(O)||O%3!==0||(d+=O/3,d>1e5))return!1;let F=X.indices===void 0?M.map((I,k)=>[k]):b(X.indices,"SCALAR",[5121,5123,5125]);if(!F||F.length%3!==0||F.length!==O)return!1;for(let I=0;I<F.length;I+=3){let k=[F[I][0],F[I+1][0],F[I+2][0]];if(k.some(w=>!Number.isInteger(w)||w<0||w>=M.length))return!1;let R=k.map(w=>Ho(E,...M[w])),_=null;if(!B){let w=R[1][0]-R[0][0],D=R[1][1]-R[0][1],N=R[1][2]-R[0][2],U=R[2][0]-R[0][0],L=R[2][1]-R[0][1],Y=R[2][2]-R[0][2];_=Me([1,0,0,0,1,0,0,0,1],D*Y-N*L,N*U-w*Y,w*L-D*U)}for(let w=0;w<3;w++)p.push(...R[w]),y.push(...B?Me(v,...B[k[w]]):_)}}}for(let G of J(P.children))if(!T(G,E))return!1;return x.delete(S),!0};for(let S of J(m[u].nodes))if(!T(S,Uo()))return{ok:!1,issue:d>1e5?"triangle_limit":"unsupported_glb"};return!d||p.length!==d*9||y.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:d,position:new Float32Array(p),normal:new Float32Array(y)}}function Se(t){try{return $o(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function ps(t){let{doc:n}=t,e=Cn(n.theme),i=e.structure,o=zn(n,t.eventConfigurationId??n.eventConfigurationId),a=ge(t.eventConfigurationId,t.eventConfiguration,o),r=t.seats,s=new Yt,l=null;if(t.registeredShellGlb){let F=Se(t.registeredShellGlb);if(F.ok){let I=F.position.length/3,k=new Float32Array(F.position.length),R=e.materials.shell??i.tierWall;for(let _=0;_<I;_++){let w=F.normal[_*3+1],D=w<-.25?.4:.62+.38*Math.max(0,w);k[_*3]=R[0]*D,k[_*3+1]=R[1]*D,k[_*3+2]=R[2]*D}l={position:F.position,normal:F.normal,color:k,floor:new Float32Array(I).fill(-2),material:new Float32Array(I),count:I}}}let c=new Map;for(let F of o)for(let I of F.objects)c.set(I.id,F.index),I.type==="section"&&c.set(I.logicalSectionId??I.id,F.index);let f=r.map(F=>c.get(F.sectionId??"")??c.get(F.rowId??"")??0),m=mn(o,r);de(s,o,r,f,m,i);let u=Jn(n,r),h=new Map,b=new Map;for(let F of n.categories??[])h.set(F.key,F.color),F.seatGlyph&&b.set(F.key,F.seatGlyph);let p=[],y=qn(o,r,f),d=new Float32Array(r.length);for(let F=0;F<o.length;F++){let I=o[F];s.setFloor(F);let k=new zt,R=[],_=I.objects.filter(w=>w.type==="section"&&!!w.outline&&w.outline.length>=3);for(let w of I.objects)if(w.type==="section")ue(s,w,I,Qn(w,u),y.bySection.get(w.id),k,_,i);else if(w.type==="shape"){let D=a.byObjectId.get(w.id);s.setMaterial((D?.kind??w.role)==="screen"?1:0),ie(s,w,I.baseHeightM,te(w,R),i,I.focal,p,D),s.setMaterial(0)}else w.type==="gaArea"?ae(s,w,I.baseHeightM,H(h.get(w.categoryKey)),i):w.type==="booth"?oe(s,w,I.baseHeightM,H(h.get(w.categoryKey)),i):w.type==="table"?re(s,w,I.baseHeightM,H(h.get(w.categoryKey)),i):w.type==="decorImage"&&se(s,w,I.baseHeightM,i);le(s,I,r,y,i,e.materials.shell,!l)}let x=o.length>1?{x:o.reduce((F,I)=>F+I.focal.x,0)/o.length,y:o.reduce((F,I)=>F+I.focal.y,0)/o.length}:n.focalPoint??{x:(m.minX+m.maxX)/2,y:(m.minY+m.maxY)/2},T=Tn(l?[s.build(),l]:[s.build()]),S=En(r,t.initialState,y,d,h,b),C=fe({doc:n,units:o,seats:r,surfaces:y,focal:x}),{labels:P,sections:A,rows:E}=he({doc:n,units:o,seats:r,surfaces:y,seatData:S,hintedSeatFloor:f,zones:C,focal:x}),v=pe({doc:n,units:o,seats:r,surfaces:y,solids:T,hintedSeatFloor:f,seatFloor:d});be(P,v),S.iYaw=Fn(S.iPosition,r.length,F=>r[F].rowId,F=>{let I=o[d[F]]?.focal??x;return[I.x*g,I.y*g]});let G=(m.minX+m.maxX)/2*g,X=(m.minY+m.maxY)/2*g,M=.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||10,B=ye(T,S,{cx:G,cz:X,radius:M}),O=xe(S,p,m,B.minY,B.maxY,M);return{solids:T,seats:S,bounds:{center:[(O.min[0]+O.max[0])/2,(O.min[1]+O.max[1])/2,(O.min[2]+O.max[2])/2],radius:M,groundY:0,box:O},renderBounds:{center:B.center,radius:B.radius},stateColorLUT:vn(e,Bt),theme:e,seatCount:r.length,focalWorld:[x.x*g,1.5,x.y*g],zones:C,stages:p,productionElements:a.elements,sections:A,rows:E,labels:P,floors:v}}export{Bt as a,Qt as b,rr as c,nn as d,g as e,sr as f,Le as g,ar as h,Vt as i,dr as j,yr as k,Mr as l,Sr as m,Rr as n,Pr as o,Ar as p,Ir as q,wr as r,Tr as s,_r as t,Br as u,ps as v};
1
+ import{a as Pn,c as An,d as In}from"./chunk-KPSJDH3N.js";import{c as bn}from"./chunk-ALE2T36W.js";import{d as Rn}from"./chunk-BLPBTW6I.js";import{e as gn,k as Mn}from"./chunk-UL5OIGIF.js";import{f as hn,p as xn,r as Xt,s as ft,u as It,x as Sn}from"./chunk-YW2WGLRM.js";import{W as ut,X as lt,ea as Gt,ga as dn,ha as Dt,ja as yn,l as pn,m as Pt,va as qt}from"./chunk-KCFEFP6H.js";import{A as At,d as H,y as nt}from"./chunk-JBOTRSMY.js";import Re from"earcut";import Pe from"polygon-clipping";var g=ut,Ae=.002;function Ie(t,n,e){let i=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=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]),r=Math.max(i,o,a);if(r<1e-9)return!0;let s=(i+o+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-i)*(s-o)*(s-a)))/r<Ae}var ht=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)}},Yt=class{constructor(){this.pos=new ht;this.nor=new ht;this.col=new ht;this.flr=new ht;this.mat=new ht;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,i,o,a,r=a,s=a){Ie(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(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(r[0],r[1],r[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,o,a,r,s,l=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(o[0],o[1],o[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function we(t,n,e){let i=n[0]-t[0],o=n[1]-t[1],a=n[2]-t[2],r=e[0]-t[0],s=e[1]-t[1],l=e[2]-t[2],c=o*l-a*s,f=a*r-i*l,m=i*s-o*r,u=Math.hypot(c,f,m)||1;return c/=u,f/=u,m/=u,[c,f,m]}function Te(t,n){let e=[...t],i=[];for(let r of t)i.push(r.x,r.y);let o=[];if(n){for(let r of n)if(!(r.length<3)){o.push(e.length);for(let s of r)e.push(s),i.push(s.x,s.y)}}let a=Re(i,o.length?o:void 0,2);return{pts:e,tris:a}}function Jt(t){return ft(t)<0?[...t].reverse():t}var _e=3;function Be(t,n,e,i){let o=i(t),a=i(n),r=i(e),s=(h,b,p,y)=>Math.abs(i({x:(h.x+b.x)/2,y:(h.y+b.y)/2})-(p+y)/2),l=(t.x+n.x+e.x)/3,c=(t.y+n.y+e.y)/3,f=(o+a+r)/3,m=Math.max(s(t,n,o,a),s(n,e,a,r),s(e,t,r,o),Math.abs(i({x:l,y:c})-f)),u=(h,b,p)=>{let y=Math.abs(i({x:(h+l)/2,y:(b+c)/2})-(p+f)/2);y>m&&(m=y)};return u((t.x+n.x)/2,(t.y+n.y)/2,(o+a)/2),u((n.x+e.x)/2,(n.y+e.y)/2,(a+r)/2),u((e.x+t.x)/2,(e.y+t.y)/2,(r+o)/2),m}function wt(t,n,e,i,o){if(o<=0)return Be(t,n,e,i);let a={x:(t.x+n.x)/2,y:(t.y+n.y)/2},r={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(wt(t,a,s,i,o-1),wt(a,n,r,i,o-1),wt(s,r,e,i,o-1),wt(a,r,s,i,o-1))}function Tt(t,n,e,i,o,a,r,s){if(r>0){let u={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+i.x)/2,y:(e.y+i.y)/2},b={x:(i.x+n.x)/2,y:(i.y+n.y)/2};Tt(t,n,u,b,o,a,r-1,s),Tt(t,u,e,h,o,a,r-1,s),Tt(t,b,h,i,o,a,r-1,s),Tt(t,u,h,b,o,a,r-1,s);return}let l=[n.x*g,o(n),n.y*g],c=[e.x*g,o(e),e.y*g],f=[i.x*g,o(i),i.y*g];if(s){t.triN(l,c,f,s(n),s(e),s(i),a);return}let m=we(l,c,f);m[1]<0&&(m=[-m[0],-m[1],-m[2]]),t.tri(l,c,f,m,a)}var Fe=8;function wn(t,n,e){if(!Number.isFinite(e))return t;let i=[],o=(a,r,s,l,c)=>{if(c>0){let f={x:(a.x+r.x)/2,y:(a.y+r.y)/2},m=n(f);if(Math.abs(m-(s+l)/2)>e){o(a,f,s,m,c-1),o(f,r,m,l,c-1);return}}i.push(a)};for(let a=0;a<t.length;a++){let r=t[a],s=t[(a+1)%t.length];o(r,s,n(r),n(s),Fe)}return i}function Nt(t,n){if(t.length<3)return t;let e=[];for(let o of t){let a=e[e.length-1];a&&Math.hypot(o.x-a.x,o.y-a.y)<n||e.push(o)}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 o=0;o<e.length;o++){let a=i.length?i[i.length-1]:e[(o-1+e.length)%e.length],r=e[o],s=e[(o+1)%e.length],l=s.x-a.x,c=s.y-a.y,f=Math.hypot(l,c);f>n&&Math.abs((r.x-a.x)*c-(r.y-a.y)*l)/f<n||i.push(r)}return i.length>=3?i:e}var Ut=.001*lt*.1;function K(t,n,e,i,o,a,r,s,l=1/0,c){if(!n||n.length<3||(l===void 0&&(l=1/0),Math.abs(ft(n))<1e-4))return;let f=Nt(wn(Nt(Jt(n),Ut),i,l),Ut),m=e?.map(P=>Nt(wn(Nt(Jt(P),Ut),i,l),Ut)).filter(P=>P.length>=3&&Math.abs(ft(P))>=1e-4),{pts:u,tris:h}=Te(f,m),b=[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],y=[r[0]*s.top,r[1]*s.top,r[2]*s.top],d=[r[0]*s.wallBottom,r[1]*s.wallBottom,r[2]*s.wallBottom],x=0;if(Number.isFinite(l))for(;x<_e;x++){let P=0;for(let A=0;A<h.length;A+=3){let E=wt(u[h[A]],u[h[A+1]],u[h[A+2]],i,x);E>P&&(P=E)}if(P<=l)break}for(let P=0;P<h.length;P+=3){let A=u[h[P]],E=u[h[P+1]],v=u[h[P+2]];Tt(t,A,E,v,i,b,x,c);let G=[A.x*g,o,A.y*g],X=[E.x*g,o,E.y*g],M=[v.x*g,o,v.y*g];t.tri(G,M,X,[0,-1,0],p)}let T=P=>{if(x<=0)return P;let A=1<<x,E=[];for(let v=0;v<P.length;v++){let G=P[v],X=P[(v+1)%P.length];for(let M=0;M<A;M++){let B=M/A;E.push({x:G.x+(X.x-G.x)*B,y:G.y+(X.y-G.y)*B})}}return E},S=pn(f),C=[{ring:T(f),flip:!1}];if(m)for(let P of m)P.length>=3&&C.push({ring:T(P),flip:!0});for(let{ring:P,flip:A}of C)for(let E=0;E<P.length;E++){let v=P[E],G=P[(E+1)%P.length],X=(G.x-v.x)*g,B=(G.y-v.y)*g,O=-X,F=Math.hypot(B,O)||1;B/=F,O/=F;let I=(v.x+G.x)/2-S.x,k=(v.y+G.y)/2-S.y,R=B*I+O*k;A&&(R=-R),R<0&&(B=-B,O=-O);let _=[B,0,O],w=[v.x*g,i(v),v.y*g],D=[G.x*g,i(G),G.y*g],N=[v.x*g,o,v.y*g],U=[G.x*g,o,G.y*g];t.tri(w,D,U,_,y,y,d),t.tri(w,U,N,_,y,d,d)}}function Tn(t){let n=0;for(let l of t)n+=l.count;let e=new Float32Array(n*3),i=new Float32Array(n*3),o=new Float32Array(n*3),a=new Float32Array(n),r=new Float32Array(n),s=0;for(let l of t)e.set(l.position,s*3),i.set(l.normal,s*3),o.set(l.color,s*3),a.set(l.floor,s),r.set(l.material,s),s+=l.count;return{position:e,normal:i,color:o,floor:a,material:r,count:n}}function jt(t,n,e=2.5){if(n<=0||t.length<3)return t;let i=Jt(t),o=i.length,a=[];for(let s=0;s<o;s++){let l=i[s],c=i[(s+1)%o],f=c.x-l.x,m=c.y-l.y,u=Math.hypot(f,m)||1;a.push({x:m/u,y:-f/u})}let r=[];for(let s=0;s<o;s++){let l=i[s],c=a[(s-1+o)%o],f=a[s],m=c.x+f.x,u=c.y+f.y,h=Math.hypot(m,u),b=()=>{r.push([l.x+c.x*n,l.y+c.y*n]),r.push([l.x+f.x*n,l.y+f.y*n])};if(h<1e-9){b();continue}m/=h,u/=h;let p=m*c.x+u*c.y,y=1/Math.max(p,1e-6);if(!Number.isFinite(y)||y>e){b();continue}r.push([l.x+m*n*y,l.y+u*n*y])}if(r.length<3)return t;try{let s=Pe.union([[...r,r[0]]]),l=null,c=-1/0;for(let m of s){let u=Math.abs(ft(m[0].map(([h,b])=>({x:h,y:b}))));u>c&&(c=u,l=m[0])}if(!l)return t;let f=l.map(([m,u])=>({x:m,y:u}));if(f.length>1){let m=f[0],u=f[f.length-1];Math.abs(m.x-u.x)<1e-9&&Math.abs(m.y-u.y)<1e-9&&f.pop()}return f.length>=3?f:t}catch{return t}}function Ht(t,n,e,i,o=28){let a=[];for(let r=0;r<o;r++){let s=r/o*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+i*Math.sin(s)})}return a}function _t(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 Bt=["available","held","sold","selected","dimmed"];function Qt(t){let n=Bt.indexOf(t);return n<0?0:n}var _n={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function rr(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.42,i=.62;return[(n+(t[0]-n)*e)*i,(n+(t[1]-n)*e)*i,(n+(t[2]-n)*e)*i]}var tn={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]},nn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function et(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}var V={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Ee=.44,Ce=.15,ve=.3,ke=.24;function Bn(t){return t===void 0||!Number.isFinite(t)||t<=0?ke:Math.min(ve,Math.max(Ce,t*Ee))}var sr=.21,Oe=.05,en=.45,Le=en+Oe,Ge=[{part:V.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:V.pad,min:[-1,.36,-.95],max:[1,en,1]},{part:V.back,min:[-1,Le,-1],max:[1,.92,-.72]},{part:V.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:V.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:V.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:V.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:V.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:V.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:V.leg,min:[.62,0,.48],max:[.82,.37,.7]}],De=[{part:V.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:V.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:V.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:V.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:V.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Xe=[{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 ar(){let t=[],n=[],e=[],i=[],o=(F,I,k)=>{let R=e.length,[_,w,D]=F,N=[w[0]-_[0],w[1]-_[1],w[2]-_[2]],U=[D[0]-_[0],D[1]-_[1],D[2]-_[2]],L=N[1]*U[2]-N[2]*U[1],Y=N[2]*U[0]-N[0]*U[2],j=N[0]*U[1]-N[1]*U[0],$=Math.hypot(L,Y,j);$>1e-9?(L/=$,Y/=$,j/=$):[L,Y,j]=I,L*I[0]+Y*I[1]+j*I[2]<0&&(L=-L,Y=-Y,j=-j);for(let z of F)t.push(...z),n.push(L,Y,j),e.push(k);i.push(R,R+1,R+2,R,R+2,R+3)},a=F=>{for(let I of Xe){let k=I.c.map(R=>R.map((_,w)=>_?F.max[w]:F.min[w]));o(k,I.n,F.part)}};for(let F of Ge)a(F);for(let F of De)a(F);let r=en,s=1.08,l=.47,c=.69,f=-.55,m=.08,u=-.48,h=.01,b=[-l,r,f],p=[l,r,f],y=[-l,r,m],d=[l,r,m],x=[-c,s,u],T=[c,s,u],S=[-c,s,h],C=[c,s,h];o([p,T,C,d],[1,0,0],V.body),o([y,S,x,b],[-1,0,0],V.body),o([S,C,T,x],[0,1,0],V.body),o([b,p,d,y],[0,-1,0],V.body),o([d,C,S,y],[0,0,1],V.body),o([b,x,T,p],[0,0,-1],V.body);let P=10,A=8,E=[0,1.205,-.23],v=[.42,.115,.38],G=e.length;for(let F=0;F<=A;F++){let I=Math.PI*F/A,k=Math.cos(I),R=Math.sin(I);for(let _=0;_<=P;_++){let w=Math.PI*2*_/P,D=R*Math.cos(w),N=R*Math.sin(w);t.push(E[0]+v[0]*D,E[1]+v[1]*k,E[2]+v[2]*N);let U=D/v[0],L=k/v[1],Y=N/v[2],j=Math.hypot(U,L,Y)||1;U/=j,L/=j,Y/=j,n.push(U,L,Y),e.push(V.head)}}for(let F=0;F<A;F++)for(let I=0;I<P;I++){let k=G+F*(P+1)+I,R=k+P+1;i.push(k,R,k+1,k+1,R,R+1)}let X=new Float32Array(t),M=new Float32Array(n),B=new Float32Array(e),O=new Uint16Array(i);return{position:X,normal:M,part:B,index:O,vertexCount:e.length,indexCount:i.length}}function Fn(t,n,e,i){let o=new Float32Array(n),a=c=>t[c*3],r=c=>t[c*3+2],s=0,l=(c,f)=>{let m=f-c;for(let u=c;u<f;u++){let[h,b]=i(u),p=h-a(u),y=b-r(u);if(m>=2){let d=Math.max(c,u-1),x=Math.min(f-1,u+1),T=a(x)-a(d),S=r(x)-r(d),C=Math.hypot(T,S);if(C>1e-6){let P=-S/C,A=T/C;P*p+A*y<0&&(P=-P,A=-A),p=P,y=A}}o[u]=p===0&&y===0?0:Math.atan2(p,y)}};for(let c=1;c<=n;c++)(c===n||e(c)!==e(s))&&(l(s,c),s=c);return o}var Vt=.22;function dr(t,n){let e=Bt[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 Ne=.42;function Ue(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let i=1/0,o=1/0,a=-1/0,r=-1/0;for(let b of t)b.x<i&&(i=b.x),b.y<o&&(o=b.y),b.x>a&&(a=b.x),b.y>r&&(r=b.y);let s=Math.max(a-i,1e-6),l=Math.max(r-o,1e-6),c=Math.max(Math.sqrt(s*l/n),1e-6),f=Math.max(1,Math.ceil(s/c)+1),m=Math.max(1,Math.ceil(l/c)+1),u=new Map,h=(b,p)=>{let y=Math.min(f-1,Math.max(0,Math.floor((b-i)/c)));return Math.min(m-1,Math.max(0,Math.floor((p-o)/c)))*f+y};for(let b=0;b<n;b++){let p=h(t[b].x,t[b].y),y=u.get(p);y?y.push(b):u.set(p,[b])}for(let b=0;b<n;b++){let p=t[b],y=Math.min(f-1,Math.max(0,Math.floor((p.x-i)/c))),d=Math.min(m-1,Math.max(0,Math.floor((p.y-o)/c))),x=1/0;for(let T=1;T<=4;T++){for(let S=d-T;S<=d+T;S++)if(!(S<0||S>=m))for(let C=y-T;C<=y+T;C++){if(C<0||C>=f||T>1&&Math.abs(S-d)<T&&Math.abs(C-y)<T)continue;let P=u.get(S*f+C);if(P)for(let A of P){if(A===b)continue;let E=Math.hypot(t[A].x-p.x,t[A].y-p.y);E<x&&(x=E)}}if(Number.isFinite(x)&&x<=T*c)break}e[b]=x}return e}function Ye(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-Gt):0}function En(t,n,e,i,o,a){let r=t.length,s=new Float32Array(r*3),l=new Float32Array(r),c=new Float32Array(r*3),f=new Float32Array(r),m=new Float32Array(r),u=new Float32Array(r),h=new Float32Array(r),b=new Float32Array(r*3),p=new Map,y=Ue(t);for(let d=0;d<r;d++){let x=t[d],S=(e?.seatPitchU(d)??y[d])*g;f[d]=Number.isFinite(S)?Math.max(.06,Math.min(Vt,S*Ne)):Vt,m[d]=Bn(Number.isFinite(S)?S:void 0);let C=Mn(x.glyph,{seatGlyph:a?.get(x.categoryKey)});u[d]=gn.indexOf(C),h[d]=x.wheelchairSpaceType==="no-seat"?0:1,s[d*3]=x.x*g,s[d*3+1]=e?e.seatDeckY(d):Ye(x),s[d*3+2]=x.y*g,l[d]=Qt(n?n(x):"available");let P=H(o?.get(x.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[d*3]=P[0],c[d*3+1]=P[1],c[d*3+2]=P[2],x.accessibility?.length){let A=H(hn(x.accessibility));A&&(b[d*3]=A[0],b[d*3+1]=A[1],b[d*3+2]=A[2])}p.set(x.id,d)}return{count:r,iPosition:s,iState:l,iCategory:c,iMaxRadius:f,iRing:b,idToIndex:p,iChairWidth:m,iGlyph:u,iPhysicalSeat:h,iFloor:i??new Float32Array(r),iYaw:new Float32Array(r)}}var je=64;function yr(t,n){let e=[];for(let r of n){let s=t.idToIndex.get(r.seatId);if(s===void 0)continue;let l=Qt(r.state);t.iState[s]!==l&&(t.iState[s]=l,e.push(s))}if(!e.length)return[];e.sort((r,s)=>r-s);let i=[],o=e[0],a=e[0];for(let r=1;r<e.length;r++){let s=e[r];if(s!==a){if(s<=a+je){a=s;continue}i.push({start:o,length:a-o+1}),o=s,a=s}}return i.push({start:o,length:a-o+1}),i}function Mr(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 Sr(t,n){let e=[...t].sort((o,a)=>o.screen.y-a.screen.y),i=[];for(let o of e){let a=i.find(r=>r.some(s=>Math.abs(s.screen.x-o.screen.x)<104&&Math.abs(s.screen.y-o.screen.y)<34));a?a.push(o):i.push([o])}return i.flatMap(o=>o.length<2?o:o.map((a,r)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(r-(o.length-1)/2)*104))}})))}var He=1.15,Ve=2.75,We=4.5,ze=.85,Ze=.5,Ke=.26;function Rr(t,n,e){let i=Math.max(1e-6,n),o=t/i,a=e?.hasZoneLabels??!0,r=new Set;return o>=.75&&r.add("floor"),o>=He&&r.add("zone"),o<=(a?Ve:We)&&(r.add("section"),r.add("ga")),o<=ze&&(r.add("annotation"),r.add("booth")),o<=Ze&&r.add("row"),o<=Ke&&r.add("seat"),r}function Pr(t,n,e,i,o,a=6){let r=a+n,s=i-a-n,l=a+e,c=o-a-e;return{...t,x:r>s?i/2:Math.max(r,Math.min(s,t.x)),y:l>c?o/2:Math.max(l,Math.min(c,t.y))}}function Ar(t,n,e,i){let o=t,a=n[0],r=n[1],s=n[2],l=o[0]*a+o[4]*r+o[8]*s+o[12],c=o[1]*a+o[5]*r+o[9]*s+o[13],f=o[2]*a+o[6]*r+o[10]*s+o[14],m=o[3]*a+o[7]*r+o[11]*s+o[15];if(!(m>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let u=l/m,h=c/m,b=f/m,p=u>=-1.05&&u<=1.05&&h>=-1.05&&h<=1.05&&b<=1;return{x:(u*.5+.5)*e,y:(1-(h*.5+.5))*i,depth:b,visible:p}}function Ir(t,n,e=n){let i=[],o=[...t].sort((a,r)=>a.screen.depth-r.screen.depth);for(let a of o){let r=!1;for(let s of i)if(on(a,s,n,e)){r=!0;break}r||i.push(a)}return i}var $e=6;function on(t,n,e,i){let o=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),r=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+$e):e;return o<r&&a<i}function wr(t,n,e){return t.length*n*.58+(e?14:0)}var qe={row:8,seat:14};function Tr(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:qe}function _r(t,n,e,i){let o=Math.max(1,Math.min(e,i)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-i/2)/o);return n*(1+1.5*a)}function Br(t,n,e,i,o=[]){let a=[...t].sort((s,l)=>(l.priority??0)-(s.priority??0)||s.focus-l.focus),r=[];for(let s of a){if(r.length>=i)break;let l=!1;for(let c of o)if(on(s,c,n,e)){l=!0;break}if(!l){for(let c of r)if(on(s,c,n,e)){l=!0;break}}l||r.push(s)}return r}var Je=.15,Qe=.9,to=1.76;function no(){return{background:{top:[...nn.top],bottom:[...nn.bottom]},structure:tn,seatStates:{..._n},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function Cn(t){let n=no();if(!t)return n;let e=H(t.background);if(e){n.background={top:et(e,Qe),bottom:et(e,to)};let r={};for(let[s,l]of Object.entries(tn))r[s]=nt(l,e,Je);n.structure=r}let i=H(t.selectionColor)??H(t.accent);i&&(n.seatStates={...n.seatStates,selected:i});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=Sn(o));let a=t.venue3d;if(a){let r=H(a.deck),s=H(a.fascia);r&&(n.structure={...n.structure,tierTop:r,gaTop:r}),s&&(n.structure={...n.structure,tierWall:s,gaWall:s}),n.materials.seat=H(a.seat),n.materials.shell=H(a.shell),typeof a.roughness=="number"&&Number.isFinite(a.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,a.roughness)))}return n}function vn(t,n){let e=[];for(let i of n)e.push(...t.seatStates[i]);return e}import Gn from"polygon-clipping";import eo from"earcut";var oo=.58,kn=.01,ot=Vt*1.5*lt,ro=.5,io=.6;function so(t,n){let e=t.length,i=[];for(let r=0;r<e;r++){let s=t[Math.max(0,r-1)],l=t[Math.min(e-1,r+1)],c=l.x-s.x,f=l.y-s.y,m=Math.hypot(c,f);if(m<1e-9){i.push([0,0]);continue}c/=m,f/=m,i.push([-f,c])}let o=0;for(let r=0;r<e;r++)o+=(t[r].x-n.x)*i[r][0]+(t[r].y-n.y)*i[r][1];return o<0?i.map(([r,s])=>[-r,-s]):i}function ao(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],i=(r,s)=>{let l=s.x-r.x,c=s.y-r.y,f=Math.hypot(l,c)||1;return{x:l/f,y:c/f}},o=i(e[1],e[0]),a=i(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var On=Math.PI/12;function co(t){if(t.length<3)return[...t];let n=[...t].sort((a,r)=>a.x-r.x||a.y-r.y),e=(a,r,s)=>(r.x-a.x)*(s.y-a.y)-(r.y-a.y)*(s.x-a.x),i=a=>{let r=[];for(let s of a){for(;r.length>=2&&e(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return r.pop(),r},o=[...i(n),...i([...n].reverse())];return o.length>=3?o:[...t]}function Dn(t,n){if(!t.length||!(n>0))return[];let e=co(t),i=(s,l,c,f)=>{let m=c-l;for(;m<0;)m+=Math.PI*2;for(;m>Math.PI*2;)m-=Math.PI*2;let u=Math.max(1,Math.ceil(m/On)),h=n/Math.cos(m/u/2);for(let b=0;b<=u;b++){let p=l+m*b/u;f.push({x:s.x+Math.cos(p)*h,y:s.y+Math.sin(p)*h})}};if(e.length<3){let s=0,l=0;for(let h of e)s+=h.x,l+=h.y;s/=e.length||1,l/=e.length||1;let c=0;for(let h of e)c=Math.max(c,Math.hypot(h.x-s,h.y-l));let f=[],m=Math.max(3,Math.ceil(Math.PI*2/On)),u=(c+n)/Math.cos(Math.PI/m);for(let h=0;h<m;h++){let b=h/m*Math.PI*2;f.push({x:s+Math.cos(b)*u,y:l+Math.sin(b)*u})}return f}let o=e.length,a=[];for(let s=0;s<o;s++){let l=e[s],c=e[(s+1)%o];a.push(Math.atan2(-(c.x-l.x),c.y-l.y))}let r=[];for(let s=0;s<o;s++)i(e[s],a[(s+o-1)%o],a[s],r);return jn(r)}function uo(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let i=1/0;for(let o=0;o+1<t.length;o++){let a=t[o],r=t[o+1],s=r.x-a.x,l=r.y-a.y,c=s*s+l*l,f=c>1e-12?((n-a.x)*s+(e-a.y)*l)/c:0;f<0?f=0:f>1&&(f=1);let m=Math.hypot(n-(a.x+f*s),e-(a.y+f*l));m<i&&(i=m)}return i}function Wt(t){let n=t.map(o=>{let a=0,r=0;for(let c of o.pts)a+=c.x,r+=c.y;let s=o.pts.length||1;a/=s,r/=s;let l=0;for(let c of o.pts){let f=Math.hypot(c.x-a,c.y-r);f>l&&(l=f)}return{cx:a,cy:r,rad:l}}),e=o=>{let a=o.length;return a<=2?[...o]:[o[Math.floor(a*.25)],o[Math.floor(a*.5)],o[Math.floor(a*.75)]]},i=[];for(let o=0;o<t.length;o++){let a=e(t[o].pts),r=[],s=1/0,l=null;for(let f of a){let m=1/0;for(let u=0;u<t.length;u++){if(u===o||Math.abs(t[u].y-t[o].y)<.001)continue;let h=n[u],b=Math.hypot(f.x-h.cx,f.y-h.cy)-h.rad;if(b>=m&&b>=s)continue;let p=uo(t[u].pts,f.x,f.y);p<m&&(m=p),t[u].depth<t[o].depth&&p<s&&(s=p,l=t[u].y)}Number.isFinite(m)&&m>0&&r.push(m)}r.sort((f,m)=>f-m);let c=r.length?r[Math.floor(r.length/2)]:1;i.push({pitch:c,belowY:l})}return i}function Xn(t,n,e,i){let o=t[n],a=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let f=o.pts[0],m=f.x-i.x,u=f.y-i.y,h=Math.hypot(m,u)||1;m/=h,u/=h;let b=Math.max(e[n].pitch,.001)*.5;return[{x:f.x+u*b,y:f.y-m*b},{x:f.x-u*b,y:f.y+m*b}]})():[];if(a.length<2)return null;let r=0,s=0;for(let f=1;f<a.length;f++){let m=Math.hypot(a[f].x-a[f-1].x,a[f].y-a[f-1].y);m>1e-6&&(r+=m,s++)}let l=s>0?r/s:0,c=ao(a,Math.max(l*io,ot));return{pts:c,nrm:so(c,i),front:Math.max(e[n].pitch*oo,ot),back:Math.max(e[n].pitch*ro,ot)}}var gt=1.5,Nn=.3;function rn(t,n){if(t.length<3)return t;let e=t[0],i=t[t.length-1],o=i.x-e.x,a=i.y-e.y,r=Math.hypot(o,a),s=-1,l=-1;for(let m=1;m<t.length-1;m++){let u=t[m],h=r>1e-12?Math.abs((u.x-e.x)*a-(u.y-e.y)*o)/r:Math.hypot(u.x-e.x,u.y-e.y);h>s&&(s=h,l=m)}if(s<=n||l<0)return[e,i];let c=rn(t.slice(0,l+1),n),f=rn(t.slice(l),n);return[...c.slice(0,-1),...f]}function Un(t,n){if(t.length<4)return t;let e=rn([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function Yn(t,n,e){if(t.length<2)return[];let i=e??Wt(t),o=new Map;for(let r=0;r<t.length;r++){let s=o.get(t[r].blockId);s?s.push(r):o.set(t[r].blockId,[r])}let a=[];for(let[,r]of o){let s=[];for(let x of r){let T=t[x].patch;T&&T.length>=3?a.push({outline:[...T],holes:[],topY:t[x].y}):s.push(x)}if(!s.length)continue;s.sort((x,T)=>t[x].depth-t[T].depth);let c=s.map(x=>Xn(t,x,i,n)).filter(x=>x!==null);if(!c.length)continue;let f=(x,T)=>({x:x.pts[T].x-x.nrm[T][0]*(x.front+gt),y:x.pts[T].y-x.nrm[T][1]*(x.front+gt)}),m=(x,T)=>({x:x.pts[T].x+x.nrm[T][0]*(x.back+gt),y:x.pts[T].y+x.nrm[T][1]*(x.back+gt)}),u=c[0],h=c[c.length-1],b=[];for(let x=0;x<u.pts.length;x++)b.push(f(u,x));for(let x of c)b.push(m(x,x.pts.length-1));for(let x=h.pts.length-1;x>=0;x--)b.push(m(h,x));for(let x=c.length-1;x>=0;x--)b.push(f(c[x],0));let p=jn(b),y=1/0;for(let x of s)t[x].y<y&&(y=t[x].y);if(!Number.isFinite(y))continue;if(p.length>=3&&Math.abs(ft(p))>1e-6&&c.every(x=>{let T=x.pts[Math.floor(x.pts.length/2)];return It(p,T.x,T.y)})){a.push({outline:Un(p,Nn),holes:[],topY:y});continue}for(let x of lo(c))a.push({outline:x,holes:[],topY:y})}return a}function lo(t){let n=[];for(let e of t){let i=[],o=[],a=e.front+gt,r=e.back+gt;for(let l=0;l<e.pts.length;l++){let c=e.pts[l],f=e.nrm[l];i.push([c.x-f[0]*a,c.y-f[1]*a]),o.push([c.x+f[0]*r,c.y+f[1]*r])}let s=[...i,...o.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=Gn.union(n[0],...n.slice(1)),i=[];for(let o of e){if(!o.length||o[0].length<4)continue;let a=o[0].map(([l,c])=>({x:l,y:c})),r=a[0],s=a[a.length-1];a.length>1&&Math.abs(r.x-s.x)<1e-9&&Math.abs(r.y-s.y)<1e-9&&a.pop(),a.length>=3&&i.push(Un(a,Nn))}return i}catch{return[]}}function jn(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 sn=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 o of n)if(!It(e,o.x,o.y)){i=!1;break}if(i)return!0}return!1}};function Ln(t,n,e,i,o,a){if(i.length<3)return;if(e.containsAll(i)){let c=[0,1,0],f=i[0];for(let m=1;m+1<i.length;m++){let u=i[m],h=i[m+1];t.tri([f.x*g,o,f.y*g],[u.x*g,o,u.y*g],[h.x*g,o,h.y*g],c,a)}return}let r=i.map(c=>[c.x,c.y]);r.push(r[0]);let s;try{s=Gn.intersection([r],n)}catch{return}let l=[0,1,0];for(let c of s){if(!c.length||c[0].length<4)continue;let f=c[0],m=[],u=[];for(let b=0;b<f.length-1;b++)m.push(f[b][0],f[b][1]),u.push([f[b][0],f[b][1]]);if(u.length<3)continue;let h=eo(m,void 0,2);for(let b=0;b<h.length;b+=3){let p=u[h[b]],y=u[h[b+1]],d=u[h[b+2]];t.tri([p[0]*g,o,p[1]*g],[y[0]*g,o,y[1]*g],[d[0]*g,o,d[1]*g],l,a)}}}function Hn(t,n,e,i,o,a,r){if(n.length<2)return;let s=r??Wt(n),l=[0,1,0],c=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,f=a&&a.length>=3?new sn([[...a]]):null,m=h=>{t.setMaterial(2),h(),t.setMaterial(0)},u=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let b=n[h];if(b.patch&&b.patch.length>=3){let C=[...b.patch],P=s[h].belowY??i;if(u(()=>{if(c&&f)Ln(t,c,f,C,b.y,o.tread);else{let A=C[0];for(let E=1;E+1<C.length;E++){let v=C[E],G=C[E+1];t.tri([A.x*g,b.y,A.y*g],[v.x*g,b.y,v.y*g],[G.x*g,b.y,G.y*g],l,o.tread)}}}),b.y>P+kn){let A=0,E=0;for(let v of C)A+=v.x,E+=v.y;A/=C.length,E/=C.length,m(()=>{for(let v=0;v<C.length;v++){let G=C[v],X=C[(v+1)%C.length],M=X.x-G.x,B=X.y-G.y,O=Math.hypot(M,B);if(O<1e-6)continue;let F=B/O,I=-M/O;(G.x-A)*F+(G.y-E)*I<0&&(F=-F,I=-I);let k=[F,0,I],R=[G.x*g,b.y,G.y*g],_=[X.x*g,b.y,X.y*g],w=[G.x*g,P,G.y*g],D=[X.x*g,P,X.y*g];t.tri(R,_,D,k,o.riser),t.tri(R,D,w,k,o.riser)}})}continue}let p=Xn(n,h,s,e);if(!p)continue;let{pts:y,nrm:d,front:x,back:T}=p,S=s[h].belowY??i;for(let C=0;C+1<y.length;C++){let P=y[C],A=y[C+1],E=d[C],v=d[C+1];if(Math.hypot(A.x-P.x,A.y-P.y)<1e-6||E[0]===0&&E[1]===0||v[0]===0&&v[1]===0)continue;let G=[(P.x-E[0]*x)*g,b.y,(P.y-E[1]*x)*g],X=[(A.x-v[0]*x)*g,b.y,(A.y-v[1]*x)*g],M=[(P.x+E[0]*T)*g,b.y,(P.y+E[1]*T)*g],B=[(A.x+v[0]*T)*g,b.y,(A.y+v[1]*T)*g];if(u(()=>{c&&f?Ln(t,c,f,[{x:P.x-E[0]*x,y:P.y-E[1]*x},{x:A.x-v[0]*x,y:A.y-v[1]*x},{x:A.x+v[0]*T,y:A.y+v[1]*T},{x:P.x+E[0]*T,y:P.y+E[1]*T}],b.y,o.tread):(t.tri(G,X,B,l,o.tread),t.tri(G,B,M,l,o.tread))}),b.y>S+kn){let O=[G[0],S,G[2]],F=[X[0],S,X[2]],I=[-E[0],0,-E[1]];m(()=>{t.tri(G,X,F,I,o.riser),t.tri(G,F,O,I,o.riser)})}}}}import Wn from"polygon-clipping";function mo(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Vn(t,n){return t.filter(e=>e.type!=="shape"||mo(e,n))}function zn(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((i,o)=>({objects:Vn(i.objects,n),focal:{x:(i.focalPoint??e).x,y:(i.focalPoint??e).y},baseHeightM:i.baseHeightM??0,index:o})):[{objects:Vn(t.objects,n),focal:e,baseHeightM:0,index:0}]}var fo={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Mt(t){return xn(t)??fo}function Zn(t,n){let e=jt(t.outline,ot),i=Mt(e),o=n.filter(r=>r!==t&&r.outline&&r.outline.length>=3&&Xt(i,Mt(r.outline)));if(!o.length)return[e];let a=r=>{let s=r.map(l=>[l.x,l.y]);return s.push(s[0]),s};try{let r=Wn.difference([a(e)],...o.map(l=>[a(l.outline)])),s=[];for(let l of r){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s.length?s:[e]}catch{return[e]}}function Kn(t,n){if(!n.length)return t;let e=a=>{let r=a.map(s=>[s.x,s.y]);return r.push(r[0]),r},i=n.map(a=>[e(a)]),o=[];for(let a of t){let r;try{r=Wn.intersection([e(a.outline)],i.flat())}catch{o.push(a);continue}for(let s of r){if(!s.length)continue;let l=s[0].map(([c,f])=>({x:c,y:f}));if(l.length>1){let c=l[0],f=l[l.length-1];Math.abs(c.x-f.x)<1e-9&&Math.abs(c.y-f.y)<1e-9&&l.pop()}l.length>=3&&o.push({outline:l,holes:[],topY:a.topY})}}return o.length?o:t}var ho=.05,$n=.05,bo=.15,an=25;function qn(t,n,e){let i=new Map,o=new Array(n.length).fill(null),a=new Float64Array(n.length),r=new Array(n.length).fill(void 0),s=new Array(n.length).fill(void 0),l=new Map,c=[],f=new Set;for(let u=0;u<t.length;u+=1){let h=t[u];for(let b of h.objects){if(b.type==="table"&&f.add(b.id),b.type!=="section"||!b.outline||b.outline.length<3)continue;let p=jt(b.outline,ot);l.set(b.id,{section:b,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:b.id,floorIndex:u,box:Mt(p),section:b,unit:h,outline:p})}}let m=new Map;for(let u of c){let h=m.get(u.floorIndex);h?h.push(u):m.set(u.floorIndex,[u])}for(let u=0;u<n.length;u++){let h=n[u],b=e?m.get(e[u])??[]:c,p=h.sectionId?b.find(d=>d.id===h.sectionId)??b.find(d=>d.section.logicalSectionId===h.sectionId&&qt({x:h.x,y:h.y},d.outline,d.section.holes)):void 0,y=p?[p]:b;for(let d of y){if(e&&d.floorIndex!==e[u]||!p&&(h.x<d.box.minX||h.x>d.box.maxX||h.y<d.box.minY||h.y>d.box.maxY||!qt({x:h.x,y:h.y},d.outline,d.section.holes)))continue;o[u]=d.id;let x=l.get(d.id);x.hasSeats=!0;let T=h.focalPoint??d.unit.focal,S=Math.hypot(h.x-T.x,h.y-T.y);S<x.frontU&&(x.frontU=S),x.seatIndices.push(u);let C=h.rowId||`__seat-${u}`,P=x.rows.get(C);P?P.push({x:h.x,y:h.y}):x.rows.set(C,[{x:h.x,y:h.y}]);break}}for(let[u,h]of l){let b=dn(h.section,{floorBaseHeightM:h.unit.baseHeightM}),p=h.unit.baseHeightM,y=b.rake>0?Math.tan(b.rake*Math.PI/180):0,d=b.rake<=.01&&b.height<=p+.001,x=h.section.surfaceKind,T=x==="flat"?!0:x==="rakedRows"&&b.rake>.01?!1:d,S=h.hasSeats?yn(u,n,h.seatIndices,h.unit.focal):{sectionId:u,rows:[],blockCount:0},P=S.rows.length<2?Pn([...h.rows.values()].map(R=>({points:R})),h.unit.focal):null,A=1/0;if(P){if(h.hasSeats)for(let R of h.rows.values())for(let _ of R){let w=P.depthAt(_.x,_.y);w<A&&(A=w)}if(!h.hasSeats||!Number.isFinite(A)){A=1/0;for(let R of h.section.outline){let _=P.depthAt(R.x,R.y);_<A&&(A=_)}}}let E=p+ho,v=Math.max(E,b.height),G=R=>{let _=Math.max(0,R-A)*ut,w=Math.min(_*y,an);return Math.max(E,b.height+w)},X=R=>{let _=Math.max(0,R)*ut,w=Math.min(_*y,an);return Math.max(E,b.height+w)},M=T?[]:S.rows.map(R=>({pts:R.pts,y:X(R.blockDepth),depth:R.blockDepth,blockId:R.blockId,...f.has(R.id)?{patch:Dn(R.pts,ot)}:{}})),B=M.length?M[0].y:v,O=M.map(R=>{let _=R.patch&&R.patch.length>=3?R.patch:R.pts,w=0,D=0;for(let L of _)w+=L.x,D+=L.y;let N=_.length||1;w/=N,D/=N;let U=0;for(let L of _){let Y=Math.hypot(L.x-w,L.y-D);Y>U&&(U=Y)}return{cx:w,cy:D,rad:U}}),F=T?()=>v:M.length>=2?(R,_)=>{let w=1/0,D=B;for(let N=0;N<M.length;N++){let U=O[N];if(Math.hypot(R-U.cx,_-U.cy)-U.rad>=w)continue;let L=M[N].patch,Y=L&&L.length>=3?It(L,R,_)?0:Dt(L,R,_):Dt(M[N].pts,R,_);Y<w&&(w=Y,D=M[N].y)}return D}:(R,_)=>P?G(P.depthAt(R,_)):v,I=[0,1,0],k=M.length>=2||T?()=>I:(R,_)=>{if(!P)return I;let w=P.depthAt(R,_);if(w<=A)return I;let D=(w-A)*ut;if(D*y>=an||b.height+D*y<=E)return I;let[N,U]=P.gradientAt(R,_);if(N===0&&U===0)return I;let L=1/Math.hypot(y,1);return[-N*y*L,L,-U*y*L]};if(!T)for(let R of S.rows){let _=X(R.blockDepth);for(let w of R.seatIndices)r[w]=_}for(let R of S.rows){let _=[];for(let L=1;L<R.pts.length;L++){let Y=Math.hypot(R.pts[L].x-R.pts[L-1].x,R.pts[L].y-R.pts[L-1].y);Y>1e-6&&_.push(Y)}_.sort((L,Y)=>L-Y);let w=_.length?_[Math.floor(_.length/2)]:1/0,D=1/0,N=R.pts[Math.floor(R.pts.length/2)];if(N)for(let L of S.rows){if(L===R||L.blockId!==R.blockId)continue;let Y=Dt(L.pts,N.x,N.y);Y>1e-6&&Y<D&&(D=Y)}let U=Math.min(w,Math.max(D,w*.5));if(Number.isFinite(U)&&U>0)for(let L of R.seatIndices)s[L]=U}i.set(u,{sectionId:u,deckAt:F,normalAt:k,flat:T,bottomY:p,rowLevels:M,landingY:B})}for(let u=0;u<n.length;u++){let h=o[u],b=n[u];if(h){let y=r[u];a[u]=(y??i.get(h).deckAt(b.x,b.y))+bo;continue}let p=b.eyeHeightM;a[u]=Number.isFinite(p)?Math.max(0,p-Gt):0}return{bySection:i,seatOwner:o,seatDeckY:u=>a[u],seatPitchU:u=>s[u]}}var W={top:1,wallBottom:.5,bottomCap:.4};function st(t,n){if(!t)return n;let e=et(At(t,.4),.62);return nt(n,e,.72)}function Jn(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 r=i.get(a.sectionId);r||(r=new Map,i.set(a.sectionId,r)),r.set(a.categoryKey,(r.get(a.categoryKey)??0)+1)}let o=new Map;for(let[a,r]of i){let s=0,l=0,c=0,f=0;for(let[m,u]of r){let h=H(e.get(m));h&&(s+=h[0]*u,l+=h[1]*u,c+=h[2]*u,f+=u)}f>0&&o.set(a,[s/f,l/f,c/f])}return o}function Qn(t,n){return H(t.color)??n.get(t.logicalSectionId??t.id)??null}import po from"polygon-clipping";function yo(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var zt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let i=n.map(l=>[l.x,l.y]);if(i.length<3)return[];i.push(i[0]);let o=Mt(n),a=this.rings.filter((l,c)=>Xt(o,this.boxes[c])&&yo(e,this.levels[c])),r=[[i]];if(a.length)try{r=po.difference([i],...a).map(c=>c.map(f=>f.map(([m,u])=>[m,u])))}catch{r=[[i]]}this.rings.push([i]),this.boxes.push(o),this.levels.push(e);let s=[];for(let l of r){if(!l.length)continue;let c=l[0].map(([f,m])=>({x:f,y:m}));if(c.length>1){let f=c[0],m=c[c.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&c.pop()}c.length>=3&&s.push(c)}return s}};function xo(t,n){if(!n)return t;let e=1/0,i=-1/0,o=1/0,a=-1/0;for(let m of t)e=Math.min(e,m.x),i=Math.max(i,m.x),o=Math.min(o,m.y),a=Math.max(a,m.y);let r=(e+i)/2,s=(o+a)/2,l=n*Math.PI/180,c=Math.cos(l),f=Math.sin(l);return t.map(m=>{let u=m.x-r,h=m.y-s;return{x:r+u*c-h*f,y:s+u*f+h*c}})}function bt(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=_t(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=Ht(e,i,t.width/2,t.height/2)}return n?xo(n,t.rotation):null}function Ft(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"&&Rn(t.stageKind)?{kind:"stage",heightM:.06}:e[n]??{kind:"plate",heightM:.25};return{...i,heightM:t.heightM??i.heightM}}var go=.08;function te(t,n){let e=bt(t),i=Ft(t),o=i.heightM;if(!e||i.kind!=="plate"&&i.kind!=="stage")return o;let a=1/0,r=1/0,s=-1/0,l=-1/0;for(let f of e)a=Math.min(a,f.x),r=Math.min(r,f.y),s=Math.max(s,f.x),l=Math.max(l,f.y);let c=o;for(let f of n)s>f.minX&&a<f.maxX&&l>f.minY&&r<f.maxY&&c<=f.topOffsetM+1e-6&&(c=f.topOffsetM+go);return n.push({minX:a,minY:r,maxX:s,maxY:l,topOffsetM:c}),c}function mt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function ne(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 Et(t,n,e){return[mt(t[0],t[1],n),mt(t[0],t[1],e),mt(t[3],t[2],e),mt(t[3],t[2],n)]}function ee(t,n,e){return[mt(t[0],t[3],n),mt(t[1],t[2],n),mt(t[1],t[2],e),mt(t[0],t[3],e)]}function at(t,n,e,i,o,a){K(t,n,void 0,()=>e,i,o,a,W)}var cn=2.4,Mo=.75,So=.15;function Ct(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:i,rotation:o}=t;if(!e||!i)return null;let a=(o??0)*Math.PI/180,r=Math.cos(a),s=Math.sin(a),l=e/2,c=i/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:n.x+f*r-m*s,y:n.y+f*s+m*r}))}function oe(t,n,e,i,o){let a=Ct(n);a&&K(t,a,void 0,()=>e+cn,e,st(i,o.boothTop),o.boothWall,W)}function un(t){if(t.shape==="round"){let f=t.radius;return f?Ht(t.center.x,t.center.y,f,f,24):null}let{width:n,height:e,rotation:i,center:o}=t;if(!n||!e)return null;let a=(i??0)*Math.PI/180,r=Math.cos(a),s=Math.sin(a),l=n/2,c=e/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([f,m])=>({x:o.x+f*r-m*s,y:o.y+f*s+m*r}))}function re(t,n,e,i,o){let a=un(n);a&&K(t,a,void 0,()=>e+Mo,e,st(i,o.tableTop),o.tableWall,W)}function ie(t,n,e,i,o,a,r,s){let l=bt(n);if(!l)return;let c=s?s.kind==="stage":n.role==="stage",f=s?s.kind==="screen":n.role==="screen",m=s?{kind:c?"stage":"solid",heightM:s.topY-s.baseY}:Ft(n),u=s?.baseY??e,h=s?.topY??e+i;if(c&&r){let x=1/0,T=-1/0,S=1/0,C=-1/0;for(let P of l)P.x<x&&(x=P.x),P.x>T&&(T=P.x),P.y<S&&(S=P.y),P.y>C&&(C=P.y);r.push({cx:(x+T)/2*g,cz:(S+C)/2*g,y:h,halfX:Math.max((T-x)/2*g,.5),halfZ:Math.max((C-S)/2*g,.5)})}let b=H(n.fill),p=c&&b?nt(o.stageTop,et(At(b,.18),.9),.9):st(b,c?o.stageTop:o.decorTop),y=f?b:null,d=c?b?nt(o.stageWall,et(b,.58),.82):o.stageWall:f?y?nt(et(y,1.42),[.24,.46,.82],.08):[.24,.46,.82]:st(H(n.fill),o.decorWall);if(m.kind==="portal"&&l.length===4){let x=ne(l);at(t,Et(x,0,.16),h,u,p,d),at(t,Et(x,.84,1),h,u,p,d),at(t,x,h,Math.max(u,h-.35),p,d);return}if(m.kind==="suite"&&l.length===4){let x=l.map((C,P)=>{let A=l[(P+1)%4],E=(C.x+A.x)/2,v=(C.y+A.y)/2;return Math.hypot(E-a.x,v-a.y)}),T=x.indexOf(Math.min(...x)),S=[0,1,2,3].map(C=>l[(T+C)%4]);at(t,Et(S,0,.08),h,u,p,d),at(t,Et(S,.92,1),h,u,p,d),at(t,ee(S,.88,1),h,u,p,d),at(t,S,h,Math.max(u,h-.18),p,d);return}at(t,l,h,u,p,d)}function ln(t){let{x:n,y:e,width:i,height:o}=t;if(!i||!o)return null;let a=n+i/2,r=e+o/2,s=(t.rotation??0)*Math.PI/180,l=Math.cos(s),c=Math.sin(s),f=i/2,m=o/2;return[[-f,-m],[f,-m],[f,m],[-f,m]].map(([u,h])=>({x:a+u*l-h*c,y:r+u*c+h*l}))}function Ro(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 o=i.match(/^url\(#([^)]+)\)$/);if(!o)return H(i);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let r=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let l=H(s[1].trim());l&&r.push(l)}return r.length?r.reduce((s,l,c)=>nt(s,l,1/(c+1)),r[0]):null}function se(t,n,e,i){if(n.layer==="foreground")return;let o=ln(n);if(!o)return;let a=e+So,r=st(Ro(n.href),i.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(r=nt(i.ground,r,s)),K(t,o,void 0,()=>a,e,r,nt(r,i.decorWall,.5),W)}function ae(t,n,e,i,o){if(!n.points||n.points.length<3)return;let a=st(i,o.gaTop);K(t,n.points,n.holes,()=>e+.15,e,a,o.gaWall,W)}var Po=.25,Ao=1.2,Io=.6,wo=.45,To=2.3,_o=Math.PI/180;function pt(t,n,e){let i=e*_o;return{x:t.x+n*Math.sin(i),y:t.y+n*Math.cos(i)}}function Bo(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let i=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let a=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(a.length<2)continue;let r=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=i&&r++;if(r>=a.length/2)return!0}return!1}var Fo=24;function Eo(t,n,e,i,o,a,r,s){let l=e.binCount,c=Fo,f=ut,m=a+.02,u=[];for(let M=0;M<l;M++){let B=(e.startBin+M+.5)*n.binStepDeg,O=new Float64Array(c+1);for(let F=0;F<=c;F++){let I=i[M]+(o[M]-i[M])*F/c;O[F]=Math.max(m,In(n,e,B,I)-Po)}u.push(O)}let h=[r.bandTop[0]*s.top,r.bandTop[1]*s.top,r.bandTop[2]*s.top],b=[r.bandTop[0]*s.bottomCap,r.bandTop[1]*s.bottomCap,r.bandTop[2]*s.bottomCap],p=[r.bandWall[0]*s.top,r.bandWall[1]*s.top,r.bandWall[2]*s.top],y=[r.bandWall[0]*s.wallBottom,r.bandWall[1]*s.wallBottom,r.bandWall[2]*s.wallBottom],d=(M,B)=>{let O=(e.startBin+M+.5)*n.binStepDeg,F=i[M]+(o[M]-i[M])*B/c,I=pt(n.centre,F,O);return[I.x*f,u[M][B],I.y*f]};{let M=Math.tan(12*Math.PI/180);for(let B=0;B<6;B++){let O=!1;for(let I=0;I<l;I++)for(let k=c-1;k>=0;k--)u[I][k]>u[I][k+1]&&(u[I][k]=u[I][k+1],O=!0);let F=e.closed?l:l-1;for(let I=0;I<F;I++){let k=(I+1)%l;for(let R=0;R<=c;R++){let _=u[k][R]-u[I][R];if(Math.abs(_)>1)continue;let w=i[I]+(o[I]-i[I])*R/c,D=i[k]+(o[k]-i[k])*R/c,N=pt(n.centre,w,(e.startBin+I+.5)*n.binStepDeg),U=pt(n.centre,D,(e.startBin+k+.5)*n.binStepDeg),L=M*Math.hypot(U.x-N.x,U.y-N.y)*f;_>L?(u[k][R]=u[I][R]+L,O=!0):-_>L&&(u[I][R]=u[k][R]+L,O=!0)}}if(!O)break}}let x=1,T=(M,B)=>{for(let O=0;O<=c;O+=4)if(Math.abs(u[M][O]-u[B][O])>x)return!0;return Math.abs(u[M][c]-u[B][c])>x},S=Math.tan(38*Math.PI/180),C=M=>(o[M]-i[M])/c*f,P=(M,B)=>u[M][B+1]-u[M][B]>S*Math.max(1e-6,C(M)),A=(M,B)=>{let O=e.closed?(M-1+l)%l:Math.max(0,M-1),F=e.closed?(M+1)%l:Math.min(l-1,M+1);Math.abs(u[O][B]-u[M][B])>x&&(O=M),Math.abs(u[F][B]-u[M][B])>x&&(F=M);let I=Math.max(0,B-1),k=Math.min(c,B+1);I<B&&P(M,I)&&(I=B),k>B&&P(M,B)&&(k=B);let R=d(O,B),_=d(F,B),w=d(M,I),D=d(M,k),N=_[0]-R[0],U=_[1]-R[1],L=_[2]-R[2],Y=D[0]-w[0],j=D[1]-w[1],$=D[2]-w[2],z=U*$-L*j,q=L*Y-N*$,tt=N*j-U*Y,Z=Math.hypot(z,q,tt);return Z>1e-12?(z/=Z,q/=Z,tt/=Z,q<0&&(z=-z,q=-q,tt=-tt),[z,q,tt]):[0,1,0]},E=(M,B)=>{let O=[M[0],a,M[2]],F=[B[0],a,B[2]],I=B[0]-M[0],k=B[2]-M[2],R=Math.hypot(I,k);if(!(R>1e-12))return;let _=[k/R,0,-I/R];t.tri(M,B,F,_,p,p,y),t.tri(M,F,O,_,p,y,y)},v=.05*lt,G=M=>o[M]-i[M]<v,X=e.closed?l:l-1;for(let M=0;M<X;M++){let B=(M+1)%l;if(G(M)||G(B))continue;if(T(M,B)){let _=(e.startBin+M+1)*n.binStepDeg,w=(j,$)=>{let z=(i[M]+i[B])/2,q=(o[M]+o[B])/2,tt=z+(q-z)*$/c,Z=pt(n.centre,tt,_);return[Z.x*f,u[j][$],Z.y*f]};for(let j=0;j<c;j++){let $=d(M,j),z=d(M,j+1),q=w(M,j),tt=w(M,j+1),Z=A(M,j),it=A(M,j+1);t.triN($,q,tt,Z,Z,it,h),t.triN($,tt,z,Z,it,it,h);let vt=d(B,j),kt=d(B,j+1),dt=w(B,j),St=w(B,j+1),yt=A(B,j),xt=A(B,j+1);t.triN(dt,vt,kt,yt,yt,xt,h),t.triN(dt,kt,St,yt,xt,xt,h);let ct=w(M,j),rt=w(M,j+1),Ot=w(B,j+1),Kt=w(B,j),Lt=rt[0]-ct[0],Rt=rt[2]-ct[2],$t=Math.hypot(Lt,Rt);if($t>1e-12){let fn=[Rt/$t,0,-Lt/$t];t.tri(ct,rt,Ot,fn,p),t.tri(ct,Ot,Kt,fn,p)}}let D=d(M,0),N=d(B,0),U=d(B,c),L=d(M,c),Y=j=>[j[0],a,j[2]];t.tri(Y(D),Y(U),Y(N),[0,-1,0],b),t.tri(Y(D),Y(L),Y(U),[0,-1,0],b),E(D,N),E(L,U);continue}for(let _=0;_<c;_++){let w=A(M,_),D=A(B,_),N=A(B,_+1),U=A(M,_+1);if(P(M,_)||P(B,_)){let z=(rt,Ot)=>{let Kt=(e.startBin+rt+.5)*n.binStepDeg,Lt=i[rt]+(o[rt]-i[rt])*(_+.5)/c,Rt=pt(n.centre,Lt,Kt);return[Rt.x*f,Ot,Rt.y*f]},q=d(M,_),tt=d(B,_),Z=z(M,u[M][_]),it=z(B,u[B][_]);t.triN(q,tt,it,w,D,D,h),t.triN(q,it,Z,w,D,w,h);let vt=d(B,_+1),kt=d(M,_+1),dt=z(M,u[M][_+1]),St=z(B,u[B][_+1]);t.triN(dt,St,vt,U,N,N,h),t.triN(dt,vt,kt,U,N,U,h);let yt=it[0]-Z[0],xt=it[2]-Z[2],ct=Math.hypot(yt,xt);if(ct>1e-12){let rt=[-xt/ct,0,yt/ct];t.tri(Z,it,St,rt,p),t.tri(Z,St,dt,rt,p)}continue}let L=d(M,_),Y=d(B,_),j=d(B,_+1),$=d(M,_+1);t.triN(L,Y,j,w,D,N,h),t.triN(L,j,$,w,N,U,h)}let O=d(M,0),F=d(B,0),I=d(B,c),k=d(M,c),R=_=>[_[0],a,_[2]];t.tri(R(O),R(I),R(F),[0,-1,0],b),t.tri(R(O),R(k),R(I),[0,-1,0],b),E(O,F),E(k,I)}if(!e.closed)for(let M of[0,l-1])for(let B=0;B<c;B++)E(d(M,B),d(M,B+1))}function ce(t,n,e){let{bottomY:i,colors:o,ao:a}=e,r=new Float64Array(n.binCount).fill(-1/0);for(let f of n.rings)for(let m of f.arcs){let u=new Float64Array(m.binCount),h=new Float64Array(m.binCount);for(let p=0;p<m.binCount;p++){let y=(m.startBin+p)%n.binCount,d=Math.max(0,m.innerR[p]-ot);u[p]=Math.max(d,r[y]+.001),h[p]=Math.max(u[p]+.001,m.outerR[p]+ot)}let b=0;for(let p=0;p<m.binCount;p++){let y=m.topLevelM[p]-i;y>b&&(b=y)}b>=Ao&&Eo(t,n,m,u,h,i,o,a);for(let p=0;p<m.binCount;p++){let y=(m.startBin+p)%n.binCount;h[p]>r[y]&&(r[y]=h[p])}}if(e.deriveShell===!1||Bo(e.shapes,n))return;let s=n.rings[n.rings.length-1],l=Io*lt,c=wo*lt;for(let f of s.arcs){let m=[],u=[];for(let p=0;p<f.binCount;p++){let y=(f.startBin+p+.5)*n.binStepDeg,d=f.outerR[p]+ot+l;m.push(pt(n.centre,d,y)),u.push(pt(n.centre,d+c,y))}let h=-1/0;for(let p=0;p<f.binCount;p++)f.topLevelM[p]>h&&(h=f.topLevelM[p]);let b=()=>h+To;f.closed?K(t,u,[m.slice().reverse()],b,i,o.shellTop,o.shellWall,a):K(t,[...u,...m.slice().reverse()],void 0,b,i,o.shellTop,o.shellWall,a)}}function ue(t,n,e,i,o,a,r,s){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,c=st(i,s.tierTop);if(!o)return;let f=y=>o.deckAt(y.x,y.y),m=Zn(n,r),u=m[0]??n.outline;if(o.rowLevels.length>=2){let y=Wt(o.rowLevels),d=Kn(Yn(o.rowLevels,e.focal,y),m),x=()=>[0,1,0];for(let S of d){let C=Math.max(l,S.topY-.02);for(let P of a.subtract(S.outline,C))K(t,P,S.holes,()=>C,l,c,s.tierWall,W,void 0,x)}d.length||K(t,u,n.holes,()=>o.landingY,l,c,s.tierWall,W);let T={tread:[c[0]*W.top,c[1]*W.top,c[2]*W.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let S of m.length?m:[u])Hn(t,o.rowLevels,e.focal,o.landingY,T,S,y);return}let h=o.flat?1/0:$n,b=y=>o.normalAt(y.x,y.y),p=o.flat?o.landingY:void 0;for(let y of a.subtract(u,p))K(t,y,n.holes,f,l,c,s.tierWall,W,h,b)}function Co(t,n,e){let i=new Set;for(let r of t.objects)r.type==="section"&&i.add(r.id);let o=new Map;for(let r=0;r<n.length;r++){let s=e.seatOwner[r];if(!s||!i.has(s))continue;let l=e.bySection.get(s);if(l&&l.rowLevels.length>=2)continue;let c=n[r],f=o.get(s);f||(f=new Map,o.set(s,f));let m=c.rowId||`__seat-${r}`,u=f.get(m);u||(u={pts:[],levelM:0,n:0},f.set(m,u)),u.pts.push({x:c.x,y:c.y}),u.levelM+=e.seatDeckY(r),u.n++}let a=[];for(let r of t.objects){if(r.type!=="section")continue;let s=e.bySection.get(r.id);if(s&&s.rowLevels.length>=2){let c=s.rowLevels.filter(f=>!f.patch).map(f=>({pts:f.pts,levelM:f.y}));c.length>=2&&a.push({sectionId:r.id,rows:c});continue}let l=o.get(r.id);l&&a.push({sectionId:r.id,rows:[...l.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return a}function le(t,n,e,i,o,a,r=!0){let s=Co(n,e,i);if(!s.length)return;let l=An(s,n.focal);l&&(t.setMaterial(0),ce(t,l,{bottomY:n.baseHeightM,colors:{bandTop:et(o.tierTop,.8),bandWall:o.tierWall,shellTop:a??et(o.tierWall,1.15),shellWall:a??o.tierWall},ao:W,shapes:n.objects.filter(c=>c.type==="shape"),deriveShell:r}))}var vo=6,ko=2.2,me=.1,Oo=.3,Lo=1.8,Go=.9,Do=.55,Xo=6e3;function fe(t){let{doc:n,units:e,seats:i,surfaces:o,focal:a}=t,r=n.zones??[],s=[];if(r.length){let l=new Map;for(let f of e)for(let m of f.objects)m.type==="section"&&m.zone&&l.set(m.id,m.zone);let c=new Map;for(let f=0;f<i.length;f++){let m=i[f],u=o.seatOwner[f],h=m.zoneId??(u?l.get(u):void 0);if(!h)continue;let b=c.get(h);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(h,b)),b.n++,m.x<b.minX&&(b.minX=m.x),m.y<b.minY&&(b.minY=m.y),m.x>b.maxX&&(b.maxX=m.x),m.y>b.maxY&&(b.maxY=m.y),b.sumY+=o.seatDeckY(f)}for(let f of r){let m=c.get(f.id),u=[];for(let[h,b]of l)b===f.id&&u.push(h);if(!m||m.n===0){s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]});continue}s.push({id:f.id,label:f.label,color:H(f.color),sectionIds:u,seatCount:m.n,center:[(m.minX+m.maxX)/2*g,m.sumY/m.n,(m.minY+m.maxY)/2*g],radius:.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||1,focalWorld:[(f.focalPoint??a).x*g,1.5,(f.focalPoint??a).y*g]})}}return s}function he(t){let{doc:n,units:e,seats:i,surfaces:o,seatData:a,hintedSeatFloor:r,zones:s,focal:l}=t,c=[],f=[],m=[];for(let u of s)u.seatCount!==0&&c.push({id:`zone:${u.id}`,kind:"zone",text:u.label,anchor:[u.center[0],u.center[1]+vo,u.center[2]],color:n.zones?.find(h=>h.id===u.id)?.color});{let u=new Map,h=new Map;for(let b=0;b<i.length;b++){let p=o.seatOwner[b];if(!p)continue;let y=u.get(p);y||(y={n:0,x:0,y:0,deck:0},u.set(p,y)),y.n++,y.x+=i[b].x,y.y+=i[b].y,y.deck+=o.seatDeckY(b);let d=h.get(p);d||(d={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},h.set(p,d)),i[b].x<d.minX&&(d.minX=i[b].x),i[b].x>d.maxX&&(d.maxX=i[b].x),i[b].y<d.minY&&(d.minY=i[b].y),i[b].y>d.maxY&&(d.maxY=i[b].y)}for(let b of e)for(let p of b.objects){if(p.type!=="section")continue;let y=u.get(p.id);if(!y||y.n===0)continue;let d=h.get(p.id),x=[y.x/y.n*g,y.deck/y.n,y.y/y.n*g],T=p.displayLabel||p.label||p.id;f.push({id:p.id,floorIndex:b.index,label:T,seatCount:y.n,center:x,radius:Math.max(1,Math.hypot(d.maxX-d.minX,d.maxY-d.minY)*.5*g),focalWorld:[b.focal.x*g,b.baseHeightM+1.5,b.focal.y*g]});let S=n.floors?.[b.index]?.name?.trim().toLocaleLowerCase();e.length>1&&S===T.trim().toLocaleLowerCase()||c.push({id:`section:${p.id}`,kind:"section",text:T,anchor:[x[0],x[1]+ko,x[2]],floorIndex:b.index})}}{for(let b of e)for(let p of b.objects){if(p.type!=="gaArea")continue;let y=Pt(p.points);if(!y)continue;let d=p.displayLabel||p.label||p.id;c.push({id:`ga:${p.id}`,kind:"ga",text:p.capacity>0?`${d} \xB7 ${p.capacity.toLocaleString()}`:d,anchor:[y.x*g,b.baseHeightM+Lo,y.y*g],floorIndex:b.index})}let u=new Map;for(let b=0;b<i.length;b++){let p=i[b],y=Math.hypot(p.x-l.x,p.y-l.y),d=u.get(p.rowId);(!d||y>d.far)&&u.set(p.rowId,{seat:p,index:b,far:y})}for(let[b,p]of u){let y=p.seat.label?p.seat.label.lastIndexOf("-"):-1,d=y>0?p.seat.label.slice(0,y):b;d&&c.push({id:`row:${b}`,kind:"row",text:d,anchor:[p.seat.x*g,o.seatDeckY(p.index)+Go,p.seat.y*g],floorIndex:r[p.index]})}let h=new Map;for(let b=0;b<i.length;b++){let p=i[b],y=p.label?p.label.lastIndexOf("-"):-1,d=h.get(p.rowId);d||(d={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?p.label.slice(0,y):p.rowId,sectionId:p.sectionId},h.set(p.rowId,d));let x=b*3,T=a.iPosition[x],S=a.iPosition[x+1],C=a.iPosition[x+2];d.n++,d.x+=T,d.y+=S,d.z+=C,d.minX=Math.min(d.minX,T),d.maxX=Math.max(d.maxX,T),d.minZ=Math.min(d.minZ,C),d.maxZ=Math.max(d.maxZ,C)}for(let[b,p]of h)m.push({id:b,label:p.label,sectionId:p.sectionId,seatCount:p.n,center:[p.x/p.n,p.y/p.n,p.z/p.n],radius:Math.max(.8,Math.hypot(p.maxX-p.minX,p.maxZ-p.minZ)*.5)});if(i.length<=Xo)for(let b=0;b<i.length;b++){let p=i[b],y=p.displayLabel||p.label;y&&c.push({id:`seat:${p.id}`,kind:"seat",text:y,anchor:[p.x*g,o.seatDeckY(b)+Do,p.y*g],floorIndex:r[b]})}}for(let u of e)for(let h of u.objects)if(h.type==="shape"&&h.role&&["entrance","exit","screen","suite","obstruction"].includes(h.role)){let b=bt(h),p=b?Pt(b):null;if(!p||!h.label)continue;c.push({id:`architecture:${h.id}`,kind:"annotation",text:h.label,anchor:[p.x*g,u.baseHeightM+Ft(h).heightM+me,p.y*g],color:h.fill,floorIndex:u.index})}else if(h.type==="text"){if(!h.text)continue;c.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*g,u.baseHeightM+me,h.position.y*g],color:h.color,rotation:h.rotation,floorIndex:u.index})}else if(h.type==="booth"){let b=Ct(h);if(!b)continue;let p=Pt(b);if(!p)continue;c.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[p.x*g,u.baseHeightM+cn+Oo,p.y*g],floorIndex:u.index})}return{labels:c,sections:f,rows:m}}function be(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 pe(t){let{doc:n,units:e,seats:i,surfaces:o,solids:a,hintedSeatFloor:r,seatFloor:s}=t,l=[];{let c=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let u=0;u<a.floor.length;u+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(a.floor[u]))),b=u*3,p=c[h];p.minX=Math.min(p.minX,a.position[b]),p.minY=Math.min(p.minY,a.position[b+1]),p.minZ=Math.min(p.minZ,a.position[b+2]),p.maxX=Math.max(p.maxX,a.position[b]),p.maxY=Math.max(p.maxY,a.position[b+1]),p.maxZ=Math.max(p.maxZ,a.position[b+2])}let f=new Map;for(let u=0;u<e.length;u++)for(let h of e[u].objects)h.type==="section"&&f.set(h.id,u);let m=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 u=0;u<i.length;u++){let h=o.seatOwner[u],b=(h!==null?f.get(h):void 0)??r[u];if(b===void 0)continue;let p=m[b],y=i[u];p.n++,y.x<p.minX&&(p.minX=y.x),y.y<p.minY&&(p.minY=y.y),y.x>p.maxX&&(p.maxX=y.x),y.y>p.maxY&&(p.maxY=y.y);let d=o.seatDeckY(u);p.sumX+=y.x*g,p.sumDeck+=d,p.sumZ+=y.y*g,p.minDeck=Math.min(p.minDeck,d),p.maxDeck=Math.max(p.maxDeck,d+1.6),s[u]=b}for(let u=0;u<e.length;u++){let h=m[u],b=n.floors?.[u],p=c[u],y=Math.min(h.n?h.minX*g:e[u].focal.x*g-1,Number.isFinite(p.minX)?p.minX:1/0),d=Math.max(h.n?h.maxX*g:e[u].focal.x*g+1,Number.isFinite(p.maxX)?p.maxX:-1/0),x=Math.min(h.n?h.minY*g:e[u].focal.y*g-1,Number.isFinite(p.minZ)?p.minZ:1/0),T=Math.max(h.n?h.maxY*g:e[u].focal.y*g+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),S=Math.min(h.n?Math.min(e[u].baseHeightM,h.minDeck):e[u].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),C=Math.max(h.n?Math.max(h.maxDeck,S+.5):S+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),P=[h.n?h.sumX/h.n:(y+d)/2,h.n?h.sumDeck/h.n:(S+C)/2,h.n?h.sumZ/h.n:(x+T)/2],A=Math.max(1,.5*Math.hypot(d-y,C-S,T-x));l.push({index:u,id:b?.id??`floor-${u}`,label:b?.name??(e.length>1?`Floor ${u+1}`:"Venue"),seatCount:h.n,center:P,radius:A,box:{min:[y,S,x],max:[d,C,T]},focalWorld:[e[u].focal.x*g,e[u].baseHeightM+1.5,e[u].focal.y*g]})}}return l}function mn(t,n){let e=1/0,i=1/0,o=-1/0,a=-1/0,r=(s,l)=>{s<e&&(e=s),l<i&&(i=l),s>o&&(o=s),l>a&&(a=l)};for(let s of n)r(s.x,s.y);for(let s of t)for(let l of s.objects)if(l.type==="section")for(let c of l.outline)r(c.x,c.y);else if(l.type==="shape"&&l.points)for(let c of l.points)r(c.x,c.y);else if(l.type==="gaArea")for(let c of l.points)r(c.x,c.y);else if(l.type==="booth"){let c=Ct(l);if(c)for(let f of c)r(f.x,f.y)}else if(l.type==="table"){let c=un(l);if(c)for(let f of c)r(f.x,f.y)}else if(l.type==="decorImage"){let c=ln(l);if(c)for(let f of c)r(f.x,f.y)}return Number.isFinite(e)||(e=-100,i=-100,o=100,a=100),{minX:e,minY:i,maxX:o,maxY:a}}function de(t,n,e,i,o,a){if(n.length===1){let r=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),s=_t(o.minX-r,o.minY-r,o.maxX-o.minX+r*2,o.maxY-o.minY+r*2);K(t,s,void 0,()=>0,-.4,a.ground,a.ground,W)}else{let r=n.reduce((h,b)=>b.baseHeightM<h.baseHeightM?b:h);t.setFloor(r.index);let s=e.filter((h,b)=>i[b]===r.index),l=mn([r],s),c=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),f=Math.max(28,Math.min(80,c*.04)),m=_t(l.minX-f,l.minY-f,l.maxX-l.minX+f*2,l.maxY-l.minY+f*2),u=r.baseHeightM-.03;K(t,m,void 0,()=>u,u-.22,a.ground,a.ground,W)}}function ye(t,n,e){let{cx:i,cz:o,radius:a}=e,r=1/0,s=1/0,l=1/0,c=-1/0,f=-1/0,m=-1/0,u=(p,y,d)=>{r=Math.min(r,p),c=Math.max(c,p),s=Math.min(s,y),f=Math.max(f,y),l=Math.min(l,d),m=Math.max(m,d)};for(let p=0;p<t.position.length;p+=3)u(t.position[p],t.position[p+1],t.position[p+2]);for(let p=0;p<n.count;p++){let y=p*3,d=n.iPosition[y],x=n.iPosition[y+1],T=n.iPosition[y+2],S=Math.max(.35,n.iMaxRadius[p]??.35);u(d-S,x,T-S),u(d+S,x+1.6,T+S)}Number.isFinite(r)||(r=i-a,c=i+a,s=0,f=a*.16,l=o-a,m=o+a);let h=[(r+c)/2,(s+f)/2,(l+m)/2],b=Math.max(1,.5*Math.hypot(c-r,f-s,m-l));return{center:h,radius:b,minY:s,maxY:f}}function xe(t,n,e,i,o,a){let r=1/0,s=1/0,l=-1/0,c=-1/0;for(let S=0;S<t.count;S++){let C=S*3,P=t.iPosition[C],A=t.iPosition[C+2];P<r&&(r=P),P>l&&(l=P),A<s&&(s=A),A>c&&(c=A)}for(let S of n)r=Math.min(r,S.cx-S.halfX),l=Math.max(l,S.cx+S.halfX),s=Math.min(s,S.cz-S.halfZ),c=Math.max(c,S.cz+S.halfZ);let f=e.minX*g,m=e.maxX*g,u=e.minY*g,h=e.maxY*g,b=f,p=m,y=u,d=h;if(Number.isFinite(r)){let S=Math.max(2,.06*Math.hypot(l-r,c-s));b=Math.max(f,r-S),p=Math.min(m,l+S),y=Math.max(u,s-S),d=Math.min(h,c+S)}let x=Math.min(0,i),T=Math.max(o,a*.05);return{min:[b,x,y],max:[p,T,d]}}function ge(t,n,e){let i=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return i();let o=bn(n);if(!o.ok||o.value.id!==t)return i();let a=new Map;for(let m of e)for(let u of m.objects)u.type==="shape"&&a.set(u.id,{shape:u,unit:m});let r=new Set,s=new Set,l=new Map((n.overlay.productionElements??[]).map(m=>{let u=m.runtimeContentImageUrl;return[m.id,typeof u=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(u)?u:void 0]})),c=[];for(let m of o.value.overlay.productionElements??[]){let u=a.get(m.objectId),h=u?bt(u.shape):null,b=m.baseElevationM??0;if(!u||!h||h.length<3||!m.id||r.has(m.id)||s.has(m.objectId)||!Number.isFinite(m.heightM)||m.heightM<.05||m.heightM>50||!Number.isFinite(b)||b<-10||b>100)return i();r.add(m.id),s.add(m.objectId);let p=h.map(E=>E.x*g),y=h.map(E=>E.y*g),d=u.unit.baseHeightM+b,x=Math.min(...p),T=Math.max(...p),S=Math.min(...y),C=Math.max(...y),P,A=l.get(m.id)??m.contentImageUrl;if(m.kind==="screen"&&A)if(T-x>=C-S){let E=Math.abs(S-u.unit.focal.y*g)<=Math.abs(C-u.unit.focal.y*g)?S-.006:C+.006;P=[[x,d,E],[T,d,E],[x,d+m.heightM,E],[T,d+m.heightM,E]]}else{let E=Math.abs(x-u.unit.focal.x*g)<=Math.abs(T-u.unit.focal.x*g)?x-.006:T+.006;P=[[E,d,S],[E,d,C],[E,d+m.heightM,S],[E,d+m.heightM,C]]}c.push({id:m.id,objectId:m.objectId,kind:m.kind,floorIndex:u.unit.index,baseY:d,topY:d+m.heightM,bounds:{min:[x,d,S],max:[T,d+m.heightM,C]},occlusion:m.occlusion,...A?{contentImageUrl:A}:{},...P?{contentPlane:P}:{}})}let f=c.sort((m,u)=>m.id.localeCompare(u.id));return{byObjectId:new Map(f.map(m=>[m.objectId,m])),elements:f}}function Q(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function J(t){return Array.isArray(t)?t:[]}function No(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Q(e))continue;let i=Q(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 Zt(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Uo(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Yo(t,n){let e=new Array(16).fill(0);for(let i=0;i<4;i++)for(let o=0;o<4;o++)for(let a=0;a<4;a++)e[i*4+o]+=t[a*4+o]*n[i*4+a];return e}function jo(t){let n=Zt(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:Zt(t.translation,3),i=t.rotation===void 0?[0,0,0,1]:Zt(t.rotation,4),o=t.scale===void 0?[1,1,1]:Zt(t.scale,3);if(!e||!i||!o)return null;let[a,r,s,l]=i,c=Math.hypot(a,r,s,l);if(!(c>1e-8))return null;let f=a/c,m=r/c,u=s/c,h=l/c,b=f+f,p=m+m,y=u+u,d=f*b,x=f*p,T=f*y,S=m*p,C=m*y,P=u*y,A=h*b,E=h*p,v=h*y;return[(1-(S+P))*o[0],(x+v)*o[0],(T-E)*o[0],0,(x-v)*o[1],(1-(d+P))*o[1],(C+A)*o[1],0,(T+E)*o[2],(C-A)*o[2],(1-(d+S))*o[2],0,e[0],e[1],e[2],1]}function Ho(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 Vo(t){let n=t[0],e=t[4],i=t[8],o=t[1],a=t[5],r=t[9],s=t[2],l=t[6],c=t[10],f=a*c-r*l,m=r*s-o*c,u=o*l-a*s,h=n*f+e*m+i*u;if(Math.abs(h)<1e-12)return null;let b=1/h;return[f*b,m*b,u*b,(i*l-e*c)*b,(n*c-i*s)*b,(e*s-n*l)*b,(e*r-i*a)*b,(i*o-n*r)*b,(n*a-e*o)*b]}function Me(t,n,e,i){let o=t[0]*n+t[1]*e+t[2]*i,a=t[3]*n+t[4]*e+t[5]*i,r=t[6]*n+t[7]*e+t[8]*i,s=Math.hypot(o,a,r)||1;return o/=s,a/=s,r/=s,[o,a,r]}function Wo(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,o=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),r=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(r===1313821514&&!i)try{let l=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!Q(l))return null;i=l}catch{return null}else if(r===5130562&&!o)o=s;else return null;e+=a}return e===t.byteLength&&i&&o?{json:i,bin:o}:null}function zo(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function Zo(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Ko(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 $o(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Wo(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:i,bin:o}=e;if(!Q(i.asset)||i.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=J(i.extensionsUsed).filter(S=>typeof S=="string");if(a.includes("KHR_draco_mesh_compression")||No(i))return{ok:!1,issue:"draco_not_allowed"};if(a.length||J(i.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(J(i.images).length||J(i.textures).length)return{ok:!1,issue:"external_resource"};let r=J(i.buffers);if(r.length!==1||!Q(r[0])||r[0].uri!==void 0||typeof r[0].byteLength!="number"||!Number.isInteger(r[0].byteLength)||r[0].byteLength<0||r[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let s=J(i.accessors),l=J(i.bufferViews),c=J(i.meshes),f=J(i.nodes),m=J(i.scenes),u=typeof i.scene=="number"?i.scene:0;if(!Q(m[u]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),b=(S,C,P)=>{if(typeof S!="number"||!Number.isInteger(S)||!Q(s[S]))return null;let A=s[S];if(A.type!==C||A.sparse!==void 0||A.normalized===!0||typeof A.count!="number"||!Number.isInteger(A.count)||A.count<1||typeof A.componentType!="number"||!P.includes(A.componentType)||typeof A.bufferView!="number")return null;let E=l[A.bufferView];if(!Q(E)||E.buffer!==0||typeof E.byteLength!="number"||!Number.isInteger(E.byteLength)||E.byteLength<0)return null;let v=Zo(A.type),G=zo(A.componentType),X=typeof E.byteStride=="number"?E.byteStride:v*G,M=typeof E.byteOffset=="number"?E.byteOffset:0,B=typeof A.byteOffset=="number"?A.byteOffset:0,O=M+B,F=B+(A.count-1)*X+v*G;if(!Number.isInteger(X)||!Number.isInteger(M)||!Number.isInteger(B)||X<v*G||M<0||B<0||M+E.byteLength>o.byteLength||F>E.byteLength)return null;let I=[];for(let k=0;k<A.count;k++){let R=[];for(let _=0;_<v;_++){let w=Ko(h,O+k*X+_*G,A.componentType);if(!Number.isFinite(w))return null;R.push(w)}I.push(R)}return I},p=[],y=[],d=0,x=new Set,T=(S,C)=>{if(typeof S!="number"||!Number.isInteger(S)||!Q(f[S])||x.has(S))return!1;x.add(S);let P=f[S],A=jo(P);if(!A)return!1;let E=Yo(C,A),v=Vo(E);if(!v)return!1;if(P.mesh!==void 0){if(typeof P.mesh!="number")return!1;let G=c[P.mesh];if(!Q(G))return!1;for(let X of J(G.primitives)){if(!Q(X)||X.mode!==void 0&&X.mode!==4||!Q(X.attributes))return!1;let M=b(X.attributes.POSITION,"VEC3",[5126]),B=X.attributes.NORMAL===void 0?null:b(X.attributes.NORMAL,"VEC3",[5126]);if(!M||X.attributes.NORMAL!==void 0&&!B)return!1;let O=M.length;if(X.indices!==void 0){let I=typeof X.indices=="number"?s[X.indices]:null;O=Q(I)?I.count:void 0}if(typeof O!="number"||!Number.isInteger(O)||O%3!==0||(d+=O/3,d>1e5))return!1;let F=X.indices===void 0?M.map((I,k)=>[k]):b(X.indices,"SCALAR",[5121,5123,5125]);if(!F||F.length%3!==0||F.length!==O)return!1;for(let I=0;I<F.length;I+=3){let k=[F[I][0],F[I+1][0],F[I+2][0]];if(k.some(w=>!Number.isInteger(w)||w<0||w>=M.length))return!1;let R=k.map(w=>Ho(E,...M[w])),_=null;if(!B){let w=R[1][0]-R[0][0],D=R[1][1]-R[0][1],N=R[1][2]-R[0][2],U=R[2][0]-R[0][0],L=R[2][1]-R[0][1],Y=R[2][2]-R[0][2];_=Me([1,0,0,0,1,0,0,0,1],D*Y-N*L,N*U-w*Y,w*L-D*U)}for(let w=0;w<3;w++)p.push(...R[w]),y.push(...B?Me(v,...B[k[w]]):_)}}}for(let G of J(P.children))if(!T(G,E))return!1;return x.delete(S),!0};for(let S of J(m[u].nodes))if(!T(S,Uo()))return{ok:!1,issue:d>1e5?"triangle_limit":"unsupported_glb"};return!d||p.length!==d*9||y.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:d,position:new Float32Array(p),normal:new Float32Array(y)}}function Se(t){try{return $o(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function ps(t){let{doc:n}=t,e=Cn(n.theme),i=e.structure,o=zn(n,t.eventConfigurationId??n.eventConfigurationId),a=ge(t.eventConfigurationId,t.eventConfiguration,o),r=t.seats,s=new Yt,l=null;if(t.registeredShellGlb){let F=Se(t.registeredShellGlb);if(F.ok){let I=F.position.length/3,k=new Float32Array(F.position.length),R=e.materials.shell??i.tierWall;for(let _=0;_<I;_++){let w=F.normal[_*3+1],D=w<-.25?.4:.62+.38*Math.max(0,w);k[_*3]=R[0]*D,k[_*3+1]=R[1]*D,k[_*3+2]=R[2]*D}l={position:F.position,normal:F.normal,color:k,floor:new Float32Array(I).fill(-2),material:new Float32Array(I),count:I}}}let c=new Map;for(let F of o)for(let I of F.objects)c.set(I.id,F.index),I.type==="section"&&c.set(I.logicalSectionId??I.id,F.index);let f=r.map(F=>c.get(F.sectionId??"")??c.get(F.rowId??"")??0),m=mn(o,r);de(s,o,r,f,m,i);let u=Jn(n,r),h=new Map,b=new Map;for(let F of n.categories??[])h.set(F.key,F.color),F.seatGlyph&&b.set(F.key,F.seatGlyph);let p=[],y=qn(o,r,f),d=new Float32Array(r.length);for(let F=0;F<o.length;F++){let I=o[F];s.setFloor(F);let k=new zt,R=[],_=I.objects.filter(w=>w.type==="section"&&!!w.outline&&w.outline.length>=3);for(let w of I.objects)if(w.type==="section")ue(s,w,I,Qn(w,u),y.bySection.get(w.id),k,_,i);else if(w.type==="shape"){let D=a.byObjectId.get(w.id);s.setMaterial((D?.kind??w.role)==="screen"?1:0),ie(s,w,I.baseHeightM,te(w,R),i,I.focal,p,D),s.setMaterial(0)}else w.type==="gaArea"?ae(s,w,I.baseHeightM,H(h.get(w.categoryKey)),i):w.type==="booth"?oe(s,w,I.baseHeightM,H(h.get(w.categoryKey)),i):w.type==="table"?re(s,w,I.baseHeightM,H(h.get(w.categoryKey)),i):w.type==="decorImage"&&se(s,w,I.baseHeightM,i);le(s,I,r,y,i,e.materials.shell,!l)}let x=o.length>1?{x:o.reduce((F,I)=>F+I.focal.x,0)/o.length,y:o.reduce((F,I)=>F+I.focal.y,0)/o.length}:n.focalPoint??{x:(m.minX+m.maxX)/2,y:(m.minY+m.maxY)/2},T=Tn(l?[s.build(),l]:[s.build()]),S=En(r,t.initialState,y,d,h,b),C=fe({doc:n,units:o,seats:r,surfaces:y,focal:x}),{labels:P,sections:A,rows:E}=he({doc:n,units:o,seats:r,surfaces:y,seatData:S,hintedSeatFloor:f,zones:C,focal:x}),v=pe({doc:n,units:o,seats:r,surfaces:y,solids:T,hintedSeatFloor:f,seatFloor:d});be(P,v),S.iYaw=Fn(S.iPosition,r.length,F=>r[F].rowId,F=>{let I=o[d[F]]?.focal??x;return[I.x*g,I.y*g]});let G=(m.minX+m.maxX)/2*g,X=(m.minY+m.maxY)/2*g,M=.5*Math.hypot((m.maxX-m.minX)*g,(m.maxY-m.minY)*g)||10,B=ye(T,S,{cx:G,cz:X,radius:M}),O=xe(S,p,m,B.minY,B.maxY,M);return{solids:T,seats:S,bounds:{center:[(O.min[0]+O.max[0])/2,(O.min[1]+O.max[1])/2,(O.min[2]+O.max[2])/2],radius:M,groundY:0,box:O},renderBounds:{center:B.center,radius:B.radius},stateColorLUT:vn(e,Bt),theme:e,seatCount:r.length,focalWorld:[x.x*g,1.5,x.y*g],zones:C,stages:p,productionElements:a.elements,sections:A,rows:E,labels:P,floors:v}}export{Bt as a,Qt as b,rr as c,nn as d,g as e,sr as f,Le as g,ar as h,Vt as i,dr as j,yr as k,Mr as l,Sr as m,Rr as n,Pr as o,Ar as p,Ir as q,wr as r,Tr as s,_r as t,Br as u,ps as v};
@@ -0,0 +1 @@
1
+ import{a as Ne,c as _e,f as be,g as De,l as Ke,t as pe,v as Be}from"./chunk-FMZ6HLDH.js";import{h as Ue,q as Ve,s as Qe,t as qe,u as he,y as ve}from"./chunk-HXYWP6NX.js";import{a as ge,b as me,d as Re,f as Me,i as oe}from"./chunk-AM2LRFAY.js";import{c as Q,n as se,q as ze,t as z,x as Ge}from"./chunk-YW2WGLRM.js";import{$ as H,A as Oe,U as Ae,Z as le,_ as q,a as wt,aa as X,b as St,ba as de,c as xt,ca as ue,d as Ct,da as Ee,e as jt,f as $t,g as Ce,ga as Te,h as kt,i as Ot,j as je,k as $e,l as ce,ma as Fe,oa as K,pa as Le,sa as Y,va as te,w as ee,xa as fe,z as ke,za as ye}from"./chunk-KCFEFP6H.js";import{i as Pe,n as M}from"./chunk-JBOTRSMY.js";var Ie=[{key:"row-seats",label:"row seats",suffix:"rows",labelSuffix:"Rows",creationWord:"Seats",objectType:"row"},{key:"table-chairs",label:"table chairs",suffix:"tables",labelSuffix:"Tables",creationWord:"Tables",objectType:"table"},{key:"booth-units",label:"booth units",suffix:"booths",labelSuffix:"Booths",creationWord:"Booths",objectType:"booth"},{key:"ga-capacity",label:"GA capacity",suffix:"ga",labelSuffix:"GA",creationWord:"Standing",objectType:"gaArea"}];function He(t){return t.floors?.length?t.floors:[{id:"floor-0",objects:t.objects}]}function At(t){return Ie.find(e=>e.key===t)}function ie(t){let e=new Map,n=Math.max(0,Math.floor(t.seatCount)),i=new Map((t.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<t.seatCount).map(a=>[a.index,a])),r=(a,u=1)=>{a&&u>0&&e.set(a,(e.get(a)??0)+u)};r(t.categoryKey,n-i.size);for(let a of i.values())a.skip||r(a.categoryKey??t.categoryKey);return e}function Et(t){return t.type==="row"||t.type==="table"?[...ie(t).keys()]:t.type==="booth"?t.categoryKey?[t.categoryKey]:[]:t.type==="gaArea"?t.capacity>0&&t.categoryKey?[t.categoryKey]:[]:[]}function Xe(t){return Ie.find(e=>e.objectType===t.type)??null}function Ye(t){return t.type==="row"||t.type==="table"||t.type==="booth"||t.type==="gaArea"}function ne(t){let e=new Map;for(let r of He(t))for(let a of r.objects){if(!Ye(a))continue;let u=Xe(a);for(let y of Et(a)){let v=e.get(y)??new Map,d=v.get(u.key)??[];if(!d.some(f=>f.id===a.id)){let f=a.displayLabel||a.label||a.id;d.push({id:a.id,label:f,type:u.objectType,floorId:r.id})}v.set(u.key,d),e.set(y,v)}}let n=new Map(t.categories.map(r=>[r.key,r.label]));return[...t.categories.map(r=>r.key),...[...e.keys()].filter(r=>!n.has(r)).sort()].flatMap(r=>{let a=e.get(r);if(!a||a.size<2)return[];let u=Ie.flatMap(y=>{let v=a.get(y.key);return v?.length?[{family:y.key,label:y.label,objectType:y.objectType,targets:v}]:[]});return[{categoryKey:r,categoryLabel:n.get(r)??r,families:u,objectIds:[...new Set(u.flatMap(y=>y.targets.map(v=>v.id)))]}]})}function We(t){let e=t.families.map(n=>`${n.label} (${n.targets.map(i=>i.label).join(", ")})`).join(" and ");return`Category \u201C${t.categoryLabel}\u201D is used by more than one kind of inventory \u2014 ${e}. Each category can belong to only one kind \u2014 use the safe split to separate them (prices, ticket tiers, accessibility, and provenance are preserved).`}function Ze(t){return t.normalize("NFKC").trim().toLocaleLowerCase("en")}function Tt(t,e,n){for(let i=1;i<=1e4;i+=1){let r=i===1?`--${e}`:`--${e}-${i}`,u=`${t.slice(0,Math.max(1,160-r.length))}${r}`;if(!n.has(u))return n.add(u),u}throw new Error(`Unable to allocate a category key for ${t} (${e})`)}function Ft(t,e,n){for(let i=1;i<=1e4;i+=1){let r=i===1?` (${e})`:` (${e} ${i})`,u=`${t.normalize("NFKC").trim().slice(0,Math.max(1,80-r.length)).trimEnd()}${r}`,y=Ze(u);if(!n.has(y))return n.add(y),u}throw new Error(`Unable to allocate a category label for ${t} (${e})`)}function Lt(t,e,n,i){let r=At(e);return{...structuredClone(t),key:Tt(t.key,r.suffix,n),label:Ft(t.label,r.labelSuffix,i)}}function Rt(t,e,n){let i=[];for(let r of He(t))for(let a of r.objects){if(!Ye(a))continue;let u=Xe(a),y=n.get(u.key);if(!(!y||y===e))if(a.type==="row"||a.type==="table"){let v=[];a.categoryKey===e&&(a.categoryKey=y);for(let d of a.overrides??[])d.categoryKey===e&&(d.categoryKey=y,v.push(d.index));(a.categoryKey===y||v.length)&&i.push({family:u.key,floorId:r.id,objectId:a.id,objectType:u.objectType,fromCategoryKey:e,toCategoryKey:y,...v.length?{seatOverrideIndices:v.sort((d,f)=>d-f)}:{}})}else a.categoryKey===e&&(a.categoryKey=y,i.push({family:u.key,floorId:r.id,objectId:a.id,objectType:u.objectType,fromCategoryKey:e,toCategoryKey:y}))}return i}function Je(t){let e=structuredClone(t),n=ne(e);if(!n.length)return{doc:e,changed:!1,changes:[],before:n,after:n};let i=new Set(e.categories.map(y=>y.key)),r=new Set(e.categories.map(y=>Ze(y.label))),a=[];for(let y of n){let v=e.categories.findIndex(x=>x.key===y.categoryKey);if(v<0)continue;let d=e.categories[v],f=y.families[0].family,g=new Map([[f,d.key]]),p=y.families.slice(1).map(x=>{let A=Lt(d,x.family,i,r);return g.set(x.family,A.key),{family:x.family,key:A.key,label:A.label,category:A}});e.categories.splice(v+1,0,...p.map(x=>x.category));let b=Rt(e,d.key,g);a.push({categoryKey:d.key,categoryLabel:d.label,retainedFamily:f,clones:p.map(({family:x,key:A,label:S})=>({family:x,key:A,label:S})),reassignments:b})}e.floors?.length&&(e.objects=e.floors[0].objects);let u=ne(e);return{doc:e,changed:a.length>0,changes:a,before:n,after:u}}function Mt(t,e){return Math.abs(t.x-e.x)<=1e-7&&Math.abs(t.y-e.y)<=1e-7}function W(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)}function re(t,e,n){let i=W(e,n,t);return Math.abs(i)>1e-7?!1:t.x>=Math.min(e.x,n.x)-1e-7&&t.x<=Math.max(e.x,n.x)+1e-7&&t.y>=Math.min(e.y,n.y)-1e-7&&t.y<=Math.max(e.y,n.y)+1e-7}function Pt(t,e,n,i){let r=W(t,e,n),a=W(t,e,i),u=W(n,i,t),y=W(n,i,e);return(r>1e-7&&a<-1e-7||r<-1e-7&&a>1e-7)&&(u>1e-7&&y<-1e-7||u<-1e-7&&y>1e-7)?!0:Math.abs(r)<=1e-7&&re(n,t,e)||Math.abs(a)<=1e-7&&re(i,t,e)||Math.abs(u)<=1e-7&&re(t,n,i)||Math.abs(y)<=1e-7&&re(e,n,i)}function Nt(t){return t.reduce((e,n,i)=>{let r=t[(i+1)%t.length];return e+n.x*r.y-r.x*n.y},0)}function _t(t){for(let e=0;e<t.length;e+=1){let n=(e+1)%t.length;for(let i=e+1;i<t.length;i+=1){let r=(i+1)%t.length;if(!(e===i||n===i||r===e)&&Pt(t[e],t[n],t[i],t[r]))return!0}}return!1}function et(t){return t.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:t.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:t.some(e=>!Number.isFinite(e.x)||!Number.isFinite(e.y)||Math.abs(e.x)>1e7||Math.abs(e.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:t.some((e,n)=>Mt(e,t[(n+1)%t.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(Nt(t))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:_t(t)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function B(t){return t.length>=3&&t.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))}function U(t,e,n){let i=(t.y-e.y)*(n.x-e.x)-(t.x-e.x)*(n.y-e.y);if(Math.abs(i)>1e-7)return!1;let r=(t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y);if(r<-1e-7)return!1;let a=(n.x-e.x)**2+(n.y-e.y)**2;return r<=a+1e-7}function G(t,e){let n=!1;for(let i=0,r=e.length-1;i<e.length;r=i++){let a=e[r],u=e[i];if(U(t,a,u))return!0;a.y>t.y!=u.y>t.y&&t.x<(u.x-a.x)*(t.y-a.y)/(u.y-a.y)+a.x&&(n=!n)}return n}function D(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)}function ot(t,e,n,i){let r=D(t,e,n),a=D(t,e,i),u=D(n,i,t),y=D(n,i,e);return(r>1e-7&&a<-1e-7||r<-1e-7&&a>1e-7)&&(u>1e-7&&y<-1e-7||u<-1e-7&&y>1e-7)?!0:Math.abs(r)<=1e-7&&U(n,t,e)||Math.abs(a)<=1e-7&&U(i,t,e)||Math.abs(u)<=1e-7&&U(t,n,i)||Math.abs(y)<=1e-7&&U(e,n,i)}function V(t){for(let e=0;e<t.length;e+=1){let n=(e+1)%t.length;for(let i=e+1;i<t.length;i+=1){let r=(i+1)%t.length;if(!(e===i||n===i||r===e)&&ot(t[e],t[n],t[i],t[r]))return!0}}return!1}function Z(t,e){for(let n=0;n<t.length;n+=1)for(let i=0;i<e.length;i+=1)if(ot(t[n],t[(n+1)%t.length],e[i],e[(i+1)%e.length]))return!0;return G(t[0],e)||G(e[0],t)}function tt(t,e){return!e.some((n,i)=>U(t,n,e[(i+1)%e.length]))&&G(t,e)}function nt(t){let e=t.outlinePath;if(!e?.segments.length)return;let n=a=>Number.isFinite(a.x)&&Number.isFinite(a.y),i=(a,u)=>Math.hypot(a.x-u.x,a.y-u.y);if(!n(e.start))return 0;let r=e.start;for(let a=0;a<e.segments.length;a++){let u=e.segments[a];if(!u||!n(u.end)||i(r,u.end)<=1e-9||u.kind==="bezier"&&(!n(u.control1)||!n(u.control2)))return a;if(u.kind==="arc"){if(!n(u.center)||!Number.isFinite(u.radius)||u.radius<=1e-6)return a;let y=Math.max(1e-4,u.radius*1e-4);if(Math.abs(i(r,u.center)-u.radius)>y||Math.abs(i(u.end,u.center)-u.radius)>y)return a}r=u.end}return i(r,e.start)>1e-4,e.segments.length-1}function Dt(t,e,n,i){let r=D(t,e,n),a=D(t,e,i),u=D(n,i,t),y=D(n,i,e);return(r>1e-7&&a<-1e-7||r<-1e-7&&a>1e-7)&&(u>1e-7&&y<-1e-7||u<-1e-7&&y>1e-7)}function it(t,e){for(let n=0;n<t.length;n+=1)for(let i=0;i<e.length;i+=1)if(Dt(t[n],t[(n+1)%t.length],e[i],e[(i+1)%e.length]))return!0;return t.some(n=>tt(n,e))||e.some(n=>tt(n,t))}function rt(t){return t.role!=="reference-focal"||!t.points||!B(t.points)?null:t.points}function st(t,e){if(t.displayLabel!==void 0){let n=t.displayLabel.normalize("NFKC").trim();(!n||n!==t.displayLabel||n.length>80)&&e.push({severity:"error",code:"invalid-display-label",message:`${t.type==="gaArea"?"GA area":t.type} "${t.label}" must use a normalized buyer label of 1 to 80 characters`,objectId:t.id})}if(t.displayType!==void 0){let n=t.displayType.normalize("NFKC").trim();(!n||n!==t.displayType||n.length>24)&&e.push({severity:"error",code:"invalid-display-type",message:`${t.type==="gaArea"?"GA area":t.type} "${t.label}" must use a normalized buyer type of 1 to 24 characters`,objectId:t.id})}}function at(t,e,n,i){let r=t.crop,a=r&&(!Number.isFinite(r.x)||!Number.isFinite(r.y)||!Number.isFinite(r.width)||!Number.isFinite(r.height)||r.x<0||r.y<0||r.width<=0||r.height<=0||r.x+r.width>1.000001||r.y+r.height>1.000001);(!Number.isFinite(t.center?.x)||!Number.isFinite(t.center?.y)||!Number.isFinite(t.width)||t.width<=0||!Number.isFinite(t.opacity)||t.opacity<0||t.opacity>1||t.rotation!==void 0&&!Number.isFinite(t.rotation)||a)&&n.push({severity:"error",code:"invalid-background-placement",message:`The ${e} image has an invalid position, size, opacity, rotation, or crop`,...i?{floorId:i}:{}})}function we(t,e,n,i){let r=t.referenceImage,a=t.backgroundImage;r&&(at(r,"reference",e,i),!r.assetId&&!r.url&&e.push({severity:"error",code:"invalid-reference-image",message:"A trace reference must identify a private asset or self-contained image",...i?{floorId:i}:{}})),a&&(at(a,a.assetId?"legacy reference":"buyer background",e,i),!a.assetId&&!a.url&&e.push({severity:"error",code:"invalid-buyer-background",message:"A buyer background must contain a renderable image URL",...i?{floorId:i}:{}}),a.assetId&&n.push({severity:"warning",code:"legacy-reference-background",message:"This legacy asset-backed background is trace-only and will migrate to the private reference layer when edited",...i?{floorId:i}:{}})),Ue(t)&&e.push({severity:"error",code:"conflicting-reference-images",message:"The canonical reference and legacy asset-backed background identify different private sources",...i?{floorId:i}:{}})}function J(t){let e=new Set(Q.map(n=>n.key));return!t||/^ref_[0-9a-f-]{36}$/.test(t.assetId)&&!!t.logicalSectionId.trim()&&["user-confirmed","authoritative-source"].includes(t.evidence)&&!!t.sourceDescription.trim()&&(t.derivation===void 0||["explicit-inventory","server-synthesized-from-aggregate"].includes(t.derivation))&&(t.aggregateEvidence===void 0||["user-confirmed","authoritative-source"].includes(t.aggregateEvidence))&&(t.derivation!=="server-synthesized-from-aggregate"||t.evidence==="user-confirmed")&&(t.sectionAssignmentEvidence===void 0||["user-confirmed","authoritative-source"].includes(t.sectionAssignmentEvidence))&&t.sectionAssignmentEvidence===void 0==!t.sectionAssignmentSourceDescription?.trim()&&(t.sectionAssignmentSourceDescription?.trim().length??0)<=240&&(t.numberingEvidence===void 0||t.numberingEvidence==="user-confirmed")&&t.numberingEvidence===void 0==!t.numberingSourceDescription?.trim()&&(t.numberingSourceDescription?.trim().length??0)<=240&&(!t.accessibility||t.accessibility.placementDerivation==="server-synthesized-row-edges"&&t.accessibility.groupLogicalSectionIds.length>0&&t.accessibility.groupLogicalSectionIds.length<=100&&new Set(t.accessibility.groupLogicalSectionIds).size===t.accessibility.groupLogicalSectionIds.length&&t.accessibility.groupLogicalSectionIds.includes(t.logicalSectionId)&&t.accessibility.groupLogicalSectionIds.every(n=>!!n.trim()&&n.length<=160)&&["user-confirmed","authoritative-source"].includes(t.accessibility.assignmentEvidence)&&!!t.accessibility.assignmentSourceDescription.trim()&&t.accessibility.assignmentSourceDescription.trim().length<=240&&t.accessibility.counts.length>0&&t.accessibility.counts.length<=Q.length&&new Set(t.accessibility.counts.map(n=>n.type)).size===t.accessibility.counts.length&&t.accessibility.counts.every(n=>e.has(n.type)&&Number.isInteger(n.count)&&n.count>0&&["user-confirmed","authoritative-source"].includes(n.evidence)&&!!n.sourceDescription.trim()&&n.sourceDescription.trim().length<=240))}function ct(t){let e=t.referenceInventoryExclusion;return!e||typeof e.assetId=="string"&&/^ref_[0-9a-f-]{36}$/.test(e.assetId)&&e.assetId===t.referenceSource?.assetId&&typeof e.logicalSectionId=="string"&&e.logicalSectionId===(t.logicalSectionId??t.id)&&typeof e.reason=="string"&&!!e.reason.trim()&&e.reason.trim().length<=80&&["user-confirmed","authoritative-source"].includes(e.evidence)&&typeof e.sourceDescription=="string"&&!!e.sourceDescription.trim()&&e.sourceDescription.trim().length<=240}function lt(t){let e=t.referenceCategorySource;return!e||/^ref_[0-9a-f-]{36}$/.test(e.assetId)&&/^#[0-9a-f]{6}$/i.test(e.sourceColor)&&(e.sourceColors===void 0||e.sourceColors.length>0&&e.sourceColors.includes(e.sourceColor)&&new Set(e.sourceColors).size===e.sourceColors.length&&e.sourceColors.every(n=>/^#[0-9a-f]{6}$/i.test(n)&&`${n[1]}${n[3]}${n[5]}`.toLowerCase()===`${e.sourceColor[1]}${e.sourceColor[3]}${e.sourceColor[5]}`.toLowerCase()))&&(e.logicalSectionIds===void 0||e.logicalSectionIds.length>0&&new Set(e.logicalSectionIds).size===e.logicalSectionIds.length&&e.logicalSectionIds.every(n=>!!n.trim()&&n.length<=160))&&(e.assignmentDerivation===void 0||["source-color-class","confirmed-logical-sections"].includes(e.assignmentDerivation))&&e.assignmentEvidence===void 0==!e.assignmentSourceDescription?.trim()&&(e.assignmentEvidence===void 0||["user-confirmed","authoritative-source"].includes(e.assignmentEvidence))&&(e.assignmentSourceDescription?.trim().length??0)<=240&&(e.assignmentDerivation!=="confirmed-logical-sections"||e.assignmentEvidence!==void 0&&!!e.assignmentSourceDescription?.trim())&&e.sourcePaletteColor===void 0==(e.sourcePaletteColorEvidence===void 0)&&e.sourcePaletteColorEvidence===void 0==!e.sourcePaletteColorSourceDescription?.trim()&&(e.sourcePaletteColor===void 0||/^#[0-9a-f]{6}$/i.test(e.sourcePaletteColor))&&(e.sourcePaletteColorEvidence===void 0||["user-confirmed","authoritative-source"].includes(e.sourcePaletteColorEvidence))&&(e.sourcePaletteColorSourceDescription?.trim().length??0)<=240&&["user-confirmed","authoritative-source"].includes(e.labelEvidence)&&!!e.labelSourceDescription.trim()&&e.labelSourceDescription.trim().length<=240&&t.price!==void 0&&["user-confirmed","authoritative-source"].includes(e.priceEvidence)&&!!e.priceSourceDescription.trim()&&e.priceSourceDescription.trim().length<=240&&e.outputColorEvidence===void 0==!e.outputColorSourceDescription?.trim()&&(e.outputColorEvidence===void 0||["user-confirmed","authoritative-source"].includes(e.outputColorEvidence))&&(e.outputColorSourceDescription?.trim().length??0)<=240&&(t.color.toLowerCase()===(e.sourcePaletteColor??e.sourceColor).toLowerCase()&&new Set((e.sourceColors??[e.sourceColor]).map(n=>`${n[1]}${n[3]}${n[5]}`.toLowerCase())).size===1||e.outputColorEvidence!==void 0&&["user-confirmed","authoritative-source"].includes(e.outputColorEvidence))}function dt(t){let e=t.referenceDirectSeatImport;return!e||/^ref_[0-9a-f-]{36}$/.test(e.assetId)&&/^source-color:(?:#[0-9a-f]{6}(?:\+#[0-9a-f]{6})*|unclassified)$/i.test(e.familyId)}function ut(t,e){let n=t.floors?.length?t.floors.map(a=>({id:a.id,objects:a.objects})):[{id:"floor-0",objects:t.objects}],i=new Map,r=new Map;for(let a of n){let u=a.objects.filter(d=>d.type==="row"),y=new Map,v=new Map;for(let d of u){if(d.segmentedRow){let f=y.get(d.segmentedRow.groupId)??[];f.push(d),y.set(d.segmentedRow.groupId,f)}if(d.rowBlockGeneration){let f=v.get(d.rowBlockGeneration.groupId)??[];f.push(d),v.set(d.rowBlockGeneration.groupId,f)}d.segmentedRow&&d.rowBlockGeneration&&e.push({severity:"error",code:"invalid-row-group-membership",message:`Row "${d.label}" cannot be both a segmented-row component and a generated row-block member`,objectId:d.id,floorId:a.id})}for(let[d,f]of y){let g=i.get(d);g&&g!==a.id&&e.push({severity:"error",code:"invalid-segmented-row",message:`Segmented row "${d}" cannot span multiple floors`,objectId:f[0].id,floorId:a.id}),i.set(d,a.id);let p=f.slice().sort(($,T)=>$.segmentedRow.componentIndex-T.segmentedRow.componentIndex),b=p[0]?.segmentedRow,x=b?.componentCount??0,A=b?JSON.stringify({displayLabel:b.displayLabel,repeatLabelOnComponents:b.repeatLabelOnComponents,displayType:b.displayType,labelPresentation:b.labelPresentation,viewFromSeatUrl:b.viewFromSeatUrl,viewFromSeatMeta:b.viewFromSeatMeta,confidenceEvidence:b.confidenceEvidence,smoothing:b.smoothing}):"";b&&x>=2&&x<=64&&p.length===x&&b.boundaryBefore==="start"&&p.every(($,T)=>{let j=$.segmentedRow;return j.kind==="segmented-row-v1"&&j.groupId===d&&j.componentCount===x&&j.componentIndex===T&&(T===0?j.boundaryBefore==="start":j.boundaryBefore!=="start")&&j.displayLabel.normalize("NFKC").trim()===j.displayLabel&&j.displayLabel.length>0&&j.displayLabel.length<=80&&JSON.stringify({displayLabel:j.displayLabel,repeatLabelOnComponents:j.repeatLabelOnComponents,displayType:j.displayType,labelPresentation:j.labelPresentation,viewFromSeatUrl:j.viewFromSeatUrl,viewFromSeatMeta:j.viewFromSeatMeta,confidenceEvidence:j.confidenceEvidence,smoothing:j.smoothing})===A})||e.push({severity:"error",code:"invalid-segmented-row",message:`Segmented row "${d}" has missing, duplicated, cyclic, or inconsistent component metadata`,objectId:f[0]?.id,floorId:a.id})}for(let[d,f]of v){let g=r.get(d);g&&g!==a.id&&e.push({severity:"error",code:"invalid-row-block-generation",message:"A generated row block cannot span multiple floors",objectId:f[0].id,floorId:a.id}),r.set(d,a.id)}}}function Kt(t){return t.type==="row"||t.type==="table"||t.type==="booth"}function Bt(t){let e=[],n=new Map((t.overrides??[]).map(i=>[i.index,i]));for(let i=0;i<t.seatCount;i++){let r=n.get(i);r?.skip||e.push({label:Ae(t,i,r),index:i})}return e}function ft(t){let e=[],n=new Map((t.overrides??[]).map(i=>[i.index,i]));for(let i=0;i<t.seatCount;i++){let r=n.get(i);r?.skip||e.push({label:r?.label??`${t.label}-${i+1}`,index:i})}return e}function yt(t){let e=[];t.eventConfigurationId!==void 0&&(typeof t.eventConfigurationId!="string"||t.eventConfigurationId.normalize("NFKC").trim()!==t.eventConfigurationId||t.eventConfigurationId.length<1||t.eventConfigurationId.length>100)&&e.push({severity:"error",code:"invalid-event-configuration",message:"Active event configuration must contain 1 to 100 normalized characters"});let n=[],i=new Set(t.categories.map(o=>o.key)),r=new Set(Q.map(o=>o.key)),a=new Map(t.categories.map(o=>[o.key,o.price!=null||o.notForSale===!0])),u=new Set;we(t,e,n),t.theme?.logoUrl!==void 0&&!se(t.theme.logoUrl)&&e.push({severity:"error",code:"invalid-theme-logo-url",message:"The buyer-facing theme logo URL is invalid"});let y=se,v=(o,I,s,l={})=>{if(I===void 0)return;if(!I||typeof I!="object"||Array.isArray(I)){e.push({severity:"error",code:"invalid-seat-view-metadata",message:`${s} view metadata is invalid`,...l});return}let c=I;o||n.push({severity:"warning",code:"orphaned-seat-view-metadata",message:`${s} view metadata has no image`,...l});let h=new Set(["exact-seat","row-representative","section-representative","floor-representative","venue-representative"]);c.projection!==void 0&&c.projection!=="equirectangular"&&e.push({severity:"error",code:"invalid-seat-view-projection",message:`${s} view projection must be equirectangular`,...l}),c.coverage!==void 0&&!h.has(c.coverage)&&e.push({severity:"error",code:"invalid-seat-view-coverage",message:`${s} view coverage is invalid`,...l});let m=(w,C,k)=>typeof w=="number"&&Number.isFinite(w)&&w>=C&&w<=k;if(c.initialBearingDeg!==void 0&&!m(c.initialBearingDeg,-360,360)&&e.push({severity:"error",code:"invalid-seat-view-bearing",message:`${s} view bearing must be between -360\xB0 and 360\xB0`,...l}),c.initialPitchDeg!==void 0&&!m(c.initialPitchDeg,-90,90)&&e.push({severity:"error",code:"invalid-seat-view-pitch",message:`${s} view pitch must be between -90\xB0 and 90\xB0`,...l}),c.capturedAt!==void 0&&(typeof c.capturedAt!="string"||c.capturedAt.length>40||!Number.isFinite(Date.parse(c.capturedAt)))&&e.push({severity:"error",code:"invalid-seat-view-capture-date",message:`${s} view capture date is invalid`,...l}),c.sourceLabel!==void 0&&(typeof c.sourceLabel!="string"||c.sourceLabel.trim().length>100)&&e.push({severity:"error",code:"invalid-seat-view-source",message:`${s} view source label is invalid`,...l}),c.previewUrl!==void 0&&!y(c.previewUrl)&&e.push({severity:"error",code:"invalid-seat-view-preview-url",message:`${s} view preview URL is invalid`,...l}),c.variants!==void 0){let w=Array.isArray(c.variants)?c.variants:[];if(!Array.isArray(c.variants)||w.length<1||w.length>4)e.push({severity:"error",code:"invalid-seat-view-variants",message:`${s} view variants must contain between 1 and 4 tiers`,...l});else{let C=new Set;for(let k of w){if(!k||typeof k!="object"||!y(k.url)||!Number.isInteger(k.width)||k.width<1||k.width>12e3||!Number.isInteger(k.height)||k.height<1||k.height>12e3||k.width!==k.height*2||typeof k.sha256!="string"||!/^[a-f0-9]{64}$/.test(k.sha256)||C.has(k.width)){e.push({severity:"error",code:"invalid-seat-view-variant",message:`${s} view variant is not a unique immutable 2:1 equirectangular tier`,...l});break}C.add(k.width)}}}for(let[w,C]of[["width",c.sourceWidth],["height",c.sourceHeight],["preview width",c.previewWidth],["preview height",c.previewHeight]])C!==void 0&&(!Number.isInteger(C)||C<1||C>32768)&&e.push({severity:"error",code:"invalid-seat-view-dimensions",message:`${s} view source ${w} is invalid`,...l});c.captureEyeHeightM!==void 0&&!m(c.captureEyeHeightM,.5,3)&&e.push({severity:"error",code:"invalid-seat-view-eye-height",message:`${s} capture eye height must be between 0.5 m and 3 m`,...l}),c.eventConfigurationId!==void 0&&(typeof c.eventConfigurationId!="string"||!c.eventConfigurationId.trim()||c.eventConfigurationId.length>100)&&e.push({severity:"error",code:"invalid-seat-view-configuration",message:`${s} event configuration id is invalid`,...l}),c.eventConfigurationVersion!==void 0&&(!Number.isInteger(c.eventConfigurationVersion)||c.eventConfigurationVersion<1)&&e.push({severity:"error",code:"invalid-seat-view-configuration-version",message:`${s} event configuration version is invalid`,...l}),c.eventConfigurationVersion!==void 0&&!c.eventConfigurationId&&e.push({severity:"error",code:"invalid-seat-view-configuration-pin",message:`${s} event configuration version requires an id`,...l})},d=(o,I,s={})=>{if(o===void 0)return;let l=C=>{e.push({severity:"error",code:"invalid-seat-confidence-evidence",message:`${I} confidence evidence ${C}`,...s})};if(!o||typeof o!="object"||Array.isArray(o)){l("is invalid");return}let c=o;c.schema!=="seatlayer.seat-confidence/1"&&l("has an unsupported schema");let h=(C,k)=>typeof C=="string"&&C.normalize("NFKC").trim()===C&&C.length>0&&C.length<=k;h(c.evidenceId,120)||l("has an invalid evidence id"),h(c.modelVersion,120)||l("has an invalid model version"),new Set(["synthetic-model","organizer-approved","calibrated-provider"]).has(c.evidenceKind)||l("has an invalid evidence kind"),new Set(["generated","geometry-verified","configuration-verified"]).has(c.modelLevel)||l("has an invalid model level");let m=c.realityLevel??"none";new Set(["none","comparable-build-reference","actual-build-checked"]).has(m)||l("has an invalid reality level"),c.eventConfigurationId!==void 0&&!h(c.eventConfigurationId,100)&&l("has an invalid event configuration id"),c.eventConfigurationVersion!==void 0&&(!Number.isInteger(c.eventConfigurationVersion)||c.eventConfigurationVersion<1)&&l("has an invalid event configuration version"),c.status!==void 0&&!new Set(["draft","approved","retracted"]).has(c.status)&&l("has an invalid publication status"),c.basisSha256!==void 0&&!/^[a-f0-9]{64}$/.test(c.basisSha256)&&l("has an invalid venue basis SHA-256"),c.basisSha256!==void 0&&c.status!=="approved"&&l("can carry a venue basis SHA-256 only after approval");for(let[C,k]of[["assessment",c.assessedAt],["expiry",c.validUntil]])k!==void 0&&(!h(k,40)||!Number.isFinite(Date.parse(k)))&&l(`has an invalid ${C} date`);c.approvedByRole!==void 0&&!h(c.approvedByRole,100)&&l("has an invalid approving organization or role"),c.sourceLabel!==void 0&&!h(c.sourceLabel,120)&&l("has an invalid source label"),c.limitations!==void 0&&(!Array.isArray(c.limitations)||c.limitations.length>6||c.limitations.some(C=>!h(C,160)))&&l("has invalid limitations"),c.evidenceKind==="synthetic-model"&&(c.modelLevel!=="generated"||m!=="none")&&l("cannot describe synthetic data as verified or reality checked"),c.modelLevel!=="generated"&&(!c.assessedAt||!c.approvedByRole)&&l("requires an assessment date and approving organization or role for verified model levels"),c.modelLevel==="configuration-verified"&&!c.eventConfigurationId&&l("requires an event configuration id for configuration verification"),m!=="none"&&(!c.assessedAt||!c.sourceLabel)&&l("requires an assessment date and source for reality evidence"),m==="actual-build-checked"&&(c.modelLevel!=="configuration-verified"||!c.eventConfigurationId)&&l("requires a configuration-verified model and event configuration for an actual-build check");let w=c.modeledTarget;w!==void 0&&(!w||typeof w!="object"||Array.isArray(w)?l("has an invalid modeled target"):((!h(w.label,80)||!h(w.methodLabel,100))&&l("has invalid modeled-target labels"),(!Number.isInteger(w.totalRayCount)||w.totalRayCount<1||w.totalRayCount>1e3||!Number.isInteger(w.clearRayCount)||w.clearRayCount<0||w.clearRayCount>w.totalRayCount)&&l("has invalid modeled-target ray counts"),new Set(["clear","partial","obstructed"]).has(w.classification)||l("has an invalid modeled-target classification"),w.occluderLabels!==void 0&&(!Array.isArray(w.occluderLabels)||w.occluderLabels.length>10||w.occluderLabels.some(C=>!h(C,100)))&&l("has invalid modeled-target occluders")))};v(t.viewFromSeatUrl,t.viewFromSeatMeta,"Venue"),d(t.confidenceEvidence,"Venue"),t.viewFromSeatUrl!==void 0&&!y(t.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-venue-view-url",message:"The whole-venue view-from-seat image URL is invalid"});for(let o of t.floors??[])o.viewFromSeatUrl!==void 0&&!y(o.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-floor-view-url",message:`Floor "${o.name}" has an invalid view-from-seat image URL`}),v(o.viewFromSeatUrl,o.viewFromSeatMeta,`Floor "${o.name}"`,{floorId:o.id}),d(o.confidenceEvidence,`Floor "${o.name}"`,{floorId:o.id});let f=t.floors?.length?t.floors.flatMap(o=>o.objects):t.objects;for(let o of f)if((o.type==="row"||o.type==="section")&&(o.viewFromSeatUrl!==void 0&&!y(o.viewFromSeatUrl)&&e.push({severity:"error",code:o.type==="row"?"invalid-row-view-url":"invalid-section-view-url",message:`${o.type==="row"?"Row":"Section"} "${o.label}" has an invalid view-from-seat image URL`,objectId:o.id}),v(o.viewFromSeatUrl,o.viewFromSeatMeta,`${o.type==="row"?"Row":"Section"} "${o.label}"`,{objectId:o.id}),d(o.confidenceEvidence,`${o.type==="row"?"Row":"Section"} "${o.label}"`,{objectId:o.id})),o.type==="row"&&o.segmentedRow&&(o.segmentedRow.viewFromSeatUrl!==void 0&&!y(o.segmentedRow.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-segmented-row-view-url",message:`Segmented row "${o.segmentedRow.displayLabel}" has an invalid view-from-seat image URL`,objectId:o.id}),v(o.segmentedRow.viewFromSeatUrl,o.segmentedRow.viewFromSeatMeta,`Segmented row "${o.segmentedRow.displayLabel}"`,{objectId:o.id}),d(o.segmentedRow.confidenceEvidence,`Segmented row "${o.segmentedRow.displayLabel}"`,{objectId:o.id})),o.type==="row"||o.type==="table")for(let I of o.overrides??[])I.viewFromSeatUrl!==void 0&&!y(I.viewFromSeatUrl)&&e.push({severity:"error",code:"invalid-seat-view-url",message:`Seat ${I.index+1} has an invalid view-from-seat image URL`,objectId:o.id,seatIndices:[I.index]}),v(I.viewFromSeatUrl,I.viewFromSeatMeta,`Seat ${I.index+1}`,{objectId:o.id,seatIndices:[I.index]}),d(I.confidenceEvidence,`Seat ${I.index+1}`,{objectId:o.id,seatIndices:[I.index]});let g=new Set;for(let o of t.categories){g.has(o.key)&&e.push({severity:"error",code:"duplicate-category-key",message:`Category key "${o.key}" is used more than once`,categoryKey:o.key}),g.add(o.key);let I=new Set;for(let s of o.tiers??[]){if(I.has(s.id)&&e.push({severity:"error",code:"duplicate-category-tier-id",message:`Ticket tier id "${s.id}" is used more than once in category "${o.key}"`,categoryKey:o.key}),s.restriction!=null&&!["companion","child","senior","student","membership","custom"].includes(s.restriction)&&e.push({severity:"error",code:"invalid-category-tier-restriction",message:`Ticket tier "${s.name}" has an unknown restriction`,categoryKey:o.key}),s.buyerMessage!=null&&(!s.buyerMessage.trim()||s.buyerMessage.length>240)&&e.push({severity:"error",code:"invalid-category-tier-buyer-message",message:`Ticket tier "${s.name}" buyer guidance must contain 1 to 240 characters`,categoryKey:o.key}),s.currency!=null&&!/^[A-Z]{3}$/.test(s.currency)&&e.push({severity:"error",code:"invalid-category-tier-currency",message:`Ticket tier "${s.name}" must use a three-letter ISO currency`,categoryKey:o.key}),s.applicability!=null){let l=s.applicability.seatLabels,c=s.applicability.accessibility;(l!==void 0&&(!Array.isArray(l)||!l.length||l.length>1e4||l.some(h=>typeof h!="string"||!h.trim()||h.length>160)||new Set(l).size!==l.length)||c!==void 0&&(!Array.isArray(c)||!c.length||c.some(h=>!r.has(h))||new Set(c).size!==c.length))&&e.push({severity:"error",code:"invalid-category-tier-applicability",message:`Ticket tier "${s.name}" has invalid seat applicability`,categoryKey:o.key})}s.evidence!=null&&(!["public-host","public-event","user-confirmed"].includes(s.evidence.provenance)||!s.evidence.sourceDescription.trim()||s.evidence.sourceDescription.length>240||s.evidence.capturedAt!==void 0&&(s.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(s.evidence.capturedAt))))&&e.push({severity:"error",code:"invalid-category-tier-evidence",message:`Ticket tier "${s.name}" has invalid evidence provenance`,categoryKey:o.key}),I.add(s.id)}lt(o)||e.push({severity:"error",code:"invalid-reference-category-source",message:`Category ${o.label||o.key} has incomplete or invalid reference evidence`,categoryKey:o.key}),dt(o)||e.push({severity:"error",code:"invalid-reference-direct-seat-import",message:`Category ${o.label||o.key} has invalid direct-seat import provenance`,categoryKey:o.key})}let p=new Map,b=new Map,x=[],A=new Map,S=0,$=0,T=new Set;for(let o of t.floors??[])we(o,e,n,o.id),T.has(o.id)&&e.push({severity:"error",code:"duplicate-floor-id",message:`Floor id "${o.id}" is used more than once`,floorId:o.id}),T.add(o.id),o.baseHeightM!==void 0&&(!Number.isFinite(o.baseHeightM)||o.baseHeightM<H||o.baseHeightM>X)&&e.push({severity:"error",code:"invalid-floor-base-height",message:`Floor "${o.name}" base height must be between ${H} and ${X} metres`,floorId:o.id});let j=t.floors&&t.floors.length?t.floors.flatMap(o=>o.objects):t.objects;ut(t,e);let P=new Set;for(let o of j)P.has(o.id)&&e.push({severity:"error",code:"duplicate-object-id",message:`Object id "${o.id}" is used more than once`,objectId:o.id}),P.add(o.id);let R=new Set;for(let o of t.zones??[])R.has(o.id)&&e.push({severity:"error",code:"duplicate-zone-id",message:`Zone id "${o.id}" is used more than once`}),R.add(o.id),o.focalPoint!==void 0&&(!Number.isFinite(o.focalPoint.x)||!Number.isFinite(o.focalPoint.y))&&e.push({severity:"error",code:"invalid-zone-focal-point",message:`Zone "${o.label}" must use a finite focal point`});let E=new Map;for(let o of j)if(!(o.type!=="section"||!o.zone)){if(t.zones?.length&&!R.has(o.zone)){e.push({severity:"error",code:"unknown-section-zone",message:`Section "${o.displayLabel??o.label}" references unknown zone "${o.zone}"`,objectId:o.id});continue}E.has(o.zone)||E.set(o.zone,o)}for(let[o,I]of E){let s=t.zones?.find(l=>l.id===o);s&&(s?.focalPoint||n.push({severity:"warning",code:"missing-zone-focal-point",message:`Zone "${s?.label??o}" uses the legacy floor focal; set its own focal point before publishing`,objectId:I.id}))}for(let o of j)if((o.type==="row"||o.type==="table"||o.type==="booth"||o.type==="gaArea")&&st(o,e),Kt(o)){if(S++,$+=o.type==="booth"?1:o.type==="row"?Fe(o):o.bookAsWhole||o.variableOccupancy?o.seatCount:ft(o).length,p.get(o.label)!==void 0?o.type!=="row"&&e.push({severity:"error",code:"duplicate-object-label",message:`Label "${o.label}" is used by more than one object`,objectId:o.id}):p.set(o.label,o.id),i.has(o.categoryKey)?u.add(o.categoryKey):e.push({severity:"error",code:"unknown-category",message:`"${o.label}" references unknown category "${o.categoryKey}"`,objectId:o.id,categoryKey:o.categoryKey}),o.type==="row"){J(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`Row "${o.label}" has invalid reference-inventory provenance`,objectId:o.id}),o.seatCount<1&&e.push({severity:"error",code:"empty-row",message:`Row "${o.label}" has no seats`,objectId:o.id});let s=new Set;for(let l of o.overrides??[]){(l.accessibility??[]).filter(w=>!r.has(w)).length&&e.push({severity:"error",code:"invalid-accessibility-type",message:`Row "${o.label}" seat ${l.index+1} uses an unknown accessibility type`,objectId:o.id,seatIndices:[l.index]}),(!Number.isInteger(l.index)||l.index<0||l.index>=o.seatCount||s.has(l.index))&&e.push({severity:"error",code:"invalid-seat-override",message:`Row "${o.label}" has a duplicated or out-of-range seat override`,objectId:o.id,...Number.isInteger(l.index)?{seatIndices:[l.index]}:{}}),s.add(l.index);let h=l.wheelchairSpaceType,m=l.accessible===!0||l.accessibility?.includes("wheelchair");h!==void 0&&h!=="seat-present"&&h!=="no-seat"?e.push({severity:"error",code:"invalid-wheelchair-space",message:`Row "${o.label}" seat ${l.index+1} has an invalid wheelchair-space type`,objectId:o.id,seatIndices:[l.index]}):h&&(!m||l.skip)&&e.push({severity:"error",code:"invalid-wheelchair-space",message:l.skip?`Row "${o.label}" seat ${l.index+1} cannot have a wheelchair-space physical type while skipped from inventory`:`Row "${o.label}" seat ${l.index+1} must include wheelchair accessibility for its physical-space type`,objectId:o.id,seatIndices:[l.index]})}for(let l of Bt(o))oe(l.label)&&e.push({severity:"error",code:"reserved-seat-label",message:`Seat label "${l.label}" uses SeatLayer's reserved GA namespace`,objectId:o.id,seatIndices:[l.index]}),b.get(l.label)!==void 0?x.push({severity:"error",code:"duplicate-seat-label",message:`Seat label "${l.label}" is used more than once`,objectId:o.id,seatIndices:[l.index]}):b.set(l.label,o.id)}else if(o.type==="table"){let s=o.bookAsWhole===!0||o.variableOccupancy===!0;if(o.seatCountsBySide){let m=["top","bottom","left","right"],w=Object.keys(o.seatCountsBySide),C=m.every(_=>Number.isInteger(o.seatCountsBySide[_])&&o.seatCountsBySide[_]>=0&&o.seatCountsBySide[_]<=40),k=C?m.reduce((_,It)=>_+o.seatCountsBySide[It],0):Number.NaN;(o.shape!=="rect"||w.length!==m.length||w.some(_=>!m.includes(_))||!C||k!==o.seatCount||k<1||k>40)&&e.push({severity:"error",code:"invalid-table-side-counts",message:`Table "${o.label}" needs top, bottom, left, and right whole-number chair counts totaling its ${o.seatCount}-chair capacity`,objectId:o.id})}s&&o.overrides?.length&&e.push({severity:"error",code:"grouped-table-chair-overrides",message:`Grouped table "${o.label}" cannot carry individual-chair overrides`,objectId:o.id,seatIndices:o.overrides.map(m=>m.index)});let l=new Set;for(let m of o.overrides??[]){(m.accessibility??[]).filter(_=>!r.has(_)).length&&e.push({severity:"error",code:"invalid-accessibility-type",message:`Table "${o.label}" chair ${m.index+1} uses an unknown accessibility type`,objectId:o.id,seatIndices:[m.index]}),(!Number.isInteger(m.index)||m.index<0||m.index>=o.seatCount||l.has(m.index))&&e.push({severity:"error",code:"invalid-seat-override",message:`Table "${o.label}" has a duplicated or out-of-range chair override`,objectId:o.id,...Number.isInteger(m.index)?{seatIndices:[m.index]}:{}}),l.add(m.index),m.categoryKey&&!i.has(m.categoryKey)?e.push({severity:"error",code:"unknown-category",message:`Table "${o.label}" chair ${m.index+1} references unknown category "${m.categoryKey}"`,objectId:o.id,seatIndices:[m.index],categoryKey:m.categoryKey}):m.categoryKey&&u.add(m.categoryKey);let C=m.wheelchairSpaceType,k=m.accessible===!0||m.accessibility?.includes("wheelchair");C!==void 0&&C!=="seat-present"&&C!=="no-seat"?e.push({severity:"error",code:"invalid-wheelchair-space",message:`Table "${o.label}" chair ${m.index+1} has an invalid wheelchair-space type`,objectId:o.id,seatIndices:[m.index]}):C&&(!k||m.skip)&&e.push({severity:"error",code:"invalid-wheelchair-space",message:m.skip?`Table "${o.label}" chair ${m.index+1} cannot have a wheelchair-space physical type while skipped from inventory`:`Table "${o.label}" chair ${m.index+1} must include wheelchair accessibility for its physical-space type`,objectId:o.id,seatIndices:[m.index]})}o.bookAsWhole&&o.variableOccupancy?e.push({severity:"error",code:"invalid-table-booking-mode",message:`Table "${o.label}" cannot be sold both as a whole table and with variable occupancy`,objectId:o.id}):o.variableOccupancy?(!Number.isInteger(o.minOccupancy)||!Number.isInteger(o.maxOccupancy)||o.minOccupancy<1||o.maxOccupancy<o.minOccupancy||o.maxOccupancy>o.seatCount)&&e.push({severity:"error",code:"invalid-table-occupancy",message:`Table "${o.label}" needs whole-number minimum and maximum guests from 1 to its ${o.seatCount}-chair capacity`,objectId:o.id}):(o.minOccupancy!=null||o.maxOccupancy!=null)&&e.push({severity:"error",code:"invalid-table-occupancy",message:`Table "${o.label}" has guest bounds without variable-occupancy selling`,objectId:o.id}),J(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`Table "${o.label}" has invalid reference-inventory provenance`,objectId:o.id}),(o.shape==="round"&&o.radius==null||o.shape==="rect"&&(o.width==null||o.height==null)||o.seatCount<1)&&e.push({severity:"error",code:"bad-table",message:`Table "${o.label}" is missing required dimensions or seats`,objectId:o.id});let h=s?[{label:o.label,index:void 0}]:ft(o);for(let m of h)oe(m.label)&&e.push({severity:"error",code:"reserved-seat-label",message:`Inventory label "${m.label}" uses SeatLayer's reserved GA namespace`,objectId:o.id}),b.get(m.label)!==void 0?x.push({severity:"error",code:"duplicate-seat-label",message:`Inventory label "${m.label}" is used more than once; grouped table labels must be unique`,objectId:o.id,...m.index===void 0?{}:{seatIndices:[m.index]}}):b.set(m.label,o.id)}else if(o.type==="booth"){J(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`Booth "${o.label}" has invalid reference-inventory provenance`,objectId:o.id});let s=o.label;oe(s)&&e.push({severity:"error",code:"reserved-seat-label",message:`Seat label "${s}" uses SeatLayer's reserved GA namespace`,objectId:o.id}),b.get(s)!==void 0?x.push({severity:"error",code:"duplicate-seat-label",message:`Seat label "${s}" is used more than once`,objectId:o.id}):b.set(s,o.id)}}else if(o.type==="gaArea"){if(!Re(o))e.push({severity:"error",code:"invalid-ga-inventory-segments",message:`GA area "${o.label}" has invalid joined-area inventory provenance`,objectId:o.id});else for(let c of Me(o))b.get(c)!==void 0?x.push({severity:"error",code:"duplicate-seat-label",message:`GA inventory label "${c}" is used more than once`,objectId:o.id}):b.set(c,o.id);J(o.referenceInventorySource)||e.push({severity:"error",code:"invalid-reference-inventory-source",message:`GA area "${o.label}" has invalid reference-inventory provenance`,objectId:o.id}),(!B(o.points)||Math.abs(z(o.points))<=1e-7||V(o.points))&&e.push({severity:"error",code:"invalid-ga-outline",message:`GA area "${o.label}" must have a finite, non-self-intersecting polygon outline`,objectId:o.id});let s=o.holes??[],l=Array.isArray(s)&&s.length<=64?s.findIndex(c=>!Array.isArray(c)||c.length>512||!B(c)||Math.abs(z(c))<=1e-7||V(c)?!0:!c.flatMap((m,w)=>{let C=c[(w+1)%c.length];return[m,{x:(m.x+C.x)/2,y:(m.y+C.y)/2}]}).every(m=>G(m,o.points))):0;if(l>=0)e.push({severity:"error",code:"invalid-ga-hole",message:`GA area "${o.label}" has a cutout outside its outline or with invalid geometry`,objectId:o.id,holeIndex:l});else if(s.some((c,h)=>s.slice(h+1).some(m=>Z(c,m)))){let c=s.findIndex((h,m)=>s.slice(m+1).some(w=>Z(h,w)));e.push({severity:"error",code:"overlapping-ga-holes",message:`GA area "${o.label}" has overlapping cutout polygons`,objectId:o.id,holeIndex:c})}i.has(o.categoryKey)?u.add(o.categoryKey):e.push({severity:"error",code:"unknown-category",message:`"${o.label}" references unknown category "${o.categoryKey}"`,objectId:o.id,categoryKey:o.categoryKey}),o.capacity<1&&e.push({severity:"error",code:"empty-ga",message:`GA area "${o.label}" has zero capacity`,objectId:o.id}),(!Number.isInteger(o.capacity)||o.capacity>ge)&&e.push({severity:"error",code:"invalid-ga-capacity",message:`GA area "${o.label}" capacity must be a whole number from 1 to ${ge}`,objectId:o.id}),S++,$+=Math.max(0,Math.floor(o.capacity))}else if(o.type==="section"){if(o.elevation!==void 0&&(!Number.isInteger(o.elevation)||o.elevation<le||o.elevation>q)){let l=Number.isInteger(o.elevation)&&o.elevation>q&&o.elevation<=Ee;n.push({severity:"warning",code:l?"legacy-section-elevation":"invalid-section-elevation",message:l?`Section "${o.label}" uses legacy tier ${o.elevation}; set an exact height before normalizing it to tier ${q}`:`Section "${o.label}" elevation must be a whole-number tier from ${le} to ${q}`,objectId:o.id})}if(o.height!==void 0&&(!Number.isFinite(o.height)||o.height<H||o.height>X)&&e.push({severity:"error",code:"invalid-section-height",message:`Section "${o.label}" exact height must be between ${H} and ${X} metres`,objectId:o.id}),o.rake!==void 0&&(!Number.isFinite(o.rake)||o.rake<de||o.rake>ue)&&e.push({severity:"error",code:"invalid-section-rake",message:`Section "${o.label}" rake must be between ${de}\xB0 and ${ue}\xB0`,objectId:o.id}),o.surfaceKind!==void 0&&o.surfaceKind!=="flat"&&o.surfaceKind!=="rakedRows"&&e.push({severity:"error",code:"invalid-section-surface-kind",message:`Section "${o.label}" surfaceKind must be 'flat' or 'rakedRows'`,objectId:o.id}),!B(o.outline)||Math.abs(z(o.outline))<=1e-7||V(o.outline)){e.push({severity:"error",code:"invalid-section-outline",message:`Section "${o.label}" must have a finite, non-self-intersecting polygon outline`,objectId:o.id});continue}if(o.outlinePath){let l=[];try{l=Oe(o.outlinePath)}catch{}(!ke(o.outlinePath)||!l.length||Math.hypot(o.outlinePath.start.x-o.outline[0].x,o.outlinePath.start.y-o.outline[0].y)>1e-4||!B(l)||Math.abs(z(l))<=1e-7||V(l))&&e.push({severity:"error",code:"invalid-section-outline-path",message:`Section "${o.label}" has an invalid or inconsistent curved outline path`,objectId:o.id,edgeIndex:nt(o)})}if(o.referenceSource&&(!/^ref_[0-9a-f-]{36}$/.test(o.referenceSource.assetId)||!/^(?:reg|ai)_[0-9a-f]{16}$/.test(o.referenceSource.regionId))&&e.push({severity:"error",code:"invalid-section-reference-source",message:`Section "${o.label}" has invalid opaque reference provenance`,objectId:o.id}),ct(o)||e.push({severity:"error",code:"invalid-section-inventory-exclusion",message:`Section "${o.label}" has incomplete or mismatched non-sellable evidence`,objectId:o.id}),o.logicalSectionId!==void 0&&!o.logicalSectionId.trim())e.push({severity:"error",code:"invalid-logical-section-id",message:`Section "${o.label}" has an empty logical section id`,objectId:o.id});else if(o.logicalSectionId){let l=JSON.stringify({displayLabel:o.displayLabel??null,entrance:o.entrance??null,viewFromSeatUrl:o.viewFromSeatUrl??null,viewFromSeatMeta:o.viewFromSeatMeta??null,confidenceEvidence:o.confidenceEvidence??null,zone:o.zone??null,labelStyle:o.labelPresentation?.labelStyle??null,labelVisible:o.labelPresentation?.visible!==!1}),c=A.get(o.logicalSectionId);c&&(c.label!==o.label||c.semanticSignature!==l)?e.push({severity:"error",code:"inconsistent-logical-section",message:`Logical section "${o.logicalSectionId}" must use one technical label and buyer-facing presentation across every component`,objectId:o.id}):c||A.set(o.logicalSectionId,{label:o.label,semanticSignature:l})}let I=o.holes??[];if(!Array.isArray(I)||I.length>64){e.push({severity:"error",code:"invalid-section-hole",message:`Section "${o.label}" has an invalid opening collection`,objectId:o.id});continue}let s=-1;for(let l=0;l<I.length;l++){let c=I[l];if(!Array.isArray(c)||c.length>512||!B(c)||Math.abs(z(c))<=1e-7||V(c)){s=l;break}if(!c.flatMap((m,w)=>{let C=c[(w+1)%c.length];return[m,{x:(m.x+C.x)/2,y:(m.y+C.y)/2}]}).every(m=>G(m,o.outline))){s=l;break}}if(s>=0)e.push({severity:"error",code:"invalid-section-hole",message:`Section "${o.label}" has an opening outside its outline or with an invalid shape`,objectId:o.id,holeIndex:s});else if(I.some((l,c)=>I.slice(c+1).some(h=>Z(l,h)))){let l=I.findIndex((c,h)=>I.slice(h+1).some(m=>Z(c,m)));e.push({severity:"error",code:"overlapping-section-holes",message:`Section "${o.label}" has overlapping openings`,objectId:o.id,holeIndex:l})}}let N=t.floors?.length?t.floors.map(o=>o.objects):[t.objects];for(let o of N){let I=o.filter(s=>s.type==="section");for(let s of o.filter(l=>l.type==="text")){let l=s.iconKey;l!==void 0&&!Ve(l)&&e.push({severity:"error",code:"invalid-icon-key",message:`Venue icon "${s.text||s.id}" references an unknown symbol`,objectId:s.id});let c=s.fontFamily;c!==void 0&&(typeof c!="string"||c.normalize("NFKC").trim()!==c||c.length<1||c.length>120)&&e.push({severity:"error",code:"invalid-text-font-family",message:`Text "${s.text||s.id}" font family must contain 1 to 120 normalized characters`,objectId:s.id});let h=s.background;(s.width!==void 0&&(!Number.isFinite(s.width)||s.width<40||s.width>1200)||s.align!==void 0&&!["left","center","right"].includes(s.align)||s.lineHeight!==void 0&&(!Number.isFinite(s.lineHeight)||s.lineHeight<.8||s.lineHeight>3)||s.letterSpacing!==void 0&&(!Number.isFinite(s.letterSpacing)||s.letterSpacing<-2||s.letterSpacing>20)||s.opacity!==void 0&&(!Number.isFinite(s.opacity)||s.opacity<.1||s.opacity>1)||h!==void 0&&(!/^#[0-9a-f]{6}$/i.test(h.color)||h.padding!==void 0&&(!Number.isFinite(h.padding)||h.padding<0||h.padding>40)||h.cornerRadius!==void 0&&(!Number.isFinite(h.cornerRadius)||h.cornerRadius<0||h.cornerRadius>40)||h.opacity!==void 0&&(!Number.isFinite(h.opacity)||h.opacity<.1||h.opacity>1)))&&e.push({severity:"error",code:"invalid-text-layout",message:`Text "${s.text||s.id}" has invalid width, spacing, opacity, alignment, or background layout`,objectId:s.id})}for(let s of o.filter(l=>l.type==="shape")){if(s.eventConfigurationIds!==void 0){let h=s.eventConfigurationIds;Array.isArray(h)&&h.length>0&&h.length<=20&&h.every(w=>typeof w=="string"&&w.normalize("NFKC").trim()===w&&w.length>=1&&w.length<=100)&&new Set(h).size===h.length||e.push({severity:"error",code:"invalid-shape-configurations",message:`Shape "${s.label||s.id}" must reference 1 to 20 unique event configuration ids`,objectId:s.id})}if(s.heightM!==void 0&&(!Number.isFinite(s.heightM)||s.heightM<.05||s.heightM>50)&&e.push({severity:"error",code:"invalid-shape-height",message:`Shape "${s.label||s.id}" height must be between 0.05 m and 50 m`,objectId:s.id}),s.stroke!==void 0&&(!s.stroke||typeof s.stroke.color!="string"||!/^#[0-9a-f]{6}$/i.test(s.stroke.color)||!Number.isFinite(s.stroke.width)||s.stroke.width<.5||s.stroke.width>40)&&e.push({severity:"error",code:"invalid-shape-stroke",message:`Shape "${s.label||s.id}" stroke must use a six-digit color and width from 0.5 to 40 chart units`,objectId:s.id}),(s.lineCap!==void 0||s.lineJoin!==void 0||s.startEnding!==void 0||s.endEnding!==void 0)&&!ve(s.kind)?e.push({severity:"error",code:"invalid-shape-line-style-applicability",message:`Shape "${s.label||s.id}" may use line caps, joins, and end decorations only when it is an open line or polyline`,objectId:s.id}):ve(s.kind)&&(s.lineCap!==void 0&&!Qe.includes(s.lineCap)||s.lineJoin!==void 0&&!qe.includes(s.lineJoin)||s.startEnding!==void 0&&!he.includes(s.startEnding)||s.endEnding!==void 0&&!he.includes(s.endEnding))&&e.push({severity:"error",code:"invalid-shape-line-style",message:`Shape "${s.label||s.id}" has an unsupported line cap, join, or ending`,objectId:s.id}),s.kind==="polygon"){let h=et(s.points??[]);h.ok||e.push({severity:"error",code:"invalid-shape-polygon",message:`Shape "${s.label||s.id}" has invalid polygon geometry: ${h.message}`,objectId:s.id})}let c=rt(s);if(c){for(let h of I)if(it(c,h.outline)){e.push({severity:"error",code:"reference-focal-overlaps-section",message:`Reference focal area "${s.label??s.id}" overlaps section "${h.label}"`,objectId:s.id});break}}}}$>me&&e.push({severity:"error",code:"inventory-capacity-exceeded",message:`Chart has ${$} bookable units; the maximum is ${me}`}),e.push(...x.slice(0,5)),x.length>5&&e.push({severity:"error",code:"duplicate-seat-label",message:`${x.length} seats share a label with another seat; the first 5 are listed above. Seat labels must be unique across the whole chart.`});for(let o of ne(t)){let I=o.families[0]?.targets[0];n.push({severity:"warning",code:"category-inventory-family-conflict",message:We(o),categoryKey:o.categoryKey,...I?{objectId:I.id,floorId:I.floorId}:{},relatedObjectIds:o.objectIds,categoryInventoryFamilies:o.families})}t.focalPoint||n.push({severity:"warning",code:"missing-focal-point",message:"Chart has no focal point set"}),S===0&&n.push({severity:"warning",code:"no-bookables",message:"Chart has no rows, tables, booths, or GA areas"});for(let o of u)if(a.get(o)===!1){let I=t.categories.find(s=>s.key===o);n.push({severity:"warning",code:"unpriced-category",message:`Category "${I?.label??o}" is used but has no price`,categoryKey:o})}return[...e,...n]}var zt=9,bt="#f7f8fb",Ut="#f5f6f8",pt="#8b93a7",Gt="#0b1220",Vt="#0b1220",Qt="#ffffff",qt=100;function O(t,e=2){let n=10**e;return Math.round(t*n)/n}function F(t){return{source:"quality",...t}}function Ht(t){return t.code==="missing-focal-point"||t.code==="missing-zone-focal-point"?"navigation":"structure"}function xe(t){return zt*Ge(t.theme?.seatScale)}function ht(t){let e=[];for(let n of t.objects)n.type==="row"?e.push(...K(n)):n.type==="table"&&e.push(...Y(n));return e}function Xt(t){let e={rowSeats:0,tableSeats:0,booths:0,gaCapacity:0};for(let n of t)for(let i of n.objects)i.type==="row"?e.rowSeats+=K(i).length:i.type==="table"?e.tableSeats+=Y(i).length:i.type==="booth"?e.booths+=1:i.type==="gaArea"&&(e.gaCapacity+=Math.max(0,Math.floor(i.capacity)));return{inventoryByKind:e,bookableUnits:e.rowSeats+e.tableSeats+e.booths+e.gaCapacity}}function L(t,e){t.filter(n=>n.code===e.code).length<qt&&t.push(e)}function Yt(t,e,n){let i=xe(t),r=2*i,a=2.3*i,u=0,y=0,v=1/0;for(let d of e){let f=new Map(d.objects.filter(S=>S.type==="row").map(S=>[S.id,S])),g=S=>{let $=d.objects.find(E=>E.id===S);if(!$||$.type!=="row"&&$.type!=="table")return"another seating object";let T=$.type==="row"?K($):Y($),j=T.length?{x:T.reduce((E,N)=>E+N.x,0)/T.length,y:T.reduce((E,N)=>E+N.y,0)/T.length}:$.type==="row"?$.origin:$.center,P=d.objects.find(E=>E.type==="section"&&te(j,E.outline,E.holes)),R=$.type==="row"?`Row \u201C${$.label}\u201D`:`Table \u201C${$.label}\u201D`;return P?.type==="section"?`${R} in \u201C${P.label}\u201D`:R},p=ht(d);u+=p.length;let b=a,x=new Map,A=new Map;for(let S of p){let $=Math.floor(S.x/b),T=Math.floor(S.y/b);for(let R=-1;R<=1;R++)for(let E=-1;E<=1;E++){let N=x.get(`${$+R}:${T+E}`)??[];for(let o of N){y++;let I=Math.hypot(S.x-o.x,S.y-o.y);if(v=Math.min(v,I),I>=a)continue;let l=(S.rowId<o.rowId?[S.rowId,o.rowId]:[o.rowId,S.rowId]).join("|"),c=A.get(l);(!c||I<c.distance)&&A.set(l,{a:S,b:o,distance:I})}}let j=`${$}:${T}`,P=x.get(j)??[];P.push(S),x.set(j,P)}for(let S of A.values()){let $=S.a.rowId===S.b.rowId,T=f.get(S.a.rowId),j=f.get(S.b.rowId),P=!$&&T?.segmentedRow?.repeatLabelOnComponents===!0&&j?.segmentedRow?.repeatLabelOnComponents===!0&&T.segmentedRow.groupId===j.segmentedRow.groupId,R=!!T?.referenceScan&&!!j?.referenceScan&&T.referenceScan.assetId===j.referenceScan.assetId&&T.referenceScan.sectionId===j.referenceScan.sectionId,E=S.distance<r?"error":"warning";if((P||R)&&E==="warning")continue;let N=E==="error"?"seat-overlap":"seat-cramped",o=g(S.a.rowId),I=g(S.b.rowId),s=O(E==="error"?r:a);L(n,F({severity:E,code:N,dimension:"geometry",title:$?`${o} has seats too close together`:`${o} and ${I} are too close together`,message:`The closest seats are ${O(S.distance)} chart units apart; at least ${s} are required.`,action:$?`Increase the seat spacing for ${o}, or use Review safe fixes.`:`Move ${o} or ${I} until they no longer overlap.`,objectId:S.a.rowId,relatedObjectIds:$?[S.a.rowId]:[S.a.rowId,S.b.rowId],floorId:d.id,measured:O(S.distance),minimum:O(E==="error"?r:a),autoFixable:$}))}}return{seats:u,checkedSeatPairs:y,minimumSeatDistance:Number.isFinite(v)?O(v):null}}function ae(t){let{width:e,height:n}=je(t);if(!t.rotation)return{x:t.position.x,y:t.position.y,width:e,height:n};let i=[{x:0,y:0},{x:e,y:0},{x:e,y:n},{x:0,y:n}].map(r=>{let a=$e(r,t.rotation);return{x:t.position.x+a.x,y:t.position.y+a.y}});return ze(i)}function vt(t,e,n=0){return t.x<e.x+e.width+n&&t.x+t.width+n>e.x&&t.y<e.y+e.height+n&&t.y+t.height+n>e.y}function Se(t,e,n){let i=ee(e.x,t.x,t.x+t.width),r=ee(e.y,t.y,t.y+t.height);return(e.x-i)**2+(e.y-r)**2<n**2}function Wt(t,e,n){let i=xe(t),r=0;for(let a of e){let u=a.objects.filter(v=>v.type==="text"),y=ht(a);r+=u.length;for(let v=0;v<u.length;v++){let d=u[v],f=ae(d),g=y.find(p=>Se(f,p,i));g&&L(n,F({severity:"warning",code:"label-collision",dimension:"labels",message:`Text \u201C${d.text}\u201D overlaps seat ${g.label}`,objectId:d.id,relatedObjectIds:[d.id,g.rowId],floorId:a.id,autoFixable:!0}));for(let p=0;p<v;p++){let b=u[p];vt(f,ae(b),2)&&L(n,F({severity:"warning",code:"label-collision",dimension:"labels",message:`Text \u201C${d.text}\u201D overlaps text \u201C${b.text}\u201D`,objectId:d.id,relatedObjectIds:[d.id,b.id],floorId:a.id,autoFixable:!0}))}}}return r}function Zt(t){return t.normalize("NFKC").trim().toLowerCase().replace(/\s+/g," ")}function Jt(t,e,n){let i=new Map;for(let a of e)for(let u of a.objects){let y=u.type,v=y==="row"||y==="table"||y==="booth"||y==="gaArea",d=v||y==="section";if(v&&!u.categoryKey.trim()){let f=y==="gaArea"?"GA area":y==="row"?"Row":y==="table"?"Table":"Booth";L(n,F({severity:"warning",code:"object-uncategorized",dimension:"structure",title:`${f} \u201C${u.label||u.id}\u201D has no category`,message:`${f} \u201C${u.label||u.id}\u201D is not assigned to any category, so buyers see no price or colour for it.`,action:"Assign a category to this object in the inspector, or create one in the Categories tab first.",objectId:u.id,floorId:a.id,autoFixable:!1}))}if(d){let f=(u.type==="section"?u.displayLabel??u.label:u.label)??"";if(f.trim()){if(y==="table"||y==="booth"||y==="gaArea"){let g=Zt(f),p=i.get(g);p&&p.raw!==f?L(n,F({severity:"warning",code:"duplicate-object-label-normalized",dimension:"labels",title:`\u201C${f}\u201D and \u201C${p.raw}\u201D read as the same label`,message:`Labels \u201C${f}\u201D and \u201C${p.raw}\u201D differ only by case, spacing, or accents, so buyers cannot tell them apart.`,action:"Make the two labels visibly distinct.",objectId:u.id,relatedObjectIds:[u.id,p.id],floorId:a.id,autoFixable:!1})):p||i.set(g,{id:u.id,raw:f})}}else{let g=y==="gaArea"?"A GA area":y==="section"?"A section":y==="row"?"A row":y==="table"?"A table":"A booth";L(n,F({severity:"warning",code:"object-unlabeled",dimension:"labels",title:`${g} has no label`,message:`${g} has an empty label; buyers rely on labels to identify what they are booking.`,action:"Give this object a short, unique label in the inspector.",objectId:u.id,floorId:a.id,autoFixable:!1}))}}}let r=[];for(let a of e){let u=a.objects.filter(y=>y.type==="row"||y.type==="table"||y.type==="booth"||y.type==="gaArea");for(let y of a.objects)if(!(y.type!=="section"||y.referenceInventoryExclusion||u.some(d=>te(fe(d),y.outline,y.holes)))){if(y.referenceSource){r.push({id:y.id,floorId:a.id});continue}L(n,F({severity:"warning",code:"empty-section",dimension:"structure",title:`Section \u201C${y.displayLabel??y.label}\u201D is empty`,message:`Section \u201C${y.displayLabel??y.label}\u201D contains no rows, tables, booths, or GA areas.`,action:"Add seating inside this section (Fill with rows), or remove the empty section.",objectId:y.id,floorId:a.id,autoFixable:!1}))}}if(r.length&&L(n,F({severity:"warning",code:"empty-section",dimension:"structure",title:r.length===1?"1 traced section has no seating yet":`${r.length} traced sections have no seating yet`,message:`${r.length} section${r.length===1?"":"s"} traced from the reference image contain${r.length===1?"s":""} no rows, tables, booths, or GA areas.`,action:"Fill them with rows, or remove the ones the venue does not sell.",objectId:r[0].id,relatedObjectIds:r.map(a=>a.id),floorId:r[0].floorId,autoFixable:!1})),t.floors&&t.floors.length>1)for(let a of t.floors)a.objects.length===0&&L(n,F({severity:"warning",code:"unused-floor",dimension:"structure",title:`Floor \u201C${a.name}\u201D is empty`,message:`Floor \u201C${a.name}\u201D has no objects on it.`,action:"Add seating to this floor, or delete it from the floor list below the canvas.",floorId:a.id,autoFixable:!1}))}var eo=5,to=16;function oo(t,e,n){for(let i of e){let r=i.focalPoint??t.focalPoint;if(r)for(let a of i.objects){if(a.type!=="section"||a.outline.length<3)continue;let{rake:u}=Te(a);if(u<eo)continue;let y=a.outline.map(p=>Math.hypot(p.x-r.x,p.y-r.y)),v=Math.max(...y);if(v<=0)continue;let d=(v-Math.min(...y))/v;if(u*d<=to)continue;let g=a.displayLabel??a.label;L(n,F({severity:"warning",code:"section-rake-inconsistent",dimension:"geometry",title:`Section \u201C${g}\u201D is too deep for a single rake`,message:`Section \u201C${g}\u201D spans ${Math.round(d*100)}% of its distance to the stage at a ${Math.round(u)}\xB0 rake, so one rake can't represent its sightlines faithfully \u2014 a real tier this deep changes slope at a cross-aisle.`,action:"Split this section at the cross-aisle into two sections, each with its own rake.",objectId:a.id,floorId:i.id,autoFixable:!1}))}}}function no(t,e,n){let i=t.theme?.background??bt,r=Ut,a=new Map;for(let d of e)for(let f of d.objects){if(f.type!=="gaArea")continue;let g=a.get(f.categoryKey)??[];g.push({id:f.id,floorId:d.id}),a.set(f.categoryKey,g)}for(let d of t.categories){let f=M(d.color,i),g=M(d.color,r);if(f==null||g==null){L(n,F({severity:"error",code:"invalid-category-color",dimension:"contrast",message:`Category \u201C${d.label}\u201D does not use a supported hex color`,categoryKey:d.key}));continue}let p=Math.min(f,g);p<3&&L(n,F({severity:"warning",code:"category-contrast-low",dimension:"contrast",title:`Category \u201C${d.label}\u201D is hard to see`,message:`Category \u201C${d.label}\u201D reaches only ${O(p)}:1 across dark and light chart backgrounds; 3:1 is required`,action:`Choose a lighter or darker color for \u201C${d.label}\u201D until this warning clears.`,categoryKey:d.key,measured:O(p),minimum:3,autoFixable:!1}));let b=a.get(d.key)??[];if(b.length){let x=pe(d.color,i,be),A=pe(d.color,r,be),S=Math.min(M(x,i)??0,M(A,r)??0);S<3&&L(n,F({severity:"warning",code:"ga-contrast-low",dimension:"contrast",message:`GA category \u201C${d.label}\u201D reaches only ${O(S)}:1 after its rendered opacity is composited; 3:1 is required`,objectId:b[0].id,categoryKey:d.key,floorId:b[0].floorId,relatedObjectIds:b.map($=>$.id),measured:O(S),minimum:3,autoFixable:!1}))}}for(let d=0;d<t.categories.length;d++)for(let f=0;f<d;f++){let g=t.categories[d],p=t.categories[f],b=Pe(g.color,p.color);b!=null&&b<25&&L(n,F({severity:"warning",code:"category-colors-too-similar",dimension:"contrast",title:`\u201C${g.label}\u201D and \u201C${p.label}\u201D look too similar`,message:`Categories \u201C${g.label}\u201D and \u201C${p.label}\u201D are only \u0394E ${O(b)} apart; 25 is required`,action:"Pick a visibly different color for either category so buyers can tell them apart.",categoryKey:g.key,measured:O(b),minimum:25,autoFixable:!1}))}for(let d of e){let f=d.objects.filter(g=>g.type==="text");for(let g of f){let p=g.color??t.theme?.textColor??pt,b=M(p,i),x=g.fontSize>=18?3:4.5;(b==null||b<x)&&L(n,F({severity:"warning",code:"text-contrast-low",dimension:"contrast",message:`Text \u201C${g.text}\u201D has ${O(b??0)}:1 contrast against the chart background; ${x}:1 is required`,objectId:g.id,floorId:d.id,measured:O(b??0),minimum:x,autoFixable:!0}))}}if(t.theme?.selectionColor){let d=M(t.theme.selectionColor,i);(d==null||d<3)&&L(n,F({severity:"warning",code:"selection-contrast-low",dimension:"contrast",title:"The selection color is hard to see",message:`Selection rings have ${O(d??0)}:1 contrast against the chart background; 3:1 is required.`,action:"In Theme, choose a Selection color that stands out clearly from the Background color.",measured:O(d??0),minimum:3,autoFixable:!1}))}if(t.theme?.textColor){let d=M(t.theme.textColor,i);(d==null||d<3)&&L(n,F({severity:"warning",code:"theme-text-contrast-low",dimension:"contrast",title:"The theme text color is hard to read",message:`Theme text has ${O(d??0)}:1 contrast against the chart background; 3:1 is required.`,action:"In Theme, choose a Text color with stronger contrast against the Background color.",measured:O(d??0),minimum:3,autoFixable:!1}))}let u=t.theme?.seatLabelColor??Gt,y=new Map,v=(d,f,g)=>{let p=y.get(d)??new Map,b=p.get(f)??[];b.push(g),p.set(f,b),y.set(d,p)};for(let d of e)for(let f of d.objects)if(f.type==="row")for(let g of ie(f).keys())v(g,"seat",f.id);else if(f.type==="table")for(let g of ie(f).keys())v(g,"table seat",f.id);else f.type==="booth"&&v(f.categoryKey,"booth",f.id);for(let d of t.categories){let f=y.get(d.key);if(f)for(let[g,p]of f){let b=g==="booth"?_e:Ne,x=Ke(De,600),A=Be(d.color,u),S=M(A,d.color);(S==null||S<x)&&L(n,F({severity:"warning",code:"bookable-label-contrast-low",dimension:"contrast",message:`${g==="booth"?"Booth":g==="seat"?"Seat":"Table-seat"} labels use ${b}u type and have ${O(S??0)}:1 contrast on category \u201C${d.label}\u201D; ${x}:1 is required for small text`,objectId:p[0],relatedObjectIds:p,measured:O(S??0),minimum:x,autoFixable:!0}))}}}function io(t,e){for(let n of t){let i=n.objects.filter(r=>r.type==="section");if(!(i.length<2))for(let r of n.objects){if(!(r.type==="row"||r.type==="table"||r.type==="booth"||r.type==="gaArea"))continue;let u=fe(r),y=i.filter(b=>te(u,b.outline,b.holes)),v=new Map;for(let b of y){let x=b.logicalSectionId??b.id,A=v.get(x)??[];A.push(b),v.set(x,A)}if(v.size<2)continue;let d=[...v.values()],f=d.map(b=>`Section \u201C${b[0].displayLabel??b[0].label}\u201D`),g=f.length===2?f.join(" and "):`${f.slice(0,-1).join(", ")}, and ${f[f.length-1]}`,p=r.type==="gaArea"?"GA area":r.type==="row"?"Row":r.type==="table"?"Table":"Booth";L(e,F({severity:"warning",code:"ambiguous-section-ownership",dimension:"structure",title:`${p} \u201C${r.label}\u201D belongs to more than one section`,message:`${p} \u201C${r.label}\u201D has its center inside ${g}, so its buyer section is unclear.`,action:"Adjust the boundaries until this object sits in one Section. If the overlapping shapes are meant to form one Section, combine them first.",objectId:r.id,relatedObjectIds:[r.id,...d.flatMap(b=>b.map(x=>x.id))],floorId:n.id,autoFixable:!1}))}}}var ro={structure:20,geometry:30,contrast:25,labels:15,navigation:10},ao={"seat-overlap":15,"seat-cramped":4,"label-collision":4,"category-contrast-low":3,"ga-contrast-low":3,"category-colors-too-similar":3,"invalid-category-color":10,"text-contrast-low":4,"bookable-label-contrast-low":3,"selection-contrast-low":3,"theme-text-contrast-low":3,"missing-focal-point":10,"object-uncategorized":3,"object-unlabeled":3,"duplicate-object-label-normalized":2,"empty-section":2,"unused-floor":2,"ambiguous-section-ownership":4,"category-inventory-family-conflict":10};function so(t){let e={...ro};for(let r of t){let a=r.severity==="error"?10:2;e[r.dimension]=Math.max(0,e[r.dimension]-(ao[r.code]??a))}let n=Object.values(e).reduce((r,a)=>r+a,0),i=n>=95?"A":n>=85?"B":n>=70?"C":n>=55?"D":"F";return{overall:n,dimensions:e,errorFree:t.every(r=>r.severity!=="error"),grade:i}}var co=new Set(["unpriced-category","object-uncategorized"]);function gt(t,e={}){let n=ye(t),i=yt(t).filter(f=>f.code!=="missing-zone-focal-point"||e.requireExplicitZoneFocals).map(f=>{let g=f.objectId?n.find(x=>x.objects.some(A=>A.id===f.objectId))?.id:void 0,p=f.code==="category-inventory-family-conflict",b=p?t.categories.find(x=>x.key===f.categoryKey):void 0;return F({...f,...p?{severity:"error",title:`Category \u201C${b?.label??f.categoryKey??"Unknown"}\u201D spans incompatible inventory types`,action:"Show the affected objects, then review the safe category split. The repair preserves price, ticket tiers, accessibility assignments, and source provenance."}:{},...e.requireExplicitZoneFocals&&f.code==="missing-zone-focal-point"?{severity:"error"}:{},...g?{floorId:g}:{},source:"structural",dimension:Ht(f),autoFixable:p})}),r=Yt(t,n,i),a=Xt(n),u=Wt(t,n,i);if(Jt(t,n,i),io(n,i),oo(t,n,i),no(t,n,i),n.reduce((f,g)=>f+g.objects.filter(p=>p.type==="row"||p.type==="table"||p.type==="booth"||p.type==="gaArea").length,0)===0){let f=new Set(["missing-focal-point","no-bookables"]);for(let g=i.length-1;g>=0;g--)f.has(i[g].code)&&i.splice(g,1)}if(e.requirePricedInventory)for(let f=0;f<i.length;f++)co.has(i[f].code)&&(i[f]={...i[f],severity:"error"});let v=i.filter(f=>f.severity==="error"),d=i.filter(f=>f.severity==="warning");return{issues:i,errors:v,warnings:d,metrics:{floors:n.length,objects:n.reduce((f,g)=>f+g.objects.length,0),seats:r.seats,bookableUnits:a.bookableUnits,inventoryByKind:a.inventoryByKind,categories:t.categories.length,freeTextLabels:u,checkedSeatPairs:r.checkedSeatPairs,minimumSeatDistance:r.minimumSeatDistance},score:so(i),deferredRules:["rendered-row-label-decollision","rendered-bookable-state-contrast","section-focus-opacity-and-backdrop","24px-pointer-hit-target","reference-image-diff","sightline-blocked","ga-density-high"]}}function lo(t,e){if(t.seatCount<2||t.seatSpacing>=e)return!1;let n=ce(K(t));t.seatSpacing=O(e,3);let i=ce(K(t));return t.origin.x=O(t.origin.x+n.x-i.x,3),t.origin.y=O(t.origin.y+n.y-i.y,3),!0}function uo(t,e){if(t.seatCount<2)return!1;let n=!1;if(t.shape==="round"){let i=ee(t.seatArc??360,0,360),r=(i>=360?360/t.seatCount:i/(t.seatCount-1))*Math.PI/180;if(r>0){let a=e/(2*Math.sin(r/2)),u=Math.max(1,a-16);(t.radius??40)<u&&(t.radius=O(u,3),n=!0)}}else{let i=Le(t),r=Math.max(i.top,i.bottom),a=Math.max(i.left,i.right);r>1&&(t.width??80)/r<e&&(t.width=O(r*e,3),n=!0),a>1&&(t.height??50)/a<e&&(t.height=O(a*e,3),n=!0)}return n}function fo(t){return[Vt,Qt].map(n=>({color:n,minimum:Math.min(...t.map(i=>M(n,i)??0))})).sort((n,i)=>i.minimum-n.minimum)[0].color}function mt(t,e,n){let i=ae(t),r=0;for(let a of e)a.type==="row"?r+=K(a).filter(u=>Se(i,u,n)).length:a.type==="table"?r+=Y(a).filter(u=>Se(i,u,n)).length:a.type==="text"&&a.id!==t.id&&vt(i,ae(a),2)&&r++;return r}function yo(t,e,n){if(mt(t,e,n)===0)return!1;let r={...t.position},a=Math.max(12,t.fontSize*1.25),u=[[0,-1],[1,0],[0,1],[-1,0],[1,-1],[1,1],[-1,1],[-1,-1]];for(let y=1;y<=12;y++)for(let[v,d]of u)if(t.position={x:O(r.x+v*a*y,3),y:O(r.y+d*a*y,3)},mt(t,e,n)===0)return!0;return t.position=r,!1}function Ho(t){let e=JSON.parse(JSON.stringify(t)),n=gt(e),i=[],r=Je(e);if(r.changed){e=r.doc;for(let f of r.changes){let g=r.before.find(b=>b.categoryKey===f.categoryKey),p=g?.families.map(b=>b.label).join(", ")??"inventory families";i.push({code:"category-inventory-family-conflict",objectId:g?.objectIds[0],message:`Split category \u201C${f.categoryLabel}\u201D across ${p}; preserved its commercial metadata and reassigned ${f.reassignments.length} affected object${f.reassignments.length===1?"":"s"}`})}}let a=xe(e),u=2.5*a,y=ye(e);for(let f of y)for(let g of f.objects)if(g.type==="row"){let p=g.seatSpacing;lo(g,u)&&i.push({code:p<2*a?"seat-overlap":"seat-cramped",objectId:g.id,message:`Expanded ${g.id} to the ${O(u)}u target pitch while preserving its centre`})}else g.type==="table"&&uo(g,u)&&i.push({code:"seat-cramped",objectId:g.id,message:`Expanded ${g.id} so its perimeter seats meet the ${O(u)}u target pitch`});let v=e.theme?.background??bt;for(let f of y)for(let g of f.objects){if(g.type!=="text")continue;let p=g.color??e.theme?.textColor??pt,b=g.fontSize>=18?3:4.5;(M(p,v)??0)<b&&(g.color=fo([v]),i.push({code:"text-contrast-low",objectId:g.id,message:`Changed ${g.id} to the highest-contrast black/white ink`}))}for(let f of y){let g=f.objects.filter(p=>p.type==="text");for(let p of g)yo(p,f.objects,a)&&i.push({code:"label-collision",objectId:p.id,message:`Moved ${p.id} to the nearest collision-free deterministic label position`})}e.floors?.length&&(e.objects=e.floors[0].objects);let d=gt(e);return{doc:e,changed:i.length>0,fixes:i,before:n,after:d}}function Yo(t){let e=(t%360+360)%360,n=e>=180?e-360:e;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}export{Ie as a,ie as b,ne as c,We as d,Je as e,et as f,Ho as g,Yo as h};