@seatlayer/core 0.110.1 → 0.112.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.
Files changed (137) hide show
  1. package/dist/ar-IOQUWTKM.js +1 -0
  2. package/dist/be-XLR5WTXS.js +1 -0
  3. package/dist/bg-AVCWLASZ.js +1 -0
  4. package/dist/ca-TKG35ICB.js +1 -0
  5. package/dist/{chunk-5IADCFUU.js → chunk-5FIX35HN.js} +1 -1
  6. package/dist/{chunk-6CBJBESS.js → chunk-5GHPGPWE.js} +1 -1
  7. package/dist/{chunk-GWGWNBGU.js → chunk-AZWAP4OE.js} +1 -1
  8. package/dist/chunk-BXQQKDIX.js +1 -0
  9. package/dist/{chunk-NVAF2E7Q.js → chunk-FZ74MVKY.js} +1 -1
  10. package/dist/{chunk-GVVZR3YS.js → chunk-MN4M5QZ4.js} +1 -1
  11. package/dist/chunk-N6K5NQYG.js +1 -0
  12. package/dist/{chunk-2VYFNNYC.js → chunk-NQLQNJV2.js} +1 -1
  13. package/dist/{chunk-ZY6WTPTI.js → chunk-NXS6JFBI.js} +1 -1
  14. package/dist/{chunk-DLHW3UDD.js → chunk-XWTAFHYQ.js} +1 -1
  15. package/dist/{chunk-YRDOE3N7.js → chunk-Z6YGWTT3.js} +1 -1
  16. package/dist/core/chart-ops/index.cjs +1 -1
  17. package/dist/core/chart-ops/index.d.cts +1 -1
  18. package/dist/core/chart-ops/index.d.ts +1 -1
  19. package/dist/core/chart-ops/index.js +1 -1
  20. package/dist/core/inventory/index.cjs +1 -1
  21. package/dist/core/inventory/index.d.cts +2 -2
  22. package/dist/core/inventory/index.d.ts +2 -2
  23. package/dist/core/inventory/index.js +1 -1
  24. package/dist/core/layout/index.cjs +1 -1
  25. package/dist/core/layout/index.d.cts +2 -2
  26. package/dist/core/layout/index.d.ts +2 -2
  27. package/dist/core/layout/index.js +1 -1
  28. package/dist/core/quality/index.d.cts +2 -2
  29. package/dist/core/quality/index.d.ts +2 -2
  30. package/dist/core/sections/index.d.cts +1 -1
  31. package/dist/core/sections/index.d.ts +1 -1
  32. package/dist/core/sections/index.js +1 -1
  33. package/dist/cs-JRLKXXM5.js +1 -0
  34. package/dist/cy-W3CYXTOV.js +1 -0
  35. package/dist/da-HG4PFYWH.js +1 -0
  36. package/dist/de-KOM2AXXJ.js +1 -0
  37. package/dist/el-NBRQ66EQ.js +1 -0
  38. package/dist/es-AVEG4ZNM.js +1 -0
  39. package/dist/et-33PIOTI4.js +1 -0
  40. package/dist/fa-CDV2VTXV.js +1 -0
  41. package/dist/fi-TKATIOE6.js +1 -0
  42. package/dist/fr-TMDNSR5N.js +1 -0
  43. package/dist/he-4G7OVLJX.js +1 -0
  44. package/dist/hi-XKXNYPYF.js +1 -0
  45. package/dist/hr-BX444QNM.js +1 -0
  46. package/dist/hu-FM46JMDP.js +1 -0
  47. package/dist/id-CBVTYGFP.js +1 -0
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.d.cts +42 -31
  50. package/dist/index.d.ts +42 -31
  51. package/dist/index.js +1 -1
  52. package/dist/it-ZOFOAG6E.js +1 -0
  53. package/dist/ja-NKEBMXTO.js +1 -0
  54. package/dist/ko-RUCELYV7.js +1 -0
  55. package/dist/ku-KKYBDVSA.js +1 -0
  56. package/dist/localeLoaders-YQXZZVNH.js +1 -0
  57. package/dist/lt-3CJ37W7A.js +1 -0
  58. package/dist/lv-H37RDMRX.js +1 -0
  59. package/dist/ms-E5RVBRE6.js +1 -0
  60. package/dist/nl-QHEOTQ7U.js +1 -0
  61. package/dist/no-43HJQ5MK.js +1 -0
  62. package/dist/pl-4LKJHMFJ.js +1 -0
  63. package/dist/pt-LSSE5QHE.js +1 -0
  64. package/dist/{renderedQuality-Frgw6jdx.d.cts → renderedQuality-BDc6pV7R.d.cts} +1 -1
  65. package/dist/{renderedQuality-Dzo2_8f4.d.ts → renderedQuality-OWT2aLPO.d.ts} +1 -1
  66. package/dist/{renderer-DuieD7jP.d.ts → renderer-D-duCvfP.d.ts} +1 -1
  67. package/dist/{renderer-DM2sv1un.d.cts → renderer-DCqApkrq.d.cts} +1 -1
  68. package/dist/ro-U2QASPIY.js +1 -0
  69. package/dist/ru-PTMWREXY.js +1 -0
  70. package/dist/sk-AY2N2ORA.js +1 -0
  71. package/dist/sl-5MQJVNB7.js +1 -0
  72. package/dist/sr-25FTJPUA.js +1 -0
  73. package/dist/{stage-CKb7aNoH.d.cts → stage-BtqKu5aX.d.cts} +1 -1
  74. package/dist/{stage-CKb7aNoH.d.ts → stage-BtqKu5aX.d.ts} +1 -1
  75. package/dist/sv-7VQX4BFH.js +1 -0
  76. package/dist/{tableSizing-C6EjKNnk.d.cts → tableSizing-BhVtwdmX.d.cts} +1 -1
  77. package/dist/{tableSizing-BDePQyPD.d.ts → tableSizing-CYuKHCfd.d.ts} +1 -1
  78. package/dist/th-E53HQMDC.js +1 -0
  79. package/dist/{ticketRestrictions-D5wgOq4P.d.ts → ticketRestrictions-CbFX7kwu.d.ts} +1 -1
  80. package/dist/{ticketRestrictions-CgYwHQOf.d.cts → ticketRestrictions-DgyhuPyA.d.cts} +1 -1
  81. package/dist/tr-IIR6E7OD.js +1 -0
  82. package/dist/uk-HBINQ4XE.js +1 -0
  83. package/dist/vi-TX6I5RWN.js +1 -0
  84. package/dist/view3d/index.cjs +195 -77
  85. package/dist/view3d/index.d.cts +260 -79
  86. package/dist/view3d/index.d.ts +260 -79
  87. package/dist/view3d/index.js +193 -75
  88. package/dist/view3d/scene/scene.worker.cjs +1 -1
  89. package/dist/view3d/scene/scene.worker.js +1 -1
  90. package/dist/zh-Hans-7QNBTEYC.js +1 -0
  91. package/dist/zh-Hant-6KK3D42X.js +1 -0
  92. package/package.json +1 -1
  93. package/dist/ar-C5PA2DVE.js +0 -1
  94. package/dist/be-TMKSMYPN.js +0 -1
  95. package/dist/bg-V6HTEDUB.js +0 -1
  96. package/dist/ca-CTZMHWW4.js +0 -1
  97. package/dist/chunk-3V32MDJI.js +0 -1
  98. package/dist/chunk-4AGC7B64.js +0 -1
  99. package/dist/cs-FUDGOUFL.js +0 -1
  100. package/dist/cy-5RRARIAP.js +0 -1
  101. package/dist/da-PONPPWKY.js +0 -1
  102. package/dist/de-PKG7AAB5.js +0 -1
  103. package/dist/el-H7OFU4QQ.js +0 -1
  104. package/dist/es-QSW5IZ6U.js +0 -1
  105. package/dist/et-GTMPSS72.js +0 -1
  106. package/dist/fa-SGLTFGJF.js +0 -1
  107. package/dist/fi-7YTEAVDM.js +0 -1
  108. package/dist/fr-ECCQ24MZ.js +0 -1
  109. package/dist/he-YHMMDOX7.js +0 -1
  110. package/dist/hi-GRAQX2E6.js +0 -1
  111. package/dist/hr-MN33LRIJ.js +0 -1
  112. package/dist/hu-NW3SMQVM.js +0 -1
  113. package/dist/id-3OPRAUF7.js +0 -1
  114. package/dist/it-RYM74YWO.js +0 -1
  115. package/dist/ja-4NI6DG5D.js +0 -1
  116. package/dist/ko-C4F6UEMK.js +0 -1
  117. package/dist/ku-DMSBMWTC.js +0 -1
  118. package/dist/localeLoaders-G3GCGLPW.js +0 -1
  119. package/dist/lt-3EXKKZFG.js +0 -1
  120. package/dist/lv-4EWNRDCG.js +0 -1
  121. package/dist/ms-7LJBSAEJ.js +0 -1
  122. package/dist/nl-GWTIWXRW.js +0 -1
  123. package/dist/no-T3FW2WLX.js +0 -1
  124. package/dist/pl-OG5OBRHR.js +0 -1
  125. package/dist/pt-YQ6VES5R.js +0 -1
  126. package/dist/ro-VK5MASYF.js +0 -1
  127. package/dist/ru-YU5CYR6T.js +0 -1
  128. package/dist/sk-CE7PXAYL.js +0 -1
  129. package/dist/sl-EYUPV4BG.js +0 -1
  130. package/dist/sr-PPXCN4IK.js +0 -1
  131. package/dist/sv-WR2BJBCJ.js +0 -1
  132. package/dist/th-JUB2DODR.js +0 -1
  133. package/dist/tr-GFHA7FT6.js +0 -1
  134. package/dist/uk-3FTS2SRK.js +0 -1
  135. package/dist/vi-7OTXPOQV.js +0 -1
  136. package/dist/zh-Hans-FD4XNYUA.js +0 -1
  137. package/dist/zh-Hant-7TXVJKJQ.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as vr,c as Hr,d as Ur}from"./chunk-5GHPGPWE.js";import{b as wr,c as kr,d as Gr,e as Nr,h as Dr}from"./chunk-PBXGWYB4.js";import{a as Nn,w as jr}from"./chunk-NQLQNJV2.js";import{a as Lr,c as Gn,d as Kt,f as kt,i as Fr}from"./chunk-Z6YGWTT3.js";import{e as Or,l as Cr}from"./chunk-JQBJZMLG.js";import{n as mo}from"./chunk-GUNNA5LB.js";import{h as Ie}from"./chunk-URW7MSCJ.js";import{Aa as qt,Ba as Ee,C as Rr,Ca as Fn,D as kn,Da as Ar,Ea as Pr,Ga as Er,Ja as uo,La as fo,_a as $t,ca as _r,da as Sr,hb as we,j as Mr,ka as st,la as Zt,ua as Ae,va as Ln,wa as Pe,ya as Ir}from"./chunk-BXQQKDIX.js";import{A as cn,D as Tr,b as Br,d as ht,y as lt}from"./chunk-JBOTRSMY.js";var ho=t=>t<=.04045?t/12.92:((t+.055)/1.055)**2.4,yo=t=>t<=.0031308?12.92*t:1.055*Math.max(0,t)**.4166666666666667-.055,po=t=>Math.min(1,Math.max(0,t));function Te(t){let n=ho(t[0]),e=ho(t[1]),o=ho(t[2]),r=Math.cbrt(.4122214708*n+.5363325363*e+.0514459929*o),a=Math.cbrt(.2119034982*n+.6806995451*e+.1073969566*o),i=Math.cbrt(.0883024619*n+.2817188376*e+.6299787005*o);return[.2104542553*r+.793617785*a-.0040720468*i,1.9779984951*r-2.428592205*a+.4505937099*i,.0259040371*r+.7827717662*a-.808675766*i]}function Be([t,n,e]){let o=(t+.3963377774*n+.2158037573*e)**3,r=(t-.1055613458*n-.0638541728*e)**3,a=(t-.0894841775*n-1.291485548*e)**3;return[po(yo(4.0767416621*o-3.3077115913*r+.2309699292*a)),po(yo(-1.2684380046*o+2.6097574011*r-.3413193965*a)),po(yo(-.0041960863*o-.7034186147*r+1.707614701*a))]}var Oe=t=>Te(t)[0];function $n(t){let[,n,e]=Te(t);return Math.hypot(n,e)}function An(t,n,e){let[,o,r]=Te(t);if(e===void 0)return Be([n,o,r]);let a=Math.hypot(o,r),i=a===0?0:e/a;return Be([n,o*i,r*i])}function Xr(t,n,e){let[o,r,a]=Te(t);return o>=n&&o<=e?t:Be([Math.min(e,Math.max(n,o)),r,a])}function Ce(t){return Be([t,-.004,-.008])}var Jn=["available","held","sold","selected","dimmed"];function xo(t){let n=Jn.indexOf(t);return n<0?0:n}var Wr={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};function Va(t){let n=.2126*t[0]+.7152*t[1]+.0722*t[2],e=.78,o=.86;return[(n+(t[0]-n)*e)*o,(n+(t[1]-n)*e)*o,(n+(t[2]-n)*e)*o]}var Vr={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}},ke=.012;function gn(t){return Oe(t.tierTop)>.6}function Pn(t){return t?Vr.day:Vr.night}function Uh(t,n){let e=Pn(n);return Xr(Va(t),e.seatMin,e.seatMax)}var bo={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]},go={top:[.05,.06,.08],bottom:[.1,.12,.15]};function W(t,n){return[Math.min(1,t[0]*n),Math.min(1,t[1]*n),Math.min(1,t[2]*n)]}import Wa from"earcut";import zr from"polygon-clipping";var _=st,Ka=.002;function za(t,n,e){let o=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),r=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),a=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),i=Math.max(o,r,a);if(i<1e-9)return!0;let s=(o+r+a)/2;return 2*Math.sqrt(Math.max(0,s*(s-o)*(s-r)*(s-a)))/i<Ka}var ne=-2,En=class{constructor(n=16384){this.len=0;this.buf=new Float32Array(n)}push3(n,e,o){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++]=o}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 o=new Float32Array(e);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Ge=class{constructor(){this.pos=new En;this.nor=new En;this.col=new En;this.flr=new En;this.mat=new En;this.currentFloor=0;this.currentMaterial=0}setFloor(n){this.currentFloor=n}setMaterial(n){this.currentMaterial=n}tri(n,e,o,r,a,i=a,s=a,c){if(za(n,e,o))return;this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor);let l=this.currentMaterial;this.mat.push1(c?.[0]??l),this.mat.push1(c?.[1]??l),this.mat.push1(c?.[2]??l)}triN(n,e,o,r,a,i,s,c=s,l=s){[...n,...e,...o].every(Number.isFinite)&&(this.pos.push3(n[0],n[1],n[2]),this.pos.push3(e[0],e[1],e[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(a[0],a[1],a[2]),this.nor.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(c[0],c[1],c[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Ya(t,n,e){let o=n[0]-t[0],r=n[1]-t[1],a=n[2]-t[2],i=e[0]-t[0],s=e[1]-t[1],c=e[2]-t[2],l=r*c-a*s,u=a*i-o*c,f=o*s-r*i,m=Math.hypot(l,u,f)||1;return l/=m,u/=m,f/=m,[l,u,f]}function Za(t,n){let e=[...t],o=[];for(let i of t)o.push(i.x,i.y);let r=[];if(n){for(let i of n)if(!(i.length<3)){r.push(e.length);for(let s of i)e.push(s),o.push(s.x,s.y)}}let a=Wa(o,r.length?r:void 0,2);return{pts:e,tris:a}}function ln(t){return Kt(t)<0?[...t].reverse():t}var qa=3;function $a(t,n,e,o){let r=o(t),a=o(n),i=o(e),s=(h,y,d,x)=>Math.abs(o({x:(h.x+y.x)/2,y:(h.y+y.y)/2})-(d+x)/2),c=(t.x+n.x+e.x)/3,l=(t.y+n.y+e.y)/3,u=(r+a+i)/3,f=Math.max(s(t,n,r,a),s(n,e,a,i),s(e,t,i,r),Math.abs(o({x:c,y:l})-u)),m=(h,y,d)=>{let x=Math.abs(o({x:(h+c)/2,y:(y+l)/2})-(d+u)/2);x>f&&(f=x)};return m((t.x+n.x)/2,(t.y+n.y)/2,(r+a)/2),m((n.x+e.x)/2,(n.y+e.y)/2,(a+i)/2),m((e.x+t.x)/2,(e.y+t.y)/2,(i+r)/2),f}function Qn(t,n,e,o,r){if(r<=0)return $a(t,n,e,o);let a={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},s={x:(e.x+t.x)/2,y:(e.y+t.y)/2};return Math.max(Qn(t,a,s,o,r-1),Qn(a,n,i,o,r-1),Qn(s,i,e,o,r-1),Qn(a,i,s,o,r-1))}function te(t,n,e,o,r,a,i,s){if(i>0){let m={x:(n.x+e.x)/2,y:(n.y+e.y)/2},h={x:(e.x+o.x)/2,y:(e.y+o.y)/2},y={x:(o.x+n.x)/2,y:(o.y+n.y)/2};te(t,n,m,y,r,a,i-1,s),te(t,m,e,h,r,a,i-1,s),te(t,y,h,o,r,a,i-1,s),te(t,m,h,y,r,a,i-1,s);return}let c=[n.x*_,r(n),n.y*_],l=[e.x*_,r(e),e.y*_],u=[o.x*_,r(o),o.y*_];if(s){t.triN(c,l,u,s(n),s(e),s(o),a);return}let f=Ya(c,l,u);f[1]<0&&(f=[-f[0],-f[1],-f[2]]),t.tri(c,l,u,f,a)}var Ja=8;function Kr(t,n,e){if(!Number.isFinite(e))return t;let o=[],r=(a,i,s,c,l)=>{if(l>0){let u={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=n(u);if(Math.abs(f-(s+c)/2)>e){r(a,u,s,f,l-1),r(u,i,f,c,l-1);return}}o.push(a)};for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length];r(i,s,n(i),n(s),Ja)}return o}function Le(t,n){if(t.length<3)return t;let e=[];for(let r of t){let a=e[e.length-1];a&&Math.hypot(r.x-a.x,r.y-a.y)<n||e.push(r)}for(;e.length>2&&Math.hypot(e[0].x-e[e.length-1].x,e[0].y-e[e.length-1].y)<n;)e.pop();if(e.length<3)return t;let o=[];for(let r=0;r<e.length;r++){let a=o.length?o[o.length-1]:e[(r-1+e.length)%e.length],i=e[r],s=e[(r+1)%e.length],c=s.x-a.x,l=s.y-a.y,u=Math.hypot(c,l);u>n&&Math.abs((i.x-a.x)*l-(i.y-a.y)*c)/u<n||o.push(i)}return o.length>=3?o:e}var Fe=.001*Zt*.1;function Z(t,n,e,o,r,a,i,s,c=1/0,l){if(!n||n.length<3||(c===void 0&&(c=1/0),Math.abs(Kt(n))<1e-4))return;let u=Le(Kr(Le(ln(n),Fe),o,c),Fe),f=e?.map(g=>Le(Kr(Le(ln(g),Fe),o,c),Fe)).filter(g=>g.length>=3&&Math.abs(Kt(g))>=1e-4),{pts:m,tris:h}=Za(u,f),y=[a[0]*s.top,a[1]*s.top,a[2]*s.top],d=[a[0]*s.bottomCap,a[1]*s.bottomCap,a[2]*s.bottomCap],x=[i[0]*s.top,i[1]*s.top,i[2]*s.top],b=[i[0]*s.wallBottom,i[1]*s.wallBottom,i[2]*s.wallBottom],p=0;if(Number.isFinite(c))for(;p<qa;p++){let g=0;for(let I=0;I<h.length;I+=3){let A=Qn(m[h[I]],m[h[I+1]],m[h[I+2]],o,p);A>g&&(g=A)}if(g<=c)break}for(let g=0;g<h.length;g+=3){let I=m[h[g]],A=m[h[g+1]],R=m[h[g+2]];te(t,I,A,R,o,y,p,l);let B=[I.x*_,r,I.y*_],C=[A.x*_,r,A.y*_],T=[R.x*_,r,R.y*_];t.tri(B,T,C,[0,-1,0],d)}let M=g=>{if(p<=0)return g;let I=1<<p,A=[];for(let R=0;R<g.length;R++){let B=g[R],C=g[(R+1)%g.length];for(let T=0;T<I;T++){let O=T/I;A.push({x:B.x+(C.x-B.x)*O,y:B.y+(C.y-B.y)*O})}}return A},P=Rr(u),S=[{ring:M(u),flip:!1}];if(f)for(let g of f)g.length>=3&&S.push({ring:M(g),flip:!0});for(let{ring:g,flip:I}of S)for(let A=0;A<g.length;A++){let R=g[A],B=g[(A+1)%g.length],C=(B.x-R.x)*_,O=(B.y-R.y)*_,E=-C,w=Math.hypot(O,E)||1;O/=w,E/=w;let L=(R.x+B.x)/2-P.x,G=(R.y+B.y)/2-P.y,k=O*L+E*G;I&&(k=-k),k<0&&(O=-O,E=-E);let N=[O,0,E],U=[R.x*_,o(R),R.y*_],X=[B.x*_,o(B),B.y*_],F=[R.x*_,r,R.y*_],v=[B.x*_,r,B.y*_];t.tri(U,X,v,N,x,x,b),t.tri(U,v,F,N,x,b,b)}}function Yr(t){let n=0;for(let c of t)n+=c.count;let e=new Float32Array(n*3),o=new Float32Array(n*3),r=new Float32Array(n*3),a=new Float32Array(n),i=new Float32Array(n),s=0;for(let c of t)e.set(c.position,s*3),o.set(c.normal,s*3),r.set(c.color,s*3),a.set(c.floor,s),i.set(c.material,s),s+=c.count;return{position:e,normal:o,color:r,floor:a,material:i,count:n}}function un(t,n,e=2.5){if(n<=0||t.length<3)return t;let o=ln(t),r=o.length,a=[];for(let s=0;s<r;s++){let c=o[s],l=o[(s+1)%r],u=l.x-c.x,f=l.y-c.y,m=Math.hypot(u,f)||1;a.push({x:f/m,y:-u/m})}let i=[];for(let s=0;s<r;s++){let c=o[s],l=a[(s-1+r)%r],u=a[s],f=l.x+u.x,m=l.y+u.y,h=Math.hypot(f,m),y=()=>{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){y();continue}f/=h,m/=h;let d=f*l.x+m*l.y,x=1/Math.max(d,1e-6);if(!Number.isFinite(x)||x>e){y();continue}i.push([c.x+f*n*x,c.y+m*n*x])}if(i.length<3)return t;try{let s=zr.union([[...i,i[0]]]),c=null,l=-1/0;for(let f of s){let m=Math.abs(Kt(f[0].map(([h,y])=>({x:h,y}))));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 Jt(t,n,e=2.5){if(t.length<3)return[];if(n<=0)return t;let o=ln(t),r=o.length,a=[];for(let c=0;c<r;c++){let l=o[c],u=o[(c+1)%r],f=Math.hypot(u.x-l.x,u.y-l.y)||1;a.push({x:-(u.y-l.y)/f,y:(u.x-l.x)/f})}let i=[],s=[];for(let c=0;c<r;c++){let l=o[c],u=a[(c-1+r)%r],f=a[c],m=u.x+f.x,h=u.y+f.y,y=Math.hypot(m,h),d=y<1e-9?1/0:1/Math.max(m/y*u.x+h/y*u.y,1e-6);if(!Number.isFinite(d)||d>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}),s.push(c,c);continue}m/=y,h/=y,i.push({x:l.x+m*n*d,y:l.y+h*n*d}),s.push(c)}for(let c=0;c<i.length;c++){let l=(c+1)%i.length,u=s[c],f=s[l];if(f!==(u+1)%r)continue;let m=o[u],h=o[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=zr.intersection([[...i.map(y=>[y.x,y.y]),[i[0].x,i[0].y]]],[[...o.map(y=>[y.x,y.y]),[o[0].x,o[0].y]]]),l=null,u=0;for(let y of c){let d=Math.abs(Kt(y[0].map(([x,b])=>({x,y:b}))));d>u&&(u=d,l=y[0])}if(!l)return[];let f=l.map(([y,d])=>({x:y,y:d})),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?ln(f):[]}catch{return[]}}function Ne(t,n,e,o,r=28){let a=[];for(let i=0;i<r;i++){let s=i/r*Math.PI*2;a.push({x:t+e*Math.cos(s),y:n+o*Math.sin(s)})}return a}function ee(t,n,e,o){return[{x:t,y:n},{x:t+e,y:n},{x:t+e,y:n+o},{x:t,y:n+o}]}var Ht={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,spine:6,armrest:7},Qa=.44,tc=.15,nc=.3,ec=.24;function qr(t){return t===void 0||!Number.isFinite(t)||t<=0?ec:Math.min(nc,Math.max(tc,t*Qa))}var Zh=.21,oc=.05,$r=.45,rc=$r+oc,ic=.92,sc=.66,qh=1.205;var $h=.6,Jh=.56,Qh=.5,t0=-.9,n0=.76,e0=.66;var o0=.38,r0=-.84,i0=.06,s0=78;var ac=.28,Zr=.15,cc=[{part:Ht.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:Ht.pad,min:[-1,.36,-.95],max:[1,$r,1]},{part:Ht.back,min:[-1,rc,-1],max:[1,ic,-.72]},{part:Ht.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:Ht.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:Ht.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:Ht.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:Ht.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:Ht.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:Ht.leg,min:[.62,0,.48],max:[.82,.37,.7]},{part:Ht.spine,min:[-.8,.3,-1],max:[.8,.6,-.9]},...[1,-1].flatMap(t=>{let n=i=>{let s=t*(Zr-i),c=t*(Zr+i);return[Math.min(s,c),Math.max(s,c)]},[e,o]=n(.09),[r,a]=n(ac/2);return[{part:Ht.armrest,min:[e,0,-.5],max:[o,.6,.05],skip:[2,3]},{part:Ht.armrest,min:[r,.6,-.74],max:[a,.655,.58],skip:[3]}]})],lc=[{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 a0(){let t=[],n=[],e=[],o=[],r=(h,y,d)=>{let x=e.length,[b,p,M]=h,P=[p[0]-b[0],p[1]-b[1],p[2]-b[2]],S=[M[0]-b[0],M[1]-b[1],M[2]-b[2]],g=P[1]*S[2]-P[2]*S[1],I=P[2]*S[0]-P[0]*S[2],A=P[0]*S[1]-P[1]*S[0],R=Math.hypot(g,I,A);R>1e-9?(g/=R,I/=R,A/=R):[g,I,A]=y,g*y[0]+I*y[1]+A*y[2]<0&&(g=-g,I=-I,A=-A);for(let B of h)t.push(...B),n.push(g,I,A),e.push(d);o.push(x,x+1,x+2,x,x+2,x+3)},a=h=>{for(let[y,d]of lc.entries()){if(h.skip?.includes(y))continue;let x=d.c.map(b=>b.map((p,M)=>p?h.max[M]:h.min[M]));r(x,d.n,h.part)}},i=h=>{let{part:y,vertical:d,across:x,along:b,alongCoord:p,halfWidth:M,swell:P,base:S}=h,g=(F,v,j)=>d?[F*M(v),p(v),j]:[F*M(v),j,p(v)],I=(F,v)=>g(F,v,P(F,v)),A=d?2:1,R=(F,v)=>{let Y=Math.max(-1,F-.001),ot=Math.min(1,F+.001),q=Math.max(0,v-.001),J=Math.min(1,v+.001),rt=I(Y,v),ft=I(ot,v),mt=I(F,q),yt=I(F,J),$=[ft[0]-rt[0],ft[1]-rt[1],ft[2]-rt[2]],K=[yt[0]-mt[0],yt[1]-mt[1],yt[2]-mt[2]],Q=[$[1]*K[2]-$[2]*K[1],$[2]*K[0]-$[0]*K[2],$[0]*K[1]-$[1]*K[0]];Q[A]<0&&(Q=[-Q[0],-Q[1],-Q[2]]);let tt=Math.hypot(...Q)||1;return[Q[0]/tt,Q[1]/tt,Q[2]/tt]},B=(F,v)=>(t.push(...F),n.push(...v),e.push(y),e.length-1),C=b.map(F=>x.map(v=>B(I(v,F),R(v,F))));for(let F=0;F<b.length-1;F++)for(let v=0;v<x.length-1;v++)o.push(C[F][v],C[F][v+1],C[F+1][v+1],C[F][v],C[F+1][v+1],C[F+1][v]);let T=[];for(let F=0;F<x.length-1;F++)T.push([x[F],b[0]]);for(let F=0;F<b.length-1;F++)T.push([x[x.length-1],b[F]]);for(let F=x.length-1;F>0;F--)T.push([x[F],b[b.length-1]]);for(let F=b.length-1;F>0;F--)T.push([x[0],b[F]]);let O=T.map(([F,v])=>g(F,v,S)),E=F=>d?[F[0],F[1]]:[F[0],F[2]],w=F=>{let[v,j]=E(O[F]),[Y,ot]=E(O[(F+1)%O.length]),q=Math.hypot(Y-v,ot-j)||1;return[(ot-j)/q,-(Y-v)/q]},L=O.reduce((F,v)=>{let[j,Y]=E(v);return[F[0]+j/O.length,F[1]+Y/O.length]},[0,0]),G=F=>{let v=w((F+O.length-1)%O.length),j=w(F),Y=v[0]+j[0],ot=v[1]+j[1],[q,J]=E(O[F]);Y*(q-L[0])+ot*(J-L[1])<0&&(Y=-Y,ot=-ot);let rt=Math.hypot(Y,ot)||1;return d?[Y/rt,ot/rt,0]:[Y/rt,0,ot/rt]},k=T.map(([F,v],j)=>B(I(F,v),G(j))),N=O.map((F,v)=>B(F,G(v)));for(let F=0;F<T.length;F++){let v=(F+1)%T.length;o.push(k[F],k[v],N[v],k[F],N[v],N[F])}let U=d?[0,0,-1]:[0,-1,0],X=O.map(F=>B(F,U));for(let F=1;F<X.length-1;F++)o.push(X[0],X[F],X[F+1])},s=h=>1-h*h*h*h,c=h=>y=>{for(let d=1;d<h.length;d++)if(y<=h[d][0]){let[x,b]=h[d-1],[p,M]=h[d];return b+(M-b)*(y-x)/(p-x)}return h[h.length-1][1]};for(let h of cc)if(h.part===Ht.back){let y=[[0,.8],[.04,.9],[.1,.97],[.25,1],[.77,.94],[.88,.88],[.95,.79],[1,sc]],d=h.min[1],x=h.max[1];i({part:h.part,vertical:!0,across:[-1,-.6,0,.6,1],along:y.map(([b])=>b),alongCoord:b=>d+(x-d)*b,halfWidth:c(y),swell:(b,p)=>h.max[2]-.12+.12*s(b)*s(2*p-1),base:h.min[2]})}else if(h.part===Ht.pad){let y=[[0,.84],[.1,.92],[.78,.92],[.9,.89],[.97,.82],[1,.72]],d=h.min[2],x=h.max[2],b=h.min[1],p=h.max[1];i({part:h.part,vertical:!1,across:[-1,-.6,0,.6,1],along:y.map(([M])=>M),alongCoord:M=>d+(x-d)*M,halfWidth:c(y),swell:(M,P)=>b+(p-b)*(.45+.55*s(M)*s(2*P-1)),base:b})}else a(h);let l=new Float32Array(t),u=new Float32Array(n),f=new Float32Array(e),m=new Uint16Array(o);return{position:l,normal:u,part:f,index:m,vertexCount:e.length,indexCount:o.length}}var Mo=20*Math.PI/180;function Jr(t,n,e,o,r){let a=new Float32Array(n),i=f=>t[f*3],s=f=>t[f*3+2],c=Math.cos(Mo),l=0,u=(f,m)=>{let h=m-f,y=r?.(f),d=y!==void 0;for(let M=f+1;!d&&M<m-1;M++){let P=i(M)-i(M-1),S=s(M)-s(M-1),g=i(M+1)-i(M),I=s(M+1)-s(M),A=Math.hypot(P,S)*Math.hypot(g,I);A>1e-9&&(P*g+S*I)/A<c&&(d=!0)}let x=0,b=0,p=!1;if(d){if(y)[x,b]=y;else{for(let P=f;P<m;P++)x+=i(P),b+=s(P);x/=h,b/=h}let M=0;for(let P=f+1;P<m;P++)M=Math.max(M,Math.hypot(i(P)-i(P-1),s(P)-s(P-1)));p=h>=3&&Math.hypot(i(m-1)-i(f),s(m-1)-s(f))<=M*1.6}for(let M=f;M<m;M++){let[P,S]=d?[x,b]:o(M),g=P-i(M),I=S-s(M);if(h>=2&&!(y&&h<3)){let A=p?f+(M-1-f+h)%h:Math.max(f,M-1),R=p?f+(M+1-f)%h:Math.min(m-1,M+1),B=i(R)-i(A),C=s(R)-s(A),T=Math.hypot(B,C);if(T>1e-6){let O=-C/T,E=B/T;O*g+E*I<0&&(O=-O,E=-E),g=O,I=E}}a[M]=g===0&&I===0?0:Math.atan2(g,I)}};for(let f=1;f<=n;f++)(f===n||e(f)!==e(l))&&(u(l,f),l=f);return a}var De=.22;function p0(t){let n=Jn[t];return n==="sold"||n==="held"?1:0}var uc=.42,Qr=1.6;function fc(t,n){let e=new Float32Array(t.length*4),o=Math.cos(Mo),r=0;for(let a=1;a<=t.length;a++){if(a<t.length&&t[a].rowId===t[r].rowId)continue;let i=a-r>=2&&!n?.has(t[r].rowId);for(let l=r;i&&l<a;l++)t[l].kind==="booth"&&(i=!1);for(let l=r+1;i&&l<a-1;l++){let u=t[l].x-t[l-1].x,f=t[l].y-t[l-1].y,m=t[l+1].x-t[l].x,h=t[l+1].y-t[l].y,y=Math.hypot(u,f)*Math.hypot(m,h);y>1e-9&&(u*m+f*h)/y<o&&(i=!1)}let s=[];for(let l=r+1;i&&l<a;l++){let u=Math.hypot(t[l].x-t[l-1].x,t[l].y-t[l-1].y);u>1e-6&&s.push(u)}s.sort((l,u)=>l-u);let c=s.length?s[Math.floor(s.length/2)]:0;for(let l=r;c>0&&l<a;l++){let u=x=>{let b=l+x;if(b<r||b>=a)return null;let p=t[b].x-t[l].x,M=t[b].y-t[l].y,P=Math.hypot(p,M);return P>1e-6?{x:p/P,y:M/P,gap:P}:null},f=u(1),m=u(-1),h=c/2,y=f??(m?{x:-m.x,y:-m.y,gap:1/0}:null);if(!y)continue;let d=f&&f.gap<c*Qr?f.gap/2:h;if(e[l*4]=y.x*d*_,e[l*4+1]=y.y*d*_,!m||m.gap>=c*Qr){let x=m??{x:-y.x,y:-y.y};e[l*4+2]=x.x*h*_,e[l*4+3]=x.y*h*_}}r=a}return e}function mc(t){let n=t.length,e=new Float64Array(n);if(n<2)return e.fill(1/0),e;let o=1/0,r=1/0,a=-1/0,i=-1/0;for(let y of t)y.x<o&&(o=y.x),y.y<r&&(r=y.y),y.x>a&&(a=y.x),y.y>i&&(i=y.y);let s=Math.max(a-o,1e-6),c=Math.max(i-r,1e-6),l=Math.max(Math.sqrt(s*c/n),1e-6),u=Math.max(1,Math.ceil(s/l)+1),f=Math.max(1,Math.ceil(c/l)+1),m=new Map,h=(y,d)=>{let x=Math.min(u-1,Math.max(0,Math.floor((y-o)/l)));return Math.min(f-1,Math.max(0,Math.floor((d-r)/l)))*u+x};for(let y=0;y<n;y++){let d=h(t[y].x,t[y].y),x=m.get(d);x?x.push(y):m.set(d,[y])}for(let y=0;y<n;y++){let d=t[y],x=Math.min(u-1,Math.max(0,Math.floor((d.x-o)/l))),b=Math.min(f-1,Math.max(0,Math.floor((d.y-r)/l))),p=1/0;for(let M=1;M<=4;M++){for(let P=b-M;P<=b+M;P++)if(!(P<0||P>=f))for(let S=x-M;S<=x+M;S++){if(S<0||S>=u||M>1&&Math.abs(P-b)<M&&Math.abs(S-x)<M)continue;let g=m.get(P*u+S);if(g)for(let I of g){if(I===y)continue;let A=Math.hypot(t[I].x-d.x,t[I].y-d.y);A<p&&(p=A)}}if(Number.isFinite(p)&&p<=M*l)break}e[y]=p}return e}function hc(t){let n=t.eyeHeightM;return Number.isFinite(n)?Math.max(0,n-Ae):0}function ti(t,n,e,o,r,a,i){let s=t.length,c=new Float32Array(s*3),l=new Float32Array(s),u=new Float32Array(s*3),f=new Float32Array(s),m=new Float32Array(s),h=new Float32Array(s),y=new Float32Array(s),d=new Float32Array(s*3),x=new Map,b=mc(t);for(let p=0;p<s;p++){let M=t[p],S=(e?.seatPitchU(p)??b[p])*_;f[p]=Number.isFinite(S)?Math.max(.06,Math.min(De,S*uc)):De,m[p]=qr(Number.isFinite(S)?S:void 0);let g=Cr(M.glyph,{seatGlyph:a?.get(M.categoryKey)}),I=M.glyph!==void 0||a?.has(M.categoryKey);h[p]=Or.indexOf(!I&&i?.has(M.rowId)?"dining":g),y[p]=M.wheelchairSpaceType==="no-seat"?0:1,c[p*3]=M.x*_,c[p*3+1]=e?e.seatDeckY(p):hc(M),c[p*3+2]=M.y*_,l[p]=xo(n?n(M):"available");let A=ht(r?.get(M.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[p*3]=A[0],u[p*3+1]=A[1],u[p*3+2]=A[2],M.accessibility?.length){let R=ht(Ie(M.accessibility));R&&(d[p*3]=R[0],d[p*3+1]=R[1],d[p*3+2]=R[2])}x.set(M.id,p)}return{count:s,iPosition:c,iState:l,iCategory:u,iMaxRadius:f,iRing:d,idToIndex:x,iChairWidth:m,iGlyph:h,iPhysicalSeat:y,iArmrests:fc(t,i),iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}var dc=64;function x0(t,n){let e=[];for(let i of n){let s=t.idToIndex.get(i.seatId);if(s===void 0)continue;let c=xo(i.state);t.iState[s]!==c&&(t.iState[s]=c,e.push(s))}if(!e.length)return[];e.sort((i,s)=>i-s);let o=[],r=e[0],a=e[0];for(let i=1;i<e.length;i++){let s=e[i];if(s!==a){if(s<=a+dc){a=s;continue}o.push({start:r,length:a-r+1}),r=s,a=s}}return o.push({start:r,length:a-r+1}),o}import Ec from"polygon-clipping";var z={top:1,wallBottom:.58,bottomCap:.4};function wn(t,n){if(!t)return n;let e=W(cn(t,.4),.62);return lt(n,e,.22)}function ni(t,n){return t?lt(n,W(cn(t,.25),.74),.62):n}var oe={full:[.72,.48],value:.8,spread:.52,paleLuma:.6},Ro=[.24,.46,.82];function ei(t){if(!t)return Ro;let n=lt(W(t,1.42),Ro,.08),e=Math.max(...n),o=e-Math.min(...n);if(e>=oe.full[0]&&o>=oe.full[1]||.2126*t[0]+.7152*t[1]+.0722*t[2]>=oe.paleLuma)return n;let r=Math.max(...t),a=Math.min(...t);if(r-a<.04)return Ro;let i=s=>oe.value-oe.spread*(1-(s-a)/(r-a));return[i(t[0]),i(t[1]),i(t[2])]}function oi(t,n){let e=Pn(gn({tierTop:n}));return t?An(t,e.sectionDeck,Math.min(e.sectionDeckChromaShare*$n(t),e.sectionDeckChromaCap)):An(n,e.deck,Math.min($n(n),ke))}function ri(t,n){let e=new Map;for(let a of t.categories??[])e.set(a.key,a.color);let o=new Map;for(let a of n){if(!a.sectionId)continue;let i=o.get(a.sectionId);i||(i=new Map,o.set(a.sectionId,i)),i.set(a.categoryKey,(i.get(a.categoryKey)??0)+1)}let r=new Map;for(let[a,i]of o){let s=0,c=0,l=0,u=0;for(let[f,m]of i){let h=ht(e.get(f));h&&(s+=h[0]*m,c+=h[1]*m,l+=h[2]*m,u+=m)}u>0&&r.set(a,[s/u,c/u,l/u])}return r}function ii(t,n){return ht(t.color)??n.get(t.logicalSectionId??t.id)??null}import bi from"polygon-clipping";import li from"polygon-clipping";import yc from"earcut";var pc=.58,si=.01,Qt=De*1.5*Zt,xc=.5,bc=.6;function gc(t,n){let e=t.length,o=[];for(let i=0;i<e;i++){let s=t[Math.max(0,i-1)],c=t[Math.min(e-1,i+1)],l=c.x-s.x,u=c.y-s.y,f=Math.hypot(l,u);if(f<1e-9){o.push([0,0]);continue}l/=f,u/=f,o.push([-u,l])}let r=0;for(let i=0;i<e;i++)r+=(t[i].x-n.x)*o[i][0]+(t[i].y-n.y)*o[i][1];return r<0?o.map(([i,s])=>[-i,-s]):o}function Mc(t,n){if(t.length<2||n<=0)return[...t];let e=[...t],o=(i,s)=>{let c=s.x-i.x,l=s.y-i.y,u=Math.hypot(c,l)||1;return{x:c/u,y:l/u}},r=o(e[1],e[0]),a=o(e[e.length-2],e[e.length-1]);return e.unshift({x:e[0].x+r.x*n,y:e[0].y+r.y*n}),e.push({x:e[e.length-1].x+a.x*n,y:e[e.length-1].y+a.y*n}),e}var ai=Math.PI/12;function Rc(t){if(t.length<3)return[...t];let n=Nn(t);return n.length>=3?n:[...t]}function ui(t,n){if(!t.length||!(n>0))return[];let e=Rc(t),o=(s,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/ai)),h=n/Math.cos(f/m/2);for(let y=0;y<=m;y++){let d=c+f*y/m;u.push({x:s.x+Math.cos(d)*h,y:s.y+Math.sin(d)*h})}};if(e.length<3){let s=0,c=0;for(let h of e)s+=h.x,c+=h.y;s/=e.length||1,c/=e.length||1;let l=0;for(let h of e)l=Math.max(l,Math.hypot(h.x-s,h.y-c));let u=[],f=Math.max(3,Math.ceil(Math.PI*2/ai)),m=(l+n)/Math.cos(Math.PI/f);for(let h=0;h<f;h++){let y=h/f*Math.PI*2;u.push({x:s+Math.cos(y)*m,y:c+Math.sin(y)*m})}return u}let r=e.length,a=[];for(let s=0;s<r;s++){let c=e[s],l=e[(s+1)%r];a.push(Math.atan2(-(l.x-c.x),l.y-c.y))}let i=[];for(let s=0;s<r;s++)o(e[s],a[(s+r-1)%r],a[s],i);return yi(i)}function _c(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let o=1/0;for(let r=0;r+1<t.length;r++){let a=t[r],i=t[r+1],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l>1e-12?((n-a.x)*s+(e-a.y)*c)/l:0;u<0?u=0:u>1&&(u=1);let f=Math.hypot(n-(a.x+u*s),e-(a.y+u*c));f<o&&(o=f)}return o}function ve(t){let n=t.map(r=>{let a=0,i=0;for(let l of r.pts)a+=l.x,i+=l.y;let s=r.pts.length||1;a/=s,i/=s;let c=0;for(let l of r.pts){let u=Math.hypot(l.x-a,l.y-i);u>c&&(c=u)}return{cx:a,cy:i,rad:c}}),e=r=>{let a=r.length;return a<=2?[...r]:[r[Math.floor(a*.25)],r[Math.floor(a*.5)],r[Math.floor(a*.75)]]},o=[];for(let r=0;r<t.length;r++){let a=e(t[r].pts),i=[],s=1/0,c=null;for(let u of a){let f=1/0;for(let m=0;m<t.length;m++){if(m===r||Math.abs(t[m].y-t[r].y)<.001)continue;let h=n[m],y=Math.hypot(u.x-h.cx,u.y-h.cy)-h.rad;if(y>=f&&y>=s)continue;let d=_c(t[m].pts,u.x,u.y);d<f&&(f=d),t[m].depth<t[r].depth&&d<s&&(s=d,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;o.push({pitch:l,belowY:c})}return o}function fi(t,n,e,o){let r=t[n],a=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let u=r.pts[0],f=u.x-o.x,m=u.y-o.y,h=Math.hypot(f,m)||1;f/=h,m/=h;let y=Math.max(e[n].pitch,.001)*.5;return[{x:u.x+m*y,y:u.y-f*y},{x:u.x-m*y,y:u.y+f*y}]})():[];if(a.length<2)return null;let i=0,s=0;for(let u=1;u<a.length;u++){let f=Math.hypot(a[u].x-a[u-1].x,a[u].y-a[u-1].y);f>1e-6&&(i+=f,s++)}let c=s>0?i/s:0,l=Mc(a,Math.max(c*bc,Qt));return{pts:l,nrm:gc(l,o),front:Math.max(e[n].pitch*pc,Qt),back:Math.max(e[n].pitch*xc,Qt)}}var Dn=1.5,mi=.3;function _o(t,n){if(t.length<3)return t;let e=t[0],o=t[t.length-1],r=o.x-e.x,a=o.y-e.y,i=Math.hypot(r,a),s=-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)*a-(m.y-e.y)*r)/i:Math.hypot(m.x-e.x,m.y-e.y);h>s&&(s=h,c=f)}if(s<=n||c<0)return[e,o];let l=_o(t.slice(0,c+1),n),u=_o(t.slice(c),n);return[...l.slice(0,-1),...u]}function hi(t,n){if(t.length<4)return t;let e=_o([...t,t[0]],n);return e.pop(),e.length>=3?e:t}function Sc(t){let n=t.map((o,r)=>{let a=t[(r+1)%t.length];return{a:o,b:a,i:r,minX:Math.min(o.x,a.x),maxX:Math.max(o.x,a.x),minY:Math.min(o.y,a.y),maxY:Math.max(o.y,a.y)}}).sort((o,r)=>o.minX-r.minX),e=(o,r,a)=>(r.x-o.x)*(a.y-o.y)-(r.y-o.y)*(a.x-o.x);for(let o=0;o<n.length;o++){let r=n[o];for(let a=o+1;a<n.length&&n[a].minX<=r.maxX;a++){let i=n[a];if(!(Math.abs(r.i-i.i)===1||Math.abs(r.i-i.i)===t.length-1||r.maxY<i.minY||i.maxY<r.minY)&&e(r.a,r.b,i.a)*e(r.a,r.b,i.b)<=0&&e(i.a,i.b,r.a)*e(i.a,i.b,r.b)<=0)return!0}}return!1}function di(t,n,e){if(t.length<2)return[];let o=e??ve(t),r=new Map;for(let i=0;i<t.length;i++){let s=r.get(t[i].blockId);s?s.push(i):r.set(t[i].blockId,[i])}let a=[];for(let[,i]of r){let s=[];for(let p of i){let M=t[p].patch;M&&M.length>=3?a.push({outline:[...M],holes:[],topY:t[p].y}):s.push(p)}if(!s.length)continue;s.sort((p,M)=>t[p].depth-t[M].depth);let l=s.map(p=>fi(t,p,o,n)).filter(p=>p!==null);if(!l.length)continue;let u=(p,M)=>({x:p.pts[M].x-p.nrm[M][0]*(p.front+Dn),y:p.pts[M].y-p.nrm[M][1]*(p.front+Dn)}),f=(p,M)=>({x:p.pts[M].x+p.nrm[M][0]*(p.back+Dn),y:p.pts[M].y+p.nrm[M][1]*(p.back+Dn)}),m=l[0],h=l[l.length-1],y=[];for(let p=0;p<m.pts.length;p++)y.push(u(m,p));for(let p of l)y.push(f(p,p.pts.length-1));for(let p=h.pts.length-1;p>=0;p--)y.push(f(h,p));for(let p=l.length-1;p>=0;p--)y.push(u(l[p],0));let d=yi(y),x=1/0;for(let p of s)t[p].y<x&&(x=t[p].y);if(!Number.isFinite(x))continue;if(d.length>=3&&Math.abs(Kt(d))>1e-6&&l.every(p=>{let M=p.pts[Math.floor(p.pts.length/2)];return kt(d,M.x,M.y)})&&!Sc(d)){a.push({outline:hi(d,mi),holes:[],topY:x});continue}for(let p of Ic(l))a.push({outline:p,holes:[],topY:x})}return a}function Ic(t){let n=[];for(let e of t){let o=[],r=[],a=e.front+Dn,i=e.back+Dn;for(let c=0;c<e.pts.length;c++){let l=e.pts[c],u=e.nrm[c];o.push([l.x-u[0]*a,l.y-u[1]*a]),r.push([l.x+u[0]*i,l.y+u[1]*i])}let s=[...o,...r.reverse()];s.length<3||(s.push(s[0]),n.push([s]))}if(!n.length)return[];try{let e=li.union(n[0],...n.slice(1)),o=[];for(let r of e){if(!r.length||r[0].length<4)continue;let a=r[0].map(([c,l])=>({x:c,y:l})),i=a[0],s=a[a.length-1];a.length>1&&Math.abs(i.x-s.x)<1e-9&&Math.abs(i.y-s.y)<1e-9&&a.pop(),a.length>=3&&o.push(hi(a,mi))}return o}catch{return[]}}function yi(t){let n=[];for(let e of t){let o=n[n.length-1];o&&Math.hypot(e.x-o.x,e.y-o.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 So=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 o of e)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(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 o=!0;for(let r of n)if(!kt(e,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function ci(t,n,e,o,r,a){if(o.length<3)return;if(e.containsAll(o)){let l=[0,1,0],u=o[0];for(let f=1;f+1<o.length;f++){let m=o[f],h=o[f+1];t.tri([u.x*_,r,u.y*_],[m.x*_,r,m.y*_],[h.x*_,r,h.y*_],l,a)}return}let i=o.map(l=>[l.x,l.y]);i.push(i[0]);let s;try{s=li.intersection([i],n)}catch{return}let c=[0,1,0];for(let l of s){if(!l.length||l[0].length<4)continue;let u=l[0],f=[],m=[];for(let y=0;y<u.length-1;y++)f.push(u[y][0],u[y][1]),m.push([u[y][0],u[y][1]]);if(m.length<3)continue;let h=yc(f,void 0,2);for(let y=0;y<h.length;y+=3){let d=m[h[y]],x=m[h[y+1]],b=m[h[y+2]];t.tri([d[0]*_,r,d[1]*_],[x[0]*_,r,x[1]*_],[b[0]*_,r,b[1]*_],c,a)}}}function pi(t,n,e,o,r,a,i){if(n.length<2)return;let s=i??ve(n),c=[0,1,0],l=a&&a.length>=3?[[...a.map(h=>[h.x,h.y]),[a[0].x,a[0].y]]]:null,u=a&&a.length>=3?new So([[...a]]):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 y=n[h];if(y.patch&&y.patch.length>=3){let S=[...y.patch],g=s[h].belowY??o;if(m(()=>{if(l&&u)ci(t,l,u,S,y.y,r.tread);else{let I=S[0];for(let A=1;A+1<S.length;A++){let R=S[A],B=S[A+1];t.tri([I.x*_,y.y,I.y*_],[R.x*_,y.y,R.y*_],[B.x*_,y.y,B.y*_],c,r.tread)}}}),y.y>g+si){let I=0,A=0;for(let R of S)I+=R.x,A+=R.y;I/=S.length,A/=S.length,f(()=>{for(let R=0;R<S.length;R++){let B=S[R],C=S[(R+1)%S.length],T=C.x-B.x,O=C.y-B.y,E=Math.hypot(T,O);if(E<1e-6)continue;let w=O/E,L=-T/E;(B.x-I)*w+(B.y-A)*L<0&&(w=-w,L=-L);let G=[w,0,L],k=[B.x*_,y.y,B.y*_],N=[C.x*_,y.y,C.y*_],U=[B.x*_,g,B.y*_],X=[C.x*_,g,C.y*_];t.tri(k,N,X,G,r.riser),t.tri(k,X,U,G,r.riser)}})}continue}let d=fi(n,h,s,e);if(!d)continue;let{pts:x,nrm:b,front:p,back:M}=d,P=s[h].belowY??o;for(let S=0;S+1<x.length;S++){let g=x[S],I=x[S+1],A=b[S],R=b[S+1];if(Math.hypot(I.x-g.x,I.y-g.y)<1e-6||A[0]===0&&A[1]===0||R[0]===0&&R[1]===0)continue;let B=[(g.x-A[0]*p)*_,y.y,(g.y-A[1]*p)*_],C=[(I.x-R[0]*p)*_,y.y,(I.y-R[1]*p)*_],T=[(g.x+A[0]*M)*_,y.y,(g.y+A[1]*M)*_],O=[(I.x+R[0]*M)*_,y.y,(I.y+R[1]*M)*_];if(m(()=>{l&&u?ci(t,l,u,[{x:g.x-A[0]*p,y:g.y-A[1]*p},{x:I.x-R[0]*p,y:I.y-R[1]*p},{x:I.x+R[0]*M,y:I.y+R[1]*M},{x:g.x+A[0]*M,y:g.y+A[1]*M}],y.y,r.tread):(t.tri(B,C,O,c,r.tread),t.tri(B,O,T,c,r.tread))}),y.y>P+si){let E=[B[0],P,B[2]],w=[C[0],P,C[2]],L=[-A[0],0,-A[1]];f(()=>{t.tri(B,C,w,L,r.riser),t.tri(B,w,E,L,r.riser)})}}}}function Ac(t,n){let e=t.eventConfigurationIds;return!e?.length||!!n&&e.includes(n)}function xi(t,n){return t.filter(e=>e.type!=="shape"||Ac(e,n))}function gi(t,n){let e=t.focalPoint??{x:0,y:0};return t.floors?.length?t.floors.map((o,r)=>({objects:xi(o.objects,n),focal:{x:(o.focalPoint??e).x,y:(o.focalPoint??e).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:xi(t.objects,n),focal:e,baseHeightM:0,index:0}]}var Pc={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function dn(t){return Lr(t)??Pc}function Mi(t,n){let e=un(t.outline,Qt),o=dn(e),r=n.filter(i=>i!==t&&i.outline&&i.outline.length>=3&&Gn(o,dn(i.outline)));if(!r.length)return[e];let a=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s};try{let i=bi.difference([a(e)],...r.map(c=>[a(c.outline)])),s=[];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&&s.push(l)}return s.length?s:[e]}catch{return[e]}}function Ri(t,n){if(!n.length)return t;let e=a=>{let i=a.map(s=>[s.x,s.y]);return i.push(i[0]),i},o=n.map(a=>[e(a)]),r=[];for(let a of t){let i;try{i=bi.intersection([e(a.outline)],o.flat())}catch{r.push(a);continue}for(let s of i){if(!s.length)continue;let c=s[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&r.push({outline:c,holes:[],topY:a.topY})}}return r.length?r:t}function wc(t,n){return t===void 0||n===void 0?!0:Math.abs(t-n)<.001}var He=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(n,e){let o=n.map(c=>[c.x,c.y]);if(o.length<3)return[];o.push(o[0]);let r=dn(n),a=this.rings.filter((c,l)=>Gn(r,this.boxes[l])&&wc(e,this.levels[l])),i=[[o]];if(a.length)try{i=Ec.difference([o],...a).map(l=>l.map(u=>u.map(([f,m])=>[f,m])))}catch{i=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(e);let s=[];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&&s.push(l)}return s}};function vn(t,n,e=t){if(!n)return t;let o=1/0,r=-1/0,a=1/0,i=-1/0;for(let m of e)o=Math.min(o,m.x),r=Math.max(r,m.x),a=Math.min(a,m.y),i=Math.max(i,m.y);let s=(o+r)/2,c=(a+i)/2,l=n*Math.PI/180,u=Math.cos(l),f=Math.sin(l);return t.map(m=>{let h=m.x-s,y=m.y-c;return{x:s+h*u-y*f,y:c+h*f+y*u}})}function _i(t){let n=Sr(t);return!n.length||!t.points?.length?[]:n.map(e=>vn(e,t.rotation,t.points))}function ut(t){let n=null;if(t.kind==="polygon"&&t.points&&t.points.length>=3)return vn(_r(t,4),t.rotation,t.points);if(t.kind==="rect"&&t.width&&t.height&&(n=ee(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,o=(t.y??0)+t.height/2;n=Ne(e,o,t.width/2,t.height/2)}return n?vn(n,t.rotation):null}function on(t){let n=t.role??"",o=n==="stage"?{kind:"stage",heightM:Pr(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{...o,heightM:t.heightM??o.heightM}}var Bc=.08,Tc=30,Oc=.015;function Cc(t,n){let e=!1;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[o],i=n[r];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}function Si(t,n){let e=ut(t)??(t.points?.length?vn(t.points,t.rotation):null),o=on(t),a=!t.role&&o.kind==="plate"&&t.heightM===void 0&&!!e&&Math.abs(Kt(e))*st**2>=Tc?Oc:o.heightM;if(!e)return{topOffsetM:a,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:a,supportOffsetM:0};let i=1/0,s=1/0,c=-1/0,l=-1/0;for(let h of e)i=Math.min(i,h.x),s=Math.min(s,h.y),c=Math.max(c,h.x),l=Math.max(l,h.y);let u=a,f=0,m=1e-6*Math.max(1,c-i,l-s);for(let h of n)c>h.minX&&i<h.maxX&&l>h.minY&&s<h.maxY&&u<=h.topOffsetM+1e-6&&(u=h.topOffsetM+Bc),i>=h.minX-m&&c<=h.maxX+m&&s>=h.minY-m&&l<=h.maxY+m&&(!h.poly||e.every(x=>Cc(x,h.poly)||kc(x,h.poly,m)))&&(f=Math.max(f,h.topOffsetM));return t.fill&&t.fill!=="none"&&t.fill!=="transparent"&&n.push({minX:i,minY:s,maxX:c,maxY:l,topOffsetM:u,poly:e}),{topOffsetM:u,supportOffsetM:Math.min(f,u)}}function kc(t,n,e){for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[r],i=n[o],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l)):0;if(Math.hypot(t.x-(a.x+u*s),t.y-(a.y+u*c))<=e)return!0}return!1}function Mn(t,n,e){return{x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e}}function zt(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 jt(t,n,e){return[Mn(t[0],t[1],n),Mn(t[0],t[1],e),Mn(t[3],t[2],e),Mn(t[3],t[2],n)]}function re(t,n,e){return[Mn(t[0],t[3],n),Mn(t[1],t[2],n),Mn(t[1],t[2],e),Mn(t[0],t[3],e)]}function dt(t,n,e,o,r,a,i){Z(t,n,i?.length?i:void 0,()=>e,o,r,a,z)}function ie(t){if(t.length<3)return t.map(e=>({...e}));let n=Nn(t);return n.length>=3?n:[...t].sort((e,o)=>e.x-o.x||e.y-o.y).map(e=>({...e}))}var Lc=.8,Fc=.6,Gc=2;function Rn(t,n){if(!n.length)return null;let e=[],o=0;for(let i of t.objects){if(i.type!=="shape"||i.role!=="wall")continue;let s=ut(i)??[],c=Ii(s)/2;!(c>0)||vc(s)/c*_>Gc||(e.push(...s),o+=c)}if(e.length<3)return null;let r=ie(e);if(r.length<3||o<Ii(r)*Fc)return null;let a=0;for(let i of n)Hc(i,r)&&(a+=1);return a>=n.length*Lc?r:null}var Ue=6,Nc=5,Dc=8;function Ai(t){return Math.max(Dc,(Number.isFinite(t)?t:0)+Nc)}function Hn(t){let n=0,e=0,o=0;for(let r=0;r<t.length;r++){let a=t[r],i=t[(r+1)%t.length],s=a.x*i.y-i.x*a.y;n+=s,e+=(a.x+i.x)*s,o+=(a.y+i.y)*s}if(Math.abs(n)<1e-9){let r=0,a=0;for(let i of t)r+=i.x,a+=i.y;return{x:r/Math.max(1,t.length),y:a/Math.max(1,t.length)}}return{x:e/(3*n),y:o/(3*n)}}function vc(t){let n=0;for(let e=0;e<t.length;e++){let o=t[e],r=t[(e+1)%t.length];n+=o.x*r.y-r.x*o.y}return Math.abs(n)/2}function Ii(t){let n=0;for(let e=0;e<t.length;e++){let o=t[e],r=t[(e+1)%t.length];n+=Math.hypot(r.x-o.x,r.y-o.y)}return n}function Hc(t,n){let e=!1;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[o],i=n[r];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}var Uc=[[/\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"]],jc=1.2,Xc=12;function Pi(t){if(t.heightM!==void 0)return!1;let n=ut(t);if(!n||n.length<3)return!1;let e=0;for(let r=0;r<n.length;r++){let a=n[r],i=n[(r+1)%n.length];e+=Math.hypot(i.x-a.x,i.y-a.y)}return e*st<Xc*2?!1:2*se(n)/e*st<=jc}function Io(t){if(!t)return null;for(let[n,e]of Uc)if(n.test(t))return e;return null}var wi="auto-rows-";function Bi(t){return t.id.startsWith(wi)&&!t.label}var Vc=1.15,Wc=.09,Ti=6,Kc=34,zc=.35,Yc=6,Zc=.35,qc=.75,$c=12,Jc=2.5,Qc=40,tl=[18,24],nl=[12,16],Ei=14,el=.8,ol=.6,rl=5,il=.3,Oi=.4,Ci=2,sl=400,al=2.6,cl=.8,ll=4,ul=26,fl=.7,ml=.5,hl=.985,dl=1.5,yl=2.2,pl=3,xl=25,bl=.985,gl=2,Ml=6,Rl=3,_l=.1,Sl=1.5,Il=1.6,Al=6e3,Pl=.6,El="#c3c7cd",Ao=300,wl=240;function Bl(t,n,e,o){if(!t.fill||!/^#[0-9a-f]{6}$/i.test(t.fill))return null;let r=Eo([...n]),a=new Set;for(let u of o)a.add(Math.floor(Math.atan2(u.y-r.y,u.x-r.x)*180/Math.PI/10));if(a.size*10<wl)return null;let{h:i,s,l:c}=Tr(Br(t.fill));return i<70/360||i>170/360||s<.2||c<.08||c>.75||e.some(u=>u!==t&&u.type==="shape"&&ut(u)?.some(f=>To(f,n)))?null:t.kind==="ellipse"?"oval-cricket":t.kind==="rect"?"pitch-football":null}var Tl="Estimated from the drawing; confirm with the venue.",wo=t=>{if(!t.length)return null;let n=[...t].sort((o,r)=>o-r),e=Math.floor(n.length/2);return n.length%2?n[e]:(n[e-1]+n[e])/2},Eo=t=>({x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}),se=t=>{let n=0;for(let e=0;e<t.length;e++){let o=t[e],r=t[(e+1)%t.length];n+=o.x*r.y-r.x*o.y}return Math.abs(n)/2};function Ol(t){return t.height!==void 0||t.rake!==void 0||t.elevation!==void 0||t.surfaceKind!==void 0}function Bo(t){let n=new Map;for(let e of t){let o=n.get(e.rowId);o?o.push(e):n.set(e.rowId,[e])}return n}function To(t,n){let e=!1;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[o],i=n[r];a.y>t.y!=i.y>t.y&&t.x<(i.x-a.x)*(t.y-a.y)/(i.y-a.y)+a.x&&(e=!e)}return e}function Oo(t,n){let e=n[0],o=1/0;for(let r=0;r<n.length;r++){let a=n[r],i=n[(r+1)%n.length],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l>0?Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l)):0,f={x:a.x+s*u,y:a.y+c*u},m=Math.hypot(t.x-f.x,t.y-f.y);m<o&&(o=m,e=f)}return e}function ki(t,n){let e=0,o=0;for(let r of t.values()){if(r.length<3)continue;let a=r[0],i=r[r.length-1],s=i.x-a.x,c=i.y-a.y,l=Math.hypot(s,c);if(l<1e-6)continue;let u={x:(a.x+i.x)/2,y:(a.y+i.y)/2},f=Oo(u,n),m=f.x-u.x,h=f.y-u.y,y=Math.hypot(m,h);y<1e-6||(o+=Math.abs((-c*m+s*h)/(l*y))*r.length,e+=r.length)}return e?o/e:0}function Cl(t,n,e){let o=t.filter(d=>d.type==="shape"),r=o.find(d=>d.role==="stage");if(r){let d=ut(r);return d?{shape:r,centre:Eo(d),outline:d,inferred:!1}:null}if(!e.length)return null;let a=1/0,i=-1/0,s=1/0,c=-1/0;for(let d of e)a=Math.min(a,d.x),i=Math.max(i,d.x),s=Math.min(s,d.y),c=Math.max(c,d.y);let l=(i-a)*(c-s),u=[];for(let d of o){if(d.role)continue;let x=ut(d);if(!x)continue;let b=se(x);if(b*st*st<6||b>l)continue;let p=Math.min(...x.map(R=>R.x)),M=Math.max(...x.map(R=>R.x)),P=Math.min(...x.map(R=>R.y)),S=Math.max(...x.map(R=>R.y)),g=0;for(let R of e)R.x>p&&R.x<M&&R.y>P&&R.y<S&&To(R,x)&&g++;if(g>e.length*.05)continue;let I=Eo(x),A=ki(n,x);A>=el&&u.push({shape:d,centre:I,outline:x,score:A,area:b,box:[p,P,M,S]})}let f=(d,x)=>x!==d&&x.area>d.area&&d.box[0]>=x.box[0]-1e-6&&d.box[1]>=x.box[1]-1e-6&&d.box[2]<=x.box[2]+1e-6&&d.box[3]<=x.box[3]+1e-6,m=u.filter(d=>!u.some(x=>f(d,x))),h=Math.max(0,...m.map(d=>d.score)),y=m.filter(d=>d.score>=h-.03).sort((d,x)=>x.area-d.area)[0]??null;return y?{shape:y.shape,centre:y.centre,outline:y.outline,inferred:!0}:null}function kl(t,n,e){if(!e||e.length<3)return Math.hypot(t.x-n.x,t.y-n.y);let o=Oo(t,e);return Math.hypot(t.x-o.x,t.y-o.y)}function Li(t){return t.length<3?[...t].sort((n,e)=>n.x-e.x||n.y-e.y):Nn(t)}function Ll(t){if(!t.length||t.length>Al)return[];let n=[...Bo(t).values()],e=n.map((s,c)=>c),o=s=>e[s]===s?s:e[s]=o(e[s]),r=Il/st,a=n.map(s=>({minX:Math.min(...s.map(c=>c.x))-r,maxX:Math.max(...s.map(c=>c.x))+r,minY:Math.min(...s.map(c=>c.y))-r,maxY:Math.max(...s.map(c=>c.y))+r}));for(let s=0;s<n.length;s++)for(let c=s+1;c<n.length;c++){let l=a[s],u=a[c];if(l.maxX<u.minX||u.maxX<l.minX||l.maxY<u.minY||u.maxY<l.minY)continue;n[s].some(m=>n[c].some(h=>Math.hypot(m.x-h.x,m.y-h.y)<=r))&&(e[o(s)]=o(c))}let i=new Map;return n.forEach((s,c)=>{let l=o(c),u=i.get(l);u?u.push(...s):i.set(l,[...s])}),[...i.values()].filter(s=>new Set(s.map(c=>c.rowId)).size>=2)}function Fl(t,n,e){if(!n.length)return null;let o=n.filter(A=>e.tableIds.has(A.rowId)||A.kind==="booth").length>n.length/2,r=Bo(n),a=!e.outline||ki(r,e.outline)>=ol,i=0,s=0;for(let A of r.values()){if(A.length<2)continue;let R=A[0],B=A[A.length-1],C=B.x-R.x,T=B.y-R.y,O=Math.hypot(C,T);if(O<1e-6)continue;let E={x:(R.x+B.x)/2,y:(R.y+B.y)/2},w=a?e.outline?Oo(E,e.outline):e.focal:e.middle,L=-T/O,G=C/O;L*(w.x-E.x)+G*(w.y-E.y)<0&&(L=-L,G=-G),i+=L*A.length,s+=G*A.length}let c={x:n.reduce((A,R)=>A+R.x,0)/n.length,y:n.reduce((A,R)=>A+R.y,0)/n.length};if(Math.hypot(i,s)<1e-9){let A=a?e.focal:e.middle;i=A.x-c.x,s=A.y-c.y}let l=Math.hypot(i,s)||1,u={x:i/l,y:s/l},f=A=>-(A.x*u.x+A.y*u.y),m=A=>-A.x*u.y+A.y*u.x,h=1/0,y=-1/0,d=1/0,x=-1/0,b=1/0,p=new Map;for(let A of n){let R=f(A),B=m(A);h=Math.min(h,R),y=Math.max(y,R),d=Math.min(d,B),x=Math.max(x,B),a&&(b=Math.min(b,kl(A,e.focal,e.outline)));let C=A.logicalRowId??A.rowId,T=p.get(C);T?T.push(R):p.set(C,[R])}a||(b=Math.max(0,h-f(e.middle)));let M=[...p.values()].map(A=>wo(A)).sort((A,R)=>A-R),P=[];if(!o)for(let A of M)P.length&&A-P[P.length-1]<Zc/st||P.push(A);let S=Ol(t),g=Ln(t,{floorBaseHeightM:e.baseHeightM}),I={id:t.id,section:t,authored:S,plane:e,facing:u,facesAction:a,hull:Li(n),sample:n.filter((A,R)=>R%Math.ceil(n.length/sl)===0),frontD:h,backD:y,latMin:d,latMax:x,frontDistance:b,rowDepths:P,rowCount:P.length,level:0,height:g.height,rake:S?g.rake:0,backHeight:0};return I.backHeight=I.height+(y-h)*st*Math.tan(I.rake*Math.PI/180),I}function Gl(t,n,e,o){if(t.length<2)return 0;let r=Math.max(1,n*st),a=e+Vc-o,i=0,s=0;for(let l=1;l<t.length;l++){let u=Math.max(qc,(t[l]-t[l-1])*st),f=(a+Wc)*(r+u)/r;i+=f-a,s+=u,a=f,r+=u}let c=Math.atan(i/s)*180/Math.PI;return Math.round(Math.max(Ti,Math.min(Kc,c))*10)/10}function Nl(t,n,e=!1){if(!e&&t.facing.x*n.facing.x+t.facing.y*n.facing.y<il)return null;let o=-1/0,r=1/0,a=-1/0;for(let m of n.hull){o=Math.max(o,-(m.x*t.facing.x+m.y*t.facing.y));let h=-m.x*t.facing.y+m.y*t.facing.x;r=Math.min(r,h),a=Math.max(a,h)}if(Math.min(t.latMax,a)-Math.max(t.latMin,r)<(e?1e-6:Oi*(t.latMax-t.latMin)))return null;let s=Ci/st,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)/s),y=-(m.x*t.facing.x+m.y*t.facing.y);c.set(h,Math.min(c.get(h)??1/0,y))}for(let m of n.sample){let h=Math.floor((-m.x*t.facing.y+m.y*t.facing.x)/s),y=-(m.x*t.facing.x+m.y*t.facing.y);l.set(h,Math.max(l.get(h)??-1/0,y))}let u=[];for(let[m,h]of c){let y=l.get(m);y!==void 0&&u.push(h-y)}let f=u.length?wo(u):t.frontD-o;return f<-1/st?null:f}function Dl(t,n){if(n.plane.floorIndex>=t.plane.floorIndex)return!1;let e=-1/0,o=1/0,r=1/0,a=-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),o=Math.min(o,l);let u=-c.x*t.facing.y+c.y*t.facing.x;r=Math.min(r,u),a=Math.max(a,u)}let i=Math.min(t.latMax,a)-Math.max(t.latMin,r),s=Math.min(t.backD,e)-Math.max(t.frontD,o);return i>Oi*(t.latMax-t.latMin)&&s>1/st}function vl(t,n){let e=new Set;for(let o of t){let r=(Math.atan2(o.y-n.y,o.x-n.x)*180/Math.PI+360)%360;e.add(Math.floor(r/10))}return e.size/36}function Hl(t,n){let e=1/0,o=-1/0;for(let a of n.hull){let i=-(a.x*t.facing.x+a.y*t.facing.y);e=Math.min(e,i),o=Math.max(o,i)}let r=Math.max(0,Math.min(o-e,t.frontD-e));return n.height+r*st*Math.tan(n.rake*Math.PI/180)}function Ul(t,n){if(!t.facesAction)return!1;let e={x:-t.facing.y,y:t.facing.x},o=Ci/st,r=Math.max(1,Math.ceil((t.backD-t.frontD)/o)),a={left:new Map,right:new Map};for(let s of n)if(!(s===t||s.plane.floorIndex!==t.plane.floorIndex)&&!(s.facing.x*t.facing.x+s.facing.y*t.facing.y>=hl))for(let c of s.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(r-1,Math.floor((l-t.frontD)/o)),h=f==="left"?t.latMin-u:u-t.latMax;h<(a[f].get(m)?.gap??1/0)&&a[f].set(m,{gap:h,other:s})}let i=s=>{let c=s==="left"?t.latMin:t.latMax,l=0;for(let[u,{other:f}]of a[s]){if((f.facing.x*e.x+f.facing.y*e.y)*(s==="left"?1:-1)<fl)continue;let h=t.frontD+(u+.5)*o,y={x:-h*t.facing.x+c*e.x,y:-h*t.facing.y+c*e.y},d=-(y.x*f.facing.x+y.y*f.facing.y),x=-y.x*f.facing.y+y.y*f.facing.x;d<f.frontD&&x>=f.latMin&&x<=f.latMax&&l++}return l/r>=ml};return i("left")&&i("right")}function jl(t,n){if(n.plane.floorIndex!==t.plane.floorIndex||n.facing.x*t.facing.x+n.facing.y*t.facing.y<bl)return!1;let e=1/0,o=-1/0,r=1/0;for(let s of n.hull){let c=-s.x*t.facing.y+s.y*t.facing.x;e=Math.min(e,c),o=Math.max(o,c),r=Math.min(r,-(s.x*t.facing.x+s.y*t.facing.y))}let a=(t.frontD-r)*st;if(a<-gl||a>Ml)return!1;let i=Math.max(e-t.latMax,t.latMin-o);return i*st<=Rl&&i*st>=-_l}function Xl(t,n=!1,e=!1,o){let r=n?nl:tl,a=new Set(e?[]:t.filter(d=>!d.authored&&Ul(d,t))),i=[...t].sort((d,x)=>d.plane.floorIndex-x.plane.floorIndex||Number(a.has(x))-Number(a.has(d))||d.frontDistance-x.frontDistance);for(let d of a)o?.add(d.id);let s=(d,x,b)=>{let p=new Map,M=[],P=new Map,S=g=>{if(g.plane.floorIndex===0||g.plane.baseHeightM>0)return g.plane.baseHeightM;let I=P.get(g.plane.floorIndex-1);return I===void 0?g.plane.baseHeightM:I+jr};for(let g of i){if(a.has(g))g.height=S(g),g.level=0,g.rake=0,g.backHeight=g.height,p.set(g.id,void 0);else if(!g.authored){let A=S(g),R;for(let E of M){if(E.plane.floorIndex>g.plane.floorIndex)continue;if(Dl(g,E)){let k=Hl(g,E)+al;k>A&&(A=k,R=E);continue}let w=Nl(g,E,a.has(E));if(w==null)continue;let L=e&&!!g.plane.stageDeck&&E.level===0&&E.plane.floorIndex===g.plane.floorIndex&&Math.max(0,w)*st<=ll,G=a.has(E)?E.height+dl:L?E.backHeight:E.backHeight+zc+Math.min(Yc,Math.max(0,w)*st)*Math.tan(E.rake*Math.PI/180);G>A&&(A=G,R=E)}let B=d.get(g);B&&B.height>A+.01?(A=B.height,R=void 0):B=void 0,g.height=Math.round(Math.min(A,g.plane.baseHeightM+Qc)*100)/100;let C=!R&&!B&&g.height>g.plane.baseHeightM;if(g.level=R?R.level+1:B?B.level:C?1:0,g.rake=Gl(g.rowDepths,g.frontDistance,g.height,g.plane.focalHeightM),!g.facesAction&&g.rowCount<rl)g.rake=0;else if(g.level===0){let E=Math.max(1e-6,(g.backD-g.frontD)*st);g.rake=Math.min(g.rake,$c,Math.round(Math.atan(Jc/E)*1800/Math.PI)/10)}else g.rowCount>=2&&(g.rake=Math.max(g.rake,r[Math.min(g.level,r.length)-1]));let T=(g.backD-g.frontD)*st,O=R&&a.has(R)||B&&b?.has(B.id);if(x!==void 0&&O&&g.rowCount>=2&&(g.rake=x),n&&T>0&&g.height+T*Math.tan(g.rake*Math.PI/180)>g.plane.baseHeightM+Ei){let E=Math.max(0,g.plane.baseHeightM+Ei-g.height);g.rake=Math.max(Ti,Math.round(Math.atan(E/T)*1800/Math.PI)/10)}e&&g.plane.stageDeck&&g.level>0&&(g.rake=Math.min(g.rake,ul)),g.backHeight=g.height+T*Math.tan(g.rake*Math.PI/180),p.set(g.id,R?.id??(B?p.get(B.id):void 0))}let I=g.plane.floorIndex;P.set(I,Math.min(P.get(I)??1/0,g.height)),M.push(g)}return p},c=s(new Map),l=new Map,u=d=>l.get(d)?.height??d.height;for(let d=!0,x=0;d&&x<t.length;x++){d=!1;for(let b of t)if(!(b.authored||a.has(b)))for(let p of t){let M=l.get(p)??p;p===b||M.height-M.plane.baseHeightM<Sl||M.height<=u(b)+.01||jl(b,p)&&(l.set(b,M),d=!0)}}let f=new Map(t.map(d=>[d.id,d])),m=t.filter(d=>!d.authored&&d.rowCount>=2&&a.has(f.get(c.get(d.id)??""))),h=m.length?wo(m.map(d=>d.rake)):void 0;if(!l.size&&h===void 0)return c;let y=new Map([...new Set(l.values())].map(d=>[d,{...d}]));return s(new Map([...l].map(([d,x])=>[d,y.get(x)])),h,new Set(m.map(d=>d.id)))}var Po=(t,n)=>!!t&&t.x===n.x&&t.y===n.y;function Fi(t,n={x:0,y:-40}){let e=we(t),o=new Map;for(let b of e){if(!b.sectionId)continue;let p=o.get(b.sectionId);p?p.push(b):o.set(b.sectionId,[b])}let r={focalInferred:!1,confident:!1,sections:[]},a=t.floors?.length?t.floors.map((b,p)=>({objects:b.objects,floorIndex:p,floorId:b.id,baseHeightM:b.baseHeightM??0,focal:b.focalPoint??t.focalPoint})):[{objects:t.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:t.focalPoint}],i=new Set(a.flatMap(b=>b.objects.filter(p=>p.type==="table").map(p=>p.id))),s=[],c,l=new Set,u=a.map(b=>{let p=O=>!t.floors?.length||O.floorId===b.floorId,M=Ll(e.filter(O=>!O.sectionId&&O.kind!=="booth"&&!i.has(O.rowId)&&p(O))),P=[];for(let O of M){let E=un(ln(Li(O)),Pl/st);if(e.some(L=>!p(L)&&To(L,E)))continue;let w=`${wi}${b.floorIndex}-${P.length}`;l.add(w),o.set(w,O),P.push({type:"section",id:w,label:"",color:El,outline:E})}let S=P.length?{...b,objects:[...b.objects,...P]}:b,g=new Set(S.objects.filter(O=>O.type==="section").map(O=>O.logicalSectionId??O.id)),I=[...o.entries()].filter(([O])=>g.has(O)).flatMap(([,O])=>O),A=Cl(S.objects,Bo(I),I),R=S.focal;(A||S.focal&&!Po(S.focal,n))&&(r.confident=!0),A&&(r.stage??={id:A.shape.id,inferred:A.inferred,...S.floorId?{floorId:S.floorId}:{}},(A.inferred||Po(S.focal,n))&&(R=A.centre,r.focalInferred=!0));let B=A&&(!A.inferred||se(A.outline)*st*st<=Ao),C=A?void 0:c,T={tableIds:i,floorIndex:S.floorIndex,floorId:S.floorId,baseHeightM:S.baseHeightM,focal:C?.focal??R,outline:A?.outline??C?.outline,focalHeightM:C?.focalHeightM??S.baseHeightM+(A&&B?on({...A.shape,role:"stage"}).heightM:0),stageDeck:C?.stageDeck??!!(A&&B&&se(A.outline)*st*st<=Ao),middle:I.length?{x:I.reduce((O,E)=>O+E.x,0)/I.length,y:I.reduce((O,E)=>O+E.y,0)/I.length}:R};for(let O of S.objects){if(O.type!=="section")continue;let E=Fl(O,o.get(O.logicalSectionId??O.id)??[],T);E&&s.push(E)}return T.outline&&(c=T),Po(S.focal,T.focal)||(r.focal??=[]).push({...S.floorId?{floorId:S.floorId}:{},point:{...T.focal}}),{unit:S,plane:T,stage:A,planeSeats:I}}),f=a.flatMap(b=>b.objects).map(b=>b.type==="shape"&&!b.role&&(Io(b.label)==="wall"||!Io(b.label)&&Pi(b))?{...b,role:"wall"}:b),m=Rn({objects:f},e)!==null;m&&(r.indoor=!0);let h=new Set,y=Xl(s,m,vl(e,u[0]?.plane.focal??n)<cl,h),d=new Map(s.filter(b=>!b.authored).map(b=>[b.id,b])),x=u.map(({unit:b,plane:p,stage:M,planeSeats:P})=>b.objects.map(S=>{let g=S.type==="shape"&&!S.role&&S.id!==M?.shape.id?Io(S.label):null;if(S.type==="shape"&&!S.role&&S.id!==M?.shape.id&&(g==="wall"||!g&&Pi(S))&&S.type==="shape"){(r.roles??=[]).push({id:S.id,...p.floorId?{floorId:p.floorId}:{},role:"wall"});let{fill:E,...w}=S;return{...w,role:"wall"}}if(g&&S.type==="shape")return(r.roles??=[]).push({id:S.id,...p.floorId?{floorId:p.floorId}:{},role:g}),{...S,role:g};let A=M?.inferred&&S.id===M.shape.id&&S.type==="shape"?Bl(S,M.outline,b.objects,P):null;if(A&&S.type==="shape")return r.stage?.id===S.id&&(r.stage.field=A),{...S,role:"stage",stageKind:A};let R=S.type==="shape"&&S.id===M?.shape.id&&S.heightM===void 0&&!S.stageKind&&s.some(E=>E.plane===p&&(h.has(E.id)||E.level===0&&E.facesAction&&E.rake<=pl&&(E.frontDistance+E.backD-E.frontD)*st>=xl)),B=R?{heightM:yl}:{};if(M?.inferred&&S.id===M.shape.id&&S.type==="shape"&&se(M.outline)*st*st<=Ao)return r.stage?.id===S.id&&(r.stage.deck=!0),{...S,role:"stage",...B};if(R&&S.type==="shape"&&S.role==="stage")return{...S,...B};let C=S.type==="section"?d.get(S.id):void 0;if(!C||S.type!=="section")return S;let T=C.rowCount>=2&&C.rake>0;l.has(C.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:C.id,floorId:p.floorId,surfaceKind:T?"rakedRows":"flat",height:C.height,rake:C.rake,stackedOn:y.get(C.id)});let O={status:"inferred",source:"public-2d-topology",note:Tl};return{...S,height:C.height,rake:C.rake,surfaceKind:T?"rakedRows":"flat",physical3dProvenance:{height:O,rake:O,surfaceKind:O}}}));if(t.floors?.length){let b=t.floors.map((p,M)=>({...p,objects:x[M],focalPoint:u[M].plane.focal}));return{doc:{...t,floors:b,objects:b[0].objects,focalPoint:b[0].focalPoint},report:r}}return{doc:{...t,objects:x[0],focalPoint:u[0].plane.focal},report:r}}function cd(t,n,e){return e<0?n>1?t.filter(o=>o.kind==="floor"):[...t]:t.filter(o=>o.floorIndex===void 0||o.floorIndex===e)}function ld(t,n){let e=[...t].sort((r,a)=>r.screen.y-a.screen.y),o=[];for(let r of e){let a=o.find(i=>i.some(s=>Math.abs(s.screen.x-r.screen.x)<104&&Math.abs(s.screen.y-r.screen.y)<34));a?a.push(r):o.push([r])}return o.flatMap(r=>r.length<2?r:r.map((a,i)=>({...a,screen:{...a.screen,x:Math.max(54,Math.min(n-54,a.screen.x+(i-(r.length-1)/2)*104))}})))}var Vl=1.15,Wl=2.75,Kl=4.5,zl=.85,Yl=.5,Zl=.26;function ud(t,n,e){let o=Math.max(1e-6,n),r=t/o,a=e?.hasZoneLabels??!0,i=new Set(["stage","gate"]);return r>=.75&&i.add("floor"),r>=Vl&&i.add("zone"),r<=(a?Wl:Kl)&&(i.add("section"),i.add("ga")),r<=zl&&(i.add("annotation"),i.add("booth")),r<=Yl&&i.add("row"),r<=Zl&&i.add("seat"),i}function fd(t,n,e,o,r,a=6){let i=a+n,s=o-a-n,c=a+e,l=r-a-e;return{...t,x:i>s?o/2:Math.max(i,Math.min(s,t.x)),y:c>l?r/2:Math.max(c,Math.min(l,t.y))}}function md(t,n,e,o){let r=t,a=n[0],i=n[1],s=n[2],c=r[0]*a+r[4]*i+r[8]*s+r[12],l=r[1]*a+r[5]*i+r[9]*s+r[13],u=r[2]*a+r[6]*i+r[10]*s+r[14],f=r[3]*a+r[7]*i+r[11]*s+r[15];if(!(f>1e-6))return{x:0,y:0,depth:1/0,visible:!1};let m=c/f,h=l/f,y=u/f,d=m>=-1.05&&m<=1.05&&h>=-1.05&&h<=1.05&&y<=1;return{x:(m*.5+.5)*e,y:(1-(h*.5+.5))*o,depth:y,visible:d}}function hd(t,n,e=n,o=()=>0){let r=[],a=[...t].sort((i,s)=>o(s)-o(i)||i.screen.depth-s.screen.depth);for(let i of a){let s=!1;for(let c of r)if(Co(i,c,n,e)){s=!0;break}s||r.push(i)}return r}var ql=6;function Co(t,n,e,o){let r=Math.abs(t.screen.x-n.screen.x),a=Math.abs(t.screen.y-n.screen.y),i=t.halfWidth!=null&&n.halfWidth!=null?Math.max(e,t.halfWidth+n.halfWidth+ql):e;return r<i&&a<o}function dd(t,n,e){return t.length*n*.58+(e?14:0)}var $l={row:8,seat:14};function yd(t){return t<480?{row:5,seat:8}:t<768?{row:6,seat:10}:$l}function pd(t,n,e,o){let r=Math.max(1,Math.min(e,o)*.5),a=Math.min(2,Math.hypot(t.x-e/2,t.y-o/2)/r);return n*(1+1.5*a)}function xd(t,n,e,o,r=[]){let a=[...t].sort((s,c)=>(c.priority??0)-(s.priority??0)||s.focus-c.focus),i=[];for(let s of a){if(i.length>=o)break;let c=!1;for(let l of r)if(Co(s,l,n,e)){c=!0;break}if(!c){for(let l of i)if(Co(s,l,n,e)){c=!0;break}}c||i.push(s)}return i}function bd(t,n,e,o){let r=t[3]*n[0]+t[7]*n[1]+t[11]*n[2]+t[15];return r<=0||!(e>0)?0:e*Math.hypot(t[0],t[4],t[8])*o/(2*r)}function Un(t,n,e){if(t.length!==4||e<=n)return null;let o=zt(t),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*_,a=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*_;if(r<1e-6||a<1e-6)return null;let i=Math.min(.22/r,.16),s=Math.min(.28,(e-n)*.13),c=Math.min(.065/a,.2);return{quad:o,side:i,face:c,opening:jt(o,i,1-i),openingTop:e-s}}function ko(t,n,e){if(t.length!==4||e-n<=.2)return null;let o=zt(t),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*_;if(r<=1e-6)return null;let a=Math.min(.14,(e-n)*.08,r*.08),i=a/r,s=jt(o,i,1-i);return{quad:o,side:i,trim:a,inner:s,panel:re(s,.15,.85),bottom:n+a,top:e-a}}function Gi(t,n,e,o){let r=ko(t,n,e);if(!r)return;let{panel:a}=r,i=(p,M)=>({x:(p.x+M.x)/2,y:(p.y+M.y)/2}),s=i(a[0],a[1]),c=i(a[3],a[2]),l=Math.hypot(s.x-o.x,s.y-o.y)<=Math.hypot(c.x-o.x,c.y-o.y),[u,f]=l?[a[0],a[1]]:[a[3],a[2]],m=l?{x:s.x-c.x,y:s.y-c.y}:{x:c.x-s.x,y:c.y-s.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 y=Math.min(.006,h*_*.05),d=m.x/h*y,x=m.y/h*y,b=(p,M)=>[p.x*_+d,M,p.y*_+x];return[b(u,r.bottom),b(f,r.bottom),b(u,r.top),b(f,r.top)]}import Ql from"polygon-clipping";import Jl from"polygon-clipping";function yn(t,n,e,o,r,a,i,s={}){let c=dn(n),l=s.ao??z,u=r.flatMap(d=>{if(d.role!=="entrance"&&d.role!=="exit")return[];let x=ut(d);if(!x||x.length!==4||!Gn(c,dn(x)))return[];let b=s.portalBase??e,p=Un(x,b,b+on(d).heightM);if(!p)return[];let M=Math.min(o,p.openingTop);return M<=e?[]:[{poly:p.opening,height:M}]});if(!u.length)return!1;let f=d=>d.map(x=>[x.x,x.y]),m=[f(n),...(s.holes??[]).map(f)],h=[e,...new Set(u.map(d=>d.height)),o].sort((d,x)=>d-x),y=[];try{for(let d=1;d<h.length;d++){let x=h[d-1],b=h[d];if(b-x<1e-6)continue;let p=u.filter(P=>P.height>x+1e-6).map(P=>[f(P.poly)]),M=p.length?Jl.difference(m,...p):[m];y.push({low:x,high:b,polys:M})}}catch{return!1}for(let d of y)for(let x of d.polys){let[b,...p]=x.map(P=>P.map(([S,g])=>({x:S,y:g}))),M=P=>l.wallBottom+(l.top-l.wallBottom)*(P-e)/(o-e);Z(t,b,p,()=>d.high,d.low,a,i,{...l,top:M(d.high),wallBottom:M(d.low)})}return!0}var Lo={depthM:1.6,thicknessM:.35,minWallM:6};function je(t,n,e,o,r,a,i,s,c){let l=o-e;if(l<=0)return;let u=s&&(c??l)>=Lo.minWallM?tu(n,s):null,f=u?o-Lo.thicknessM:o,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]],y=d=>z.wallBottom+(z.top-z.wallBottom)*(d-e)/l;for(let[d,x,b]of h){let p={...z,top:y(x),wallBottom:y(d)},M=W(a,b),P=W(i,b);yn(t,n,d,x,r,M,P,{portalBase:e,ao:p})||Z(t,n,void 0,()=>x,d,M,P,p)}for(let[d,...x]of u??[])Z(t,d,x.length?x:void 0,()=>o,f,W(a,1.12),W(i,.78),z)}function tu(t,n){let e=Lo.depthM/_,o=t.map(i=>{let s=n.x-i.x,c=n.y-i.y,l=Math.hypot(s,c)||1;return{x:i.x+s/l*e,y:i.y+c/l*e}}),r=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s},a=[[r(t)],[r(o)]];for(let i=0;i<t.length;i++){let s=(i+1)%t.length;a.push([r([t[i],t[s],o[s],o[i]])])}try{let[i,...s]=a,c=Ql.union(i,...s);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 ae(t,n,e){let o=ht(n.stroke?.color),r=n.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let a=n.kind==="line"||n.kind==="polyline",i=a?vn(n.points??[],n.rotation):ut(n);if(!i||i.length<2)return;let s=r*.5,c=Gr(n)?Dr(i,...Nr(r)):Array.from({length:a?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*s,h=(u.x-l.x)/f*s,y=[(l.x+m)*_,e,(l.y+h)*_],d=[(u.x+m)*_,e,(u.y+h)*_],x=[(u.x-m)*_,e,(u.y-h)*_],b=[(l.x-m)*_,e,(l.y-h)*_];t.tri(y,d,x,[0,1,0],o),t.tri(y,x,b,[0,1,0],o)}}function Ni(t){return t==="bar"||t==="concession"||t==="coat"||t==="restroom"}var jn=(t,n,e)=>({x:t.x+(n.x-t.x)*e,y:t.y+(n.y-t.y)*e});function Xe(t,n,e,o){let[r,a,i,s]=n?t:[t[3],t[2],t[1],t[0]];return[jn(r,s,e),jn(a,i,e),jn(a,i,o),jn(r,s,o)]}function Di(t,n,e,o,r,a,i,s,c=!1){if(e.length!==4||r-o<.4)return!1;let l=A=>c?Math.min(A,r):A,u=zt(e),f=Math.hypot(u[3].x-u[0].x,u[3].y-u[0].y)*_;if(f<.4)return!1;let m=jn(u[0],u[1],.5),h=jn(u[3],u[2],.5),y=Math.hypot(m.x-s.x,m.y-s.y)<=Math.hypot(h.x-s.x,h.y-s.y),d=lt(i,[.92,.9,.86],.35),x=W(a,.72),b=r-o;if(n==="restroom"){let A=Math.min(.18,b*.08);return dt(t,u,r-A,o,i,a),dt(t,u,r,r-A,d,d),!0}let p=o+Math.min(1.1,b),M=n==="coat"?1:Math.min(.5,.75/f),P=Xe(u,y,0,M);if(dt(t,P,p-.05,o,x,a),dt(t,P,p,p-.05,d,d),n==="coat"||f<1.2)return!0;if(n==="bar"){let A=Xe(u,y,Math.max(M+.2,1-.45/f),1),R=l(o+Math.max(Math.min(2.2,b*2),p-o+.6));return dt(t,A,R,o,i,x),!0}let S=Xe(u,y,Math.max(M+.25,.55),1),g=l(o+Math.max(2.6,p-o+1.4));if(g-.14<=p)return!0;dt(t,S,g-.14,o,i,a),dt(t,u,g,g-.14,d,x);let I=Math.min(.08,.1/Math.max(.1,Math.hypot(u[1].x-u[0].x,u[1].y-u[0].y)*_));for(let[A,R]of[[0,I],[1-I,1]])dt(t,Xe(jt(u,A,R),y,0,Math.min(.08,.1/f)),g-.14,p,x,x);return!0}var _n=.06,nu=.05,Hi=.05,vi=.15,Fo=25;function Ui(t,n,e){let o=new Map,r=new Array(n.length).fill(null),a=new Float64Array(n.length),i=new Array(n.length).fill(void 0),s=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 y of h.objects){if(y.type==="table"&&u.add(y.id),y.type!=="section"||!y.outline||y.outline.length<3)continue;let d=un(y.outline,Qt);c.set(y.id,{section:y,unit:h,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:y.id,floorIndex:m,box:dn(d),section:y,unit:h,outline:d})}}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],y=e?f.get(e[m])??[]:l,d=h.sectionId?y.find(b=>b.id===h.sectionId)??y.find(b=>b.section.logicalSectionId===h.sectionId&&$t({x:h.x,y:h.y},b.outline,b.section.holes)):void 0,x=d?[d]:y;for(let b of x){if(e&&b.floorIndex!==e[m]||!d&&(h.x<b.box.minX||h.x>b.box.maxX||h.y<b.box.minY||h.y>b.box.maxY||!$t({x:h.x,y:h.y},b.outline,b.section.holes)))continue;r[m]=b.id;let p=c.get(b.id);p.hasSeats=!0;let M=h.focalPoint??b.unit.focal,P=Math.hypot(h.x-M.x,h.y-M.y);P<p.frontU&&(p.frontU=P),p.seatIndices.push(m);let S=h.rowId||`__seat-${m}`,g=p.rows.get(S);g?g.push({x:h.x,y:h.y}):p.rows.set(S,[{x:h.x,y:h.y}]);break}}for(let[m,h]of c){let y=Ln(h.section,{floorBaseHeightM:h.unit.baseHeightM}),d=h.unit.baseHeightM,x=y.rake>0?Math.tan(y.rake*Math.PI/180):0,b=y.rake<=.01&&y.height<=d+.001,p=h.section.surfaceKind,M=p==="flat"?!0:p==="rakedRows"&&y.rake>.01?!1:b,P=h.hasSeats?Ir(m,n,h.seatIndices,h.unit.focal):{sectionId:m,rows:[],blockCount:0},g=P.rows.length<2?vr([...h.rows.values()].map(k=>({points:k})),h.unit.focal):null,I=1/0;if(g){if(h.hasSeats)for(let k of h.rows.values())for(let N of k){let U=g.depthAt(N.x,N.y);U<I&&(I=U)}if(!h.hasSeats||!Number.isFinite(I)){I=1/0;for(let k of h.section.outline){let N=g.depthAt(k.x,k.y);N<I&&(I=N)}}}let A=d+nu,R=Math.max(A,y.height),B=k=>{let N=Math.max(0,k-I)*st,U=Math.min(N*x,Fo);return Math.max(A,y.height+U)},C=k=>{let N=Math.max(0,k)*st,U=Math.min(N*x,Fo);return Math.max(A,y.height+U)},T=M?[]:P.rows.map(k=>({pts:k.pts,y:C(k.blockDepth),depth:k.blockDepth,blockId:k.blockId,...u.has(k.id)?{patch:ui(k.pts,Qt)}:{}})),O=T.length?T[0].y:R,E=T.map(k=>{let N=k.patch&&k.patch.length>=3?k.patch:k.pts,U=0,X=0;for(let j of N)U+=j.x,X+=j.y;let F=N.length||1;U/=F,X/=F;let v=0;for(let j of N){let Y=Math.hypot(j.x-U,j.y-X);Y>v&&(v=Y)}return{cx:U,cy:X,rad:v}}),w=M?()=>R:T.length>=2?(k,N)=>{let U=1/0,X=O;for(let F=0;F<T.length;F++){let v=E[F];if(Math.hypot(k-v.cx,N-v.cy)-v.rad>=U)continue;let j=T[F].patch,Y=j&&j.length>=3?kt(j,k,N)?0:Pe(j,k,N):Pe(T[F].pts,k,N);Y<U&&(U=Y,X=T[F].y)}return X}:(k,N)=>g?B(g.depthAt(k,N)):R,L=[0,1,0],G=T.length>=2||M?()=>L:(k,N)=>{if(!g)return L;let U=g.depthAt(k,N);if(U<=I)return L;let X=(U-I)*st;if(X*x>=Fo||y.height+X*x<=A)return L;let[F,v]=g.gradientAt(k,N);if(F===0&&v===0)return L;let j=1/Math.hypot(x,1);return[-F*x*j,j,-v*x*j]};if(!M)for(let k of P.rows){let N=C(k.blockDepth);for(let U of k.seatIndices)i[U]=N}for(let k of P.rows){let N=[];for(let j=1;j<k.pts.length;j++){let Y=Math.hypot(k.pts[j].x-k.pts[j-1].x,k.pts[j].y-k.pts[j-1].y);Y>1e-6&&N.push(Y)}N.sort((j,Y)=>j-Y);let U=N.length?N[Math.floor(N.length/2)]:1/0,X=1/0,F=k.pts[Math.floor(k.pts.length/2)];if(F)for(let j of P.rows){if(j===k||j.blockId!==k.blockId)continue;let Y=Pe(j.pts,F.x,F.y);Y>1e-6&&Y<X&&(X=Y)}let v=Math.min(U,Math.max(X,U*.5));if(Number.isFinite(v)&&v>0)for(let j of k.seatIndices)s[j]=v}o.set(m,{sectionId:m,deckAt:w,normalAt:G,flat:M,bottomY:d,rowLevels:T,landingY:O})}for(let m=0;m<n.length;m++){let h=r[m],y=n[m];if(h){let b=i[m];a[m]=(b??o.get(h).deckAt(y.x,y.y))+vi;continue}let d=y.eyeHeightM,x=Number.isFinite(d)?Math.max(0,d-Ae):0;a[m]=y.kind==="booth"?x+_n+vi:x}return{bySection:o,seatOwner:r,seatDeckY:m=>a[m],seatPitchU:m=>s[m]}}var Ki=10,Bn=11,Xn=[.93,.94,.95],eu=[.93,.8,.22],ou=[.82,.14,.16],ru=[.78,.1,.12],Go=[.74,.77,.8],No={width:7.32,height:2.44,depth:2},Ve={width:1.83,height:1.22,depth:1,fromEndBoards:3.35},iu=1.5,su=1.8,Do=2.4,Xt=(t,n)=>[t[0]-n[0],t[1]-n[1],t[2]-n[2]],le=(t,n)=>[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]],pn=t=>{let n=Math.hypot(t[0],t[1],t[2])||1;return[t[0]/n,t[1]/n,t[2]/n]};function tn(t,n,e,o,r){let a=pn(Xt(e,n)),i=pn(le(a,Math.abs(a[1])<.9?[0,1,0]:[1,0,0])),s=le(i,a),c=(l,u)=>{let f=u===0||u===3?-o:o,m=u<2?-o:o;return[l[0]+i[0]*f+s[0]*m,l[1]+i[1]*f+s[1]*m,l[2]+i[2]*f+s[2]*m]};for(let l=0;l<4;l++){let u=(l+1)%4,f=c(n,l),m=c(n,u),h=c(e,l),y=c(e,u),d=pn(le(Xt(m,f),Xt(h,f))),x=Xt([(f[0]+m[0])/2,(f[1]+m[1])/2,(f[2]+m[2])/2],n);d[0]*x[0]+d[1]*x[1]+d[2]*x[2]<0&&(d=[-d[0],-d[1],-d[2]]);let b=W(r,.86+.14*Math.max(0,d[1]));t.tri(f,m,y,d,b),t.tri(f,y,h,d,b)}}function ce(t,n,e,o,r){let a=Math.hypot(...Xt(e,n)),i=Math.hypot(...Xt(r,n)),s=pn(le(Xt(e,n),Xt(r,n)));t.tri(n,e,o,s,[0,0,0],[a,0,0],[a,i,0]),t.tri(n,o,r,s,[0,0,0],[a,i,0],[0,i,0])}function Ho(t,n,e,o,r,a,i,s,c){let l=(p,M)=>[p[0],p[1]+M,p[2]],u=p=>[p[0]+o[0]*a,p[1],p[2]+o[2]*a],f=l(n,r),m=l(e,r),h=u(n),y=u(e),d=u(f),x=u(m);t.setMaterial(c),tn(t,n,f,i,s),tn(t,e,m,i,s),tn(t,f,m,i,s),t.setMaterial(Bn);let b=Math.min(i,.03);for(let[p,M]of[[h,d],[y,x],[f,d],[m,x],[d,x],[n,h],[e,y],[h,y]])tn(t,p,M,b,W(s,.92));t.setMaterial(Ki),ce(t,h,y,x,d),ce(t,f,m,x,d),ce(t,n,h,d,f),ce(t,e,y,x,m),t.setMaterial(0)}var vo={height:.711,width:.2286,pitchLength:20.12},au=[.88,.8,.6];function zi(t,n,e){if(n.length!==4)return;let o=i=>Math.hypot(n[(i+1)%4].x-n[i].x,n[(i+1)%4].y-n[i].y),r=o(0)<=o(1)?0:1,a=Math.max(o(0),o(1))*_/vo.pitchLength;if(a>.2){t.setMaterial(Bn);for(let i of[r,r+2]){let s=n[i%4],c=n[(i+1)%4],l=o(i%4)||1,u={x:(s.x+c.x)/2,y:(s.y+c.y)/2},f=(c.x-s.x)/l,m=(c.y-s.y)/l;for(let h of[-1,0,1]){let y=h*vo.width*a/2/_,d=Et({x:u.x+f*y,y:u.y+m*y},e);tn(t,d,[d[0],d[1]+vo.height*a,d[2]],.019*a,au)}}t.setMaterial(0)}}var Et=(t,n)=>[t.x*_,n,t.y*_];function Yi(t){if(t.length<3)return null;let n=0,e=0;for(let b of t)n+=b.x,e+=b.y;n/=t.length,e/=t.length;let o=0,r=0,a=0;for(let b of t){let p=b.x-n,M=b.y-e;o+=p*p,r+=M*M,a+=p*M}let i=.5*Math.atan2(2*a,o-r),s=Math.cos(i),c=Math.sin(i),l=1/0,u=-1/0,f=1/0,m=-1/0;for(let b of t){let p=(b.x-n)*s+(b.y-e)*c,M=-(b.x-n)*c+(b.y-e)*s;l=Math.min(l,p),u=Math.max(u,p),f=Math.min(f,M),m=Math.max(m,M)}let h=(u-l)*_,y=(m-f)*_;if(!(h>4)||!(y>2))return null;let d={a:(l+u)/2,b:(f+m)/2};return{at:(b,p)=>{let M=d.a+b/_,P=d.b+p/_;return{x:n+s*M-c*P,y:e+c*M+s*P}},lengthM:h,widthM:y}}function Zi(t,n,e,o,r,a){let i=n.map(c=>Et(c,e)),s=n.map(c=>Et(c,e+o));t.setMaterial(0);for(let c=0;c<n.length;c++)tn(t,i[c],s[c],r,a);t.setMaterial(Bn);for(let c=0;c+1<n.length;c++)tn(t,s[c],s[c+1],.025,a);t.setMaterial(Ki);for(let c=0;c+1<n.length;c++)ce(t,i[c],i[c+1],s[c+1],s[c]);t.setMaterial(0)}var ji=[.66,.29,.22],cu=[.87,.79,.58],Xi=[.17,.36,.63],qi=[.56,.59,.63],lu=[.7,.7,.68],uu={length:176.9,trackWidth:9.76,longJump:{runway:40,runwayWidth:1.22,pit:9,pitWidth:2.75,fromKerb:3,start:-25},highJump:{matLength:3,matWidth:5,matHeight:.7,apron:15,intoBend:3.5,bar:2},cage:{radius:3.5,height:7,intoBend:10,pad:1.07,sectorDeg:34.92,sector:60,openDeg:120}};function $i(t,n,e){let o=Yi(n);if(!o)return;let{at:r,lengthM:a,widthM:i}=o,s=uu,c=Math.min(1.2,Math.max(.5,a/s.length)),l=i/2,u=a/2-l,f=l-s.trackWidth;if(!(u>30*c)||!(f>22*c))return;let m=e+.03,h=(T,O,E=0)=>{Z(t,T,void 0,()=>m+E,m+E-.004,O,O,z)},y=(T,O,E,w)=>[r(T,E),r(O,E),r(O,w),r(T,w)];t.setMaterial(0),h(y(u-.08,u+.08,-l+.2,-f-.2),Xn);let d=s.longJump,x=f-d.fromKerb*c,b=(d.start+d.runway)*c;h(y(d.start*c,b,x-d.runwayWidth*c/2,x+d.runwayWidth*c/2),ji),h(y(b,b+d.pit*c,x-d.pitWidth*c/2,x+d.pitWidth*c/2),cu);let p=s.highJump,M=-(u+p.intoBend*c),P=[];for(let T=0;T<=16;T++){let O=-Math.PI/2+Math.PI*T/16;P.push(r(M-.3*c+Math.cos(O)*p.apron*c,Math.sin(O)*p.apron*c))}h(P,ji),Z(t,y(M-p.matLength*c,M,-(p.matWidth*c)/2,p.matWidth*c/2),void 0,()=>e+p.matHeight*c,e,Xi,W(Xi,.82),z),t.setMaterial(Bn);let S=[-1,1].map(T=>r(M+.25*c,T*(p.bar+.1)*c));for(let T of S)tn(t,Et(T,e),Et(T,e+(p.bar+.3)*c),.02,Xn);tn(t,Et(S[0],e+p.bar*c),Et(S[1],e+p.bar*c),.015,Xn),t.setMaterial(0);let g=s.cage,I=u+g.intoBend*c;h(((T,O)=>Array.from({length:O},(E,w)=>{let L=2*Math.PI*w/O;return r(I+Math.cos(L)*T,Math.sin(L)*T)}))(g.pad*c,16),lu);let R=g.sectorDeg/2*Math.PI/180;for(let T of[-1,1]){let O=g.sector*c,E=-Math.cos(R),w=T*Math.sin(R);h([r(I+w*.15,-E*.15),r(I+E*O+w*.15,w*O-E*.15),r(I+E*O-w*.15,w*O+E*.15),r(I-w*.15,E*.15)],Xn,.006)}let B=g.openDeg/2*Math.PI/180,C=[];for(let T=0;T<=6;T++){let O=B+(2*Math.PI-2*B)*T/6;C.push(r(I-Math.cos(O)*g.radius*c,Math.sin(O)*g.radius*c))}Zi(t,C,e,g.height*c,.05,qi)}var fu=[.95,.8,.16],Vi=[.13,.17,.2],Wi=[.78,.8,.83],mu={backY:70,backHalf:25,pole:{x:70,y:-18},net:{height:9,inset:.5,wing:15},poleHeight:12,dugout:{length:18,depth:2.4,height:1,along:.32,inset:1.9}};function Ji(t,n,e,o,r,a){let i=mu,s={x:i.pole.x-i.backHalf,y:i.pole.y-i.backY},c=Math.hypot(s.x,s.y),l=s.x/c,u=s.y/c,f=(M,P,S)=>n(M*(i.backHalf+l*P+u*S),i.backY+u*P-l*S),m=i.net,h=i.backY-m.inset,y=i.backHalf-m.inset,d=[f(-1,m.wing,m.inset)];for(let M of[-y,-y/2,y/2,y])d.push(n(M,h));d.push(f(1,m.wing,m.inset)),Zi(t,d,e,m.height*o,.05,qi),t.setMaterial(0);for(let M of[-1,1]){let P=Et(n(M*(i.pole.x-.4),i.pole.y+.4),e);tn(t,P,[P[0],P[1]+i.poleHeight*o,P[2]],.09,fu)}if(!a)return;let x=i.dugout,b=x.along*c-x.length/2,p=b+x.length;for(let M of[-1,1]){let P=[f(M,b,x.inset-x.depth/2),f(M,p,x.inset-x.depth/2)],S=[f(M,b,x.inset+x.depth/2),f(M,p,x.inset+x.depth/2)],g=Math.ceil(x.length),I=!0;for(let C=0;I&&C<=g;C++){let T=C/g;I=r({x:P[0].x+(P[1].x-P[0].x)*T,y:P[0].y+(P[1].y-P[0].y)*T})}if(!I)continue;let A=[P[0],P[1],S[1],S[0]];Z(t,A,void 0,()=>e+(x.height-.1)*o,e,Vi,W(Vi,.85),z);let R=(C,T)=>({x:C.x+(C.x-T.x)*.04,y:C.y+(C.y-T.y)*.04}),B=[R(P[0],S[1]),R(P[1],S[0]),R(S[1],P[0]),R(S[0],P[1])];Z(t,B,void 0,()=>e+x.height*o,e+(x.height-.14)*o,Wi,W(Wi,.9),z)}}function Qi(t,n,e,o,r,a){let i=n.lengthM/2,s=n.widthM/2;if(a){let c=No.width/2*o,l=No.depth*o;for(let u of[-1,1]){let f=n.at(u*(i+l),-c),m=n.at(u*(i+l),c);if(!r(f)||!r(m))continue;let h=Et(n.at(u*i,-c),e),y=Et(n.at(u*i,c),e),d=Et(n.at(u*(i+1),0),e),x=Et(n.at(u*i,0),e);Ho(t,h,y,pn(Xt(d,x)),No.height*o,l,.06,Xn,0)}}t.setMaterial(Bn);for(let c of[-1,1])for(let l of[-1,1]){if(!r(n.at(c*i,l*s)))continue;let u=Et(n.at(c*i,l*s),e),f=[u[0],u[1]+iu*o,u[2]];tn(t,u,f,.02,eu);let m=pn(Xt(Et(n.at(c*(i+1),l*(s+1)),e),u)),h=[f[0]+m[0]*.4*o,f[1]-.14*o,f[2]+m[2]*.4*o],y=[f[0],f[1]-.28*o,f[2]];t.tri(f,h,y,pn(le(Xt(h,f),Xt(y,f))),ou)}t.setMaterial(0)}function ts(t,n,e,o,r){let a=Yi(n);if(!a)return;let{at:i,lengthM:s}=a,c=Math.min(1.2,Math.max(.5,s/60)),l=s/2-Ve.fromEndBoards*c,u=Ve.width/2*c;for(let x of[-1,1]){let b=Et(i(x*l,-u),e),p=Et(i(x*l,u),e),M=Et(i(x*(l+1),0),e),P=Et(i(x*l,0),e);Ho(t,b,p,pn(Xt(M,P)),Ve.height*c,Ve.depth*c,.03,ru,Bn)}let f=Jt(n,r/2/_);if(f.length<3)return;let m=o+su;t.setMaterial(Bn);let h=Do;for(let x=0;x<f.length;x++){let b=f[x],p=f[(x+1)%f.length],M=Math.hypot(p.x-b.x,p.y-b.y)*_,P=0;for(;h+(M-P)>=Do;){P+=Do-h,h=0;let S=M>0?P/M:0,g={x:b.x+(p.x-b.x)*S,y:b.y+(p.y-b.y)*S};tn(t,Et(g,o),Et(g,m),.025,Go)}h+=M-P}let y=Jt(n,(r/2-.03)/_),d=Jt(n,(r/2+.03)/_);y.length>=3&&d.length>=3&&Z(t,y,[d.slice().reverse()],()=>m,m-.05,Go,W(Go,.9),z),t.setMaterial(0)}function ns(t,n,e,o,r){if(n.length!==4||!(r-o>.2))return;let a=(y,d)=>({x:(y.x+d.x)/2,y:(y.y+d.y)/2}),i=y=>Math.hypot(y.x-e.x,y.y-e.y),s=i(a(n[0],n[1]))<=i(a(n[3],n[2])),[c,l,u]=s?[n[0],n[1],n[3]]:[n[3],n[2],n[0]],f=Math.hypot(u.x-c.x,u.y-c.y)*_;if(!(f>.05))return;let m=Et(c,o),h=Et(l,o);Ho(t,m,h,pn(Xt(Et(u,o),m)),r-o,f,.06,Xn,0)}var hu=[.12,.38,.16],du=[.72,.62,.45],yu=[.88,.93,.96],es=[.95,.95,.94],pu=[.66,.29,.22],Uo={length:20.12,width:3.05},xu=.14,bu=9.76,rn=[.93,.94,.95],We=[.1,.11,.13],gu=[.45,.85,1.25],Mu=1.45,os=.012,rs=.004,is=1.07,Ke=.15,ss=[.93,.76,.18],jo={height:.2,proud:.02,buried:.03};function Tn(t,n,e,o,r,a){t.setMaterial(a),Z(t,n,e?[e.slice().reverse()]:void 0,()=>o,o-.004,r,r,z)}var Vn=(t,n)=>Jt(t,n/_);function cs(t,n,e){let o=n.x-t.x,r=n.y-t.y,a=Math.hypot(o,r);if(a<1e-9)return null;let i=-r/a*e,s=o/a*e;return[{x:t.x+i,y:t.y+s},{x:n.x+i,y:n.y+s},{x:n.x-i,y:n.y-s},{x:t.x-i,y:t.y-s}]}function Ru(t,n,e,o){let r=n.map(a=>[a.x*_,e,a.y*_]);t.tri(r[0],r[1],r[2],[0,1,0],o),t.tri(r[0],r[2],r[3],[0,1,0],o)}function Wn(t,n,e,o,r,a){let i=e/_,s=[{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,s,void 0,()=>r,o,a,W(a,.85),z)}function Vt(t,n,e,o,r,a,i){let s=cs(n,e,o/_);s&&Z(t,s,void 0,()=>a,r,i,W(i,.85),z)}function he(t){let n=zt(t),e={x:(n[0].x+n[2].x)/2,y:(n[0].y+n[2].y)/2},o=Math.hypot(n[1].x-n[0].x,n[1].y-n[0].y)||1,r=Math.hypot(n[3].x-n[0].x,n[3].y-n[0].y)||1,a={x:(n[1].x-n[0].x)/o,y:(n[1].y-n[0].y)/o},i={x:(n[3].x-n[0].x)/r,y:(n[3].y-n[0].y)/r};return{at:(c,l)=>({x:e.x+(a.x*c+i.x*l)/_,y:e.y+(a.y*c+i.y*l)/_}),lengthM:o*_,widthM:r*_}}function Xo(t){let n=1/0,e=-1/0,o=1/0,r=-1/0;for(let m of t.points??[])n=Math.min(n,m.x),e=Math.max(e,m.x),o=Math.min(o,m.y),r=Math.max(r,m.y);let a=(t.rotation??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),c=(n+e)/2,l=(o+r)/2,u=m=>a?{x:c+(m.x-c)*i-(m.y-l)*s,y:l+(m.x-c)*s+(m.y-l)*i}:m,f=(m,h,y,d)=>u({x:c+m/y*(e-n),y:l+h/d*(r-o)});return{turn:u,shortSideM:Math.min(e-n,r-o)*_,local:f,widthU:e-n}}function _u(t){let n=fo(t).find(e=>e.closed&&!e.fill&&e.points.length===4);return n?n.points.map(Xo(t).turn):null}function ls(t,n,e){let o=fo(n);if(!o.length)return;let{turn:r,shortSideM:a}=Xo(n),i=Math.max(.04,Math.min(.3,a*.004))/_,s=0;t.setMaterial(0);for(let u of o){if(!u.fill)continue;let f=u.points.map(r);Tn(t,f,null,e+os+s*rs,ht(u.fill)??rn,0),s++}let c=o.filter(u=>!(u.fill&&u.ink===u.fill)),l=[...new Set(c.map(u=>u.ink??uo))];for(let u of l){let f=e+os+s++*rs,m=ht(u)??rn;for(let h of c){if((h.ink??uo)!==u)continue;let y=h.points.map(r),d=h.closed?y.length:y.length-1;for(let x=0;x<d;x++){let b=cs(y[x],y[(x+1)%y.length],i);b&&Ru(t,b,f,m)}}}}function us(t,n,e,o,r,a){if(n.length<3)return!1;let i=o+.006,s=r??hu;if(e==="oval-cricket"){let c=n.reduce((g,I)=>g+I.x,0)/n.length,l=n.reduce((g,I)=>g+I.y,0)/n.length,u=g=>n.map(I=>({x:c+(I.x-c)*g,y:l+(I.y-l)*g})),f=8;for(let g=0;g<f;g++){let I=u(1-g/f),A=g===f-1?null:u(1-(g+1)/f);Tn(t,I,A,i,W(s,g%2?1.04:.96),4)}let m=n[0];for(let g of n)Math.hypot(g.x-c,g.y-l)>Math.hypot(m.x-c,m.y-l)&&(m=g);let h=Math.hypot(m.x-c,m.y-l)||1,y=(m.x-c)/h,d=(m.y-l)/h,x=-d,b=y,p=Math.min(1,2*h*_*xu/Uo.length),M=Uo.length*p/2/_,P=Uo.width*p/2/_,S=(a&&_u(a))??[[-M,-P],[M,-P],[M,P],[-M,P]].map(([g,I])=>({x:c+y*g+x*I,y:l+d*g+b*I}));return Tn(t,S,null,i+.004,du,0),zi(t,S,i+.004),t.setMaterial(0),!0}if(e==="rink-hockey"){let c=Vn(n,Ke);Tn(t,c,null,i,yu,0),t.setMaterial(0),Z(t,n,[c.slice().reverse()],()=>o+is,o,es,W(es,.9),z);let l=Vn(n,Ke-jo.buried),u=Vn(n,Ke+jo.proud);return l.length>=3&&u.length>=3&&Z(t,l,[u.slice().reverse()],()=>o+jo.height,o,ss,W(ss,.92),z),ts(t,n,i,o+is,Ke),!0}if(e==="ring-boxing"&&n.length===4){let{at:c}=he(n),l=[c(-3.05,-3.05),c(3.05,-3.05),c(3.05,3.05),c(-3.05,3.05)],u=[[.77,.19,.19],rn,[.17,.42,.69],rn];t.setMaterial(0),l.forEach((f,m)=>Wn(t,f,.07,o,o+Mu,u[m]));for(let f of gu)for(let m=0;m<4;m++)Vt(t,l[m],l[(m+1)%4],.025,o+f-.025,o+f+.025,rn);return!0}if(e==="court-tennis"&&n.length===4){let{at:c}=he(n);t.setMaterial(0),Vt(t,c(0,-6.4),c(0,6.4),.015,o,o+.95,We),Vt(t,c(0,-6.4),c(0,6.4),.03,o+.95,o+1,rn);for(let l of[-1,1])Wn(t,c(0,l*6.4),.05,o,o+1.07,We);return!0}if(e==="court-basketball"&&n.length===4){let{at:c,lengthM:l}=he(n),u=Math.min(14,l/2-.5);t.setMaterial(0);for(let f of[-1,1]){let m=c(f*(u+1.2),0),h=c(f*(u-1.2),0);Wn(t,m,.12,o,o+3.4,We),Vt(t,m,h,.06,o+3.25,o+3.4,We),Vt(t,c(f*(u-1.2),-.9),c(f*(u-1.2),.9),.03,o+2.9,o+3.95,rn)}return!0}if(e==="pitch-rugby"&&n.length===4){let{at:c,lengthM:l}=he(n),u=l*(50/120);t.setMaterial(0);for(let f of[-1,1]){for(let m of[-2.8,2.8])Wn(t,c(f*u,m),.07,o,o+12,rn);Vt(t,c(f*u,-2.8),c(f*u,2.8),.06,o+2.94,o+3.06,rn)}return!0}if(e==="track-athletics"){let c=Vn(n,bu);return c.length<3?!1:(Tn(t,n,c,i,pu,0),Tn(t,c,null,i,s,4),t.setMaterial(0),$i(t,n,o),!0)}return!1}var ue=140,as=1.6,fe=[.9,.91,.93],ze=[.15,.19,.3],me=[.14,.15,.18],Su=[.1,.24,.18],Ye=.9,Iu=6,Au={"pitch-football":105,"pitch-rugby":120,"court-tennis":23.77,"court-basketball":32},Pu={sidelineShare:15/19,fromSideline:1.35,tableHalfLength:4.5,tableHalfDepth:.38,tableHeight:.76,benchFrom:6,benchTo:12.5,benchHalfDepth:.25,benchHeight:.45,benchBackHeight:.85},Eu=[.13,.15,.2],wu=[.82,.84,.87];function fs(t,n,e,o,r,a=!1,i=!1){let s=n.stageKind;if(!s||e.length<3)return;if(t.setMaterial(0),s==="diamond-baseball"){let{local:R,widthU:B}=Xo(n);if(!(B>0))return;let C=R(0,0,ue,ue),T=r.filter(E=>Math.hypot(E.x-C.x,E.y-C.y)<=B),O=Math.min(1.2,Math.max(.5,B*_/ue));Ji(t,(E,w)=>R(E,w,ue,ue),o,O,E=>T.every(w=>Math.hypot(w.x-E.x,w.y-E.y)*_>=as),!i),t.setMaterial(0);return}if(s==="oval-cricket"){let R=Vn(e,2.85),B=Vn(e,3.1);R.length>=3&&B.length>=3&&Tn(t,R,B,o+.03,rn,0),t.setMaterial(0);return}let c=Au[s];if(!c||e.length!==4)return;let{at:l,lengthM:u,widthM:f}=he(e),m=Math.min(1.2,Math.max(.5,u/c)),h=u/2,y=f/2,d=Math.max(h,y)+14,x=l(0,0),b=r.filter(R=>Math.hypot(R.x-x.x,R.y-x.y)*_<d),p=R=>b.every(B=>Math.hypot(B.x-R.x,B.y-R.y)*_>=as),M=(R,B)=>{let C=Math.max(1,Math.ceil(Math.hypot(B.x-R.x,B.y-R.y)*_));for(let T=0;T<=C;T++)if(!p({x:R.x+(B.x-R.x)*(T/C),y:R.y+(B.y-R.y)*(T/C)}))return!1;return!0},P=(R,B,C,T,O)=>{let E=Math.hypot(B[0]-R[0],B[1]-R[1]),w=Math.max(1,Math.round(E/Iu));for(let L=0;L<w;L++){let G=L/w+.012,k=(L+1)/w-.012,N=l(R[0]+(B[0]-R[0])*G,R[1]+(B[1]-R[1])*G),U=l(R[0]+(B[0]-R[0])*k,R[1]+(B[1]-R[1])*k);M(N,U)&&Vt(t,N,U,.06,o,o+O,T&&L%2?T:C)}};if(s==="court-basketball"){let R=Pu;for(let B of[-1,1]){let C=B*(y*R.sidelineShare+R.fromSideline*m),T=C+B*R.tableHalfDepth*m,O=(G,k)=>M(l(G,C),l(k,C))&&M(l(G,T),l(k,T)),E=R.tableHalfLength*m;if(!O(-E,E))continue;let w=l(-E,C),L=l(E,C);Vt(t,w,L,R.tableHalfDepth*m,o,o+R.tableHeight-.04,Eu),Vt(t,w,L,R.tableHalfDepth*m+.04,o+R.tableHeight-.06,o+R.tableHeight,wu);for(let G of[-1,1]){let k=G*R.benchFrom*m,N=G*R.benchTo*m;if(!O(k,N))continue;Vt(t,l(k,C),l(N,C),R.benchHalfDepth,o,o+R.benchHeight,me);let U=C+B*(R.benchHalfDepth+.04);Vt(t,l(k,U),l(N,U),.03,o,o+R.benchBackHeight,me)}break}return}if(s==="court-tennis"){let R=h+6.4*m,B=y+3.66*m;for(let T of[-1,1])P([T*R,-B],[T*R,B],Su,null,1);let C=l(0,y+1.2*m);p(C)&&(Wn(t,C,.3,o,o+1.5,me),Wn(t,C,.36,o+1.5,o+1.62,rn));return}Qi(t,{at:l,lengthM:u,widthM:f},o,m,p,s==="pitch-football"&&!a);let S=y+3.2*m,g=h+4*m,I=3*m,A=15*m;P([-h+I,S],[h-I,S],fe,ze,Ye),P([-h+I,-S],[-A,-S],fe,ze,Ye),P([A,-S],[h-I,-S],fe,ze,Ye);for(let R of[-1,1])P([R*g,-y+I],[R*g,y-I],fe,ze,Ye);for(let R of i?[]:[-1,1]){let B=R*2.5*m,C=R*10.5*m,T=-(y+4.4*m),O=l(B,T),E=l(C,T);!M(O,E)||!M(l(B,T-.75*m),l(C,T-.75*m))||(Vt(t,O,E,.35,o,o+.45,me),Vt(t,l(B,T-.75*m),l(C,T-.75*m),.05,o,o+1.9,me),Vt(t,l(B,T-.2*m),l(C,T-.2*m),.62,o+1.9,o+1.98,fe))}}var $e=[.19,.4,.15],Bu=.012,Qe=2.4,Tu=1,Ou=.75,Cu=.15;function sn(t){if(t.points&&t.points.length>=3)return t.points;let{center:n,width:e,height:o,rotation:r}=t;if(!e||!o)return null;let a=(r??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),c=e/2,l=o/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:n.x+u*i-f*s,y:n.y+u*s+f*i}))}function ps(t,n,e,o,r,a,i=!1){let s=sn(n);if(s){if(i){let c=wn(o,r.boothTop),l=ln([...s]);Z(t,un(l,ku/_),[l.slice().reverse()],()=>e+.03,e,c,W(c,.8),z);return}if(!(!n.points&&a&&Fu(t,s,e,o,a))){if(!n.points&&a&&s.length===4){Lu(t,s,e,o,a);return}Z(t,s,void 0,()=>e+Qe,e,wn(o,r.boothTop),r.boothWall,z)}}}var Vo=1.1,ms=[.9,.9,.88],ku=.1,Ze=[.87,.87,.85],hs=.08;function xs(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}),o=0,r=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<r&&(r=u,o=c)}let a=[0,1,2,3].map(c=>t[(o+c)%4]),i=(c,l,u)=>({x:c.x+(l.x-c.x)*u,y:c.y+(l.y-c.y)*u});return{q:a,part:(c,l,u,f)=>{let m=i(a[0],a[1],c),h=i(a[0],a[1],l),y=i(a[3],a[2],c),d=i(a[3],a[2],l);return[i(m,y,u),i(h,d,u),i(h,d,f),i(m,y,f)]},depthM:Math.hypot(a[3].x-a[0].x,a[3].y-a[0].y)*_,widthM:Math.hypot(a[1].x-a[0].x,a[1].y-a[0].y)*_}}function Lu(t,n,e,o,r){let{q:a,part:i}=xs(n,r),s=o??[.35,.42,.55],c=lt(s,[.78,.78,.77],.62),l=lt(s,[.95,.95,.94],.45);dt(t,a,e+_n,e,c,W(c,.8)),dt(t,i(.05,.95,.72,.98),e+Vo-.05,e+_n,l,W(l,.8)),dt(t,i(.03,.97,.7,1),e+Vo,e+Vo-.05,ms,W(ms,.9))}function Fu(t,n,e,o,r){if(n.length!==4)return!1;let{q:a,part:i,depthM:s,widthM:c}=xs(n,r);if(s<1||c<1)return!1;let l=o??[.35,.42,.55],u=lt(l,[.78,.78,.77],.62),f=e+Qe,m=hs/c,h=hs/s;dt(t,a,e+_n,e,u,W(u,.8)),dt(t,i(0,1,1-h,1),f,e+_n,Ze,W(Ze,.9));for(let[x,b]of[[0,m],[1-m,1]])dt(t,i(x,b,0,1-h),f,e+_n,Ze,W(Ze,.9));dt(t,i(m,1-m,0,Math.min(.5,.06/s)),f,f-.3,l,W(l,.85));let y=Math.min(.4,.6/c),d=Math.min(.12,.3/s);return dt(t,i(.5-y,.5+y,.72-d,.72+d),e+Tu,e+_n,lt(l,[.95,.95,.94],.7),W(l,.75)),!0}function to(t){if(t.shape==="round"){let u=t.radius;return u?Ne(t.center.x,t.center.y,u,u,24):null}let{width:n,height:e,rotation:o,center:r}=t;if(!n||!e)return null;let a=(o??0)*Math.PI/180,i=Math.cos(a),s=Math.sin(a),c=n/2,l=e/2;return[[-c,-l],[c,-l],[c,l],[-c,l]].map(([u,f])=>({x:r.x+u*i-f*s,y:r.y+u*s+f*i}))}function bs(t,n,e,o,r,a=!0){let i=to(n);if(!i)return;let s=i.reduce((y,d)=>y+d.x,0)/i.length,c=i.reduce((y,d)=>y+d.y,0)/i.length,l=y=>i.map(d=>({x:s+(d.x-s)*y,y:c+(d.y-c)*y})),u=gn(r)?1:Du,f=a&&o?wn(o,r.tableTop):W(Gu,u),m=W(Nu,u),h=e+Ou;Z(t,i,void 0,()=>h,e+vu,f,W(f,.86),z),Z(t,l(.12),void 0,()=>h+.12,h,m,W(m,.8),z)}var Gu=[.93,.92,.89],Nu=[.78,.66,.42],Du=.62,vu=.25,de={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function Hu(t,n,e){let o=t.reduce((b,p)=>b+p.x,0)/4,r=t.reduce((b,p)=>b+p.y,0)/4,a=t[3].x-t[0].x,i=t[3].y-t[0].y,s=Math.hypot(a,i)||1;a/=s,i/=s,a*(n.x-o)+i*(n.y-r)<0&&(a=-a,i=-i);let c=-i,l=a,u=de.armM/_,f=de.widthM/_,m=s/2+de.insideM/_,h=e?-1:1,y=o+a*(m+(e?0:u)),d=r+i*(m+(e?0:u)),x=(b,p)=>({x:y+a*b*h+c*p,y:d+i*b*h+l*p});return[x(0,0),x(-u,u),x(-u-f,u),x(-f,0),x(-u-f,-u),x(-u,-u)]}function Uu(t,n,e,o,r){let a=[.94,.95,.96];Z(t,Hu(n,o,r),void 0,()=>e+de.high,e+de.low,a,a,z)}function Je(t,n){let e=ht(t);return e?{top:W(cn(e,.12),.95),wall:W(cn(e,.12),.85)}:{top:n.tierTop,wall:n.tierWall}}function gs(t,n,e,o,r,a,i,s,c=[]){let l=ut(n),u=_i(n);if(!n.role&&(!n.fill||n.fill==="none"||n.fill==="transparent")||!l){ae(t,n,e+o+Bu);return}let m=s?s.kind==="stage":n.role==="stage",h=s?s.kind==="screen":n.role==="screen",y=s?{kind:m?"stage":"solid",heightM:s.topY-s.baseY}:on(n),d=s?.baseY??e,x=s?.topY??e+o,b=null;if(m&&i){let O=1/0,E=-1/0,w=1/0,L=-1/0;for(let G of l)G.x<O&&(O=G.x),G.x>E&&(E=G.x),G.y<w&&(w=G.y),G.y>L&&(L=G.y);b={cx:(O+E)/2*_,cz:(w+L)/2*_,y:x,halfX:Math.max((E-O)/2*_,.5),halfZ:Math.max((L-w)/2*_,.5)},i.push(b)}let p=ht(n.fill),M=n.role==="wall"||n.role==="entrance"||n.role==="exit",P=M?Je(n.fill,r).top:m&&p?lt(r.stageTop,W(cn(p,.18),.9),.9):!n.role&&p?p:wn(p,m?r.stageTop:r.decorTop),g=M?Je(n.fill,r).wall:m?p?lt(r.stageWall,W(p,.58),.82):r.stageWall:h?ei(h?p:null):wn(ht(n.fill),r.decorWall),I=m&&gn(r)?Pn(!0):null,A=I?ys(P,I.stageTop):P,R=I?ys(g,I.stageWall):g;if(b&&(b.top=A),n.role==="wall"&&!s){je(t,l,d,x,c,A,R,a),ae(t,n,x+.012);return}if(h&&l.length===4&&x-d>.2){let O=ko(l,d,x);if(!O)return;let{quad:E,side:w,trim:L,inner:G,panel:k}=O,N=[.12,.15,.18];for(let[U,X]of[[0,w],[1-w,1]])dt(t,jt(E,U,X),x,d,N,N);dt(t,G,d+L,d,N,N),dt(t,G,x,x-L,N,N),dt(t,k,x-L,d+L,R,R),ae(t,n,x+.012);return}let B=p?W(cn(p,.15),.82):R,C=p?W(cn(p,.1),1.02):A;if(Ni(n.role)&&!s&&Di(t,n.role,l,d,x,B,C,a,n.heightM!==void 0))return;if((n.role==="sound"||s?.kind==="sound_desk")&&l.length===4&&x-d>.3){let O=zt(l),E=Math.hypot(O[1].x-O[0].x,O[1].y-O[0].y)*_,w=Math.min(.12,.09/Math.max(E,.001)),L=[.18,.21,.24],G=x-Math.min(.12,(x-d)*.15);for(let[k,N]of[[0,w],[1-w,1]])dt(t,jt(O,k,N),G,d,L,L);dt(t,O,x,G,A,L);return}if(n.role==="rail"&&l.length===4&&x>d){let O=zt(l),E=Math.hypot(O[1].x-O[0].x,O[1].y-O[0].y)*_,w=Math.max(1,Math.min(128,Math.ceil(E/1.4))),L=Math.min(.08,.055/Math.max(.055,E)),G=[.58,.64,.66];for(let k=0;k<=w;k++){let N=k/w,U=Math.min(1-L,Math.max(0,N-L/2));dt(t,jt(O,U,U+L),x,d,G,W(G,.8))}for(let k of[.52,1]){let N=d+(x-d)*k;dt(t,O,N,Math.max(d,N-.055),G,W(G,.8))}return}if(n.role==="goal"&&l.length===4){ns(t,zt(l),a,d,x),t.setMaterial(0);return}if(y.kind==="portal"&&l.length===4){let O=Un(l,d,x);if(!O)return;let{quad:E,side:w,face:L,openingTop:G}=O;for(let[k,N,U]of[[0,L,1],[L,1-L,.67],[1-L,1,1]]){let X=re(E,k,N),F=W(A,U),v=W(R,U);for(let[j,Y]of[[0,w],[1-w,1]])dt(t,jt(X,j,Y),G,d,F,v);dt(t,X,x,G,F,v)}(n.role==="entrance"||n.role==="exit")&&Uu(t,E,d,a,n.role==="exit");return}if(y.kind==="suite"&&l.length===4){let O=l.map((L,G)=>{let k=l[(G+1)%4],N=(L.x+k.x)/2,U=(L.y+k.y)/2;return Math.hypot(N-a.x,U-a.y)}),E=O.indexOf(Math.min(...O)),w=[0,1,2,3].map(L=>l[(E+L)%4]);dt(t,jt(w,0,.08),x,d,A,R),dt(t,jt(w,.92,1),x,d,A,R),dt(t,re(w,.88,1),x,d,A,R),dt(t,w,x,Math.max(d,x-.18),A,R);return}if(m&&!n.stageKind?.startsWith("pitch-")&&x-d>.12){let O=x-Math.min(.06,(x-d)*.15);dt(t,l,O,d,A,R,u),dt(t,l,x,O,A,lt(A,R,.2),u)}else dt(t,l,x,d,A,R,u);if((n.stageKind==="pitch-football"||n.stageKind==="pitch-rugby")&&l.length===4){t.setMaterial(4);let O=zt(l),E=lt(p??$e,$e,p?.45:0);for(let w=0;w<12;w++){let L=jt(O,w/12,(w+1)/12),G=W(E,w%2?1.09:.91),k=L.map(N=>[N.x*_,x+.006,N.y*_]);t.tri(k[0],k[1],k[2],[0,1,0],G),t.tri(k[0],k[2],k[3],[0,1,0],G)}}n.stageKind&&n.stageKind!=="pitch-football"&&us(t,l,n.stageKind,x,p,n),m&&qt(n.stageKind)&&ls(t,n,x),t.setMaterial(h?1:0),ae(t,n,x+.012)}function no(t){let{x:n,y:e,width:o,height:r}=t;if(!o||!r)return null;let a=n+o/2,i=e+r/2,s=(t.rotation??0)*Math.PI/180,c=Math.cos(s),l=Math.sin(s),u=o/2,f=r/2;return[[-u,-f],[u,-f],[u,f],[-u,f]].map(([m,h])=>({x:a+m*c-h*l,y:i+m*l+h*c}))}function ju(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 o=e[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return ht(o);let a=n.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!a)return null;let i=[];for(let s of a[1].matchAll(/stop-color="([^"]+)"/gi)){let c=ht(s[1].trim());c&&i.push(c)}return i.length?i.reduce((s,c,l)=>lt(s,c,1/(l+1)),i[0]):null}function Ms(t,n,e,o){if(n.layer==="foreground")return;let r=no(n);if(!r)return;let a=e+Cu,i=wn(ju(n.href),o.decorTop),s=Math.max(0,Math.min(1,n.opacity??1));s<1&&(i=lt(o.ground,i,s)),Z(t,r,void 0,()=>a,e,i,lt(i,o.decorWall,.5),z)}function Rs(t,n,e,o,r){if(!n.points||n.points.length<3)return;let a=ni(o,r.gaTop);t.setMaterial(Xu),Z(t,n.points,n.holes,()=>e+ye,e,a,r.gaWall,z),t.setMaterial(0),Ku(t,n.points,e+ye)}var Xu=13,ye=.15,qe=[.72,.74,.76],Wo=1.1,ds=.12,Ko=.05,Vu=.06,Wu=2.4;function Ku(t,n,e){let o=ln([...n]),r=Jt(o,ds/_),a=Jt(o,(ds+Ko)/_);if(r.length<3||a.length<3)return;for(let s of[e+Wo,e+Wo*.5])Z(t,r,[a.slice().reverse()],()=>s,s-Ko,qe,W(qe,.85),z);let i=Vu/2/_;for(let s=0;s<r.length;s++){let c=r[s],l=r[(s+1)%r.length],u=Math.hypot(l.x-c.x,l.y-c.y)*_,f=Math.max(1,Math.round(u/Wu));for(let m=0;m<f;m++){let h=m/f,y=c.x+(l.x-c.x)*h,d=c.y+(l.y-c.y)*h,x=[{x:y-i,y:d-i},{x:y+i,y:d-i},{x:y+i,y:d+i},{x:y-i,y:d+i}];Z(t,x,void 0,()=>e+Wo-Ko,e,qe,W(qe,.8),z)}}}function ys(t,n){return Oe(t)<n?An(t,n):t}function _s(t){let n=1/0,e=1/0,o=-1/0,r=-1/0;for(let a of t)n=Math.min(n,a.x),o=Math.max(o,a.x),e=Math.min(e,a.y),r=Math.max(r,a.y);return{x:(n+o)/2,y:(e+r)/2}}function zu(t,n){let e=_s(t),o=_s(n);return kt(n,e.x,e.y)||kt(t,o.x,o.y)}function eo(t){let n=new Set;if(t.length<2)return n;let e=[...t].sort((r,a)=>r.baseHeightM-a.baseHeightM||r.index-a.index),o=[];for(let r of e){let a=[];for(let i of r.objects){if(i.type!=="shape"||i.role!=="stage")continue;let s=ut(i);!s||s.length<3||(o.some(c=>zu(s,c))?n.add(i):a.push(s))}o.push(...a)}return n}var Yu=1.5,Zu=30,qu=4,$u=3.6,Ju=6,zo=15,Qu=3,tf=1;function nf(t){return Math.max($u,Math.min(Ju,2.4+.15*t))}var pe=Math.PI*2;function ef(t,n){let e=0,o=0;for(let f of t)e+=f.x,o+=f.y;let r=Math.atan2(o/t.length-n.y,e/t.length-n.x),a=t.map(f=>{let m=Math.atan2(f.y-n.y,f.x-n.x)-r;for(;m>Math.PI;)m-=pe;for(;m<-Math.PI;)m+=pe;return m+r}),i=a.map((f,m)=>m).sort((f,m)=>a[f]-a[m]),s=a[i[0]],c=a[i[i.length-1]];if(c-s>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,y=(f+1)%t.length,d=Math.abs(a[h]-a[f])<=Math.abs(a[y]-a[f])?h:y,x=t[d];return l(m)<=l(x)?[m,x]:[x,m]};return{start:s,end:c,startEdge:u(i[0]),endEdge:u(i[i.length-1])}}function Ss(t){return t.type==="shape"&&t.role==="wall"&&t.heightM===void 0}function Yo(t,n,e=()=>!0){let o=[];for(let c of t){if(!Ss(c)||!e(c))continue;let l=ut(c);if(!l||l.length<3)continue;let u=ef(l,n);if(!u)return[];o.push(u)}if(o.length<2)return[];let r=t.flatMap(c=>{if(c.type!=="shape"||c.role!=="entrance"&&c.role!=="exit")return[];let l=ut(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}]}),a=c=>(c%pe+pe)%pe;o.sort((c,l)=>a(c.start)-a(l.start));let i=c=>Math.hypot(c.x-n.x,c.y-n.y),s=[];for(let c=0;c<o.length;c++){let l=o[c],u=o[(c+1)%o.length],f=a(u.start-l.end);if(f<=0||f>=Math.PI/2)continue;let m=g=>a(g-l.end)<f;if(o.some(g=>g!==l&&g!==u&&(m(g.start)||m(g.end)||a(l.end-g.start)<g.end-g.start)))continue;let[y,d]=l.endEdge,[x,b]=u.startEdge,p={x:(y.x+d.x)/2,y:(y.y+d.y)/2},M={x:(x.x+b.x)/2,y:(x.y+b.y)/2},P=Math.hypot(M.x-p.x,M.y-p.y)*_;if(P<Yu||P>Zu||Math.abs(i(p)-i(M))*_>qu+.2*P)continue;let S={x:(p.x+M.x)/2,y:(p.y+M.y)/2};r.some(g=>m(Math.atan2(g.y-n.y,g.x-n.x))&&Math.abs(i(g)-i(S))*_<=Qu)||s.push({quad:[y,d,b,x],mid:S,widthM:P,openingM:nf(P)})}return s}function Is(t,n){let e=[];for(let a of n)if(a.text?.trim())for(let i of t){let s=Math.hypot(a.position.x-i.mid.x,a.position.y-i.mid.y)*_;s<=zo&&e.push({text:a,gate:i,d:s})}e.sort((a,i)=>a.d-i.d);let o=new Map,r=new Set;for(let{text:a,gate:i}of e)o.has(a.id)||r.has(i)||(o.set(a.id,i),r.add(i));return o}function As(t,n,e,o,r,a,i,s=()=>!0){let c=Yo(n,Hn(e),s);if(!c.length)return;let l=n.find(f=>Ss(f)&&s(f)),u=Je(l?.fill,i);t.setMaterial(Ue);for(let f of c)r-f.openingM<tf||je(t,f.quad,o+f.openingM,o+r,[],u.top,u.wall,a,r);t.setMaterial(0)}var of=6,rf=2.2,oo=.1,sf=/^(gate|entrance|entry|exit|way in|way out|door)s?$/i,af=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),cf=.3,lf=1.8,uf=.9,ff=.55,mf=1,Ps=4e3,hf=6,Es="#d8a425",df="#e8c15a",Zo="#1c1608";function ws(t){let n=yf(t);if(!n)return null;let e=wr(t).find(o=>o.icon===n.icon);return{...n,name:e?.titleFallback??n.icon}}function yf(t){let n=t.accessibility;if(n?.length)return{icon:n.includes("wheelchair")?"wheelchair":n[0],color:Ie(n)};let e=t.commercial;return e?.obstructedView?{icon:"obstructedView",color:Es,ink:Zo}:e?.restrictedView?{icon:"restrictedView",color:Es,ink:Zo}:e?.premium?{icon:"premium",color:df,ink:Zo}:null}function pf(t,n){if(!t)return;let e,o=0;for(let[a,i]of t)i>o&&(o=i,e=a);let r=n.categories?.find(a=>a.key===e)?.color;return r&&/^#[0-9a-f]{6}$/i.test(r)?r:void 0}var xf=6e3,bf=.25,Bs=[-90,90,-135,135,-45,45];function gf(t,n,e,o){let r=t.flatMap(({id:i,a:s,members:c})=>{let l=(s.minX+s.maxX)/2,u=(s.minY+s.maxY)/2,f=.5*Math.hypot(s.maxX-s.minX,s.maxY-s.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*bf?[{id:i,cx:l,cy:u,half:f,members:c}]:[]}).sort((i,s)=>i.half-s.half),a=new Map;return r.forEach(({id:i,cx:s,cy:c,members:l},u)=>{let f=o.x-s,m=o.y-c,d=(Math.hypot(f,m)>1e-6?Math.atan2(m,f):0)+Bs[u%Bs.length]*Math.PI/180,x=Math.cos(d),b=Math.sin(d),p=-1,M=-1/0;for(let P of l){let S=(n[P].x-s)*x+(n[P].y-c)*b;S>M&&(M=S,p=P)}a.set(i,[n[p].x*_,e.seatDeckY(p),n[p].y*_])}),a}function Os(t){let{doc:n,units:e,seats:o,surfaces:r,focal:a}=t,i=n.zones??[],s=[];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<o.length;m++){let h=o[m],y=r.seatOwner[m],d=h.zoneId??(y?c.get(y):void 0);if(!d)continue;let x=l.get(d);x||(x={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(d,x));let b=u.get(d);b||u.set(d,b=[]),b.push(m),x.n++,h.x<x.minX&&(x.minX=h.x),h.y<x.minY&&(x.minY=h.y),h.x>x.maxX&&(x.maxX=h.x),h.y>x.maxY&&(x.maxY=h.y),x.sumY+=r.seatDeckY(m)}let f=gf(i.flatMap(m=>{let h=l.get(m.id);return h?[{id:m.id,a:h,members:u.get(m.id)??[]}]:[]}),o,r,a);for(let m of i){let h=l.get(m.id),y=[];for(let[d,x]of c)x===m.id&&y.push(d);if(!h||h.n===0){s.push({id:m.id,label:m.label,color:ht(m.color),sectionIds:y,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(m.focalPoint??a).x*_,1.5,(m.focalPoint??a).y*_]});continue}s.push({id:m.id,label:m.label,color:ht(m.color),sectionIds:y,seatCount:h.n,...f.has(m.id)?{labelAt:f.get(m.id)}:{},center:[(h.minX+h.maxX)/2*_,h.sumY/h.n,(h.minY+h.maxY)/2*_],radius:.5*Math.hypot((h.maxX-h.minX)*_,(h.maxY-h.minY)*_)||1,focalWorld:[(m.focalPoint??a).x*_,1.5,(m.focalPoint??a).y*_]})}}return s}function Cs(t){let{doc:n,units:e,seats:o,surfaces:r,seatData:a,hintedSeatFloor:i,zones:s,focal:c}=t,l=[],u=[],f=[],m=new Map;for(let y of e)for(let d of y.objects){if(d.type!=="section"||!d.zone)continue;let x=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!x)continue;let b=n.floors?.[y.index]?.name?.trim().toLocaleLowerCase();if(e.length>1&&b===x)continue;let p=m.get(d.zone);p||m.set(d.zone,p=new Set),p.add(x)}for(let y of s)y.seatCount!==0&&(m.get(y.id)?.has(y.label.trim().toLocaleLowerCase())||l.push({id:`zone:${y.id}`,kind:"zone",text:y.label,anchor:[(y.labelAt??y.center)[0],(y.labelAt??y.center)[1]+of,(y.labelAt??y.center)[2]],color:n.zones?.find(d=>d.id===y.id)?.color}));{let y=new Map,d=new Map,x=new Map,b=new Map;for(let p=0;p<o.length;p++){let M=r.seatOwner[p];if(!M)continue;let P=y.get(M);P||(P={n:0,x:0,y:0,deck:0},y.set(M,P)),P.n++,P.x+=o[p].x,P.y+=o[p].y,P.deck+=r.seatDeckY(p);let S=o[p].categoryKey;if(S){let I=d.get(M);I||(I=new Map,d.set(M,I)),I.set(S,(I.get(S)??0)+1)}if(o[p].accessibility?.includes("wheelchair")){let I=x.get(M);I?I.push(p):x.set(M,[p])}let g=b.get(M);g||(g={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},b.set(M,g)),g.minDeck=Math.min(g.minDeck,r.seatDeckY(p)),g.maxDeck=Math.max(g.maxDeck,r.seatDeckY(p)),o[p].x<g.minX&&(g.minX=o[p].x),o[p].x>g.maxX&&(g.maxX=o[p].x),o[p].y<g.minY&&(g.minY=o[p].y),o[p].y>g.maxY&&(g.maxY=o[p].y)}for(let p of e)for(let M of p.objects){if(M.type!=="section"||Bi(M))continue;let P=y.get(M.id);if(!P||P.n===0)continue;let S=b.get(M.id),g=[P.x/P.n*_,P.deck/P.n,P.y/P.n*_],I=M.displayLabel||M.label||M.id;u.push({id:M.id,floorIndex:p.index,label:I,seatCount:P.n,center:g,radius:Math.max(1,Math.hypot(S.maxX-S.minX,S.maxY-S.minY)*.5*_),box:{min:[S.minX*_-.4,S.minDeck,S.minY*_-.4],max:[S.maxX*_+.4,S.maxDeck+1,S.maxY*_+.4]},focalWorld:[p.focal.x*_,p.baseHeightM+1.5,p.focal.y*_]});let A=n.floors?.[p.index]?.name?.trim().toLocaleLowerCase();if(!(e.length>1&&A===I.trim().toLocaleLowerCase())){let R=pf(d.get(M.id),n),B=x.get(M.id);l.push({id:`section:${M.id}`,kind:"section",text:I,anchor:[g[0],g[1]+rf,g[2]],floorIndex:p.index,...R?{tint:R}:{},...B?{wheelchairSeats:B}:{}})}}}{for(let g of e)for(let I of g.objects){if(I.type!=="gaArea")continue;let A=kn(I.points);if(!A)continue;let R=I.labelPresentation?.visible===!1?"":I.displayLabel||I.label||I.id,B=I.capacity>0?[R,I.capacity.toLocaleString()].filter(Boolean).join(" \xB7 "):R;B&&l.push({id:`ga:${I.id}`,kind:"ga",text:B,areaName:R,anchor:[A.x*_,g.baseHeightM+lf,A.y*_],floorIndex:g.index})}let y=new Map,d=new Map;for(let g of e)for(let I of g.objects)if(I.type==="section"&&y.set(I.id,I.displayLabel||I.label||I.id),I.type==="row"){let A=I.displayLabel?.trim()||I.segmentedRow?.displayLabel?.trim();A&&d.set(I.id,A)}let x=new Map;for(let g=0;g<o.length;g++){let I=o[g],A=Math.hypot(I.x-c.x,I.y-c.y),R=x.get(I.rowId);(!R||A>R.far)&&x.set(I.rowId,{seat:I,index:g,far:A})}for(let[g,I]of x){let A=r.seatOwner[I.index]??I.seat.sectionId,R=Ts(I.seat.label,g,y.get(A??""),d.get(g));R&&l.push({id:`row:${g}`,kind:"row",text:R,anchor:[I.seat.x*_,r.seatDeckY(I.index)+uf,I.seat.y*_],floorIndex:i[I.index]})}let b=new Map;for(let g=0;g<o.length;g++){let I=o[g],A=b.get(I.rowId);A||(A={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:Ts(I.label,I.rowId,y.get(r.seatOwner[g]??I.sectionId??""),d.get(I.rowId)),sectionId:r.seatOwner[g]??I.sectionId},b.set(I.rowId,A));let R=g*3,B=a.iPosition[R],C=a.iPosition[R+1],T=a.iPosition[R+2];A.n++,A.x+=B,A.y+=C,A.z+=T,A.minX=Math.min(A.minX,B),A.maxX=Math.max(A.maxX,B),A.minZ=Math.min(A.minZ,T),A.maxZ=Math.max(A.maxZ,T)}for(let[g,I]of b)f.push({id:g,label:I.label,sectionId:I.sectionId,seatCount:I.n,center:[I.x/I.n,I.y/I.n,I.z/I.n],radius:Math.max(.8,Math.hypot(I.maxX-I.minX,I.maxZ-I.minZ)*.5)});let p=0,M=(g,I)=>{p++,l.push({id:`access:${o[g].id}`,kind:"access",text:I.name,icon:I.icon,color:I.color,...I.ink?{ink:I.ink}:{},seatWidthM:a.iChairWidth[g]*2,anchor:[o[g].x*_,r.seatDeckY(g)+mf,o[g].y*_],floorIndex:i[g],rowId:o[g].rowId})},P=null,S=()=>{if(P){let g=ws(o[P.seats[0]]),I=P.seats.length,A=Math.max(1,Math.round(I/hf));for(let R=0;R<A&&p<Ps;R++)M(P.seats[Math.min(I-1,Math.floor((R+.5)*I/A))],g)}P=null};for(let g=0;g<o.length&&p<Ps;g++){let I=ws(o[g]);if(I&&o[g].accessibility?.length){S(),M(g,I);continue}if(!I){S();continue}P&&P.rowId===o[g].rowId&&P.icon===I.icon?P.seats.push(g):(S(),P={rowId:o[g].rowId,icon:I.icon,seats:[g]})}if(S(),o.length<=xf)for(let g=0;g<o.length;g++){let I=o[g],A=Mf(I.displayLabel||I.label);A&&l.push({id:`seat:${I.id}`,kind:"seat",seatWidthM:a.iChairWidth[g]*2,text:A,anchor:[I.x*_,r.seatDeckY(g)+ff,I.y*_],floorIndex:i[g],rowId:I.rowId})}}let h=eo(e);for(let y of e){let d=Rn(y,e.length===1?o:o.filter((p,M)=>i[M]===y.index)),x=d?Is(Yo(y.objects,Hn(d)),y.objects.filter(p=>p.type==="text")):new Map,b=[...x.values()];for(let p of y.objects){let M=p.type==="text"?x.get(p.id):void 0;if(p.type==="shape"&&(p.role==="entrance"||p.role==="exit")&&sf.test(p.label?.trim()??"")){let P=ut(p),S=P?kn(P):null;if(S&&b.some(g=>Math.hypot(S.x-g.mid.x,S.y-g.mid.y)*_<=zo+g.widthM))continue}if(M&&p.type==="text")l.push({id:`text:${p.id}`,kind:"gate",text:p.text,icon:"entrance",anchor:[M.mid.x*_,y.baseHeightM+M.openingM+oo,M.mid.y*_],color:p.color,floorIndex:y.index});else if(p.type==="shape"&&p.role&&af.has(p.role)){if(h.has(p))continue;let P=ut(p),S=P?kn(P):null;if(!S||!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:[S.x*_,y.baseHeightM+on(p).heightM+oo,S.y*_],color:p.fill,floorIndex:y.index})}else if(p.type==="text"){let P=p.semanticKind==="icon"?mo(p.iconKey)?.key:void 0,S=p.text||(P?mo(P).label:"");if(!S)continue;l.push({id:`text:${p.id}`,kind:"annotation",text:S,...P?{venueIcon:P}:{},anchor:P?[(p.position.x+p.fontSize/2)*_,y.baseHeightM+oo,(p.position.y+p.fontSize/2)*_]:[p.position.x*_,y.baseHeightM+oo,p.position.y*_],color:p.color,rotation:p.rotation,floorIndex:y.index})}else if(p.type==="booth"){if(p.labelPresentation?.visible===!1)continue;let P=sn(p);if(!P)continue;let S=kn(P);if(!S)continue;l.push({id:`booth:${p.id}`,kind:"booth",text:p.displayLabel||p.label||p.id,anchor:[S.x*_,y.baseHeightM+Qe+cf,S.y*_],floorIndex:y.index})}}}return{labels:l,sections:u,rows:f}}function ks(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 Mf(t){let n=t.lastIndexOf("-");return n>=0&&n<t.length-1?t.slice(n+1):t}function Ts(t,n,e,o){if(o?.trim())return o.trim();let r=t?t.lastIndexOf("-"):-1,a=r>0?t.slice(0,r):n;return a&&kr(a,e)}var xe=3,On=.38,be=.24;function Rf(t){if(t.length<3)return null;let n=t[0],e=t[Math.floor(t.length/2)],o=t[t.length-1],r=(e.x-n.x)*_,a=(e.y-n.y)*_,i=(o.x-n.x)*_,s=(o.y-n.y)*_,c=2*(r*s-a*i);if(Math.abs(c)<1e-7)return null;let l=r*r+a*a,u=i*i+s*s,f=(l*s-u*a)/c+n.x*_,m=(r*u-i*l)/c+n.y*_,h=Math.hypot(n.x*_-f,n.y*_-m);return h<1||h>200||!Number.isFinite(h)||t.some(y=>Math.abs(Math.hypot(y.x*_-f,y.y*_-m)-h)>.03)?null:{x:f,z:m,radius:h}}function Ls(t){let n=[],e=new Map,o=(c,l)=>`${Math.floor(c/xe)},${Math.floor(l/xe)}`;for(let c of t)for(let l of c.rows){for(let f of l.pts){let m=f.x*_,h=f.y*_,y=o(m,h),d=e.get(y)??[];d.push({x:m,z:h,y:l.y,floor:c.floorIndex}),e.set(y,d)}if(l.patch||l.pts.length<2)continue;let u=Rf(l.pts);for(let f of[0,l.pts.length-1]){let m=l.pts[f],h=l.pts[f===0?1:f-1],y=m.x-h.x,d=m.y-h.y,x=Math.hypot(y,d);x<1e-6||n.push({sectionId:c.sectionId,floorIndex:c.floorIndex,curve:u,row:l,point:m,x:m.x*_,z:m.y*_,dx:y/x,dz:d/x})}}let r=new Map;n.forEach((c,l)=>{let u=o(c.x,c.z),f=r.get(u)??[];f.push(l),r.set(u,f)});let a=(c,l)=>{let u=Math.floor(c/xe),f=Math.floor(l/xe);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 a(c.x,c.z))for(let y of r.get(h)??[]){let d=n[y];if(c.sectionId===d.sectionId&&c.row.blockId===d.row.blockId||c.floorIndex!==d.floorIndex||Math.abs(c.row.y-d.row.y)>.05)continue;let x=d.x-c.x,b=d.z-c.z,p=Math.hypot(x,b);if(p<On*2+.45||p>xe)continue;let M=c.curve&&d.curve&&Math.hypot(c.curve.x-d.curve.x,c.curve.z-d.curve.z)<=.05&&Math.abs(c.curve.radius-d.curve.radius)<=.05,P=Math.min((x*c.dx+b*c.dz)/p,(-x*d.dx-b*d.dz)/p);(M?P<.8:P<.98)||!M&&(Math.abs(x*c.dz-b*c.dx)>.15||Math.abs(x*d.dz-b*d.dx)>.15)||(p<f-.02?(u=y,f=p,m=!1):Math.abs(p-f)<=.02&&(m=!0))}u>=0&&!m&&i.set(l,u)});let s=[];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,y=(f.z-u.z)/m,d=!1;for(let b of a((u.x+f.x)/2,(u.z+f.z)/2))for(let p of e.get(b)??[]){if(p.floor!==u.floorIndex||Math.abs(p.y-u.row.y)>.75)continue;let M=(p.x-u.x)*h+(p.z-u.z)*y,P=Math.abs((p.x-u.x)*y-(p.z-u.z)*h);M>.01&&M<m-.01&&P<be+On&&(d=!0)}if(d)continue;let x=(b,p)=>({x:(u.x+h*b-y*p)/_,y:(u.z+y*b+h*p)/_});s.push({sections:[u.sectionId,f.sectionId],blocks:[u.row.blockId,f.row.blockId],floorIndex:u.floorIndex,ends:[u.point,f.point],clearWidthM:m-2*On,heightM:(u.row.y+f.row.y)/2,outline:[x(On,-be),x(m-On,-be),x(m-On,be),x(On,be)]})}return s}var qo={key:[1,1,1],ambient:[1,1,1]},rp=.5,_f=[{id:"daylight",label:"Daylight",description:"Open air by day: pale concrete under a warm sun and a blue sky.",background:"#dce3e8",materials:{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87},light:{key:[1.05,1,.93],ambient:[.95,.99,1.06]},indoor:!1},{id:"floodlit",label:"Floodlit night",description:"A night match: dark sky, hard cool-white floodlights.",background:"#0c1420",materials:{deck:"#66727c",fascia:"#3a4a58",shell:"#4c6072",roughness:.84},light:{key:[1.08,1.08,1.12],ambient:[.8,.88,1.1]},indoor:!1},{id:"evening",label:"Evening",description:"A quiet dark hall: slate structure in a cool, even light.",background:"#17232e",materials:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87},light:{key:[1,.99,.96],ambient:[.94,.98,1.06]},indoor:!1},{id:"arena-show",label:"Arena show",description:"House lights down for a show: deep blue room, warm light on the floor.",background:"#10121c",materials:{deck:"#626a7a",fascia:"#383f52",shell:"#484f66",roughness:.82},light:{key:[1.08,.98,.88],ambient:[.8,.84,1.16]},indoor:!0},{id:"theatre",label:"Theatre house lights",description:"A warm auditorium before curtain-up: amber light, dark warm room.",background:"#1c1512",materials:{deck:"#74685c",fascia:"#4c4038",shell:"#5c4e44",roughness:.9},light:{key:[1.14,.98,.78],ambient:[1.04,.94,.84]},indoor:!0},{id:"concert-hall",label:"Concert hall",description:"A bright hall in pale wood and cream, softly warm.",background:"#e9e2d6",materials:{deck:"#d2c8b8",fascia:"#bcb0a0",shell:"#c8beae",roughness:.8},light:{key:[1.06,1,.9],ambient:[1.02,1,.95]},indoor:!0}],Sf=new Map(_f.map(t=>[t.id,t])),Fs="plain",Gs=3e3;function Ns(t,n){return t.openField?n?"daylight":"floodlit":t.openAir?n?"daylight":t.court?"floodlit":"evening":t.court||t.inTheRound||t.stage&&t.seatCount>Gs?n?"daylight":"arena-show":t.stage?n?"concert-hall":"theatre":n?"daylight":"evening"}function Ds(t){return t.openField||t.openAir?!1:t.indoorCourt?!0:t.stage&&!t.inTheRound&&!t.court&&t.standing<t.seatCount&&t.seatCount<=Gs}function $o(t){return t&&Sf.get(t)||null}var If=.15,Af=.9,Pf=1.76;function Ef(t,n,e){let o=t??wf,r=(a,i,s)=>[Math.min(1,a[0]*i*s[0]),Math.min(1,a[1]*i*s[1]),Math.min(1,a[2]*i*s[2])];return ge(t)?{indoor:e,ceiling:r(o,1.02,n.light.ambient),wall:r(o,.9,n.light.ambient),lamp:r([.1,.1,.1],1,n.light.key)}:{indoor:e,ceiling:r(o,.7,n.light.ambient),wall:r(o,1.55,n.light.ambient),lamp:r([.92,.86,.74],1,n.light.key)}}var wf=[.075,.09,.115];function vs(t){return ge(t)?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function ge(t){return!!t&&t[0]*.2126+t[1]*.7152+t[2]*.0722>.55}function Bf(){return{background:{top:[...go.top],bottom:[...go.bottom]},sky:vs(null),structure:bo,seatStates:{...Wr},seatScale:1,materials:{seat:null,shell:null,roughness:.78},light:{key:[...qo.key],ambient:[...qo.ambient]},house:null}}function Tf(t){return ge(t)?{deck:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function Hs(t,n){let e=t?.venue3d?.look;if(e===Fs)return{look:null,chosen:!0};let o=$o(e);return o?{look:o,chosen:!0}:n?{look:$o(Ns(n,ge(ht(t?.background)))),chosen:!1}:{look:null,chosen:!1}}function Of(t,n){let{look:e,chosen:o}=Hs(t,n);return ht(t?.background)??(o?ht(e?.background):null)}function Us(t,n){let e=Bf();t??={};let{look:o,chosen:r}=Hs(t,n);o&&(e.light={key:[...o.light.key],ambient:[...o.light.ambient]});let a=Of(t,n);if(o&&(e.house=Ef(a,o,r?o.indoor:!!n&&Ds(n))),a){e.background={top:W(a,Af),bottom:W(a,Pf)},e.sky=vs(a);let u={};for(let[m,h]of Object.entries(bo))u[m]=lt(h,a,If);a[0]*.2126+a[1]*.7152+a[2]*.0722>.55&&(u.ground=W(a,.86)),e.structure=u}let i=ht(t.selectionColor)??ht(t.accent);i&&(e.seatStates={...e.seatStates,selected:i});let s=t.seatScale;typeof s=="number"&&Number.isFinite(s)&&(e.seatScale=Fr(s));let c=Object.fromEntries(Object.entries(t.venue3d??{}).filter(([u,f])=>f!=null&&u!=="look")),l={...Tf(a),...o?.materials,...c};if(l){let u=ht(l.deck),f=ht(l.fascia);u&&(e.structure={...e.structure,tierTop:u,gaTop:u}),f&&(e.structure={...e.structure,tierWall:f,gaWall:f}),e.materials.seat=ht(l.seat),e.materials.shell=ht(l.shell),typeof l.roughness=="number"&&Number.isFinite(l.roughness)&&(e.materials.roughness=Math.min(1,Math.max(0,l.roughness)))}return Cf(e,ge(a)),e}function Cf(t,n){let e=Pn(n);t.seatStates={...t.seatStates,held:Ce(e.unavailable),sold:Ce(e.unavailable),dimmed:Ce(e.dimmed)};let o=(a,i)=>An(a,i,Math.min($n(a),ke)),r=t.structure;t.structure={...r,ground:o(r.ground,e.ground),tierTop:o(r.tierTop,e.deck),tierWall:o(r.tierWall,e.fascia)},t.materials.shell&&(t.materials.shell=o(t.materials.shell,e.shell))}function js(t,n){let e=[];for(let o of n)e.push(...t.seatStates[o]);return e}var Kn=12,kf=1500,Lf=240,Ff=.25;function zn(t,n){if(!n.length)return!1;let e=0,o=0,r=0,a=new Set;for(let s of n)e+=s.x,o+=s.y,r+=Math.hypot(s.x-t.x,s.y-t.y),a.add(Math.floor(Math.atan2(s.y-t.y,s.x-t.x)*180/Math.PI/10));let i=Math.hypot(t.x-e/n.length,t.y-o/n.length);return a.size*10>Lf&&i<Ff*(r/n.length)}function Xs(t,n,e,o){let r=1/0,a=0;for(let i=0;i<t.length;i++){let s=t[i],c=t[(i+1)%t.length],l=c.x-s.x,u=c.y-s.y,f=e*u-o*l;if(Math.abs(f)<1e-12)continue;let m=((s.x-n.x)*u-(s.y-n.y)*l)/f,h=((s.x-n.x)*o-(s.y-n.y)*e)/f;m>0&&h>=0&&h<1&&(a+=1,r=Math.min(r,m))}return a%2===1?r:0}function Vs(t,n){let e=t.stageKind??"";if(qt(e)||e==="round"||!n.length)return null;let o=ut(t);if(!o||o.length<3)return null;let r={x:o.reduce((g,I)=>g+I.x,0)/o.length,y:o.reduce((g,I)=>g+I.y,0)/o.length},a=0,i=0;for(let g of n)a+=g.x,i+=g.y;let s=r.x-a/n.length,c=r.y-i/n.length,l=Math.hypot(s,c);if(l<1e-6||zn(r,n))return null;let u=s/l,f=c/l,m=-f,h=u,y=-1/0,d=1/0,x=1/0,b=-1/0;for(let g of o){let I=(g.x-r.x)*u+(g.y-r.y)*f,A=(g.x-r.x)*m+(g.y-r.y)*h;y=Math.max(y,I),d=Math.min(d,I),x=Math.min(x,A),b=Math.max(b,A)}let p=(b-x)*_,M=(y-d)*_;if(p<3||M<1.5||p*M>kf)return null;let P=(g,I)=>({x:r.x+u*g+m*I,y:r.y+f*g+h*I});return{poly:o,centre:r,ux:u,uy:f,vx:m,vy:h,back:y,front:d,left:x,right:b,widthM:p,depthM:M,at:P,box:(g,I,A,R)=>[P(g,A),P(g,R),P(I,R),P(I,A)]}}function zs(t){return t===Er}var Gf={heightShare:.6,heightMin:4.6,heightMax:10.5,heightFloor:2.6,ceilingClear:.5,pierShare:.075,pierMin:.45,pierMax:1.2,headerShare:.17,headerMin:.7,headerMax:1.6,riseShare:.1,riseMaxShare:.2,moulding:.11,cornice:.14,plinth:.4,fold:.34,foldsMin:10,foldsMax:56,swag:2.2,swagsMin:3,swagsMax:9,dropShare:.11,dropMin:.45,dropMax:1.1,fringe:.1,board:.28,boardsMax:96,boardEdge:.04,boardLift:.02,curtainClear:.12,fringeClear:.18,valanceClear:.24,valanceFringeClear:.3,archClear:.36,mouldingClear:.44},Nf=.18,Df=.2,vf=.02,Hf=2.4,ro=[.2,.165,.145],Ws=[.12,.1,.1],io=[.5,.055,.075],so=[.15,.012,.028],Uf=[.4,.04,.06],jf=[.13,.01,.024],nn=[.8,.6,.24],en=[.46,.33,.12],ao=[.36,.295,.225],Yn=[.2,.165,.13],Jo=[1,.62,.34],Xf=[.37,.25,.15],Vf=[1,.87,.64];function Wf(t){let n=Math.sin(t*12.9898+4.1414)*43758.5453;return n-Math.floor(n)}function Ks(t,n){let e=[];for(let r=0;r<t.length;r++){let a=t[r],i=t[(r+1)%t.length];a.across>n!=i.across>n&&e.push(a.along+(n-a.across)/(i.across-a.across)*(i.along-a.along))}e.sort((r,a)=>r-a);let o=[];for(let r=0;r+1<e.length;r+=2)o.push([e[r],e[r+1]]);return o}function Ys(t,n,e,o={}){let{poly:r,centre:a,ux:i,uy:s,vx:c,vy:l,back:u,front:f,left:m,right:h,widthM:y,at:d,box:x}=n,b=Gf,p=Nf/_,M=Df/_,P=o.maxTopY===void 0?1/0:o.maxTopY-b.ceilingClear-e,S=Math.max(b.heightFloor,Math.min(P,Math.max(b.heightMin,Math.min(b.heightMax,y*b.heightShare)))),g=e+S,I=vf/_,A=u-2*p,R=u-p,B=m+p+M,C=h-p-M;for(let[V,it]of[[m+p,B],[C,h-p]])Z(t,x(A,R,V,it),void 0,()=>g,e,ro,ro,z);Z(t,x(A,R,B,C),void 0,()=>g,g-.3,ro,ro,z),Z(t,x(A+I,R-I,B,C),void 0,()=>e+Math.min(Hf,S-1),e,Ws,Ws,z);let T=r.map(V=>({along:(V.x-a.x)*i+(V.y-a.y)*s,across:(V.x-a.x)*c+(V.y-a.y)*l})),O=(V,it)=>[V.x*_,it,V.y*_],E=[0,1,0],w=e+b.boardLift,L=b.boardEdge/_,G=Math.min(b.boardsMax,Math.max(4,Math.round(y/b.board))),k=h-m-2*L,N=(f+A)/2,U=Math.max(1e-6,(A-f)/2),X=(m+h)/2,F=Math.max(1e-6,(h-m)/2),v=(V,it,et)=>{let pt=Math.hypot((it-N)/U,(et-X)/F);return lt(V,Vf,.42*Math.pow(Math.max(0,1-pt),1.3))},j=3;for(let V=0;V<G;V++){let it=m+L+k*V/G,et=m+L+k*(V+1)/G,pt=Ks(T,it+k*1e-4),Mt=Ks(T,et-k*1e-4);if(!pt.length||pt.length!==Mt.length)continue;let At=W(Xf,.84+.3*Wf(V));for(let Pt=0;Pt<pt.length;Pt++){let vt=pt[Pt][0]+L,Nt=Mt[Pt][0]+L,Dt=Math.min(pt[Pt][1]-L,A-L),bn=Math.min(Mt[Pt][1]-L,A-L);if(!(Dt<=vt||bn<=Nt))for(let hn=0;hn<j;hn++){let In=hn/j,qn=(hn+1)/j,Se=vt+(Dt-vt)*In,hr=vt+(Dt-vt)*qn,dr=Nt+(bn-Nt)*In,yr=Nt+(bn-Nt)*qn,pr=O(d(Se,it),w),Ha=O(d(hr,it),w),Ua=O(d(dr,et),w),xr=O(d(yr,et),w),br=v(At,Se,it),ja=v(At,hr,it),Xa=v(At,dr,et),gr=v(At,yr,et);t.tri(pr,Ua,xr,E,br,Xa,gr),t.tri(pr,xr,Ha,E,br,gr,ja)}}}let Y=(C-B)*_,ot=Math.max(b.pierMin,Math.min(b.pierMax,y*b.pierShare)),q=m+p+ot/_,J=h-p-ot/_,rt=(J-q)*_;if(rt<1||Y<1)return;let ft=Math.max(b.headerMin,Math.min(b.headerMax,S*b.headerShare)),mt=S-ft,yt=Math.min(rt*b.riseShare,mt*b.riseMaxShare),$=V=>mt-yt*(1-Math.sqrt(Math.max(0,1-V*V))),K=[-i,0,-s],Q=(V,it,et)=>O(d(A-et/_,V),e+it),tt=(V,it,et,pt,Mt,At,Pt,vt,Nt,Dt,bn)=>{let hn=Q(it,pt,V),In=Q(et,Mt,V),qn=Q(et,Pt,V),Se=Q(it,At,V);t.tri(hn,In,qn,K,vt,Nt,bn),t.tri(hn,qn,Se,K,vt,bn,Dt)};t.setMaterial(Kn);let at=Math.max(b.foldsMin,Math.min(b.foldsMax,Math.round(Y/b.fold))),xt=[0,.07,.22,.5,1],gt=(V,it,et,pt)=>{let Mt=V/(at*2)*2-1,At=W(V%2?et:pt,(1-.3*Mt*Mt)*(1-.42*it)),Pt=Math.pow(1-it,5)*(1-.5*Mt*Mt);return[Math.min(1,At[0]*(1+1.3*Pt)+Jo[0]*.06*Pt),Math.min(1,At[1]*(1+1.3*Pt)+Jo[1]*.06*Pt),Math.min(1,At[2]*(1+1.3*Pt)+Jo[2]*.06*Pt)]};for(let V=0;V<at*2;V++){let it=B+(C-B)*V/(at*2),et=B+(C-B)*(V+1)/(at*2);for(let pt=0;pt+1<xt.length;pt++){let Mt=xt[pt],At=xt[pt+1];tt(b.curtainClear,it,et,S*Mt,S*Mt,S*At,S*At,gt(V,Mt,io,so),gt(V+1,Mt,io,so),gt(V,At,io,so),gt(V+1,At,io,so))}}tt(b.fringeClear,q,J,0,0,b.fringe,b.fringe,en,en,nn,nn);let _t=Math.max(b.swagsMin,Math.min(b.swagsMax,Math.round(rt/b.swag))),Ft=Math.max(b.dropMin,Math.min(b.dropMax,S*b.dropShare)),wt=_t*8,Yt=V=>{let it=V/wt*2-1,et=Math.sin(Math.PI*(V%8/8));return{x:q+(J-q)*V/wt,low:$(it)-Ft*(.42+.58*et),high:$(it)+.2,tone:.55+.45*et}};for(let V=0;V<wt;V++){let it=Yt(V),et=Yt(V+1),pt=(Mt,At)=>W(lt(jf,Uf,Mt),1-.3*At);tt(b.valanceClear,it.x,et.x,it.low,et.low,it.high,et.high,pt(it.tone,0),pt(et.tone,0),pt(it.tone,1),pt(et.tone,1)),tt(b.valanceFringeClear,it.x,et.x,it.low-b.fringe*.4,et.low-b.fringe*.4,it.low+b.fringe*.6,et.low+b.fringe*.6,en,en,nn,nn)}let Ct=V=>lt(ao,Yn,Math.min(1,V/S)),Gt=m+p,D=h-p;for(let[V,it]of[[Gt,q],[J,D]]){let et=W(ao,.62);tt(b.archClear,V,it,0,0,b.plinth,b.plinth,et,et,et,et),tt(b.archClear,V,it,b.plinth,b.plinth,S,S,Ct(b.plinth),Ct(b.plinth),Ct(S),Ct(S))}let H=28;for(let V=0;V<H;V++){let it=V/H*2-1,et=(V+1)/H*2-1,pt=q+(J-q)*V/H,Mt=q+(J-q)*(V+1)/H;tt(b.archClear,pt,Mt,$(it),$(et),S,S,Ct($(it)),Ct($(et)),Ct(S),Ct(S)),tt(b.mouldingClear,pt,Mt,$(it),$(et),$(it)+b.moulding,$(et)+b.moulding,nn,nn,en,en)}let ct=b.moulding/_;tt(b.mouldingClear,q-ct,q,b.plinth,b.plinth,$(-1)+b.moulding,$(-1)+b.moulding,en,nn,en,nn),tt(b.mouldingClear,J,J+ct,b.plinth,b.plinth,$(1)+b.moulding,$(1)+b.moulding,nn,en,nn,en),tt(b.mouldingClear,Gt,D,S-b.cornice,S-b.cornice,S,S,en,en,nn,nn);let Bt=[c,0,l],Ot=(V,it,et,pt,Mt,At,Pt,vt,Nt)=>{let Dt=Q(pt,Mt,it),bn=Q(pt,Mt,et),hn=Q(At,Pt,it),In=Q(At,Pt,et);t.tri(Dt,hn,In,V,vt,Nt,Nt),t.tri(Dt,In,bn,V,vt,Nt,vt)},Tt=W(ao,.66),St=W(Yn,.66);Ot([-Bt[0],0,-Bt[2]],0,b.archClear,Gt,0,Gt,S,Tt,St),Ot(Bt,0,b.archClear,D,0,D,S,Tt,St),Ot(E,0,b.archClear,Gt,S,D,S,W(Yn,.9),W(Yn,.9));let bt=W(ao,.8),an=W(Yn,.8);Ot(Bt,b.curtainClear,b.archClear,q,0,q,$(-1),bt,an),Ot([-Bt[0],0,-Bt[2]],b.curtainClear,b.archClear,J,0,J,$(1),bt,an);let nt=W(Yn,.62),It=[0,-1,0];for(let V=0;V<H;V++){let it=V/H*2-1,et=(V+1)/H*2-1;Ot(It,b.curtainClear,b.archClear,q+(J-q)*V/H,$(it),q+(J-q)*(V+1)/H,$(et),nt,nt)}t.setMaterial(0)}var Zs=[.13,.14,.17],Zn=[.4,.43,.47],Kf=.18,zf=.02,Yf=2.4,Zf=[.055,.06,.075],qf=[.46,.33,.22],$f=[1,.96,.84],Jf=[.98,.66,.28],Qf=[.5,.31,.15],tm=[1,.87,.64],Lt={lampEvery:1.8,lampsMin:3,lampsMax:14,lampDrop:.45,lampRadius:[.11,.2],poolShare:.44,poolEdge:.9,poolStrength:.5,washByDay:.35,drapeClear:.12,glowClear:.06,coreClear:.12,poolLift:.02};function qs(t,n,e,o,r={}){let a=Vs(n,o);if(!a)return null;if(zs(n.stageKind))return Ys(t,a,e,r.theatre),"theatre";let{poly:i,ux:s,uy:c,vx:l,vy:u,back:f,front:m,left:h,right:y,widthM:d,depthM:x,at:b,box:p}=a,M=Kf/_,P=e+Math.max(3.5,Math.min(8,d*.35)),S=e+Math.min(Yf,P-e-1),g=.2/_,I=m+Math.min(x*.25,1.5)/_,A=zf/_;Z(t,p(f-2*M+A,f-M-A,h+M+g,y-M-g),void 0,()=>S,e,Zs,Zs,z);for(let[K,Q]of[[h+M,h+M+g],[y-M-g,y-M]])Z(t,p(f-2*M,f-M,K,Q),void 0,()=>P+.3,e,Zn,Zn,z),Z(t,p(I+g,f-2*M,K,Q),void 0,()=>P+.3,P,Zn,Zn,z);Z(t,p(I,I+g,h+M,y-M),void 0,()=>P+.3,P,Zn,Zn,z);let R=(K,Q)=>[K.x*_,Q,K.y*_],B=[-s,0,-c],C=h+M+g,T=y-M-g,O=f-2*M-Lt.drapeClear/_,E=P-e,w=r.night===!1?Lt.washByDay:1,L=(K,Q)=>lt(Zf,qf,w*(1-K*K)*Math.pow(Math.max(0,1-Q),1.6)),G=(K,Q,tt=0)=>R(b(O-tt/_,(C+T)/2+K*(T-C)/2),e+E*Q);t.setMaterial(Kn);let k=8,N=5;for(let K=0;K<k;K++)for(let Q=0;Q<N;Q++){let tt=K/k*2-1,at=(K+1)/k*2-1,xt=Q/N,gt=(Q+1)/N;t.tri(G(tt,xt),G(at,xt),G(at,gt),B,L(tt,xt),L(at,xt),L(at,gt)),t.tri(G(tt,xt),G(at,gt),G(tt,gt),B,L(tt,xt),L(at,gt),L(tt,gt))}let U=Math.max(Lt.lampsMin,Math.min(Lt.lampsMax,Math.round(d/Lt.lampEvery))),X=Math.max(Lt.lampRadius[0],Math.min(Lt.lampRadius[1],d*.012)),F=(T-C)*_,v=1-Lt.lampDrop/E,j=(K,Q,tt,at,xt)=>{let _t=Q/F*2,Ft=Q/E;for(let wt=0;wt<10;wt++){let Yt=2*Math.PI*wt/10,Ct=2*Math.PI*(wt+1)/10,Gt=[Math.cos(Yt)*_t,Math.sin(Yt)*Ft],D=[Math.cos(Ct)*_t,Math.sin(Ct)*Ft];t.tri(G(K,v,tt),G(K+Gt[0],v+Gt[1],tt),G(K+D[0],v+D[1],tt),B,at,xt(Gt[0],Gt[1]),xt(D[0],D[1]))}};for(let K=0;K<U;K++){let Q=(K+.5)/U*2-1;j(Q,X*3,Lt.glowClear,lt(L(Q,v),Qf,.85),(tt,at)=>L(Q+tt,v+at)),j(Q,X,Lt.coreClear,$f,()=>Jf)}if(t.setMaterial(0),!r.night||!r.deck)return"rig";let Y=r.deck,ot=b((m+f-2*M)/2,(h+y)/2),q=e+Lt.poolLift,J=[0,1,0],rt=[{r:.4,k:.72},{r:.72,k:.28},{r:1,k:0}],ft=28,mt=[];for(let K=0;K<ft;K++){let Q=2*Math.PI*K/ft,tt=Math.cos(Q)*(f-2*M-m)*Lt.poolShare,at=Math.sin(Q)*(y-h)*Lt.poolShare,xt=Math.hypot(tt,at),gt=(s*tt+l*at)/xt,_t=(c*tt+u*at)/xt;mt.push(Math.min(xt,Xs(i,ot,gt,_t)*Lt.poolEdge))}if(mt.some(K=>!(K>0)))return"rig";let yt=(K,Q)=>{let tt=2*Math.PI*(K%ft)/ft,at=Math.cos(tt)*(f-2*M-m)*Lt.poolShare,xt=Math.sin(tt)*(y-h)*Lt.poolShare,gt=Math.hypot(at,xt),_t=mt[K%ft]*Q/gt;return R({x:ot.x+(s*at+l*xt)*_t,y:ot.y+(c*at+u*xt)*_t},q)},$=K=>lt(Y,tm,Lt.poolStrength*K);for(let K=0;K<ft;K++){t.tri(R(ot,q),yt(K,rt[0].r),yt(K+1,rt[0].r),J,$(1),$(rt[0].k),$(rt[0].k));for(let Q=0;Q+1<rt.length;Q++){let tt=rt[Q],at=rt[Q+1];t.tri(yt(K,tt.r),yt(K,at.r),yt(K+1,at.r),J,$(tt.k),$(at.k),$(at.k)),t.tri(yt(K,tt.r),yt(K+1,at.r),yt(K+1,tt.r),J,$(tt.k),$(at.k),$(tt.k))}}return"rig"}function $s(t,n){let e={openField:!1,openAir:!1,court:!1,indoorCourt:!1,inTheRound:!1,stage:!1,standing:0,seatCount:n.length};for(let o of t)for(let r of o.objects){if(r.type==="gaArea"&&(e.standing+=r.capacity),r.type!=="shape")continue;let a=r.stageKind;if(Ee(a)){e.openField=!0;continue}if(Fn(a)&&(e.openAir=!0),qt(a)){e.court=!0,Ar(a)&&(e.indoorCourt=!0);continue}if(r.role!=="stage")continue;if(e.stage=!0,a==="round"){e.inTheRound=!0;continue}let i=ut(r);if(!i||i.length<3)continue;let s={x:i.reduce((c,l)=>c+l.x,0)/i.length,y:i.reduce((c,l)=>c+l.y,0)/i.length};zn(s,n)&&(e.inTheRound=!0)}return e}var Sn=72,nm=1.2,em=5,om=30,rm=4;function im(t,n,e,o){let r=0;for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length],c=s.x-i.x,l=s.y-i.y,u=e*l-o*c;if(Math.abs(u)<1e-12)continue;let f=((i.x-n.x)*l-(i.y-n.y)*c)/u,m=((i.x-n.x)*o-(i.y-n.y)*e)/u;f>r&&m>=-1e-9&&m<=1+1e-9&&(r=f)}return r}function sm(t,n){if(t.length<3)return null;let e={x:t.reduce((s,c)=>s+c.x,0)/t.length,y:t.reduce((s,c)=>s+c.y,0)/t.length},o=2*Math.PI/Sn,r=new Float64Array(Sn);for(let s=0;s<Sn;s++)if(r[s]=im(t,e,Math.cos(s*o),Math.sin(s*o)),!(r[s]>0))return null;let a=new Float64Array(Sn).fill(1/0);for(let s of n){let c=s.x-e.x,l=s.y-e.y,u=Math.hypot(c,l),f=(Math.round(Math.atan2(l,c)/o)%Sn+Sn)%Sn;u>r[f]&&u<a[f]&&(a[f]=u)}let i=[];for(let s=0;s<Sn;s++){let l=Number.isFinite(a[s])&&a[s]-r[s]<=om/_?a[s]+nm/_:r[s]+em/_;i.push({x:e.x+Math.cos(s*o)*l,y:e.y+Math.sin(s*o)*l})}return i}function am(t){return lt(W(t,.84),[.33,.36,.31],.22)}function Js(t,n,e,o,r){let a=sm(n,o);if(!a)return;let i=e-.015;t.setMaterial(rm);let s=am(r);Z(t,a,void 0,()=>i,i-.004,s,s,z),t.setMaterial(0)}function Qs(t,n,e,o=[],r){if(n<1)return null;let a=1/0,i=-1/0,s=1/0,c=-1/0,l=-1/0,u=(M,P)=>{M<a&&(a=M),M>i&&(i=M),P<s&&(s=P),P>c&&(c=P)};for(let M=0;M<n;M++)u(t[M*3],t[M*3+2]),t[M*3+1]>l&&(l=t[M*3+1]);for(let[M,P]of o)u(M,P);if(!Number.isFinite(a)||!Number.isFinite(l))return null;let f=(a+i)/2,m=(s+c)/2,h=Math.max(4,(i-a)/2),y=Math.max(4,(c-s)/2),d=1,x=(M,P)=>{let S=Math.hypot((M-f)/h,(P-m)/y);S>d&&(d=S)};for(let M=0;M<n;M++)x(t[M*3],t[M*3+2]);for(let[M,P]of o)x(M,P);let b=Math.min(9,Math.max(5,2*Math.max(h,y)*.1)),p=Math.max(e+8,l+b);return{centre:[f,m],radii:[h*d+6,y*d+6],floorY:e,ceilingY:r===void 0?p:Math.max(r,l+5)}}var Rt={stepM:.79,spacingM:.45,tries:8,edgeM:.35,heightM:[1.5,1.78],capDesktop:6e3,capSmall:2e3,smallCeiling:3e4,maxCellsPerArea:6e4,maxCellsPerVenue:24e4,behind:{levelM:.6,clearM:6,fullM:14,from:.3,sideM:4},clothes:8,skins:4,hairs:5};function ra(t,n,e=!0){if(!e)return 0;let o=n<=Rt.smallCeiling?Rt.capSmall:Rt.capDesktop;return Math.max(0,Math.min(o,Math.floor(n-t)))}function ia(){let t=globalThis;return(t.navigator?.hardwareConcurrency??8)<=4||(t.navigator?.deviceMemory??8)<=4||(t.matchMedia?.("(pointer: coarse)").matches??!1)?Rt.smallCeiling:Rt.smallCeiling*2}var ta=[[1,0],[.92388,.382683],[.707107,.707107],[.382683,.92388],[0,1],[-.382683,.92388],[-.707107,.707107],[-.92388,.382683],[-1,0],[-.92388,-.382683],[-.707107,-.707107],[-.382683,-.92388],[0,-1],[.382683,-.92388],[.707107,-.707107],[.92388,-.382683]],cm=[[.939693,-.34202],[.954588,-.29793],[.967415,-.253195],[.978148,-.207912],[.986762,-.162178],[.993238,-.116093],[.997564,-.069756],[.999729,-.023269],[.999729,.023269],[.997564,.069756],[.993238,.116093],[.986762,.162178],[.978148,.207912],[.967415,.253195],[.954588,.29793],[.939693,.34202]];function xn(t,n,e,o){let r=Math.imul(t|0,2654435761)^Math.imul(n|0,2246822519)^Math.imul(e|0,3266489917)^Math.imul(o|0,668265263);return r^=r>>>15,r=Math.imul(r,739982445),r^=r>>>12,r=Math.imul(r,695872825),r^=r>>>15,r>>>0}var co=t=>t/4294967296;function na(t,n,e){let o=!1;for(let r=0,a=t.length-1;r<t.length;a=r++){let i=t[r],s=t[a];i.y>e!=s.y>e&&n<(s.x-i.x)*(e-i.y)/(s.y-i.y)+i.x&&(o=!o)}return o}function ea(t,n,e){let o=1/0;for(let r=0,a=t.length-1;r<t.length;a=r++){let i=t[r],s=t[a],c=s.x-i.x,l=s.y-i.y,u=c*c+l*l,f=u>0?Math.max(0,Math.min(1,((n-i.x)*c+(e-i.y)*l)/u)):0,m=n-(i.x+c*f),h=e-(i.y+l*f);o=Math.min(o,m*m+h*h)}return o}var sa=(t,n)=>(t+32768)*65536+(n+32768);function lm(t,n){let e=t.focal;if(!e)return null;let o=Math.sqrt(Rt.behind.fullM*Rt.behind.fullM+Rt.behind.sideM*Rt.behind.sideM)/_,r=1/0,a=1/0,i=-1/0,s=-1/0;for(let f of t.points)r=Math.min(r,f.x),i=Math.max(i,f.x),a=Math.min(a,f.y),s=Math.max(s,f.y);let c=4/_,l=new Map,u=[];for(let f of n){if(f.floorIndex!==t.floorIndex||f.x<r-o||f.x>i+o||f.y<a-o||f.y>s+o||Math.abs(f.deckY-t.floorY)>Rt.behind.levelM)continue;let m=e.x-f.x,h=e.y-f.y,y=Math.sqrt(m*m+h*h);if(!(y>0))continue;let d=sa(Math.floor(f.x/c),Math.floor(f.y/c)),x=l.get(d);x||l.set(d,x=[]),x.push(u.length),u.push(f.x,f.y,m/y,h/y)}return u.length?{cell:c,cells:l,data:u}:null}function um(t,n,e){let{clearM:o,fullM:r,from:a,sideM:i}=Rt.behind,s=Math.floor(n/t.cell),c=Math.floor(e/t.cell),l=1;for(let u=c-4;u<=c+4;u++)for(let f=s-4;f<=s+4;f++){let m=t.cells.get(sa(f,u));if(m)for(let h of m){let y=(n-t.data[h])*_,d=(e-t.data[h+1])*_,x=t.data[h+2],b=t.data[h+3],p=y*x+d*b;if(!(p<=0||p>=r)&&!(Math.abs(y*b-d*x)>i)){if(p<o)return 0;l=Math.min(l,a+(1-a)*(p-o)/(r-o))}}}return l}function oa(t,n,e,o,r){return(Math.ceil(n/r)-Math.floor(t/r)+1)*(Math.ceil(o/r)-Math.floor(e/r)+1)}function fm(t,n,e,o,r){let a=Rt.stepM/_,i=oa(t,n,e,o,a);if(i<=r)return a;let s=a*Math.sqrt(i/r);for(let c=0;c<400&&oa(t,n,e,o,s)>r;c++)s*=1.05;return s}function mm(t,n,e,o){if(t.points.length<3||!(t.capacity>0))return[];let r=Rt.edgeM/_,a=r*r,i=1/0,s=1/0,c=-1/0,l=-1/0;for(let S of t.points)i=Math.min(i,S.x),c=Math.max(c,S.x),s=Math.min(s,S.y),l=Math.max(l,S.y);if(!Number.isFinite(i+c+s+l))return[];let u=fm(i,c,s,l,o),f=lm(t,e),m=[],h=Rt.spacingM/_,y=h*h,d=Math.floor(s/u),x=Math.ceil(l/u),b=Math.floor(i/u),p=Math.ceil(c/u),M=p-b+1,P=new Int32Array(M*(x-d+1)).fill(-1);for(let S=d;S<=x;S++)for(let g=b;g<=p;g++)for(let I=0;I<Rt.tries;I++){let A=(g+co(xn(g,S,n,10+I*2)))*u,R=(S+co(xn(g,S,n,11+I*2)))*u;if(!na(t.points,A,R)||ea(t.points,A,R)<a||t.holes?.some(T=>T.length>=3&&(na(T,A,R)||ea(T,A,R)<a)))continue;let B=!0;for(let T=-1;T<=0&&B;T++)for(let O=-1;O<=1&&B&&!(T===0&&O>=0);O++){let E=g+O-b,w=S+T-d;if(E<0||E>=M||w<0)continue;let L=P[w*M+E];if(L<0)continue;let G=m[L].x-A,k=m[L].y-R;G*G+k*k<y&&(B=!1)}if(!B)continue;let C=f?um(f,A,R):1;if(C<=0||C<1&&co(xn(g,S,n,3))>=C)break;P[(S-d)*M+(g-b)]=m.length,m.push({x:A,y:R,i:g,j:S,order:xn(g,S,n,4),thinned:C<1});break}return m}function hm(t,n,e=Rt.capDesktop){if(!(e>0)||!t.length)return null;let o=Math.max(64,Math.min(Rt.maxCellsPerArea,Math.floor(Rt.maxCellsPerVenue/t.length))),r=t.map((m,h)=>{let y=mm(m,h,n,o);return y.sort((d,x)=>d.order-x.order||d.j-x.j||d.i-x.i),y.slice(0,Math.min(y.length,Math.floor(m.capacity)))}),a=r.reduce((m,h)=>m+h.length,0);if(!a)return null;let i=a>e?r.map(m=>m.slice(0,Math.floor(m.length*e/a))):r,s=i.reduce((m,h)=>m+h.length,0);if(!s)return null;let c={count:s,iPosition:new Float32Array(s*3),iFacing:new Float32Array(s*2),iHeight:new Float32Array(s),iTone:new Float32Array(s),iFloor:new Float32Array(s)},[l,u]=Rt.heightM,f=0;return i.forEach((m,h)=>{let y=t[h];for(let d of m){c.iPosition[f*3]=d.x*_,c.iPosition[f*3+1]=y.floorY,c.iPosition[f*3+2]=d.y*_;let x=co(xn(d.i,d.j,h,5));c.iHeight[f]=l+x*(u-l)*(d.thinned?.5:1),c.iTone[f]=xn(d.i,d.j,h,9)%Rt.hairs*(Rt.clothes*Rt.skins)+xn(d.i,d.j,h,6)%Rt.clothes*Rt.skins+xn(d.i,d.j,h,7)%Rt.skins,c.iFloor[f]=y.floorIndex;let b=xn(d.i,d.j,h,8)&15,p=ta[b][0],M=ta[b][1];if(y.focal){let P=y.focal.x-d.x,S=y.focal.y-d.y,g=Math.sqrt(P*P+S*S);if(g>0){let[I,A]=cm[b];p=(P*I-S*A)/g,M=(P*A+S*I)/g}}c.iFacing[f*2]=p,c.iFacing[f*2+1]=M,f++}}),c}function aa(t,n,e){try{return hm(t,n,e)}catch{return null}}var Qo=.6,ca=3,dm=.25,ym=6;function pm(t,n,e,o){let r=1/0;for(let a=0,i=o.length-1;a<o.length;i=a++){let s=o[i],c=o[a],l=c.x-s.x,u=c.y-s.y,f=n*u-e*l;if(Math.abs(f)<1e-12)continue;let m=((s.x-t.x)*u-(s.y-t.y)*l)/f,h=((s.x-t.x)*e-(s.y-t.y)*n)/f;m>1e-9&&h>=-1e-9&&h<=1+1e-9&&(r=Math.min(r,m))}return r}function xm(t,n){if(kt(n,t.x,t.y))return 0;let e=1/0;for(let o=0,r=n.length-1;o<n.length;r=o++){let a=n[r],i=n[o],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c||1,u=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/l));e=Math.min(e,Math.hypot(t.x-(a.x+u*s),t.y-(a.y+u*c)))}return e}function la(t,n){return new Map([...bm(t,n)].map(([e,o])=>[e,o.toward]))}function bm(t,n){let e=t.map(i=>({booth:i,ring:sn(i)})).filter(i=>!!i.ring&&i.ring.length===4&&!i.booth.points),o=e.map(({ring:i})=>({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))})),r=(ca+Qo)/_,a=new Map;return e.forEach(({booth:i,ring:s},c)=>{let l={x:s.reduce((y,d)=>y+d.x,0)/4,y:s.reduce((y,d)=>y+d.y,0)/4},u=[0,1,2,3].map(y=>{let d=s[y],x=s[(y+1)%4],b={x:(d.x+x.x)/2,y:(d.y+x.y)/2},p=b.x-l.x,M=b.y-l.y,P=Math.hypot(p,M)||1,S={x:b.x+p/P*Qo/_,y:b.y+M/P*Qo/_},g=ca/_;return o.forEach((I,A)=>{A===c||S.x<I.minX-r||S.x>I.maxX+r||S.y<I.minY-r||S.y>I.maxY+r||(g=Math.min(g,xm(S,e[A].ring)))}),{open:g*_,toward:{x:b.x+p/P*10/_,y:b.y+M/P*10/_},focal:Math.hypot(b.x-n.x,b.y-n.y),normal:{x:p/P,y:M/P},halfDepthM:P*_,halfWidthM:Math.hypot(x.x-d.x,x.y-d.y)*_/2,mid:b}}),f=Math.max(...u.map(y=>y.open)),m=u.filter(y=>y.open>=f-dm).sort((y,d)=>y.focal-d.focal)[0],h=ym/_;e.forEach((y,d)=>{d!==c&&(h=Math.min(h,pm(m.mid,m.normal.x,m.normal.y,y.ring)))}),a.set(i.id,{toward:m.toward,normal:m.normal,halfDepthM:m.halfDepthM,halfWidthM:m.halfWidthM,aisleM:h*_})}),a}import gm from"polygon-clipping";var Mm=.45,Rm=1500,_m=200;function ua(t,n){if(t.role!=="stage"||qt(t.stageKind))return t;let e=ut(t);if(!e||e.length<3||Math.abs(Kt(e))*_*_>Rm)return t;let o=n.filter(i=>kt(e,i.x,i.y));if(!o.length||o.length>_m)return t;let r=Mm/_,a=o.map(i=>[[[i.x-r,i.y-r],[i.x+r,i.y-r],[i.x+r,i.y+r],[i.x-r,i.y+r],[i.x-r,i.y-r]]]);try{let i=gm.difference([[...e.map(l=>[l.x,l.y]),[e[0].x,e[0].y]]],...a),s=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(Kt(u));f>c&&(c=f,s=u)}return!s||s.length<3?t:{...t,kind:"polygon",points:s,rotation:0}}catch{return t}}function tr(t,n,e,o,r,a,i,s,c,l=[],u=r){if(n.length!==e.length||n.length<2||a-r<1.5)return;let f=(d,x,b)=>{yn(t,d,x,b,l,i,s,{portalBase:u,ao:c})||Z(t,d,void 0,()=>b,x,i,s,c)},m=(d,x,b)=>({x:d.x+(x.x-d.x)*b,y:d.y+(x.y-d.y)*b}),h=o?n.length:n.length-1,y=0;for(let d=0;d<h;d++){let x=(d+1)%n.length,b=Math.hypot(e[x].x-e[d].x,e[x].y-e[d].y)*st;if(b<1e-5)continue;let p=(g,I)=>[m(n[d],n[x],g),m(n[d],n[x],I),m(e[d],e[x],I),m(e[d],e[x],g)];f(p(0,1),r,r+.95),f(p(0,1),a-.22,a);let M=Math.ceil((y-.32)/6)*6,P=!1,S=!1;for(let g=M;g<y+b;g+=6){let I=Math.max(0,(g-y)/b),A=Math.min(1,(g+.32-y)/b);A<=I||(f(p(I,A),r+.95,a-.22),P||=I<1e-6,S||=A>1-1e-6)}if(!o&&(d===0&&!P||d===h-1&&!S)){let g=Math.min(1,.32/b);f(p(d===0?0:1-g,d===0?g:1),r+.95,a-.22)}y+=b}}import Cn from"polygon-clipping";var Re=.65;function nr(t,n){let e=1/0;for(let o of n)for(let r=0;r<o.length;r++){let a=o[r],i=o[(r+1)%o.length],s=i.x-a.x,c=i.y-a.y,l=Math.max(0,Math.min(1,((t.x-a.x)*s+(t.y-a.y)*c)/(s*s+c*c||1)));e=Math.min(e,Math.hypot(t.x-a.x-l*s,t.y-a.y-l*c))}return e}var er=.01;function fa(t,n,e,o,r,a,i,s=[],c=!0,l={bays:[],walls:[]}){if(o-r<=1e-5)return;let u=o-r>=3,f=u?o-Re:r;t.setMaterial(5);let m=u?[]:s.filter(g=>{if(g.role!=="entrance"&&g.role!=="exit")return!1;let I=ut(g);if(!I)return!1;let A=Un(I,r,r+on(g).heightM);return A!==null&&A.openingTop<=o-.12});if((!m.length||!yn(t,n,f,o,m,a,i,{holes:e,portalBase:r}))&&Z(t,n,e,()=>o,f,a,i,z,void 0,()=>[0,1,0]),!u){t.setMaterial(0);return}let h=c&&l.bays.length?Sm(n,e,Jt(n,Me/_),l):null,y=6/_,d=.22/_,x=s.flatMap(g=>{if(g.role!=="entrance"&&g.role!=="exit")return[];let I=ut(g);return I?.length?[{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))}]:[]}),b=Math.min(...n.map(g=>g.x)),p=Math.max(...n.map(g=>g.x)),M=Math.min(...n.map(g=>g.y)),P=Math.max(...n.map(g=>g.y));for(let g=b+y/2;g<p;g+=y)for(let I=M+y/2;I<P;I+=y){if(x.some(R=>g+d>=R.minX&&g-d<=R.maxX&&I+d>=R.minY&&I-d<=R.maxY))continue;let A=[{x:g-d,y:I-d},{x:g+d,y:I-d},{x:g+d,y:I+d},{x:g-d,y:I+d}];!$t({x:g,y:I},n,e)||nr({x:g,y:I},[n,...e??[]])<d*Math.SQRT2+(c?Me/_:0)||h&&nr({x:g,y:I},h.flat())<d*Math.SQRT2+Me/_||Z(t,A,void 0,()=>f,r,a,i,z)}if(h){for(let[g,...I]of h)Z(t,g,I,()=>f,r-er,a,i,z);t.setMaterial(0);return}let S=Jt(n,Me/_);if(c&&S.length>=3){let g=s.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let B=ut(R);return!!B&&B.some(C=>!$t(C,n,void 0)||nr(C,[n])<=Me/_)}),I=[S.slice().reverse()],A=r-er;(!g.length||!yn(t,n,A,f,g,a,i,{holes:I,portalBase:r+er}))&&Z(t,n,I,()=>f,A,a,i,z)}t.setMaterial(0)}var or=.25,Me=or;function Sm(t,n,e,o){if(e.length<3)return null;let r=i=>{let s=i.map(c=>[c.x,c.y]);return s.push(s[0]),s},a=i=>{let[s,...c]=i.map(l=>[r(l)]);return Cn.union(s,...c)};try{let i=[r(t),...(n??[]).map(r)],s=Cn.difference(i,[r(e)]),c=Cn.intersection(i,a(o.bays));if(!c.length)return null;let l=Cn.difference(Cn.intersection(i,a(o.walls)),c);return Cn.union(Cn.difference(s,c),l).map(f=>f.map(m=>m.slice(0,-1).map(([h,y])=>({x:h,y}))))}catch{return null}}var Im=.02,Am=.25,Pm=1.2,Em=.6,wm=.45,Bm=2.3,Tm=Math.PI/180,ma=.005;function fn(t,n,e){let o=e*Tm;return{x:t.x+n*Math.sin(o),y:t.y+n*Math.cos(o)}}function Om(t,n){let e=n.rings[n.rings.length-1];if(!e)return!1;let o=e.outerRMedian*.85;for(let r of t){if(r.role!=="wall")continue;let a=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(a.length<2)continue;let i=0;for(let s of a)Math.hypot(s.x-n.centre.x,s.y-n.centre.y)>=o&&i++;if(i>=a.length/2)return!0}return!1}var Cm=24,km=.01;function Lm(t,n,e,o,r,a,i,s,c){let l=e.binCount,u=Cm,f=st,m=a+.02,h=a-km,y=[];for(let E=0;E<l;E++){let w=(e.startBin+E+.5)*n.binStepDeg,L=new Float64Array(u+1);for(let G=0;G<=u;G++){let k=o[E]+(r[E]-o[E])*G/u;L[G]=Math.max(m,Ur(n,e,w,k)-Am)}y.push(L)}if(c){let E=0;for(let w=0;w+1<l;w++)for(let L=0;L<u;L++){let G=fn(n.centre,o[w]+(r[w]-o[w])*L/u,(e.startBin+w+.5)*n.binStepDeg),k=fn(n.centre,o[w+1]+(r[w+1]-o[w+1])*(L+1)/u,(e.startBin+w+1.5)*n.binStepDeg);E=Math.max(E,Math.hypot(k.x-G.x,k.y-G.y))}for(let w=0;w<l;w++){let L=(e.startBin+w+.5)*n.binStepDeg;for(let G=0;G<=u;G++){let k=fn(n.centre,o[w]+(r[w]-o[w])*G/u,L),N=c(k.x,k.y,E*1.01);N!==null&&(y[w][G]=Math.min(y[w][G],Math.max(h+ma,N-ma)))}}}let d=[i.bandTop[0]*s.top,i.bandTop[1]*s.top,i.bandTop[2]*s.top],x=[i.bandTop[0]*s.bottomCap,i.bandTop[1]*s.bottomCap,i.bandTop[2]*s.bottomCap],b=[i.bandWall[0]*s.top,i.bandWall[1]*s.top,i.bandWall[2]*s.top],p=[i.bandWall[0]*s.wallBottom,i.bandWall[1]*s.wallBottom,i.bandWall[2]*s.wallBottom],M=(E,w)=>{let L=(e.startBin+E+.5)*n.binStepDeg,G=o[E]+(r[E]-o[E])*w/u,k=fn(n.centre,G,L);return[k.x*f,y[E][w],k.y*f]};{let E=Math.tan(12*Math.PI/180);for(let w=0;w<6;w++){let L=!1;for(let k=0;k<l;k++)for(let N=u-1;N>=0;N--)y[k][N]>y[k][N+1]&&(y[k][N]=y[k][N+1],L=!0);let G=e.closed?l:l-1;for(let k=0;k<G;k++){let N=(k+1)%l;for(let U=0;U<=u;U++){let X=y[N][U]-y[k][U];if(Math.abs(X)>1)continue;let F=o[k]+(r[k]-o[k])*U/u,v=o[N]+(r[N]-o[N])*U/u,j=fn(n.centre,F,(e.startBin+k+.5)*n.binStepDeg),Y=fn(n.centre,v,(e.startBin+N+.5)*n.binStepDeg),ot=E*Math.hypot(Y.x-j.x,Y.y-j.y)*f;X>ot?(y[N][U]=y[k][U]+ot,L=!0):-X>ot&&(y[k][U]=y[N][U]+ot,L=!0)}}if(!L)break}}let P=1,S=(E,w)=>{for(let L=0;L<=u;L+=4)if(Math.abs(y[E][L]-y[w][L])>P)return!0;return Math.abs(y[E][u]-y[w][u])>P},g=Math.tan(38*Math.PI/180),I=E=>(r[E]-o[E])/u*f,A=(E,w)=>y[E][w+1]-y[E][w]>g*Math.max(1e-6,I(E)),R=(E,w)=>{let L=e.closed?(E-1+l)%l:Math.max(0,E-1),G=e.closed?(E+1)%l:Math.min(l-1,E+1);Math.abs(y[L][w]-y[E][w])>P&&(L=E),Math.abs(y[G][w]-y[E][w])>P&&(G=E);let k=Math.max(0,w-1),N=Math.min(u,w+1);k<w&&A(E,k)&&(k=w),N>w&&A(E,w)&&(N=w);let U=M(L,w),X=M(G,w),F=M(E,k),v=M(E,N),j=X[0]-U[0],Y=X[1]-U[1],ot=X[2]-U[2],q=v[0]-F[0],J=v[1]-F[1],rt=v[2]-F[2],ft=Y*rt-ot*J,mt=ot*q-j*rt,yt=j*J-Y*q,$=Math.hypot(ft,mt,yt);return $>1e-12?(ft/=$,mt/=$,yt/=$,mt<0&&(ft=-ft,mt=-mt,yt=-yt),[ft,mt,yt]):[0,1,0]},B=(E,w,L=!1)=>{let G=L&&Math.min(E[1],w[1])-a>=3,k=[E[0],G?E[1]-Re:h,E[2]],N=[w[0],G?w[1]-Re:h,w[2]],U=w[0]-E[0],X=w[2]-E[2],F=Math.hypot(U,X);if(!(F>1e-12))return;let v=[X/F,0,-U/F];t.tri(E,w,N,v,b,b,p),t.tri(E,N,k,v,b,p,p)},C=.05*Zt,T=E=>r[E]-o[E]<C,O=e.closed?l:l-1;for(let E=0;E<O;E++){let w=(E+1)%l;if(T(E)||T(w))continue;if(S(E,w)){let X=(e.startBin+E+1)*n.binStepDeg,F=(J,rt)=>{let ft=(o[E]+o[w])/2,mt=(r[E]+r[w])/2,yt=ft+(mt-ft)*rt/u,$=fn(n.centre,yt,X);return[$.x*f,y[J][rt],$.y*f]};for(let J=0;J<u;J++){let rt=M(E,J),ft=M(E,J+1),mt=F(E,J),yt=F(E,J+1),$=R(E,J),K=R(E,J+1);t.triN(rt,mt,yt,$,$,K,d),t.triN(rt,yt,ft,$,K,K,d);let Q=M(w,J),tt=M(w,J+1),at=F(w,J),xt=F(w,J+1),gt=R(w,J),_t=R(w,J+1);t.triN(at,Q,tt,gt,gt,_t,d),t.triN(at,tt,xt,gt,_t,_t,d);let Ft=F(E,J),wt=F(E,J+1),Yt=F(w,J+1),Ct=F(w,J),Gt=wt[0]-Ft[0],D=wt[2]-Ft[2],H=Math.hypot(Gt,D);if(H>1e-12){let ct=[D/H,0,-Gt/H];t.tri(Ft,wt,Yt,ct,b),t.tri(Ft,Yt,Ct,ct,b)}}let v=M(E,0),j=M(w,0),Y=M(w,u),ot=M(E,u),q=J=>[J[0],h,J[2]];Math.min(v[1],j[1])-a<3&&(t.tri(q(v),q(Y),q(j),[0,-1,0],x),t.tri(q(v),q(ot),q(Y),[0,-1,0],x)),B(v,j,!0),B(ot,Y,!0);continue}for(let X=0;X<u;X++){let F=R(E,X),v=R(w,X),j=R(w,X+1),Y=R(E,X+1);if(A(E,X)||A(w,X)){let ft=(wt,Yt)=>{let Ct=(e.startBin+wt+.5)*n.binStepDeg,Gt=o[wt]+(r[wt]-o[wt])*(X+.5)/u,D=fn(n.centre,Gt,Ct);return[D.x*f,Yt,D.y*f]},mt=M(E,X),yt=M(w,X),$=ft(E,y[E][X]),K=ft(w,y[w][X]);t.triN(mt,yt,K,F,v,v,d),t.triN(mt,K,$,F,v,F,d);let Q=M(w,X+1),tt=M(E,X+1),at=ft(E,y[E][X+1]),xt=ft(w,y[w][X+1]);t.triN(at,xt,Q,Y,j,j,d),t.triN(at,Q,tt,Y,j,Y,d);let gt=K[0]-$[0],_t=K[2]-$[2],Ft=Math.hypot(gt,_t);if(Ft>1e-12){let wt=[-_t/Ft,0,gt/Ft];t.tri($,K,xt,wt,b),t.tri($,xt,at,wt,b)}continue}let ot=M(E,X),q=M(w,X),J=M(w,X+1),rt=M(E,X+1);t.triN(ot,q,J,F,v,j,d),t.triN(ot,J,rt,F,j,Y,d)}let L=M(E,0),G=M(w,0),k=M(w,u),N=M(E,u),U=X=>[X[0],h,X[2]];Math.min(L[1],G[1])-a<3&&(t.tri(U(L),U(k),U(G),[0,-1,0],x),t.tri(U(L),U(N),U(k),[0,-1,0],x)),B(L,G,!0),B(N,k,!0)}if(!e.closed)for(let E of[0,l-1])for(let w=0;w<u;w++)B(M(E,w),M(E,w+1))}function ha(t,n,e){let{bottomY:o,colors:r,ao:a}=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 d=0;d<f.binCount;d++){let x=(f.startBin+d)%n.binCount,b=Math.max(0,f.innerR[d]-Qt);m[d]=Math.max(b,i[x]+.001),h[d]=Math.max(m[d]+.001,f.outerR[d]+Qt)}let y=0;for(let d=0;d<f.binCount;d++){let x=f.topLevelM[d]-o;x>y&&(y=x)}y>=Pm&&Lm(t,n,f,m,h,o,r,a,e.standTopNear);for(let d=0;d<f.binCount;d++){let x=(f.startBin+d)%n.binCount;h[d]>i[x]&&(i[x]=h[d])}}if(e.deriveShell===!1||Om(e.shapes,n))return;let s=n.rings[n.rings.length-1],c=Em*Zt,l=wm*Zt;for(let u of s.arcs){let f=[],m=[];for(let R=0;R<u.binCount;R++){let B=(u.startBin+R+.5)*n.binStepDeg,C=u.outerR[R]+Qt+c;f.push(fn(n.centre,C,B)),m.push(fn(n.centre,C+l,B))}let h=-1/0;for(let R=0;R<u.binCount;R++)u.topLevelM[R]>h&&(h=u.topLevelM[R]);let y=h+Bm,d=u.closed?m:[...m,...f.slice().reverse()],x=u.closed?[f.slice().reverse()]:void 0,b=lt(r.shellWall,[.66,.71,.72],.62),p=(R,B,C,T,O)=>{let E=Math.abs(T-h)<1e-6?T-Im:T;yn(t,R,C,E,e.shapes,r.shellTop,O,{holes:B,portalBase:o,ao:a})||Z(t,R,B,()=>E,C,r.shellTop,O,a)},M=Math.max(1,Math.ceil((h-o)/4.5)),P=(h-o)/M,S=new Set,g=e.tierFrontLevels??n.rings.map(R=>{let B=R.arcs.flatMap(C=>Array.from(C.frontLevelM)).filter(Number.isFinite).sort((C,T)=>C-T);return B[Math.floor(B.length/2)]});for(let R of g)Number.isFinite(R)&&R-o>=3&&R<h&&S.add(Math.max(0,Math.min(M-1,Math.floor((R-o)/P))));let I=Math.min(...g.filter(R=>Number.isFinite(R)&&R-o>=3&&R<h));for(let R=0;R<M;R++)o+(R+1)*P<=I-Re&&Number.isFinite(I)&&S.add(R);for(let R=0;R<M;R++){let B=o+(h-o)*R/M,C=o+(h-o)*(R+1)/M;S.has(R)&&C-B>=3.2?(p(d,x,B,B+.45,b),tr(t,f,m,u.closed,B+.45,C-.16,r.shellTop,b,a,e.shapes,o)):p(d,x,B,C-.16,b),p(d,x,C-.16,C,W(b,.62))}tr(t,f,m,u.closed,h,y,r.shellTop,b,a,e.shapes,o);let A=8;for(let R=1;R<m.length;R++){if(A+=Math.hypot(m[R].x-m[R-1].x,m[R].y-m[R-1].y)*st,A<8)continue;A=0;let B=m[R],C=m[R-1],T=B.x-C.x,O=B.y-C.y,E=Math.max(1,Math.hypot(T,O)),w=T/E*.16*Zt,L=O/E*.16*Zt,G=Math.max(1,Math.hypot(B.x-n.centre.x,B.y-n.centre.y)),k=(B.x-n.centre.x)/G*.24*Zt,N=(B.y-n.centre.y)/G*.24*Zt,U=[{x:B.x-w,y:B.y-L},{x:B.x+w,y:B.y+L},{x:B.x+w+k,y:B.y+L+N},{x:B.x-w+k,y:B.y-L+N}];p(U,void 0,o,h,W(b,1.12))}}}var Fm=2.5,da=.65,Gm=2,Nm=.03;function Dm(t,n){let e=()=>{let o=n;for(;t.length>2;){let r=t[0],a=t[1],i=Math.hypot(a.x-r.x,a.y-r.y);if(i>o){t[0]={x:r.x+(a.x-r.x)/i*o,y:r.y+(a.y-r.y)/i*o};return}o-=i,t.shift()}};e(),t.reverse(),e(),t.reverse()}function sr(t,n,e){let o=new Map;for(let a of t){let i=o.get(a.blockId);(!i||a.depth<i.depth)&&o.set(a.blockId,a)}let r=[];for(let[a,i]of o){if(i.y-e<Fm||i.pts.length<2)continue;let s=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*da/_,y:u.y-m/h*da/_}}),c=[],l=[s[0]];for(let u=1;u<s.length;u++){let f=s[u-1],m=s[u];Math.hypot(m.x-f.x,m.y-f.y)*_>Gm?(l.length>=2&&c.push(l),l=[m]):l.push(m)}l.length>=2&&c.push(l);for(let u of c)Dm(u,Nm/_);c.length&&r.push({blockId:a,y:i.y,runs:c})}return r}var ya=.1,vm=1.1,Hm=.22,rr=.95,ir=.05,pa=1.8;function xa(t,n,e,o){let r=[.72,.72,.69],a=[.48,.55,.57];for(let i of sr(n,e,o)){let s=i.y;for(let c of i.runs){let l=pa;for(let u=1;u<c.length;u++){let f=c[u-1],m=c[u],h=m.x-f.x,y=m.y-f.y,d=Math.hypot(h,y);if(d<1e-5)continue;let x=b=>{let p=-y/d*b/_/2,M=h/d*b/_/2;return[{x:f.x+p,y:f.y+M},{x:m.x+p,y:m.y+M},{x:m.x-p,y:m.y-M},{x:f.x-p,y:f.y-M}]};if(Z(t,x(Hm),void 0,()=>s+ya,s-vm,r,r,z),Z(t,x(ir),void 0,()=>s+rr,s+rr-ir,a,a,z),l+=d*_,l>=pa||u===c.length-1){l=0;let b=.028/_,p=[{x:f.x-b,y:f.y-b},{x:f.x+b,y:f.y-b},{x:f.x+b,y:f.y+b},{x:f.x-b,y:f.y+b}];Z(t,p,void 0,()=>s+rr-ir,s+ya,a,a,z)}}}}}var Um=.9,jm=1.5,Xm=.3;function ba(t,n,e){let o=[],r=[],a=Um/_,i=jm/_,s=Xm/_;for(let c of t)for(let l of c.runs){if(l.length<2)continue;let u=l.slice(),f=(x,b)=>{let p=u[x],M=u[b],P=Math.hypot(p.x-M.x,p.y-M.y)||1;u[x]={x:p.x+(p.x-M.x)/P*s,y:p.y+(p.y-M.y)/P*s}};f(0,1),f(u.length-1,u.length-2);let m=u.map((x,b)=>{let p=u[Math.max(0,b-1)],M=u[Math.min(u.length-1,b+1)],P=M.x-p.x,S=M.y-p.y,g=Math.hypot(P,S)||1,I=-S/g,A=P/g;return I*(x.x-n.x)+A*(x.y-n.y)<0&&(I=-I,A=-A),{nx:I,ny:A}}),h=u.map((x,b)=>({x:x.x-m[b].nx*i,y:x.y-m[b].ny*i})),y=u.map((x,b)=>({x:x.x+m[b].nx*a,y:x.y+m[b].ny*a})),d=u.map((x,b)=>({x:x.x+m[b].nx*(a+e/_),y:x.y+m[b].ny*(a+e/_)}));o.push([...h,...y.slice().reverse()]),r.push([...y,...d.reverse()])}return{bays:o,walls:r}}var ar=.88,lo=.27,Vm=1.2,Wm=.01,Km=7,zm=.05,Ym=.25;function ga(t,n,e,o,r){let a=[.67,.71,.68],i=[a[0]*ar,a[1]*ar,a[2]*ar],s=c=>!!r&&r.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,y=f.y-m.y,d=Math.hypot(h,y);if(d<1e-5)continue;h/=d,y/=d;let x=1/0;for(let w=0;w<e.length;w++){let L=e[w],G=e[(w+1)%e.length],k=G.x-L.x,N=G.y-L.y,U=h*N-y*k;if(Math.abs(U)<1e-8)continue;let X=L.x-f.x,F=L.y-f.y,v=(X*N-F*k)/U,j=(X*y-F*h)/U;v>0&&j>=0&&j<=1&&(x=Math.min(x,v))}let b=.3/_,p=x-.04/_;if(!Number.isFinite(x)||x*_>2||p-b<.12/_)continue;let M=!!o&&s(c),P=r?.[c]?.pitch,S=M&&P&&Number.isFinite(P)?Math.min(Vm/_,Math.max(lo/_,P-lo/_-Wm/_)):lo/_,g=-y,I=h;o&&g*(o.x-f.x)+I*(o.y-f.y)<0&&(g=-g,I=-I);let A=lo/_,R=[{x:f.x+h*b+g*A,y:f.y+y*b+I*A},{x:f.x+h*p+g*A,y:f.y+y*p+I*A},{x:f.x+h*p-g*S,y:f.y+y*p-I*S},{x:f.x+h*b-g*S,y:f.y+y*b-I*S}];if(!R.every(w=>kt(e,w.x,w.y)))continue;let B=r?.[c]?.belowY,C=B==null?0:l.y-B,T=!!o&&C>.03&&C<=.65;if(T&&o){let w=(L,G)=>Math.hypot((L.x+G.x)/2-o.x,(L.y+G.y)/2-o.y);w(R[0],R[1])>w(R[3],R[2])&&(R=[R[3],R[2],R[1],R[0]])}let O=T?Math.ceil((C-1e-8)/.2):1,E=(w,L,G)=>({x:w.x+(L.x-w.x)*G,y:w.y+(L.y-w.y)*G});for(let w=0;w<O;w++){let L=w/O,G=(w+1)/O,k=[E(R[0],R[3],L),E(R[1],R[2],L),E(R[1],R[2],G),E(R[0],R[3],G)],N=l.y+.008-(T?C*(1-G):0);if(Z(t,k,void 0,()=>N,N-(T?C/O+.1:.16),a,i,z),!T)continue;let U=Math.hypot(k[3].x-k[0].x,k[3].y-k[0].y)*_;if(U<1e-4)continue;let X=Math.min(zm/U,Ym),F=E(k[0],k[3],X),v=E(k[1],k[2],X),j=ot=>[ot.x*_,N+.004,ot.y*_],Y=[.8,.67,.3];t.setMaterial(Km),t.tri(j(k[0]),j(k[1]),j(v),[0,1,0],Y),t.tri(j(k[0]),j(v),j(F),[0,1,0],Y),t.setMaterial(0)}}}}var Zm=.02,qm=.012,$m=.01,Jm=.3,Qm=.5;function th(t,n,e){if(t.length===1)return Math.hypot(n-t[0].x,e-t[0].y);let o=1/0;for(let r=0;r+1<t.length;r++){let a=t[r],i=t[r+1],s=i.x-a.x,c=i.y-a.y,l=s*s+c*c,u=l>1e-12?((n-a.x)*s+(e-a.y)*c)/l:0;u=Math.max(0,Math.min(1,u)),o=Math.min(o,Math.hypot(n-(a.x+u*s),e-(a.y+u*c)))}return o}function nh(t,n,e,o){let r=1/0,a=Number.NaN;for(let i=0;i<t.length;i++){let s=n[i];if(Math.hypot(e-s.cx,o-s.cy)-s.rad>=r)continue;let c=th(t[i].pts,e,o);c<r&&(r=c,a=t[i].y)}return a}function Ma(t,n,e,o,r,a,i){let s=o.filter(m=>m.pts.length>0);if(s.length<2||n.length<3)return;let c=s.map(m=>{let h=0,y=0;for(let x of m.pts)h+=x.x,y+=x.y;h/=m.pts.length,y/=m.pts.length;let d=0;for(let x of m.pts)d=Math.max(d,Math.hypot(x.x-h,x.y-y));return{cx:h,cy:y,rad:d}}),l=[...n],u=e.map(m=>[...m]),f=Zm/_;for(let m of[l,...u])for(let h=0;h<m.length;h++){let y=m[h],d=m[(h+1)%m.length],x=d.x-y.x,b=d.y-y.y,p=Math.hypot(x,b);if(p*_<.05)continue;let M=(y.x+d.x)/2,P=(y.y+d.y)/2,S=b/p,g=-x/p;$t({x:M+S*f,y:P+g*f},l,u)&&(S=-S,g=-g);let I=r.x-M,A=r.y-P,R=Math.hypot(I,A)||1;if((S*I+g*A)/R>Qm)continue;let B=1/0;for(let k of[.2,.5,.8]){let N=nh(s,c,y.x+x*k-S*f*2,y.y+b*k-g*f*2);Number.isFinite(N)&&(B=Math.min(B,N))}if(!Number.isFinite(B)||B-a<Jm)continue;let C=a-$m,T=B-qm,O={x:(y.x-S*f)*_,z:(y.y-g*f)*_},E={x:(d.x-S*f)*_,z:(d.y-g*f)*_},w=[S,0,g],L=W(i,z.wallBottom),G=W(i,z.top);t.tri([O.x,T,O.z],[E.x,T,E.z],[E.x,C,E.z],w,G,G,L),t.tri([O.x,T,O.z],[E.x,C,E.z],[O.x,C,O.z],w,G,L,L)}}function Ra(t,n,e,o,r,a,i,s,c=!1){if(!n.outline||n.outline.length<3)return;let l=e.baseHeightM,u=e.objects.filter(p=>p.type==="shape"&&(p.role==="entrance"||p.role==="exit")),f=oi(o,s.tierTop);if(!r)return;let m=p=>r.deckAt(p.x,p.y),h=Mi(n,i),y=h[0]??n.outline;if(r.rowLevels.length>=2){let p=ve(r.rowLevels),M=Ri(di(r.rowLevels,e.focal,p),h),P=ba(sr(r.rowLevels,e.focal,l),e.focal,or);for(let g of M){let I=Math.max(l,g.topY-_a);for(let A of a.subtract(g.outline,I))fa(t,A,g.holes,I,l,s.tierTop,s.tierWall,u,!c,P);t.setMaterial(5),Ma(t,g.outline,g.holes,r.rowLevels,e.focal,I,s.tierWall),t.setMaterial(0)}M.length||Z(t,y,n.holes,()=>r.landingY,l,f,s.tierWall,z);let S={tread:[f[0]*z.top,f[1]*z.top,f[2]*z.top],riser:[f[0]*.72,f[1]*.72,f[2]*.72]};for(let g of h.length?h:[y])pi(t,r.rowLevels,e.focal,r.landingY,S,g,p);xa(t,r.rowLevels,e.focal,l),ga(t,r.rowLevels,n.outline,e.focal,p);return}let d=r.flat?1/0:Hi,x=p=>r.normalAt(p.x,p.y),b=r.flat?r.landingY:void 0;for(let p of a.subtract(y,b))Z(t,p,n.holes,m,l,f,s.tierWall,z,d,x)}function eh(t,n,e){let o=new Set;for(let i of t.objects)i.type==="section"&&o.add(i.id);let r=new Map;for(let i=0;i<n.length;i++){let s=e.seatOwner[i];if(!s||!o.has(s))continue;let c=e.bySection.get(s);if(c&&c.rowLevels.length>=2)continue;let l=n[i];if(l.kind==="booth")continue;let u=r.get(s);u||(u=new Map,r.set(s,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 a=[];for(let i of t.objects){if(i.type!=="section")continue;let s=e.bySection.get(i.id);if(s&&s.rowLevels.length>=2){let l=s.rowLevels.filter(u=>!u.patch).map(u=>({pts:u.pts,levelM:u.y}));l.length>=2&&a.push({sectionId:i.id,rows:l});continue}let c=r.get(i.id);c&&a.push({sectionId:i.id,rows:[...c.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return a}function oh(t,n){let e=1/0;for(let o=0;o<n.length;o++){let r=n[o],a=n[(o+1)%n.length],i=a.x-r.x,s=a.y-r.y,c=Math.max(0,Math.min(1,((t.x-r.x)*i+(t.y-r.y)*s)/(i*i+s*s||1)));e=Math.min(e,Math.hypot(t.x-r.x-c*i,t.y-r.y-c*s))}return e}var _a=.02;function rh(t,n){let e=t.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=n.bySection.get(o.id);if(!r)return[];let a=1/0,i=-1/0,s=1/0,c=-1/0;for(let u of o.outline)u.x<a&&(a=u.x),u.x>i&&(i=u.x),u.y<s&&(s=u.y),u.y>c&&(c=u.y);let l=r.landingY;for(let u of r.rowLevels)l=Math.min(l,u.y-_a);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:l,minX:a,maxX:i,minY:s,maxY:c}]});return(o,r,a)=>{let i=null;for(let s of e){if(o<s.minX-a||o>s.maxX+a||r<s.minY-a||r>s.maxY+a)continue;let c={x:o,y:r};if(!$t(c,s.outline,s.holes)&&oh(c,s.outline)>a)continue;let l=Math.min(s.surface.deckAt(o,r),s.floorTop);(i===null||l<i)&&(i=l)}return i}}var ih=3,sh=.4;function Sa(t,n,e,o,r,a,i=!0){let s=eh(n,e,o);if(s.length<ih)return;let c=Hr(s,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),ha(t,c,{bottomY:n.baseHeightM,tierFrontLevels:s.map(u=>Math.min(...u.rows.map(f=>f.levelM))),colors:{bandTop:W(r.tierTop,.8),bandWall:r.tierWall,shellTop:a??W(r.tierWall,1.15),shellWall:a??r.tierWall},ao:z,shapes:n.objects.filter(u=>u.type==="shape"),deriveShell:i&&l>=sh,standTopNear:rh(n,o)}),t.setMaterial(0)}function Ia(t){let{doc:n,units:e,seats:o,surfaces:r,solids:a,hintedSeatFloor:i,seatFloor:s}=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<a.floor.length;m+=1){let h=Math.max(0,Math.min(e.length-1,Math.round(a.floor[m]))),y=m*3,d=l[h];d.minX=Math.min(d.minX,a.position[y]),d.minY=Math.min(d.minY,a.position[y+1]),d.minZ=Math.min(d.minZ,a.position[y+2]),d.maxX=Math.max(d.maxX,a.position[y]),d.maxY=Math.max(d.maxY,a.position[y+1]),d.maxZ=Math.max(d.maxZ,a.position[y+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<o.length;m++){let h=r.seatOwner[m],y=(h!==null?u.get(h):void 0)??i[m];if(y===void 0)continue;let d=f[y],x=o[m];d.n++,x.x<d.minX&&(d.minX=x.x),x.y<d.minY&&(d.minY=x.y),x.x>d.maxX&&(d.maxX=x.x),x.y>d.maxY&&(d.maxY=x.y);let b=r.seatDeckY(m);d.sumX+=x.x*_,d.sumDeck+=b,d.sumZ+=x.y*_,d.minDeck=Math.min(d.minDeck,b),d.maxDeck=Math.max(d.maxDeck,b+1.6),s[m]=y}for(let m=0;m<e.length;m++){let h=f[m],y=n.floors?.[m],d=l[m],x=Math.min(h.n?h.minX*_:e[m].focal.x*_-1,Number.isFinite(d.minX)?d.minX:1/0),b=Math.max(h.n?h.maxX*_:e[m].focal.x*_+1,Number.isFinite(d.maxX)?d.maxX:-1/0),p=Math.min(h.n?h.minY*_:e[m].focal.y*_-1,Number.isFinite(d.minZ)?d.minZ:1/0),M=Math.max(h.n?h.maxY*_:e[m].focal.y*_+1,Number.isFinite(d.maxZ)?d.maxZ:-1/0),P=Math.min(h.n?Math.min(e[m].baseHeightM,h.minDeck):e[m].baseHeightM,Number.isFinite(d.minY)?d.minY:1/0),S=Math.max(h.n?Math.max(h.maxDeck,P+.5):P+.5,Number.isFinite(d.maxY)?d.maxY:-1/0),g=[h.n?h.sumX/h.n:(x+b)/2,h.n?h.sumDeck/h.n:(P+S)/2,h.n?h.sumZ/h.n:(p+M)/2],I=Math.max(1,.5*Math.hypot(b-x,S-P,M-p));c.push({index:m,id:y?.id??`floor-${m}`,label:y?.name??(e.length>1?`Floor ${m+1}`:"Venue"),seatCount:h.n,center:g,radius:I,box:{min:[x,P,p],max:[b,S,M]},focalWorld:[e[m].focal.x*_,e[m].baseHeightM+1.5,e[m].focal.y*_]})}}return c}function fr(t,n){let e=1/0,o=1/0,r=-1/0,a=-1/0,i=(s,c)=>{s<e&&(e=s),c<o&&(o=c),s>r&&(r=s),c>a&&(a=c)};for(let s of n)i(s.x,s.y);for(let s of t)for(let c of s.objects)if(c.type==="section")for(let l of c.outline)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=sn(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="table"){let l=to(c);if(l)for(let u of l)i(u.x,u.y)}else if(c.type==="decorImage"){let l=no(c);if(l)for(let u of l)i(u.x,u.y)}return Number.isFinite(e)||(e=-100,o=-100,r=100,a=100),{minX:e,minY:o,maxX:r,maxY:a}}function Oa(t,n,e,o,r,a){if(n.length===1){let i=e.map(f=>({x:f.x,y:f.y}));for(let f of n[0].objects)f.type==="section"?i.push(...f.outline):f.type==="shape"?i.push(...ut(f)??f.points??[]):f.type==="gaArea"?i.push(...f.points):f.type==="booth"?i.push(...sn(f)??[]):f.type==="table"?i.push(...to(f)??[]):f.type==="decorImage"&&i.push(...no(f)??[]);if(wa(t,n[0],e,a)||Ta(t,n[0],e,i,a))return!1;if(Ea(t,n[0].baseHeightM,i,a))return!0;let s=ie(i),c=(r.minX+r.maxX)/2,l=(r.minY+r.maxY)/2,u=s.length>=3?s.map(f=>{let m=f.x-c,h=f.y-l,y=Math.max(1,Math.hypot(m,h));return{x:f.x+m/y*80,y:f.y+h/y*80}}):ee(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return Z(t,u,void 0,()=>-.04,-.22,a.ground,a.ground,z),!1}else{let i=n.reduce((d,x)=>x.baseHeightM<d.baseHeightM?x:d);t.setFloor(ne);let s={...i,objects:n.flatMap(d=>d.objects)},c=e.map(d=>({x:d.x,y:d.y}));for(let d of s.objects)d.type==="section"&&c.push(...d.outline);if(wa(t,s,e,a)||Ta(t,s,e,c,a))return!1;if(Ea(t,i.baseHeightM,c,a))return!0;let l=e.filter((d,x)=>o[x]===i.index),u=fr([i],l),f=Math.hypot(u.maxX-u.minX,u.maxY-u.minY),m=Math.max(28,Math.min(80,f*.04)),h=ee(u.minX-m,u.minY-m,u.maxX-u.minX+m*2,u.maxY-u.minY+m*2),y=i.baseHeightM-.03;return Z(t,h,void 0,()=>y,y-.22,a.ground,a.ground,z),!1}}function mr(t,n,e,o){let{cx:r,cz:a,radius:i}=e,s=1/0,c=1/0,l=1/0,u=-1/0,f=-1/0,m=-1/0,h=(x,b,p)=>{s=Math.min(s,x),u=Math.max(u,x),c=Math.min(c,b),f=Math.max(f,b),l=Math.min(l,p),m=Math.max(m,p)};for(let x=0;x<t.position.length;x+=3){let b=x/3;o&&b>=o[0]&&b<o[1]||h(t.position[x],t.position[x+1],t.position[x+2])}for(let x=0;x<n.count;x++){let b=x*3,p=n.iPosition[b],M=n.iPosition[b+1],P=n.iPosition[b+2],S=Math.max(.35,n.iMaxRadius[x]??.35);h(p-S,M,P-S),h(p+S,M+1.6,P+S)}Number.isFinite(s)||(s=r-i,u=r+i,c=0,f=i*.16,l=a-i,m=a+i);let y=[(s+u)/2,(c+f)/2,(l+m)/2],d=Math.max(1,.5*Math.hypot(u-s,f-c,m-l));return{center:y,radius:d,minY:c,maxY:f}}var ah=4096;function Ca(t,n,e=[]){let o=Math.max(1,Math.ceil(t.count/ah)),r=Math.ceil(t.count/o),a=new Float32Array((r*2+n.length*4+e.length)*3),i=0;for(let s=0;s<t.count;s+=o){let c=t.iPosition[s*3],l=t.iPosition[s*3+1],u=t.iPosition[s*3+2];a[i++]=c,a[i++]=l,a[i++]=u,a[i++]=c,a[i++]=0,a[i++]=u}for(let[s,c,l]of e)a[i++]=s,a[i++]=c,a[i++]=l;for(let s of n)for(let[c,l]of[[-1,-1],[1,-1],[1,1],[-1,1]])a[i++]=s.cx+c*s.halfX,a[i++]=s.y,a[i++]=s.cz+l*s.halfZ;return a.subarray(0,i)}function ka(t,n,e,o,r,a,i=[]){let s=1/0,c=1/0,l=-1/0,u=-1/0;for(let S=0;S<t.count;S++){let g=S*3,I=t.iPosition[g],A=t.iPosition[g+2];I<s&&(s=I),I>l&&(l=I),A<c&&(c=A),A>u&&(u=A)}for(let[S,,g]of i)S<s&&(s=S),S>l&&(l=S),g<c&&(c=g),g>u&&(u=g);for(let S of n)s=Math.min(s,S.cx-S.halfX),l=Math.max(l,S.cx+S.halfX),c=Math.min(c,S.cz-S.halfZ),u=Math.max(u,S.cz+S.halfZ);let f=e.minX*_,m=e.maxX*_,h=e.minY*_,y=e.maxY*_,d=f,x=m,b=h,p=y;if(Number.isFinite(s)){let S=Math.max(2,.06*Math.hypot(l-s,u-c));d=Math.max(f,s-S),x=Math.min(m,l+S),b=Math.max(h,c-S),p=Math.min(y,u+S)}let M=Math.min(0,o),P=Math.max(r,a*.05);return{min:[d,M,b],max:[x,P,p]}}var cr=12,ch=.5,lh=6,lr=.8,Aa=5,uh=.6,fh=40,ur=0,Pa=8;function Ea(t,n,e,o){let r=ie([...e]);if(r.length<3)return!1;let a=1/0,i=1/0,s=-1/0,c=-1/0;for(let S of r)a=Math.min(a,S.x),s=Math.max(s,S.x),i=Math.min(i,S.y),c=Math.max(c,S.y);let l=Math.hypot(s-a,c-i)*_,u=Math.max(fh,l*uh),f=S=>un(r,S/_,1.2),m=f(ch),h=[m,f(lh),f(cr),f(cr+Aa),f(cr+Aa+u)];if(h.some(S=>S.length!==m.length))return!1;let y=lt(o.ground,[.78,.76,.72],.35),d=lt(o.ground,[.56,.62,.52],.3),x=[y[0]*lr,y[1]*lr,y[2]*lr],b=n-.04;t.setMaterial(ur),Z(t,m,void 0,()=>b,n-.22,x,x,z);let p=[0,1,0],M=(S,g,I,A,R)=>{let B=S.map(E=>[E.x*_,b,E.y*_]),C=g.map(E=>[E.x*_,b,E.y*_]),[T,O]=R;for(let E=0;E<B.length;E++){let w=(E+1)%B.length;t.tri(B[E],C[w],C[E],p,I,A,A,[T,O,O]),t.tri(B[E],B[w],C[w],p,I,I,A,[T,T,O])}},P=[ur,ur];return M(h[0],h[1],x,y,P),M(h[1],h[2],y,y,P),M(h[2],h[3],y,d,P),M(h[3],h[4],d,d,[Pa,Pa+1]),t.setMaterial(0),!0}function wa(t,n,e,o){let r=Rn(n,e);if(!r)return!1;let a=n.baseHeightM,i=lt(o.ground,[.62,.55,.47],.4);return Z(t,r,void 0,()=>a-.04,a-.22,i,i,z),!0}var mh=3e3,hh=20,Ba=1.5,dh=1.2,yh=.25;function Ta(t,n,e,o,r){if(!e.length||e.length>mh||o.length<3)return!1;for(let R of n.objects){if(R.type==="shape"&&Fn(R.stageKind))return!1;if(R.type==="section"){let{height:B}=Ln(R,{floorBaseHeightM:n.baseHeightM});if(B-n.baseHeightM>hh)return!1}}let a=0,i=0;for(let R of o)a+=R.x,i+=R.y;a/=o.length,i/=o.length;let s=0,c=0,l=0;for(let R of o){let B=R.x-a,C=R.y-i;s+=B*B,c+=C*C,l+=B*C}let u=.5*Math.atan2(2*l,s-c),f=Math.cos(u),m=Math.sin(u),h=-m,y=f,d=1/0,x=-1/0,b=1/0,p=-1/0;for(let R of o){let B=(R.x-a)*f+(R.y-i)*m,C=(R.x-a)*h+(R.y-i)*y;d=Math.min(d,B),x=Math.max(x,B),b=Math.min(b,C),p=Math.max(p,C)}let M=R=>[[d-R,b-R],[x+R,b-R],[x+R,p+R],[d-R,p+R]].map(([B,C])=>({x:a+f*B+h*C,y:i+m*B+y*C})),P=M(Ba/_),S=M((Ba+yh)/_),g=n.baseHeightM,I=lt(r.ground,[.62,.55,.47],.4),A=lt(r.ground,[.86,.86,.84],.55);return Z(t,S,void 0,()=>g-.04,g-.22,I,I,z),Z(t,S,[P.slice().reverse()],()=>g+dh,g-.04,lt(A,[1,1,1],.2),A,z),!0}function La(t,n,e){let o=()=>({byObjectId:new Map,elements:[]});if(!n||!t)return o();let r=Mr(n);if(!r.ok||r.value.id!==t)return o();let a=new Map;for(let f of e)for(let m of f.objects)m.type==="shape"&&a.set(m.id,{shape:m,unit:f});let i=new Set,s=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 r.value.overlay.productionElements??[]){let m=a.get(f.objectId),h=m?ut(m.shape):null,y=f.baseElevationM??0;if(!m||!h||h.length<3||!f.id||i.has(f.id)||s.has(f.objectId)||!Number.isFinite(f.heightM)||f.heightM<.05||f.heightM>50||!Number.isFinite(y)||y<-10||y>100)return o();i.add(f.id),s.add(f.objectId);let d=h.map(A=>A.x*_),x=h.map(A=>A.y*_),b=m.unit.baseHeightM+y,p=Math.min(...d),M=Math.max(...d),P=Math.min(...x),S=Math.max(...x),g,I=c.get(f.id)??f.contentImageUrl;if(f.kind==="screen"&&I&&(g=Gi(h,b,b+f.heightM,m.unit.focal),!g))if(M-p>=S-P){let A=Math.abs(P-m.unit.focal.y*_)<=Math.abs(S-m.unit.focal.y*_)?P-.006:S+.006;g=[[p,b,A],[M,b,A],[p,b+f.heightM,A],[M,b+f.heightM,A]]}else{let A=Math.abs(p-m.unit.focal.x*_)<=Math.abs(M-m.unit.focal.x*_)?p-.006:M+.006;g=[[A,b,P],[A,b,S],[A,b+f.heightM,P],[A,b+f.heightM,S]]}l.push({id:f.id,objectId:f.objectId,kind:f.kind,floorIndex:m.unit.index,baseY:b,topY:b+f.heightM,bounds:{min:[p,b,P],max:[M,b+f.heightM,S]},occlusion:f.occlusion,...I?{contentImageUrl:I}:{},...g?{contentPlane:g}:{}})}let u=l.sort((f,m)=>f.id.localeCompare(m.id));return{byObjectId:new Map(u.map(f=>[f.objectId,f])),elements:u}}var ph=[1,.87,.64],xh=[1,.96,.84],Fa=[.98,.66,.28],mn={poolEdge:{stage:.88,ring:.74},poolStrength:.6,poolLift:{stage:.02,ring:.006},lamps:{stage:8,ring:4},lampOut:.7,lampHeightM:[6,12],lampRadiusM:[.16,.28],minSpanM:3};function bh(t,n){let e=t.stageKind;if(e==="ring-boxing")return"ring";if(qt(e)||!n.length)return null;if(e==="round")return"stage";let o=ut(t);return!o||o.length<3?null:zn(Ga(o),n)?"stage":null}function gh(t,n,e,o){let r=1/0;for(let a=0;a<t.length;a++){let i=t[a],s=t[(a+1)%t.length],c=s.x-i.x,l=s.y-i.y,u=e*l-o*c;if(Math.abs(u)<1e-12)continue;let f=((i.x-n.x)*l-(i.y-n.y)*c)/u,m=((i.x-n.x)*o-(i.y-n.y)*e)/u;f>1e-9&&m>=-1e-9&&m<=1+1e-9&&(r=Math.min(r,f))}return Number.isFinite(r)?r:0}function Ga(t){return{x:t.reduce((n,e)=>n+e.x,0)/t.length,y:t.reduce((n,e)=>n+e.y,0)/t.length}}function Na(t,n,e,o,r={}){if(!r.night||!r.deck)return!1;let a=bh(n,o);if(!a)return!1;let i=ut(n);if(!i||i.length<3)return!1;let s=Ga(i);if(!kt(i,s.x,s.y))return!1;let c=28,l=[];for(let R=0;R<c;R++){let B=2*Math.PI*R/c;l.push(gh(i,s,Math.cos(B),Math.sin(B))*mn.poolEdge[a])}if(l.some(R=>!(R>0)))return!1;let u=Math.min(...l)*_;if(u*2<mn.minSpanM*mn.poolEdge[a])return!1;let f=r.deck,m=e+mn.poolLift[a],h=[0,1,0],y=(R,B)=>{let C=2*Math.PI*(R%c)/c,T=l[R%c]*B;return[(s.x+Math.cos(C)*T)*_,m,(s.y+Math.sin(C)*T)*_]},d=[s.x*_,m,s.y*_],x=R=>lt(f,ph,mn.poolStrength*R),b=[{r:.4,k:.72},{r:.72,k:.28},{r:1,k:0}];t.setMaterial(0);for(let R=0;R<c;R++){t.tri(d,y(R+1,b[0].r),y(R,b[0].r),h,x(1),x(b[0].k),x(b[0].k));for(let B=0;B+1<b.length;B++){let C=b[B],T=b[B+1];t.tri(y(R,C.r),y(R+1,T.r),y(R,T.r),h,x(C.k),x(T.k),x(T.k)),t.tri(y(R,C.r),y(R+1,C.r),y(R+1,T.r),h,x(C.k),x(C.k),x(T.k))}}let[p,M]=mn.lampHeightM,P=e+Math.max(p,Math.min(M,u*1.6)),S=Math.max(mn.lampRadiusM[0],Math.min(mn.lampRadiusM[1],u*.05)),g=[0,-1,0],I=mn.lamps[a],A=10;t.setMaterial(Kn);for(let R=0;R<I;R++){let B=2*Math.PI*(R+.5)/I,C=u*mn.lampOut,T=s.x*_+Math.cos(B)*C,O=s.y*_+Math.sin(B)*C;for(let E=0;E<A;E++){let w=2*Math.PI*E/A,L=2*Math.PI*(E+1)/A;t.tri([T,P,O],[T+Math.cos(w)*S,P,O+Math.sin(w)*S],[T+Math.cos(L)*S,P,O+Math.sin(L)*S],g,xh,Fa,Fa)}}return t.setMaterial(0),!0}function Mh(t){let n=Math.min(1,Math.max(0,t));return n<=.0031308?n*12.92:1.055*Math.pow(n,1/2.4)-.055}function Ut(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Wt(t){return Array.isArray(t)?t:[]}function Rh(t){let n=[t];for(;n.length;){let e=n.pop();if(Array.isArray(e)){n.push(...e);continue}if(!Ut(e))continue;let o=Ut(e.extensions)?e.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;n.push(...Object.values(e))}return!1}function _e(t,n){return!Array.isArray(t)||t.length!==n||!t.every(e=>typeof e=="number"&&Number.isFinite(e))?null:t}function _h(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Sh(t,n){let e=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let a=0;a<4;a++)e[o*4+r]+=t[a*4+r]*n[o*4+a];return e}function Ih(t){let n=_e(t.matrix,16);if(n)return n;if(t.matrix!==void 0)return null;let e=t.translation===void 0?[0,0,0]:_e(t.translation,3),o=t.rotation===void 0?[0,0,0,1]:_e(t.rotation,4),r=t.scale===void 0?[1,1,1]:_e(t.scale,3);if(!e||!o||!r)return null;let[a,i,s,c]=o,l=Math.hypot(a,i,s,c);if(!(l>1e-8))return null;let u=a/l,f=i/l,m=s/l,h=c/l,y=u+u,d=f+f,x=m+m,b=u*y,p=u*d,M=u*x,P=f*d,S=f*x,g=m*x,I=h*y,A=h*d,R=h*x;return[(1-(P+g))*r[0],(p+R)*r[0],(M-A)*r[0],0,(p-R)*r[1],(1-(b+g))*r[1],(S+I)*r[1],0,(M+A)*r[2],(S-I)*r[2],(1-(b+P))*r[2],0,e[0],e[1],e[2],1]}function Ah(t,n,e,o){return[t[0]*n+t[4]*e+t[8]*o+t[12],t[1]*n+t[5]*e+t[9]*o+t[13],t[2]*n+t[6]*e+t[10]*o+t[14]]}function Ph(t){let n=t[0],e=t[4],o=t[8],r=t[1],a=t[5],i=t[9],s=t[2],c=t[6],l=t[10],u=a*l-i*c,f=i*s-r*l,m=r*c-a*s,h=n*u+e*f+o*m;if(Math.abs(h)<1e-12)return null;let y=1/h;return[u*y,f*y,m*y,(o*c-e*l)*y,(n*l-o*s)*y,(e*s-n*c)*y,(e*i-o*a)*y,(o*r-n*i)*y,(n*a-e*r)*y]}function Da(t,n,e,o){let r=t[0]*n+t[1]*e+t[2]*o,a=t[3]*n+t[4]*e+t[5]*o,i=t[6]*n+t[7]*e+t[8]*o,s=Math.hypot(r,a,i)||1;return r/=s,a/=s,i/=s,[r,a,i]}function Eh(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,o=null,r=null;for(;e+8<=t.byteLength;){let a=n.getUint32(e,!0),i=n.getUint32(e+4,!0);if(e+=8,a%4!==0||e+a>t.byteLength)return null;let s=t.subarray(e,e+a);if(i===1313821514&&!o)try{let c=JSON.parse(new TextDecoder().decode(s).replace(/[\u0000 ]+$/g,""));if(!Ut(c))return null;o=c}catch{return null}else if(i===5130562&&!r)r=s;else return null;e+=a}return e===t.byteLength&&o&&r?{json:o,bin:r}:null}function wh(t){return t===5120||t===5121?1:t===5122||t===5123?2:t===5125||t===5126?4:0}function Bh(t){return t==="SCALAR"?1:t==="VEC2"?2:t==="VEC3"?3:t==="VEC4"?4:0}function Th(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 Oh(t){let n=t instanceof Uint8Array?t:new Uint8Array(t),e=Eh(n);if(!e)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=e;if(!Ut(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let a=Wt(o.extensionsUsed).filter(A=>typeof A=="string");if(a.includes("KHR_draco_mesh_compression")||Rh(o))return{ok:!1,issue:"draco_not_allowed"};if(a.length||Wt(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(Wt(o.images).length||Wt(o.textures).length)return{ok:!1,issue:"external_resource"};let i=Wt(o.buffers);if(i.length!==1||!Ut(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let s=Wt(o.accessors),c=Wt(o.bufferViews),l=Wt(o.meshes),u=Wt(o.nodes),f=Wt(o.scenes),m=typeof o.scene=="number"?o.scene:0;if(!Ut(f[m]))return{ok:!1,issue:"unsupported_glb"};let h=new DataView(r.buffer,r.byteOffset,r.byteLength),y=(A,R,B,C=!1)=>{if(typeof A!="number"||!Number.isInteger(A)||!Ut(s[A]))return null;let T=s[A],O=typeof R=="string"?T.type===R:R.includes(T.type),E=T.componentType!==5126,w=C&&E?T.normalized===!0:T.normalized!==!0;if(!O||T.sparse!==void 0||!w||typeof T.count!="number"||!Number.isInteger(T.count)||T.count<1||typeof T.componentType!="number"||!B.includes(T.componentType)||typeof T.bufferView!="number")return null;let L=c[T.bufferView];if(!Ut(L)||L.buffer!==0||typeof L.byteLength!="number"||!Number.isInteger(L.byteLength)||L.byteLength<0)return null;let G=Bh(T.type),k=wh(T.componentType),N=typeof L.byteStride=="number"?L.byteStride:G*k,U=typeof L.byteOffset=="number"?L.byteOffset:0,X=typeof T.byteOffset=="number"?T.byteOffset:0,F=U+X,v=X+(T.count-1)*N+G*k;if(!Number.isInteger(N)||!Number.isInteger(U)||!Number.isInteger(X)||N<G*k||U<0||X<0||U+L.byteLength>r.byteLength||v>L.byteLength)return null;let j=[];for(let Y=0;Y<T.count;Y++){let ot=[];for(let q=0;q<G;q++){let J=Th(h,F+Y*N+q*k,T.componentType);if(!Number.isFinite(J))return null;ot.push(J)}j.push(ot)}return j},d=[],x=[],b=[],p=!1,M=Wt(o.materials),P=A=>{if(A===void 0)return null;if(typeof A!="number"||!Number.isInteger(A)||!Ut(M[A]))return!1;let R=M[A].pbrMetallicRoughness;if(R===void 0)return null;if(!Ut(R))return!1;if(R.baseColorFactor===void 0)return null;let B=_e(R.baseColorFactor,4);return!B||B.some(C=>C<0||C>1)?!1:[B[0],B[1],B[2]]},S=0,g=new Set,I=(A,R)=>{if(typeof A!="number"||!Number.isInteger(A)||!Ut(u[A])||g.has(A))return!1;g.add(A);let B=u[A],C=Ih(B);if(!C)return!1;let T=Sh(R,C),O=Ph(T);if(!O)return!1;if(B.mesh!==void 0){if(typeof B.mesh!="number")return!1;let E=l[B.mesh];if(!Ut(E))return!1;for(let w of Wt(E.primitives)){if(!Ut(w)||w.mode!==void 0&&w.mode!==4||!Ut(w.attributes))return!1;let L=y(w.attributes.POSITION,"VEC3",[5126]),G=w.attributes.NORMAL===void 0?null:y(w.attributes.NORMAL,"VEC3",[5126]);if(!L||w.attributes.NORMAL!==void 0&&!G)return!1;let k=P(w.material);if(k===!1)return!1;let N=w.attributes.COLOR_0===void 0?null:y(w.attributes.COLOR_0,["VEC3","VEC4"],[5126,5121,5123],!0);if(w.attributes.COLOR_0!==void 0&&(!N||N.length!==L.length))return!1;let U=N?s[w.attributes.COLOR_0]:null,X=!U||U.componentType===5126?1:U.componentType===5121?1/255:1/65535,F=k!==null||N!==null;F&&(p=!0);let v=L.length;if(w.indices!==void 0){let Y=typeof w.indices=="number"?s[w.indices]:null;v=Ut(Y)?Y.count:void 0}if(typeof v!="number"||!Number.isInteger(v)||v%3!==0||(S+=v/3,S>1e5))return!1;let j=w.indices===void 0?L.map((Y,ot)=>[ot]):y(w.indices,"SCALAR",[5121,5123,5125]);if(!j||j.length%3!==0||j.length!==v)return!1;for(let Y=0;Y<j.length;Y+=3){let ot=[j[Y][0],j[Y+1][0],j[Y+2][0]];if(ot.some(rt=>!Number.isInteger(rt)||rt<0||rt>=L.length))return!1;let q=ot.map(rt=>Ah(T,...L[rt])),J=null;if(!G){let rt=q[1][0]-q[0][0],ft=q[1][1]-q[0][1],mt=q[1][2]-q[0][2],yt=q[2][0]-q[0][0],$=q[2][1]-q[0][1],K=q[2][2]-q[0][2];J=Da([1,0,0,0,1,0,0,0,1],ft*K-mt*$,mt*yt-rt*K,rt*$-ft*yt)}for(let rt=0;rt<3;rt++){if(d.push(...q[rt]),x.push(...G?Da(O,...G[ot[rt]]):J),!F){b.push(-1,-1,-1);continue}let ft=N?N[ot[rt]]:null;for(let mt=0;mt<3;mt++)b.push(Mh((k?k[mt]:1)*(ft?ft[mt]*X:1)))}}}}for(let E of Wt(B.children))if(!I(E,T))return!1;return g.delete(A),!0};for(let A of Wt(f[m].nodes))if(!I(A,_h()))return{ok:!1,issue:S>1e5?"triangle_limit":"unsupported_glb"};return!S||d.length!==S*9||x.length!==d.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:S,position:new Float32Array(d),normal:new Float32Array(x),color:p?new Float32Array(b):null}}function va(t){try{return Oh(t)}catch{return{ok:!1,issue:"invalid_glb"}}}function qb(t){let{doc:n}=t,e=gi(n,t.eventConfigurationId??n.eventConfigurationId),o=Us(n.theme,$s(e,t.seats)),r=o.structure,a=La(t.eventConfigurationId,t.eventConfiguration,e),i=t.seats,s=new Ge,c=null;if(t.registeredShellGlb){let D=va(t.registeredShellGlb);if(D.ok){let H=D.position.length/3,ct=new Float32Array(D.position.length),Bt=o.materials.shell??r.tierWall,Ot=D.color;for(let Tt=0;Tt<H;Tt++){let St=D.normal[Tt*3+1],bt=St<-.25?.4:.62+.38*Math.max(0,St),an=!!Ot&&Ot[Tt*3]!==-1;ct[Tt*3]=(an?Ot[Tt*3]:Bt[0])*bt,ct[Tt*3+1]=(an?Ot[Tt*3+1]:Bt[1])*bt,ct[Tt*3+2]=(an?Ot[Tt*3+2]:Bt[2])*bt}c={position:D.position,normal:D.normal,color:ct,floor:new Float32Array(H).fill(ne),material:new Float32Array(H),count:H}}}let l=new Map;for(let D of e)for(let H of D.objects)l.set(H.id,D.index),H.type==="section"&&l.set(H.logicalSectionId??H.id,D.index);let u=i.map(D=>l.get(D.sectionId??"")??l.get(D.rowId??"")??0),f=fr(e,i),m=s.vertexCount,y=Oa(s,e,i,u,f,r)?s.vertexCount:m,d=ri(n,i),x=new Map,b=new Map;for(let D of n.categories??[])x.set(D.key,D.color),D.seatGlyph&&b.set(D.key,D.seatGlyph);let p=[],M=Ui(e,i,u),P=new Map;i.forEach((D,H)=>{let ct=M.seatDeckY(H);Number.isFinite(ct)&&P.set(D.rowId,Math.min(P.get(D.rowId)??1/0,ct))});let S=new Float32Array(i.length),g=[],I=[],A=new Map((n.floors??[]).map((D,H)=>[D.id,H])),R=e.map(()=>[]);for(let D of i){let H=D.floorId?A.get(D.floorId)??0:0;R[Math.min(H,R.length-1)]?.push(D)}let B=(D,H)=>{if(!H||H.length<3)return!1;let ct=Math.min(...H.map(St=>St.x)),Bt=Math.max(...H.map(St=>St.x)),Ot=Math.min(...H.map(St=>St.y)),Tt=Math.max(...H.map(St=>St.y));for(let St=0;St<D;St++)for(let bt of R[St])if(!(bt.x<ct||bt.x>Bt||bt.y<Ot||bt.y>Tt)&&$t(bt,H,void 0))return!0;return!1},C=eo(e),T=null,O=-1/0;i.forEach((D,H)=>{let ct=M.seatDeckY(H);Number.isFinite(ct)&&ct>O&&(O=ct)});let E=!1,w=D=>e.length===1?i:i.filter((H,ct)=>u[ct]===D),L=(D,H)=>{let ct=sn(D);if(!ct)return!1;let Bt=1/0,Ot=1/0,Tt=-1/0,St=-1/0;for(let bt of ct)Bt=Math.min(Bt,bt.x),Tt=Math.max(Tt,bt.x),Ot=Math.min(Ot,bt.y),St=Math.max(St,bt.y);return i.some((bt,an)=>bt.kind!=="booth"&&(e.length===1||u[an]===H)&&bt.x>Bt&&bt.x<Tt&&bt.y>Ot&&bt.y<St&&kt(ct,bt.x,bt.y))},G,k=[],N;for(let D=0;D<e.length;D++){let H=e[D];s.setFloor(D);let ct=Rn(H,w(D)),Bt=0;if(ct){let nt=0;for(let It of H.objects)if(It.type==="section")for(let V of M.bySection.get(It.id)?.rowLevels??[])nt=Math.max(nt,V.y-H.baseHeightM);Bt=Ai(nt);for(let It of ct)k.push([It.x*_,It.y*_]);if(N=Math.max(N??-1/0,H.baseHeightM+Bt),!G){let It=Hn(ct);G={centre:[It.x*_,It.y*_]}}}let Ot=new He,Tt=[],St=H.objects.filter(nt=>nt.type==="shape"&&(nt.role==="entrance"||nt.role==="exit")),bt=H.objects.filter(nt=>nt.type==="section"&&!!nt.outline&&nt.outline.length>=3),an=la(H.objects.filter(nt=>nt.type==="booth"),H.focal);for(let nt of H.objects)if(nt.type==="section"){let It=s.vertexCount;Ra(s,nt,H,ii(nt,d),M.bySection.get(nt.id),Ot,bt,r,D>0&&B(D,nt.outline));let V=s.vertexCount-It;V>0&&g.push({sectionId:nt.id,start:It,count:V})}else if(nt.type==="shape"){let It=a.byObjectId.get(nt.id);if(C.has(nt)&&!It)continue;let V=p.length,it=ct!==null&&nt.role==="wall"&&!It;s.setMaterial(it?Ue:(It?.kind??nt.role)==="screen"?1:0);let et=nt.role==="stage"&&!It?ua(nt,w(D)):it&&nt.heightM===void 0?{...nt,heightM:Bt}:nt,pt=Si(et,Tt),Mt=e.length>1&&nt.role==="stage";if(Mt&&s.setFloor(ne),gs(s,et,H.baseHeightM+pt.supportOffsetM,pt.topOffsetM-pt.supportOffsetM,r,H.focal,p,It,St),s.setMaterial(0),nt.role==="stage"&&!It&&p.length>V&&(T??D)===D){T=D;let At=n.floors?.[D]?.id,Pt=e.length>1&&At?i.filter(Dt=>Dt.floorId===At):i,vt=qs(s,et,p[p.length-1].y,Pt,{deck:p[p.length-1].top,night:!gn(r),theatre:{maxTopY:ct?H.baseHeightM+Bt:Math.max((e[0]?.baseHeightM??0)+8,O+5)}});vt==="theatre"&&(E=!0),vt===null&&Na(s,et,p[p.length-1].y,Pt,{deck:p[p.length-1].top,night:!gn(r)});let Nt=qt(et.stageKind)?ut(et):null;Nt&&fs(s,et,Nt,p[p.length-1].y,Pt,H.objects.some(Dt=>Dt.type==="shape"&&Dt.role==="goal"),H.objects.some(Dt=>Dt.type==="shape"&&Dt.role==="dugout")),Nt&&Ee(et.stageKind)&&Js(s,Nt,p[p.length-1].y,Pt,$e),s.setMaterial(0)}Mt&&s.setFloor(D)}else if(nt.type==="gaArea"){let It=s.vertexCount;Rs(s,nt,H.baseHeightM,ht(x.get(nt.categoryKey)),r);let V=s.vertexCount-It;V>0&&I.push({sectionId:nt.id,start:It,count:V})}else nt.type==="booth"?ps(s,nt,H.baseHeightM,ht(x.get(nt.categoryKey)),r,an.get(nt.id)??H.focal,L(nt,D)):nt.type==="table"?bs(s,nt,Math.max(H.baseHeightM,P.get(nt.id)??H.baseHeightM),ht(nt.fill??n.theme?.decorFill??"#232c40"),r,!!(nt.fill??n.theme?.decorFill)):nt.type==="decorImage"&&Ms(s,nt,H.baseHeightM,r);ct&&As(s,H.objects,ct,H.baseHeightM,Bt,H.focal,r,nt=>!a.byObjectId.has(nt.id)),Sa(s,H,i,M,r,o.materials.shell,!c)}let U=e.length>1?{x:e.reduce((D,H)=>D+H.focal.x,0)/e.length,y:e.reduce((D,H)=>D+H.focal.y,0)/e.length}:n.focalPoint??{x:(f.minX+f.maxX)/2,y:(f.minY+f.maxY)/2},X=Yr(c?[s.build(),c]:[s.build()]),F=new Map;for(let D of e)for(let H of D.objects)H.type==="table"&&F.set(H.id,H.center);let v=ti(i,t.initialState,M,S,x,b,new Set(F.keys())),j=Os({doc:n,units:e,seats:i,surfaces:M,focal:U}),{labels:Y,sections:ot,rows:q}=Cs({doc:n,units:e,seats:i,surfaces:M,seatData:v,hintedSeatFloor:u,zones:j,focal:U}),J=new Map(ot.map((D,H)=>[D.id,H]));M.seatOwner.forEach((D,H)=>{v.iSection[H]=D?J.get(D)??-1:-1});let rt=Ia({doc:n,units:e,seats:i,surfaces:M,solids:X,hintedSeatFloor:u,seatFloor:S});ks(Y,rt),v.iYaw=Jr(v.iPosition,i.length,D=>i[D].rowId,D=>{let H=e[S[D]]?.focal??U;return[H.x*_,H.y*_]},D=>{let H=F.get(i[D].rowId);return H?[H.x*_,H.y*_]:void 0});let ft=!!n.focalPoint||e.some(D=>D.objects.some(H=>H.type==="shape"&&H.role==="stage")),mt=e.flatMap((D,H)=>D.objects.flatMap(ct=>ct.type==="gaArea"&&ct.points?.length>=3?[{points:ct.points,holes:ct.holes,capacity:ct.capacity,floorY:D.baseHeightM+ye,floorIndex:H,focal:ft?D.focal:null}]:[])),yt=e.flatMap(D=>D.objects.flatMap(H=>H.type==="gaArea"&&H.points?.length>=3?[{id:H.id,points:H.points,...H.holes?.length?{holes:H.holes}:{},floorY:D.baseHeightM+ye,floorIndex:D.index}]:[])),$=mt.length?aa(mt,i.flatMap((D,H)=>D.kind==="booth"||F.has(D.rowId)?[]:[{x:D.x,y:D.y,deckY:M.seatDeckY(H),floorIndex:e.length>1?u[H]:0}]),Math.min(t.crowdFigures??Number.POSITIVE_INFINITY,ra(i.length,t.crowdSeatCeiling??ia()))):null,K=(f.minX+f.maxX)/2*_,Q=(f.minY+f.maxY)/2*_,tt=.5*Math.hypot((f.maxX-f.minX)*_,(f.maxY-f.minY)*_)||10,at=mr(X,v,{cx:K,cz:Q,radius:tt},[m,y]),xt=mr(X,v,{cx:K,cz:Q,radius:tt}),gt=Fh(e),_t=ka(v,p,f,at.minY,at.maxY,tt,gt),Ft=!G&&e.some(D=>D.objects.some(H=>H.type==="shape"&&Fn(H.stageKind))),wt=!!o.house&&!Ft&&!c&&(!!G||o.house.indoor),Yt=p.flatMap(D=>[[D.cx-D.halfX,D.cz-D.halfZ],[D.cx+D.halfX,D.cz-D.halfZ],[D.cx+D.halfX,D.cz+D.halfZ],[D.cx-D.halfX,D.cz+D.halfZ]]),Ct=wt?Qs(v.iPosition,i.length,e[0]?.baseHeightM??0,[...Yt,...k],N):null;return{sharedAisles:Ls(e.flatMap(D=>D.objects.flatMap(H=>{if(H.type!=="section")return[];let ct=M.bySection.get(H.id);return ct?[{sectionId:H.id,floorIndex:D.index,rows:ct.rowLevels}]:[]}))),solids:X,sectionSolidRanges:g,seats:v,...$?{crowd:$}:{},...yt.length?{areas:yt}:{},...I.length?{areaSolidRanges:I}:{},seatSectionIds:M.seatOwner,bounds:{center:[(_t.min[0]+_t.max[0])/2,(_t.min[1]+_t.max[1])/2,(_t.min[2]+_t.max[2])/2],radius:tt,groundY:0,box:_t,fitPoints:Ca(v,p,gt)},...G?{room:G}:{},...Ft?{outdoor:!0}:{},...Ct?{house:E?{...Ct,theatre:!0}:Ct}:{},renderBounds:{center:at.center,radius:at.radius},clipBounds:{center:xt.center,radius:xt.radius},stateColorLUT:js(o,Jn),theme:o,seatCount:i.length,focalWorld:[U.x*_,1.5,U.y*_],zones:j,stages:p,productionElements:a.elements,sections:ot,rows:q,labels:Y,floors:rt}}function Fh(t){let n=[];for(let e of t)for(let o of e.objects){let r=o.type==="gaArea"?o.points:o.type==="booth"?sn(o):null;for(let a of r??[])n.push([a.x*_,e.baseHeightM,a.y*_])}return n}function Gh(t,n){let{doc:e,report:o}=Fi(t),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let c=new Map(o.roles.map(h=>[h.id,h.role])),l=h=>h.map(y=>y.type==="shape"&&c.has(y.id)?{...y,role:c.get(y.id)}:y),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,y)=>{h.eyeHeightM!==void 0&&(f[y]=h.eyeHeightM),h.focalPoint&&(m[y*2]=h.focalPoint.x,m[y*2+1]=h.focalPoint.y)}),{doc:{...t,objects:u?.[0]?.objects??l(t.objects),...u?{floors:u}:{}},report:o,eyeHeightM:f,focal:m}}let a=new Map(we(e).map(c=>[c.id,c])),i=new Float64Array(n.length).fill(Number.NaN),s=new Float64Array(n.length*2).fill(Number.NaN);return n.forEach((c,l)=>{let u=a.get(c.id)??c;u.eyeHeightM!==void 0&&(i[l]=u.eyeHeightM),u.focalPoint&&(s[l*2]=u.focalPoint.x,s[l*2+1]=u.focalPoint.y)}),{doc:e,report:o,eyeHeightM:i,focal:s}}function Nh(t,n){return t.map((e,o)=>{let r=n.eyeHeightM[o],a=n.focal[o*2],i=n.focal[o*2+1],s={...e};return Number.isNaN(r)?delete s.eyeHeightM:s.eyeHeightM=r,Number.isNaN(a)?delete s.focalPoint:s.focalPoint={x:a,y:i},s})}function tg(t){let n=t.estimate===!1?null:Gh(t.doc,t.seats);return n?{input:{...t,doc:n.doc,seats:Nh(t.seats,n)},estimate:n}:{input:t}}export{Zh as a,rc as b,ic as c,sc as d,qh as e,$h as f,Jh as g,Qh as h,t0 as i,n0 as j,e0 as k,o0 as l,r0 as m,i0 as n,s0 as o,Zr as p,a0 as q,Jn as r,xo as s,gn as t,Uh as u,go as v,_ as w,De as x,p0 as y,x0 as z,rp as A,gi as B,Qe as C,sn as D,ia as E,bm as F,Fi as G,cd as H,ld as I,ud as J,fd as K,md as L,hd as M,Co as N,dd as O,yd as P,pd as Q,xd as R,bd as S,Mf as T,qb as U,Gh as V,Nh as W,tg as X};
@@ -1 +1 @@
1
- import{k as u,l as d}from"./chunk-URW7MSCJ.js";import{Pa as p,Ta as y,ab as s}from"./chunk-3V32MDJI.js";var x=e=>Math.round(e*1e6)/1e6+0;function _(e){let o=e.map(r=>({x:x(r.x),y:x(r.y)})).sort((r,i)=>r.x-i.x||r.y-i.y).filter((r,i,a)=>i===0||r.x!==a[i-1].x||r.y!==a[i-1].y);if(o.length<3)return o;let t=(r,i,a)=>{let f=i.x-r.x,c=i.y-r.y,b=a.x-r.x,m=a.y-r.y;return f*m-c*b>1e-6*Math.hypot(f,c)*Math.hypot(b,m)},n=r=>{let i=[];for(let a of r){for(;i.length>=2&&!t(i[i.length-2],i[i.length-1],a);)i.pop();i.push(a)}return i.pop(),i};return[...n(o),...n([...o].reverse())]}function w(e,o){if(!e.length)return e;let t={x:e.reduce((n,r)=>n+r.x,0)/e.length,y:e.reduce((n,r)=>n+r.y,0)/e.length};return e.map(n=>{let r=n.x-t.x,i=n.y-t.y,a=Math.hypot(r,i)||1;return{x:n.x+r/a*o,y:n.y+i/a*o}})}var l=class extends Error{constructor(t,n,r={}){super(n);this.code=t;this.details=r;this.name="ChartOperationError"}};function M(e,o){let t=s(e),n=o?t.find(r=>r.id===o):t[0];if(!n)throw new l("floor_not_found",`Unknown chart floor: ${o}`,{floorId:o});return{floorId:n.id,objects:n.objects}}function E(e,o){if(!e.categories.some(t=>t.key===o))throw new l("category_not_found",`Unknown chart category: ${o}. Call get_chart to list valid category keys.`,{categoryKey:o})}function L(e,o,t,n){let r=new Set([...n,...e.categories.map(i=>i.key),...e.zones?.map(i=>i.id)??[],...e.floors?.map(i=>i.id)??[],...e.floors?.length?e.floors.flatMap(i=>i.objects.map(a=>a.id)):e.objects.map(i=>i.id)]);for(let i=0;i<100;i++){let a=t(o);if(a&&!r.has(a))return n.add(a),a}throw new l("id_generation_failed",`Unable to allocate a unique ${o} id`)}function $(e){let o=[];for(let n of e)n.type==="row"?o.push(...p(n).map(r=>({x:r.x,y:r.y}))):n.type==="table"?o.push(...y(n).map(r=>({x:r.x,y:r.y}))):n.type==="gaArea"?o.push(...n.points):n.type==="booth"&&o.push(n.center);if(o.length<3)return null;let t=w(_(o),22);return t.length>=3?t:null}function T(e,o){let t=M(e,o),n=s(e).find(r=>r.id===t.floorId);return{...e,objects:t.objects,floors:void 0,focalPoint:n.focalPoint,referenceImage:n.referenceImage,backgroundImage:n.backgroundImage}}var I=24,P=80;function F(e,o){let t=e.normalize("NFKC").trim();if(t.length>I)throw new l("invalid_operation",`${o} displayed type must be at most ${I} characters`);return t}function k(e,o){if(e.displayType===void 0)return!1;let t=F(e.displayType,o);return t?(e.displayType=t,!1):(delete e.displayType,!0)}function N(e,o){if(e.displayLabel===void 0)return!1;let t=e.displayLabel.normalize("NFKC").trim();if(t.length>P)throw new l("invalid_operation",`${o} displayed label must be at most ${P} characters`);return t?(e.displayLabel=t,!1):(delete e.displayLabel,!0)}function h(e,o){let t=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(t))throw new l("invalid_operation",`${o} must use a six-digit hex color`);return t}function C(e,o){if(!Number.isFinite(e)||e<u||e>d)throw new l("invalid_operation",`${o} label size must be from ${u} to ${d}`)}function U(e,o){e.size!==void 0&&e.size!==null&&C(e.size,o),e.color!==void 0&&e.color!==null&&h(e.color,`${o} label color`)}function R(e,o){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new l("invalid_operation",`${o} label positionPreset must be one of start, end, both, none`);let t=e?.labelStyle;t&&(t.size!==void 0&&C(t.size,o),t.color!==void 0&&h(t.color,`${o} label color`))}function B(e,o){let t=e?structuredClone(e):{},n=t.labelStyle?{...t.labelStyle}:{};return o.size===null?delete n.size:o.size!==void 0&&(n.size=o.size),o.color===null?delete n.color:o.color!==void 0&&(n.color=h(o.color,"Label color")),n.size===void 0&&n.color===void 0?delete t.labelStyle:t.labelStyle=n,o.visible!==void 0&&(t.visible=o.visible),Object.keys(t).length?t:void 0}function G(e,o,t){let n=o.normalize("NFKC").trim();if(!n||n.length>80)throw new l("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.zones??[]).some(r=>r.id!==t&&r.label.normalize("NFKC").trim().toLocaleLowerCase("en")===n.toLocaleLowerCase("en")))throw new l("invalid_operation",`Zone label already exists: ${n}`);return n}function Z(e,o){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new l("invalid_operation",`${o} must contain finite x and y values`);return{x:e.x,y:e.y}}function K(e,o,t){return(o.x-e.x)*(t.y-e.y)-(o.y-e.y)*(t.x-e.x)}var Y=Math.PI/180,X=Math.PI/180;function q(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function S(e){if(e.floors?.length){let o=e.floors[0];e.objects=o.objects,e.focalPoint=o.focalPoint,e.referenceImage=o.referenceImage,e.backgroundImage=o.backgroundImage}return e}var H=0,g=120,v=4;function j(e){if(!Number.isFinite(e)||e<H||e>g)throw new l("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function Q(e,o){let t=s(e);if(t.length>=5)throw new l("invalid_operation","A chart can contain at most five physical floors");let n=(o.name??String(t.length+1)).normalize("NFKC").trim();if(!n||n.length>80)throw new l("invalid_operation","Floor names must contain 1 to 80 characters");if(t.some(c=>c.name.toLocaleLowerCase("en")===n.toLocaleLowerCase("en")))throw new l("invalid_operation",`Floor name already exists: ${n}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let i=e.floors[e.floors.length-1].baseHeightM??Math.min(g,(e.floors.length-1)*v),a=Math.min(g,i+v),f=L(e,"floor",o.idFactory,new Set);return e.floors.push({id:f,name:n,baseHeightM:a,objects:[],focalPoint:{...e.focalPoint}}),S(e),{changed:!0,floorId:f,floorCount:e.floors.length,baseHeightM:a}}function ee(e,o){let t=s(e),n=t.find(a=>a.id===o.floorId);if(!n)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});let r=o.name.normalize("NFKC").trim();if(!r||r.length>80)throw new l("invalid_operation","Floor names must contain 1 to 80 characters");if(t.some(a=>a.id!==n.id&&a.name.toLocaleLowerCase("en")===r.toLocaleLowerCase("en")))throw new l("invalid_operation",`Floor name already exists: ${r}`);let i=n.name!==r;return i&&(n.name=r),{changed:i,floorId:n.id,floorName:r}}function oe(e,o){if(!e.floors?.length)throw new l("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let t=e.floors.find(r=>r.id===o.floorId);if(!t)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});j(o.baseHeightM);let n=t.baseHeightM!==o.baseHeightM;return n&&(t.baseHeightM=o.baseHeightM,t.physical3dProvenance={...t.physical3dProvenance,baseHeightM:{status:"confirmed",source:"user-review",note:"Physical floor height reviewed through the shared Designer/Copilot operation."}}),{changed:n,floorId:t.id,baseHeightM:o.baseHeightM}}function te(e,o){if(!e.floors?.length)throw new l("invalid_operation","A single-floor chart cannot remove its only floor");let t=e.floors.findIndex(r=>r.id===o.floorId);if(t<0)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});let[n]=e.floors.splice(t,1);if(e.floors.length===1){let[r]=e.floors;e.objects=r.objects,e.focalPoint=r.focalPoint,e.referenceImage=r.referenceImage,e.backgroundImage=r.backgroundImage,e.floors=void 0}else S(e);return{changed:!0,floorId:n.id,removedObjects:n.objects.length,floorCount:s(e).length}}export{_ as a,l as b,M as c,E as d,L as e,$ as f,T as g,F as h,k as i,N as j,h as k,U as l,R as m,B as n,G as o,Z as p,K as q,Y as r,X as s,q as t,S as u,g as v,v as w,Q as x,ee as y,oe as z,te as A};
1
+ import{k as u,l as d}from"./chunk-URW7MSCJ.js";import{Ra as p,Va as y,cb as s}from"./chunk-BXQQKDIX.js";var x=e=>Math.round(e*1e6)/1e6+0;function _(e){let o=e.map(r=>({x:x(r.x),y:x(r.y)})).sort((r,i)=>r.x-i.x||r.y-i.y).filter((r,i,a)=>i===0||r.x!==a[i-1].x||r.y!==a[i-1].y);if(o.length<3)return o;let t=(r,i,a)=>{let f=i.x-r.x,c=i.y-r.y,b=a.x-r.x,m=a.y-r.y;return f*m-c*b>1e-6*Math.hypot(f,c)*Math.hypot(b,m)},n=r=>{let i=[];for(let a of r){for(;i.length>=2&&!t(i[i.length-2],i[i.length-1],a);)i.pop();i.push(a)}return i.pop(),i};return[...n(o),...n([...o].reverse())]}function w(e,o){if(!e.length)return e;let t={x:e.reduce((n,r)=>n+r.x,0)/e.length,y:e.reduce((n,r)=>n+r.y,0)/e.length};return e.map(n=>{let r=n.x-t.x,i=n.y-t.y,a=Math.hypot(r,i)||1;return{x:n.x+r/a*o,y:n.y+i/a*o}})}var l=class extends Error{constructor(t,n,r={}){super(n);this.code=t;this.details=r;this.name="ChartOperationError"}};function M(e,o){let t=s(e),n=o?t.find(r=>r.id===o):t[0];if(!n)throw new l("floor_not_found",`Unknown chart floor: ${o}`,{floorId:o});return{floorId:n.id,objects:n.objects}}function E(e,o){if(!e.categories.some(t=>t.key===o))throw new l("category_not_found",`Unknown chart category: ${o}. Call get_chart to list valid category keys.`,{categoryKey:o})}function L(e,o,t,n){let r=new Set([...n,...e.categories.map(i=>i.key),...e.zones?.map(i=>i.id)??[],...e.floors?.map(i=>i.id)??[],...e.floors?.length?e.floors.flatMap(i=>i.objects.map(a=>a.id)):e.objects.map(i=>i.id)]);for(let i=0;i<100;i++){let a=t(o);if(a&&!r.has(a))return n.add(a),a}throw new l("id_generation_failed",`Unable to allocate a unique ${o} id`)}function $(e){let o=[];for(let n of e)n.type==="row"?o.push(...p(n).map(r=>({x:r.x,y:r.y}))):n.type==="table"?o.push(...y(n).map(r=>({x:r.x,y:r.y}))):n.type==="gaArea"?o.push(...n.points):n.type==="booth"&&o.push(n.center);if(o.length<3)return null;let t=w(_(o),22);return t.length>=3?t:null}function T(e,o){let t=M(e,o),n=s(e).find(r=>r.id===t.floorId);return{...e,objects:t.objects,floors:void 0,focalPoint:n.focalPoint,referenceImage:n.referenceImage,backgroundImage:n.backgroundImage}}var I=24,P=80;function F(e,o){let t=e.normalize("NFKC").trim();if(t.length>I)throw new l("invalid_operation",`${o} displayed type must be at most ${I} characters`);return t}function k(e,o){if(e.displayType===void 0)return!1;let t=F(e.displayType,o);return t?(e.displayType=t,!1):(delete e.displayType,!0)}function N(e,o){if(e.displayLabel===void 0)return!1;let t=e.displayLabel.normalize("NFKC").trim();if(t.length>P)throw new l("invalid_operation",`${o} displayed label must be at most ${P} characters`);return t?(e.displayLabel=t,!1):(delete e.displayLabel,!0)}function h(e,o){let t=e.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(t))throw new l("invalid_operation",`${o} must use a six-digit hex color`);return t}function C(e,o){if(!Number.isFinite(e)||e<u||e>d)throw new l("invalid_operation",`${o} label size must be from ${u} to ${d}`)}function U(e,o){e.size!==void 0&&e.size!==null&&C(e.size,o),e.color!==void 0&&e.color!==null&&h(e.color,`${o} label color`)}function R(e,o){if(e?.positionPreset!==void 0&&!["start","end","both","none"].includes(e.positionPreset))throw new l("invalid_operation",`${o} label positionPreset must be one of start, end, both, none`);let t=e?.labelStyle;t&&(t.size!==void 0&&C(t.size,o),t.color!==void 0&&h(t.color,`${o} label color`))}function B(e,o){let t=e?structuredClone(e):{},n=t.labelStyle?{...t.labelStyle}:{};return o.size===null?delete n.size:o.size!==void 0&&(n.size=o.size),o.color===null?delete n.color:o.color!==void 0&&(n.color=h(o.color,"Label color")),n.size===void 0&&n.color===void 0?delete t.labelStyle:t.labelStyle=n,o.visible!==void 0&&(t.visible=o.visible),Object.keys(t).length?t:void 0}function G(e,o,t){let n=o.normalize("NFKC").trim();if(!n||n.length>80)throw new l("invalid_operation","Zone labels must contain 1 to 80 characters");if((e.zones??[]).some(r=>r.id!==t&&r.label.normalize("NFKC").trim().toLocaleLowerCase("en")===n.toLocaleLowerCase("en")))throw new l("invalid_operation",`Zone label already exists: ${n}`);return n}function Z(e,o){if(!Number.isFinite(e?.x)||!Number.isFinite(e?.y))throw new l("invalid_operation",`${o} must contain finite x and y values`);return{x:e.x,y:e.y}}function K(e,o,t){return(o.x-e.x)*(t.y-e.y)-(o.y-e.y)*(t.x-e.x)}var Y=Math.PI/180,X=Math.PI/180;function q(e){return e.type==="row"||e.type==="table"?e.seatCount:e.type==="gaArea"?Math.max(0,Math.floor(e.capacity)):e.type==="booth"?1:0}function S(e){if(e.floors?.length){let o=e.floors[0];e.objects=o.objects,e.focalPoint=o.focalPoint,e.referenceImage=o.referenceImage,e.backgroundImage=o.backgroundImage}return e}var H=0,g=120,v=4;function j(e){if(!Number.isFinite(e)||e<H||e>g)throw new l("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function Q(e,o){let t=s(e);if(t.length>=5)throw new l("invalid_operation","A chart can contain at most five physical floors");let n=(o.name??String(t.length+1)).normalize("NFKC").trim();if(!n||n.length>80)throw new l("invalid_operation","Floor names must contain 1 to 80 characters");if(t.some(c=>c.name.toLocaleLowerCase("en")===n.toLocaleLowerCase("en")))throw new l("invalid_operation",`Floor name already exists: ${n}`);e.floors?.length||(e.floors=[{id:"floor-0",name:"1",objects:e.objects,baseHeightM:0,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]);let i=e.floors[e.floors.length-1].baseHeightM??Math.min(g,(e.floors.length-1)*v),a=Math.min(g,i+v),f=L(e,"floor",o.idFactory,new Set);return e.floors.push({id:f,name:n,baseHeightM:a,objects:[],focalPoint:{...e.focalPoint}}),S(e),{changed:!0,floorId:f,floorCount:e.floors.length,baseHeightM:a}}function ee(e,o){let t=s(e),n=t.find(a=>a.id===o.floorId);if(!n)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});let r=o.name.normalize("NFKC").trim();if(!r||r.length>80)throw new l("invalid_operation","Floor names must contain 1 to 80 characters");if(t.some(a=>a.id!==n.id&&a.name.toLocaleLowerCase("en")===r.toLocaleLowerCase("en")))throw new l("invalid_operation",`Floor name already exists: ${r}`);let i=n.name!==r;return i&&(n.name=r),{changed:i,floorId:n.id,floorName:r}}function oe(e,o){if(!e.floors?.length)throw new l("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let t=e.floors.find(r=>r.id===o.floorId);if(!t)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});j(o.baseHeightM);let n=t.baseHeightM!==o.baseHeightM;return n&&(t.baseHeightM=o.baseHeightM,t.physical3dProvenance={...t.physical3dProvenance,baseHeightM:{status:"confirmed",source:"user-review",note:"Physical floor height reviewed through the shared Designer/Copilot operation."}}),{changed:n,floorId:t.id,baseHeightM:o.baseHeightM}}function te(e,o){if(!e.floors?.length)throw new l("invalid_operation","A single-floor chart cannot remove its only floor");let t=e.floors.findIndex(r=>r.id===o.floorId);if(t<0)throw new l("floor_not_found",`Unknown chart floor: ${o.floorId}`,{floorId:o.floorId});let[n]=e.floors.splice(t,1);if(e.floors.length===1){let[r]=e.floors;e.objects=r.objects,e.focalPoint=r.focalPoint,e.referenceImage=r.referenceImage,e.backgroundImage=r.backgroundImage,e.floors=void 0}else S(e);return{changed:!0,floorId:n.id,removedObjects:n.objects.length,floorCount:s(e).length}}export{_ as a,l as b,M as c,E as d,L as e,$ as f,T as g,F as h,k as i,N as j,h as k,U as l,R as m,B as n,G as o,Z as p,K as q,Y as r,X as s,q as t,S as u,g as v,v as w,Q as x,ee as y,oe as z,te as A};
@@ -1 +1 @@
1
- import{m as S}from"./chunk-URW7MSCJ.js";import{N as f,ab as A,ja as w}from"./chunk-3V32MDJI.js";var j=36,x=160;function v(e,t=360){let o=f(Math.round(Number.isFinite(e)?e:1),1,40),s=f(Number.isFinite(t)?t:360,120,360);return Math.round(f(o*4*(360/s),j,x))}function l(e){return typeof e=="string"&&S.includes(e)}function b(e,t){return e&&t?"both":e?"start":t?"end":"none"}function g(e){let t=new Map,o=w(e);if(!o.size)return t;let s=new Map;for(let r of e){if(r.type!=="row"||!o.has(r.id))continue;let i=r.segmentedRow.groupId,a=s.get(i)??[];a.push(r),s.set(i,a)}for(let r of s.values())r.sort((i,a)=>i.segmentedRow.componentIndex-a.segmentedRow.componentIndex),r.forEach((i,a)=>{let c=r[a+1];t.set(i.id,{start:a>0&&i.segmentedRow.boundaryBefore==="continuous",end:!!c&&c.segmentedRow.boundaryBefore==="continuous"})});return t}function h(e,t){let o=Number.isInteger(e.seatCount)&&e.seatCount>0?e.seatCount:0,s=new Set;for(let n of e.overrides??[])n.skip&&s.add(n.index);let r=n=>n>=0&&n<o&&!s.has(n),i=b(!t?.start,!t?.end),a=l(e.aisleSeats)?e.aisleSeats:void 0;if(!a)return{automatic:i,slots:[]};let c=a,d=-1,m=-1;for(let n=0;n<o;n+=1)r(n)&&(d<0&&(d=n),m=n);let u=new Set;if(d>=0){(c==="start"||c==="both")&&u.add(d),(c==="end"||c==="both")&&u.add(m);for(let n of s)r(n-1)&&u.add(n-1),r(n+1)&&u.add(n+1)}return{override:a,automatic:i,slots:[...u].sort((n,O)=>n-O)}}function D(e,t=[e]){return h(e,e.segmentedRow?g(t).get(e.id):void 0)}function I(e){let t=new Set;for(let o of A(e)){let s=g(o.objects);for(let r of o.objects)if(r.type==="row")for(let i of h(r,s.get(r.id)).slots)t.add(`${r.id}:${i}`)}return t}function E(e,t,o){return I(e).has(`${t}:${o}`)}function R(e){let t=l(e.aisleSeats)?e.aisleSeats:"none";return{start:t==="start"||t==="both",end:t==="end"||t==="both"}}function p(e,t){e.aisleSeats=t}function N(e,t,o){if(!l(e.aisleSeats)){delete t.aisleSeats,delete o.aisleSeats;return}let s=R(e);p(t,b(s.start,!0)),p(o,b(!0,s.end))}function U(e,t){let o=e[0],s=e[e.length-1];if(!o||!s||!l(o.aisleSeats)&&!l(s.aisleSeats)){delete t.aisleSeats;return}p(t,b(R(o).start,R(s).end))}export{j as a,x as b,v as c,l as d,D as e,I as f,E as g,N as h,U as i};
1
+ import{m as S}from"./chunk-URW7MSCJ.js";import{N as f,cb as A,ja as w}from"./chunk-BXQQKDIX.js";var j=36,x=160;function v(e,t=360){let o=f(Math.round(Number.isFinite(e)?e:1),1,40),s=f(Number.isFinite(t)?t:360,120,360);return Math.round(f(o*4*(360/s),j,x))}function l(e){return typeof e=="string"&&S.includes(e)}function b(e,t){return e&&t?"both":e?"start":t?"end":"none"}function g(e){let t=new Map,o=w(e);if(!o.size)return t;let s=new Map;for(let r of e){if(r.type!=="row"||!o.has(r.id))continue;let i=r.segmentedRow.groupId,a=s.get(i)??[];a.push(r),s.set(i,a)}for(let r of s.values())r.sort((i,a)=>i.segmentedRow.componentIndex-a.segmentedRow.componentIndex),r.forEach((i,a)=>{let c=r[a+1];t.set(i.id,{start:a>0&&i.segmentedRow.boundaryBefore==="continuous",end:!!c&&c.segmentedRow.boundaryBefore==="continuous"})});return t}function h(e,t){let o=Number.isInteger(e.seatCount)&&e.seatCount>0?e.seatCount:0,s=new Set;for(let n of e.overrides??[])n.skip&&s.add(n.index);let r=n=>n>=0&&n<o&&!s.has(n),i=b(!t?.start,!t?.end),a=l(e.aisleSeats)?e.aisleSeats:void 0;if(!a)return{automatic:i,slots:[]};let c=a,d=-1,m=-1;for(let n=0;n<o;n+=1)r(n)&&(d<0&&(d=n),m=n);let u=new Set;if(d>=0){(c==="start"||c==="both")&&u.add(d),(c==="end"||c==="both")&&u.add(m);for(let n of s)r(n-1)&&u.add(n-1),r(n+1)&&u.add(n+1)}return{override:a,automatic:i,slots:[...u].sort((n,O)=>n-O)}}function D(e,t=[e]){return h(e,e.segmentedRow?g(t).get(e.id):void 0)}function I(e){let t=new Set;for(let o of A(e)){let s=g(o.objects);for(let r of o.objects)if(r.type==="row")for(let i of h(r,s.get(r.id)).slots)t.add(`${r.id}:${i}`)}return t}function E(e,t,o){return I(e).has(`${t}:${o}`)}function R(e){let t=l(e.aisleSeats)?e.aisleSeats:"none";return{start:t==="start"||t==="both",end:t==="end"||t==="both"}}function p(e,t){e.aisleSeats=t}function N(e,t,o){if(!l(e.aisleSeats)){delete t.aisleSeats,delete o.aisleSeats;return}let s=R(e);p(t,b(s.start,!0)),p(o,b(!0,s.end))}function U(e,t){let o=e[0],s=e[e.length-1];if(!o||!s||!l(o.aisleSeats)&&!l(s.aisleSeats)){delete t.aisleSeats;return}p(t,b(R(o).start,R(s).end))}export{j as a,x as b,v as c,l as d,D as e,I as f,E as g,N as h,U as i};
@@ -1 +1 @@
1
- import{f as D}from"./chunk-NVAF2E7Q.js";import{g as A,i as P}from"./chunk-GVVZR3YS.js";import{C as M,N as v,Na as w,Pa as C,Qa as S,Sa as O,Ta as j}from"./chunk-3V32MDJI.js";function x(r){return r.floors?.length?r.floors.flatMap(o=>o.objects):r.objects}function B(r){return x(r).reduce((o,n)=>n.type==="row"?o+w(n):n.type==="table"?o+O(n):n.type==="gaArea"?o+Math.max(0,Math.floor(n.capacity)):n.type==="booth"?o+1:o,0)}function G(r){let o={};for(let a of r.categories??[])o[a.key]=0;let n=(a,s)=>{s>0&&(o[a]=(o[a]??0)+s)};for(let a of x(r))if(a.type==="row")for(let s of C(a))n(s.categoryKey,1);else if(a.type==="table")if(a.bookAsWhole||a.variableOccupancy)n(a.categoryKey,Math.max(0,Math.round(a.seatCount)));else for(let s of j(a))n(s.categoryKey,1);else a.type==="gaArea"?n(a.categoryKey,Math.max(0,Math.floor(a.capacity))):a.type==="booth"&&n(a.categoryKey,1);return o}function _(r){if(!r.template)return null;let o=x(r),n=o.filter(c=>c.type==="row"||c.type==="table"||c.type==="gaArea");if(!n.length)return null;let s=o.filter(c=>c.type==="booth").length+n.reduce((c,l)=>c+(l.type==="table"?2:1),0),y=B(r),h=Math.max(s+1,Math.min(5e4,y*4)),d=[.5,1,1.5,2].map(c=>v(Math.round(y*c),s,h));return{family:r.template.family,display:r.template.family.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase()),min:s,max:h,presets:["S","M","L","XL"].map((c,l)=>({size:c,seats:d[l]}))}}function R(r){let o=C(r);return o.length?M(o):{...r.origin}}function N(r,o){let n=_(r);if(!n)return structuredClone(r);let a=structuredClone(r),s=x(a),y=s.filter(t=>t.type==="row"||t.type==="table"||t.type==="gaArea"),h=s.filter(t=>t.type==="booth").length,d=Math.max(n.min,Math.min(n.max,Math.round(o))),c=d-h,l=y.map((t,e)=>{let u=t.type==="gaArea"?Math.max(0,Math.floor(t.capacity)):t.seatCount,p=t.type==="table"?2:1;return{object:t,index:e,current:u,minimum:p,value:p,fraction:0}}),K=l.reduce((t,e)=>t+e.minimum,0),g=Math.max(0,c-K),T=l.reduce((t,e)=>t+Math.max(1,e.current-e.minimum),0);for(let t of l){let e=g*Math.max(1,t.current-t.minimum)/T,u=Math.floor(e);t.value+=u,t.fraction=e-u}g=c-l.reduce((t,e)=>t+e.value,0),l.sort((t,e)=>e.fraction-t.fraction||t.index-e.index);for(let t=0;t<g;t++)l[t%l.length].value++;l.sort((t,e)=>t.index-e.index);for(let t of l)if(t.object.type==="row"){let e=R(t.object);t.object.seatCount=t.value;let u=R(t.object);t.object.origin.x+=e.x-u.x,t.object.origin.y+=e.y-u.y}else if(t.object.type==="table"){let e=t.object;if(e.seatCountsBySide){let u=["top","bottom","left","right"],p=S(e),z=u.reduce((i,f)=>i+p[f],0)||1,m=u.map((i,f)=>{let b=t.value*p[i]/z;return{side:i,index:f,value:Math.floor(b),fraction:b-Math.floor(b)}}),L=t.value-m.reduce((i,f)=>i+f.value,0);m.sort((i,f)=>f.fraction-i.fraction||i.index-f.index);for(let i=0;i<L;i++)m[i%m.length].value+=1;m.sort((i,f)=>i.index-f.index),e.seatCountsBySide={top:m[0].value,bottom:m[1].value,left:m[2].value,right:m[3].value},e.sides=u.filter(i=>e.seatCountsBySide[i]>0)}e.seatCount=t.value,e.overrides&&(e.overrides=e.overrides.filter(u=>u.index<t.value),e.overrides.length||delete e.overrides)}else{let e=t.object;e.capacity=P(e)?Math.min(t.value,A):t.value,e.variableOccupancy&&(e.maxOccupancy=Math.min(e.maxOccupancy??e.capacity,e.capacity),e.minOccupancy=Math.min(e.minOccupancy??1,e.maxOccupancy)),e.wheelchairPlaces&&(e.wheelchairPlaces=Math.min(e.wheelchairPlaces,e.capacity))}return a.floors?.length&&(a.objects=a.floors[0].objects),a.template={family:a.template.family,targetSeats:d},a=D(a).doc,a.template={family:r.template.family,targetSeats:B(a)},a}export{B as a,G as b,_ as c,N as d};
1
+ import{f as D}from"./chunk-FZ74MVKY.js";import{g as A,i as P}from"./chunk-MN4M5QZ4.js";import{C as M,N as v,Pa as w,Ra as C,Sa as S,Ua as O,Va as j}from"./chunk-BXQQKDIX.js";function x(r){return r.floors?.length?r.floors.flatMap(o=>o.objects):r.objects}function B(r){return x(r).reduce((o,n)=>n.type==="row"?o+w(n):n.type==="table"?o+O(n):n.type==="gaArea"?o+Math.max(0,Math.floor(n.capacity)):n.type==="booth"?o+1:o,0)}function G(r){let o={};for(let a of r.categories??[])o[a.key]=0;let n=(a,s)=>{s>0&&(o[a]=(o[a]??0)+s)};for(let a of x(r))if(a.type==="row")for(let s of C(a))n(s.categoryKey,1);else if(a.type==="table")if(a.bookAsWhole||a.variableOccupancy)n(a.categoryKey,Math.max(0,Math.round(a.seatCount)));else for(let s of j(a))n(s.categoryKey,1);else a.type==="gaArea"?n(a.categoryKey,Math.max(0,Math.floor(a.capacity))):a.type==="booth"&&n(a.categoryKey,1);return o}function _(r){if(!r.template)return null;let o=x(r),n=o.filter(c=>c.type==="row"||c.type==="table"||c.type==="gaArea");if(!n.length)return null;let s=o.filter(c=>c.type==="booth").length+n.reduce((c,l)=>c+(l.type==="table"?2:1),0),y=B(r),h=Math.max(s+1,Math.min(5e4,y*4)),d=[.5,1,1.5,2].map(c=>v(Math.round(y*c),s,h));return{family:r.template.family,display:r.template.family.replace(/-/g," ").replace(/\b\w/g,c=>c.toUpperCase()),min:s,max:h,presets:["S","M","L","XL"].map((c,l)=>({size:c,seats:d[l]}))}}function R(r){let o=C(r);return o.length?M(o):{...r.origin}}function N(r,o){let n=_(r);if(!n)return structuredClone(r);let a=structuredClone(r),s=x(a),y=s.filter(t=>t.type==="row"||t.type==="table"||t.type==="gaArea"),h=s.filter(t=>t.type==="booth").length,d=Math.max(n.min,Math.min(n.max,Math.round(o))),c=d-h,l=y.map((t,e)=>{let u=t.type==="gaArea"?Math.max(0,Math.floor(t.capacity)):t.seatCount,p=t.type==="table"?2:1;return{object:t,index:e,current:u,minimum:p,value:p,fraction:0}}),K=l.reduce((t,e)=>t+e.minimum,0),g=Math.max(0,c-K),T=l.reduce((t,e)=>t+Math.max(1,e.current-e.minimum),0);for(let t of l){let e=g*Math.max(1,t.current-t.minimum)/T,u=Math.floor(e);t.value+=u,t.fraction=e-u}g=c-l.reduce((t,e)=>t+e.value,0),l.sort((t,e)=>e.fraction-t.fraction||t.index-e.index);for(let t=0;t<g;t++)l[t%l.length].value++;l.sort((t,e)=>t.index-e.index);for(let t of l)if(t.object.type==="row"){let e=R(t.object);t.object.seatCount=t.value;let u=R(t.object);t.object.origin.x+=e.x-u.x,t.object.origin.y+=e.y-u.y}else if(t.object.type==="table"){let e=t.object;if(e.seatCountsBySide){let u=["top","bottom","left","right"],p=S(e),z=u.reduce((i,f)=>i+p[f],0)||1,m=u.map((i,f)=>{let b=t.value*p[i]/z;return{side:i,index:f,value:Math.floor(b),fraction:b-Math.floor(b)}}),L=t.value-m.reduce((i,f)=>i+f.value,0);m.sort((i,f)=>f.fraction-i.fraction||i.index-f.index);for(let i=0;i<L;i++)m[i%m.length].value+=1;m.sort((i,f)=>i.index-f.index),e.seatCountsBySide={top:m[0].value,bottom:m[1].value,left:m[2].value,right:m[3].value},e.sides=u.filter(i=>e.seatCountsBySide[i]>0)}e.seatCount=t.value,e.overrides&&(e.overrides=e.overrides.filter(u=>u.index<t.value),e.overrides.length||delete e.overrides)}else{let e=t.object;e.capacity=P(e)?Math.min(t.value,A):t.value,e.variableOccupancy&&(e.maxOccupancy=Math.min(e.maxOccupancy??e.capacity,e.capacity),e.minOccupancy=Math.min(e.minOccupancy??1,e.maxOccupancy)),e.wheelchairPlaces&&(e.wheelchairPlaces=Math.min(e.wheelchairPlaces,e.capacity))}return a.floors?.length&&(a.objects=a.floors[0].objects),a.template={family:a.template.family,targetSeats:d},a=D(a).doc,a.template={family:r.template.family,targetSeats:B(a)},a}export{B as a,G as b,_ as c,N as d};
@@ -1 +1 @@
1
- import{N as c}from"./chunk-3V32MDJI.js";function s(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let i=e[n],a=e[(n+1)%o];t+=i.x*a.y-a.x*i.y}return t/2}function g(e){return s(e)*2}function X(e,t,n){let o=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){let r=e[i],u=e[a];r.y>n!=u.y>n&&t<(u.x-r.x)*(n-r.y)/(u.y-r.y)+r.x&&(o=!o)}return o}var l=.15,x=1.6;function O(e){return c(e??1,l,x)}var Y=["in","out","both"];function p(e){return e?.type==="shape"&&e.gate!=null&&typeof e.gate=="object"}function T(e){return e?.type==="shape"&&!e.gate&&(e.role==="entrance"||e.role==="exit")&&e.kind!=="line"&&e.kind!=="polyline"}function C(e){return e.type==="row"||e.type==="section"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function B(e){return e==="out"?"exit":"entrance"}function m(e){return e.floors?.length?e.floors.flatMap(t=>t.objects):e.objects}function f(e){let t=new Map;for(let n of m(e))p(n)&&t.set(n.id,n);return t}function I(e){if(e.gate.hideFromBuyers)return;let t=e.label?.normalize("NFKC").trim();return t?t.slice(0,40):void 0}function R(e){let t=new Set([...f(e).values()].map(n=>n.label?.trim().toLowerCase()));for(let n=0;n<26;n++){let o=`Gate ${String.fromCharCode(65+n)}`;if(!t.has(o.toLowerCase()))return o}for(let n=27;;n++)if(!t.has(`gate ${n}`))return`Gate ${n}`}function _(e,t,n){let o=t*.46,i=Math.max(e.length,2)*o*.6,a=n?o*1.25:0;return Math.round(i+a+t)}function d(e){let t=1/0,n=1/0,o=-1/0,i=-1/0,a=!1;for(let r of e)!Number.isFinite(r.x)||!Number.isFinite(r.y)||(a=!0,r.x<t&&(t=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>i&&(i=r.y));return a?{minX:t,minY:n,maxX:o,maxY:i}:null}function j(e){let t=d(e);return t?y(t):null}function y(e){return{x:e.minX,y:e.minY,width:e.maxX-e.minX,height:e.maxY-e.minY}}function w(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}export{d as a,j as b,w as c,s as d,g as e,X as f,l as g,x as h,O as i,Y as j,p as k,T as l,C as m,B as n,f as o,I as p,R as q,_ as r};
1
+ import{N as c}from"./chunk-BXQQKDIX.js";function s(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let i=e[n],a=e[(n+1)%o];t+=i.x*a.y-a.x*i.y}return t/2}function g(e){return s(e)*2}function X(e,t,n){let o=!1;for(let i=0,a=e.length-1;i<e.length;a=i++){let r=e[i],u=e[a];r.y>n!=u.y>n&&t<(u.x-r.x)*(n-r.y)/(u.y-r.y)+r.x&&(o=!o)}return o}var l=.15,x=1.6;function O(e){return c(e??1,l,x)}var Y=["in","out","both"];function p(e){return e?.type==="shape"&&e.gate!=null&&typeof e.gate=="object"}function T(e){return e?.type==="shape"&&!e.gate&&(e.role==="entrance"||e.role==="exit")&&e.kind!=="line"&&e.kind!=="polyline"}function C(e){return e.type==="row"||e.type==="section"||e.type==="table"||e.type==="booth"||e.type==="gaArea"}function B(e){return e==="out"?"exit":"entrance"}function m(e){return e.floors?.length?e.floors.flatMap(t=>t.objects):e.objects}function f(e){let t=new Map;for(let n of m(e))p(n)&&t.set(n.id,n);return t}function I(e){if(e.gate.hideFromBuyers)return;let t=e.label?.normalize("NFKC").trim();return t?t.slice(0,40):void 0}function R(e){let t=new Set([...f(e).values()].map(n=>n.label?.trim().toLowerCase()));for(let n=0;n<26;n++){let o=`Gate ${String.fromCharCode(65+n)}`;if(!t.has(o.toLowerCase()))return o}for(let n=27;;n++)if(!t.has(`gate ${n}`))return`Gate ${n}`}function _(e,t,n){let o=t*.46,i=Math.max(e.length,2)*o*.6,a=n?o*1.25:0;return Math.round(i+a+t)}function d(e){let t=1/0,n=1/0,o=-1/0,i=-1/0,a=!1;for(let r of e)!Number.isFinite(r.x)||!Number.isFinite(r.y)||(a=!0,r.x<t&&(t=r.x),r.y<n&&(n=r.y),r.x>o&&(o=r.x),r.y>i&&(i=r.y));return a?{minX:t,minY:n,maxX:o,maxY:i}:null}function j(e){let t=d(e);return t?y(t):null}function y(e){return{x:e.minX,y:e.minY,width:e.maxX-e.minX,height:e.maxY-e.minY}}function w(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}export{d as a,j as b,w as c,s as d,g as e,X as f,l as g,x as h,O as i,Y as j,p as k,T as l,C as m,B as n,f as o,I as p,R as q,_ as r};