@seatlayer/core 0.107.0 → 0.109.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/ar-TPTLODBK.js +1 -0
- package/dist/be-SX5AJ2EF.js +1 -0
- package/dist/bg-T7FBXPVU.js +1 -0
- package/dist/ca-TTI23CKH.js +1 -0
- package/dist/{categoryInventory-D8g-kaQ4.d.cts → categoryInventory-WNOXm5Il.d.cts} +1 -1
- package/dist/{categoryInventory-BfYSZRQ-.d.ts → categoryInventory-nNbloQGE.d.ts} +1 -1
- package/dist/{chunk-45W3GKPP.js → chunk-2JFCDE27.js} +1 -1
- package/dist/{chunk-JXIX3PNI.js → chunk-33SRM2CP.js} +1 -1
- package/dist/{chunk-T7DQX3MB.js → chunk-FBXZWNND.js} +1 -1
- package/dist/{chunk-WR6VXY5U.js → chunk-GPZFVQXV.js} +1 -1
- package/dist/chunk-GUXENCHS.js +1 -0
- package/dist/{chunk-YPGONGDK.js → chunk-HSEX7LUB.js} +1 -1
- package/dist/{chunk-MADX5HYP.js → chunk-JRZHC75P.js} +1 -1
- package/dist/{chunk-BBPJXOTD.js → chunk-LFV56MPT.js} +1 -1
- package/dist/{chunk-RI4LNRP4.js → chunk-MRLWH6RC.js} +1 -1
- package/dist/{chunk-QXJEN5LV.js → chunk-T2QG47QQ.js} +1 -1
- package/dist/{chunk-R6BN4HDQ.js → chunk-UEDS3HJ3.js} +1 -1
- package/dist/{chunk-VBNOTYBG.js → chunk-UNSAUDO2.js} +1 -1
- package/dist/{chunk-N562FZPD.js → chunk-UUIZHJYL.js} +1 -1
- package/dist/{chunk-LWBTU56C.js → chunk-WKWXU5QM.js} +1 -1
- package/dist/chunk-YE4NP3XB.js +1 -0
- package/dist/{chunk-74TZDIMP.js → chunk-ZYQXT5JP.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/render-assets/index.js +1 -1
- 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/cs-KEMKTFP3.js +1 -0
- package/dist/cy-EGUWNAAE.js +1 -0
- package/dist/da-AHX4SSIT.js +1 -0
- package/dist/de-U3ISXVMR.js +1 -0
- package/dist/el-NBMJFLGN.js +1 -0
- package/dist/es-IYOV3DZF.js +1 -0
- package/dist/et-QHFQ3BIM.js +1 -0
- package/dist/{eventConfigurations-Bw1zW-6G.d.cts → eventConfigurations-Dp0gQBxf.d.cts} +1 -1
- package/dist/{eventConfigurations-DD1i6TSa.d.ts → eventConfigurations-QwuBqi8E.d.ts} +1 -1
- package/dist/fa-FEFRLXP7.js +1 -0
- package/dist/fi-HB6NGCIV.js +1 -0
- package/dist/fr-5EX7Z5Z5.js +1 -0
- package/dist/he-MEW7GMCW.js +1 -0
- package/dist/hi-V2CICZDC.js +1 -0
- package/dist/hr-SUZYZ3DL.js +1 -0
- package/dist/hu-RJFHJPXB.js +1 -0
- package/dist/id-LEP73A6A.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +107 -14
- package/dist/index.d.ts +107 -14
- package/dist/index.js +1 -1
- package/dist/it-V65UNUVY.js +1 -0
- package/dist/ja-3HISSPHC.js +1 -0
- package/dist/ko-5DFMEYUO.js +1 -0
- package/dist/ku-H3EOMAJX.js +1 -0
- package/dist/{labeling-Bho4KGut.d.cts → labeling-Bzfv743A.d.cts} +1 -1
- package/dist/{labeling-DABtLO2e.d.ts → labeling-CLrYgex2.d.ts} +1 -1
- package/dist/localeLoaders-M2TUVL75.js +1 -0
- package/dist/lt-XHIM3BWS.js +1 -0
- package/dist/lv-P5EQD4YY.js +1 -0
- package/dist/ms-XC3SU4I2.js +1 -0
- package/dist/nl-K2N44NUV.js +1 -0
- package/dist/no-C4MFGLSN.js +1 -0
- package/dist/pl-ADABFEA3.js +1 -0
- package/dist/pt-4AQPHHDG.js +1 -0
- package/dist/{renderedQuality-BHQnbC9M.d.cts → renderedQuality-D7adZpeD.d.cts} +1 -1
- package/dist/{renderedQuality-DFbFLsci.d.ts → renderedQuality-DL_Bwohi.d.ts} +1 -1
- package/dist/{renderer-DiMguwVt.d.ts → renderer-BaX5XS07.d.cts} +34 -9
- package/dist/{renderer-BDdsk9AZ.d.cts → renderer-GIwwPupP.d.ts} +34 -9
- package/dist/ro-PZLP7BEU.js +1 -0
- package/dist/ru-33R4HJF2.js +1 -0
- package/dist/{seatTypeIcons-C_4CKG9D.d.ts → seatTypeIcons-BbHRuAXE.d.ts} +1 -1
- package/dist/{seatTypeIcons-DyJDDsaT.d.cts → seatTypeIcons-CnIsRKIM.d.cts} +1 -1
- package/dist/{sections-BHPs1PT8.d.ts → sections-BOaTNaYG.d.ts} +1 -1
- package/dist/{sections-BVrNW7Ne.d.cts → sections-DRiD7LLT.d.cts} +1 -1
- package/dist/{segmentedRowModel-DPZ8VAbP.d.cts → segmentedRowModel-C0MT2W3h.d.cts} +1 -1
- package/dist/{segmentedRowModel-2c46otTs.d.ts → segmentedRowModel-CDm8wEMA.d.ts} +1 -1
- package/dist/sk-XCXFOU73.js +1 -0
- package/dist/sl-23PMG7BB.js +1 -0
- package/dist/sr-SOPFKPZ5.js +1 -0
- package/dist/sv-PKDMDUS5.js +1 -0
- package/dist/{tableSizing-Dj5yxEn5.d.cts → tableSizing-BvWmV_II.d.cts} +3 -3
- package/dist/{tableSizing-C8A2XC6C.d.ts → tableSizing-CjeVoew4.d.ts} +3 -3
- package/dist/th-NU4K5DFF.js +1 -0
- package/dist/{ticketRestrictions-DsAql5wr.d.cts → ticketRestrictions-Cp_Wkjy9.d.cts} +2 -2
- package/dist/{ticketRestrictions-DE79a54T.d.ts → ticketRestrictions-P3RuwcmT.d.ts} +2 -2
- package/dist/tr-HEDRXONB.js +1 -0
- package/dist/{types-BZQ35nwD.d.cts → types-fSWyPu3f.d.cts} +3 -0
- package/dist/{types-BZQ35nwD.d.ts → types-fSWyPu3f.d.ts} +3 -0
- package/dist/uk-T7JNLCSZ.js +1 -0
- package/dist/vi-EWDKGL2Y.js +1 -0
- package/dist/view3d/crossfade/panorama.d.cts +1 -1
- package/dist/view3d/crossfade/panorama.d.ts +1 -1
- package/dist/view3d/index.cjs +32 -32
- package/dist/view3d/index.d.cts +3 -3
- package/dist/view3d/index.d.ts +3 -3
- package/dist/view3d/index.js +4 -4
- package/dist/view3d/scene/scene.worker.cjs +1 -1
- package/dist/view3d/scene/scene.worker.js +1 -1
- package/dist/zh-Hans-ED7CX2SQ.js +1 -0
- package/dist/zh-Hant-UKJQ2KBS.js +1 -0
- package/package.json +1 -1
- package/dist/ar-D6ASWQBI.js +0 -1
- package/dist/be-T23MSCFC.js +0 -1
- package/dist/bg-2MMSY43I.js +0 -1
- package/dist/ca-HSW3LSXH.js +0 -1
- package/dist/chunk-227OYVC4.js +0 -1
- package/dist/chunk-J33DNOMI.js +0 -1
- package/dist/cs-W36YX555.js +0 -1
- package/dist/cy-6264NCZV.js +0 -1
- package/dist/da-QPYLJUH7.js +0 -1
- package/dist/de-Q5VU4NBN.js +0 -1
- package/dist/el-HYLFHJC3.js +0 -1
- package/dist/es-N35HVHMD.js +0 -1
- package/dist/et-HQUPUM5Y.js +0 -1
- package/dist/fa-JL3HW42Q.js +0 -1
- package/dist/fi-ZFWROLPU.js +0 -1
- package/dist/fr-6EKBGKIT.js +0 -1
- package/dist/he-KSOTIRJW.js +0 -1
- package/dist/hi-72CF2RXB.js +0 -1
- package/dist/hr-2CRBTSQT.js +0 -1
- package/dist/hu-Y33MEJPT.js +0 -1
- package/dist/id-UW2QRTC3.js +0 -1
- package/dist/it-XFIJHKQA.js +0 -1
- package/dist/ja-LHVHSM5J.js +0 -1
- package/dist/ko-MCXETVAQ.js +0 -1
- package/dist/ku-MNPV6BJJ.js +0 -1
- package/dist/localeLoaders-UTZMQJQF.js +0 -1
- package/dist/lt-OVUV42OZ.js +0 -1
- package/dist/lv-3ZE6IM47.js +0 -1
- package/dist/ms-LF5QQTFJ.js +0 -1
- package/dist/nl-D4FX7T7U.js +0 -1
- package/dist/no-JLXHCMSU.js +0 -1
- package/dist/pl-TR5U2EPQ.js +0 -1
- package/dist/pt-HRM4OUMU.js +0 -1
- package/dist/ro-UFIOIOVH.js +0 -1
- package/dist/ru-VMRD53B7.js +0 -1
- package/dist/sk-4DALII6N.js +0 -1
- package/dist/sl-CDZGH6C6.js +0 -1
- package/dist/sr-KMFWIJPY.js +0 -1
- package/dist/sv-2JROBNJB.js +0 -1
- package/dist/th-MF3TSZDL.js +0 -1
- package/dist/tr-76YSRBN3.js +0 -1
- package/dist/uk-JQKEV42K.js +0 -1
- package/dist/vi-KRM5S2Q7.js +0 -1
- package/dist/zh-Hans-FEUYIOYS.js +0 -1
- package/dist/zh-Hant-PK2XOE2G.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as co,c as lo,d as uo}from"./chunk-45W3GKPP.js";import{b as $e,c as eo,d as io,e as so,h as ao}from"./chunk-LWBTU56C.js";import{v as fo}from"./chunk-QXJEN5LV.js";import{a as oo,c as qt,d as pt,f as xt,i as ro}from"./chunk-T7DQX3MB.js";import{e as to,l as no}from"./chunk-4N5CHKHD.js";import{n as oe}from"./chunk-JXIX3PNI.js";import{h as Sn}from"./chunk-R6BN4HDQ.js";import{Aa as Zt,Ba as An,C as Ye,Ca as Ze,D as Kt,Ga as ee,Ia as qe,Xa as Pt,ca as ze,da as Ke,eb as En,j as We,ka as $,la as Rt,ua as In,va as Vt,wa as _n,ya as Ve}from"./chunk-J33DNOMI.js";import{A as Et,D as Je,b as Qe,d as it,y as at}from"./chunk-JBOTRSMY.js";var re=t=>t<=.04045?t/12.92:((t+.055)/1.055)**2.4,ie=t=>t<=.0031308?12.92*t:1.055*Math.max(0,t)**.4166666666666667-.055,se=t=>Math.min(1,Math.max(0,t));function Bn(t){let n=re(t[0]),e=re(t[1]),r=re(t[2]),o=Math.cbrt(.4122214708*n+.5363325363*e+.0514459929*r),s=Math.cbrt(.2119034982*n+.6806995451*e+.1073969566*r),i=Math.cbrt(.0883024619*n+.2817188376*e+.6299787005*r);return[.2104542553*o+.793617785*s-.0040720468*i,1.9779984951*o-2.428592205*s+.4505937099*i,.0259040371*o+.7827717662*s-.808675766*i]}function wn([t,n,e]){let r=(t+.3963377774*n+.2158037573*e)**3,o=(t-.1055613458*n-.0638541728*e)**3,s=(t-.0894841775*n-1.291485548*e)**3;return[se(ie(4.0767416621*r-3.3077115913*o+.2309699292*s)),se(ie(-1.2684380046*r+2.6097574011*o-.3413193965*s)),se(ie(-.0041960863*r-.7034186147*o+1.707614701*s))]}var Tn=t=>Bn(t)[0];function an(t){let[,n,e]=Bn(t);return Math.hypot(n,e)}function Xt(t,n,e){let[,r,o]=Bn(t);if(e===void 0)return wn([n,r,o]);let s=Math.hypot(r,o),i=s===0?0:e/s;return wn([n,r*i,o*i])}function mo(t,n,e){let[r,o,s]=Bn(t);return r>=n&&r<=e?t:wn([Math.min(e,Math.max(n,r)),o,s])}function On(t){return wn([t,-.004,-.008])}var cn=["available","held","sold","selected","dimmed"];function ae(t){let n=cn.indexOf(t);return n<0?0:n}var yo={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Mi(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.78,r=.86;return[(n+(t[0]-n)*e)*r,(n+(t[1]-n)*e)*r,(n+(t[2]-n)*e)*r]}var ho={day:{ground:.9,deck:.84,fascia:.77,shell:.79,seatMin:.45,seatMax:.58,unavailable:.58,dimmed:.62,sectionDeck:.66,sectionDeckChromaShare:.8,sectionDeckChromaCap:.11,stageTop:.52,stageWall:.42},night:{ground:.26,deck:.34,fascia:.28,shell:.32,seatMin:.64,seatMax:.8,unavailable:.42,dimmed:.39,sectionDeck:.34,sectionDeckChromaShare:.45,sectionDeckChromaCap:.05,stageTop:0,stageWall:0}},Cn=.012;function kn(t){return Tn(t.tierTop)>.6}function jt(t){return t?ho.day:ho.night}function nu(t,n){let e=jt(n);return mo(Mi(t),e.seatMin,e.seatMax)}var ce={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]},le={top:[.05,.06,.08],bottom:[.1,.12,.15]};function V(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}import Ri from"earcut";import xo from"polygon-clipping";var P=$,Pi=.002;function Si(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),i=Math.max(r,o,s);if(i<1e-9)return!0;let a=(r+o+s)/2;return 2*Math.sqrt(Math.max(0,a*(a-r)*(a-o)*(a-s)))/i<Pi}var Ut=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=n,this.buf[this.len++]=e,this.buf[this.len++]=r}push1(n){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=n}grow(n){let e=this.buf.length*2;for(;e<n;)e*=2;let r=new Float32Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},vn=class{constructor(){this.pos=new Ut;this.nor=new Ut;this.col=new Ut;this.flr=new Ut;this.mat=new Ut;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,r,o,s,i=s,a=s){Si(n,e,r)||(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(i[0],i[1],i[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(n,e,r,o,s,i,a,c=a,l=a){[...n,...e,...r].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(s[0],s[1],s[2]),this.nor.push3(i[0],i[1],i[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(c[0],c[1],c[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Ii(t,n,e){let r=n[0]-t[0],o=n[1]-t[1],s=n[2]-t[2],i=e[0]-t[0],a=e[1]-t[1],c=e[2]-t[2],l=o*c-s*a,u=s*i-r*c,f=r*a-o*i,m=Math.hypot(l,u,f)||1;return l/=m,u/=m,f/=m,[l,u,f]}function _i(t,n){let e=[...t],r=[];for(let i of t)r.push(i.x,i.y);let o=[];if(n){for(let i of n)if(!(i.length<3)){o.push(e.length);for(let a of i)e.push(a),r.push(a.x,a.y)}}let s=Ri(r,o.length?o:void 0,2);return{pts:e,tris:s}}function wt(t){return pt(t)<0?[...t].reverse():t}var Ai=3;function Ei(t,n,e,r){let o=r(t),s=r(n),i=r(e),a=(h,d,y,b)=>Math.abs(r({x:(h.x+d.x)/2,y:(h.y+d.y)/2})-(y+b)/2),c=(t.x+n.x+e.x)/3,l=(t.y+n.y+e.y)/3,u=(o+s+i)/3,f=Math.max(a(t,n,o,s),a(n,e,s,i),a(e,t,i,o),Math.abs(r({x:c,y:l})-u)),m=(h,d,y)=>{let b=Math.abs(r({x:(h+c)/2,y:(d+l)/2})-(y+u)/2);b>f&&(f=b)};return m((t.x+n.x)/2,(t.y+n.y)/2,(o+s)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(s+i)/2),m((e.x+t.x)/2,(e.y+t.y)/2,(i+o)/2),f}function ln(t,n,e,r,o){if(o<=0)return Ei(t,n,e,r);let s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},i={x:(n.x+e.x)/2,y:(n.y+e.y)/2},a={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max(ln(t,s,a,r,o-1),ln(s,n,i,r,o-1),ln(a,i,e,r,o-1),ln(s,i,a,r,o-1))}function un(t,n,e,r,o,s,i,a){if(i>0){let m={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+r.x)/2,y:(e.y+r.y)/2},d={x:(r.x+n.x)/2,y:(r.y+n.y)/2};un(t,n,m,d,o,s,i-1,a),un(t,m,e,h,o,s,i-1,a),un(t,d,h,r,o,s,i-1,a),un(t,m,h,d,o,s,i-1,a);return}let c=[n.x*P,o(n),n.y*P],l=[e.x*P,o(e),e.y*P],u=[r.x*P,o(r),r.y*P];if(a){t.triN(c,l,u,a(n),a(e),a(r),s);return}let f=Ii(c,l,u);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(c,l,u,f,s)}var wi=8;function po(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(s,i,a,c,l)=>{if(l>0){let u={x:(s.x+i.x)/2,y:(s.y+i.y)/2},f=n(u);if(Math.abs(f-(a+c)/2)>e){o(s,u,a,f,l-1),o(u,i,f,c,l-1);return}}r.push(s)};for(let s=0;s<t.length;s++){let i=t[s],a=t[(s+1)%t.length];o(i,a,n(i),n(a),wi)}return r}function Fn(t,n){if(t.length<3)return t;let e=[];for(let o of t){let s=e[e.length-1];s&&Math.hypot(o.x-s.x,o.y-s.y)<n||e.push(o)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let r=[];for(let o=0;o<e.length;o++){let s=r.length?r[r.length-1]:e[(o-1+e.length)%e.length],i=e[o],a=e[(o+1)%e.length],c=a.x-s.x,l=a.y-s.y,u=Math.hypot(c,l);u>n&&Math.abs((i.x-s.x)*l-(i.y-s.y)*c)/u<n||r.push(i)}return r.length>=3?r:e}var Ln=.001*Rt*.1;function Z(t,n,e,r,o,s,i,a,c=1/0,l){if(!n||n.length<3||(c===void 0&&(c=1/0),Math.abs(pt(n))<1e-4))return;let u=Fn(po(Fn(wt(n),Ln),r,c),Ln),f=e?.map(x=>Fn(po(Fn(wt(x),Ln),r,c),Ln)).filter(x=>x.length>=3&&Math.abs(pt(x))>=1e-4),{pts:m,tris:h}=_i(u,f),d=[s[0]*a.top,s[1]*a.top,s[2]*a.top],y=[s[0]*a.bottomCap,s[1]*a.bottomCap,s[2]*a.bottomCap],b=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.wallBottom,i[1]*a.wallBottom,i[2]*a.wallBottom],g=0;if(Number.isFinite(c))for(;g<Ai;g++){let x=0;for(let I=0;I<h.length;I+=3){let S=ln(m[h[I]],m[h[I+1]],m[h[I+2]],r,g);S>x&&(x=S)}if(x<=c)break}for(let x=0;x<h.length;x+=3){let I=m[h[x]],S=m[h[x+1]],_=m[h[x+2]];un(t,I,S,_,r,d,g,l);let O=[I.x*P,o,I.y*P],C=[S.x*P,o,S.y*P],F=[_.x*P,o,_.y*P];t.tri(O,F,C,[0,-1,0],y)}let R=x=>{if(g<=0)return x;let I=1<<g,S=[];for(let _=0;_<x.length;_++){let O=x[_],C=x[(_+1)%x.length];for(let F=0;F<I;F++){let k=F/I;S.push({x:O.x+(C.x-O.x)*k,y:O.y+(C.y-O.y)*k})}}return S},A=Ye(u),M=[{ring:R(u),flip:!1}];if(f)for(let x of f)x.length>=3&&M.push({ring:R(x),flip:!0});for(let{ring:x,flip:I}of M)for(let S=0;S<x.length;S++){let _=x[S],O=x[(S+1)%x.length],C=(O.x-_.x)*P,k=(O.y-_.y)*P,E=-C,w=Math.hypot(k,E)||1;k/=w,E/=w;let B=(_.x+O.x)/2-A.x,L=(_.y+O.y)/2-A.y,T=k*B+E*L;I&&(T=-T),T<0&&(k=-k,E=-E);let v=[k,0,E],H=[_.x*P,r(_),_.y*P],j=[O.x*P,r(O),O.y*P],D=[_.x*P,o,_.y*P],U=[O.x*P,o,O.y*P];t.tri(H,j,U,v,b,b,p),t.tri(H,U,D,v,b,p,p)}}function bo(t){let n=0;for(let c of t)n+=c.count;let e=new Float32Array(n*3),r=new Float32Array(n*3),o=new Float32Array(n*3),s=new Float32Array(n),i=new Float32Array(n),a=0;for(let c of t)e.set(c.position,a*3),r.set(c.normal,a*3),o.set(c.color,a*3),s.set(c.floor,a),i.set(c.material,a),a+=c.count;return{position:e,normal:r,color:o,floor:s,material:i,count:n}}function It(t,n,e=2.5){if(n<=0||t.length<3)return t;let r=wt(t),o=r.length,s=[];for(let a=0;a<o;a++){let c=r[a],l=r[(a+1)%o],u=l.x-c.x,f=l.y-c.y,m=Math.hypot(u,f)||1;s.push({x:f/m,y:-u/m})}let i=[];for(let a=0;a<o;a++){let c=r[a],l=s[(a-1+o)%o],u=s[a],f=l.x+u.x,m=l.y+u.y,h=Math.hypot(f,m),d=()=>{i.push([c.x+l.x*n,c.y+l.y*n]),i.push([c.x+u.x*n,c.y+u.y*n])};if(h<1e-9){d();continue}f/=h,m/=h;let y=f*l.x+m*l.y,b=1/Math.max(y,1e-6);if(!Number.isFinite(b)||b>e){d();continue}i.push([c.x+f*n*b,c.y+m*n*b])}if(i.length<3)return t;try{let a=xo.union([[...i,i[0]]]),c=null,l=-1/0;for(let f of a){let m=Math.abs(pt(f[0].map(([h,d])=>({x:h,y:d}))));m>l&&(l=m,c=f[0])}if(!c)return t;let u=c.map(([f,m])=>({x:f,y:m}));if(u.length>1){let f=u[0],m=u[u.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&u.pop()}return u.length>=3?u:t}catch{return t}}function Lt(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let r=wt(t),o=r.length,s=[];for(let c=0;c<o;c++){let l=r[c],u=r[(c+1)%o],f=Math.hypot(u.x-l.x,u.y-l.y)||1;s.push({x:-(u.y-l.y)/f,y:(u.x-l.x)/f})}let i=[],a=[];for(let c=0;c<o;c++){let l=r[c],u=s[(c-1+o)%o],f=s[c],m=u.x+f.x,h=u.y+f.y,d=Math.hypot(m,h),y=d<1e-9?1/0:1/Math.max(m/d*u.x+h/d*u.y,1e-6);if(!Number.isFinite(y)||y>e){i.push({x:l.x+u.x*n,y:l.y+u.y*n},{x:l.x+f.x*n,y:l.y+f.y*n}),a.push(c,c);continue}m/=d,h/=d,i.push({x:l.x+m*n*y,y:l.y+h*n*y}),a.push(c)}for(let c=0;c<i.length;c++){let l=(c+1)%i.length,u=a[c],f=a[l];if(f!==(u+1)%o)continue;let m=r[u],h=r[f];if((i[l].x-i[c].x)*(h.x-m.x)+(i[l].y-i[c].y)*(h.y-m.y)<=0)return[]}try{let c=xo.intersection([[...i.map(d=>[d.x,d.y]),[i[0].x,i[0].y]]],[[...r.map(d=>[d.x,d.y]),[r[0].x,r[0].y]]]),l=null,u=0;for(let d of c){let y=Math.abs(pt(d[0].map(([b,p])=>({x:b,y:p}))));y>u&&(u=y,l=d[0])}if(!l)return[];let f=l.map(([d,y])=>({x:d,y})),m=f[0],h=f[f.length-1];return f.length>1&&Math.abs(m.x-h.x)<1e-9&&Math.abs(m.y-h.y)<1e-9&&f.pop(),f.length>=3?wt(f):[]}catch{return[]}}function Nn(t,n,e,r,o=28){let s=[];for(let i=0;i<o;i++){let a=i/o*Math.PI*2;s.push({x:t+e*Math.cos(a),y:n+r*Math.sin(a)})}return s}function fn(t,n,e,r){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+r},{x:t,y:n+r}]}var ut={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Bi=.44,Ti=.15,Oi=.3,Ci=.24;function Mo(t){return t===void 0||!Number.isFinite(t)||t<=0?Ci:Math.min(Oi,Math.max(Ti,t*Bi))}var lu=.21,ki=.05,ue=.45,Fi=ue+ki,Li=.92,go=.66,vi=1.205,Ni=-.23,Gi=.38,Di=[{part:ut.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ut.pad,min:[-1,.36,-.95],max:[1,ue,1]},{part:ut.back,min:[-1,Fi,-1],max:[1,Li,-.72]},{part:ut.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ut.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ut.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ut.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ut.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ut.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ut.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Hi=[{part:ut.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ut.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ut.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ut.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ut.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Xi=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function uu(){let t=[],n=[],e=[],r=[],o=(D,U,X)=>{let Y=e.length,[nt,rt,q]=D,Q=[rt[0]-nt[0],rt[1]-nt[1],rt[2]-nt[2]],J=[q[0]-nt[0],q[1]-nt[1],q[2]-nt[2]],N=Q[1]*J[2]-Q[2]*J[1],G=Q[2]*J[0]-Q[0]*J[2],W=Q[0]*J[1]-Q[1]*J[0],lt=Math.hypot(N,G,W);lt>1e-9?(N/=lt,G/=lt,W/=lt):[N,G,W]=U,N*U[0]+G*U[1]+W*U[2]<0&&(N=-N,G=-G,W=-W);for(let ft of D)t.push(...ft),n.push(N,G,W),e.push(X);r.push(Y,Y+1,Y+2,Y,Y+2,Y+3)},s=D=>{for(let U of Xi){let X=U.c.map(Y=>Y.map((nt,rt)=>nt?D.max[rt]:D.min[rt]));o(X,U.n,D.part)}},i=(D,U)=>{let[X,Y,nt]=U?[0,1,2]:[0,2,1],rt=D.min[X],q=D.max[X],Q=D.min[Y],J=D.max[Y],N=(q-rt)*.1,G=(J-Q)*.1,W=U?[[rt+N,Q],[q-N,Q],[q,Q+G],[q*.94,J-(J-Q)*.23],[q*go,J],[rt*go,J],[rt*.94,J-(J-Q)*.23],[rt,Q+G]]:[[rt+N,Q],[q-N,Q],[q,Q+G],[q,J-G],[q-N,J],[rt+N,J],[rt,J-G],[rt,Q+G]],lt=(st,tt,et)=>{let ht=[0,0,0];return ht[X]=st,ht[Y]=tt,ht[nt]=et,ht},ft=[D.min[nt],D.max[nt]].map(st=>W.map(([tt,et])=>lt(tt,et,st)));for(let st=0;st<W.length;st++){let tt=(st+1)%W.length,et=[0,0,0];et[X]=(W[st][0]+W[tt][0])/2-(rt+q)/2,et[Y]=(W[st][1]+W[tt][1])/2-(Q+J)/2,o([ft[0][st],ft[0][tt],ft[1][tt],ft[1][st]],et,D.part)}for(let st=0;st<2;st++){let tt=[0,0,0];tt[nt]=st?1:-1;let et=ft[st];for(let ht=1;ht<et.length-1;ht++){let z=e.length;for(let mt of[et[0],et[ht],et[ht+1]])t.push(...mt),n.push(...tt),e.push(D.part);r.push(z,z+1,z+2)}}};for(let D of Di)D.part===ut.pad||D.part===ut.back?i(D,D.part===ut.back):s(D);for(let D of Hi)s(D);let a=ue,c=1.08,l=.47,u=.69,f=-.55,m=.08,h=-.48,d=.01,y=[-l,a,f],b=[l,a,f],p=[-l,a,m],g=[l,a,m],R=[-u,c,h],A=[u,c,h],M=[-u,c,d],x=[u,c,d];o([b,A,x,g],[1,0,0],ut.body),o([p,M,R,y],[-1,0,0],ut.body),o([y,b,g,p],[0,-1,0],ut.body);let I=c+.07,S=.24,_=[-S,I,h],O=[S,I,h],C=[-S,I,d],F=[S,I,d];o([M,C,_,R],[-.5,1,0],ut.body),o([C,F,O,_],[0,1,0],ut.body),o([F,x,A,O],[.5,1,0],ut.body),o([g,x,M,p],[0,0,1],ut.body),o([x,F,C,M],[0,0,1],ut.body),o([y,R,A,b],[0,0,-1],ut.body),o([R,_,O,A],[0,0,-1],ut.body);let k=10,E=8,w=[0,vi,Ni],B=[.32,.115,Gi],L=e.length;for(let D=0;D<=E;D++){let U=Math.PI*D/E,X=Math.cos(U),Y=Math.sin(U);for(let nt=0;nt<=k;nt++){let rt=Math.PI*2*nt/k,q=Y*Math.cos(rt),Q=Y*Math.sin(rt);t.push(w[0]+B[0]*q,w[1]+B[1]*X,w[2]+B[2]*Q);let J=q/B[0],N=X/B[1],G=Q/B[2],W=Math.hypot(J,N,G)||1;J/=W,N/=W,G/=W,n.push(J,N,G),e.push(ut.head)}}for(let D=0;D<E;D++)for(let U=0;U<k;U++){let X=L+D*(k+1)+U,Y=X+k+1;r.push(X,Y,X+1,X+1,Y,Y+1)}let T=new Float32Array(t),v=new Float32Array(n),H=new Float32Array(e),j=new Uint16Array(r);return{position:T,normal:v,part:H,index:j,vertexCount:e.length,indexCount:r.length}}function Ro(t,n,e,r){let o=new Float32Array(n),s=l=>t[l*3],i=l=>t[l*3+2],a=0,c=(l,u)=>{let f=u-l;for(let m=l;m<u;m++){let[h,d]=r(m),y=h-s(m),b=d-i(m);if(f>=2){let p=Math.max(l,m-1),g=Math.min(u-1,m+1),R=s(g)-s(p),A=i(g)-i(p),M=Math.hypot(R,A);if(M>1e-6){let x=-A/M,I=R/M;x*y+I*b<0&&(x=-x,I=-I),y=x,b=I}}o[m]=y===0&&b===0?0:Math.atan2(y,b)}};for(let l=1;l<=n;l++)(l===n||e(l)!==e(a))&&(c(a,l),a=l);return o}var Gn=.22;function gu(t,n){let e=cn[t];if(e!=="sold"&&e!=="held")return-1;let r=(n+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var ji=.42;function Ui(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let r=1/0,o=1/0,s=-1/0,i=-1/0;for(let d of t)d.x<r&&(r=d.x),d.y<o&&(o=d.y),d.x>s&&(s=d.x),d.y>i&&(i=d.y);let a=Math.max(s-r,1e-6),c=Math.max(i-o,1e-6),l=Math.max(Math.sqrt(a*c/n),1e-6),u=Math.max(1,Math.ceil(a/l)+1),f=Math.max(1,Math.ceil(c/l)+1),m=new Map,h=(d,y)=>{let b=Math.min(u-1,Math.max(0,Math.floor((d-r)/l)));return Math.min(f-1,Math.max(0,Math.floor((y-o)/l)))*u+b};for(let d=0;d<n;d++){let y=h(t[d].x,t[d].y),b=m.get(y);b?b.push(d):m.set(y,[d])}for(let d=0;d<n;d++){let y=t[d],b=Math.min(u-1,Math.max(0,Math.floor((y.x-r)/l))),p=Math.min(f-1,Math.max(0,Math.floor((y.y-o)/l))),g=1/0;for(let R=1;R<=4;R++){for(let A=p-R;A<=p+R;A++)if(!(A<0||A>=f))for(let M=b-R;M<=b+R;M++){if(M<0||M>=u||R>1&&Math.abs(A-p)<R&&Math.abs(M-b)<R)continue;let x=m.get(A*u+M);if(x)for(let I of x){if(I===d)continue;let S=Math.hypot(t[I].x-y.x,t[I].y-y.y);S<g&&(g=S)}}if(Number.isFinite(g)&&g<=R*l)break}e[d]=g}return e}function Wi(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-In):0}function Po(t,n,e,r,o,s){let i=t.length,a=new Float32Array(i*3),c=new Float32Array(i),l=new Float32Array(i*3),u=new Float32Array(i),f=new Float32Array(i),m=new Float32Array(i),h=new Float32Array(i),d=new Float32Array(i*3),y=new Map,b=Ui(t);for(let p=0;p<i;p++){let g=t[p],A=(e?.seatPitchU(p)??b[p])*P;u[p]=Number.isFinite(A)?Math.max(.06,Math.min(Gn,A*ji)):Gn,f[p]=Mo(Number.isFinite(A)?A:void 0);let M=no(g.glyph,{seatGlyph:s?.get(g.categoryKey)});m[p]=to.indexOf(M),h[p]=g.wheelchairSpaceType==="no-seat"?0:1,a[p*3]=g.x*P,a[p*3+1]=e?e.seatDeckY(p):Wi(g),a[p*3+2]=g.y*P,c[p]=ae(n?n(g):"available");let x=it(o?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[p*3]=x[0],l[p*3+1]=x[1],l[p*3+2]=x[2],g.accessibility?.length){let I=it(Sn(g.accessibility));I&&(d[p*3]=I[0],d[p*3+1]=I[1],d[p*3+2]=I[2])}y.set(g.id,p)}return{count:i,iPosition:a,iState:c,iCategory:l,iMaxRadius:u,iRing:d,idToIndex:y,iChairWidth:f,iGlyph:m,iPhysicalSeat:h,iFloor:r??new Float32Array(i),iSection:new Float32Array(i).fill(-1),iYaw:new Float32Array(i)}}var Yi=64;function Mu(t,n){let e=[];for(let i of n){let a=t.idToIndex.get(i.seatId);if(a===void 0)continue;let c=ae(i.state);t.iState[a]!==c&&(t.iState[a]=c,e.push(a))}if(!e.length)return[];e.sort((i,a)=>i-a);let r=[],o=e[0],s=e[0];for(let i=1;i<e.length;i++){let a=e[i];if(a!==s){if(a<=s+Yi){s=a;continue}r.push({start:o,length:s-o+1}),o=a,s=a}}return r.push({start:o,length:s-o+1}),r}import rs from"polygon-clipping";var K={top:1,wallBottom:.58,bottomCap:.4};function Wt(t,n){if(!t)return n;let e=V(Et(t,.4),.62);return at(n,e,.22)}function So(t,n){return t?at(n,V(Et(t,.25),.74),.62):n}function Io(t,n){let e=jt(kn({tierTop:n}));return t?Xt(t,e.sectionDeck,Math.min(e.sectionDeckChromaShare*an(t),e.sectionDeckChromaCap)):Xt(n,e.deck,Math.min(an(n),Cn))}function _o(t,n){let e=new Map;for(let s of t.categories??[])e.set(s.key,s.color);let r=new Map;for(let s of n){if(!s.sectionId)continue;let i=r.get(s.sectionId);i||(i=new Map,r.set(s.sectionId,i)),i.set(s.categoryKey,(i.get(s.categoryKey)??0)+1)}let o=new Map;for(let[s,i]of r){let a=0,c=0,l=0,u=0;for(let[f,m]of i){let h=it(e.get(f));h&&(a+=h[0]*m,c+=h[1]*m,l+=h[2]*m,u+=m)}u>0&&o.set(s,[a/u,c/u,l/u])}return o}function Ao(t,n){return it(t.color)??n.get(t.logicalSectionId??t.id)??null}import Do from"polygon-clipping";import To from"polygon-clipping";import zi from"earcut";var Ki=.58,Eo=.01,St=Gn*1.5*Rt,Vi=.5,Zi=.6;function qi(t,n){let e=t.length,r=[];for(let i=0;i<e;i++){let a=t[Math.max(0,i-1)],c=t[Math.min(e-1,i+1)],l=c.x-a.x,u=c.y-a.y,f=Math.hypot(l,u);if(f<1e-9){r.push([0,0]);continue}l/=f,u/=f,r.push([-u,l])}let o=0;for(let i=0;i<e;i++)o+=(t[i].x-n.x)*r[i][0]+(t[i].y-n.y)*r[i][1];return o<0?r.map(([i,a])=>[-i,-a]):r}function $i(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,a)=>{let c=a.x-i.x,l=a.y-i.y,u=Math.hypot(c,l)||1;return{x:c/u,y:l/u}},o=r(e[1],e[0]),s=r(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+s.x*n,y:e[e.length-1].y+s.y*n}),e}var wo=Math.PI/12;function Qi(t){if(t.length<3)return[...t];let n=[...t].sort((s,i)=>s.x-i.x||s.y-i.y),e=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),r=s=>{let i=[];for(let a of s){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o:[...t]}function Oo(t,n){if(!t.length||!(n>0))return[];let e=Qi(t),r=(a,c,l,u)=>{let f=l-c;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/wo)),h=n/Math.cos(f/m/2);for(let d=0;d<=m;d++){let y=c+f*d/m;u.push({x:a.x+Math.cos(y)*h,y:a.y+Math.sin(y)*h})}};if(e.length<3){let a=0,c=0;for(let h of e)a+=h.x,c+=h.y;a/=e.length||1,c/=e.length||1;let l=0;for(let h of e)l=Math.max(l,Math.hypot(h.x-a,h.y-c));let u=[],f=Math.max(3,Math.ceil(Math.PI*2/wo)),m=(l+n)/Math.cos(Math.PI/f);for(let h=0;h<f;h++){let d=h/f*Math.PI*2;u.push({x:a+Math.cos(d)*m,y:c+Math.sin(d)*m})}return u}let o=e.length,s=[];for(let a=0;a<o;a++){let c=e[a],l=e[(a+1)%o];s.push(Math.atan2(-(l.x-c.x),l.y-c.y))}let i=[];for(let a=0;a<o;a++)r(e[a],s[(a+o-1)%o],s[a],i);return vo(i)}function Ji(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let s=t[o],i=t[o+1],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l>1e-12?((n-s.x)*a+(e-s.y)*c)/l:0;u<0?u=0:u>1&&(u=1);let f=Math.hypot(n-(s.x+u*a),e-(s.y+u*c));f<r&&(r=f)}return r}function Dn(t){let n=t.map(o=>{let s=0,i=0;for(let l of o.pts)s+=l.x,i+=l.y;let a=o.pts.length||1;s/=a,i/=a;let c=0;for(let l of o.pts){let u=Math.hypot(l.x-s,l.y-i);u>c&&(c=u)}return{cx:s,cy:i,rad:c}}),e=o=>{let s=o.length;return s<=2?[...o]:[o[Math.floor(s*.25)],o[Math.floor(s*.5)],o[Math.floor(s*.75)]]},r=[];for(let o=0;o<t.length;o++){let s=e(t[o].pts),i=[],a=1/0,c=null;for(let u of s){let f=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let h=n[m],d=Math.hypot(u.x-h.cx,u.y-h.cy)-h.rad;if(d>=f&&d>=a)continue;let y=Ji(t[m].pts,u.x,u.y);y<f&&(f=y),t[m].depth<t[o].depth&&y<a&&(a=y,c=t[m].y)}Number.isFinite(f)&&f>0&&i.push(f)}i.sort((u,f)=>u-f);let l=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:l,belowY:c})}return r}function Co(t,n,e,r){let o=t[n],s=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let u=o.pts[0],f=u.x-r.x,m=u.y-r.y,h=Math.hypot(f,m)||1;f/=h,m/=h;let d=Math.max(e[n].pitch,.001)*.5;return[{x:u.x+m*d,y:u.y-f*d},{x:u.x-m*d,y:u.y+f*d}]})():[];if(s.length<2)return null;let i=0,a=0;for(let u=1;u<s.length;u++){let f=Math.hypot(s[u].x-s[u-1].x,s[u].y-s[u-1].y);f>1e-6&&(i+=f,a++)}let c=a>0?i/a:0,l=$i(s,Math.max(c*Zi,St));return{pts:l,nrm:qi(l,r),front:Math.max(e[n].pitch*Ki,St),back:Math.max(e[n].pitch*Vi,St)}}var $t=1.5,ko=.3;function fe(t,n){if(t.length<3)return t;let e=t[0],r=t[t.length-1],o=r.x-e.x,s=r.y-e.y,i=Math.hypot(o,s),a=-1,c=-1;for(let f=1;f<t.length-1;f++){let m=t[f],h=i>1e-12?Math.abs((m.x-e.x)*s-(m.y-e.y)*o)/i:Math.hypot(m.x-e.x,m.y-e.y);h>a&&(a=h,c=f)}if(a<=n||c<0)return[e,r];let l=fe(t.slice(0,c+1),n),u=fe(t.slice(c),n);return[...l.slice(0,-1),...u]}function Fo(t,n){if(t.length<4)return t;let e=fe([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function ts(t){let n=t.map((r,o)=>{let s=t[(o+1)%t.length];return{a:r,b:s,i:o,minX:Math.min(r.x,s.x),maxX:Math.max(r.x,s.x),minY:Math.min(r.y,s.y),maxY:Math.max(r.y,s.y)}}).sort((r,o)=>r.minX-o.minX),e=(r,o,s)=>(o.x-r.x)*(s.y-r.y)-(o.y-r.y)*(s.x-r.x);for(let r=0;r<n.length;r++){let o=n[r];for(let s=r+1;s<n.length&&n[s].minX<=o.maxX;s++){let i=n[s];if(!(Math.abs(o.i-i.i)===1||Math.abs(o.i-i.i)===t.length-1||o.maxY<i.minY||i.maxY<o.minY)&&e(o.a,o.b,i.a)*e(o.a,o.b,i.b)<=0&&e(i.a,i.b,o.a)*e(i.a,i.b,o.b)<=0)return!0}}return!1}function Lo(t,n,e){if(t.length<2)return[];let r=e??Dn(t),o=new Map;for(let i=0;i<t.length;i++){let a=o.get(t[i].blockId);a?a.push(i):o.set(t[i].blockId,[i])}let s=[];for(let[,i]of o){let a=[];for(let g of i){let R=t[g].patch;R&&R.length>=3?s.push({outline:[...R],holes:[],topY:t[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,R)=>t[g].depth-t[R].depth);let l=a.map(g=>Co(t,g,r,n)).filter(g=>g!==null);if(!l.length)continue;let u=(g,R)=>({x:g.pts[R].x-g.nrm[R][0]*(g.front+$t),y:g.pts[R].y-g.nrm[R][1]*(g.front+$t)}),f=(g,R)=>({x:g.pts[R].x+g.nrm[R][0]*(g.back+$t),y:g.pts[R].y+g.nrm[R][1]*(g.back+$t)}),m=l[0],h=l[l.length-1],d=[];for(let g=0;g<m.pts.length;g++)d.push(u(m,g));for(let g of l)d.push(f(g,g.pts.length-1));for(let g=h.pts.length-1;g>=0;g--)d.push(f(h,g));for(let g=l.length-1;g>=0;g--)d.push(u(l[g],0));let y=vo(d),b=1/0;for(let g of a)t[g].y<b&&(b=t[g].y);if(!Number.isFinite(b))continue;if(y.length>=3&&Math.abs(pt(y))>1e-6&&l.every(g=>{let R=g.pts[Math.floor(g.pts.length/2)];return xt(y,R.x,R.y)})&&!ts(y)){s.push({outline:Fo(y,ko),holes:[],topY:b});continue}for(let g of ns(l))s.push({outline:g,holes:[],topY:b})}return s}function ns(t){let n=[];for(let e of t){let r=[],o=[],s=e.front+$t,i=e.back+$t;for(let c=0;c<e.pts.length;c++){let l=e.pts[c],u=e.nrm[c];r.push([l.x-u[0]*s,l.y-u[1]*s]),o.push([l.x+u[0]*i,l.y+u[1]*i])}let a=[...r,...o.reverse()];a.length<3||(a.push(a[0]),n.push([a]))}if(!n.length)return[];try{let e=To.union(n[0],...n.slice(1)),r=[];for(let o of e){if(!o.length||o[0].length<4)continue;let s=o[0].map(([c,l])=>({x:c,y:l})),i=s[0],a=s[s.length-1];s.length>1&&Math.abs(i.x-a.x)<1e-9&&Math.abs(i.y-a.y)<1e-9&&s.pop(),s.length>=3&&r.push(Fo(s,ko))}return r}catch{return[]}}function vo(t){let n=[];for(let e of t){let r=n[n.length-1];r&&Math.hypot(e.x-r.x,e.y-r.y)<1e-9||n.push(e)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<1e-9;)n.pop();return n}var me=class{constructor(n){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=n;for(let e of n)for(let r of e)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(n){for(let e of n)if(e.x<this.minX||e.x>this.maxX||e.y<this.minY||e.y>this.maxY)return!1;for(let e of this.rings){let r=!0;for(let o of n)if(!xt(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function Bo(t,n,e,r,o,s){if(r.length<3)return;if(e.containsAll(r)){let l=[0,1,0],u=r[0];for(let f=1;f+1<r.length;f++){let m=r[f],h=r[f+1];t.tri([u.x*P,o,u.y*P],[m.x*P,o,m.y*P],[h.x*P,o,h.y*P],l,s)}return}let i=r.map(l=>[l.x,l.y]);i.push(i[0]);let a;try{a=To.intersection([i],n)}catch{return}let c=[0,1,0];for(let l of a){if(!l.length||l[0].length<4)continue;let u=l[0],f=[],m=[];for(let d=0;d<u.length-1;d++)f.push(u[d][0],u[d][1]),m.push([u[d][0],u[d][1]]);if(m.length<3)continue;let h=zi(f,void 0,2);for(let d=0;d<h.length;d+=3){let y=m[h[d]],b=m[h[d+1]],p=m[h[d+2]];t.tri([y[0]*P,o,y[1]*P],[b[0]*P,o,b[1]*P],[p[0]*P,o,p[1]*P],c,s)}}}function No(t,n,e,r,o,s,i){if(n.length<2)return;let a=i??Dn(n),c=[0,1,0],l=s&&s.length>=3?[[...s.map(h=>[h.x,h.y]),[s[0].x,s[0].y]]]:null,u=s&&s.length>=3?new me([[...s]]):null,f=h=>{t.setMaterial(2),h(),t.setMaterial(0)},m=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let d=n[h];if(d.patch&&d.patch.length>=3){let M=[...d.patch],x=a[h].belowY??r;if(m(()=>{if(l&&u)Bo(t,l,u,M,d.y,o.tread);else{let I=M[0];for(let S=1;S+1<M.length;S++){let _=M[S],O=M[S+1];t.tri([I.x*P,d.y,I.y*P],[_.x*P,d.y,_.y*P],[O.x*P,d.y,O.y*P],c,o.tread)}}}),d.y>x+Eo){let I=0,S=0;for(let _ of M)I+=_.x,S+=_.y;I/=M.length,S/=M.length,f(()=>{for(let _=0;_<M.length;_++){let O=M[_],C=M[(_+1)%M.length],F=C.x-O.x,k=C.y-O.y,E=Math.hypot(F,k);if(E<1e-6)continue;let w=k/E,B=-F/E;(O.x-I)*w+(O.y-S)*B<0&&(w=-w,B=-B);let L=[w,0,B],T=[O.x*P,d.y,O.y*P],v=[C.x*P,d.y,C.y*P],H=[O.x*P,x,O.y*P],j=[C.x*P,x,C.y*P];t.tri(T,v,j,L,o.riser),t.tri(T,j,H,L,o.riser)}})}continue}let y=Co(n,h,a,e);if(!y)continue;let{pts:b,nrm:p,front:g,back:R}=y,A=a[h].belowY??r;for(let M=0;M+1<b.length;M++){let x=b[M],I=b[M+1],S=p[M],_=p[M+1];if(Math.hypot(I.x-x.x,I.y-x.y)<1e-6||S[0]===0&&S[1]===0||_[0]===0&&_[1]===0)continue;let O=[(x.x-S[0]*g)*P,d.y,(x.y-S[1]*g)*P],C=[(I.x-_[0]*g)*P,d.y,(I.y-_[1]*g)*P],F=[(x.x+S[0]*R)*P,d.y,(x.y+S[1]*R)*P],k=[(I.x+_[0]*R)*P,d.y,(I.y+_[1]*R)*P];if(m(()=>{l&&u?Bo(t,l,u,[{x:x.x-S[0]*g,y:x.y-S[1]*g},{x:I.x-_[0]*g,y:I.y-_[1]*g},{x:I.x+_[0]*R,y:I.y+_[1]*R},{x:x.x+S[0]*R,y:x.y+S[1]*R}],d.y,o.tread):(t.tri(O,C,k,c,o.tread),t.tri(O,k,F,c,o.tread))}),d.y>A+Eo){let E=[O[0],A,O[2]],w=[C[0],A,C[2]],B=[-S[0],0,-S[1]];f(()=>{t.tri(O,C,w,B,o.riser),t.tri(O,w,E,B,o.riser)})}}}}function es(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Go(t,n){return t.filter(e=>e.type!=="shape"||es(e,n))}function Ho(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:Go(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:Go(t.objects,n),focal:e,baseHeightM:0,index:0}]}var os={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Tt(t){return oo(t)??os}function Xo(t,n){let e=It(t.outline,St),r=Tt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&qt(r,Tt(i.outline)));if(!o.length)return[e];let s=i=>{let a=i.map(c=>[c.x,c.y]);return a.push(a[0]),a};try{let i=Do.difference([s(e)],...o.map(c=>[s(c.outline)])),a=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&a.push(l)}return a.length?a:[e]}catch{return[e]}}function jo(t,n){if(!n.length)return t;let e=s=>{let i=s.map(a=>[a.x,a.y]);return i.push(i[0]),i},r=n.map(s=>[e(s)]),o=[];for(let s of t){let i;try{i=Do.intersection([e(s.outline)],r.flat())}catch{o.push(s);continue}for(let a of i){if(!a.length)continue;let c=a[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&o.push({outline:c,holes:[],topY:s.topY})}}return o.length?o:t}function is(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var Hn=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let r=n.map(c=>[c.x,c.y]);if(r.length<3)return[];r.push(r[0]);let o=Tt(n),s=this.rings.filter((c,l)=>qt(o,this.boxes[l])&&is(e,this.levels[l])),i=[[r]];if(s.length)try{i=rs.difference([r],...s).map(l=>l.map(u=>u.map(([f,m])=>[f,m])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let a=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&a.push(l)}return a}};function Qt(t,n,e=t){if(!n)return t;let r=1/0,o=-1/0,s=1/0,i=-1/0;for(let m of e)r=Math.min(r,m.x),o=Math.max(o,m.x),s=Math.min(s,m.y),i=Math.max(i,m.y);let a=(r+o)/2,c=(s+i)/2,l=n*Math.PI/180,u=Math.cos(l),f=Math.sin(l);return t.map(m=>{let h=m.x-a,d=m.y-c;return{x:a+h*u-d*f,y:c+h*f+d*u}})}function Uo(t){let n=Ke(t);return!n.length||!t.points?.length?[]:n.map(e=>Qt(e,t.rotation,t.points))}function ct(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3)return Qt(ze(t,4),t.rotation,t.points);if(t.kind==="rect"&&t.width&&t.height&&(n=fn(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let e=(t.x??0)+t.width/2,r=(t.y??0)+t.height/2;n=Nn(e,r,t.width/2,t.height/2)}return n?Qt(n,t.rotation):null}function _t(t){let n=t.role??"",r=n==="stage"?{kind:"stage",heightM:Ze(t.stageKind)}:{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}}[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var ss=.08,as=30,cs=.015;function ls(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[r],i=n[o];s.y>t.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(e=!e)}return e}function Wo(t,n){let e=ct(t)??(t.points?.length?Qt(t.points,t.rotation):null),r=_t(t),s=!t.role&&r.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(pt(e))*$**2>=as?cs:r.heightM;if(!e)return{topOffsetM:s,supportOffsetM:0};if(r.kind!=="plate"&&r.kind!=="stage")return{topOffsetM:s,supportOffsetM:0};let i=1/0,a=1/0,c=-1/0,l=-1/0;for(let h of e)i=Math.min(i,h.x),a=Math.min(a,h.y),c=Math.max(c,h.x),l=Math.max(l,h.y);let u=s,f=0,m=1e-6*Math.max(1,c-i,l-a);for(let h of n)c>h.minX&&i<h.maxX&&l>h.minY&&a<h.maxY&&u<=h.topOffsetM+1e-6&&(u=h.topOffsetM+ss),i>=h.minX-m&&c<=h.maxX+m&&a>=h.minY-m&&l<=h.maxY+m&&(!h.poly||e.every(b=>ls(b,h.poly)||us(b,h.poly,m)))&&(f=Math.max(f,h.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:a,maxX:c,maxY:l,topOffsetM:u,poly:e}),{topOffsetM:u,supportOffsetM:Math.min(f,u)}}function us(t,n,e){for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[o],i=n[r],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l?Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/l)):0;if(Math.hypot(t.x-(s.x+u*a),t.y-(s.y+u*c))<=e)return!0}return!1}function vt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function bt(t){if(t.length!==4)return t;let n=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),e=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return n>=e?t:[t[1],t[2],t[3],t[0]]}function dt(t,n,e){return[vt(t[0],t[1],n),vt(t[0],t[1],e),vt(t[3],t[2],e),vt(t[3],t[2],n)]}function mn(t,n,e){return[vt(t[0],t[3],n),vt(t[1],t[2],n),vt(t[1],t[2],e),vt(t[0],t[3],e)]}function ot(t,n,e,r,o,s,i){Z(t,n,i?.length?i:void 0,()=>e,r,o,s,K)}function hn(t){if(t.length<3)return t.map(s=>({...s}));let n=[...t].sort((s,i)=>s.x-i.x||s.y-i.y),e=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),r=s=>{let i=[];for(let a of s){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o.map(s=>({...s})):n.map(s=>({...s}))}var fs=.8,ms=.6,hs=2;function Nt(t,n){if(!n.length)return null;let e=[],r=0;for(let i of t.objects){if(i.type!=="shape"||i.role!=="wall")continue;let a=ct(i)??[],c=Yo(a)/2;!(c>0)||ps(a)/c*P>hs||(e.push(...a),r+=c)}if(e.length<3)return null;let o=hn(e);if(o.length<3||r<Yo(o)*ms)return null;let s=0;for(let i of n)xs(i,o)&&(s+=1);return s>=n.length*fs?o:null}var Xn=6,ys=5,ds=8;function zo(t){return Math.max(ds,(Number.isFinite(t)?t:0)+ys)}function Jt(t){let n=0,e=0,r=0;for(let o=0;o<t.length;o++){let s=t[o],i=t[(o+1)%t.length],a=s.x*i.y-i.x*s.y;n+=a,e+=(s.x+i.x)*a,r+=(s.y+i.y)*a}if(Math.abs(n)<1e-9){let o=0,s=0;for(let i of t)o+=i.x,s+=i.y;return{x:o/Math.max(1,t.length),y:s/Math.max(1,t.length)}}return{x:e/(3*n),y:r/(3*n)}}function ps(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2}function Yo(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=Math.hypot(o.x-r.x,o.y-r.y)}return n}function xs(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[r],i=n[o];s.y>t.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(e=!e)}return e}var bs=[[/\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"]],gs=1.2,Ms=12;function Ko(t){if(t.heightM!==void 0)return!1;let n=ct(t);if(!n||n.length<3)return!1;let e=0;for(let o=0;o<n.length;o++){let s=n[o],i=n[(o+1)%n.length];e+=Math.hypot(i.x-s.x,i.y-s.y)}return e*$<Ms*2?!1:2*yn(n)/e*$<=gs}function he(t){if(!t)return null;for(let[n,e]of bs)if(n.test(t))return e;return null}var Zo="auto-rows-";function qo(t){return t.id.startsWith(Zo)&&!t.label}var Rs=1.15,Ps=.09,$o=6,Ss=34,Is=.35,_s=6,As=.35,Es=.75,ws=12,Bs=2.5,Ts=40,Os=[18,24],Cs=[12,16],Vo=14,ks=.8,Fs=.6,Ls=5,vs=.3,Qo=.4,Jo=2,Ns=400,Gs=2.6,Ds=.8,Hs=4,Xs=26,js=.7,Us=.5,Ws=.985,Ys=1.5,zs=2.2,Ks=3,Vs=25,Zs=.985,qs=2,$s=6,Qs=3,Js=.1,ta=1.5,na=1.6,ea=6e3,oa=.6,ra="#c3c7cd",ye=300,ia=240;function sa(t,n,e,r){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let o=pe([...n]),s=new Set;for(let u of r)s.add(Math.floor(Math.atan2(u.y-o.y,u.x-o.x)*180/Math.PI/10));if(s.size*10<ia)return null;let{h:i,s:a,l:c}=Je(Qe(t.fill));return i<70/360||i>170/360||a<.2||c<.08||c>.75||e.some(u=>u!==t&&u.type==="shape"&&ct(u)?.some(f=>ge(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var aa="Estimated from the drawing; confirm with the venue.",xe=t=>{if(!t.length)return null;let n=[...t].sort((r,o)=>r-o),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2},pe=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),yn=t=>{let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2};function ca(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function be(t){let n=new Map;for(let e of t){let r=n.get(e.rowId);r?r.push(e):n.set(e.rowId,[e])}return n}function ge(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[r],i=n[o];s.y>t.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(e=!e)}return e}function Me(t,n){let e=n[0],r=1/0;for(let o=0;o<n.length;o++){let s=n[o],i=n[(o+1)%n.length],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l>0?Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/l)):0,f={x:s.x+a*u,y:s.y+c*u},m=Math.hypot(t.x-f.x,t.y-f.y);m<r&&(r=m,e=f)}return e}function tr(t,n){let e=0,r=0;for(let o of t.values()){if(o.length<3)continue;let s=o[0],i=o[o.length-1],a=i.x-s.x,c=i.y-s.y,l=Math.hypot(a,c);if(l<1e-6)continue;let u={x:(s.x+i.x)/2,y:(s.y+i.y)/2},f=Me(u,n),m=f.x-u.x,h=f.y-u.y,d=Math.hypot(m,h);d<1e-6||(r+=Math.abs((-c*m+a*h)/(l*d))*o.length,e+=o.length)}return e?r/e:0}function la(t,n,e){let r=t.filter(y=>y.type==="shape"),o=r.find(y=>y.role==="stage");if(o){let y=ct(o);return y?{shape:o,centre:pe(y),outline:y,inferred:!1}:null}if(!e.length)return null;let s=1/0,i=-1/0,a=1/0,c=-1/0;for(let y of e)s=Math.min(s,y.x),i=Math.max(i,y.x),a=Math.min(a,y.y),c=Math.max(c,y.y);let l=(i-s)*(c-a),u=[];for(let y of r){if(y.role)continue;let b=ct(y);if(!b)continue;let p=yn(b);if(p*$*$<6||p>l)continue;let g=Math.min(...b.map(_=>_.x)),R=Math.max(...b.map(_=>_.x)),A=Math.min(...b.map(_=>_.y)),M=Math.max(...b.map(_=>_.y)),x=0;for(let _ of e)_.x>g&&_.x<R&&_.y>A&&_.y<M&&ge(_,b)&&x++;if(x>e.length*.05)continue;let I=pe(b),S=tr(n,b);S>=ks&&u.push({shape:y,centre:I,outline:b,score:S,area:p,box:[g,A,R,M]})}let f=(y,b)=>b!==y&&b.area>y.area&&y.box[0]>=b.box[0]-1e-6&&y.box[1]>=b.box[1]-1e-6&&y.box[2]<=b.box[2]+1e-6&&y.box[3]<=b.box[3]+1e-6,m=u.filter(y=>!u.some(b=>f(y,b))),h=Math.max(0,...m.map(y=>y.score)),d=m.filter(y=>y.score>=h-.03).sort((y,b)=>b.area-y.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function ua(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let r=Me(t,e);return Math.hypot(t.x-r.x,t.y-r.y)}function nr(t){let n=[...t].sort((s,i)=>s.x-i.x||s.y-i.y);if(n.length<3)return n;let e=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),r=[];for(let s of n){for(;r.length>=2&&e(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}let o=[];for(let s=n.length-1;s>=0;s--){let i=n[s];for(;o.length>=2&&e(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}return[...r.slice(0,-1),...o.slice(0,-1)]}function fa(t){if(!t.length||t.length>ea)return[];let n=[...be(t).values()],e=n.map((a,c)=>c),r=a=>e[a]===a?a:e[a]=r(e[a]),o=na/$,s=n.map(a=>({minX:Math.min(...a.map(c=>c.x))-o,maxX:Math.max(...a.map(c=>c.x))+o,minY:Math.min(...a.map(c=>c.y))-o,maxY:Math.max(...a.map(c=>c.y))+o}));for(let a=0;a<n.length;a++)for(let c=a+1;c<n.length;c++){let l=s[a],u=s[c];if(l.maxX<u.minX||u.maxX<l.minX||l.maxY<u.minY||u.maxY<l.minY)continue;n[a].some(m=>n[c].some(h=>Math.hypot(m.x-h.x,m.y-h.y)<=o))&&(e[r(a)]=r(c))}let i=new Map;return n.forEach((a,c)=>{let l=r(c),u=i.get(l);u?u.push(...a):i.set(l,[...a])}),[...i.values()].filter(a=>new Set(a.map(c=>c.rowId)).size>=2)}function ma(t,n,e){if(!n.length)return null;let r=n.filter(S=>e.tableIds.has(S.rowId)||S.kind==="booth").length>n.length/2,o=be(n),s=!e.outline||tr(o,e.outline)>=Fs,i=0,a=0;for(let S of o.values()){if(S.length<2)continue;let _=S[0],O=S[S.length-1],C=O.x-_.x,F=O.y-_.y,k=Math.hypot(C,F);if(k<1e-6)continue;let E={x:(_.x+O.x)/2,y:(_.y+O.y)/2},w=s?e.outline?Me(E,e.outline):e.focal:e.middle,B=-F/k,L=C/k;B*(w.x-E.x)+L*(w.y-E.y)<0&&(B=-B,L=-L),i+=B*S.length,a+=L*S.length}let c={x:n.reduce((S,_)=>S+_.x,0)/n.length,y:n.reduce((S,_)=>S+_.y,0)/n.length};if(Math.hypot(i,a)<1e-9){let S=s?e.focal:e.middle;i=S.x-c.x,a=S.y-c.y}let l=Math.hypot(i,a)||1,u={x:i/l,y:a/l},f=S=>-(S.x*u.x+S.y*u.y),m=S=>-S.x*u.y+S.y*u.x,h=1/0,d=-1/0,y=1/0,b=-1/0,p=1/0,g=new Map;for(let S of n){let _=f(S),O=m(S);h=Math.min(h,_),d=Math.max(d,_),y=Math.min(y,O),b=Math.max(b,O),s&&(p=Math.min(p,ua(S,e.focal,e.outline)));let C=S.logicalRowId??S.rowId,F=g.get(C);F?F.push(_):g.set(C,[_])}s||(p=Math.max(0,h-f(e.middle)));let R=[...g.values()].map(S=>xe(S)).sort((S,_)=>S-_),A=[];if(!r)for(let S of R)A.length&&S-A[A.length-1]<As/$||A.push(S);let M=ca(t),x=Vt(t,{floorBaseHeightM:e.baseHeightM}),I={id:t.id,section:t,authored:M,plane:e,facing:u,facesAction:s,hull:nr(n),sample:n.filter((S,_)=>_%Math.ceil(n.length/Ns)===0),frontD:h,backD:d,latMin:y,latMax:b,frontDistance:p,rowDepths:A,rowCount:A.length,level:0,height:x.height,rake:M?x.rake:0,backHeight:0};return I.backHeight=I.height+(d-h)*$*Math.tan(I.rake*Math.PI/180),I}function ha(t,n,e,r){if(t.length<2)return 0;let o=Math.max(1,n*$),s=e+Rs-r,i=0,a=0;for(let l=1;l<t.length;l++){let u=Math.max(Es,(t[l]-t[l-1])*$),f=(s+Ps)*(o+u)/o;i+=f-s,a+=u,s=f,o+=u}let c=Math.atan(i/a)*180/Math.PI;return Math.round(Math.max($o,Math.min(Ss,c))*10)/10}function ya(t,n,e=!1){if(!e&&t.facing.x*n.facing.x+t.facing.y*n.facing.y<vs)return null;let r=-1/0,o=1/0,s=-1/0;for(let m of n.hull){r=Math.max(r,-(m.x*t.facing.x+m.y*t.facing.y));let h=-m.x*t.facing.y+m.y*t.facing.x;o=Math.min(o,h),s=Math.max(s,h)}if(Math.min(t.latMax,s)-Math.max(t.latMin,o)<(e?1e-6:Qo*(t.latMax-t.latMin)))return null;let a=Jo/$,c=new Map,l=new Map;for(let m of t.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/a),d=-(m.x*t.facing.x+m.y*t.facing.y);c.set(h,Math.min(c.get(h)??1/0,d))}for(let m of n.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/a),d=-(m.x*t.facing.x+m.y*t.facing.y);l.set(h,Math.max(l.get(h)??-1/0,d))}let u=[];for(let[m,h]of c){let d=l.get(m);d!==void 0&&u.push(h-d)}let f=u.length?xe(u):t.frontD-r;return f<-1/$?null:f}function da(t,n){if(n.plane.floorIndex>=t.plane.floorIndex)return!1;let e=-1/0,r=1/0,o=1/0,s=-1/0;for(let c of n.hull){let l=-(c.x*t.facing.x+c.y*t.facing.y);e=Math.max(e,l),r=Math.min(r,l);let u=-c.x*t.facing.y+c.y*t.facing.x;o=Math.min(o,u),s=Math.max(s,u)}let i=Math.min(t.latMax,s)-Math.max(t.latMin,o),a=Math.min(t.backD,e)-Math.max(t.frontD,r);return i>Qo*(t.latMax-t.latMin)&&a>1/$}function pa(t,n){let e=new Set;for(let r of t){let o=(Math.atan2(r.y-n.y,r.x-n.x)*180/Math.PI+360)%360;e.add(Math.floor(o/10))}return e.size/36}function xa(t,n){let e=1/0,r=-1/0;for(let s of n.hull){let i=-(s.x*t.facing.x+s.y*t.facing.y);e=Math.min(e,i),r=Math.max(r,i)}let o=Math.max(0,Math.min(r-e,t.frontD-e));return n.height+o*$*Math.tan(n.rake*Math.PI/180)}function ba(t,n){if(!t.facesAction)return!1;let e={x:-t.facing.y,y:t.facing.x},r=Jo/$,o=Math.max(1,Math.ceil((t.backD-t.frontD)/r)),s={left:new Map,right:new Map};for(let a of n)if(!(a===t||a.plane.floorIndex!==t.plane.floorIndex)&&!(a.facing.x*t.facing.x+a.facing.y*t.facing.y>=Ws))for(let c of a.sample){let l=-(c.x*t.facing.x+c.y*t.facing.y);if(l<t.frontD||l>t.backD)continue;let u=-c.x*t.facing.y+c.y*t.facing.x,f=u<t.latMin?"left":u>t.latMax?"right":null;if(!f)return!1;let m=Math.min(o-1,Math.floor((l-t.frontD)/r)),h=f==="left"?t.latMin-u:u-t.latMax;h<(s[f].get(m)?.gap??1/0)&&s[f].set(m,{gap:h,other:a})}let i=a=>{let c=a==="left"?t.latMin:t.latMax,l=0;for(let[u,{other:f}]of s[a]){if((f.facing.x*e.x+f.facing.y*e.y)*(a==="left"?1:-1)<js)continue;let h=t.frontD+(u+.5)*r,d={x:-h*t.facing.x+c*e.x,y:-h*t.facing.y+c*e.y},y=-(d.x*f.facing.x+d.y*f.facing.y),b=-d.x*f.facing.y+d.y*f.facing.x;y<f.frontD&&b>=f.latMin&&b<=f.latMax&&l++}return l/o>=Us};return i("left")&&i("right")}function ga(t,n){if(n.plane.floorIndex!==t.plane.floorIndex||n.facing.x*t.facing.x+n.facing.y*t.facing.y<Zs)return!1;let e=1/0,r=-1/0,o=1/0;for(let a of n.hull){let c=-a.x*t.facing.y+a.y*t.facing.x;e=Math.min(e,c),r=Math.max(r,c),o=Math.min(o,-(a.x*t.facing.x+a.y*t.facing.y))}let s=(t.frontD-o)*$;if(s<-qs||s>$s)return!1;let i=Math.max(e-t.latMax,t.latMin-r);return i*$<=Qs&&i*$>=-Js}function Ma(t,n=!1,e=!1,r){let o=n?Cs:Os,s=new Set(e?[]:t.filter(y=>!y.authored&&ba(y,t))),i=[...t].sort((y,b)=>y.plane.floorIndex-b.plane.floorIndex||Number(s.has(b))-Number(s.has(y))||y.frontDistance-b.frontDistance);for(let y of s)r?.add(y.id);let a=(y,b,p)=>{let g=new Map,R=[],A=new Map,M=x=>{if(x.plane.floorIndex===0||x.plane.baseHeightM>0)return x.plane.baseHeightM;let I=A.get(x.plane.floorIndex-1);return I===void 0?x.plane.baseHeightM:I+fo};for(let x of i){if(s.has(x))x.height=M(x),x.level=0,x.rake=0,x.backHeight=x.height,g.set(x.id,void 0);else if(!x.authored){let S=M(x),_;for(let E of R){if(E.plane.floorIndex>x.plane.floorIndex)continue;if(da(x,E)){let T=xa(x,E)+Gs;T>S&&(S=T,_=E);continue}let w=ya(x,E,s.has(E));if(w==null)continue;let B=e&&!!x.plane.stageDeck&&E.level===0&&E.plane.floorIndex===x.plane.floorIndex&&Math.max(0,w)*$<=Hs,L=s.has(E)?E.height+Ys:B?E.backHeight:E.backHeight+Is+Math.min(_s,Math.max(0,w)*$)*Math.tan(E.rake*Math.PI/180);L>S&&(S=L,_=E)}let O=y.get(x);O&&O.height>S+.01?(S=O.height,_=void 0):O=void 0,x.height=Math.round(Math.min(S,x.plane.baseHeightM+Ts)*100)/100;let C=!_&&!O&&x.height>x.plane.baseHeightM;if(x.level=_?_.level+1:O?O.level:C?1:0,x.rake=ha(x.rowDepths,x.frontDistance,x.height,x.plane.focalHeightM),!x.facesAction&&x.rowCount<Ls)x.rake=0;else if(x.level===0){let E=Math.max(1e-6,(x.backD-x.frontD)*$);x.rake=Math.min(x.rake,ws,Math.round(Math.atan(Bs/E)*1800/Math.PI)/10)}else x.rowCount>=2&&(x.rake=Math.max(x.rake,o[Math.min(x.level,o.length)-1]));let F=(x.backD-x.frontD)*$,k=_&&s.has(_)||O&&p?.has(O.id);if(b!==void 0&&k&&x.rowCount>=2&&(x.rake=b),n&&F>0&&x.height+F*Math.tan(x.rake*Math.PI/180)>x.plane.baseHeightM+Vo){let E=Math.max(0,x.plane.baseHeightM+Vo-x.height);x.rake=Math.max($o,Math.round(Math.atan(E/F)*1800/Math.PI)/10)}e&&x.plane.stageDeck&&x.level>0&&(x.rake=Math.min(x.rake,Xs)),x.backHeight=x.height+F*Math.tan(x.rake*Math.PI/180),g.set(x.id,_?.id??(O?g.get(O.id):void 0))}let I=x.plane.floorIndex;A.set(I,Math.min(A.get(I)??1/0,x.height)),R.push(x)}return g},c=a(new Map),l=new Map,u=y=>l.get(y)?.height??y.height;for(let y=!0,b=0;y&&b<t.length;b++){y=!1;for(let p of t)if(!(p.authored||s.has(p)))for(let g of t){let R=l.get(g)??g;g===p||R.height-R.plane.baseHeightM<ta||R.height<=u(p)+.01||ga(p,g)&&(l.set(p,R),y=!0)}}let f=new Map(t.map(y=>[y.id,y])),m=t.filter(y=>!y.authored&&y.rowCount>=2&&s.has(f.get(c.get(y.id)??""))),h=m.length?xe(m.map(y=>y.rake)):void 0;if(!l.size&&h===void 0)return c;let d=new Map([...new Set(l.values())].map(y=>[y,{...y}]));return a(new Map([...l].map(([y,b])=>[y,d.get(b)])),h,new Set(m.map(y=>y.id)))}var de=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function er(t,n={x:0,y:-40}){let e=En(t),r=new Map;for(let p of e){if(!p.sectionId)continue;let g=r.get(p.sectionId);g?g.push(p):r.set(p.sectionId,[p])}let o={focalInferred:!1,confident:!1,sections:[]},s=t.floors?.length?t.floors.map((p,g)=>({objects:p.objects,floorIndex:g,floorId:p.id,baseHeightM:p.baseHeightM??0,focal:p.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(s.flatMap(p=>p.objects.filter(g=>g.type==="table").map(g=>g.id))),a=[],c,l=new Set,u=s.map(p=>{let g=k=>!t.floors?.length||k.floorId===p.floorId,R=fa(e.filter(k=>!k.sectionId&&k.kind!=="booth"&&!i.has(k.rowId)&&g(k))),A=[];for(let k of R){let E=It(wt(nr(k)),oa/$);if(e.some(B=>!g(B)&&ge(B,E)))continue;let w=`${Zo}${p.floorIndex}-${A.length}`;l.add(w),r.set(w,k),A.push({type:"section",id:w,label:"",color:ra,outline:E})}let M=A.length?{...p,objects:[...p.objects,...A]}:p,x=new Set(M.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),I=[...r.entries()].filter(([k])=>x.has(k)).flatMap(([,k])=>k),S=la(M.objects,be(I),I),_=M.focal;(S||M.focal&&!de(M.focal,n))&&(o.confident=!0),S&&(o.stage??={id:S.shape.id,inferred:S.inferred,...M.floorId?{floorId:M.floorId}:{}},(S.inferred||de(M.focal,n))&&(_=S.centre,o.focalInferred=!0));let O=S&&(!S.inferred||yn(S.outline)*$*$<=ye),C=S?void 0:c,F={tableIds:i,floorIndex:M.floorIndex,floorId:M.floorId,baseHeightM:M.baseHeightM,focal:C?.focal??_,outline:S?.outline??C?.outline,focalHeightM:C?.focalHeightM??M.baseHeightM+(S&&O?_t({...S.shape,role:"stage"}).heightM:0),stageDeck:C?.stageDeck??!!(S&&O&&yn(S.outline)*$*$<=ye),middle:I.length?{x:I.reduce((k,E)=>k+E.x,0)/I.length,y:I.reduce((k,E)=>k+E.y,0)/I.length}:_};for(let k of M.objects){if(k.type!=="section")continue;let E=ma(k,r.get(k.logicalSectionId??k.id)??[],F);E&&a.push(E)}return F.outline&&(c=F),de(M.focal,F.focal)||(o.focal??=[]).push({...M.floorId?{floorId:M.floorId}:{},point:{...F.focal}}),{unit:M,plane:F,stage:S,planeSeats:I}}),f=s.flatMap(p=>p.objects).map(p=>p.type==="shape"&&!p.role&&(he(p.label)==="wall"||!he(p.label)&&Ko(p))?{...p,role:"wall"}:p),m=Nt({objects:f},e)!==null;m&&(o.indoor=!0);let h=new Set,d=Ma(a,m,pa(e,u[0]?.plane.focal??n)<Ds,h),y=new Map(a.filter(p=>!p.authored).map(p=>[p.id,p])),b=u.map(({unit:p,plane:g,stage:R,planeSeats:A})=>p.objects.map(M=>{let x=M.type==="shape"&&!M.role&&M.id!==R?.shape.id?he(M.label):null;if(M.type==="shape"&&!M.role&&M.id!==R?.shape.id&&(x==="wall"||!x&&Ko(M))&&M.type==="shape"){(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:"wall"});let{fill:E,...w}=M;return{...w,role:"wall"}}if(x&&M.type==="shape")return(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:x}),{...M,role:x};let S=R?.inferred&&M.id===R.shape.id&&M.type==="shape"?sa(M,R.outline,p.objects,A):null;if(S&&M.type==="shape")return o.stage?.id===M.id&&(o.stage.field=S),{...M,role:"stage",stageKind:S};let _=M.type==="shape"&&M.id===R?.shape.id&&M.heightM===void 0&&!M.stageKind&&a.some(E=>E.plane===g&&(h.has(E.id)||E.level===0&&E.facesAction&&E.rake<=Ks&&(E.frontDistance+E.backD-E.frontD)*$>=Vs)),O=_?{heightM:zs}:{};if(R?.inferred&&M.id===R.shape.id&&M.type==="shape"&&yn(R.outline)*$*$<=ye)return o.stage?.id===M.id&&(o.stage.deck=!0),{...M,role:"stage",...O};if(_&&M.type==="shape"&&M.role==="stage")return{...M,...O};let C=M.type==="section"?y.get(M.id):void 0;if(!C||M.type!=="section")return M;let F=C.rowCount>=2&&C.rake>0;l.has(C.id)?o.looseRowBlocks=(o.looseRowBlocks??0)+1:o.sections.push({id:C.id,floorId:g.floorId,surfaceKind:F?"rakedRows":"flat",height:C.height,rake:C.rake,stackedOn:d.get(C.id)});let k={status:"inferred",source:"public-2d-topology",note:aa};return{...M,height:C.height,rake:C.rake,surfaceKind:F?"rakedRows":"flat",physical3dProvenance:{height:k,rake:k,surfaceKind:k}}}));if(t.floors?.length){let p=t.floors.map((g,R)=>({...g,objects:b[R],focalPoint:u[R].plane.focal}));return{doc:{...t,floors:p,objects:p[0].objects,focalPoint:p[0].focalPoint},report:o}}return{doc:{...t,objects:b[0],focalPoint:u[0].plane.focal},report:o}}function lf(t,n,e){return e<0?n>1?t.filter(r=>r.kind==="floor"):[...t]:t.filter(r=>r.floorIndex===void 0||r.floorIndex===e)}function uf(t,n){let e=[...t].sort((o,s)=>o.screen.y-s.screen.y),r=[];for(let o of e){let s=r.find(i=>i.some(a=>Math.abs(a.screen.x-o.screen.x)<104&&Math.abs(a.screen.y-o.screen.y)<34));s?s.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((s,i)=>({...s,screen:{...s.screen,x:Math.max(54,Math.min(n-54,s.screen.x+(i-(o.length-1)/2)*104))}})))}var Ra=1.15,Pa=2.75,Sa=4.5,Ia=.85,_a=.5,Aa=.26;function ff(t,n,e){let r=Math.max(1e-6,n),o=t/r,s=e?.hasZoneLabels??!0,i=new Set(["stage","gate"]);return o>=.75&&i.add("floor"),o>=Ra&&i.add("zone"),o<=(s?Pa:Sa)&&(i.add("section"),i.add("ga")),o<=Ia&&(i.add("annotation"),i.add("booth")),o<=_a&&i.add("row"),o<=Aa&&i.add("seat"),i}function mf(t,n,e,r,o,s=6){let i=s+n,a=r-s-n,c=s+e,l=o-s-e;return{...t,x:i>a?r/2:Math.max(i,Math.min(a,t.x)),y:c>l?o/2:Math.max(c,Math.min(l,t.y))}}function hf(t,n,e,r){let o=t,s=n[0],i=n[1],a=n[2],c=o[0]*s+o[4]*i+o[8]*a+o[12],l=o[1]*s+o[5]*i+o[9]*a+o[13],u=o[2]*s+o[6]*i+o[10]*a+o[14],f=o[3]*s+o[7]*i+o[11]*a+o[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=c/f,h=l/f,d=u/f,y=m>=-1.05&&m<=1.05&&h>=-1.05&&h<=1.05&&d<=1;return{x:(m*.5+.5)*e,y:(1-(h*.5+.5))*r,depth:d,visible:y}}function yf(t,n,e=n,r=()=>0){let o=[],s=[...t].sort((i,a)=>r(a)-r(i)||i.screen.depth-a.screen.depth);for(let i of s){let a=!1;for(let c of o)if(Re(i,c,n,e)){a=!0;break}a||o.push(i)}return o}var Ea=6;function Re(t,n,e,r){let o=Math.abs(t.screen.x-n.screen.x),s=Math.abs(t.screen.y-n.screen.y),i=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+Ea):e;return o<i&&s<r}function df(t,n,e){return t.length*n*.58+(e?14:0)}var wa={row:8,seat:14};function pf(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:wa}function xf(t,n,e,r){let o=Math.max(1,Math.min(e,r)*.5),s=Math.min(2,Math.hypot(t.x-e/2,t.y-r/2)/o);return n*(1+1.5*s)}function bf(t,n,e,r,o=[]){let s=[...t].sort((a,c)=>(c.priority??0)-(a.priority??0)||a.focus-c.focus),i=[];for(let a of s){if(i.length>=r)break;let c=!1;for(let l of o)if(Re(a,l,n,e)){c=!0;break}if(!c){for(let l of i)if(Re(a,l,n,e)){c=!0;break}}c||i.push(a)}return i}function gf(t,n,e,r){let o=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15];return o<=0||!(e>0)?0:e*Math.hypot(t[0],t[4],t[8])*r/(2*o)}function tn(t,n,e){if(t.length!==4||e<=n)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P,s=Math.hypot(r[3].x-r[0].x,r[3].y-r[0].y)*P;if(o<1e-6||s<1e-6)return null;let i=Math.min(.22/o,.16),a=Math.min(.28,(e-n)*.13),c=Math.min(.065/s,.2);return{quad:r,side:i,face:c,opening:dt(r,i,1-i),openingTop:e-a}}function Pe(t,n,e){if(t.length!==4||e-n<=.2)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P;if(o<=1e-6)return null;let s=Math.min(.14,(e-n)*.08,o*.08),i=s/o,a=dt(r,i,1-i);return{quad:r,side:i,trim:s,inner:a,panel:mn(a,.15,.85),bottom:n+s,top:e-s}}function or(t,n,e,r){let o=Pe(t,n,e);if(!o)return;let{panel:s}=o,i=(g,R)=>({x:(g.x+R.x)/2,y:(g.y+R.y)/2}),a=i(s[0],s[1]),c=i(s[3],s[2]),l=Math.hypot(a.x-r.x,a.y-r.y)<=Math.hypot(c.x-r.x,c.y-r.y),[u,f]=l?[s[0],s[1]]:[s[3],s[2]],m=l?{x:a.x-c.x,y:a.y-c.y}:{x:c.x-a.x,y:c.y-a.y},h=Math.hypot(m.x,m.y);if(h<1e-6)return;-(f.y-u.y)*m.x+(f.x-u.x)*m.y<0&&([u,f]=[f,u]);let d=Math.min(.006,h*P*.05),y=m.x/h*d,b=m.y/h*d,p=(g,R)=>[g.x*P+y,R,g.y*P+b];return[p(u,o.bottom),p(f,o.bottom),p(u,o.top),p(f,o.top)]}import Ta from"polygon-clipping";import Ba from"polygon-clipping";function Ot(t,n,e,r,o,s,i,a={}){let c=Tt(n),l=a.ao??K,u=o.flatMap(y=>{if(y.role!=="entrance"&&y.role!=="exit")return[];let b=ct(y);if(!b||b.length!==4||!qt(c,Tt(b)))return[];let p=a.portalBase??e,g=tn(b,p,p+_t(y).heightM);if(!g)return[];let R=Math.min(r,g.openingTop);return R<=e?[]:[{poly:g.opening,height:R}]});if(!u.length)return!1;let f=y=>y.map(b=>[b.x,b.y]),m=[f(n),...(a.holes??[]).map(f)],h=[e,...new Set(u.map(y=>y.height)),r].sort((y,b)=>y-b),d=[];try{for(let y=1;y<h.length;y++){let b=h[y-1],p=h[y];if(p-b<1e-6)continue;let g=u.filter(A=>A.height>b+1e-6).map(A=>[f(A.poly)]),R=g.length?Ba.difference(m,...g):[m];d.push({low:b,high:p,polys:R})}}catch{return!1}for(let y of d)for(let b of y.polys){let[p,...g]=b.map(A=>A.map(([M,x])=>({x:M,y:x}))),R=A=>l.wallBottom+(l.top-l.wallBottom)*(A-e)/(r-e);Z(t,p,g,()=>y.high,y.low,s,i,{...l,top:R(y.high),wallBottom:R(y.low)})}return!0}var Se={depthM:1.6,thicknessM:.35,minWallM:6};function jn(t,n,e,r,o,s,i,a,c){let l=r-e;if(l<=0)return;let u=a&&(c??l)>=Se.minWallM?Oa(n,a):null,f=u?r-Se.thicknessM:r,m=f-e,h=m<1.5?[[e,f,1]]:u?[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f,1]]:[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f-.1,1],[f-.1,f,1.1]],d=y=>K.wallBottom+(K.top-K.wallBottom)*(y-e)/l;for(let[y,b,p]of h){let g={...K,top:d(b),wallBottom:d(y)},R=V(s,p),A=V(i,p);Ot(t,n,y,b,o,R,A,{portalBase:e,ao:g})||Z(t,n,void 0,()=>b,y,R,A,g)}for(let[y,...b]of u??[])Z(t,y,b.length?b:void 0,()=>r,f,V(s,1.12),V(i,.78),K)}function Oa(t,n){let e=Se.depthM/P,r=t.map(i=>{let a=n.x-i.x,c=n.y-i.y,l=Math.hypot(a,c)||1;return{x:i.x+a/l*e,y:i.y+c/l*e}}),o=i=>{let a=i.map(c=>[c.x,c.y]);return a.push(a[0]),a},s=[[o(t)],[o(r)]];for(let i=0;i<t.length;i++){let a=(i+1)%t.length;s.push([o([t[i],t[a],r[a],r[i]])])}try{let[i,...a]=s,c=Ta.union(i,...a);return c.length?c.map(l=>l.map(u=>u.slice(0,-1).map(([f,m])=>({x:f,y:m})))):null}catch{return null}}function dn(t,n,e){let r=it(n.stroke?.color),o=n.stroke?.width??0;if(!r||!Number.isFinite(o)||o<=0)return;let s=n.kind==="line"||n.kind==="polyline",i=s?Qt(n.points??[],n.rotation):ct(n);if(!i||i.length<2)return;let a=o*.5,c=io(n)?ao(i,...so(o)):Array.from({length:s?i.length-1:i.length},(l,u)=>[i[u],i[(u+1)%i.length]]);for(let[l,u]of c){let f=Math.hypot(u.x-l.x,u.y-l.y);if(f<1e-6)continue;let m=-(u.y-l.y)/f*a,h=(u.x-l.x)/f*a,d=[(l.x+m)*P,e,(l.y+h)*P],y=[(u.x+m)*P,e,(u.y+h)*P],b=[(u.x-m)*P,e,(u.y-h)*P],p=[(l.x-m)*P,e,(l.y-h)*P];t.tri(d,y,b,[0,1,0],r),t.tri(d,b,p,[0,1,0],r)}}function rr(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var nn=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function Un(t,n,e,r){let[o,s,i,a]=n?t:[t[3],t[2],t[1],t[0]];return[nn(o,a,e),nn(s,i,e),nn(s,i,r),nn(o,a,r)]}function ir(t,n,e,r,o,s,i,a,c=!1){if(e.length!==4||o-r<.4)return!1;let l=S=>c?Math.min(S,o):S,u=bt(e),f=Math.hypot(u[3].x-u[0].x,u[3].y-u[0].y)*P;if(f<.4)return!1;let m=nn(u[0],u[1],.5),h=nn(u[3],u[2],.5),d=Math.hypot(m.x-a.x,m.y-a.y)<=Math.hypot(h.x-a.x,h.y-a.y),y=at(i,[.92,.9,.86],.35),b=V(s,.72),p=o-r;if(n==="restroom"){let S=Math.min(.18,p*.08);return ot(t,u,o-S,r,i,s),ot(t,u,o,o-S,y,y),!0}let g=r+Math.min(1.1,p),R=n==="coat"?1:Math.min(.5,.75/f),A=Un(u,d,0,R);if(ot(t,A,g-.05,r,b,s),ot(t,A,g,g-.05,y,y),n==="coat"||f<1.2)return!0;if(n==="bar"){let S=Un(u,d,Math.max(R+.2,1-.45/f),1),_=l(r+Math.max(Math.min(2.2,p*2),g-r+.6));return ot(t,S,_,r,i,b),!0}let M=Un(u,d,Math.max(R+.25,.55),1),x=l(r+Math.max(2.6,g-r+1.4));if(x-.14<=g)return!0;ot(t,M,x-.14,r,i,s),ot(t,u,x,x-.14,y,b);let I=Math.min(.08,.1/Math.max(.1,Math.hypot(u[1].x-u[0].x,u[1].y-u[0].y)*P));for(let[S,_]of[[0,I],[1-I,1]])ot(t,Un(dt(u,S,_),d,0,Math.min(.08,.1/f)),x-.14,g,b,b);return!0}var Gt=.06,Ca=.05,ar=.05,sr=.15,Ie=25;function cr(t,n,e){let r=new Map,o=new Array(n.length).fill(null),s=new Float64Array(n.length),i=new Array(n.length).fill(void 0),a=new Array(n.length).fill(void 0),c=new Map,l=[],u=new Set;for(let m=0;m<t.length;m+=1){let h=t[m];for(let d of h.objects){if(d.type==="table"&&u.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let y=It(d.outline,St);c.set(d.id,{section:d,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:d.id,floorIndex:m,box:Tt(y),section:d,unit:h,outline:y})}}let f=new Map;for(let m of l){let h=f.get(m.floorIndex);h?h.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<n.length;m++){let h=n[m],d=e?f.get(e[m])??[]:l,y=h.sectionId?d.find(p=>p.id===h.sectionId)??d.find(p=>p.section.logicalSectionId===h.sectionId&&Pt({x:h.x,y:h.y},p.outline,p.section.holes)):void 0,b=y?[y]:d;for(let p of b){if(e&&p.floorIndex!==e[m]||!y&&(h.x<p.box.minX||h.x>p.box.maxX||h.y<p.box.minY||h.y>p.box.maxY||!Pt({x:h.x,y:h.y},p.outline,p.section.holes)))continue;o[m]=p.id;let g=c.get(p.id);g.hasSeats=!0;let R=h.focalPoint??p.unit.focal,A=Math.hypot(h.x-R.x,h.y-R.y);A<g.frontU&&(g.frontU=A),g.seatIndices.push(m);let M=h.rowId||`__seat-${m}`,x=g.rows.get(M);x?x.push({x:h.x,y:h.y}):g.rows.set(M,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let d=Vt(h.section,{floorBaseHeightM:h.unit.baseHeightM}),y=h.unit.baseHeightM,b=d.rake>0?Math.tan(d.rake*Math.PI/180):0,p=d.rake<=.01&&d.height<=y+.001,g=h.section.surfaceKind,R=g==="flat"?!0:g==="rakedRows"&&d.rake>.01?!1:p,A=h.hasSeats?Ve(m,n,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},x=A.rows.length<2?co([...h.rows.values()].map(T=>({points:T})),h.unit.focal):null,I=1/0;if(x){if(h.hasSeats)for(let T of h.rows.values())for(let v of T){let H=x.depthAt(v.x,v.y);H<I&&(I=H)}if(!h.hasSeats||!Number.isFinite(I)){I=1/0;for(let T of h.section.outline){let v=x.depthAt(T.x,T.y);v<I&&(I=v)}}}let S=y+Ca,_=Math.max(S,d.height),O=T=>{let v=Math.max(0,T-I)*$,H=Math.min(v*b,Ie);return Math.max(S,d.height+H)},C=T=>{let v=Math.max(0,T)*$,H=Math.min(v*b,Ie);return Math.max(S,d.height+H)},F=R?[]:A.rows.map(T=>({pts:T.pts,y:C(T.blockDepth),depth:T.blockDepth,blockId:T.blockId,...u.has(T.id)?{patch:Oo(T.pts,St)}:{}})),k=F.length?F[0].y:_,E=F.map(T=>{let v=T.patch&&T.patch.length>=3?T.patch:T.pts,H=0,j=0;for(let X of v)H+=X.x,j+=X.y;let D=v.length||1;H/=D,j/=D;let U=0;for(let X of v){let Y=Math.hypot(X.x-H,X.y-j);Y>U&&(U=Y)}return{cx:H,cy:j,rad:U}}),w=R?()=>_:F.length>=2?(T,v)=>{let H=1/0,j=k;for(let D=0;D<F.length;D++){let U=E[D];if(Math.hypot(T-U.cx,v-U.cy)-U.rad>=H)continue;let X=F[D].patch,Y=X&&X.length>=3?xt(X,T,v)?0:_n(X,T,v):_n(F[D].pts,T,v);Y<H&&(H=Y,j=F[D].y)}return j}:(T,v)=>x?O(x.depthAt(T,v)):_,B=[0,1,0],L=F.length>=2||R?()=>B:(T,v)=>{if(!x)return B;let H=x.depthAt(T,v);if(H<=I)return B;let j=(H-I)*$;if(j*b>=Ie||d.height+j*b<=S)return B;let[D,U]=x.gradientAt(T,v);if(D===0&&U===0)return B;let X=1/Math.hypot(b,1);return[-D*b*X,X,-U*b*X]};if(!R)for(let T of A.rows){let v=C(T.blockDepth);for(let H of T.seatIndices)i[H]=v}for(let T of A.rows){let v=[];for(let X=1;X<T.pts.length;X++){let Y=Math.hypot(T.pts[X].x-T.pts[X-1].x,T.pts[X].y-T.pts[X-1].y);Y>1e-6&&v.push(Y)}v.sort((X,Y)=>X-Y);let H=v.length?v[Math.floor(v.length/2)]:1/0,j=1/0,D=T.pts[Math.floor(T.pts.length/2)];if(D)for(let X of A.rows){if(X===T||X.blockId!==T.blockId)continue;let Y=_n(X.pts,D.x,D.y);Y>1e-6&&Y<j&&(j=Y)}let U=Math.min(H,Math.max(j,H*.5));if(Number.isFinite(U)&&U>0)for(let X of T.seatIndices)a[X]=U}r.set(m,{sectionId:m,deckAt:w,normalAt:L,flat:R,bottomY:y,rowLevels:F,landingY:k})}for(let m=0;m<n.length;m++){let h=o[m],d=n[m];if(h){let p=i[m];s[m]=(p??r.get(h).deckAt(d.x,d.y))+sr;continue}let y=d.eyeHeightM,b=Number.isFinite(y)?Math.max(0,y-In):0;s[m]=d.kind==="booth"?b+Gt+sr:b}return{bySection:r,seatOwner:o,seatDeckY:m=>s[m],seatPitchU:m=>a[m]}}var ka=[.12,.38,.16],Fa=[.72,.62,.45],La=[.88,.93,.96],lr=[.95,.95,.94],va=[.66,.29,.22],_e={length:20.12,width:3.05},Na=.14,Ga=9.76,Ct=[.93,.94,.95],Wn=[.1,.11,.13],Da=[.45,.85,1.25],Ha=1.45,ur=.012,fr=.004,Xa=1.07,ja=.15;function on(t,n,e,r,o,s){t.setMaterial(s),Z(t,n,e?[e.slice().reverse()]:void 0,()=>r,r-.004,o,o,K)}var mr=(t,n)=>Lt(t,n/P);function hr(t,n,e){let r=n.x-t.x,o=n.y-t.y,s=Math.hypot(r,o);if(s<1e-9)return null;let i=-o/s*e,a=r/s*e;return[{x:t.x+i,y:t.y+a},{x:n.x+i,y:n.y+a},{x:n.x-i,y:n.y-a},{x:t.x-i,y:t.y-a}]}function Ua(t,n,e,r){let o=n.map(s=>[s.x*P,e,s.y*P]);t.tri(o[0],o[1],o[2],[0,1,0],r),t.tri(o[0],o[2],o[3],[0,1,0],r)}function Yn(t,n,e,r,o,s){let i=e/P,a=[{x:n.x-i,y:n.y-i},{x:n.x+i,y:n.y-i},{x:n.x+i,y:n.y+i},{x:n.x-i,y:n.y+i}];Z(t,a,void 0,()=>o,r,s,V(s,.85),K)}function en(t,n,e,r,o,s,i){let a=hr(n,e,r/P);a&&Z(t,a,void 0,()=>s,o,i,V(i,.85),K)}function zn(t){let n=bt(t),e={x:(n[0].x+n[2].x)/2,y:(n[0].y+n[2].y)/2},r=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y)||1,o=Math.hypot(n[3].x-n[0].x,n[3].y-n[0].y)||1,s={x:(n[1].x-n[0].x)/r,y:(n[1].y-n[0].y)/r},i={x:(n[3].x-n[0].x)/o,y:(n[3].y-n[0].y)/o};return{at:(c,l)=>({x:e.x+(s.x*c+i.x*l)/P,y:e.y+(s.y*c+i.y*l)/P}),lengthM:r*P,widthM:o*P}}function yr(t,n,e){let r=qe(n);if(!r.length)return;let o=1/0,s=-1/0,i=1/0,a=-1/0;for(let R of n.points??[])o=Math.min(o,R.x),s=Math.max(s,R.x),i=Math.min(i,R.y),a=Math.max(a,R.y);let c=(n.rotation??0)*Math.PI/180,l=Math.cos(c),u=Math.sin(c),f=(o+s)/2,m=(i+a)/2,h=R=>c?{x:f+(R.x-f)*l-(R.y-m)*u,y:m+(R.x-f)*u+(R.y-m)*l}:R,d=Math.min(s-o,a-i)*P,y=Math.max(.04,Math.min(.3,d*.004))/P,b=0;t.setMaterial(0);for(let R of r){if(!R.fill)continue;let A=R.points.map(h);on(t,A,null,e+ur+b*fr,it(R.fill)??Ct,0),b++}let p=r.filter(R=>!(R.fill&&R.ink===R.fill)),g=[...new Set(p.map(R=>R.ink??ee))];for(let R of g){let A=e+ur+b++*fr,M=it(R)??Ct;for(let x of p){if((x.ink??ee)!==R)continue;let I=x.points.map(h),S=x.closed?I.length:I.length-1;for(let _=0;_<S;_++){let O=hr(I[_],I[(_+1)%I.length],y);O&&Ua(t,O,A,M)}}}}function dr(t,n,e,r,o){if(n.length<3)return!1;let s=r+.006,i=o??ka;if(e==="oval-cricket"){let a=n.reduce((M,x)=>M+x.x,0)/n.length,c=n.reduce((M,x)=>M+x.y,0)/n.length,l=M=>n.map(x=>({x:a+(x.x-a)*M,y:c+(x.y-c)*M})),u=8;for(let M=0;M<u;M++){let x=l(1-M/u),I=M===u-1?null:l(1-(M+1)/u);on(t,x,I,s,V(i,M%2?1.04:.96),4)}let f=n[0];for(let M of n)Math.hypot(M.x-a,M.y-c)>Math.hypot(f.x-a,f.y-c)&&(f=M);let m=Math.hypot(f.x-a,f.y-c)||1,h=(f.x-a)/m,d=(f.y-c)/m,y=-d,b=h,p=Math.min(1,2*m*P*Na/_e.length),g=_e.length*p/2/P,R=_e.width*p/2/P,A=[[-g,-R],[g,-R],[g,R],[-g,R]].map(([M,x])=>({x:a+h*M+y*x,y:c+d*M+b*x}));return on(t,A,null,s+.004,Fa,0),t.setMaterial(0),!0}if(e==="rink-hockey"){let a=mr(n,ja);return on(t,a,null,s,La,0),t.setMaterial(0),Z(t,n,[a.slice().reverse()],()=>r+Xa,r,lr,V(lr,.9),K),!0}if(e==="ring-boxing"&&n.length===4){let{at:a}=zn(n),c=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],l=[[.77,.19,.19],Ct,[.17,.42,.69],Ct];t.setMaterial(0),c.forEach((u,f)=>Yn(t,u,.07,r,r+Ha,l[f]));for(let u of Da)for(let f=0;f<4;f++)en(t,c[f],c[(f+1)%4],.025,r+u-.025,r+u+.025,Ct);return!0}if(e==="court-tennis"&&n.length===4){let{at:a}=zn(n);t.setMaterial(0),en(t,a(0,-6.4),a(0,6.4),.015,r,r+.95,Wn),en(t,a(0,-6.4),a(0,6.4),.03,r+.95,r+1,Ct);for(let c of[-1,1])Yn(t,a(0,c*6.4),.05,r,r+1.07,Wn);return!0}if(e==="court-basketball"&&n.length===4){let{at:a,lengthM:c}=zn(n),l=Math.min(14,c/2-.5);t.setMaterial(0);for(let u of[-1,1]){let f=a(u*(l+1.2),0),m=a(u*(l-1.2),0);Yn(t,f,.12,r,r+3.4,Wn),en(t,f,m,.06,r+3.25,r+3.4,Wn),en(t,a(u*(l-1.2),-.9),a(u*(l-1.2),.9),.03,r+2.9,r+3.95,Ct)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:a,lengthM:c}=zn(n),l=c*(50/120);t.setMaterial(0);for(let u of[-1,1]){for(let f of[-2.8,2.8])Yn(t,a(u*l,f),.07,r,r+12,Ct);en(t,a(u*l,-2.8),a(u*l,2.8),.06,r+2.94,r+3.06,Ct)}return!0}if(e==="track-athletics"){let a=mr(n,Ga);return a.length<3?!1:(on(t,n,a,s,va,0),on(t,a,null,s,i,4),t.setMaterial(0),!0)}return!1}var pr=[.19,.4,.15],Wa=.012,qn=2.4,Ya=1,za=.75,Ka=.15;function At(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:r,rotation:o}=t;if(!e||!r)return null;let s=(o??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),c=e/2,l=r/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:n.x+u*i-f*a,y:n.y+u*a+f*i}))}function Sr(t,n,e,r,o,s,i=!1){let a=At(n);if(a){if(i){let c=Wt(r,o.boothTop),l=wt([...a]);Z(t,It(l,Va/P),[l.slice().reverse()],()=>e+.03,e,c,V(c,.8),K);return}if(!(!n.points&&s&&qa(t,a,e,r,s))){if(!n.points&&s&&a.length===4){Za(t,a,e,r,s);return}Z(t,a,void 0,()=>e+qn,e,Wt(r,o.boothTop),o.boothWall,K)}}}var Ae=1.1,xr=[.9,.9,.88],Va=.1,Kn=[.87,.87,.85],br=.08;function Ir(t,n){let e=c=>({x:(t[c].x+t[(c+1)%4].x)/2,y:(t[c].y+t[(c+1)%4].y)/2}),r=0,o=1/0;for(let c=0;c<4;c++){let l=e(c),u=Math.hypot(l.x-n.x,l.y-n.y);u<o&&(o=u,r=c)}let s=[0,1,2,3].map(c=>t[(r+c)%4]),i=(c,l,u)=>({x:c.x+(l.x-c.x)*u,y:c.y+(l.y-c.y)*u});return{q:s,part:(c,l,u,f)=>{let m=i(s[0],s[1],c),h=i(s[0],s[1],l),d=i(s[3],s[2],c),y=i(s[3],s[2],l);return[i(m,d,u),i(h,y,u),i(h,y,f),i(m,d,f)]},depthM:Math.hypot(s[3].x-s[0].x,s[3].y-s[0].y)*P,widthM:Math.hypot(s[1].x-s[0].x,s[1].y-s[0].y)*P}}function Za(t,n,e,r,o){let{q:s,part:i}=Ir(n,o),a=r??[.35,.42,.55],c=at(a,[.78,.78,.77],.62),l=at(a,[.95,.95,.94],.45);ot(t,s,e+Gt,e,c,V(c,.8)),ot(t,i(.05,.95,.72,.98),e+Ae-.05,e+Gt,l,V(l,.8)),ot(t,i(.03,.97,.7,1),e+Ae,e+Ae-.05,xr,V(xr,.9))}function qa(t,n,e,r,o){if(n.length!==4)return!1;let{q:s,part:i,depthM:a,widthM:c}=Ir(n,o);if(a<1||c<1)return!1;let l=r??[.35,.42,.55],u=at(l,[.78,.78,.77],.62),f=e+qn,m=br/c,h=br/a;ot(t,s,e+Gt,e,u,V(u,.8)),ot(t,i(0,1,1-h,1),f,e+Gt,Kn,V(Kn,.9));for(let[b,p]of[[0,m],[1-m,1]])ot(t,i(b,p,0,1-h),f,e+Gt,Kn,V(Kn,.9));ot(t,i(m,1-m,0,Math.min(.5,.06/a)),f,f-.3,l,V(l,.85));let d=Math.min(.4,.6/c),y=Math.min(.12,.3/a);return ot(t,i(.5-d,.5+d,.72-y,.72+y),e+Ya,e+Gt,at(l,[.95,.95,.94],.7),V(l,.75)),!0}function $n(t){if(t.shape==="round"){let u=t.radius;return u?Nn(t.center.x,t.center.y,u,u,24):null}let{width:n,height:e,rotation:r,center:o}=t;if(!n||!e)return null;let s=(r??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),c=n/2,l=e/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:o.x+u*i-f*a,y:o.y+u*a+f*i}))}function _r(t,n,e,r,o,s=!0){let i=$n(n);if(!i)return;let a=i.reduce((m,h)=>m+h.x,0)/i.length,c=i.reduce((m,h)=>m+h.y,0)/i.length,l=m=>i.map(h=>({x:a+(h.x-a)*m,y:c+(h.y-c)*m})),u=s&&r?Wt(r,o.tableTop):$a,f=e+za;Z(t,i,void 0,()=>f,e+Qa,u,V(u,.86),K),Z(t,l(.12),void 0,()=>f+.12,f,gr,V(gr,.8),K)}var $a=[.93,.92,.89],gr=[.78,.66,.42],Qa=.25,pn={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function Ja(t,n,e){let r=t.reduce((p,g)=>p+g.x,0)/4,o=t.reduce((p,g)=>p+g.y,0)/4,s=t[3].x-t[0].x,i=t[3].y-t[0].y,a=Math.hypot(s,i)||1;s/=a,i/=a,s*(n.x-r)+i*(n.y-o)<0&&(s=-s,i=-i);let c=-i,l=s,u=pn.armM/P,f=pn.widthM/P,m=a/2+pn.insideM/P,h=e?-1:1,d=r+s*(m+(e?0:u)),y=o+i*(m+(e?0:u)),b=(p,g)=>({x:d+s*p*h+c*g,y:y+i*p*h+l*g});return[b(0,0),b(-u,u),b(-u-f,u),b(-f,0),b(-u-f,-u),b(-u,-u)]}function tc(t,n,e,r,o){let s=[.94,.95,.96];Z(t,Ja(n,r,o),void 0,()=>e+pn.high,e+pn.low,s,s,K)}function Zn(t,n){let e=it(t);return e?{top:V(Et(e,.12),.95),wall:V(Et(e,.12),.85)}:{top:n.tierTop,wall:n.tierWall}}function Ar(t,n,e,r,o,s,i,a,c=[]){let l=ct(n),u=Uo(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!l){dn(t,n,e+r+Wa);return}let m=a?a.kind==="stage":n.role==="stage",h=a?a.kind==="screen":n.role==="screen",d=a?{kind:m?"stage":"solid",heightM:a.topY-a.baseY}:_t(n),y=a?.baseY??e,b=a?.topY??e+r;if(m&&i){let F=1/0,k=-1/0,E=1/0,w=-1/0;for(let B of l)B.x<F&&(F=B.x),B.x>k&&(k=B.x),B.y<E&&(E=B.y),B.y>w&&(w=B.y);i.push({cx:(F+k)/2*P,cz:(E+w)/2*P,y:b,halfX:Math.max((k-F)/2*P,.5),halfZ:Math.max((w-E)/2*P,.5)})}let p=it(n.fill),g=n.role==="wall"||n.role==="entrance"||n.role==="exit",R=g?Zn(n.fill,o).top:m&&p?at(o.stageTop,V(Et(p,.18),.9),.9):!n.role&&p?p:Wt(p,m?o.stageTop:o.decorTop),A=h?p:null,M=g?Zn(n.fill,o).wall:m?p?at(o.stageWall,V(p,.58),.82):o.stageWall:h?A?at(V(A,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Wt(it(n.fill),o.decorWall),x=m&&kn(o)?jt(!0):null,I=x?Pr(R,x.stageTop):R,S=x?Pr(M,x.stageWall):M;if(n.role==="wall"&&!a){jn(t,l,y,b,c,I,S,s),dn(t,n,b+.012);return}if(h&&l.length===4&&b-y>.2){let F=Pe(l,y,b);if(!F)return;let{quad:k,side:E,trim:w,inner:B,panel:L}=F,T=[.12,.15,.18];for(let[v,H]of[[0,E],[1-E,1]])ot(t,dt(k,v,H),b,y,T,T);ot(t,B,y+w,y,T,T),ot(t,B,b,b-w,T,T),ot(t,L,b-w,y+w,S,S),dn(t,n,b+.012);return}let _=p?V(Et(p,.15),.82):S,O=p?V(Et(p,.1),1.02):I;if(rr(n.role)&&!a&&ir(t,n.role,l,y,b,_,O,s,n.heightM!==void 0))return;if((n.role==="sound"||a?.kind==="sound_desk")&&l.length===4&&b-y>.3){let F=bt(l),k=Math.hypot(F[1].x-F[0].x,F[1].y-F[0].y)*P,E=Math.min(.12,.09/Math.max(k,.001)),w=[.18,.21,.24],B=b-Math.min(.12,(b-y)*.15);for(let[L,T]of[[0,E],[1-E,1]])ot(t,dt(F,L,T),B,y,w,w);ot(t,F,b,B,I,w);return}if(n.role==="rail"&&l.length===4&&b>y){let F=bt(l),k=Math.hypot(F[1].x-F[0].x,F[1].y-F[0].y)*P,E=Math.max(1,Math.min(128,Math.ceil(k/1.4))),w=Math.min(.08,.055/Math.max(.055,k)),B=[.58,.64,.66];for(let L=0;L<=E;L++){let T=L/E,v=Math.min(1-w,Math.max(0,T-w/2));ot(t,dt(F,v,v+w),b,y,B,V(B,.8))}for(let L of[.52,1]){let T=y+(b-y)*L;ot(t,F,T,Math.max(y,T-.055),B,V(B,.8))}return}if(n.role==="goal"&&l.length===4){let F=bt(l),k=Math.hypot(F[1].x-F[0].x,F[1].y-F[0].y)*P,E=Math.min(.12,.1/Math.max(.1,k)),w=[.9,.94,.94];for(let[B,L]of[[0,E],[1-E,1]])ot(t,dt(F,B,L),Math.max(y,b-.1),y,w,w);ot(t,F,b,Math.max(y,b-.1),w,w);return}if(d.kind==="portal"&&l.length===4){let F=tn(l,y,b);if(!F)return;let{quad:k,side:E,face:w,openingTop:B}=F;for(let[L,T,v]of[[0,w,1],[w,1-w,.67],[1-w,1,1]]){let H=mn(k,L,T),j=V(I,v),D=V(S,v);for(let[U,X]of[[0,E],[1-E,1]])ot(t,dt(H,U,X),B,y,j,D);ot(t,H,b,B,j,D)}(n.role==="entrance"||n.role==="exit")&&tc(t,k,y,s,n.role==="exit");return}if(d.kind==="suite"&&l.length===4){let F=l.map((w,B)=>{let L=l[(B+1)%4],T=(w.x+L.x)/2,v=(w.y+L.y)/2;return Math.hypot(T-s.x,v-s.y)}),k=F.indexOf(Math.min(...F)),E=[0,1,2,3].map(w=>l[(k+w)%4]);ot(t,dt(E,0,.08),b,y,I,S),ot(t,dt(E,.92,1),b,y,I,S),ot(t,mn(E,.88,1),b,y,I,S),ot(t,E,b,Math.max(y,b-.18),I,S);return}if(m&&!n.stageKind?.startsWith("pitch-")&&b-y>.12){let F=b-Math.min(.06,(b-y)*.15);ot(t,l,F,y,I,S,u),ot(t,l,b,F,I,at(I,S,.2),u)}else ot(t,l,b,y,I,S,u);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&l.length===4){t.setMaterial(4);let F=bt(l),k=at(p??pr,pr,p?.45:0);for(let E=0;E<12;E++){let w=dt(F,E/12,(E+1)/12),B=V(k,E%2?1.09:.91),L=w.map(T=>[T.x*P,b+.006,T.y*P]);t.tri(L[0],L[1],L[2],[0,1,0],B),t.tri(L[0],L[2],L[3],[0,1,0],B)}}n.stageKind&&n.stageKind!=="pitch-football"&&dr(t,l,n.stageKind,b,p),m&&Zt(n.stageKind)&&yr(t,n,b),t.setMaterial(h?1:0),dn(t,n,b+.012)}function Qn(t){let{x:n,y:e,width:r,height:o}=t;if(!r||!o)return null;let s=n+r/2,i=e+o/2,a=(t.rotation??0)*Math.PI/180,c=Math.cos(a),l=Math.sin(a),u=r/2,f=o/2;return[[-u,-f],[u,-f],[u,f],[-u,f]].map(([m,h])=>({x:s+m*c-h*l,y:i+m*l+h*c}))}function nc(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let r=e[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return it(r);let s=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!s)return null;let i=[];for(let a of s[1].matchAll(/stop-color="([^"]+)"/gi)){let c=it(a[1].trim());c&&i.push(c)}return i.length?i.reduce((a,c,l)=>at(a,c,1/(l+1)),i[0]):null}function Er(t,n,e,r){if(n.layer==="foreground")return;let o=Qn(n);if(!o)return;let s=e+Ka,i=Wt(nc(n.href),r.decorTop),a=Math.max(0,Math.min(1,n.opacity??1));a<1&&(i=at(r.ground,i,a)),Z(t,o,void 0,()=>s,e,i,at(i,r.decorWall,.5),K)}function wr(t,n,e,r,o){if(!n.points||n.points.length<3)return;let s=So(r,o.gaTop);Z(t,n.points,n.holes,()=>e+Mr,e,s,o.gaWall,K),rc(t,n.points,e+Mr)}var Mr=.15,Vn=[.72,.74,.76],Ee=1.1,Rr=.12,we=.05,ec=.06,oc=2.4;function rc(t,n,e){let r=wt([...n]),o=Lt(r,Rr/P),s=Lt(r,(Rr+we)/P);if(o.length<3||s.length<3)return;for(let a of[e+Ee,e+Ee*.5])Z(t,o,[s.slice().reverse()],()=>a,a-we,Vn,V(Vn,.85),K);let i=ec/2/P;for(let a=0;a<o.length;a++){let c=o[a],l=o[(a+1)%o.length],u=Math.hypot(l.x-c.x,l.y-c.y)*P,f=Math.max(1,Math.round(u/oc));for(let m=0;m<f;m++){let h=m/f,d=c.x+(l.x-c.x)*h,y=c.y+(l.y-c.y)*h,b=[{x:d-i,y:y-i},{x:d+i,y:y-i},{x:d+i,y:y+i},{x:d-i,y:y+i}];Z(t,b,void 0,()=>e+Ee-we,e,Vn,V(Vn,.8),K)}}}function Pr(t,n){return Tn(t)<n?Xt(t,n):t}var ic=1.5,sc=30,ac=4,cc=3.6,lc=6,Be=15,uc=3,fc=1;function mc(t){return Math.max(cc,Math.min(lc,2.4+.15*t))}var xn=Math.PI*2;function hc(t,n){let e=0,r=0;for(let f of t)e+=f.x,r+=f.y;let o=Math.atan2(r/t.length-n.y,e/t.length-n.x),s=t.map(f=>{let m=Math.atan2(f.y-n.y,f.x-n.x)-o;for(;m>Math.PI;)m-=xn;for(;m<-Math.PI;)m+=xn;return m+o}),i=s.map((f,m)=>m).sort((f,m)=>s[f]-s[m]),a=s[i[0]],c=s[i[i.length-1]];if(c-a>Math.PI)return null;let l=f=>Math.hypot(f.x-n.x,f.y-n.y),u=f=>{let m=t[f],h=(f+t.length-1)%t.length,d=(f+1)%t.length,y=Math.abs(s[h]-s[f])<=Math.abs(s[d]-s[f])?h:d,b=t[y];return l(m)<=l(b)?[m,b]:[b,m]};return{start:a,end:c,startEdge:u(i[0]),endEdge:u(i[i.length-1])}}function Br(t){return t.type==="shape"&&t.role==="wall"&&t.heightM===void 0}function Te(t,n,e=()=>!0){let r=[];for(let c of t){if(!Br(c)||!e(c))continue;let l=ct(c);if(!l||l.length<3)continue;let u=hc(l,n);if(!u)return[];r.push(u)}if(r.length<2)return[];let o=t.flatMap(c=>{if(c.type!=="shape"||c.role!=="entrance"&&c.role!=="exit")return[];let l=ct(c);if(!l?.length)return[];let u=0,f=0;for(let m of l)u+=m.x,f+=m.y;return[{x:u/l.length,y:f/l.length}]}),s=c=>(c%xn+xn)%xn;r.sort((c,l)=>s(c.start)-s(l.start));let i=c=>Math.hypot(c.x-n.x,c.y-n.y),a=[];for(let c=0;c<r.length;c++){let l=r[c],u=r[(c+1)%r.length],f=s(u.start-l.end);if(f<=0||f>=Math.PI/2)continue;let m=x=>s(x-l.end)<f;if(r.some(x=>x!==l&&x!==u&&(m(x.start)||m(x.end)||s(l.end-x.start)<x.end-x.start)))continue;let[d,y]=l.endEdge,[b,p]=u.startEdge,g={x:(d.x+y.x)/2,y:(d.y+y.y)/2},R={x:(b.x+p.x)/2,y:(b.y+p.y)/2},A=Math.hypot(R.x-g.x,R.y-g.y)*P;if(A<ic||A>sc||Math.abs(i(g)-i(R))*P>ac+.2*A)continue;let M={x:(g.x+R.x)/2,y:(g.y+R.y)/2};o.some(x=>m(Math.atan2(x.y-n.y,x.x-n.x))&&Math.abs(i(x)-i(M))*P<=uc)||a.push({quad:[d,y,p,b],mid:M,widthM:A,openingM:mc(A)})}return a}function Tr(t,n){let e=[];for(let s of n)if(s.text?.trim())for(let i of t){let a=Math.hypot(s.position.x-i.mid.x,s.position.y-i.mid.y)*P;a<=Be&&e.push({text:s,gate:i,d:a})}e.sort((s,i)=>s.d-i.d);let r=new Map,o=new Set;for(let{text:s,gate:i}of e)r.has(s.id)||o.has(i)||(r.set(s.id,i),o.add(i));return r}function Or(t,n,e,r,o,s,i,a=()=>!0){let c=Te(n,Jt(e),a);if(!c.length)return;let l=n.find(f=>Br(f)&&a(f)),u=Zn(l?.fill,i);t.setMaterial(Xn);for(let f of c)o-f.openingM<fc||jn(t,f.quad,r+f.openingM,r+o,[],u.top,u.wall,s,o);t.setMaterial(0)}var yc=6,dc=2.2,Jn=.1,pc=/^(gate|entrance|entry|exit|way in|way out|door)s?$/i,xc=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),bc=.3,gc=1.8,Mc=.9,Rc=.55,Pc=1,Cr=4e3,Sc=6,kr="#d8a425",Ic="#e8c15a",Oe="#1c1608";function Fr(t){let n=_c(t);if(!n)return null;let e=$e(t).find(r=>r.icon===n.icon);return{...n,name:e?.titleFallback??n.icon}}function _c(t){let n=t.accessibility;if(n?.length)return{icon:n.includes("wheelchair")?"wheelchair":n[0],color:Sn(n)};let e=t.commercial;return e?.obstructedView?{icon:"obstructedView",color:kr,ink:Oe}:e?.restrictedView?{icon:"restrictedView",color:kr,ink:Oe}:e?.premium?{icon:"premium",color:Ic,ink:Oe}:null}function Ac(t,n){if(!t)return;let e,r=0;for(let[s,i]of t)i>r&&(r=i,e=s);let o=n.categories?.find(s=>s.key===e)?.color;return o&&/^#[0-9a-f]{6}$/i.test(o)?o:void 0}var Ec=6e3,wc=.25,Lr=[-90,90,-135,135,-45,45];function Bc(t,n,e,r){let o=t.flatMap(({id:i,a,members:c})=>{let l=(a.minX+a.maxX)/2,u=(a.minY+a.maxY)/2,f=.5*Math.hypot(a.maxX-a.minX,a.maxY-a.minY),m=1/0;for(let h of c)m=Math.min(m,Math.hypot(n[h].x-l,n[h].y-u));return c.length&&m>=f*wc?[{id:i,cx:l,cy:u,half:f,members:c}]:[]}).sort((i,a)=>i.half-a.half),s=new Map;return o.forEach(({id:i,cx:a,cy:c,members:l},u)=>{let f=r.x-a,m=r.y-c,y=(Math.hypot(f,m)>1e-6?Math.atan2(m,f):0)+Lr[u%Lr.length]*Math.PI/180,b=Math.cos(y),p=Math.sin(y),g=-1,R=-1/0;for(let A of l){let M=(n[A].x-a)*b+(n[A].y-c)*p;M>R&&(R=M,g=A)}s.set(i,[n[g].x*P,e.seatDeckY(g),n[g].y*P])}),s}function Nr(t){let{doc:n,units:e,seats:r,surfaces:o,focal:s}=t,i=n.zones??[],a=[];if(i.length){let c=new Map;for(let m of e)for(let h of m.objects)h.type==="section"&&h.zone&&c.set(h.id,h.zone);let l=new Map,u=new Map;for(let m=0;m<r.length;m++){let h=r[m],d=o.seatOwner[m],y=h.zoneId??(d?c.get(d):void 0);if(!y)continue;let b=l.get(y);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(y,b));let p=u.get(y);p||u.set(y,p=[]),p.push(m),b.n++,h.x<b.minX&&(b.minX=h.x),h.y<b.minY&&(b.minY=h.y),h.x>b.maxX&&(b.maxX=h.x),h.y>b.maxY&&(b.maxY=h.y),b.sumY+=o.seatDeckY(m)}let f=Bc(i.flatMap(m=>{let h=l.get(m.id);return h?[{id:m.id,a:h,members:u.get(m.id)??[]}]:[]}),r,o,s);for(let m of i){let h=l.get(m.id),d=[];for(let[y,b]of c)b===m.id&&d.push(y);if(!h||h.n===0){a.push({id:m.id,label:m.label,color:it(m.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(m.focalPoint??s).x*P,1.5,(m.focalPoint??s).y*P]});continue}a.push({id:m.id,label:m.label,color:it(m.color),sectionIds:d,seatCount:h.n,...f.has(m.id)?{labelAt:f.get(m.id)}:{},center:[(h.minX+h.maxX)/2*P,h.sumY/h.n,(h.minY+h.maxY)/2*P],radius:.5*Math.hypot((h.maxX-h.minX)*P,(h.maxY-h.minY)*P)||1,focalWorld:[(m.focalPoint??s).x*P,1.5,(m.focalPoint??s).y*P]})}}return a}function Gr(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:s,hintedSeatFloor:i,zones:a,focal:c}=t,l=[],u=[],f=[],m=new Map;for(let h of e)for(let d of h.objects){if(d.type!=="section"||!d.zone)continue;let y=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!y)continue;let b=n.floors?.[h.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&b===y)continue;let p=m.get(d.zone);p||m.set(d.zone,p=new Set),p.add(y)}for(let h of a)h.seatCount!==0&&(m.get(h.id)?.has(h.label.trim().toLocaleLowerCase())||l.push({id:`zone:${h.id}`,kind:"zone",text:h.label,anchor:[(h.labelAt??h.center)[0],(h.labelAt??h.center)[1]+yc,(h.labelAt??h.center)[2]],color:n.zones?.find(d=>d.id===h.id)?.color}));{let h=new Map,d=new Map,y=new Map,b=new Map;for(let p=0;p<r.length;p++){let g=o.seatOwner[p];if(!g)continue;let R=h.get(g);R||(R={n:0,x:0,y:0,deck:0},h.set(g,R)),R.n++,R.x+=r[p].x,R.y+=r[p].y,R.deck+=o.seatDeckY(p);let A=r[p].categoryKey;if(A){let x=d.get(g);x||(x=new Map,d.set(g,x)),x.set(A,(x.get(A)??0)+1)}if(r[p].accessibility?.includes("wheelchair")){let x=y.get(g);x?x.push(p):y.set(g,[p])}let M=b.get(g);M||(M={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},b.set(g,M)),M.minDeck=Math.min(M.minDeck,o.seatDeckY(p)),M.maxDeck=Math.max(M.maxDeck,o.seatDeckY(p)),r[p].x<M.minX&&(M.minX=r[p].x),r[p].x>M.maxX&&(M.maxX=r[p].x),r[p].y<M.minY&&(M.minY=r[p].y),r[p].y>M.maxY&&(M.maxY=r[p].y)}for(let p of e)for(let g of p.objects){if(g.type!=="section"||qo(g))continue;let R=h.get(g.id);if(!R||R.n===0)continue;let A=b.get(g.id),M=[R.x/R.n*P,R.deck/R.n,R.y/R.n*P],x=g.displayLabel||g.label||g.id;u.push({id:g.id,floorIndex:p.index,label:x,seatCount:R.n,center:M,radius:Math.max(1,Math.hypot(A.maxX-A.minX,A.maxY-A.minY)*.5*P),box:{min:[A.minX*P-.4,A.minDeck,A.minY*P-.4],max:[A.maxX*P+.4,A.maxDeck+1,A.maxY*P+.4]},focalWorld:[p.focal.x*P,p.baseHeightM+1.5,p.focal.y*P]});let I=n.floors?.[p.index]?.name?.trim().toLocaleLowerCase();if(!(e.length>1&&I===x.trim().toLocaleLowerCase())){let S=Ac(d.get(g.id),n),_=y.get(g.id);l.push({id:`section:${g.id}`,kind:"section",text:x,anchor:[M[0],M[1]+dc,M[2]],floorIndex:p.index,...S?{tint:S}:{},..._?{wheelchairSeats:_}:{}})}}}{for(let M of e)for(let x of M.objects){if(x.type!=="gaArea")continue;let I=Kt(x.points);if(!I)continue;let S=x.labelPresentation?.visible===!1?"":x.displayLabel||x.label||x.id,_=x.capacity>0?[S,x.capacity.toLocaleString()].filter(Boolean).join(" \xB7 "):S;_&&l.push({id:`ga:${x.id}`,kind:"ga",text:_,anchor:[I.x*P,M.baseHeightM+gc,I.y*P],floorIndex:M.index})}let h=new Map,d=new Map;for(let M of e)for(let x of M.objects)if(x.type==="section"&&h.set(x.id,x.displayLabel||x.label||x.id),x.type==="row"){let I=x.displayLabel?.trim()||x.segmentedRow?.displayLabel?.trim();I&&d.set(x.id,I)}let y=new Map;for(let M=0;M<r.length;M++){let x=r[M],I=Math.hypot(x.x-c.x,x.y-c.y),S=y.get(x.rowId);(!S||I>S.far)&&y.set(x.rowId,{seat:x,index:M,far:I})}for(let[M,x]of y){let I=o.seatOwner[x.index]??x.seat.sectionId,S=vr(x.seat.label,M,h.get(I??""),d.get(M));S&&l.push({id:`row:${M}`,kind:"row",text:S,anchor:[x.seat.x*P,o.seatDeckY(x.index)+Mc,x.seat.y*P],floorIndex:i[x.index]})}let b=new Map;for(let M=0;M<r.length;M++){let x=r[M],I=b.get(x.rowId);I||(I={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:vr(x.label,x.rowId,h.get(o.seatOwner[M]??x.sectionId??""),d.get(x.rowId)),sectionId:o.seatOwner[M]??x.sectionId},b.set(x.rowId,I));let S=M*3,_=s.iPosition[S],O=s.iPosition[S+1],C=s.iPosition[S+2];I.n++,I.x+=_,I.y+=O,I.z+=C,I.minX=Math.min(I.minX,_),I.maxX=Math.max(I.maxX,_),I.minZ=Math.min(I.minZ,C),I.maxZ=Math.max(I.maxZ,C)}for(let[M,x]of b)f.push({id:M,label:x.label,sectionId:x.sectionId,seatCount:x.n,center:[x.x/x.n,x.y/x.n,x.z/x.n],radius:Math.max(.8,Math.hypot(x.maxX-x.minX,x.maxZ-x.minZ)*.5)});let p=0,g=(M,x)=>{p++,l.push({id:`access:${r[M].id}`,kind:"access",text:x.name,icon:x.icon,color:x.color,...x.ink?{ink:x.ink}:{},seatWidthM:s.iChairWidth[M]*2,anchor:[r[M].x*P,o.seatDeckY(M)+Pc,r[M].y*P],floorIndex:i[M],rowId:r[M].rowId})},R=null,A=()=>{if(R){let M=Fr(r[R.seats[0]]),x=R.seats.length,I=Math.max(1,Math.round(x/Sc));for(let S=0;S<I&&p<Cr;S++)g(R.seats[Math.min(x-1,Math.floor((S+.5)*x/I))],M)}R=null};for(let M=0;M<r.length&&p<Cr;M++){let x=Fr(r[M]);if(x&&r[M].accessibility?.length){A(),g(M,x);continue}if(!x){A();continue}R&&R.rowId===r[M].rowId&&R.icon===x.icon?R.seats.push(M):(A(),R={rowId:r[M].rowId,icon:x.icon,seats:[M]})}if(A(),r.length<=Ec)for(let M=0;M<r.length;M++){let x=r[M],I=Tc(x.displayLabel||x.label);I&&l.push({id:`seat:${x.id}`,kind:"seat",seatWidthM:s.iChairWidth[M]*2,text:I,anchor:[x.x*P,o.seatDeckY(M)+Rc,x.y*P],floorIndex:i[M],rowId:x.rowId})}}for(let h of e){let d=Nt(h,e.length===1?r:r.filter((p,g)=>i[g]===h.index)),y=d?Tr(Te(h.objects,Jt(d)),h.objects.filter(p=>p.type==="text")):new Map,b=[...y.values()];for(let p of h.objects){let g=p.type==="text"?y.get(p.id):void 0;if(p.type==="shape"&&(p.role==="entrance"||p.role==="exit")&&pc.test(p.label?.trim()??"")){let R=ct(p),A=R?Kt(R):null;if(A&&b.some(M=>Math.hypot(A.x-M.mid.x,A.y-M.mid.y)*P<=Be+M.widthM))continue}if(g&&p.type==="text")l.push({id:`text:${p.id}`,kind:"gate",text:p.text,icon:"entrance",anchor:[g.mid.x*P,h.baseHeightM+g.openingM+Jn,g.mid.y*P],color:p.color,floorIndex:h.index});else if(p.type==="shape"&&p.role&&xc.has(p.role)){let R=ct(p),A=R?Kt(R):null;if(!A||!p.label||p.gate?.hideFromBuyers)continue;l.push({id:`architecture:${p.id}`,kind:p.role==="stage"?"stage":p.role==="entrance"||p.role==="exit"?"gate":"annotation",text:p.label,...p.role==="entrance"||p.role==="exit"?{icon:p.role}:{},...p.gate?.stepFree?{stepFree:!0}:{},anchor:[A.x*P,h.baseHeightM+_t(p).heightM+Jn,A.y*P],color:p.fill,floorIndex:h.index})}else if(p.type==="text"){let R=p.semanticKind==="icon"?oe(p.iconKey)?.key:void 0,A=p.text||(R?oe(R).label:"");if(!A)continue;l.push({id:`text:${p.id}`,kind:"annotation",text:A,...R?{venueIcon:R}:{},anchor:R?[(p.position.x+p.fontSize/2)*P,h.baseHeightM+Jn,(p.position.y+p.fontSize/2)*P]:[p.position.x*P,h.baseHeightM+Jn,p.position.y*P],color:p.color,rotation:p.rotation,floorIndex:h.index})}else if(p.type==="booth"){if(p.labelPresentation?.visible===!1)continue;let R=At(p);if(!R)continue;let A=Kt(R);if(!A)continue;l.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[A.x*P,h.baseHeightM+qn+bc,A.y*P],floorIndex:h.index})}}}return{labels:l,sections:u,rows:f}}function Dr(t,n){if(n.length>1)for(let e of n)t.push({id:`floor:${e.id}`,kind:"floor",text:e.label,anchor:[e.center[0],e.box.max[1]+1.2,e.center[2]],floorIndex:e.index})}function Tc(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function vr(t,n,e,r){if(r?.trim())return r.trim();let o=t?t.lastIndexOf("-"):-1,s=o>0?t.slice(0,o):n;return s&&eo(s,e)}var bn=3,Yt=.38,gn=.24;function Oc(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],r=t[t.length-1],o=(e.x-n.x)*P,s=(e.y-n.y)*P,i=(r.x-n.x)*P,a=(r.y-n.y)*P,c=2*(o*a-s*i);if(Math.abs(c)<1e-7)return null;let l=o*o+s*s,u=i*i+a*a,f=(l*a-u*s)/c+n.x*P,m=(o*u-i*l)/c+n.y*P,h=Math.hypot(n.x*P-f,n.y*P-m);return h<1||h>200||!Number.isFinite(h)||t.some(d=>Math.abs(Math.hypot(d.x*P-f,d.y*P-m)-h)>.03)?null:{x:f,z:m,radius:h}}function Hr(t){let n=[],e=new Map,r=(c,l)=>`${Math.floor(c/bn)},${Math.floor(l/bn)}`;for(let c of t)for(let l of c.rows){for(let f of l.pts){let m=f.x*P,h=f.y*P,d=r(m,h),y=e.get(d)??[];y.push({x:m,z:h,y:l.y,floor:c.floorIndex}),e.set(d,y)}if(l.patch||l.pts.length<2)continue;let u=Oc(l.pts);for(let f of[0,l.pts.length-1]){let m=l.pts[f],h=l.pts[f===0?1:f-1],d=m.x-h.x,y=m.y-h.y,b=Math.hypot(d,y);b<1e-6||n.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:u,row:l,point:m,x:m.x*P,z:m.y*P,dx:d/b,dz:y/b})}}let o=new Map;n.forEach((c,l)=>{let u=r(c.x,c.z),f=o.get(u)??[];f.push(l),o.set(u,f)});let s=(c,l)=>{let u=Math.floor(c/bn),f=Math.floor(l/bn);return[-1,0,1].flatMap(m=>[-1,0,1].map(h=>`${u+m},${f+h}`))},i=new Map;n.forEach((c,l)=>{let u=-1,f=1/0,m=!1;for(let h of s(c.x,c.z))for(let d of o.get(h)??[]){let y=n[d];if(c.sectionId===y.sectionId&&c.row.blockId===y.row.blockId||c.floorIndex!==y.floorIndex||Math.abs(c.row.y-y.row.y)>.05)continue;let b=y.x-c.x,p=y.z-c.z,g=Math.hypot(b,p);if(g<Yt*2+.45||g>bn)continue;let R=c.curve&&y.curve&&Math.hypot(c.curve.x-y.curve.x,c.curve.z-y.curve.z)<=.05&&Math.abs(c.curve.radius-y.curve.radius)<=.05,A=Math.min((b*c.dx+p*c.dz)/g,(-b*y.dx-p*y.dz)/g);(R?A<.8:A<.98)||!R&&(Math.abs(b*c.dz-p*c.dx)>.15||Math.abs(b*y.dz-p*y.dx)>.15)||(g<f-.02?(u=d,f=g,m=!1):Math.abs(g-f)<=.02&&(m=!0))}u>=0&&!m&&i.set(l,u)});let a=[];for(let[c,l]of i){if(c>=l||i.get(l)!==c)continue;let u=n[c],f=n[l],m=Math.hypot(f.x-u.x,f.z-u.z),h=(f.x-u.x)/m,d=(f.z-u.z)/m,y=!1;for(let p of s((u.x+f.x)/2,(u.z+f.z)/2))for(let g of e.get(p)??[]){if(g.floor!==u.floorIndex||Math.abs(g.y-u.row.y)>.75)continue;let R=(g.x-u.x)*h+(g.z-u.z)*d,A=Math.abs((g.x-u.x)*d-(g.z-u.z)*h);R>.01&&R<m-.01&&A<gn+Yt&&(y=!0)}if(y)continue;let b=(p,g)=>({x:(u.x+h*p-d*g)/P,y:(u.z+d*p+h*g)/P});a.push({sections:[u.sectionId,f.sectionId],blocks:[u.row.blockId,f.row.blockId],floorIndex:u.floorIndex,ends:[u.point,f.point],clearWidthM:m-2*Yt,heightM:(u.row.y+f.row.y)/2,outline:[b(Yt,-gn),b(m-Yt,-gn),b(m-Yt,gn),b(Yt,gn)]})}return a}var Cc=.15,kc=.9,Fc=1.76;function Xr(t){return Ce(t)?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function Ce(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55}function Lc(){return{background:{top:[...le.top],bottom:[...le.bottom]},sky:Xr(null),structure:ce,seatStates:{...yo},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function vc(t){return Ce(t)?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function jr(t){let n=Lc();t??={};let e=it(t.background);if(e){n.background={top:V(e,kc),bottom:V(e,Fc)},n.sky=Xr(e);let a={};for(let[l,u]of Object.entries(ce))a[l]=at(u,e,Cc);e[0]*.2126+e[1]*.7152+e[2]*.0722>.55&&(a.ground=V(e,.86)),n.structure=a}let r=it(t.selectionColor)??it(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=ro(o));let s=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([,a])=>a!=null)),i={...vc(e),...s};if(i){let a=it(i.deck),c=it(i.fascia);a&&(n.structure={...n.structure,tierTop:a,gaTop:a}),c&&(n.structure={...n.structure,tierWall:c,gaWall:c}),n.materials.seat=it(i.seat),n.materials.shell=it(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return Nc(n,Ce(e)),n}function Nc(t,n){let e=jt(n);t.seatStates={...t.seatStates,held:On(e.unavailable),sold:On(e.unavailable),dimmed:On(e.dimmed)};let r=(s,i)=>Xt(s,i,Math.min(an(s),Cn)),o=t.structure;t.structure={...o,ground:r(o.ground,e.ground),tierTop:r(o.tierTop,e.deck),tierWall:r(o.tierWall,e.fascia)},t.materials.shell&&(t.materials.shell=r(t.materials.shell,e.shell))}function Ur(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var ke=.6,Wr=3,Gc=.25;function Dc(t,n){if(xt(n,t.x,t.y))return 0;let e=1/0;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[o],i=n[r],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c||1,u=Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/l));e=Math.min(e,Math.hypot(t.x-(s.x+u*a),t.y-(s.y+u*c)))}return e}function Yr(t,n){let e=t.map(i=>({booth:i,ring:At(i)})).filter(i=>!!i.ring&&i.ring.length===4&&!i.booth.points),r=e.map(({ring:i})=>({minX:Math.min(...i.map(a=>a.x)),maxX:Math.max(...i.map(a=>a.x)),minY:Math.min(...i.map(a=>a.y)),maxY:Math.max(...i.map(a=>a.y))})),o=(Wr+ke)/P,s=new Map;return e.forEach(({booth:i,ring:a},c)=>{let l={x:a.reduce((h,d)=>h+d.x,0)/4,y:a.reduce((h,d)=>h+d.y,0)/4},u=[0,1,2,3].map(h=>{let d=a[h],y=a[(h+1)%4],b={x:(d.x+y.x)/2,y:(d.y+y.y)/2},p=b.x-l.x,g=b.y-l.y,R=Math.hypot(p,g)||1,A={x:b.x+p/R*ke/P,y:b.y+g/R*ke/P},M=Wr/P;return r.forEach((x,I)=>{I===c||A.x<x.minX-o||A.x>x.maxX+o||A.y<x.minY-o||A.y>x.maxY+o||(M=Math.min(M,Dc(A,e[I].ring)))}),{open:M*P,toward:{x:b.x+p/R*10/P,y:b.y+g/R*10/P},focal:Math.hypot(b.x-n.x,b.y-n.y)}}),f=Math.max(...u.map(h=>h.open)),m=u.filter(h=>h.open>=f-Gc).sort((h,d)=>h.focal-d.focal)[0];s.set(i.id,m.toward)}),s}import Hc from"polygon-clipping";var Xc=.45,jc=1500,Uc=200;function zr(t,n){if(t.role!=="stage"||Zt(t.stageKind))return t;let e=ct(t);if(!e||e.length<3||Math.abs(pt(e))*P*P>jc)return t;let r=n.filter(i=>xt(e,i.x,i.y));if(!r.length||r.length>Uc)return t;let o=Xc/P,s=r.map(i=>[[[i.x-o,i.y-o],[i.x+o,i.y-o],[i.x+o,i.y+o],[i.x-o,i.y+o],[i.x-o,i.y-o]]]);try{let i=Hc.difference([[...e.map(l=>[l.x,l.y]),[e[0].x,e[0].y]]],...s),a=null,c=0;for(let l of i){let u=l[0].slice(0,-1).map(([m,h])=>({x:m,y:h})),f=Math.abs(pt(u));f>c&&(c=f,a=u)}return!a||a.length<3?t:{...t,kind:"polygon",points:a,rotation:0}}catch{return t}}function Fe(t,n,e,r,o,s,i,a,c,l=[],u=o){if(n.length!==e.length||n.length<2||s-o<1.5)return;let f=(y,b,p)=>{Ot(t,y,b,p,l,i,a,{portalBase:u,ao:c})||Z(t,y,void 0,()=>p,b,i,a,c)},m=(y,b,p)=>({x:y.x+(b.x-y.x)*p,y:y.y+(b.y-y.y)*p}),h=r?n.length:n.length-1,d=0;for(let y=0;y<h;y++){let b=(y+1)%n.length,p=Math.hypot(e[b].x-e[y].x,e[b].y-e[y].y)*$;if(p<1e-5)continue;let g=(x,I)=>[m(n[y],n[b],x),m(n[y],n[b],I),m(e[y],e[b],I),m(e[y],e[b],x)];f(g(0,1),o,o+.95),f(g(0,1),s-.22,s);let R=Math.ceil((d-.32)/6)*6,A=!1,M=!1;for(let x=R;x<d+p;x+=6){let I=Math.max(0,(x-d)/p),S=Math.min(1,(x+.32-d)/p);S<=I||(f(g(I,S),o+.95,s-.22),A||=I<1e-6,M||=S>1-1e-6)}if(!r&&(y===0&&!A||y===h-1&&!M)){let x=Math.min(1,.32/p);f(g(y===0?0:1-x,y===0?x:1),o+.95,s-.22)}d+=p}}import zt from"polygon-clipping";var Rn=.65;function Le(t,n){let e=1/0;for(let r of n)for(let o=0;o<r.length;o++){let s=r[o],i=r[(o+1)%r.length],a=i.x-s.x,c=i.y-s.y,l=Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/(a*a+c*c||1)));e=Math.min(e,Math.hypot(t.x-s.x-l*a,t.y-s.y-l*c))}return e}var ve=.01;function Kr(t,n,e,r,o,s,i,a=[],c=!0,l={bays:[],walls:[]}){if(r-o<=1e-5)return;let u=r-o>=3,f=u?r-Rn:o;t.setMaterial(5);let m=u?[]:a.filter(x=>{if(x.role!=="entrance"&&x.role!=="exit")return!1;let I=ct(x);if(!I)return!1;let S=tn(I,o,o+_t(x).heightM);return S!==null&&S.openingTop<=r-.12});if((!m.length||!Ot(t,n,f,r,m,s,i,{holes:e,portalBase:o}))&&Z(t,n,e,()=>r,f,s,i,K,void 0,()=>[0,1,0]),!u){t.setMaterial(0);return}let h=c&&l.bays.length?Wc(n,e,Lt(n,Mn/P),l):null,d=6/P,y=.22/P,b=a.flatMap(x=>{if(x.role!=="entrance"&&x.role!=="exit")return[];let I=ct(x);return I?.length?[{minX:Math.min(...I.map(S=>S.x)),maxX:Math.max(...I.map(S=>S.x)),minY:Math.min(...I.map(S=>S.y)),maxY:Math.max(...I.map(S=>S.y))}]:[]}),p=Math.min(...n.map(x=>x.x)),g=Math.max(...n.map(x=>x.x)),R=Math.min(...n.map(x=>x.y)),A=Math.max(...n.map(x=>x.y));for(let x=p+d/2;x<g;x+=d)for(let I=R+d/2;I<A;I+=d){if(b.some(_=>x+y>=_.minX&&x-y<=_.maxX&&I+y>=_.minY&&I-y<=_.maxY))continue;let S=[{x:x-y,y:I-y},{x:x+y,y:I-y},{x:x+y,y:I+y},{x:x-y,y:I+y}];!Pt({x,y:I},n,e)||Le({x,y:I},[n,...e??[]])<y*Math.SQRT2+(c?Mn/P:0)||h&&Le({x,y:I},h.flat())<y*Math.SQRT2+Mn/P||Z(t,S,void 0,()=>f,o,s,i,K)}if(h){for(let[x,...I]of h)Z(t,x,I,()=>f,o-ve,s,i,K);t.setMaterial(0);return}let M=Lt(n,Mn/P);if(c&&M.length>=3){let x=a.filter(_=>{if(_.role!=="entrance"&&_.role!=="exit")return!1;let O=ct(_);return!!O&&O.some(C=>!Pt(C,n,void 0)||Le(C,[n])<=Mn/P)}),I=[M.slice().reverse()],S=o-ve;(!x.length||!Ot(t,n,S,f,x,s,i,{holes:I,portalBase:o+ve}))&&Z(t,n,I,()=>f,S,s,i,K)}t.setMaterial(0)}var Ne=.25,Mn=Ne;function Wc(t,n,e,r){if(e.length<3)return null;let o=i=>{let a=i.map(c=>[c.x,c.y]);return a.push(a[0]),a},s=i=>{let[a,...c]=i.map(l=>[o(l)]);return zt.union(a,...c)};try{let i=[o(t),...(n??[]).map(o)],a=zt.difference(i,[o(e)]),c=zt.intersection(i,s(r.bays));if(!c.length)return null;let l=zt.difference(zt.intersection(i,s(r.walls)),c);return zt.union(zt.difference(a,c),l).map(f=>f.map(m=>m.slice(0,-1).map(([h,d])=>({x:h,y:d}))))}catch{return null}}var Yc=.02,zc=.25,Kc=1.2,Vc=.6,Zc=.45,qc=2.3,$c=Math.PI/180,Vr=.005;function Bt(t,n,e){let r=e*$c;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function Qc(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let r=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let s=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(s.length<2)continue;let i=0;for(let a of s)Math.hypot(a.x-n.centre.x,a.y-n.centre.y)>=r&&i++;if(i>=s.length/2)return!0}return!1}var Jc=24,tl=.01;function nl(t,n,e,r,o,s,i,a,c){let l=e.binCount,u=Jc,f=$,m=s+.02,h=s-tl,d=[];for(let E=0;E<l;E++){let w=(e.startBin+E+.5)*n.binStepDeg,B=new Float64Array(u+1);for(let L=0;L<=u;L++){let T=r[E]+(o[E]-r[E])*L/u;B[L]=Math.max(m,uo(n,e,w,T)-zc)}d.push(B)}if(c){let E=0;for(let w=0;w+1<l;w++)for(let B=0;B<u;B++){let L=Bt(n.centre,r[w]+(o[w]-r[w])*B/u,(e.startBin+w+.5)*n.binStepDeg),T=Bt(n.centre,r[w+1]+(o[w+1]-r[w+1])*(B+1)/u,(e.startBin+w+1.5)*n.binStepDeg);E=Math.max(E,Math.hypot(T.x-L.x,T.y-L.y))}for(let w=0;w<l;w++){let B=(e.startBin+w+.5)*n.binStepDeg;for(let L=0;L<=u;L++){let T=Bt(n.centre,r[w]+(o[w]-r[w])*L/u,B),v=c(T.x,T.y,E*1.01);v!==null&&(d[w][L]=Math.min(d[w][L],Math.max(h+Vr,v-Vr)))}}}let y=[i.bandTop[0]*a.top,i.bandTop[1]*a.top,i.bandTop[2]*a.top],b=[i.bandTop[0]*a.bottomCap,i.bandTop[1]*a.bottomCap,i.bandTop[2]*a.bottomCap],p=[i.bandWall[0]*a.top,i.bandWall[1]*a.top,i.bandWall[2]*a.top],g=[i.bandWall[0]*a.wallBottom,i.bandWall[1]*a.wallBottom,i.bandWall[2]*a.wallBottom],R=(E,w)=>{let B=(e.startBin+E+.5)*n.binStepDeg,L=r[E]+(o[E]-r[E])*w/u,T=Bt(n.centre,L,B);return[T.x*f,d[E][w],T.y*f]};{let E=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let B=!1;for(let T=0;T<l;T++)for(let v=u-1;v>=0;v--)d[T][v]>d[T][v+1]&&(d[T][v]=d[T][v+1],B=!0);let L=e.closed?l:l-1;for(let T=0;T<L;T++){let v=(T+1)%l;for(let H=0;H<=u;H++){let j=d[v][H]-d[T][H];if(Math.abs(j)>1)continue;let D=r[T]+(o[T]-r[T])*H/u,U=r[v]+(o[v]-r[v])*H/u,X=Bt(n.centre,D,(e.startBin+T+.5)*n.binStepDeg),Y=Bt(n.centre,U,(e.startBin+v+.5)*n.binStepDeg),nt=E*Math.hypot(Y.x-X.x,Y.y-X.y)*f;j>nt?(d[v][H]=d[T][H]+nt,B=!0):-j>nt&&(d[T][H]=d[v][H]+nt,B=!0)}}if(!B)break}}let A=1,M=(E,w)=>{for(let B=0;B<=u;B+=4)if(Math.abs(d[E][B]-d[w][B])>A)return!0;return Math.abs(d[E][u]-d[w][u])>A},x=Math.tan(38*Math.PI/180),I=E=>(o[E]-r[E])/u*f,S=(E,w)=>d[E][w+1]-d[E][w]>x*Math.max(1e-6,I(E)),_=(E,w)=>{let B=e.closed?(E-1+l)%l:Math.max(0,E-1),L=e.closed?(E+1)%l:Math.min(l-1,E+1);Math.abs(d[B][w]-d[E][w])>A&&(B=E),Math.abs(d[L][w]-d[E][w])>A&&(L=E);let T=Math.max(0,w-1),v=Math.min(u,w+1);T<w&&S(E,T)&&(T=w),v>w&&S(E,w)&&(v=w);let H=R(B,w),j=R(L,w),D=R(E,T),U=R(E,v),X=j[0]-H[0],Y=j[1]-H[1],nt=j[2]-H[2],rt=U[0]-D[0],q=U[1]-D[1],Q=U[2]-D[2],J=Y*Q-nt*q,N=nt*rt-X*Q,G=X*q-Y*rt,W=Math.hypot(J,N,G);return W>1e-12?(J/=W,N/=W,G/=W,N<0&&(J=-J,N=-N,G=-G),[J,N,G]):[0,1,0]},O=(E,w,B=!1)=>{let L=B&&Math.min(E[1],w[1])-s>=3,T=[E[0],L?E[1]-Rn:h,E[2]],v=[w[0],L?w[1]-Rn:h,w[2]],H=w[0]-E[0],j=w[2]-E[2],D=Math.hypot(H,j);if(!(D>1e-12))return;let U=[j/D,0,-H/D];t.tri(E,w,v,U,p,p,g),t.tri(E,v,T,U,p,g,g)},C=.05*Rt,F=E=>o[E]-r[E]<C,k=e.closed?l:l-1;for(let E=0;E<k;E++){let w=(E+1)%l;if(F(E)||F(w))continue;if(M(E,w)){let j=(e.startBin+E+1)*n.binStepDeg,D=(q,Q)=>{let J=(r[E]+r[w])/2,N=(o[E]+o[w])/2,G=J+(N-J)*Q/u,W=Bt(n.centre,G,j);return[W.x*f,d[q][Q],W.y*f]};for(let q=0;q<u;q++){let Q=R(E,q),J=R(E,q+1),N=D(E,q),G=D(E,q+1),W=_(E,q),lt=_(E,q+1);t.triN(Q,N,G,W,W,lt,y),t.triN(Q,G,J,W,lt,lt,y);let ft=R(w,q),st=R(w,q+1),tt=D(w,q),et=D(w,q+1),ht=_(w,q),z=_(w,q+1);t.triN(tt,ft,st,ht,ht,z,y),t.triN(tt,st,et,ht,z,z,y);let mt=D(E,q),yt=D(E,q+1),Dt=D(w,q+1),Ht=D(w,q),kt=yt[0]-mt[0],Ft=yt[2]-mt[2],sn=Math.hypot(kt,Ft);if(sn>1e-12){let Pn=[Ft/sn,0,-kt/sn];t.tri(mt,yt,Dt,Pn,p),t.tri(mt,Dt,Ht,Pn,p)}}let U=R(E,0),X=R(w,0),Y=R(w,u),nt=R(E,u),rt=q=>[q[0],h,q[2]];Math.min(U[1],X[1])-s<3&&(t.tri(rt(U),rt(Y),rt(X),[0,-1,0],b),t.tri(rt(U),rt(nt),rt(Y),[0,-1,0],b)),O(U,X,!0),O(nt,Y,!0);continue}for(let j=0;j<u;j++){let D=_(E,j),U=_(w,j),X=_(w,j+1),Y=_(E,j+1);if(S(E,j)||S(w,j)){let J=(yt,Dt)=>{let Ht=(e.startBin+yt+.5)*n.binStepDeg,kt=r[yt]+(o[yt]-r[yt])*(j+.5)/u,Ft=Bt(n.centre,kt,Ht);return[Ft.x*f,Dt,Ft.y*f]},N=R(E,j),G=R(w,j),W=J(E,d[E][j]),lt=J(w,d[w][j]);t.triN(N,G,lt,D,U,U,y),t.triN(N,lt,W,D,U,D,y);let ft=R(w,j+1),st=R(E,j+1),tt=J(E,d[E][j+1]),et=J(w,d[w][j+1]);t.triN(tt,et,ft,Y,X,X,y),t.triN(tt,ft,st,Y,X,Y,y);let ht=lt[0]-W[0],z=lt[2]-W[2],mt=Math.hypot(ht,z);if(mt>1e-12){let yt=[-z/mt,0,ht/mt];t.tri(W,lt,et,yt,p),t.tri(W,et,tt,yt,p)}continue}let nt=R(E,j),rt=R(w,j),q=R(w,j+1),Q=R(E,j+1);t.triN(nt,rt,q,D,U,X,y),t.triN(nt,q,Q,D,X,Y,y)}let B=R(E,0),L=R(w,0),T=R(w,u),v=R(E,u),H=j=>[j[0],h,j[2]];Math.min(B[1],L[1])-s<3&&(t.tri(H(B),H(T),H(L),[0,-1,0],b),t.tri(H(B),H(v),H(T),[0,-1,0],b)),O(B,L,!0),O(v,T,!0)}if(!e.closed)for(let E of[0,l-1])for(let w=0;w<u;w++)O(R(E,w),R(E,w+1))}function Zr(t,n,e){let{bottomY:r,colors:o,ao:s}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let u of n.rings)for(let f of u.arcs){let m=new Float64Array(f.binCount),h=new Float64Array(f.binCount);for(let y=0;y<f.binCount;y++){let b=(f.startBin+y)%n.binCount,p=Math.max(0,f.innerR[y]-St);m[y]=Math.max(p,i[b]+.001),h[y]=Math.max(m[y]+.001,f.outerR[y]+St)}let d=0;for(let y=0;y<f.binCount;y++){let b=f.topLevelM[y]-r;b>d&&(d=b)}d>=Kc&&nl(t,n,f,m,h,r,o,s,e.standTopNear);for(let y=0;y<f.binCount;y++){let b=(f.startBin+y)%n.binCount;h[y]>i[b]&&(i[b]=h[y])}}if(e.deriveShell===!1||Qc(e.shapes,n))return;let a=n.rings[n.rings.length-1],c=Vc*Rt,l=Zc*Rt;for(let u of a.arcs){let f=[],m=[];for(let _=0;_<u.binCount;_++){let O=(u.startBin+_+.5)*n.binStepDeg,C=u.outerR[_]+St+c;f.push(Bt(n.centre,C,O)),m.push(Bt(n.centre,C+l,O))}let h=-1/0;for(let _=0;_<u.binCount;_++)u.topLevelM[_]>h&&(h=u.topLevelM[_]);let d=h+qc,y=u.closed?m:[...m,...f.slice().reverse()],b=u.closed?[f.slice().reverse()]:void 0,p=at(o.shellWall,[.66,.71,.72],.62),g=(_,O,C,F,k)=>{let E=Math.abs(F-h)<1e-6?F-Yc:F;Ot(t,_,C,E,e.shapes,o.shellTop,k,{holes:O,portalBase:r,ao:s})||Z(t,_,O,()=>E,C,o.shellTop,k,s)},R=Math.max(1,Math.ceil((h-r)/4.5)),A=(h-r)/R,M=new Set,x=e.tierFrontLevels??n.rings.map(_=>{let O=_.arcs.flatMap(C=>Array.from(C.frontLevelM)).filter(Number.isFinite).sort((C,F)=>C-F);return O[Math.floor(O.length/2)]});for(let _ of x)Number.isFinite(_)&&_-r>=3&&_<h&&M.add(Math.max(0,Math.min(R-1,Math.floor((_-r)/A))));let I=Math.min(...x.filter(_=>Number.isFinite(_)&&_-r>=3&&_<h));for(let _=0;_<R;_++)r+(_+1)*A<=I-Rn&&Number.isFinite(I)&&M.add(_);for(let _=0;_<R;_++){let O=r+(h-r)*_/R,C=r+(h-r)*(_+1)/R;M.has(_)&&C-O>=3.2?(g(y,b,O,O+.45,p),Fe(t,f,m,u.closed,O+.45,C-.16,o.shellTop,p,s,e.shapes,r)):g(y,b,O,C-.16,p),g(y,b,C-.16,C,V(p,.62))}Fe(t,f,m,u.closed,h,d,o.shellTop,p,s,e.shapes,r);let S=8;for(let _=1;_<m.length;_++){if(S+=Math.hypot(m[_].x-m[_-1].x,m[_].y-m[_-1].y)*$,S<8)continue;S=0;let O=m[_],C=m[_-1],F=O.x-C.x,k=O.y-C.y,E=Math.max(1,Math.hypot(F,k)),w=F/E*.16*Rt,B=k/E*.16*Rt,L=Math.max(1,Math.hypot(O.x-n.centre.x,O.y-n.centre.y)),T=(O.x-n.centre.x)/L*.24*Rt,v=(O.y-n.centre.y)/L*.24*Rt,H=[{x:O.x-w,y:O.y-B},{x:O.x+w,y:O.y+B},{x:O.x+w+T,y:O.y+B+v},{x:O.x-w+T,y:O.y-B+v}];g(H,void 0,r,h,V(p,1.12))}}}var el=2.5,qr=.65,ol=2,rl=.03;function il(t,n){let e=()=>{let r=n;for(;t.length>2;){let o=t[0],s=t[1],i=Math.hypot(s.x-o.x,s.y-o.y);if(i>r){t[0]={x:o.x+(s.x-o.x)/i*r,y:o.y+(s.y-o.y)/i*r};return}r-=i,t.shift()}};e(),t.reverse(),e(),t.reverse()}function He(t,n,e){let r=new Map;for(let s of t){let i=r.get(s.blockId);(!i||s.depth<i.depth)&&r.set(s.blockId,s)}let o=[];for(let[s,i]of r){if(i.y-e<el||i.pts.length<2)continue;let a=i.pts.map(u=>{let f=u.x-n.x,m=u.y-n.y,h=Math.max(1,Math.hypot(f,m));return{x:u.x-f/h*qr/P,y:u.y-m/h*qr/P}}),c=[],l=[a[0]];for(let u=1;u<a.length;u++){let f=a[u-1],m=a[u];Math.hypot(m.x-f.x,m.y-f.y)*P>ol?(l.length>=2&&c.push(l),l=[m]):l.push(m)}l.length>=2&&c.push(l);for(let u of c)il(u,rl/P);c.length&&o.push({blockId:s,y:i.y,runs:c})}return o}var $r=.1,sl=1.1,al=.22,Ge=.95,De=.05,Qr=1.8;function Jr(t,n,e,r){let o=[.72,.72,.69],s=[.48,.55,.57];for(let i of He(n,e,r)){let a=i.y;for(let c of i.runs){let l=Qr;for(let u=1;u<c.length;u++){let f=c[u-1],m=c[u],h=m.x-f.x,d=m.y-f.y,y=Math.hypot(h,d);if(y<1e-5)continue;let b=p=>{let g=-d/y*p/P/2,R=h/y*p/P/2;return[{x:f.x+g,y:f.y+R},{x:m.x+g,y:m.y+R},{x:m.x-g,y:m.y-R},{x:f.x-g,y:f.y-R}]};if(Z(t,b(al),void 0,()=>a+$r,a-sl,o,o,K),Z(t,b(De),void 0,()=>a+Ge,a+Ge-De,s,s,K),l+=y*P,l>=Qr||u===c.length-1){l=0;let p=.028/P,g=[{x:f.x-p,y:f.y-p},{x:f.x+p,y:f.y-p},{x:f.x+p,y:f.y+p},{x:f.x-p,y:f.y+p}];Z(t,g,void 0,()=>a+Ge-De,a+$r,s,s,K)}}}}}var cl=.9,ll=1.5,ul=.3;function ti(t,n,e){let r=[],o=[],s=cl/P,i=ll/P,a=ul/P;for(let c of t)for(let l of c.runs){if(l.length<2)continue;let u=l.slice(),f=(b,p)=>{let g=u[b],R=u[p],A=Math.hypot(g.x-R.x,g.y-R.y)||1;u[b]={x:g.x+(g.x-R.x)/A*a,y:g.y+(g.y-R.y)/A*a}};f(0,1),f(u.length-1,u.length-2);let m=u.map((b,p)=>{let g=u[Math.max(0,p-1)],R=u[Math.min(u.length-1,p+1)],A=R.x-g.x,M=R.y-g.y,x=Math.hypot(A,M)||1,I=-M/x,S=A/x;return I*(b.x-n.x)+S*(b.y-n.y)<0&&(I=-I,S=-S),{nx:I,ny:S}}),h=u.map((b,p)=>({x:b.x-m[p].nx*i,y:b.y-m[p].ny*i})),d=u.map((b,p)=>({x:b.x+m[p].nx*s,y:b.y+m[p].ny*s})),y=u.map((b,p)=>({x:b.x+m[p].nx*(s+e/P),y:b.y+m[p].ny*(s+e/P)}));r.push([...h,...d.slice().reverse()]),o.push([...d,...y.reverse()])}return{bays:r,walls:o}}var Xe=.88,te=.27,fl=1.2,ml=.01;function ni(t,n,e,r,o){let s=[.67,.71,.68],i=[s[0]*Xe,s[1]*Xe,s[2]*Xe],a=c=>!!o&&o.some((l,u)=>u!==c&&l?.belowY!=null&&Math.abs(l.belowY-n[c].y)<1e-6&&n[u].blockId===n[c].blockId);for(let c=0;c<n.length;c++){let l=n[c];if(!(l.pts.length<2))for(let u of[0,l.pts.length-1]){let f=l.pts[u],m=l.pts[u===0?1:u-1],h=f.x-m.x,d=f.y-m.y,y=Math.hypot(h,d);if(y<1e-5)continue;h/=y,d/=y;let b=1/0;for(let w=0;w<e.length;w++){let B=e[w],L=e[(w+1)%e.length],T=L.x-B.x,v=L.y-B.y,H=h*v-d*T;if(Math.abs(H)<1e-8)continue;let j=B.x-f.x,D=B.y-f.y,U=(j*v-D*T)/H,X=(j*d-D*h)/H;U>0&&X>=0&&X<=1&&(b=Math.min(b,U))}let p=.3/P,g=b-.04/P;if(!Number.isFinite(b)||b*P>2||g-p<.12/P)continue;let R=!!r&&a(c),A=o?.[c]?.pitch,M=R&&A&&Number.isFinite(A)?Math.min(fl/P,Math.max(te/P,A-te/P-ml/P)):te/P,x=-d,I=h;r&&x*(r.x-f.x)+I*(r.y-f.y)<0&&(x=-x,I=-I);let S=te/P,_=[{x:f.x+h*p+x*S,y:f.y+d*p+I*S},{x:f.x+h*g+x*S,y:f.y+d*g+I*S},{x:f.x+h*g-x*M,y:f.y+d*g-I*M},{x:f.x+h*p-x*M,y:f.y+d*p-I*M}];if(!_.every(w=>xt(e,w.x,w.y)))continue;let O=o?.[c]?.belowY,C=O==null?0:l.y-O,F=!!r&&C>.03&&C<=.65;if(F&&r){let w=(B,L)=>Math.hypot((B.x+L.x)/2-r.x,(B.y+L.y)/2-r.y);w(_[0],_[1])>w(_[3],_[2])&&(_=[_[3],_[2],_[1],_[0]])}let k=F?Math.ceil((C-1e-8)/.2):1,E=(w,B,L)=>({x:w.x+(B.x-w.x)*L,y:w.y+(B.y-w.y)*L});for(let w=0;w<k;w++){let B=w/k,L=(w+1)/k,T=[E(_[0],_[3],B),E(_[1],_[2],B),E(_[1],_[2],L),E(_[0],_[3],L)],v=l.y+.008-(F?C*(1-L):0);Z(t,T,void 0,()=>v,v-(F?C/k+.1:.16),s,i,K)}}}}var hl=.02,yl=.012,dl=.01,pl=.3,xl=.5;function bl(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let s=t[o],i=t[o+1],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l>1e-12?((n-s.x)*a+(e-s.y)*c)/l:0;u=Math.max(0,Math.min(1,u)),r=Math.min(r,Math.hypot(n-(s.x+u*a),e-(s.y+u*c)))}return r}function gl(t,n,e,r){let o=1/0,s=Number.NaN;for(let i=0;i<t.length;i++){let a=n[i];if(Math.hypot(e-a.cx,r-a.cy)-a.rad>=o)continue;let c=bl(t[i].pts,e,r);c<o&&(o=c,s=t[i].y)}return s}function ei(t,n,e,r,o,s,i){let a=r.filter(m=>m.pts.length>0);if(a.length<2||n.length<3)return;let c=a.map(m=>{let h=0,d=0;for(let b of m.pts)h+=b.x,d+=b.y;h/=m.pts.length,d/=m.pts.length;let y=0;for(let b of m.pts)y=Math.max(y,Math.hypot(b.x-h,b.y-d));return{cx:h,cy:d,rad:y}}),l=[...n],u=e.map(m=>[...m]),f=hl/P;for(let m of[l,...u])for(let h=0;h<m.length;h++){let d=m[h],y=m[(h+1)%m.length],b=y.x-d.x,p=y.y-d.y,g=Math.hypot(b,p);if(g*P<.05)continue;let R=(d.x+y.x)/2,A=(d.y+y.y)/2,M=p/g,x=-b/g;Pt({x:R+M*f,y:A+x*f},l,u)&&(M=-M,x=-x);let I=o.x-R,S=o.y-A,_=Math.hypot(I,S)||1;if((M*I+x*S)/_>xl)continue;let O=1/0;for(let T of[.2,.5,.8]){let v=gl(a,c,d.x+b*T-M*f*2,d.y+p*T-x*f*2);Number.isFinite(v)&&(O=Math.min(O,v))}if(!Number.isFinite(O)||O-s<pl)continue;let C=s-dl,F=O-yl,k={x:(d.x-M*f)*P,z:(d.y-x*f)*P},E={x:(y.x-M*f)*P,z:(y.y-x*f)*P},w=[M,0,x],B=V(i,K.wallBottom),L=V(i,K.top);t.tri([k.x,F,k.z],[E.x,F,E.z],[E.x,C,E.z],w,L,L,B),t.tri([k.x,F,k.z],[E.x,C,E.z],[k.x,C,k.z],w,L,B,B)}}function oi(t,n,e,r,o,s,i,a,c=!1){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,u=e.objects.filter(g=>g.type==="shape"&&(g.role==="entrance"||g.role==="exit")),f=Io(r,a.tierTop);if(!o)return;let m=g=>o.deckAt(g.x,g.y),h=Xo(n,i),d=h[0]??n.outline;if(o.rowLevels.length>=2){let g=Dn(o.rowLevels),R=jo(Lo(o.rowLevels,e.focal,g),h),A=ti(He(o.rowLevels,e.focal,l),e.focal,Ne);for(let x of R){let I=Math.max(l,x.topY-ri);for(let S of s.subtract(x.outline,I))Kr(t,S,x.holes,I,l,a.tierTop,a.tierWall,u,!c,A);t.setMaterial(5),ei(t,x.outline,x.holes,o.rowLevels,e.focal,I,a.tierWall),t.setMaterial(0)}R.length||Z(t,d,n.holes,()=>o.landingY,l,f,a.tierWall,K);let M={tread:[f[0]*K.top,f[1]*K.top,f[2]*K.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let x of h.length?h:[d])No(t,o.rowLevels,e.focal,o.landingY,M,x,g);Jr(t,o.rowLevels,e.focal,l),ni(t,o.rowLevels,n.outline,e.focal,g);return}let y=o.flat?1/0:ar,b=g=>o.normalAt(g.x,g.y),p=o.flat?o.landingY:void 0;for(let g of s.subtract(d,p))Z(t,g,n.holes,m,l,f,a.tierWall,K,y,b)}function Ml(t,n,e){let r=new Set;for(let i of t.objects)i.type==="section"&&r.add(i.id);let o=new Map;for(let i=0;i<n.length;i++){let a=e.seatOwner[i];if(!a||!r.has(a))continue;let c=e.bySection.get(a);if(c&&c.rowLevels.length>=2)continue;let l=n[i];if(l.kind==="booth")continue;let u=o.get(a);u||(u=new Map,o.set(a,u));let f=l.rowId||`__seat-${i}`,m=u.get(f);m||(m={pts:[],levelM:0,n:0},u.set(f,m)),m.pts.push({x:l.x,y:l.y}),m.levelM+=e.seatDeckY(i),m.n++}let s=[];for(let i of t.objects){if(i.type!=="section")continue;let a=e.bySection.get(i.id);if(a&&a.rowLevels.length>=2){let l=a.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));l.length>=2&&s.push({sectionId:i.id,rows:l});continue}let c=o.get(i.id);c&&s.push({sectionId:i.id,rows:[...c.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return s}function Rl(t,n){let e=1/0;for(let r=0;r<n.length;r++){let o=n[r],s=n[(r+1)%n.length],i=s.x-o.x,a=s.y-o.y,c=Math.max(0,Math.min(1,((t.x-o.x)*i+(t.y-o.y)*a)/(i*i+a*a||1)));e=Math.min(e,Math.hypot(t.x-o.x-c*i,t.y-o.y-c*a))}return e}var ri=.02;function Pl(t,n){let e=t.objects.filter(r=>r.type==="section"&&!!r.outline&&r.outline.length>=3).flatMap(r=>{let o=n.bySection.get(r.id);if(!o)return[];let s=1/0,i=-1/0,a=1/0,c=-1/0;for(let u of r.outline)u.x<s&&(s=u.x),u.x>i&&(i=u.x),u.y<a&&(a=u.y),u.y>c&&(c=u.y);let l=o.landingY;for(let u of o.rowLevels)l=Math.min(l,u.y-ri);return[{outline:r.outline,holes:r.holes,surface:o,floorTop:l,minX:s,maxX:i,minY:a,maxY:c}]});return(r,o,s)=>{let i=null;for(let a of e){if(r<a.minX-s||r>a.maxX+s||o<a.minY-s||o>a.maxY+s)continue;let c={x:r,y:o};if(!Pt(c,a.outline,a.holes)&&Rl(c,a.outline)>s)continue;let l=Math.min(a.surface.deckAt(r,o),a.floorTop);(i===null||l<i)&&(i=l)}return i}}var Sl=3,Il=.4;function ii(t,n,e,r,o,s,i=!0){let a=Ml(n,e,r);if(a.length<Sl)return;let c=lo(a,n.focal);if(!c)return;let l=Math.max(0,...c.rings.map(u=>u.arcs.reduce((f,m)=>f+m.binCount,0)))/c.binCount;t.setMaterial(5),Zr(t,c,{bottomY:n.baseHeightM,tierFrontLevels:a.map(u=>Math.min(...u.rows.map(f=>f.levelM))),colors:{bandTop:V(o.tierTop,.8),bandWall:o.tierWall,shellTop:s??V(o.tierWall,1.15),shellWall:s??o.tierWall},ao:K,shapes:n.objects.filter(u=>u.type==="shape"),deriveShell:i&&l>=Il,standTopNear:Pl(n,r)}),t.setMaterial(0)}function si(t){let{doc:n,units:e,seats:r,surfaces:o,solids:s,hintedSeatFloor:i,seatFloor:a}=t,c=[];{let l=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<s.floor.length;m+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(s.floor[m]))),d=m*3,y=l[h];y.minX=Math.min(y.minX,s.position[d]),y.minY=Math.min(y.minY,s.position[d+1]),y.minZ=Math.min(y.minZ,s.position[d+2]),y.maxX=Math.max(y.maxX,s.position[d]),y.maxY=Math.max(y.maxY,s.position[d+1]),y.maxZ=Math.max(y.maxZ,s.position[d+2])}let u=new Map;for(let m=0;m<e.length;m++)for(let h of e[m].objects)h.type==="section"&&u.set(h.id,m);let f=e.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let m=0;m<r.length;m++){let h=o.seatOwner[m],d=(h!==null?u.get(h):void 0)??i[m];if(d===void 0)continue;let y=f[d],b=r[m];y.n++,b.x<y.minX&&(y.minX=b.x),b.y<y.minY&&(y.minY=b.y),b.x>y.maxX&&(y.maxX=b.x),b.y>y.maxY&&(y.maxY=b.y);let p=o.seatDeckY(m);y.sumX+=b.x*P,y.sumDeck+=p,y.sumZ+=b.y*P,y.minDeck=Math.min(y.minDeck,p),y.maxDeck=Math.max(y.maxDeck,p+1.6),a[m]=d}for(let m=0;m<e.length;m++){let h=f[m],d=n.floors?.[m],y=l[m],b=Math.min(h.n?h.minX*P:e[m].focal.x*P-1,Number.isFinite(y.minX)?y.minX:1/0),p=Math.max(h.n?h.maxX*P:e[m].focal.x*P+1,Number.isFinite(y.maxX)?y.maxX:-1/0),g=Math.min(h.n?h.minY*P:e[m].focal.y*P-1,Number.isFinite(y.minZ)?y.minZ:1/0),R=Math.max(h.n?h.maxY*P:e[m].focal.y*P+1,Number.isFinite(y.maxZ)?y.maxZ:-1/0),A=Math.min(h.n?Math.min(e[m].baseHeightM,h.minDeck):e[m].baseHeightM,Number.isFinite(y.minY)?y.minY:1/0),M=Math.max(h.n?Math.max(h.maxDeck,A+.5):A+.5,Number.isFinite(y.maxY)?y.maxY:-1/0),x=[h.n?h.sumX/h.n:(b+p)/2,h.n?h.sumDeck/h.n:(A+M)/2,h.n?h.sumZ/h.n:(g+R)/2],I=Math.max(1,.5*Math.hypot(p-b,M-A,R-g));c.push({index:m,id:d?.id??`floor-${m}`,label:d?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:x,radius:I,box:{min:[b,A,g],max:[p,M,R]},focalWorld:[e[m].focal.x*P,e[m].baseHeightM+1.5,e[m].focal.y*P]})}}return c}function je(t,n){let e=1/0,r=1/0,o=-1/0,s=-1/0,i=(a,c)=>{a<e&&(e=a),c<r&&(r=c),a>o&&(o=a),c>s&&(s=c)};for(let a of n)i(a.x,a.y);for(let a of t)for(let c of a.objects)if(c.type==="section")for(let l of c.outline)i(l.x,l.y);else if(c.type==="shape"&&c.points)for(let l of c.points)i(l.x,l.y);else if(c.type==="gaArea")for(let l of c.points)i(l.x,l.y);else if(c.type==="booth"){let l=At(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="table"){let l=$n(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="decorImage"){let l=Qn(c);if(l)for(let u of l)i(u.x,u.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,s=100),{minX:e,minY:r,maxX:o,maxY:s}}function mi(t,n,e,r,o,s,i){if(n.length===1){let a=e.map(m=>({x:m.x,y:m.y}));for(let m of n[0].objects)m.type==="section"?a.push(...m.outline):m.type==="shape"?a.push(...ct(m)??m.points??[]):m.type==="gaArea"?a.push(...m.points):m.type==="booth"?a.push(...At(m)??[]):m.type==="table"?a.push(...$n(m)??[]):m.type==="decorImage"&&a.push(...Qn(m)??[]);if(li(t,n[0],e,s)||fi(t,n[0],e,a,s))return!1;if(i&&ci(t,n[0].baseHeightM,a,s,i))return!0;let c=hn(a),l=(o.minX+o.maxX)/2,u=(o.minY+o.maxY)/2,f=c.length>=3?c.map(m=>{let h=m.x-l,d=m.y-u,y=Math.max(1,Math.hypot(h,d));return{x:m.x+h/y*80,y:m.y+d/y*80}}):fn(o.minX-28,o.minY-28,o.maxX-o.minX+56,o.maxY-o.minY+56);return Z(t,f,void 0,()=>-.04,-.22,s.ground,s.ground,K),!1}else{let a=n.reduce((b,p)=>p.baseHeightM<b.baseHeightM?p:b);t.setFloor(a.index);let c={...a,objects:n.flatMap(b=>b.objects)},l=e.map(b=>({x:b.x,y:b.y}));for(let b of c.objects)b.type==="section"&&l.push(...b.outline);if(li(t,c,e,s)||fi(t,c,e,l,s))return!1;if(i&&ci(t,a.baseHeightM,l,s,i))return!0;let u=e.filter((b,p)=>r[p]===a.index),f=je([a],u),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),h=Math.max(28,Math.min(80,m*.04)),d=fn(f.minX-h,f.minY-h,f.maxX-f.minX+h*2,f.maxY-f.minY+h*2),y=a.baseHeightM-.03;return Z(t,d,void 0,()=>y,y-.22,s.ground,s.ground,K),!1}}function Ue(t,n,e,r){let{cx:o,cz:s,radius:i}=e,a=1/0,c=1/0,l=1/0,u=-1/0,f=-1/0,m=-1/0,h=(b,p,g)=>{a=Math.min(a,b),u=Math.max(u,b),c=Math.min(c,p),f=Math.max(f,p),l=Math.min(l,g),m=Math.max(m,g)};for(let b=0;b<t.position.length;b+=3){let p=b/3;r&&p>=r[0]&&p<r[1]||h(t.position[b],t.position[b+1],t.position[b+2])}for(let b=0;b<n.count;b++){let p=b*3,g=n.iPosition[p],R=n.iPosition[p+1],A=n.iPosition[p+2],M=Math.max(.35,n.iMaxRadius[b]??.35);h(g-M,R,A-M),h(g+M,R+1.6,A+M)}Number.isFinite(a)||(a=o-i,u=o+i,c=0,f=i*.16,l=s-i,m=s+i);let d=[(a+u)/2,(c+f)/2,(l+m)/2],y=Math.max(1,.5*Math.hypot(u-a,f-c,m-l));return{center:d,radius:y,minY:c,maxY:f}}var _l=4096;function hi(t,n,e=[]){let r=Math.max(1,Math.ceil(t.count/_l)),o=Math.ceil(t.count/r),s=new Float32Array((o*2+n.length*4+e.length)*3),i=0;for(let a=0;a<t.count;a+=r){let c=t.iPosition[a*3],l=t.iPosition[a*3+1],u=t.iPosition[a*3+2];s[i++]=c,s[i++]=l,s[i++]=u,s[i++]=c,s[i++]=0,s[i++]=u}for(let[a,c,l]of e)s[i++]=a,s[i++]=c,s[i++]=l;for(let a of n)for(let[c,l]of[[-1,-1],[1,-1],[1,1],[-1,1]])s[i++]=a.cx+c*a.halfX,s[i++]=a.y,s[i++]=a.cz+l*a.halfZ;return s.subarray(0,i)}function yi(t,n,e,r,o,s,i=[]){let a=1/0,c=1/0,l=-1/0,u=-1/0;for(let M=0;M<t.count;M++){let x=M*3,I=t.iPosition[x],S=t.iPosition[x+2];I<a&&(a=I),I>l&&(l=I),S<c&&(c=S),S>u&&(u=S)}for(let[M,,x]of i)M<a&&(a=M),M>l&&(l=M),x<c&&(c=x),x>u&&(u=x);for(let M of n)a=Math.min(a,M.cx-M.halfX),l=Math.max(l,M.cx+M.halfX),c=Math.min(c,M.cz-M.halfZ),u=Math.max(u,M.cz+M.halfZ);let f=e.minX*P,m=e.maxX*P,h=e.minY*P,d=e.maxY*P,y=f,b=m,p=h,g=d;if(Number.isFinite(a)){let M=Math.max(2,.06*Math.hypot(l-a,u-c));y=Math.max(f,a-M),b=Math.min(m,l+M),p=Math.max(h,c-M),g=Math.min(d,u+M)}let R=Math.min(0,r),A=Math.max(o,s*.05);return{min:[y,R,p],max:[b,A,g]}}var ai=12,Al=.6,El=40;function ci(t,n,e,r,o){let s=hn([...e]);if(s.length<3)return!1;let i=1/0,a=1/0,c=-1/0,l=-1/0;for(let A of s)i=Math.min(i,A.x),c=Math.max(c,A.x),a=Math.min(a,A.y),l=Math.max(l,A.y);let u=Math.hypot(c-i,l-a)*P,f=It(s,ai/P,1.2),m=Math.max(El,u*Al),h=It(s,(ai+m)/P,1.2);if(f.length!==h.length)return!1;let d=at(r.ground,[.78,.76,.72],.35),y=at(r.ground,[.56,.62,.52],.3);Z(t,f,void 0,()=>n-.04,n-.22,d,d,K);let b=n-.05,p=f.map(A=>[A.x*P,b,A.y*P]),g=h.map(A=>[A.x*P,b,A.y*P]),R=[0,1,0];for(let A=0;A<p.length;A++){let M=(A+1)%p.length;t.tri(p[A],g[M],g[A],R,y,o,o),t.tri(p[A],p[M],g[M],R,y,y,o)}return!0}function li(t,n,e,r){let o=Nt(n,e);if(!o)return!1;let s=n.baseHeightM,i=at(r.ground,[.62,.55,.47],.4);return Z(t,o,void 0,()=>s-.04,s-.22,i,i,K),!0}var wl=3e3,Bl=20,ui=1.5,Tl=1.2,Ol=.25;function fi(t,n,e,r,o){if(!e.length||e.length>wl||r.length<3)return!1;for(let _ of n.objects){if(_.type==="shape"&&An(_.stageKind))return!1;if(_.type==="section"){let{height:O}=Vt(_,{floorBaseHeightM:n.baseHeightM});if(O-n.baseHeightM>Bl)return!1}}let s=0,i=0;for(let _ of r)s+=_.x,i+=_.y;s/=r.length,i/=r.length;let a=0,c=0,l=0;for(let _ of r){let O=_.x-s,C=_.y-i;a+=O*O,c+=C*C,l+=O*C}let u=.5*Math.atan2(2*l,a-c),f=Math.cos(u),m=Math.sin(u),h=-m,d=f,y=1/0,b=-1/0,p=1/0,g=-1/0;for(let _ of r){let O=(_.x-s)*f+(_.y-i)*m,C=(_.x-s)*h+(_.y-i)*d;y=Math.min(y,O),b=Math.max(b,O),p=Math.min(p,C),g=Math.max(g,C)}let R=_=>[[y-_,p-_],[b+_,p-_],[b+_,g+_],[y-_,g+_]].map(([O,C])=>({x:s+f*O+h*C,y:i+m*O+d*C})),A=R(ui/P),M=R((ui+Ol)/P),x=n.baseHeightM,I=at(o.ground,[.62,.55,.47],.4),S=at(o.ground,[.86,.86,.84],.55);return Z(t,M,void 0,()=>x-.04,x-.22,I,I,K),Z(t,M,[A.slice().reverse()],()=>x+Tl,x-.04,at(S,[1,1,1],.2),S,K),!0}function di(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=We(n);if(!o.ok||o.value.id!==t)return r();let s=new Map;for(let f of e)for(let m of f.objects)m.type==="shape"&&s.set(m.id,{shape:m,unit:f});let i=new Set,a=new Set,c=new Map((n.overlay.productionElements??[]).map(f=>{let m=f.runtimeContentImageUrl;return[f.id,typeof m=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(m)?m:void 0]})),l=[];for(let f of o.value.overlay.productionElements??[]){let m=s.get(f.objectId),h=m?ct(m.shape):null,d=f.baseElevationM??0;if(!m||!h||h.length<3||!f.id||i.has(f.id)||a.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(d)||d<-10||d>100)return r();i.add(f.id),a.add(f.objectId);let y=h.map(S=>S.x*P),b=h.map(S=>S.y*P),p=m.unit.baseHeightM+d,g=Math.min(...y),R=Math.max(...y),A=Math.min(...b),M=Math.max(...b),x,I=c.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&I&&(x=or(h,p,p+f.heightM,m.unit.focal),!x))if(R-g>=M-A){let S=Math.abs(A-m.unit.focal.y*P)<=Math.abs(M-m.unit.focal.y*P)?A-.006:M+.006;x=[[g,p,S],[R,p,S],[g,p+f.heightM,S],[R,p+f.heightM,S]]}else{let S=Math.abs(g-m.unit.focal.x*P)<=Math.abs(R-m.unit.focal.x*P)?g-.006:R+.006;x=[[S,p,A],[S,p,M],[S,p+f.heightM,A],[S,p+f.heightM,M]]}l.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:p,topY:p+f.heightM,bounds:{min:[g,p,A],max:[R,p+f.heightM,M]},occlusion:f.occlusion,...I?{contentImageUrl:I}:{},...x?{contentPlane:x}:{}})}let u=l.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(u.map(f=>[f.objectId,f])),elements:u}}var pi=[.13,.14,.17],rn=[.4,.43,.47],Cl=.18,kl=.02,Fl=2.4,Ll=1500,vl=240,Nl=.25;function xi(t,n,e,r){let o=n.stageKind??"";if(Zt(o)||o==="round"||!r.length)return;let s=ct(n);if(!s||s.length<3)return;let i={x:s.reduce((B,L)=>B+L.x,0)/s.length,y:s.reduce((B,L)=>B+L.y,0)/s.length},a=0,c=0,l=new Set;for(let B of r)a+=B.x,c+=B.y,l.add(Math.floor(Math.atan2(B.y-i.y,B.x-i.x)*180/Math.PI/10));let u=i.x-a/r.length,f=i.y-c/r.length,m=Math.hypot(u,f);if(m<1e-6)return;let h=r.reduce((B,L)=>B+Math.hypot(L.x-i.x,L.y-i.y),0)/r.length;if(l.size*10>vl&&m<Nl*h)return;let d=u/m,y=f/m,b=-y,p=d,g=-1/0,R=1/0,A=1/0,M=-1/0;for(let B of s){let L=(B.x-i.x)*d+(B.y-i.y)*y,T=(B.x-i.x)*b+(B.y-i.y)*p;g=Math.max(g,L),R=Math.min(R,L),A=Math.min(A,T),M=Math.max(M,T)}let x=(M-A)*P,I=(g-R)*P;if(x<3||I<1.5||x*I>Ll)return;let S=Cl/P,_=(B,L)=>({x:i.x+d*B+b*L,y:i.y+y*B+p*L}),O=(B,L,T,v)=>[_(B,T),_(B,v),_(L,v),_(L,T)],C=e+Math.max(3.5,Math.min(8,x*.35)),F=e+Math.min(Fl,C-e-1),k=.2/P,E=R+Math.min(I*.25,1.5)/P,w=kl/P;Z(t,O(g-2*S+w,g-S-w,A+S+k,M-S-k),void 0,()=>F,e,pi,pi,K);for(let[B,L]of[[A+S,A+S+k],[M-S-k,M-S]])Z(t,O(g-2*S,g-S,B,L),void 0,()=>C+.3,e,rn,rn,K),Z(t,O(E+k,g-2*S,B,L),void 0,()=>C+.3,C,rn,rn,K);Z(t,O(E,E+k,A+S,M-S),void 0,()=>C+.3,C,rn,rn,K)}function Mt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function gt(t){return Array.isArray(t)?t:[]}function Gl(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Mt(e))continue;let r=Mt(e.extensions)?e.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function ne(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Dl(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Hl(t,n){let e=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let s=0;s<4;s++)e[r*4+o]+=t[s*4+o]*n[r*4+s];return e}function Xl(t){let n=ne(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:ne(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:ne(t.rotation,4),o=t.scale===void 0?[1,1,1]:ne(t.scale,3);if(!e||!r||!o)return null;let[s,i,a,c]=r,l=Math.hypot(s,i,a,c);if(!(l>1e-8))return null;let u=s/l,f=i/l,m=a/l,h=c/l,d=u+u,y=f+f,b=m+m,p=u*d,g=u*y,R=u*b,A=f*y,M=f*b,x=m*b,I=h*d,S=h*y,_=h*b;return[(1-(A+x))*o[0],(g+_)*o[0],(R-S)*o[0],0,(g-_)*o[1],(1-(p+x))*o[1],(M+I)*o[1],0,(R+S)*o[2],(M-I)*o[2],(1-(p+A))*o[2],0,e[0],e[1],e[2],1]}function jl(t,n,e,r){return[t[0]*n+t[4]*e+t[8]*r+t[12],t[1]*n+t[5]*e+t[9]*r+t[13],t[2]*n+t[6]*e+t[10]*r+t[14]]}function Ul(t){let n=t[0],e=t[4],r=t[8],o=t[1],s=t[5],i=t[9],a=t[2],c=t[6],l=t[10],u=s*l-i*c,f=i*a-o*l,m=o*c-s*a,h=n*u+e*f+r*m;if(Math.abs(h)<1e-12)return null;let d=1/h;return[u*d,f*d,m*d,(r*c-e*l)*d,(n*l-r*a)*d,(e*a-n*c)*d,(e*i-r*s)*d,(r*o-n*i)*d,(n*s-e*o)*d]}function bi(t,n,e,r){let o=t[0]*n+t[1]*e+t[2]*r,s=t[3]*n+t[4]*e+t[5]*r,i=t[6]*n+t[7]*e+t[8]*r,a=Math.hypot(o,s,i)||1;return o/=a,s/=a,i/=a,[o,s,i]}function Wl(t){if(t.byteLength<20||t.byteLength>8388608)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==t.byteLength)return null;let e=12,r=null,o=null;for(;e+8<=t.byteLength;){let s=n.getUint32(e,!0),i=n.getUint32(e+4,!0);if(e+=8,s%4!==0||e+s>t.byteLength)return null;let a=t.subarray(e,e+s);if(i===1313821514&&!r)try{let c=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!Mt(c))return null;r=c}catch{return null}else if(i===5130562&&!o)o=a;else return null;e+=s}return e===t.byteLength&&r&&o?{json:r,bin:o}:null}function Yl(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function zl(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Kl(t,n,e){return e===5120?t.getInt8(n):e===5121?t.getUint8(n):e===5122?t.getInt16(n,!0):e===5123?t.getUint16(n,!0):e===5125?t.getUint32(n,!0):t.getFloat32(n,!0)}function Vl(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Wl(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!Mt(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let s=gt(r.extensionsUsed).filter(A=>typeof A=="string");if(s.includes("KHR_draco_mesh_compression")||Gl(r))return{ok:!1,issue:"draco_not_allowed"};if(s.length||gt(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(gt(r.images).length||gt(r.textures).length)return{ok:!1,issue:"external_resource"};let i=gt(r.buffers);if(i.length!==1||!Mt(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let a=gt(r.accessors),c=gt(r.bufferViews),l=gt(r.meshes),u=gt(r.nodes),f=gt(r.scenes),m=typeof r.scene=="number"?r.scene:0;if(!Mt(f[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),d=(A,M,x)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(a[A]))return null;let I=a[A];if(I.type!==M||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!x.includes(I.componentType)||typeof I.bufferView!="number")return null;let S=c[I.bufferView];if(!Mt(S)||S.buffer!==0||typeof S.byteLength!="number"||!Number.isInteger(S.byteLength)||S.byteLength<0)return null;let _=zl(I.type),O=Yl(I.componentType),C=typeof S.byteStride=="number"?S.byteStride:_*O,F=typeof S.byteOffset=="number"?S.byteOffset:0,k=typeof I.byteOffset=="number"?I.byteOffset:0,E=F+k,w=k+(I.count-1)*C+_*O;if(!Number.isInteger(C)||!Number.isInteger(F)||!Number.isInteger(k)||C<_*O||F<0||k<0||F+S.byteLength>o.byteLength||w>S.byteLength)return null;let B=[];for(let L=0;L<I.count;L++){let T=[];for(let v=0;v<_;v++){let H=Kl(h,E+L*C+v*O,I.componentType);if(!Number.isFinite(H))return null;T.push(H)}B.push(T)}return B},y=[],b=[],p=0,g=new Set,R=(A,M)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(u[A])||g.has(A))return!1;g.add(A);let x=u[A],I=Xl(x);if(!I)return!1;let S=Hl(M,I),_=Ul(S);if(!_)return!1;if(x.mesh!==void 0){if(typeof x.mesh!="number")return!1;let O=l[x.mesh];if(!Mt(O))return!1;for(let C of gt(O.primitives)){if(!Mt(C)||C.mode!==void 0&&C.mode!==4||!Mt(C.attributes))return!1;let F=d(C.attributes.POSITION,"VEC3",[5126]),k=C.attributes.NORMAL===void 0?null:d(C.attributes.NORMAL,"VEC3",[5126]);if(!F||C.attributes.NORMAL!==void 0&&!k)return!1;let E=F.length;if(C.indices!==void 0){let B=typeof C.indices=="number"?a[C.indices]:null;E=Mt(B)?B.count:void 0}if(typeof E!="number"||!Number.isInteger(E)||E%3!==0||(p+=E/3,p>1e5))return!1;let w=C.indices===void 0?F.map((B,L)=>[L]):d(C.indices,"SCALAR",[5121,5123,5125]);if(!w||w.length%3!==0||w.length!==E)return!1;for(let B=0;B<w.length;B+=3){let L=[w[B][0],w[B+1][0],w[B+2][0]];if(L.some(H=>!Number.isInteger(H)||H<0||H>=F.length))return!1;let T=L.map(H=>jl(S,...F[H])),v=null;if(!k){let H=T[1][0]-T[0][0],j=T[1][1]-T[0][1],D=T[1][2]-T[0][2],U=T[2][0]-T[0][0],X=T[2][1]-T[0][1],Y=T[2][2]-T[0][2];v=bi([1,0,0,0,1,0,0,0,1],j*Y-D*X,D*U-H*Y,H*X-j*U)}for(let H=0;H<3;H++)y.push(...T[H]),b.push(...k?bi(_,...k[L[H]]):v)}}}for(let O of gt(x.children))if(!R(O,S))return!1;return g.delete(A),!0};for(let A of gt(f[m].nodes))if(!R(A,Dl()))return{ok:!1,issue:p>1e5?"triangle_limit":"unsupported_glb"};return!p||y.length!==p*9||b.length!==y.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:p,position:new Float32Array(y),normal:new Float32Array(b)}}function gi(t){try{return Vl(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function td(t){let{doc:n}=t,e=jr(n.theme),r=e.structure,o=Ho(n,t.eventConfigurationId??n.eventConfigurationId),s=di(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,a=new vn,c=null;if(t.registeredShellGlb){let N=gi(t.registeredShellGlb);if(N.ok){let G=N.position.length/3,W=new Float32Array(N.position.length),lt=e.materials.shell??r.tierWall;for(let ft=0;ft<G;ft++){let st=N.normal[ft*3+1],tt=st<-.25?.4:.62+.38*Math.max(0,st);W[ft*3]=lt[0]*tt,W[ft*3+1]=lt[1]*tt,W[ft*3+2]=lt[2]*tt}c={position:N.position,normal:N.normal,color:W,floor:new Float32Array(G).fill(-2),material:new Float32Array(G),count:G}}}let l=new Map;for(let N of o)for(let G of N.objects)l.set(G.id,N.index),G.type==="section"&&l.set(G.logicalSectionId??G.id,N.index);let u=i.map(N=>l.get(N.sectionId??"")??l.get(N.rowId??"")??0),f=je(o,i),m=a.vertexCount,d=mi(a,o,i,u,f,r,at(e.background.top,e.background.bottom,.5))?a.vertexCount:m,y=_o(n,i),b=new Map,p=new Map;for(let N of n.categories??[])b.set(N.key,N.color),N.seatGlyph&&p.set(N.key,N.seatGlyph);let g=[],R=cr(o,i,u),A=new Map;i.forEach((N,G)=>{let W=R.seatDeckY(G);Number.isFinite(W)&&A.set(N.rowId,Math.min(A.get(N.rowId)??1/0,W))});let M=new Float32Array(i.length),x=[],I=new Map((n.floors??[]).map((N,G)=>[N.id,G])),S=o.map(()=>[]);for(let N of i){let G=N.floorId?I.get(N.floorId)??0:0;S[Math.min(G,S.length-1)]?.push(N)}let _=(N,G)=>{if(!G||G.length<3)return!1;let W=Math.min(...G.map(tt=>tt.x)),lt=Math.max(...G.map(tt=>tt.x)),ft=Math.min(...G.map(tt=>tt.y)),st=Math.max(...G.map(tt=>tt.y));for(let tt=0;tt<N;tt++)for(let et of S[tt])if(!(et.x<W||et.x>lt||et.y<ft||et.y>st)&&Pt(et,G,void 0))return!0;return!1},O=null,C=N=>o.length===1?i:i.filter((G,W)=>u[W]===N),F=(N,G)=>{let W=At(N);if(!W)return!1;let lt=1/0,ft=1/0,st=-1/0,tt=-1/0;for(let et of W)lt=Math.min(lt,et.x),st=Math.max(st,et.x),ft=Math.min(ft,et.y),tt=Math.max(tt,et.y);return i.some((et,ht)=>et.kind!=="booth"&&(o.length===1||u[ht]===G)&&et.x>lt&&et.x<st&&et.y>ft&&et.y<tt&&xt(W,et.x,et.y))},k;for(let N=0;N<o.length;N++){let G=o[N];a.setFloor(N);let W=Nt(G,C(N)),lt=0;if(W){let z=0;for(let mt of G.objects)if(mt.type==="section")for(let yt of R.bySection.get(mt.id)?.rowLevels??[])z=Math.max(z,yt.y-G.baseHeightM);if(lt=zo(z),!k){let mt=Jt(W);k={centre:[mt.x*P,mt.y*P]}}}let ft=new Hn,st=[],tt=G.objects.filter(z=>z.type==="shape"&&(z.role==="entrance"||z.role==="exit")),et=G.objects.filter(z=>z.type==="section"&&!!z.outline&&z.outline.length>=3),ht=Yr(G.objects.filter(z=>z.type==="booth"),G.focal);for(let z of G.objects)if(z.type==="section"){let mt=a.vertexCount;oi(a,z,G,Ao(z,y),R.bySection.get(z.id),ft,et,r,N>0&&_(N,z.outline));let yt=a.vertexCount-mt;yt>0&&x.push({sectionId:z.id,start:mt,count:yt})}else if(z.type==="shape"){let mt=s.byObjectId.get(z.id),yt=g.length,Dt=W!==null&&z.role==="wall"&&!mt;a.setMaterial(Dt?Xn:(mt?.kind??z.role)==="screen"?1:0);let Ht=z.role==="stage"&&!mt?zr(z,C(N)):Dt&&z.heightM===void 0?{...z,heightM:lt}:z,kt=Wo(Ht,st);if(Ar(a,Ht,G.baseHeightM+kt.supportOffsetM,kt.topOffsetM-kt.supportOffsetM,r,G.focal,g,mt,tt),a.setMaterial(0),z.role==="stage"&&!mt&&g.length>yt&&(O??N)===N){O=N;let Ft=n.floors?.[N]?.id,sn=o.length>1&&Ft?i.filter(Pn=>Pn.floorId===Ft):i;xi(a,Ht,g[g.length-1].y,sn)}}else z.type==="gaArea"?wr(a,z,G.baseHeightM,it(b.get(z.categoryKey)),r):z.type==="booth"?Sr(a,z,G.baseHeightM,it(b.get(z.categoryKey)),r,ht.get(z.id)??G.focal,F(z,N)):z.type==="table"?_r(a,z,Math.max(G.baseHeightM,A.get(z.id)??G.baseHeightM),it(z.fill??n.theme?.decorFill??"#232c40"),r,!!(z.fill??n.theme?.decorFill)):z.type==="decorImage"&&Er(a,z,G.baseHeightM,r);W&&Or(a,G.objects,W,G.baseHeightM,lt,G.focal,r,z=>!s.byObjectId.has(z.id)),ii(a,G,i,R,r,e.materials.shell,!c)}let E=o.length>1?{x:o.reduce((N,G)=>N+G.focal.x,0)/o.length,y:o.reduce((N,G)=>N+G.focal.y,0)/o.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},w=bo(c?[a.build(),c]:[a.build()]),B=Po(i,t.initialState,R,M,b,p),L=Nr({doc:n,units:o,seats:i,surfaces:R,focal:E}),{labels:T,sections:v,rows:H}=Gr({doc:n,units:o,seats:i,surfaces:R,seatData:B,hintedSeatFloor:u,zones:L,focal:E}),j=new Map(v.map((N,G)=>[N.id,G]));R.seatOwner.forEach((N,G)=>{B.iSection[G]=N?j.get(N)??-1:-1});let D=si({doc:n,units:o,seats:i,surfaces:R,solids:w,hintedSeatFloor:u,seatFloor:M});Dr(T,D),B.iYaw=Ro(B.iPosition,i.length,N=>i[N].rowId,N=>{let G=o[M[N]]?.focal??E;return[G.x*P,G.y*P]});let U=(f.minX+f.maxX)/2*P,X=(f.minY+f.maxY)/2*P,Y=.5*Math.hypot((f.maxX-f.minX)*P,(f.maxY-f.minY)*P)||10,nt=Ue(w,B,{cx:U,cz:X,radius:Y},[m,d]),rt=Ue(w,B,{cx:U,cz:X,radius:Y}),q=Zl(o),Q=yi(B,g,f,nt.minY,nt.maxY,Y,q);return{sharedAisles:Hr(o.flatMap(N=>N.objects.flatMap(G=>{if(G.type!=="section")return[];let W=R.bySection.get(G.id);return W?[{sectionId:G.id,floorIndex:N.index,rows:W.rowLevels}]:[]}))),solids:w,sectionSolidRanges:x,seats:B,seatSectionIds:R.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:Y,groundY:0,box:Q,fitPoints:hi(B,g,q)},...k?{room:k}:{},...!k&&o.some(N=>N.objects.some(G=>G.type==="shape"&&An(G.stageKind)))?{outdoor:!0}:{},renderBounds:{center:nt.center,radius:nt.radius},clipBounds:{center:rt.center,radius:rt.radius},stateColorLUT:Ur(e,cn),theme:e,seatCount:i.length,focalWorld:[E.x*P,1.5,E.y*P],zones:L,stages:g,productionElements:s.elements,sections:v,rows:H,labels:T,floors:D}}function Zl(t){let n=[];for(let e of t)for(let r of e.objects){let o=r.type==="gaArea"?r.points:r.type==="booth"?At(r):null;for(let s of o??[])n.push([s.x*P,e.baseHeightM,s.y*P])}return n}function ql(t,n){let{doc:e,report:r}=er(t),o=r.confident&&(r.sections.length>0||!!r.looseRowBlocks);if(!o&&!r.roles?.length)return null;if(!o){let c=new Map(r.roles.map(h=>[h.id,h.role])),l=h=>h.map(d=>d.type==="shape"&&c.has(d.id)?{...d,role:c.get(d.id)}:d),u=t.floors?.map(h=>({...h,objects:l(h.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((h,d)=>{h.eyeHeightM!==void 0&&(f[d]=h.eyeHeightM),h.focalPoint&&(m[d*2]=h.focalPoint.x,m[d*2+1]=h.focalPoint.y)}),{doc:{...t,objects:u?.[0]?.objects??l(t.objects),...u?{floors:u}:{}},report:r,eyeHeightM:f,focal:m}}let s=new Map(En(e).map(c=>[c.id,c])),i=new Float64Array(n.length).fill(Number.NaN),a=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((c,l)=>{let u=s.get(c.id)??c;u.eyeHeightM!==void 0&&(i[l]=u.eyeHeightM),u.focalPoint&&(a[l*2]=u.focalPoint.x,a[l*2+1]=u.focalPoint.y)}),{doc:e,report:r,eyeHeightM:i,focal:a}}function $l(t,n){return t.map((e,r)=>{let o=n.eyeHeightM[r],s=n.focal[r*2],i=n.focal[r*2+1],a={...e};return Number.isNaN(o)?delete a.eyeHeightM:a.eyeHeightM=o,Number.isNaN(s)?delete a.focalPoint:a.focalPoint={x:s,y:i},a})}function rd(t){let n=t.estimate===!1?null:ql(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:$l(t.seats,n)},estimate:n}:{input:t}}export{lu as a,Fi as b,Li as c,go as d,vi as e,uu as f,cn as g,ae as h,kn as i,nu as j,le as k,P as l,Gn as m,gu as n,Mu as o,er as p,lf as q,uf as r,ff as s,mf as t,hf as u,yf as v,Re as w,df as x,pf as y,xf as z,bf as A,gf as B,Tc as C,td as D,ql as E,$l as F,rd as G};
|
|
1
|
+
import{a as co,c as lo,d as uo}from"./chunk-2JFCDE27.js";import{b as $e,c as eo,d as io,e as so,h as ao}from"./chunk-WKWXU5QM.js";import{v as fo}from"./chunk-T2QG47QQ.js";import{a as oo,c as qt,d as pt,f as xt,i as ro}from"./chunk-FBXZWNND.js";import{e as to,l as no}from"./chunk-4N5CHKHD.js";import{n as oe}from"./chunk-33SRM2CP.js";import{h as Sn}from"./chunk-UEDS3HJ3.js";import{Aa as Zt,Ba as An,C as Ye,Ca as Ze,D as Kt,Ga as ee,Ia as qe,Xa as Pt,ca as ze,da as Ke,eb as En,j as We,ka as $,la as Rt,ua as In,va as Vt,wa as _n,ya as Ve}from"./chunk-YE4NP3XB.js";import{A as Et,D as Je,b as Qe,d as it,y as at}from"./chunk-JBOTRSMY.js";var re=t=>t<=.04045?t/12.92:((t+.055)/1.055)**2.4,ie=t=>t<=.0031308?12.92*t:1.055*Math.max(0,t)**.4166666666666667-.055,se=t=>Math.min(1,Math.max(0,t));function Bn(t){let n=re(t[0]),e=re(t[1]),r=re(t[2]),o=Math.cbrt(.4122214708*n+.5363325363*e+.0514459929*r),s=Math.cbrt(.2119034982*n+.6806995451*e+.1073969566*r),i=Math.cbrt(.0883024619*n+.2817188376*e+.6299787005*r);return[.2104542553*o+.793617785*s-.0040720468*i,1.9779984951*o-2.428592205*s+.4505937099*i,.0259040371*o+.7827717662*s-.808675766*i]}function wn([t,n,e]){let r=(t+.3963377774*n+.2158037573*e)**3,o=(t-.1055613458*n-.0638541728*e)**3,s=(t-.0894841775*n-1.291485548*e)**3;return[se(ie(4.0767416621*r-3.3077115913*o+.2309699292*s)),se(ie(-1.2684380046*r+2.6097574011*o-.3413193965*s)),se(ie(-.0041960863*r-.7034186147*o+1.707614701*s))]}var Tn=t=>Bn(t)[0];function an(t){let[,n,e]=Bn(t);return Math.hypot(n,e)}function Xt(t,n,e){let[,r,o]=Bn(t);if(e===void 0)return wn([n,r,o]);let s=Math.hypot(r,o),i=s===0?0:e/s;return wn([n,r*i,o*i])}function mo(t,n,e){let[r,o,s]=Bn(t);return r>=n&&r<=e?t:wn([Math.min(e,Math.max(n,r)),o,s])}function On(t){return wn([t,-.004,-.008])}var cn=["available","held","sold","selected","dimmed"];function ae(t){let n=cn.indexOf(t);return n<0?0:n}var yo={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Mi(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.78,r=.86;return[(n+(t[0]-n)*e)*r,(n+(t[1]-n)*e)*r,(n+(t[2]-n)*e)*r]}var ho={day:{ground:.9,deck:.84,fascia:.77,shell:.79,seatMin:.45,seatMax:.58,unavailable:.58,dimmed:.62,sectionDeck:.66,sectionDeckChromaShare:.8,sectionDeckChromaCap:.11,stageTop:.52,stageWall:.42},night:{ground:.26,deck:.34,fascia:.28,shell:.32,seatMin:.64,seatMax:.8,unavailable:.42,dimmed:.39,sectionDeck:.34,sectionDeckChromaShare:.45,sectionDeckChromaCap:.05,stageTop:0,stageWall:0}},Cn=.012;function kn(t){return Tn(t.tierTop)>.6}function jt(t){return t?ho.day:ho.night}function nu(t,n){let e=jt(n);return mo(Mi(t),e.seatMin,e.seatMax)}var ce={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]},le={top:[.05,.06,.08],bottom:[.1,.12,.15]};function V(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}import Ri from"earcut";import xo from"polygon-clipping";var P=$,Pi=.002;function Si(t,n,e){let r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),o=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),i=Math.max(r,o,s);if(i<1e-9)return!0;let a=(r+o+s)/2;return 2*Math.sqrt(Math.max(0,a*(a-r)*(a-o)*(a-s)))/i<Pi}var Ut=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=n,this.buf[this.len++]=e,this.buf[this.len++]=r}push1(n){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=n}grow(n){let e=this.buf.length*2;for(;e<n;)e*=2;let r=new Float32Array(e);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},vn=class{constructor(){this.pos=new Ut;this.nor=new Ut;this.col=new Ut;this.flr=new Ut;this.mat=new Ut;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,r,o,s,i=s,a=s){Si(n,e,r)||(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(i[0],i[1],i[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(n,e,r,o,s,i,a,c=a,l=a){[...n,...e,...r].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(s[0],s[1],s[2]),this.nor.push3(i[0],i[1],i[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(c[0],c[1],c[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Ii(t,n,e){let r=n[0]-t[0],o=n[1]-t[1],s=n[2]-t[2],i=e[0]-t[0],a=e[1]-t[1],c=e[2]-t[2],l=o*c-s*a,u=s*i-r*c,f=r*a-o*i,m=Math.hypot(l,u,f)||1;return l/=m,u/=m,f/=m,[l,u,f]}function _i(t,n){let e=[...t],r=[];for(let i of t)r.push(i.x,i.y);let o=[];if(n){for(let i of n)if(!(i.length<3)){o.push(e.length);for(let a of i)e.push(a),r.push(a.x,a.y)}}let s=Ri(r,o.length?o:void 0,2);return{pts:e,tris:s}}function wt(t){return pt(t)<0?[...t].reverse():t}var Ai=3;function Ei(t,n,e,r){let o=r(t),s=r(n),i=r(e),a=(h,d,y,b)=>Math.abs(r({x:(h.x+d.x)/2,y:(h.y+d.y)/2})-(y+b)/2),c=(t.x+n.x+e.x)/3,l=(t.y+n.y+e.y)/3,u=(o+s+i)/3,f=Math.max(a(t,n,o,s),a(n,e,s,i),a(e,t,i,o),Math.abs(r({x:c,y:l})-u)),m=(h,d,y)=>{let b=Math.abs(r({x:(h+c)/2,y:(d+l)/2})-(y+u)/2);b>f&&(f=b)};return m((t.x+n.x)/2,(t.y+n.y)/2,(o+s)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(s+i)/2),m((e.x+t.x)/2,(e.y+t.y)/2,(i+o)/2),f}function ln(t,n,e,r,o){if(o<=0)return Ei(t,n,e,r);let s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},i={x:(n.x+e.x)/2,y:(n.y+e.y)/2},a={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max(ln(t,s,a,r,o-1),ln(s,n,i,r,o-1),ln(a,i,e,r,o-1),ln(s,i,a,r,o-1))}function un(t,n,e,r,o,s,i,a){if(i>0){let m={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+r.x)/2,y:(e.y+r.y)/2},d={x:(r.x+n.x)/2,y:(r.y+n.y)/2};un(t,n,m,d,o,s,i-1,a),un(t,m,e,h,o,s,i-1,a),un(t,d,h,r,o,s,i-1,a),un(t,m,h,d,o,s,i-1,a);return}let c=[n.x*P,o(n),n.y*P],l=[e.x*P,o(e),e.y*P],u=[r.x*P,o(r),r.y*P];if(a){t.triN(c,l,u,a(n),a(e),a(r),s);return}let f=Ii(c,l,u);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(c,l,u,f,s)}var wi=8;function po(t,n,e){if(!Number.isFinite(e))return t;let r=[],o=(s,i,a,c,l)=>{if(l>0){let u={x:(s.x+i.x)/2,y:(s.y+i.y)/2},f=n(u);if(Math.abs(f-(a+c)/2)>e){o(s,u,a,f,l-1),o(u,i,f,c,l-1);return}}r.push(s)};for(let s=0;s<t.length;s++){let i=t[s],a=t[(s+1)%t.length];o(i,a,n(i),n(a),wi)}return r}function Fn(t,n){if(t.length<3)return t;let e=[];for(let o of t){let s=e[e.length-1];s&&Math.hypot(o.x-s.x,o.y-s.y)<n||e.push(o)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let r=[];for(let o=0;o<e.length;o++){let s=r.length?r[r.length-1]:e[(o-1+e.length)%e.length],i=e[o],a=e[(o+1)%e.length],c=a.x-s.x,l=a.y-s.y,u=Math.hypot(c,l);u>n&&Math.abs((i.x-s.x)*l-(i.y-s.y)*c)/u<n||r.push(i)}return r.length>=3?r:e}var Ln=.001*Rt*.1;function Z(t,n,e,r,o,s,i,a,c=1/0,l){if(!n||n.length<3||(c===void 0&&(c=1/0),Math.abs(pt(n))<1e-4))return;let u=Fn(po(Fn(wt(n),Ln),r,c),Ln),f=e?.map(x=>Fn(po(Fn(wt(x),Ln),r,c),Ln)).filter(x=>x.length>=3&&Math.abs(pt(x))>=1e-4),{pts:m,tris:h}=_i(u,f),d=[s[0]*a.top,s[1]*a.top,s[2]*a.top],y=[s[0]*a.bottomCap,s[1]*a.bottomCap,s[2]*a.bottomCap],b=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.wallBottom,i[1]*a.wallBottom,i[2]*a.wallBottom],g=0;if(Number.isFinite(c))for(;g<Ai;g++){let x=0;for(let I=0;I<h.length;I+=3){let S=ln(m[h[I]],m[h[I+1]],m[h[I+2]],r,g);S>x&&(x=S)}if(x<=c)break}for(let x=0;x<h.length;x+=3){let I=m[h[x]],S=m[h[x+1]],_=m[h[x+2]];un(t,I,S,_,r,d,g,l);let O=[I.x*P,o,I.y*P],C=[S.x*P,o,S.y*P],F=[_.x*P,o,_.y*P];t.tri(O,F,C,[0,-1,0],y)}let R=x=>{if(g<=0)return x;let I=1<<g,S=[];for(let _=0;_<x.length;_++){let O=x[_],C=x[(_+1)%x.length];for(let F=0;F<I;F++){let k=F/I;S.push({x:O.x+(C.x-O.x)*k,y:O.y+(C.y-O.y)*k})}}return S},A=Ye(u),M=[{ring:R(u),flip:!1}];if(f)for(let x of f)x.length>=3&&M.push({ring:R(x),flip:!0});for(let{ring:x,flip:I}of M)for(let S=0;S<x.length;S++){let _=x[S],O=x[(S+1)%x.length],C=(O.x-_.x)*P,k=(O.y-_.y)*P,E=-C,w=Math.hypot(k,E)||1;k/=w,E/=w;let B=(_.x+O.x)/2-A.x,L=(_.y+O.y)/2-A.y,T=k*B+E*L;I&&(T=-T),T<0&&(k=-k,E=-E);let v=[k,0,E],H=[_.x*P,r(_),_.y*P],j=[O.x*P,r(O),O.y*P],D=[_.x*P,o,_.y*P],U=[O.x*P,o,O.y*P];t.tri(H,j,U,v,b,b,p),t.tri(H,U,D,v,b,p,p)}}function bo(t){let n=0;for(let c of t)n+=c.count;let e=new Float32Array(n*3),r=new Float32Array(n*3),o=new Float32Array(n*3),s=new Float32Array(n),i=new Float32Array(n),a=0;for(let c of t)e.set(c.position,a*3),r.set(c.normal,a*3),o.set(c.color,a*3),s.set(c.floor,a),i.set(c.material,a),a+=c.count;return{position:e,normal:r,color:o,floor:s,material:i,count:n}}function It(t,n,e=2.5){if(n<=0||t.length<3)return t;let r=wt(t),o=r.length,s=[];for(let a=0;a<o;a++){let c=r[a],l=r[(a+1)%o],u=l.x-c.x,f=l.y-c.y,m=Math.hypot(u,f)||1;s.push({x:f/m,y:-u/m})}let i=[];for(let a=0;a<o;a++){let c=r[a],l=s[(a-1+o)%o],u=s[a],f=l.x+u.x,m=l.y+u.y,h=Math.hypot(f,m),d=()=>{i.push([c.x+l.x*n,c.y+l.y*n]),i.push([c.x+u.x*n,c.y+u.y*n])};if(h<1e-9){d();continue}f/=h,m/=h;let y=f*l.x+m*l.y,b=1/Math.max(y,1e-6);if(!Number.isFinite(b)||b>e){d();continue}i.push([c.x+f*n*b,c.y+m*n*b])}if(i.length<3)return t;try{let a=xo.union([[...i,i[0]]]),c=null,l=-1/0;for(let f of a){let m=Math.abs(pt(f[0].map(([h,d])=>({x:h,y:d}))));m>l&&(l=m,c=f[0])}if(!c)return t;let u=c.map(([f,m])=>({x:f,y:m}));if(u.length>1){let f=u[0],m=u[u.length-1];Math.abs(f.x-m.x)<1e-9&&Math.abs(f.y-m.y)<1e-9&&u.pop()}return u.length>=3?u:t}catch{return t}}function Lt(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let r=wt(t),o=r.length,s=[];for(let c=0;c<o;c++){let l=r[c],u=r[(c+1)%o],f=Math.hypot(u.x-l.x,u.y-l.y)||1;s.push({x:-(u.y-l.y)/f,y:(u.x-l.x)/f})}let i=[],a=[];for(let c=0;c<o;c++){let l=r[c],u=s[(c-1+o)%o],f=s[c],m=u.x+f.x,h=u.y+f.y,d=Math.hypot(m,h),y=d<1e-9?1/0:1/Math.max(m/d*u.x+h/d*u.y,1e-6);if(!Number.isFinite(y)||y>e){i.push({x:l.x+u.x*n,y:l.y+u.y*n},{x:l.x+f.x*n,y:l.y+f.y*n}),a.push(c,c);continue}m/=d,h/=d,i.push({x:l.x+m*n*y,y:l.y+h*n*y}),a.push(c)}for(let c=0;c<i.length;c++){let l=(c+1)%i.length,u=a[c],f=a[l];if(f!==(u+1)%o)continue;let m=r[u],h=r[f];if((i[l].x-i[c].x)*(h.x-m.x)+(i[l].y-i[c].y)*(h.y-m.y)<=0)return[]}try{let c=xo.intersection([[...i.map(d=>[d.x,d.y]),[i[0].x,i[0].y]]],[[...r.map(d=>[d.x,d.y]),[r[0].x,r[0].y]]]),l=null,u=0;for(let d of c){let y=Math.abs(pt(d[0].map(([b,p])=>({x:b,y:p}))));y>u&&(u=y,l=d[0])}if(!l)return[];let f=l.map(([d,y])=>({x:d,y})),m=f[0],h=f[f.length-1];return f.length>1&&Math.abs(m.x-h.x)<1e-9&&Math.abs(m.y-h.y)<1e-9&&f.pop(),f.length>=3?wt(f):[]}catch{return[]}}function Nn(t,n,e,r,o=28){let s=[];for(let i=0;i<o;i++){let a=i/o*Math.PI*2;s.push({x:t+e*Math.cos(a),y:n+r*Math.sin(a)})}return s}function fn(t,n,e,r){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+r},{x:t,y:n+r}]}var ut={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Bi=.44,Ti=.15,Oi=.3,Ci=.24;function Mo(t){return t===void 0||!Number.isFinite(t)||t<=0?Ci:Math.min(Oi,Math.max(Ti,t*Bi))}var lu=.21,ki=.05,ue=.45,Fi=ue+ki,Li=.92,go=.66,vi=1.205,Ni=-.23,Gi=.38,Di=[{part:ut.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ut.pad,min:[-1,.36,-.95],max:[1,ue,1]},{part:ut.back,min:[-1,Fi,-1],max:[1,Li,-.72]},{part:ut.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ut.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ut.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ut.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ut.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ut.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ut.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Hi=[{part:ut.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ut.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ut.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ut.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ut.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}],Xi=[{n:[1,0,0],c:[[1,0,0],[1,1,0],[1,1,1],[1,0,1]]},{n:[-1,0,0],c:[[0,0,1],[0,1,1],[0,1,0],[0,0,0]]},{n:[0,1,0],c:[[0,1,0],[0,1,1],[1,1,1],[1,1,0]]},{n:[0,-1,0],c:[[0,0,1],[0,0,0],[1,0,0],[1,0,1]]},{n:[0,0,1],c:[[0,0,1],[1,0,1],[1,1,1],[0,1,1]]},{n:[0,0,-1],c:[[1,0,0],[0,0,0],[0,1,0],[1,1,0]]}];function uu(){let t=[],n=[],e=[],r=[],o=(D,U,X)=>{let Y=e.length,[nt,rt,q]=D,Q=[rt[0]-nt[0],rt[1]-nt[1],rt[2]-nt[2]],J=[q[0]-nt[0],q[1]-nt[1],q[2]-nt[2]],N=Q[1]*J[2]-Q[2]*J[1],G=Q[2]*J[0]-Q[0]*J[2],W=Q[0]*J[1]-Q[1]*J[0],lt=Math.hypot(N,G,W);lt>1e-9?(N/=lt,G/=lt,W/=lt):[N,G,W]=U,N*U[0]+G*U[1]+W*U[2]<0&&(N=-N,G=-G,W=-W);for(let ft of D)t.push(...ft),n.push(N,G,W),e.push(X);r.push(Y,Y+1,Y+2,Y,Y+2,Y+3)},s=D=>{for(let U of Xi){let X=U.c.map(Y=>Y.map((nt,rt)=>nt?D.max[rt]:D.min[rt]));o(X,U.n,D.part)}},i=(D,U)=>{let[X,Y,nt]=U?[0,1,2]:[0,2,1],rt=D.min[X],q=D.max[X],Q=D.min[Y],J=D.max[Y],N=(q-rt)*.1,G=(J-Q)*.1,W=U?[[rt+N,Q],[q-N,Q],[q,Q+G],[q*.94,J-(J-Q)*.23],[q*go,J],[rt*go,J],[rt*.94,J-(J-Q)*.23],[rt,Q+G]]:[[rt+N,Q],[q-N,Q],[q,Q+G],[q,J-G],[q-N,J],[rt+N,J],[rt,J-G],[rt,Q+G]],lt=(st,tt,et)=>{let ht=[0,0,0];return ht[X]=st,ht[Y]=tt,ht[nt]=et,ht},ft=[D.min[nt],D.max[nt]].map(st=>W.map(([tt,et])=>lt(tt,et,st)));for(let st=0;st<W.length;st++){let tt=(st+1)%W.length,et=[0,0,0];et[X]=(W[st][0]+W[tt][0])/2-(rt+q)/2,et[Y]=(W[st][1]+W[tt][1])/2-(Q+J)/2,o([ft[0][st],ft[0][tt],ft[1][tt],ft[1][st]],et,D.part)}for(let st=0;st<2;st++){let tt=[0,0,0];tt[nt]=st?1:-1;let et=ft[st];for(let ht=1;ht<et.length-1;ht++){let z=e.length;for(let mt of[et[0],et[ht],et[ht+1]])t.push(...mt),n.push(...tt),e.push(D.part);r.push(z,z+1,z+2)}}};for(let D of Di)D.part===ut.pad||D.part===ut.back?i(D,D.part===ut.back):s(D);for(let D of Hi)s(D);let a=ue,c=1.08,l=.47,u=.69,f=-.55,m=.08,h=-.48,d=.01,y=[-l,a,f],b=[l,a,f],p=[-l,a,m],g=[l,a,m],R=[-u,c,h],A=[u,c,h],M=[-u,c,d],x=[u,c,d];o([b,A,x,g],[1,0,0],ut.body),o([p,M,R,y],[-1,0,0],ut.body),o([y,b,g,p],[0,-1,0],ut.body);let I=c+.07,S=.24,_=[-S,I,h],O=[S,I,h],C=[-S,I,d],F=[S,I,d];o([M,C,_,R],[-.5,1,0],ut.body),o([C,F,O,_],[0,1,0],ut.body),o([F,x,A,O],[.5,1,0],ut.body),o([g,x,M,p],[0,0,1],ut.body),o([x,F,C,M],[0,0,1],ut.body),o([y,R,A,b],[0,0,-1],ut.body),o([R,_,O,A],[0,0,-1],ut.body);let k=10,E=8,w=[0,vi,Ni],B=[.32,.115,Gi],L=e.length;for(let D=0;D<=E;D++){let U=Math.PI*D/E,X=Math.cos(U),Y=Math.sin(U);for(let nt=0;nt<=k;nt++){let rt=Math.PI*2*nt/k,q=Y*Math.cos(rt),Q=Y*Math.sin(rt);t.push(w[0]+B[0]*q,w[1]+B[1]*X,w[2]+B[2]*Q);let J=q/B[0],N=X/B[1],G=Q/B[2],W=Math.hypot(J,N,G)||1;J/=W,N/=W,G/=W,n.push(J,N,G),e.push(ut.head)}}for(let D=0;D<E;D++)for(let U=0;U<k;U++){let X=L+D*(k+1)+U,Y=X+k+1;r.push(X,Y,X+1,X+1,Y,Y+1)}let T=new Float32Array(t),v=new Float32Array(n),H=new Float32Array(e),j=new Uint16Array(r);return{position:T,normal:v,part:H,index:j,vertexCount:e.length,indexCount:r.length}}function Ro(t,n,e,r){let o=new Float32Array(n),s=l=>t[l*3],i=l=>t[l*3+2],a=0,c=(l,u)=>{let f=u-l;for(let m=l;m<u;m++){let[h,d]=r(m),y=h-s(m),b=d-i(m);if(f>=2){let p=Math.max(l,m-1),g=Math.min(u-1,m+1),R=s(g)-s(p),A=i(g)-i(p),M=Math.hypot(R,A);if(M>1e-6){let x=-A/M,I=R/M;x*y+I*b<0&&(x=-x,I=-I),y=x,b=I}}o[m]=y===0&&b===0?0:Math.atan2(y,b)}};for(let l=1;l<=n;l++)(l===n||e(l)!==e(a))&&(c(a,l),a=l);return o}var Gn=.22;function gu(t,n){let e=cn[t];if(e!=="sold"&&e!=="held")return-1;let r=(n+1)*2654435761;return r^=r>>>15,r=Math.imul(r,2246822519),r^=r>>>13,(r>>>0)%1e5/1e5}var ji=.42;function Ui(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let r=1/0,o=1/0,s=-1/0,i=-1/0;for(let d of t)d.x<r&&(r=d.x),d.y<o&&(o=d.y),d.x>s&&(s=d.x),d.y>i&&(i=d.y);let a=Math.max(s-r,1e-6),c=Math.max(i-o,1e-6),l=Math.max(Math.sqrt(a*c/n),1e-6),u=Math.max(1,Math.ceil(a/l)+1),f=Math.max(1,Math.ceil(c/l)+1),m=new Map,h=(d,y)=>{let b=Math.min(u-1,Math.max(0,Math.floor((d-r)/l)));return Math.min(f-1,Math.max(0,Math.floor((y-o)/l)))*u+b};for(let d=0;d<n;d++){let y=h(t[d].x,t[d].y),b=m.get(y);b?b.push(d):m.set(y,[d])}for(let d=0;d<n;d++){let y=t[d],b=Math.min(u-1,Math.max(0,Math.floor((y.x-r)/l))),p=Math.min(f-1,Math.max(0,Math.floor((y.y-o)/l))),g=1/0;for(let R=1;R<=4;R++){for(let A=p-R;A<=p+R;A++)if(!(A<0||A>=f))for(let M=b-R;M<=b+R;M++){if(M<0||M>=u||R>1&&Math.abs(A-p)<R&&Math.abs(M-b)<R)continue;let x=m.get(A*u+M);if(x)for(let I of x){if(I===d)continue;let S=Math.hypot(t[I].x-y.x,t[I].y-y.y);S<g&&(g=S)}}if(Number.isFinite(g)&&g<=R*l)break}e[d]=g}return e}function Wi(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-In):0}function Po(t,n,e,r,o,s){let i=t.length,a=new Float32Array(i*3),c=new Float32Array(i),l=new Float32Array(i*3),u=new Float32Array(i),f=new Float32Array(i),m=new Float32Array(i),h=new Float32Array(i),d=new Float32Array(i*3),y=new Map,b=Ui(t);for(let p=0;p<i;p++){let g=t[p],A=(e?.seatPitchU(p)??b[p])*P;u[p]=Number.isFinite(A)?Math.max(.06,Math.min(Gn,A*ji)):Gn,f[p]=Mo(Number.isFinite(A)?A:void 0);let M=no(g.glyph,{seatGlyph:s?.get(g.categoryKey)});m[p]=to.indexOf(M),h[p]=g.wheelchairSpaceType==="no-seat"?0:1,a[p*3]=g.x*P,a[p*3+1]=e?e.seatDeckY(p):Wi(g),a[p*3+2]=g.y*P,c[p]=ae(n?n(g):"available");let x=it(o?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[p*3]=x[0],l[p*3+1]=x[1],l[p*3+2]=x[2],g.accessibility?.length){let I=it(Sn(g.accessibility));I&&(d[p*3]=I[0],d[p*3+1]=I[1],d[p*3+2]=I[2])}y.set(g.id,p)}return{count:i,iPosition:a,iState:c,iCategory:l,iMaxRadius:u,iRing:d,idToIndex:y,iChairWidth:f,iGlyph:m,iPhysicalSeat:h,iFloor:r??new Float32Array(i),iSection:new Float32Array(i).fill(-1),iYaw:new Float32Array(i)}}var Yi=64;function Mu(t,n){let e=[];for(let i of n){let a=t.idToIndex.get(i.seatId);if(a===void 0)continue;let c=ae(i.state);t.iState[a]!==c&&(t.iState[a]=c,e.push(a))}if(!e.length)return[];e.sort((i,a)=>i-a);let r=[],o=e[0],s=e[0];for(let i=1;i<e.length;i++){let a=e[i];if(a!==s){if(a<=s+Yi){s=a;continue}r.push({start:o,length:s-o+1}),o=a,s=a}}return r.push({start:o,length:s-o+1}),r}import rs from"polygon-clipping";var K={top:1,wallBottom:.58,bottomCap:.4};function Wt(t,n){if(!t)return n;let e=V(Et(t,.4),.62);return at(n,e,.22)}function So(t,n){return t?at(n,V(Et(t,.25),.74),.62):n}function Io(t,n){let e=jt(kn({tierTop:n}));return t?Xt(t,e.sectionDeck,Math.min(e.sectionDeckChromaShare*an(t),e.sectionDeckChromaCap)):Xt(n,e.deck,Math.min(an(n),Cn))}function _o(t,n){let e=new Map;for(let s of t.categories??[])e.set(s.key,s.color);let r=new Map;for(let s of n){if(!s.sectionId)continue;let i=r.get(s.sectionId);i||(i=new Map,r.set(s.sectionId,i)),i.set(s.categoryKey,(i.get(s.categoryKey)??0)+1)}let o=new Map;for(let[s,i]of r){let a=0,c=0,l=0,u=0;for(let[f,m]of i){let h=it(e.get(f));h&&(a+=h[0]*m,c+=h[1]*m,l+=h[2]*m,u+=m)}u>0&&o.set(s,[a/u,c/u,l/u])}return o}function Ao(t,n){return it(t.color)??n.get(t.logicalSectionId??t.id)??null}import Do from"polygon-clipping";import To from"polygon-clipping";import zi from"earcut";var Ki=.58,Eo=.01,St=Gn*1.5*Rt,Vi=.5,Zi=.6;function qi(t,n){let e=t.length,r=[];for(let i=0;i<e;i++){let a=t[Math.max(0,i-1)],c=t[Math.min(e-1,i+1)],l=c.x-a.x,u=c.y-a.y,f=Math.hypot(l,u);if(f<1e-9){r.push([0,0]);continue}l/=f,u/=f,r.push([-u,l])}let o=0;for(let i=0;i<e;i++)o+=(t[i].x-n.x)*r[i][0]+(t[i].y-n.y)*r[i][1];return o<0?r.map(([i,a])=>[-i,-a]):r}function $i(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],r=(i,a)=>{let c=a.x-i.x,l=a.y-i.y,u=Math.hypot(c,l)||1;return{x:c/u,y:l/u}},o=r(e[1],e[0]),s=r(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+o.x*n,y:e[0].y+o.y*n}),e.push({x:e[e.length-1].x+s.x*n,y:e[e.length-1].y+s.y*n}),e}var wo=Math.PI/12;function Qi(t){if(t.length<3)return[...t];let n=[...t].sort((s,i)=>s.x-i.x||s.y-i.y),e=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),r=s=>{let i=[];for(let a of s){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o:[...t]}function Oo(t,n){if(!t.length||!(n>0))return[];let e=Qi(t),r=(a,c,l,u)=>{let f=l-c;for(;f<0;)f+=Math.PI*2;for(;f>Math.PI*2;)f-=Math.PI*2;let m=Math.max(1,Math.ceil(f/wo)),h=n/Math.cos(f/m/2);for(let d=0;d<=m;d++){let y=c+f*d/m;u.push({x:a.x+Math.cos(y)*h,y:a.y+Math.sin(y)*h})}};if(e.length<3){let a=0,c=0;for(let h of e)a+=h.x,c+=h.y;a/=e.length||1,c/=e.length||1;let l=0;for(let h of e)l=Math.max(l,Math.hypot(h.x-a,h.y-c));let u=[],f=Math.max(3,Math.ceil(Math.PI*2/wo)),m=(l+n)/Math.cos(Math.PI/f);for(let h=0;h<f;h++){let d=h/f*Math.PI*2;u.push({x:a+Math.cos(d)*m,y:c+Math.sin(d)*m})}return u}let o=e.length,s=[];for(let a=0;a<o;a++){let c=e[a],l=e[(a+1)%o];s.push(Math.atan2(-(l.x-c.x),l.y-c.y))}let i=[];for(let a=0;a<o;a++)r(e[a],s[(a+o-1)%o],s[a],i);return vo(i)}function Ji(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let s=t[o],i=t[o+1],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l>1e-12?((n-s.x)*a+(e-s.y)*c)/l:0;u<0?u=0:u>1&&(u=1);let f=Math.hypot(n-(s.x+u*a),e-(s.y+u*c));f<r&&(r=f)}return r}function Dn(t){let n=t.map(o=>{let s=0,i=0;for(let l of o.pts)s+=l.x,i+=l.y;let a=o.pts.length||1;s/=a,i/=a;let c=0;for(let l of o.pts){let u=Math.hypot(l.x-s,l.y-i);u>c&&(c=u)}return{cx:s,cy:i,rad:c}}),e=o=>{let s=o.length;return s<=2?[...o]:[o[Math.floor(s*.25)],o[Math.floor(s*.5)],o[Math.floor(s*.75)]]},r=[];for(let o=0;o<t.length;o++){let s=e(t[o].pts),i=[],a=1/0,c=null;for(let u of s){let f=1/0;for(let m=0;m<t.length;m++){if(m===o||Math.abs(t[m].y-t[o].y)<.001)continue;let h=n[m],d=Math.hypot(u.x-h.cx,u.y-h.cy)-h.rad;if(d>=f&&d>=a)continue;let y=Ji(t[m].pts,u.x,u.y);y<f&&(f=y),t[m].depth<t[o].depth&&y<a&&(a=y,c=t[m].y)}Number.isFinite(f)&&f>0&&i.push(f)}i.sort((u,f)=>u-f);let l=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:l,belowY:c})}return r}function Co(t,n,e,r){let o=t[n],s=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let u=o.pts[0],f=u.x-r.x,m=u.y-r.y,h=Math.hypot(f,m)||1;f/=h,m/=h;let d=Math.max(e[n].pitch,.001)*.5;return[{x:u.x+m*d,y:u.y-f*d},{x:u.x-m*d,y:u.y+f*d}]})():[];if(s.length<2)return null;let i=0,a=0;for(let u=1;u<s.length;u++){let f=Math.hypot(s[u].x-s[u-1].x,s[u].y-s[u-1].y);f>1e-6&&(i+=f,a++)}let c=a>0?i/a:0,l=$i(s,Math.max(c*Zi,St));return{pts:l,nrm:qi(l,r),front:Math.max(e[n].pitch*Ki,St),back:Math.max(e[n].pitch*Vi,St)}}var $t=1.5,ko=.3;function fe(t,n){if(t.length<3)return t;let e=t[0],r=t[t.length-1],o=r.x-e.x,s=r.y-e.y,i=Math.hypot(o,s),a=-1,c=-1;for(let f=1;f<t.length-1;f++){let m=t[f],h=i>1e-12?Math.abs((m.x-e.x)*s-(m.y-e.y)*o)/i:Math.hypot(m.x-e.x,m.y-e.y);h>a&&(a=h,c=f)}if(a<=n||c<0)return[e,r];let l=fe(t.slice(0,c+1),n),u=fe(t.slice(c),n);return[...l.slice(0,-1),...u]}function Fo(t,n){if(t.length<4)return t;let e=fe([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function ts(t){let n=t.map((r,o)=>{let s=t[(o+1)%t.length];return{a:r,b:s,i:o,minX:Math.min(r.x,s.x),maxX:Math.max(r.x,s.x),minY:Math.min(r.y,s.y),maxY:Math.max(r.y,s.y)}}).sort((r,o)=>r.minX-o.minX),e=(r,o,s)=>(o.x-r.x)*(s.y-r.y)-(o.y-r.y)*(s.x-r.x);for(let r=0;r<n.length;r++){let o=n[r];for(let s=r+1;s<n.length&&n[s].minX<=o.maxX;s++){let i=n[s];if(!(Math.abs(o.i-i.i)===1||Math.abs(o.i-i.i)===t.length-1||o.maxY<i.minY||i.maxY<o.minY)&&e(o.a,o.b,i.a)*e(o.a,o.b,i.b)<=0&&e(i.a,i.b,o.a)*e(i.a,i.b,o.b)<=0)return!0}}return!1}function Lo(t,n,e){if(t.length<2)return[];let r=e??Dn(t),o=new Map;for(let i=0;i<t.length;i++){let a=o.get(t[i].blockId);a?a.push(i):o.set(t[i].blockId,[i])}let s=[];for(let[,i]of o){let a=[];for(let g of i){let R=t[g].patch;R&&R.length>=3?s.push({outline:[...R],holes:[],topY:t[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,R)=>t[g].depth-t[R].depth);let l=a.map(g=>Co(t,g,r,n)).filter(g=>g!==null);if(!l.length)continue;let u=(g,R)=>({x:g.pts[R].x-g.nrm[R][0]*(g.front+$t),y:g.pts[R].y-g.nrm[R][1]*(g.front+$t)}),f=(g,R)=>({x:g.pts[R].x+g.nrm[R][0]*(g.back+$t),y:g.pts[R].y+g.nrm[R][1]*(g.back+$t)}),m=l[0],h=l[l.length-1],d=[];for(let g=0;g<m.pts.length;g++)d.push(u(m,g));for(let g of l)d.push(f(g,g.pts.length-1));for(let g=h.pts.length-1;g>=0;g--)d.push(f(h,g));for(let g=l.length-1;g>=0;g--)d.push(u(l[g],0));let y=vo(d),b=1/0;for(let g of a)t[g].y<b&&(b=t[g].y);if(!Number.isFinite(b))continue;if(y.length>=3&&Math.abs(pt(y))>1e-6&&l.every(g=>{let R=g.pts[Math.floor(g.pts.length/2)];return xt(y,R.x,R.y)})&&!ts(y)){s.push({outline:Fo(y,ko),holes:[],topY:b});continue}for(let g of ns(l))s.push({outline:g,holes:[],topY:b})}return s}function ns(t){let n=[];for(let e of t){let r=[],o=[],s=e.front+$t,i=e.back+$t;for(let c=0;c<e.pts.length;c++){let l=e.pts[c],u=e.nrm[c];r.push([l.x-u[0]*s,l.y-u[1]*s]),o.push([l.x+u[0]*i,l.y+u[1]*i])}let a=[...r,...o.reverse()];a.length<3||(a.push(a[0]),n.push([a]))}if(!n.length)return[];try{let e=To.union(n[0],...n.slice(1)),r=[];for(let o of e){if(!o.length||o[0].length<4)continue;let s=o[0].map(([c,l])=>({x:c,y:l})),i=s[0],a=s[s.length-1];s.length>1&&Math.abs(i.x-a.x)<1e-9&&Math.abs(i.y-a.y)<1e-9&&s.pop(),s.length>=3&&r.push(Fo(s,ko))}return r}catch{return[]}}function vo(t){let n=[];for(let e of t){let r=n[n.length-1];r&&Math.hypot(e.x-r.x,e.y-r.y)<1e-9||n.push(e)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<1e-9;)n.pop();return n}var me=class{constructor(n){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=n;for(let e of n)for(let r of e)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(n){for(let e of n)if(e.x<this.minX||e.x>this.maxX||e.y<this.minY||e.y>this.maxY)return!1;for(let e of this.rings){let r=!0;for(let o of n)if(!xt(e,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function Bo(t,n,e,r,o,s){if(r.length<3)return;if(e.containsAll(r)){let l=[0,1,0],u=r[0];for(let f=1;f+1<r.length;f++){let m=r[f],h=r[f+1];t.tri([u.x*P,o,u.y*P],[m.x*P,o,m.y*P],[h.x*P,o,h.y*P],l,s)}return}let i=r.map(l=>[l.x,l.y]);i.push(i[0]);let a;try{a=To.intersection([i],n)}catch{return}let c=[0,1,0];for(let l of a){if(!l.length||l[0].length<4)continue;let u=l[0],f=[],m=[];for(let d=0;d<u.length-1;d++)f.push(u[d][0],u[d][1]),m.push([u[d][0],u[d][1]]);if(m.length<3)continue;let h=zi(f,void 0,2);for(let d=0;d<h.length;d+=3){let y=m[h[d]],b=m[h[d+1]],p=m[h[d+2]];t.tri([y[0]*P,o,y[1]*P],[b[0]*P,o,b[1]*P],[p[0]*P,o,p[1]*P],c,s)}}}function No(t,n,e,r,o,s,i){if(n.length<2)return;let a=i??Dn(n),c=[0,1,0],l=s&&s.length>=3?[[...s.map(h=>[h.x,h.y]),[s[0].x,s[0].y]]]:null,u=s&&s.length>=3?new me([[...s]]):null,f=h=>{t.setMaterial(2),h(),t.setMaterial(0)},m=h=>{t.setMaterial(3),h(),t.setMaterial(0)};for(let h=0;h<n.length;h++){let d=n[h];if(d.patch&&d.patch.length>=3){let M=[...d.patch],x=a[h].belowY??r;if(m(()=>{if(l&&u)Bo(t,l,u,M,d.y,o.tread);else{let I=M[0];for(let S=1;S+1<M.length;S++){let _=M[S],O=M[S+1];t.tri([I.x*P,d.y,I.y*P],[_.x*P,d.y,_.y*P],[O.x*P,d.y,O.y*P],c,o.tread)}}}),d.y>x+Eo){let I=0,S=0;for(let _ of M)I+=_.x,S+=_.y;I/=M.length,S/=M.length,f(()=>{for(let _=0;_<M.length;_++){let O=M[_],C=M[(_+1)%M.length],F=C.x-O.x,k=C.y-O.y,E=Math.hypot(F,k);if(E<1e-6)continue;let w=k/E,B=-F/E;(O.x-I)*w+(O.y-S)*B<0&&(w=-w,B=-B);let L=[w,0,B],T=[O.x*P,d.y,O.y*P],v=[C.x*P,d.y,C.y*P],H=[O.x*P,x,O.y*P],j=[C.x*P,x,C.y*P];t.tri(T,v,j,L,o.riser),t.tri(T,j,H,L,o.riser)}})}continue}let y=Co(n,h,a,e);if(!y)continue;let{pts:b,nrm:p,front:g,back:R}=y,A=a[h].belowY??r;for(let M=0;M+1<b.length;M++){let x=b[M],I=b[M+1],S=p[M],_=p[M+1];if(Math.hypot(I.x-x.x,I.y-x.y)<1e-6||S[0]===0&&S[1]===0||_[0]===0&&_[1]===0)continue;let O=[(x.x-S[0]*g)*P,d.y,(x.y-S[1]*g)*P],C=[(I.x-_[0]*g)*P,d.y,(I.y-_[1]*g)*P],F=[(x.x+S[0]*R)*P,d.y,(x.y+S[1]*R)*P],k=[(I.x+_[0]*R)*P,d.y,(I.y+_[1]*R)*P];if(m(()=>{l&&u?Bo(t,l,u,[{x:x.x-S[0]*g,y:x.y-S[1]*g},{x:I.x-_[0]*g,y:I.y-_[1]*g},{x:I.x+_[0]*R,y:I.y+_[1]*R},{x:x.x+S[0]*R,y:x.y+S[1]*R}],d.y,o.tread):(t.tri(O,C,k,c,o.tread),t.tri(O,k,F,c,o.tread))}),d.y>A+Eo){let E=[O[0],A,O[2]],w=[C[0],A,C[2]],B=[-S[0],0,-S[1]];f(()=>{t.tri(O,C,w,B,o.riser),t.tri(O,w,E,B,o.riser)})}}}}function es(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function Go(t,n){return t.filter(e=>e.type!=="shape"||es(e,n))}function Ho(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((r,o)=>({objects:Go(r.objects,n),focal:{x:(r.focalPoint??e).x,y:(r.focalPoint??e).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:Go(t.objects,n),focal:e,baseHeightM:0,index:0}]}var os={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Tt(t){return oo(t)??os}function Xo(t,n){let e=It(t.outline,St),r=Tt(e),o=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&qt(r,Tt(i.outline)));if(!o.length)return[e];let s=i=>{let a=i.map(c=>[c.x,c.y]);return a.push(a[0]),a};try{let i=Do.difference([s(e)],...o.map(c=>[s(c.outline)])),a=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&a.push(l)}return a.length?a:[e]}catch{return[e]}}function jo(t,n){if(!n.length)return t;let e=s=>{let i=s.map(a=>[a.x,a.y]);return i.push(i[0]),i},r=n.map(s=>[e(s)]),o=[];for(let s of t){let i;try{i=Do.intersection([e(s.outline)],r.flat())}catch{o.push(s);continue}for(let a of i){if(!a.length)continue;let c=a[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&o.push({outline:c,holes:[],topY:s.topY})}}return o.length?o:t}function is(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var Hn=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let r=n.map(c=>[c.x,c.y]);if(r.length<3)return[];r.push(r[0]);let o=Tt(n),s=this.rings.filter((c,l)=>qt(o,this.boxes[l])&&is(e,this.levels[l])),i=[[r]];if(s.length)try{i=rs.difference([r],...s).map(l=>l.map(u=>u.map(([f,m])=>[f,m])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(e);let a=[];for(let c of i){if(!c.length)continue;let l=c[0].map(([u,f])=>({x:u,y:f}));if(l.length>1){let u=l[0],f=l[l.length-1];Math.abs(u.x-f.x)<1e-9&&Math.abs(u.y-f.y)<1e-9&&l.pop()}l.length>=3&&a.push(l)}return a}};function Qt(t,n,e=t){if(!n)return t;let r=1/0,o=-1/0,s=1/0,i=-1/0;for(let m of e)r=Math.min(r,m.x),o=Math.max(o,m.x),s=Math.min(s,m.y),i=Math.max(i,m.y);let a=(r+o)/2,c=(s+i)/2,l=n*Math.PI/180,u=Math.cos(l),f=Math.sin(l);return t.map(m=>{let h=m.x-a,d=m.y-c;return{x:a+h*u-d*f,y:c+h*f+d*u}})}function Uo(t){let n=Ke(t);return!n.length||!t.points?.length?[]:n.map(e=>Qt(e,t.rotation,t.points))}function ct(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3)return Qt(ze(t,4),t.rotation,t.points);if(t.kind==="rect"&&t.width&&t.height&&(n=fn(t.x??0,t.y??0,t.width,t.height)),t.kind==="ellipse"&&t.width&&t.height){let e=(t.x??0)+t.width/2,r=(t.y??0)+t.height/2;n=Nn(e,r,t.width/2,t.height/2)}return n?Qt(n,t.rotation):null}function _t(t){let n=t.role??"",r=n==="stage"?{kind:"stage",heightM:Ze(t.stageKind)}:{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}}[n]??{kind:"plate",heightM:.25};return{...r,heightM:t.heightM??r.heightM}}var ss=.08,as=30,cs=.015;function ls(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[r],i=n[o];s.y>t.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(e=!e)}return e}function Wo(t,n){let e=ct(t)??(t.points?.length?Qt(t.points,t.rotation):null),r=_t(t),s=!t.role&&r.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(pt(e))*$**2>=as?cs:r.heightM;if(!e)return{topOffsetM:s,supportOffsetM:0};if(r.kind!=="plate"&&r.kind!=="stage")return{topOffsetM:s,supportOffsetM:0};let i=1/0,a=1/0,c=-1/0,l=-1/0;for(let h of e)i=Math.min(i,h.x),a=Math.min(a,h.y),c=Math.max(c,h.x),l=Math.max(l,h.y);let u=s,f=0,m=1e-6*Math.max(1,c-i,l-a);for(let h of n)c>h.minX&&i<h.maxX&&l>h.minY&&a<h.maxY&&u<=h.topOffsetM+1e-6&&(u=h.topOffsetM+ss),i>=h.minX-m&&c<=h.maxX+m&&a>=h.minY-m&&l<=h.maxY+m&&(!h.poly||e.every(b=>ls(b,h.poly)||us(b,h.poly,m)))&&(f=Math.max(f,h.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:a,maxX:c,maxY:l,topOffsetM:u,poly:e}),{topOffsetM:u,supportOffsetM:Math.min(f,u)}}function us(t,n,e){for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[o],i=n[r],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l?Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/l)):0;if(Math.hypot(t.x-(s.x+u*a),t.y-(s.y+u*c))<=e)return!0}return!1}function vt(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function bt(t){if(t.length!==4)return t;let n=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y),e=Math.hypot(t[2].x-t[1].x,t[2].y-t[1].y);return n>=e?t:[t[1],t[2],t[3],t[0]]}function dt(t,n,e){return[vt(t[0],t[1],n),vt(t[0],t[1],e),vt(t[3],t[2],e),vt(t[3],t[2],n)]}function mn(t,n,e){return[vt(t[0],t[3],n),vt(t[1],t[2],n),vt(t[1],t[2],e),vt(t[0],t[3],e)]}function ot(t,n,e,r,o,s,i){Z(t,n,i?.length?i:void 0,()=>e,r,o,s,K)}function hn(t){if(t.length<3)return t.map(s=>({...s}));let n=[...t].sort((s,i)=>s.x-i.x||s.y-i.y),e=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),r=s=>{let i=[];for(let a of s){for(;i.length>=2&&e(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),i},o=[...r(n),...r([...n].reverse())];return o.length>=3?o.map(s=>({...s})):n.map(s=>({...s}))}var fs=.8,ms=.6,hs=2;function Nt(t,n){if(!n.length)return null;let e=[],r=0;for(let i of t.objects){if(i.type!=="shape"||i.role!=="wall")continue;let a=ct(i)??[],c=Yo(a)/2;!(c>0)||ps(a)/c*P>hs||(e.push(...a),r+=c)}if(e.length<3)return null;let o=hn(e);if(o.length<3||r<Yo(o)*ms)return null;let s=0;for(let i of n)xs(i,o)&&(s+=1);return s>=n.length*fs?o:null}var Xn=6,ys=5,ds=8;function zo(t){return Math.max(ds,(Number.isFinite(t)?t:0)+ys)}function Jt(t){let n=0,e=0,r=0;for(let o=0;o<t.length;o++){let s=t[o],i=t[(o+1)%t.length],a=s.x*i.y-i.x*s.y;n+=a,e+=(s.x+i.x)*a,r+=(s.y+i.y)*a}if(Math.abs(n)<1e-9){let o=0,s=0;for(let i of t)o+=i.x,s+=i.y;return{x:o/Math.max(1,t.length),y:s/Math.max(1,t.length)}}return{x:e/(3*n),y:r/(3*n)}}function ps(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2}function Yo(t){let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=Math.hypot(o.x-r.x,o.y-r.y)}return n}function xs(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[r],i=n[o];s.y>t.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(e=!e)}return e}var bs=[[/\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"]],gs=1.2,Ms=12;function Ko(t){if(t.heightM!==void 0)return!1;let n=ct(t);if(!n||n.length<3)return!1;let e=0;for(let o=0;o<n.length;o++){let s=n[o],i=n[(o+1)%n.length];e+=Math.hypot(i.x-s.x,i.y-s.y)}return e*$<Ms*2?!1:2*yn(n)/e*$<=gs}function he(t){if(!t)return null;for(let[n,e]of bs)if(n.test(t))return e;return null}var Zo="auto-rows-";function qo(t){return t.id.startsWith(Zo)&&!t.label}var Rs=1.15,Ps=.09,$o=6,Ss=34,Is=.35,_s=6,As=.35,Es=.75,ws=12,Bs=2.5,Ts=40,Os=[18,24],Cs=[12,16],Vo=14,ks=.8,Fs=.6,Ls=5,vs=.3,Qo=.4,Jo=2,Ns=400,Gs=2.6,Ds=.8,Hs=4,Xs=26,js=.7,Us=.5,Ws=.985,Ys=1.5,zs=2.2,Ks=3,Vs=25,Zs=.985,qs=2,$s=6,Qs=3,Js=.1,ta=1.5,na=1.6,ea=6e3,oa=.6,ra="#c3c7cd",ye=300,ia=240;function sa(t,n,e,r){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let o=pe([...n]),s=new Set;for(let u of r)s.add(Math.floor(Math.atan2(u.y-o.y,u.x-o.x)*180/Math.PI/10));if(s.size*10<ia)return null;let{h:i,s:a,l:c}=Je(Qe(t.fill));return i<70/360||i>170/360||a<.2||c<.08||c>.75||e.some(u=>u!==t&&u.type==="shape"&&ct(u)?.some(f=>ge(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var aa="Estimated from the drawing; confirm with the venue.",xe=t=>{if(!t.length)return null;let n=[...t].sort((r,o)=>r-o),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2},pe=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),yn=t=>{let n=0;for(let e=0;e<t.length;e++){let r=t[e],o=t[(e+1)%t.length];n+=r.x*o.y-o.x*r.y}return Math.abs(n)/2};function ca(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function be(t){let n=new Map;for(let e of t){let r=n.get(e.rowId);r?r.push(e):n.set(e.rowId,[e])}return n}function ge(t,n){let e=!1;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[r],i=n[o];s.y>t.y!=i.y>t.y&&t.x<(i.x-s.x)*(t.y-s.y)/(i.y-s.y)+s.x&&(e=!e)}return e}function Me(t,n){let e=n[0],r=1/0;for(let o=0;o<n.length;o++){let s=n[o],i=n[(o+1)%n.length],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l>0?Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/l)):0,f={x:s.x+a*u,y:s.y+c*u},m=Math.hypot(t.x-f.x,t.y-f.y);m<r&&(r=m,e=f)}return e}function tr(t,n){let e=0,r=0;for(let o of t.values()){if(o.length<3)continue;let s=o[0],i=o[o.length-1],a=i.x-s.x,c=i.y-s.y,l=Math.hypot(a,c);if(l<1e-6)continue;let u={x:(s.x+i.x)/2,y:(s.y+i.y)/2},f=Me(u,n),m=f.x-u.x,h=f.y-u.y,d=Math.hypot(m,h);d<1e-6||(r+=Math.abs((-c*m+a*h)/(l*d))*o.length,e+=o.length)}return e?r/e:0}function la(t,n,e){let r=t.filter(y=>y.type==="shape"),o=r.find(y=>y.role==="stage");if(o){let y=ct(o);return y?{shape:o,centre:pe(y),outline:y,inferred:!1}:null}if(!e.length)return null;let s=1/0,i=-1/0,a=1/0,c=-1/0;for(let y of e)s=Math.min(s,y.x),i=Math.max(i,y.x),a=Math.min(a,y.y),c=Math.max(c,y.y);let l=(i-s)*(c-a),u=[];for(let y of r){if(y.role)continue;let b=ct(y);if(!b)continue;let p=yn(b);if(p*$*$<6||p>l)continue;let g=Math.min(...b.map(_=>_.x)),R=Math.max(...b.map(_=>_.x)),A=Math.min(...b.map(_=>_.y)),M=Math.max(...b.map(_=>_.y)),x=0;for(let _ of e)_.x>g&&_.x<R&&_.y>A&&_.y<M&&ge(_,b)&&x++;if(x>e.length*.05)continue;let I=pe(b),S=tr(n,b);S>=ks&&u.push({shape:y,centre:I,outline:b,score:S,area:p,box:[g,A,R,M]})}let f=(y,b)=>b!==y&&b.area>y.area&&y.box[0]>=b.box[0]-1e-6&&y.box[1]>=b.box[1]-1e-6&&y.box[2]<=b.box[2]+1e-6&&y.box[3]<=b.box[3]+1e-6,m=u.filter(y=>!u.some(b=>f(y,b))),h=Math.max(0,...m.map(y=>y.score)),d=m.filter(y=>y.score>=h-.03).sort((y,b)=>b.area-y.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function ua(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let r=Me(t,e);return Math.hypot(t.x-r.x,t.y-r.y)}function nr(t){let n=[...t].sort((s,i)=>s.x-i.x||s.y-i.y);if(n.length<3)return n;let e=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),r=[];for(let s of n){for(;r.length>=2&&e(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}let o=[];for(let s=n.length-1;s>=0;s--){let i=n[s];for(;o.length>=2&&e(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}return[...r.slice(0,-1),...o.slice(0,-1)]}function fa(t){if(!t.length||t.length>ea)return[];let n=[...be(t).values()],e=n.map((a,c)=>c),r=a=>e[a]===a?a:e[a]=r(e[a]),o=na/$,s=n.map(a=>({minX:Math.min(...a.map(c=>c.x))-o,maxX:Math.max(...a.map(c=>c.x))+o,minY:Math.min(...a.map(c=>c.y))-o,maxY:Math.max(...a.map(c=>c.y))+o}));for(let a=0;a<n.length;a++)for(let c=a+1;c<n.length;c++){let l=s[a],u=s[c];if(l.maxX<u.minX||u.maxX<l.minX||l.maxY<u.minY||u.maxY<l.minY)continue;n[a].some(m=>n[c].some(h=>Math.hypot(m.x-h.x,m.y-h.y)<=o))&&(e[r(a)]=r(c))}let i=new Map;return n.forEach((a,c)=>{let l=r(c),u=i.get(l);u?u.push(...a):i.set(l,[...a])}),[...i.values()].filter(a=>new Set(a.map(c=>c.rowId)).size>=2)}function ma(t,n,e){if(!n.length)return null;let r=n.filter(S=>e.tableIds.has(S.rowId)||S.kind==="booth").length>n.length/2,o=be(n),s=!e.outline||tr(o,e.outline)>=Fs,i=0,a=0;for(let S of o.values()){if(S.length<2)continue;let _=S[0],O=S[S.length-1],C=O.x-_.x,F=O.y-_.y,k=Math.hypot(C,F);if(k<1e-6)continue;let E={x:(_.x+O.x)/2,y:(_.y+O.y)/2},w=s?e.outline?Me(E,e.outline):e.focal:e.middle,B=-F/k,L=C/k;B*(w.x-E.x)+L*(w.y-E.y)<0&&(B=-B,L=-L),i+=B*S.length,a+=L*S.length}let c={x:n.reduce((S,_)=>S+_.x,0)/n.length,y:n.reduce((S,_)=>S+_.y,0)/n.length};if(Math.hypot(i,a)<1e-9){let S=s?e.focal:e.middle;i=S.x-c.x,a=S.y-c.y}let l=Math.hypot(i,a)||1,u={x:i/l,y:a/l},f=S=>-(S.x*u.x+S.y*u.y),m=S=>-S.x*u.y+S.y*u.x,h=1/0,d=-1/0,y=1/0,b=-1/0,p=1/0,g=new Map;for(let S of n){let _=f(S),O=m(S);h=Math.min(h,_),d=Math.max(d,_),y=Math.min(y,O),b=Math.max(b,O),s&&(p=Math.min(p,ua(S,e.focal,e.outline)));let C=S.logicalRowId??S.rowId,F=g.get(C);F?F.push(_):g.set(C,[_])}s||(p=Math.max(0,h-f(e.middle)));let R=[...g.values()].map(S=>xe(S)).sort((S,_)=>S-_),A=[];if(!r)for(let S of R)A.length&&S-A[A.length-1]<As/$||A.push(S);let M=ca(t),x=Vt(t,{floorBaseHeightM:e.baseHeightM}),I={id:t.id,section:t,authored:M,plane:e,facing:u,facesAction:s,hull:nr(n),sample:n.filter((S,_)=>_%Math.ceil(n.length/Ns)===0),frontD:h,backD:d,latMin:y,latMax:b,frontDistance:p,rowDepths:A,rowCount:A.length,level:0,height:x.height,rake:M?x.rake:0,backHeight:0};return I.backHeight=I.height+(d-h)*$*Math.tan(I.rake*Math.PI/180),I}function ha(t,n,e,r){if(t.length<2)return 0;let o=Math.max(1,n*$),s=e+Rs-r,i=0,a=0;for(let l=1;l<t.length;l++){let u=Math.max(Es,(t[l]-t[l-1])*$),f=(s+Ps)*(o+u)/o;i+=f-s,a+=u,s=f,o+=u}let c=Math.atan(i/a)*180/Math.PI;return Math.round(Math.max($o,Math.min(Ss,c))*10)/10}function ya(t,n,e=!1){if(!e&&t.facing.x*n.facing.x+t.facing.y*n.facing.y<vs)return null;let r=-1/0,o=1/0,s=-1/0;for(let m of n.hull){r=Math.max(r,-(m.x*t.facing.x+m.y*t.facing.y));let h=-m.x*t.facing.y+m.y*t.facing.x;o=Math.min(o,h),s=Math.max(s,h)}if(Math.min(t.latMax,s)-Math.max(t.latMin,o)<(e?1e-6:Qo*(t.latMax-t.latMin)))return null;let a=Jo/$,c=new Map,l=new Map;for(let m of t.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/a),d=-(m.x*t.facing.x+m.y*t.facing.y);c.set(h,Math.min(c.get(h)??1/0,d))}for(let m of n.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/a),d=-(m.x*t.facing.x+m.y*t.facing.y);l.set(h,Math.max(l.get(h)??-1/0,d))}let u=[];for(let[m,h]of c){let d=l.get(m);d!==void 0&&u.push(h-d)}let f=u.length?xe(u):t.frontD-r;return f<-1/$?null:f}function da(t,n){if(n.plane.floorIndex>=t.plane.floorIndex)return!1;let e=-1/0,r=1/0,o=1/0,s=-1/0;for(let c of n.hull){let l=-(c.x*t.facing.x+c.y*t.facing.y);e=Math.max(e,l),r=Math.min(r,l);let u=-c.x*t.facing.y+c.y*t.facing.x;o=Math.min(o,u),s=Math.max(s,u)}let i=Math.min(t.latMax,s)-Math.max(t.latMin,o),a=Math.min(t.backD,e)-Math.max(t.frontD,r);return i>Qo*(t.latMax-t.latMin)&&a>1/$}function pa(t,n){let e=new Set;for(let r of t){let o=(Math.atan2(r.y-n.y,r.x-n.x)*180/Math.PI+360)%360;e.add(Math.floor(o/10))}return e.size/36}function xa(t,n){let e=1/0,r=-1/0;for(let s of n.hull){let i=-(s.x*t.facing.x+s.y*t.facing.y);e=Math.min(e,i),r=Math.max(r,i)}let o=Math.max(0,Math.min(r-e,t.frontD-e));return n.height+o*$*Math.tan(n.rake*Math.PI/180)}function ba(t,n){if(!t.facesAction)return!1;let e={x:-t.facing.y,y:t.facing.x},r=Jo/$,o=Math.max(1,Math.ceil((t.backD-t.frontD)/r)),s={left:new Map,right:new Map};for(let a of n)if(!(a===t||a.plane.floorIndex!==t.plane.floorIndex)&&!(a.facing.x*t.facing.x+a.facing.y*t.facing.y>=Ws))for(let c of a.sample){let l=-(c.x*t.facing.x+c.y*t.facing.y);if(l<t.frontD||l>t.backD)continue;let u=-c.x*t.facing.y+c.y*t.facing.x,f=u<t.latMin?"left":u>t.latMax?"right":null;if(!f)return!1;let m=Math.min(o-1,Math.floor((l-t.frontD)/r)),h=f==="left"?t.latMin-u:u-t.latMax;h<(s[f].get(m)?.gap??1/0)&&s[f].set(m,{gap:h,other:a})}let i=a=>{let c=a==="left"?t.latMin:t.latMax,l=0;for(let[u,{other:f}]of s[a]){if((f.facing.x*e.x+f.facing.y*e.y)*(a==="left"?1:-1)<js)continue;let h=t.frontD+(u+.5)*r,d={x:-h*t.facing.x+c*e.x,y:-h*t.facing.y+c*e.y},y=-(d.x*f.facing.x+d.y*f.facing.y),b=-d.x*f.facing.y+d.y*f.facing.x;y<f.frontD&&b>=f.latMin&&b<=f.latMax&&l++}return l/o>=Us};return i("left")&&i("right")}function ga(t,n){if(n.plane.floorIndex!==t.plane.floorIndex||n.facing.x*t.facing.x+n.facing.y*t.facing.y<Zs)return!1;let e=1/0,r=-1/0,o=1/0;for(let a of n.hull){let c=-a.x*t.facing.y+a.y*t.facing.x;e=Math.min(e,c),r=Math.max(r,c),o=Math.min(o,-(a.x*t.facing.x+a.y*t.facing.y))}let s=(t.frontD-o)*$;if(s<-qs||s>$s)return!1;let i=Math.max(e-t.latMax,t.latMin-r);return i*$<=Qs&&i*$>=-Js}function Ma(t,n=!1,e=!1,r){let o=n?Cs:Os,s=new Set(e?[]:t.filter(y=>!y.authored&&ba(y,t))),i=[...t].sort((y,b)=>y.plane.floorIndex-b.plane.floorIndex||Number(s.has(b))-Number(s.has(y))||y.frontDistance-b.frontDistance);for(let y of s)r?.add(y.id);let a=(y,b,p)=>{let g=new Map,R=[],A=new Map,M=x=>{if(x.plane.floorIndex===0||x.plane.baseHeightM>0)return x.plane.baseHeightM;let I=A.get(x.plane.floorIndex-1);return I===void 0?x.plane.baseHeightM:I+fo};for(let x of i){if(s.has(x))x.height=M(x),x.level=0,x.rake=0,x.backHeight=x.height,g.set(x.id,void 0);else if(!x.authored){let S=M(x),_;for(let E of R){if(E.plane.floorIndex>x.plane.floorIndex)continue;if(da(x,E)){let T=xa(x,E)+Gs;T>S&&(S=T,_=E);continue}let w=ya(x,E,s.has(E));if(w==null)continue;let B=e&&!!x.plane.stageDeck&&E.level===0&&E.plane.floorIndex===x.plane.floorIndex&&Math.max(0,w)*$<=Hs,L=s.has(E)?E.height+Ys:B?E.backHeight:E.backHeight+Is+Math.min(_s,Math.max(0,w)*$)*Math.tan(E.rake*Math.PI/180);L>S&&(S=L,_=E)}let O=y.get(x);O&&O.height>S+.01?(S=O.height,_=void 0):O=void 0,x.height=Math.round(Math.min(S,x.plane.baseHeightM+Ts)*100)/100;let C=!_&&!O&&x.height>x.plane.baseHeightM;if(x.level=_?_.level+1:O?O.level:C?1:0,x.rake=ha(x.rowDepths,x.frontDistance,x.height,x.plane.focalHeightM),!x.facesAction&&x.rowCount<Ls)x.rake=0;else if(x.level===0){let E=Math.max(1e-6,(x.backD-x.frontD)*$);x.rake=Math.min(x.rake,ws,Math.round(Math.atan(Bs/E)*1800/Math.PI)/10)}else x.rowCount>=2&&(x.rake=Math.max(x.rake,o[Math.min(x.level,o.length)-1]));let F=(x.backD-x.frontD)*$,k=_&&s.has(_)||O&&p?.has(O.id);if(b!==void 0&&k&&x.rowCount>=2&&(x.rake=b),n&&F>0&&x.height+F*Math.tan(x.rake*Math.PI/180)>x.plane.baseHeightM+Vo){let E=Math.max(0,x.plane.baseHeightM+Vo-x.height);x.rake=Math.max($o,Math.round(Math.atan(E/F)*1800/Math.PI)/10)}e&&x.plane.stageDeck&&x.level>0&&(x.rake=Math.min(x.rake,Xs)),x.backHeight=x.height+F*Math.tan(x.rake*Math.PI/180),g.set(x.id,_?.id??(O?g.get(O.id):void 0))}let I=x.plane.floorIndex;A.set(I,Math.min(A.get(I)??1/0,x.height)),R.push(x)}return g},c=a(new Map),l=new Map,u=y=>l.get(y)?.height??y.height;for(let y=!0,b=0;y&&b<t.length;b++){y=!1;for(let p of t)if(!(p.authored||s.has(p)))for(let g of t){let R=l.get(g)??g;g===p||R.height-R.plane.baseHeightM<ta||R.height<=u(p)+.01||ga(p,g)&&(l.set(p,R),y=!0)}}let f=new Map(t.map(y=>[y.id,y])),m=t.filter(y=>!y.authored&&y.rowCount>=2&&s.has(f.get(c.get(y.id)??""))),h=m.length?xe(m.map(y=>y.rake)):void 0;if(!l.size&&h===void 0)return c;let d=new Map([...new Set(l.values())].map(y=>[y,{...y}]));return a(new Map([...l].map(([y,b])=>[y,d.get(b)])),h,new Set(m.map(y=>y.id)))}var de=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function er(t,n={x:0,y:-40}){let e=En(t),r=new Map;for(let p of e){if(!p.sectionId)continue;let g=r.get(p.sectionId);g?g.push(p):r.set(p.sectionId,[p])}let o={focalInferred:!1,confident:!1,sections:[]},s=t.floors?.length?t.floors.map((p,g)=>({objects:p.objects,floorIndex:g,floorId:p.id,baseHeightM:p.baseHeightM??0,focal:p.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(s.flatMap(p=>p.objects.filter(g=>g.type==="table").map(g=>g.id))),a=[],c,l=new Set,u=s.map(p=>{let g=k=>!t.floors?.length||k.floorId===p.floorId,R=fa(e.filter(k=>!k.sectionId&&k.kind!=="booth"&&!i.has(k.rowId)&&g(k))),A=[];for(let k of R){let E=It(wt(nr(k)),oa/$);if(e.some(B=>!g(B)&&ge(B,E)))continue;let w=`${Zo}${p.floorIndex}-${A.length}`;l.add(w),r.set(w,k),A.push({type:"section",id:w,label:"",color:ra,outline:E})}let M=A.length?{...p,objects:[...p.objects,...A]}:p,x=new Set(M.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),I=[...r.entries()].filter(([k])=>x.has(k)).flatMap(([,k])=>k),S=la(M.objects,be(I),I),_=M.focal;(S||M.focal&&!de(M.focal,n))&&(o.confident=!0),S&&(o.stage??={id:S.shape.id,inferred:S.inferred,...M.floorId?{floorId:M.floorId}:{}},(S.inferred||de(M.focal,n))&&(_=S.centre,o.focalInferred=!0));let O=S&&(!S.inferred||yn(S.outline)*$*$<=ye),C=S?void 0:c,F={tableIds:i,floorIndex:M.floorIndex,floorId:M.floorId,baseHeightM:M.baseHeightM,focal:C?.focal??_,outline:S?.outline??C?.outline,focalHeightM:C?.focalHeightM??M.baseHeightM+(S&&O?_t({...S.shape,role:"stage"}).heightM:0),stageDeck:C?.stageDeck??!!(S&&O&&yn(S.outline)*$*$<=ye),middle:I.length?{x:I.reduce((k,E)=>k+E.x,0)/I.length,y:I.reduce((k,E)=>k+E.y,0)/I.length}:_};for(let k of M.objects){if(k.type!=="section")continue;let E=ma(k,r.get(k.logicalSectionId??k.id)??[],F);E&&a.push(E)}return F.outline&&(c=F),de(M.focal,F.focal)||(o.focal??=[]).push({...M.floorId?{floorId:M.floorId}:{},point:{...F.focal}}),{unit:M,plane:F,stage:S,planeSeats:I}}),f=s.flatMap(p=>p.objects).map(p=>p.type==="shape"&&!p.role&&(he(p.label)==="wall"||!he(p.label)&&Ko(p))?{...p,role:"wall"}:p),m=Nt({objects:f},e)!==null;m&&(o.indoor=!0);let h=new Set,d=Ma(a,m,pa(e,u[0]?.plane.focal??n)<Ds,h),y=new Map(a.filter(p=>!p.authored).map(p=>[p.id,p])),b=u.map(({unit:p,plane:g,stage:R,planeSeats:A})=>p.objects.map(M=>{let x=M.type==="shape"&&!M.role&&M.id!==R?.shape.id?he(M.label):null;if(M.type==="shape"&&!M.role&&M.id!==R?.shape.id&&(x==="wall"||!x&&Ko(M))&&M.type==="shape"){(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:"wall"});let{fill:E,...w}=M;return{...w,role:"wall"}}if(x&&M.type==="shape")return(o.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:x}),{...M,role:x};let S=R?.inferred&&M.id===R.shape.id&&M.type==="shape"?sa(M,R.outline,p.objects,A):null;if(S&&M.type==="shape")return o.stage?.id===M.id&&(o.stage.field=S),{...M,role:"stage",stageKind:S};let _=M.type==="shape"&&M.id===R?.shape.id&&M.heightM===void 0&&!M.stageKind&&a.some(E=>E.plane===g&&(h.has(E.id)||E.level===0&&E.facesAction&&E.rake<=Ks&&(E.frontDistance+E.backD-E.frontD)*$>=Vs)),O=_?{heightM:zs}:{};if(R?.inferred&&M.id===R.shape.id&&M.type==="shape"&&yn(R.outline)*$*$<=ye)return o.stage?.id===M.id&&(o.stage.deck=!0),{...M,role:"stage",...O};if(_&&M.type==="shape"&&M.role==="stage")return{...M,...O};let C=M.type==="section"?y.get(M.id):void 0;if(!C||M.type!=="section")return M;let F=C.rowCount>=2&&C.rake>0;l.has(C.id)?o.looseRowBlocks=(o.looseRowBlocks??0)+1:o.sections.push({id:C.id,floorId:g.floorId,surfaceKind:F?"rakedRows":"flat",height:C.height,rake:C.rake,stackedOn:d.get(C.id)});let k={status:"inferred",source:"public-2d-topology",note:aa};return{...M,height:C.height,rake:C.rake,surfaceKind:F?"rakedRows":"flat",physical3dProvenance:{height:k,rake:k,surfaceKind:k}}}));if(t.floors?.length){let p=t.floors.map((g,R)=>({...g,objects:b[R],focalPoint:u[R].plane.focal}));return{doc:{...t,floors:p,objects:p[0].objects,focalPoint:p[0].focalPoint},report:o}}return{doc:{...t,objects:b[0],focalPoint:u[0].plane.focal},report:o}}function lf(t,n,e){return e<0?n>1?t.filter(r=>r.kind==="floor"):[...t]:t.filter(r=>r.floorIndex===void 0||r.floorIndex===e)}function uf(t,n){let e=[...t].sort((o,s)=>o.screen.y-s.screen.y),r=[];for(let o of e){let s=r.find(i=>i.some(a=>Math.abs(a.screen.x-o.screen.x)<104&&Math.abs(a.screen.y-o.screen.y)<34));s?s.push(o):r.push([o])}return r.flatMap(o=>o.length<2?o:o.map((s,i)=>({...s,screen:{...s.screen,x:Math.max(54,Math.min(n-54,s.screen.x+(i-(o.length-1)/2)*104))}})))}var Ra=1.15,Pa=2.75,Sa=4.5,Ia=.85,_a=.5,Aa=.26;function ff(t,n,e){let r=Math.max(1e-6,n),o=t/r,s=e?.hasZoneLabels??!0,i=new Set(["stage","gate"]);return o>=.75&&i.add("floor"),o>=Ra&&i.add("zone"),o<=(s?Pa:Sa)&&(i.add("section"),i.add("ga")),o<=Ia&&(i.add("annotation"),i.add("booth")),o<=_a&&i.add("row"),o<=Aa&&i.add("seat"),i}function mf(t,n,e,r,o,s=6){let i=s+n,a=r-s-n,c=s+e,l=o-s-e;return{...t,x:i>a?r/2:Math.max(i,Math.min(a,t.x)),y:c>l?o/2:Math.max(c,Math.min(l,t.y))}}function hf(t,n,e,r){let o=t,s=n[0],i=n[1],a=n[2],c=o[0]*s+o[4]*i+o[8]*a+o[12],l=o[1]*s+o[5]*i+o[9]*a+o[13],u=o[2]*s+o[6]*i+o[10]*a+o[14],f=o[3]*s+o[7]*i+o[11]*a+o[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=c/f,h=l/f,d=u/f,y=m>=-1.05&&m<=1.05&&h>=-1.05&&h<=1.05&&d<=1;return{x:(m*.5+.5)*e,y:(1-(h*.5+.5))*r,depth:d,visible:y}}function yf(t,n,e=n,r=()=>0){let o=[],s=[...t].sort((i,a)=>r(a)-r(i)||i.screen.depth-a.screen.depth);for(let i of s){let a=!1;for(let c of o)if(Re(i,c,n,e)){a=!0;break}a||o.push(i)}return o}var Ea=6;function Re(t,n,e,r){let o=Math.abs(t.screen.x-n.screen.x),s=Math.abs(t.screen.y-n.screen.y),i=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+Ea):e;return o<i&&s<r}function df(t,n,e){return t.length*n*.58+(e?14:0)}var wa={row:8,seat:14};function pf(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:wa}function xf(t,n,e,r){let o=Math.max(1,Math.min(e,r)*.5),s=Math.min(2,Math.hypot(t.x-e/2,t.y-r/2)/o);return n*(1+1.5*s)}function bf(t,n,e,r,o=[]){let s=[...t].sort((a,c)=>(c.priority??0)-(a.priority??0)||a.focus-c.focus),i=[];for(let a of s){if(i.length>=r)break;let c=!1;for(let l of o)if(Re(a,l,n,e)){c=!0;break}if(!c){for(let l of i)if(Re(a,l,n,e)){c=!0;break}}c||i.push(a)}return i}function gf(t,n,e,r){let o=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15];return o<=0||!(e>0)?0:e*Math.hypot(t[0],t[4],t[8])*r/(2*o)}function tn(t,n,e){if(t.length!==4||e<=n)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P,s=Math.hypot(r[3].x-r[0].x,r[3].y-r[0].y)*P;if(o<1e-6||s<1e-6)return null;let i=Math.min(.22/o,.16),a=Math.min(.28,(e-n)*.13),c=Math.min(.065/s,.2);return{quad:r,side:i,face:c,opening:dt(r,i,1-i),openingTop:e-a}}function Pe(t,n,e){if(t.length!==4||e-n<=.2)return null;let r=bt(t),o=Math.hypot(r[1].x-r[0].x,r[1].y-r[0].y)*P;if(o<=1e-6)return null;let s=Math.min(.14,(e-n)*.08,o*.08),i=s/o,a=dt(r,i,1-i);return{quad:r,side:i,trim:s,inner:a,panel:mn(a,.15,.85),bottom:n+s,top:e-s}}function or(t,n,e,r){let o=Pe(t,n,e);if(!o)return;let{panel:s}=o,i=(g,R)=>({x:(g.x+R.x)/2,y:(g.y+R.y)/2}),a=i(s[0],s[1]),c=i(s[3],s[2]),l=Math.hypot(a.x-r.x,a.y-r.y)<=Math.hypot(c.x-r.x,c.y-r.y),[u,f]=l?[s[0],s[1]]:[s[3],s[2]],m=l?{x:a.x-c.x,y:a.y-c.y}:{x:c.x-a.x,y:c.y-a.y},h=Math.hypot(m.x,m.y);if(h<1e-6)return;-(f.y-u.y)*m.x+(f.x-u.x)*m.y<0&&([u,f]=[f,u]);let d=Math.min(.006,h*P*.05),y=m.x/h*d,b=m.y/h*d,p=(g,R)=>[g.x*P+y,R,g.y*P+b];return[p(u,o.bottom),p(f,o.bottom),p(u,o.top),p(f,o.top)]}import Ta from"polygon-clipping";import Ba from"polygon-clipping";function Ot(t,n,e,r,o,s,i,a={}){let c=Tt(n),l=a.ao??K,u=o.flatMap(y=>{if(y.role!=="entrance"&&y.role!=="exit")return[];let b=ct(y);if(!b||b.length!==4||!qt(c,Tt(b)))return[];let p=a.portalBase??e,g=tn(b,p,p+_t(y).heightM);if(!g)return[];let R=Math.min(r,g.openingTop);return R<=e?[]:[{poly:g.opening,height:R}]});if(!u.length)return!1;let f=y=>y.map(b=>[b.x,b.y]),m=[f(n),...(a.holes??[]).map(f)],h=[e,...new Set(u.map(y=>y.height)),r].sort((y,b)=>y-b),d=[];try{for(let y=1;y<h.length;y++){let b=h[y-1],p=h[y];if(p-b<1e-6)continue;let g=u.filter(A=>A.height>b+1e-6).map(A=>[f(A.poly)]),R=g.length?Ba.difference(m,...g):[m];d.push({low:b,high:p,polys:R})}}catch{return!1}for(let y of d)for(let b of y.polys){let[p,...g]=b.map(A=>A.map(([M,x])=>({x:M,y:x}))),R=A=>l.wallBottom+(l.top-l.wallBottom)*(A-e)/(r-e);Z(t,p,g,()=>y.high,y.low,s,i,{...l,top:R(y.high),wallBottom:R(y.low)})}return!0}var Se={depthM:1.6,thicknessM:.35,minWallM:6};function jn(t,n,e,r,o,s,i,a,c){let l=r-e;if(l<=0)return;let u=a&&(c??l)>=Se.minWallM?Oa(n,a):null,f=u?r-Se.thicknessM:r,m=f-e,h=m<1.5?[[e,f,1]]:u?[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f,1]]:[[e,e+Math.min(.9,m*.18),.82],[e+Math.min(.9,m*.18),f-.1,1],[f-.1,f,1.1]],d=y=>K.wallBottom+(K.top-K.wallBottom)*(y-e)/l;for(let[y,b,p]of h){let g={...K,top:d(b),wallBottom:d(y)},R=V(s,p),A=V(i,p);Ot(t,n,y,b,o,R,A,{portalBase:e,ao:g})||Z(t,n,void 0,()=>b,y,R,A,g)}for(let[y,...b]of u??[])Z(t,y,b.length?b:void 0,()=>r,f,V(s,1.12),V(i,.78),K)}function Oa(t,n){let e=Se.depthM/P,r=t.map(i=>{let a=n.x-i.x,c=n.y-i.y,l=Math.hypot(a,c)||1;return{x:i.x+a/l*e,y:i.y+c/l*e}}),o=i=>{let a=i.map(c=>[c.x,c.y]);return a.push(a[0]),a},s=[[o(t)],[o(r)]];for(let i=0;i<t.length;i++){let a=(i+1)%t.length;s.push([o([t[i],t[a],r[a],r[i]])])}try{let[i,...a]=s,c=Ta.union(i,...a);return c.length?c.map(l=>l.map(u=>u.slice(0,-1).map(([f,m])=>({x:f,y:m})))):null}catch{return null}}function dn(t,n,e){let r=it(n.stroke?.color),o=n.stroke?.width??0;if(!r||!Number.isFinite(o)||o<=0)return;let s=n.kind==="line"||n.kind==="polyline",i=s?Qt(n.points??[],n.rotation):ct(n);if(!i||i.length<2)return;let a=o*.5,c=io(n)?ao(i,...so(o)):Array.from({length:s?i.length-1:i.length},(l,u)=>[i[u],i[(u+1)%i.length]]);for(let[l,u]of c){let f=Math.hypot(u.x-l.x,u.y-l.y);if(f<1e-6)continue;let m=-(u.y-l.y)/f*a,h=(u.x-l.x)/f*a,d=[(l.x+m)*P,e,(l.y+h)*P],y=[(u.x+m)*P,e,(u.y+h)*P],b=[(u.x-m)*P,e,(u.y-h)*P],p=[(l.x-m)*P,e,(l.y-h)*P];t.tri(d,y,b,[0,1,0],r),t.tri(d,b,p,[0,1,0],r)}}function rr(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var nn=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function Un(t,n,e,r){let[o,s,i,a]=n?t:[t[3],t[2],t[1],t[0]];return[nn(o,a,e),nn(s,i,e),nn(s,i,r),nn(o,a,r)]}function ir(t,n,e,r,o,s,i,a,c=!1){if(e.length!==4||o-r<.4)return!1;let l=S=>c?Math.min(S,o):S,u=bt(e),f=Math.hypot(u[3].x-u[0].x,u[3].y-u[0].y)*P;if(f<.4)return!1;let m=nn(u[0],u[1],.5),h=nn(u[3],u[2],.5),d=Math.hypot(m.x-a.x,m.y-a.y)<=Math.hypot(h.x-a.x,h.y-a.y),y=at(i,[.92,.9,.86],.35),b=V(s,.72),p=o-r;if(n==="restroom"){let S=Math.min(.18,p*.08);return ot(t,u,o-S,r,i,s),ot(t,u,o,o-S,y,y),!0}let g=r+Math.min(1.1,p),R=n==="coat"?1:Math.min(.5,.75/f),A=Un(u,d,0,R);if(ot(t,A,g-.05,r,b,s),ot(t,A,g,g-.05,y,y),n==="coat"||f<1.2)return!0;if(n==="bar"){let S=Un(u,d,Math.max(R+.2,1-.45/f),1),_=l(r+Math.max(Math.min(2.2,p*2),g-r+.6));return ot(t,S,_,r,i,b),!0}let M=Un(u,d,Math.max(R+.25,.55),1),x=l(r+Math.max(2.6,g-r+1.4));if(x-.14<=g)return!0;ot(t,M,x-.14,r,i,s),ot(t,u,x,x-.14,y,b);let I=Math.min(.08,.1/Math.max(.1,Math.hypot(u[1].x-u[0].x,u[1].y-u[0].y)*P));for(let[S,_]of[[0,I],[1-I,1]])ot(t,Un(dt(u,S,_),d,0,Math.min(.08,.1/f)),x-.14,g,b,b);return!0}var Gt=.06,Ca=.05,ar=.05,sr=.15,Ie=25;function cr(t,n,e){let r=new Map,o=new Array(n.length).fill(null),s=new Float64Array(n.length),i=new Array(n.length).fill(void 0),a=new Array(n.length).fill(void 0),c=new Map,l=[],u=new Set;for(let m=0;m<t.length;m+=1){let h=t[m];for(let d of h.objects){if(d.type==="table"&&u.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let y=It(d.outline,St);c.set(d.id,{section:d,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:d.id,floorIndex:m,box:Tt(y),section:d,unit:h,outline:y})}}let f=new Map;for(let m of l){let h=f.get(m.floorIndex);h?h.push(m):f.set(m.floorIndex,[m])}for(let m=0;m<n.length;m++){let h=n[m],d=e?f.get(e[m])??[]:l,y=h.sectionId?d.find(p=>p.id===h.sectionId)??d.find(p=>p.section.logicalSectionId===h.sectionId&&Pt({x:h.x,y:h.y},p.outline,p.section.holes)):void 0,b=y?[y]:d;for(let p of b){if(e&&p.floorIndex!==e[m]||!y&&(h.x<p.box.minX||h.x>p.box.maxX||h.y<p.box.minY||h.y>p.box.maxY||!Pt({x:h.x,y:h.y},p.outline,p.section.holes)))continue;o[m]=p.id;let g=c.get(p.id);g.hasSeats=!0;let R=h.focalPoint??p.unit.focal,A=Math.hypot(h.x-R.x,h.y-R.y);A<g.frontU&&(g.frontU=A),g.seatIndices.push(m);let M=h.rowId||`__seat-${m}`,x=g.rows.get(M);x?x.push({x:h.x,y:h.y}):g.rows.set(M,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let d=Vt(h.section,{floorBaseHeightM:h.unit.baseHeightM}),y=h.unit.baseHeightM,b=d.rake>0?Math.tan(d.rake*Math.PI/180):0,p=d.rake<=.01&&d.height<=y+.001,g=h.section.surfaceKind,R=g==="flat"?!0:g==="rakedRows"&&d.rake>.01?!1:p,A=h.hasSeats?Ve(m,n,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},x=A.rows.length<2?co([...h.rows.values()].map(T=>({points:T})),h.unit.focal):null,I=1/0;if(x){if(h.hasSeats)for(let T of h.rows.values())for(let v of T){let H=x.depthAt(v.x,v.y);H<I&&(I=H)}if(!h.hasSeats||!Number.isFinite(I)){I=1/0;for(let T of h.section.outline){let v=x.depthAt(T.x,T.y);v<I&&(I=v)}}}let S=y+Ca,_=Math.max(S,d.height),O=T=>{let v=Math.max(0,T-I)*$,H=Math.min(v*b,Ie);return Math.max(S,d.height+H)},C=T=>{let v=Math.max(0,T)*$,H=Math.min(v*b,Ie);return Math.max(S,d.height+H)},F=R?[]:A.rows.map(T=>({pts:T.pts,y:C(T.blockDepth),depth:T.blockDepth,blockId:T.blockId,...u.has(T.id)?{patch:Oo(T.pts,St)}:{}})),k=F.length?F[0].y:_,E=F.map(T=>{let v=T.patch&&T.patch.length>=3?T.patch:T.pts,H=0,j=0;for(let X of v)H+=X.x,j+=X.y;let D=v.length||1;H/=D,j/=D;let U=0;for(let X of v){let Y=Math.hypot(X.x-H,X.y-j);Y>U&&(U=Y)}return{cx:H,cy:j,rad:U}}),w=R?()=>_:F.length>=2?(T,v)=>{let H=1/0,j=k;for(let D=0;D<F.length;D++){let U=E[D];if(Math.hypot(T-U.cx,v-U.cy)-U.rad>=H)continue;let X=F[D].patch,Y=X&&X.length>=3?xt(X,T,v)?0:_n(X,T,v):_n(F[D].pts,T,v);Y<H&&(H=Y,j=F[D].y)}return j}:(T,v)=>x?O(x.depthAt(T,v)):_,B=[0,1,0],L=F.length>=2||R?()=>B:(T,v)=>{if(!x)return B;let H=x.depthAt(T,v);if(H<=I)return B;let j=(H-I)*$;if(j*b>=Ie||d.height+j*b<=S)return B;let[D,U]=x.gradientAt(T,v);if(D===0&&U===0)return B;let X=1/Math.hypot(b,1);return[-D*b*X,X,-U*b*X]};if(!R)for(let T of A.rows){let v=C(T.blockDepth);for(let H of T.seatIndices)i[H]=v}for(let T of A.rows){let v=[];for(let X=1;X<T.pts.length;X++){let Y=Math.hypot(T.pts[X].x-T.pts[X-1].x,T.pts[X].y-T.pts[X-1].y);Y>1e-6&&v.push(Y)}v.sort((X,Y)=>X-Y);let H=v.length?v[Math.floor(v.length/2)]:1/0,j=1/0,D=T.pts[Math.floor(T.pts.length/2)];if(D)for(let X of A.rows){if(X===T||X.blockId!==T.blockId)continue;let Y=_n(X.pts,D.x,D.y);Y>1e-6&&Y<j&&(j=Y)}let U=Math.min(H,Math.max(j,H*.5));if(Number.isFinite(U)&&U>0)for(let X of T.seatIndices)a[X]=U}r.set(m,{sectionId:m,deckAt:w,normalAt:L,flat:R,bottomY:y,rowLevels:F,landingY:k})}for(let m=0;m<n.length;m++){let h=o[m],d=n[m];if(h){let p=i[m];s[m]=(p??r.get(h).deckAt(d.x,d.y))+sr;continue}let y=d.eyeHeightM,b=Number.isFinite(y)?Math.max(0,y-In):0;s[m]=d.kind==="booth"?b+Gt+sr:b}return{bySection:r,seatOwner:o,seatDeckY:m=>s[m],seatPitchU:m=>a[m]}}var ka=[.12,.38,.16],Fa=[.72,.62,.45],La=[.88,.93,.96],lr=[.95,.95,.94],va=[.66,.29,.22],_e={length:20.12,width:3.05},Na=.14,Ga=9.76,Ct=[.93,.94,.95],Wn=[.1,.11,.13],Da=[.45,.85,1.25],Ha=1.45,ur=.012,fr=.004,Xa=1.07,ja=.15;function on(t,n,e,r,o,s){t.setMaterial(s),Z(t,n,e?[e.slice().reverse()]:void 0,()=>r,r-.004,o,o,K)}var mr=(t,n)=>Lt(t,n/P);function hr(t,n,e){let r=n.x-t.x,o=n.y-t.y,s=Math.hypot(r,o);if(s<1e-9)return null;let i=-o/s*e,a=r/s*e;return[{x:t.x+i,y:t.y+a},{x:n.x+i,y:n.y+a},{x:n.x-i,y:n.y-a},{x:t.x-i,y:t.y-a}]}function Ua(t,n,e,r){let o=n.map(s=>[s.x*P,e,s.y*P]);t.tri(o[0],o[1],o[2],[0,1,0],r),t.tri(o[0],o[2],o[3],[0,1,0],r)}function Yn(t,n,e,r,o,s){let i=e/P,a=[{x:n.x-i,y:n.y-i},{x:n.x+i,y:n.y-i},{x:n.x+i,y:n.y+i},{x:n.x-i,y:n.y+i}];Z(t,a,void 0,()=>o,r,s,V(s,.85),K)}function en(t,n,e,r,o,s,i){let a=hr(n,e,r/P);a&&Z(t,a,void 0,()=>s,o,i,V(i,.85),K)}function zn(t){let n=bt(t),e={x:(n[0].x+n[2].x)/2,y:(n[0].y+n[2].y)/2},r=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y)||1,o=Math.hypot(n[3].x-n[0].x,n[3].y-n[0].y)||1,s={x:(n[1].x-n[0].x)/r,y:(n[1].y-n[0].y)/r},i={x:(n[3].x-n[0].x)/o,y:(n[3].y-n[0].y)/o};return{at:(c,l)=>({x:e.x+(s.x*c+i.x*l)/P,y:e.y+(s.y*c+i.y*l)/P}),lengthM:r*P,widthM:o*P}}function yr(t,n,e){let r=qe(n);if(!r.length)return;let o=1/0,s=-1/0,i=1/0,a=-1/0;for(let R of n.points??[])o=Math.min(o,R.x),s=Math.max(s,R.x),i=Math.min(i,R.y),a=Math.max(a,R.y);let c=(n.rotation??0)*Math.PI/180,l=Math.cos(c),u=Math.sin(c),f=(o+s)/2,m=(i+a)/2,h=R=>c?{x:f+(R.x-f)*l-(R.y-m)*u,y:m+(R.x-f)*u+(R.y-m)*l}:R,d=Math.min(s-o,a-i)*P,y=Math.max(.04,Math.min(.3,d*.004))/P,b=0;t.setMaterial(0);for(let R of r){if(!R.fill)continue;let A=R.points.map(h);on(t,A,null,e+ur+b*fr,it(R.fill)??Ct,0),b++}let p=r.filter(R=>!(R.fill&&R.ink===R.fill)),g=[...new Set(p.map(R=>R.ink??ee))];for(let R of g){let A=e+ur+b++*fr,M=it(R)??Ct;for(let x of p){if((x.ink??ee)!==R)continue;let I=x.points.map(h),S=x.closed?I.length:I.length-1;for(let _=0;_<S;_++){let O=hr(I[_],I[(_+1)%I.length],y);O&&Ua(t,O,A,M)}}}}function dr(t,n,e,r,o){if(n.length<3)return!1;let s=r+.006,i=o??ka;if(e==="oval-cricket"){let a=n.reduce((M,x)=>M+x.x,0)/n.length,c=n.reduce((M,x)=>M+x.y,0)/n.length,l=M=>n.map(x=>({x:a+(x.x-a)*M,y:c+(x.y-c)*M})),u=8;for(let M=0;M<u;M++){let x=l(1-M/u),I=M===u-1?null:l(1-(M+1)/u);on(t,x,I,s,V(i,M%2?1.04:.96),4)}let f=n[0];for(let M of n)Math.hypot(M.x-a,M.y-c)>Math.hypot(f.x-a,f.y-c)&&(f=M);let m=Math.hypot(f.x-a,f.y-c)||1,h=(f.x-a)/m,d=(f.y-c)/m,y=-d,b=h,p=Math.min(1,2*m*P*Na/_e.length),g=_e.length*p/2/P,R=_e.width*p/2/P,A=[[-g,-R],[g,-R],[g,R],[-g,R]].map(([M,x])=>({x:a+h*M+y*x,y:c+d*M+b*x}));return on(t,A,null,s+.004,Fa,0),t.setMaterial(0),!0}if(e==="rink-hockey"){let a=mr(n,ja);return on(t,a,null,s,La,0),t.setMaterial(0),Z(t,n,[a.slice().reverse()],()=>r+Xa,r,lr,V(lr,.9),K),!0}if(e==="ring-boxing"&&n.length===4){let{at:a}=zn(n),c=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],l=[[.77,.19,.19],Ct,[.17,.42,.69],Ct];t.setMaterial(0),c.forEach((u,f)=>Yn(t,u,.07,r,r+Ha,l[f]));for(let u of Da)for(let f=0;f<4;f++)en(t,c[f],c[(f+1)%4],.025,r+u-.025,r+u+.025,Ct);return!0}if(e==="court-tennis"&&n.length===4){let{at:a}=zn(n);t.setMaterial(0),en(t,a(0,-6.4),a(0,6.4),.015,r,r+.95,Wn),en(t,a(0,-6.4),a(0,6.4),.03,r+.95,r+1,Ct);for(let c of[-1,1])Yn(t,a(0,c*6.4),.05,r,r+1.07,Wn);return!0}if(e==="court-basketball"&&n.length===4){let{at:a,lengthM:c}=zn(n),l=Math.min(14,c/2-.5);t.setMaterial(0);for(let u of[-1,1]){let f=a(u*(l+1.2),0),m=a(u*(l-1.2),0);Yn(t,f,.12,r,r+3.4,Wn),en(t,f,m,.06,r+3.25,r+3.4,Wn),en(t,a(u*(l-1.2),-.9),a(u*(l-1.2),.9),.03,r+2.9,r+3.95,Ct)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:a,lengthM:c}=zn(n),l=c*(50/120);t.setMaterial(0);for(let u of[-1,1]){for(let f of[-2.8,2.8])Yn(t,a(u*l,f),.07,r,r+12,Ct);en(t,a(u*l,-2.8),a(u*l,2.8),.06,r+2.94,r+3.06,Ct)}return!0}if(e==="track-athletics"){let a=mr(n,Ga);return a.length<3?!1:(on(t,n,a,s,va,0),on(t,a,null,s,i,4),t.setMaterial(0),!0)}return!1}var pr=[.19,.4,.15],Wa=.012,qn=2.4,Ya=1,za=.75,Ka=.15;function At(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:r,rotation:o}=t;if(!e||!r)return null;let s=(o??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),c=e/2,l=r/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:n.x+u*i-f*a,y:n.y+u*a+f*i}))}function Sr(t,n,e,r,o,s,i=!1){let a=At(n);if(a){if(i){let c=Wt(r,o.boothTop),l=wt([...a]);Z(t,It(l,Va/P),[l.slice().reverse()],()=>e+.03,e,c,V(c,.8),K);return}if(!(!n.points&&s&&qa(t,a,e,r,s))){if(!n.points&&s&&a.length===4){Za(t,a,e,r,s);return}Z(t,a,void 0,()=>e+qn,e,Wt(r,o.boothTop),o.boothWall,K)}}}var Ae=1.1,xr=[.9,.9,.88],Va=.1,Kn=[.87,.87,.85],br=.08;function Ir(t,n){let e=c=>({x:(t[c].x+t[(c+1)%4].x)/2,y:(t[c].y+t[(c+1)%4].y)/2}),r=0,o=1/0;for(let c=0;c<4;c++){let l=e(c),u=Math.hypot(l.x-n.x,l.y-n.y);u<o&&(o=u,r=c)}let s=[0,1,2,3].map(c=>t[(r+c)%4]),i=(c,l,u)=>({x:c.x+(l.x-c.x)*u,y:c.y+(l.y-c.y)*u});return{q:s,part:(c,l,u,f)=>{let m=i(s[0],s[1],c),h=i(s[0],s[1],l),d=i(s[3],s[2],c),y=i(s[3],s[2],l);return[i(m,d,u),i(h,y,u),i(h,y,f),i(m,d,f)]},depthM:Math.hypot(s[3].x-s[0].x,s[3].y-s[0].y)*P,widthM:Math.hypot(s[1].x-s[0].x,s[1].y-s[0].y)*P}}function Za(t,n,e,r,o){let{q:s,part:i}=Ir(n,o),a=r??[.35,.42,.55],c=at(a,[.78,.78,.77],.62),l=at(a,[.95,.95,.94],.45);ot(t,s,e+Gt,e,c,V(c,.8)),ot(t,i(.05,.95,.72,.98),e+Ae-.05,e+Gt,l,V(l,.8)),ot(t,i(.03,.97,.7,1),e+Ae,e+Ae-.05,xr,V(xr,.9))}function qa(t,n,e,r,o){if(n.length!==4)return!1;let{q:s,part:i,depthM:a,widthM:c}=Ir(n,o);if(a<1||c<1)return!1;let l=r??[.35,.42,.55],u=at(l,[.78,.78,.77],.62),f=e+qn,m=br/c,h=br/a;ot(t,s,e+Gt,e,u,V(u,.8)),ot(t,i(0,1,1-h,1),f,e+Gt,Kn,V(Kn,.9));for(let[b,p]of[[0,m],[1-m,1]])ot(t,i(b,p,0,1-h),f,e+Gt,Kn,V(Kn,.9));ot(t,i(m,1-m,0,Math.min(.5,.06/a)),f,f-.3,l,V(l,.85));let d=Math.min(.4,.6/c),y=Math.min(.12,.3/a);return ot(t,i(.5-d,.5+d,.72-y,.72+y),e+Ya,e+Gt,at(l,[.95,.95,.94],.7),V(l,.75)),!0}function $n(t){if(t.shape==="round"){let u=t.radius;return u?Nn(t.center.x,t.center.y,u,u,24):null}let{width:n,height:e,rotation:r,center:o}=t;if(!n||!e)return null;let s=(r??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),c=n/2,l=e/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:o.x+u*i-f*a,y:o.y+u*a+f*i}))}function _r(t,n,e,r,o,s=!0){let i=$n(n);if(!i)return;let a=i.reduce((m,h)=>m+h.x,0)/i.length,c=i.reduce((m,h)=>m+h.y,0)/i.length,l=m=>i.map(h=>({x:a+(h.x-a)*m,y:c+(h.y-c)*m})),u=s&&r?Wt(r,o.tableTop):$a,f=e+za;Z(t,i,void 0,()=>f,e+Qa,u,V(u,.86),K),Z(t,l(.12),void 0,()=>f+.12,f,gr,V(gr,.8),K)}var $a=[.93,.92,.89],gr=[.78,.66,.42],Qa=.25,pn={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function Ja(t,n,e){let r=t.reduce((p,g)=>p+g.x,0)/4,o=t.reduce((p,g)=>p+g.y,0)/4,s=t[3].x-t[0].x,i=t[3].y-t[0].y,a=Math.hypot(s,i)||1;s/=a,i/=a,s*(n.x-r)+i*(n.y-o)<0&&(s=-s,i=-i);let c=-i,l=s,u=pn.armM/P,f=pn.widthM/P,m=a/2+pn.insideM/P,h=e?-1:1,d=r+s*(m+(e?0:u)),y=o+i*(m+(e?0:u)),b=(p,g)=>({x:d+s*p*h+c*g,y:y+i*p*h+l*g});return[b(0,0),b(-u,u),b(-u-f,u),b(-f,0),b(-u-f,-u),b(-u,-u)]}function tc(t,n,e,r,o){let s=[.94,.95,.96];Z(t,Ja(n,r,o),void 0,()=>e+pn.high,e+pn.low,s,s,K)}function Zn(t,n){let e=it(t);return e?{top:V(Et(e,.12),.95),wall:V(Et(e,.12),.85)}:{top:n.tierTop,wall:n.tierWall}}function Ar(t,n,e,r,o,s,i,a,c=[]){let l=ct(n),u=Uo(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!l){dn(t,n,e+r+Wa);return}let m=a?a.kind==="stage":n.role==="stage",h=a?a.kind==="screen":n.role==="screen",d=a?{kind:m?"stage":"solid",heightM:a.topY-a.baseY}:_t(n),y=a?.baseY??e,b=a?.topY??e+r;if(m&&i){let F=1/0,k=-1/0,E=1/0,w=-1/0;for(let B of l)B.x<F&&(F=B.x),B.x>k&&(k=B.x),B.y<E&&(E=B.y),B.y>w&&(w=B.y);i.push({cx:(F+k)/2*P,cz:(E+w)/2*P,y:b,halfX:Math.max((k-F)/2*P,.5),halfZ:Math.max((w-E)/2*P,.5)})}let p=it(n.fill),g=n.role==="wall"||n.role==="entrance"||n.role==="exit",R=g?Zn(n.fill,o).top:m&&p?at(o.stageTop,V(Et(p,.18),.9),.9):!n.role&&p?p:Wt(p,m?o.stageTop:o.decorTop),A=h?p:null,M=g?Zn(n.fill,o).wall:m?p?at(o.stageWall,V(p,.58),.82):o.stageWall:h?A?at(V(A,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Wt(it(n.fill),o.decorWall),x=m&&kn(o)?jt(!0):null,I=x?Pr(R,x.stageTop):R,S=x?Pr(M,x.stageWall):M;if(n.role==="wall"&&!a){jn(t,l,y,b,c,I,S,s),dn(t,n,b+.012);return}if(h&&l.length===4&&b-y>.2){let F=Pe(l,y,b);if(!F)return;let{quad:k,side:E,trim:w,inner:B,panel:L}=F,T=[.12,.15,.18];for(let[v,H]of[[0,E],[1-E,1]])ot(t,dt(k,v,H),b,y,T,T);ot(t,B,y+w,y,T,T),ot(t,B,b,b-w,T,T),ot(t,L,b-w,y+w,S,S),dn(t,n,b+.012);return}let _=p?V(Et(p,.15),.82):S,O=p?V(Et(p,.1),1.02):I;if(rr(n.role)&&!a&&ir(t,n.role,l,y,b,_,O,s,n.heightM!==void 0))return;if((n.role==="sound"||a?.kind==="sound_desk")&&l.length===4&&b-y>.3){let F=bt(l),k=Math.hypot(F[1].x-F[0].x,F[1].y-F[0].y)*P,E=Math.min(.12,.09/Math.max(k,.001)),w=[.18,.21,.24],B=b-Math.min(.12,(b-y)*.15);for(let[L,T]of[[0,E],[1-E,1]])ot(t,dt(F,L,T),B,y,w,w);ot(t,F,b,B,I,w);return}if(n.role==="rail"&&l.length===4&&b>y){let F=bt(l),k=Math.hypot(F[1].x-F[0].x,F[1].y-F[0].y)*P,E=Math.max(1,Math.min(128,Math.ceil(k/1.4))),w=Math.min(.08,.055/Math.max(.055,k)),B=[.58,.64,.66];for(let L=0;L<=E;L++){let T=L/E,v=Math.min(1-w,Math.max(0,T-w/2));ot(t,dt(F,v,v+w),b,y,B,V(B,.8))}for(let L of[.52,1]){let T=y+(b-y)*L;ot(t,F,T,Math.max(y,T-.055),B,V(B,.8))}return}if(n.role==="goal"&&l.length===4){let F=bt(l),k=Math.hypot(F[1].x-F[0].x,F[1].y-F[0].y)*P,E=Math.min(.12,.1/Math.max(.1,k)),w=[.9,.94,.94];for(let[B,L]of[[0,E],[1-E,1]])ot(t,dt(F,B,L),Math.max(y,b-.1),y,w,w);ot(t,F,b,Math.max(y,b-.1),w,w);return}if(d.kind==="portal"&&l.length===4){let F=tn(l,y,b);if(!F)return;let{quad:k,side:E,face:w,openingTop:B}=F;for(let[L,T,v]of[[0,w,1],[w,1-w,.67],[1-w,1,1]]){let H=mn(k,L,T),j=V(I,v),D=V(S,v);for(let[U,X]of[[0,E],[1-E,1]])ot(t,dt(H,U,X),B,y,j,D);ot(t,H,b,B,j,D)}(n.role==="entrance"||n.role==="exit")&&tc(t,k,y,s,n.role==="exit");return}if(d.kind==="suite"&&l.length===4){let F=l.map((w,B)=>{let L=l[(B+1)%4],T=(w.x+L.x)/2,v=(w.y+L.y)/2;return Math.hypot(T-s.x,v-s.y)}),k=F.indexOf(Math.min(...F)),E=[0,1,2,3].map(w=>l[(k+w)%4]);ot(t,dt(E,0,.08),b,y,I,S),ot(t,dt(E,.92,1),b,y,I,S),ot(t,mn(E,.88,1),b,y,I,S),ot(t,E,b,Math.max(y,b-.18),I,S);return}if(m&&!n.stageKind?.startsWith("pitch-")&&b-y>.12){let F=b-Math.min(.06,(b-y)*.15);ot(t,l,F,y,I,S,u),ot(t,l,b,F,I,at(I,S,.2),u)}else ot(t,l,b,y,I,S,u);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&l.length===4){t.setMaterial(4);let F=bt(l),k=at(p??pr,pr,p?.45:0);for(let E=0;E<12;E++){let w=dt(F,E/12,(E+1)/12),B=V(k,E%2?1.09:.91),L=w.map(T=>[T.x*P,b+.006,T.y*P]);t.tri(L[0],L[1],L[2],[0,1,0],B),t.tri(L[0],L[2],L[3],[0,1,0],B)}}n.stageKind&&n.stageKind!=="pitch-football"&&dr(t,l,n.stageKind,b,p),m&&Zt(n.stageKind)&&yr(t,n,b),t.setMaterial(h?1:0),dn(t,n,b+.012)}function Qn(t){let{x:n,y:e,width:r,height:o}=t;if(!r||!o)return null;let s=n+r/2,i=e+o/2,a=(t.rotation??0)*Math.PI/180,c=Math.cos(a),l=Math.sin(a),u=r/2,f=o/2;return[[-u,-f],[u,-f],[u,f],[-u,f]].map(([m,h])=>({x:s+m*c-h*l,y:i+m*l+h*c}))}function nc(t){if(!t||!t.startsWith("data:image/svg+xml"))return null;let n=t.slice(t.indexOf(",")+1);if(/;base64/i.test(t.slice(0,t.indexOf(","))))try{n=atob(n)}catch{return null}else try{n=decodeURIComponent(n)}catch{}let e=n.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!e)return null;let r=e[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return it(r);let s=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!s)return null;let i=[];for(let a of s[1].matchAll(/stop-color="([^"]+)"/gi)){let c=it(a[1].trim());c&&i.push(c)}return i.length?i.reduce((a,c,l)=>at(a,c,1/(l+1)),i[0]):null}function Er(t,n,e,r){if(n.layer==="foreground")return;let o=Qn(n);if(!o)return;let s=e+Ka,i=Wt(nc(n.href),r.decorTop),a=Math.max(0,Math.min(1,n.opacity??1));a<1&&(i=at(r.ground,i,a)),Z(t,o,void 0,()=>s,e,i,at(i,r.decorWall,.5),K)}function wr(t,n,e,r,o){if(!n.points||n.points.length<3)return;let s=So(r,o.gaTop);Z(t,n.points,n.holes,()=>e+Mr,e,s,o.gaWall,K),rc(t,n.points,e+Mr)}var Mr=.15,Vn=[.72,.74,.76],Ee=1.1,Rr=.12,we=.05,ec=.06,oc=2.4;function rc(t,n,e){let r=wt([...n]),o=Lt(r,Rr/P),s=Lt(r,(Rr+we)/P);if(o.length<3||s.length<3)return;for(let a of[e+Ee,e+Ee*.5])Z(t,o,[s.slice().reverse()],()=>a,a-we,Vn,V(Vn,.85),K);let i=ec/2/P;for(let a=0;a<o.length;a++){let c=o[a],l=o[(a+1)%o.length],u=Math.hypot(l.x-c.x,l.y-c.y)*P,f=Math.max(1,Math.round(u/oc));for(let m=0;m<f;m++){let h=m/f,d=c.x+(l.x-c.x)*h,y=c.y+(l.y-c.y)*h,b=[{x:d-i,y:y-i},{x:d+i,y:y-i},{x:d+i,y:y+i},{x:d-i,y:y+i}];Z(t,b,void 0,()=>e+Ee-we,e,Vn,V(Vn,.8),K)}}}function Pr(t,n){return Tn(t)<n?Xt(t,n):t}var ic=1.5,sc=30,ac=4,cc=3.6,lc=6,Be=15,uc=3,fc=1;function mc(t){return Math.max(cc,Math.min(lc,2.4+.15*t))}var xn=Math.PI*2;function hc(t,n){let e=0,r=0;for(let f of t)e+=f.x,r+=f.y;let o=Math.atan2(r/t.length-n.y,e/t.length-n.x),s=t.map(f=>{let m=Math.atan2(f.y-n.y,f.x-n.x)-o;for(;m>Math.PI;)m-=xn;for(;m<-Math.PI;)m+=xn;return m+o}),i=s.map((f,m)=>m).sort((f,m)=>s[f]-s[m]),a=s[i[0]],c=s[i[i.length-1]];if(c-a>Math.PI)return null;let l=f=>Math.hypot(f.x-n.x,f.y-n.y),u=f=>{let m=t[f],h=(f+t.length-1)%t.length,d=(f+1)%t.length,y=Math.abs(s[h]-s[f])<=Math.abs(s[d]-s[f])?h:d,b=t[y];return l(m)<=l(b)?[m,b]:[b,m]};return{start:a,end:c,startEdge:u(i[0]),endEdge:u(i[i.length-1])}}function Br(t){return t.type==="shape"&&t.role==="wall"&&t.heightM===void 0}function Te(t,n,e=()=>!0){let r=[];for(let c of t){if(!Br(c)||!e(c))continue;let l=ct(c);if(!l||l.length<3)continue;let u=hc(l,n);if(!u)return[];r.push(u)}if(r.length<2)return[];let o=t.flatMap(c=>{if(c.type!=="shape"||c.role!=="entrance"&&c.role!=="exit")return[];let l=ct(c);if(!l?.length)return[];let u=0,f=0;for(let m of l)u+=m.x,f+=m.y;return[{x:u/l.length,y:f/l.length}]}),s=c=>(c%xn+xn)%xn;r.sort((c,l)=>s(c.start)-s(l.start));let i=c=>Math.hypot(c.x-n.x,c.y-n.y),a=[];for(let c=0;c<r.length;c++){let l=r[c],u=r[(c+1)%r.length],f=s(u.start-l.end);if(f<=0||f>=Math.PI/2)continue;let m=x=>s(x-l.end)<f;if(r.some(x=>x!==l&&x!==u&&(m(x.start)||m(x.end)||s(l.end-x.start)<x.end-x.start)))continue;let[d,y]=l.endEdge,[b,p]=u.startEdge,g={x:(d.x+y.x)/2,y:(d.y+y.y)/2},R={x:(b.x+p.x)/2,y:(b.y+p.y)/2},A=Math.hypot(R.x-g.x,R.y-g.y)*P;if(A<ic||A>sc||Math.abs(i(g)-i(R))*P>ac+.2*A)continue;let M={x:(g.x+R.x)/2,y:(g.y+R.y)/2};o.some(x=>m(Math.atan2(x.y-n.y,x.x-n.x))&&Math.abs(i(x)-i(M))*P<=uc)||a.push({quad:[d,y,p,b],mid:M,widthM:A,openingM:mc(A)})}return a}function Tr(t,n){let e=[];for(let s of n)if(s.text?.trim())for(let i of t){let a=Math.hypot(s.position.x-i.mid.x,s.position.y-i.mid.y)*P;a<=Be&&e.push({text:s,gate:i,d:a})}e.sort((s,i)=>s.d-i.d);let r=new Map,o=new Set;for(let{text:s,gate:i}of e)r.has(s.id)||o.has(i)||(r.set(s.id,i),o.add(i));return r}function Or(t,n,e,r,o,s,i,a=()=>!0){let c=Te(n,Jt(e),a);if(!c.length)return;let l=n.find(f=>Br(f)&&a(f)),u=Zn(l?.fill,i);t.setMaterial(Xn);for(let f of c)o-f.openingM<fc||jn(t,f.quad,r+f.openingM,r+o,[],u.top,u.wall,s,o);t.setMaterial(0)}var yc=6,dc=2.2,Jn=.1,pc=/^(gate|entrance|entry|exit|way in|way out|door)s?$/i,xc=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),bc=.3,gc=1.8,Mc=.9,Rc=.55,Pc=1,Cr=4e3,Sc=6,kr="#d8a425",Ic="#e8c15a",Oe="#1c1608";function Fr(t){let n=_c(t);if(!n)return null;let e=$e(t).find(r=>r.icon===n.icon);return{...n,name:e?.titleFallback??n.icon}}function _c(t){let n=t.accessibility;if(n?.length)return{icon:n.includes("wheelchair")?"wheelchair":n[0],color:Sn(n)};let e=t.commercial;return e?.obstructedView?{icon:"obstructedView",color:kr,ink:Oe}:e?.restrictedView?{icon:"restrictedView",color:kr,ink:Oe}:e?.premium?{icon:"premium",color:Ic,ink:Oe}:null}function Ac(t,n){if(!t)return;let e,r=0;for(let[s,i]of t)i>r&&(r=i,e=s);let o=n.categories?.find(s=>s.key===e)?.color;return o&&/^#[0-9a-f]{6}$/i.test(o)?o:void 0}var Ec=6e3,wc=.25,Lr=[-90,90,-135,135,-45,45];function Bc(t,n,e,r){let o=t.flatMap(({id:i,a,members:c})=>{let l=(a.minX+a.maxX)/2,u=(a.minY+a.maxY)/2,f=.5*Math.hypot(a.maxX-a.minX,a.maxY-a.minY),m=1/0;for(let h of c)m=Math.min(m,Math.hypot(n[h].x-l,n[h].y-u));return c.length&&m>=f*wc?[{id:i,cx:l,cy:u,half:f,members:c}]:[]}).sort((i,a)=>i.half-a.half),s=new Map;return o.forEach(({id:i,cx:a,cy:c,members:l},u)=>{let f=r.x-a,m=r.y-c,y=(Math.hypot(f,m)>1e-6?Math.atan2(m,f):0)+Lr[u%Lr.length]*Math.PI/180,b=Math.cos(y),p=Math.sin(y),g=-1,R=-1/0;for(let A of l){let M=(n[A].x-a)*b+(n[A].y-c)*p;M>R&&(R=M,g=A)}s.set(i,[n[g].x*P,e.seatDeckY(g),n[g].y*P])}),s}function Nr(t){let{doc:n,units:e,seats:r,surfaces:o,focal:s}=t,i=n.zones??[],a=[];if(i.length){let c=new Map;for(let m of e)for(let h of m.objects)h.type==="section"&&h.zone&&c.set(h.id,h.zone);let l=new Map,u=new Map;for(let m=0;m<r.length;m++){let h=r[m],d=o.seatOwner[m],y=h.zoneId??(d?c.get(d):void 0);if(!y)continue;let b=l.get(y);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(y,b));let p=u.get(y);p||u.set(y,p=[]),p.push(m),b.n++,h.x<b.minX&&(b.minX=h.x),h.y<b.minY&&(b.minY=h.y),h.x>b.maxX&&(b.maxX=h.x),h.y>b.maxY&&(b.maxY=h.y),b.sumY+=o.seatDeckY(m)}let f=Bc(i.flatMap(m=>{let h=l.get(m.id);return h?[{id:m.id,a:h,members:u.get(m.id)??[]}]:[]}),r,o,s);for(let m of i){let h=l.get(m.id),d=[];for(let[y,b]of c)b===m.id&&d.push(y);if(!h||h.n===0){a.push({id:m.id,label:m.label,color:it(m.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(m.focalPoint??s).x*P,1.5,(m.focalPoint??s).y*P]});continue}a.push({id:m.id,label:m.label,color:it(m.color),sectionIds:d,seatCount:h.n,...f.has(m.id)?{labelAt:f.get(m.id)}:{},center:[(h.minX+h.maxX)/2*P,h.sumY/h.n,(h.minY+h.maxY)/2*P],radius:.5*Math.hypot((h.maxX-h.minX)*P,(h.maxY-h.minY)*P)||1,focalWorld:[(m.focalPoint??s).x*P,1.5,(m.focalPoint??s).y*P]})}}return a}function Gr(t){let{doc:n,units:e,seats:r,surfaces:o,seatData:s,hintedSeatFloor:i,zones:a,focal:c}=t,l=[],u=[],f=[],m=new Map;for(let h of e)for(let d of h.objects){if(d.type!=="section"||!d.zone)continue;let y=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!y)continue;let b=n.floors?.[h.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&b===y)continue;let p=m.get(d.zone);p||m.set(d.zone,p=new Set),p.add(y)}for(let h of a)h.seatCount!==0&&(m.get(h.id)?.has(h.label.trim().toLocaleLowerCase())||l.push({id:`zone:${h.id}`,kind:"zone",text:h.label,anchor:[(h.labelAt??h.center)[0],(h.labelAt??h.center)[1]+yc,(h.labelAt??h.center)[2]],color:n.zones?.find(d=>d.id===h.id)?.color}));{let h=new Map,d=new Map,y=new Map,b=new Map;for(let p=0;p<r.length;p++){let g=o.seatOwner[p];if(!g)continue;let R=h.get(g);R||(R={n:0,x:0,y:0,deck:0},h.set(g,R)),R.n++,R.x+=r[p].x,R.y+=r[p].y,R.deck+=o.seatDeckY(p);let A=r[p].categoryKey;if(A){let x=d.get(g);x||(x=new Map,d.set(g,x)),x.set(A,(x.get(A)??0)+1)}if(r[p].accessibility?.includes("wheelchair")){let x=y.get(g);x?x.push(p):y.set(g,[p])}let M=b.get(g);M||(M={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},b.set(g,M)),M.minDeck=Math.min(M.minDeck,o.seatDeckY(p)),M.maxDeck=Math.max(M.maxDeck,o.seatDeckY(p)),r[p].x<M.minX&&(M.minX=r[p].x),r[p].x>M.maxX&&(M.maxX=r[p].x),r[p].y<M.minY&&(M.minY=r[p].y),r[p].y>M.maxY&&(M.maxY=r[p].y)}for(let p of e)for(let g of p.objects){if(g.type!=="section"||qo(g))continue;let R=h.get(g.id);if(!R||R.n===0)continue;let A=b.get(g.id),M=[R.x/R.n*P,R.deck/R.n,R.y/R.n*P],x=g.displayLabel||g.label||g.id;u.push({id:g.id,floorIndex:p.index,label:x,seatCount:R.n,center:M,radius:Math.max(1,Math.hypot(A.maxX-A.minX,A.maxY-A.minY)*.5*P),box:{min:[A.minX*P-.4,A.minDeck,A.minY*P-.4],max:[A.maxX*P+.4,A.maxDeck+1,A.maxY*P+.4]},focalWorld:[p.focal.x*P,p.baseHeightM+1.5,p.focal.y*P]});let I=n.floors?.[p.index]?.name?.trim().toLocaleLowerCase();if(!(e.length>1&&I===x.trim().toLocaleLowerCase())){let S=Ac(d.get(g.id),n),_=y.get(g.id);l.push({id:`section:${g.id}`,kind:"section",text:x,anchor:[M[0],M[1]+dc,M[2]],floorIndex:p.index,...S?{tint:S}:{},..._?{wheelchairSeats:_}:{}})}}}{for(let M of e)for(let x of M.objects){if(x.type!=="gaArea")continue;let I=Kt(x.points);if(!I)continue;let S=x.labelPresentation?.visible===!1?"":x.displayLabel||x.label||x.id,_=x.capacity>0?[S,x.capacity.toLocaleString()].filter(Boolean).join(" \xB7 "):S;_&&l.push({id:`ga:${x.id}`,kind:"ga",text:_,anchor:[I.x*P,M.baseHeightM+gc,I.y*P],floorIndex:M.index})}let h=new Map,d=new Map;for(let M of e)for(let x of M.objects)if(x.type==="section"&&h.set(x.id,x.displayLabel||x.label||x.id),x.type==="row"){let I=x.displayLabel?.trim()||x.segmentedRow?.displayLabel?.trim();I&&d.set(x.id,I)}let y=new Map;for(let M=0;M<r.length;M++){let x=r[M],I=Math.hypot(x.x-c.x,x.y-c.y),S=y.get(x.rowId);(!S||I>S.far)&&y.set(x.rowId,{seat:x,index:M,far:I})}for(let[M,x]of y){let I=o.seatOwner[x.index]??x.seat.sectionId,S=vr(x.seat.label,M,h.get(I??""),d.get(M));S&&l.push({id:`row:${M}`,kind:"row",text:S,anchor:[x.seat.x*P,o.seatDeckY(x.index)+Mc,x.seat.y*P],floorIndex:i[x.index]})}let b=new Map;for(let M=0;M<r.length;M++){let x=r[M],I=b.get(x.rowId);I||(I={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:vr(x.label,x.rowId,h.get(o.seatOwner[M]??x.sectionId??""),d.get(x.rowId)),sectionId:o.seatOwner[M]??x.sectionId},b.set(x.rowId,I));let S=M*3,_=s.iPosition[S],O=s.iPosition[S+1],C=s.iPosition[S+2];I.n++,I.x+=_,I.y+=O,I.z+=C,I.minX=Math.min(I.minX,_),I.maxX=Math.max(I.maxX,_),I.minZ=Math.min(I.minZ,C),I.maxZ=Math.max(I.maxZ,C)}for(let[M,x]of b)f.push({id:M,label:x.label,sectionId:x.sectionId,seatCount:x.n,center:[x.x/x.n,x.y/x.n,x.z/x.n],radius:Math.max(.8,Math.hypot(x.maxX-x.minX,x.maxZ-x.minZ)*.5)});let p=0,g=(M,x)=>{p++,l.push({id:`access:${r[M].id}`,kind:"access",text:x.name,icon:x.icon,color:x.color,...x.ink?{ink:x.ink}:{},seatWidthM:s.iChairWidth[M]*2,anchor:[r[M].x*P,o.seatDeckY(M)+Pc,r[M].y*P],floorIndex:i[M],rowId:r[M].rowId})},R=null,A=()=>{if(R){let M=Fr(r[R.seats[0]]),x=R.seats.length,I=Math.max(1,Math.round(x/Sc));for(let S=0;S<I&&p<Cr;S++)g(R.seats[Math.min(x-1,Math.floor((S+.5)*x/I))],M)}R=null};for(let M=0;M<r.length&&p<Cr;M++){let x=Fr(r[M]);if(x&&r[M].accessibility?.length){A(),g(M,x);continue}if(!x){A();continue}R&&R.rowId===r[M].rowId&&R.icon===x.icon?R.seats.push(M):(A(),R={rowId:r[M].rowId,icon:x.icon,seats:[M]})}if(A(),r.length<=Ec)for(let M=0;M<r.length;M++){let x=r[M],I=Tc(x.displayLabel||x.label);I&&l.push({id:`seat:${x.id}`,kind:"seat",seatWidthM:s.iChairWidth[M]*2,text:I,anchor:[x.x*P,o.seatDeckY(M)+Rc,x.y*P],floorIndex:i[M],rowId:x.rowId})}}for(let h of e){let d=Nt(h,e.length===1?r:r.filter((p,g)=>i[g]===h.index)),y=d?Tr(Te(h.objects,Jt(d)),h.objects.filter(p=>p.type==="text")):new Map,b=[...y.values()];for(let p of h.objects){let g=p.type==="text"?y.get(p.id):void 0;if(p.type==="shape"&&(p.role==="entrance"||p.role==="exit")&&pc.test(p.label?.trim()??"")){let R=ct(p),A=R?Kt(R):null;if(A&&b.some(M=>Math.hypot(A.x-M.mid.x,A.y-M.mid.y)*P<=Be+M.widthM))continue}if(g&&p.type==="text")l.push({id:`text:${p.id}`,kind:"gate",text:p.text,icon:"entrance",anchor:[g.mid.x*P,h.baseHeightM+g.openingM+Jn,g.mid.y*P],color:p.color,floorIndex:h.index});else if(p.type==="shape"&&p.role&&xc.has(p.role)){let R=ct(p),A=R?Kt(R):null;if(!A||!p.label||p.gate?.hideFromBuyers)continue;l.push({id:`architecture:${p.id}`,kind:p.role==="stage"?"stage":p.role==="entrance"||p.role==="exit"?"gate":"annotation",text:p.label,...p.role==="entrance"||p.role==="exit"?{icon:p.role}:{},...p.gate?.stepFree?{stepFree:!0}:{},anchor:[A.x*P,h.baseHeightM+_t(p).heightM+Jn,A.y*P],color:p.fill,floorIndex:h.index})}else if(p.type==="text"){let R=p.semanticKind==="icon"?oe(p.iconKey)?.key:void 0,A=p.text||(R?oe(R).label:"");if(!A)continue;l.push({id:`text:${p.id}`,kind:"annotation",text:A,...R?{venueIcon:R}:{},anchor:R?[(p.position.x+p.fontSize/2)*P,h.baseHeightM+Jn,(p.position.y+p.fontSize/2)*P]:[p.position.x*P,h.baseHeightM+Jn,p.position.y*P],color:p.color,rotation:p.rotation,floorIndex:h.index})}else if(p.type==="booth"){if(p.labelPresentation?.visible===!1)continue;let R=At(p);if(!R)continue;let A=Kt(R);if(!A)continue;l.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[A.x*P,h.baseHeightM+qn+bc,A.y*P],floorIndex:h.index})}}}return{labels:l,sections:u,rows:f}}function Dr(t,n){if(n.length>1)for(let e of n)t.push({id:`floor:${e.id}`,kind:"floor",text:e.label,anchor:[e.center[0],e.box.max[1]+1.2,e.center[2]],floorIndex:e.index})}function Tc(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function vr(t,n,e,r){if(r?.trim())return r.trim();let o=t?t.lastIndexOf("-"):-1,s=o>0?t.slice(0,o):n;return s&&eo(s,e)}var bn=3,Yt=.38,gn=.24;function Oc(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],r=t[t.length-1],o=(e.x-n.x)*P,s=(e.y-n.y)*P,i=(r.x-n.x)*P,a=(r.y-n.y)*P,c=2*(o*a-s*i);if(Math.abs(c)<1e-7)return null;let l=o*o+s*s,u=i*i+a*a,f=(l*a-u*s)/c+n.x*P,m=(o*u-i*l)/c+n.y*P,h=Math.hypot(n.x*P-f,n.y*P-m);return h<1||h>200||!Number.isFinite(h)||t.some(d=>Math.abs(Math.hypot(d.x*P-f,d.y*P-m)-h)>.03)?null:{x:f,z:m,radius:h}}function Hr(t){let n=[],e=new Map,r=(c,l)=>`${Math.floor(c/bn)},${Math.floor(l/bn)}`;for(let c of t)for(let l of c.rows){for(let f of l.pts){let m=f.x*P,h=f.y*P,d=r(m,h),y=e.get(d)??[];y.push({x:m,z:h,y:l.y,floor:c.floorIndex}),e.set(d,y)}if(l.patch||l.pts.length<2)continue;let u=Oc(l.pts);for(let f of[0,l.pts.length-1]){let m=l.pts[f],h=l.pts[f===0?1:f-1],d=m.x-h.x,y=m.y-h.y,b=Math.hypot(d,y);b<1e-6||n.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:u,row:l,point:m,x:m.x*P,z:m.y*P,dx:d/b,dz:y/b})}}let o=new Map;n.forEach((c,l)=>{let u=r(c.x,c.z),f=o.get(u)??[];f.push(l),o.set(u,f)});let s=(c,l)=>{let u=Math.floor(c/bn),f=Math.floor(l/bn);return[-1,0,1].flatMap(m=>[-1,0,1].map(h=>`${u+m},${f+h}`))},i=new Map;n.forEach((c,l)=>{let u=-1,f=1/0,m=!1;for(let h of s(c.x,c.z))for(let d of o.get(h)??[]){let y=n[d];if(c.sectionId===y.sectionId&&c.row.blockId===y.row.blockId||c.floorIndex!==y.floorIndex||Math.abs(c.row.y-y.row.y)>.05)continue;let b=y.x-c.x,p=y.z-c.z,g=Math.hypot(b,p);if(g<Yt*2+.45||g>bn)continue;let R=c.curve&&y.curve&&Math.hypot(c.curve.x-y.curve.x,c.curve.z-y.curve.z)<=.05&&Math.abs(c.curve.radius-y.curve.radius)<=.05,A=Math.min((b*c.dx+p*c.dz)/g,(-b*y.dx-p*y.dz)/g);(R?A<.8:A<.98)||!R&&(Math.abs(b*c.dz-p*c.dx)>.15||Math.abs(b*y.dz-p*y.dx)>.15)||(g<f-.02?(u=d,f=g,m=!1):Math.abs(g-f)<=.02&&(m=!0))}u>=0&&!m&&i.set(l,u)});let a=[];for(let[c,l]of i){if(c>=l||i.get(l)!==c)continue;let u=n[c],f=n[l],m=Math.hypot(f.x-u.x,f.z-u.z),h=(f.x-u.x)/m,d=(f.z-u.z)/m,y=!1;for(let p of s((u.x+f.x)/2,(u.z+f.z)/2))for(let g of e.get(p)??[]){if(g.floor!==u.floorIndex||Math.abs(g.y-u.row.y)>.75)continue;let R=(g.x-u.x)*h+(g.z-u.z)*d,A=Math.abs((g.x-u.x)*d-(g.z-u.z)*h);R>.01&&R<m-.01&&A<gn+Yt&&(y=!0)}if(y)continue;let b=(p,g)=>({x:(u.x+h*p-d*g)/P,y:(u.z+d*p+h*g)/P});a.push({sections:[u.sectionId,f.sectionId],blocks:[u.row.blockId,f.row.blockId],floorIndex:u.floorIndex,ends:[u.point,f.point],clearWidthM:m-2*Yt,heightM:(u.row.y+f.row.y)/2,outline:[b(Yt,-gn),b(m-Yt,-gn),b(m-Yt,gn),b(Yt,gn)]})}return a}var Cc=.15,kc=.9,Fc=1.76;function Xr(t){return Ce(t)?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function Ce(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55}function Lc(){return{background:{top:[...le.top],bottom:[...le.bottom]},sky:Xr(null),structure:ce,seatStates:{...yo},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function vc(t){return Ce(t)?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function jr(t){let n=Lc();t??={};let e=it(t.background);if(e){n.background={top:V(e,kc),bottom:V(e,Fc)},n.sky=Xr(e);let a={};for(let[l,u]of Object.entries(ce))a[l]=at(u,e,Cc);e[0]*.2126+e[1]*.7152+e[2]*.0722>.55&&(a.ground=V(e,.86)),n.structure=a}let r=it(t.selectionColor)??it(t.accent);r&&(n.seatStates={...n.seatStates,selected:r});let o=t.seatScale;typeof o=="number"&&Number.isFinite(o)&&(n.seatScale=ro(o));let s=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([,a])=>a!=null)),i={...vc(e),...s};if(i){let a=it(i.deck),c=it(i.fascia);a&&(n.structure={...n.structure,tierTop:a,gaTop:a}),c&&(n.structure={...n.structure,tierWall:c,gaWall:c}),n.materials.seat=it(i.seat),n.materials.shell=it(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(n.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return Nc(n,Ce(e)),n}function Nc(t,n){let e=jt(n);t.seatStates={...t.seatStates,held:On(e.unavailable),sold:On(e.unavailable),dimmed:On(e.dimmed)};let r=(s,i)=>Xt(s,i,Math.min(an(s),Cn)),o=t.structure;t.structure={...o,ground:r(o.ground,e.ground),tierTop:r(o.tierTop,e.deck),tierWall:r(o.tierWall,e.fascia)},t.materials.shell&&(t.materials.shell=r(t.materials.shell,e.shell))}function Ur(t,n){let e=[];for(let r of n)e.push(...t.seatStates[r]);return e}var ke=.6,Wr=3,Gc=.25;function Dc(t,n){if(xt(n,t.x,t.y))return 0;let e=1/0;for(let r=0,o=n.length-1;r<n.length;o=r++){let s=n[o],i=n[r],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c||1,u=Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/l));e=Math.min(e,Math.hypot(t.x-(s.x+u*a),t.y-(s.y+u*c)))}return e}function Yr(t,n){let e=t.map(i=>({booth:i,ring:At(i)})).filter(i=>!!i.ring&&i.ring.length===4&&!i.booth.points),r=e.map(({ring:i})=>({minX:Math.min(...i.map(a=>a.x)),maxX:Math.max(...i.map(a=>a.x)),minY:Math.min(...i.map(a=>a.y)),maxY:Math.max(...i.map(a=>a.y))})),o=(Wr+ke)/P,s=new Map;return e.forEach(({booth:i,ring:a},c)=>{let l={x:a.reduce((h,d)=>h+d.x,0)/4,y:a.reduce((h,d)=>h+d.y,0)/4},u=[0,1,2,3].map(h=>{let d=a[h],y=a[(h+1)%4],b={x:(d.x+y.x)/2,y:(d.y+y.y)/2},p=b.x-l.x,g=b.y-l.y,R=Math.hypot(p,g)||1,A={x:b.x+p/R*ke/P,y:b.y+g/R*ke/P},M=Wr/P;return r.forEach((x,I)=>{I===c||A.x<x.minX-o||A.x>x.maxX+o||A.y<x.minY-o||A.y>x.maxY+o||(M=Math.min(M,Dc(A,e[I].ring)))}),{open:M*P,toward:{x:b.x+p/R*10/P,y:b.y+g/R*10/P},focal:Math.hypot(b.x-n.x,b.y-n.y)}}),f=Math.max(...u.map(h=>h.open)),m=u.filter(h=>h.open>=f-Gc).sort((h,d)=>h.focal-d.focal)[0];s.set(i.id,m.toward)}),s}import Hc from"polygon-clipping";var Xc=.45,jc=1500,Uc=200;function zr(t,n){if(t.role!=="stage"||Zt(t.stageKind))return t;let e=ct(t);if(!e||e.length<3||Math.abs(pt(e))*P*P>jc)return t;let r=n.filter(i=>xt(e,i.x,i.y));if(!r.length||r.length>Uc)return t;let o=Xc/P,s=r.map(i=>[[[i.x-o,i.y-o],[i.x+o,i.y-o],[i.x+o,i.y+o],[i.x-o,i.y+o],[i.x-o,i.y-o]]]);try{let i=Hc.difference([[...e.map(l=>[l.x,l.y]),[e[0].x,e[0].y]]],...s),a=null,c=0;for(let l of i){let u=l[0].slice(0,-1).map(([m,h])=>({x:m,y:h})),f=Math.abs(pt(u));f>c&&(c=f,a=u)}return!a||a.length<3?t:{...t,kind:"polygon",points:a,rotation:0}}catch{return t}}function Fe(t,n,e,r,o,s,i,a,c,l=[],u=o){if(n.length!==e.length||n.length<2||s-o<1.5)return;let f=(y,b,p)=>{Ot(t,y,b,p,l,i,a,{portalBase:u,ao:c})||Z(t,y,void 0,()=>p,b,i,a,c)},m=(y,b,p)=>({x:y.x+(b.x-y.x)*p,y:y.y+(b.y-y.y)*p}),h=r?n.length:n.length-1,d=0;for(let y=0;y<h;y++){let b=(y+1)%n.length,p=Math.hypot(e[b].x-e[y].x,e[b].y-e[y].y)*$;if(p<1e-5)continue;let g=(x,I)=>[m(n[y],n[b],x),m(n[y],n[b],I),m(e[y],e[b],I),m(e[y],e[b],x)];f(g(0,1),o,o+.95),f(g(0,1),s-.22,s);let R=Math.ceil((d-.32)/6)*6,A=!1,M=!1;for(let x=R;x<d+p;x+=6){let I=Math.max(0,(x-d)/p),S=Math.min(1,(x+.32-d)/p);S<=I||(f(g(I,S),o+.95,s-.22),A||=I<1e-6,M||=S>1-1e-6)}if(!r&&(y===0&&!A||y===h-1&&!M)){let x=Math.min(1,.32/p);f(g(y===0?0:1-x,y===0?x:1),o+.95,s-.22)}d+=p}}import zt from"polygon-clipping";var Rn=.65;function Le(t,n){let e=1/0;for(let r of n)for(let o=0;o<r.length;o++){let s=r[o],i=r[(o+1)%r.length],a=i.x-s.x,c=i.y-s.y,l=Math.max(0,Math.min(1,((t.x-s.x)*a+(t.y-s.y)*c)/(a*a+c*c||1)));e=Math.min(e,Math.hypot(t.x-s.x-l*a,t.y-s.y-l*c))}return e}var ve=.01;function Kr(t,n,e,r,o,s,i,a=[],c=!0,l={bays:[],walls:[]}){if(r-o<=1e-5)return;let u=r-o>=3,f=u?r-Rn:o;t.setMaterial(5);let m=u?[]:a.filter(x=>{if(x.role!=="entrance"&&x.role!=="exit")return!1;let I=ct(x);if(!I)return!1;let S=tn(I,o,o+_t(x).heightM);return S!==null&&S.openingTop<=r-.12});if((!m.length||!Ot(t,n,f,r,m,s,i,{holes:e,portalBase:o}))&&Z(t,n,e,()=>r,f,s,i,K,void 0,()=>[0,1,0]),!u){t.setMaterial(0);return}let h=c&&l.bays.length?Wc(n,e,Lt(n,Mn/P),l):null,d=6/P,y=.22/P,b=a.flatMap(x=>{if(x.role!=="entrance"&&x.role!=="exit")return[];let I=ct(x);return I?.length?[{minX:Math.min(...I.map(S=>S.x)),maxX:Math.max(...I.map(S=>S.x)),minY:Math.min(...I.map(S=>S.y)),maxY:Math.max(...I.map(S=>S.y))}]:[]}),p=Math.min(...n.map(x=>x.x)),g=Math.max(...n.map(x=>x.x)),R=Math.min(...n.map(x=>x.y)),A=Math.max(...n.map(x=>x.y));for(let x=p+d/2;x<g;x+=d)for(let I=R+d/2;I<A;I+=d){if(b.some(_=>x+y>=_.minX&&x-y<=_.maxX&&I+y>=_.minY&&I-y<=_.maxY))continue;let S=[{x:x-y,y:I-y},{x:x+y,y:I-y},{x:x+y,y:I+y},{x:x-y,y:I+y}];!Pt({x,y:I},n,e)||Le({x,y:I},[n,...e??[]])<y*Math.SQRT2+(c?Mn/P:0)||h&&Le({x,y:I},h.flat())<y*Math.SQRT2+Mn/P||Z(t,S,void 0,()=>f,o,s,i,K)}if(h){for(let[x,...I]of h)Z(t,x,I,()=>f,o-ve,s,i,K);t.setMaterial(0);return}let M=Lt(n,Mn/P);if(c&&M.length>=3){let x=a.filter(_=>{if(_.role!=="entrance"&&_.role!=="exit")return!1;let O=ct(_);return!!O&&O.some(C=>!Pt(C,n,void 0)||Le(C,[n])<=Mn/P)}),I=[M.slice().reverse()],S=o-ve;(!x.length||!Ot(t,n,S,f,x,s,i,{holes:I,portalBase:o+ve}))&&Z(t,n,I,()=>f,S,s,i,K)}t.setMaterial(0)}var Ne=.25,Mn=Ne;function Wc(t,n,e,r){if(e.length<3)return null;let o=i=>{let a=i.map(c=>[c.x,c.y]);return a.push(a[0]),a},s=i=>{let[a,...c]=i.map(l=>[o(l)]);return zt.union(a,...c)};try{let i=[o(t),...(n??[]).map(o)],a=zt.difference(i,[o(e)]),c=zt.intersection(i,s(r.bays));if(!c.length)return null;let l=zt.difference(zt.intersection(i,s(r.walls)),c);return zt.union(zt.difference(a,c),l).map(f=>f.map(m=>m.slice(0,-1).map(([h,d])=>({x:h,y:d}))))}catch{return null}}var Yc=.02,zc=.25,Kc=1.2,Vc=.6,Zc=.45,qc=2.3,$c=Math.PI/180,Vr=.005;function Bt(t,n,e){let r=e*$c;return{x:t.x+n*Math.sin(r),y:t.y+n*Math.cos(r)}}function Qc(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let r=e.outerRMedian*.85;for(let o of t){if(o.role!=="wall")continue;let s=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(s.length<2)continue;let i=0;for(let a of s)Math.hypot(a.x-n.centre.x,a.y-n.centre.y)>=r&&i++;if(i>=s.length/2)return!0}return!1}var Jc=24,tl=.01;function nl(t,n,e,r,o,s,i,a,c){let l=e.binCount,u=Jc,f=$,m=s+.02,h=s-tl,d=[];for(let E=0;E<l;E++){let w=(e.startBin+E+.5)*n.binStepDeg,B=new Float64Array(u+1);for(let L=0;L<=u;L++){let T=r[E]+(o[E]-r[E])*L/u;B[L]=Math.max(m,uo(n,e,w,T)-zc)}d.push(B)}if(c){let E=0;for(let w=0;w+1<l;w++)for(let B=0;B<u;B++){let L=Bt(n.centre,r[w]+(o[w]-r[w])*B/u,(e.startBin+w+.5)*n.binStepDeg),T=Bt(n.centre,r[w+1]+(o[w+1]-r[w+1])*(B+1)/u,(e.startBin+w+1.5)*n.binStepDeg);E=Math.max(E,Math.hypot(T.x-L.x,T.y-L.y))}for(let w=0;w<l;w++){let B=(e.startBin+w+.5)*n.binStepDeg;for(let L=0;L<=u;L++){let T=Bt(n.centre,r[w]+(o[w]-r[w])*L/u,B),v=c(T.x,T.y,E*1.01);v!==null&&(d[w][L]=Math.min(d[w][L],Math.max(h+Vr,v-Vr)))}}}let y=[i.bandTop[0]*a.top,i.bandTop[1]*a.top,i.bandTop[2]*a.top],b=[i.bandTop[0]*a.bottomCap,i.bandTop[1]*a.bottomCap,i.bandTop[2]*a.bottomCap],p=[i.bandWall[0]*a.top,i.bandWall[1]*a.top,i.bandWall[2]*a.top],g=[i.bandWall[0]*a.wallBottom,i.bandWall[1]*a.wallBottom,i.bandWall[2]*a.wallBottom],R=(E,w)=>{let B=(e.startBin+E+.5)*n.binStepDeg,L=r[E]+(o[E]-r[E])*w/u,T=Bt(n.centre,L,B);return[T.x*f,d[E][w],T.y*f]};{let E=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let B=!1;for(let T=0;T<l;T++)for(let v=u-1;v>=0;v--)d[T][v]>d[T][v+1]&&(d[T][v]=d[T][v+1],B=!0);let L=e.closed?l:l-1;for(let T=0;T<L;T++){let v=(T+1)%l;for(let H=0;H<=u;H++){let j=d[v][H]-d[T][H];if(Math.abs(j)>1)continue;let D=r[T]+(o[T]-r[T])*H/u,U=r[v]+(o[v]-r[v])*H/u,X=Bt(n.centre,D,(e.startBin+T+.5)*n.binStepDeg),Y=Bt(n.centre,U,(e.startBin+v+.5)*n.binStepDeg),nt=E*Math.hypot(Y.x-X.x,Y.y-X.y)*f;j>nt?(d[v][H]=d[T][H]+nt,B=!0):-j>nt&&(d[T][H]=d[v][H]+nt,B=!0)}}if(!B)break}}let A=1,M=(E,w)=>{for(let B=0;B<=u;B+=4)if(Math.abs(d[E][B]-d[w][B])>A)return!0;return Math.abs(d[E][u]-d[w][u])>A},x=Math.tan(38*Math.PI/180),I=E=>(o[E]-r[E])/u*f,S=(E,w)=>d[E][w+1]-d[E][w]>x*Math.max(1e-6,I(E)),_=(E,w)=>{let B=e.closed?(E-1+l)%l:Math.max(0,E-1),L=e.closed?(E+1)%l:Math.min(l-1,E+1);Math.abs(d[B][w]-d[E][w])>A&&(B=E),Math.abs(d[L][w]-d[E][w])>A&&(L=E);let T=Math.max(0,w-1),v=Math.min(u,w+1);T<w&&S(E,T)&&(T=w),v>w&&S(E,w)&&(v=w);let H=R(B,w),j=R(L,w),D=R(E,T),U=R(E,v),X=j[0]-H[0],Y=j[1]-H[1],nt=j[2]-H[2],rt=U[0]-D[0],q=U[1]-D[1],Q=U[2]-D[2],J=Y*Q-nt*q,N=nt*rt-X*Q,G=X*q-Y*rt,W=Math.hypot(J,N,G);return W>1e-12?(J/=W,N/=W,G/=W,N<0&&(J=-J,N=-N,G=-G),[J,N,G]):[0,1,0]},O=(E,w,B=!1)=>{let L=B&&Math.min(E[1],w[1])-s>=3,T=[E[0],L?E[1]-Rn:h,E[2]],v=[w[0],L?w[1]-Rn:h,w[2]],H=w[0]-E[0],j=w[2]-E[2],D=Math.hypot(H,j);if(!(D>1e-12))return;let U=[j/D,0,-H/D];t.tri(E,w,v,U,p,p,g),t.tri(E,v,T,U,p,g,g)},C=.05*Rt,F=E=>o[E]-r[E]<C,k=e.closed?l:l-1;for(let E=0;E<k;E++){let w=(E+1)%l;if(F(E)||F(w))continue;if(M(E,w)){let j=(e.startBin+E+1)*n.binStepDeg,D=(q,Q)=>{let J=(r[E]+r[w])/2,N=(o[E]+o[w])/2,G=J+(N-J)*Q/u,W=Bt(n.centre,G,j);return[W.x*f,d[q][Q],W.y*f]};for(let q=0;q<u;q++){let Q=R(E,q),J=R(E,q+1),N=D(E,q),G=D(E,q+1),W=_(E,q),lt=_(E,q+1);t.triN(Q,N,G,W,W,lt,y),t.triN(Q,G,J,W,lt,lt,y);let ft=R(w,q),st=R(w,q+1),tt=D(w,q),et=D(w,q+1),ht=_(w,q),z=_(w,q+1);t.triN(tt,ft,st,ht,ht,z,y),t.triN(tt,st,et,ht,z,z,y);let mt=D(E,q),yt=D(E,q+1),Dt=D(w,q+1),Ht=D(w,q),kt=yt[0]-mt[0],Ft=yt[2]-mt[2],sn=Math.hypot(kt,Ft);if(sn>1e-12){let Pn=[Ft/sn,0,-kt/sn];t.tri(mt,yt,Dt,Pn,p),t.tri(mt,Dt,Ht,Pn,p)}}let U=R(E,0),X=R(w,0),Y=R(w,u),nt=R(E,u),rt=q=>[q[0],h,q[2]];Math.min(U[1],X[1])-s<3&&(t.tri(rt(U),rt(Y),rt(X),[0,-1,0],b),t.tri(rt(U),rt(nt),rt(Y),[0,-1,0],b)),O(U,X,!0),O(nt,Y,!0);continue}for(let j=0;j<u;j++){let D=_(E,j),U=_(w,j),X=_(w,j+1),Y=_(E,j+1);if(S(E,j)||S(w,j)){let J=(yt,Dt)=>{let Ht=(e.startBin+yt+.5)*n.binStepDeg,kt=r[yt]+(o[yt]-r[yt])*(j+.5)/u,Ft=Bt(n.centre,kt,Ht);return[Ft.x*f,Dt,Ft.y*f]},N=R(E,j),G=R(w,j),W=J(E,d[E][j]),lt=J(w,d[w][j]);t.triN(N,G,lt,D,U,U,y),t.triN(N,lt,W,D,U,D,y);let ft=R(w,j+1),st=R(E,j+1),tt=J(E,d[E][j+1]),et=J(w,d[w][j+1]);t.triN(tt,et,ft,Y,X,X,y),t.triN(tt,ft,st,Y,X,Y,y);let ht=lt[0]-W[0],z=lt[2]-W[2],mt=Math.hypot(ht,z);if(mt>1e-12){let yt=[-z/mt,0,ht/mt];t.tri(W,lt,et,yt,p),t.tri(W,et,tt,yt,p)}continue}let nt=R(E,j),rt=R(w,j),q=R(w,j+1),Q=R(E,j+1);t.triN(nt,rt,q,D,U,X,y),t.triN(nt,q,Q,D,X,Y,y)}let B=R(E,0),L=R(w,0),T=R(w,u),v=R(E,u),H=j=>[j[0],h,j[2]];Math.min(B[1],L[1])-s<3&&(t.tri(H(B),H(T),H(L),[0,-1,0],b),t.tri(H(B),H(v),H(T),[0,-1,0],b)),O(B,L,!0),O(v,T,!0)}if(!e.closed)for(let E of[0,l-1])for(let w=0;w<u;w++)O(R(E,w),R(E,w+1))}function Zr(t,n,e){let{bottomY:r,colors:o,ao:s}=e,i=new Float64Array(n.binCount).fill(-1/0);for(let u of n.rings)for(let f of u.arcs){let m=new Float64Array(f.binCount),h=new Float64Array(f.binCount);for(let y=0;y<f.binCount;y++){let b=(f.startBin+y)%n.binCount,p=Math.max(0,f.innerR[y]-St);m[y]=Math.max(p,i[b]+.001),h[y]=Math.max(m[y]+.001,f.outerR[y]+St)}let d=0;for(let y=0;y<f.binCount;y++){let b=f.topLevelM[y]-r;b>d&&(d=b)}d>=Kc&&nl(t,n,f,m,h,r,o,s,e.standTopNear);for(let y=0;y<f.binCount;y++){let b=(f.startBin+y)%n.binCount;h[y]>i[b]&&(i[b]=h[y])}}if(e.deriveShell===!1||Qc(e.shapes,n))return;let a=n.rings[n.rings.length-1],c=Vc*Rt,l=Zc*Rt;for(let u of a.arcs){let f=[],m=[];for(let _=0;_<u.binCount;_++){let O=(u.startBin+_+.5)*n.binStepDeg,C=u.outerR[_]+St+c;f.push(Bt(n.centre,C,O)),m.push(Bt(n.centre,C+l,O))}let h=-1/0;for(let _=0;_<u.binCount;_++)u.topLevelM[_]>h&&(h=u.topLevelM[_]);let d=h+qc,y=u.closed?m:[...m,...f.slice().reverse()],b=u.closed?[f.slice().reverse()]:void 0,p=at(o.shellWall,[.66,.71,.72],.62),g=(_,O,C,F,k)=>{let E=Math.abs(F-h)<1e-6?F-Yc:F;Ot(t,_,C,E,e.shapes,o.shellTop,k,{holes:O,portalBase:r,ao:s})||Z(t,_,O,()=>E,C,o.shellTop,k,s)},R=Math.max(1,Math.ceil((h-r)/4.5)),A=(h-r)/R,M=new Set,x=e.tierFrontLevels??n.rings.map(_=>{let O=_.arcs.flatMap(C=>Array.from(C.frontLevelM)).filter(Number.isFinite).sort((C,F)=>C-F);return O[Math.floor(O.length/2)]});for(let _ of x)Number.isFinite(_)&&_-r>=3&&_<h&&M.add(Math.max(0,Math.min(R-1,Math.floor((_-r)/A))));let I=Math.min(...x.filter(_=>Number.isFinite(_)&&_-r>=3&&_<h));for(let _=0;_<R;_++)r+(_+1)*A<=I-Rn&&Number.isFinite(I)&&M.add(_);for(let _=0;_<R;_++){let O=r+(h-r)*_/R,C=r+(h-r)*(_+1)/R;M.has(_)&&C-O>=3.2?(g(y,b,O,O+.45,p),Fe(t,f,m,u.closed,O+.45,C-.16,o.shellTop,p,s,e.shapes,r)):g(y,b,O,C-.16,p),g(y,b,C-.16,C,V(p,.62))}Fe(t,f,m,u.closed,h,d,o.shellTop,p,s,e.shapes,r);let S=8;for(let _=1;_<m.length;_++){if(S+=Math.hypot(m[_].x-m[_-1].x,m[_].y-m[_-1].y)*$,S<8)continue;S=0;let O=m[_],C=m[_-1],F=O.x-C.x,k=O.y-C.y,E=Math.max(1,Math.hypot(F,k)),w=F/E*.16*Rt,B=k/E*.16*Rt,L=Math.max(1,Math.hypot(O.x-n.centre.x,O.y-n.centre.y)),T=(O.x-n.centre.x)/L*.24*Rt,v=(O.y-n.centre.y)/L*.24*Rt,H=[{x:O.x-w,y:O.y-B},{x:O.x+w,y:O.y+B},{x:O.x+w+T,y:O.y+B+v},{x:O.x-w+T,y:O.y-B+v}];g(H,void 0,r,h,V(p,1.12))}}}var el=2.5,qr=.65,ol=2,rl=.03;function il(t,n){let e=()=>{let r=n;for(;t.length>2;){let o=t[0],s=t[1],i=Math.hypot(s.x-o.x,s.y-o.y);if(i>r){t[0]={x:o.x+(s.x-o.x)/i*r,y:o.y+(s.y-o.y)/i*r};return}r-=i,t.shift()}};e(),t.reverse(),e(),t.reverse()}function He(t,n,e){let r=new Map;for(let s of t){let i=r.get(s.blockId);(!i||s.depth<i.depth)&&r.set(s.blockId,s)}let o=[];for(let[s,i]of r){if(i.y-e<el||i.pts.length<2)continue;let a=i.pts.map(u=>{let f=u.x-n.x,m=u.y-n.y,h=Math.max(1,Math.hypot(f,m));return{x:u.x-f/h*qr/P,y:u.y-m/h*qr/P}}),c=[],l=[a[0]];for(let u=1;u<a.length;u++){let f=a[u-1],m=a[u];Math.hypot(m.x-f.x,m.y-f.y)*P>ol?(l.length>=2&&c.push(l),l=[m]):l.push(m)}l.length>=2&&c.push(l);for(let u of c)il(u,rl/P);c.length&&o.push({blockId:s,y:i.y,runs:c})}return o}var $r=.1,sl=1.1,al=.22,Ge=.95,De=.05,Qr=1.8;function Jr(t,n,e,r){let o=[.72,.72,.69],s=[.48,.55,.57];for(let i of He(n,e,r)){let a=i.y;for(let c of i.runs){let l=Qr;for(let u=1;u<c.length;u++){let f=c[u-1],m=c[u],h=m.x-f.x,d=m.y-f.y,y=Math.hypot(h,d);if(y<1e-5)continue;let b=p=>{let g=-d/y*p/P/2,R=h/y*p/P/2;return[{x:f.x+g,y:f.y+R},{x:m.x+g,y:m.y+R},{x:m.x-g,y:m.y-R},{x:f.x-g,y:f.y-R}]};if(Z(t,b(al),void 0,()=>a+$r,a-sl,o,o,K),Z(t,b(De),void 0,()=>a+Ge,a+Ge-De,s,s,K),l+=y*P,l>=Qr||u===c.length-1){l=0;let p=.028/P,g=[{x:f.x-p,y:f.y-p},{x:f.x+p,y:f.y-p},{x:f.x+p,y:f.y+p},{x:f.x-p,y:f.y+p}];Z(t,g,void 0,()=>a+Ge-De,a+$r,s,s,K)}}}}}var cl=.9,ll=1.5,ul=.3;function ti(t,n,e){let r=[],o=[],s=cl/P,i=ll/P,a=ul/P;for(let c of t)for(let l of c.runs){if(l.length<2)continue;let u=l.slice(),f=(b,p)=>{let g=u[b],R=u[p],A=Math.hypot(g.x-R.x,g.y-R.y)||1;u[b]={x:g.x+(g.x-R.x)/A*a,y:g.y+(g.y-R.y)/A*a}};f(0,1),f(u.length-1,u.length-2);let m=u.map((b,p)=>{let g=u[Math.max(0,p-1)],R=u[Math.min(u.length-1,p+1)],A=R.x-g.x,M=R.y-g.y,x=Math.hypot(A,M)||1,I=-M/x,S=A/x;return I*(b.x-n.x)+S*(b.y-n.y)<0&&(I=-I,S=-S),{nx:I,ny:S}}),h=u.map((b,p)=>({x:b.x-m[p].nx*i,y:b.y-m[p].ny*i})),d=u.map((b,p)=>({x:b.x+m[p].nx*s,y:b.y+m[p].ny*s})),y=u.map((b,p)=>({x:b.x+m[p].nx*(s+e/P),y:b.y+m[p].ny*(s+e/P)}));r.push([...h,...d.slice().reverse()]),o.push([...d,...y.reverse()])}return{bays:r,walls:o}}var Xe=.88,te=.27,fl=1.2,ml=.01;function ni(t,n,e,r,o){let s=[.67,.71,.68],i=[s[0]*Xe,s[1]*Xe,s[2]*Xe],a=c=>!!o&&o.some((l,u)=>u!==c&&l?.belowY!=null&&Math.abs(l.belowY-n[c].y)<1e-6&&n[u].blockId===n[c].blockId);for(let c=0;c<n.length;c++){let l=n[c];if(!(l.pts.length<2))for(let u of[0,l.pts.length-1]){let f=l.pts[u],m=l.pts[u===0?1:u-1],h=f.x-m.x,d=f.y-m.y,y=Math.hypot(h,d);if(y<1e-5)continue;h/=y,d/=y;let b=1/0;for(let w=0;w<e.length;w++){let B=e[w],L=e[(w+1)%e.length],T=L.x-B.x,v=L.y-B.y,H=h*v-d*T;if(Math.abs(H)<1e-8)continue;let j=B.x-f.x,D=B.y-f.y,U=(j*v-D*T)/H,X=(j*d-D*h)/H;U>0&&X>=0&&X<=1&&(b=Math.min(b,U))}let p=.3/P,g=b-.04/P;if(!Number.isFinite(b)||b*P>2||g-p<.12/P)continue;let R=!!r&&a(c),A=o?.[c]?.pitch,M=R&&A&&Number.isFinite(A)?Math.min(fl/P,Math.max(te/P,A-te/P-ml/P)):te/P,x=-d,I=h;r&&x*(r.x-f.x)+I*(r.y-f.y)<0&&(x=-x,I=-I);let S=te/P,_=[{x:f.x+h*p+x*S,y:f.y+d*p+I*S},{x:f.x+h*g+x*S,y:f.y+d*g+I*S},{x:f.x+h*g-x*M,y:f.y+d*g-I*M},{x:f.x+h*p-x*M,y:f.y+d*p-I*M}];if(!_.every(w=>xt(e,w.x,w.y)))continue;let O=o?.[c]?.belowY,C=O==null?0:l.y-O,F=!!r&&C>.03&&C<=.65;if(F&&r){let w=(B,L)=>Math.hypot((B.x+L.x)/2-r.x,(B.y+L.y)/2-r.y);w(_[0],_[1])>w(_[3],_[2])&&(_=[_[3],_[2],_[1],_[0]])}let k=F?Math.ceil((C-1e-8)/.2):1,E=(w,B,L)=>({x:w.x+(B.x-w.x)*L,y:w.y+(B.y-w.y)*L});for(let w=0;w<k;w++){let B=w/k,L=(w+1)/k,T=[E(_[0],_[3],B),E(_[1],_[2],B),E(_[1],_[2],L),E(_[0],_[3],L)],v=l.y+.008-(F?C*(1-L):0);Z(t,T,void 0,()=>v,v-(F?C/k+.1:.16),s,i,K)}}}}var hl=.02,yl=.012,dl=.01,pl=.3,xl=.5;function bl(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let r=1/0;for(let o=0;o+1<t.length;o++){let s=t[o],i=t[o+1],a=i.x-s.x,c=i.y-s.y,l=a*a+c*c,u=l>1e-12?((n-s.x)*a+(e-s.y)*c)/l:0;u=Math.max(0,Math.min(1,u)),r=Math.min(r,Math.hypot(n-(s.x+u*a),e-(s.y+u*c)))}return r}function gl(t,n,e,r){let o=1/0,s=Number.NaN;for(let i=0;i<t.length;i++){let a=n[i];if(Math.hypot(e-a.cx,r-a.cy)-a.rad>=o)continue;let c=bl(t[i].pts,e,r);c<o&&(o=c,s=t[i].y)}return s}function ei(t,n,e,r,o,s,i){let a=r.filter(m=>m.pts.length>0);if(a.length<2||n.length<3)return;let c=a.map(m=>{let h=0,d=0;for(let b of m.pts)h+=b.x,d+=b.y;h/=m.pts.length,d/=m.pts.length;let y=0;for(let b of m.pts)y=Math.max(y,Math.hypot(b.x-h,b.y-d));return{cx:h,cy:d,rad:y}}),l=[...n],u=e.map(m=>[...m]),f=hl/P;for(let m of[l,...u])for(let h=0;h<m.length;h++){let d=m[h],y=m[(h+1)%m.length],b=y.x-d.x,p=y.y-d.y,g=Math.hypot(b,p);if(g*P<.05)continue;let R=(d.x+y.x)/2,A=(d.y+y.y)/2,M=p/g,x=-b/g;Pt({x:R+M*f,y:A+x*f},l,u)&&(M=-M,x=-x);let I=o.x-R,S=o.y-A,_=Math.hypot(I,S)||1;if((M*I+x*S)/_>xl)continue;let O=1/0;for(let T of[.2,.5,.8]){let v=gl(a,c,d.x+b*T-M*f*2,d.y+p*T-x*f*2);Number.isFinite(v)&&(O=Math.min(O,v))}if(!Number.isFinite(O)||O-s<pl)continue;let C=s-dl,F=O-yl,k={x:(d.x-M*f)*P,z:(d.y-x*f)*P},E={x:(y.x-M*f)*P,z:(y.y-x*f)*P},w=[M,0,x],B=V(i,K.wallBottom),L=V(i,K.top);t.tri([k.x,F,k.z],[E.x,F,E.z],[E.x,C,E.z],w,L,L,B),t.tri([k.x,F,k.z],[E.x,C,E.z],[k.x,C,k.z],w,L,B,B)}}function oi(t,n,e,r,o,s,i,a,c=!1){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,u=e.objects.filter(g=>g.type==="shape"&&(g.role==="entrance"||g.role==="exit")),f=Io(r,a.tierTop);if(!o)return;let m=g=>o.deckAt(g.x,g.y),h=Xo(n,i),d=h[0]??n.outline;if(o.rowLevels.length>=2){let g=Dn(o.rowLevels),R=jo(Lo(o.rowLevels,e.focal,g),h),A=ti(He(o.rowLevels,e.focal,l),e.focal,Ne);for(let x of R){let I=Math.max(l,x.topY-ri);for(let S of s.subtract(x.outline,I))Kr(t,S,x.holes,I,l,a.tierTop,a.tierWall,u,!c,A);t.setMaterial(5),ei(t,x.outline,x.holes,o.rowLevels,e.focal,I,a.tierWall),t.setMaterial(0)}R.length||Z(t,d,n.holes,()=>o.landingY,l,f,a.tierWall,K);let M={tread:[f[0]*K.top,f[1]*K.top,f[2]*K.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let x of h.length?h:[d])No(t,o.rowLevels,e.focal,o.landingY,M,x,g);Jr(t,o.rowLevels,e.focal,l),ni(t,o.rowLevels,n.outline,e.focal,g);return}let y=o.flat?1/0:ar,b=g=>o.normalAt(g.x,g.y),p=o.flat?o.landingY:void 0;for(let g of s.subtract(d,p))Z(t,g,n.holes,m,l,f,a.tierWall,K,y,b)}function Ml(t,n,e){let r=new Set;for(let i of t.objects)i.type==="section"&&r.add(i.id);let o=new Map;for(let i=0;i<n.length;i++){let a=e.seatOwner[i];if(!a||!r.has(a))continue;let c=e.bySection.get(a);if(c&&c.rowLevels.length>=2)continue;let l=n[i];if(l.kind==="booth")continue;let u=o.get(a);u||(u=new Map,o.set(a,u));let f=l.rowId||`__seat-${i}`,m=u.get(f);m||(m={pts:[],levelM:0,n:0},u.set(f,m)),m.pts.push({x:l.x,y:l.y}),m.levelM+=e.seatDeckY(i),m.n++}let s=[];for(let i of t.objects){if(i.type!=="section")continue;let a=e.bySection.get(i.id);if(a&&a.rowLevels.length>=2){let l=a.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));l.length>=2&&s.push({sectionId:i.id,rows:l});continue}let c=o.get(i.id);c&&s.push({sectionId:i.id,rows:[...c.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return s}function Rl(t,n){let e=1/0;for(let r=0;r<n.length;r++){let o=n[r],s=n[(r+1)%n.length],i=s.x-o.x,a=s.y-o.y,c=Math.max(0,Math.min(1,((t.x-o.x)*i+(t.y-o.y)*a)/(i*i+a*a||1)));e=Math.min(e,Math.hypot(t.x-o.x-c*i,t.y-o.y-c*a))}return e}var ri=.02;function Pl(t,n){let e=t.objects.filter(r=>r.type==="section"&&!!r.outline&&r.outline.length>=3).flatMap(r=>{let o=n.bySection.get(r.id);if(!o)return[];let s=1/0,i=-1/0,a=1/0,c=-1/0;for(let u of r.outline)u.x<s&&(s=u.x),u.x>i&&(i=u.x),u.y<a&&(a=u.y),u.y>c&&(c=u.y);let l=o.landingY;for(let u of o.rowLevels)l=Math.min(l,u.y-ri);return[{outline:r.outline,holes:r.holes,surface:o,floorTop:l,minX:s,maxX:i,minY:a,maxY:c}]});return(r,o,s)=>{let i=null;for(let a of e){if(r<a.minX-s||r>a.maxX+s||o<a.minY-s||o>a.maxY+s)continue;let c={x:r,y:o};if(!Pt(c,a.outline,a.holes)&&Rl(c,a.outline)>s)continue;let l=Math.min(a.surface.deckAt(r,o),a.floorTop);(i===null||l<i)&&(i=l)}return i}}var Sl=3,Il=.4;function ii(t,n,e,r,o,s,i=!0){let a=Ml(n,e,r);if(a.length<Sl)return;let c=lo(a,n.focal);if(!c)return;let l=Math.max(0,...c.rings.map(u=>u.arcs.reduce((f,m)=>f+m.binCount,0)))/c.binCount;t.setMaterial(5),Zr(t,c,{bottomY:n.baseHeightM,tierFrontLevels:a.map(u=>Math.min(...u.rows.map(f=>f.levelM))),colors:{bandTop:V(o.tierTop,.8),bandWall:o.tierWall,shellTop:s??V(o.tierWall,1.15),shellWall:s??o.tierWall},ao:K,shapes:n.objects.filter(u=>u.type==="shape"),deriveShell:i&&l>=Il,standTopNear:Pl(n,r)}),t.setMaterial(0)}function si(t){let{doc:n,units:e,seats:r,surfaces:o,solids:s,hintedSeatFloor:i,seatFloor:a}=t,c=[];{let l=e.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let m=0;m<s.floor.length;m+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(s.floor[m]))),d=m*3,y=l[h];y.minX=Math.min(y.minX,s.position[d]),y.minY=Math.min(y.minY,s.position[d+1]),y.minZ=Math.min(y.minZ,s.position[d+2]),y.maxX=Math.max(y.maxX,s.position[d]),y.maxY=Math.max(y.maxY,s.position[d+1]),y.maxZ=Math.max(y.maxZ,s.position[d+2])}let u=new Map;for(let m=0;m<e.length;m++)for(let h of e[m].objects)h.type==="section"&&u.set(h.id,m);let f=e.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let m=0;m<r.length;m++){let h=o.seatOwner[m],d=(h!==null?u.get(h):void 0)??i[m];if(d===void 0)continue;let y=f[d],b=r[m];y.n++,b.x<y.minX&&(y.minX=b.x),b.y<y.minY&&(y.minY=b.y),b.x>y.maxX&&(y.maxX=b.x),b.y>y.maxY&&(y.maxY=b.y);let p=o.seatDeckY(m);y.sumX+=b.x*P,y.sumDeck+=p,y.sumZ+=b.y*P,y.minDeck=Math.min(y.minDeck,p),y.maxDeck=Math.max(y.maxDeck,p+1.6),a[m]=d}for(let m=0;m<e.length;m++){let h=f[m],d=n.floors?.[m],y=l[m],b=Math.min(h.n?h.minX*P:e[m].focal.x*P-1,Number.isFinite(y.minX)?y.minX:1/0),p=Math.max(h.n?h.maxX*P:e[m].focal.x*P+1,Number.isFinite(y.maxX)?y.maxX:-1/0),g=Math.min(h.n?h.minY*P:e[m].focal.y*P-1,Number.isFinite(y.minZ)?y.minZ:1/0),R=Math.max(h.n?h.maxY*P:e[m].focal.y*P+1,Number.isFinite(y.maxZ)?y.maxZ:-1/0),A=Math.min(h.n?Math.min(e[m].baseHeightM,h.minDeck):e[m].baseHeightM,Number.isFinite(y.minY)?y.minY:1/0),M=Math.max(h.n?Math.max(h.maxDeck,A+.5):A+.5,Number.isFinite(y.maxY)?y.maxY:-1/0),x=[h.n?h.sumX/h.n:(b+p)/2,h.n?h.sumDeck/h.n:(A+M)/2,h.n?h.sumZ/h.n:(g+R)/2],I=Math.max(1,.5*Math.hypot(p-b,M-A,R-g));c.push({index:m,id:d?.id??`floor-${m}`,label:d?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:x,radius:I,box:{min:[b,A,g],max:[p,M,R]},focalWorld:[e[m].focal.x*P,e[m].baseHeightM+1.5,e[m].focal.y*P]})}}return c}function je(t,n){let e=1/0,r=1/0,o=-1/0,s=-1/0,i=(a,c)=>{a<e&&(e=a),c<r&&(r=c),a>o&&(o=a),c>s&&(s=c)};for(let a of n)i(a.x,a.y);for(let a of t)for(let c of a.objects)if(c.type==="section")for(let l of c.outline)i(l.x,l.y);else if(c.type==="shape"&&c.points)for(let l of c.points)i(l.x,l.y);else if(c.type==="gaArea")for(let l of c.points)i(l.x,l.y);else if(c.type==="booth"){let l=At(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="table"){let l=$n(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="decorImage"){let l=Qn(c);if(l)for(let u of l)i(u.x,u.y)}return Number.isFinite(e)||(e=-100,r=-100,o=100,s=100),{minX:e,minY:r,maxX:o,maxY:s}}function mi(t,n,e,r,o,s,i){if(n.length===1){let a=e.map(m=>({x:m.x,y:m.y}));for(let m of n[0].objects)m.type==="section"?a.push(...m.outline):m.type==="shape"?a.push(...ct(m)??m.points??[]):m.type==="gaArea"?a.push(...m.points):m.type==="booth"?a.push(...At(m)??[]):m.type==="table"?a.push(...$n(m)??[]):m.type==="decorImage"&&a.push(...Qn(m)??[]);if(li(t,n[0],e,s)||fi(t,n[0],e,a,s))return!1;if(i&&ci(t,n[0].baseHeightM,a,s,i))return!0;let c=hn(a),l=(o.minX+o.maxX)/2,u=(o.minY+o.maxY)/2,f=c.length>=3?c.map(m=>{let h=m.x-l,d=m.y-u,y=Math.max(1,Math.hypot(h,d));return{x:m.x+h/y*80,y:m.y+d/y*80}}):fn(o.minX-28,o.minY-28,o.maxX-o.minX+56,o.maxY-o.minY+56);return Z(t,f,void 0,()=>-.04,-.22,s.ground,s.ground,K),!1}else{let a=n.reduce((b,p)=>p.baseHeightM<b.baseHeightM?p:b);t.setFloor(a.index);let c={...a,objects:n.flatMap(b=>b.objects)},l=e.map(b=>({x:b.x,y:b.y}));for(let b of c.objects)b.type==="section"&&l.push(...b.outline);if(li(t,c,e,s)||fi(t,c,e,l,s))return!1;if(i&&ci(t,a.baseHeightM,l,s,i))return!0;let u=e.filter((b,p)=>r[p]===a.index),f=je([a],u),m=Math.hypot(f.maxX-f.minX,f.maxY-f.minY),h=Math.max(28,Math.min(80,m*.04)),d=fn(f.minX-h,f.minY-h,f.maxX-f.minX+h*2,f.maxY-f.minY+h*2),y=a.baseHeightM-.03;return Z(t,d,void 0,()=>y,y-.22,s.ground,s.ground,K),!1}}function Ue(t,n,e,r){let{cx:o,cz:s,radius:i}=e,a=1/0,c=1/0,l=1/0,u=-1/0,f=-1/0,m=-1/0,h=(b,p,g)=>{a=Math.min(a,b),u=Math.max(u,b),c=Math.min(c,p),f=Math.max(f,p),l=Math.min(l,g),m=Math.max(m,g)};for(let b=0;b<t.position.length;b+=3){let p=b/3;r&&p>=r[0]&&p<r[1]||h(t.position[b],t.position[b+1],t.position[b+2])}for(let b=0;b<n.count;b++){let p=b*3,g=n.iPosition[p],R=n.iPosition[p+1],A=n.iPosition[p+2],M=Math.max(.35,n.iMaxRadius[b]??.35);h(g-M,R,A-M),h(g+M,R+1.6,A+M)}Number.isFinite(a)||(a=o-i,u=o+i,c=0,f=i*.16,l=s-i,m=s+i);let d=[(a+u)/2,(c+f)/2,(l+m)/2],y=Math.max(1,.5*Math.hypot(u-a,f-c,m-l));return{center:d,radius:y,minY:c,maxY:f}}var _l=4096;function hi(t,n,e=[]){let r=Math.max(1,Math.ceil(t.count/_l)),o=Math.ceil(t.count/r),s=new Float32Array((o*2+n.length*4+e.length)*3),i=0;for(let a=0;a<t.count;a+=r){let c=t.iPosition[a*3],l=t.iPosition[a*3+1],u=t.iPosition[a*3+2];s[i++]=c,s[i++]=l,s[i++]=u,s[i++]=c,s[i++]=0,s[i++]=u}for(let[a,c,l]of e)s[i++]=a,s[i++]=c,s[i++]=l;for(let a of n)for(let[c,l]of[[-1,-1],[1,-1],[1,1],[-1,1]])s[i++]=a.cx+c*a.halfX,s[i++]=a.y,s[i++]=a.cz+l*a.halfZ;return s.subarray(0,i)}function yi(t,n,e,r,o,s,i=[]){let a=1/0,c=1/0,l=-1/0,u=-1/0;for(let M=0;M<t.count;M++){let x=M*3,I=t.iPosition[x],S=t.iPosition[x+2];I<a&&(a=I),I>l&&(l=I),S<c&&(c=S),S>u&&(u=S)}for(let[M,,x]of i)M<a&&(a=M),M>l&&(l=M),x<c&&(c=x),x>u&&(u=x);for(let M of n)a=Math.min(a,M.cx-M.halfX),l=Math.max(l,M.cx+M.halfX),c=Math.min(c,M.cz-M.halfZ),u=Math.max(u,M.cz+M.halfZ);let f=e.minX*P,m=e.maxX*P,h=e.minY*P,d=e.maxY*P,y=f,b=m,p=h,g=d;if(Number.isFinite(a)){let M=Math.max(2,.06*Math.hypot(l-a,u-c));y=Math.max(f,a-M),b=Math.min(m,l+M),p=Math.max(h,c-M),g=Math.min(d,u+M)}let R=Math.min(0,r),A=Math.max(o,s*.05);return{min:[y,R,p],max:[b,A,g]}}var ai=12,Al=.6,El=40;function ci(t,n,e,r,o){let s=hn([...e]);if(s.length<3)return!1;let i=1/0,a=1/0,c=-1/0,l=-1/0;for(let A of s)i=Math.min(i,A.x),c=Math.max(c,A.x),a=Math.min(a,A.y),l=Math.max(l,A.y);let u=Math.hypot(c-i,l-a)*P,f=It(s,ai/P,1.2),m=Math.max(El,u*Al),h=It(s,(ai+m)/P,1.2);if(f.length!==h.length)return!1;let d=at(r.ground,[.78,.76,.72],.35),y=at(r.ground,[.56,.62,.52],.3);Z(t,f,void 0,()=>n-.04,n-.22,d,d,K);let b=n-.05,p=f.map(A=>[A.x*P,b,A.y*P]),g=h.map(A=>[A.x*P,b,A.y*P]),R=[0,1,0];for(let A=0;A<p.length;A++){let M=(A+1)%p.length;t.tri(p[A],g[M],g[A],R,y,o,o),t.tri(p[A],p[M],g[M],R,y,y,o)}return!0}function li(t,n,e,r){let o=Nt(n,e);if(!o)return!1;let s=n.baseHeightM,i=at(r.ground,[.62,.55,.47],.4);return Z(t,o,void 0,()=>s-.04,s-.22,i,i,K),!0}var wl=3e3,Bl=20,ui=1.5,Tl=1.2,Ol=.25;function fi(t,n,e,r,o){if(!e.length||e.length>wl||r.length<3)return!1;for(let _ of n.objects){if(_.type==="shape"&&An(_.stageKind))return!1;if(_.type==="section"){let{height:O}=Vt(_,{floorBaseHeightM:n.baseHeightM});if(O-n.baseHeightM>Bl)return!1}}let s=0,i=0;for(let _ of r)s+=_.x,i+=_.y;s/=r.length,i/=r.length;let a=0,c=0,l=0;for(let _ of r){let O=_.x-s,C=_.y-i;a+=O*O,c+=C*C,l+=O*C}let u=.5*Math.atan2(2*l,a-c),f=Math.cos(u),m=Math.sin(u),h=-m,d=f,y=1/0,b=-1/0,p=1/0,g=-1/0;for(let _ of r){let O=(_.x-s)*f+(_.y-i)*m,C=(_.x-s)*h+(_.y-i)*d;y=Math.min(y,O),b=Math.max(b,O),p=Math.min(p,C),g=Math.max(g,C)}let R=_=>[[y-_,p-_],[b+_,p-_],[b+_,g+_],[y-_,g+_]].map(([O,C])=>({x:s+f*O+h*C,y:i+m*O+d*C})),A=R(ui/P),M=R((ui+Ol)/P),x=n.baseHeightM,I=at(o.ground,[.62,.55,.47],.4),S=at(o.ground,[.86,.86,.84],.55);return Z(t,M,void 0,()=>x-.04,x-.22,I,I,K),Z(t,M,[A.slice().reverse()],()=>x+Tl,x-.04,at(S,[1,1,1],.2),S,K),!0}function di(t,n,e){let r=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return r();let o=We(n);if(!o.ok||o.value.id!==t)return r();let s=new Map;for(let f of e)for(let m of f.objects)m.type==="shape"&&s.set(m.id,{shape:m,unit:f});let i=new Set,a=new Set,c=new Map((n.overlay.productionElements??[]).map(f=>{let m=f.runtimeContentImageUrl;return[f.id,typeof m=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(m)?m:void 0]})),l=[];for(let f of o.value.overlay.productionElements??[]){let m=s.get(f.objectId),h=m?ct(m.shape):null,d=f.baseElevationM??0;if(!m||!h||h.length<3||!f.id||i.has(f.id)||a.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(d)||d<-10||d>100)return r();i.add(f.id),a.add(f.objectId);let y=h.map(S=>S.x*P),b=h.map(S=>S.y*P),p=m.unit.baseHeightM+d,g=Math.min(...y),R=Math.max(...y),A=Math.min(...b),M=Math.max(...b),x,I=c.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&I&&(x=or(h,p,p+f.heightM,m.unit.focal),!x))if(R-g>=M-A){let S=Math.abs(A-m.unit.focal.y*P)<=Math.abs(M-m.unit.focal.y*P)?A-.006:M+.006;x=[[g,p,S],[R,p,S],[g,p+f.heightM,S],[R,p+f.heightM,S]]}else{let S=Math.abs(g-m.unit.focal.x*P)<=Math.abs(R-m.unit.focal.x*P)?g-.006:R+.006;x=[[S,p,A],[S,p,M],[S,p+f.heightM,A],[S,p+f.heightM,M]]}l.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:p,topY:p+f.heightM,bounds:{min:[g,p,A],max:[R,p+f.heightM,M]},occlusion:f.occlusion,...I?{contentImageUrl:I}:{},...x?{contentPlane:x}:{}})}let u=l.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(u.map(f=>[f.objectId,f])),elements:u}}var pi=[.13,.14,.17],rn=[.4,.43,.47],Cl=.18,kl=.02,Fl=2.4,Ll=1500,vl=240,Nl=.25;function xi(t,n,e,r){let o=n.stageKind??"";if(Zt(o)||o==="round"||!r.length)return;let s=ct(n);if(!s||s.length<3)return;let i={x:s.reduce((B,L)=>B+L.x,0)/s.length,y:s.reduce((B,L)=>B+L.y,0)/s.length},a=0,c=0,l=new Set;for(let B of r)a+=B.x,c+=B.y,l.add(Math.floor(Math.atan2(B.y-i.y,B.x-i.x)*180/Math.PI/10));let u=i.x-a/r.length,f=i.y-c/r.length,m=Math.hypot(u,f);if(m<1e-6)return;let h=r.reduce((B,L)=>B+Math.hypot(L.x-i.x,L.y-i.y),0)/r.length;if(l.size*10>vl&&m<Nl*h)return;let d=u/m,y=f/m,b=-y,p=d,g=-1/0,R=1/0,A=1/0,M=-1/0;for(let B of s){let L=(B.x-i.x)*d+(B.y-i.y)*y,T=(B.x-i.x)*b+(B.y-i.y)*p;g=Math.max(g,L),R=Math.min(R,L),A=Math.min(A,T),M=Math.max(M,T)}let x=(M-A)*P,I=(g-R)*P;if(x<3||I<1.5||x*I>Ll)return;let S=Cl/P,_=(B,L)=>({x:i.x+d*B+b*L,y:i.y+y*B+p*L}),O=(B,L,T,v)=>[_(B,T),_(B,v),_(L,v),_(L,T)],C=e+Math.max(3.5,Math.min(8,x*.35)),F=e+Math.min(Fl,C-e-1),k=.2/P,E=R+Math.min(I*.25,1.5)/P,w=kl/P;Z(t,O(g-2*S+w,g-S-w,A+S+k,M-S-k),void 0,()=>F,e,pi,pi,K);for(let[B,L]of[[A+S,A+S+k],[M-S-k,M-S]])Z(t,O(g-2*S,g-S,B,L),void 0,()=>C+.3,e,rn,rn,K),Z(t,O(E+k,g-2*S,B,L),void 0,()=>C+.3,C,rn,rn,K);Z(t,O(E,E+k,A+S,M-S),void 0,()=>C+.3,C,rn,rn,K)}function Mt(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function gt(t){return Array.isArray(t)?t:[]}function Gl(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Mt(e))continue;let r=Mt(e.extensions)?e.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function ne(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function Dl(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Hl(t,n){let e=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let s=0;s<4;s++)e[r*4+o]+=t[s*4+o]*n[r*4+s];return e}function Xl(t){let n=ne(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:ne(t.translation,3),r=t.rotation===void 0?[0,0,0,1]:ne(t.rotation,4),o=t.scale===void 0?[1,1,1]:ne(t.scale,3);if(!e||!r||!o)return null;let[s,i,a,c]=r,l=Math.hypot(s,i,a,c);if(!(l>1e-8))return null;let u=s/l,f=i/l,m=a/l,h=c/l,d=u+u,y=f+f,b=m+m,p=u*d,g=u*y,R=u*b,A=f*y,M=f*b,x=m*b,I=h*d,S=h*y,_=h*b;return[(1-(A+x))*o[0],(g+_)*o[0],(R-S)*o[0],0,(g-_)*o[1],(1-(p+x))*o[1],(M+I)*o[1],0,(R+S)*o[2],(M-I)*o[2],(1-(p+A))*o[2],0,e[0],e[1],e[2],1]}function jl(t,n,e,r){return[t[0]*n+t[4]*e+t[8]*r+t[12],t[1]*n+t[5]*e+t[9]*r+t[13],t[2]*n+t[6]*e+t[10]*r+t[14]]}function Ul(t){let n=t[0],e=t[4],r=t[8],o=t[1],s=t[5],i=t[9],a=t[2],c=t[6],l=t[10],u=s*l-i*c,f=i*a-o*l,m=o*c-s*a,h=n*u+e*f+r*m;if(Math.abs(h)<1e-12)return null;let d=1/h;return[u*d,f*d,m*d,(r*c-e*l)*d,(n*l-r*a)*d,(e*a-n*c)*d,(e*i-r*s)*d,(r*o-n*i)*d,(n*s-e*o)*d]}function bi(t,n,e,r){let o=t[0]*n+t[1]*e+t[2]*r,s=t[3]*n+t[4]*e+t[5]*r,i=t[6]*n+t[7]*e+t[8]*r,a=Math.hypot(o,s,i)||1;return o/=a,s/=a,i/=a,[o,s,i]}function Wl(t){if(t.byteLength<20||t.byteLength>8388608)return null;let n=new DataView(t.buffer,t.byteOffset,t.byteLength);if(n.getUint32(0,!0)!==1179937895||n.getUint32(4,!0)!==2||n.getUint32(8,!0)!==t.byteLength)return null;let e=12,r=null,o=null;for(;e+8<=t.byteLength;){let s=n.getUint32(e,!0),i=n.getUint32(e+4,!0);if(e+=8,s%4!==0||e+s>t.byteLength)return null;let a=t.subarray(e,e+s);if(i===1313821514&&!r)try{let c=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!Mt(c))return null;r=c}catch{return null}else if(i===5130562&&!o)o=a;else return null;e+=s}return e===t.byteLength&&r&&o?{json:r,bin:o}:null}function Yl(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function zl(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Kl(t,n,e){return e===5120?t.getInt8(n):e===5121?t.getUint8(n):e===5122?t.getInt16(n,!0):e===5123?t.getUint16(n,!0):e===5125?t.getUint32(n,!0):t.getFloat32(n,!0)}function Vl(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Wl(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=e;if(!Mt(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let s=gt(r.extensionsUsed).filter(A=>typeof A=="string");if(s.includes("KHR_draco_mesh_compression")||Gl(r))return{ok:!1,issue:"draco_not_allowed"};if(s.length||gt(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(gt(r.images).length||gt(r.textures).length)return{ok:!1,issue:"external_resource"};let i=gt(r.buffers);if(i.length!==1||!Mt(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let a=gt(r.accessors),c=gt(r.bufferViews),l=gt(r.meshes),u=gt(r.nodes),f=gt(r.scenes),m=typeof r.scene=="number"?r.scene:0;if(!Mt(f[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(o.buffer,o.byteOffset,o.byteLength),d=(A,M,x)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(a[A]))return null;let I=a[A];if(I.type!==M||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!x.includes(I.componentType)||typeof I.bufferView!="number")return null;let S=c[I.bufferView];if(!Mt(S)||S.buffer!==0||typeof S.byteLength!="number"||!Number.isInteger(S.byteLength)||S.byteLength<0)return null;let _=zl(I.type),O=Yl(I.componentType),C=typeof S.byteStride=="number"?S.byteStride:_*O,F=typeof S.byteOffset=="number"?S.byteOffset:0,k=typeof I.byteOffset=="number"?I.byteOffset:0,E=F+k,w=k+(I.count-1)*C+_*O;if(!Number.isInteger(C)||!Number.isInteger(F)||!Number.isInteger(k)||C<_*O||F<0||k<0||F+S.byteLength>o.byteLength||w>S.byteLength)return null;let B=[];for(let L=0;L<I.count;L++){let T=[];for(let v=0;v<_;v++){let H=Kl(h,E+L*C+v*O,I.componentType);if(!Number.isFinite(H))return null;T.push(H)}B.push(T)}return B},y=[],b=[],p=0,g=new Set,R=(A,M)=>{if(typeof A!="number"||!Number.isInteger(A)||!Mt(u[A])||g.has(A))return!1;g.add(A);let x=u[A],I=Xl(x);if(!I)return!1;let S=Hl(M,I),_=Ul(S);if(!_)return!1;if(x.mesh!==void 0){if(typeof x.mesh!="number")return!1;let O=l[x.mesh];if(!Mt(O))return!1;for(let C of gt(O.primitives)){if(!Mt(C)||C.mode!==void 0&&C.mode!==4||!Mt(C.attributes))return!1;let F=d(C.attributes.POSITION,"VEC3",[5126]),k=C.attributes.NORMAL===void 0?null:d(C.attributes.NORMAL,"VEC3",[5126]);if(!F||C.attributes.NORMAL!==void 0&&!k)return!1;let E=F.length;if(C.indices!==void 0){let B=typeof C.indices=="number"?a[C.indices]:null;E=Mt(B)?B.count:void 0}if(typeof E!="number"||!Number.isInteger(E)||E%3!==0||(p+=E/3,p>1e5))return!1;let w=C.indices===void 0?F.map((B,L)=>[L]):d(C.indices,"SCALAR",[5121,5123,5125]);if(!w||w.length%3!==0||w.length!==E)return!1;for(let B=0;B<w.length;B+=3){let L=[w[B][0],w[B+1][0],w[B+2][0]];if(L.some(H=>!Number.isInteger(H)||H<0||H>=F.length))return!1;let T=L.map(H=>jl(S,...F[H])),v=null;if(!k){let H=T[1][0]-T[0][0],j=T[1][1]-T[0][1],D=T[1][2]-T[0][2],U=T[2][0]-T[0][0],X=T[2][1]-T[0][1],Y=T[2][2]-T[0][2];v=bi([1,0,0,0,1,0,0,0,1],j*Y-D*X,D*U-H*Y,H*X-j*U)}for(let H=0;H<3;H++)y.push(...T[H]),b.push(...k?bi(_,...k[L[H]]):v)}}}for(let O of gt(x.children))if(!R(O,S))return!1;return g.delete(A),!0};for(let A of gt(f[m].nodes))if(!R(A,Dl()))return{ok:!1,issue:p>1e5?"triangle_limit":"unsupported_glb"};return!p||y.length!==p*9||b.length!==y.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:p,position:new Float32Array(y),normal:new Float32Array(b)}}function gi(t){try{return Vl(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function td(t){let{doc:n}=t,e=jr(n.theme),r=e.structure,o=Ho(n,t.eventConfigurationId??n.eventConfigurationId),s=di(t.eventConfigurationId,t.eventConfiguration,o),i=t.seats,a=new vn,c=null;if(t.registeredShellGlb){let N=gi(t.registeredShellGlb);if(N.ok){let G=N.position.length/3,W=new Float32Array(N.position.length),lt=e.materials.shell??r.tierWall;for(let ft=0;ft<G;ft++){let st=N.normal[ft*3+1],tt=st<-.25?.4:.62+.38*Math.max(0,st);W[ft*3]=lt[0]*tt,W[ft*3+1]=lt[1]*tt,W[ft*3+2]=lt[2]*tt}c={position:N.position,normal:N.normal,color:W,floor:new Float32Array(G).fill(-2),material:new Float32Array(G),count:G}}}let l=new Map;for(let N of o)for(let G of N.objects)l.set(G.id,N.index),G.type==="section"&&l.set(G.logicalSectionId??G.id,N.index);let u=i.map(N=>l.get(N.sectionId??"")??l.get(N.rowId??"")??0),f=je(o,i),m=a.vertexCount,d=mi(a,o,i,u,f,r,at(e.background.top,e.background.bottom,.5))?a.vertexCount:m,y=_o(n,i),b=new Map,p=new Map;for(let N of n.categories??[])b.set(N.key,N.color),N.seatGlyph&&p.set(N.key,N.seatGlyph);let g=[],R=cr(o,i,u),A=new Map;i.forEach((N,G)=>{let W=R.seatDeckY(G);Number.isFinite(W)&&A.set(N.rowId,Math.min(A.get(N.rowId)??1/0,W))});let M=new Float32Array(i.length),x=[],I=new Map((n.floors??[]).map((N,G)=>[N.id,G])),S=o.map(()=>[]);for(let N of i){let G=N.floorId?I.get(N.floorId)??0:0;S[Math.min(G,S.length-1)]?.push(N)}let _=(N,G)=>{if(!G||G.length<3)return!1;let W=Math.min(...G.map(tt=>tt.x)),lt=Math.max(...G.map(tt=>tt.x)),ft=Math.min(...G.map(tt=>tt.y)),st=Math.max(...G.map(tt=>tt.y));for(let tt=0;tt<N;tt++)for(let et of S[tt])if(!(et.x<W||et.x>lt||et.y<ft||et.y>st)&&Pt(et,G,void 0))return!0;return!1},O=null,C=N=>o.length===1?i:i.filter((G,W)=>u[W]===N),F=(N,G)=>{let W=At(N);if(!W)return!1;let lt=1/0,ft=1/0,st=-1/0,tt=-1/0;for(let et of W)lt=Math.min(lt,et.x),st=Math.max(st,et.x),ft=Math.min(ft,et.y),tt=Math.max(tt,et.y);return i.some((et,ht)=>et.kind!=="booth"&&(o.length===1||u[ht]===G)&&et.x>lt&&et.x<st&&et.y>ft&&et.y<tt&&xt(W,et.x,et.y))},k;for(let N=0;N<o.length;N++){let G=o[N];a.setFloor(N);let W=Nt(G,C(N)),lt=0;if(W){let z=0;for(let mt of G.objects)if(mt.type==="section")for(let yt of R.bySection.get(mt.id)?.rowLevels??[])z=Math.max(z,yt.y-G.baseHeightM);if(lt=zo(z),!k){let mt=Jt(W);k={centre:[mt.x*P,mt.y*P]}}}let ft=new Hn,st=[],tt=G.objects.filter(z=>z.type==="shape"&&(z.role==="entrance"||z.role==="exit")),et=G.objects.filter(z=>z.type==="section"&&!!z.outline&&z.outline.length>=3),ht=Yr(G.objects.filter(z=>z.type==="booth"),G.focal);for(let z of G.objects)if(z.type==="section"){let mt=a.vertexCount;oi(a,z,G,Ao(z,y),R.bySection.get(z.id),ft,et,r,N>0&&_(N,z.outline));let yt=a.vertexCount-mt;yt>0&&x.push({sectionId:z.id,start:mt,count:yt})}else if(z.type==="shape"){let mt=s.byObjectId.get(z.id),yt=g.length,Dt=W!==null&&z.role==="wall"&&!mt;a.setMaterial(Dt?Xn:(mt?.kind??z.role)==="screen"?1:0);let Ht=z.role==="stage"&&!mt?zr(z,C(N)):Dt&&z.heightM===void 0?{...z,heightM:lt}:z,kt=Wo(Ht,st);if(Ar(a,Ht,G.baseHeightM+kt.supportOffsetM,kt.topOffsetM-kt.supportOffsetM,r,G.focal,g,mt,tt),a.setMaterial(0),z.role==="stage"&&!mt&&g.length>yt&&(O??N)===N){O=N;let Ft=n.floors?.[N]?.id,sn=o.length>1&&Ft?i.filter(Pn=>Pn.floorId===Ft):i;xi(a,Ht,g[g.length-1].y,sn)}}else z.type==="gaArea"?wr(a,z,G.baseHeightM,it(b.get(z.categoryKey)),r):z.type==="booth"?Sr(a,z,G.baseHeightM,it(b.get(z.categoryKey)),r,ht.get(z.id)??G.focal,F(z,N)):z.type==="table"?_r(a,z,Math.max(G.baseHeightM,A.get(z.id)??G.baseHeightM),it(z.fill??n.theme?.decorFill??"#232c40"),r,!!(z.fill??n.theme?.decorFill)):z.type==="decorImage"&&Er(a,z,G.baseHeightM,r);W&&Or(a,G.objects,W,G.baseHeightM,lt,G.focal,r,z=>!s.byObjectId.has(z.id)),ii(a,G,i,R,r,e.materials.shell,!c)}let E=o.length>1?{x:o.reduce((N,G)=>N+G.focal.x,0)/o.length,y:o.reduce((N,G)=>N+G.focal.y,0)/o.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},w=bo(c?[a.build(),c]:[a.build()]),B=Po(i,t.initialState,R,M,b,p),L=Nr({doc:n,units:o,seats:i,surfaces:R,focal:E}),{labels:T,sections:v,rows:H}=Gr({doc:n,units:o,seats:i,surfaces:R,seatData:B,hintedSeatFloor:u,zones:L,focal:E}),j=new Map(v.map((N,G)=>[N.id,G]));R.seatOwner.forEach((N,G)=>{B.iSection[G]=N?j.get(N)??-1:-1});let D=si({doc:n,units:o,seats:i,surfaces:R,solids:w,hintedSeatFloor:u,seatFloor:M});Dr(T,D),B.iYaw=Ro(B.iPosition,i.length,N=>i[N].rowId,N=>{let G=o[M[N]]?.focal??E;return[G.x*P,G.y*P]});let U=(f.minX+f.maxX)/2*P,X=(f.minY+f.maxY)/2*P,Y=.5*Math.hypot((f.maxX-f.minX)*P,(f.maxY-f.minY)*P)||10,nt=Ue(w,B,{cx:U,cz:X,radius:Y},[m,d]),rt=Ue(w,B,{cx:U,cz:X,radius:Y}),q=Zl(o),Q=yi(B,g,f,nt.minY,nt.maxY,Y,q);return{sharedAisles:Hr(o.flatMap(N=>N.objects.flatMap(G=>{if(G.type!=="section")return[];let W=R.bySection.get(G.id);return W?[{sectionId:G.id,floorIndex:N.index,rows:W.rowLevels}]:[]}))),solids:w,sectionSolidRanges:x,seats:B,seatSectionIds:R.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:Y,groundY:0,box:Q,fitPoints:hi(B,g,q)},...k?{room:k}:{},...!k&&o.some(N=>N.objects.some(G=>G.type==="shape"&&An(G.stageKind)))?{outdoor:!0}:{},renderBounds:{center:nt.center,radius:nt.radius},clipBounds:{center:rt.center,radius:rt.radius},stateColorLUT:Ur(e,cn),theme:e,seatCount:i.length,focalWorld:[E.x*P,1.5,E.y*P],zones:L,stages:g,productionElements:s.elements,sections:v,rows:H,labels:T,floors:D}}function Zl(t){let n=[];for(let e of t)for(let r of e.objects){let o=r.type==="gaArea"?r.points:r.type==="booth"?At(r):null;for(let s of o??[])n.push([s.x*P,e.baseHeightM,s.y*P])}return n}function ql(t,n){let{doc:e,report:r}=er(t),o=r.confident&&(r.sections.length>0||!!r.looseRowBlocks);if(!o&&!r.roles?.length)return null;if(!o){let c=new Map(r.roles.map(h=>[h.id,h.role])),l=h=>h.map(d=>d.type==="shape"&&c.has(d.id)?{...d,role:c.get(d.id)}:d),u=t.floors?.map(h=>({...h,objects:l(h.objects)})),f=new Float64Array(n.length).fill(Number.NaN),m=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((h,d)=>{h.eyeHeightM!==void 0&&(f[d]=h.eyeHeightM),h.focalPoint&&(m[d*2]=h.focalPoint.x,m[d*2+1]=h.focalPoint.y)}),{doc:{...t,objects:u?.[0]?.objects??l(t.objects),...u?{floors:u}:{}},report:r,eyeHeightM:f,focal:m}}let s=new Map(En(e).map(c=>[c.id,c])),i=new Float64Array(n.length).fill(Number.NaN),a=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((c,l)=>{let u=s.get(c.id)??c;u.eyeHeightM!==void 0&&(i[l]=u.eyeHeightM),u.focalPoint&&(a[l*2]=u.focalPoint.x,a[l*2+1]=u.focalPoint.y)}),{doc:e,report:r,eyeHeightM:i,focal:a}}function $l(t,n){return t.map((e,r)=>{let o=n.eyeHeightM[r],s=n.focal[r*2],i=n.focal[r*2+1],a={...e};return Number.isNaN(o)?delete a.eyeHeightM:a.eyeHeightM=o,Number.isNaN(s)?delete a.focalPoint:a.focalPoint={x:s,y:i},a})}function rd(t){let n=t.estimate===!1?null:ql(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:$l(t.seats,n)},estimate:n}:{input:t}}export{lu as a,Fi as b,Li as c,go as d,vi as e,uu as f,cn as g,ae as h,kn as i,nu as j,le as k,P as l,Gn as m,gu as n,Mu as o,er as p,lf as q,uf as r,ff as s,mf as t,hf as u,yf as v,Re as w,df as x,pf as y,xf as z,bf as A,gf as B,Tc as C,td as D,ql as E,$l as F,rd as G};
|