@seatlayer/core 0.98.0 → 0.100.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{categoryInventory-4XH7dMDH.d.ts → categoryInventory-DdJdJ4Og.d.ts} +1 -1
- package/dist/{categoryInventory-C-bfH2av.d.cts → categoryInventory-DuOez0-4.d.cts} +1 -1
- package/dist/{chunk-M5VINTGE.js → chunk-23OTKCJU.js} +1 -1
- package/dist/chunk-COOPHSHM.js +1 -0
- package/dist/{chunk-CUACREZL.js → chunk-CTIGUXXK.js} +1 -1
- package/dist/{chunk-P4C24CIZ.js → chunk-D723OZEY.js} +1 -1
- package/dist/chunk-FYJJSWEM.js +1 -0
- package/dist/chunk-GLGXP5I7.js +1 -0
- package/dist/{chunk-FLMKHAUT.js → chunk-HO4MFTVX.js} +1 -1
- package/dist/chunk-HYEZPOZU.js +1 -0
- package/dist/{chunk-YPESNMTC.js → chunk-KFVUBZMK.js} +1 -1
- package/dist/{chunk-OLGPAFXW.js → chunk-L34T3APU.js} +1 -1
- package/dist/{chunk-IW7QZIMF.js → chunk-N4J4CT6P.js} +1 -1
- package/dist/{chunk-2P72QUJR.js → chunk-UIMDB6GZ.js} +1 -1
- package/dist/chunk-UISTXRO5.js +1 -0
- package/dist/{chunk-ASIIXY5M.js → chunk-VWT44HBR.js} +1 -1
- package/dist/core/chart-ops/index.cjs +1 -1
- package/dist/core/chart-ops/index.d.cts +6 -4
- package/dist/core/chart-ops/index.d.ts +6 -4
- package/dist/core/chart-ops/index.js +1 -1
- package/dist/core/inventory/index.cjs +1 -1
- package/dist/core/inventory/index.d.cts +4 -4
- package/dist/core/inventory/index.d.ts +4 -4
- package/dist/core/inventory/index.js +1 -1
- package/dist/core/layout/index.cjs +1 -1
- package/dist/core/layout/index.d.cts +5 -5
- package/dist/core/layout/index.d.ts +5 -5
- package/dist/core/layout/index.js +1 -1
- package/dist/core/quality/index.d.cts +3 -3
- package/dist/core/quality/index.d.ts +3 -3
- package/dist/core/quality/index.js +1 -1
- package/dist/core/render-assets/index.d.cts +2 -2
- package/dist/core/render-assets/index.d.ts +2 -2
- package/dist/core/seatConfidence.d.cts +1 -1
- package/dist/core/seatConfidence.d.ts +1 -1
- package/dist/core/sections/index.cjs +1 -1
- package/dist/core/sections/index.d.cts +5 -5
- package/dist/core/sections/index.d.ts +5 -5
- package/dist/core/sections/index.js +1 -1
- package/dist/{eventConfigurations-BEyHDxBT.d.ts → eventConfigurations-BISNREZL.d.ts} +1 -1
- package/dist/{eventConfigurations-BE0rFmbQ.d.cts → eventConfigurations-DYn5XP3J.d.cts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +18 -13
- package/dist/index.d.ts +18 -13
- package/dist/index.js +1 -1
- package/dist/{labeling-HWSKKrX8.d.ts → labeling-CzuSxAkr.d.ts} +1 -1
- package/dist/{labeling-SURRJh5u.d.cts → labeling-owTTG6e0.d.cts} +1 -1
- package/dist/{openPanorama-6FMXAJ6O.js → openPanorama-VD6PE3YZ.js} +2 -2
- package/dist/{renderedQuality-QWHMvOej.d.cts → renderedQuality-BZycehrC.d.cts} +1 -1
- package/dist/{renderedQuality-CZNfpB1H.d.ts → renderedQuality-DPElQ3-x.d.ts} +1 -1
- package/dist/{renderer-CuXYGgR3.d.ts → renderer-DPKIlnuF.d.ts} +10 -1
- package/dist/{renderer-DEnthjgs.d.cts → renderer-DnsIDiWN.d.cts} +10 -1
- package/dist/{seatTypeIcons-BAyWebjw.d.cts → seatTypeIcons-QwEebl3k.d.cts} +1 -1
- package/dist/{seatTypeIcons-CqLiEH9C.d.ts → seatTypeIcons-dy3XQVWN.d.ts} +1 -1
- package/dist/{sections-DOk8zxm5.d.ts → sections-C8VTe6BN.d.ts} +1 -1
- package/dist/{sections-BlCiPWJJ.d.cts → sections-DSIfnBJY.d.cts} +1 -1
- package/dist/{segmentedRowModel-BbHdWqJy.d.cts → segmentedRowModel-CDvvJJ4-.d.cts} +1 -1
- package/dist/{segmentedRowModel-oVUtwW87.d.ts → segmentedRowModel-I8eYUQft.d.ts} +1 -1
- package/dist/{tableSizing-ExOrUwtX.d.ts → tableSizing-0PwrOWi5.d.ts} +20 -13
- package/dist/{tableSizing-DaEXRHYs.d.cts → tableSizing-x8ADFtKS.d.cts} +20 -13
- package/dist/{ticketRestrictions-BHUMet7N.d.ts → ticketRestrictions-C8H-XJha.d.ts} +2 -2
- package/dist/{ticketRestrictions-BvG_INSV.d.cts → ticketRestrictions-O-fv0Os6.d.cts} +2 -2
- package/dist/{types-BbqhOJ5L.d.ts → types-DWx32xXH.d.cts} +10 -1
- package/dist/{types-BbqhOJ5L.d.cts → types-DWx32xXH.d.ts} +10 -1
- package/dist/view3d/crossfade/panorama.cjs +1 -1
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/crossfade/panorama.js +1 -1
- package/dist/view3d/index.cjs +135 -47
- package/dist/view3d/index.d.cts +35 -4
- package/dist/view3d/index.d.ts +35 -4
- package/dist/view3d/index.js +133 -45
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2MXDWZQ4.js +0 -1
- package/dist/chunk-QEPYNCBJ.js +0 -1
- package/dist/chunk-SPM2LMKI.js +0 -1
- package/dist/chunk-VAI2VDQR.js +0 -1
- package/dist/chunk-Z43H6AWN.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var vi=Object.create;var Bn=Object.defineProperty;var Ei=Object.getOwnPropertyDescriptor;var Ai=Object.getOwnPropertyNames;var Ci=Object.getPrototypeOf,_i=Object.prototype.hasOwnProperty;var ki=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ai(t))!_i.call(e,r)&&r!==n&&Bn(e,r,{get:()=>t[r],enumerable:!(o=Ei(t,r))||o.enumerable});return e};var Fe=(e,t,n)=>(n=e!=null?vi(Ci(e)):{},ki(t||!e||!e.__esModule?Bn(n,"default",{value:e,enumerable:!0}):n,e));var hu=Math.PI/180;function Qt(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function it(e){return e.length?Qt(e):null}function Fn(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function Dn(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[Fn(e,.5)];let o=Array.from({length:n+1},(c,f)=>Fn(e,f/n)),r=new Float64Array(o.length);for(let c=1;c<o.length;c+=1){let f=o[c].x-o[c-1].x,u=o[c].y-o[c-1].y;r[c]=r[c-1]+Math.hypot(f,u)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let c=0;c<t;c+=1){let f=i*c/(t-1);for(;a<r.length-1&&r[a]<f;)a+=1;let u=r[a-1],l=r[a],h=l===u?0:(f-u)/(l-u);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*h,y:o[a-1].y+(o[a].y-o[a-1].y)*h})}return s}function Nn(e,t,n){return Math.max(t,Math.min(n,e))}function Gn(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((h,m)=>h.segmentedRow.componentIndex-m.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((h,m)=>h.segmentedRow?.kind==="segmented-row-v1"&&h.segmentedRow.groupId===o&&h.segmentedRow.componentCount===s&&h.segmentedRow.componentIndex===m&&h.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(m===0?h.segmentedRow.boundaryBefore==="start":h.segmentedRow.boundaryBefore!=="start")&&h.segmentedRow.displayLabel===a.displayLabel)))continue;let f=i.reduce((h,m)=>h+m.seatCount,0),u=0,l=0;for(let h of i)h.segmentedRow.boundaryBefore==="break"&&(u+=1),t.set(h.id,{groupId:o,adjacencyOffset:u,displayOffset:l,displayLabel:a.displayLabel,totalSeats:f,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),u+=h.seatCount,l+=h.seatCount}return t}var Ti="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Li="abcdefghijklmnopqrstuvwxyz";function Oi(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function qt(e,t=!1){let n=t?Li:Ti;return Oi(Math.max(0,Math.floor(e)-1),n)}var Bi=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function jn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Bi)for(;t>=o;)n+=r,t-=o;return n}function Fi(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function gt(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,c=e.seatCount;if(i==="updown"||i==="updown-descending"){let m=Math.ceil(c/2),d=i==="updown"?t<m?n+2*t:n-1+2*(c-t):t<m?n+2*(m-1-t):n+1+2*(t-m);return`${s}${d}`}let f=i==="odd"||i==="even"?2:r,u=a!=null&&Number.isFinite(a)?a-(c-1)*f:n,l=o==="center"?Fi(c)[t]:o==="rtl"?c-1-t:t,h;switch(i){case"odd":{let m=u%2===1?u:u+1;h=String(m+l*2);break}case"even":{let m=u%2===0?u:u+1;h=String(m+l*2);break}case"roman":h=jn(u+l*r);break;case"letters-upper":h=qt(u+l*r,!1);break;case"letters-lower":h=qt(u+l*r,!0);break;default:h=String(u+l*r);break}return`${s}${h}`}function Di(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Hn(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${gt(e,t)}`}function Jt(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return gt(e,t);if(!n)return`${e.displayLabel||e.label}-${gt(e,t)}`;let r=Di(n),i=n.displayOffset+t;return`${n.displayLabel}-${gt(r,i)}`}var J=.02291666666666667,ge=1/J,Ni=58,Gi=Ni*J;var ji=3,Xn=0,en=120,Hi=0,Xi=45,Ui=7,Ee=1.2;function tn(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function Vi(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=Ui?e:ji}function De(e,t={}){let n=tn(t.floorBaseHeightM,Xn,en,0),o=Math.min(en,n+Vi(e.elevation)*Gi),r=e.height===void 0?o:tn(e.height,Xn,en,o),i=tn(e.rake,Hi,Xi,0);return{height:r,rake:i}}function Un(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function ze(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c,u=f>1e-12?((t-i.x)*a+(n-i.y)*c)/f:0;u<0?u=0:u>1&&(u=1);let l=t-(i.x+u*a),h=n-(i.y+u*c);if(Math.abs(l)>=o||Math.abs(h)>=o)continue;let m=Math.hypot(l,h);m<o&&(o=m)}return o}function Yi(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function Vn(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function nn(e,t){let n=1/0;for(let o of Un(e)){let r=ze(t,o.x,o.y);r<n&&(n=r)}for(let o of Un(t)){let r=ze(e,o.x,o.y);r<n&&(n=r)}return n}function Ki(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let u of e)n+=u.x,o+=u.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let u of e){let l=Math.hypot(u.x-n,u.y-o);l>r&&(r=l,i=u)}let s=i.x-n,a=i.y-o,c=Math.hypot(s,a);c>1e-9?(s/=c,a/=c):(s=1,a=0);let f=e.map((u,l)=>({p:u,i:l,t:(u.x-n)*s+(u.y-o)*a})).sort((u,l)=>u.t-l.t);return{pts:f.map(u=>u.p),seatIndices:f.map(u=>t[u.i])}}function on(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let y of e)n+=y.x,o+=y.y;n/=t,o/=t;let r=0,i=0,s=0,a=0,c=0,f=0,u=0;for(let y of e){let M=y.x-n,g=y.y-o;r+=M*M,s+=g*g,i+=M*g,a+=M*M*M,c+=g*g*g,f+=M*g*g,u+=g*M*M}let l=r*s-i*i;if(Math.abs(l)<1e-9)return null;let h=(a+f)/2,m=(c+u)/2,d=(h*s-m*i)/l,p=(m*r-h*i)/l,b=d+n,x=p+o;return!Number.isFinite(b)||!Number.isFinite(x)?null:{cx:b,cy:x}}var Wi=.15;function zi(e){if(e.length<2)return null;let t=e.map(y=>{let M=0,g=0;for(let v of y.pts)M+=v.x,g+=v.y;return{x:M/y.pts.length,y:g/y.pts.length}}),n=0,o=0;for(let y of t)n+=y.x,o+=y.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let y of t){let M=y.x-n,g=y.y-o;r+=M*M,i+=M*g,s+=g*g}let a=r+s,c=r*s-i*i,f=a/2+Math.sqrt(Math.max(0,a*a/4-c)),u,l;Math.abs(i)>1e-12?(u=f-s,l=i):r>=s?(u=1,l=0):(u=0,l=1);let h=Math.hypot(u,l);if(!(h>1e-12))return null;u/=h,l/=h;let m=1/0,d=-1/0,p=[];for(let y of e){let M=1/0,g=-1/0;for(let v of y.pts){let S=v.x*u+v.y*l;S<M&&(M=S),S>g&&(g=S),S<m&&(m=S),S>d&&(d=S)}p.push(g-M)}let b=d-m;return b>1e-9?(p.sort((y,M)=>y-M),p[Math.min(p.length-1,Math.floor(p.length*.9))]/b<=Zi?{x:u,y:l}:null):null}var Zi=.35;function Mt(e,t,n,o){let r=new Map;for(let S of n){let R=t[S],I=R.rowId||`__seat-${S}`,P=r.get(I);P||(P={pts:[],idx:[]},r.set(I,P)),P.pts.push({x:R.x,y:R.y}),P.idx.push(S)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[S,R]of r){let I=Ki(R.pts,R.idx),P=0;for(let A of I.pts)P+=Math.hypot(A.x-o.x,A.y-o.y);i.push({id:S,pts:I.pts,seatIndices:I.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:P/I.pts.length})}let s=i.map(S=>Yi(S.pts)),a=i.length<=256?i.length*(i.length-1)/2:0,c=a?new Float64Array(a):null;c?.fill(Number.NaN);let f=c?new Map(i.map((S,R)=>[S,R])):null,u=(S,R)=>(S>R&&([S,R]=[R,S]),S*(2*i.length-S-1)/2+(R-S-1)),l=(S,R)=>{if(!c)return nn(i[S].pts,i[R].pts);let I=u(S,R),P=c[I];if(!Number.isNaN(P))return P;let A=nn(i[S].pts,i[R].pts);return c[I]=A,A},h=(S,R)=>f?l(f.get(S),f.get(R)):nn(S.pts,R.pts),m=[];for(let S=0;S<i.length;S++){let R=1/0;for(let I=0;I<i.length;I++){if(S===I||Vn(s[S],s[I])>=R)continue;let P=l(S,I);P<R&&(R=P)}Number.isFinite(R)&&m.push(R)}m.sort((S,R)=>S-R);let d=m.length?m[Math.floor(m.length/2)]:1,p=Math.max(d*1.8,1e-6),b=i.map(()=>[]);for(let S=0;S<i.length;S++)for(let R=S+1;R<i.length;R++)Vn(s[S],s[R])>p||l(S,R)<=p&&(b[S].push(R),b[R].push(S));let x=0;for(let S=0;S<i.length;S++){if(i[S].blockId!==-1)continue;let R=x++,I=[S];for(i[S].blockId=R;I.length;){let P=I.pop();for(let A of b[P])i[A].blockId===-1&&(i[A].blockId=R,I.push(A))}}let y=new Map;for(let S of i){let R=y.get(S.blockId)??[];R.push(S),y.set(S.blockId,R)}let M=[];for(let S of i){if(S.pts.length<4)continue;let R=on(S.pts);R&&(!Number.isFinite(R.cx)||!Number.isFinite(R.cy)||M.push({x:R.cx,y:R.cy}))}let g=M.length>=2?(()=>{let S=M.map(P=>P.x).sort((P,A)=>P-A),R=M.map(P=>P.y).sort((P,A)=>P-A),I=Math.floor(M.length/2);return{cx:S[I],cy:R[I]}})():null;if(g){let S=T=>Math.hypot(T.x-g.cx,T.y-g.cy),R=1/0,I=-1/0,P=[];for(let T of i){let k=1/0,E=-1/0;for(let C of T.pts){let O=S(C);O<k&&(k=O),O>E&&(E=O)}P.push(E-k),k<R&&(R=k),E>I&&(I=E)}let A=I-R;P.sort((T,k)=>T-k);let _=P[Math.min(P.length-1,Math.floor(P.length*.9))];if(A>1e-9&&_/A<=Wi){let T=i.map(D=>{let V=0;for(let U of D.pts)V+=S(U);return{row:D,radius:V/D.pts.length}}),k=0,E=0;for(let D of T)k+=D.radius,E+=D.row.focalDistance;k/=T.length,E/=T.length;let C=0;for(let D of T)C+=(D.radius-k)*(D.row.focalDistance-E);if(C<0)for(let D of T)D.radius=-D.radius;let F=1/0;for(let D of T)D.radius<F&&(F=D.radius);T.sort((D,V)=>D.radius-V.radius);let L=-1,B=-1/0,N=A/Math.max(1,T.length)*.5,H=[];for(let D of T)D.radius-B>N&&(L++,B=D.radius),D.row.ordinal=L,D.row.blockDepth=D.radius-F,H.push(D.row);return{sectionId:e,rows:H,blockCount:x}}}let v=[];for(let[,S]of y){let R=zi(S);if(R){let I=A=>{let _=0;for(let T of A.pts)_+=T.x*R.x+T.y*R.y;return _/A.pts.length};S.sort((A,_)=>I(A)-I(_)),S.length>=2&&S[0].focalDistance>S[S.length-1].focalDistance&&S.reverse();let P=0;for(let A=0;A<S.length;A++)A>0&&(P+=h(S[A-1],S[A])),S[A].ordinal=A,S[A].blockDepth=P,v.push(S[A])}else{let I=1/0;for(let P of S)P.focalDistance<I&&(I=P.focalDistance);S.sort((P,A)=>P.focalDistance-A.focalDistance);for(let P=0;P<S.length;P++)S[P].ordinal=P,S[P].blockDepth=Math.max(0,S[P].focalDistance-I),v.push(S[P])}}return{sectionId:e,rows:v,blockCount:x}}var $i=/^\d{4}-\d{2}-\d{2}$/;function Qi(e){let t=Date.parse(e);return Number.isFinite(t)?$i.test(e)?t+864e5:t:null}function qi(e,t=Date.now()){if(e.validUntil===void 0){if(e.status!=="approved")return!0;let o=e.assessedAt?Date.parse(e.assessedAt):Number.NaN;return Number.isFinite(o)&&(t instanceof Date?t.getTime():t)<=o+366*864e5}let n=Qi(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function Ji(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function es(e){return e.status!=="draft"&&e.status!=="retracted"}function ts(e,t){return e.status===void 0?t===void 0:e.status!=="approved"?!0:typeof t=="string"&&typeof e.basisSha256=="string"&&e.basisSha256===t}function Yn(e,t={}){return!!e&&es(e)&&Ji(e,t.activeConfigurationId,t.activeConfigurationVersion)&&ts(e,t.activeBasisSha256)&&qi(e,t.now)}var ns=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),os=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function Xe(e){return!!e&&ns.has(e)}function zn(e){return!!e&&os.has(e)}var St=1.1,rs={"pitch-football":{width:105,height:68},"rink-hockey":{width:60,height:30},"track-athletics":{width:176.9,height:92.5},"oval-cricket":{width:150,height:140},"pitch-rugby":{width:120,height:70},"diamond-baseball":{width:140,height:140},"court-basketball":{width:32,height:19},"court-tennis":{width:36.57,height:18.29},"ring-boxing":{width:7.8,height:7.8}},is={"pitch-football":"#2f7d4f","rink-hockey":"#e8f1f8","track-athletics":"#a4472f","oval-cricket":"#3d8a53","pitch-rugby":"#2f7d4f","diamond-baseball":"#2f7d4f","court-basketball":"#c8894f","court-tennis":"#3f7a5a","ring-boxing":"#2a4d8f"};var ss=Math.PI*2;function as(e,t,n,o,r,i){return{x:r+e*n-t*o,y:i+e*o+t*n}}function Kn(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let i=0;i<=r;i++){let s=-Math.PI/2+i/r*Math.PI;o.push({x:n+t*Math.cos(s),y:t*Math.sin(s)})}for(let i=0;i<=r;i++){let s=Math.PI/2+i/r*Math.PI;o.push({x:-n+t*Math.cos(s),y:t*Math.sin(s)})}return o}var Wn=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),i=r+70,s=[],a=Math.atan2(o.y-r,o.x),c=Math.atan2(o.y-r,-o.x);for(let f=0;f<=24;f++){let u=a+(c-a)*f/24;s.push({x:i*Math.cos(u),y:r+i*Math.sin(u)})}return{half:70,home:t,backstop:n,fence:s}})();var It="#f1f5f9";function st(e){return Xe(e)}function Ne(e,t,n,o,r=32){let i=[];for(let s=0;s<r;s++){let a=s/r*ss;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Te(e,t,n,o){return[{x:e-n,y:t-o},{x:e+n,y:t-o},{x:e+n,y:t+o},{x:e-n,y:t+o}]}function cs(e){let{kind:t,cx:n,cy:o,width:r,height:i}=e,s=(e.rotation??0)*Math.PI/180,a=Math.cos(s),c=Math.sin(s),f=r/2,u=i/2,l=[],h=rs[t],m=p=>h?p/h.width*r:0,d=p=>h?p/h.height*i:0;switch(t){case"pitch-football":{l.push({points:[{x:0,y:-u},{x:0,y:u}],closed:!1}),l.push({points:Ne(0,0,m(9.15),d(9.15)),closed:!0});for(let p of[-1,1])l.push({points:Te(p*(f-m(16.5)/2),0,m(16.5)/2,d(40.32)/2),closed:!0}),l.push({points:Te(p*(f-m(5.5)/2),0,m(5.5)/2,d(18.32)/2),closed:!0});break}case"rink-hockey":{l.push({points:[{x:0,y:-u},{x:0,y:u}],closed:!1,ink:"#d63b3b"});for(let p of[-1,1]){l.push({points:[{x:p*m(7.5),y:-u},{x:p*m(7.5),y:u}],closed:!1,ink:"#2f6ecb"}),l.push({points:[{x:p*(f-m(4)),y:-d(11)},{x:p*(f-m(4)),y:d(11)}],closed:!1,ink:"#d63b3b"});for(let b of[-1,1])l.push({points:Ne(p*m(20.5),b*d(7),m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"})}l.push({points:Ne(0,0,m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"});break}case"track-athletics":{let b=u-d(1.22)*8;b>0&&l.push({points:Kn(f-m(1.22)*8,b),closed:!0,fill:"#2f7d4f"});for(let x=1;x<8;x++){let y=d(1.22)*x,M=u-y;if(M<=0)break;l.push({points:Kn(f-m(1.22)*x,M),closed:!0})}break}case"oval-cricket":{l.push({points:Ne(0,0,m(27.4),d(27.4+20.12/2),40),closed:!0}),l.push({points:Te(0,0,m(3.05)/2,d(20.12)/2),closed:!0,ink:"#d8cfae"});break}case"pitch-rugby":{let p=b=>({points:[{x:m(b),y:-u},{x:m(b),y:u}],closed:!1});l.push(p(0));for(let b of[-1,1]){l.push(p(b*50),p(b*28));for(let x=-35;x<35;x+=4)l.push({points:[{x:m(b*10),y:d(x)},{x:m(b*10),y:d(Math.min(35,x+2))}],closed:!1})}break}case"diamond-baseball":{let p=(O,F)=>({x:m(O),y:d(F)}),{home:b}=Wn,x=27.43,y=x/Math.SQRT2,M={x:b.x+y,y:b.y-y},g={x:b.x,y:b.y-2*y},v={x:b.x-y,y:b.y-y},S={x:b.x,y:b.y-18.44},R="#b98a59",I=is["diamond-baseball"],P=38.94,A=[p(b.x,b.y)],_=Math.atan2(b.y-P/Math.SQRT2-S.y,P/Math.SQRT2),T=Math.PI-_;for(let O=0;O<=16;O++){let F=_-(_+Math.PI*2-T)%(Math.PI*2)*(O/16);A.push(p(S.x+29*Math.cos(F),S.y+29*Math.sin(F)))}l.push({points:A,closed:!0,fill:R,ink:R});let k={x:b.x,y:b.y-y},E=[{x:b.x,y:b.y},M,g,v].map(O=>p(k.x+(O.x-k.x)*.84,k.y+(O.y-k.y)*.84));l.push({points:E,closed:!0,fill:I,ink:I}),l.push({points:Ne(m(S.x),d(S.y),m(2.74),d(2.74),20),closed:!0,fill:R,ink:R}),l.push({points:Ne(m(b.x),d(b.y),m(3.96),d(3.96),20),closed:!0,fill:R,ink:R});let C=Wn.fence;l.push({points:[p(b.x,b.y),p(C[0].x,C[0].y)],closed:!1}),l.push({points:[p(b.x,b.y),p(C[C.length-1].x,C[C.length-1].y)],closed:!1});for(let O of[M,g,v])l.push({points:Te(m(O.x),d(O.y),m(.3),d(.3)),closed:!0,fill:It});break}case"court-basketball":{l.push({points:Te(0,0,m(14),d(7.5)),closed:!0}),l.push({points:[{x:0,y:-d(7.5)},{x:0,y:d(7.5)}],closed:!1}),l.push({points:Ne(0,0,m(1.8),d(1.8),24),closed:!0});for(let p of[-1,1]){let b=p*14,x=p*(14-5.8),y=p*(14-1.575);l.push({points:Te(m((b+x)/2),0,m(2.9),d(2.45)),closed:!0,fill:"#2f5d8a"}),l.push({points:Ne(m(x),0,m(1.8),d(1.8),24),closed:!0});let M=Math.sqrt(6.75*6.75-6.6*6.6),g=[{x:m(b),y:-d(6.6)}],v=Math.atan2(-6.6,-p*M),S=2*Math.atan2(6.6,M);for(let R=0;R<=16;R++){let I=v-p*S*(R/16);g.push({x:m(y+6.75*Math.cos(I)),y:d(6.75*Math.sin(I))})}g.push({x:m(b),y:d(6.6)}),l.push({points:g,closed:!1})}break}case"court-tennis":{l.push({points:Te(0,0,m(11.885),d(5.485)),closed:!0,fill:"#2b5f99"});for(let p of[-1,1])l.push({points:[{x:-m(11.885),y:p*d(4.115)},{x:m(11.885),y:p*d(4.115)}],closed:!1}),l.push({points:[{x:p*m(6.4),y:-d(4.115)},{x:p*m(6.4),y:d(4.115)}],closed:!1});l.push({points:[{x:-m(6.4),y:0},{x:m(6.4),y:0}],closed:!1}),l.push({points:[{x:0,y:-d(6.4)},{x:0,y:d(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{l.push({points:Te(0,0,m(3.05),d(3.05)),closed:!0});let x=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[y,M,g]of x)l.push({points:Te(y*m(3.05),M*d(3.05),m(.3),d(.3)),closed:!0,fill:g,ink:g});break}default:return[]}return l.map(p=>({...p,points:p.points.map(b=>as(b.x,b.y,a,c,n,o))}))}function Zn(e){if(e.role!=="stage"||!st(e.stageKind))return[];let t=null;if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null&&e.width>0&&e.height>0&&[e.x,e.y,e.width,e.height].every(Number.isFinite))t={cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height};else if(e.points&&e.points.length>=3&&e.points.every(n=>Number.isFinite(n.x)&&Number.isFinite(n.y))){let n=e.points.map(u=>u.x),o=e.points.map(u=>u.y),r=Math.min(...n),i=Math.max(...n),s=Math.min(...o),a=Math.max(...o),c=Math.max(1,i-r),f=Math.max(1,a-s);t={cx:r+c/2,cy:s+f/2,width:c,height:f}}return t?cs({kind:e.stageKind,...t}):[]}var ls=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,us=/[\s"'<>`\\]/;function fs(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return ls.test(e);if(us.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function $n(e){let t=e.trim();return fs(t)?t:null}var rn="seatlayer.event-configuration/1";var Ze=100,ms=120,hs=2e5,ds=1e4,ps=/^[a-f0-9]{64}$/,bs=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function at(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ue(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function ys(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function Qn(e){return!Array.isArray(e)||e.length>hs||!e.every(t=>Ue(t,Ze))?null:[...new Set(e)].sort()}function xs(e){return!at(e)||!Ue(e.chartId,Ze)||!Ue(e.version,Ze)||e.sha256!==void 0&&(typeof e.sha256!="string"||!ps.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function sn(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function gs(e){return at(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&sn(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Ms(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>ds)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!at(a)||!Ue(a.id,Ze)||!Ue(a.objectId,Ze)||!n.has(a.objectId)||!bs.has(String(a.kind))||!sn(a.heightM,.05,50)||a.baseElevationM!==void 0&&!sn(a.baseElevationM,-10,100))return null;let c=gs(a.occlusion);if(!c||o.has(a.id)||r.has(a.objectId))return null;let f=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?$n(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!f||a.kind!=="screen"||++i>1))return null;o.add(a.id),r.add(a.objectId),s.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:c,...f?{contentImageUrl:f}:{}})}return s.sort((a,c)=>a.id.localeCompare(c.id))}function Ss(e){let t=[];if(!at(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==rn&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${rn}`}),Ue(e.id,Ze)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),Ue(e.label,ms)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),ys(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=xs(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let o=at(e.overlay)?e.overlay:null,r=Qn(o?.objectIds),i=Qn(o?.productionKillSeatIds),s=r?Ms(o?.productionElements,r):null;return(!o||!r||!i)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),s===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!r||!i||s===null?{issues:t}:{issues:t,value:{schema:rn,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function qn(e){let t=Ss(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function Is(e){if((e.kind==="polygon"||e.kind==="polyline"||e.kind==="line")&&e.points&&e.points.length>=2)return e.points;if(e.x==null||e.y==null||e.width==null||e.height==null)return null;let t=e.x,n=e.y,o=e.width,r=e.height;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+r},{x:t,y:n+r}]}function Ps(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),i=Math.sin(o),s=e.x-t.x,a=e.y-t.y;return{x:t.x+s*r-a*i,y:t.y+s*i+a*r}}function Jn(e){let t=Is(e);if(!t||t.length<2)return null;let n=e.rotation??0,o=Math.abs(n)<1e-6?t:t.map(c=>Ps(c,{x:t.reduce((f,u)=>f+u.x,0)/t.length,y:t.reduce((f,u)=>f+u.y,0)/t.length},n)),r=1/0,i=1/0,s=-1/0,a=-1/0;for(let c of o)r=Math.min(r,c.x),i=Math.min(i,c.y),s=Math.max(s,c.x),a=Math.max(a,c.y);return!Number.isFinite(r)||s-r<1e-6||a-i<1e-6?null:{minX:r,minY:i,maxX:s,maxY:a}}var Rs=5,ws=3,vs=.92,Es=1.9,As=2,Cs=.6,_s=1,ks=.06;function Ts(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?St:st(e.stageKind)?ks:_s}function eo(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=-1/0;for(let s of oo(e)){let a=s.baseHeightM??0;for(let c of s.objects){if(c.type!=="shape"||c.role!=="stage")continue;let f=Jn(c);f&&(t=Math.min(t,f.minX),n=Math.min(n,f.minY),o=Math.max(o,f.maxX),r=Math.max(r,f.maxY),i=Math.max(i,a+Ts(c)))}}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minX:t,minY:n,maxX:o,maxY:r,deckTopM:i}}function Ls(e,t,n,o){let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let m of e)Number.isFinite(m.eyeHeightM)&&(r=Math.min(r,m.x),s=Math.max(s,m.x),i=Math.min(i,m.y),a=Math.max(a,m.y));if(!Number.isFinite(r))return null;let c=r*t,f=i*t,u=Math.max(1,Math.ceil((s-r)*t/n)+1),l=Math.max(1,Math.ceil((a-i)*t/n)+1),h=new Float64Array(u*l).fill(-1/0);for(let m of e){if(!Number.isFinite(m.eyeHeightM))continue;let d=m.eyeHeightM-Ee,p=Math.min(u-1,Math.max(0,Math.floor((m.x*t-c)/n))),x=Math.min(l-1,Math.max(0,Math.floor((m.y*t-f)/n)))*u+p,y=d+o;y>h[x]&&(h[x]=y)}return{cellM:n,minX:c,minY:f,cols:u,rows:l,top:h}}function Os(e,t,n){let o=Math.floor((t-e.minX)/e.cellM),r=Math.floor((n-e.minY)/e.cellM);return o<0||r<0||o>=e.cols||r>=e.rows?-1/0:e.top[r*e.cols+o]}function to(e,t,n={}){let o=new Map;if(!t||!e.length)return o;let r=n.metresPerChartUnit??J,i=n.cellM??Cs,s=n.chairBackM??vs,a=n.selfRowSkipM??As,c=n.clearThreshold??.9,f=n.partialThreshold??.25,u=Math.max(1,n.columns??Rs),l=Math.max(1,n.rows??ws),h=Ls(e,r,i,s);if(!h)return o;let m=(t.maxX-t.minX)*r,d=(t.maxY-t.minY)*r,p=m>=d,b=(t.minX+t.maxX)/2*r,x=(t.minY+t.maxY)/2*r,y=[];for(let g=0;g<u;g++){let v=(g+.5)/u-.5,S=p?b+v*m:b,R=p?x:x+v*d;for(let I=0;I<l;I++){let P=t.deckTopM+(l===1?0:I/(l-1)*Es);y.push({x:S,y:R,z:P})}}let M=i/2;for(let g of e){if(!Number.isFinite(g.eyeHeightM))continue;let v=g.x*r,S=g.y*r,R=g.eyeHeightM,I=0,P=1/0;for(let _ of y){let T=_.x-v,k=_.y-S,E=Math.hypot(T,k);if(!(E>a)){I++;continue}let C=T/E,O=k/E,F=0;for(let L=a;L<E;L+=M){let B=Os(h,v+C*L,S+O*L);if(!(!Number.isFinite(B)||B>=R)&&B>R+(_.z-R)*L/E){F=L;break}}F?P=Math.min(P,F):I++}let A=I/y.length;A>=c||o.set(g.id,{seatId:g.id,mark:A<f?"obstructedView":"restrictedView",visibleFraction:A,totalRays:y.length,atDistanceM:Number.isFinite(P)?P:0})}return o}function no(e,t){if(!t.size)return 0;let n=0;for(let o of e){let r=t.get(o.id);if(!r)continue;let i=o.commercial;i?.restrictedView!==void 0||i?.obstructedView!==void 0||(o.commercial={...i,[r.mark]:!0},n++)}return n}function an(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Rt=Math.PI/180;var ct=16;function cn(e,t,n,o){let r=n*Rt,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function co(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return Dn(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let f=0;f<t;f++)s.push(cn(f*n,0,r,i));return s}let a=o/(t-1)*Rt,c=n/(2*Math.sin(Math.abs(a)/2));for(let f=0;f<t;f++){let u=f*a,l=c*Math.sin(u),h=-c+c*Math.cos(u);s.push(cn(l,h,r,i))}return s}function lo(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function Bs(e,t){let n=lo(e);return co(e).map((o,r)=>{let i=n.get(r),s=an(i),a=Hn(e,r,i),c={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:Jt(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(c).some(f=>f!==void 0&&f!==!1&&f!=="")?c:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle??e.seatLabelStyle}})}function Fs(e){let t=[];for(let n of Bs(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function Ds(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function Ns(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(u=>[u.index,u])),r=(u,l,h,m)=>{let d=o.get(u),p=an(d),b=d?.label??`${e.label}-${u+1}`,x=e.displayLabel??e.label;return{index:u,label:b,displayLabel:d?.displayLabel??`${x}-${u+1}`,x:l+(d?.dx??0),y:h+(d?.dy??0),categoryKey:d?.categoryKey??e.categoryKey,skipped:!!d?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:d?.wheelchairSpaceType,commercial:d?.commercial,glyph:d?.glyph,viewUrl:d?.viewFromSeatUrl,viewMeta:d?.viewFromSeatUrl?d.viewFromSeatMeta:void 0,labelStyle:d?.labelStyle,...m?{side:m}:{}}};if(e.shape==="round"){let u=(e.radius??40)+ct,l=e.rotation*Rt,h=Math.max(0,Math.min(360,e.seatArc??360));if(h>=360||n===1){for(let b=0;b<n;b++){let x=l+b/n*2*Math.PI;t.push(r(b,e.center.x+u*Math.cos(x),e.center.y+u*Math.sin(x)))}return t}let m=h*Rt,d=(2*Math.PI-m)/2,p=l+d;for(let b=0;b<n;b++){let x=p+b/(n-1)*m;t.push(r(b,e.center.x+u*Math.cos(x),e.center.y+u*Math.sin(x)))}return t}let i=e.width??80,s=e.height??50,a=Ds(e),c=["top","bottom","left","right"],f=0;for(let u of c){let l=a[u];for(let h=0;h<l;h++){let m,d;u==="top"?(m=-i/2+(h+.5)*i/l,d=-s/2-ct):u==="bottom"?(m=-i/2+(h+.5)*i/l,d=s/2+ct):u==="left"?(m=-i/2-ct,d=-s/2+(h+.5)*s/l):(m=i/2+ct,d=-s/2+(h+.5)*s/l);let p=cn(m,d,e.rotation,e.center);t.push(r(f++,p.x,p.y,u))}}return t}function Gs(e){return Ns(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function js(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function ro(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,a=t[r].x,c=t[r].y;s>e.y!=c>e.y&&e.x<(a-i)*(e.y-s)/(c-s)+i&&(n=!n)}return n}function Hs(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),a=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=a+1e-7})}function ln(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function me(e,t,n){return ro(e,t)&&!ln(n).some(o=>ro(e,o)||Hs(e,o))}function Pt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function uo(e){switch(e.type){case"row":{let t=co(e),n=lo(e),o=0,r=0,i=0;for(let s=0;s<t.length;s++){let a=n.get(s);a?.skip||(o+=t[s].x+(a?.dx??0),r+=t[s].y+(a?.dy??0),i++)}return i?{x:o/i,y:r/i}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Pt(e.points);case"section":return Pt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Pt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function io(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Xs(e,t){if(e.type!=="gaArea"||!io(e.points,t.outline))return!1;let n=ln(e.holes),o=ln(t.holes);return n.length===o.length&&n.every((r,i)=>io(r,o[i]))}function Us(e,t,n=e.filter(r=>r.type==="section"),o=uo(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(s=>(s.logicalSectionId??s.id)===r&&(Xs(t,s)||me(o,s.outline,s.holes))):void 0)??n.find(s=>me(o,s.outline,s.holes))}function oo(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function so(e,t,n,o,r,i,s,a,c){let f=[],u=e.filter(p=>p.type==="section"),l=Gn(e),h=p=>!p?.eventConfigurationId||p.eventConfigurationId===o&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===c),m=p=>Yn(p,{activeConfigurationId:o,activeConfigurationVersion:c,activeBasisSha256:r,now:a}),d=(p,b)=>m(p)?{...p,coverage:b}:void 0;for(let p of e){let b=[];if(p.type==="row"?b=Fs(p):p.type==="table"?b=Gs(p):p.type==="booth"&&(b=js(p)),!b.length)continue;for(let v of b)v.viewUrl&&!h(v.viewMeta)&&(v.viewUrl=void 0,v.viewMeta=void 0);if(p.type==="row"){let v=l.get(p.id);if(v){let S=new Map((p.overrides??[]).map(R=>[R.index,R]));for(let R of b){let I=Number(R.id.slice(R.id.lastIndexOf(":")+1));if(!Number.isInteger(I))continue;R.logicalRowId=v.groupId,R.logicalSeatIndex=v.adjacencyOffset+I,S.get(I)?.displayLabel||(R.displayLabel=Jt(p,I,v)),!R.viewUrl&&v.viewFromSeatUrl&&h(v.viewFromSeatMeta)&&(R.viewUrl=v.viewFromSeatUrl,R.viewMeta=v.viewFromSeatMeta);let P=S.get(I)?.confidenceEvidence;R.confidenceEvidence=d(P,"exact-seat")??d(p.confidenceEvidence,"row-representative")??d(v.confidenceEvidence,"row-representative")}}}let x=Us(e,p,u,p.type==="row"?Pt(b):uo(p)),y=x?.viewFromSeatUrl,g=(x?.zone?t?.find(v=>v.id===x.zone):void 0)?.focalPoint??n;for(let v of b){if(!v.confidenceEvidence){let S=Number(v.id.slice(v.id.lastIndexOf(":")+1)),R=(p.type==="row"||p.type==="table")&&Number.isInteger(S)?p.overrides?.find(I=>I.index===S)?.confidenceEvidence:void 0;v.confidenceEvidence=d(R,"exact-seat")??(p.type==="row"?d(p.confidenceEvidence,"row-representative"):void 0)}v.confidenceEvidence??=d(x?.confidenceEvidence,"section-representative")??(s?d(s.evidence,s.coverage):void 0),!v.viewUrl&&y&&h(x?.viewFromSeatMeta)&&(v.viewUrl=y,v.viewMeta=x?.viewFromSeatMeta),!v.viewUrl&&i&&h(i.meta)&&(v.viewUrl=i.url,v.viewMeta=i.meta),x&&(v.sectionId=x.logicalSectionId??x.id),x?.zone&&(v.zoneId=x.zone),g&&(v.focalPoint={...g})}f.push(...b)}return f}function $e(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,c=so(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&ao(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,c);for(let f of c)f.floorId=r.id;for(let f of c)o.push(f)}return o}let n=so(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.confidenceBasisSha256,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);return t.resolveEyeHeights!==!1&&ao(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),Vs(e,n,t)}function Vs(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||no(t,to(t,eo(e))),t}function ao(e,t,n,o){let r=e.filter(l=>l.type==="section"),i=n>0||r.some(l=>l.height!==void 0||l.rake!==void 0||(l.elevation??0)>0);if(!r.length||!i||!t){for(let l of o)l.eyeHeightM=n+Ee;return}let s=new Array(o.length),a=new Map;for(let l of r)a.has(l.id)||a.set(l.id,l);let c=new Map,f=new Map;for(let l=0;l<o.length;l++){let h=o[l],d=(h.sectionId?a.get(h.sectionId)??r.find(b=>b.logicalSectionId===h.sectionId&&me({x:h.x,y:h.y},b.outline,b.holes)):void 0)??r.find(b=>me({x:h.x,y:h.y},b.outline,b.holes))??null;if(s[l]=d,!d)continue;c.has(d.id)||c.set(d.id,De(d,{floorBaseHeightM:n}));let p=f.get(d.id);p?p.push(l):f.set(d.id,[l])}let u=new Array(o.length).fill(void 0);for(let[l,h]of f){let m=c.get(l);if(!m)continue;let d=m.rake>0?Math.tan(m.rake*Math.PI/180):0,p=Mt(l,o,h,t);for(let b of p.rows){let x=b.blockDepth*J*d,y=m.height+x;for(let M of b.seatIndices)u[M]=y}}for(let l=0;l<o.length;l++){let h=o[l],m=s[l];if(!m){h.eyeHeightM=n+Ee;continue}let d=c.get(m.id);h.eyeHeightM=(u[l]??d.height)+Ee}}var mo=Fe(require("earcut"),1),un=Fe(require("polygon-clipping"),1);function de(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let r=e[n],i=e[(n+1)%o];t+=r.x*i.y-i.x*r.y}return t/2}function pe(e,t,n){let o=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let s=e[r],a=e[i];s.y>n!=a.y>n&&t<(a.x-s.x)*(n-s.y)/(a.y-s.y)+s.x&&(o=!o)}return o}var w=J,Ys=.002;function Ks(e,t,n){let o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.max(o,r,i);if(s<1e-9)return!0;let a=(o+r+i)/2;return 2*Math.sqrt(Math.max(0,a*(a-o)*(a-r)*(a-i)))/s<Ys}var Ve=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=o}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let o=new Float32Array(n);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Et=class{constructor(){this.pos=new Ve;this.nor=new Ve;this.col=new Ve;this.flr=new Ve;this.mat=new Ve;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,o,r,i,s=i,a=i){Ks(t,n,o)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[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(t,n,o,r,i,s,a,c=a,f=a){[...t,...n,...o].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(c[0],c[1],c[2]),this.col.push3(f[0],f[1],f[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 Ws(e,t,n){let o=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=n[0]-e[0],a=n[1]-e[1],c=n[2]-e[2],f=r*c-i*a,u=i*s-o*c,l=o*a-r*s,h=Math.hypot(f,u,l)||1;return f/=h,u/=h,l/=h,[f,u,l]}function zs(e,t){let n=[...e],o=[];for(let s of e)o.push(s.x,s.y);let r=[];if(t){for(let s of t)if(!(s.length<3)){r.push(n.length);for(let a of s)n.push(a),o.push(a.x,a.y)}}let i=(0,mo.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function Ae(e){return de(e)<0?[...e].reverse():e}var Zs=3;function $s(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(m,d,p,b)=>Math.abs(o({x:(m.x+d.x)/2,y:(m.y+d.y)/2})-(p+b)/2),c=(e.x+t.x+n.x)/3,f=(e.y+t.y+n.y)/3,u=(r+i+s)/3,l=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:c,y:f})-u)),h=(m,d,p)=>{let b=Math.abs(o({x:(m+c)/2,y:(d+f)/2})-(p+u)/2);b>l&&(l=b)};return h((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),h((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),h((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),l}function lt(e,t,n,o,r){if(r<=0)return $s(e,t,n,o);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(lt(e,i,a,o,r-1),lt(i,t,s,o,r-1),lt(a,s,n,o,r-1),lt(i,s,a,o,r-1))}function ut(e,t,n,o,r,i,s,a){if(s>0){let h={x:(t.x+n.x)/2,y:(t.y+n.y)/2},m={x:(n.x+o.x)/2,y:(n.y+o.y)/2},d={x:(o.x+t.x)/2,y:(o.y+t.y)/2};ut(e,t,h,d,r,i,s-1,a),ut(e,h,n,m,r,i,s-1,a),ut(e,d,m,o,r,i,s-1,a),ut(e,h,m,d,r,i,s-1,a);return}let c=[t.x*w,r(t),t.y*w],f=[n.x*w,r(n),n.y*w],u=[o.x*w,r(o),o.y*w];if(a){e.triN(c,f,u,a(t),a(n),a(o),i);return}let l=Ws(c,f,u);l[1]<0&&(l=[-l[0],-l[1],-l[2]]),e.tri(c,f,u,l,i)}var Qs=8;function fo(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,c,f)=>{if(f>0){let u={x:(i.x+s.x)/2,y:(i.y+s.y)/2},l=t(u);if(Math.abs(l-(a+c)/2)>n){r(i,u,a,l,f-1),r(u,s,l,c,f-1);return}}o.push(i)};for(let i=0;i<e.length;i++){let s=e[i],a=e[(i+1)%e.length];r(s,a,t(s),t(a),Qs)}return o}function wt(e,t){if(e.length<3)return e;let n=[];for(let r of e){let i=n[n.length-1];i&&Math.hypot(r.x-i.x,r.y-i.y)<t||n.push(r)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let o=[];for(let r=0;r<n.length;r++){let i=o.length?o[o.length-1]:n[(r-1+n.length)%n.length],s=n[r],a=n[(r+1)%n.length],c=a.x-i.x,f=a.y-i.y,u=Math.hypot(c,f);u>t&&Math.abs((s.x-i.x)*f-(s.y-i.y)*c)/u<t||o.push(s)}return o.length>=3?o:n}var vt=.001*ge*.1;function W(e,t,n,o,r,i,s,a,c=1/0,f){if(!t||t.length<3||(c===void 0&&(c=1/0),Math.abs(de(t))<1e-4))return;let u=wt(fo(wt(Ae(t),vt),o,c),vt),l=n?.map(S=>wt(fo(wt(Ae(S),vt),o,c),vt)).filter(S=>S.length>=3&&Math.abs(de(S))>=1e-4),{pts:h,tris:m}=zs(u,l),d=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],b=[s[0]*a.top,s[1]*a.top,s[2]*a.top],x=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],y=0;if(Number.isFinite(c))for(;y<Zs;y++){let S=0;for(let R=0;R<m.length;R+=3){let I=lt(h[m[R]],h[m[R+1]],h[m[R+2]],o,y);I>S&&(S=I)}if(S<=c)break}for(let S=0;S<m.length;S+=3){let R=h[m[S]],I=h[m[S+1]],P=h[m[S+2]];ut(e,R,I,P,o,d,y,f);let A=[R.x*w,r,R.y*w],_=[I.x*w,r,I.y*w],T=[P.x*w,r,P.y*w];e.tri(A,T,_,[0,-1,0],p)}let M=S=>{if(y<=0)return S;let R=1<<y,I=[];for(let P=0;P<S.length;P++){let A=S[P],_=S[(P+1)%S.length];for(let T=0;T<R;T++){let k=T/R;I.push({x:A.x+(_.x-A.x)*k,y:A.y+(_.y-A.y)*k})}}return I},g=Qt(u),v=[{ring:M(u),flip:!1}];if(l)for(let S of l)S.length>=3&&v.push({ring:M(S),flip:!0});for(let{ring:S,flip:R}of v)for(let I=0;I<S.length;I++){let P=S[I],A=S[(I+1)%S.length],_=(A.x-P.x)*w,k=(A.y-P.y)*w,E=-_,C=Math.hypot(k,E)||1;k/=C,E/=C;let O=(P.x+A.x)/2-g.x,F=(P.y+A.y)/2-g.y,L=k*O+E*F;R&&(L=-L),L<0&&(k=-k,E=-E);let B=[k,0,E],N=[P.x*w,o(P),P.y*w],H=[A.x*w,o(A),A.y*w],D=[P.x*w,r,P.y*w],V=[A.x*w,r,A.y*w];e.tri(N,H,V,B,b,b,x),e.tri(N,V,D,B,b,x,x)}}function ho(e){let t=0;for(let c of e)t+=c.count;let n=new Float32Array(t*3),o=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),s=new Float32Array(t),a=0;for(let c of e)n.set(c.position,a*3),o.set(c.normal,a*3),r.set(c.color,a*3),i.set(c.floor,a),s.set(c.material,a),a+=c.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function Ie(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=Ae(e),r=o.length,i=[];for(let a=0;a<r;a++){let c=o[a],f=o[(a+1)%r],u=f.x-c.x,l=f.y-c.y,h=Math.hypot(u,l)||1;i.push({x:l/h,y:-u/h})}let s=[];for(let a=0;a<r;a++){let c=o[a],f=i[(a-1+r)%r],u=i[a],l=f.x+u.x,h=f.y+u.y,m=Math.hypot(l,h),d=()=>{s.push([c.x+f.x*t,c.y+f.y*t]),s.push([c.x+u.x*t,c.y+u.y*t])};if(m<1e-9){d();continue}l/=m,h/=m;let p=l*f.x+h*f.y,b=1/Math.max(p,1e-6);if(!Number.isFinite(b)||b>n){d();continue}s.push([c.x+l*t*b,c.y+h*t*b])}if(s.length<3)return e;try{let a=un.default.union([[...s,s[0]]]),c=null,f=-1/0;for(let l of a){let h=Math.abs(de(l[0].map(([m,d])=>({x:m,y:d}))));h>f&&(f=h,c=l[0])}if(!c)return e;let u=c.map(([l,h])=>({x:l,y:h}));if(u.length>1){let l=u[0],h=u[u.length-1];Math.abs(l.x-h.x)<1e-9&&Math.abs(l.y-h.y)<1e-9&&u.pop()}return u.length>=3?u:e}catch{return e}}function Ye(e,t,n=2.5){if(e.length<3)return[];if(t<=0)return e;let o=Ae(e),r=o.length,i=[];for(let c=0;c<r;c++){let f=o[c],u=o[(c+1)%r],l=Math.hypot(u.x-f.x,u.y-f.y)||1;i.push({x:-(u.y-f.y)/l,y:(u.x-f.x)/l})}let s=[],a=[];for(let c=0;c<r;c++){let f=o[c],u=i[(c-1+r)%r],l=i[c],h=u.x+l.x,m=u.y+l.y,d=Math.hypot(h,m),p=d<1e-9?1/0:1/Math.max(h/d*u.x+m/d*u.y,1e-6);if(!Number.isFinite(p)||p>n){s.push({x:f.x+u.x*t,y:f.y+u.y*t},{x:f.x+l.x*t,y:f.y+l.y*t}),a.push(c,c);continue}h/=d,m/=d,s.push({x:f.x+h*t*p,y:f.y+m*t*p}),a.push(c)}for(let c=0;c<s.length;c++){let f=(c+1)%s.length,u=a[c],l=a[f];if(l!==(u+1)%r)continue;let h=o[u],m=o[l];if((s[f].x-s[c].x)*(m.x-h.x)+(s[f].y-s[c].y)*(m.y-h.y)<=0)return[]}try{let c=un.default.intersection([[...s.map(d=>[d.x,d.y]),[s[0].x,s[0].y]]],[[...o.map(d=>[d.x,d.y]),[o[0].x,o[0].y]]]),f=null,u=0;for(let d of c){let p=Math.abs(de(d[0].map(([b,x])=>({x:b,y:x}))));p>u&&(u=p,f=d[0])}if(!f)return[];let l=f.map(([d,p])=>({x:d,y:p})),h=l[0],m=l[l.length-1];return l.length>1&&Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&l.pop(),l.length>=3?Ae(l):[]}catch{return[]}}function At(e,t,n,o,r=28){let i=[];for(let s=0;s<r;s++){let a=s/r*Math.PI*2;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function ft(e,t,n,o){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+o},{x:e,y:t+o}]}var mt=3,Ke=.38,ht=.24;function qs(e){if(e.length<3)return null;let t=e[0],n=e[Math.floor(e.length/2)],o=e[e.length-1],r=(n.x-t.x)*w,i=(n.y-t.y)*w,s=(o.x-t.x)*w,a=(o.y-t.y)*w,c=2*(r*a-i*s);if(Math.abs(c)<1e-7)return null;let f=r*r+i*i,u=s*s+a*a,l=(f*a-u*i)/c+t.x*w,h=(r*u-s*f)/c+t.y*w,m=Math.hypot(t.x*w-l,t.y*w-h);return m<1||m>200||!Number.isFinite(m)||e.some(d=>Math.abs(Math.hypot(d.x*w-l,d.y*w-h)-m)>.03)?null:{x:l,z:h,radius:m}}function po(e){let t=[],n=new Map,o=(c,f)=>`${Math.floor(c/mt)},${Math.floor(f/mt)}`;for(let c of e)for(let f of c.rows){for(let l of f.pts){let h=l.x*w,m=l.y*w,d=o(h,m),p=n.get(d)??[];p.push({x:h,z:m,y:f.y,floor:c.floorIndex}),n.set(d,p)}if(f.patch||f.pts.length<2)continue;let u=qs(f.pts);for(let l of[0,f.pts.length-1]){let h=f.pts[l],m=f.pts[l===0?1:l-1],d=h.x-m.x,p=h.y-m.y,b=Math.hypot(d,p);b<1e-6||t.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:u,row:f,point:h,x:h.x*w,z:h.y*w,dx:d/b,dz:p/b})}}let r=new Map;t.forEach((c,f)=>{let u=o(c.x,c.z),l=r.get(u)??[];l.push(f),r.set(u,l)});let i=(c,f)=>{let u=Math.floor(c/mt),l=Math.floor(f/mt);return[-1,0,1].flatMap(h=>[-1,0,1].map(m=>`${u+h},${l+m}`))},s=new Map;t.forEach((c,f)=>{let u=-1,l=1/0,h=!1;for(let m of i(c.x,c.z))for(let d of r.get(m)??[]){let p=t[d];if(c.sectionId===p.sectionId&&c.row.blockId===p.row.blockId||c.floorIndex!==p.floorIndex||Math.abs(c.row.y-p.row.y)>.05)continue;let b=p.x-c.x,x=p.z-c.z,y=Math.hypot(b,x);if(y<Ke*2+.45||y>mt)continue;let M=c.curve&&p.curve&&Math.hypot(c.curve.x-p.curve.x,c.curve.z-p.curve.z)<=.05&&Math.abs(c.curve.radius-p.curve.radius)<=.05,g=Math.min((b*c.dx+x*c.dz)/y,(-b*p.dx-x*p.dz)/y);(M?g<.8:g<.98)||!M&&(Math.abs(b*c.dz-x*c.dx)>.15||Math.abs(b*p.dz-x*p.dx)>.15)||(y<l-.02?(u=d,l=y,h=!1):Math.abs(y-l)<=.02&&(h=!0))}u>=0&&!h&&s.set(f,u)});let a=[];for(let[c,f]of s){if(c>=f||s.get(f)!==c)continue;let u=t[c],l=t[f],h=Math.hypot(l.x-u.x,l.z-u.z),m=(l.x-u.x)/h,d=(l.z-u.z)/h,p=!1;for(let x of i((u.x+l.x)/2,(u.z+l.z)/2))for(let y of n.get(x)??[]){if(y.floor!==u.floorIndex||Math.abs(y.y-u.row.y)>.75)continue;let M=(y.x-u.x)*m+(y.z-u.z)*d,g=Math.abs((y.x-u.x)*d-(y.z-u.z)*m);M>.01&&M<h-.01&&g<ht+Ke&&(p=!0)}if(p)continue;let b=(x,y)=>({x:(u.x+m*x-d*y)/w,y:(u.z+d*x+m*y)/w});a.push({sections:[u.sectionId,l.sectionId],blocks:[u.row.blockId,l.row.blockId],floorIndex:u.floorIndex,ends:[u.point,l.point],clearWidthM:h-2*Ke,heightM:(u.row.y+l.row.y)/2,outline:[b(Ke,-ht),b(h-Ke,-ht),b(h-Ke,ht),b(Ke,ht)]})}return a}var Js=/^#?([\da-f]{3}|[\da-f]{6})$/i;function bo(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function ea(e){let t=Js.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function oe(e){let t=ea(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function ta(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function re(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function Ce(e,t){let n=ta(e);return re(e,[n,n,n],t)}function yo({r:e,g:t,b:n}){let o=e/255,r=t/255,i=n/255,s=Math.max(o,r,i),a=Math.min(o,r,i),c=(s+a)/2;if(s===a)return{h:0,s:0,l:c};let f=s-a,u=c>.5?f/(2-s-a):f/(s+a),l;return s===o?l=((r-i)/f+(r<i?6:0))/6:s===r?l=((i-o)/f+2)/6:l=((o-r)/f+4)/6,{h:l,s:u,l:c}}var Ct=["available","held","sold","selected","dimmed"];function xo(e){let t=Ct.indexOf(e);return t<0?0:t}var go={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var fn={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]},mn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function z(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var na=.15,oa=1.6;function Mo(e){return Nn(e??1,na,oa)}var ra=.15,ia=.9,sa=1.76;function aa(){return{background:{top:[...mn.top],bottom:[...mn.bottom]},structure:fn,seatStates:{...go},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function ca(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{deck:"#a8ada9",fascia:"#69777c",shell:"#8d9ca0",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function So(e){let t=aa();e??={};let n=oe(e.background);if(n){t.background={top:z(n,ia),bottom:z(n,sa)};let a={};for(let[f,u]of Object.entries(fn))a[f]=re(u,n,ra);n[0]*.2126+n[1]*.7152+n[2]*.0722>.55&&(a.ground=z(n,.86)),t.structure=a}let o=oe(e.selectionColor)??oe(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=Mo(r));let i=Object.fromEntries(Object.entries(e.venue3d??{}).filter(([,a])=>a!=null)),s={...ca(n),...i};if(s){let a=oe(s.deck),c=oe(s.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),c&&(t.structure={...t.structure,tierWall:c,gaWall:c}),t.materials.seat=oe(s.seat),t.materials.shell=oe(s.shell),typeof s.roughness=="number"&&Number.isFinite(s.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,s.roughness)))}return t}function Io(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}var la=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],lf=new Map(la.map(e=>[e.key,e]));var ua={wheelchair:"#3b82f6",companion:"#8b5cf6","semi-ambulatory":"#0ea5e9","designated-aisle":"#0284c7","step-free":"#16a34a",hearing:"#14b8a6",cart:"#7c3aed","sign-language":"#f59e0b","low-vision":"#d97706","sensory-friendly":"#6366f1","plus-size":"#ec4899","lift-armrest":"#22c55e"};function Po(e){let t=e?.[0];return t&&ua[t]||"#3b82f6"}var fa=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],uf=new Map(fa.map(e=>[e.key,e]));var ma=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],ff=new Set(ma);var wo=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],vo=wo.map(e=>e.key),ha=new Map(wo.map(e=>[e.key,e]));function Ro(e){return typeof e=="string"&&ha.has(e)}function Eo(e,t){return Ro(e)?e:Ro(t?.seatGlyph)?t.seatGlyph:"circle"}var ue={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},da=.44,pa=.15,ba=.3,ya=.24;function Ao(e){return e===void 0||!Number.isFinite(e)||e<=0?ya:Math.min(ba,Math.max(pa,e*da))}var xa=.05,Co=.45,ga=Co+xa,Ma=.92;var bf=[{part:ue.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ue.pad,min:[-1,.36,-.95],max:[1,Co,1]},{part:ue.back,min:[-1,ga,-1],max:[1,Ma,-.72]},{part:ue.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ue.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ue.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ue.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ue.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ue.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ue.leg,min:[.62,0,.48],max:[.82,.37,.7]}],yf=[{part:ue.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ue.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ue.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ue.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ue.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function _o(e,t,n,o){let r=new Float32Array(t),i=f=>e[f*3],s=f=>e[f*3+2],a=0,c=(f,u)=>{let l=u-f;for(let h=f;h<u;h++){let[m,d]=o(h),p=m-i(h),b=d-s(h);if(l>=2){let x=Math.max(f,h-1),y=Math.min(u-1,h+1),M=i(y)-i(x),g=s(y)-s(x),v=Math.hypot(M,g);if(v>1e-6){let S=-g/v,R=M/v;S*p+R*b<0&&(S=-S,R=-R),p=S,b=R}}r[h]=p===0&&b===0?0:Math.atan2(p,b)}};for(let f=1;f<=t;f++)(f===t||n(f)!==n(a))&&(c(a,f),a=f);return r}var _t=.22;var Sa=.42;function Ia(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let d of e)d.x<o&&(o=d.x),d.y<r&&(r=d.y),d.x>i&&(i=d.x),d.y>s&&(s=d.y);let a=Math.max(i-o,1e-6),c=Math.max(s-r,1e-6),f=Math.max(Math.sqrt(a*c/t),1e-6),u=Math.max(1,Math.ceil(a/f)+1),l=Math.max(1,Math.ceil(c/f)+1),h=new Map,m=(d,p)=>{let b=Math.min(u-1,Math.max(0,Math.floor((d-o)/f)));return Math.min(l-1,Math.max(0,Math.floor((p-r)/f)))*u+b};for(let d=0;d<t;d++){let p=m(e[d].x,e[d].y),b=h.get(p);b?b.push(d):h.set(p,[d])}for(let d=0;d<t;d++){let p=e[d],b=Math.min(u-1,Math.max(0,Math.floor((p.x-o)/f))),x=Math.min(l-1,Math.max(0,Math.floor((p.y-r)/f))),y=1/0;for(let M=1;M<=4;M++){for(let g=x-M;g<=x+M;g++)if(!(g<0||g>=l))for(let v=b-M;v<=b+M;v++){if(v<0||v>=u||M>1&&Math.abs(g-x)<M&&Math.abs(v-b)<M)continue;let S=h.get(g*u+v);if(S)for(let R of S){if(R===d)continue;let I=Math.hypot(e[R].x-p.x,e[R].y-p.y);I<y&&(y=I)}}if(Number.isFinite(y)&&y<=M*f)break}n[d]=y}return n}function Pa(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-Ee):0}function ko(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),c=new Float32Array(s),f=new Float32Array(s*3),u=new Float32Array(s),l=new Float32Array(s),h=new Float32Array(s),m=new Float32Array(s),d=new Float32Array(s*3),p=new Map,b=Ia(e);for(let x=0;x<s;x++){let y=e[x],g=(n?.seatPitchU(x)??b[x])*w;u[x]=Number.isFinite(g)?Math.max(.06,Math.min(_t,g*Sa)):_t,l[x]=Ao(Number.isFinite(g)?g:void 0);let v=Eo(y.glyph,{seatGlyph:i?.get(y.categoryKey)});h[x]=vo.indexOf(v),m[x]=y.wheelchairSpaceType==="no-seat"?0:1,a[x*3]=y.x*w,a[x*3+1]=n?n.seatDeckY(x):Pa(y),a[x*3+2]=y.y*w,c[x]=xo(t?t(y):"available");let S=oe(r?.get(y.categoryKey)??"#6e7bff")??[.43,.48,1];if(f[x*3]=S[0],f[x*3+1]=S[1],f[x*3+2]=S[2],y.accessibility?.length){let R=oe(Po(y.accessibility));R&&(d[x*3]=R[0],d[x*3+1]=R[1],d[x*3+2]=R[2])}p.set(y.id,x)}return{count:s,iPosition:a,iState:c,iCategory:f,iMaxRadius:u,iRing:d,idToIndex:p,iChairWidth:l,iGlyph:h,iPhysicalSeat:m,iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}function Ra(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let o=t-e.x,r=n-e.y,i=Math.hypot(o,r);return i<1e-9?[0,0]:[o/i,r/i]}}}function wa(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let m of e)n+=m.x,o+=m.y,r+=Math.hypot(m.x-t.x,m.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let m of e){let d=Math.hypot(m.x-n,m.y-o);d>a&&(a=d,s=m)}let c=s.x-n,f=s.y-o,u=Math.hypot(c,f);u>1e-9?(c/=u,f/=u):(c=1,f=0);let l=[...e].sort((m,d)=>(m.x-n)*c+(m.y-o)*f-((d.x-n)*c+(d.y-o)*f)),h=0;for(let m of l){let d=Math.hypot(m.x-n,m.y-o);d>h&&(h=d)}return{pts:l,cx:n,cy:o,radius:h,depth:r}}function To(e,t,n){let o=e.pts;if(o.length===1)return Math.hypot(t-o[0].x,n-o[0].y);let r=1/0;for(let i=0;i+1<o.length;i++){let s=o[i],a=o[i+1],c=a.x-s.x,f=a.y-s.y,u=c*c+f*f,l=u>1e-12?((t-s.x)*c+(n-s.y)*f)/u:0;l<0?l=0:l>1&&(l=1);let h=Math.hypot(t-(s.x+l*c),n-(s.y+l*f));h<r&&(r=h)}return r}var kt=8;function va(e,t,n){let o=new Array(kt).fill(1/0),r=new Array(kt).fill(-1);for(let u=0;u<e.length;u++){let l=e[u],h=Math.hypot(t-l.cx,n-l.cy)-l.radius;for(let m=0;m<kt;m++)if(h<o[m]){for(let d=kt-1;d>m;d--)o[d]=o[d-1],r[d]=r[d-1];o[m]=h,r[m]=u;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let u of r){if(u<0)continue;let l=To(e[u],t,n);for(let h=0;h<3;h++)if(l<i[h]){for(let m=2;m>h;m--)i[m]=i[m-1],s[m]=s[m-1];i[h]=l,s[h]=u;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,c=0,f=0;for(let u=0;u<3;u++){let l=s[u];if(l<0||i[u]>a)continue;let h=1/(i[u]*i[u]);c+=h*e[l].depth,f+=h}return f>0?c/f:e[s[0]].depth}function Ea(e){let t=(o,r)=>va(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let c=e[a];if(Math.hypot(o-c.cx,r-c.cy)-c.radius>=i)continue;let f=To(c,o,r);f<i&&(i=f,s=a)}return s};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(o,r)=>{let i=(t(o+.5,r)-t(o-.5,r))/1,s=(t(o,r+.5)-t(o,r-.5))/(2*.5),a=Math.hypot(i,s);return a<1e-9?[0,0]:[i/a,s/a]}}}function Lo(e,t){let n=[];for(let o of e){let r=wa(o.points,t);r&&n.push(r)}return n.length<2?Ra(t):(n.sort((o,r)=>o.depth-r.depth),Ea(n))}var pn=Fe(require("polygon-clipping"),1);var Do=Fe(require("earcut"),1);var Aa=.58,Oo=.01,Me=_t*1.5*ge,Ca=.5,_a=.6;function ka(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],c=e[Math.min(n-1,s+1)],f=c.x-a.x,u=c.y-a.y,l=Math.hypot(f,u);if(l<1e-9){o.push([0,0]);continue}f/=l,u/=l,o.push([-u,f])}let r=0;for(let s=0;s<n;s++)r+=(e[s].x-t.x)*o[s][0]+(e[s].y-t.y)*o[s][1];return r<0?o.map(([s,a])=>[-s,-a]):o}function Ta(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let c=a.x-s.x,f=a.y-s.y,u=Math.hypot(c,f)||1;return{x:c/u,y:f/u}},r=o(n[1],n[0]),i=o(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+r.x*t,y:n[0].y+r.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var Bo=Math.PI/12;function La(e){if(e.length<3)return[...e];let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r:[...e]}function No(e,t){if(!e.length||!(t>0))return[];let n=La(e),o=(a,c,f,u)=>{let l=f-c;for(;l<0;)l+=Math.PI*2;for(;l>Math.PI*2;)l-=Math.PI*2;let h=Math.max(1,Math.ceil(l/Bo)),m=t/Math.cos(l/h/2);for(let d=0;d<=h;d++){let p=c+l*d/h;u.push({x:a.x+Math.cos(p)*m,y:a.y+Math.sin(p)*m})}};if(n.length<3){let a=0,c=0;for(let m of n)a+=m.x,c+=m.y;a/=n.length||1,c/=n.length||1;let f=0;for(let m of n)f=Math.max(f,Math.hypot(m.x-a,m.y-c));let u=[],l=Math.max(3,Math.ceil(Math.PI*2/Bo)),h=(f+t)/Math.cos(Math.PI/l);for(let m=0;m<l;m++){let d=m/l*Math.PI*2;u.push({x:a+Math.cos(d)*h,y:c+Math.sin(d)*h})}return u}let r=n.length,i=[];for(let a=0;a<r;a++){let c=n[a],f=n[(a+1)%r];i.push(Math.atan2(-(f.x-c.x),f.y-c.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return Uo(s)}function Oa(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c,u=f>1e-12?((t-i.x)*a+(n-i.y)*c)/f:0;u<0?u=0:u>1&&(u=1);let l=Math.hypot(t-(i.x+u*a),n-(i.y+u*c));l<o&&(o=l)}return o}function Tt(e){let t=e.map(r=>{let i=0,s=0;for(let f of r.pts)i+=f.x,s+=f.y;let a=r.pts.length||1;i/=a,s/=a;let c=0;for(let f of r.pts){let u=Math.hypot(f.x-i,f.y-s);u>c&&(c=u)}return{cx:i,cy:s,rad:c}}),n=r=>{let i=r.length;return i<=2?[...r]:[r[Math.floor(i*.25)],r[Math.floor(i*.5)],r[Math.floor(i*.75)]]},o=[];for(let r=0;r<e.length;r++){let i=n(e[r].pts),s=[],a=1/0,c=null;for(let u of i){let l=1/0;for(let h=0;h<e.length;h++){if(h===r||Math.abs(e[h].y-e[r].y)<.001)continue;let m=t[h],d=Math.hypot(u.x-m.cx,u.y-m.cy)-m.rad;if(d>=l&&d>=a)continue;let p=Oa(e[h].pts,u.x,u.y);p<l&&(l=p),e[h].depth<e[r].depth&&p<a&&(a=p,c=e[h].y)}Number.isFinite(l)&&l>0&&s.push(l)}s.sort((u,l)=>u-l);let f=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:f,belowY:c})}return o}function Go(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let u=r.pts[0],l=u.x-o.x,h=u.y-o.y,m=Math.hypot(l,h)||1;l/=m,h/=m;let d=Math.max(n[t].pitch,.001)*.5;return[{x:u.x+h*d,y:u.y-l*d},{x:u.x-h*d,y:u.y+l*d}]})():[];if(i.length<2)return null;let s=0,a=0;for(let u=1;u<i.length;u++){let l=Math.hypot(i[u].x-i[u-1].x,i[u].y-i[u-1].y);l>1e-6&&(s+=l,a++)}let c=a>0?s/a:0,f=Ta(i,Math.max(c*_a,Me));return{pts:f,nrm:ka(f,o),front:Math.max(n[t].pitch*Aa,Me),back:Math.max(n[t].pitch*Ca,Me)}}var Qe=1.5,jo=.3;function hn(e,t){if(e.length<3)return e;let n=e[0],o=e[e.length-1],r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i),a=-1,c=-1;for(let l=1;l<e.length-1;l++){let h=e[l],m=s>1e-12?Math.abs((h.x-n.x)*i-(h.y-n.y)*r)/s:Math.hypot(h.x-n.x,h.y-n.y);m>a&&(a=m,c=l)}if(a<=t||c<0)return[n,o];let f=hn(e.slice(0,c+1),t),u=hn(e.slice(c),t);return[...f.slice(0,-1),...u]}function Ho(e,t){if(e.length<4)return e;let n=hn([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function Ba(e){let t=e.map((o,r)=>{let i=e[(r+1)%e.length];return{a:o,b:i,i:r,minX:Math.min(o.x,i.x),maxX:Math.max(o.x,i.x),minY:Math.min(o.y,i.y),maxY:Math.max(o.y,i.y)}}).sort((o,r)=>o.minX-r.minX),n=(o,r,i)=>(r.x-o.x)*(i.y-o.y)-(r.y-o.y)*(i.x-o.x);for(let o=0;o<t.length;o++){let r=t[o];for(let i=o+1;i<t.length&&t[i].minX<=r.maxX;i++){let s=t[i];if(!(Math.abs(r.i-s.i)===1||Math.abs(r.i-s.i)===e.length-1||r.maxY<s.minY||s.maxY<r.minY)&&n(r.a,r.b,s.a)*n(r.a,r.b,s.b)<=0&&n(s.a,s.b,r.a)*n(s.a,s.b,r.b)<=0)return!0}}return!1}function Xo(e,t,n){if(e.length<2)return[];let o=n??Tt(e),r=new Map;for(let s=0;s<e.length;s++){let a=r.get(e[s].blockId);a?a.push(s):r.set(e[s].blockId,[s])}let i=[];for(let[,s]of r){let a=[];for(let y of s){let M=e[y].patch;M&&M.length>=3?i.push({outline:[...M],holes:[],topY:e[y].y}):a.push(y)}if(!a.length)continue;a.sort((y,M)=>e[y].depth-e[M].depth);let f=a.map(y=>Go(e,y,o,t)).filter(y=>y!==null);if(!f.length)continue;let u=(y,M)=>({x:y.pts[M].x-y.nrm[M][0]*(y.front+Qe),y:y.pts[M].y-y.nrm[M][1]*(y.front+Qe)}),l=(y,M)=>({x:y.pts[M].x+y.nrm[M][0]*(y.back+Qe),y:y.pts[M].y+y.nrm[M][1]*(y.back+Qe)}),h=f[0],m=f[f.length-1],d=[];for(let y=0;y<h.pts.length;y++)d.push(u(h,y));for(let y of f)d.push(l(y,y.pts.length-1));for(let y=m.pts.length-1;y>=0;y--)d.push(l(m,y));for(let y=f.length-1;y>=0;y--)d.push(u(f[y],0));let p=Uo(d),b=1/0;for(let y of a)e[y].y<b&&(b=e[y].y);if(!Number.isFinite(b))continue;if(p.length>=3&&Math.abs(de(p))>1e-6&&f.every(y=>{let M=y.pts[Math.floor(y.pts.length/2)];return pe(p,M.x,M.y)})&&!Ba(p)){i.push({outline:Ho(p,jo),holes:[],topY:b});continue}for(let y of Fa(f))i.push({outline:y,holes:[],topY:b})}return i}function Fa(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+Qe,s=n.back+Qe;for(let c=0;c<n.pts.length;c++){let f=n.pts[c],u=n.nrm[c];o.push([f.x-u[0]*i,f.y-u[1]*i]),r.push([f.x+u[0]*s,f.y+u[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=pn.default.union(t[0],...t.slice(1)),o=[];for(let r of n){if(!r.length||r[0].length<4)continue;let i=r[0].map(([c,f])=>({x:c,y:f})),s=i[0],a=i[i.length-1];i.length>1&&Math.abs(s.x-a.x)<1e-9&&Math.abs(s.y-a.y)<1e-9&&i.pop(),i.length>=3&&o.push(Ho(i,jo))}return o}catch{return[]}}function Uo(e){let t=[];for(let n of e){let o=t[t.length-1];o&&Math.hypot(n.x-o.x,n.y-o.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var dn=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let o of n)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let o=!0;for(let r of t)if(!pe(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function Fo(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let f=[0,1,0],u=o[0];for(let l=1;l+1<o.length;l++){let h=o[l],m=o[l+1];e.tri([u.x*w,r,u.y*w],[h.x*w,r,h.y*w],[m.x*w,r,m.y*w],f,i)}return}let s=o.map(f=>[f.x,f.y]);s.push(s[0]);let a;try{a=pn.default.intersection([s],t)}catch{return}let c=[0,1,0];for(let f of a){if(!f.length||f[0].length<4)continue;let u=f[0],l=[],h=[];for(let d=0;d<u.length-1;d++)l.push(u[d][0],u[d][1]),h.push([u[d][0],u[d][1]]);if(h.length<3)continue;let m=(0,Do.default)(l,void 0,2);for(let d=0;d<m.length;d+=3){let p=h[m[d]],b=h[m[d+1]],x=h[m[d+2]];e.tri([p[0]*w,r,p[1]*w],[b[0]*w,r,b[1]*w],[x[0]*w,r,x[1]*w],c,i)}}}function Vo(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??Tt(t),c=[0,1,0],f=i&&i.length>=3?[[...i.map(m=>[m.x,m.y]),[i[0].x,i[0].y]]]:null,u=i&&i.length>=3?new dn([[...i]]):null,l=m=>{e.setMaterial(2),m(),e.setMaterial(0)},h=m=>{e.setMaterial(3),m(),e.setMaterial(0)};for(let m=0;m<t.length;m++){let d=t[m];if(d.patch&&d.patch.length>=3){let v=[...d.patch],S=a[m].belowY??o;if(h(()=>{if(f&&u)Fo(e,f,u,v,d.y,r.tread);else{let R=v[0];for(let I=1;I+1<v.length;I++){let P=v[I],A=v[I+1];e.tri([R.x*w,d.y,R.y*w],[P.x*w,d.y,P.y*w],[A.x*w,d.y,A.y*w],c,r.tread)}}}),d.y>S+Oo){let R=0,I=0;for(let P of v)R+=P.x,I+=P.y;R/=v.length,I/=v.length,l(()=>{for(let P=0;P<v.length;P++){let A=v[P],_=v[(P+1)%v.length],T=_.x-A.x,k=_.y-A.y,E=Math.hypot(T,k);if(E<1e-6)continue;let C=k/E,O=-T/E;(A.x-R)*C+(A.y-I)*O<0&&(C=-C,O=-O);let F=[C,0,O],L=[A.x*w,d.y,A.y*w],B=[_.x*w,d.y,_.y*w],N=[A.x*w,S,A.y*w],H=[_.x*w,S,_.y*w];e.tri(L,B,H,F,r.riser),e.tri(L,H,N,F,r.riser)}})}continue}let p=Go(t,m,a,n);if(!p)continue;let{pts:b,nrm:x,front:y,back:M}=p,g=a[m].belowY??o;for(let v=0;v+1<b.length;v++){let S=b[v],R=b[v+1],I=x[v],P=x[v+1];if(Math.hypot(R.x-S.x,R.y-S.y)<1e-6||I[0]===0&&I[1]===0||P[0]===0&&P[1]===0)continue;let A=[(S.x-I[0]*y)*w,d.y,(S.y-I[1]*y)*w],_=[(R.x-P[0]*y)*w,d.y,(R.y-P[1]*y)*w],T=[(S.x+I[0]*M)*w,d.y,(S.y+I[1]*M)*w],k=[(R.x+P[0]*M)*w,d.y,(R.y+P[1]*M)*w];if(h(()=>{f&&u?Fo(e,f,u,[{x:S.x-I[0]*y,y:S.y-I[1]*y},{x:R.x-P[0]*y,y:R.y-P[1]*y},{x:R.x+P[0]*M,y:R.y+P[1]*M},{x:S.x+I[0]*M,y:S.y+I[1]*M}],d.y,r.tread):(e.tri(A,_,k,c,r.tread),e.tri(A,k,T,c,r.tread))}),d.y>g+Oo){let E=[A[0],g,A[2]],C=[_[0],g,_[2]],O=[-I[0],0,-I[1]];l(()=>{e.tri(A,_,C,O,r.riser),e.tri(A,C,E,O,r.riser)})}}}}function Yo(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=!1;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(i=!0,s.x<t&&(t=s.x),s.y<n&&(n=s.y),s.x>o&&(o=s.x),s.y>r&&(r=s.y));return i?{minX:t,minY:n,maxX:o,maxY:r}:null}function qe(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var bn=Fe(require("polygon-clipping"),1);function Da(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function Ko(e,t){return e.filter(n=>n.type!=="shape"||Da(n,t))}function Wo(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:Ko(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:Ko(e.objects,t),focal:n,baseHeightM:0,index:0}]}var Na={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Le(e){return Yo(e)??Na}function zo(e,t){let n=Ie(e.outline,Me),o=Le(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&qe(o,Le(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(c=>[c.x,c.y]);return a.push(a[0]),a};try{let s=bn.default.difference([i(n)],...r.map(c=>[i(c.outline)])),a=[];for(let c of s){if(!c.length)continue;let f=c[0].map(([u,l])=>({x:u,y:l}));if(f.length>1){let u=f[0],l=f[f.length-1];Math.abs(u.x-l.x)<1e-9&&Math.abs(u.y-l.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a.length?a:[n]}catch{return[n]}}function Zo(e,t){if(!t.length)return e;let n=i=>{let s=i.map(a=>[a.x,a.y]);return s.push(s[0]),s},o=t.map(i=>[n(i)]),r=[];for(let i of e){let s;try{s=bn.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let c=a[0].map(([f,u])=>({x:f,y:u}));if(c.length>1){let f=c[0],u=c[c.length-1];Math.abs(f.x-u.x)<1e-9&&Math.abs(f.y-u.y)<1e-9&&c.pop()}c.length>=3&&r.push({outline:c,holes:[],topY:i.topY})}}return r.length?r:e}var Ge=.06,Ga=.05,Qo=.05,$o=.15,yn=25;function qo(e,t,n){let o=new Map,r=new Array(t.length).fill(null),i=new Float64Array(t.length),s=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),c=new Map,f=[],u=new Set;for(let h=0;h<e.length;h+=1){let m=e[h];for(let d of m.objects){if(d.type==="table"&&u.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let p=Ie(d.outline,Me);c.set(d.id,{section:d,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),f.push({id:d.id,floorIndex:h,box:Le(p),section:d,unit:m,outline:p})}}let l=new Map;for(let h of f){let m=l.get(h.floorIndex);m?m.push(h):l.set(h.floorIndex,[h])}for(let h=0;h<t.length;h++){let m=t[h],d=n?l.get(n[h])??[]:f,p=m.sectionId?d.find(x=>x.id===m.sectionId)??d.find(x=>x.section.logicalSectionId===m.sectionId&&me({x:m.x,y:m.y},x.outline,x.section.holes)):void 0,b=p?[p]:d;for(let x of b){if(n&&x.floorIndex!==n[h]||!p&&(m.x<x.box.minX||m.x>x.box.maxX||m.y<x.box.minY||m.y>x.box.maxY||!me({x:m.x,y:m.y},x.outline,x.section.holes)))continue;r[h]=x.id;let y=c.get(x.id);y.hasSeats=!0;let M=m.focalPoint??x.unit.focal,g=Math.hypot(m.x-M.x,m.y-M.y);g<y.frontU&&(y.frontU=g),y.seatIndices.push(h);let v=m.rowId||`__seat-${h}`,S=y.rows.get(v);S?S.push({x:m.x,y:m.y}):y.rows.set(v,[{x:m.x,y:m.y}]);break}}for(let[h,m]of c){let d=De(m.section,{floorBaseHeightM:m.unit.baseHeightM}),p=m.unit.baseHeightM,b=d.rake>0?Math.tan(d.rake*Math.PI/180):0,x=d.rake<=.01&&d.height<=p+.001,y=m.section.surfaceKind,M=y==="flat"?!0:y==="rakedRows"&&d.rake>.01?!1:x,g=m.hasSeats?Mt(h,t,m.seatIndices,m.unit.focal):{sectionId:h,rows:[],blockCount:0},S=g.rows.length<2?Lo([...m.rows.values()].map(L=>({points:L})),m.unit.focal):null,R=1/0;if(S){if(m.hasSeats)for(let L of m.rows.values())for(let B of L){let N=S.depthAt(B.x,B.y);N<R&&(R=N)}if(!m.hasSeats||!Number.isFinite(R)){R=1/0;for(let L of m.section.outline){let B=S.depthAt(L.x,L.y);B<R&&(R=B)}}}let I=p+Ga,P=Math.max(I,d.height),A=L=>{let B=Math.max(0,L-R)*J,N=Math.min(B*b,yn);return Math.max(I,d.height+N)},_=L=>{let B=Math.max(0,L)*J,N=Math.min(B*b,yn);return Math.max(I,d.height+N)},T=M?[]:g.rows.map(L=>({pts:L.pts,y:_(L.blockDepth),depth:L.blockDepth,blockId:L.blockId,...u.has(L.id)?{patch:No(L.pts,Me)}:{}})),k=T.length?T[0].y:P,E=T.map(L=>{let B=L.patch&&L.patch.length>=3?L.patch:L.pts,N=0,H=0;for(let U of B)N+=U.x,H+=U.y;let D=B.length||1;N/=D,H/=D;let V=0;for(let U of B){let Z=Math.hypot(U.x-N,U.y-H);Z>V&&(V=Z)}return{cx:N,cy:H,rad:V}}),C=M?()=>P:T.length>=2?(L,B)=>{let N=1/0,H=k;for(let D=0;D<T.length;D++){let V=E[D];if(Math.hypot(L-V.cx,B-V.cy)-V.rad>=N)continue;let U=T[D].patch,Z=U&&U.length>=3?pe(U,L,B)?0:ze(U,L,B):ze(T[D].pts,L,B);Z<N&&(N=Z,H=T[D].y)}return H}:(L,B)=>S?A(S.depthAt(L,B)):P,O=[0,1,0],F=T.length>=2||M?()=>O:(L,B)=>{if(!S)return O;let N=S.depthAt(L,B);if(N<=R)return O;let H=(N-R)*J;if(H*b>=yn||d.height+H*b<=I)return O;let[D,V]=S.gradientAt(L,B);if(D===0&&V===0)return O;let U=1/Math.hypot(b,1);return[-D*b*U,U,-V*b*U]};if(!M)for(let L of g.rows){let B=_(L.blockDepth);for(let N of L.seatIndices)s[N]=B}for(let L of g.rows){let B=[];for(let U=1;U<L.pts.length;U++){let Z=Math.hypot(L.pts[U].x-L.pts[U-1].x,L.pts[U].y-L.pts[U-1].y);Z>1e-6&&B.push(Z)}B.sort((U,Z)=>U-Z);let N=B.length?B[Math.floor(B.length/2)]:1/0,H=1/0,D=L.pts[Math.floor(L.pts.length/2)];if(D)for(let U of g.rows){if(U===L||U.blockId!==L.blockId)continue;let Z=ze(U.pts,D.x,D.y);Z>1e-6&&Z<H&&(H=Z)}let V=Math.min(N,Math.max(H,N*.5));if(Number.isFinite(V)&&V>0)for(let U of L.seatIndices)a[U]=V}o.set(h,{sectionId:h,deckAt:C,normalAt:F,flat:M,bottomY:p,rowLevels:T,landingY:k})}for(let h=0;h<t.length;h++){let m=r[h],d=t[h];if(m){let x=s[h];i[h]=(x??o.get(m).deckAt(d.x,d.y))+$o;continue}let p=d.eyeHeightM,b=Number.isFinite(p)?Math.max(0,p-Ee):0;i[h]=d.kind==="booth"?b+Ge+$o:b}return{bySection:o,seatOwner:r,seatDeckY:h=>i[h],seatPitchU:h=>a[h]}}var K={top:1,wallBottom:.58,bottomCap:.4};function je(e,t){if(!e)return t;let n=z(Ce(e,.4),.62);return re(t,n,.22)}function Jo(e,t){return e?re(t,z(Ce(e,.08),.9),.82):t}function er(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let o=new Map;for(let i of t){if(!i.sectionId)continue;let s=o.get(i.sectionId);s||(s=new Map,o.set(i.sectionId,s)),s.set(i.categoryKey,(s.get(i.categoryKey)??0)+1)}let r=new Map;for(let[i,s]of o){let a=0,c=0,f=0,u=0;for(let[l,h]of s){let m=oe(n.get(l));m&&(a+=m[0]*h,c+=m[1]*h,f+=m[2]*h,u+=h)}u>0&&r.set(i,[a/u,c/u,f/u])}return r}function tr(e,t){return oe(e.color)??t.get(e.logicalSectionId??e.id)??null}var nr=Fe(require("polygon-clipping"),1);function ja(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var Lt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(c=>[c.x,c.y]);if(o.length<3)return[];o.push(o[0]);let r=Le(t),i=this.rings.filter((c,f)=>qe(r,this.boxes[f])&&ja(n,this.levels[f])),s=[[o]];if(i.length)try{s=nr.default.difference([o],...i).map(f=>f.map(u=>u.map(([l,h])=>[l,h])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let c of s){if(!c.length)continue;let f=c[0].map(([u,l])=>({x:u,y:l}));if(f.length>1){let u=f[0],l=f[f.length-1];Math.abs(u.x-l.x)<1e-9&&Math.abs(u.y-l.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a}};function Ot(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,i=-1/0;for(let l of e)n=Math.min(n,l.x),o=Math.max(o,l.x),r=Math.min(r,l.y),i=Math.max(i,l.y);let s=(n+o)/2,a=(r+i)/2,c=t*Math.PI/180,f=Math.cos(c),u=Math.sin(c);return e.map(l=>{let h=l.x-s,m=l.y-a;return{x:s+h*f-m*u,y:a+h*u+m*f}})}function se(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=ft(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,o=(e.y??0)+e.height/2;t=At(n,o,e.width/2,e.height/2)}return t?Ot(t,e.rotation):null}function Pe(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},o=t==="stage"&&st(e.stageKind)?{kind:"stage",heightM:e.stageKind==="ring-boxing"?St:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var Ha=.08,Xa=30,Ua=.015;function Va(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function or(e,t){let n=se(e)??(e.points?.length?Ot(e.points,e.rotation):null),o=Pe(e),i=!e.role&&o.kind==="plate"&&e.heightM===void 0&&!!n&&Math.abs(de(n))*J**2>=Xa?Ua:o.heightM;if(!n)return{topOffsetM:i,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:i,supportOffsetM:0};let s=1/0,a=1/0,c=-1/0,f=-1/0;for(let m of n)s=Math.min(s,m.x),a=Math.min(a,m.y),c=Math.max(c,m.x),f=Math.max(f,m.y);let u=i,l=0,h=1e-6*Math.max(1,c-s,f-a);for(let m of t)c>m.minX&&s<m.maxX&&f>m.minY&&a<m.maxY&&u<=m.topOffsetM+1e-6&&(u=m.topOffsetM+Ha),s>=m.minX-h&&c<=m.maxX+h&&a>=m.minY-h&&f<=m.maxY+h&&(!m.poly||n.every(b=>Va(b,m.poly)||Ya(b,m.poly,h)))&&(l=Math.max(l,m.topOffsetM));return e.fill&&e.fill!=="none"&&e.fill!=="transparent"&&t.push({minX:s,minY:a,maxX:c,maxY:f,topOffsetM:u,poly:n}),{topOffsetM:u,supportOffsetM:Math.min(l,u)}}function Ya(e,t,n){for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c,u=f?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/f)):0;if(Math.hypot(e.x-(i.x+u*a),e.y-(i.y+u*c))<=n)return!0}return!1}function He(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function be(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function fe(e,t,n){return[He(e[0],e[1],t),He(e[0],e[1],n),He(e[3],e[2],n),He(e[3],e[2],t)]}function dt(e,t,n){return[He(e[0],e[3],t),He(e[1],e[2],t),He(e[1],e[2],n),He(e[0],e[3],n)]}function ee(e,t,n,o,r,i){W(e,t,void 0,()=>n,o,r,i,K)}function Je(e,t,n){if(e.length!==4||n<=t)return null;let o=be(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*w,i=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*w;if(r<1e-6||i<1e-6)return null;let s=Math.min(.22/r,.16),a=Math.min(.28,(n-t)*.13),c=Math.min(.065/i,.2);return{quad:o,side:s,face:c,opening:fe(o,s,1-s),openingTop:n-a}}function xn(e,t,n){if(e.length!==4||n-t<=.2)return null;let o=be(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*w;if(r<=1e-6)return null;let i=Math.min(.14,(n-t)*.08,r*.08),s=i/r,a=fe(o,s,1-s);return{quad:o,side:s,trim:i,inner:a,panel:dt(a,.15,.85),bottom:t+i,top:n-i}}function rr(e,t,n,o){let r=xn(e,t,n);if(!r)return;let{panel:i}=r,s=(y,M)=>({x:(y.x+M.x)/2,y:(y.y+M.y)/2}),a=s(i[0],i[1]),c=s(i[3],i[2]),f=Math.hypot(a.x-o.x,a.y-o.y)<=Math.hypot(c.x-o.x,c.y-o.y),[u,l]=f?[i[0],i[1]]:[i[3],i[2]],h=f?{x:a.x-c.x,y:a.y-c.y}:{x:c.x-a.x,y:c.y-a.y},m=Math.hypot(h.x,h.y);if(m<1e-6)return;-(l.y-u.y)*h.x+(l.x-u.x)*h.y<0&&([u,l]=[l,u]);let d=Math.min(.006,m*w*.05),p=h.x/m*d,b=h.y/m*d,x=(y,M)=>[y.x*w+p,M,y.y*w+b];return[x(u,r.bottom),x(l,r.bottom),x(u,r.top),x(l,r.top)]}var ir=Fe(require("polygon-clipping"),1);function Oe(e,t,n,o,r,i,s,a={}){let c=Le(t),f=a.ao??K,u=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let b=se(p);if(!b||b.length!==4||!qe(c,Le(b)))return[];let x=a.portalBase??n,y=Je(b,x,x+Pe(p).heightM);if(!y)return[];let M=Math.min(o,y.openingTop);return M<=n?[]:[{poly:y.opening,height:M}]});if(!u.length)return!1;let l=p=>p.map(b=>[b.x,b.y]),h=[l(t),...(a.holes??[]).map(l)],m=[n,...new Set(u.map(p=>p.height)),o].sort((p,b)=>p-b),d=[];try{for(let p=1;p<m.length;p++){let b=m[p-1],x=m[p];if(x-b<1e-6)continue;let y=u.filter(g=>g.height>b+1e-6).map(g=>[l(g.poly)]),M=y.length?ir.default.difference(h,...y):[h];d.push({low:b,high:x,polys:M})}}catch{return!1}for(let p of d)for(let b of p.polys){let[x,...y]=b.map(g=>g.map(([v,S])=>({x:v,y:S}))),M=g=>f.wallBottom+(f.top-f.wallBottom)*(g-n)/(o-n);W(e,x,y,()=>p.high,p.low,i,s,{...f,top:M(p.high),wallBottom:M(p.low)})}return!0}function sr(e,t,n,o,r,i,s){let a=o-n;if(a<=0)return;let c=a<1.5?[[n,o,1]]:[[n,n+Math.min(.9,a*.18),.82],[n+Math.min(.9,a*.18),o-.1,1],[o-.1,o,1.1]],f=u=>K.wallBottom+(K.top-K.wallBottom)*(u-n)/a;for(let[u,l,h]of c){let m={...K,top:f(l),wallBottom:f(u)},d=z(i,h),p=z(s,h);Oe(e,t,u,l,r,d,p,{portalBase:n,ao:m})||W(e,t,void 0,()=>l,u,d,p,m)}}function pt(e,t,n){let o=oe(t.stroke?.color),r=t.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let i=t.kind==="line"||t.kind==="polyline",s=i?Ot(t.points??[],t.rotation):se(t);if(!s||s.length<2)return;let a=i?s.length-1:s.length,c=r*.5;for(let f=0;f<a;f++){let u=s[f],l=s[(f+1)%s.length],h=Math.hypot(l.x-u.x,l.y-u.y);if(h<1e-6)continue;let m=-(l.y-u.y)/h*c,d=(l.x-u.x)/h*c,p=[(u.x+m)*w,n,(u.y+d)*w],b=[(l.x+m)*w,n,(l.y+d)*w],x=[(l.x-m)*w,n,(l.y-d)*w],y=[(u.x-m)*w,n,(u.y-d)*w];e.tri(p,b,x,[0,1,0],o),e.tri(p,x,y,[0,1,0],o)}}function ar(e){return e==="bar"||e==="concession"||e==="coat"||e==="restroom"}var et=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function Bt(e,t,n,o){let[r,i,s,a]=t?e:[e[3],e[2],e[1],e[0]];return[et(r,a,n),et(i,s,n),et(i,s,o),et(r,a,o)]}function cr(e,t,n,o,r,i,s,a,c=!1){if(n.length!==4||r-o<.4)return!1;let f=I=>c?Math.min(I,r):I,u=be(n),l=Math.hypot(u[3].x-u[0].x,u[3].y-u[0].y)*w;if(l<.4)return!1;let h=et(u[0],u[1],.5),m=et(u[3],u[2],.5),d=Math.hypot(h.x-a.x,h.y-a.y)<=Math.hypot(m.x-a.x,m.y-a.y),p=re(s,[.92,.9,.86],.35),b=z(i,.72),x=r-o;if(t==="restroom"){let I=Math.min(.18,x*.08);return ee(e,u,r-I,o,s,i),ee(e,u,r,r-I,p,p),!0}let y=o+Math.min(1.1,x),M=t==="coat"?1:Math.min(.5,.75/l),g=Bt(u,d,0,M);if(ee(e,g,y-.05,o,b,i),ee(e,g,y,y-.05,p,p),t==="coat"||l<1.2)return!0;if(t==="bar"){let I=Bt(u,d,Math.max(M+.2,1-.45/l),1),P=f(o+Math.max(Math.min(2.2,x*2),y-o+.6));return ee(e,I,P,o,s,b),!0}let v=Bt(u,d,Math.max(M+.25,.55),1),S=f(o+Math.max(2.6,y-o+1.4));if(S-.14<=y)return!0;ee(e,v,S-.14,o,s,i),ee(e,u,S,S-.14,p,b);let R=Math.min(.08,.1/Math.max(.1,Math.hypot(u[1].x-u[0].x,u[1].y-u[0].y)*w));for(let[I,P]of[[0,R],[1-R,1]])ee(e,Bt(fe(u,I,P),d,0,Math.min(.08,.1/l)),S-.14,y,b,b);return!0}var Ka=[.12,.38,.16],Wa=[.72,.62,.45],za=[.88,.93,.96],lr=[.95,.95,.94],Za=[.66,.29,.22],gn={length:20.12,width:3.05},$a=.14,Qa=9.76,Be=[.93,.94,.95],Ft=[.1,.11,.13],qa=[.45,.85,1.25],Ja=1.45,ur=.012,fr=.004,ec=1.07,tc=.15;function nt(e,t,n,o,r,i){e.setMaterial(i),W(e,t,n?[n.slice().reverse()]:void 0,()=>o,o-.004,r,r,K)}var mr=(e,t)=>Ye(e,t/w);function hr(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<1e-9)return null;let s=-r/i*n,a=o/i*n;return[{x:e.x+s,y:e.y+a},{x:t.x+s,y:t.y+a},{x:t.x-s,y:t.y-a},{x:e.x-s,y:e.y-a}]}function nc(e,t,n,o){let r=t.map(i=>[i.x*w,n,i.y*w]);e.tri(r[0],r[1],r[2],[0,1,0],o),e.tri(r[0],r[2],r[3],[0,1,0],o)}function Dt(e,t,n,o,r,i){let s=n/w,a=[{x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s},{x:t.x-s,y:t.y+s}];W(e,a,void 0,()=>r,o,i,z(i,.85),K)}function tt(e,t,n,o,r,i,s){let a=hr(t,n,o/w);a&&W(e,a,void 0,()=>i,r,s,z(s,.85),K)}function Nt(e){let t=be(e),n={x:(t[0].x+t[2].x)/2,y:(t[0].y+t[2].y)/2},o=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y)||1,r=Math.hypot(t[3].x-t[0].x,t[3].y-t[0].y)||1,i={x:(t[1].x-t[0].x)/o,y:(t[1].y-t[0].y)/o},s={x:(t[3].x-t[0].x)/r,y:(t[3].y-t[0].y)/r};return{at:(c,f)=>({x:n.x+(i.x*c+s.x*f)/w,y:n.y+(i.y*c+s.y*f)/w}),lengthM:o*w,widthM:r*w}}function dr(e,t,n){let o=Zn(t);if(!o.length)return;let r=1/0,i=-1/0,s=1/0,a=-1/0;for(let M of t.points??[])r=Math.min(r,M.x),i=Math.max(i,M.x),s=Math.min(s,M.y),a=Math.max(a,M.y);let c=(t.rotation??0)*Math.PI/180,f=Math.cos(c),u=Math.sin(c),l=(r+i)/2,h=(s+a)/2,m=M=>c?{x:l+(M.x-l)*f-(M.y-h)*u,y:h+(M.x-l)*u+(M.y-h)*f}:M,d=Math.min(i-r,a-s)*w,p=Math.max(.04,Math.min(.3,d*.004))/w,b=0;e.setMaterial(0);for(let M of o){if(!M.fill)continue;let g=M.points.map(m);nt(e,g,null,n+ur+b*fr,oe(M.fill)??Be,0),b++}let x=o.filter(M=>!(M.fill&&M.ink===M.fill)),y=[...new Set(x.map(M=>M.ink??It))];for(let M of y){let g=n+ur+b++*fr,v=oe(M)??Be;for(let S of x){if((S.ink??It)!==M)continue;let R=S.points.map(m),I=S.closed?R.length:R.length-1;for(let P=0;P<I;P++){let A=hr(R[P],R[(P+1)%R.length],p);A&&nc(e,A,g,v)}}}}function pr(e,t,n,o,r){if(t.length<3)return!1;let i=o+.006,s=r??Ka;if(n==="oval-cricket"){let a=t.reduce((v,S)=>v+S.x,0)/t.length,c=t.reduce((v,S)=>v+S.y,0)/t.length,f=v=>t.map(S=>({x:a+(S.x-a)*v,y:c+(S.y-c)*v})),u=8;for(let v=0;v<u;v++){let S=f(1-v/u),R=v===u-1?null:f(1-(v+1)/u);nt(e,S,R,i,z(s,v%2?1.04:.96),4)}let l=t[0];for(let v of t)Math.hypot(v.x-a,v.y-c)>Math.hypot(l.x-a,l.y-c)&&(l=v);let h=Math.hypot(l.x-a,l.y-c)||1,m=(l.x-a)/h,d=(l.y-c)/h,p=-d,b=m,x=Math.min(1,2*h*w*$a/gn.length),y=gn.length*x/2/w,M=gn.width*x/2/w,g=[[-y,-M],[y,-M],[y,M],[-y,M]].map(([v,S])=>({x:a+m*v+p*S,y:c+d*v+b*S}));return nt(e,g,null,i+.004,Wa,0),e.setMaterial(0),!0}if(n==="rink-hockey"){let a=mr(t,tc);return nt(e,a,null,i,za,0),e.setMaterial(0),W(e,t,[a.slice().reverse()],()=>o+ec,o,lr,z(lr,.9),K),!0}if(n==="ring-boxing"&&t.length===4){let{at:a}=Nt(t),c=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],f=[[.77,.19,.19],Be,[.17,.42,.69],Be];e.setMaterial(0),c.forEach((u,l)=>Dt(e,u,.07,o,o+Ja,f[l]));for(let u of qa)for(let l=0;l<4;l++)tt(e,c[l],c[(l+1)%4],.025,o+u-.025,o+u+.025,Be);return!0}if(n==="court-tennis"&&t.length===4){let{at:a}=Nt(t);e.setMaterial(0),tt(e,a(0,-6.4),a(0,6.4),.015,o,o+.95,Ft),tt(e,a(0,-6.4),a(0,6.4),.03,o+.95,o+1,Be);for(let c of[-1,1])Dt(e,a(0,c*6.4),.05,o,o+1.07,Ft);return!0}if(n==="court-basketball"&&t.length===4){let{at:a,lengthM:c}=Nt(t),f=Math.min(14,c/2-.5);e.setMaterial(0);for(let u of[-1,1]){let l=a(u*(f+1.2),0),h=a(u*(f-1.2),0);Dt(e,l,.12,o,o+3.4,Ft),tt(e,l,h,.06,o+3.25,o+3.4,Ft),tt(e,a(u*(f-1.2),-.9),a(u*(f-1.2),.9),.03,o+2.9,o+3.95,Be)}return!0}if(n==="pitch-rugby"&&t.length===4){let{at:a,lengthM:c}=Nt(t),f=c*(50/120);e.setMaterial(0);for(let u of[-1,1]){for(let l of[-2.8,2.8])Dt(e,a(u*f,l),.07,o,o+12,Be);tt(e,a(u*f,-2.8),a(u*f,2.8),.06,o+2.94,o+3.06,Be)}return!0}if(n==="track-athletics"){let a=mr(t,Qa);return a.length<3?!1:(nt(e,t,a,i,Za,0),nt(e,a,null,i,s,4),e.setMaterial(0),!0)}return!1}var oc=.012,Ht=2.4,rc=1,ic=.75,sc=.15;function _e(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:o,rotation:r}=e;if(!n||!o)return null;let i=(r??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=n/2,f=o/2;return[[-c,-f],[c,-f],[c,f],[-c,f]].map(([u,l])=>({x:t.x+u*s-l*a,y:t.y+u*a+l*s}))}function Sr(e,t,n,o,r,i,s=!1){let a=_e(t);if(a){if(s){let c=je(o,r.boothTop),f=Ae([...a]);W(e,Ie(f,ac/w),[f.slice().reverse()],()=>n+.03,n,c,z(c,.8),K);return}if(!(!t.points&&i&&lc(e,a,n,o,i))){if(!t.points&&i&&a.length===4){cc(e,a,n,o,i);return}W(e,a,void 0,()=>n+Ht,n,je(o,r.boothTop),r.boothWall,K)}}}var Mn=1.1,br=[.9,.9,.88],ac=.1,Gt=[.87,.87,.85],yr=.08;function Ir(e,t){let n=c=>({x:(e[c].x+e[(c+1)%4].x)/2,y:(e[c].y+e[(c+1)%4].y)/2}),o=0,r=1/0;for(let c=0;c<4;c++){let f=n(c),u=Math.hypot(f.x-t.x,f.y-t.y);u<r&&(r=u,o=c)}let i=[0,1,2,3].map(c=>e[(o+c)%4]),s=(c,f,u)=>({x:c.x+(f.x-c.x)*u,y:c.y+(f.y-c.y)*u});return{q:i,part:(c,f,u,l)=>{let h=s(i[0],i[1],c),m=s(i[0],i[1],f),d=s(i[3],i[2],c),p=s(i[3],i[2],f);return[s(h,d,u),s(m,p,u),s(m,p,l),s(h,d,l)]},depthM:Math.hypot(i[3].x-i[0].x,i[3].y-i[0].y)*w,widthM:Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*w}}function cc(e,t,n,o,r){let{q:i,part:s}=Ir(t,r),a=o??[.35,.42,.55],c=re(a,[.78,.78,.77],.62),f=re(a,[.95,.95,.94],.45);ee(e,i,n+Ge,n,c,z(c,.8)),ee(e,s(.05,.95,.72,.98),n+Mn-.05,n+Ge,f,z(f,.8)),ee(e,s(.03,.97,.7,1),n+Mn,n+Mn-.05,br,z(br,.9))}function lc(e,t,n,o,r){if(t.length!==4)return!1;let{q:i,part:s,depthM:a,widthM:c}=Ir(t,r);if(a<1||c<1)return!1;let f=o??[.35,.42,.55],u=re(f,[.78,.78,.77],.62),l=n+Ht,h=yr/c,m=yr/a;ee(e,i,n+Ge,n,u,z(u,.8)),ee(e,s(0,1,1-m,1),l,n+Ge,Gt,z(Gt,.9));for(let[b,x]of[[0,h],[1-h,1]])ee(e,s(b,x,0,1-m),l,n+Ge,Gt,z(Gt,.9));ee(e,s(h,1-h,0,Math.min(.5,.06/a)),l,l-.3,f,z(f,.85));let d=Math.min(.4,.6/c),p=Math.min(.12,.3/a);return ee(e,s(.5-d,.5+d,.72-p,.72+p),n+rc,n+Ge,re(f,[.95,.95,.94],.7),z(f,.75)),!0}function Xt(e){if(e.shape==="round"){let u=e.radius;return u?At(e.center.x,e.center.y,u,u,24):null}let{width:t,height:n,rotation:o,center:r}=e;if(!t||!n)return null;let i=(o??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),c=t/2,f=n/2;return[[-c,-f],[c,-f],[c,f],[-c,f]].map(([u,l])=>({x:r.x+u*s-l*a,y:r.y+u*a+l*s}))}function Pr(e,t,n,o,r,i=!0){let s=Xt(t);if(!s)return;let a=s.reduce((h,m)=>h+m.x,0)/s.length,c=s.reduce((h,m)=>h+m.y,0)/s.length,f=h=>s.map(m=>({x:a+(m.x-a)*h,y:c+(m.y-c)*h})),u=i&&o?je(o,r.tableTop):uc,l=n+ic;W(e,s,void 0,()=>l,n+fc,u,z(u,.86),K),W(e,f(.12),void 0,()=>l+.12,l,xr,z(xr,.8),K)}var uc=[.93,.92,.89],xr=[.78,.66,.42],fc=.25;function Rr(e,t,n,o,r,i,s,a,c=[]){let f=se(t);if(!t.role&&(!t.fill||t.fill==="none"||t.fill==="transparent")||!f){pt(e,t,n+o+oc);return}let l=a?a.kind==="stage":t.role==="stage",h=a?a.kind==="screen":t.role==="screen",m=a?{kind:l?"stage":"solid",heightM:a.topY-a.baseY}:Pe(t),d=a?.baseY??n,p=a?.topY??n+o;if(l&&s){let I=1/0,P=-1/0,A=1/0,_=-1/0;for(let T of f)T.x<I&&(I=T.x),T.x>P&&(P=T.x),T.y<A&&(A=T.y),T.y>_&&(_=T.y);s.push({cx:(I+P)/2*w,cz:(A+_)/2*w,y:p,halfX:Math.max((P-I)/2*w,.5),halfZ:Math.max((_-A)/2*w,.5)})}let b=oe(t.fill),x=t.role==="wall"||t.role==="entrance"||t.role==="exit",y=x?b?z(Ce(b,.12),.95):r.tierTop:l&&b?re(r.stageTop,z(Ce(b,.18),.9),.9):!t.role&&b?b:je(b,l?r.stageTop:r.decorTop),M=h?b:null,g=x?b?z(Ce(b,.12),.85):r.tierWall:l?b?re(r.stageWall,z(b,.58),.82):r.stageWall:h?M?re(z(M,1.42),[.24,.46,.82],.08):[.24,.46,.82]:je(oe(t.fill),r.decorWall);if(t.role==="wall"&&!a){sr(e,f,d,p,c,y,g),pt(e,t,p+.012);return}if(h&&f.length===4&&p-d>.2){let I=xn(f,d,p);if(!I)return;let{quad:P,side:A,trim:_,inner:T,panel:k}=I,E=[.12,.15,.18];for(let[C,O]of[[0,A],[1-A,1]])ee(e,fe(P,C,O),p,d,E,E);ee(e,T,d+_,d,E,E),ee(e,T,p,p-_,E,E),ee(e,k,p-_,d+_,g,g),pt(e,t,p+.012);return}let v=b?z(Ce(b,.15),.82):g,S=b?z(Ce(b,.1),1.02):y;if(ar(t.role)&&!a&&cr(e,t.role,f,d,p,v,S,i,t.heightM!==void 0))return;if((t.role==="sound"||a?.kind==="sound_desk")&&f.length===4&&p-d>.3){let I=be(f),P=Math.hypot(I[1].x-I[0].x,I[1].y-I[0].y)*w,A=Math.min(.12,.09/Math.max(P,.001)),_=[.18,.21,.24],T=p-Math.min(.12,(p-d)*.15);for(let[k,E]of[[0,A],[1-A,1]])ee(e,fe(I,k,E),T,d,_,_);ee(e,I,p,T,y,_);return}if(t.role==="rail"&&f.length===4&&p>d){let I=be(f),P=Math.hypot(I[1].x-I[0].x,I[1].y-I[0].y)*w,A=Math.max(1,Math.min(128,Math.ceil(P/1.4))),_=Math.min(.08,.055/Math.max(.055,P)),T=[.58,.64,.66];for(let k=0;k<=A;k++){let E=k/A,C=Math.min(1-_,Math.max(0,E-_/2));ee(e,fe(I,C,C+_),p,d,T,z(T,.8))}for(let k of[.52,1]){let E=d+(p-d)*k;ee(e,I,E,Math.max(d,E-.055),T,z(T,.8))}return}if(t.role==="goal"&&f.length===4){let I=be(f),P=Math.hypot(I[1].x-I[0].x,I[1].y-I[0].y)*w,A=Math.min(.12,.1/Math.max(.1,P)),_=[.9,.94,.94];for(let[T,k]of[[0,A],[1-A,1]])ee(e,fe(I,T,k),Math.max(d,p-.1),d,_,_);ee(e,I,p,Math.max(d,p-.1),_,_);return}if(m.kind==="portal"&&f.length===4){let I=Je(f,d,p);if(!I)return;let{quad:P,side:A,face:_,openingTop:T}=I;for(let[k,E,C]of[[0,_,1],[_,1-_,.67],[1-_,1,1]]){let O=dt(P,k,E),F=z(y,C),L=z(g,C);for(let[B,N]of[[0,A],[1-A,1]])ee(e,fe(O,B,N),T,d,F,L);ee(e,O,p,T,F,L)}return}if(m.kind==="suite"&&f.length===4){let I=f.map((_,T)=>{let k=f[(T+1)%4],E=(_.x+k.x)/2,C=(_.y+k.y)/2;return Math.hypot(E-i.x,C-i.y)}),P=I.indexOf(Math.min(...I)),A=[0,1,2,3].map(_=>f[(P+_)%4]);ee(e,fe(A,0,.08),p,d,y,g),ee(e,fe(A,.92,1),p,d,y,g),ee(e,dt(A,.88,1),p,d,y,g),ee(e,A,p,Math.max(d,p-.18),y,g);return}if(l&&!t.stageKind?.startsWith("pitch-")&&p-d>.12){let I=p-Math.min(.06,(p-d)*.15);ee(e,f,I,d,y,g),ee(e,f,p,I,y,re(y,g,.2))}else ee(e,f,p,d,y,g);if((t.stageKind==="pitch-football"||t.stageKind==="pitch-rugby")&&f.length===4){e.setMaterial(4);let I=be(f);for(let P=0;P<12;P++){let A=fe(I,P/12,(P+1)/12),_=z(b??[.12,.38,.16],P%2?1.035:.965),T=A.map(k=>[k.x*w,p+.006,k.y*w]);e.tri(T[0],T[1],T[2],[0,1,0],_),e.tri(T[0],T[2],T[3],[0,1,0],_)}}t.stageKind&&t.stageKind!=="pitch-football"&&pr(e,f,t.stageKind,p,b),l&&Xe(t.stageKind)&&dr(e,t,p),e.setMaterial(h?1:0),pt(e,t,p+.012)}function Ut(e){let{x:t,y:n,width:o,height:r}=e;if(!o||!r)return null;let i=t+o/2,s=n+r/2,a=(e.rotation??0)*Math.PI/180,c=Math.cos(a),f=Math.sin(a),u=o/2,l=r/2;return[[-u,-l],[u,-l],[u,l],[-u,l]].map(([h,m])=>({x:i+h*c-m*f,y:s+h*f+m*c}))}function mc(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let o=n[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return oe(o);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let s=[];for(let a of i[1].matchAll(/stop-color="([^"]+)"/gi)){let c=oe(a[1].trim());c&&s.push(c)}return s.length?s.reduce((a,c,f)=>re(a,c,1/(f+1)),s[0]):null}function wr(e,t,n,o){if(t.layer==="foreground")return;let r=Ut(t);if(!r)return;let i=n+sc,s=je(mc(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=re(o.ground,s,a)),W(e,r,void 0,()=>i,n,s,re(s,o.decorWall,.5),K)}function vr(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=je(o,r.gaTop);W(e,t.points,t.holes,()=>n+gr,n,i,r.gaWall,K),pc(e,t.points,n+gr)}var gr=.15,jt=[.72,.74,.76],Sn=1.1,Mr=.12,In=.05,hc=.06,dc=2.4;function pc(e,t,n){let o=Ae([...t]),r=Ye(o,Mr/w),i=Ye(o,(Mr+In)/w);if(r.length<3||i.length<3)return;for(let a of[n+Sn,n+Sn*.5])W(e,r,[i.slice().reverse()],()=>a,a-In,jt,z(jt,.85),K);let s=hc/2/w;for(let a=0;a<r.length;a++){let c=r[a],f=r[(a+1)%r.length],u=Math.hypot(f.x-c.x,f.y-c.y)*w,l=Math.max(1,Math.round(u/dc));for(let h=0;h<l;h++){let m=h/l,d=c.x+(f.x-c.x)*m,p=c.y+(f.y-c.y)*m,b=[{x:d-s,y:p-s},{x:d+s,y:p-s},{x:d+s,y:p+s},{x:d-s,y:p+s}];W(e,b,void 0,()=>n+Sn-In,n,jt,z(jt,.8),K)}}}var Pn=.6,Er=3,bc=.25;function yc(e,t){if(pe(t,e.x,e.y))return 0;let n=1/0;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c||1,u=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/f));n=Math.min(n,Math.hypot(e.x-(i.x+u*a),e.y-(i.y+u*c)))}return n}function Ar(e,t){let n=e.map(s=>({booth:s,ring:_e(s)})).filter(s=>!!s.ring&&s.ring.length===4&&!s.booth.points),o=n.map(({ring:s})=>({minX:Math.min(...s.map(a=>a.x)),maxX:Math.max(...s.map(a=>a.x)),minY:Math.min(...s.map(a=>a.y)),maxY:Math.max(...s.map(a=>a.y))})),r=(Er+Pn)/w,i=new Map;return n.forEach(({booth:s,ring:a},c)=>{let f={x:a.reduce((m,d)=>m+d.x,0)/4,y:a.reduce((m,d)=>m+d.y,0)/4},u=[0,1,2,3].map(m=>{let d=a[m],p=a[(m+1)%4],b={x:(d.x+p.x)/2,y:(d.y+p.y)/2},x=b.x-f.x,y=b.y-f.y,M=Math.hypot(x,y)||1,g={x:b.x+x/M*Pn/w,y:b.y+y/M*Pn/w},v=Er/w;return o.forEach((S,R)=>{R===c||g.x<S.minX-r||g.x>S.maxX+r||g.y<S.minY-r||g.y>S.maxY+r||(v=Math.min(v,yc(g,n[R].ring)))}),{open:v*w,toward:{x:b.x+x/M*10/w,y:b.y+y/M*10/w},focal:Math.hypot(b.x-t.x,b.y-t.y)}}),l=Math.max(...u.map(m=>m.open)),h=u.filter(m=>m.open>=l-bc).sort((m,d)=>m.focal-d.focal)[0];i.set(s.id,h.toward)}),i}var Cr=Fe(require("polygon-clipping"),1);var xc=.45,gc=1500,Mc=200;function _r(e,t){if(e.role!=="stage"||Xe(e.stageKind))return e;let n=se(e);if(!n||n.length<3||Math.abs(de(n))*w*w>gc)return e;let o=t.filter(s=>pe(n,s.x,s.y));if(!o.length||o.length>Mc)return e;let r=xc/w,i=o.map(s=>[[[s.x-r,s.y-r],[s.x+r,s.y-r],[s.x+r,s.y+r],[s.x-r,s.y+r],[s.x-r,s.y-r]]]);try{let s=Cr.default.difference([[...n.map(f=>[f.x,f.y]),[n[0].x,n[0].y]]],...i),a=null,c=0;for(let f of s){let u=f[0].slice(0,-1).map(([h,m])=>({x:h,y:m})),l=Math.abs(de(u));l>c&&(c=l,a=u)}return!a||a.length<3?e:{...e,kind:"polygon",points:a,rotation:0}}catch{return e}}var Sc=Math.PI/180,ie=96,Ic=6,Pc=60,Rc=150,kr=.2,wc=.35;function vc(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/Sc;return n<0?n+360:n}function Vt(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function Yt(e,t,n=2){let o=e.length,r=new Float64Array(o);for(let i=0;i<o;i++){let s=0,a=0;for(let c=-n;c<=n;c++){let f=i+c;if(t)f=(f%o+o)%o;else if(f<0||f>=o)continue;s+=e[f],a++}r[i]=s/a}return r}function Tr(e,t){let n=e.filter(h=>h.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let h of n)for(let m of h.rows){for(let d of m.pts)r+=d.x,i+=d.y,s++;if(m.pts.length>=4){let d=on(m.pts);d&&Number.isFinite(d.cx)&&Number.isFinite(d.cy)&&o.push({x:d.cx,y:d.cy})}}if(!s)return null;let a={x:r/s,y:i/s},c=a;if(o.length>=8){let h=Vt(o.map(x=>x.x)),m=Vt(o.map(x=>x.y)),d=0;for(let x of n)for(let y of x.rows)for(let M of y.pts){let g=Math.hypot(M.x-a.x,M.y-a.y);g>d&&(d=g)}let p=0,b=d*.2;for(let x of n)for(let y of x.rows)for(let M of y.pts)Math.hypot(M.x-h,M.y-m)<b&&p++;Math.hypot(h-a.x,m-a.y)<=d&&p/s<.01&&(c={x:h,y:m})}let f=[];for(let h of n){let m={sectionId:h.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let d of h.rows)for(let p of d.pts){let b=Math.hypot(p.x-c.x,p.y-c.y),x=Math.min(ie-1,Math.floor(vc(c,p)/(360/ie)));m.samples.push({r:b,bin:x,levelM:d.levelM}),b<m.rMin&&(m.rMin=b),b>m.rMax&&(m.rMax=b)}m.samples.length&&f.push(m)}if(!f.length)return null;f.sort((h,m)=>h.rMin+h.rMax-(m.rMin+m.rMax));let u=[];for(let h of f){let m=!1;for(let d of u){let p=Math.min(h.rMax,d.rMax)-Math.max(h.rMin,d.rMin),b=Math.min(h.rMax-h.rMin,d.rMax-d.rMin);if(b>1e-9&&p>=wc*b){d.members.push(h),d.rMin=Math.min(d.rMin,h.rMin),d.rMax=Math.max(d.rMax,h.rMax),m=!0;break}}m||u.push({members:[h],rMin:h.rMin,rMax:h.rMax})}let l=[];for(let h of u){let m=new Array(ie).fill(null);for(let k of h.members)for(let E of k.samples){let C=m[E.bin];C||(C={samples:[]},m[E.bin]=C),C.samples.push({r:E.r,levelM:E.levelM})}let d=m.map(k=>!!k);if(!d.filter(Boolean).length)continue;let b=[],x=[];for(let k of m){if(!k)continue;let E=1/0,C=-1/0;for(let O of k.samples)O.r<E&&(E=O.r),O.r>C&&(C=O.r);b.push(E),x.push(C)}let y=Vt(b),M=Vt(x);if(!(y>=kr*M)||!(M>0))continue;let g=[...b].sort((k,E)=>k-E);if(!(g[Math.floor(g.length*.1)]>=kr*M))continue;let S=m.map(k=>{if(!k)return null;let E=[...k.samples].sort((D,V)=>D.r-V.r),C=E[0].r,O=E[E.length-1].r,F=E[0].levelM,L=-1/0;for(let D of E)D.levelM>L&&(L=D.levelM);let B=[];for(let D of E){let V={r:D.r,l:D.levelM};for(;B.length&&Math.abs(B[B.length-1].r-V.r)<1e-9;){if(B[B.length-1].l<=V.l){V.skip=!0;break}B.pop()}if(!V.skip){for(;B.length>=2;){let U=B[B.length-2],Z=B[B.length-1];if((Z.r-U.r)*(V.l-U.l)-(Z.l-U.l)*(V.r-U.r)<=0)B.pop();else break}B.push(V)}}let N=B.map(D=>D.r),H=B.map(D=>D.l);return{inner:C,outer:O,front:F,top:L,profile:{rs:N,ls:H}}}),R=d.slice();for(let k=0;k<ie;k++){if(R[k])continue;let E=-1,C=-1,O=0;for(let X=1;X<=ie;X++){let q=(k-X+ie*2)%ie;if(R[q]){E=q;break}}for(let X=1;X<=ie;X++){let q=(k+X)%ie;if(R[q]){C=q,O=X;break}}if(E<0||C<0)continue;let F=0;for(let X=1;X<=ie;X++){let q=(k-X+ie*2)%ie;if(d[q]){F=X;break}}if(F-1+O>Ic)continue;let B=S[E],N=S[C],H=F/(F+O),D=B.inner+(N.inner-B.inner)*H,V=B.outer+(N.outer-B.outer)*H,U=B.front+(N.front-B.front)*H,Z=B.top+(N.top-B.top)*H;S[k]={inner:D,outer:V,front:U,top:Z,profile:{rs:[D,V],ls:[U,Z]}}}for(let k=0;k<ie;k++)S[k]&&(R[k]=!0);let I=360/ie,P=[],A=R.filter(Boolean).length,_=[];if(A===ie)_.push({start:0,len:ie});else{let k=0;for(;R[k];)k=(k+1)%ie;let E=-1;for(let C=0;C<=ie;C++){let O=(k+C)%ie,F=C<ie&&R[O];if(F&&E<0)E=O;else if(!F&&E>=0){let L=(O-E+ie)%ie||ie;_.push({start:E,len:L}),E=-1}}}for(let k of _){if(k.len*I<Pc&&k.len<ie)continue;let E=k.len===ie,C=new Float64Array(k.len),O=new Float64Array(k.len),F=new Float64Array(k.len),L=new Float64Array(k.len),B=[];for(let X=0;X<k.len;X++){let q=S[(k.start+X)%ie];C[X]=q.inner,O[X]=q.outer,F[X]=q.front,L[X]=q.top,B.push(q.profile??{rs:[q.inner,q.outer],ls:[q.front,q.top]})}let N=Yt(C,E),H=Yt(O,E),D=Yt(F,E),V=Yt(L,E);for(let X=0;X<k.len;X++)N[X]>C[X]&&(N[X]=C[X]),H[X]<O[X]&&(H[X]=O[X]),N[X]>H[X]-1e-6&&(N[X]=Math.max(0,H[X]-1e-6)),V[X]<D[X]&&(V[X]=D[X]);let U={startBin:k.start,binCount:k.len,closed:E,innerR:N,outerR:H,frontLevelM:D,topLevelM:V,profiles:B},Z=(X,q,$)=>{let j=B[X],G=j.rs,Q=j.ls;if(q<=G[0]){Q[0]>$&&(Q[0]=$);return}if(q>=G[G.length-1]){Q[Q.length-1]>$&&(Q[Q.length-1]=$);return}for(let te=0;te+1<G.length;te++)if(q<=G[te+1]){Q[te]>$&&(Q[te]=$),Q[te+1]>$&&(Q[te+1]=$);return}};for(let X=0;X<k.len;X++){let q=m[(k.start+X)%ie];if(q)for(let $ of q.samples){Z(X,$.r,$.levelM);let j=E?(X-1+k.len)%k.len:X-1,G=E?(X+1)%k.len:X+1;j>=0&&Z(j,$.r,$.levelM),G<k.len&&Z(G,$.r,$.levelM)}}P.push(U)}P.reduce((k,E)=>k+E.binCount*I,0)<Rc||l.push({arcs:P,sectionIds:h.members.map(k=>k.sectionId),innerRMedian:y,outerRMedian:M})}if(!l.length)return null;if(l.sort((h,m)=>h.innerRMedian-m.innerRMedian),t){let h=l[l.length-1].outerRMedian;if(Math.hypot(t.x-c.x,t.y-c.y)>.9*h)return null}return{centre:c,binCount:ie,binStepDeg:360/ie,rings:l}}function Lr(e,t,n,o){let r=e.binStepDeg,i=n/r-.5-t.startBin;i=(i%e.binCount+e.binCount)%e.binCount,i>t.binCount-1&&(t.closed?i=i-t.binCount<t.binCount-i?0:t.binCount-1:i=i-(t.binCount-1)<e.binCount-i?t.binCount-1:0);let s=Math.floor(i),a=t.closed?(s+1)%t.binCount:Math.min(t.binCount-1,s+1),c=i-s,f=u=>{let l=t.profiles[u],h=l.rs,m=l.ls;if(o<=h[0])return m[0];if(o>=h[h.length-1])return m[m.length-1];for(let d=0;d+1<h.length;d++)if(o<=h[d+1]){let p=h[d+1]-h[d],b=p>1e-9?(o-h[d])/p:0;return m[d]+(m[d+1]-m[d])*b}return m[m.length-1]};return f(s)*(1-c)+f(a)*c}function Rn(e,t,n,o,r,i,s,a,c,f=[],u=r){if(t.length!==n.length||t.length<2||i-r<1.5)return;let l=(p,b,x)=>{Oe(e,p,b,x,f,s,a,{portalBase:u,ao:c})||W(e,p,void 0,()=>x,b,s,a,c)},h=(p,b,x)=>({x:p.x+(b.x-p.x)*x,y:p.y+(b.y-p.y)*x}),m=o?t.length:t.length-1,d=0;for(let p=0;p<m;p++){let b=(p+1)%t.length,x=Math.hypot(n[b].x-n[p].x,n[b].y-n[p].y)*J;if(x<1e-5)continue;let y=(S,R)=>[h(t[p],t[b],S),h(t[p],t[b],R),h(n[p],n[b],R),h(n[p],n[b],S)];l(y(0,1),r,r+.95),l(y(0,1),i-.22,i);let M=Math.ceil((d-.32)/6)*6,g=!1,v=!1;for(let S=M;S<d+x;S+=6){let R=Math.max(0,(S-d)/x),I=Math.min(1,(S+.32-d)/x);I<=R||(l(y(R,I),r+.95,i-.22),g||=R<1e-6,v||=I>1-1e-6)}if(!o&&(p===0&&!g||p===m-1&&!v)){let S=Math.min(1,.32/x);l(y(p===0?0:1-S,p===0?S:1),r+.95,i-.22)}d+=x}}var bt=.65;function Or(e,t){let n=1/0;for(let o of t)for(let r=0;r<o.length;r++){let i=o[r],s=o[(r+1)%o.length],a=s.x-i.x,c=s.y-i.y,f=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/(a*a+c*c||1)));n=Math.min(n,Math.hypot(e.x-i.x-f*a,e.y-i.y-f*c))}return n}var Br=.01;function Fr(e,t,n,o,r,i,s,a=[],c=!0){if(o-r<=1e-5)return;let f=o-r>=3,u=f?o-bt:r;e.setMaterial(5);let l=f?[]:a.filter(g=>{if(g.role!=="entrance"&&g.role!=="exit")return!1;let v=se(g);if(!v)return!1;let S=Je(v,r,r+Pe(g).heightM);return S!==null&&S.openingTop<=o-.12});if((!l.length||!Oe(e,t,u,o,l,i,s,{holes:n,portalBase:r}))&&W(e,t,n,()=>o,u,i,s,K,void 0,()=>[0,1,0]),!f){e.setMaterial(0);return}let h=6/w,m=.22/w,d=a.flatMap(g=>{if(g.role!=="entrance"&&g.role!=="exit")return[];let v=se(g);return v?.length?[{minX:Math.min(...v.map(S=>S.x)),maxX:Math.max(...v.map(S=>S.x)),minY:Math.min(...v.map(S=>S.y)),maxY:Math.max(...v.map(S=>S.y))}]:[]}),p=Math.min(...t.map(g=>g.x)),b=Math.max(...t.map(g=>g.x)),x=Math.min(...t.map(g=>g.y)),y=Math.max(...t.map(g=>g.y));for(let g=p+h/2;g<b;g+=h)for(let v=x+h/2;v<y;v+=h){if(d.some(R=>g+m>=R.minX&&g-m<=R.maxX&&v+m>=R.minY&&v-m<=R.maxY))continue;let S=[{x:g-m,y:v-m},{x:g+m,y:v-m},{x:g+m,y:v+m},{x:g-m,y:v+m}];!me({x:g,y:v},t,n)||Or({x:g,y:v},[t,...n??[]])<m*Math.SQRT2+(c?wn/w:0)||W(e,S,void 0,()=>u,r,i,s,K)}let M=Ye(t,wn/w);if(c&&M.length>=3){let g=a.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let I=se(R);return!!I&&I.some(P=>!me(P,t,void 0)||Or(P,[t])<=wn/w)}),v=[M.slice().reverse()],S=r-Br;(!g.length||!Oe(e,t,S,u,g,i,s,{holes:v,portalBase:r+Br}))&&W(e,t,v,()=>u,S,i,s,K)}e.setMaterial(0)}var wn=.25;var Ec=.02,Ac=.25,Cc=1.2,_c=.6,kc=.45,Tc=2.3,Lc=Math.PI/180,Dr=.005;function ke(e,t,n){let o=n*Lc;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Oc(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let o=n.outerRMedian*.85;for(let r of e){if(r.role!=="wall")continue;let i=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(i.length<2)continue;let s=0;for(let a of i)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=o&&s++;if(s>=i.length/2)return!0}return!1}var Bc=24,Fc=.01;function Dc(e,t,n,o,r,i,s,a,c){let f=n.binCount,u=Bc,l=J,h=i+.02,m=i-Fc,d=[];for(let E=0;E<f;E++){let C=(n.startBin+E+.5)*t.binStepDeg,O=new Float64Array(u+1);for(let F=0;F<=u;F++){let L=o[E]+(r[E]-o[E])*F/u;O[F]=Math.max(h,Lr(t,n,C,L)-Ac)}d.push(O)}if(c){let E=0;for(let C=0;C+1<f;C++)for(let O=0;O<u;O++){let F=ke(t.centre,o[C]+(r[C]-o[C])*O/u,(n.startBin+C+.5)*t.binStepDeg),L=ke(t.centre,o[C+1]+(r[C+1]-o[C+1])*(O+1)/u,(n.startBin+C+1.5)*t.binStepDeg);E=Math.max(E,Math.hypot(L.x-F.x,L.y-F.y))}for(let C=0;C<f;C++){let O=(n.startBin+C+.5)*t.binStepDeg;for(let F=0;F<=u;F++){let L=ke(t.centre,o[C]+(r[C]-o[C])*F/u,O),B=c(L.x,L.y,E*1.01);B!==null&&(d[C][F]=Math.min(d[C][F],Math.max(m+Dr,B-Dr)))}}}let p=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],b=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],x=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],y=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],M=(E,C)=>{let O=(n.startBin+E+.5)*t.binStepDeg,F=o[E]+(r[E]-o[E])*C/u,L=ke(t.centre,F,O);return[L.x*l,d[E][C],L.y*l]};{let E=Math.tan(12*Math.PI/180);for(let C=0;C<6;C++){let O=!1;for(let L=0;L<f;L++)for(let B=u-1;B>=0;B--)d[L][B]>d[L][B+1]&&(d[L][B]=d[L][B+1],O=!0);let F=n.closed?f:f-1;for(let L=0;L<F;L++){let B=(L+1)%f;for(let N=0;N<=u;N++){let H=d[B][N]-d[L][N];if(Math.abs(H)>1)continue;let D=o[L]+(r[L]-o[L])*N/u,V=o[B]+(r[B]-o[B])*N/u,U=ke(t.centre,D,(n.startBin+L+.5)*t.binStepDeg),Z=ke(t.centre,V,(n.startBin+B+.5)*t.binStepDeg),X=E*Math.hypot(Z.x-U.x,Z.y-U.y)*l;H>X?(d[B][N]=d[L][N]+X,O=!0):-H>X&&(d[L][N]=d[B][N]+X,O=!0)}}if(!O)break}}let g=1,v=(E,C)=>{for(let O=0;O<=u;O+=4)if(Math.abs(d[E][O]-d[C][O])>g)return!0;return Math.abs(d[E][u]-d[C][u])>g},S=Math.tan(38*Math.PI/180),R=E=>(r[E]-o[E])/u*l,I=(E,C)=>d[E][C+1]-d[E][C]>S*Math.max(1e-6,R(E)),P=(E,C)=>{let O=n.closed?(E-1+f)%f:Math.max(0,E-1),F=n.closed?(E+1)%f:Math.min(f-1,E+1);Math.abs(d[O][C]-d[E][C])>g&&(O=E),Math.abs(d[F][C]-d[E][C])>g&&(F=E);let L=Math.max(0,C-1),B=Math.min(u,C+1);L<C&&I(E,L)&&(L=C),B>C&&I(E,C)&&(B=C);let N=M(O,C),H=M(F,C),D=M(E,L),V=M(E,B),U=H[0]-N[0],Z=H[1]-N[1],X=H[2]-N[2],q=V[0]-D[0],$=V[1]-D[1],j=V[2]-D[2],G=Z*j-X*$,Q=X*q-U*j,te=U*$-Z*q,ne=Math.hypot(G,Q,te);return ne>1e-12?(G/=ne,Q/=ne,te/=ne,Q<0&&(G=-G,Q=-Q,te=-te),[G,Q,te]):[0,1,0]},A=(E,C,O=!1)=>{let F=O&&Math.min(E[1],C[1])-i>=3,L=[E[0],F?E[1]-bt:m,E[2]],B=[C[0],F?C[1]-bt:m,C[2]],N=C[0]-E[0],H=C[2]-E[2],D=Math.hypot(N,H);if(!(D>1e-12))return;let V=[H/D,0,-N/D];e.tri(E,C,B,V,x,x,y),e.tri(E,B,L,V,x,y,y)},_=.05*ge,T=E=>r[E]-o[E]<_,k=n.closed?f:f-1;for(let E=0;E<k;E++){let C=(E+1)%f;if(T(E)||T(C))continue;if(v(E,C)){let H=(n.startBin+E+1)*t.binStepDeg,D=($,j)=>{let G=(o[E]+o[C])/2,Q=(r[E]+r[C])/2,te=G+(Q-G)*j/u,ne=ke(t.centre,te,H);return[ne.x*l,d[$][j],ne.y*l]};for(let $=0;$<u;$++){let j=M(E,$),G=M(E,$+1),Q=D(E,$),te=D(E,$+1),ne=P(E,$),ce=P(E,$+1);e.triN(j,Q,te,ne,ne,ce,p),e.triN(j,te,G,ne,ce,ce,p);let ae=M(C,$),Y=M(C,$+1),le=D(C,$),Re=D(C,$+1),we=P(C,$),ve=P(C,$+1);e.triN(le,ae,Y,we,we,ve,p),e.triN(le,Y,Re,we,ve,ve,p);let Se=D(E,$),he=D(E,$+1),We=D(C,$+1),Zt=D(C,$),xt=he[0]-Se[0],rt=he[2]-Se[2],$t=Math.hypot(xt,rt);if($t>1e-12){let On=[rt/$t,0,-xt/$t];e.tri(Se,he,We,On,x),e.tri(Se,We,Zt,On,x)}}let V=M(E,0),U=M(C,0),Z=M(C,u),X=M(E,u),q=$=>[$[0],m,$[2]];Math.min(V[1],U[1])-i<3&&(e.tri(q(V),q(Z),q(U),[0,-1,0],b),e.tri(q(V),q(X),q(Z),[0,-1,0],b)),A(V,U,!0),A(X,Z,!0);continue}for(let H=0;H<u;H++){let D=P(E,H),V=P(C,H),U=P(C,H+1),Z=P(E,H+1);if(I(E,H)||I(C,H)){let G=(he,We)=>{let Zt=(n.startBin+he+.5)*t.binStepDeg,xt=o[he]+(r[he]-o[he])*(H+.5)/u,rt=ke(t.centre,xt,Zt);return[rt.x*l,We,rt.y*l]},Q=M(E,H),te=M(C,H),ne=G(E,d[E][H]),ce=G(C,d[C][H]);e.triN(Q,te,ce,D,V,V,p),e.triN(Q,ce,ne,D,V,D,p);let ae=M(C,H+1),Y=M(E,H+1),le=G(E,d[E][H+1]),Re=G(C,d[C][H+1]);e.triN(le,Re,ae,Z,U,U,p),e.triN(le,ae,Y,Z,U,Z,p);let we=ce[0]-ne[0],ve=ce[2]-ne[2],Se=Math.hypot(we,ve);if(Se>1e-12){let he=[-ve/Se,0,we/Se];e.tri(ne,ce,Re,he,x),e.tri(ne,Re,le,he,x)}continue}let X=M(E,H),q=M(C,H),$=M(C,H+1),j=M(E,H+1);e.triN(X,q,$,D,V,U,p),e.triN(X,$,j,D,U,Z,p)}let O=M(E,0),F=M(C,0),L=M(C,u),B=M(E,u),N=H=>[H[0],m,H[2]];Math.min(O[1],F[1])-i<3&&(e.tri(N(O),N(L),N(F),[0,-1,0],b),e.tri(N(O),N(B),N(L),[0,-1,0],b)),A(O,F,!0),A(B,L,!0)}if(!n.closed)for(let E of[0,f-1])for(let C=0;C<u;C++)A(M(E,C),M(E,C+1))}function Nr(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let u of t.rings)for(let l of u.arcs){let h=new Float64Array(l.binCount),m=new Float64Array(l.binCount);for(let p=0;p<l.binCount;p++){let b=(l.startBin+p)%t.binCount,x=Math.max(0,l.innerR[p]-Me);h[p]=Math.max(x,s[b]+.001),m[p]=Math.max(h[p]+.001,l.outerR[p]+Me)}let d=0;for(let p=0;p<l.binCount;p++){let b=l.topLevelM[p]-o;b>d&&(d=b)}d>=Cc&&Dc(e,t,l,h,m,o,r,i,n.standTopNear);for(let p=0;p<l.binCount;p++){let b=(l.startBin+p)%t.binCount;m[p]>s[b]&&(s[b]=m[p])}}if(n.deriveShell===!1||Oc(n.shapes,t))return;let a=t.rings[t.rings.length-1],c=_c*ge,f=kc*ge;for(let u of a.arcs){let l=[],h=[];for(let P=0;P<u.binCount;P++){let A=(u.startBin+P+.5)*t.binStepDeg,_=u.outerR[P]+Me+c;l.push(ke(t.centre,_,A)),h.push(ke(t.centre,_+f,A))}let m=-1/0;for(let P=0;P<u.binCount;P++)u.topLevelM[P]>m&&(m=u.topLevelM[P]);let d=m+Tc,p=u.closed?h:[...h,...l.slice().reverse()],b=u.closed?[l.slice().reverse()]:void 0,x=re(r.shellWall,[.66,.71,.72],.62),y=(P,A,_,T,k)=>{let E=Math.abs(T-m)<1e-6?T-Ec:T;Oe(e,P,_,E,n.shapes,r.shellTop,k,{holes:A,portalBase:o,ao:i})||W(e,P,A,()=>E,_,r.shellTop,k,i)},M=Math.max(1,Math.ceil((m-o)/4.5)),g=(m-o)/M,v=new Set,S=n.tierFrontLevels??t.rings.map(P=>{let A=P.arcs.flatMap(_=>Array.from(_.frontLevelM)).filter(Number.isFinite).sort((_,T)=>_-T);return A[Math.floor(A.length/2)]});for(let P of S)Number.isFinite(P)&&P-o>=3&&P<m&&v.add(Math.max(0,Math.min(M-1,Math.floor((P-o)/g))));let R=Math.min(...S.filter(P=>Number.isFinite(P)&&P-o>=3&&P<m));for(let P=0;P<M;P++)o+(P+1)*g<=R-bt&&Number.isFinite(R)&&v.add(P);for(let P=0;P<M;P++){let A=o+(m-o)*P/M,_=o+(m-o)*(P+1)/M;v.has(P)&&_-A>=3.2?(y(p,b,A,A+.45,x),Rn(e,l,h,u.closed,A+.45,_-.16,r.shellTop,x,i,n.shapes,o)):y(p,b,A,_-.16,x),y(p,b,_-.16,_,z(x,.62))}Rn(e,l,h,u.closed,m,d,r.shellTop,x,i,n.shapes,o);let I=8;for(let P=1;P<h.length;P++){if(I+=Math.hypot(h[P].x-h[P-1].x,h[P].y-h[P-1].y)*J,I<8)continue;I=0;let A=h[P],_=h[P-1],T=A.x-_.x,k=A.y-_.y,E=Math.max(1,Math.hypot(T,k)),C=T/E*.16*ge,O=k/E*.16*ge,F=Math.max(1,Math.hypot(A.x-t.centre.x,A.y-t.centre.y)),L=(A.x-t.centre.x)/F*.24*ge,B=(A.y-t.centre.y)/F*.24*ge,N=[{x:A.x-C,y:A.y-O},{x:A.x+C,y:A.y+O},{x:A.x+C+L,y:A.y+O+B},{x:A.x-C+L,y:A.y-O+B}];y(N,void 0,o,m,z(x,1.12))}}}function Gr(e,t,n,o){let r=new Map;for(let a of t){let c=r.get(a.blockId);(!c||a.depth<c.depth)&&r.set(a.blockId,a)}let i=[.68,.72,.72],s=[.48,.55,.57];for(let a of r.values()){if(a.y-o<2.5||a.pts.length<2)continue;let c=a.pts.map(u=>{let l=u.x-n.x,h=u.y-n.y,m=Math.max(1,Math.hypot(l,h));return{x:u.x-l/m*.65/w,y:u.y-h/m*.65/w}}),f=2;for(let u=1;u<c.length;u++){let l=c[u-1],h=c[u],m=h.x-l.x,d=h.y-l.y,p=Math.hypot(m,d);if(p<1e-5||p*w>2)continue;let b=x=>{let y=-d/p*x/w/2,M=m/p*x/w/2;return[{x:l.x+y,y:l.y+M},{x:h.x+y,y:h.y+M},{x:h.x-y,y:h.y-M},{x:l.x-y,y:l.y-M}]};W(e,b(.22),void 0,()=>a.y-.06,a.y-.56,i,i,K);for(let x of[.5,.95])W(e,b(.045),void 0,()=>a.y+x,a.y+x-.045,s,s,K);if(f+=p*w,f>=1.8||u===c.length-1){f=0;let x=.028/w,y=[{x:l.x-x,y:l.y-x},{x:l.x+x,y:l.y-x},{x:l.x+x,y:l.y+x},{x:l.x-x,y:l.y+x}];W(e,y,void 0,()=>a.y+.95-.045,a.y-.06,s,s,K)}}}}function jr(e,t,n,o,r){let i=[.67,.71,.68];for(let s=0;s<t.length;s++){let a=t[s];if(!(a.pts.length<2))for(let c of[0,a.pts.length-1]){let f=a.pts[c],u=a.pts[c===0?1:c-1],l=f.x-u.x,h=f.y-u.y,m=Math.hypot(l,h);if(m<1e-5)continue;l/=m,h/=m;let d=1/0;for(let I=0;I<n.length;I++){let P=n[I],A=n[(I+1)%n.length],_=A.x-P.x,T=A.y-P.y,k=l*T-h*_;if(Math.abs(k)<1e-8)continue;let E=P.x-f.x,C=P.y-f.y,O=(E*T-C*_)/k,F=(E*h-C*l)/k;O>0&&F>=0&&F<=1&&(d=Math.min(d,O))}let p=.3/w,b=d-.04/w;if(!Number.isFinite(d)||d*w>2||b-p<.12/w)continue;let x=.27/w,y=[{x:f.x+l*p-h*x,y:f.y+h*p+l*x},{x:f.x+l*b-h*x,y:f.y+h*b+l*x},{x:f.x+l*b+h*x,y:f.y+h*b-l*x},{x:f.x+l*p+h*x,y:f.y+h*p-l*x}];if(!y.every(I=>pe(n,I.x,I.y)))continue;let M=r?.[s]?.belowY,g=M==null?0:a.y-M,v=!!o&&g>.03&&g<=.65;if(v&&o){let I=(P,A)=>Math.hypot((P.x+A.x)/2-o.x,(P.y+A.y)/2-o.y);I(y[0],y[1])>I(y[3],y[2])&&(y=[y[3],y[2],y[1],y[0]])}let S=v?Math.ceil((g-1e-8)/.2):1,R=(I,P,A)=>({x:I.x+(P.x-I.x)*A,y:I.y+(P.y-I.y)*A});for(let I=0;I<S;I++){let P=I/S,A=(I+1)/S,_=[R(y[0],y[3],P),R(y[1],y[2],P),R(y[1],y[2],A),R(y[0],y[3],A)],T=a.y+.008-(v?g*(1-A):0);if(W(e,_,void 0,()=>T,T-(v?g/S+.1:.16),i,[.43,.47,.46],K),!v)continue;let k=Math.hypot(_[3].x-_[0].x,_[3].y-_[0].y)*w,E=Math.min(.04/k,.25),C=R(_[0],_[3],E),O=R(_[1],_[2],E),F=B=>[B.x*w,T+.004,B.y*w],L=[.66,.59,.39];e.tri(F(_[0]),F(_[1]),F(O),[0,1,0],L),e.tri(F(_[0]),F(O),F(C),[0,1,0],L)}}}}function Hr(e,t,n,o,r,i,s,a,c=!1){if(!t.outline||t.outline.length<3)return;let f=n.baseHeightM,u=n.objects.filter(y=>y.type==="shape"&&(y.role==="entrance"||y.role==="exit")),l=Jo(o,a.tierTop);if(!r)return;let h=y=>r.deckAt(y.x,y.y),m=zo(t,s),d=m[0]??t.outline;if(r.rowLevels.length>=2){let y=Tt(r.rowLevels),M=Zo(Xo(r.rowLevels,n.focal,y),m);for(let v of M){let S=Math.max(f,v.topY-Xr);for(let R of i.subtract(v.outline,S))Fr(e,R,v.holes,S,f,a.tierTop,a.tierWall,u,!c)}M.length||W(e,d,t.holes,()=>r.landingY,f,l,a.tierWall,K);let g={tread:[l[0]*K.top,l[1]*K.top,l[2]*K.top],riser:[l[0]*.72,l[1]*.72,l[2]*.72]};for(let v of m.length?m:[d])Vo(e,r.rowLevels,n.focal,r.landingY,g,v,y);Gr(e,r.rowLevels,n.focal,f),jr(e,r.rowLevels,t.outline,n.focal,y);return}let p=r.flat?1/0:Qo,b=y=>r.normalAt(y.x,y.y),x=r.flat?r.landingY:void 0;for(let y of i.subtract(d,x))W(e,y,t.holes,h,f,l,a.tierWall,K,p,b)}function Nc(e,t,n){let o=new Set;for(let s of e.objects)s.type==="section"&&o.add(s.id);let r=new Map;for(let s=0;s<t.length;s++){let a=n.seatOwner[s];if(!a||!o.has(a))continue;let c=n.bySection.get(a);if(c&&c.rowLevels.length>=2)continue;let f=t[s];if(f.kind==="booth")continue;let u=r.get(a);u||(u=new Map,r.set(a,u));let l=f.rowId||`__seat-${s}`,h=u.get(l);h||(h={pts:[],levelM:0,n:0},u.set(l,h)),h.pts.push({x:f.x,y:f.y}),h.levelM+=n.seatDeckY(s),h.n++}let i=[];for(let s of e.objects){if(s.type!=="section")continue;let a=n.bySection.get(s.id);if(a&&a.rowLevels.length>=2){let f=a.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));f.length>=2&&i.push({sectionId:s.id,rows:f});continue}let c=r.get(s.id);c&&i.push({sectionId:s.id,rows:[...c.values()].map(f=>({pts:f.pts,levelM:f.levelM/f.n}))})}return i}function Gc(e,t){let n=1/0;for(let o=0;o<t.length;o++){let r=t[o],i=t[(o+1)%t.length],s=i.x-r.x,a=i.y-r.y,c=Math.max(0,Math.min(1,((e.x-r.x)*s+(e.y-r.y)*a)/(s*s+a*a||1)));n=Math.min(n,Math.hypot(e.x-r.x-c*s,e.y-r.y-c*a))}return n}var Xr=.02;function jc(e,t){let n=e.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=t.bySection.get(o.id);if(!r)return[];let i=1/0,s=-1/0,a=1/0,c=-1/0;for(let u of o.outline)u.x<i&&(i=u.x),u.x>s&&(s=u.x),u.y<a&&(a=u.y),u.y>c&&(c=u.y);let f=r.landingY;for(let u of r.rowLevels)f=Math.min(f,u.y-Xr);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:f,minX:i,maxX:s,minY:a,maxY:c}]});return(o,r,i)=>{let s=null;for(let a of n){if(o<a.minX-i||o>a.maxX+i||r<a.minY-i||r>a.maxY+i)continue;let c={x:o,y:r};if(!me(c,a.outline,a.holes)&&Gc(c,a.outline)>i)continue;let f=Math.min(a.surface.deckAt(o,r),a.floorTop);(s===null||f<s)&&(s=f)}return s}}var Hc=3,Xc=.4;function Ur(e,t,n,o,r,i,s=!0){let a=Nc(t,n,o);if(a.length<Hc)return;let c=Tr(a,t.focal);if(!c)return;let f=Math.max(0,...c.rings.map(u=>u.arcs.reduce((l,h)=>l+h.binCount,0)))/c.binCount;e.setMaterial(5),Nr(e,c,{bottomY:t.baseHeightM,tierFrontLevels:a.map(u=>Math.min(...u.rows.map(l=>l.levelM))),colors:{bandTop:z(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??z(r.tierWall,1.15),shellWall:i??r.tierWall},ao:K,shapes:t.objects.filter(u=>u.type==="shape"),deriveShell:s&&f>=Xc,standTopNear:jc(t,o)}),e.setMaterial(0)}function yt(e){if(e.length<3)return e.map(i=>({...i}));let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r.map(i=>({...i})):t.map(i=>({...i}))}var Uc=.8,Vc=.6,Yc=2;function Kt(e,t){if(!t.length)return null;let n=[],o=0;for(let s of e.objects){if(s.type!=="shape"||s.role!=="wall")continue;let a=se(s)??[],c=Vr(a)/2;!(c>0)||Kc(a)/c*w>Yc||(n.push(...a),o+=c)}if(n.length<3)return null;let r=yt(n);if(r.length<3||o<Vr(r)*Vc)return null;let i=0;for(let s of t)Wc(s,r)&&(i+=1);return i>=t.length*Uc?r:null}function Kc(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2}function Vr(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=Math.hypot(r.x-o.x,r.y-o.y)}return t}function Wc(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}var Yr=4;var zc=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"],[/\b(walls?|outline|boundary|perimeter)\b/i,"wall"]],Zc=1.2,$c=12;function Kr(e){if(e.heightM!==void 0)return!1;let t=se(e);if(!t||t.length<3)return!1;let n=0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length];n+=Math.hypot(s.x-i.x,s.y-i.y)}return n*J<$c*2?!1:2*Wt(t)/n*J<=Zc}function vn(e){if(!e)return null;for(let[t,n]of zc)if(t.test(e))return n;return null}var Zr="auto-rows-";function $r(e){return e.id.startsWith(Zr)&&!e.label}var Qc=1.15,qc=.09,Qr=6,Jc=34,el=.35,tl=6,nl=.35,ol=.75,rl=12,il=2.5,sl=40,al=[18,24],cl=[12,16],Wr=14,ll=.8,ul=.6,fl=5,ml=.3,qr=.4,hl=2,dl=400,pl=2.6,bl=1.6,yl=6e3,xl=.6,gl="#c3c7cd",zr=300,Ml=240;function Sl(e,t,n,o){if(!e.fill||!/^#[0-9a-f]{6}$/i.test(e.fill))return null;let r=An([...t]),i=new Set;for(let u of o)i.add(Math.floor(Math.atan2(u.y-r.y,u.x-r.x)*180/Math.PI/10));if(i.size*10<Ml)return null;let{h:s,s:a,l:c}=yo(bo(e.fill));return s<70/360||s>170/360||a<.2||c<.08||c>.75||n.some(u=>u!==e&&u.type==="shape"&&se(u)?.some(l=>_n(l,t)))?null:e.kind==="ellipse"?"oval-cricket":e.kind==="rect"?"pitch-football":null}var Il="Estimated from the drawing; confirm with the venue.",Jr=e=>{if(!e.length)return null;let t=[...e].sort((o,r)=>o-r),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2},An=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length}),Wt=e=>{let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2};function Pl(e){return e.height!==void 0||e.rake!==void 0||e.elevation!==void 0||e.surfaceKind!==void 0}function Cn(e){let t=new Map;for(let n of e){let o=t.get(n.rowId);o?o.push(n):t.set(n.rowId,[n])}return t}function _n(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function kn(e,t){let n=t[0],o=1/0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length],a=s.x-i.x,c=s.y-i.y,f=a*a+c*c,u=f>0?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*c)/f)):0,l={x:i.x+a*u,y:i.y+c*u},h=Math.hypot(e.x-l.x,e.y-l.y);h<o&&(o=h,n=l)}return n}function ei(e,t){let n=0,o=0;for(let r of e.values()){if(r.length<3)continue;let i=r[0],s=r[r.length-1],a=s.x-i.x,c=s.y-i.y,f=Math.hypot(a,c);if(f<1e-6)continue;let u={x:(i.x+s.x)/2,y:(i.y+s.y)/2},l=kn(u,t),h=l.x-u.x,m=l.y-u.y,d=Math.hypot(h,m);d<1e-6||(o+=Math.abs((-c*h+a*m)/(f*d))*r.length,n+=r.length)}return n?o/n:0}function Rl(e,t,n){let o=e.filter(p=>p.type==="shape"),r=o.find(p=>p.role==="stage");if(r){let p=se(r);return p?{shape:r,centre:An(p),outline:p,inferred:!1}:null}if(!n.length)return null;let i=1/0,s=-1/0,a=1/0,c=-1/0;for(let p of n)i=Math.min(i,p.x),s=Math.max(s,p.x),a=Math.min(a,p.y),c=Math.max(c,p.y);let f=(s-i)*(c-a),u=[];for(let p of o){if(p.role)continue;let b=se(p);if(!b)continue;let x=Wt(b);if(x*J*J<6||x>f)continue;let y=Math.min(...b.map(P=>P.x)),M=Math.max(...b.map(P=>P.x)),g=Math.min(...b.map(P=>P.y)),v=Math.max(...b.map(P=>P.y)),S=0;for(let P of n)P.x>y&&P.x<M&&P.y>g&&P.y<v&&_n(P,b)&&S++;if(S>n.length*.05)continue;let R=An(b),I=ei(t,b);I>=ll&&u.push({shape:p,centre:R,outline:b,score:I,area:x,box:[y,g,M,v]})}let l=(p,b)=>b!==p&&b.area>p.area&&p.box[0]>=b.box[0]-1e-6&&p.box[1]>=b.box[1]-1e-6&&p.box[2]<=b.box[2]+1e-6&&p.box[3]<=b.box[3]+1e-6,h=u.filter(p=>!u.some(b=>l(p,b))),m=Math.max(0,...h.map(p=>p.score)),d=h.filter(p=>p.score>=m-.03).sort((p,b)=>b.area-p.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function wl(e,t,n){if(!n||n.length<3)return Math.hypot(e.x-t.x,e.y-t.y);let o=kn(e,n);return Math.hypot(e.x-o.x,e.y-o.y)}function ti(e){let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y);if(t.length<3)return t;let n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=[];for(let i of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}let r=[];for(let i=t.length-1;i>=0;i--){let s=t[i];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return[...o.slice(0,-1),...r.slice(0,-1)]}function vl(e){if(!e.length||e.length>yl)return[];let t=[...Cn(e).values()],n=t.map((a,c)=>c),o=a=>n[a]===a?a:n[a]=o(n[a]),r=bl/J,i=t.map(a=>({minX:Math.min(...a.map(c=>c.x))-r,maxX:Math.max(...a.map(c=>c.x))+r,minY:Math.min(...a.map(c=>c.y))-r,maxY:Math.max(...a.map(c=>c.y))+r}));for(let a=0;a<t.length;a++)for(let c=a+1;c<t.length;c++){let f=i[a],u=i[c];if(f.maxX<u.minX||u.maxX<f.minX||f.maxY<u.minY||u.maxY<f.minY)continue;t[a].some(h=>t[c].some(m=>Math.hypot(h.x-m.x,h.y-m.y)<=r))&&(n[o(a)]=o(c))}let s=new Map;return t.forEach((a,c)=>{let f=o(c),u=s.get(f);u?u.push(...a):s.set(f,[...a])}),[...s.values()].filter(a=>new Set(a.map(c=>c.rowId)).size>=2)}function El(e,t,n){if(!t.length)return null;let o=t.filter(I=>n.tableIds.has(I.rowId)||I.kind==="booth").length>t.length/2,r=Cn(t),i=!n.outline||ei(r,n.outline)>=ul,s=0,a=0;for(let I of r.values()){if(I.length<2)continue;let P=I[0],A=I[I.length-1],_=A.x-P.x,T=A.y-P.y,k=Math.hypot(_,T);if(k<1e-6)continue;let E={x:(P.x+A.x)/2,y:(P.y+A.y)/2},C=i?n.outline?kn(E,n.outline):n.focal:n.middle,O=-T/k,F=_/k;O*(C.x-E.x)+F*(C.y-E.y)<0&&(O=-O,F=-F),s+=O*I.length,a+=F*I.length}let c={x:t.reduce((I,P)=>I+P.x,0)/t.length,y:t.reduce((I,P)=>I+P.y,0)/t.length};if(Math.hypot(s,a)<1e-9){let I=i?n.focal:n.middle;s=I.x-c.x,a=I.y-c.y}let f=Math.hypot(s,a)||1,u={x:s/f,y:a/f},l=I=>-(I.x*u.x+I.y*u.y),h=I=>-I.x*u.y+I.y*u.x,m=1/0,d=-1/0,p=1/0,b=-1/0,x=1/0,y=new Map;for(let I of t){let P=l(I),A=h(I);m=Math.min(m,P),d=Math.max(d,P),p=Math.min(p,A),b=Math.max(b,A),i&&(x=Math.min(x,wl(I,n.focal,n.outline)));let _=I.logicalRowId??I.rowId,T=y.get(_);T?T.push(P):y.set(_,[P])}i||(x=Math.max(0,m-l(n.middle)));let M=[...y.values()].map(I=>Jr(I)).sort((I,P)=>I-P),g=[];if(!o)for(let I of M)g.length&&I-g[g.length-1]<nl/J||g.push(I);let v=Pl(e),S=De(e,{floorBaseHeightM:n.baseHeightM}),R={id:e.id,section:e,authored:v,plane:n,facing:u,facesAction:i,hull:ti(t),sample:t.filter((I,P)=>P%Math.ceil(t.length/dl)===0),frontD:m,backD:d,latMin:p,latMax:b,frontDistance:x,rowDepths:g,rowCount:g.length,level:0,height:S.height,rake:v?S.rake:0,backHeight:0};return R.backHeight=R.height+(d-m)*J*Math.tan(R.rake*Math.PI/180),R}function Al(e,t,n,o){if(e.length<2)return 0;let r=Math.max(1,t*J),i=n+Qc-o,s=0,a=0;for(let f=1;f<e.length;f++){let u=Math.max(ol,(e[f]-e[f-1])*J),l=(i+qc)*(r+u)/r;s+=l-i,a+=u,i=l,r+=u}let c=Math.atan(s/a)*180/Math.PI;return Math.round(Math.max(Qr,Math.min(Jc,c))*10)/10}function Cl(e,t){if(e.facing.x*t.facing.x+e.facing.y*t.facing.y<ml)return null;let n=-1/0,o=1/0,r=-1/0;for(let l of t.hull){n=Math.max(n,-(l.x*e.facing.x+l.y*e.facing.y));let h=-l.x*e.facing.y+l.y*e.facing.x;o=Math.min(o,h),r=Math.max(r,h)}if(Math.min(e.latMax,r)-Math.max(e.latMin,o)<qr*(e.latMax-e.latMin))return null;let s=hl/J,a=new Map,c=new Map;for(let l of e.sample){let h=Math.floor((-l.x*e.facing.y+l.y*e.facing.x)/s),m=-(l.x*e.facing.x+l.y*e.facing.y);a.set(h,Math.min(a.get(h)??1/0,m))}for(let l of t.sample){let h=Math.floor((-l.x*e.facing.y+l.y*e.facing.x)/s),m=-(l.x*e.facing.x+l.y*e.facing.y);c.set(h,Math.max(c.get(h)??-1/0,m))}let f=[];for(let[l,h]of a){let m=c.get(l);m!==void 0&&f.push(h-m)}let u=f.length?Jr(f):e.frontD-n;return u<-1/J?null:u}function _l(e,t){if(t.plane.floorIndex>=e.plane.floorIndex)return!1;let n=-1/0,o=1/0,r=1/0,i=-1/0;for(let c of t.hull){let f=-(c.x*e.facing.x+c.y*e.facing.y);n=Math.max(n,f),o=Math.min(o,f);let u=-c.x*e.facing.y+c.y*e.facing.x;r=Math.min(r,u),i=Math.max(i,u)}let s=Math.min(e.latMax,i)-Math.max(e.latMin,r),a=Math.min(e.backD,n)-Math.max(e.frontD,o);return s>qr*(e.latMax-e.latMin)&&a>1/J}function kl(e,t=!1){let n=t?cl:al,o=new Map,r=[...e].sort((c,f)=>c.plane.floorIndex-f.plane.floorIndex||c.frontDistance-f.frontDistance),i=[],s=new Map,a=c=>{if(c.plane.floorIndex===0||c.plane.baseHeightM>0)return c.plane.baseHeightM;let f=s.get(c.plane.floorIndex-1);return f===void 0?c.plane.baseHeightM:f+Yr};for(let c of r){if(!c.authored){let u=a(c),l;for(let d of i){if(d.plane.floorIndex>c.plane.floorIndex)continue;if(_l(c,d)){let x=d.backHeight+pl;x>u&&(u=x,l=d);continue}let p=Cl(c,d);if(p==null)continue;let b=d.backHeight+el+Math.min(tl,Math.max(0,p)*J)*Math.tan(d.rake*Math.PI/180);b>u&&(u=b,l=d)}c.height=Math.round(Math.min(u,c.plane.baseHeightM+sl)*100)/100;let h=!l&&c.height>c.plane.baseHeightM;if(c.level=l?l.level+1:h?1:0,c.rake=Al(c.rowDepths,c.frontDistance,c.height,c.plane.focalHeightM),!c.facesAction&&c.rowCount<fl)c.rake=0;else if(!l&&!h){let d=Math.max(1e-6,(c.backD-c.frontD)*J);c.rake=Math.min(c.rake,rl,Math.round(Math.atan(il/d)*1800/Math.PI)/10)}else c.rowCount>=2&&(c.rake=Math.max(c.rake,n[Math.min(c.level,n.length)-1]));let m=(c.backD-c.frontD)*J;if(t&&m>0&&c.height+m*Math.tan(c.rake*Math.PI/180)>c.plane.baseHeightM+Wr){let d=Math.max(0,c.plane.baseHeightM+Wr-c.height);c.rake=Math.max(Qr,Math.round(Math.atan(d/m)*1800/Math.PI)/10)}c.backHeight=c.height+m*Math.tan(c.rake*Math.PI/180),o.set(c.id,l?.id)}let f=c.plane.floorIndex;s.set(f,Math.min(s.get(f)??1/0,c.height)),i.push(c)}return o}var En=(e,t)=>!!e&&e.x===t.x&&e.y===t.y;function ni(e,t={x:0,y:-40}){let n=$e(e),o=new Map;for(let b of n){if(!b.sectionId)continue;let x=o.get(b.sectionId);x?x.push(b):o.set(b.sectionId,[b])}let r={focalInferred:!1,confident:!1,sections:[]},i=e.floors?.length?e.floors.map((b,x)=>({objects:b.objects,floorIndex:x,floorId:b.id,baseHeightM:b.baseHeightM??0,focal:b.focalPoint??e.focalPoint})):[{objects:e.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:e.focalPoint}],s=new Set(i.flatMap(b=>b.objects.filter(x=>x.type==="table").map(x=>x.id))),a=[],c,f=new Set,u=i.map(b=>{let x=T=>!e.floors?.length||T.floorId===b.floorId,y=vl(n.filter(T=>!T.sectionId&&T.kind!=="booth"&&!s.has(T.rowId)&&x(T))),M=[];for(let T of y){let k=Ie(Ae(ti(T)),xl/J);if(n.some(C=>!x(C)&&_n(C,k)))continue;let E=`${Zr}${b.floorIndex}-${M.length}`;f.add(E),o.set(E,T),M.push({type:"section",id:E,label:"",color:gl,outline:k})}let g=M.length?{...b,objects:[...b.objects,...M]}:b,v=new Set(g.objects.filter(T=>T.type==="section").map(T=>T.logicalSectionId??T.id)),S=[...o.entries()].filter(([T])=>v.has(T)).flatMap(([,T])=>T),R=Rl(g.objects,Cn(S),S),I=g.focal;(R||g.focal&&!En(g.focal,t))&&(r.confident=!0),R&&(r.stage??={id:R.shape.id,inferred:R.inferred,...g.floorId?{floorId:g.floorId}:{}},(R.inferred||En(g.focal,t))&&(I=R.centre,r.focalInferred=!0));let P=R&&(!R.inferred||Wt(R.outline)*J*J<=zr),A=R?void 0:c,_={tableIds:s,floorIndex:g.floorIndex,floorId:g.floorId,baseHeightM:g.baseHeightM,focal:A?.focal??I,outline:R?.outline??A?.outline,focalHeightM:A?.focalHeightM??g.baseHeightM+(R&&P?Pe({...R.shape,role:"stage"}).heightM:0),middle:S.length?{x:S.reduce((T,k)=>T+k.x,0)/S.length,y:S.reduce((T,k)=>T+k.y,0)/S.length}:I};for(let T of g.objects){if(T.type!=="section")continue;let k=El(T,o.get(T.logicalSectionId??T.id)??[],_);k&&a.push(k)}return _.outline&&(c=_),En(g.focal,_.focal)||(r.focal??=[]).push({...g.floorId?{floorId:g.floorId}:{},point:{..._.focal}}),{unit:g,plane:_,stage:R,planeSeats:S}}),l=i.flatMap(b=>b.objects).map(b=>b.type==="shape"&&!b.role&&(vn(b.label)==="wall"||!vn(b.label)&&Kr(b))?{...b,role:"wall"}:b),h=Kt({objects:l},n)!==null;h&&(r.indoor=!0);let m=kl(a,h),d=new Map(a.filter(b=>!b.authored).map(b=>[b.id,b])),p=u.map(({unit:b,plane:x,stage:y,planeSeats:M})=>b.objects.map(g=>{let v=g.type==="shape"&&!g.role&&g.id!==y?.shape.id?vn(g.label):null;if(g.type==="shape"&&!g.role&&g.id!==y?.shape.id&&(v==="wall"||!v&&Kr(g))&&g.type==="shape"){(r.roles??=[]).push({id:g.id,...x.floorId?{floorId:x.floorId}:{},role:"wall"});let{fill:_,...T}=g;return{...T,role:"wall"}}if(v&&g.type==="shape")return(r.roles??=[]).push({id:g.id,...x.floorId?{floorId:x.floorId}:{},role:v}),{...g,role:v};let R=y?.inferred&&g.id===y.shape.id&&g.type==="shape"?Sl(g,y.outline,b.objects,M):null;if(R&&g.type==="shape")return r.stage?.id===g.id&&(r.stage.field=R),{...g,role:"stage",stageKind:R};if(y?.inferred&&g.id===y.shape.id&&g.type==="shape"&&Wt(y.outline)*J*J<=zr)return r.stage?.id===g.id&&(r.stage.deck=!0),{...g,role:"stage"};let I=g.type==="section"?d.get(g.id):void 0;if(!I||g.type!=="section")return g;let P=I.rowCount>=2&&I.rake>0;f.has(I.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:I.id,floorId:x.floorId,surfaceKind:P?"rakedRows":"flat",height:I.height,rake:I.rake,stackedOn:m.get(I.id)});let A={status:"inferred",source:"public-2d-topology",note:Il};return{...g,height:I.height,rake:I.rake,surfaceKind:P?"rakedRows":"flat",physical3dProvenance:{height:A,rake:A,surfaceKind:A}}}));if(e.floors?.length){let b=e.floors.map((x,y)=>({...x,objects:p[y],focalPoint:u[y].plane.focal}));return{doc:{...e,floors:b,objects:b[0].objects,focalPoint:b[0].focalPoint},report:r}}return{doc:{...e,objects:p[0],focalPoint:u[0].plane.focal},report:r}}var oi=/^[\p{L}\p{N}]{1,4}$/u,Tl=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function ri(e,t){let n=t?.trim();if(!n)return e;let o=e.toLocaleLowerCase("en-US"),r=n.toLocaleLowerCase("en-US");if(o.startsWith(`${r} `)){let s=e.slice(n.length).trim();if(oi.test(s))return s}let i=Tl.exec(e);if(i){let s=i[1].toLocaleLowerCase("en-US"),a=i[2].trim();if((r.startsWith(s)||s.startsWith(r))&&oi.test(a))return a}return e}var Ll=6,Ol=2.2,ii=.1,Bl=.3,Fl=1.8,Dl=.9,Nl=.55,Gl=6e3;function ai(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let c=new Map;for(let u of n)for(let l of u.objects)l.type==="section"&&l.zone&&c.set(l.id,l.zone);let f=new Map;for(let u=0;u<o.length;u++){let l=o[u],h=r.seatOwner[u],m=l.zoneId??(h?c.get(h):void 0);if(!m)continue;let d=f.get(m);d||(d={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},f.set(m,d)),d.n++,l.x<d.minX&&(d.minX=l.x),l.y<d.minY&&(d.minY=l.y),l.x>d.maxX&&(d.maxX=l.x),l.y>d.maxY&&(d.maxY=l.y),d.sumY+=r.seatDeckY(u)}for(let u of s){let l=f.get(u.id),h=[];for(let[m,d]of c)d===u.id&&h.push(m);if(!l||l.n===0){a.push({id:u.id,label:u.label,color:oe(u.color),sectionIds:h,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(u.focalPoint??i).x*w,1.5,(u.focalPoint??i).y*w]});continue}a.push({id:u.id,label:u.label,color:oe(u.color),sectionIds:h,seatCount:l.n,center:[(l.minX+l.maxX)/2*w,l.sumY/l.n,(l.minY+l.maxY)/2*w],radius:.5*Math.hypot((l.maxX-l.minX)*w,(l.maxY-l.minY)*w)||1,focalWorld:[(u.focalPoint??i).x*w,1.5,(u.focalPoint??i).y*w]})}}return a}function ci(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:c}=e,f=[],u=[],l=[],h=new Map;for(let m of n)for(let d of m.objects){if(d.type!=="section"||!d.zone)continue;let p=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!p)continue;let b=t.floors?.[m.index]?.name?.trim().toLocaleLowerCase();if(n.length>1&&b===p)continue;let x=h.get(d.zone);x||h.set(d.zone,x=new Set),x.add(p)}for(let m of a)m.seatCount!==0&&(h.get(m.id)?.has(m.label.trim().toLocaleLowerCase())||f.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+Ll,m.center[2]],color:t.zones?.find(d=>d.id===m.id)?.color}));{let m=new Map,d=new Map;for(let p=0;p<o.length;p++){let b=r.seatOwner[p];if(!b)continue;let x=m.get(b);x||(x={n:0,x:0,y:0,deck:0},m.set(b,x)),x.n++,x.x+=o[p].x,x.y+=o[p].y,x.deck+=r.seatDeckY(p);let y=d.get(b);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},d.set(b,y)),y.minDeck=Math.min(y.minDeck,r.seatDeckY(p)),y.maxDeck=Math.max(y.maxDeck,r.seatDeckY(p)),o[p].x<y.minX&&(y.minX=o[p].x),o[p].x>y.maxX&&(y.maxX=o[p].x),o[p].y<y.minY&&(y.minY=o[p].y),o[p].y>y.maxY&&(y.maxY=o[p].y)}for(let p of n)for(let b of p.objects){if(b.type!=="section"||$r(b))continue;let x=m.get(b.id);if(!x||x.n===0)continue;let y=d.get(b.id),M=[x.x/x.n*w,x.deck/x.n,x.y/x.n*w],g=b.displayLabel||b.label||b.id;u.push({id:b.id,floorIndex:p.index,label:g,seatCount:x.n,center:M,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*w),box:{min:[y.minX*w-.4,y.minDeck,y.minY*w-.4],max:[y.maxX*w+.4,y.maxDeck+1,y.maxY*w+.4]},focalWorld:[p.focal.x*w,p.baseHeightM+1.5,p.focal.y*w]});let v=t.floors?.[p.index]?.name?.trim().toLocaleLowerCase();n.length>1&&v===g.trim().toLocaleLowerCase()||f.push({id:`section:${b.id}`,kind:"section",text:g,anchor:[M[0],M[1]+Ol,M[2]],floorIndex:p.index})}}{for(let x of n)for(let y of x.objects){if(y.type!=="gaArea")continue;let M=it(y.points);if(!M)continue;let g=y.displayLabel||y.label||y.id;f.push({id:`ga:${y.id}`,kind:"ga",text:y.capacity>0?`${g} \xB7 ${y.capacity.toLocaleString()}`:g,anchor:[M.x*w,x.baseHeightM+Fl,M.y*w],floorIndex:x.index})}let m=new Map,d=new Map;for(let x of n)for(let y of x.objects)if(y.type==="section"&&m.set(y.id,y.displayLabel||y.label||y.id),y.type==="row"){let M=y.displayLabel?.trim()||y.segmentedRow?.displayLabel?.trim();M&&d.set(y.id,M)}let p=new Map;for(let x=0;x<o.length;x++){let y=o[x],M=Math.hypot(y.x-c.x,y.y-c.y),g=p.get(y.rowId);(!g||M>g.far)&&p.set(y.rowId,{seat:y,index:x,far:M})}for(let[x,y]of p){let M=r.seatOwner[y.index]??y.seat.sectionId,g=si(y.seat.label,x,m.get(M??""),d.get(x));g&&f.push({id:`row:${x}`,kind:"row",text:g,anchor:[y.seat.x*w,r.seatDeckY(y.index)+Dl,y.seat.y*w],floorIndex:s[y.index]})}let b=new Map;for(let x=0;x<o.length;x++){let y=o[x],M=b.get(y.rowId);M||(M={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:si(y.label,y.rowId,m.get(r.seatOwner[x]??y.sectionId??""),d.get(y.rowId)),sectionId:r.seatOwner[x]??y.sectionId},b.set(y.rowId,M));let g=x*3,v=i.iPosition[g],S=i.iPosition[g+1],R=i.iPosition[g+2];M.n++,M.x+=v,M.y+=S,M.z+=R,M.minX=Math.min(M.minX,v),M.maxX=Math.max(M.maxX,v),M.minZ=Math.min(M.minZ,R),M.maxZ=Math.max(M.maxZ,R)}for(let[x,y]of b)l.push({id:x,label:y.label,sectionId:y.sectionId,seatCount:y.n,center:[y.x/y.n,y.y/y.n,y.z/y.n],radius:Math.max(.8,Math.hypot(y.maxX-y.minX,y.maxZ-y.minZ)*.5)});if(o.length<=Gl)for(let x=0;x<o.length;x++){let y=o[x],M=jl(y.displayLabel||y.label);M&&f.push({id:`seat:${y.id}`,kind:"seat",seatWidthM:i.iChairWidth[x]*2,text:M,anchor:[y.x*w,r.seatDeckY(x)+Nl,y.y*w],floorIndex:s[x],rowId:y.rowId})}}for(let m of n)for(let d of m.objects)if(d.type==="shape"&&d.role&&["entrance","exit","screen","suite","obstruction"].includes(d.role)){let p=se(d),b=p?it(p):null;if(!b||!d.label)continue;f.push({id:`architecture:${d.id}`,kind:"annotation",text:d.label,anchor:[b.x*w,m.baseHeightM+Pe(d).heightM+ii,b.y*w],color:d.fill,floorIndex:m.index})}else if(d.type==="text"){if(!d.text)continue;f.push({id:`text:${d.id}`,kind:"annotation",text:d.text,anchor:[d.position.x*w,m.baseHeightM+ii,d.position.y*w],color:d.color,rotation:d.rotation,floorIndex:m.index})}else if(d.type==="booth"){let p=_e(d);if(!p)continue;let b=it(p);if(!b)continue;f.push({id:`booth:${d.id}`,kind:"booth",text:d.displayLabel||d.label||d.id,anchor:[b.x*w,m.baseHeightM+Ht+Bl,b.y*w],floorIndex:m.index})}return{labels:f,sections:u,rows:l}}function li(e,t){if(t.length>1)for(let n of t)e.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function jl(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function si(e,t,n,o){if(o?.trim())return o.trim();let r=e?e.lastIndexOf("-"):-1,i=r>0?e.slice(0,r):t;return i&&ri(i,n)}function ui(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,c=[];{let f=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let h=0;h<i.floor.length;h+=1){let m=Math.max(0,Math.min(n.length-1,Math.round(i.floor[h]))),d=h*3,p=f[m];p.minX=Math.min(p.minX,i.position[d]),p.minY=Math.min(p.minY,i.position[d+1]),p.minZ=Math.min(p.minZ,i.position[d+2]),p.maxX=Math.max(p.maxX,i.position[d]),p.maxY=Math.max(p.maxY,i.position[d+1]),p.maxZ=Math.max(p.maxZ,i.position[d+2])}let u=new Map;for(let h=0;h<n.length;h++)for(let m of n[h].objects)m.type==="section"&&u.set(m.id,h);let l=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let h=0;h<o.length;h++){let m=r.seatOwner[h],d=(m!==null?u.get(m):void 0)??s[h];if(d===void 0)continue;let p=l[d],b=o[h];p.n++,b.x<p.minX&&(p.minX=b.x),b.y<p.minY&&(p.minY=b.y),b.x>p.maxX&&(p.maxX=b.x),b.y>p.maxY&&(p.maxY=b.y);let x=r.seatDeckY(h);p.sumX+=b.x*w,p.sumDeck+=x,p.sumZ+=b.y*w,p.minDeck=Math.min(p.minDeck,x),p.maxDeck=Math.max(p.maxDeck,x+1.6),a[h]=d}for(let h=0;h<n.length;h++){let m=l[h],d=t.floors?.[h],p=f[h],b=Math.min(m.n?m.minX*w:n[h].focal.x*w-1,Number.isFinite(p.minX)?p.minX:1/0),x=Math.max(m.n?m.maxX*w:n[h].focal.x*w+1,Number.isFinite(p.maxX)?p.maxX:-1/0),y=Math.min(m.n?m.minY*w:n[h].focal.y*w-1,Number.isFinite(p.minZ)?p.minZ:1/0),M=Math.max(m.n?m.maxY*w:n[h].focal.y*w+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),g=Math.min(m.n?Math.min(n[h].baseHeightM,m.minDeck):n[h].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),v=Math.max(m.n?Math.max(m.maxDeck,g+.5):g+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),S=[m.n?m.sumX/m.n:(b+x)/2,m.n?m.sumDeck/m.n:(g+v)/2,m.n?m.sumZ/m.n:(y+M)/2],R=Math.max(1,.5*Math.hypot(x-b,v-g,M-y));c.push({index:h,id:d?.id??`floor-${h}`,label:d?.name??(n.length>1?`Floor ${h+1}`:"Venue"),seatCount:m.n,center:S,radius:R,box:{min:[b,g,y],max:[x,v,M]},focalWorld:[n[h].focal.x*w,n[h].baseHeightM+1.5,n[h].focal.y*w]})}}return c}function Tn(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,c)=>{a<n&&(n=a),c<o&&(o=c),a>r&&(r=a),c>i&&(i=c)};for(let a of t)s(a.x,a.y);for(let a of e)for(let c of a.objects)if(c.type==="section")for(let f of c.outline)s(f.x,f.y);else if(c.type==="shape"&&c.points)for(let f of c.points)s(f.x,f.y);else if(c.type==="gaArea")for(let f of c.points)s(f.x,f.y);else if(c.type==="booth"){let f=_e(c);if(f)for(let u of f)s(u.x,u.y)}else if(c.type==="table"){let f=Xt(c);if(f)for(let u of f)s(u.x,u.y)}else if(c.type==="decorImage"){let f=Ut(c);if(f)for(let u of f)s(u.x,u.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function bi(e,t,n,o,r,i,s){if(t.length===1){let a=n.map(h=>({x:h.x,y:h.y}));for(let h of t[0].objects)h.type==="section"?a.push(...h.outline):h.type==="shape"?a.push(...se(h)??h.points??[]):h.type==="gaArea"?a.push(...h.points):h.type==="booth"?a.push(..._e(h)??[]):h.type==="table"?a.push(...Xt(h)??[]):h.type==="decorImage"&&a.push(...Ut(h)??[]);if(hi(e,t[0],n,i)||pi(e,t[0],n,a,i))return!1;if(s&&mi(e,t[0].baseHeightM,a,i,s))return!0;let c=yt(a),f=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2,l=c.length>=3?c.map(h=>{let m=h.x-f,d=h.y-u,p=Math.max(1,Math.hypot(m,d));return{x:h.x+m/p*80,y:h.y+d/p*80}}):ft(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return W(e,l,void 0,()=>-.04,-.22,i.ground,i.ground,K),!1}else{let a=t.reduce((b,x)=>x.baseHeightM<b.baseHeightM?x:b);e.setFloor(a.index);let c={...a,objects:t.flatMap(b=>b.objects)},f=n.map(b=>({x:b.x,y:b.y}));for(let b of c.objects)b.type==="section"&&f.push(...b.outline);if(hi(e,c,n,i)||pi(e,c,n,f,i))return!1;if(s&&mi(e,a.baseHeightM,f,i,s))return!0;let u=n.filter((b,x)=>o[x]===a.index),l=Tn([a],u),h=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),m=Math.max(28,Math.min(80,h*.04)),d=ft(l.minX-m,l.minY-m,l.maxX-l.minX+m*2,l.maxY-l.minY+m*2),p=a.baseHeightM-.03;return W(e,d,void 0,()=>p,p-.22,i.ground,i.ground,K),!1}}function Ln(e,t,n,o){let{cx:r,cz:i,radius:s}=n,a=1/0,c=1/0,f=1/0,u=-1/0,l=-1/0,h=-1/0,m=(b,x,y)=>{a=Math.min(a,b),u=Math.max(u,b),c=Math.min(c,x),l=Math.max(l,x),f=Math.min(f,y),h=Math.max(h,y)};for(let b=0;b<e.position.length;b+=3){let x=b/3;o&&x>=o[0]&&x<o[1]||m(e.position[b],e.position[b+1],e.position[b+2])}for(let b=0;b<t.count;b++){let x=b*3,y=t.iPosition[x],M=t.iPosition[x+1],g=t.iPosition[x+2],v=Math.max(.35,t.iMaxRadius[b]??.35);m(y-v,M,g-v),m(y+v,M+1.6,g+v)}Number.isFinite(a)||(a=r-s,u=r+s,c=0,l=s*.16,f=i-s,h=i+s);let d=[(a+u)/2,(c+l)/2,(f+h)/2],p=Math.max(1,.5*Math.hypot(u-a,l-c,h-f));return{center:d,radius:p,minY:c,maxY:l}}function yi(e,t,n,o,r,i){let s=1/0,a=1/0,c=-1/0,f=-1/0;for(let g=0;g<e.count;g++){let v=g*3,S=e.iPosition[v],R=e.iPosition[v+2];S<s&&(s=S),S>c&&(c=S),R<a&&(a=R),R>f&&(f=R)}for(let g of t)s=Math.min(s,g.cx-g.halfX),c=Math.max(c,g.cx+g.halfX),a=Math.min(a,g.cz-g.halfZ),f=Math.max(f,g.cz+g.halfZ);let u=n.minX*w,l=n.maxX*w,h=n.minY*w,m=n.maxY*w,d=u,p=l,b=h,x=m;if(Number.isFinite(s)){let g=Math.max(2,.06*Math.hypot(c-s,f-a));d=Math.max(u,s-g),p=Math.min(l,c+g),b=Math.max(h,a-g),x=Math.min(m,f+g)}let y=Math.min(0,o),M=Math.max(r,i*.05);return{min:[d,y,b],max:[p,M,x]}}var fi=12,Hl=.6,Xl=40;function mi(e,t,n,o,r){let i=yt([...n]);if(i.length<3)return!1;let s=1/0,a=1/0,c=-1/0,f=-1/0;for(let g of i)s=Math.min(s,g.x),c=Math.max(c,g.x),a=Math.min(a,g.y),f=Math.max(f,g.y);let u=Math.hypot(c-s,f-a)*w,l=Ie(i,fi/w,1.2),h=Math.max(Xl,u*Hl),m=Ie(i,(fi+h)/w,1.2);if(l.length!==m.length)return!1;let d=re(o.ground,[.78,.76,.72],.35),p=re(o.ground,[.56,.62,.52],.3);W(e,l,void 0,()=>t-.04,t-.22,d,d,K);let b=t-.05,x=l.map(g=>[g.x*w,b,g.y*w]),y=m.map(g=>[g.x*w,b,g.y*w]),M=[0,1,0];for(let g=0;g<x.length;g++){let v=(g+1)%x.length;e.tri(x[g],y[v],y[g],M,p,r,r),e.tri(x[g],x[v],y[v],M,p,p,r)}return!0}function hi(e,t,n,o){let r=Kt(t,n);if(!r)return!1;let i=t.baseHeightM,s=re(o.ground,[.62,.55,.47],.4);return W(e,r,void 0,()=>i-.04,i-.22,s,s,K),!0}var Ul=3e3,Vl=20,di=1.5,Yl=1.2,Kl=.25;function pi(e,t,n,o,r){if(!n.length||n.length>Ul||o.length<3)return!1;for(let P of t.objects){if(P.type==="shape"&&zn(P.stageKind))return!1;if(P.type==="section"){let{height:A}=De(P,{floorBaseHeightM:t.baseHeightM});if(A-t.baseHeightM>Vl)return!1}}let i=0,s=0;for(let P of o)i+=P.x,s+=P.y;i/=o.length,s/=o.length;let a=0,c=0,f=0;for(let P of o){let A=P.x-i,_=P.y-s;a+=A*A,c+=_*_,f+=A*_}let u=.5*Math.atan2(2*f,a-c),l=Math.cos(u),h=Math.sin(u),m=-h,d=l,p=1/0,b=-1/0,x=1/0,y=-1/0;for(let P of o){let A=(P.x-i)*l+(P.y-s)*h,_=(P.x-i)*m+(P.y-s)*d;p=Math.min(p,A),b=Math.max(b,A),x=Math.min(x,_),y=Math.max(y,_)}let M=P=>[[p-P,x-P],[b+P,x-P],[b+P,y+P],[p-P,y+P]].map(([A,_])=>({x:i+l*A+m*_,y:s+h*A+d*_})),g=M(di/w),v=M((di+Kl)/w),S=t.baseHeightM,R=re(r.ground,[.62,.55,.47],.4),I=re(r.ground,[.86,.86,.84],.55);return W(e,v,void 0,()=>S-.04,S-.22,R,R,K),W(e,v,[g.slice().reverse()],()=>S+Yl,S-.04,re(I,[1,1,1],.2),I,K),!0}function xi(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=qn(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let l of n)for(let h of l.objects)h.type==="shape"&&i.set(h.id,{shape:h,unit:l});let s=new Set,a=new Set,c=new Map((t.overlay.productionElements??[]).map(l=>{let h=l.runtimeContentImageUrl;return[l.id,typeof h=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(h)?h:void 0]})),f=[];for(let l of r.value.overlay.productionElements??[]){let h=i.get(l.objectId),m=h?se(h.shape):null,d=l.baseElevationM??0;if(!h||!m||m.length<3||!l.id||s.has(l.id)||a.has(l.objectId)||!Number.isFinite(l.heightM)||l.heightM<.05||l.heightM>50||!Number.isFinite(d)||d<-10||d>100)return o();s.add(l.id),a.add(l.objectId);let p=m.map(I=>I.x*w),b=m.map(I=>I.y*w),x=h.unit.baseHeightM+d,y=Math.min(...p),M=Math.max(...p),g=Math.min(...b),v=Math.max(...b),S,R=c.get(l.id)??l.contentImageUrl;if(l.kind==="screen"&&R&&(S=rr(m,x,x+l.heightM,h.unit.focal),!S))if(M-y>=v-g){let I=Math.abs(g-h.unit.focal.y*w)<=Math.abs(v-h.unit.focal.y*w)?g-.006:v+.006;S=[[y,x,I],[M,x,I],[y,x+l.heightM,I],[M,x+l.heightM,I]]}else{let I=Math.abs(y-h.unit.focal.x*w)<=Math.abs(M-h.unit.focal.x*w)?y-.006:M+.006;S=[[I,x,g],[I,x,v],[I,x+l.heightM,g],[I,x+l.heightM,v]]}f.push({id:l.id,objectId:l.objectId,kind:l.kind,floorIndex:h.unit.index,baseY:x,topY:x+l.heightM,bounds:{min:[y,x,g],max:[M,x+l.heightM,v]},occlusion:l.occlusion,...R?{contentImageUrl:R}:{},...S?{contentPlane:S}:{}})}let u=f.sort((l,h)=>l.id.localeCompare(h.id));return{byObjectId:new Map(u.map(l=>[l.objectId,l])),elements:u}}var gi=[.13,.14,.17],ot=[.4,.43,.47],Wl=.18,zl=.02,Zl=2.4,$l=1500,Ql=240;function Mi(e,t,n,o){let r=t.stageKind??"";if(Xe(r)||r==="round"||!o.length)return;let i=se(t);if(!i||i.length<3)return;let s={x:i.reduce((C,O)=>C+O.x,0)/i.length,y:i.reduce((C,O)=>C+O.y,0)/i.length},a=0,c=0,f=new Set;for(let C of o)a+=C.x,c+=C.y,f.add(Math.floor(Math.atan2(C.y-s.y,C.x-s.x)*180/Math.PI/10));if(f.size*10>Ql)return;let u=s.x-a/o.length,l=s.y-c/o.length,h=Math.hypot(u,l);if(h<1e-6)return;let m=u/h,d=l/h,p=-d,b=m,x=-1/0,y=1/0,M=1/0,g=-1/0;for(let C of i){let O=(C.x-s.x)*m+(C.y-s.y)*d,F=(C.x-s.x)*p+(C.y-s.y)*b;x=Math.max(x,O),y=Math.min(y,O),M=Math.min(M,F),g=Math.max(g,F)}let v=(g-M)*w,S=(x-y)*w;if(v<3||S<1.5||v*S>$l)return;let R=Wl/w,I=(C,O)=>({x:s.x+m*C+p*O,y:s.y+d*C+b*O}),P=(C,O,F,L)=>[I(C,F),I(C,L),I(O,L),I(O,F)],A=n+Math.max(3.5,Math.min(8,v*.35)),_=n+Math.min(Zl,A-n-1),T=.2/w,k=y+Math.min(S*.25,1.5)/w,E=zl/w;W(e,P(x-2*R+E,x-R-E,M+R+T,g-R-T),void 0,()=>_,n,gi,gi,K);for(let[C,O]of[[M+R,M+R+T],[g-R-T,g-R]])W(e,P(x-2*R,x-R,C,O),void 0,()=>A+.3,n,ot,ot,K),W(e,P(k+T,x-2*R,C,O),void 0,()=>A+.3,A,ot,ot,K);W(e,P(k,k+T,M+R,g-R),void 0,()=>A+.3,A,ot,ot,K)}function xe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ye(e){return Array.isArray(e)?e:[]}function ql(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!xe(n))continue;let o=xe(n.extensions)?n.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function zt(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function Jl(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function eu(e,t){let n=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let i=0;i<4;i++)n[o*4+r]+=e[i*4+r]*t[o*4+i];return n}function tu(e){let t=zt(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:zt(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:zt(e.rotation,4),r=e.scale===void 0?[1,1,1]:zt(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,c]=o,f=Math.hypot(i,s,a,c);if(!(f>1e-8))return null;let u=i/f,l=s/f,h=a/f,m=c/f,d=u+u,p=l+l,b=h+h,x=u*d,y=u*p,M=u*b,g=l*p,v=l*b,S=h*b,R=m*d,I=m*p,P=m*b;return[(1-(g+S))*r[0],(y+P)*r[0],(M-I)*r[0],0,(y-P)*r[1],(1-(x+S))*r[1],(v+R)*r[1],0,(M+I)*r[2],(v-R)*r[2],(1-(x+g))*r[2],0,n[0],n[1],n[2],1]}function nu(e,t,n,o){return[e[0]*t+e[4]*n+e[8]*o+e[12],e[1]*t+e[5]*n+e[9]*o+e[13],e[2]*t+e[6]*n+e[10]*o+e[14]]}function ou(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],c=e[6],f=e[10],u=i*f-s*c,l=s*a-r*f,h=r*c-i*a,m=t*u+n*l+o*h;if(Math.abs(m)<1e-12)return null;let d=1/m;return[u*d,l*d,h*d,(o*c-n*f)*d,(t*f-o*a)*d,(n*a-t*c)*d,(n*s-o*i)*d,(o*r-t*s)*d,(t*i-n*r)*d]}function Si(e,t,n,o){let r=e[0]*t+e[1]*n+e[2]*o,i=e[3]*t+e[4]*n+e[5]*o,s=e[6]*t+e[7]*n+e[8]*o,a=Math.hypot(r,i,s)||1;return r/=a,i/=a,s/=a,[r,i,s]}function ru(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,o=null,r=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),s=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let a=e.subarray(n,n+i);if(s===1313821514&&!o)try{let c=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!xe(c))return null;o=c}catch{return null}else if(s===5130562&&!r)r=a;else return null;n+=i}return n===e.byteLength&&o&&r?{json:o,bin:r}:null}function iu(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function su(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function au(e,t,n){return n===5120?e.getInt8(t):n===5121?e.getUint8(t):n===5122?e.getInt16(t,!0):n===5123?e.getUint16(t,!0):n===5125?e.getUint32(t,!0):e.getFloat32(t,!0)}function cu(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=ru(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!xe(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=ye(o.extensionsUsed).filter(g=>typeof g=="string");if(i.includes("KHR_draco_mesh_compression")||ql(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||ye(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(ye(o.images).length||ye(o.textures).length)return{ok:!1,issue:"external_resource"};let s=ye(o.buffers);if(s.length!==1||!xe(s[0])||s[0].uri!==void 0||typeof s[0].byteLength!="number"||!Number.isInteger(s[0].byteLength)||s[0].byteLength<0||s[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let a=ye(o.accessors),c=ye(o.bufferViews),f=ye(o.meshes),u=ye(o.nodes),l=ye(o.scenes),h=typeof o.scene=="number"?o.scene:0;if(!xe(l[h]))return{ok:!1,issue:"unsupported_glb"};let m=new DataView(r.buffer,r.byteOffset,r.byteLength),d=(g,v,S)=>{if(typeof g!="number"||!Number.isInteger(g)||!xe(a[g]))return null;let R=a[g];if(R.type!==v||R.sparse!==void 0||R.normalized===!0||typeof R.count!="number"||!Number.isInteger(R.count)||R.count<1||typeof R.componentType!="number"||!S.includes(R.componentType)||typeof R.bufferView!="number")return null;let I=c[R.bufferView];if(!xe(I)||I.buffer!==0||typeof I.byteLength!="number"||!Number.isInteger(I.byteLength)||I.byteLength<0)return null;let P=su(R.type),A=iu(R.componentType),_=typeof I.byteStride=="number"?I.byteStride:P*A,T=typeof I.byteOffset=="number"?I.byteOffset:0,k=typeof R.byteOffset=="number"?R.byteOffset:0,E=T+k,C=k+(R.count-1)*_+P*A;if(!Number.isInteger(_)||!Number.isInteger(T)||!Number.isInteger(k)||_<P*A||T<0||k<0||T+I.byteLength>r.byteLength||C>I.byteLength)return null;let O=[];for(let F=0;F<R.count;F++){let L=[];for(let B=0;B<P;B++){let N=au(m,E+F*_+B*A,R.componentType);if(!Number.isFinite(N))return null;L.push(N)}O.push(L)}return O},p=[],b=[],x=0,y=new Set,M=(g,v)=>{if(typeof g!="number"||!Number.isInteger(g)||!xe(u[g])||y.has(g))return!1;y.add(g);let S=u[g],R=tu(S);if(!R)return!1;let I=eu(v,R),P=ou(I);if(!P)return!1;if(S.mesh!==void 0){if(typeof S.mesh!="number")return!1;let A=f[S.mesh];if(!xe(A))return!1;for(let _ of ye(A.primitives)){if(!xe(_)||_.mode!==void 0&&_.mode!==4||!xe(_.attributes))return!1;let T=d(_.attributes.POSITION,"VEC3",[5126]),k=_.attributes.NORMAL===void 0?null:d(_.attributes.NORMAL,"VEC3",[5126]);if(!T||_.attributes.NORMAL!==void 0&&!k)return!1;let E=T.length;if(_.indices!==void 0){let O=typeof _.indices=="number"?a[_.indices]:null;E=xe(O)?O.count:void 0}if(typeof E!="number"||!Number.isInteger(E)||E%3!==0||(x+=E/3,x>1e5))return!1;let C=_.indices===void 0?T.map((O,F)=>[F]):d(_.indices,"SCALAR",[5121,5123,5125]);if(!C||C.length%3!==0||C.length!==E)return!1;for(let O=0;O<C.length;O+=3){let F=[C[O][0],C[O+1][0],C[O+2][0]];if(F.some(N=>!Number.isInteger(N)||N<0||N>=T.length))return!1;let L=F.map(N=>nu(I,...T[N])),B=null;if(!k){let N=L[1][0]-L[0][0],H=L[1][1]-L[0][1],D=L[1][2]-L[0][2],V=L[2][0]-L[0][0],U=L[2][1]-L[0][1],Z=L[2][2]-L[0][2];B=Si([1,0,0,0,1,0,0,0,1],H*Z-D*U,D*V-N*Z,N*U-H*V)}for(let N=0;N<3;N++)p.push(...L[N]),b.push(...k?Si(P,...k[F[N]]):B)}}}for(let A of ye(S.children))if(!M(A,I))return!1;return y.delete(g),!0};for(let g of ye(l[h].nodes))if(!M(g,Jl()))return{ok:!1,issue:x>1e5?"triangle_limit":"unsupported_glb"};return!x||p.length!==x*9||b.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:x,position:new Float32Array(p),normal:new Float32Array(b)}}function Ii(e){try{return cu(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function Pi(e){let{doc:t}=e,n=So(t.theme),o=n.structure,r=Wo(t,e.eventConfigurationId??t.eventConfigurationId),i=xi(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new Et,c=null;if(e.registeredShellGlb){let j=Ii(e.registeredShellGlb);if(j.ok){let G=j.position.length/3,Q=new Float32Array(j.position.length),te=n.materials.shell??o.tierWall;for(let ne=0;ne<G;ne++){let ce=j.normal[ne*3+1],ae=ce<-.25?.4:.62+.38*Math.max(0,ce);Q[ne*3]=te[0]*ae,Q[ne*3+1]=te[1]*ae,Q[ne*3+2]=te[2]*ae}c={position:j.position,normal:j.normal,color:Q,floor:new Float32Array(G).fill(-2),material:new Float32Array(G),count:G}}}let f=new Map;for(let j of r)for(let G of j.objects)f.set(G.id,j.index),G.type==="section"&&f.set(G.logicalSectionId??G.id,j.index);let u=s.map(j=>f.get(j.sectionId??"")??f.get(j.rowId??"")??0),l=Tn(r,s),h=a.vertexCount,d=bi(a,r,s,u,l,o,re(n.background.top,n.background.bottom,.5))?a.vertexCount:h,p=er(t,s),b=new Map,x=new Map;for(let j of t.categories??[])b.set(j.key,j.color),j.seatGlyph&&x.set(j.key,j.seatGlyph);let y=[],M=qo(r,s,u),g=new Map;s.forEach((j,G)=>{let Q=M.seatDeckY(G);Number.isFinite(Q)&&g.set(j.rowId,Math.min(g.get(j.rowId)??1/0,Q))});let v=new Float32Array(s.length),S=[],R=new Map((t.floors??[]).map((j,G)=>[j.id,G])),I=r.map(()=>[]);for(let j of s){let G=j.floorId?R.get(j.floorId)??0:0;I[Math.min(G,I.length-1)]?.push(j)}let P=(j,G)=>{if(!G||G.length<3)return!1;let Q=Math.min(...G.map(ae=>ae.x)),te=Math.max(...G.map(ae=>ae.x)),ne=Math.min(...G.map(ae=>ae.y)),ce=Math.max(...G.map(ae=>ae.y));for(let ae=0;ae<j;ae++)for(let Y of I[ae])if(!(Y.x<Q||Y.x>te||Y.y<ne||Y.y>ce)&&me(Y,G,void 0))return!0;return!1},A=null,_=j=>r.length===1?s:s.filter((G,Q)=>u[Q]===j),T=(j,G)=>{let Q=_e(j);if(!Q)return!1;let te=1/0,ne=1/0,ce=-1/0,ae=-1/0;for(let Y of Q)te=Math.min(te,Y.x),ce=Math.max(ce,Y.x),ne=Math.min(ne,Y.y),ae=Math.max(ae,Y.y);return s.some((Y,le)=>Y.kind!=="booth"&&(r.length===1||u[le]===G)&&Y.x>te&&Y.x<ce&&Y.y>ne&&Y.y<ae&&pe(Q,Y.x,Y.y))};for(let j=0;j<r.length;j++){let G=r[j];a.setFloor(j);let Q=new Lt,te=[],ne=G.objects.filter(Y=>Y.type==="shape"&&(Y.role==="entrance"||Y.role==="exit")),ce=G.objects.filter(Y=>Y.type==="section"&&!!Y.outline&&Y.outline.length>=3),ae=Ar(G.objects.filter(Y=>Y.type==="booth"),G.focal);for(let Y of G.objects)if(Y.type==="section"){let le=a.vertexCount;Hr(a,Y,G,tr(Y,p),M.bySection.get(Y.id),Q,ce,o,j>0&&P(j,Y.outline));let Re=a.vertexCount-le;Re>0&&S.push({sectionId:Y.id,start:le,count:Re})}else if(Y.type==="shape"){let le=i.byObjectId.get(Y.id),Re=y.length;a.setMaterial((le?.kind??Y.role)==="screen"?1:0);let we=Y.role==="stage"&&!le?_r(Y,_(j)):Y,ve=or(we,te);if(Rr(a,we,G.baseHeightM+ve.supportOffsetM,ve.topOffsetM-ve.supportOffsetM,o,G.focal,y,le,ne),a.setMaterial(0),Y.role==="stage"&&!le&&y.length>Re&&(A??j)===j){A=j;let Se=t.floors?.[j]?.id,he=r.length>1&&Se?s.filter(We=>We.floorId===Se):s;Mi(a,we,y[y.length-1].y,he)}}else Y.type==="gaArea"?vr(a,Y,G.baseHeightM,oe(b.get(Y.categoryKey)),o):Y.type==="booth"?Sr(a,Y,G.baseHeightM,oe(b.get(Y.categoryKey)),o,ae.get(Y.id)??G.focal,T(Y,j)):Y.type==="table"?Pr(a,Y,Math.max(G.baseHeightM,g.get(Y.id)??G.baseHeightM),oe(Y.fill??t.theme?.decorFill??"#232c40"),o,!!(Y.fill??t.theme?.decorFill)):Y.type==="decorImage"&&wr(a,Y,G.baseHeightM,o);Ur(a,G,s,M,o,n.materials.shell,!c)}let k=r.length>1?{x:r.reduce((j,G)=>j+G.focal.x,0)/r.length,y:r.reduce((j,G)=>j+G.focal.y,0)/r.length}:t.focalPoint??{x:(l.minX+l.maxX)/2,y:(l.minY+l.maxY)/2},E=ho(c?[a.build(),c]:[a.build()]),C=ko(s,e.initialState,M,v,b,x),O=ai({doc:t,units:r,seats:s,surfaces:M,focal:k}),{labels:F,sections:L,rows:B}=ci({doc:t,units:r,seats:s,surfaces:M,seatData:C,hintedSeatFloor:u,zones:O,focal:k}),N=new Map(L.map((j,G)=>[j.id,G]));M.seatOwner.forEach((j,G)=>{C.iSection[G]=j?N.get(j)??-1:-1});let H=ui({doc:t,units:r,seats:s,surfaces:M,solids:E,hintedSeatFloor:u,seatFloor:v});li(F,H),C.iYaw=_o(C.iPosition,s.length,j=>s[j].rowId,j=>{let G=r[v[j]]?.focal??k;return[G.x*w,G.y*w]});let D=(l.minX+l.maxX)/2*w,V=(l.minY+l.maxY)/2*w,U=.5*Math.hypot((l.maxX-l.minX)*w,(l.maxY-l.minY)*w)||10,Z=Ln(E,C,{cx:D,cz:V,radius:U},[h,d]),X=Ln(E,C,{cx:D,cz:V,radius:U}),q=yi(C,y,l,Z.minY,Z.maxY,U);return{sharedAisles:po(r.flatMap(j=>j.objects.flatMap(G=>{if(G.type!=="section")return[];let Q=M.bySection.get(G.id);return Q?[{sectionId:G.id,floorIndex:j.index,rows:Q.rowLevels}]:[]}))),solids:E,sectionSolidRanges:S,seats:C,seatSectionIds:M.seatOwner,bounds:{center:[(q.min[0]+q.max[0])/2,(q.min[1]+q.max[1])/2,(q.min[2]+q.max[2])/2],radius:U,groundY:0,box:q},renderBounds:{center:Z.center,radius:Z.radius},clipBounds:{center:X.center,radius:X.radius},stateColorLUT:Io(n,Ct),theme:n,seatCount:s.length,focalWorld:[k.x*w,1.5,k.y*w],zones:O,stages:y,productionElements:i.elements,sections:L,rows:B,labels:F,floors:H}}function lu(e,t){let{doc:n,report:o}=ni(e),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let c=new Map(o.roles.map(m=>[m.id,m.role])),f=m=>m.map(d=>d.type==="shape"&&c.has(d.id)?{...d,role:c.get(d.id)}:d),u=e.floors?.map(m=>({...m,objects:f(m.objects)})),l=new Float64Array(t.length).fill(Number.NaN),h=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((m,d)=>{m.eyeHeightM!==void 0&&(l[d]=m.eyeHeightM),m.focalPoint&&(h[d*2]=m.focalPoint.x,h[d*2+1]=m.focalPoint.y)}),{doc:{...e,objects:u?.[0]?.objects??f(e.objects),...u?{floors:u}:{}},report:o,eyeHeightM:l,focal:h}}let i=new Map($e(n).map(c=>[c.id,c])),s=new Float64Array(t.length).fill(Number.NaN),a=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((c,f)=>{let u=i.get(c.id)??c;u.eyeHeightM!==void 0&&(s[f]=u.eyeHeightM),u.focalPoint&&(a[f*2]=u.focalPoint.x,a[f*2+1]=u.focalPoint.y)}),{doc:n,report:o,eyeHeightM:s,focal:a}}function uu(e,t){return e.map((n,o)=>{let r=t.eyeHeightM[o],i=t.focal[o*2],s=t.focal[o*2+1],a={...n};return Number.isNaN(r)?delete a.eyeHeightM:a.eyeHeightM=r,Number.isNaN(i)?delete a.focalPoint:a.focalPoint={x:i,y:s},a})}function Ri(e){let t=e.estimate===!1?null:lu(e.doc,e.seats);return t?{input:{...e,doc:t.doc,seats:uu(e.seats,t)},estimate:t}:{input:e}}function fu(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(n=>n.buffer)}var wi=self;wi.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??$e(e.data.doc),{input:r,estimate:i}=Ri({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),s=Pi(r),a=fu(s);i&&a.push(i.eyeHeightM.buffer,i.focal.buffer),wi.postMessage({model:s,buildMs:performance.now()-t,...n?{seats:o}:{},...i?{estimate:i}:{}},a)};
|
|
1
|
+
"use strict";var Zi=Object.create;var Zn=Object.defineProperty;var $i=Object.getOwnPropertyDescriptor;var Qi=Object.getOwnPropertyNames;var qi=Object.getPrototypeOf,Ji=Object.prototype.hasOwnProperty;var es=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Qi(t))!Ji.call(e,r)&&r!==n&&Zn(e,r,{get:()=>t[r],enumerable:!(o=$i(t,r))||o.enumerable});return e};var Te=(e,t,n)=>(n=e!=null?Zi(qi(e)):{},es(t||!e||!e.__esModule?Zn(n,"default",{value:e,enumerable:!0}):n,e));var wf=Math.PI/180;function on(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function ut(e){return e.length?on(e):null}function $n(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function Qn(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[$n(e,.5)];let o=Array.from({length:n+1},(u,f)=>$n(e,f/n)),r=new Float64Array(o.length);for(let u=1;u<o.length;u+=1){let f=o[u].x-o[u-1].x,c=o[u].y-o[u-1].y;r[u]=r[u-1]+Math.hypot(f,c)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let u=0;u<t;u+=1){let f=i*u/(t-1);for(;a<r.length-1&&r[a]<f;)a+=1;let c=r[a-1],l=r[a],h=l===c?0:(f-c)/(l-c);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*h,y:o[a-1].y+(o[a].y-o[a-1].y)*h})}return s}function qn(e,t,n){return Math.max(t,Math.min(n,e))}function Jn(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((h,m)=>h.segmentedRow.componentIndex-m.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((h,m)=>h.segmentedRow?.kind==="segmented-row-v1"&&h.segmentedRow.groupId===o&&h.segmentedRow.componentCount===s&&h.segmentedRow.componentIndex===m&&h.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(m===0?h.segmentedRow.boundaryBefore==="start":h.segmentedRow.boundaryBefore!=="start")&&h.segmentedRow.displayLabel===a.displayLabel)))continue;let f=i.reduce((h,m)=>h+m.seatCount,0),c=0,l=0;for(let h of i)h.segmentedRow.boundaryBefore==="break"&&(c+=1),t.set(h.id,{groupId:o,adjacencyOffset:c,displayOffset:l,displayLabel:a.displayLabel,totalSeats:f,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),c+=h.seatCount,l+=h.seatCount}return t}var ts="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var ns="abcdefghijklmnopqrstuvwxyz";function os(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function rn(e,t=!1){let n=t?ns:ts;return os(Math.max(0,Math.floor(e)-1),n)}var rs=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function eo(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of rs)for(;t>=o;)n+=r,t-=o;return n}function is(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function At(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,u=e.seatCount;if(i==="updown"||i==="updown-descending"){let m=Math.ceil(u/2),d=i==="updown"?t<m?n+2*t:n-1+2*(u-t):t<m?n+2*(m-1-t):n+1+2*(t-m);return`${s}${d}`}let f=i==="odd"||i==="even"?2:r,c=a!=null&&Number.isFinite(a)?a-(u-1)*f:n,l=o==="center"?is(u)[t]:o==="rtl"?u-1-t:t,h;switch(i){case"odd":{let m=c%2===1?c:c+1;h=String(m+l*2);break}case"even":{let m=c%2===0?c:c+1;h=String(m+l*2);break}case"roman":h=eo(c+l*r);break;case"letters-upper":h=rn(c+l*r,!1);break;case"letters-lower":h=rn(c+l*r,!0);break;default:h=String(c+l*r);break}return`${s}${h}`}function ss(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function to(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${At(e,t)}`}function sn(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return At(e,t);if(!n)return`${e.displayLabel||e.label}-${At(e,t)}`;let r=ss(n),i=n.displayOffset+t;return`${n.displayLabel}-${At(r,i)}`}var $=.02291666666666667,Ie=1/$,as=58,cs=as*$;var ls=3,no=0,an=120,us=0,fs=45,ms=7,ve=1.2;function cn(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function hs(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=ms?e:ls}function Ge(e,t={}){let n=cn(t.floorBaseHeightM,no,an,0),o=Math.min(an,n+hs(e.elevation)*cs),r=e.height===void 0?o:cn(e.height,no,an,o),i=cn(e.rake,us,fs,0);return{height:r,rake:i}}function oo(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function qe(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,u=s.y-i.y,f=a*a+u*u,c=f>1e-12?((t-i.x)*a+(n-i.y)*u)/f:0;c<0?c=0:c>1&&(c=1);let l=t-(i.x+c*a),h=n-(i.y+c*u);if(Math.abs(l)>=o||Math.abs(h)>=o)continue;let m=Math.hypot(l,h);m<o&&(o=m)}return o}function ds(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function ro(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function ln(e,t){let n=1/0;for(let o of oo(e)){let r=qe(t,o.x,o.y);r<n&&(n=r)}for(let o of oo(t)){let r=qe(e,o.x,o.y);r<n&&(n=r)}return n}function ps(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let c of e)n+=c.x,o+=c.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let c of e){let l=Math.hypot(c.x-n,c.y-o);l>r&&(r=l,i=c)}let s=i.x-n,a=i.y-o,u=Math.hypot(s,a);u>1e-9?(s/=u,a/=u):(s=1,a=0);let f=e.map((c,l)=>({p:c,i:l,t:(c.x-n)*s+(c.y-o)*a})).sort((c,l)=>c.t-l.t);return{pts:f.map(c=>c.p),seatIndices:f.map(c=>t[c.i])}}function un(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let g of e)n+=g.x,o+=g.y;n/=t,o/=t;let r=0,i=0,s=0,a=0,u=0,f=0,c=0;for(let g of e){let P=g.x-n,E=g.y-o;r+=P*P,s+=E*E,i+=P*E,a+=P*P*P,u+=E*E*E,f+=P*E*E,c+=E*P*P}let l=r*s-i*i;if(Math.abs(l)<1e-9)return null;let h=(a+f)/2,m=(u+c)/2,d=(h*s-m*i)/l,p=(m*r-h*i)/l,y=d+n,x=p+o;return!Number.isFinite(y)||!Number.isFinite(x)?null:{cx:y,cy:x}}var bs=.15;function ys(e){if(e.length<2)return null;let t=e.map(S=>{let b=0,I=0;for(let M of S.pts)b+=M.x,I+=M.y;return{x:b/S.pts.length,y:I/S.pts.length}}),n=0,o=0;for(let S of t)n+=S.x,o+=S.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let S of t){let b=S.x-n,I=S.y-o;r+=b*b,i+=b*I,s+=I*I}let a=r+s,u=r*s-i*i,f=a/2+Math.sqrt(Math.max(0,a*a/4-u)),c,l;Math.abs(i)>1e-12?(c=f-s,l=i):r>=s?(c=1,l=0):(c=0,l=1);let h=Math.hypot(c,l);if(!(h>1e-12))return null;c/=h,l/=h;let m=0,d=0,p=0;for(let S of e){if(S.pts.length<2)continue;let b=S.pts[0],I=S.pts[S.pts.length-1],M=I.x-b.x,R=I.y-b.y,_=Math.hypot(M,R);if(!(_>1e-9))continue;let k=M/_,O=R/_;m+=(k*k-O*O)*_,d+=2*k*O*_,p+=_}if(p>0&&Math.hypot(m,d)>=gs*p){let S=Math.atan2(d,m)/2,b=Math.cos(S),I=Math.sin(S);Math.abs(c*b+l*I)>Ms&&(c=-I,l=b)}let y=1/0,x=-1/0,g=[];for(let S of e){let b=1/0,I=-1/0;for(let M of S.pts){let R=M.x*c+M.y*l;R<b&&(b=R),R>I&&(I=R),R<y&&(y=R),R>x&&(x=R)}g.push(I-b)}let P=x-y;return P>1e-9?(g.sort((S,b)=>S-b),g[Math.min(g.length-1,Math.floor(g.length*.9))]/P<=xs?{x:c,y:l}:null):null}var xs=.35,gs=.8,Ms=.7;function Et(e,t,n,o){let r=new Map;for(let b of n){let I=t[b],M=I.rowId||`__seat-${b}`,R=r.get(M);R||(R={pts:[],idx:[]},r.set(M,R)),R.pts.push({x:I.x,y:I.y}),R.idx.push(b)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[b,I]of r){let M=ps(I.pts,I.idx),R=0;for(let _ of M.pts)R+=Math.hypot(_.x-o.x,_.y-o.y);i.push({id:b,pts:M.pts,seatIndices:M.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:R/M.pts.length})}let s=i.map(b=>ds(b.pts)),a=i.length<=256?i.length*(i.length-1)/2:0,u=a?new Float64Array(a):null;u?.fill(Number.NaN);let f=u?new Map(i.map((b,I)=>[b,I])):null,c=(b,I)=>(b>I&&([b,I]=[I,b]),b*(2*i.length-b-1)/2+(I-b-1)),l=(b,I)=>{if(!u)return ln(i[b].pts,i[I].pts);let M=c(b,I),R=u[M];if(!Number.isNaN(R))return R;let _=ln(i[b].pts,i[I].pts);return u[M]=_,_},h=(b,I)=>f?l(f.get(b),f.get(I)):ln(b.pts,I.pts),m=[];for(let b=0;b<i.length;b++){let I=1/0;for(let M=0;M<i.length;M++){if(b===M||ro(s[b],s[M])>=I)continue;let R=l(b,M);R<I&&(I=R)}Number.isFinite(I)&&m.push(I)}m.sort((b,I)=>b-I);let d=m.length?m[Math.floor(m.length/2)]:1,p=Math.max(d*1.8,1e-6),y=i.map(()=>[]);for(let b=0;b<i.length;b++)for(let I=b+1;I<i.length;I++)ro(s[b],s[I])>p||l(b,I)<=p&&(y[b].push(I),y[I].push(b));let x=0;for(let b=0;b<i.length;b++){if(i[b].blockId!==-1)continue;let I=x++,M=[b];for(i[b].blockId=I;M.length;){let R=M.pop();for(let _ of y[R])i[_].blockId===-1&&(i[_].blockId=I,M.push(_))}}let g=new Map;for(let b of i){let I=g.get(b.blockId)??[];I.push(b),g.set(b.blockId,I)}let P=[];for(let b of i){if(b.pts.length<4)continue;let I=un(b.pts);I&&(!Number.isFinite(I.cx)||!Number.isFinite(I.cy)||P.push({x:I.cx,y:I.cy}))}let E=P.length>=2?(()=>{let b=P.map(R=>R.x).sort((R,_)=>R-_),I=P.map(R=>R.y).sort((R,_)=>R-_),M=Math.floor(P.length/2);return{cx:b[M],cy:I[M]}})():null;if(E){let b=O=>Math.hypot(O.x-E.cx,O.y-E.cy),I=1/0,M=-1/0,R=[];for(let O of i){let C=1/0,A=-1/0;for(let v of O.pts){let T=b(v);T<C&&(C=T),T>A&&(A=T)}R.push(A-C),C<I&&(I=C),A>M&&(M=A)}let _=M-I;R.sort((O,C)=>O-C);let k=R[Math.min(R.length-1,Math.floor(R.length*.9))];if(_>1e-9&&k/_<=bs){let O=i.map(D=>{let V=0;for(let X of D.pts)V+=b(X);return{row:D,radius:V/D.pts.length}}),C=0,A=0;for(let D of O)C+=D.radius,A+=D.row.focalDistance;C/=O.length,A/=O.length;let v=0;for(let D of O)v+=(D.radius-C)*(D.row.focalDistance-A);if(v<0)for(let D of O)D.radius=-D.radius;let F=1/0;for(let D of O)D.radius<F&&(F=D.radius);O.sort((D,V)=>D.radius-V.radius);let L=-1,B=-1/0,N=_/Math.max(1,O.length)*.5,j=[];for(let D of O)D.radius-B>N&&(L++,B=D.radius),D.row.ordinal=L,D.row.blockDepth=D.radius-F,j.push(D.row);return{sectionId:e,rows:j,blockCount:x}}}let S=[];for(let[,b]of g){let I=ys(b);if(I){let M=O=>{let C=0;for(let A of O.pts)C+=A.x*I.x+A.y*I.y;return C/O.pts.length};b.sort((O,C)=>M(O)-M(C)),b.length>=2&&b[0].focalDistance>b[b.length-1].focalDistance&&b.reverse();let R=[],_=d*.5;for(let O of b){let C=R[R.length-1];C&&Math.abs(M(O)-M(C[0]))<_?C.push(O):R.push([O])}let k=0;for(let O=0;O<R.length;O++){if(O>0){let C=1/0;for(let A of R[O-1])for(let v of R[O])C=Math.min(C,h(A,v));k+=C}for(let C of R[O])C.ordinal=O,C.blockDepth=k,S.push(C)}}else{let M=1/0;for(let R of b)R.focalDistance<M&&(M=R.focalDistance);b.sort((R,_)=>R.focalDistance-_.focalDistance);for(let R=0;R<b.length;R++)b[R].ordinal=R,b[R].blockDepth=Math.max(0,b[R].focalDistance-M),S.push(b[R])}}return{sectionId:e,rows:S,blockCount:x}}var Ss=/^\d{4}-\d{2}-\d{2}$/;function Is(e){let t=Date.parse(e);return Number.isFinite(t)?Ss.test(e)?t+864e5:t:null}function Rs(e,t=Date.now()){if(e.validUntil===void 0){if(e.status!=="approved")return!0;let o=e.assessedAt?Date.parse(e.assessedAt):Number.NaN;return Number.isFinite(o)&&(t instanceof Date?t.getTime():t)<=o+366*864e5}let n=Is(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function Ps(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function ws(e){return e.status!=="draft"&&e.status!=="retracted"}function As(e,t){return e.status===void 0?t===void 0:e.status!=="approved"?!0:typeof t=="string"&&typeof e.basisSha256=="string"&&e.basisSha256===t}function io(e,t={}){return!!e&&ws(e)&&Ps(e,t.activeConfigurationId,t.activeConfigurationVersion)&&As(e,t.activeBasisSha256)&&Rs(e,t.now)}var Es=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),_s=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function We(e){return!!e&&Es.has(e)}function _t(e){return!!e&&_s.has(e)}var vt=1.1,vs={"pitch-football":{width:105,height:68},"rink-hockey":{width:60,height:30},"track-athletics":{width:176.9,height:92.5},"oval-cricket":{width:150,height:140},"pitch-rugby":{width:120,height:70},"diamond-baseball":{width:140,height:140},"court-basketball":{width:32,height:19},"court-tennis":{width:36.57,height:18.29},"ring-boxing":{width:7.8,height:7.8}},Cs={"pitch-football":"#2f7d4f","rink-hockey":"#e8f1f8","track-athletics":"#a4472f","oval-cricket":"#3d8a53","pitch-rugby":"#2f7d4f","diamond-baseball":"#2f7d4f","court-basketball":"#c8894f","court-tennis":"#3f7a5a","ring-boxing":"#2a4d8f"};var ks=Math.PI*2;function Ts(e,t,n,o,r,i){return{x:r+e*n-t*o,y:i+e*o+t*n}}function so(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let i=0;i<=r;i++){let s=-Math.PI/2+i/r*Math.PI;o.push({x:n+t*Math.cos(s),y:t*Math.sin(s)})}for(let i=0;i<=r;i++){let s=Math.PI/2+i/r*Math.PI;o.push({x:-n+t*Math.cos(s),y:t*Math.sin(s)})}return o}var ao=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),i=r+70,s=[],a=Math.atan2(o.y-r,o.x),u=Math.atan2(o.y-r,-o.x);for(let f=0;f<=24;f++){let c=a+(u-a)*f/24;s.push({x:i*Math.cos(c),y:r+i*Math.sin(c)})}return{half:70,home:t,backstop:n,fence:s}})();var Ct="#f1f5f9";function ft(e){return We(e)}function je(e,t,n,o,r=32){let i=[];for(let s=0;s<r;s++){let a=s/r*ks;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Le(e,t,n,o){return[{x:e-n,y:t-o},{x:e+n,y:t-o},{x:e+n,y:t+o},{x:e-n,y:t+o}]}function Ls(e){let{kind:t,cx:n,cy:o,width:r,height:i}=e,s=(e.rotation??0)*Math.PI/180,a=Math.cos(s),u=Math.sin(s),f=r/2,c=i/2,l=[],h=vs[t],m=p=>h?p/h.width*r:0,d=p=>h?p/h.height*i:0;switch(t){case"pitch-football":{l.push({points:[{x:0,y:-c},{x:0,y:c}],closed:!1}),l.push({points:je(0,0,m(9.15),d(9.15)),closed:!0});for(let p of[-1,1])l.push({points:Le(p*(f-m(16.5)/2),0,m(16.5)/2,d(40.32)/2),closed:!0}),l.push({points:Le(p*(f-m(5.5)/2),0,m(5.5)/2,d(18.32)/2),closed:!0});break}case"rink-hockey":{l.push({points:[{x:0,y:-c},{x:0,y:c}],closed:!1,ink:"#d63b3b"});for(let p of[-1,1]){l.push({points:[{x:p*m(7.5),y:-c},{x:p*m(7.5),y:c}],closed:!1,ink:"#2f6ecb"}),l.push({points:[{x:p*(f-m(4)),y:-d(11)},{x:p*(f-m(4)),y:d(11)}],closed:!1,ink:"#d63b3b"});for(let y of[-1,1])l.push({points:je(p*m(20.5),y*d(7),m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"})}l.push({points:je(0,0,m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"});break}case"track-athletics":{let y=c-d(1.22)*8;y>0&&l.push({points:so(f-m(1.22)*8,y),closed:!0,fill:"#2f7d4f"});for(let x=1;x<8;x++){let g=d(1.22)*x,P=c-g;if(P<=0)break;l.push({points:so(f-m(1.22)*x,P),closed:!0})}break}case"oval-cricket":{l.push({points:je(0,0,m(27.4),d(27.4+20.12/2),40),closed:!0}),l.push({points:Le(0,0,m(3.05)/2,d(20.12)/2),closed:!0,ink:"#d8cfae"});break}case"pitch-rugby":{let p=y=>({points:[{x:m(y),y:-c},{x:m(y),y:c}],closed:!1});l.push(p(0));for(let y of[-1,1]){l.push(p(y*50),p(y*28));for(let x=-35;x<35;x+=4)l.push({points:[{x:m(y*10),y:d(x)},{x:m(y*10),y:d(Math.min(35,x+2))}],closed:!1})}break}case"diamond-baseball":{let p=(T,F)=>({x:m(T),y:d(F)}),{home:y}=ao,x=27.43,g=x/Math.SQRT2,P={x:y.x+g,y:y.y-g},E={x:y.x,y:y.y-2*g},S={x:y.x-g,y:y.y-g},b={x:y.x,y:y.y-18.44},I="#b98a59",M=Cs["diamond-baseball"],R=38.94,_=[p(y.x,y.y)],k=Math.atan2(y.y-R/Math.SQRT2-b.y,R/Math.SQRT2),O=Math.PI-k;for(let T=0;T<=16;T++){let F=k-(k+Math.PI*2-O)%(Math.PI*2)*(T/16);_.push(p(b.x+29*Math.cos(F),b.y+29*Math.sin(F)))}l.push({points:_,closed:!0,fill:I,ink:I});let C={x:y.x,y:y.y-g},A=[{x:y.x,y:y.y},P,E,S].map(T=>p(C.x+(T.x-C.x)*.84,C.y+(T.y-C.y)*.84));l.push({points:A,closed:!0,fill:M,ink:M}),l.push({points:je(m(b.x),d(b.y),m(2.74),d(2.74),20),closed:!0,fill:I,ink:I}),l.push({points:je(m(y.x),d(y.y),m(3.96),d(3.96),20),closed:!0,fill:I,ink:I});let v=ao.fence;l.push({points:[p(y.x,y.y),p(v[0].x,v[0].y)],closed:!1}),l.push({points:[p(y.x,y.y),p(v[v.length-1].x,v[v.length-1].y)],closed:!1});for(let T of[P,E,S])l.push({points:Le(m(T.x),d(T.y),m(.3),d(.3)),closed:!0,fill:Ct});break}case"court-basketball":{l.push({points:Le(0,0,m(14),d(7.5)),closed:!0}),l.push({points:[{x:0,y:-d(7.5)},{x:0,y:d(7.5)}],closed:!1}),l.push({points:je(0,0,m(1.8),d(1.8),24),closed:!0});for(let p of[-1,1]){let y=p*14,x=p*(14-5.8),g=p*(14-1.575);l.push({points:Le(m((y+x)/2),0,m(2.9),d(2.45)),closed:!0,fill:"#2f5d8a"}),l.push({points:je(m(x),0,m(1.8),d(1.8),24),closed:!0});let P=Math.sqrt(6.75*6.75-6.6*6.6),E=[{x:m(y),y:-d(6.6)}],S=Math.atan2(-6.6,-p*P),b=2*Math.atan2(6.6,P);for(let I=0;I<=16;I++){let M=S-p*b*(I/16);E.push({x:m(g+6.75*Math.cos(M)),y:d(6.75*Math.sin(M))})}E.push({x:m(y),y:d(6.6)}),l.push({points:E,closed:!1})}break}case"court-tennis":{l.push({points:Le(0,0,m(11.885),d(5.485)),closed:!0,fill:"#2b5f99"});for(let p of[-1,1])l.push({points:[{x:-m(11.885),y:p*d(4.115)},{x:m(11.885),y:p*d(4.115)}],closed:!1}),l.push({points:[{x:p*m(6.4),y:-d(4.115)},{x:p*m(6.4),y:d(4.115)}],closed:!1});l.push({points:[{x:-m(6.4),y:0},{x:m(6.4),y:0}],closed:!1}),l.push({points:[{x:0,y:-d(6.4)},{x:0,y:d(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{l.push({points:Le(0,0,m(3.05),d(3.05)),closed:!0});let x=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[g,P,E]of x)l.push({points:Le(g*m(3.05),P*d(3.05),m(.3),d(.3)),closed:!0,fill:E,ink:E});break}default:return[]}return l.map(p=>({...p,points:p.points.map(y=>Ts(y.x,y.y,a,u,n,o))}))}function co(e){if(e.role!=="stage"||!ft(e.stageKind))return[];let t=null;if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null&&e.width>0&&e.height>0&&[e.x,e.y,e.width,e.height].every(Number.isFinite))t={cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height};else if(e.points&&e.points.length>=3&&e.points.every(n=>Number.isFinite(n.x)&&Number.isFinite(n.y))){let n=e.points.map(c=>c.x),o=e.points.map(c=>c.y),r=Math.min(...n),i=Math.max(...n),s=Math.min(...o),a=Math.max(...o),u=Math.max(1,i-r),f=Math.max(1,a-s);t={cx:r+u/2,cy:s+f/2,width:u,height:f}}return t?Ls({kind:e.stageKind,...t}):[]}var Os=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Bs=/[\s"'<>`\\]/;function Fs(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Os.test(e);if(Bs.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function lo(e){let t=e.trim();return Fs(t)?t:null}var fn="seatlayer.event-configuration/1";var Je=100,Ds=120,Ns=2e5,Gs=1e4,js=/^[a-f0-9]{64}$/,Hs=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function mt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ze(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Xs(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function uo(e){return!Array.isArray(e)||e.length>Ns||!e.every(t=>ze(t,Je))?null:[...new Set(e)].sort()}function Us(e){return!mt(e)||!ze(e.chartId,Je)||!ze(e.version,Je)||e.sha256!==void 0&&(typeof e.sha256!="string"||!js.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function mn(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function Vs(e){return mt(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&mn(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Ys(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>Gs)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!mt(a)||!ze(a.id,Je)||!ze(a.objectId,Je)||!n.has(a.objectId)||!Hs.has(String(a.kind))||!mn(a.heightM,.05,50)||a.baseElevationM!==void 0&&!mn(a.baseElevationM,-10,100))return null;let u=Vs(a.occlusion);if(!u||o.has(a.id)||r.has(a.objectId))return null;let f=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?lo(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!f||a.kind!=="screen"||++i>1))return null;o.add(a.id),r.add(a.objectId),s.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:u,...f?{contentImageUrl:f}:{}})}return s.sort((a,u)=>a.id.localeCompare(u.id))}function Ks(e){let t=[];if(!mt(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==fn&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${fn}`}),ze(e.id,Je)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),ze(e.label,Ds)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Xs(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=Us(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let o=mt(e.overlay)?e.overlay:null,r=uo(o?.objectIds),i=uo(o?.productionKillSeatIds),s=r?Ys(o?.productionElements,r):null;return(!o||!r||!i)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),s===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!r||!i||s===null?{issues:t}:{issues:t,value:{schema:fn,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function fo(e){let t=Ks(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function Ws(e){if((e.kind==="polygon"||e.kind==="polyline"||e.kind==="line")&&e.points&&e.points.length>=2)return e.points;if(e.x==null||e.y==null||e.width==null||e.height==null)return null;let t=e.x,n=e.y,o=e.width,r=e.height;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+r},{x:t,y:n+r}]}function zs(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),i=Math.sin(o),s=e.x-t.x,a=e.y-t.y;return{x:t.x+s*r-a*i,y:t.y+s*i+a*r}}function mo(e){let t=Ws(e);if(!t||t.length<2)return null;let n=e.rotation??0,o=Math.abs(n)<1e-6?t:t.map(u=>zs(u,{x:t.reduce((f,c)=>f+c.x,0)/t.length,y:t.reduce((f,c)=>f+c.y,0)/t.length},n)),r=1/0,i=1/0,s=-1/0,a=-1/0;for(let u of o)r=Math.min(r,u.x),i=Math.min(i,u.y),s=Math.max(s,u.x),a=Math.max(a,u.y);return!Number.isFinite(r)||s-r<1e-6||a-i<1e-6?null:{minX:r,minY:i,maxX:s,maxY:a}}var Zs=5,$s=3,Qs=.92,qs=1.9,Js=2,ea=.6,ta=1,na=.06;function oa(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?vt:ft(e.stageKind)?na:ta}function ho(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=-1/0;for(let s of yo(e)){let a=s.baseHeightM??0;for(let u of s.objects){if(u.type!=="shape"||u.role!=="stage")continue;let f=mo(u);f&&(t=Math.min(t,f.minX),n=Math.min(n,f.minY),o=Math.max(o,f.maxX),r=Math.max(r,f.maxY),i=Math.max(i,a+oa(u)))}}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minX:t,minY:n,maxX:o,maxY:r,deckTopM:i}}function ra(e,t,n,o){let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let m of e)Number.isFinite(m.eyeHeightM)&&(r=Math.min(r,m.x),s=Math.max(s,m.x),i=Math.min(i,m.y),a=Math.max(a,m.y));if(!Number.isFinite(r))return null;let u=r*t,f=i*t,c=Math.max(1,Math.ceil((s-r)*t/n)+1),l=Math.max(1,Math.ceil((a-i)*t/n)+1),h=new Float64Array(c*l).fill(-1/0);for(let m of e){if(!Number.isFinite(m.eyeHeightM))continue;let d=m.eyeHeightM-ve,p=Math.min(c-1,Math.max(0,Math.floor((m.x*t-u)/n))),x=Math.min(l-1,Math.max(0,Math.floor((m.y*t-f)/n)))*c+p,g=d+o;g>h[x]&&(h[x]=g)}return{cellM:n,minX:u,minY:f,cols:c,rows:l,top:h}}function ia(e,t,n){let o=Math.floor((t-e.minX)/e.cellM),r=Math.floor((n-e.minY)/e.cellM);return o<0||r<0||o>=e.cols||r>=e.rows?-1/0:e.top[r*e.cols+o]}function po(e,t,n={}){let o=new Map;if(!t||!e.length)return o;let r=n.metresPerChartUnit??$,i=n.cellM??ea,s=n.chairBackM??Qs,a=n.selfRowSkipM??Js,u=n.clearThreshold??.9,f=n.partialThreshold??.25,c=Math.max(1,n.columns??Zs),l=Math.max(1,n.rows??$s),h=ra(e,r,i,s);if(!h)return o;let m=(t.maxX-t.minX)*r,d=(t.maxY-t.minY)*r,p=m>=d,y=(t.minX+t.maxX)/2*r,x=(t.minY+t.maxY)/2*r,g=[];for(let E=0;E<c;E++){let S=(E+.5)/c-.5,b=p?y+S*m:y,I=p?x:x+S*d;for(let M=0;M<l;M++){let R=t.deckTopM+(l===1?0:M/(l-1)*qs);g.push({x:b,y:I,z:R})}}let P=i/2;for(let E of e){if(!Number.isFinite(E.eyeHeightM))continue;let S=E.x*r,b=E.y*r,I=E.eyeHeightM,M=0,R=1/0;for(let k of g){let O=k.x-S,C=k.y-b,A=Math.hypot(O,C);if(!(A>a)){M++;continue}let v=O/A,T=C/A,F=0;for(let L=a;L<A;L+=P){let B=ia(h,S+v*L,b+T*L);if(!(!Number.isFinite(B)||B>=I)&&B>I+(k.z-I)*L/A){F=L;break}}F?R=Math.min(R,F):M++}let _=M/g.length;_>=u||o.set(E.id,{seatId:E.id,mark:_<f?"obstructedView":"restrictedView",visibleFraction:_,totalRays:g.length,atDistanceM:Number.isFinite(R)?R:0})}return o}function bo(e,t){if(!t.size)return 0;let n=0;for(let o of e){let r=t.get(o.id);if(!r)continue;let i=o.commercial;i?.restrictedView!==void 0||i?.obstructedView!==void 0||(o.commercial={...i,[r.mark]:!0},n++)}return n}function hn(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Tt=Math.PI/180;var ht=16;function dn(e,t,n,o){let r=n*Tt,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function Io(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return Qn(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let f=0;f<t;f++)s.push(dn(f*n,0,r,i));return s}let a=o/(t-1)*Tt,u=n/(2*Math.sin(Math.abs(a)/2));for(let f=0;f<t;f++){let c=f*a,l=u*Math.sin(c),h=-u+u*Math.cos(c);s.push(dn(l,h,r,i))}return s}function Ro(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function sa(e,t){let n=Ro(e);return Io(e).map((o,r)=>{let i=n.get(r),s=hn(i),a=to(e,r,i),u={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:sn(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(u).some(f=>f!==void 0&&f!==!1&&f!=="")?u:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle??e.seatLabelStyle}})}function aa(e){let t=[];for(let n of sa(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function ca(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function la(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(c=>[c.index,c])),r=(c,l,h,m)=>{let d=o.get(c),p=hn(d),y=d?.label??`${e.label}-${c+1}`,x=e.displayLabel??e.label;return{index:c,label:y,displayLabel:d?.displayLabel??`${x}-${c+1}`,x:l+(d?.dx??0),y:h+(d?.dy??0),categoryKey:d?.categoryKey??e.categoryKey,skipped:!!d?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:d?.wheelchairSpaceType,commercial:d?.commercial,glyph:d?.glyph,viewUrl:d?.viewFromSeatUrl,viewMeta:d?.viewFromSeatUrl?d.viewFromSeatMeta:void 0,labelStyle:d?.labelStyle,...m?{side:m}:{}}};if(e.shape==="round"){let c=(e.radius??40)+ht,l=e.rotation*Tt,h=Math.max(0,Math.min(360,e.seatArc??360));if(h>=360||n===1){for(let y=0;y<n;y++){let x=l+y/n*2*Math.PI;t.push(r(y,e.center.x+c*Math.cos(x),e.center.y+c*Math.sin(x)))}return t}let m=h*Tt,d=(2*Math.PI-m)/2,p=l+d;for(let y=0;y<n;y++){let x=p+y/(n-1)*m;t.push(r(y,e.center.x+c*Math.cos(x),e.center.y+c*Math.sin(x)))}return t}let i=e.width??80,s=e.height??50,a=ca(e),u=["top","bottom","left","right"],f=0;for(let c of u){let l=a[c];for(let h=0;h<l;h++){let m,d;c==="top"?(m=-i/2+(h+.5)*i/l,d=-s/2-ht):c==="bottom"?(m=-i/2+(h+.5)*i/l,d=s/2+ht):c==="left"?(m=-i/2-ht,d=-s/2+(h+.5)*s/l):(m=i/2+ht,d=-s/2+(h+.5)*s/l);let p=dn(m,d,e.rotation,e.center);t.push(r(f++,p.x,p.y,c))}}return t}function ua(e){return la(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function fa(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function xo(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,a=t[r].x,u=t[r].y;s>e.y!=u>e.y&&e.x<(a-i)*(e.y-s)/(u-s)+i&&(n=!n)}return n}function ma(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),a=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=a+1e-7})}function pn(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function be(e,t,n){return xo(e,t)&&!pn(n).some(o=>xo(e,o)||ma(e,o))}function kt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function Po(e){switch(e.type){case"row":{let t=Io(e),n=Ro(e),o=0,r=0,i=0;for(let s=0;s<t.length;s++){let a=n.get(s);a?.skip||(o+=t[s].x+(a?.dx??0),r+=t[s].y+(a?.dy??0),i++)}return i?{x:o/i,y:r/i}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return kt(e.points);case"section":return kt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?kt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function go(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function ha(e,t){if(e.type!=="gaArea"||!go(e.points,t.outline))return!1;let n=pn(e.holes),o=pn(t.holes);return n.length===o.length&&n.every((r,i)=>go(r,o[i]))}function da(e,t,n=e.filter(r=>r.type==="section"),o=Po(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(s=>(s.logicalSectionId??s.id)===r&&(ha(t,s)||be(o,s.outline,s.holes))):void 0)??n.find(s=>be(o,s.outline,s.holes))}function yo(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function Mo(e,t,n,o,r,i,s,a,u){let f=[],c=e.filter(p=>p.type==="section"),l=Jn(e),h=p=>!p?.eventConfigurationId||p.eventConfigurationId===o&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===u),m=p=>io(p,{activeConfigurationId:o,activeConfigurationVersion:u,activeBasisSha256:r,now:a}),d=(p,y)=>m(p)?{...p,coverage:y}:void 0;for(let p of e){let y=[];if(p.type==="row"?y=aa(p):p.type==="table"?y=ua(p):p.type==="booth"&&(y=fa(p)),!y.length)continue;for(let S of y)S.viewUrl&&!h(S.viewMeta)&&(S.viewUrl=void 0,S.viewMeta=void 0);if(p.type==="row"){let S=l.get(p.id);if(S){let b=new Map((p.overrides??[]).map(I=>[I.index,I]));for(let I of y){let M=Number(I.id.slice(I.id.lastIndexOf(":")+1));if(!Number.isInteger(M))continue;I.logicalRowId=S.groupId,I.logicalSeatIndex=S.adjacencyOffset+M,b.get(M)?.displayLabel||(I.displayLabel=sn(p,M,S)),!I.viewUrl&&S.viewFromSeatUrl&&h(S.viewFromSeatMeta)&&(I.viewUrl=S.viewFromSeatUrl,I.viewMeta=S.viewFromSeatMeta);let R=b.get(M)?.confidenceEvidence;I.confidenceEvidence=d(R,"exact-seat")??d(p.confidenceEvidence,"row-representative")??d(S.confidenceEvidence,"row-representative")}}}let x=da(e,p,c,p.type==="row"?kt(y):Po(p)),g=x?.viewFromSeatUrl,E=(x?.zone?t?.find(S=>S.id===x.zone):void 0)?.focalPoint??n;for(let S of y){if(!S.confidenceEvidence){let b=Number(S.id.slice(S.id.lastIndexOf(":")+1)),I=(p.type==="row"||p.type==="table")&&Number.isInteger(b)?p.overrides?.find(M=>M.index===b)?.confidenceEvidence:void 0;S.confidenceEvidence=d(I,"exact-seat")??(p.type==="row"?d(p.confidenceEvidence,"row-representative"):void 0)}S.confidenceEvidence??=d(x?.confidenceEvidence,"section-representative")??(s?d(s.evidence,s.coverage):void 0),!S.viewUrl&&g&&h(x?.viewFromSeatMeta)&&(S.viewUrl=g,S.viewMeta=x?.viewFromSeatMeta),!S.viewUrl&&i&&h(i.meta)&&(S.viewUrl=i.url,S.viewMeta=i.meta),x&&(S.sectionId=x.logicalSectionId??x.id),x?.zone&&(S.zoneId=x.zone),E&&(S.focalPoint={...E})}f.push(...y)}return f}function et(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,u=Mo(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&So(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,u);for(let f of u)f.floorId=r.id;for(let f of u)o.push(f)}return o}let n=Mo(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.confidenceBasisSha256,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);return t.resolveEyeHeights!==!1&&So(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),pa(e,n,t)}function pa(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||bo(t,po(t,ho(e))),t}function So(e,t,n,o){let r=e.filter(l=>l.type==="section"),i=n>0||r.some(l=>l.height!==void 0||l.rake!==void 0||(l.elevation??0)>0);if(!r.length||!i||!t){for(let l of o)l.eyeHeightM=n+ve;return}let s=new Array(o.length),a=new Map;for(let l of r)a.has(l.id)||a.set(l.id,l);let u=new Map,f=new Map;for(let l=0;l<o.length;l++){let h=o[l],d=(h.sectionId?a.get(h.sectionId)??r.find(y=>y.logicalSectionId===h.sectionId&&be({x:h.x,y:h.y},y.outline,y.holes)):void 0)??r.find(y=>be({x:h.x,y:h.y},y.outline,y.holes))??null;if(s[l]=d,!d)continue;u.has(d.id)||u.set(d.id,Ge(d,{floorBaseHeightM:n}));let p=f.get(d.id);p?p.push(l):f.set(d.id,[l])}let c=new Array(o.length).fill(void 0);for(let[l,h]of f){let m=u.get(l);if(!m)continue;let d=m.rake>0?Math.tan(m.rake*Math.PI/180):0,p=Et(l,o,h,t);for(let y of p.rows){let x=y.blockDepth*$*d,g=m.height+x;for(let P of y.seatIndices)c[P]=g}}for(let l=0;l<o.length;l++){let h=o[l],m=s[l];if(!m){h.eyeHeightM=n+ve;continue}let d=u.get(m.id);h.eyeHeightM=(c[l]??d.height)+ve}}var Ao=Te(require("earcut"),1),bn=Te(require("polygon-clipping"),1);function ye(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let r=e[n],i=e[(n+1)%o];t+=r.x*i.y-i.x*r.y}return t/2}function xe(e,t,n){let o=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let s=e[r],a=e[i];s.y>n!=a.y>n&&t<(a.x-s.x)*(n-s.y)/(a.y-s.y)+s.x&&(o=!o)}return o}var w=$,ba=.002;function ya(e,t,n){let o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.max(o,r,i);if(s<1e-9)return!0;let a=(o+r+i)/2;return 2*Math.sqrt(Math.max(0,a*(a-o)*(a-r)*(a-i)))/s<ba}var Ze=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=o}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let o=new Float32Array(n);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Bt=class{constructor(){this.pos=new Ze;this.nor=new Ze;this.col=new Ze;this.flr=new Ze;this.mat=new Ze;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,o,r,i,s=i,a=i){ya(t,n,o)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[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(t,n,o,r,i,s,a,u=a,f=a){[...t,...n,...o].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(u[0],u[1],u[2]),this.col.push3(f[0],f[1],f[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 xa(e,t,n){let o=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=n[0]-e[0],a=n[1]-e[1],u=n[2]-e[2],f=r*u-i*a,c=i*s-o*u,l=o*a-r*s,h=Math.hypot(f,c,l)||1;return f/=h,c/=h,l/=h,[f,c,l]}function ga(e,t){let n=[...e],o=[];for(let s of e)o.push(s.x,s.y);let r=[];if(t){for(let s of t)if(!(s.length<3)){r.push(n.length);for(let a of s)n.push(a),o.push(a.x,a.y)}}let i=(0,Ao.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function Ce(e){return ye(e)<0?[...e].reverse():e}var Ma=3;function Sa(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(m,d,p,y)=>Math.abs(o({x:(m.x+d.x)/2,y:(m.y+d.y)/2})-(p+y)/2),u=(e.x+t.x+n.x)/3,f=(e.y+t.y+n.y)/3,c=(r+i+s)/3,l=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:u,y:f})-c)),h=(m,d,p)=>{let y=Math.abs(o({x:(m+u)/2,y:(d+f)/2})-(p+c)/2);y>l&&(l=y)};return h((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),h((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),h((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),l}function dt(e,t,n,o,r){if(r<=0)return Sa(e,t,n,o);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(dt(e,i,a,o,r-1),dt(i,t,s,o,r-1),dt(a,s,n,o,r-1),dt(i,s,a,o,r-1))}function pt(e,t,n,o,r,i,s,a){if(s>0){let h={x:(t.x+n.x)/2,y:(t.y+n.y)/2},m={x:(n.x+o.x)/2,y:(n.y+o.y)/2},d={x:(o.x+t.x)/2,y:(o.y+t.y)/2};pt(e,t,h,d,r,i,s-1,a),pt(e,h,n,m,r,i,s-1,a),pt(e,d,m,o,r,i,s-1,a),pt(e,h,m,d,r,i,s-1,a);return}let u=[t.x*w,r(t),t.y*w],f=[n.x*w,r(n),n.y*w],c=[o.x*w,r(o),o.y*w];if(a){e.triN(u,f,c,a(t),a(n),a(o),i);return}let l=xa(u,f,c);l[1]<0&&(l=[-l[0],-l[1],-l[2]]),e.tri(u,f,c,l,i)}var Ia=8;function wo(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,u,f)=>{if(f>0){let c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},l=t(c);if(Math.abs(l-(a+u)/2)>n){r(i,c,a,l,f-1),r(c,s,l,u,f-1);return}}o.push(i)};for(let i=0;i<e.length;i++){let s=e[i],a=e[(i+1)%e.length];r(s,a,t(s),t(a),Ia)}return o}function Lt(e,t){if(e.length<3)return e;let n=[];for(let r of e){let i=n[n.length-1];i&&Math.hypot(r.x-i.x,r.y-i.y)<t||n.push(r)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let o=[];for(let r=0;r<n.length;r++){let i=o.length?o[o.length-1]:n[(r-1+n.length)%n.length],s=n[r],a=n[(r+1)%n.length],u=a.x-i.x,f=a.y-i.y,c=Math.hypot(u,f);c>t&&Math.abs((s.x-i.x)*f-(s.y-i.y)*u)/c<t||o.push(s)}return o.length>=3?o:n}var Ot=.001*Ie*.1;function z(e,t,n,o,r,i,s,a,u=1/0,f){if(!t||t.length<3||(u===void 0&&(u=1/0),Math.abs(ye(t))<1e-4))return;let c=Lt(wo(Lt(Ce(t),Ot),o,u),Ot),l=n?.map(b=>Lt(wo(Lt(Ce(b),Ot),o,u),Ot)).filter(b=>b.length>=3&&Math.abs(ye(b))>=1e-4),{pts:h,tris:m}=ga(c,l),d=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],y=[s[0]*a.top,s[1]*a.top,s[2]*a.top],x=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],g=0;if(Number.isFinite(u))for(;g<Ma;g++){let b=0;for(let I=0;I<m.length;I+=3){let M=dt(h[m[I]],h[m[I+1]],h[m[I+2]],o,g);M>b&&(b=M)}if(b<=u)break}for(let b=0;b<m.length;b+=3){let I=h[m[b]],M=h[m[b+1]],R=h[m[b+2]];pt(e,I,M,R,o,d,g,f);let _=[I.x*w,r,I.y*w],k=[M.x*w,r,M.y*w],O=[R.x*w,r,R.y*w];e.tri(_,O,k,[0,-1,0],p)}let P=b=>{if(g<=0)return b;let I=1<<g,M=[];for(let R=0;R<b.length;R++){let _=b[R],k=b[(R+1)%b.length];for(let O=0;O<I;O++){let C=O/I;M.push({x:_.x+(k.x-_.x)*C,y:_.y+(k.y-_.y)*C})}}return M},E=on(c),S=[{ring:P(c),flip:!1}];if(l)for(let b of l)b.length>=3&&S.push({ring:P(b),flip:!0});for(let{ring:b,flip:I}of S)for(let M=0;M<b.length;M++){let R=b[M],_=b[(M+1)%b.length],k=(_.x-R.x)*w,C=(_.y-R.y)*w,A=-k,v=Math.hypot(C,A)||1;C/=v,A/=v;let T=(R.x+_.x)/2-E.x,F=(R.y+_.y)/2-E.y,L=C*T+A*F;I&&(L=-L),L<0&&(C=-C,A=-A);let B=[C,0,A],N=[R.x*w,o(R),R.y*w],j=[_.x*w,o(_),_.y*w],D=[R.x*w,r,R.y*w],V=[_.x*w,r,_.y*w];e.tri(N,j,V,B,y,y,x),e.tri(N,V,D,B,y,x,x)}}function Eo(e){let t=0;for(let u of e)t+=u.count;let n=new Float32Array(t*3),o=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),s=new Float32Array(t),a=0;for(let u of e)n.set(u.position,a*3),o.set(u.normal,a*3),r.set(u.color,a*3),i.set(u.floor,a),s.set(u.material,a),a+=u.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function Pe(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=Ce(e),r=o.length,i=[];for(let a=0;a<r;a++){let u=o[a],f=o[(a+1)%r],c=f.x-u.x,l=f.y-u.y,h=Math.hypot(c,l)||1;i.push({x:l/h,y:-c/h})}let s=[];for(let a=0;a<r;a++){let u=o[a],f=i[(a-1+r)%r],c=i[a],l=f.x+c.x,h=f.y+c.y,m=Math.hypot(l,h),d=()=>{s.push([u.x+f.x*t,u.y+f.y*t]),s.push([u.x+c.x*t,u.y+c.y*t])};if(m<1e-9){d();continue}l/=m,h/=m;let p=l*f.x+h*f.y,y=1/Math.max(p,1e-6);if(!Number.isFinite(y)||y>n){d();continue}s.push([u.x+l*t*y,u.y+h*t*y])}if(s.length<3)return e;try{let a=bn.default.union([[...s,s[0]]]),u=null,f=-1/0;for(let l of a){let h=Math.abs(ye(l[0].map(([m,d])=>({x:m,y:d}))));h>f&&(f=h,u=l[0])}if(!u)return e;let c=u.map(([l,h])=>({x:l,y:h}));if(c.length>1){let l=c[0],h=c[c.length-1];Math.abs(l.x-h.x)<1e-9&&Math.abs(l.y-h.y)<1e-9&&c.pop()}return c.length>=3?c:e}catch{return e}}function He(e,t,n=2.5){if(e.length<3)return[];if(t<=0)return e;let o=Ce(e),r=o.length,i=[];for(let u=0;u<r;u++){let f=o[u],c=o[(u+1)%r],l=Math.hypot(c.x-f.x,c.y-f.y)||1;i.push({x:-(c.y-f.y)/l,y:(c.x-f.x)/l})}let s=[],a=[];for(let u=0;u<r;u++){let f=o[u],c=i[(u-1+r)%r],l=i[u],h=c.x+l.x,m=c.y+l.y,d=Math.hypot(h,m),p=d<1e-9?1/0:1/Math.max(h/d*c.x+m/d*c.y,1e-6);if(!Number.isFinite(p)||p>n){s.push({x:f.x+c.x*t,y:f.y+c.y*t},{x:f.x+l.x*t,y:f.y+l.y*t}),a.push(u,u);continue}h/=d,m/=d,s.push({x:f.x+h*t*p,y:f.y+m*t*p}),a.push(u)}for(let u=0;u<s.length;u++){let f=(u+1)%s.length,c=a[u],l=a[f];if(l!==(c+1)%r)continue;let h=o[c],m=o[l];if((s[f].x-s[u].x)*(m.x-h.x)+(s[f].y-s[u].y)*(m.y-h.y)<=0)return[]}try{let u=bn.default.intersection([[...s.map(d=>[d.x,d.y]),[s[0].x,s[0].y]]],[[...o.map(d=>[d.x,d.y]),[o[0].x,o[0].y]]]),f=null,c=0;for(let d of u){let p=Math.abs(ye(d[0].map(([y,x])=>({x:y,y:x}))));p>c&&(c=p,f=d[0])}if(!f)return[];let l=f.map(([d,p])=>({x:d,y:p})),h=l[0],m=l[l.length-1];return l.length>1&&Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&l.pop(),l.length>=3?Ce(l):[]}catch{return[]}}function Ft(e,t,n,o,r=28){let i=[];for(let s=0;s<r;s++){let a=s/r*Math.PI*2;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function bt(e,t,n,o){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+o},{x:e,y:t+o}]}var yt=3,$e=.38,xt=.24;function Ra(e){if(e.length<3)return null;let t=e[0],n=e[Math.floor(e.length/2)],o=e[e.length-1],r=(n.x-t.x)*w,i=(n.y-t.y)*w,s=(o.x-t.x)*w,a=(o.y-t.y)*w,u=2*(r*a-i*s);if(Math.abs(u)<1e-7)return null;let f=r*r+i*i,c=s*s+a*a,l=(f*a-c*i)/u+t.x*w,h=(r*c-s*f)/u+t.y*w,m=Math.hypot(t.x*w-l,t.y*w-h);return m<1||m>200||!Number.isFinite(m)||e.some(d=>Math.abs(Math.hypot(d.x*w-l,d.y*w-h)-m)>.03)?null:{x:l,z:h,radius:m}}function _o(e){let t=[],n=new Map,o=(u,f)=>`${Math.floor(u/yt)},${Math.floor(f/yt)}`;for(let u of e)for(let f of u.rows){for(let l of f.pts){let h=l.x*w,m=l.y*w,d=o(h,m),p=n.get(d)??[];p.push({x:h,z:m,y:f.y,floor:u.floorIndex}),n.set(d,p)}if(f.patch||f.pts.length<2)continue;let c=Ra(f.pts);for(let l of[0,f.pts.length-1]){let h=f.pts[l],m=f.pts[l===0?1:l-1],d=h.x-m.x,p=h.y-m.y,y=Math.hypot(d,p);y<1e-6||t.push({sectionId:u.sectionId,floorIndex:u.floorIndex,curve:c,row:f,point:h,x:h.x*w,z:h.y*w,dx:d/y,dz:p/y})}}let r=new Map;t.forEach((u,f)=>{let c=o(u.x,u.z),l=r.get(c)??[];l.push(f),r.set(c,l)});let i=(u,f)=>{let c=Math.floor(u/yt),l=Math.floor(f/yt);return[-1,0,1].flatMap(h=>[-1,0,1].map(m=>`${c+h},${l+m}`))},s=new Map;t.forEach((u,f)=>{let c=-1,l=1/0,h=!1;for(let m of i(u.x,u.z))for(let d of r.get(m)??[]){let p=t[d];if(u.sectionId===p.sectionId&&u.row.blockId===p.row.blockId||u.floorIndex!==p.floorIndex||Math.abs(u.row.y-p.row.y)>.05)continue;let y=p.x-u.x,x=p.z-u.z,g=Math.hypot(y,x);if(g<$e*2+.45||g>yt)continue;let P=u.curve&&p.curve&&Math.hypot(u.curve.x-p.curve.x,u.curve.z-p.curve.z)<=.05&&Math.abs(u.curve.radius-p.curve.radius)<=.05,E=Math.min((y*u.dx+x*u.dz)/g,(-y*p.dx-x*p.dz)/g);(P?E<.8:E<.98)||!P&&(Math.abs(y*u.dz-x*u.dx)>.15||Math.abs(y*p.dz-x*p.dx)>.15)||(g<l-.02?(c=d,l=g,h=!1):Math.abs(g-l)<=.02&&(h=!0))}c>=0&&!h&&s.set(f,c)});let a=[];for(let[u,f]of s){if(u>=f||s.get(f)!==u)continue;let c=t[u],l=t[f],h=Math.hypot(l.x-c.x,l.z-c.z),m=(l.x-c.x)/h,d=(l.z-c.z)/h,p=!1;for(let x of i((c.x+l.x)/2,(c.z+l.z)/2))for(let g of n.get(x)??[]){if(g.floor!==c.floorIndex||Math.abs(g.y-c.row.y)>.75)continue;let P=(g.x-c.x)*m+(g.z-c.z)*d,E=Math.abs((g.x-c.x)*d-(g.z-c.z)*m);P>.01&&P<h-.01&&E<xt+$e&&(p=!0)}if(p)continue;let y=(x,g)=>({x:(c.x+m*x-d*g)/w,y:(c.z+d*x+m*g)/w});a.push({sections:[c.sectionId,l.sectionId],blocks:[c.row.blockId,l.row.blockId],floorIndex:c.floorIndex,ends:[c.point,l.point],clearWidthM:h-2*$e,heightM:(c.row.y+l.row.y)/2,outline:[y($e,-xt),y(h-$e,-xt),y(h-$e,xt),y($e,xt)]})}return a}var Pa=/^#?([\da-f]{3}|[\da-f]{6})$/i;function vo(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function wa(e){let t=Pa.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function ne(e){let t=wa(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function Aa(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function te(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function we(e,t){let n=Aa(e);return te(e,[n,n,n],t)}function Co({r:e,g:t,b:n}){let o=e/255,r=t/255,i=n/255,s=Math.max(o,r,i),a=Math.min(o,r,i),u=(s+a)/2;if(s===a)return{h:0,s:0,l:u};let f=s-a,c=u>.5?f/(2-s-a):f/(s+a),l;return s===o?l=((r-i)/f+(r<i?6:0))/6:s===r?l=((i-o)/f+2)/6:l=((o-r)/f+4)/6,{h:l,s:c,l:u}}var Dt=["available","held","sold","selected","dimmed"];function ko(e){let t=Dt.indexOf(e);return t<0?0:t}var To={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var yn={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]},xn={top:[.05,.06,.08],bottom:[.1,.12,.15]};function Z(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var Ea=.15,_a=1.6;function Lo(e){return qn(e??1,Ea,_a)}var va=.15,Ca=.9,ka=1.76;function Oo(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function Ta(){return{background:{top:[...xn.top],bottom:[...xn.bottom]},sky:Oo(null),structure:yn,seatStates:{...To},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function La(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function Bo(e){let t=Ta();e??={};let n=ne(e.background);if(n){t.background={top:Z(n,Ca),bottom:Z(n,ka)},t.sky=Oo(n);let a={};for(let[f,c]of Object.entries(yn))a[f]=te(c,n,va);n[0]*.2126+n[1]*.7152+n[2]*.0722>.55&&(a.ground=Z(n,.86)),t.structure=a}let o=ne(e.selectionColor)??ne(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=Lo(r));let i=Object.fromEntries(Object.entries(e.venue3d??{}).filter(([,a])=>a!=null)),s={...La(n),...i};if(s){let a=ne(s.deck),u=ne(s.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),u&&(t.structure={...t.structure,tierWall:u,gaWall:u}),t.materials.seat=ne(s.seat),t.materials.shell=ne(s.shell),typeof s.roughness=="number"&&Number.isFinite(s.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,s.roughness)))}return t}function Fo(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}function Do(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=!1;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(i=!0,s.x<t&&(t=s.x),s.y<n&&(n=s.y),s.x>o&&(o=s.x),s.y>r&&(r=s.y));return i?{minX:t,minY:n,maxX:o,maxY:r}:null}function tt(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var Oa=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],Sm=new Map(Oa.map(e=>[e.key,e]));var Ba={wheelchair:"#3b82f6",companion:"#8b5cf6","semi-ambulatory":"#0ea5e9","designated-aisle":"#0284c7","step-free":"#16a34a",hearing:"#14b8a6",cart:"#7c3aed","sign-language":"#f59e0b","low-vision":"#d97706","sensory-friendly":"#6366f1","plus-size":"#ec4899","lift-armrest":"#22c55e"};function Nt(e){let t=e?.[0];return t&&Ba[t]||"#3b82f6"}var Fa=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],Im=new Map(Fa.map(e=>[e.key,e]));var Da=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Rm=new Set(Da);function gt(e){if(e.length<3)return e.map(i=>({...i}));let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r.map(i=>({...i})):t.map(i=>({...i}))}var fr=Te(require("polygon-clipping"),1);var Y={top:1,wallBottom:.58,bottomCap:.4};function Qe(e,t){if(!e)return t;let n=Z(we(e,.4),.62);return te(t,n,.22)}function No(e,t){return e?te(t,Z(we(e,.25),.74),.62):t}function Go(e,t){return e?te(t,Z(we(e,.08),.9),.82):t}function jo(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let o=new Map;for(let i of t){if(!i.sectionId)continue;let s=o.get(i.sectionId);s||(s=new Map,o.set(i.sectionId,s)),s.set(i.categoryKey,(s.get(i.categoryKey)??0)+1)}let r=new Map;for(let[i,s]of o){let a=0,u=0,f=0,c=0;for(let[l,h]of s){let m=ne(n.get(l));m&&(a+=m[0]*h,u+=m[1]*h,f+=m[2]*h,c+=h)}c>0&&r.set(i,[a/c,u/c,f/c])}return r}function Ho(e,t){return ne(e.color)??t.get(e.logicalSectionId??e.id)??null}var In=Te(require("polygon-clipping"),1);var Sn=Te(require("polygon-clipping"),1);var Uo=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],Vo=Uo.map(e=>e.key),Na=new Map(Uo.map(e=>[e.key,e]));function Xo(e){return typeof e=="string"&&Na.has(e)}function Yo(e,t){return Xo(e)?e:Xo(t?.seatGlyph)?t.seatGlyph:"circle"}var de={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Ga=.44,ja=.15,Ha=.3,Xa=.24;function Ko(e){return e===void 0||!Number.isFinite(e)||e<=0?Xa:Math.min(Ha,Math.max(ja,e*Ga))}var Ua=.05,Wo=.45,Va=Wo+Ua,Ya=.92;var km=[{part:de.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:de.pad,min:[-1,.36,-.95],max:[1,Wo,1]},{part:de.back,min:[-1,Va,-1],max:[1,Ya,-.72]},{part:de.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:de.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:de.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:de.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:de.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:de.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:de.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Tm=[{part:de.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:de.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:de.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:de.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:de.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function zo(e,t,n,o){let r=new Float32Array(t),i=f=>e[f*3],s=f=>e[f*3+2],a=0,u=(f,c)=>{let l=c-f;for(let h=f;h<c;h++){let[m,d]=o(h),p=m-i(h),y=d-s(h);if(l>=2){let x=Math.max(f,h-1),g=Math.min(c-1,h+1),P=i(g)-i(x),E=s(g)-s(x),S=Math.hypot(P,E);if(S>1e-6){let b=-E/S,I=P/S;b*p+I*y<0&&(b=-b,I=-I),p=b,y=I}}r[h]=p===0&&y===0?0:Math.atan2(p,y)}};for(let f=1;f<=t;f++)(f===t||n(f)!==n(a))&&(u(a,f),a=f);return r}var Gt=.22;var Ka=.42;function Wa(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let d of e)d.x<o&&(o=d.x),d.y<r&&(r=d.y),d.x>i&&(i=d.x),d.y>s&&(s=d.y);let a=Math.max(i-o,1e-6),u=Math.max(s-r,1e-6),f=Math.max(Math.sqrt(a*u/t),1e-6),c=Math.max(1,Math.ceil(a/f)+1),l=Math.max(1,Math.ceil(u/f)+1),h=new Map,m=(d,p)=>{let y=Math.min(c-1,Math.max(0,Math.floor((d-o)/f)));return Math.min(l-1,Math.max(0,Math.floor((p-r)/f)))*c+y};for(let d=0;d<t;d++){let p=m(e[d].x,e[d].y),y=h.get(p);y?y.push(d):h.set(p,[d])}for(let d=0;d<t;d++){let p=e[d],y=Math.min(c-1,Math.max(0,Math.floor((p.x-o)/f))),x=Math.min(l-1,Math.max(0,Math.floor((p.y-r)/f))),g=1/0;for(let P=1;P<=4;P++){for(let E=x-P;E<=x+P;E++)if(!(E<0||E>=l))for(let S=y-P;S<=y+P;S++){if(S<0||S>=c||P>1&&Math.abs(E-x)<P&&Math.abs(S-y)<P)continue;let b=h.get(E*c+S);if(b)for(let I of b){if(I===d)continue;let M=Math.hypot(e[I].x-p.x,e[I].y-p.y);M<g&&(g=M)}}if(Number.isFinite(g)&&g<=P*f)break}n[d]=g}return n}function za(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-ve):0}function Zo(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),u=new Float32Array(s),f=new Float32Array(s*3),c=new Float32Array(s),l=new Float32Array(s),h=new Float32Array(s),m=new Float32Array(s),d=new Float32Array(s*3),p=new Map,y=Wa(e);for(let x=0;x<s;x++){let g=e[x],E=(n?.seatPitchU(x)??y[x])*w;c[x]=Number.isFinite(E)?Math.max(.06,Math.min(Gt,E*Ka)):Gt,l[x]=Ko(Number.isFinite(E)?E:void 0);let S=Yo(g.glyph,{seatGlyph:i?.get(g.categoryKey)});h[x]=Vo.indexOf(S),m[x]=g.wheelchairSpaceType==="no-seat"?0:1,a[x*3]=g.x*w,a[x*3+1]=n?n.seatDeckY(x):za(g),a[x*3+2]=g.y*w,u[x]=ko(t?t(g):"available");let b=ne(r?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(f[x*3]=b[0],f[x*3+1]=b[1],f[x*3+2]=b[2],g.accessibility?.length){let I=ne(Nt(g.accessibility));I&&(d[x*3]=I[0],d[x*3+1]=I[1],d[x*3+2]=I[2])}p.set(g.id,x)}return{count:s,iPosition:a,iState:u,iCategory:f,iMaxRadius:c,iRing:d,idToIndex:p,iChairWidth:l,iGlyph:h,iPhysicalSeat:m,iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}var Jo=Te(require("earcut"),1);var Za=.58,$o=.01,Re=Gt*1.5*Ie,$a=.5,Qa=.6;function qa(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],u=e[Math.min(n-1,s+1)],f=u.x-a.x,c=u.y-a.y,l=Math.hypot(f,c);if(l<1e-9){o.push([0,0]);continue}f/=l,c/=l,o.push([-c,f])}let r=0;for(let s=0;s<n;s++)r+=(e[s].x-t.x)*o[s][0]+(e[s].y-t.y)*o[s][1];return r<0?o.map(([s,a])=>[-s,-a]):o}function Ja(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let u=a.x-s.x,f=a.y-s.y,c=Math.hypot(u,f)||1;return{x:u/c,y:f/c}},r=o(n[1],n[0]),i=o(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+r.x*t,y:n[0].y+r.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var Qo=Math.PI/12;function ec(e){if(e.length<3)return[...e];let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r:[...e]}function er(e,t){if(!e.length||!(t>0))return[];let n=ec(e),o=(a,u,f,c)=>{let l=f-u;for(;l<0;)l+=Math.PI*2;for(;l>Math.PI*2;)l-=Math.PI*2;let h=Math.max(1,Math.ceil(l/Qo)),m=t/Math.cos(l/h/2);for(let d=0;d<=h;d++){let p=u+l*d/h;c.push({x:a.x+Math.cos(p)*m,y:a.y+Math.sin(p)*m})}};if(n.length<3){let a=0,u=0;for(let m of n)a+=m.x,u+=m.y;a/=n.length||1,u/=n.length||1;let f=0;for(let m of n)f=Math.max(f,Math.hypot(m.x-a,m.y-u));let c=[],l=Math.max(3,Math.ceil(Math.PI*2/Qo)),h=(f+t)/Math.cos(Math.PI/l);for(let m=0;m<l;m++){let d=m/l*Math.PI*2;c.push({x:a+Math.cos(d)*h,y:u+Math.sin(d)*h})}return c}let r=n.length,i=[];for(let a=0;a<r;a++){let u=n[a],f=n[(a+1)%r];i.push(Math.atan2(-(f.x-u.x),f.y-u.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return ir(s)}function tc(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,u=s.y-i.y,f=a*a+u*u,c=f>1e-12?((t-i.x)*a+(n-i.y)*u)/f:0;c<0?c=0:c>1&&(c=1);let l=Math.hypot(t-(i.x+c*a),n-(i.y+c*u));l<o&&(o=l)}return o}function jt(e){let t=e.map(r=>{let i=0,s=0;for(let f of r.pts)i+=f.x,s+=f.y;let a=r.pts.length||1;i/=a,s/=a;let u=0;for(let f of r.pts){let c=Math.hypot(f.x-i,f.y-s);c>u&&(u=c)}return{cx:i,cy:s,rad:u}}),n=r=>{let i=r.length;return i<=2?[...r]:[r[Math.floor(i*.25)],r[Math.floor(i*.5)],r[Math.floor(i*.75)]]},o=[];for(let r=0;r<e.length;r++){let i=n(e[r].pts),s=[],a=1/0,u=null;for(let c of i){let l=1/0;for(let h=0;h<e.length;h++){if(h===r||Math.abs(e[h].y-e[r].y)<.001)continue;let m=t[h],d=Math.hypot(c.x-m.cx,c.y-m.cy)-m.rad;if(d>=l&&d>=a)continue;let p=tc(e[h].pts,c.x,c.y);p<l&&(l=p),e[h].depth<e[r].depth&&p<a&&(a=p,u=e[h].y)}Number.isFinite(l)&&l>0&&s.push(l)}s.sort((c,l)=>c-l);let f=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:f,belowY:u})}return o}function tr(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let c=r.pts[0],l=c.x-o.x,h=c.y-o.y,m=Math.hypot(l,h)||1;l/=m,h/=m;let d=Math.max(n[t].pitch,.001)*.5;return[{x:c.x+h*d,y:c.y-l*d},{x:c.x-h*d,y:c.y+l*d}]})():[];if(i.length<2)return null;let s=0,a=0;for(let c=1;c<i.length;c++){let l=Math.hypot(i[c].x-i[c-1].x,i[c].y-i[c-1].y);l>1e-6&&(s+=l,a++)}let u=a>0?s/a:0,f=Ja(i,Math.max(u*Qa,Re));return{pts:f,nrm:qa(f,o),front:Math.max(n[t].pitch*Za,Re),back:Math.max(n[t].pitch*$a,Re)}}var nt=1.5,nr=.3;function gn(e,t){if(e.length<3)return e;let n=e[0],o=e[e.length-1],r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i),a=-1,u=-1;for(let l=1;l<e.length-1;l++){let h=e[l],m=s>1e-12?Math.abs((h.x-n.x)*i-(h.y-n.y)*r)/s:Math.hypot(h.x-n.x,h.y-n.y);m>a&&(a=m,u=l)}if(a<=t||u<0)return[n,o];let f=gn(e.slice(0,u+1),t),c=gn(e.slice(u),t);return[...f.slice(0,-1),...c]}function or(e,t){if(e.length<4)return e;let n=gn([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function nc(e){let t=e.map((o,r)=>{let i=e[(r+1)%e.length];return{a:o,b:i,i:r,minX:Math.min(o.x,i.x),maxX:Math.max(o.x,i.x),minY:Math.min(o.y,i.y),maxY:Math.max(o.y,i.y)}}).sort((o,r)=>o.minX-r.minX),n=(o,r,i)=>(r.x-o.x)*(i.y-o.y)-(r.y-o.y)*(i.x-o.x);for(let o=0;o<t.length;o++){let r=t[o];for(let i=o+1;i<t.length&&t[i].minX<=r.maxX;i++){let s=t[i];if(!(Math.abs(r.i-s.i)===1||Math.abs(r.i-s.i)===e.length-1||r.maxY<s.minY||s.maxY<r.minY)&&n(r.a,r.b,s.a)*n(r.a,r.b,s.b)<=0&&n(s.a,s.b,r.a)*n(s.a,s.b,r.b)<=0)return!0}}return!1}function rr(e,t,n){if(e.length<2)return[];let o=n??jt(e),r=new Map;for(let s=0;s<e.length;s++){let a=r.get(e[s].blockId);a?a.push(s):r.set(e[s].blockId,[s])}let i=[];for(let[,s]of r){let a=[];for(let g of s){let P=e[g].patch;P&&P.length>=3?i.push({outline:[...P],holes:[],topY:e[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,P)=>e[g].depth-e[P].depth);let f=a.map(g=>tr(e,g,o,t)).filter(g=>g!==null);if(!f.length)continue;let c=(g,P)=>({x:g.pts[P].x-g.nrm[P][0]*(g.front+nt),y:g.pts[P].y-g.nrm[P][1]*(g.front+nt)}),l=(g,P)=>({x:g.pts[P].x+g.nrm[P][0]*(g.back+nt),y:g.pts[P].y+g.nrm[P][1]*(g.back+nt)}),h=f[0],m=f[f.length-1],d=[];for(let g=0;g<h.pts.length;g++)d.push(c(h,g));for(let g of f)d.push(l(g,g.pts.length-1));for(let g=m.pts.length-1;g>=0;g--)d.push(l(m,g));for(let g=f.length-1;g>=0;g--)d.push(c(f[g],0));let p=ir(d),y=1/0;for(let g of a)e[g].y<y&&(y=e[g].y);if(!Number.isFinite(y))continue;if(p.length>=3&&Math.abs(ye(p))>1e-6&&f.every(g=>{let P=g.pts[Math.floor(g.pts.length/2)];return xe(p,P.x,P.y)})&&!nc(p)){i.push({outline:or(p,nr),holes:[],topY:y});continue}for(let g of oc(f))i.push({outline:g,holes:[],topY:y})}return i}function oc(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+nt,s=n.back+nt;for(let u=0;u<n.pts.length;u++){let f=n.pts[u],c=n.nrm[u];o.push([f.x-c[0]*i,f.y-c[1]*i]),r.push([f.x+c[0]*s,f.y+c[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=Sn.default.union(t[0],...t.slice(1)),o=[];for(let r of n){if(!r.length||r[0].length<4)continue;let i=r[0].map(([u,f])=>({x:u,y:f})),s=i[0],a=i[i.length-1];i.length>1&&Math.abs(s.x-a.x)<1e-9&&Math.abs(s.y-a.y)<1e-9&&i.pop(),i.length>=3&&o.push(or(i,nr))}return o}catch{return[]}}function ir(e){let t=[];for(let n of e){let o=t[t.length-1];o&&Math.hypot(n.x-o.x,n.y-o.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var Mn=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let o of n)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let o=!0;for(let r of t)if(!xe(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function qo(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let f=[0,1,0],c=o[0];for(let l=1;l+1<o.length;l++){let h=o[l],m=o[l+1];e.tri([c.x*w,r,c.y*w],[h.x*w,r,h.y*w],[m.x*w,r,m.y*w],f,i)}return}let s=o.map(f=>[f.x,f.y]);s.push(s[0]);let a;try{a=Sn.default.intersection([s],t)}catch{return}let u=[0,1,0];for(let f of a){if(!f.length||f[0].length<4)continue;let c=f[0],l=[],h=[];for(let d=0;d<c.length-1;d++)l.push(c[d][0],c[d][1]),h.push([c[d][0],c[d][1]]);if(h.length<3)continue;let m=(0,Jo.default)(l,void 0,2);for(let d=0;d<m.length;d+=3){let p=h[m[d]],y=h[m[d+1]],x=h[m[d+2]];e.tri([p[0]*w,r,p[1]*w],[y[0]*w,r,y[1]*w],[x[0]*w,r,x[1]*w],u,i)}}}function sr(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??jt(t),u=[0,1,0],f=i&&i.length>=3?[[...i.map(m=>[m.x,m.y]),[i[0].x,i[0].y]]]:null,c=i&&i.length>=3?new Mn([[...i]]):null,l=m=>{e.setMaterial(2),m(),e.setMaterial(0)},h=m=>{e.setMaterial(3),m(),e.setMaterial(0)};for(let m=0;m<t.length;m++){let d=t[m];if(d.patch&&d.patch.length>=3){let S=[...d.patch],b=a[m].belowY??o;if(h(()=>{if(f&&c)qo(e,f,c,S,d.y,r.tread);else{let I=S[0];for(let M=1;M+1<S.length;M++){let R=S[M],_=S[M+1];e.tri([I.x*w,d.y,I.y*w],[R.x*w,d.y,R.y*w],[_.x*w,d.y,_.y*w],u,r.tread)}}}),d.y>b+$o){let I=0,M=0;for(let R of S)I+=R.x,M+=R.y;I/=S.length,M/=S.length,l(()=>{for(let R=0;R<S.length;R++){let _=S[R],k=S[(R+1)%S.length],O=k.x-_.x,C=k.y-_.y,A=Math.hypot(O,C);if(A<1e-6)continue;let v=C/A,T=-O/A;(_.x-I)*v+(_.y-M)*T<0&&(v=-v,T=-T);let F=[v,0,T],L=[_.x*w,d.y,_.y*w],B=[k.x*w,d.y,k.y*w],N=[_.x*w,b,_.y*w],j=[k.x*w,b,k.y*w];e.tri(L,B,j,F,r.riser),e.tri(L,j,N,F,r.riser)}})}continue}let p=tr(t,m,a,n);if(!p)continue;let{pts:y,nrm:x,front:g,back:P}=p,E=a[m].belowY??o;for(let S=0;S+1<y.length;S++){let b=y[S],I=y[S+1],M=x[S],R=x[S+1];if(Math.hypot(I.x-b.x,I.y-b.y)<1e-6||M[0]===0&&M[1]===0||R[0]===0&&R[1]===0)continue;let _=[(b.x-M[0]*g)*w,d.y,(b.y-M[1]*g)*w],k=[(I.x-R[0]*g)*w,d.y,(I.y-R[1]*g)*w],O=[(b.x+M[0]*P)*w,d.y,(b.y+M[1]*P)*w],C=[(I.x+R[0]*P)*w,d.y,(I.y+R[1]*P)*w];if(h(()=>{f&&c?qo(e,f,c,[{x:b.x-M[0]*g,y:b.y-M[1]*g},{x:I.x-R[0]*g,y:I.y-R[1]*g},{x:I.x+R[0]*P,y:I.y+R[1]*P},{x:b.x+M[0]*P,y:b.y+M[1]*P}],d.y,r.tread):(e.tri(_,k,C,u,r.tread),e.tri(_,C,O,u,r.tread))}),d.y>E+$o){let A=[_[0],E,_[2]],v=[k[0],E,k[2]],T=[-M[0],0,-M[1]];l(()=>{e.tri(_,k,v,T,r.riser),e.tri(_,v,A,T,r.riser)})}}}}function rc(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function ar(e,t){return e.filter(n=>n.type!=="shape"||rc(n,t))}function cr(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:ar(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:ar(e.objects,t),focal:n,baseHeightM:0,index:0}]}var ic={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Oe(e){return Do(e)??ic}function lr(e,t){let n=Pe(e.outline,Re),o=Oe(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&tt(o,Oe(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(u=>[u.x,u.y]);return a.push(a[0]),a};try{let s=In.default.difference([i(n)],...r.map(u=>[i(u.outline)])),a=[];for(let u of s){if(!u.length)continue;let f=u[0].map(([c,l])=>({x:c,y:l}));if(f.length>1){let c=f[0],l=f[f.length-1];Math.abs(c.x-l.x)<1e-9&&Math.abs(c.y-l.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a.length?a:[n]}catch{return[n]}}function ur(e,t){if(!t.length)return e;let n=i=>{let s=i.map(a=>[a.x,a.y]);return s.push(s[0]),s},o=t.map(i=>[n(i)]),r=[];for(let i of e){let s;try{s=In.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let u=a[0].map(([f,c])=>({x:f,y:c}));if(u.length>1){let f=u[0],c=u[u.length-1];Math.abs(f.x-c.x)<1e-9&&Math.abs(f.y-c.y)<1e-9&&u.pop()}u.length>=3&&r.push({outline:u,holes:[],topY:i.topY})}}return r.length?r:e}function sc(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var Ht=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(u=>[u.x,u.y]);if(o.length<3)return[];o.push(o[0]);let r=Oe(t),i=this.rings.filter((u,f)=>tt(r,this.boxes[f])&&sc(n,this.levels[f])),s=[[o]];if(i.length)try{s=fr.default.difference([o],...i).map(f=>f.map(c=>c.map(([l,h])=>[l,h])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let u of s){if(!u.length)continue;let f=u[0].map(([c,l])=>({x:c,y:l}));if(f.length>1){let c=f[0],l=f[f.length-1];Math.abs(c.x-l.x)<1e-9&&Math.abs(c.y-l.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a}};function Xt(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,i=-1/0;for(let l of e)n=Math.min(n,l.x),o=Math.max(o,l.x),r=Math.min(r,l.y),i=Math.max(i,l.y);let s=(n+o)/2,a=(r+i)/2,u=t*Math.PI/180,f=Math.cos(u),c=Math.sin(u);return e.map(l=>{let h=l.x-s,m=l.y-a;return{x:s+h*f-m*c,y:a+h*c+m*f}})}function ie(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=bt(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,o=(e.y??0)+e.height/2;t=Ft(n,o,e.width/2,e.height/2)}return t?Xt(t,e.rotation):null}function Ae(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},o=t==="stage"&&ft(e.stageKind)?{kind:"stage",heightM:e.stageKind==="ring-boxing"?vt:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var ac=.08,cc=30,lc=.015;function uc(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function mr(e,t){let n=ie(e)??(e.points?.length?Xt(e.points,e.rotation):null),o=Ae(e),i=!e.role&&o.kind==="plate"&&e.heightM===void 0&&!!n&&Math.abs(ye(n))*$**2>=cc?lc:o.heightM;if(!n)return{topOffsetM:i,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:i,supportOffsetM:0};let s=1/0,a=1/0,u=-1/0,f=-1/0;for(let m of n)s=Math.min(s,m.x),a=Math.min(a,m.y),u=Math.max(u,m.x),f=Math.max(f,m.y);let c=i,l=0,h=1e-6*Math.max(1,u-s,f-a);for(let m of t)u>m.minX&&s<m.maxX&&f>m.minY&&a<m.maxY&&c<=m.topOffsetM+1e-6&&(c=m.topOffsetM+ac),s>=m.minX-h&&u<=m.maxX+h&&a>=m.minY-h&&f<=m.maxY+h&&(!m.poly||n.every(y=>uc(y,m.poly)||fc(y,m.poly,h)))&&(l=Math.max(l,m.topOffsetM));return e.fill&&e.fill!=="none"&&e.fill!=="transparent"&&t.push({minX:s,minY:a,maxX:u,maxY:f,topOffsetM:c,poly:n}),{topOffsetM:c,supportOffsetM:Math.min(l,c)}}function fc(e,t,n){for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,u=s.y-i.y,f=a*a+u*u,c=f?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*u)/f)):0;if(Math.hypot(e.x-(i.x+c*a),e.y-(i.y+c*u))<=n)return!0}return!1}function Xe(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function ge(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function pe(e,t,n){return[Xe(e[0],e[1],t),Xe(e[0],e[1],n),Xe(e[3],e[2],n),Xe(e[3],e[2],t)]}function Mt(e,t,n){return[Xe(e[0],e[3],t),Xe(e[1],e[2],t),Xe(e[1],e[2],n),Xe(e[0],e[3],n)]}function ee(e,t,n,o,r,i){z(e,t,void 0,()=>n,o,r,i,Y)}var mc=.8,hc=.6,dc=2;function ot(e,t){if(!t.length)return null;let n=[],o=0;for(let s of e.objects){if(s.type!=="shape"||s.role!=="wall")continue;let a=ie(s)??[],u=hr(a)/2;!(u>0)||yc(a)/u*w>dc||(n.push(...a),o+=u)}if(n.length<3)return null;let r=gt(n);if(r.length<3||o<hr(r)*hc)return null;let i=0;for(let s of t)xc(s,r)&&(i+=1);return i>=t.length*mc?r:null}var dr=6,pc=5,bc=8;function pr(e){return Math.max(bc,(Number.isFinite(e)?e:0)+pc)}function br(e){let t=0,n=0,o=0;for(let r=0;r<e.length;r++){let i=e[r],s=e[(r+1)%e.length],a=i.x*s.y-s.x*i.y;t+=a,n+=(i.x+s.x)*a,o+=(i.y+s.y)*a}if(Math.abs(t)<1e-9){let r=0,i=0;for(let s of e)r+=s.x,i+=s.y;return{x:r/Math.max(1,e.length),y:i/Math.max(1,e.length)}}return{x:n/(3*t),y:o/(3*t)}}function yc(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2}function hr(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=Math.hypot(r.x-o.x,r.y-o.y)}return t}function xc(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function gc(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let o=t-e.x,r=n-e.y,i=Math.hypot(o,r);return i<1e-9?[0,0]:[o/i,r/i]}}}function Mc(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let m of e)n+=m.x,o+=m.y,r+=Math.hypot(m.x-t.x,m.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let m of e){let d=Math.hypot(m.x-n,m.y-o);d>a&&(a=d,s=m)}let u=s.x-n,f=s.y-o,c=Math.hypot(u,f);c>1e-9?(u/=c,f/=c):(u=1,f=0);let l=[...e].sort((m,d)=>(m.x-n)*u+(m.y-o)*f-((d.x-n)*u+(d.y-o)*f)),h=0;for(let m of l){let d=Math.hypot(m.x-n,m.y-o);d>h&&(h=d)}return{pts:l,cx:n,cy:o,radius:h,depth:r}}function yr(e,t,n){let o=e.pts;if(o.length===1)return Math.hypot(t-o[0].x,n-o[0].y);let r=1/0;for(let i=0;i+1<o.length;i++){let s=o[i],a=o[i+1],u=a.x-s.x,f=a.y-s.y,c=u*u+f*f,l=c>1e-12?((t-s.x)*u+(n-s.y)*f)/c:0;l<0?l=0:l>1&&(l=1);let h=Math.hypot(t-(s.x+l*u),n-(s.y+l*f));h<r&&(r=h)}return r}var Ut=8;function Sc(e,t,n){let o=new Array(Ut).fill(1/0),r=new Array(Ut).fill(-1);for(let c=0;c<e.length;c++){let l=e[c],h=Math.hypot(t-l.cx,n-l.cy)-l.radius;for(let m=0;m<Ut;m++)if(h<o[m]){for(let d=Ut-1;d>m;d--)o[d]=o[d-1],r[d]=r[d-1];o[m]=h,r[m]=c;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let c of r){if(c<0)continue;let l=yr(e[c],t,n);for(let h=0;h<3;h++)if(l<i[h]){for(let m=2;m>h;m--)i[m]=i[m-1],s[m]=s[m-1];i[h]=l,s[h]=c;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,u=0,f=0;for(let c=0;c<3;c++){let l=s[c];if(l<0||i[c]>a)continue;let h=1/(i[c]*i[c]);u+=h*e[l].depth,f+=h}return f>0?u/f:e[s[0]].depth}function Ic(e){let t=(o,r)=>Sc(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let u=e[a];if(Math.hypot(o-u.cx,r-u.cy)-u.radius>=i)continue;let f=yr(u,o,r);f<i&&(i=f,s=a)}return s};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(o,r)=>{let i=(t(o+.5,r)-t(o-.5,r))/1,s=(t(o,r+.5)-t(o,r-.5))/(2*.5),a=Math.hypot(i,s);return a<1e-9?[0,0]:[i/a,s/a]}}}function xr(e,t){let n=[];for(let o of e){let r=Mc(o.points,t);r&&n.push(r)}return n.length<2?gc(t):(n.sort((o,r)=>o.depth-r.depth),Ic(n))}var Ue=.06,Rc=.05,Mr=.05,gr=.15,Rn=25;function Sr(e,t,n){let o=new Map,r=new Array(t.length).fill(null),i=new Float64Array(t.length),s=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),u=new Map,f=[],c=new Set;for(let h=0;h<e.length;h+=1){let m=e[h];for(let d of m.objects){if(d.type==="table"&&c.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let p=Pe(d.outline,Re);u.set(d.id,{section:d,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),f.push({id:d.id,floorIndex:h,box:Oe(p),section:d,unit:m,outline:p})}}let l=new Map;for(let h of f){let m=l.get(h.floorIndex);m?m.push(h):l.set(h.floorIndex,[h])}for(let h=0;h<t.length;h++){let m=t[h],d=n?l.get(n[h])??[]:f,p=m.sectionId?d.find(x=>x.id===m.sectionId)??d.find(x=>x.section.logicalSectionId===m.sectionId&&be({x:m.x,y:m.y},x.outline,x.section.holes)):void 0,y=p?[p]:d;for(let x of y){if(n&&x.floorIndex!==n[h]||!p&&(m.x<x.box.minX||m.x>x.box.maxX||m.y<x.box.minY||m.y>x.box.maxY||!be({x:m.x,y:m.y},x.outline,x.section.holes)))continue;r[h]=x.id;let g=u.get(x.id);g.hasSeats=!0;let P=m.focalPoint??x.unit.focal,E=Math.hypot(m.x-P.x,m.y-P.y);E<g.frontU&&(g.frontU=E),g.seatIndices.push(h);let S=m.rowId||`__seat-${h}`,b=g.rows.get(S);b?b.push({x:m.x,y:m.y}):g.rows.set(S,[{x:m.x,y:m.y}]);break}}for(let[h,m]of u){let d=Ge(m.section,{floorBaseHeightM:m.unit.baseHeightM}),p=m.unit.baseHeightM,y=d.rake>0?Math.tan(d.rake*Math.PI/180):0,x=d.rake<=.01&&d.height<=p+.001,g=m.section.surfaceKind,P=g==="flat"?!0:g==="rakedRows"&&d.rake>.01?!1:x,E=m.hasSeats?Et(h,t,m.seatIndices,m.unit.focal):{sectionId:h,rows:[],blockCount:0},b=E.rows.length<2?xr([...m.rows.values()].map(L=>({points:L})),m.unit.focal):null,I=1/0;if(b){if(m.hasSeats)for(let L of m.rows.values())for(let B of L){let N=b.depthAt(B.x,B.y);N<I&&(I=N)}if(!m.hasSeats||!Number.isFinite(I)){I=1/0;for(let L of m.section.outline){let B=b.depthAt(L.x,L.y);B<I&&(I=B)}}}let M=p+Rc,R=Math.max(M,d.height),_=L=>{let B=Math.max(0,L-I)*$,N=Math.min(B*y,Rn);return Math.max(M,d.height+N)},k=L=>{let B=Math.max(0,L)*$,N=Math.min(B*y,Rn);return Math.max(M,d.height+N)},O=P?[]:E.rows.map(L=>({pts:L.pts,y:k(L.blockDepth),depth:L.blockDepth,blockId:L.blockId,...c.has(L.id)?{patch:er(L.pts,Re)}:{}})),C=O.length?O[0].y:R,A=O.map(L=>{let B=L.patch&&L.patch.length>=3?L.patch:L.pts,N=0,j=0;for(let X of B)N+=X.x,j+=X.y;let D=B.length||1;N/=D,j/=D;let V=0;for(let X of B){let W=Math.hypot(X.x-N,X.y-j);W>V&&(V=W)}return{cx:N,cy:j,rad:V}}),v=P?()=>R:O.length>=2?(L,B)=>{let N=1/0,j=C;for(let D=0;D<O.length;D++){let V=A[D];if(Math.hypot(L-V.cx,B-V.cy)-V.rad>=N)continue;let X=O[D].patch,W=X&&X.length>=3?xe(X,L,B)?0:qe(X,L,B):qe(O[D].pts,L,B);W<N&&(N=W,j=O[D].y)}return j}:(L,B)=>b?_(b.depthAt(L,B)):R,T=[0,1,0],F=O.length>=2||P?()=>T:(L,B)=>{if(!b)return T;let N=b.depthAt(L,B);if(N<=I)return T;let j=(N-I)*$;if(j*y>=Rn||d.height+j*y<=M)return T;let[D,V]=b.gradientAt(L,B);if(D===0&&V===0)return T;let X=1/Math.hypot(y,1);return[-D*y*X,X,-V*y*X]};if(!P)for(let L of E.rows){let B=k(L.blockDepth);for(let N of L.seatIndices)s[N]=B}for(let L of E.rows){let B=[];for(let X=1;X<L.pts.length;X++){let W=Math.hypot(L.pts[X].x-L.pts[X-1].x,L.pts[X].y-L.pts[X-1].y);W>1e-6&&B.push(W)}B.sort((X,W)=>X-W);let N=B.length?B[Math.floor(B.length/2)]:1/0,j=1/0,D=L.pts[Math.floor(L.pts.length/2)];if(D)for(let X of E.rows){if(X===L||X.blockId!==L.blockId)continue;let W=qe(X.pts,D.x,D.y);W>1e-6&&W<j&&(j=W)}let V=Math.min(N,Math.max(j,N*.5));if(Number.isFinite(V)&&V>0)for(let X of L.seatIndices)a[X]=V}o.set(h,{sectionId:h,deckAt:v,normalAt:F,flat:P,bottomY:p,rowLevels:O,landingY:C})}for(let h=0;h<t.length;h++){let m=r[h],d=t[h];if(m){let x=s[h];i[h]=(x??o.get(m).deckAt(d.x,d.y))+gr;continue}let p=d.eyeHeightM,y=Number.isFinite(p)?Math.max(0,p-ve):0;i[h]=d.kind==="booth"?y+Ue+gr:y}return{bySection:o,seatOwner:r,seatDeckY:h=>i[h],seatPitchU:h=>a[h]}}function rt(e,t,n){if(e.length!==4||n<=t)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*w,i=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*w;if(r<1e-6||i<1e-6)return null;let s=Math.min(.22/r,.16),a=Math.min(.28,(n-t)*.13),u=Math.min(.065/i,.2);return{quad:o,side:s,face:u,opening:pe(o,s,1-s),openingTop:n-a}}function Pn(e,t,n){if(e.length!==4||n-t<=.2)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*w;if(r<=1e-6)return null;let i=Math.min(.14,(n-t)*.08,r*.08),s=i/r,a=pe(o,s,1-s);return{quad:o,side:s,trim:i,inner:a,panel:Mt(a,.15,.85),bottom:t+i,top:n-i}}function Ir(e,t,n,o){let r=Pn(e,t,n);if(!r)return;let{panel:i}=r,s=(g,P)=>({x:(g.x+P.x)/2,y:(g.y+P.y)/2}),a=s(i[0],i[1]),u=s(i[3],i[2]),f=Math.hypot(a.x-o.x,a.y-o.y)<=Math.hypot(u.x-o.x,u.y-o.y),[c,l]=f?[i[0],i[1]]:[i[3],i[2]],h=f?{x:a.x-u.x,y:a.y-u.y}:{x:u.x-a.x,y:u.y-a.y},m=Math.hypot(h.x,h.y);if(m<1e-6)return;-(l.y-c.y)*h.x+(l.x-c.x)*h.y<0&&([c,l]=[l,c]);let d=Math.min(.006,m*w*.05),p=h.x/m*d,y=h.y/m*d,x=(g,P)=>[g.x*w+p,P,g.y*w+y];return[x(c,r.bottom),x(l,r.bottom),x(c,r.top),x(l,r.top)]}var Rr=Te(require("polygon-clipping"),1);function Be(e,t,n,o,r,i,s,a={}){let u=Oe(t),f=a.ao??Y,c=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let y=ie(p);if(!y||y.length!==4||!tt(u,Oe(y)))return[];let x=a.portalBase??n,g=rt(y,x,x+Ae(p).heightM);if(!g)return[];let P=Math.min(o,g.openingTop);return P<=n?[]:[{poly:g.opening,height:P}]});if(!c.length)return!1;let l=p=>p.map(y=>[y.x,y.y]),h=[l(t),...(a.holes??[]).map(l)],m=[n,...new Set(c.map(p=>p.height)),o].sort((p,y)=>p-y),d=[];try{for(let p=1;p<m.length;p++){let y=m[p-1],x=m[p];if(x-y<1e-6)continue;let g=c.filter(E=>E.height>y+1e-6).map(E=>[l(E.poly)]),P=g.length?Rr.default.difference(h,...g):[h];d.push({low:y,high:x,polys:P})}}catch{return!1}for(let p of d)for(let y of p.polys){let[x,...g]=y.map(E=>E.map(([S,b])=>({x:S,y:b}))),P=E=>f.wallBottom+(f.top-f.wallBottom)*(E-n)/(o-n);z(e,x,g,()=>p.high,p.low,i,s,{...f,top:P(p.high),wallBottom:P(p.low)})}return!0}function Pr(e,t,n,o,r,i,s){let a=o-n;if(a<=0)return;let u=a<1.5?[[n,o,1]]:[[n,n+Math.min(.9,a*.18),.82],[n+Math.min(.9,a*.18),o-.1,1],[o-.1,o,1.1]],f=c=>Y.wallBottom+(Y.top-Y.wallBottom)*(c-n)/a;for(let[c,l,h]of u){let m={...Y,top:f(l),wallBottom:f(c)},d=Z(i,h),p=Z(s,h);Be(e,t,c,l,r,d,p,{portalBase:n,ao:m})||z(e,t,void 0,()=>l,c,d,p,m)}}function St(e,t,n){let o=ne(t.stroke?.color),r=t.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let i=t.kind==="line"||t.kind==="polyline",s=i?Xt(t.points??[],t.rotation):ie(t);if(!s||s.length<2)return;let a=i?s.length-1:s.length,u=r*.5;for(let f=0;f<a;f++){let c=s[f],l=s[(f+1)%s.length],h=Math.hypot(l.x-c.x,l.y-c.y);if(h<1e-6)continue;let m=-(l.y-c.y)/h*u,d=(l.x-c.x)/h*u,p=[(c.x+m)*w,n,(c.y+d)*w],y=[(l.x+m)*w,n,(l.y+d)*w],x=[(l.x-m)*w,n,(l.y-d)*w],g=[(c.x-m)*w,n,(c.y-d)*w];e.tri(p,y,x,[0,1,0],o),e.tri(p,x,g,[0,1,0],o)}}function wr(e){return e==="bar"||e==="concession"||e==="coat"||e==="restroom"}var it=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function Vt(e,t,n,o){let[r,i,s,a]=t?e:[e[3],e[2],e[1],e[0]];return[it(r,a,n),it(i,s,n),it(i,s,o),it(r,a,o)]}function Ar(e,t,n,o,r,i,s,a,u=!1){if(n.length!==4||r-o<.4)return!1;let f=M=>u?Math.min(M,r):M,c=ge(n),l=Math.hypot(c[3].x-c[0].x,c[3].y-c[0].y)*w;if(l<.4)return!1;let h=it(c[0],c[1],.5),m=it(c[3],c[2],.5),d=Math.hypot(h.x-a.x,h.y-a.y)<=Math.hypot(m.x-a.x,m.y-a.y),p=te(s,[.92,.9,.86],.35),y=Z(i,.72),x=r-o;if(t==="restroom"){let M=Math.min(.18,x*.08);return ee(e,c,r-M,o,s,i),ee(e,c,r,r-M,p,p),!0}let g=o+Math.min(1.1,x),P=t==="coat"?1:Math.min(.5,.75/l),E=Vt(c,d,0,P);if(ee(e,E,g-.05,o,y,i),ee(e,E,g,g-.05,p,p),t==="coat"||l<1.2)return!0;if(t==="bar"){let M=Vt(c,d,Math.max(P+.2,1-.45/l),1),R=f(o+Math.max(Math.min(2.2,x*2),g-o+.6));return ee(e,M,R,o,s,y),!0}let S=Vt(c,d,Math.max(P+.25,.55),1),b=f(o+Math.max(2.6,g-o+1.4));if(b-.14<=g)return!0;ee(e,S,b-.14,o,s,i),ee(e,c,b,b-.14,p,y);let I=Math.min(.08,.1/Math.max(.1,Math.hypot(c[1].x-c[0].x,c[1].y-c[0].y)*w));for(let[M,R]of[[0,I],[1-I,1]])ee(e,Vt(pe(c,M,R),d,0,Math.min(.08,.1/l)),b-.14,g,y,y);return!0}var Pc=[.12,.38,.16],wc=[.72,.62,.45],Ac=[.88,.93,.96],Er=[.95,.95,.94],Ec=[.66,.29,.22],wn={length:20.12,width:3.05},_c=.14,vc=9.76,Fe=[.93,.94,.95],Yt=[.1,.11,.13],Cc=[.45,.85,1.25],kc=1.45,_r=.012,vr=.004,Tc=1.07,Lc=.15;function at(e,t,n,o,r,i){e.setMaterial(i),z(e,t,n?[n.slice().reverse()]:void 0,()=>o,o-.004,r,r,Y)}var Cr=(e,t)=>He(e,t/w);function kr(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<1e-9)return null;let s=-r/i*n,a=o/i*n;return[{x:e.x+s,y:e.y+a},{x:t.x+s,y:t.y+a},{x:t.x-s,y:t.y-a},{x:e.x-s,y:e.y-a}]}function Oc(e,t,n,o){let r=t.map(i=>[i.x*w,n,i.y*w]);e.tri(r[0],r[1],r[2],[0,1,0],o),e.tri(r[0],r[2],r[3],[0,1,0],o)}function Kt(e,t,n,o,r,i){let s=n/w,a=[{x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s},{x:t.x-s,y:t.y+s}];z(e,a,void 0,()=>r,o,i,Z(i,.85),Y)}function st(e,t,n,o,r,i,s){let a=kr(t,n,o/w);a&&z(e,a,void 0,()=>i,r,s,Z(s,.85),Y)}function Wt(e){let t=ge(e),n={x:(t[0].x+t[2].x)/2,y:(t[0].y+t[2].y)/2},o=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y)||1,r=Math.hypot(t[3].x-t[0].x,t[3].y-t[0].y)||1,i={x:(t[1].x-t[0].x)/o,y:(t[1].y-t[0].y)/o},s={x:(t[3].x-t[0].x)/r,y:(t[3].y-t[0].y)/r};return{at:(u,f)=>({x:n.x+(i.x*u+s.x*f)/w,y:n.y+(i.y*u+s.y*f)/w}),lengthM:o*w,widthM:r*w}}function Tr(e,t,n){let o=co(t);if(!o.length)return;let r=1/0,i=-1/0,s=1/0,a=-1/0;for(let P of t.points??[])r=Math.min(r,P.x),i=Math.max(i,P.x),s=Math.min(s,P.y),a=Math.max(a,P.y);let u=(t.rotation??0)*Math.PI/180,f=Math.cos(u),c=Math.sin(u),l=(r+i)/2,h=(s+a)/2,m=P=>u?{x:l+(P.x-l)*f-(P.y-h)*c,y:h+(P.x-l)*c+(P.y-h)*f}:P,d=Math.min(i-r,a-s)*w,p=Math.max(.04,Math.min(.3,d*.004))/w,y=0;e.setMaterial(0);for(let P of o){if(!P.fill)continue;let E=P.points.map(m);at(e,E,null,n+_r+y*vr,ne(P.fill)??Fe,0),y++}let x=o.filter(P=>!(P.fill&&P.ink===P.fill)),g=[...new Set(x.map(P=>P.ink??Ct))];for(let P of g){let E=n+_r+y++*vr,S=ne(P)??Fe;for(let b of x){if((b.ink??Ct)!==P)continue;let I=b.points.map(m),M=b.closed?I.length:I.length-1;for(let R=0;R<M;R++){let _=kr(I[R],I[(R+1)%I.length],p);_&&Oc(e,_,E,S)}}}}function Lr(e,t,n,o,r){if(t.length<3)return!1;let i=o+.006,s=r??Pc;if(n==="oval-cricket"){let a=t.reduce((S,b)=>S+b.x,0)/t.length,u=t.reduce((S,b)=>S+b.y,0)/t.length,f=S=>t.map(b=>({x:a+(b.x-a)*S,y:u+(b.y-u)*S})),c=8;for(let S=0;S<c;S++){let b=f(1-S/c),I=S===c-1?null:f(1-(S+1)/c);at(e,b,I,i,Z(s,S%2?1.04:.96),4)}let l=t[0];for(let S of t)Math.hypot(S.x-a,S.y-u)>Math.hypot(l.x-a,l.y-u)&&(l=S);let h=Math.hypot(l.x-a,l.y-u)||1,m=(l.x-a)/h,d=(l.y-u)/h,p=-d,y=m,x=Math.min(1,2*h*w*_c/wn.length),g=wn.length*x/2/w,P=wn.width*x/2/w,E=[[-g,-P],[g,-P],[g,P],[-g,P]].map(([S,b])=>({x:a+m*S+p*b,y:u+d*S+y*b}));return at(e,E,null,i+.004,wc,0),e.setMaterial(0),!0}if(n==="rink-hockey"){let a=Cr(t,Lc);return at(e,a,null,i,Ac,0),e.setMaterial(0),z(e,t,[a.slice().reverse()],()=>o+Tc,o,Er,Z(Er,.9),Y),!0}if(n==="ring-boxing"&&t.length===4){let{at:a}=Wt(t),u=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],f=[[.77,.19,.19],Fe,[.17,.42,.69],Fe];e.setMaterial(0),u.forEach((c,l)=>Kt(e,c,.07,o,o+kc,f[l]));for(let c of Cc)for(let l=0;l<4;l++)st(e,u[l],u[(l+1)%4],.025,o+c-.025,o+c+.025,Fe);return!0}if(n==="court-tennis"&&t.length===4){let{at:a}=Wt(t);e.setMaterial(0),st(e,a(0,-6.4),a(0,6.4),.015,o,o+.95,Yt),st(e,a(0,-6.4),a(0,6.4),.03,o+.95,o+1,Fe);for(let u of[-1,1])Kt(e,a(0,u*6.4),.05,o,o+1.07,Yt);return!0}if(n==="court-basketball"&&t.length===4){let{at:a,lengthM:u}=Wt(t),f=Math.min(14,u/2-.5);e.setMaterial(0);for(let c of[-1,1]){let l=a(c*(f+1.2),0),h=a(c*(f-1.2),0);Kt(e,l,.12,o,o+3.4,Yt),st(e,l,h,.06,o+3.25,o+3.4,Yt),st(e,a(c*(f-1.2),-.9),a(c*(f-1.2),.9),.03,o+2.9,o+3.95,Fe)}return!0}if(n==="pitch-rugby"&&t.length===4){let{at:a,lengthM:u}=Wt(t),f=u*(50/120);e.setMaterial(0);for(let c of[-1,1]){for(let l of[-2.8,2.8])Kt(e,a(c*f,l),.07,o,o+12,Fe);st(e,a(c*f,-2.8),a(c*f,2.8),.06,o+2.94,o+3.06,Fe)}return!0}if(n==="track-athletics"){let a=Cr(t,vc);return a.length<3?!1:(at(e,t,a,i,Ec,0),at(e,a,null,i,s,4),e.setMaterial(0),!0)}return!1}var Or=[.19,.4,.15],Bc=.012,$t=2.4,Fc=1,Dc=.75,Nc=.15;function Ee(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:o,rotation:r}=e;if(!n||!o)return null;let i=(r??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),u=n/2,f=o/2;return[[-u,-f],[u,-f],[u,f],[-u,f]].map(([c,l])=>({x:t.x+c*s-l*a,y:t.y+c*a+l*s}))}function jr(e,t,n,o,r,i,s=!1){let a=Ee(t);if(a){if(s){let u=Qe(o,r.boothTop),f=Ce([...a]);z(e,Pe(f,Gc/w),[f.slice().reverse()],()=>n+.03,n,u,Z(u,.8),Y);return}if(!(!t.points&&i&&Hc(e,a,n,o,i))){if(!t.points&&i&&a.length===4){jc(e,a,n,o,i);return}z(e,a,void 0,()=>n+$t,n,Qe(o,r.boothTop),r.boothWall,Y)}}}var An=1.1,Br=[.9,.9,.88],Gc=.1,zt=[.87,.87,.85],Fr=.08;function Hr(e,t){let n=u=>({x:(e[u].x+e[(u+1)%4].x)/2,y:(e[u].y+e[(u+1)%4].y)/2}),o=0,r=1/0;for(let u=0;u<4;u++){let f=n(u),c=Math.hypot(f.x-t.x,f.y-t.y);c<r&&(r=c,o=u)}let i=[0,1,2,3].map(u=>e[(o+u)%4]),s=(u,f,c)=>({x:u.x+(f.x-u.x)*c,y:u.y+(f.y-u.y)*c});return{q:i,part:(u,f,c,l)=>{let h=s(i[0],i[1],u),m=s(i[0],i[1],f),d=s(i[3],i[2],u),p=s(i[3],i[2],f);return[s(h,d,c),s(m,p,c),s(m,p,l),s(h,d,l)]},depthM:Math.hypot(i[3].x-i[0].x,i[3].y-i[0].y)*w,widthM:Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*w}}function jc(e,t,n,o,r){let{q:i,part:s}=Hr(t,r),a=o??[.35,.42,.55],u=te(a,[.78,.78,.77],.62),f=te(a,[.95,.95,.94],.45);ee(e,i,n+Ue,n,u,Z(u,.8)),ee(e,s(.05,.95,.72,.98),n+An-.05,n+Ue,f,Z(f,.8)),ee(e,s(.03,.97,.7,1),n+An,n+An-.05,Br,Z(Br,.9))}function Hc(e,t,n,o,r){if(t.length!==4)return!1;let{q:i,part:s,depthM:a,widthM:u}=Hr(t,r);if(a<1||u<1)return!1;let f=o??[.35,.42,.55],c=te(f,[.78,.78,.77],.62),l=n+$t,h=Fr/u,m=Fr/a;ee(e,i,n+Ue,n,c,Z(c,.8)),ee(e,s(0,1,1-m,1),l,n+Ue,zt,Z(zt,.9));for(let[y,x]of[[0,h],[1-h,1]])ee(e,s(y,x,0,1-m),l,n+Ue,zt,Z(zt,.9));ee(e,s(h,1-h,0,Math.min(.5,.06/a)),l,l-.3,f,Z(f,.85));let d=Math.min(.4,.6/u),p=Math.min(.12,.3/a);return ee(e,s(.5-d,.5+d,.72-p,.72+p),n+Fc,n+Ue,te(f,[.95,.95,.94],.7),Z(f,.75)),!0}function Qt(e){if(e.shape==="round"){let c=e.radius;return c?Ft(e.center.x,e.center.y,c,c,24):null}let{width:t,height:n,rotation:o,center:r}=e;if(!t||!n)return null;let i=(o??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),u=t/2,f=n/2;return[[-u,-f],[u,-f],[u,f],[-u,f]].map(([c,l])=>({x:r.x+c*s-l*a,y:r.y+c*a+l*s}))}function Xr(e,t,n,o,r,i=!0){let s=Qt(t);if(!s)return;let a=s.reduce((h,m)=>h+m.x,0)/s.length,u=s.reduce((h,m)=>h+m.y,0)/s.length,f=h=>s.map(m=>({x:a+(m.x-a)*h,y:u+(m.y-u)*h})),c=i&&o?Qe(o,r.tableTop):Xc,l=n+Dc;z(e,s,void 0,()=>l,n+Uc,c,Z(c,.86),Y),z(e,f(.12),void 0,()=>l+.12,l,Dr,Z(Dr,.8),Y)}var Xc=[.93,.92,.89],Dr=[.78,.66,.42],Uc=.25;function Ur(e,t,n,o,r,i,s,a,u=[]){let f=ie(t);if(!t.role&&(!t.fill||t.fill==="none"||t.fill==="transparent")||!f){St(e,t,n+o+Bc);return}let l=a?a.kind==="stage":t.role==="stage",h=a?a.kind==="screen":t.role==="screen",m=a?{kind:l?"stage":"solid",heightM:a.topY-a.baseY}:Ae(t),d=a?.baseY??n,p=a?.topY??n+o;if(l&&s){let M=1/0,R=-1/0,_=1/0,k=-1/0;for(let O of f)O.x<M&&(M=O.x),O.x>R&&(R=O.x),O.y<_&&(_=O.y),O.y>k&&(k=O.y);s.push({cx:(M+R)/2*w,cz:(_+k)/2*w,y:p,halfX:Math.max((R-M)/2*w,.5),halfZ:Math.max((k-_)/2*w,.5)})}let y=ne(t.fill),x=t.role==="wall"||t.role==="entrance"||t.role==="exit",g=x?y?Z(we(y,.12),.95):r.tierTop:l&&y?te(r.stageTop,Z(we(y,.18),.9),.9):!t.role&&y?y:Qe(y,l?r.stageTop:r.decorTop),P=h?y:null,E=x?y?Z(we(y,.12),.85):r.tierWall:l?y?te(r.stageWall,Z(y,.58),.82):r.stageWall:h?P?te(Z(P,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Qe(ne(t.fill),r.decorWall);if(t.role==="wall"&&!a){Pr(e,f,d,p,u,g,E),St(e,t,p+.012);return}if(h&&f.length===4&&p-d>.2){let M=Pn(f,d,p);if(!M)return;let{quad:R,side:_,trim:k,inner:O,panel:C}=M,A=[.12,.15,.18];for(let[v,T]of[[0,_],[1-_,1]])ee(e,pe(R,v,T),p,d,A,A);ee(e,O,d+k,d,A,A),ee(e,O,p,p-k,A,A),ee(e,C,p-k,d+k,E,E),St(e,t,p+.012);return}let S=y?Z(we(y,.15),.82):E,b=y?Z(we(y,.1),1.02):g;if(wr(t.role)&&!a&&Ar(e,t.role,f,d,p,S,b,i,t.heightM!==void 0))return;if((t.role==="sound"||a?.kind==="sound_desk")&&f.length===4&&p-d>.3){let M=ge(f),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*w,_=Math.min(.12,.09/Math.max(R,.001)),k=[.18,.21,.24],O=p-Math.min(.12,(p-d)*.15);for(let[C,A]of[[0,_],[1-_,1]])ee(e,pe(M,C,A),O,d,k,k);ee(e,M,p,O,g,k);return}if(t.role==="rail"&&f.length===4&&p>d){let M=ge(f),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*w,_=Math.max(1,Math.min(128,Math.ceil(R/1.4))),k=Math.min(.08,.055/Math.max(.055,R)),O=[.58,.64,.66];for(let C=0;C<=_;C++){let A=C/_,v=Math.min(1-k,Math.max(0,A-k/2));ee(e,pe(M,v,v+k),p,d,O,Z(O,.8))}for(let C of[.52,1]){let A=d+(p-d)*C;ee(e,M,A,Math.max(d,A-.055),O,Z(O,.8))}return}if(t.role==="goal"&&f.length===4){let M=ge(f),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*w,_=Math.min(.12,.1/Math.max(.1,R)),k=[.9,.94,.94];for(let[O,C]of[[0,_],[1-_,1]])ee(e,pe(M,O,C),Math.max(d,p-.1),d,k,k);ee(e,M,p,Math.max(d,p-.1),k,k);return}if(m.kind==="portal"&&f.length===4){let M=rt(f,d,p);if(!M)return;let{quad:R,side:_,face:k,openingTop:O}=M;for(let[C,A,v]of[[0,k,1],[k,1-k,.67],[1-k,1,1]]){let T=Mt(R,C,A),F=Z(g,v),L=Z(E,v);for(let[B,N]of[[0,_],[1-_,1]])ee(e,pe(T,B,N),O,d,F,L);ee(e,T,p,O,F,L)}return}if(m.kind==="suite"&&f.length===4){let M=f.map((k,O)=>{let C=f[(O+1)%4],A=(k.x+C.x)/2,v=(k.y+C.y)/2;return Math.hypot(A-i.x,v-i.y)}),R=M.indexOf(Math.min(...M)),_=[0,1,2,3].map(k=>f[(R+k)%4]);ee(e,pe(_,0,.08),p,d,g,E),ee(e,pe(_,.92,1),p,d,g,E),ee(e,Mt(_,.88,1),p,d,g,E),ee(e,_,p,Math.max(d,p-.18),g,E);return}if(l&&!t.stageKind?.startsWith("pitch-")&&p-d>.12){let M=p-Math.min(.06,(p-d)*.15);ee(e,f,M,d,g,E),ee(e,f,p,M,g,te(g,E,.2))}else ee(e,f,p,d,g,E);if((t.stageKind==="pitch-football"||t.stageKind==="pitch-rugby")&&f.length===4){e.setMaterial(4);let M=ge(f),R=te(y??Or,Or,y?.45:0);for(let _=0;_<12;_++){let k=pe(M,_/12,(_+1)/12),O=Z(R,_%2?1.09:.91),C=k.map(A=>[A.x*w,p+.006,A.y*w]);e.tri(C[0],C[1],C[2],[0,1,0],O),e.tri(C[0],C[2],C[3],[0,1,0],O)}}t.stageKind&&t.stageKind!=="pitch-football"&&Lr(e,f,t.stageKind,p,y),l&&We(t.stageKind)&&Tr(e,t,p),e.setMaterial(h?1:0),St(e,t,p+.012)}function qt(e){let{x:t,y:n,width:o,height:r}=e;if(!o||!r)return null;let i=t+o/2,s=n+r/2,a=(e.rotation??0)*Math.PI/180,u=Math.cos(a),f=Math.sin(a),c=o/2,l=r/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([h,m])=>({x:i+h*u-m*f,y:s+h*f+m*u}))}function Vc(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let o=n[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return ne(o);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let s=[];for(let a of i[1].matchAll(/stop-color="([^"]+)"/gi)){let u=ne(a[1].trim());u&&s.push(u)}return s.length?s.reduce((a,u,f)=>te(a,u,1/(f+1)),s[0]):null}function Vr(e,t,n,o){if(t.layer==="foreground")return;let r=qt(t);if(!r)return;let i=n+Nc,s=Qe(Vc(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=te(o.ground,s,a)),z(e,r,void 0,()=>i,n,s,te(s,o.decorWall,.5),Y)}function Yr(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=No(o,r.gaTop);z(e,t.points,t.holes,()=>n+Nr,n,i,r.gaWall,Y),Wc(e,t.points,n+Nr)}var Nr=.15,Zt=[.72,.74,.76],En=1.1,Gr=.12,_n=.05,Yc=.06,Kc=2.4;function Wc(e,t,n){let o=Ce([...t]),r=He(o,Gr/w),i=He(o,(Gr+_n)/w);if(r.length<3||i.length<3)return;for(let a of[n+En,n+En*.5])z(e,r,[i.slice().reverse()],()=>a,a-_n,Zt,Z(Zt,.85),Y);let s=Yc/2/w;for(let a=0;a<r.length;a++){let u=r[a],f=r[(a+1)%r.length],c=Math.hypot(f.x-u.x,f.y-u.y)*w,l=Math.max(1,Math.round(c/Kc));for(let h=0;h<l;h++){let m=h/l,d=u.x+(f.x-u.x)*m,p=u.y+(f.y-u.y)*m,y=[{x:d-s,y:p-s},{x:d+s,y:p-s},{x:d+s,y:p+s},{x:d-s,y:p+s}];z(e,y,void 0,()=>n+En-_n,n,Zt,Z(Zt,.8),Y)}}}var vn=.6,Kr=3,zc=.25;function Zc(e,t){if(xe(t,e.x,e.y))return 0;let n=1/0;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,u=s.y-i.y,f=a*a+u*u||1,c=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*u)/f));n=Math.min(n,Math.hypot(e.x-(i.x+c*a),e.y-(i.y+c*u)))}return n}function Wr(e,t){let n=e.map(s=>({booth:s,ring:Ee(s)})).filter(s=>!!s.ring&&s.ring.length===4&&!s.booth.points),o=n.map(({ring:s})=>({minX:Math.min(...s.map(a=>a.x)),maxX:Math.max(...s.map(a=>a.x)),minY:Math.min(...s.map(a=>a.y)),maxY:Math.max(...s.map(a=>a.y))})),r=(Kr+vn)/w,i=new Map;return n.forEach(({booth:s,ring:a},u)=>{let f={x:a.reduce((m,d)=>m+d.x,0)/4,y:a.reduce((m,d)=>m+d.y,0)/4},c=[0,1,2,3].map(m=>{let d=a[m],p=a[(m+1)%4],y={x:(d.x+p.x)/2,y:(d.y+p.y)/2},x=y.x-f.x,g=y.y-f.y,P=Math.hypot(x,g)||1,E={x:y.x+x/P*vn/w,y:y.y+g/P*vn/w},S=Kr/w;return o.forEach((b,I)=>{I===u||E.x<b.minX-r||E.x>b.maxX+r||E.y<b.minY-r||E.y>b.maxY+r||(S=Math.min(S,Zc(E,n[I].ring)))}),{open:S*w,toward:{x:y.x+x/P*10/w,y:y.y+g/P*10/w},focal:Math.hypot(y.x-t.x,y.y-t.y)}}),l=Math.max(...c.map(m=>m.open)),h=c.filter(m=>m.open>=l-zc).sort((m,d)=>m.focal-d.focal)[0];i.set(s.id,h.toward)}),i}var zr=Te(require("polygon-clipping"),1);var $c=.45,Qc=1500,qc=200;function Zr(e,t){if(e.role!=="stage"||We(e.stageKind))return e;let n=ie(e);if(!n||n.length<3||Math.abs(ye(n))*w*w>Qc)return e;let o=t.filter(s=>xe(n,s.x,s.y));if(!o.length||o.length>qc)return e;let r=$c/w,i=o.map(s=>[[[s.x-r,s.y-r],[s.x+r,s.y-r],[s.x+r,s.y+r],[s.x-r,s.y+r],[s.x-r,s.y-r]]]);try{let s=zr.default.difference([[...n.map(f=>[f.x,f.y]),[n[0].x,n[0].y]]],...i),a=null,u=0;for(let f of s){let c=f[0].slice(0,-1).map(([h,m])=>({x:h,y:m})),l=Math.abs(ye(c));l>u&&(u=l,a=c)}return!a||a.length<3?e:{...e,kind:"polygon",points:a,rotation:0}}catch{return e}}var Jc=Math.PI/180,oe=96,el=6,tl=60,nl=150,$r=.2,ol=.35;function rl(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/Jc;return n<0?n+360:n}function Jt(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function en(e,t,n=2){let o=e.length,r=new Float64Array(o);for(let i=0;i<o;i++){let s=0,a=0;for(let u=-n;u<=n;u++){let f=i+u;if(t)f=(f%o+o)%o;else if(f<0||f>=o)continue;s+=e[f],a++}r[i]=s/a}return r}function Qr(e,t){let n=e.filter(h=>h.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let h of n)for(let m of h.rows){for(let d of m.pts)r+=d.x,i+=d.y,s++;if(m.pts.length>=4){let d=un(m.pts);d&&Number.isFinite(d.cx)&&Number.isFinite(d.cy)&&o.push({x:d.cx,y:d.cy})}}if(!s)return null;let a={x:r/s,y:i/s},u=a;if(o.length>=8){let h=Jt(o.map(x=>x.x)),m=Jt(o.map(x=>x.y)),d=0;for(let x of n)for(let g of x.rows)for(let P of g.pts){let E=Math.hypot(P.x-a.x,P.y-a.y);E>d&&(d=E)}let p=0,y=d*.2;for(let x of n)for(let g of x.rows)for(let P of g.pts)Math.hypot(P.x-h,P.y-m)<y&&p++;Math.hypot(h-a.x,m-a.y)<=d&&p/s<.01&&(u={x:h,y:m})}let f=[];for(let h of n){let m={sectionId:h.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let d of h.rows)for(let p of d.pts){let y=Math.hypot(p.x-u.x,p.y-u.y),x=Math.min(oe-1,Math.floor(rl(u,p)/(360/oe)));m.samples.push({r:y,bin:x,levelM:d.levelM}),y<m.rMin&&(m.rMin=y),y>m.rMax&&(m.rMax=y)}m.samples.length&&f.push(m)}if(!f.length)return null;f.sort((h,m)=>h.rMin+h.rMax-(m.rMin+m.rMax));let c=[];for(let h of f){let m=!1;for(let d of c){let p=Math.min(h.rMax,d.rMax)-Math.max(h.rMin,d.rMin),y=Math.min(h.rMax-h.rMin,d.rMax-d.rMin);if(y>1e-9&&p>=ol*y){d.members.push(h),d.rMin=Math.min(d.rMin,h.rMin),d.rMax=Math.max(d.rMax,h.rMax),m=!0;break}}m||c.push({members:[h],rMin:h.rMin,rMax:h.rMax})}let l=[];for(let h of c){let m=new Array(oe).fill(null);for(let C of h.members)for(let A of C.samples){let v=m[A.bin];v||(v={samples:[]},m[A.bin]=v),v.samples.push({r:A.r,levelM:A.levelM})}let d=m.map(C=>!!C);if(!d.filter(Boolean).length)continue;let y=[],x=[];for(let C of m){if(!C)continue;let A=1/0,v=-1/0;for(let T of C.samples)T.r<A&&(A=T.r),T.r>v&&(v=T.r);y.push(A),x.push(v)}let g=Jt(y),P=Jt(x);if(!(g>=$r*P)||!(P>0))continue;let E=[...y].sort((C,A)=>C-A);if(!(E[Math.floor(E.length*.1)]>=$r*P))continue;let b=m.map(C=>{if(!C)return null;let A=[...C.samples].sort((D,V)=>D.r-V.r),v=A[0].r,T=A[A.length-1].r,F=A[0].levelM,L=-1/0;for(let D of A)D.levelM>L&&(L=D.levelM);let B=[];for(let D of A){let V={r:D.r,l:D.levelM};for(;B.length&&Math.abs(B[B.length-1].r-V.r)<1e-9;){if(B[B.length-1].l<=V.l){V.skip=!0;break}B.pop()}if(!V.skip){for(;B.length>=2;){let X=B[B.length-2],W=B[B.length-1];if((W.r-X.r)*(V.l-X.l)-(W.l-X.l)*(V.r-X.r)<=0)B.pop();else break}B.push(V)}}let N=B.map(D=>D.r),j=B.map(D=>D.l);return{inner:v,outer:T,front:F,top:L,profile:{rs:N,ls:j}}}),I=d.slice();for(let C=0;C<oe;C++){if(I[C])continue;let A=-1,v=-1,T=0;for(let U=1;U<=oe;U++){let J=(C-U+oe*2)%oe;if(I[J]){A=J;break}}for(let U=1;U<=oe;U++){let J=(C+U)%oe;if(I[J]){v=J,T=U;break}}if(A<0||v<0)continue;let F=0;for(let U=1;U<=oe;U++){let J=(C-U+oe*2)%oe;if(d[J]){F=U;break}}if(F-1+T>el)continue;let B=b[A],N=b[v],j=F/(F+T),D=B.inner+(N.inner-B.inner)*j,V=B.outer+(N.outer-B.outer)*j,X=B.front+(N.front-B.front)*j,W=B.top+(N.top-B.top)*j;b[C]={inner:D,outer:V,front:X,top:W,profile:{rs:[D,V],ls:[X,W]}}}for(let C=0;C<oe;C++)b[C]&&(I[C]=!0);let M=360/oe,R=[],_=I.filter(Boolean).length,k=[];if(_===oe)k.push({start:0,len:oe});else{let C=0;for(;I[C];)C=(C+1)%oe;let A=-1;for(let v=0;v<=oe;v++){let T=(C+v)%oe,F=v<oe&&I[T];if(F&&A<0)A=T;else if(!F&&A>=0){let L=(T-A+oe)%oe||oe;k.push({start:A,len:L}),A=-1}}}for(let C of k){if(C.len*M<tl&&C.len<oe)continue;let A=C.len===oe,v=new Float64Array(C.len),T=new Float64Array(C.len),F=new Float64Array(C.len),L=new Float64Array(C.len),B=[];for(let U=0;U<C.len;U++){let J=b[(C.start+U)%oe];v[U]=J.inner,T[U]=J.outer,F[U]=J.front,L[U]=J.top,B.push(J.profile??{rs:[J.inner,J.outer],ls:[J.front,J.top]})}let N=en(v,A),j=en(T,A),D=en(F,A),V=en(L,A);for(let U=0;U<C.len;U++)N[U]>v[U]&&(N[U]=v[U]),j[U]<T[U]&&(j[U]=T[U]),N[U]>j[U]-1e-6&&(N[U]=Math.max(0,j[U]-1e-6)),V[U]<D[U]&&(V[U]=D[U]);let X={startBin:C.start,binCount:C.len,closed:A,innerR:N,outerR:j,frontLevelM:D,topLevelM:V,profiles:B},W=(U,J,Q)=>{let ce=B[U],ae=ce.rs,G=ce.ls;if(J<=ae[0]){G[0]>Q&&(G[0]=Q);return}if(J>=ae[ae.length-1]){G[G.length-1]>Q&&(G[G.length-1]=Q);return}for(let H=0;H+1<ae.length;H++)if(J<=ae[H+1]){G[H]>Q&&(G[H]=Q),G[H+1]>Q&&(G[H+1]=Q);return}};for(let U=0;U<C.len;U++){let J=m[(C.start+U)%oe];if(J)for(let Q of J.samples){W(U,Q.r,Q.levelM);let ce=A?(U-1+C.len)%C.len:U-1,ae=A?(U+1)%C.len:U+1;ce>=0&&W(ce,Q.r,Q.levelM),ae<C.len&&W(ae,Q.r,Q.levelM)}}R.push(X)}R.reduce((C,A)=>C+A.binCount*M,0)<nl||l.push({arcs:R,sectionIds:h.members.map(C=>C.sectionId),innerRMedian:g,outerRMedian:P})}if(!l.length)return null;if(l.sort((h,m)=>h.innerRMedian-m.innerRMedian),t){let h=l[l.length-1].outerRMedian;if(Math.hypot(t.x-u.x,t.y-u.y)>.9*h)return null}return{centre:u,binCount:oe,binStepDeg:360/oe,rings:l}}function qr(e,t,n,o){let r=e.binStepDeg,i=n/r-.5-t.startBin;i=(i%e.binCount+e.binCount)%e.binCount,i>t.binCount-1&&(t.closed?i=i-t.binCount<t.binCount-i?0:t.binCount-1:i=i-(t.binCount-1)<e.binCount-i?t.binCount-1:0);let s=Math.floor(i),a=t.closed?(s+1)%t.binCount:Math.min(t.binCount-1,s+1),u=i-s,f=c=>{let l=t.profiles[c],h=l.rs,m=l.ls;if(o<=h[0])return m[0];if(o>=h[h.length-1])return m[m.length-1];for(let d=0;d+1<h.length;d++)if(o<=h[d+1]){let p=h[d+1]-h[d],y=p>1e-9?(o-h[d])/p:0;return m[d]+(m[d+1]-m[d])*y}return m[m.length-1]};return f(s)*(1-u)+f(a)*u}function Cn(e,t,n,o,r,i,s,a,u,f=[],c=r){if(t.length!==n.length||t.length<2||i-r<1.5)return;let l=(p,y,x)=>{Be(e,p,y,x,f,s,a,{portalBase:c,ao:u})||z(e,p,void 0,()=>x,y,s,a,u)},h=(p,y,x)=>({x:p.x+(y.x-p.x)*x,y:p.y+(y.y-p.y)*x}),m=o?t.length:t.length-1,d=0;for(let p=0;p<m;p++){let y=(p+1)%t.length,x=Math.hypot(n[y].x-n[p].x,n[y].y-n[p].y)*$;if(x<1e-5)continue;let g=(b,I)=>[h(t[p],t[y],b),h(t[p],t[y],I),h(n[p],n[y],I),h(n[p],n[y],b)];l(g(0,1),r,r+.95),l(g(0,1),i-.22,i);let P=Math.ceil((d-.32)/6)*6,E=!1,S=!1;for(let b=P;b<d+x;b+=6){let I=Math.max(0,(b-d)/x),M=Math.min(1,(b+.32-d)/x);M<=I||(l(g(I,M),r+.95,i-.22),E||=I<1e-6,S||=M>1-1e-6)}if(!o&&(p===0&&!E||p===m-1&&!S)){let b=Math.min(1,.32/x);l(g(p===0?0:1-b,p===0?b:1),r+.95,i-.22)}d+=x}}var Ve=Te(require("polygon-clipping"),1),Rt=.65;function kn(e,t){let n=1/0;for(let o of t)for(let r=0;r<o.length;r++){let i=o[r],s=o[(r+1)%o.length],a=s.x-i.x,u=s.y-i.y,f=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*u)/(a*a+u*u||1)));n=Math.min(n,Math.hypot(e.x-i.x-f*a,e.y-i.y-f*u))}return n}var Tn=.01;function Jr(e,t,n,o,r,i,s,a=[],u=!0,f={bays:[],walls:[]}){if(o-r<=1e-5)return;let c=o-r>=3,l=c?o-Rt:r;e.setMaterial(5);let h=c?[]:a.filter(b=>{if(b.role!=="entrance"&&b.role!=="exit")return!1;let I=ie(b);if(!I)return!1;let M=rt(I,r,r+Ae(b).heightM);return M!==null&&M.openingTop<=o-.12});if((!h.length||!Be(e,t,l,o,h,i,s,{holes:n,portalBase:r}))&&z(e,t,n,()=>o,l,i,s,Y,void 0,()=>[0,1,0]),!c){e.setMaterial(0);return}let m=u&&f.bays.length?il(t,n,He(t,It/w),f):null,d=6/w,p=.22/w,y=a.flatMap(b=>{if(b.role!=="entrance"&&b.role!=="exit")return[];let I=ie(b);return I?.length?[{minX:Math.min(...I.map(M=>M.x)),maxX:Math.max(...I.map(M=>M.x)),minY:Math.min(...I.map(M=>M.y)),maxY:Math.max(...I.map(M=>M.y))}]:[]}),x=Math.min(...t.map(b=>b.x)),g=Math.max(...t.map(b=>b.x)),P=Math.min(...t.map(b=>b.y)),E=Math.max(...t.map(b=>b.y));for(let b=x+d/2;b<g;b+=d)for(let I=P+d/2;I<E;I+=d){if(y.some(R=>b+p>=R.minX&&b-p<=R.maxX&&I+p>=R.minY&&I-p<=R.maxY))continue;let M=[{x:b-p,y:I-p},{x:b+p,y:I-p},{x:b+p,y:I+p},{x:b-p,y:I+p}];!be({x:b,y:I},t,n)||kn({x:b,y:I},[t,...n??[]])<p*Math.SQRT2+(u?It/w:0)||m&&kn({x:b,y:I},m.flat())<p*Math.SQRT2+It/w||z(e,M,void 0,()=>l,r,i,s,Y)}if(m){for(let[b,...I]of m)z(e,b,I,()=>l,r-Tn,i,s,Y);e.setMaterial(0);return}let S=He(t,It/w);if(u&&S.length>=3){let b=a.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let _=ie(R);return!!_&&_.some(k=>!be(k,t,void 0)||kn(k,[t])<=It/w)}),I=[S.slice().reverse()],M=r-Tn;(!b.length||!Be(e,t,M,l,b,i,s,{holes:I,portalBase:r+Tn}))&&z(e,t,I,()=>l,M,i,s,Y)}e.setMaterial(0)}var Ln=.25,It=Ln;function il(e,t,n,o){if(n.length<3)return null;let r=s=>{let a=s.map(u=>[u.x,u.y]);return a.push(a[0]),a},i=s=>{let[a,...u]=s.map(f=>[r(f)]);return Ve.default.union(a,...u)};try{let s=[r(e),...(t??[]).map(r)],a=Ve.default.difference(s,[r(n)]),u=Ve.default.intersection(s,i(o.bays));if(!u.length)return null;let f=Ve.default.difference(Ve.default.intersection(s,i(o.walls)),u);return Ve.default.union(Ve.default.difference(a,u),f).map(l=>l.map(h=>h.slice(0,-1).map(([m,d])=>({x:m,y:d}))))}catch{return null}}var sl=.02,al=.25,cl=1.2,ll=.6,ul=.45,fl=2.3,ml=Math.PI/180,ei=.005;function ke(e,t,n){let o=n*ml;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function hl(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let o=n.outerRMedian*.85;for(let r of e){if(r.role!=="wall")continue;let i=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(i.length<2)continue;let s=0;for(let a of i)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=o&&s++;if(s>=i.length/2)return!0}return!1}var dl=24,pl=.01;function bl(e,t,n,o,r,i,s,a,u){let f=n.binCount,c=dl,l=$,h=i+.02,m=i-pl,d=[];for(let A=0;A<f;A++){let v=(n.startBin+A+.5)*t.binStepDeg,T=new Float64Array(c+1);for(let F=0;F<=c;F++){let L=o[A]+(r[A]-o[A])*F/c;T[F]=Math.max(h,qr(t,n,v,L)-al)}d.push(T)}if(u){let A=0;for(let v=0;v+1<f;v++)for(let T=0;T<c;T++){let F=ke(t.centre,o[v]+(r[v]-o[v])*T/c,(n.startBin+v+.5)*t.binStepDeg),L=ke(t.centre,o[v+1]+(r[v+1]-o[v+1])*(T+1)/c,(n.startBin+v+1.5)*t.binStepDeg);A=Math.max(A,Math.hypot(L.x-F.x,L.y-F.y))}for(let v=0;v<f;v++){let T=(n.startBin+v+.5)*t.binStepDeg;for(let F=0;F<=c;F++){let L=ke(t.centre,o[v]+(r[v]-o[v])*F/c,T),B=u(L.x,L.y,A*1.01);B!==null&&(d[v][F]=Math.min(d[v][F],Math.max(m+ei,B-ei)))}}}let p=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],y=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],x=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],g=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],P=(A,v)=>{let T=(n.startBin+A+.5)*t.binStepDeg,F=o[A]+(r[A]-o[A])*v/c,L=ke(t.centre,F,T);return[L.x*l,d[A][v],L.y*l]};{let A=Math.tan(12*Math.PI/180);for(let v=0;v<6;v++){let T=!1;for(let L=0;L<f;L++)for(let B=c-1;B>=0;B--)d[L][B]>d[L][B+1]&&(d[L][B]=d[L][B+1],T=!0);let F=n.closed?f:f-1;for(let L=0;L<F;L++){let B=(L+1)%f;for(let N=0;N<=c;N++){let j=d[B][N]-d[L][N];if(Math.abs(j)>1)continue;let D=o[L]+(r[L]-o[L])*N/c,V=o[B]+(r[B]-o[B])*N/c,X=ke(t.centre,D,(n.startBin+L+.5)*t.binStepDeg),W=ke(t.centre,V,(n.startBin+B+.5)*t.binStepDeg),U=A*Math.hypot(W.x-X.x,W.y-X.y)*l;j>U?(d[B][N]=d[L][N]+U,T=!0):-j>U&&(d[L][N]=d[B][N]+U,T=!0)}}if(!T)break}}let E=1,S=(A,v)=>{for(let T=0;T<=c;T+=4)if(Math.abs(d[A][T]-d[v][T])>E)return!0;return Math.abs(d[A][c]-d[v][c])>E},b=Math.tan(38*Math.PI/180),I=A=>(r[A]-o[A])/c*l,M=(A,v)=>d[A][v+1]-d[A][v]>b*Math.max(1e-6,I(A)),R=(A,v)=>{let T=n.closed?(A-1+f)%f:Math.max(0,A-1),F=n.closed?(A+1)%f:Math.min(f-1,A+1);Math.abs(d[T][v]-d[A][v])>E&&(T=A),Math.abs(d[F][v]-d[A][v])>E&&(F=A);let L=Math.max(0,v-1),B=Math.min(c,v+1);L<v&&M(A,L)&&(L=v),B>v&&M(A,v)&&(B=v);let N=P(T,v),j=P(F,v),D=P(A,L),V=P(A,B),X=j[0]-N[0],W=j[1]-N[1],U=j[2]-N[2],J=V[0]-D[0],Q=V[1]-D[1],ce=V[2]-D[2],ae=W*ce-U*Q,G=U*J-X*ce,H=X*Q-W*J,q=Math.hypot(ae,G,H);return q>1e-12?(ae/=q,G/=q,H/=q,G<0&&(ae=-ae,G=-G,H=-H),[ae,G,H]):[0,1,0]},_=(A,v,T=!1)=>{let F=T&&Math.min(A[1],v[1])-i>=3,L=[A[0],F?A[1]-Rt:m,A[2]],B=[v[0],F?v[1]-Rt:m,v[2]],N=v[0]-A[0],j=v[2]-A[2],D=Math.hypot(N,j);if(!(D>1e-12))return;let V=[j/D,0,-N/D];e.tri(A,v,B,V,x,x,g),e.tri(A,B,L,V,x,g,g)},k=.05*Ie,O=A=>r[A]-o[A]<k,C=n.closed?f:f-1;for(let A=0;A<C;A++){let v=(A+1)%f;if(O(A)||O(v))continue;if(S(A,v)){let j=(n.startBin+A+1)*t.binStepDeg,D=(Q,ce)=>{let ae=(o[A]+o[v])/2,G=(r[A]+r[v])/2,H=ae+(G-ae)*ce/c,q=ke(t.centre,H,j);return[q.x*l,d[Q][ce],q.y*l]};for(let Q=0;Q<c;Q++){let ce=P(A,Q),ae=P(A,Q+1),G=D(A,Q),H=D(A,Q+1),q=R(A,Q),ue=R(A,Q+1);e.triN(ce,G,H,q,q,ue,p),e.triN(ce,H,ae,q,ue,ue,p);let fe=P(v,Q),he=P(v,Q+1),re=D(v,Q),se=D(v,Q+1),_e=R(v,Q),K=R(v,Q+1);e.triN(re,fe,he,_e,_e,K,p),e.triN(re,he,se,_e,K,K,p);let le=D(A,Q),me=D(A,Q+1),Ye=D(v,Q+1),Ke=D(v,Q),De=me[0]-le[0],Ne=me[2]-le[2],lt=Math.hypot(De,Ne);if(lt>1e-12){let wt=[Ne/lt,0,-De/lt];e.tri(le,me,Ye,wt,x),e.tri(le,Ye,Ke,wt,x)}}let V=P(A,0),X=P(v,0),W=P(v,c),U=P(A,c),J=Q=>[Q[0],m,Q[2]];Math.min(V[1],X[1])-i<3&&(e.tri(J(V),J(W),J(X),[0,-1,0],y),e.tri(J(V),J(U),J(W),[0,-1,0],y)),_(V,X,!0),_(U,W,!0);continue}for(let j=0;j<c;j++){let D=R(A,j),V=R(v,j),X=R(v,j+1),W=R(A,j+1);if(M(A,j)||M(v,j)){let ae=(me,Ye)=>{let Ke=(n.startBin+me+.5)*t.binStepDeg,De=o[me]+(r[me]-o[me])*(j+.5)/c,Ne=ke(t.centre,De,Ke);return[Ne.x*l,Ye,Ne.y*l]},G=P(A,j),H=P(v,j),q=ae(A,d[A][j]),ue=ae(v,d[v][j]);e.triN(G,H,ue,D,V,V,p),e.triN(G,ue,q,D,V,D,p);let fe=P(v,j+1),he=P(A,j+1),re=ae(A,d[A][j+1]),se=ae(v,d[v][j+1]);e.triN(re,se,fe,W,X,X,p),e.triN(re,fe,he,W,X,W,p);let _e=ue[0]-q[0],K=ue[2]-q[2],le=Math.hypot(_e,K);if(le>1e-12){let me=[-K/le,0,_e/le];e.tri(q,ue,se,me,x),e.tri(q,se,re,me,x)}continue}let U=P(A,j),J=P(v,j),Q=P(v,j+1),ce=P(A,j+1);e.triN(U,J,Q,D,V,X,p),e.triN(U,Q,ce,D,X,W,p)}let T=P(A,0),F=P(v,0),L=P(v,c),B=P(A,c),N=j=>[j[0],m,j[2]];Math.min(T[1],F[1])-i<3&&(e.tri(N(T),N(L),N(F),[0,-1,0],y),e.tri(N(T),N(B),N(L),[0,-1,0],y)),_(T,F,!0),_(B,L,!0)}if(!n.closed)for(let A of[0,f-1])for(let v=0;v<c;v++)_(P(A,v),P(A,v+1))}function ti(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let c of t.rings)for(let l of c.arcs){let h=new Float64Array(l.binCount),m=new Float64Array(l.binCount);for(let p=0;p<l.binCount;p++){let y=(l.startBin+p)%t.binCount,x=Math.max(0,l.innerR[p]-Re);h[p]=Math.max(x,s[y]+.001),m[p]=Math.max(h[p]+.001,l.outerR[p]+Re)}let d=0;for(let p=0;p<l.binCount;p++){let y=l.topLevelM[p]-o;y>d&&(d=y)}d>=cl&&bl(e,t,l,h,m,o,r,i,n.standTopNear);for(let p=0;p<l.binCount;p++){let y=(l.startBin+p)%t.binCount;m[p]>s[y]&&(s[y]=m[p])}}if(n.deriveShell===!1||hl(n.shapes,t))return;let a=t.rings[t.rings.length-1],u=ll*Ie,f=ul*Ie;for(let c of a.arcs){let l=[],h=[];for(let R=0;R<c.binCount;R++){let _=(c.startBin+R+.5)*t.binStepDeg,k=c.outerR[R]+Re+u;l.push(ke(t.centre,k,_)),h.push(ke(t.centre,k+f,_))}let m=-1/0;for(let R=0;R<c.binCount;R++)c.topLevelM[R]>m&&(m=c.topLevelM[R]);let d=m+fl,p=c.closed?h:[...h,...l.slice().reverse()],y=c.closed?[l.slice().reverse()]:void 0,x=te(r.shellWall,[.66,.71,.72],.62),g=(R,_,k,O,C)=>{let A=Math.abs(O-m)<1e-6?O-sl:O;Be(e,R,k,A,n.shapes,r.shellTop,C,{holes:_,portalBase:o,ao:i})||z(e,R,_,()=>A,k,r.shellTop,C,i)},P=Math.max(1,Math.ceil((m-o)/4.5)),E=(m-o)/P,S=new Set,b=n.tierFrontLevels??t.rings.map(R=>{let _=R.arcs.flatMap(k=>Array.from(k.frontLevelM)).filter(Number.isFinite).sort((k,O)=>k-O);return _[Math.floor(_.length/2)]});for(let R of b)Number.isFinite(R)&&R-o>=3&&R<m&&S.add(Math.max(0,Math.min(P-1,Math.floor((R-o)/E))));let I=Math.min(...b.filter(R=>Number.isFinite(R)&&R-o>=3&&R<m));for(let R=0;R<P;R++)o+(R+1)*E<=I-Rt&&Number.isFinite(I)&&S.add(R);for(let R=0;R<P;R++){let _=o+(m-o)*R/P,k=o+(m-o)*(R+1)/P;S.has(R)&&k-_>=3.2?(g(p,y,_,_+.45,x),Cn(e,l,h,c.closed,_+.45,k-.16,r.shellTop,x,i,n.shapes,o)):g(p,y,_,k-.16,x),g(p,y,k-.16,k,Z(x,.62))}Cn(e,l,h,c.closed,m,d,r.shellTop,x,i,n.shapes,o);let M=8;for(let R=1;R<h.length;R++){if(M+=Math.hypot(h[R].x-h[R-1].x,h[R].y-h[R-1].y)*$,M<8)continue;M=0;let _=h[R],k=h[R-1],O=_.x-k.x,C=_.y-k.y,A=Math.max(1,Math.hypot(O,C)),v=O/A*.16*Ie,T=C/A*.16*Ie,F=Math.max(1,Math.hypot(_.x-t.centre.x,_.y-t.centre.y)),L=(_.x-t.centre.x)/F*.24*Ie,B=(_.y-t.centre.y)/F*.24*Ie,N=[{x:_.x-v,y:_.y-T},{x:_.x+v,y:_.y+T},{x:_.x+v+L,y:_.y+T+B},{x:_.x-v+L,y:_.y-T+B}];g(N,void 0,o,m,Z(x,1.12))}}}var yl=2.5,ni=.65,xl=2,gl=.03;function Ml(e,t){let n=()=>{let o=t;for(;e.length>2;){let r=e[0],i=e[1],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>o){e[0]={x:r.x+(i.x-r.x)/s*o,y:r.y+(i.y-r.y)/s*o};return}o-=s,e.shift()}};n(),e.reverse(),n(),e.reverse()}function Fn(e,t,n){let o=new Map;for(let i of e){let s=o.get(i.blockId);(!s||i.depth<s.depth)&&o.set(i.blockId,i)}let r=[];for(let[i,s]of o){if(s.y-n<yl||s.pts.length<2)continue;let a=s.pts.map(c=>{let l=c.x-t.x,h=c.y-t.y,m=Math.max(1,Math.hypot(l,h));return{x:c.x-l/m*ni/w,y:c.y-h/m*ni/w}}),u=[],f=[a[0]];for(let c=1;c<a.length;c++){let l=a[c-1],h=a[c];Math.hypot(h.x-l.x,h.y-l.y)*w>xl?(f.length>=2&&u.push(f),f=[h]):f.push(h)}f.length>=2&&u.push(f);for(let c of u)Ml(c,gl/w);u.length&&r.push({blockId:i,y:s.y,runs:u})}return r}var oi=.1,Sl=1.1,Il=.22,On=.95,Bn=.05,ri=1.8;function ii(e,t,n,o){let r=[.72,.72,.69],i=[.48,.55,.57];for(let s of Fn(t,n,o)){let a=s.y;for(let u of s.runs){let f=ri;for(let c=1;c<u.length;c++){let l=u[c-1],h=u[c],m=h.x-l.x,d=h.y-l.y,p=Math.hypot(m,d);if(p<1e-5)continue;let y=x=>{let g=-d/p*x/w/2,P=m/p*x/w/2;return[{x:l.x+g,y:l.y+P},{x:h.x+g,y:h.y+P},{x:h.x-g,y:h.y-P},{x:l.x-g,y:l.y-P}]};if(z(e,y(Il),void 0,()=>a+oi,a-Sl,r,r,Y),z(e,y(Bn),void 0,()=>a+On,a+On-Bn,i,i,Y),f+=p*w,f>=ri||c===u.length-1){f=0;let x=.028/w,g=[{x:l.x-x,y:l.y-x},{x:l.x+x,y:l.y-x},{x:l.x+x,y:l.y+x},{x:l.x-x,y:l.y+x}];z(e,g,void 0,()=>a+On-Bn,a+oi,i,i,Y)}}}}}var Rl=.9,Pl=1.5,wl=.3;function si(e,t,n){let o=[],r=[],i=Rl/w,s=Pl/w,a=wl/w;for(let u of e)for(let f of u.runs){if(f.length<2)continue;let c=f.slice(),l=(y,x)=>{let g=c[y],P=c[x],E=Math.hypot(g.x-P.x,g.y-P.y)||1;c[y]={x:g.x+(g.x-P.x)/E*a,y:g.y+(g.y-P.y)/E*a}};l(0,1),l(c.length-1,c.length-2);let h=c.map((y,x)=>{let g=c[Math.max(0,x-1)],P=c[Math.min(c.length-1,x+1)],E=P.x-g.x,S=P.y-g.y,b=Math.hypot(E,S)||1,I=-S/b,M=E/b;return I*(y.x-t.x)+M*(y.y-t.y)<0&&(I=-I,M=-M),{nx:I,ny:M}}),m=c.map((y,x)=>({x:y.x-h[x].nx*s,y:y.y-h[x].ny*s})),d=c.map((y,x)=>({x:y.x+h[x].nx*i,y:y.y+h[x].ny*i})),p=c.map((y,x)=>({x:y.x+h[x].nx*(i+n/w),y:y.y+h[x].ny*(i+n/w)}));o.push([...m,...d.slice().reverse()]),r.push([...d,...p.reverse()])}return{bays:o,walls:r}}var Dn=.88,tn=.27,Al=1.2,El=.01;function ai(e,t,n,o,r){let i=[.67,.71,.68],s=[i[0]*Dn,i[1]*Dn,i[2]*Dn],a=u=>!!r&&r.some((f,c)=>c!==u&&f?.belowY!=null&&Math.abs(f.belowY-t[u].y)<1e-6&&t[c].blockId===t[u].blockId);for(let u=0;u<t.length;u++){let f=t[u];if(!(f.pts.length<2))for(let c of[0,f.pts.length-1]){let l=f.pts[c],h=f.pts[c===0?1:c-1],m=l.x-h.x,d=l.y-h.y,p=Math.hypot(m,d);if(p<1e-5)continue;m/=p,d/=p;let y=1/0;for(let v=0;v<n.length;v++){let T=n[v],F=n[(v+1)%n.length],L=F.x-T.x,B=F.y-T.y,N=m*B-d*L;if(Math.abs(N)<1e-8)continue;let j=T.x-l.x,D=T.y-l.y,V=(j*B-D*L)/N,X=(j*d-D*m)/N;V>0&&X>=0&&X<=1&&(y=Math.min(y,V))}let x=.3/w,g=y-.04/w;if(!Number.isFinite(y)||y*w>2||g-x<.12/w)continue;let P=!!o&&a(u),E=r?.[u]?.pitch,S=P&&E&&Number.isFinite(E)?Math.min(Al/w,Math.max(tn/w,E-tn/w-El/w)):tn/w,b=-d,I=m;o&&b*(o.x-l.x)+I*(o.y-l.y)<0&&(b=-b,I=-I);let M=tn/w,R=[{x:l.x+m*x+b*M,y:l.y+d*x+I*M},{x:l.x+m*g+b*M,y:l.y+d*g+I*M},{x:l.x+m*g-b*S,y:l.y+d*g-I*S},{x:l.x+m*x-b*S,y:l.y+d*x-I*S}];if(!R.every(v=>xe(n,v.x,v.y)))continue;let _=r?.[u]?.belowY,k=_==null?0:f.y-_,O=!!o&&k>.03&&k<=.65;if(O&&o){let v=(T,F)=>Math.hypot((T.x+F.x)/2-o.x,(T.y+F.y)/2-o.y);v(R[0],R[1])>v(R[3],R[2])&&(R=[R[3],R[2],R[1],R[0]])}let C=O?Math.ceil((k-1e-8)/.2):1,A=(v,T,F)=>({x:v.x+(T.x-v.x)*F,y:v.y+(T.y-v.y)*F});for(let v=0;v<C;v++){let T=v/C,F=(v+1)/C,L=[A(R[0],R[3],T),A(R[1],R[2],T),A(R[1],R[2],F),A(R[0],R[3],F)],B=f.y+.008-(O?k*(1-F):0);z(e,L,void 0,()=>B,B-(O?k/C+.1:.16),i,s,Y)}}}}function ci(e,t,n,o,r,i,s,a,u=!1){if(!t.outline||t.outline.length<3)return;let f=n.baseHeightM,c=n.objects.filter(g=>g.type==="shape"&&(g.role==="entrance"||g.role==="exit")),l=Go(o,a.tierTop);if(!r)return;let h=g=>r.deckAt(g.x,g.y),m=lr(t,s),d=m[0]??t.outline;if(r.rowLevels.length>=2){let g=jt(r.rowLevels),P=ur(rr(r.rowLevels,n.focal,g),m),E=si(Fn(r.rowLevels,n.focal,f),n.focal,Ln);for(let b of P){let I=Math.max(f,b.topY-li);for(let M of i.subtract(b.outline,I))Jr(e,M,b.holes,I,f,a.tierTop,a.tierWall,c,!u,E)}P.length||z(e,d,t.holes,()=>r.landingY,f,l,a.tierWall,Y);let S={tread:[l[0]*Y.top,l[1]*Y.top,l[2]*Y.top],riser:[l[0]*.72,l[1]*.72,l[2]*.72]};for(let b of m.length?m:[d])sr(e,r.rowLevels,n.focal,r.landingY,S,b,g);ii(e,r.rowLevels,n.focal,f),ai(e,r.rowLevels,t.outline,n.focal,g);return}let p=r.flat?1/0:Mr,y=g=>r.normalAt(g.x,g.y),x=r.flat?r.landingY:void 0;for(let g of i.subtract(d,x))z(e,g,t.holes,h,f,l,a.tierWall,Y,p,y)}function _l(e,t,n){let o=new Set;for(let s of e.objects)s.type==="section"&&o.add(s.id);let r=new Map;for(let s=0;s<t.length;s++){let a=n.seatOwner[s];if(!a||!o.has(a))continue;let u=n.bySection.get(a);if(u&&u.rowLevels.length>=2)continue;let f=t[s];if(f.kind==="booth")continue;let c=r.get(a);c||(c=new Map,r.set(a,c));let l=f.rowId||`__seat-${s}`,h=c.get(l);h||(h={pts:[],levelM:0,n:0},c.set(l,h)),h.pts.push({x:f.x,y:f.y}),h.levelM+=n.seatDeckY(s),h.n++}let i=[];for(let s of e.objects){if(s.type!=="section")continue;let a=n.bySection.get(s.id);if(a&&a.rowLevels.length>=2){let f=a.rowLevels.filter(c=>!c.patch).map(c=>({pts:c.pts,levelM:c.y}));f.length>=2&&i.push({sectionId:s.id,rows:f});continue}let u=r.get(s.id);u&&i.push({sectionId:s.id,rows:[...u.values()].map(f=>({pts:f.pts,levelM:f.levelM/f.n}))})}return i}function vl(e,t){let n=1/0;for(let o=0;o<t.length;o++){let r=t[o],i=t[(o+1)%t.length],s=i.x-r.x,a=i.y-r.y,u=Math.max(0,Math.min(1,((e.x-r.x)*s+(e.y-r.y)*a)/(s*s+a*a||1)));n=Math.min(n,Math.hypot(e.x-r.x-u*s,e.y-r.y-u*a))}return n}var li=.02;function Cl(e,t){let n=e.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=t.bySection.get(o.id);if(!r)return[];let i=1/0,s=-1/0,a=1/0,u=-1/0;for(let c of o.outline)c.x<i&&(i=c.x),c.x>s&&(s=c.x),c.y<a&&(a=c.y),c.y>u&&(u=c.y);let f=r.landingY;for(let c of r.rowLevels)f=Math.min(f,c.y-li);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:f,minX:i,maxX:s,minY:a,maxY:u}]});return(o,r,i)=>{let s=null;for(let a of n){if(o<a.minX-i||o>a.maxX+i||r<a.minY-i||r>a.maxY+i)continue;let u={x:o,y:r};if(!be(u,a.outline,a.holes)&&vl(u,a.outline)>i)continue;let f=Math.min(a.surface.deckAt(o,r),a.floorTop);(s===null||f<s)&&(s=f)}return s}}var kl=3,Tl=.4;function ui(e,t,n,o,r,i,s=!0){let a=_l(t,n,o);if(a.length<kl)return;let u=Qr(a,t.focal);if(!u)return;let f=Math.max(0,...u.rings.map(c=>c.arcs.reduce((l,h)=>l+h.binCount,0)))/u.binCount;e.setMaterial(5),ti(e,u,{bottomY:t.baseHeightM,tierFrontLevels:a.map(c=>Math.min(...c.rows.map(l=>l.levelM))),colors:{bandTop:Z(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??Z(r.tierWall,1.15),shellWall:i??r.tierWall},ao:Y,shapes:t.objects.filter(c=>c.type==="shape"),deriveShell:s&&f>=Tl,standTopNear:Cl(t,o)}),e.setMaterial(0)}var fi=4;var Ll=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"],[/\b(walls?|outline|boundary|perimeter)\b/i,"wall"]],Ol=1.2,Bl=12;function mi(e){if(e.heightM!==void 0)return!1;let t=ie(e);if(!t||t.length<3)return!1;let n=0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length];n+=Math.hypot(s.x-i.x,s.y-i.y)}return n*$<Bl*2?!1:2*Pt(t)/n*$<=Ol}function Nn(e){if(!e)return null;for(let[t,n]of Ll)if(t.test(e))return n;return null}var di="auto-rows-";function pi(e){return e.id.startsWith(di)&&!e.label}var Fl=1.15,Dl=.09,bi=6,Nl=34,Gl=.35,jl=6,Hl=.35,Xl=.75,Ul=12,Vl=2.5,Yl=40,Kl=[18,24],Wl=[12,16],hi=14,zl=.8,Zl=.6,$l=5,Ql=.3,yi=.4,xi=2,ql=400,Jl=2.6,eu=.8,tu=4,nu=26,ou=.7,ru=.5,iu=.985,su=1.5,au=1.8,cu=3,lu=25,uu=.985,fu=2,mu=6,hu=3,du=.1,pu=1.5,bu=1.6,yu=6e3,xu=.6,gu="#c3c7cd",Gn=300,Mu=240;function Su(e,t,n,o){if(!e.fill||!/^#[0-9a-f]{6}$/i.test(e.fill))return null;let r=Hn([...t]),i=new Set;for(let c of o)i.add(Math.floor(Math.atan2(c.y-r.y,c.x-r.x)*180/Math.PI/10));if(i.size*10<Mu)return null;let{h:s,s:a,l:u}=Co(vo(e.fill));return s<70/360||s>170/360||a<.2||u<.08||u>.75||n.some(c=>c!==e&&c.type==="shape"&&ie(c)?.some(l=>Vn(l,t)))?null:e.kind==="ellipse"?"oval-cricket":e.kind==="rect"?"pitch-football":null}var Iu="Estimated from the drawing; confirm with the venue.",Xn=e=>{if(!e.length)return null;let t=[...e].sort((o,r)=>o-r),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2},Hn=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length}),Pt=e=>{let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2};function Ru(e){return e.height!==void 0||e.rake!==void 0||e.elevation!==void 0||e.surfaceKind!==void 0}function Un(e){let t=new Map;for(let n of e){let o=t.get(n.rowId);o?o.push(n):t.set(n.rowId,[n])}return t}function Vn(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function Yn(e,t){let n=t[0],o=1/0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length],a=s.x-i.x,u=s.y-i.y,f=a*a+u*u,c=f>0?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*u)/f)):0,l={x:i.x+a*c,y:i.y+u*c},h=Math.hypot(e.x-l.x,e.y-l.y);h<o&&(o=h,n=l)}return n}function gi(e,t){let n=0,o=0;for(let r of e.values()){if(r.length<3)continue;let i=r[0],s=r[r.length-1],a=s.x-i.x,u=s.y-i.y,f=Math.hypot(a,u);if(f<1e-6)continue;let c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},l=Yn(c,t),h=l.x-c.x,m=l.y-c.y,d=Math.hypot(h,m);d<1e-6||(o+=Math.abs((-u*h+a*m)/(f*d))*r.length,n+=r.length)}return n?o/n:0}function Pu(e,t,n){let o=e.filter(p=>p.type==="shape"),r=o.find(p=>p.role==="stage");if(r){let p=ie(r);return p?{shape:r,centre:Hn(p),outline:p,inferred:!1}:null}if(!n.length)return null;let i=1/0,s=-1/0,a=1/0,u=-1/0;for(let p of n)i=Math.min(i,p.x),s=Math.max(s,p.x),a=Math.min(a,p.y),u=Math.max(u,p.y);let f=(s-i)*(u-a),c=[];for(let p of o){if(p.role)continue;let y=ie(p);if(!y)continue;let x=Pt(y);if(x*$*$<6||x>f)continue;let g=Math.min(...y.map(R=>R.x)),P=Math.max(...y.map(R=>R.x)),E=Math.min(...y.map(R=>R.y)),S=Math.max(...y.map(R=>R.y)),b=0;for(let R of n)R.x>g&&R.x<P&&R.y>E&&R.y<S&&Vn(R,y)&&b++;if(b>n.length*.05)continue;let I=Hn(y),M=gi(t,y);M>=zl&&c.push({shape:p,centre:I,outline:y,score:M,area:x,box:[g,E,P,S]})}let l=(p,y)=>y!==p&&y.area>p.area&&p.box[0]>=y.box[0]-1e-6&&p.box[1]>=y.box[1]-1e-6&&p.box[2]<=y.box[2]+1e-6&&p.box[3]<=y.box[3]+1e-6,h=c.filter(p=>!c.some(y=>l(p,y))),m=Math.max(0,...h.map(p=>p.score)),d=h.filter(p=>p.score>=m-.03).sort((p,y)=>y.area-p.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function wu(e,t,n){if(!n||n.length<3)return Math.hypot(e.x-t.x,e.y-t.y);let o=Yn(e,n);return Math.hypot(e.x-o.x,e.y-o.y)}function Mi(e){let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y);if(t.length<3)return t;let n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=[];for(let i of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}let r=[];for(let i=t.length-1;i>=0;i--){let s=t[i];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return[...o.slice(0,-1),...r.slice(0,-1)]}function Au(e){if(!e.length||e.length>yu)return[];let t=[...Un(e).values()],n=t.map((a,u)=>u),o=a=>n[a]===a?a:n[a]=o(n[a]),r=bu/$,i=t.map(a=>({minX:Math.min(...a.map(u=>u.x))-r,maxX:Math.max(...a.map(u=>u.x))+r,minY:Math.min(...a.map(u=>u.y))-r,maxY:Math.max(...a.map(u=>u.y))+r}));for(let a=0;a<t.length;a++)for(let u=a+1;u<t.length;u++){let f=i[a],c=i[u];if(f.maxX<c.minX||c.maxX<f.minX||f.maxY<c.minY||c.maxY<f.minY)continue;t[a].some(h=>t[u].some(m=>Math.hypot(h.x-m.x,h.y-m.y)<=r))&&(n[o(a)]=o(u))}let s=new Map;return t.forEach((a,u)=>{let f=o(u),c=s.get(f);c?c.push(...a):s.set(f,[...a])}),[...s.values()].filter(a=>new Set(a.map(u=>u.rowId)).size>=2)}function Eu(e,t,n){if(!t.length)return null;let o=t.filter(M=>n.tableIds.has(M.rowId)||M.kind==="booth").length>t.length/2,r=Un(t),i=!n.outline||gi(r,n.outline)>=Zl,s=0,a=0;for(let M of r.values()){if(M.length<2)continue;let R=M[0],_=M[M.length-1],k=_.x-R.x,O=_.y-R.y,C=Math.hypot(k,O);if(C<1e-6)continue;let A={x:(R.x+_.x)/2,y:(R.y+_.y)/2},v=i?n.outline?Yn(A,n.outline):n.focal:n.middle,T=-O/C,F=k/C;T*(v.x-A.x)+F*(v.y-A.y)<0&&(T=-T,F=-F),s+=T*M.length,a+=F*M.length}let u={x:t.reduce((M,R)=>M+R.x,0)/t.length,y:t.reduce((M,R)=>M+R.y,0)/t.length};if(Math.hypot(s,a)<1e-9){let M=i?n.focal:n.middle;s=M.x-u.x,a=M.y-u.y}let f=Math.hypot(s,a)||1,c={x:s/f,y:a/f},l=M=>-(M.x*c.x+M.y*c.y),h=M=>-M.x*c.y+M.y*c.x,m=1/0,d=-1/0,p=1/0,y=-1/0,x=1/0,g=new Map;for(let M of t){let R=l(M),_=h(M);m=Math.min(m,R),d=Math.max(d,R),p=Math.min(p,_),y=Math.max(y,_),i&&(x=Math.min(x,wu(M,n.focal,n.outline)));let k=M.logicalRowId??M.rowId,O=g.get(k);O?O.push(R):g.set(k,[R])}i||(x=Math.max(0,m-l(n.middle)));let P=[...g.values()].map(M=>Xn(M)).sort((M,R)=>M-R),E=[];if(!o)for(let M of P)E.length&&M-E[E.length-1]<Hl/$||E.push(M);let S=Ru(e),b=Ge(e,{floorBaseHeightM:n.baseHeightM}),I={id:e.id,section:e,authored:S,plane:n,facing:c,facesAction:i,hull:Mi(t),sample:t.filter((M,R)=>R%Math.ceil(t.length/ql)===0),frontD:m,backD:d,latMin:p,latMax:y,frontDistance:x,rowDepths:E,rowCount:E.length,level:0,height:b.height,rake:S?b.rake:0,backHeight:0};return I.backHeight=I.height+(d-m)*$*Math.tan(I.rake*Math.PI/180),I}function _u(e,t,n,o){if(e.length<2)return 0;let r=Math.max(1,t*$),i=n+Fl-o,s=0,a=0;for(let f=1;f<e.length;f++){let c=Math.max(Xl,(e[f]-e[f-1])*$),l=(i+Dl)*(r+c)/r;s+=l-i,a+=c,i=l,r+=c}let u=Math.atan(s/a)*180/Math.PI;return Math.round(Math.max(bi,Math.min(Nl,u))*10)/10}function vu(e,t,n=!1){if(!n&&e.facing.x*t.facing.x+e.facing.y*t.facing.y<Ql)return null;let o=-1/0,r=1/0,i=-1/0;for(let h of t.hull){o=Math.max(o,-(h.x*e.facing.x+h.y*e.facing.y));let m=-h.x*e.facing.y+h.y*e.facing.x;r=Math.min(r,m),i=Math.max(i,m)}if(Math.min(e.latMax,i)-Math.max(e.latMin,r)<(n?1e-6:yi*(e.latMax-e.latMin)))return null;let a=xi/$,u=new Map,f=new Map;for(let h of e.sample){let m=Math.floor((-h.x*e.facing.y+h.y*e.facing.x)/a),d=-(h.x*e.facing.x+h.y*e.facing.y);u.set(m,Math.min(u.get(m)??1/0,d))}for(let h of t.sample){let m=Math.floor((-h.x*e.facing.y+h.y*e.facing.x)/a),d=-(h.x*e.facing.x+h.y*e.facing.y);f.set(m,Math.max(f.get(m)??-1/0,d))}let c=[];for(let[h,m]of u){let d=f.get(h);d!==void 0&&c.push(m-d)}let l=c.length?Xn(c):e.frontD-o;return l<-1/$?null:l}function Cu(e,t){if(t.plane.floorIndex>=e.plane.floorIndex)return!1;let n=-1/0,o=1/0,r=1/0,i=-1/0;for(let u of t.hull){let f=-(u.x*e.facing.x+u.y*e.facing.y);n=Math.max(n,f),o=Math.min(o,f);let c=-u.x*e.facing.y+u.y*e.facing.x;r=Math.min(r,c),i=Math.max(i,c)}let s=Math.min(e.latMax,i)-Math.max(e.latMin,r),a=Math.min(e.backD,n)-Math.max(e.frontD,o);return s>yi*(e.latMax-e.latMin)&&a>1/$}function ku(e,t){let n=new Set;for(let o of e){let r=(Math.atan2(o.y-t.y,o.x-t.x)*180/Math.PI+360)%360;n.add(Math.floor(r/10))}return n.size/36}function Tu(e,t){let n=1/0,o=-1/0;for(let i of t.hull){let s=-(i.x*e.facing.x+i.y*e.facing.y);n=Math.min(n,s),o=Math.max(o,s)}let r=Math.max(0,Math.min(o-n,e.frontD-n));return t.height+r*$*Math.tan(t.rake*Math.PI/180)}function Lu(e,t){if(!e.facesAction)return!1;let n={x:-e.facing.y,y:e.facing.x},o=xi/$,r=Math.max(1,Math.ceil((e.backD-e.frontD)/o)),i={left:new Map,right:new Map};for(let a of t)if(!(a===e||a.plane.floorIndex!==e.plane.floorIndex)&&!(a.facing.x*e.facing.x+a.facing.y*e.facing.y>=iu))for(let u of a.sample){let f=-(u.x*e.facing.x+u.y*e.facing.y);if(f<e.frontD||f>e.backD)continue;let c=-u.x*e.facing.y+u.y*e.facing.x,l=c<e.latMin?"left":c>e.latMax?"right":null;if(!l)return!1;let h=Math.min(r-1,Math.floor((f-e.frontD)/o)),m=l==="left"?e.latMin-c:c-e.latMax;m<(i[l].get(h)?.gap??1/0)&&i[l].set(h,{gap:m,other:a})}let s=a=>{let u=a==="left"?e.latMin:e.latMax,f=0;for(let[c,{other:l}]of i[a]){if((l.facing.x*n.x+l.facing.y*n.y)*(a==="left"?1:-1)<ou)continue;let m=e.frontD+(c+.5)*o,d={x:-m*e.facing.x+u*n.x,y:-m*e.facing.y+u*n.y},p=-(d.x*l.facing.x+d.y*l.facing.y),y=-d.x*l.facing.y+d.y*l.facing.x;p<l.frontD&&y>=l.latMin&&y<=l.latMax&&f++}return f/r>=ru};return s("left")&&s("right")}function Ou(e,t){if(t.plane.floorIndex!==e.plane.floorIndex||t.facing.x*e.facing.x+t.facing.y*e.facing.y<uu)return!1;let n=1/0,o=-1/0,r=1/0;for(let a of t.hull){let u=-a.x*e.facing.y+a.y*e.facing.x;n=Math.min(n,u),o=Math.max(o,u),r=Math.min(r,-(a.x*e.facing.x+a.y*e.facing.y))}let i=(e.frontD-r)*$;if(i<-fu||i>mu)return!1;let s=Math.max(n-e.latMax,e.latMin-o);return s*$<=hu&&s*$>=-du}function Bu(e,t=!1,n=!1,o){let r=t?Wl:Kl,i=new Set(n?[]:e.filter(p=>!p.authored&&Lu(p,e))),s=[...e].sort((p,y)=>p.plane.floorIndex-y.plane.floorIndex||Number(i.has(y))-Number(i.has(p))||p.frontDistance-y.frontDistance);for(let p of i)o?.add(p.id);let a=(p,y,x)=>{let g=new Map,P=[],E=new Map,S=b=>{if(b.plane.floorIndex===0||b.plane.baseHeightM>0)return b.plane.baseHeightM;let I=E.get(b.plane.floorIndex-1);return I===void 0?b.plane.baseHeightM:I+fi};for(let b of s){if(i.has(b))b.height=S(b),b.level=0,b.rake=0,b.backHeight=b.height,g.set(b.id,void 0);else if(!b.authored){let M=S(b),R;for(let A of P){if(A.plane.floorIndex>b.plane.floorIndex)continue;if(Cu(b,A)){let L=Tu(b,A)+Jl;L>M&&(M=L,R=A);continue}let v=vu(b,A,i.has(A));if(v==null)continue;let T=n&&!!b.plane.stageDeck&&A.level===0&&A.plane.floorIndex===b.plane.floorIndex&&Math.max(0,v)*$<=tu,F=i.has(A)?A.height+su:T?A.backHeight:A.backHeight+Gl+Math.min(jl,Math.max(0,v)*$)*Math.tan(A.rake*Math.PI/180);F>M&&(M=F,R=A)}let _=p.get(b);_&&_.height>M+.01?(M=_.height,R=void 0):_=void 0,b.height=Math.round(Math.min(M,b.plane.baseHeightM+Yl)*100)/100;let k=!R&&!_&&b.height>b.plane.baseHeightM;if(b.level=R?R.level+1:_?_.level:k?1:0,b.rake=_u(b.rowDepths,b.frontDistance,b.height,b.plane.focalHeightM),!b.facesAction&&b.rowCount<$l)b.rake=0;else if(b.level===0){let A=Math.max(1e-6,(b.backD-b.frontD)*$);b.rake=Math.min(b.rake,Ul,Math.round(Math.atan(Vl/A)*1800/Math.PI)/10)}else b.rowCount>=2&&(b.rake=Math.max(b.rake,r[Math.min(b.level,r.length)-1]));let O=(b.backD-b.frontD)*$,C=R&&i.has(R)||_&&x?.has(_.id);if(y!==void 0&&C&&b.rowCount>=2&&(b.rake=y),t&&O>0&&b.height+O*Math.tan(b.rake*Math.PI/180)>b.plane.baseHeightM+hi){let A=Math.max(0,b.plane.baseHeightM+hi-b.height);b.rake=Math.max(bi,Math.round(Math.atan(A/O)*1800/Math.PI)/10)}n&&b.plane.stageDeck&&b.level>0&&(b.rake=Math.min(b.rake,nu)),b.backHeight=b.height+O*Math.tan(b.rake*Math.PI/180),g.set(b.id,R?.id??(_?g.get(_.id):void 0))}let I=b.plane.floorIndex;E.set(I,Math.min(E.get(I)??1/0,b.height)),P.push(b)}return g},u=a(new Map),f=new Map,c=p=>f.get(p)?.height??p.height;for(let p=!0,y=0;p&&y<e.length;y++){p=!1;for(let x of e)if(!(x.authored||i.has(x)))for(let g of e){let P=f.get(g)??g;g===x||P.height-P.plane.baseHeightM<pu||P.height<=c(x)+.01||Ou(x,g)&&(f.set(x,P),p=!0)}}let l=new Map(e.map(p=>[p.id,p])),h=e.filter(p=>!p.authored&&p.rowCount>=2&&i.has(l.get(u.get(p.id)??""))),m=h.length?Xn(h.map(p=>p.rake)):void 0;if(!f.size&&m===void 0)return u;let d=new Map([...new Set(f.values())].map(p=>[p,{...p}]));return a(new Map([...f].map(([p,y])=>[p,d.get(y)])),m,new Set(h.map(p=>p.id)))}var jn=(e,t)=>!!e&&e.x===t.x&&e.y===t.y;function Si(e,t={x:0,y:-40}){let n=et(e),o=new Map;for(let x of n){if(!x.sectionId)continue;let g=o.get(x.sectionId);g?g.push(x):o.set(x.sectionId,[x])}let r={focalInferred:!1,confident:!1,sections:[]},i=e.floors?.length?e.floors.map((x,g)=>({objects:x.objects,floorIndex:g,floorId:x.id,baseHeightM:x.baseHeightM??0,focal:x.focalPoint??e.focalPoint})):[{objects:e.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:e.focalPoint}],s=new Set(i.flatMap(x=>x.objects.filter(g=>g.type==="table").map(g=>g.id))),a=[],u,f=new Set,c=i.map(x=>{let g=C=>!e.floors?.length||C.floorId===x.floorId,P=Au(n.filter(C=>!C.sectionId&&C.kind!=="booth"&&!s.has(C.rowId)&&g(C))),E=[];for(let C of P){let A=Pe(Ce(Mi(C)),xu/$);if(n.some(T=>!g(T)&&Vn(T,A)))continue;let v=`${di}${x.floorIndex}-${E.length}`;f.add(v),o.set(v,C),E.push({type:"section",id:v,label:"",color:gu,outline:A})}let S=E.length?{...x,objects:[...x.objects,...E]}:x,b=new Set(S.objects.filter(C=>C.type==="section").map(C=>C.logicalSectionId??C.id)),I=[...o.entries()].filter(([C])=>b.has(C)).flatMap(([,C])=>C),M=Pu(S.objects,Un(I),I),R=S.focal;(M||S.focal&&!jn(S.focal,t))&&(r.confident=!0),M&&(r.stage??={id:M.shape.id,inferred:M.inferred,...S.floorId?{floorId:S.floorId}:{}},(M.inferred||jn(S.focal,t))&&(R=M.centre,r.focalInferred=!0));let _=M&&(!M.inferred||Pt(M.outline)*$*$<=Gn),k=M?void 0:u,O={tableIds:s,floorIndex:S.floorIndex,floorId:S.floorId,baseHeightM:S.baseHeightM,focal:k?.focal??R,outline:M?.outline??k?.outline,focalHeightM:k?.focalHeightM??S.baseHeightM+(M&&_?Ae({...M.shape,role:"stage"}).heightM:0),stageDeck:k?.stageDeck??!!(M&&_&&Pt(M.outline)*$*$<=Gn),middle:I.length?{x:I.reduce((C,A)=>C+A.x,0)/I.length,y:I.reduce((C,A)=>C+A.y,0)/I.length}:R};for(let C of S.objects){if(C.type!=="section")continue;let A=Eu(C,o.get(C.logicalSectionId??C.id)??[],O);A&&a.push(A)}return O.outline&&(u=O),jn(S.focal,O.focal)||(r.focal??=[]).push({...S.floorId?{floorId:S.floorId}:{},point:{...O.focal}}),{unit:S,plane:O,stage:M,planeSeats:I}}),l=i.flatMap(x=>x.objects).map(x=>x.type==="shape"&&!x.role&&(Nn(x.label)==="wall"||!Nn(x.label)&&mi(x))?{...x,role:"wall"}:x),h=ot({objects:l},n)!==null;h&&(r.indoor=!0);let m=new Set,d=Bu(a,h,ku(n,c[0]?.plane.focal??t)<eu,m),p=new Map(a.filter(x=>!x.authored).map(x=>[x.id,x])),y=c.map(({unit:x,plane:g,stage:P,planeSeats:E})=>x.objects.map(S=>{let b=S.type==="shape"&&!S.role&&S.id!==P?.shape.id?Nn(S.label):null;if(S.type==="shape"&&!S.role&&S.id!==P?.shape.id&&(b==="wall"||!b&&mi(S))&&S.type==="shape"){(r.roles??=[]).push({id:S.id,...g.floorId?{floorId:g.floorId}:{},role:"wall"});let{fill:A,...v}=S;return{...v,role:"wall"}}if(b&&S.type==="shape")return(r.roles??=[]).push({id:S.id,...g.floorId?{floorId:g.floorId}:{},role:b}),{...S,role:b};let M=P?.inferred&&S.id===P.shape.id&&S.type==="shape"?Su(S,P.outline,x.objects,E):null;if(M&&S.type==="shape")return r.stage?.id===S.id&&(r.stage.field=M),{...S,role:"stage",stageKind:M};let R=S.type==="shape"&&S.id===P?.shape.id&&S.heightM===void 0&&!S.stageKind&&a.some(A=>A.plane===g&&(m.has(A.id)||A.level===0&&A.facesAction&&A.rake<=cu&&(A.frontDistance+A.backD-A.frontD)*$>=lu)),_=R?{heightM:au}:{};if(P?.inferred&&S.id===P.shape.id&&S.type==="shape"&&Pt(P.outline)*$*$<=Gn)return r.stage?.id===S.id&&(r.stage.deck=!0),{...S,role:"stage",..._};if(R&&S.type==="shape"&&S.role==="stage")return{...S,..._};let k=S.type==="section"?p.get(S.id):void 0;if(!k||S.type!=="section")return S;let O=k.rowCount>=2&&k.rake>0;f.has(k.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:k.id,floorId:g.floorId,surfaceKind:O?"rakedRows":"flat",height:k.height,rake:k.rake,stackedOn:d.get(k.id)});let C={status:"inferred",source:"public-2d-topology",note:Iu};return{...S,height:k.height,rake:k.rake,surfaceKind:O?"rakedRows":"flat",physical3dProvenance:{height:C,rake:C,surfaceKind:C}}}));if(e.floors?.length){let x=e.floors.map((g,P)=>({...g,objects:y[P],focalPoint:c[P].plane.focal}));return{doc:{...e,floors:x,objects:x[0].objects,focalPoint:x[0].focalPoint},report:r}}return{doc:{...e,objects:y[0],focalPoint:c[0].plane.focal},report:r}}var Ii=/^[\p{L}\p{N}]{1,4}$/u,Fu=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function Ri(e,t){let n=t?.trim();if(!n)return e;let o=e.toLocaleLowerCase("en-US"),r=n.toLocaleLowerCase("en-US");if(o.startsWith(`${r} `)){let s=e.slice(n.length).trim();if(Ii.test(s))return s}let i=Fu.exec(e);if(i){let s=i[1].toLocaleLowerCase("en-US"),a=i[2].trim();if((r.startsWith(s)||s.startsWith(r))&&Ii.test(a))return a}return e}var Du=6,Nu=2.2,Pi=.1,Gu=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),ju=.3,Hu=1.8,Xu=.9,Uu=.55,Vu=1,wi=4e3,Yu=6,Ai="#d8a425",Ku="#e8c15a",Kn="#1c1608";function Ei(e){let t=e.accessibility;if(t?.length)return{icon:t.includes("wheelchair")?"wheelchair":t[0],color:Nt(t)};let n=e.commercial;return n?.obstructedView?{icon:"obstructedView",color:Ai,ink:Kn}:n?.restrictedView?{icon:"restrictedView",color:Ai,ink:Kn}:n?.premium?{icon:"premium",color:Ku,ink:Kn}:null}var Wu=6e3;function vi(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let u=new Map;for(let c of n)for(let l of c.objects)l.type==="section"&&l.zone&&u.set(l.id,l.zone);let f=new Map;for(let c=0;c<o.length;c++){let l=o[c],h=r.seatOwner[c],m=l.zoneId??(h?u.get(h):void 0);if(!m)continue;let d=f.get(m);d||(d={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},f.set(m,d)),d.n++,l.x<d.minX&&(d.minX=l.x),l.y<d.minY&&(d.minY=l.y),l.x>d.maxX&&(d.maxX=l.x),l.y>d.maxY&&(d.maxY=l.y),d.sumY+=r.seatDeckY(c)}for(let c of s){let l=f.get(c.id),h=[];for(let[m,d]of u)d===c.id&&h.push(m);if(!l||l.n===0){a.push({id:c.id,label:c.label,color:ne(c.color),sectionIds:h,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(c.focalPoint??i).x*w,1.5,(c.focalPoint??i).y*w]});continue}a.push({id:c.id,label:c.label,color:ne(c.color),sectionIds:h,seatCount:l.n,center:[(l.minX+l.maxX)/2*w,l.sumY/l.n,(l.minY+l.maxY)/2*w],radius:.5*Math.hypot((l.maxX-l.minX)*w,(l.maxY-l.minY)*w)||1,focalWorld:[(c.focalPoint??i).x*w,1.5,(c.focalPoint??i).y*w]})}}return a}function Ci(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:u}=e,f=[],c=[],l=[],h=new Map;for(let m of n)for(let d of m.objects){if(d.type!=="section"||!d.zone)continue;let p=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!p)continue;let y=t.floors?.[m.index]?.name?.trim().toLocaleLowerCase();if(n.length>1&&y===p)continue;let x=h.get(d.zone);x||h.set(d.zone,x=new Set),x.add(p)}for(let m of a)m.seatCount!==0&&(h.get(m.id)?.has(m.label.trim().toLocaleLowerCase())||f.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+Du,m.center[2]],color:t.zones?.find(d=>d.id===m.id)?.color}));{let m=new Map,d=new Map;for(let p=0;p<o.length;p++){let y=r.seatOwner[p];if(!y)continue;let x=m.get(y);x||(x={n:0,x:0,y:0,deck:0},m.set(y,x)),x.n++,x.x+=o[p].x,x.y+=o[p].y,x.deck+=r.seatDeckY(p);let g=d.get(y);g||(g={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},d.set(y,g)),g.minDeck=Math.min(g.minDeck,r.seatDeckY(p)),g.maxDeck=Math.max(g.maxDeck,r.seatDeckY(p)),o[p].x<g.minX&&(g.minX=o[p].x),o[p].x>g.maxX&&(g.maxX=o[p].x),o[p].y<g.minY&&(g.minY=o[p].y),o[p].y>g.maxY&&(g.maxY=o[p].y)}for(let p of n)for(let y of p.objects){if(y.type!=="section"||pi(y))continue;let x=m.get(y.id);if(!x||x.n===0)continue;let g=d.get(y.id),P=[x.x/x.n*w,x.deck/x.n,x.y/x.n*w],E=y.displayLabel||y.label||y.id;c.push({id:y.id,floorIndex:p.index,label:E,seatCount:x.n,center:P,radius:Math.max(1,Math.hypot(g.maxX-g.minX,g.maxY-g.minY)*.5*w),box:{min:[g.minX*w-.4,g.minDeck,g.minY*w-.4],max:[g.maxX*w+.4,g.maxDeck+1,g.maxY*w+.4]},focalWorld:[p.focal.x*w,p.baseHeightM+1.5,p.focal.y*w]});let S=t.floors?.[p.index]?.name?.trim().toLocaleLowerCase();n.length>1&&S===E.trim().toLocaleLowerCase()||f.push({id:`section:${y.id}`,kind:"section",text:E,anchor:[P[0],P[1]+Nu,P[2]],floorIndex:p.index})}}{for(let S of n)for(let b of S.objects){if(b.type!=="gaArea")continue;let I=ut(b.points);if(!I)continue;let M=b.displayLabel||b.label||b.id;f.push({id:`ga:${b.id}`,kind:"ga",text:b.capacity>0?`${M} \xB7 ${b.capacity.toLocaleString()}`:M,anchor:[I.x*w,S.baseHeightM+Hu,I.y*w],floorIndex:S.index})}let m=new Map,d=new Map;for(let S of n)for(let b of S.objects)if(b.type==="section"&&m.set(b.id,b.displayLabel||b.label||b.id),b.type==="row"){let I=b.displayLabel?.trim()||b.segmentedRow?.displayLabel?.trim();I&&d.set(b.id,I)}let p=new Map;for(let S=0;S<o.length;S++){let b=o[S],I=Math.hypot(b.x-u.x,b.y-u.y),M=p.get(b.rowId);(!M||I>M.far)&&p.set(b.rowId,{seat:b,index:S,far:I})}for(let[S,b]of p){let I=r.seatOwner[b.index]??b.seat.sectionId,M=_i(b.seat.label,S,m.get(I??""),d.get(S));M&&f.push({id:`row:${S}`,kind:"row",text:M,anchor:[b.seat.x*w,r.seatDeckY(b.index)+Xu,b.seat.y*w],floorIndex:s[b.index]})}let y=new Map;for(let S=0;S<o.length;S++){let b=o[S],I=y.get(b.rowId);I||(I={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:_i(b.label,b.rowId,m.get(r.seatOwner[S]??b.sectionId??""),d.get(b.rowId)),sectionId:r.seatOwner[S]??b.sectionId},y.set(b.rowId,I));let M=S*3,R=i.iPosition[M],_=i.iPosition[M+1],k=i.iPosition[M+2];I.n++,I.x+=R,I.y+=_,I.z+=k,I.minX=Math.min(I.minX,R),I.maxX=Math.max(I.maxX,R),I.minZ=Math.min(I.minZ,k),I.maxZ=Math.max(I.maxZ,k)}for(let[S,b]of y)l.push({id:S,label:b.label,sectionId:b.sectionId,seatCount:b.n,center:[b.x/b.n,b.y/b.n,b.z/b.n],radius:Math.max(.8,Math.hypot(b.maxX-b.minX,b.maxZ-b.minZ)*.5)});let x=0,g=(S,b)=>{x++,f.push({id:`access:${o[S].id}`,kind:"access",text:"",icon:b.icon,color:b.color,...b.ink?{ink:b.ink}:{},seatWidthM:i.iChairWidth[S]*2,anchor:[o[S].x*w,r.seatDeckY(S)+Vu,o[S].y*w],floorIndex:s[S],rowId:o[S].rowId})},P=null,E=()=>{if(P){let S=Ei(o[P.seats[0]]),b=P.seats.length,I=Math.max(1,Math.round(b/Yu));for(let M=0;M<I&&x<wi;M++)g(P.seats[Math.min(b-1,Math.floor((M+.5)*b/I))],S)}P=null};for(let S=0;S<o.length&&x<wi;S++){let b=Ei(o[S]);if(b&&o[S].accessibility?.length){E(),g(S,b);continue}if(!b){E();continue}P&&P.rowId===o[S].rowId&&P.icon===b.icon?P.seats.push(S):(E(),P={rowId:o[S].rowId,icon:b.icon,seats:[S]})}if(E(),o.length<=Wu)for(let S=0;S<o.length;S++){let b=o[S],I=zu(b.displayLabel||b.label);I&&f.push({id:`seat:${b.id}`,kind:"seat",seatWidthM:i.iChairWidth[S]*2,text:I,anchor:[b.x*w,r.seatDeckY(S)+Uu,b.y*w],floorIndex:s[S],rowId:b.rowId})}}for(let m of n)for(let d of m.objects)if(d.type==="shape"&&d.role&&Gu.has(d.role)){let p=ie(d),y=p?ut(p):null;if(!y||!d.label)continue;f.push({id:`architecture:${d.id}`,kind:d.role==="stage"?"stage":"annotation",text:d.label,anchor:[y.x*w,m.baseHeightM+Ae(d).heightM+Pi,y.y*w],color:d.fill,floorIndex:m.index})}else if(d.type==="text"){if(!d.text)continue;f.push({id:`text:${d.id}`,kind:"annotation",text:d.text,anchor:[d.position.x*w,m.baseHeightM+Pi,d.position.y*w],color:d.color,rotation:d.rotation,floorIndex:m.index})}else if(d.type==="booth"){let p=Ee(d);if(!p)continue;let y=ut(p);if(!y)continue;f.push({id:`booth:${d.id}`,kind:"booth",text:d.displayLabel||d.label||d.id,anchor:[y.x*w,m.baseHeightM+$t+ju,y.y*w],floorIndex:m.index})}return{labels:f,sections:c,rows:l}}function ki(e,t){if(t.length>1)for(let n of t)e.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function zu(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function _i(e,t,n,o){if(o?.trim())return o.trim();let r=e?e.lastIndexOf("-"):-1,i=r>0?e.slice(0,r):t;return i&&Ri(i,n)}function Ti(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,u=[];{let f=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let h=0;h<i.floor.length;h+=1){let m=Math.max(0,Math.min(n.length-1,Math.round(i.floor[h]))),d=h*3,p=f[m];p.minX=Math.min(p.minX,i.position[d]),p.minY=Math.min(p.minY,i.position[d+1]),p.minZ=Math.min(p.minZ,i.position[d+2]),p.maxX=Math.max(p.maxX,i.position[d]),p.maxY=Math.max(p.maxY,i.position[d+1]),p.maxZ=Math.max(p.maxZ,i.position[d+2])}let c=new Map;for(let h=0;h<n.length;h++)for(let m of n[h].objects)m.type==="section"&&c.set(m.id,h);let l=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let h=0;h<o.length;h++){let m=r.seatOwner[h],d=(m!==null?c.get(m):void 0)??s[h];if(d===void 0)continue;let p=l[d],y=o[h];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 x=r.seatDeckY(h);p.sumX+=y.x*w,p.sumDeck+=x,p.sumZ+=y.y*w,p.minDeck=Math.min(p.minDeck,x),p.maxDeck=Math.max(p.maxDeck,x+1.6),a[h]=d}for(let h=0;h<n.length;h++){let m=l[h],d=t.floors?.[h],p=f[h],y=Math.min(m.n?m.minX*w:n[h].focal.x*w-1,Number.isFinite(p.minX)?p.minX:1/0),x=Math.max(m.n?m.maxX*w:n[h].focal.x*w+1,Number.isFinite(p.maxX)?p.maxX:-1/0),g=Math.min(m.n?m.minY*w:n[h].focal.y*w-1,Number.isFinite(p.minZ)?p.minZ:1/0),P=Math.max(m.n?m.maxY*w:n[h].focal.y*w+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),E=Math.min(m.n?Math.min(n[h].baseHeightM,m.minDeck):n[h].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),S=Math.max(m.n?Math.max(m.maxDeck,E+.5):E+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),b=[m.n?m.sumX/m.n:(y+x)/2,m.n?m.sumDeck/m.n:(E+S)/2,m.n?m.sumZ/m.n:(g+P)/2],I=Math.max(1,.5*Math.hypot(x-y,S-E,P-g));u.push({index:h,id:d?.id??`floor-${h}`,label:d?.name??(n.length>1?`Floor ${h+1}`:"Venue"),seatCount:m.n,center:b,radius:I,box:{min:[y,E,g],max:[x,S,P]},focalWorld:[n[h].focal.x*w,n[h].baseHeightM+1.5,n[h].focal.y*w]})}}return u}function Wn(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,u)=>{a<n&&(n=a),u<o&&(o=u),a>r&&(r=a),u>i&&(i=u)};for(let a of t)s(a.x,a.y);for(let a of e)for(let u of a.objects)if(u.type==="section")for(let f of u.outline)s(f.x,f.y);else if(u.type==="shape"&&u.points)for(let f of u.points)s(f.x,f.y);else if(u.type==="gaArea")for(let f of u.points)s(f.x,f.y);else if(u.type==="booth"){let f=Ee(u);if(f)for(let c of f)s(c.x,c.y)}else if(u.type==="table"){let f=Qt(u);if(f)for(let c of f)s(c.x,c.y)}else if(u.type==="decorImage"){let f=qt(u);if(f)for(let c of f)s(c.x,c.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function Ni(e,t,n,o,r,i,s){if(t.length===1){let a=n.map(h=>({x:h.x,y:h.y}));for(let h of t[0].objects)h.type==="section"?a.push(...h.outline):h.type==="shape"?a.push(...ie(h)??h.points??[]):h.type==="gaArea"?a.push(...h.points):h.type==="booth"?a.push(...Ee(h)??[]):h.type==="table"?a.push(...Qt(h)??[]):h.type==="decorImage"&&a.push(...qt(h)??[]);if(Bi(e,t[0],n,i)||Di(e,t[0],n,a,i))return!1;if(s&&Oi(e,t[0].baseHeightM,a,i,s))return!0;let u=gt(a),f=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2,l=u.length>=3?u.map(h=>{let m=h.x-f,d=h.y-c,p=Math.max(1,Math.hypot(m,d));return{x:h.x+m/p*80,y:h.y+d/p*80}}):bt(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return z(e,l,void 0,()=>-.04,-.22,i.ground,i.ground,Y),!1}else{let a=t.reduce((y,x)=>x.baseHeightM<y.baseHeightM?x:y);e.setFloor(a.index);let u={...a,objects:t.flatMap(y=>y.objects)},f=n.map(y=>({x:y.x,y:y.y}));for(let y of u.objects)y.type==="section"&&f.push(...y.outline);if(Bi(e,u,n,i)||Di(e,u,n,f,i))return!1;if(s&&Oi(e,a.baseHeightM,f,i,s))return!0;let c=n.filter((y,x)=>o[x]===a.index),l=Wn([a],c),h=Math.hypot(l.maxX-l.minX,l.maxY-l.minY),m=Math.max(28,Math.min(80,h*.04)),d=bt(l.minX-m,l.minY-m,l.maxX-l.minX+m*2,l.maxY-l.minY+m*2),p=a.baseHeightM-.03;return z(e,d,void 0,()=>p,p-.22,i.ground,i.ground,Y),!1}}function zn(e,t,n,o){let{cx:r,cz:i,radius:s}=n,a=1/0,u=1/0,f=1/0,c=-1/0,l=-1/0,h=-1/0,m=(y,x,g)=>{a=Math.min(a,y),c=Math.max(c,y),u=Math.min(u,x),l=Math.max(l,x),f=Math.min(f,g),h=Math.max(h,g)};for(let y=0;y<e.position.length;y+=3){let x=y/3;o&&x>=o[0]&&x<o[1]||m(e.position[y],e.position[y+1],e.position[y+2])}for(let y=0;y<t.count;y++){let x=y*3,g=t.iPosition[x],P=t.iPosition[x+1],E=t.iPosition[x+2],S=Math.max(.35,t.iMaxRadius[y]??.35);m(g-S,P,E-S),m(g+S,P+1.6,E+S)}Number.isFinite(a)||(a=r-s,c=r+s,u=0,l=s*.16,f=i-s,h=i+s);let d=[(a+c)/2,(u+l)/2,(f+h)/2],p=Math.max(1,.5*Math.hypot(c-a,l-u,h-f));return{center:d,radius:p,minY:u,maxY:l}}var Zu=4096;function Gi(e,t,n=[]){let o=Math.max(1,Math.ceil(e.count/Zu)),r=Math.ceil(e.count/o),i=new Float32Array((r*2+t.length*4+n.length)*3),s=0;for(let a=0;a<e.count;a+=o){let u=e.iPosition[a*3],f=e.iPosition[a*3+1],c=e.iPosition[a*3+2];i[s++]=u,i[s++]=f,i[s++]=c,i[s++]=u,i[s++]=0,i[s++]=c}for(let[a,u,f]of n)i[s++]=a,i[s++]=u,i[s++]=f;for(let a of t)for(let[u,f]of[[-1,-1],[1,-1],[1,1],[-1,1]])i[s++]=a.cx+u*a.halfX,i[s++]=a.y,i[s++]=a.cz+f*a.halfZ;return i.subarray(0,s)}function ji(e,t,n,o,r,i,s=[]){let a=1/0,u=1/0,f=-1/0,c=-1/0;for(let S=0;S<e.count;S++){let b=S*3,I=e.iPosition[b],M=e.iPosition[b+2];I<a&&(a=I),I>f&&(f=I),M<u&&(u=M),M>c&&(c=M)}for(let[S,,b]of s)S<a&&(a=S),S>f&&(f=S),b<u&&(u=b),b>c&&(c=b);for(let S of t)a=Math.min(a,S.cx-S.halfX),f=Math.max(f,S.cx+S.halfX),u=Math.min(u,S.cz-S.halfZ),c=Math.max(c,S.cz+S.halfZ);let l=n.minX*w,h=n.maxX*w,m=n.minY*w,d=n.maxY*w,p=l,y=h,x=m,g=d;if(Number.isFinite(a)){let S=Math.max(2,.06*Math.hypot(f-a,c-u));p=Math.max(l,a-S),y=Math.min(h,f+S),x=Math.max(m,u-S),g=Math.min(d,c+S)}let P=Math.min(0,o),E=Math.max(r,i*.05);return{min:[p,P,x],max:[y,E,g]}}var Li=12,$u=.6,Qu=40;function Oi(e,t,n,o,r){let i=gt([...n]);if(i.length<3)return!1;let s=1/0,a=1/0,u=-1/0,f=-1/0;for(let E of i)s=Math.min(s,E.x),u=Math.max(u,E.x),a=Math.min(a,E.y),f=Math.max(f,E.y);let c=Math.hypot(u-s,f-a)*w,l=Pe(i,Li/w,1.2),h=Math.max(Qu,c*$u),m=Pe(i,(Li+h)/w,1.2);if(l.length!==m.length)return!1;let d=te(o.ground,[.78,.76,.72],.35),p=te(o.ground,[.56,.62,.52],.3);z(e,l,void 0,()=>t-.04,t-.22,d,d,Y);let y=t-.05,x=l.map(E=>[E.x*w,y,E.y*w]),g=m.map(E=>[E.x*w,y,E.y*w]),P=[0,1,0];for(let E=0;E<x.length;E++){let S=(E+1)%x.length;e.tri(x[E],g[S],g[E],P,p,r,r),e.tri(x[E],x[S],g[S],P,p,p,r)}return!0}function Bi(e,t,n,o){let r=ot(t,n);if(!r)return!1;let i=t.baseHeightM,s=te(o.ground,[.62,.55,.47],.4);return z(e,r,void 0,()=>i-.04,i-.22,s,s,Y),!0}var qu=3e3,Ju=20,Fi=1.5,ef=1.2,tf=.25;function Di(e,t,n,o,r){if(!n.length||n.length>qu||o.length<3)return!1;for(let R of t.objects){if(R.type==="shape"&&_t(R.stageKind))return!1;if(R.type==="section"){let{height:_}=Ge(R,{floorBaseHeightM:t.baseHeightM});if(_-t.baseHeightM>Ju)return!1}}let i=0,s=0;for(let R of o)i+=R.x,s+=R.y;i/=o.length,s/=o.length;let a=0,u=0,f=0;for(let R of o){let _=R.x-i,k=R.y-s;a+=_*_,u+=k*k,f+=_*k}let c=.5*Math.atan2(2*f,a-u),l=Math.cos(c),h=Math.sin(c),m=-h,d=l,p=1/0,y=-1/0,x=1/0,g=-1/0;for(let R of o){let _=(R.x-i)*l+(R.y-s)*h,k=(R.x-i)*m+(R.y-s)*d;p=Math.min(p,_),y=Math.max(y,_),x=Math.min(x,k),g=Math.max(g,k)}let P=R=>[[p-R,x-R],[y+R,x-R],[y+R,g+R],[p-R,g+R]].map(([_,k])=>({x:i+l*_+m*k,y:s+h*_+d*k})),E=P(Fi/w),S=P((Fi+tf)/w),b=t.baseHeightM,I=te(r.ground,[.62,.55,.47],.4),M=te(r.ground,[.86,.86,.84],.55);return z(e,S,void 0,()=>b-.04,b-.22,I,I,Y),z(e,S,[E.slice().reverse()],()=>b+ef,b-.04,te(M,[1,1,1],.2),M,Y),!0}function Hi(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=fo(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let l of n)for(let h of l.objects)h.type==="shape"&&i.set(h.id,{shape:h,unit:l});let s=new Set,a=new Set,u=new Map((t.overlay.productionElements??[]).map(l=>{let h=l.runtimeContentImageUrl;return[l.id,typeof h=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(h)?h:void 0]})),f=[];for(let l of r.value.overlay.productionElements??[]){let h=i.get(l.objectId),m=h?ie(h.shape):null,d=l.baseElevationM??0;if(!h||!m||m.length<3||!l.id||s.has(l.id)||a.has(l.objectId)||!Number.isFinite(l.heightM)||l.heightM<.05||l.heightM>50||!Number.isFinite(d)||d<-10||d>100)return o();s.add(l.id),a.add(l.objectId);let p=m.map(M=>M.x*w),y=m.map(M=>M.y*w),x=h.unit.baseHeightM+d,g=Math.min(...p),P=Math.max(...p),E=Math.min(...y),S=Math.max(...y),b,I=u.get(l.id)??l.contentImageUrl;if(l.kind==="screen"&&I&&(b=Ir(m,x,x+l.heightM,h.unit.focal),!b))if(P-g>=S-E){let M=Math.abs(E-h.unit.focal.y*w)<=Math.abs(S-h.unit.focal.y*w)?E-.006:S+.006;b=[[g,x,M],[P,x,M],[g,x+l.heightM,M],[P,x+l.heightM,M]]}else{let M=Math.abs(g-h.unit.focal.x*w)<=Math.abs(P-h.unit.focal.x*w)?g-.006:P+.006;b=[[M,x,E],[M,x,S],[M,x+l.heightM,E],[M,x+l.heightM,S]]}f.push({id:l.id,objectId:l.objectId,kind:l.kind,floorIndex:h.unit.index,baseY:x,topY:x+l.heightM,bounds:{min:[g,x,E],max:[P,x+l.heightM,S]},occlusion:l.occlusion,...I?{contentImageUrl:I}:{},...b?{contentPlane:b}:{}})}let c=f.sort((l,h)=>l.id.localeCompare(h.id));return{byObjectId:new Map(c.map(l=>[l.objectId,l])),elements:c}}var Xi=[.13,.14,.17],ct=[.4,.43,.47],nf=.18,of=.02,rf=2.4,sf=1500,af=240,cf=.25;function Ui(e,t,n,o){let r=t.stageKind??"";if(We(r)||r==="round"||!o.length)return;let i=ie(t);if(!i||i.length<3)return;let s={x:i.reduce((T,F)=>T+F.x,0)/i.length,y:i.reduce((T,F)=>T+F.y,0)/i.length},a=0,u=0,f=new Set;for(let T of o)a+=T.x,u+=T.y,f.add(Math.floor(Math.atan2(T.y-s.y,T.x-s.x)*180/Math.PI/10));let c=s.x-a/o.length,l=s.y-u/o.length,h=Math.hypot(c,l);if(h<1e-6)return;let m=o.reduce((T,F)=>T+Math.hypot(F.x-s.x,F.y-s.y),0)/o.length;if(f.size*10>af&&h<cf*m)return;let d=c/h,p=l/h,y=-p,x=d,g=-1/0,P=1/0,E=1/0,S=-1/0;for(let T of i){let F=(T.x-s.x)*d+(T.y-s.y)*p,L=(T.x-s.x)*y+(T.y-s.y)*x;g=Math.max(g,F),P=Math.min(P,F),E=Math.min(E,L),S=Math.max(S,L)}let b=(S-E)*w,I=(g-P)*w;if(b<3||I<1.5||b*I>sf)return;let M=nf/w,R=(T,F)=>({x:s.x+d*T+y*F,y:s.y+p*T+x*F}),_=(T,F,L,B)=>[R(T,L),R(T,B),R(F,B),R(F,L)],k=n+Math.max(3.5,Math.min(8,b*.35)),O=n+Math.min(rf,k-n-1),C=.2/w,A=P+Math.min(I*.25,1.5)/w,v=of/w;z(e,_(g-2*M+v,g-M-v,E+M+C,S-M-C),void 0,()=>O,n,Xi,Xi,Y);for(let[T,F]of[[E+M,E+M+C],[S-M-C,S-M]])z(e,_(g-2*M,g-M,T,F),void 0,()=>k+.3,n,ct,ct,Y),z(e,_(A+C,g-2*M,T,F),void 0,()=>k+.3,k,ct,ct,Y);z(e,_(A,A+C,E+M,S-M),void 0,()=>k+.3,k,ct,ct,Y)}function Se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Me(e){return Array.isArray(e)?e:[]}function lf(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!Se(n))continue;let o=Se(n.extensions)?n.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function nn(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function uf(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function ff(e,t){let n=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let i=0;i<4;i++)n[o*4+r]+=e[i*4+r]*t[o*4+i];return n}function mf(e){let t=nn(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:nn(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:nn(e.rotation,4),r=e.scale===void 0?[1,1,1]:nn(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,u]=o,f=Math.hypot(i,s,a,u);if(!(f>1e-8))return null;let c=i/f,l=s/f,h=a/f,m=u/f,d=c+c,p=l+l,y=h+h,x=c*d,g=c*p,P=c*y,E=l*p,S=l*y,b=h*y,I=m*d,M=m*p,R=m*y;return[(1-(E+b))*r[0],(g+R)*r[0],(P-M)*r[0],0,(g-R)*r[1],(1-(x+b))*r[1],(S+I)*r[1],0,(P+M)*r[2],(S-I)*r[2],(1-(x+E))*r[2],0,n[0],n[1],n[2],1]}function hf(e,t,n,o){return[e[0]*t+e[4]*n+e[8]*o+e[12],e[1]*t+e[5]*n+e[9]*o+e[13],e[2]*t+e[6]*n+e[10]*o+e[14]]}function df(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],u=e[6],f=e[10],c=i*f-s*u,l=s*a-r*f,h=r*u-i*a,m=t*c+n*l+o*h;if(Math.abs(m)<1e-12)return null;let d=1/m;return[c*d,l*d,h*d,(o*u-n*f)*d,(t*f-o*a)*d,(n*a-t*u)*d,(n*s-o*i)*d,(o*r-t*s)*d,(t*i-n*r)*d]}function Vi(e,t,n,o){let r=e[0]*t+e[1]*n+e[2]*o,i=e[3]*t+e[4]*n+e[5]*o,s=e[6]*t+e[7]*n+e[8]*o,a=Math.hypot(r,i,s)||1;return r/=a,i/=a,s/=a,[r,i,s]}function pf(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,o=null,r=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),s=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let a=e.subarray(n,n+i);if(s===1313821514&&!o)try{let u=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!Se(u))return null;o=u}catch{return null}else if(s===5130562&&!r)r=a;else return null;n+=i}return n===e.byteLength&&o&&r?{json:o,bin:r}:null}function bf(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function yf(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function xf(e,t,n){return n===5120?e.getInt8(t):n===5121?e.getUint8(t):n===5122?e.getInt16(t,!0):n===5123?e.getUint16(t,!0):n===5125?e.getUint32(t,!0):e.getFloat32(t,!0)}function gf(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=pf(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!Se(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=Me(o.extensionsUsed).filter(E=>typeof E=="string");if(i.includes("KHR_draco_mesh_compression")||lf(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||Me(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(Me(o.images).length||Me(o.textures).length)return{ok:!1,issue:"external_resource"};let s=Me(o.buffers);if(s.length!==1||!Se(s[0])||s[0].uri!==void 0||typeof s[0].byteLength!="number"||!Number.isInteger(s[0].byteLength)||s[0].byteLength<0||s[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let a=Me(o.accessors),u=Me(o.bufferViews),f=Me(o.meshes),c=Me(o.nodes),l=Me(o.scenes),h=typeof o.scene=="number"?o.scene:0;if(!Se(l[h]))return{ok:!1,issue:"unsupported_glb"};let m=new DataView(r.buffer,r.byteOffset,r.byteLength),d=(E,S,b)=>{if(typeof E!="number"||!Number.isInteger(E)||!Se(a[E]))return null;let I=a[E];if(I.type!==S||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!b.includes(I.componentType)||typeof I.bufferView!="number")return null;let M=u[I.bufferView];if(!Se(M)||M.buffer!==0||typeof M.byteLength!="number"||!Number.isInteger(M.byteLength)||M.byteLength<0)return null;let R=yf(I.type),_=bf(I.componentType),k=typeof M.byteStride=="number"?M.byteStride:R*_,O=typeof M.byteOffset=="number"?M.byteOffset:0,C=typeof I.byteOffset=="number"?I.byteOffset:0,A=O+C,v=C+(I.count-1)*k+R*_;if(!Number.isInteger(k)||!Number.isInteger(O)||!Number.isInteger(C)||k<R*_||O<0||C<0||O+M.byteLength>r.byteLength||v>M.byteLength)return null;let T=[];for(let F=0;F<I.count;F++){let L=[];for(let B=0;B<R;B++){let N=xf(m,A+F*k+B*_,I.componentType);if(!Number.isFinite(N))return null;L.push(N)}T.push(L)}return T},p=[],y=[],x=0,g=new Set,P=(E,S)=>{if(typeof E!="number"||!Number.isInteger(E)||!Se(c[E])||g.has(E))return!1;g.add(E);let b=c[E],I=mf(b);if(!I)return!1;let M=ff(S,I),R=df(M);if(!R)return!1;if(b.mesh!==void 0){if(typeof b.mesh!="number")return!1;let _=f[b.mesh];if(!Se(_))return!1;for(let k of Me(_.primitives)){if(!Se(k)||k.mode!==void 0&&k.mode!==4||!Se(k.attributes))return!1;let O=d(k.attributes.POSITION,"VEC3",[5126]),C=k.attributes.NORMAL===void 0?null:d(k.attributes.NORMAL,"VEC3",[5126]);if(!O||k.attributes.NORMAL!==void 0&&!C)return!1;let A=O.length;if(k.indices!==void 0){let T=typeof k.indices=="number"?a[k.indices]:null;A=Se(T)?T.count:void 0}if(typeof A!="number"||!Number.isInteger(A)||A%3!==0||(x+=A/3,x>1e5))return!1;let v=k.indices===void 0?O.map((T,F)=>[F]):d(k.indices,"SCALAR",[5121,5123,5125]);if(!v||v.length%3!==0||v.length!==A)return!1;for(let T=0;T<v.length;T+=3){let F=[v[T][0],v[T+1][0],v[T+2][0]];if(F.some(N=>!Number.isInteger(N)||N<0||N>=O.length))return!1;let L=F.map(N=>hf(M,...O[N])),B=null;if(!C){let N=L[1][0]-L[0][0],j=L[1][1]-L[0][1],D=L[1][2]-L[0][2],V=L[2][0]-L[0][0],X=L[2][1]-L[0][1],W=L[2][2]-L[0][2];B=Vi([1,0,0,0,1,0,0,0,1],j*W-D*X,D*V-N*W,N*X-j*V)}for(let N=0;N<3;N++)p.push(...L[N]),y.push(...C?Vi(R,...C[F[N]]):B)}}}for(let _ of Me(b.children))if(!P(_,M))return!1;return g.delete(E),!0};for(let E of Me(l[h].nodes))if(!P(E,uf()))return{ok:!1,issue:x>1e5?"triangle_limit":"unsupported_glb"};return!x||p.length!==x*9||y.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:x,position:new Float32Array(p),normal:new Float32Array(y)}}function Yi(e){try{return gf(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function Ki(e){let{doc:t}=e,n=Bo(t.theme),o=n.structure,r=cr(t,e.eventConfigurationId??t.eventConfigurationId),i=Hi(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new Bt,u=null;if(e.registeredShellGlb){let G=Yi(e.registeredShellGlb);if(G.ok){let H=G.position.length/3,q=new Float32Array(G.position.length),ue=n.materials.shell??o.tierWall;for(let fe=0;fe<H;fe++){let he=G.normal[fe*3+1],re=he<-.25?.4:.62+.38*Math.max(0,he);q[fe*3]=ue[0]*re,q[fe*3+1]=ue[1]*re,q[fe*3+2]=ue[2]*re}u={position:G.position,normal:G.normal,color:q,floor:new Float32Array(H).fill(-2),material:new Float32Array(H),count:H}}}let f=new Map;for(let G of r)for(let H of G.objects)f.set(H.id,G.index),H.type==="section"&&f.set(H.logicalSectionId??H.id,G.index);let c=s.map(G=>f.get(G.sectionId??"")??f.get(G.rowId??"")??0),l=Wn(r,s),h=a.vertexCount,d=Ni(a,r,s,c,l,o,te(n.background.top,n.background.bottom,.5))?a.vertexCount:h,p=jo(t,s),y=new Map,x=new Map;for(let G of t.categories??[])y.set(G.key,G.color),G.seatGlyph&&x.set(G.key,G.seatGlyph);let g=[],P=Sr(r,s,c),E=new Map;s.forEach((G,H)=>{let q=P.seatDeckY(H);Number.isFinite(q)&&E.set(G.rowId,Math.min(E.get(G.rowId)??1/0,q))});let S=new Float32Array(s.length),b=[],I=new Map((t.floors??[]).map((G,H)=>[G.id,H])),M=r.map(()=>[]);for(let G of s){let H=G.floorId?I.get(G.floorId)??0:0;M[Math.min(H,M.length-1)]?.push(G)}let R=(G,H)=>{if(!H||H.length<3)return!1;let q=Math.min(...H.map(re=>re.x)),ue=Math.max(...H.map(re=>re.x)),fe=Math.min(...H.map(re=>re.y)),he=Math.max(...H.map(re=>re.y));for(let re=0;re<G;re++)for(let se of M[re])if(!(se.x<q||se.x>ue||se.y<fe||se.y>he)&&be(se,H,void 0))return!0;return!1},_=null,k=G=>r.length===1?s:s.filter((H,q)=>c[q]===G),O=(G,H)=>{let q=Ee(G);if(!q)return!1;let ue=1/0,fe=1/0,he=-1/0,re=-1/0;for(let se of q)ue=Math.min(ue,se.x),he=Math.max(he,se.x),fe=Math.min(fe,se.y),re=Math.max(re,se.y);return s.some((se,_e)=>se.kind!=="booth"&&(r.length===1||c[_e]===H)&&se.x>ue&&se.x<he&&se.y>fe&&se.y<re&&xe(q,se.x,se.y))},C;for(let G=0;G<r.length;G++){let H=r[G];a.setFloor(G);let q=ot(H,k(G)),ue=0;if(q){let K=0;for(let le of H.objects)if(le.type==="section")for(let me of P.bySection.get(le.id)?.rowLevels??[])K=Math.max(K,me.y-H.baseHeightM);if(ue=pr(K),!C){let le=br(q);C={centre:[le.x*w,le.y*w]}}}let fe=new Ht,he=[],re=H.objects.filter(K=>K.type==="shape"&&(K.role==="entrance"||K.role==="exit")),se=H.objects.filter(K=>K.type==="section"&&!!K.outline&&K.outline.length>=3),_e=Wr(H.objects.filter(K=>K.type==="booth"),H.focal);for(let K of H.objects)if(K.type==="section"){let le=a.vertexCount;ci(a,K,H,Ho(K,p),P.bySection.get(K.id),fe,se,o,G>0&&R(G,K.outline));let me=a.vertexCount-le;me>0&&b.push({sectionId:K.id,start:le,count:me})}else if(K.type==="shape"){let le=i.byObjectId.get(K.id),me=g.length,Ye=q!==null&&K.role==="wall"&&!le;a.setMaterial(Ye?dr:(le?.kind??K.role)==="screen"?1:0);let Ke=K.role==="stage"&&!le?Zr(K,k(G)):Ye&&K.heightM===void 0?{...K,heightM:ue}:K,De=mr(Ke,he);if(Ur(a,Ke,H.baseHeightM+De.supportOffsetM,De.topOffsetM-De.supportOffsetM,o,H.focal,g,le,re),a.setMaterial(0),K.role==="stage"&&!le&&g.length>me&&(_??G)===G){_=G;let Ne=t.floors?.[G]?.id,lt=r.length>1&&Ne?s.filter(wt=>wt.floorId===Ne):s;Ui(a,Ke,g[g.length-1].y,lt)}}else K.type==="gaArea"?Yr(a,K,H.baseHeightM,ne(y.get(K.categoryKey)),o):K.type==="booth"?jr(a,K,H.baseHeightM,ne(y.get(K.categoryKey)),o,_e.get(K.id)??H.focal,O(K,G)):K.type==="table"?Xr(a,K,Math.max(H.baseHeightM,E.get(K.id)??H.baseHeightM),ne(K.fill??t.theme?.decorFill??"#232c40"),o,!!(K.fill??t.theme?.decorFill)):K.type==="decorImage"&&Vr(a,K,H.baseHeightM,o);ui(a,H,s,P,o,n.materials.shell,!u)}let A=r.length>1?{x:r.reduce((G,H)=>G+H.focal.x,0)/r.length,y:r.reduce((G,H)=>G+H.focal.y,0)/r.length}:t.focalPoint??{x:(l.minX+l.maxX)/2,y:(l.minY+l.maxY)/2},v=Eo(u?[a.build(),u]:[a.build()]),T=Zo(s,e.initialState,P,S,y,x),F=vi({doc:t,units:r,seats:s,surfaces:P,focal:A}),{labels:L,sections:B,rows:N}=Ci({doc:t,units:r,seats:s,surfaces:P,seatData:T,hintedSeatFloor:c,zones:F,focal:A}),j=new Map(B.map((G,H)=>[G.id,H]));P.seatOwner.forEach((G,H)=>{T.iSection[H]=G?j.get(G)??-1:-1});let D=Ti({doc:t,units:r,seats:s,surfaces:P,solids:v,hintedSeatFloor:c,seatFloor:S});ki(L,D),T.iYaw=zo(T.iPosition,s.length,G=>s[G].rowId,G=>{let H=r[S[G]]?.focal??A;return[H.x*w,H.y*w]});let V=(l.minX+l.maxX)/2*w,X=(l.minY+l.maxY)/2*w,W=.5*Math.hypot((l.maxX-l.minX)*w,(l.maxY-l.minY)*w)||10,U=zn(v,T,{cx:V,cz:X,radius:W},[h,d]),J=zn(v,T,{cx:V,cz:X,radius:W}),Q=Mf(r),ce=ji(T,g,l,U.minY,U.maxY,W,Q);return{sharedAisles:_o(r.flatMap(G=>G.objects.flatMap(H=>{if(H.type!=="section")return[];let q=P.bySection.get(H.id);return q?[{sectionId:H.id,floorIndex:G.index,rows:q.rowLevels}]:[]}))),solids:v,sectionSolidRanges:b,seats:T,seatSectionIds:P.seatOwner,bounds:{center:[(ce.min[0]+ce.max[0])/2,(ce.min[1]+ce.max[1])/2,(ce.min[2]+ce.max[2])/2],radius:W,groundY:0,box:ce,fitPoints:Gi(T,g,Q)},...C?{room:C}:{},...!C&&r.some(G=>G.objects.some(H=>H.type==="shape"&&_t(H.stageKind)))?{outdoor:!0}:{},renderBounds:{center:U.center,radius:U.radius},clipBounds:{center:J.center,radius:J.radius},stateColorLUT:Fo(n,Dt),theme:n,seatCount:s.length,focalWorld:[A.x*w,1.5,A.y*w],zones:F,stages:g,productionElements:i.elements,sections:B,rows:N,labels:L,floors:D}}function Mf(e){let t=[];for(let n of e)for(let o of n.objects){let r=o.type==="gaArea"?o.points:o.type==="booth"?Ee(o):null;for(let i of r??[])t.push([i.x*w,n.baseHeightM,i.y*w])}return t}function Sf(e,t){let{doc:n,report:o}=Si(e),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let u=new Map(o.roles.map(m=>[m.id,m.role])),f=m=>m.map(d=>d.type==="shape"&&u.has(d.id)?{...d,role:u.get(d.id)}:d),c=e.floors?.map(m=>({...m,objects:f(m.objects)})),l=new Float64Array(t.length).fill(Number.NaN),h=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((m,d)=>{m.eyeHeightM!==void 0&&(l[d]=m.eyeHeightM),m.focalPoint&&(h[d*2]=m.focalPoint.x,h[d*2+1]=m.focalPoint.y)}),{doc:{...e,objects:c?.[0]?.objects??f(e.objects),...c?{floors:c}:{}},report:o,eyeHeightM:l,focal:h}}let i=new Map(et(n).map(u=>[u.id,u])),s=new Float64Array(t.length).fill(Number.NaN),a=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((u,f)=>{let c=i.get(u.id)??u;c.eyeHeightM!==void 0&&(s[f]=c.eyeHeightM),c.focalPoint&&(a[f*2]=c.focalPoint.x,a[f*2+1]=c.focalPoint.y)}),{doc:n,report:o,eyeHeightM:s,focal:a}}function If(e,t){return e.map((n,o)=>{let r=t.eyeHeightM[o],i=t.focal[o*2],s=t.focal[o*2+1],a={...n};return Number.isNaN(r)?delete a.eyeHeightM:a.eyeHeightM=r,Number.isNaN(i)?delete a.focalPoint:a.focalPoint={x:i,y:s},a})}function Wi(e){let t=e.estimate===!1?null:Sf(e.doc,e.seats);return t?{input:{...e,doc:t.doc,seats:If(e.seats,t)},estimate:t}:{input:e}}function Rf(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(n=>n.buffer)}var zi=self;zi.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??et(e.data.doc),{input:r,estimate:i}=Wi({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),s=Ki(r),a=Rf(s);i&&a.push(i.eyeHeightM.buffer,i.focal.buffer),zi.postMessage({model:s,buildMs:performance.now()-t,...n?{seats:o}:{},...i?{estimate:i}:{}},a)};
|