@seatlayer/core 0.96.0 → 0.97.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 (123) hide show
  1. package/dist/ar-Q44JP5JY.js +1 -0
  2. package/dist/be-CGFFSIQL.js +1 -0
  3. package/dist/bg-WOYK6OLH.js +1 -0
  4. package/dist/ca-77ZVI3X5.js +1 -0
  5. package/dist/chunk-2P72QUJR.js +1 -0
  6. package/dist/chunk-5N4H3KMR.js +1 -0
  7. package/dist/chunk-ASIIXY5M.js +1 -0
  8. package/dist/{chunk-O3DGXAIC.js → chunk-CUACREZL.js} +1 -1
  9. package/dist/{chunk-CEIVHWRB.js → chunk-FLMKHAUT.js} +1 -1
  10. package/dist/{chunk-TKYTTEJ2.js → chunk-IW7QZIMF.js} +1 -1
  11. package/dist/chunk-M5VINTGE.js +1 -0
  12. package/dist/chunk-NGZXKXOY.js +1 -0
  13. package/dist/{chunk-U7CVRE4P.js → chunk-OLGPAFXW.js} +1 -1
  14. package/dist/{chunk-M5X6G7FD.js → chunk-P4C24CIZ.js} +1 -1
  15. package/dist/{chunk-A3ZL3R75.js → chunk-QEPYNCBJ.js} +1 -1
  16. package/dist/chunk-VAI2VDQR.js +1 -0
  17. package/dist/{chunk-Q3MSDG4S.js → chunk-YPESNMTC.js} +1 -1
  18. package/dist/chunk-Z43H6AWN.js +1 -0
  19. package/dist/core/chart-ops/index.cjs +1 -1
  20. package/dist/core/chart-ops/index.d.cts +40 -18
  21. package/dist/core/chart-ops/index.d.ts +40 -18
  22. package/dist/core/chart-ops/index.js +1 -1
  23. package/dist/core/inventory/index.cjs +1 -1
  24. package/dist/core/inventory/index.js +1 -1
  25. package/dist/core/layout/index.cjs +1 -1
  26. package/dist/core/layout/index.js +1 -1
  27. package/dist/core/quality/index.js +1 -1
  28. package/dist/core/render-assets/index.js +1 -1
  29. package/dist/core/sections/index.js +1 -1
  30. package/dist/cs-OSBZYCSR.js +1 -0
  31. package/dist/cy-ZCOJW2WH.js +1 -0
  32. package/dist/da-2PDK6JTR.js +1 -0
  33. package/dist/de-R5LLVFUU.js +1 -0
  34. package/dist/el-ZPFVDCWA.js +1 -0
  35. package/dist/es-7YASJP32.js +1 -0
  36. package/dist/et-J4TV6KQL.js +1 -0
  37. package/dist/fa-4TEO7UGM.js +1 -0
  38. package/dist/fi-GIUDDKMH.js +1 -0
  39. package/dist/fr-J5J2XJLA.js +1 -0
  40. package/dist/he-OCEHSVUJ.js +1 -0
  41. package/dist/hi-EK5CTBW5.js +1 -0
  42. package/dist/hr-SLDTQOYC.js +1 -0
  43. package/dist/hu-2QNE77NO.js +1 -0
  44. package/dist/id-LGDAFQJK.js +1 -0
  45. package/dist/index.cjs +1 -1
  46. package/dist/index.d.cts +8 -16
  47. package/dist/index.d.ts +8 -16
  48. package/dist/index.js +1 -1
  49. package/dist/it-DT4Y3IYB.js +1 -0
  50. package/dist/ja-D5EY2XCQ.js +1 -0
  51. package/dist/ko-DD2NV45Q.js +1 -0
  52. package/dist/ku-KZCMVLBE.js +1 -0
  53. package/dist/localeLoaders-GGAKX22E.js +1 -0
  54. package/dist/lt-QWGTJ47Y.js +1 -0
  55. package/dist/lv-LYAIG3VK.js +1 -0
  56. package/dist/ms-XTF4KNGD.js +1 -0
  57. package/dist/nl-QEXY6XHS.js +1 -0
  58. package/dist/no-HCOXN2CN.js +1 -0
  59. package/dist/pl-BWY53TSD.js +1 -0
  60. package/dist/pt-2UJUBCPL.js +1 -0
  61. package/dist/ro-GGXOLTED.js +1 -0
  62. package/dist/ru-ZTFK3WCU.js +1 -0
  63. package/dist/sk-KU543Y2U.js +1 -0
  64. package/dist/sl-FT576R7A.js +1 -0
  65. package/dist/sr-WE3J46JE.js +1 -0
  66. package/dist/stage-CKb7aNoH.d.cts +18 -0
  67. package/dist/stage-CKb7aNoH.d.ts +18 -0
  68. package/dist/sv-YEAOPSEB.js +1 -0
  69. package/dist/th-BEBRDHJA.js +1 -0
  70. package/dist/tr-LOAHUPSH.js +1 -0
  71. package/dist/uk-2GMICSHN.js +1 -0
  72. package/dist/vi-TC5B6AUR.js +1 -0
  73. package/dist/view3d/index.cjs +241 -78
  74. package/dist/view3d/index.d.cts +146 -78
  75. package/dist/view3d/index.d.ts +146 -78
  76. package/dist/view3d/index.js +239 -76
  77. package/dist/view3d/scene/scene.worker.cjs +1 -1
  78. package/dist/view3d/scene/scene.worker.js +1 -1
  79. package/dist/zh-Hans-TSZWTZQY.js +1 -0
  80. package/dist/zh-Hant-TLB4FZYM.js +1 -0
  81. package/package.json +1 -1
  82. package/dist/ar-3S65PDDG.js +0 -1
  83. package/dist/be-WJKGEBTI.js +0 -1
  84. package/dist/bg-TZUF36MP.js +0 -1
  85. package/dist/ca-WLW64J7W.js +0 -1
  86. package/dist/chunk-F2EXXZSZ.js +0 -1
  87. package/dist/chunk-F7TP67LK.js +0 -1
  88. package/dist/chunk-LAX7F5ML.js +0 -1
  89. package/dist/chunk-LFJUXTIO.js +0 -1
  90. package/dist/chunk-M7JA4BGP.js +0 -1
  91. package/dist/cs-HQXANWJA.js +0 -1
  92. package/dist/cy-EG5BJOG7.js +0 -1
  93. package/dist/da-5XEBRUEE.js +0 -1
  94. package/dist/de-SCVAU32D.js +0 -1
  95. package/dist/el-KBW7YAF5.js +0 -1
  96. package/dist/es-IFLC65KX.js +0 -1
  97. package/dist/et-OXB22VMP.js +0 -1
  98. package/dist/fa-GFAZXHP6.js +0 -1
  99. package/dist/fi-AI67VYYH.js +0 -1
  100. package/dist/fr-V3RG2KYP.js +0 -1
  101. package/dist/he-J3I6MRUR.js +0 -1
  102. package/dist/hr-SA4WZ3AG.js +0 -1
  103. package/dist/hu-TM35NZ4U.js +0 -1
  104. package/dist/it-E4QYIYC4.js +0 -1
  105. package/dist/ja-S5M7EINH.js +0 -1
  106. package/dist/ku-DNZQIUUG.js +0 -1
  107. package/dist/localeLoaders-JTNNRDK2.js +0 -1
  108. package/dist/lt-ETQDX2HL.js +0 -1
  109. package/dist/lv-FYFIWI4F.js +0 -1
  110. package/dist/nl-XOG5SBZQ.js +0 -1
  111. package/dist/no-7UGUTFXW.js +0 -1
  112. package/dist/pl-5HR7DQIK.js +0 -1
  113. package/dist/pt-L4CCONDZ.js +0 -1
  114. package/dist/ro-KZVPOCZ6.js +0 -1
  115. package/dist/ru-CD7HYORB.js +0 -1
  116. package/dist/sk-AQZOHJYW.js +0 -1
  117. package/dist/sl-XYRITXI6.js +0 -1
  118. package/dist/sr-6VTXFVHT.js +0 -1
  119. package/dist/sv-EJWP7WJV.js +0 -1
  120. package/dist/tr-VKVADTIZ.js +0 -1
  121. package/dist/uk-QSJV3LDS.js +0 -1
  122. package/dist/zh-Hans-2FN4LFAW.js +0 -1
  123. package/dist/zh-Hant-5T2AB4FR.js +0 -1
@@ -1 +1 @@
1
- "use strict";var Ao=Object.create;var Nt=Object.defineProperty;var _o=Object.getOwnPropertyDescriptor;var ko=Object.getOwnPropertyNames;var To=Object.getPrototypeOf,Lo=Object.prototype.hasOwnProperty;var Oo=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ko(t))!Lo.call(e,o)&&o!==n&&Nt(e,o,{get:()=>t[o],enumerable:!(r=_o(t,o))||r.enumerable});return e};var Ie=(e,t,n)=>(n=e!=null?Ao(To(e)):{},Oo(t||!e||!e.__esModule?Nt(n,"default",{value:e,enumerable:!0}):n,e));var Rs=Math.PI/180;function dt(e){let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;let r=e.length||1;return{x:t/r,y:n/r}}function _e(e){return e.length?dt(e):null}function Gt(e,t){let n=1-t,r=n*n*n,o=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:r*e.start.x+o*e.control1.x+i*e.control2.x+s*e.end.x,y:r*e.start.y+o*e.control1.y+i*e.control2.y+s*e.end.y}}function jt(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[Gt(e,.5)];let r=Array.from({length:n+1},(m,u)=>Gt(e,u/n)),o=new Float64Array(r.length);for(let m=1;m<r.length;m+=1){let u=r[m].x-r[m-1].x,l=r[m].y-r[m-1].y;o[m]=o[m-1]+Math.hypot(u,l)}let i=o[o.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let m=0;m<t;m+=1){let u=i*m/(t-1);for(;a<o.length-1&&o[a]<u;)a+=1;let l=o[a-1],d=o[a],c=d===l?0:(u-l)/(d-l);s.push({x:r[a-1].x+(r[a].x-r[a-1].x)*c,y:r[a-1].y+(r[a].y-r[a-1].y)*c})}return s}function Ut(e,t,n){return Math.max(t,Math.min(n,e))}function Yt(e){let t=new Map,n=new Map;for(let r of e){if(r.type!=="row"||!r.segmentedRow)continue;let o=n.get(r.segmentedRow.groupId)??[];o.push(r),n.set(r.segmentedRow.groupId,o)}for(let[r,o]of n){let i=o.slice().sort((c,f)=>c.segmentedRow.componentIndex-f.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((c,f)=>c.segmentedRow?.kind==="segmented-row-v1"&&c.segmentedRow.groupId===r&&c.segmentedRow.componentCount===s&&c.segmentedRow.componentIndex===f&&c.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(f===0?c.segmentedRow.boundaryBefore==="start":c.segmentedRow.boundaryBefore!=="start")&&c.segmentedRow.displayLabel===a.displayLabel)))continue;let u=i.reduce((c,f)=>c+f.seatCount,0),l=0,d=0;for(let c of i)c.segmentedRow.boundaryBefore==="break"&&(l+=1),t.set(c.id,{groupId:r,adjacencyOffset:l,displayOffset:d,displayLabel:a.displayLabel,totalSeats:u,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),l+=c.seatCount,d+=c.seatCount}return t}var Bo="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Fo="abcdefghijklmnopqrstuvwxyz";function Do(e,t){let n=t.length,r=e+1,o="";for(;r>0;){r-=1;let i=r%n;o=t[i]+o,r=Math.floor(r/n)}return o}function bt(e,t=!1){let n=t?Fo:Bo;return Do(Math.max(0,Math.floor(e)-1),n)}var No=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function Xt(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[r,o]of No)for(;t>=r;)n+=o,t-=r;return n}function Go(e){let t=new Array(e);return Array.from({length:e},(n,r)=>r).sort((n,r)=>Math.abs(2*n-(e-1))-Math.abs(2*r-(e-1))||n-r).forEach((n,r)=>t[n]=r),t}function He(e,t){let n=e.seatLabelStart??1,r=e.seatNumbering?.direction??"ltr",o=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,m=e.seatCount;if(i==="updown"||i==="updown-descending"){let f=Math.ceil(m/2),b=i==="updown"?t<f?n+2*t:n-1+2*(m-t):t<f?n+2*(f-1-t):n+1+2*(t-f);return`${s}${b}`}let u=i==="odd"||i==="even"?2:o,l=a!=null&&Number.isFinite(a)?a-(m-1)*u:n,d=r==="center"?Go(m)[t]:r==="rtl"?m-1-t:t,c;switch(i){case"odd":{let f=l%2===1?l:l+1;c=String(f+d*2);break}case"even":{let f=l%2===0?l:l+1;c=String(f+d*2);break}case"roman":c=Xt(l+d*o);break;case"letters-upper":c=bt(l+d*o,!1);break;case"letters-lower":c=bt(l+d*o,!0);break;default:c=String(l+d*o);break}return`${s}${c}`}function jo(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Vt(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${He(e,t)}`}function pt(e,t,n,r){if(r?.displayLabel)return r.displayLabel;if(e.seatDisplayLabelMode==="number")return He(e,t);if(!n)return`${e.displayLabel||e.label}-${He(e,t)}`;let o=jo(n),i=n.displayOffset+t;return`${n.displayLabel}-${He(o,i)}`}var te=.02291666666666667,me=1/te,Uo=58,Yo=Uo*te;var Xo=3,Ht=0,ht=120,Vo=0,Ho=45,Ko=7,ce=1.2;function yt(e,t,n,r){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):r}function zo(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=Ko?e:Xo}function Ke(e,t={}){let n=yt(t.floorBaseHeightM,Ht,ht,0),r=Math.min(ht,n+zo(e.elevation)*Yo),o=e.height===void 0?r:yt(e.height,Ht,ht,r),i=yt(e.rake,Vo,Ho,0);return{height:o,rake:i}}function Kt(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function ve(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let r=1/0;for(let o=0;o+1<e.length;o++){let i=e[o],s=e[o+1],a=s.x-i.x,m=s.y-i.y,u=a*a+m*m,l=u>1e-12?((t-i.x)*a+(n-i.y)*m)/u:0;l<0?l=0:l>1&&(l=1);let d=t-(i.x+l*a),c=n-(i.y+l*m);if(Math.abs(d)>=r||Math.abs(c)>=r)continue;let f=Math.hypot(d,c);f<r&&(r=f)}return r}function Wo(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let r=e.length||1;t/=r,n/=r;let o=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>o&&(o=s)}return{cx:t,cy:n,r:o}}function zt(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function gt(e,t){let n=1/0;for(let r of Kt(e)){let o=ve(t,r.x,r.y);o<n&&(n=o)}for(let r of Kt(t)){let o=ve(e,r.x,r.y);o<n&&(n=o)}return n}function Zo(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,r=0;for(let l of e)n+=l.x,r+=l.y;n/=e.length,r/=e.length;let o=-1,i=e[0];for(let l of e){let d=Math.hypot(l.x-n,l.y-r);d>o&&(o=d,i=l)}let s=i.x-n,a=i.y-r,m=Math.hypot(s,a);m>1e-9?(s/=m,a/=m):(s=1,a=0);let u=e.map((l,d)=>({p:l,i:d,t:(l.x-n)*s+(l.y-r)*a})).sort((l,d)=>l.t-d.t);return{pts:u.map(l=>l.p),seatIndices:u.map(l=>t[l.i])}}function xt(e){let t=e.length;if(t<3)return null;let n=0,r=0;for(let x of e)n+=x.x,r+=x.y;n/=t,r/=t;let o=0,i=0,s=0,a=0,m=0,u=0,l=0;for(let x of e){let I=x.x-n,w=x.y-r;o+=I*I,s+=w*w,i+=I*w,a+=I*I*I,m+=w*w*w,u+=I*w*w,l+=w*I*I}let d=o*s-i*i;if(Math.abs(d)<1e-9)return null;let c=(a+u)/2,f=(m+l)/2,b=(c*s-f*i)/d,p=(f*o-c*i)/d,h=b+n,y=p+r;return!Number.isFinite(h)||!Number.isFinite(y)?null:{cx:h,cy:y}}var $o=.15;function Qo(e){if(e.length<2)return null;let t=e.map(x=>{let I=0,w=0;for(let P of x.pts)I+=P.x,w+=P.y;return{x:I/x.pts.length,y:w/x.pts.length}}),n=0,r=0;for(let x of t)n+=x.x,r+=x.y;n/=t.length,r/=t.length;let o=0,i=0,s=0;for(let x of t){let I=x.x-n,w=x.y-r;o+=I*I,i+=I*w,s+=w*w}let a=o+s,m=o*s-i*i,u=a/2+Math.sqrt(Math.max(0,a*a/4-m)),l,d;Math.abs(i)>1e-12?(l=u-s,d=i):o>=s?(l=1,d=0):(l=0,d=1);let c=Math.hypot(l,d);if(!(c>1e-12))return null;l/=c,d/=c;let f=1/0,b=-1/0,p=[];for(let x of e){let I=1/0,w=-1/0;for(let P of x.pts){let g=P.x*l+P.y*d;g<I&&(I=g),g>w&&(w=g),g<f&&(f=g),g>b&&(b=g)}p.push(w-I)}let h=b-f;return h>1e-9?(p.sort((x,I)=>x-I),p[Math.min(p.length-1,Math.floor(p.length*.9))]/h<=qo?{x:l,y:d}:null):null}var qo=.35;function ze(e,t,n,r){let o=new Map;for(let g of n){let M=t[g],R=M.rowId||`__seat-${g}`,k=o.get(R);k||(k={pts:[],idx:[]},o.set(R,k)),k.pts.push({x:M.x,y:M.y}),k.idx.push(g)}if(!o.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[g,M]of o){let R=Zo(M.pts,M.idx),k=0;for(let L of R.pts)k+=Math.hypot(L.x-r.x,L.y-r.y);i.push({id:g,pts:R.pts,seatIndices:R.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:k/R.pts.length})}let s=i.map(g=>Wo(g.pts)),a=i.length<=256?i.length*(i.length-1)/2:0,m=a?new Float64Array(a):null;m?.fill(Number.NaN);let u=m?new Map(i.map((g,M)=>[g,M])):null,l=(g,M)=>(g>M&&([g,M]=[M,g]),g*(2*i.length-g-1)/2+(M-g-1)),d=(g,M)=>{if(!m)return gt(i[g].pts,i[M].pts);let R=l(g,M),k=m[R];if(!Number.isNaN(k))return k;let L=gt(i[g].pts,i[M].pts);return m[R]=L,L},c=(g,M)=>u?d(u.get(g),u.get(M)):gt(g.pts,M.pts),f=[];for(let g=0;g<i.length;g++){let M=1/0;for(let R=0;R<i.length;R++){if(g===R||zt(s[g],s[R])>=M)continue;let k=d(g,R);k<M&&(M=k)}Number.isFinite(M)&&f.push(M)}f.sort((g,M)=>g-M);let b=f.length?f[Math.floor(f.length/2)]:1,p=Math.max(b*1.8,1e-6),h=i.map(()=>[]);for(let g=0;g<i.length;g++)for(let M=g+1;M<i.length;M++)zt(s[g],s[M])>p||d(g,M)<=p&&(h[g].push(M),h[M].push(g));let y=0;for(let g=0;g<i.length;g++){if(i[g].blockId!==-1)continue;let M=y++,R=[g];for(i[g].blockId=M;R.length;){let k=R.pop();for(let L of h[k])i[L].blockId===-1&&(i[L].blockId=M,R.push(L))}}let x=new Map;for(let g of i){let M=x.get(g.blockId)??[];M.push(g),x.set(g.blockId,M)}let I=[];for(let g of i){if(g.pts.length<4)continue;let M=xt(g.pts);M&&(!Number.isFinite(M.cx)||!Number.isFinite(M.cy)||I.push({x:M.cx,y:M.cy}))}let w=I.length>=2?(()=>{let g=I.map(k=>k.x).sort((k,L)=>k-L),M=I.map(k=>k.y).sort((k,L)=>k-L),R=Math.floor(I.length/2);return{cx:g[R],cy:M[R]}})():null;if(w){let g=v=>Math.hypot(v.x-w.cx,v.y-w.cy),M=1/0,R=-1/0,k=[];for(let v of i){let S=1/0,T=-1/0;for(let N of v.pts){let E=g(N);E<S&&(S=E),E>T&&(T=E)}k.push(T-S),S<M&&(M=S),T>R&&(R=T)}let L=R-M;k.sort((v,S)=>v-S);let U=k[Math.min(k.length-1,Math.floor(k.length*.9))];if(L>1e-9&&U/L<=$o){let v=i.map(F=>{let j=0;for(let Y of F.pts)j+=g(Y);return{row:F,radius:j/F.pts.length}}),S=0,T=0;for(let F of v)S+=F.radius,T+=F.row.focalDistance;S/=v.length,T/=v.length;let N=0;for(let F of v)N+=(F.radius-S)*(F.row.focalDistance-T);if(N<0)for(let F of v)F.radius=-F.radius;let O=1/0;for(let F of v)F.radius<O&&(O=F.radius);v.sort((F,j)=>F.radius-j.radius);let A=-1,_=-1/0,B=L/Math.max(1,v.length)*.5,D=[];for(let F of v)F.radius-_>B&&(A++,_=F.radius),F.row.ordinal=A,F.row.blockDepth=F.radius-O,D.push(F.row);return{sectionId:e,rows:D,blockCount:y}}}let P=[];for(let[,g]of x){let M=Qo(g);if(M){let R=L=>{let U=0;for(let v of L.pts)U+=v.x*M.x+v.y*M.y;return U/L.pts.length};g.sort((L,U)=>R(L)-R(U)),g.length>=2&&g[0].focalDistance>g[g.length-1].focalDistance&&g.reverse();let k=0;for(let L=0;L<g.length;L++)L>0&&(k+=c(g[L-1],g[L])),g[L].ordinal=L,g[L].blockDepth=k,P.push(g[L])}else{let R=1/0;for(let k of g)k.focalDistance<R&&(R=k.focalDistance);g.sort((k,L)=>k.focalDistance-L.focalDistance);for(let k=0;k<g.length;k++)g[k].ordinal=k,g[k].blockDepth=Math.max(0,g[k].focalDistance-R),P.push(g[k])}}return{sectionId:e,rows:P,blockCount:y}}var Jo=/^\d{4}-\d{2}-\d{2}$/;function er(e){let t=Date.parse(e);return Number.isFinite(t)?Jo.test(e)?t+864e5:t:null}function tr(e,t=Date.now()){if(e.validUntil===void 0){if(e.status!=="approved")return!0;let r=e.assessedAt?Date.parse(e.assessedAt):Number.NaN;return Number.isFinite(r)&&(t instanceof Date?t.getTime():t)<=r+366*864e5}let n=er(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function nr(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function or(e){return e.status!=="draft"&&e.status!=="retracted"}function rr(e,t){return e.status===void 0?t===void 0:e.status!=="approved"?!0:typeof t=="string"&&typeof e.basisSha256=="string"&&e.basisSha256===t}function Wt(e,t={}){return!!e&&or(e)&&nr(e,t.activeConfigurationId,t.activeConfigurationVersion)&&rr(e,t.activeBasisSha256)&&tr(e,t.now)}var Fs=Math.PI*2;function We(e){return e==="pitch-football"||e==="rink-hockey"||e==="track-athletics"||e==="oval-cricket"}var ir=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,sr=/[\s"'<>`\\]/;function ar(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return ir.test(e);if(sr.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function Zt(e){let t=e.trim();return ar(t)?t:null}var Mt="seatlayer.event-configuration/1";var Re=100,cr=120,ur=2e5,lr=1e4,fr=/^[a-f0-9]{64}$/,mr=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function ke(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function be(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function dr(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function $t(e){return!Array.isArray(e)||e.length>ur||!e.every(t=>be(t,Re))?null:[...new Set(e)].sort()}function br(e){return!ke(e)||!be(e.chartId,Re)||!be(e.version,Re)||e.sha256!==void 0&&(typeof e.sha256!="string"||!fr.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function St(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function pr(e){return ke(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&St(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function hr(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>lr)return null;let n=new Set(t),r=new Set,o=new Set,i=0,s=[];for(let a of e){if(!ke(a)||!be(a.id,Re)||!be(a.objectId,Re)||!n.has(a.objectId)||!mr.has(String(a.kind))||!St(a.heightM,.05,50)||a.baseElevationM!==void 0&&!St(a.baseElevationM,-10,100))return null;let m=pr(a.occlusion);if(!m||r.has(a.id)||o.has(a.objectId))return null;let u=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?Zt(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!u||a.kind!=="screen"||++i>1))return null;r.add(a.id),o.add(a.objectId),s.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:m,...u?{contentImageUrl:u}:{}})}return s.sort((a,m)=>a.id.localeCompare(m.id))}function yr(e){let t=[];if(!ke(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==Mt&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${Mt}`}),be(e.id,Re)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),be(e.label,cr)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),dr(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=br(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let r=ke(e.overlay)?e.overlay:null,o=$t(r?.objectIds),i=$t(r?.productionKillSeatIds),s=o?hr(r?.productionElements,o):null;return(!r||!o||!i)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),s===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!o||!i||s===null?{issues:t}:{issues:t,value:{schema:Mt,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:o,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function Qt(e){let t=yr(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function gr(e){if((e.kind==="polygon"||e.kind==="polyline"||e.kind==="line")&&e.points&&e.points.length>=2)return e.points;if(e.x==null||e.y==null||e.width==null||e.height==null)return null;let t=e.x,n=e.y,r=e.width,o=e.height;return[{x:t,y:n},{x:t+r,y:n},{x:t+r,y:n+o},{x:t,y:n+o}]}function xr(e,t,n){let r=n*Math.PI/180,o=Math.cos(r),i=Math.sin(r),s=e.x-t.x,a=e.y-t.y;return{x:t.x+s*o-a*i,y:t.y+s*i+a*o}}function qt(e){let t=gr(e);if(!t||t.length<2)return null;let n=e.rotation??0,r=Math.abs(n)<1e-6?t:t.map(m=>xr(m,{x:t.reduce((u,l)=>u+l.x,0)/t.length,y:t.reduce((u,l)=>u+l.y,0)/t.length},n)),o=1/0,i=1/0,s=-1/0,a=-1/0;for(let m of r)o=Math.min(o,m.x),i=Math.min(i,m.y),s=Math.max(s,m.x),a=Math.max(a,m.y);return!Number.isFinite(o)||s-o<1e-6||a-i<1e-6?null:{minX:o,minY:i,maxX:s,maxY:a}}var Mr=5,Sr=3,wr=.92,Ir=1.9,vr=2,Rr=.6,Pr=1,Cr=.06;function Er(e){return e.heightM!==void 0?e.heightM:We(e.stageKind)?Cr:Pr}function Jt(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=-1/0;for(let s of nn(e)){let a=s.baseHeightM??0;for(let m of s.objects){if(m.type!=="shape"||m.role!=="stage")continue;let u=qt(m);u&&(t=Math.min(t,u.minX),n=Math.min(n,u.minY),r=Math.max(r,u.maxX),o=Math.max(o,u.maxY),i=Math.max(i,a+Er(m)))}}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minX:t,minY:n,maxX:r,maxY:o,deckTopM:i}}function Ar(e,t,n,r){let o=1/0,i=1/0,s=-1/0,a=-1/0;for(let f of e)Number.isFinite(f.eyeHeightM)&&(o=Math.min(o,f.x),s=Math.max(s,f.x),i=Math.min(i,f.y),a=Math.max(a,f.y));if(!Number.isFinite(o))return null;let m=o*t,u=i*t,l=Math.max(1,Math.ceil((s-o)*t/n)+1),d=Math.max(1,Math.ceil((a-i)*t/n)+1),c=new Float64Array(l*d).fill(-1/0);for(let f of e){if(!Number.isFinite(f.eyeHeightM))continue;let b=f.eyeHeightM-ce,p=Math.min(l-1,Math.max(0,Math.floor((f.x*t-m)/n))),y=Math.min(d-1,Math.max(0,Math.floor((f.y*t-u)/n)))*l+p,x=b+r;x>c[y]&&(c[y]=x)}return{cellM:n,minX:m,minY:u,cols:l,rows:d,top:c}}function _r(e,t,n){let r=Math.floor((t-e.minX)/e.cellM),o=Math.floor((n-e.minY)/e.cellM);return r<0||o<0||r>=e.cols||o>=e.rows?-1/0:e.top[o*e.cols+r]}function en(e,t,n={}){let r=new Map;if(!t||!e.length)return r;let o=n.metresPerChartUnit??te,i=n.cellM??Rr,s=n.chairBackM??wr,a=n.selfRowSkipM??vr,m=n.clearThreshold??.9,u=n.partialThreshold??.25,l=Math.max(1,n.columns??Mr),d=Math.max(1,n.rows??Sr),c=Ar(e,o,i,s);if(!c)return r;let f=(t.maxX-t.minX)*o,b=(t.maxY-t.minY)*o,p=f>=b,h=(t.minX+t.maxX)/2*o,y=(t.minY+t.maxY)/2*o,x=[];for(let w=0;w<l;w++){let P=(w+.5)/l-.5,g=p?h+P*f:h,M=p?y:y+P*b;for(let R=0;R<d;R++){let k=t.deckTopM+(d===1?0:R/(d-1)*Ir);x.push({x:g,y:M,z:k})}}let I=i/2;for(let w of e){if(!Number.isFinite(w.eyeHeightM))continue;let P=w.x*o,g=w.y*o,M=w.eyeHeightM,R=0,k=1/0;for(let U of x){let v=U.x-P,S=U.y-g,T=Math.hypot(v,S);if(!(T>a)){R++;continue}let N=v/T,E=S/T,O=0;for(let A=a;A<T;A+=I){let _=_r(c,P+N*A,g+E*A);if(!(!Number.isFinite(_)||_>=M)&&_>M+(U.z-M)*A/T){O=A;break}}O?k=Math.min(k,O):R++}let L=R/x.length;L>=m||r.set(w.id,{seatId:w.id,mark:L<u?"obstructedView":"restrictedView",visibleFraction:L,totalRays:x.length,atDistanceM:Number.isFinite(k)?k:0})}return r}function tn(e,t){if(!t.size)return 0;let n=0;for(let r of e){let o=t.get(r.id);if(!o)continue;let i=r.commercial;i?.restrictedView!==void 0||i?.obstructedView!==void 0||(r.commercial={...i,[o.mark]:!0},n++)}return n}function wt(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var $e=Math.PI/180;var Te=16;function It(e,t,n,r){let o=n*$e,i=Math.cos(o),s=Math.sin(o);return{x:r.x+e*i-t*s,y:r.y+e*s+t*i}}function cn(e){let{seatCount:t,seatSpacing:n,curve:r,rotation:o,origin:i}=e,s=[];if(e.path)return jt(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(r===0){for(let u=0;u<t;u++)s.push(It(u*n,0,o,i));return s}let a=r/(t-1)*$e,m=n/(2*Math.sin(Math.abs(a)/2));for(let u=0;u<t;u++){let l=u*a,d=m*Math.sin(l),c=-m+m*Math.cos(l);s.push(It(d,c,o,i))}return s}function un(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function kr(e,t){let n=un(e);return cn(e).map((r,o)=>{let i=n.get(o),s=wt(i),a=Vt(e,o,i),m={...e.commercial,...i?.commercial};return{index:o,x:r.x+(i?.dx??0),y:r.y+(i?.dy??0),label:a,displayLabel:pt(e,o,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(m).some(u=>u!==void 0&&u!==!1&&u!=="")?m:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle??e.seatLabelStyle}})}function Tr(e){let t=[];for(let n of kr(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function Lr(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),r={top:0,bottom:0,left:0,right:0};if(!n.length)return r;let o=Math.max(0,Math.round(e.seatCount));for(let i=0;i<o;i++)r[n[i%n.length]]+=1;return r}function Or(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let r=new Map((e.overrides??[]).map(l=>[l.index,l])),o=(l,d,c,f)=>{let b=r.get(l),p=wt(b),h=b?.label??`${e.label}-${l+1}`,y=e.displayLabel??e.label;return{index:l,label:h,displayLabel:b?.displayLabel??`${y}-${l+1}`,x:d+(b?.dx??0),y:c+(b?.dy??0),categoryKey:b?.categoryKey??e.categoryKey,skipped:!!b?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:b?.wheelchairSpaceType,commercial:b?.commercial,glyph:b?.glyph,viewUrl:b?.viewFromSeatUrl,viewMeta:b?.viewFromSeatUrl?b.viewFromSeatMeta:void 0,labelStyle:b?.labelStyle,...f?{side:f}:{}}};if(e.shape==="round"){let l=(e.radius??40)+Te,d=e.rotation*$e,c=Math.max(0,Math.min(360,e.seatArc??360));if(c>=360||n===1){for(let h=0;h<n;h++){let y=d+h/n*2*Math.PI;t.push(o(h,e.center.x+l*Math.cos(y),e.center.y+l*Math.sin(y)))}return t}let f=c*$e,b=(2*Math.PI-f)/2,p=d+b;for(let h=0;h<n;h++){let y=p+h/(n-1)*f;t.push(o(h,e.center.x+l*Math.cos(y),e.center.y+l*Math.sin(y)))}return t}let i=e.width??80,s=e.height??50,a=Lr(e),m=["top","bottom","left","right"],u=0;for(let l of m){let d=a[l];for(let c=0;c<d;c++){let f,b;l==="top"?(f=-i/2+(c+.5)*i/d,b=-s/2-Te):l==="bottom"?(f=-i/2+(c+.5)*i/d,b=s/2+Te):l==="left"?(f=-i/2-Te,b=-s/2+(c+.5)*s/d):(f=i/2+Te,b=-s/2+(c+.5)*s/d);let p=It(f,b,e.rotation,e.center);t.push(o(u++,p.x,p.y,l))}}return t}function Br(e){return Or(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function Fr(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function on(e,t){let n=!1;for(let r=0,o=t.length-1;r<t.length;o=r++){let i=t[r].x,s=t[r].y,a=t[o].x,m=t[o].y;s>e.y!=m>e.y&&e.x<(a-i)*(e.y-s)/(m-s)+i&&(n=!n)}return n}function Dr(e,t){return t.some((n,r)=>{let o=t[(r+1)%t.length],i=(e.y-n.y)*(o.x-n.x)-(e.x-n.x)*(o.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(o.x-n.x)+(e.y-n.y)*(o.y-n.y),a=(o.x-n.x)**2+(o.y-n.y)**2;return s>=-1e-7&&s<=a+1e-7})}function vt(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function pe(e,t,n){return on(e,t)&&!vt(n).some(r=>on(e,r)||Dr(e,r))}function Ze(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;return{x:t/e.length,y:n/e.length}}function ln(e){switch(e.type){case"row":{let t=cn(e),n=un(e),r=0,o=0,i=0;for(let s=0;s<t.length;s++){let a=n.get(s);a?.skip||(r+=t[s].x+(a?.dx??0),o+=t[s].y+(a?.dy??0),i++)}return i?{x:r/i,y:o/i}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Ze(e.points);case"section":return Ze(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Ze(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function rn(e,t){return e.length===t.length&&e.every((n,r)=>n.x===t[r].x&&n.y===t[r].y)}function Nr(e,t){if(e.type!=="gaArea"||!rn(e.points,t.outline))return!1;let n=vt(e.holes),r=vt(t.holes);return n.length===r.length&&n.every((o,i)=>rn(o,r[i]))}function Gr(e,t,n=e.filter(o=>o.type==="section"),r=ln(t)){let o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(o?n.find(s=>(s.logicalSectionId??s.id)===o&&(Nr(t,s)||pe(r,s.outline,s.holes))):void 0)??n.find(s=>pe(r,s.outline,s.holes))}function nn(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function sn(e,t,n,r,o,i,s,a,m){let u=[],l=e.filter(p=>p.type==="section"),d=Yt(e),c=p=>!p?.eventConfigurationId||p.eventConfigurationId===r&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===m),f=p=>Wt(p,{activeConfigurationId:r,activeConfigurationVersion:m,activeBasisSha256:o,now:a}),b=(p,h)=>f(p)?{...p,coverage:h}:void 0;for(let p of e){let h=[];if(p.type==="row"?h=Tr(p):p.type==="table"?h=Br(p):p.type==="booth"&&(h=Fr(p)),!h.length)continue;for(let P of h)P.viewUrl&&!c(P.viewMeta)&&(P.viewUrl=void 0,P.viewMeta=void 0);if(p.type==="row"){let P=d.get(p.id);if(P){let g=new Map((p.overrides??[]).map(M=>[M.index,M]));for(let M of h){let R=Number(M.id.slice(M.id.lastIndexOf(":")+1));if(!Number.isInteger(R))continue;M.logicalRowId=P.groupId,M.logicalSeatIndex=P.adjacencyOffset+R,g.get(R)?.displayLabel||(M.displayLabel=pt(p,R,P)),!M.viewUrl&&P.viewFromSeatUrl&&c(P.viewFromSeatMeta)&&(M.viewUrl=P.viewFromSeatUrl,M.viewMeta=P.viewFromSeatMeta);let k=g.get(R)?.confidenceEvidence;M.confidenceEvidence=b(k,"exact-seat")??b(p.confidenceEvidence,"row-representative")??b(P.confidenceEvidence,"row-representative")}}}let y=Gr(e,p,l,p.type==="row"?Ze(h):ln(p)),x=y?.viewFromSeatUrl,w=(y?.zone?t?.find(P=>P.id===y.zone):void 0)?.focalPoint??n;for(let P of h){if(!P.confidenceEvidence){let g=Number(P.id.slice(P.id.lastIndexOf(":")+1)),M=(p.type==="row"||p.type==="table")&&Number.isInteger(g)?p.overrides?.find(R=>R.index===g)?.confidenceEvidence:void 0;P.confidenceEvidence=b(M,"exact-seat")??(p.type==="row"?b(p.confidenceEvidence,"row-representative"):void 0)}P.confidenceEvidence??=b(y?.confidenceEvidence,"section-representative")??(s?b(s.evidence,s.coverage):void 0),!P.viewUrl&&x&&c(y?.viewFromSeatMeta)&&(P.viewUrl=x,P.viewMeta=y?.viewFromSeatMeta),!P.viewUrl&&i&&c(i.meta)&&(P.viewUrl=i.url,P.viewMeta=i.meta),y&&(P.sectionId=y.logicalSectionId??y.id),y?.zone&&(P.zoneId=y.zone),w&&(P.focalPoint={...w})}u.push(...h)}return u}function fn(e,t={}){if(e.floors?.length){let r=[];for(let o of e.floors){let i=o.focalPoint??e.focalPoint,s=o.viewFromSeatUrl?{url:o.viewFromSeatUrl,meta:o.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=o.confidenceEvidence?{evidence:o.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,m=sn(o.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&an(o.objects,o.focalPoint??e.focalPoint,o.baseHeightM??0,m);for(let u of m)u.floorId=o.id;for(let u of m)r.push(u)}return r}let n=sn(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.confidenceBasisSha256,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);return t.resolveEyeHeights!==!1&&an(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),jr(e,n,t)}function jr(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||tn(t,en(t,Jt(e))),t}function an(e,t,n,r){let o=e.filter(d=>d.type==="section"),i=n>0||o.some(d=>d.height!==void 0||d.rake!==void 0||(d.elevation??0)>0);if(!o.length||!i||!t){for(let d of r)d.eyeHeightM=n+ce;return}let s=new Array(r.length),a=new Map;for(let d of o)a.has(d.id)||a.set(d.id,d);let m=new Map,u=new Map;for(let d=0;d<r.length;d++){let c=r[d],b=(c.sectionId?a.get(c.sectionId)??o.find(h=>h.logicalSectionId===c.sectionId&&pe({x:c.x,y:c.y},h.outline,h.holes)):void 0)??o.find(h=>pe({x:c.x,y:c.y},h.outline,h.holes))??null;if(s[d]=b,!b)continue;m.has(b.id)||m.set(b.id,Ke(b,{floorBaseHeightM:n}));let p=u.get(b.id);p?p.push(d):u.set(b.id,[d])}let l=new Array(r.length).fill(void 0);for(let[d,c]of u){let f=m.get(d);if(!f)continue;let b=f.rake>0?Math.tan(f.rake*Math.PI/180):0,p=ze(d,r,c,t);for(let h of p.rows){let y=h.blockDepth*te*b,x=f.height+y;for(let I of h.seatIndices)l[I]=x}}for(let d=0;d<r.length;d++){let c=r[d],f=s[d];if(!f){c.eyeHeightM=n+ce;continue}let b=m.get(f.id);c.eyeHeightM=(l[d]??b.height)+ce}}var Ur=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Yr(e){let t=Ur.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(o=>o+o).join(""):t[1],r=parseInt(n,16);return[r>>16&255,r>>8&255,r&255]}function W(e){let t=Yr(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function Xr(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function ne(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function Le(e,t){let n=Xr(e);return ne(e,[n,n,n],t)}var Qe=["available","held","sold","selected","dimmed"];function mn(e){let t=Qe.indexOf(e);return t<0?0:t}var dn={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var Rt={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]},Pt={top:[.05,.06,.08],bottom:[.1,.12,.15]};function ie(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var Vr=.15,Hr=1.6;function bn(e){return Ut(e??1,Vr,Hr)}var Kr=.15,zr=.9,Wr=1.76;function Zr(){return{background:{top:[...Pt.top],bottom:[...Pt.bottom]},structure:Rt,seatStates:{...dn},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function pn(e){let t=Zr();if(!e)return t;let n=W(e.background);if(n){t.background={top:ie(n,zr),bottom:ie(n,Wr)};let s={};for(let[a,m]of Object.entries(Rt))s[a]=ne(m,n,Kr);t.structure=s}let r=W(e.selectionColor)??W(e.accent);r&&(t.seatStates={...t.seatStates,selected:r});let o=e.seatScale;typeof o=="number"&&Number.isFinite(o)&&(t.seatScale=bn(o));let i=e.venue3d;if(i){let s=W(i.deck),a=W(i.fascia);s&&(t.structure={...t.structure,tierTop:s,gaTop:s}),a&&(t.structure={...t.structure,tierWall:a,gaWall:a}),t.materials.seat=W(i.seat),t.materials.shell=W(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return t}function hn(e,t){let n=[];for(let r of t)n.push(...e.seatStates[r]);return n}var gn=Ie(require("earcut"),1),xn=Ie(require("polygon-clipping"),1);function he(e){let t=0;for(let n=0,r=e.length;n<r;n+=1){let o=e[n],i=e[(n+1)%r];t+=o.x*i.y-i.x*o.y}return t/2}function Oe(e,t,n){let r=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){let s=e[o],a=e[i];s.y>n!=a.y>n&&t<(a.x-s.x)*(n-s.y)/(a.y-s.y)+s.x&&(r=!r)}return r}var C=te,$r=.002;function Qr(e,t,n){let r=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),o=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.max(r,o,i);if(s<1e-9)return!0;let a=(r+o+i)/2;return 2*Math.sqrt(Math.max(0,a*(a-r)*(a-o)*(a-i)))/s<$r}var ye=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=r}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let r=new Float32Array(n);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},et=class{constructor(){this.pos=new ye;this.nor=new ye;this.col=new ye;this.flr=new ye;this.mat=new ye;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,r,o,i,s=i,a=i){Qr(t,n,r)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(t,n,r,o,i,s,a,m=a,u=a){[...t,...n,...r].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(m[0],m[1],m[2]),this.col.push3(u[0],u[1],u[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 qr(e,t,n){let r=t[0]-e[0],o=t[1]-e[1],i=t[2]-e[2],s=n[0]-e[0],a=n[1]-e[1],m=n[2]-e[2],u=o*m-i*a,l=i*s-r*m,d=r*a-o*s,c=Math.hypot(u,l,d)||1;return u/=c,l/=c,d/=c,[u,l,d]}function Jr(e,t){let n=[...e],r=[];for(let s of e)r.push(s.x,s.y);let o=[];if(t){for(let s of t)if(!(s.length<3)){o.push(n.length);for(let a of s)n.push(a),r.push(a.x,a.y)}}let i=(0,gn.default)(r,o.length?o:void 0,2);return{pts:n,tris:i}}function Ct(e){return he(e)<0?[...e].reverse():e}var ei=3;function ti(e,t,n,r){let o=r(e),i=r(t),s=r(n),a=(f,b,p,h)=>Math.abs(r({x:(f.x+b.x)/2,y:(f.y+b.y)/2})-(p+h)/2),m=(e.x+t.x+n.x)/3,u=(e.y+t.y+n.y)/3,l=(o+i+s)/3,d=Math.max(a(e,t,o,i),a(t,n,i,s),a(n,e,s,o),Math.abs(r({x:m,y:u})-l)),c=(f,b,p)=>{let h=Math.abs(r({x:(f+m)/2,y:(b+u)/2})-(p+l)/2);h>d&&(d=h)};return c((e.x+t.x)/2,(e.y+t.y)/2,(o+i)/2),c((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),c((n.x+e.x)/2,(n.y+e.y)/2,(s+o)/2),d}function Be(e,t,n,r,o){if(o<=0)return ti(e,t,n,r);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(Be(e,i,a,r,o-1),Be(i,t,s,r,o-1),Be(a,s,n,r,o-1),Be(i,s,a,r,o-1))}function Fe(e,t,n,r,o,i,s,a){if(s>0){let c={x:(t.x+n.x)/2,y:(t.y+n.y)/2},f={x:(n.x+r.x)/2,y:(n.y+r.y)/2},b={x:(r.x+t.x)/2,y:(r.y+t.y)/2};Fe(e,t,c,b,o,i,s-1,a),Fe(e,c,n,f,o,i,s-1,a),Fe(e,b,f,r,o,i,s-1,a),Fe(e,c,f,b,o,i,s-1,a);return}let m=[t.x*C,o(t),t.y*C],u=[n.x*C,o(n),n.y*C],l=[r.x*C,o(r),r.y*C];if(a){e.triN(m,u,l,a(t),a(n),a(r),i);return}let d=qr(m,u,l);d[1]<0&&(d=[-d[0],-d[1],-d[2]]),e.tri(m,u,l,d,i)}var ni=8;function yn(e,t,n){if(!Number.isFinite(n))return e;let r=[],o=(i,s,a,m,u)=>{if(u>0){let l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},d=t(l);if(Math.abs(d-(a+m)/2)>n){o(i,l,a,d,u-1),o(l,s,d,m,u-1);return}}r.push(i)};for(let i=0;i<e.length;i++){let s=e[i],a=e[(i+1)%e.length];o(s,a,t(s),t(a),ni)}return r}function qe(e,t){if(e.length<3)return e;let n=[];for(let o of e){let i=n[n.length-1];i&&Math.hypot(o.x-i.x,o.y-i.y)<t||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let r=[];for(let o=0;o<n.length;o++){let i=r.length?r[r.length-1]:n[(o-1+n.length)%n.length],s=n[o],a=n[(o+1)%n.length],m=a.x-i.x,u=a.y-i.y,l=Math.hypot(m,u);l>t&&Math.abs((s.x-i.x)*u-(s.y-i.y)*m)/l<t||r.push(s)}return r.length>=3?r:n}var Je=.001*me*.1;function J(e,t,n,r,o,i,s,a,m=1/0,u){if(!t||t.length<3||(m===void 0&&(m=1/0),Math.abs(he(t))<1e-4))return;let l=qe(yn(qe(Ct(t),Je),r,m),Je),d=n?.map(g=>qe(yn(qe(Ct(g),Je),r,m),Je)).filter(g=>g.length>=3&&Math.abs(he(g))>=1e-4),{pts:c,tris:f}=Jr(l,d),b=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],h=[s[0]*a.top,s[1]*a.top,s[2]*a.top],y=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],x=0;if(Number.isFinite(m))for(;x<ei;x++){let g=0;for(let M=0;M<f.length;M+=3){let R=Be(c[f[M]],c[f[M+1]],c[f[M+2]],r,x);R>g&&(g=R)}if(g<=m)break}for(let g=0;g<f.length;g+=3){let M=c[f[g]],R=c[f[g+1]],k=c[f[g+2]];Fe(e,M,R,k,r,b,x,u);let L=[M.x*C,o,M.y*C],U=[R.x*C,o,R.y*C],v=[k.x*C,o,k.y*C];e.tri(L,v,U,[0,-1,0],p)}let I=g=>{if(x<=0)return g;let M=1<<x,R=[];for(let k=0;k<g.length;k++){let L=g[k],U=g[(k+1)%g.length];for(let v=0;v<M;v++){let S=v/M;R.push({x:L.x+(U.x-L.x)*S,y:L.y+(U.y-L.y)*S})}}return R},w=dt(l),P=[{ring:I(l),flip:!1}];if(d)for(let g of d)g.length>=3&&P.push({ring:I(g),flip:!0});for(let{ring:g,flip:M}of P)for(let R=0;R<g.length;R++){let k=g[R],L=g[(R+1)%g.length],U=(L.x-k.x)*C,S=(L.y-k.y)*C,T=-U,N=Math.hypot(S,T)||1;S/=N,T/=N;let E=(k.x+L.x)/2-w.x,O=(k.y+L.y)/2-w.y,A=S*E+T*O;M&&(A=-A),A<0&&(S=-S,T=-T);let _=[S,0,T],B=[k.x*C,r(k),k.y*C],D=[L.x*C,r(L),L.y*C],F=[k.x*C,o,k.y*C],j=[L.x*C,o,L.y*C];e.tri(B,D,j,_,h,h,y),e.tri(B,j,F,_,h,y,y)}}function Mn(e){let t=0;for(let m of e)t+=m.count;let n=new Float32Array(t*3),r=new Float32Array(t*3),o=new Float32Array(t*3),i=new Float32Array(t),s=new Float32Array(t),a=0;for(let m of e)n.set(m.position,a*3),r.set(m.normal,a*3),o.set(m.color,a*3),i.set(m.floor,a),s.set(m.material,a),a+=m.count;return{position:n,normal:r,color:o,floor:i,material:s,count:t}}function tt(e,t,n=2.5){if(t<=0||e.length<3)return e;let r=Ct(e),o=r.length,i=[];for(let a=0;a<o;a++){let m=r[a],u=r[(a+1)%o],l=u.x-m.x,d=u.y-m.y,c=Math.hypot(l,d)||1;i.push({x:d/c,y:-l/c})}let s=[];for(let a=0;a<o;a++){let m=r[a],u=i[(a-1+o)%o],l=i[a],d=u.x+l.x,c=u.y+l.y,f=Math.hypot(d,c),b=()=>{s.push([m.x+u.x*t,m.y+u.y*t]),s.push([m.x+l.x*t,m.y+l.y*t])};if(f<1e-9){b();continue}d/=f,c/=f;let p=d*u.x+c*u.y,h=1/Math.max(p,1e-6);if(!Number.isFinite(h)||h>n){b();continue}s.push([m.x+d*t*h,m.y+c*t*h])}if(s.length<3)return e;try{let a=xn.default.union([[...s,s[0]]]),m=null,u=-1/0;for(let d of a){let c=Math.abs(he(d[0].map(([f,b])=>({x:f,y:b}))));c>u&&(u=c,m=d[0])}if(!m)return e;let l=m.map(([d,c])=>({x:d,y:c}));if(l.length>1){let d=l[0],c=l[l.length-1];Math.abs(d.x-c.x)<1e-9&&Math.abs(d.y-c.y)<1e-9&&l.pop()}return l.length>=3?l:e}catch{return e}}function nt(e,t,n,r,o=28){let i=[];for(let s=0;s<o;s++){let a=s/o*Math.PI*2;i.push({x:e+n*Math.cos(a),y:t+r*Math.sin(a)})}return i}function De(e,t,n,r){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}]}var oi=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],xa=new Map(oi.map(e=>[e.key,e]));var ri={wheelchair:"#3b82f6",companion:"#8b5cf6","semi-ambulatory":"#0ea5e9","designated-aisle":"#0284c7","step-free":"#16a34a",hearing:"#14b8a6",cart:"#7c3aed","sign-language":"#f59e0b","low-vision":"#d97706","sensory-friendly":"#6366f1","plus-size":"#ec4899","lift-armrest":"#22c55e"};function Sn(e){let t=e?.[0];return t&&ri[t]||"#3b82f6"}var ii=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],Ma=new Map(ii.map(e=>[e.key,e]));var si=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Sa=new Set(si);var In=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],vn=In.map(e=>e.key),ai=new Map(In.map(e=>[e.key,e]));function wn(e){return typeof e=="string"&&ai.has(e)}function Rn(e,t){return wn(e)?e:wn(t?.seatGlyph)?t.seatGlyph:"circle"}var ee={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},ci=.44,ui=.15,li=.3,fi=.24;function Pn(e){return e===void 0||!Number.isFinite(e)||e<=0?fi:Math.min(li,Math.max(ui,e*ci))}var mi=.05,Cn=.45,di=Cn+mi,bi=.92;var Pa=[{part:ee.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ee.pad,min:[-1,.36,-.95],max:[1,Cn,1]},{part:ee.back,min:[-1,di,-1],max:[1,bi,-.72]},{part:ee.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ee.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ee.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ee.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ee.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ee.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ee.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Ca=[{part:ee.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ee.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ee.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ee.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ee.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function En(e,t,n,r){let o=new Float32Array(t),i=u=>e[u*3],s=u=>e[u*3+2],a=0,m=(u,l)=>{let d=l-u;for(let c=u;c<l;c++){let[f,b]=r(c),p=f-i(c),h=b-s(c);if(d>=2){let y=Math.max(u,c-1),x=Math.min(l-1,c+1),I=i(x)-i(y),w=s(x)-s(y),P=Math.hypot(I,w);if(P>1e-6){let g=-w/P,M=I/P;g*p+M*h<0&&(g=-g,M=-M),p=g,h=M}}o[c]=p===0&&h===0?0:Math.atan2(p,h)}};for(let u=1;u<=t;u++)(u===t||n(u)!==n(a))&&(m(a,u),a=u);return o}var ot=.22;var pi=.42;function hi(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let b of e)b.x<r&&(r=b.x),b.y<o&&(o=b.y),b.x>i&&(i=b.x),b.y>s&&(s=b.y);let a=Math.max(i-r,1e-6),m=Math.max(s-o,1e-6),u=Math.max(Math.sqrt(a*m/t),1e-6),l=Math.max(1,Math.ceil(a/u)+1),d=Math.max(1,Math.ceil(m/u)+1),c=new Map,f=(b,p)=>{let h=Math.min(l-1,Math.max(0,Math.floor((b-r)/u)));return Math.min(d-1,Math.max(0,Math.floor((p-o)/u)))*l+h};for(let b=0;b<t;b++){let p=f(e[b].x,e[b].y),h=c.get(p);h?h.push(b):c.set(p,[b])}for(let b=0;b<t;b++){let p=e[b],h=Math.min(l-1,Math.max(0,Math.floor((p.x-r)/u))),y=Math.min(d-1,Math.max(0,Math.floor((p.y-o)/u))),x=1/0;for(let I=1;I<=4;I++){for(let w=y-I;w<=y+I;w++)if(!(w<0||w>=d))for(let P=h-I;P<=h+I;P++){if(P<0||P>=l||I>1&&Math.abs(w-y)<I&&Math.abs(P-h)<I)continue;let g=c.get(w*l+P);if(g)for(let M of g){if(M===b)continue;let R=Math.hypot(e[M].x-p.x,e[M].y-p.y);R<x&&(x=R)}}if(Number.isFinite(x)&&x<=I*u)break}n[b]=x}return n}function yi(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-ce):0}function An(e,t,n,r,o,i){let s=e.length,a=new Float32Array(s*3),m=new Float32Array(s),u=new Float32Array(s*3),l=new Float32Array(s),d=new Float32Array(s),c=new Float32Array(s),f=new Float32Array(s),b=new Float32Array(s*3),p=new Map,h=hi(e);for(let y=0;y<s;y++){let x=e[y],w=(n?.seatPitchU(y)??h[y])*C;l[y]=Number.isFinite(w)?Math.max(.06,Math.min(ot,w*pi)):ot,d[y]=Pn(Number.isFinite(w)?w:void 0);let P=Rn(x.glyph,{seatGlyph:i?.get(x.categoryKey)});c[y]=vn.indexOf(P),f[y]=x.wheelchairSpaceType==="no-seat"?0:1,a[y*3]=x.x*C,a[y*3+1]=n?n.seatDeckY(y):yi(x),a[y*3+2]=x.y*C,m[y]=mn(t?t(x):"available");let g=W(o?.get(x.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[y*3]=g[0],u[y*3+1]=g[1],u[y*3+2]=g[2],x.accessibility?.length){let M=W(Sn(x.accessibility));M&&(b[y*3]=M[0],b[y*3+1]=M[1],b[y*3+2]=M[2])}p.set(x.id,y)}return{count:s,iPosition:a,iState:m,iCategory:u,iMaxRadius:l,iRing:b,idToIndex:p,iChairWidth:d,iGlyph:c,iPhysicalSeat:f,iFloor:r??new Float32Array(s),iYaw:new Float32Array(s)}}function gi(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let r=t-e.x,o=n-e.y,i=Math.hypot(r,o);return i<1e-9?[0,0]:[r/i,o/i]}}}function xi(e,t){if(!e.length)return null;let n=0,r=0,o=0;for(let f of e)n+=f.x,r+=f.y,o+=Math.hypot(f.x-t.x,f.y-t.y);let i=e.length;n/=i,r/=i,o/=i;let s=e[0],a=-1;for(let f of e){let b=Math.hypot(f.x-n,f.y-r);b>a&&(a=b,s=f)}let m=s.x-n,u=s.y-r,l=Math.hypot(m,u);l>1e-9?(m/=l,u/=l):(m=1,u=0);let d=[...e].sort((f,b)=>(f.x-n)*m+(f.y-r)*u-((b.x-n)*m+(b.y-r)*u)),c=0;for(let f of d){let b=Math.hypot(f.x-n,f.y-r);b>c&&(c=b)}return{pts:d,cx:n,cy:r,radius:c,depth:o}}function _n(e,t,n){let r=e.pts;if(r.length===1)return Math.hypot(t-r[0].x,n-r[0].y);let o=1/0;for(let i=0;i+1<r.length;i++){let s=r[i],a=r[i+1],m=a.x-s.x,u=a.y-s.y,l=m*m+u*u,d=l>1e-12?((t-s.x)*m+(n-s.y)*u)/l:0;d<0?d=0:d>1&&(d=1);let c=Math.hypot(t-(s.x+d*m),n-(s.y+d*u));c<o&&(o=c)}return o}var rt=8;function Mi(e,t,n){let r=new Array(rt).fill(1/0),o=new Array(rt).fill(-1);for(let l=0;l<e.length;l++){let d=e[l],c=Math.hypot(t-d.cx,n-d.cy)-d.radius;for(let f=0;f<rt;f++)if(c<r[f]){for(let b=rt-1;b>f;b--)r[b]=r[b-1],o[b]=o[b-1];r[f]=c,o[f]=l;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let l of o){if(l<0)continue;let d=_n(e[l],t,n);for(let c=0;c<3;c++)if(d<i[c]){for(let f=2;f>c;f--)i[f]=i[f-1],s[f]=s[f-1];i[c]=d,s[c]=l;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,m=0,u=0;for(let l=0;l<3;l++){let d=s[l];if(d<0||i[l]>a)continue;let c=1/(i[l]*i[l]);m+=c*e[d].depth,u+=c}return u>0?m/u:e[s[0]].depth}function Si(e){let t=(r,o)=>Mi(e,r,o),n=(r,o)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let m=e[a];if(Math.hypot(r-m.cx,o-m.cy)-m.radius>=i)continue;let u=_n(m,r,o);u<i&&(i=u,s=a)}return s};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(r,o)=>{let i=(t(r+.5,o)-t(r-.5,o))/1,s=(t(r,o+.5)-t(r,o-.5))/(2*.5),a=Math.hypot(i,s);return a<1e-9?[0,0]:[i/a,s/a]}}}function kn(e,t){let n=[];for(let r of e){let o=xi(r.points,t);o&&n.push(o)}return n.length<2?gi(t):(n.sort((r,o)=>r.depth-o.depth),Si(n))}var _t=Ie(require("polygon-clipping"),1);var Bn=Ie(require("earcut"),1);var wi=.58,Tn=.01,se=ot*1.5*me,Ii=.5,vi=.6;function Ri(e,t){let n=e.length,r=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],m=e[Math.min(n-1,s+1)],u=m.x-a.x,l=m.y-a.y,d=Math.hypot(u,l);if(d<1e-9){r.push([0,0]);continue}u/=d,l/=d,r.push([-l,u])}let o=0;for(let s=0;s<n;s++)o+=(e[s].x-t.x)*r[s][0]+(e[s].y-t.y)*r[s][1];return o<0?r.map(([s,a])=>[-s,-a]):r}function Pi(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],r=(s,a)=>{let m=a.x-s.x,u=a.y-s.y,l=Math.hypot(m,u)||1;return{x:m/l,y:u/l}},o=r(n[1],n[0]),i=r(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*t,y:n[0].y+o.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var Ln=Math.PI/12;function Ci(e){if(e.length<3)return[...e];let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),r=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},o=[...r(t),...r([...t].reverse())];return o.length>=3?o:[...e]}function Fn(e,t){if(!e.length||!(t>0))return[];let n=Ci(e),r=(a,m,u,l)=>{let d=u-m;for(;d<0;)d+=Math.PI*2;for(;d>Math.PI*2;)d-=Math.PI*2;let c=Math.max(1,Math.ceil(d/Ln)),f=t/Math.cos(d/c/2);for(let b=0;b<=c;b++){let p=m+d*b/c;l.push({x:a.x+Math.cos(p)*f,y:a.y+Math.sin(p)*f})}};if(n.length<3){let a=0,m=0;for(let f of n)a+=f.x,m+=f.y;a/=n.length||1,m/=n.length||1;let u=0;for(let f of n)u=Math.max(u,Math.hypot(f.x-a,f.y-m));let l=[],d=Math.max(3,Math.ceil(Math.PI*2/Ln)),c=(u+t)/Math.cos(Math.PI/d);for(let f=0;f<d;f++){let b=f/d*Math.PI*2;l.push({x:a+Math.cos(b)*c,y:m+Math.sin(b)*c})}return l}let o=n.length,i=[];for(let a=0;a<o;a++){let m=n[a],u=n[(a+1)%o];i.push(Math.atan2(-(u.x-m.x),u.y-m.y))}let s=[];for(let a=0;a<o;a++)r(n[a],i[(a+o-1)%o],i[a],s);return Un(s)}function Ei(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let r=1/0;for(let o=0;o+1<e.length;o++){let i=e[o],s=e[o+1],a=s.x-i.x,m=s.y-i.y,u=a*a+m*m,l=u>1e-12?((t-i.x)*a+(n-i.y)*m)/u:0;l<0?l=0:l>1&&(l=1);let d=Math.hypot(t-(i.x+l*a),n-(i.y+l*m));d<r&&(r=d)}return r}function it(e){let t=e.map(o=>{let i=0,s=0;for(let u of o.pts)i+=u.x,s+=u.y;let a=o.pts.length||1;i/=a,s/=a;let m=0;for(let u of o.pts){let l=Math.hypot(u.x-i,u.y-s);l>m&&(m=l)}return{cx:i,cy:s,rad:m}}),n=o=>{let i=o.length;return i<=2?[...o]:[o[Math.floor(i*.25)],o[Math.floor(i*.5)],o[Math.floor(i*.75)]]},r=[];for(let o=0;o<e.length;o++){let i=n(e[o].pts),s=[],a=1/0,m=null;for(let l of i){let d=1/0;for(let c=0;c<e.length;c++){if(c===o||Math.abs(e[c].y-e[o].y)<.001)continue;let f=t[c],b=Math.hypot(l.x-f.cx,l.y-f.cy)-f.rad;if(b>=d&&b>=a)continue;let p=Ei(e[c].pts,l.x,l.y);p<d&&(d=p),e[c].depth<e[o].depth&&p<a&&(a=p,m=e[c].y)}Number.isFinite(d)&&d>0&&s.push(d)}s.sort((l,d)=>l-d);let u=s.length?s[Math.floor(s.length/2)]:1;r.push({pitch:u,belowY:m})}return r}function Dn(e,t,n,r){let o=e[t],i=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let l=o.pts[0],d=l.x-r.x,c=l.y-r.y,f=Math.hypot(d,c)||1;d/=f,c/=f;let b=Math.max(n[t].pitch,.001)*.5;return[{x:l.x+c*b,y:l.y-d*b},{x:l.x-c*b,y:l.y+d*b}]})():[];if(i.length<2)return null;let s=0,a=0;for(let l=1;l<i.length;l++){let d=Math.hypot(i[l].x-i[l-1].x,i[l].y-i[l-1].y);d>1e-6&&(s+=d,a++)}let m=a>0?s/a:0,u=Pi(i,Math.max(m*vi,se));return{pts:u,nrm:Ri(u,r),front:Math.max(n[t].pitch*wi,se),back:Math.max(n[t].pitch*Ii,se)}}var Pe=1.5,Nn=.3;function Et(e,t){if(e.length<3)return e;let n=e[0],r=e[e.length-1],o=r.x-n.x,i=r.y-n.y,s=Math.hypot(o,i),a=-1,m=-1;for(let d=1;d<e.length-1;d++){let c=e[d],f=s>1e-12?Math.abs((c.x-n.x)*i-(c.y-n.y)*o)/s:Math.hypot(c.x-n.x,c.y-n.y);f>a&&(a=f,m=d)}if(a<=t||m<0)return[n,r];let u=Et(e.slice(0,m+1),t),l=Et(e.slice(m),t);return[...u.slice(0,-1),...l]}function Gn(e,t){if(e.length<4)return e;let n=Et([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function jn(e,t,n){if(e.length<2)return[];let r=n??it(e),o=new Map;for(let s=0;s<e.length;s++){let a=o.get(e[s].blockId);a?a.push(s):o.set(e[s].blockId,[s])}let i=[];for(let[,s]of o){let a=[];for(let x of s){let I=e[x].patch;I&&I.length>=3?i.push({outline:[...I],holes:[],topY:e[x].y}):a.push(x)}if(!a.length)continue;a.sort((x,I)=>e[x].depth-e[I].depth);let u=a.map(x=>Dn(e,x,r,t)).filter(x=>x!==null);if(!u.length)continue;let l=(x,I)=>({x:x.pts[I].x-x.nrm[I][0]*(x.front+Pe),y:x.pts[I].y-x.nrm[I][1]*(x.front+Pe)}),d=(x,I)=>({x:x.pts[I].x+x.nrm[I][0]*(x.back+Pe),y:x.pts[I].y+x.nrm[I][1]*(x.back+Pe)}),c=u[0],f=u[u.length-1],b=[];for(let x=0;x<c.pts.length;x++)b.push(l(c,x));for(let x of u)b.push(d(x,x.pts.length-1));for(let x=f.pts.length-1;x>=0;x--)b.push(d(f,x));for(let x=u.length-1;x>=0;x--)b.push(l(u[x],0));let p=Un(b),h=1/0;for(let x of a)e[x].y<h&&(h=e[x].y);if(!Number.isFinite(h))continue;if(p.length>=3&&Math.abs(he(p))>1e-6&&u.every(x=>{let I=x.pts[Math.floor(x.pts.length/2)];return Oe(p,I.x,I.y)})){i.push({outline:Gn(p,Nn),holes:[],topY:h});continue}for(let x of Ai(u))i.push({outline:x,holes:[],topY:h})}return i}function Ai(e){let t=[];for(let n of e){let r=[],o=[],i=n.front+Pe,s=n.back+Pe;for(let m=0;m<n.pts.length;m++){let u=n.pts[m],l=n.nrm[m];r.push([u.x-l[0]*i,u.y-l[1]*i]),o.push([u.x+l[0]*s,u.y+l[1]*s])}let a=[...r,...o.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=_t.default.union(t[0],...t.slice(1)),r=[];for(let o of n){if(!o.length||o[0].length<4)continue;let i=o[0].map(([m,u])=>({x:m,y:u})),s=i[0],a=i[i.length-1];i.length>1&&Math.abs(s.x-a.x)<1e-9&&Math.abs(s.y-a.y)<1e-9&&i.pop(),i.length>=3&&r.push(Gn(i,Nn))}return r}catch{return[]}}function Un(e){let t=[];for(let n of e){let r=t[t.length-1];r&&Math.hypot(n.x-r.x,n.y-r.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var At=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let r of n)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let r=!0;for(let o of t)if(!Oe(n,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function On(e,t,n,r,o,i){if(r.length<3)return;if(n.containsAll(r)){let u=[0,1,0],l=r[0];for(let d=1;d+1<r.length;d++){let c=r[d],f=r[d+1];e.tri([l.x*C,o,l.y*C],[c.x*C,o,c.y*C],[f.x*C,o,f.y*C],u,i)}return}let s=r.map(u=>[u.x,u.y]);s.push(s[0]);let a;try{a=_t.default.intersection([s],t)}catch{return}let m=[0,1,0];for(let u of a){if(!u.length||u[0].length<4)continue;let l=u[0],d=[],c=[];for(let b=0;b<l.length-1;b++)d.push(l[b][0],l[b][1]),c.push([l[b][0],l[b][1]]);if(c.length<3)continue;let f=(0,Bn.default)(d,void 0,2);for(let b=0;b<f.length;b+=3){let p=c[f[b]],h=c[f[b+1]],y=c[f[b+2]];e.tri([p[0]*C,o,p[1]*C],[h[0]*C,o,h[1]*C],[y[0]*C,o,y[1]*C],m,i)}}}function Yn(e,t,n,r,o,i,s){if(t.length<2)return;let a=s??it(t),m=[0,1,0],u=i&&i.length>=3?[[...i.map(f=>[f.x,f.y]),[i[0].x,i[0].y]]]:null,l=i&&i.length>=3?new At([[...i]]):null,d=f=>{e.setMaterial(2),f(),e.setMaterial(0)},c=f=>{e.setMaterial(3),f(),e.setMaterial(0)};for(let f=0;f<t.length;f++){let b=t[f];if(b.patch&&b.patch.length>=3){let P=[...b.patch],g=a[f].belowY??r;if(c(()=>{if(u&&l)On(e,u,l,P,b.y,o.tread);else{let M=P[0];for(let R=1;R+1<P.length;R++){let k=P[R],L=P[R+1];e.tri([M.x*C,b.y,M.y*C],[k.x*C,b.y,k.y*C],[L.x*C,b.y,L.y*C],m,o.tread)}}}),b.y>g+Tn){let M=0,R=0;for(let k of P)M+=k.x,R+=k.y;M/=P.length,R/=P.length,d(()=>{for(let k=0;k<P.length;k++){let L=P[k],U=P[(k+1)%P.length],v=U.x-L.x,S=U.y-L.y,T=Math.hypot(v,S);if(T<1e-6)continue;let N=S/T,E=-v/T;(L.x-M)*N+(L.y-R)*E<0&&(N=-N,E=-E);let O=[N,0,E],A=[L.x*C,b.y,L.y*C],_=[U.x*C,b.y,U.y*C],B=[L.x*C,g,L.y*C],D=[U.x*C,g,U.y*C];e.tri(A,_,D,O,o.riser),e.tri(A,D,B,O,o.riser)}})}continue}let p=Dn(t,f,a,n);if(!p)continue;let{pts:h,nrm:y,front:x,back:I}=p,w=a[f].belowY??r;for(let P=0;P+1<h.length;P++){let g=h[P],M=h[P+1],R=y[P],k=y[P+1];if(Math.hypot(M.x-g.x,M.y-g.y)<1e-6||R[0]===0&&R[1]===0||k[0]===0&&k[1]===0)continue;let L=[(g.x-R[0]*x)*C,b.y,(g.y-R[1]*x)*C],U=[(M.x-k[0]*x)*C,b.y,(M.y-k[1]*x)*C],v=[(g.x+R[0]*I)*C,b.y,(g.y+R[1]*I)*C],S=[(M.x+k[0]*I)*C,b.y,(M.y+k[1]*I)*C];if(c(()=>{u&&l?On(e,u,l,[{x:g.x-R[0]*x,y:g.y-R[1]*x},{x:M.x-k[0]*x,y:M.y-k[1]*x},{x:M.x+k[0]*I,y:M.y+k[1]*I},{x:g.x+R[0]*I,y:g.y+R[1]*I}],b.y,o.tread):(e.tri(L,U,S,m,o.tread),e.tri(L,S,v,m,o.tread))}),b.y>w+Tn){let T=[L[0],w,L[2]],N=[U[0],w,U[2]],E=[-R[0],0,-R[1]];d(()=>{e.tri(L,U,N,E,o.riser),e.tri(L,N,T,E,o.riser)})}}}}function Xn(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=!1;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(i=!0,s.x<t&&(t=s.x),s.y<n&&(n=s.y),s.x>r&&(r=s.x),s.y>o&&(o=s.y));return i?{minX:t,minY:n,maxX:r,maxY:o}:null}function st(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var kt=Ie(require("polygon-clipping"),1);function _i(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function Vn(e,t){return e.filter(n=>n.type!=="shape"||_i(n,t))}function Hn(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((r,o)=>({objects:Vn(r.objects,t),focal:{x:(r.focalPoint??n).x,y:(r.focalPoint??n).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:Vn(e.objects,t),focal:n,baseHeightM:0,index:0}]}var ki={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Ce(e){return Xn(e)??ki}function Kn(e,t){let n=tt(e.outline,se),r=Ce(n),o=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&st(r,Ce(s.outline)));if(!o.length)return[n];let i=s=>{let a=s.map(m=>[m.x,m.y]);return a.push(a[0]),a};try{let s=kt.default.difference([i(n)],...o.map(m=>[i(m.outline)])),a=[];for(let m of s){if(!m.length)continue;let u=m[0].map(([l,d])=>({x:l,y:d}));if(u.length>1){let l=u[0],d=u[u.length-1];Math.abs(l.x-d.x)<1e-9&&Math.abs(l.y-d.y)<1e-9&&u.pop()}u.length>=3&&a.push(u)}return a.length?a:[n]}catch{return[n]}}function zn(e,t){if(!t.length)return e;let n=i=>{let s=i.map(a=>[a.x,a.y]);return s.push(s[0]),s},r=t.map(i=>[n(i)]),o=[];for(let i of e){let s;try{s=kt.default.intersection([n(i.outline)],r.flat())}catch{o.push(i);continue}for(let a of s){if(!a.length)continue;let m=a[0].map(([u,l])=>({x:u,y:l}));if(m.length>1){let u=m[0],l=m[m.length-1];Math.abs(u.x-l.x)<1e-9&&Math.abs(u.y-l.y)<1e-9&&m.pop()}m.length>=3&&o.push({outline:m,holes:[],topY:i.topY})}}return o.length?o:e}var Ti=.05,Wn=.05,Li=.15,Tt=25;function Zn(e,t,n){let r=new Map,o=new Array(t.length).fill(null),i=new Float64Array(t.length),s=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),m=new Map,u=[],l=new Set;for(let c=0;c<e.length;c+=1){let f=e[c];for(let b of f.objects){if(b.type==="table"&&l.add(b.id),b.type!=="section"||!b.outline||b.outline.length<3)continue;let p=tt(b.outline,se);m.set(b.id,{section:b,unit:f,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),u.push({id:b.id,floorIndex:c,box:Ce(p),section:b,unit:f,outline:p})}}let d=new Map;for(let c of u){let f=d.get(c.floorIndex);f?f.push(c):d.set(c.floorIndex,[c])}for(let c=0;c<t.length;c++){let f=t[c],b=n?d.get(n[c])??[]:u,p=f.sectionId?b.find(y=>y.id===f.sectionId)??b.find(y=>y.section.logicalSectionId===f.sectionId&&pe({x:f.x,y:f.y},y.outline,y.section.holes)):void 0,h=p?[p]:b;for(let y of h){if(n&&y.floorIndex!==n[c]||!p&&(f.x<y.box.minX||f.x>y.box.maxX||f.y<y.box.minY||f.y>y.box.maxY||!pe({x:f.x,y:f.y},y.outline,y.section.holes)))continue;o[c]=y.id;let x=m.get(y.id);x.hasSeats=!0;let I=f.focalPoint??y.unit.focal,w=Math.hypot(f.x-I.x,f.y-I.y);w<x.frontU&&(x.frontU=w),x.seatIndices.push(c);let P=f.rowId||`__seat-${c}`,g=x.rows.get(P);g?g.push({x:f.x,y:f.y}):x.rows.set(P,[{x:f.x,y:f.y}]);break}}for(let[c,f]of m){let b=Ke(f.section,{floorBaseHeightM:f.unit.baseHeightM}),p=f.unit.baseHeightM,h=b.rake>0?Math.tan(b.rake*Math.PI/180):0,y=b.rake<=.01&&b.height<=p+.001,x=f.section.surfaceKind,I=x==="flat"?!0:x==="rakedRows"&&b.rake>.01?!1:y,w=f.hasSeats?ze(c,t,f.seatIndices,f.unit.focal):{sectionId:c,rows:[],blockCount:0},g=w.rows.length<2?kn([...f.rows.values()].map(A=>({points:A})),f.unit.focal):null,M=1/0;if(g){if(f.hasSeats)for(let A of f.rows.values())for(let _ of A){let B=g.depthAt(_.x,_.y);B<M&&(M=B)}if(!f.hasSeats||!Number.isFinite(M)){M=1/0;for(let A of f.section.outline){let _=g.depthAt(A.x,A.y);_<M&&(M=_)}}}let R=p+Ti,k=Math.max(R,b.height),L=A=>{let _=Math.max(0,A-M)*te,B=Math.min(_*h,Tt);return Math.max(R,b.height+B)},U=A=>{let _=Math.max(0,A)*te,B=Math.min(_*h,Tt);return Math.max(R,b.height+B)},v=I?[]:w.rows.map(A=>({pts:A.pts,y:U(A.blockDepth),depth:A.blockDepth,blockId:A.blockId,...l.has(A.id)?{patch:Fn(A.pts,se)}:{}})),S=v.length?v[0].y:k,T=v.map(A=>{let _=A.patch&&A.patch.length>=3?A.patch:A.pts,B=0,D=0;for(let Y of _)B+=Y.x,D+=Y.y;let F=_.length||1;B/=F,D/=F;let j=0;for(let Y of _){let X=Math.hypot(Y.x-B,Y.y-D);X>j&&(j=X)}return{cx:B,cy:D,rad:j}}),N=I?()=>k:v.length>=2?(A,_)=>{let B=1/0,D=S;for(let F=0;F<v.length;F++){let j=T[F];if(Math.hypot(A-j.cx,_-j.cy)-j.rad>=B)continue;let Y=v[F].patch,X=Y&&Y.length>=3?Oe(Y,A,_)?0:ve(Y,A,_):ve(v[F].pts,A,_);X<B&&(B=X,D=v[F].y)}return D}:(A,_)=>g?L(g.depthAt(A,_)):k,E=[0,1,0],O=v.length>=2||I?()=>E:(A,_)=>{if(!g)return E;let B=g.depthAt(A,_);if(B<=M)return E;let D=(B-M)*te;if(D*h>=Tt||b.height+D*h<=R)return E;let[F,j]=g.gradientAt(A,_);if(F===0&&j===0)return E;let Y=1/Math.hypot(h,1);return[-F*h*Y,Y,-j*h*Y]};if(!I)for(let A of w.rows){let _=U(A.blockDepth);for(let B of A.seatIndices)s[B]=_}for(let A of w.rows){let _=[];for(let Y=1;Y<A.pts.length;Y++){let X=Math.hypot(A.pts[Y].x-A.pts[Y-1].x,A.pts[Y].y-A.pts[Y-1].y);X>1e-6&&_.push(X)}_.sort((Y,X)=>Y-X);let B=_.length?_[Math.floor(_.length/2)]:1/0,D=1/0,F=A.pts[Math.floor(A.pts.length/2)];if(F)for(let Y of w.rows){if(Y===A||Y.blockId!==A.blockId)continue;let X=ve(Y.pts,F.x,F.y);X>1e-6&&X<D&&(D=X)}let j=Math.min(B,Math.max(D,B*.5));if(Number.isFinite(j)&&j>0)for(let Y of A.seatIndices)a[Y]=j}r.set(c,{sectionId:c,deckAt:N,normalAt:O,flat:I,bottomY:p,rowLevels:v,landingY:S})}for(let c=0;c<t.length;c++){let f=o[c],b=t[c];if(f){let h=s[c];i[c]=(h??r.get(f).deckAt(b.x,b.y))+Li;continue}let p=b.eyeHeightM;i[c]=Number.isFinite(p)?Math.max(0,p-ce):0}return{bySection:r,seatOwner:o,seatDeckY:c=>i[c],seatPitchU:c=>a[c]}}var Q={top:1,wallBottom:.5,bottomCap:.4};function ue(e,t){if(!e)return t;let n=ie(Le(e,.4),.62);return ne(t,n,.72)}function $n(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let r=new Map;for(let i of t){if(!i.sectionId)continue;let s=r.get(i.sectionId);s||(s=new Map,r.set(i.sectionId,s)),s.set(i.categoryKey,(s.get(i.categoryKey)??0)+1)}let o=new Map;for(let[i,s]of r){let a=0,m=0,u=0,l=0;for(let[d,c]of s){let f=W(n.get(d));f&&(a+=f[0]*c,m+=f[1]*c,u+=f[2]*c,l+=c)}l>0&&o.set(i,[a/l,m/l,u/l])}return o}function Qn(e,t){return W(e.color)??t.get(e.logicalSectionId??e.id)??null}var qn=Ie(require("polygon-clipping"),1);function Oi(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var at=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let r=t.map(m=>[m.x,m.y]);if(r.length<3)return[];r.push(r[0]);let o=Ce(t),i=this.rings.filter((m,u)=>st(o,this.boxes[u])&&Oi(n,this.levels[u])),s=[[r]];if(i.length)try{s=qn.default.difference([r],...i).map(u=>u.map(l=>l.map(([d,c])=>[d,c])))}catch{s=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(n);let a=[];for(let m of s){if(!m.length)continue;let u=m[0].map(([l,d])=>({x:l,y:d}));if(u.length>1){let l=u[0],d=u[u.length-1];Math.abs(l.x-d.x)<1e-9&&Math.abs(l.y-d.y)<1e-9&&u.pop()}u.length>=3&&a.push(u)}return a}};function Bi(e,t){if(!t)return e;let n=1/0,r=-1/0,o=1/0,i=-1/0;for(let d of e)n=Math.min(n,d.x),r=Math.max(r,d.x),o=Math.min(o,d.y),i=Math.max(i,d.y);let s=(n+r)/2,a=(o+i)/2,m=t*Math.PI/180,u=Math.cos(m),l=Math.sin(m);return e.map(d=>{let c=d.x-s,f=d.y-a;return{x:s+c*u-f*l,y:a+c*l+f*u}})}function ge(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=De(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,r=(e.y??0)+e.height/2;t=nt(n,r,e.width/2,e.height/2)}return t?Bi(t,e.rotation):null}function Ne(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},r=t==="stage"&&We(e.stageKind)?{kind:"stage",heightM:.06}:n[t]??{kind:"plate",heightM:.25};return{...r,heightM:e.heightM??r.heightM}}var Fi=.08;function Jn(e,t){let n=ge(e),r=Ne(e),o=r.heightM;if(!n||r.kind!=="plate"&&r.kind!=="stage")return o;let i=1/0,s=1/0,a=-1/0,m=-1/0;for(let l of n)i=Math.min(i,l.x),s=Math.min(s,l.y),a=Math.max(a,l.x),m=Math.max(m,l.y);let u=o;for(let l of t)a>l.minX&&i<l.maxX&&m>l.minY&&s<l.maxY&&u<=l.topOffsetM+1e-6&&(u=l.topOffsetM+Fi);return t.push({minX:i,minY:s,maxX:a,maxY:m,topOffsetM:u}),u}function de(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function eo(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function Ge(e,t,n){return[de(e[0],e[1],t),de(e[0],e[1],n),de(e[3],e[2],n),de(e[3],e[2],t)]}function to(e,t,n){return[de(e[0],e[3],t),de(e[1],e[2],t),de(e[1],e[2],n),de(e[0],e[3],n)]}function le(e,t,n,r,o,i){J(e,t,void 0,()=>n,r,o,i,Q)}var Lt=2.4,Di=.75,Ni=.15;function je(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:r,rotation:o}=e;if(!n||!r)return null;let i=(o??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),m=n/2,u=r/2;return[[-m,-u],[m,-u],[m,u],[-m,u]].map(([l,d])=>({x:t.x+l*s-d*a,y:t.y+l*a+d*s}))}function no(e,t,n,r,o){let i=je(t);i&&J(e,i,void 0,()=>n+Lt,n,ue(r,o.boothTop),o.boothWall,Q)}function Ot(e){if(e.shape==="round"){let l=e.radius;return l?nt(e.center.x,e.center.y,l,l,24):null}let{width:t,height:n,rotation:r,center:o}=e;if(!t||!n)return null;let i=(r??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),m=t/2,u=n/2;return[[-m,-u],[m,-u],[m,u],[-m,u]].map(([l,d])=>({x:o.x+l*s-d*a,y:o.y+l*a+d*s}))}function oo(e,t,n,r,o){let i=Ot(t);i&&J(e,i,void 0,()=>n+Di,n,ue(r,o.tableTop),o.tableWall,Q)}function ro(e,t,n,r,o,i,s,a){let m=ge(t);if(!m)return;let u=a?a.kind==="stage":t.role==="stage",l=a?a.kind==="screen":t.role==="screen",d=a?{kind:u?"stage":"solid",heightM:a.topY-a.baseY}:Ne(t),c=a?.baseY??n,f=a?.topY??n+r;if(u&&s){let x=1/0,I=-1/0,w=1/0,P=-1/0;for(let g of m)g.x<x&&(x=g.x),g.x>I&&(I=g.x),g.y<w&&(w=g.y),g.y>P&&(P=g.y);s.push({cx:(x+I)/2*C,cz:(w+P)/2*C,y:f,halfX:Math.max((I-x)/2*C,.5),halfZ:Math.max((P-w)/2*C,.5)})}let b=W(t.fill),p=u&&b?ne(o.stageTop,ie(Le(b,.18),.9),.9):ue(b,u?o.stageTop:o.decorTop),h=l?b:null,y=u?b?ne(o.stageWall,ie(b,.58),.82):o.stageWall:l?h?ne(ie(h,1.42),[.24,.46,.82],.08):[.24,.46,.82]:ue(W(t.fill),o.decorWall);if(d.kind==="portal"&&m.length===4){let x=eo(m);le(e,Ge(x,0,.16),f,c,p,y),le(e,Ge(x,.84,1),f,c,p,y),le(e,x,f,Math.max(c,f-.35),p,y);return}if(d.kind==="suite"&&m.length===4){let x=m.map((P,g)=>{let M=m[(g+1)%4],R=(P.x+M.x)/2,k=(P.y+M.y)/2;return Math.hypot(R-i.x,k-i.y)}),I=x.indexOf(Math.min(...x)),w=[0,1,2,3].map(P=>m[(I+P)%4]);le(e,Ge(w,0,.08),f,c,p,y),le(e,Ge(w,.92,1),f,c,p,y),le(e,to(w,.88,1),f,c,p,y),le(e,w,f,Math.max(c,f-.18),p,y);return}le(e,m,f,c,p,y)}function Bt(e){let{x:t,y:n,width:r,height:o}=e;if(!r||!o)return null;let i=t+r/2,s=n+o/2,a=(e.rotation??0)*Math.PI/180,m=Math.cos(a),u=Math.sin(a),l=r/2,d=o/2;return[[-l,-d],[l,-d],[l,d],[-l,d]].map(([c,f])=>({x:i+c*m-f*u,y:s+c*u+f*m}))}function Gi(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let r=n[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return W(r);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let s=[];for(let a of i[1].matchAll(/stop-color="([^"]+)"/gi)){let m=W(a[1].trim());m&&s.push(m)}return s.length?s.reduce((a,m,u)=>ne(a,m,1/(u+1)),s[0]):null}function io(e,t,n,r){if(t.layer==="foreground")return;let o=Bt(t);if(!o)return;let i=n+Ni,s=ue(Gi(t.href),r.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=ne(r.ground,s,a)),J(e,o,void 0,()=>i,n,s,ne(s,r.decorWall,.5),Q)}function so(e,t,n,r,o){if(!t.points||t.points.length<3)return;let i=ue(r,o.gaTop);J(e,t.points,t.holes,()=>n+.15,n,i,o.gaWall,Q)}var ji=Math.PI/180,K=96,Ui=6,Yi=60,Xi=150,ao=.2,Vi=.35;function Hi(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/ji;return n<0?n+360:n}function ct(e){if(!e.length)return NaN;let t=[...e].sort((n,r)=>n-r);return t[Math.floor(t.length/2)]}function ut(e,t,n=2){let r=e.length,o=new Float64Array(r);for(let i=0;i<r;i++){let s=0,a=0;for(let m=-n;m<=n;m++){let u=i+m;if(t)u=(u%r+r)%r;else if(u<0||u>=r)continue;s+=e[u],a++}o[i]=s/a}return o}function co(e,t){let n=e.filter(c=>c.rows.length>=1);if(n.length<1)return null;let r=[],o=0,i=0,s=0;for(let c of n)for(let f of c.rows){for(let b of f.pts)o+=b.x,i+=b.y,s++;if(f.pts.length>=4){let b=xt(f.pts);b&&Number.isFinite(b.cx)&&Number.isFinite(b.cy)&&r.push({x:b.cx,y:b.cy})}}if(!s)return null;let a={x:o/s,y:i/s},m=a;if(r.length>=8){let c=ct(r.map(y=>y.x)),f=ct(r.map(y=>y.y)),b=0;for(let y of n)for(let x of y.rows)for(let I of x.pts){let w=Math.hypot(I.x-a.x,I.y-a.y);w>b&&(b=w)}let p=0,h=b*.2;for(let y of n)for(let x of y.rows)for(let I of x.pts)Math.hypot(I.x-c,I.y-f)<h&&p++;Math.hypot(c-a.x,f-a.y)<=b&&p/s<.01&&(m={x:c,y:f})}let u=[];for(let c of n){let f={sectionId:c.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let b of c.rows)for(let p of b.pts){let h=Math.hypot(p.x-m.x,p.y-m.y),y=Math.min(K-1,Math.floor(Hi(m,p)/(360/K)));f.samples.push({r:h,bin:y,levelM:b.levelM}),h<f.rMin&&(f.rMin=h),h>f.rMax&&(f.rMax=h)}f.samples.length&&u.push(f)}if(!u.length)return null;u.sort((c,f)=>c.rMin+c.rMax-(f.rMin+f.rMax));let l=[];for(let c of u){let f=!1;for(let b of l){let p=Math.min(c.rMax,b.rMax)-Math.max(c.rMin,b.rMin),h=Math.min(c.rMax-c.rMin,b.rMax-b.rMin);if(h>1e-9&&p>=Vi*h){b.members.push(c),b.rMin=Math.min(b.rMin,c.rMin),b.rMax=Math.max(b.rMax,c.rMax),f=!0;break}}f||l.push({members:[c],rMin:c.rMin,rMax:c.rMax})}let d=[];for(let c of l){let f=new Array(K).fill(null);for(let S of c.members)for(let T of S.samples){let N=f[T.bin];N||(N={samples:[]},f[T.bin]=N),N.samples.push({r:T.r,levelM:T.levelM})}let b=f.map(S=>!!S);if(!b.filter(Boolean).length)continue;let h=[],y=[];for(let S of f){if(!S)continue;let T=1/0,N=-1/0;for(let E of S.samples)E.r<T&&(T=E.r),E.r>N&&(N=E.r);h.push(T),y.push(N)}let x=ct(h),I=ct(y);if(!(x>=ao*I)||!(I>0))continue;let w=[...h].sort((S,T)=>S-T);if(!(w[Math.floor(w.length*.1)]>=ao*I))continue;let g=f.map(S=>{if(!S)return null;let T=[...S.samples].sort((F,j)=>F.r-j.r),N=T[0].r,E=T[T.length-1].r,O=T[0].levelM,A=-1/0;for(let F of T)F.levelM>A&&(A=F.levelM);let _=[];for(let F of T){let j={r:F.r,l:F.levelM};for(;_.length&&Math.abs(_[_.length-1].r-j.r)<1e-9;){if(_[_.length-1].l<=j.l){j.skip=!0;break}_.pop()}if(!j.skip){for(;_.length>=2;){let Y=_[_.length-2],X=_[_.length-1];if((X.r-Y.r)*(j.l-Y.l)-(X.l-Y.l)*(j.r-Y.r)<=0)_.pop();else break}_.push(j)}}let B=_.map(F=>F.r),D=_.map(F=>F.l);return{inner:N,outer:E,front:O,top:A,profile:{rs:B,ls:D}}}),M=b.slice();for(let S=0;S<K;S++){if(M[S])continue;let T=-1,N=-1,E=0;for(let G=1;G<=K;G++){let V=(S-G+K*2)%K;if(M[V]){T=V;break}}for(let G=1;G<=K;G++){let V=(S+G)%K;if(M[V]){N=V,E=G;break}}if(T<0||N<0)continue;let O=0;for(let G=1;G<=K;G++){let V=(S-G+K*2)%K;if(b[V]){O=G;break}}if(O-1+E>Ui)continue;let _=g[T],B=g[N],D=O/(O+E),F=_.inner+(B.inner-_.inner)*D,j=_.outer+(B.outer-_.outer)*D,Y=_.front+(B.front-_.front)*D,X=_.top+(B.top-_.top)*D;g[S]={inner:F,outer:j,front:Y,top:X,profile:{rs:[F,j],ls:[Y,X]}}}for(let S=0;S<K;S++)g[S]&&(M[S]=!0);let R=360/K,k=[],L=M.filter(Boolean).length,U=[];if(L===K)U.push({start:0,len:K});else{let S=0;for(;M[S];)S=(S+1)%K;let T=-1;for(let N=0;N<=K;N++){let E=(S+N)%K,O=N<K&&M[E];if(O&&T<0)T=E;else if(!O&&T>=0){let A=(E-T+K)%K||K;U.push({start:T,len:A}),T=-1}}}for(let S of U){if(S.len*R<Yi&&S.len<K)continue;let T=S.len===K,N=new Float64Array(S.len),E=new Float64Array(S.len),O=new Float64Array(S.len),A=new Float64Array(S.len),_=[];for(let G=0;G<S.len;G++){let V=g[(S.start+G)%K];N[G]=V.inner,E[G]=V.outer,O[G]=V.front,A[G]=V.top,_.push(V.profile??{rs:[V.inner,V.outer],ls:[V.front,V.top]})}let B=ut(N,T),D=ut(E,T),F=ut(O,T),j=ut(A,T);for(let G=0;G<S.len;G++)B[G]>N[G]&&(B[G]=N[G]),D[G]<E[G]&&(D[G]=E[G]),B[G]>D[G]-1e-6&&(B[G]=Math.max(0,D[G]-1e-6)),j[G]<F[G]&&(j[G]=F[G]);let Y={startBin:S.start,binCount:S.len,closed:T,innerR:B,outerR:D,frontLevelM:F,topLevelM:j,profiles:_},X=(G,V,H)=>{let $=_[G],Z=$.rs,z=$.ls;if(V<=Z[0]){z[0]>H&&(z[0]=H);return}if(V>=Z[Z.length-1]){z[z.length-1]>H&&(z[z.length-1]=H);return}for(let q=0;q+1<Z.length;q++)if(V<=Z[q+1]){z[q]>H&&(z[q]=H),z[q+1]>H&&(z[q+1]=H);return}};for(let G=0;G<S.len;G++){let V=f[(S.start+G)%K];if(V)for(let H of V.samples){X(G,H.r,H.levelM);let $=T?(G-1+S.len)%S.len:G-1,Z=T?(G+1)%S.len:G+1;$>=0&&X($,H.r,H.levelM),Z<S.len&&X(Z,H.r,H.levelM)}}k.push(Y)}k.reduce((S,T)=>S+T.binCount*R,0)<Xi||d.push({arcs:k,sectionIds:c.members.map(S=>S.sectionId),innerRMedian:x,outerRMedian:I})}if(!d.length)return null;if(d.sort((c,f)=>c.innerRMedian-f.innerRMedian),t){let c=d[d.length-1].outerRMedian;if(Math.hypot(t.x-m.x,t.y-m.y)>.9*c)return null}return{centre:m,binCount:K,binStepDeg:360/K,rings:d}}function uo(e,t,n,r){let o=e.binStepDeg,i=n/o-.5-t.startBin;i=(i%e.binCount+e.binCount)%e.binCount,i>t.binCount-1&&(t.closed?i=i-t.binCount<t.binCount-i?0:t.binCount-1:i=i-(t.binCount-1)<e.binCount-i?t.binCount-1:0);let s=Math.floor(i),a=t.closed?(s+1)%t.binCount:Math.min(t.binCount-1,s+1),m=i-s,u=l=>{let d=t.profiles[l],c=d.rs,f=d.ls;if(r<=c[0])return f[0];if(r>=c[c.length-1])return f[f.length-1];for(let b=0;b+1<c.length;b++)if(r<=c[b+1]){let p=c[b+1]-c[b],h=p>1e-9?(r-c[b])/p:0;return f[b]+(f[b+1]-f[b])*h}return f[f.length-1]};return u(s)*(1-m)+u(a)*m}var Ki=.25,zi=1.2,Wi=.6,Zi=.45,$i=2.3,Qi=Math.PI/180;function xe(e,t,n){let r=n*Qi;return{x:e.x+t*Math.sin(r),y:e.y+t*Math.cos(r)}}function qi(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let r=n.outerRMedian*.85;for(let o of e){if(o.role!=="wall")continue;let i=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(i.length<2)continue;let s=0;for(let a of i)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=r&&s++;if(s>=i.length/2)return!0}return!1}var Ji=24;function es(e,t,n,r,o,i,s,a){let m=n.binCount,u=Ji,l=te,d=i+.02,c=[];for(let v=0;v<m;v++){let S=(n.startBin+v+.5)*t.binStepDeg,T=new Float64Array(u+1);for(let N=0;N<=u;N++){let E=r[v]+(o[v]-r[v])*N/u;T[N]=Math.max(d,uo(t,n,S,E)-Ki)}c.push(T)}let f=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],b=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],p=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],h=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],y=(v,S)=>{let T=(n.startBin+v+.5)*t.binStepDeg,N=r[v]+(o[v]-r[v])*S/u,E=xe(t.centre,N,T);return[E.x*l,c[v][S],E.y*l]};{let v=Math.tan(12*Math.PI/180);for(let S=0;S<6;S++){let T=!1;for(let E=0;E<m;E++)for(let O=u-1;O>=0;O--)c[E][O]>c[E][O+1]&&(c[E][O]=c[E][O+1],T=!0);let N=n.closed?m:m-1;for(let E=0;E<N;E++){let O=(E+1)%m;for(let A=0;A<=u;A++){let _=c[O][A]-c[E][A];if(Math.abs(_)>1)continue;let B=r[E]+(o[E]-r[E])*A/u,D=r[O]+(o[O]-r[O])*A/u,F=xe(t.centre,B,(n.startBin+E+.5)*t.binStepDeg),j=xe(t.centre,D,(n.startBin+O+.5)*t.binStepDeg),Y=v*Math.hypot(j.x-F.x,j.y-F.y)*l;_>Y?(c[O][A]=c[E][A]+Y,T=!0):-_>Y&&(c[E][A]=c[O][A]+Y,T=!0)}}if(!T)break}}let x=1,I=(v,S)=>{for(let T=0;T<=u;T+=4)if(Math.abs(c[v][T]-c[S][T])>x)return!0;return Math.abs(c[v][u]-c[S][u])>x},w=Math.tan(38*Math.PI/180),P=v=>(o[v]-r[v])/u*l,g=(v,S)=>c[v][S+1]-c[v][S]>w*Math.max(1e-6,P(v)),M=(v,S)=>{let T=n.closed?(v-1+m)%m:Math.max(0,v-1),N=n.closed?(v+1)%m:Math.min(m-1,v+1);Math.abs(c[T][S]-c[v][S])>x&&(T=v),Math.abs(c[N][S]-c[v][S])>x&&(N=v);let E=Math.max(0,S-1),O=Math.min(u,S+1);E<S&&g(v,E)&&(E=S),O>S&&g(v,S)&&(O=S);let A=y(T,S),_=y(N,S),B=y(v,E),D=y(v,O),F=_[0]-A[0],j=_[1]-A[1],Y=_[2]-A[2],X=D[0]-B[0],G=D[1]-B[1],V=D[2]-B[2],H=j*V-Y*G,$=Y*X-F*V,Z=F*G-j*X,z=Math.hypot(H,$,Z);return z>1e-12?(H/=z,$/=z,Z/=z,$<0&&(H=-H,$=-$,Z=-Z),[H,$,Z]):[0,1,0]},R=(v,S)=>{let T=[v[0],i,v[2]],N=[S[0],i,S[2]],E=S[0]-v[0],O=S[2]-v[2],A=Math.hypot(E,O);if(!(A>1e-12))return;let _=[O/A,0,-E/A];e.tri(v,S,N,_,p,p,h),e.tri(v,N,T,_,p,h,h)},k=.05*me,L=v=>o[v]-r[v]<k,U=n.closed?m:m-1;for(let v=0;v<U;v++){let S=(v+1)%m;if(L(v)||L(S))continue;if(I(v,S)){let _=(n.startBin+v+1)*t.binStepDeg,B=(G,V)=>{let H=(r[v]+r[S])/2,$=(o[v]+o[S])/2,Z=H+($-H)*V/u,z=xe(t.centre,Z,_);return[z.x*l,c[G][V],z.y*l]};for(let G=0;G<u;G++){let V=y(v,G),H=y(v,G+1),$=B(v,G),Z=B(v,G+1),z=M(v,G),q=M(v,G+1);e.triN(V,$,Z,z,z,q,f),e.triN(V,Z,H,z,q,q,f);let Ue=y(S,G),Ye=y(S,G+1),Me=B(S,G),Ee=B(S,G+1),Se=M(S,G),we=M(S,G+1);e.triN(Me,Ue,Ye,Se,Se,we,f),e.triN(Me,Ye,Ee,Se,we,we,f);let fe=B(v,G),ae=B(v,G+1),Xe=B(S,G+1),ft=B(S,G),Ve=ae[0]-fe[0],Ae=ae[2]-fe[2],mt=Math.hypot(Ve,Ae);if(mt>1e-12){let Dt=[Ae/mt,0,-Ve/mt];e.tri(fe,ae,Xe,Dt,p),e.tri(fe,Xe,ft,Dt,p)}}let D=y(v,0),F=y(S,0),j=y(S,u),Y=y(v,u),X=G=>[G[0],i,G[2]];e.tri(X(D),X(j),X(F),[0,-1,0],b),e.tri(X(D),X(Y),X(j),[0,-1,0],b),R(D,F),R(Y,j);continue}for(let _=0;_<u;_++){let B=M(v,_),D=M(S,_),F=M(S,_+1),j=M(v,_+1);if(g(v,_)||g(S,_)){let H=(ae,Xe)=>{let ft=(n.startBin+ae+.5)*t.binStepDeg,Ve=r[ae]+(o[ae]-r[ae])*(_+.5)/u,Ae=xe(t.centre,Ve,ft);return[Ae.x*l,Xe,Ae.y*l]},$=y(v,_),Z=y(S,_),z=H(v,c[v][_]),q=H(S,c[S][_]);e.triN($,Z,q,B,D,D,f),e.triN($,q,z,B,D,B,f);let Ue=y(S,_+1),Ye=y(v,_+1),Me=H(v,c[v][_+1]),Ee=H(S,c[S][_+1]);e.triN(Me,Ee,Ue,j,F,F,f),e.triN(Me,Ue,Ye,j,F,j,f);let Se=q[0]-z[0],we=q[2]-z[2],fe=Math.hypot(Se,we);if(fe>1e-12){let ae=[-we/fe,0,Se/fe];e.tri(z,q,Ee,ae,p),e.tri(z,Ee,Me,ae,p)}continue}let Y=y(v,_),X=y(S,_),G=y(S,_+1),V=y(v,_+1);e.triN(Y,X,G,B,D,F,f),e.triN(Y,G,V,B,F,j,f)}let T=y(v,0),N=y(S,0),E=y(S,u),O=y(v,u),A=_=>[_[0],i,_[2]];e.tri(A(T),A(E),A(N),[0,-1,0],b),e.tri(A(T),A(O),A(E),[0,-1,0],b),R(T,N),R(O,E)}if(!n.closed)for(let v of[0,m-1])for(let S=0;S<u;S++)R(y(v,S),y(v,S+1))}function lo(e,t,n){let{bottomY:r,colors:o,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let l of t.rings)for(let d of l.arcs){let c=new Float64Array(d.binCount),f=new Float64Array(d.binCount);for(let p=0;p<d.binCount;p++){let h=(d.startBin+p)%t.binCount,y=Math.max(0,d.innerR[p]-se);c[p]=Math.max(y,s[h]+.001),f[p]=Math.max(c[p]+.001,d.outerR[p]+se)}let b=0;for(let p=0;p<d.binCount;p++){let h=d.topLevelM[p]-r;h>b&&(b=h)}b>=zi&&es(e,t,d,c,f,r,o,i);for(let p=0;p<d.binCount;p++){let h=(d.startBin+p)%t.binCount;f[p]>s[h]&&(s[h]=f[p])}}if(n.deriveShell===!1||qi(n.shapes,t))return;let a=t.rings[t.rings.length-1],m=Wi*me,u=Zi*me;for(let l of a.arcs){let d=[],c=[];for(let p=0;p<l.binCount;p++){let h=(l.startBin+p+.5)*t.binStepDeg,y=l.outerR[p]+se+m;d.push(xe(t.centre,y,h)),c.push(xe(t.centre,y+u,h))}let f=-1/0;for(let p=0;p<l.binCount;p++)l.topLevelM[p]>f&&(f=l.topLevelM[p]);let b=()=>f+$i;l.closed?J(e,c,[d.slice().reverse()],b,r,o.shellTop,o.shellWall,i):J(e,[...c,...d.slice().reverse()],void 0,b,r,o.shellTop,o.shellWall,i)}}function fo(e,t,n,r,o,i,s,a){if(!t.outline||t.outline.length<3)return;let m=n.baseHeightM,u=ue(r,a.tierTop);if(!o)return;let l=h=>o.deckAt(h.x,h.y),d=Kn(t,s),c=d[0]??t.outline;if(o.rowLevels.length>=2){let h=it(o.rowLevels),y=zn(jn(o.rowLevels,n.focal,h),d),x=()=>[0,1,0];for(let w of y){let P=Math.max(m,w.topY-.02);for(let g of i.subtract(w.outline,P))J(e,g,w.holes,()=>P,m,u,a.tierWall,Q,void 0,x)}y.length||J(e,c,t.holes,()=>o.landingY,m,u,a.tierWall,Q);let I={tread:[u[0]*Q.top,u[1]*Q.top,u[2]*Q.top],riser:[u[0]*.72,u[1]*.72,u[2]*.72]};for(let w of d.length?d:[c])Yn(e,o.rowLevels,n.focal,o.landingY,I,w,h);return}let f=o.flat?1/0:Wn,b=h=>o.normalAt(h.x,h.y),p=o.flat?o.landingY:void 0;for(let h of i.subtract(c,p))J(e,h,t.holes,l,m,u,a.tierWall,Q,f,b)}function ts(e,t,n){let r=new Set;for(let s of e.objects)s.type==="section"&&r.add(s.id);let o=new Map;for(let s=0;s<t.length;s++){let a=n.seatOwner[s];if(!a||!r.has(a))continue;let m=n.bySection.get(a);if(m&&m.rowLevels.length>=2)continue;let u=t[s],l=o.get(a);l||(l=new Map,o.set(a,l));let d=u.rowId||`__seat-${s}`,c=l.get(d);c||(c={pts:[],levelM:0,n:0},l.set(d,c)),c.pts.push({x:u.x,y:u.y}),c.levelM+=n.seatDeckY(s),c.n++}let i=[];for(let s of e.objects){if(s.type!=="section")continue;let a=n.bySection.get(s.id);if(a&&a.rowLevels.length>=2){let u=a.rowLevels.filter(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));u.length>=2&&i.push({sectionId:s.id,rows:u});continue}let m=o.get(s.id);m&&i.push({sectionId:s.id,rows:[...m.values()].map(u=>({pts:u.pts,levelM:u.levelM/u.n}))})}return i}function mo(e,t,n,r,o,i,s=!0){let a=ts(t,n,r);if(!a.length)return;let m=co(a,t.focal);m&&(e.setMaterial(0),lo(e,m,{bottomY:t.baseHeightM,colors:{bandTop:ie(o.tierTop,.8),bandWall:o.tierWall,shellTop:i??ie(o.tierWall,1.15),shellWall:i??o.tierWall},ao:Q,shapes:t.objects.filter(u=>u.type==="shape"),deriveShell:s}))}var bo=/^[\p{L}\p{N}]{1,4}$/u,ns=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function po(e,t){let n=t?.trim();if(!n)return e;let r=e.toLocaleLowerCase("en-US"),o=n.toLocaleLowerCase("en-US");if(r.startsWith(`${o} `)){let s=e.slice(n.length).trim();if(bo.test(s))return s}let i=ns.exec(e);if(i){let s=i[1].toLocaleLowerCase("en-US"),a=i[2].trim();if((o.startsWith(s)||s.startsWith(o))&&bo.test(a))return a}return e}var os=6,rs=2.2,ho=.1,is=.3,ss=1.8,as=.9,cs=.55,us=6e3;function yo(e){let{doc:t,units:n,seats:r,surfaces:o,focal:i}=e,s=t.zones??[],a=[];if(s.length){let m=new Map;for(let l of n)for(let d of l.objects)d.type==="section"&&d.zone&&m.set(d.id,d.zone);let u=new Map;for(let l=0;l<r.length;l++){let d=r[l],c=o.seatOwner[l],f=d.zoneId??(c?m.get(c):void 0);if(!f)continue;let b=u.get(f);b||(b={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},u.set(f,b)),b.n++,d.x<b.minX&&(b.minX=d.x),d.y<b.minY&&(b.minY=d.y),d.x>b.maxX&&(b.maxX=d.x),d.y>b.maxY&&(b.maxY=d.y),b.sumY+=o.seatDeckY(l)}for(let l of s){let d=u.get(l.id),c=[];for(let[f,b]of m)b===l.id&&c.push(f);if(!d||d.n===0){a.push({id:l.id,label:l.label,color:W(l.color),sectionIds:c,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(l.focalPoint??i).x*C,1.5,(l.focalPoint??i).y*C]});continue}a.push({id:l.id,label:l.label,color:W(l.color),sectionIds:c,seatCount:d.n,center:[(d.minX+d.maxX)/2*C,d.sumY/d.n,(d.minY+d.maxY)/2*C],radius:.5*Math.hypot((d.maxX-d.minX)*C,(d.maxY-d.minY)*C)||1,focalWorld:[(l.focalPoint??i).x*C,1.5,(l.focalPoint??i).y*C]})}}return a}function go(e){let{doc:t,units:n,seats:r,surfaces:o,seatData:i,hintedSeatFloor:s,zones:a,focal:m}=e,u=[],l=[],d=[];for(let c of a)c.seatCount!==0&&u.push({id:`zone:${c.id}`,kind:"zone",text:c.label,anchor:[c.center[0],c.center[1]+os,c.center[2]],color:t.zones?.find(f=>f.id===c.id)?.color});{let c=new Map,f=new Map;for(let b=0;b<r.length;b++){let p=o.seatOwner[b];if(!p)continue;let h=c.get(p);h||(h={n:0,x:0,y:0,deck:0},c.set(p,h)),h.n++,h.x+=r[b].x,h.y+=r[b].y,h.deck+=o.seatDeckY(b);let y=f.get(p);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},f.set(p,y)),r[b].x<y.minX&&(y.minX=r[b].x),r[b].x>y.maxX&&(y.maxX=r[b].x),r[b].y<y.minY&&(y.minY=r[b].y),r[b].y>y.maxY&&(y.maxY=r[b].y)}for(let b of n)for(let p of b.objects){if(p.type!=="section")continue;let h=c.get(p.id);if(!h||h.n===0)continue;let y=f.get(p.id),x=[h.x/h.n*C,h.deck/h.n,h.y/h.n*C],I=p.displayLabel||p.label||p.id;l.push({id:p.id,floorIndex:b.index,label:I,seatCount:h.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*C),focalWorld:[b.focal.x*C,b.baseHeightM+1.5,b.focal.y*C]});let w=t.floors?.[b.index]?.name?.trim().toLocaleLowerCase();n.length>1&&w===I.trim().toLocaleLowerCase()||u.push({id:`section:${p.id}`,kind:"section",text:I,anchor:[x[0],x[1]+rs,x[2]],floorIndex:b.index})}}{for(let p of n)for(let h of p.objects){if(h.type!=="gaArea")continue;let y=_e(h.points);if(!y)continue;let x=h.displayLabel||h.label||h.id;u.push({id:`ga:${h.id}`,kind:"ga",text:h.capacity>0?`${x} \xB7 ${h.capacity.toLocaleString()}`:x,anchor:[y.x*C,p.baseHeightM+ss,y.y*C],floorIndex:p.index})}let c=new Map;for(let p of n)for(let h of p.objects)h.type==="section"&&c.set(h.id,h.displayLabel||h.label||h.id);let f=new Map;for(let p=0;p<r.length;p++){let h=r[p],y=Math.hypot(h.x-m.x,h.y-m.y),x=f.get(h.rowId);(!x||y>x.far)&&f.set(h.rowId,{seat:h,index:p,far:y})}for(let[p,h]of f){let y=fs(h.seat.label,p,c.get(h.seat.sectionId??""));y&&u.push({id:`row:${p}`,kind:"row",text:y,anchor:[h.seat.x*C,o.seatDeckY(h.index)+as,h.seat.y*C],floorIndex:s[h.index]})}let b=new Map;for(let p=0;p<r.length;p++){let h=r[p],y=h.label?h.label.lastIndexOf("-"):-1,x=b.get(h.rowId);x||(x={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?h.label.slice(0,y):h.rowId,sectionId:h.sectionId},b.set(h.rowId,x));let I=p*3,w=i.iPosition[I],P=i.iPosition[I+1],g=i.iPosition[I+2];x.n++,x.x+=w,x.y+=P,x.z+=g,x.minX=Math.min(x.minX,w),x.maxX=Math.max(x.maxX,w),x.minZ=Math.min(x.minZ,g),x.maxZ=Math.max(x.maxZ,g)}for(let[p,h]of b)d.push({id:p,label:h.label,sectionId:h.sectionId,seatCount:h.n,center:[h.x/h.n,h.y/h.n,h.z/h.n],radius:Math.max(.8,Math.hypot(h.maxX-h.minX,h.maxZ-h.minZ)*.5)});if(r.length<=us)for(let p=0;p<r.length;p++){let h=r[p],y=ls(h.displayLabel||h.label);y&&u.push({id:`seat:${h.id}`,kind:"seat",text:y,anchor:[h.x*C,o.seatDeckY(p)+cs,h.y*C],floorIndex:s[p]})}}for(let c of n)for(let f of c.objects)if(f.type==="shape"&&f.role&&["entrance","exit","screen","suite","obstruction"].includes(f.role)){let b=ge(f),p=b?_e(b):null;if(!p||!f.label)continue;u.push({id:`architecture:${f.id}`,kind:"annotation",text:f.label,anchor:[p.x*C,c.baseHeightM+Ne(f).heightM+ho,p.y*C],color:f.fill,floorIndex:c.index})}else if(f.type==="text"){if(!f.text)continue;u.push({id:`text:${f.id}`,kind:"annotation",text:f.text,anchor:[f.position.x*C,c.baseHeightM+ho,f.position.y*C],color:f.color,rotation:f.rotation,floorIndex:c.index})}else if(f.type==="booth"){let b=je(f);if(!b)continue;let p=_e(b);if(!p)continue;u.push({id:`booth:${f.id}`,kind:"booth",text:f.displayLabel||f.label||f.id,anchor:[p.x*C,c.baseHeightM+Lt+is,p.y*C],floorIndex:c.index})}return{labels:u,sections:l,rows:d}}function xo(e,t){if(t.length>1)for(let n of t)e.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function ls(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function fs(e,t,n){let r=e?e.lastIndexOf("-"):-1,o=r>0?e.slice(0,r):t;return o&&po(o,n)}function Mo(e){let{doc:t,units:n,seats:r,surfaces:o,solids:i,hintedSeatFloor:s,seatFloor:a}=e,m=[];{let u=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let c=0;c<i.floor.length;c+=1){let f=Math.max(0,Math.min(n.length-1,Math.round(i.floor[c]))),b=c*3,p=u[f];p.minX=Math.min(p.minX,i.position[b]),p.minY=Math.min(p.minY,i.position[b+1]),p.minZ=Math.min(p.minZ,i.position[b+2]),p.maxX=Math.max(p.maxX,i.position[b]),p.maxY=Math.max(p.maxY,i.position[b+1]),p.maxZ=Math.max(p.maxZ,i.position[b+2])}let l=new Map;for(let c=0;c<n.length;c++)for(let f of n[c].objects)f.type==="section"&&l.set(f.id,c);let d=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let c=0;c<r.length;c++){let f=o.seatOwner[c],b=(f!==null?l.get(f):void 0)??s[c];if(b===void 0)continue;let p=d[b],h=r[c];p.n++,h.x<p.minX&&(p.minX=h.x),h.y<p.minY&&(p.minY=h.y),h.x>p.maxX&&(p.maxX=h.x),h.y>p.maxY&&(p.maxY=h.y);let y=o.seatDeckY(c);p.sumX+=h.x*C,p.sumDeck+=y,p.sumZ+=h.y*C,p.minDeck=Math.min(p.minDeck,y),p.maxDeck=Math.max(p.maxDeck,y+1.6),a[c]=b}for(let c=0;c<n.length;c++){let f=d[c],b=t.floors?.[c],p=u[c],h=Math.min(f.n?f.minX*C:n[c].focal.x*C-1,Number.isFinite(p.minX)?p.minX:1/0),y=Math.max(f.n?f.maxX*C:n[c].focal.x*C+1,Number.isFinite(p.maxX)?p.maxX:-1/0),x=Math.min(f.n?f.minY*C:n[c].focal.y*C-1,Number.isFinite(p.minZ)?p.minZ:1/0),I=Math.max(f.n?f.maxY*C:n[c].focal.y*C+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),w=Math.min(f.n?Math.min(n[c].baseHeightM,f.minDeck):n[c].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),P=Math.max(f.n?Math.max(f.maxDeck,w+.5):w+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),g=[f.n?f.sumX/f.n:(h+y)/2,f.n?f.sumDeck/f.n:(w+P)/2,f.n?f.sumZ/f.n:(x+I)/2],M=Math.max(1,.5*Math.hypot(y-h,P-w,I-x));m.push({index:c,id:b?.id??`floor-${c}`,label:b?.name??(n.length>1?`Floor ${c+1}`:"Venue"),seatCount:f.n,center:g,radius:M,box:{min:[h,w,x],max:[y,P,I]},focalWorld:[n[c].focal.x*C,n[c].baseHeightM+1.5,n[c].focal.y*C]})}}return m}function Ft(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0,s=(a,m)=>{a<n&&(n=a),m<r&&(r=m),a>o&&(o=a),m>i&&(i=m)};for(let a of t)s(a.x,a.y);for(let a of e)for(let m of a.objects)if(m.type==="section")for(let u of m.outline)s(u.x,u.y);else if(m.type==="shape"&&m.points)for(let u of m.points)s(u.x,u.y);else if(m.type==="gaArea")for(let u of m.points)s(u.x,u.y);else if(m.type==="booth"){let u=je(m);if(u)for(let l of u)s(l.x,l.y)}else if(m.type==="table"){let u=Ot(m);if(u)for(let l of u)s(l.x,l.y)}else if(m.type==="decorImage"){let u=Bt(m);if(u)for(let l of u)s(l.x,l.y)}return Number.isFinite(n)||(n=-100,r=-100,o=100,i=100),{minX:n,minY:r,maxX:o,maxY:i}}function So(e,t,n,r,o,i){if(t.length===1){let s=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),a=De(o.minX-s,o.minY-s,o.maxX-o.minX+s*2,o.maxY-o.minY+s*2);J(e,a,void 0,()=>0,-.4,i.ground,i.ground,Q)}else{let s=t.reduce((f,b)=>b.baseHeightM<f.baseHeightM?b:f);e.setFloor(s.index);let a=n.filter((f,b)=>r[b]===s.index),m=Ft([s],a),u=Math.hypot(m.maxX-m.minX,m.maxY-m.minY),l=Math.max(28,Math.min(80,u*.04)),d=De(m.minX-l,m.minY-l,m.maxX-m.minX+l*2,m.maxY-m.minY+l*2),c=s.baseHeightM-.03;J(e,d,void 0,()=>c,c-.22,i.ground,i.ground,Q)}}function wo(e,t,n){let{cx:r,cz:o,radius:i}=n,s=1/0,a=1/0,m=1/0,u=-1/0,l=-1/0,d=-1/0,c=(p,h,y)=>{s=Math.min(s,p),u=Math.max(u,p),a=Math.min(a,h),l=Math.max(l,h),m=Math.min(m,y),d=Math.max(d,y)};for(let p=0;p<e.position.length;p+=3)c(e.position[p],e.position[p+1],e.position[p+2]);for(let p=0;p<t.count;p++){let h=p*3,y=t.iPosition[h],x=t.iPosition[h+1],I=t.iPosition[h+2],w=Math.max(.35,t.iMaxRadius[p]??.35);c(y-w,x,I-w),c(y+w,x+1.6,I+w)}Number.isFinite(s)||(s=r-i,u=r+i,a=0,l=i*.16,m=o-i,d=o+i);let f=[(s+u)/2,(a+l)/2,(m+d)/2],b=Math.max(1,.5*Math.hypot(u-s,l-a,d-m));return{center:f,radius:b,minY:a,maxY:l}}function Io(e,t,n,r,o,i){let s=1/0,a=1/0,m=-1/0,u=-1/0;for(let w=0;w<e.count;w++){let P=w*3,g=e.iPosition[P],M=e.iPosition[P+2];g<s&&(s=g),g>m&&(m=g),M<a&&(a=M),M>u&&(u=M)}for(let w of t)s=Math.min(s,w.cx-w.halfX),m=Math.max(m,w.cx+w.halfX),a=Math.min(a,w.cz-w.halfZ),u=Math.max(u,w.cz+w.halfZ);let l=n.minX*C,d=n.maxX*C,c=n.minY*C,f=n.maxY*C,b=l,p=d,h=c,y=f;if(Number.isFinite(s)){let w=Math.max(2,.06*Math.hypot(m-s,u-a));b=Math.max(l,s-w),p=Math.min(d,m+w),h=Math.max(c,a-w),y=Math.min(f,u+w)}let x=Math.min(0,r),I=Math.max(o,i*.05);return{min:[b,x,h],max:[p,I,y]}}function vo(e,t,n){let r=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return r();let o=Qt(t);if(!o.ok||o.value.id!==e)return r();let i=new Map;for(let d of n)for(let c of d.objects)c.type==="shape"&&i.set(c.id,{shape:c,unit:d});let s=new Set,a=new Set,m=new Map((t.overlay.productionElements??[]).map(d=>{let c=d.runtimeContentImageUrl;return[d.id,typeof c=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(c)?c:void 0]})),u=[];for(let d of o.value.overlay.productionElements??[]){let c=i.get(d.objectId),f=c?ge(c.shape):null,b=d.baseElevationM??0;if(!c||!f||f.length<3||!d.id||s.has(d.id)||a.has(d.objectId)||!Number.isFinite(d.heightM)||d.heightM<.05||d.heightM>50||!Number.isFinite(b)||b<-10||b>100)return r();s.add(d.id),a.add(d.objectId);let p=f.map(R=>R.x*C),h=f.map(R=>R.y*C),y=c.unit.baseHeightM+b,x=Math.min(...p),I=Math.max(...p),w=Math.min(...h),P=Math.max(...h),g,M=m.get(d.id)??d.contentImageUrl;if(d.kind==="screen"&&M)if(I-x>=P-w){let R=Math.abs(w-c.unit.focal.y*C)<=Math.abs(P-c.unit.focal.y*C)?w-.006:P+.006;g=[[x,y,R],[I,y,R],[x,y+d.heightM,R],[I,y+d.heightM,R]]}else{let R=Math.abs(x-c.unit.focal.x*C)<=Math.abs(I-c.unit.focal.x*C)?x-.006:I+.006;g=[[R,y,w],[R,y,P],[R,y+d.heightM,w],[R,y+d.heightM,P]]}u.push({id:d.id,objectId:d.objectId,kind:d.kind,floorIndex:c.unit.index,baseY:y,topY:y+d.heightM,bounds:{min:[x,y,w],max:[I,y+d.heightM,P]},occlusion:d.occlusion,...M?{contentImageUrl:M}:{},...g?{contentPlane:g}:{}})}let l=u.sort((d,c)=>d.id.localeCompare(c.id));return{byObjectId:new Map(l.map(d=>[d.objectId,d])),elements:l}}function re(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function oe(e){return Array.isArray(e)?e:[]}function ms(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!re(n))continue;let r=re(n.extensions)?n.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function lt(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function ds(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function bs(e,t){let n=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let i=0;i<4;i++)n[r*4+o]+=e[i*4+o]*t[r*4+i];return n}function ps(e){let t=lt(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:lt(e.translation,3),r=e.rotation===void 0?[0,0,0,1]:lt(e.rotation,4),o=e.scale===void 0?[1,1,1]:lt(e.scale,3);if(!n||!r||!o)return null;let[i,s,a,m]=r,u=Math.hypot(i,s,a,m);if(!(u>1e-8))return null;let l=i/u,d=s/u,c=a/u,f=m/u,b=l+l,p=d+d,h=c+c,y=l*b,x=l*p,I=l*h,w=d*p,P=d*h,g=c*h,M=f*b,R=f*p,k=f*h;return[(1-(w+g))*o[0],(x+k)*o[0],(I-R)*o[0],0,(x-k)*o[1],(1-(y+g))*o[1],(P+M)*o[1],0,(I+R)*o[2],(P-M)*o[2],(1-(y+w))*o[2],0,n[0],n[1],n[2],1]}function hs(e,t,n,r){return[e[0]*t+e[4]*n+e[8]*r+e[12],e[1]*t+e[5]*n+e[9]*r+e[13],e[2]*t+e[6]*n+e[10]*r+e[14]]}function ys(e){let t=e[0],n=e[4],r=e[8],o=e[1],i=e[5],s=e[9],a=e[2],m=e[6],u=e[10],l=i*u-s*m,d=s*a-o*u,c=o*m-i*a,f=t*l+n*d+r*c;if(Math.abs(f)<1e-12)return null;let b=1/f;return[l*b,d*b,c*b,(r*m-n*u)*b,(t*u-r*a)*b,(n*a-t*m)*b,(n*s-r*i)*b,(r*o-t*s)*b,(t*i-n*o)*b]}function Ro(e,t,n,r){let o=e[0]*t+e[1]*n+e[2]*r,i=e[3]*t+e[4]*n+e[5]*r,s=e[6]*t+e[7]*n+e[8]*r,a=Math.hypot(o,i,s)||1;return o/=a,i/=a,s/=a,[o,i,s]}function gs(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,r=null,o=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),s=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let a=e.subarray(n,n+i);if(s===1313821514&&!r)try{let m=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!re(m))return null;r=m}catch{return null}else if(s===5130562&&!o)o=a;else return null;n+=i}return n===e.byteLength&&r&&o?{json:r,bin:o}:null}function xs(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function Ms(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Ss(e,t,n){return n===5120?e.getInt8(t):n===5121?e.getUint8(t):n===5122?e.getInt16(t,!0):n===5123?e.getUint16(t,!0):n===5125?e.getUint32(t,!0):e.getFloat32(t,!0)}function ws(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=gs(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=n;if(!re(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=oe(r.extensionsUsed).filter(w=>typeof w=="string");if(i.includes("KHR_draco_mesh_compression")||ms(r))return{ok:!1,issue:"draco_not_allowed"};if(i.length||oe(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(oe(r.images).length||oe(r.textures).length)return{ok:!1,issue:"external_resource"};let s=oe(r.buffers);if(s.length!==1||!re(s[0])||s[0].uri!==void 0||typeof s[0].byteLength!="number"||!Number.isInteger(s[0].byteLength)||s[0].byteLength<0||s[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let a=oe(r.accessors),m=oe(r.bufferViews),u=oe(r.meshes),l=oe(r.nodes),d=oe(r.scenes),c=typeof r.scene=="number"?r.scene:0;if(!re(d[c]))return{ok:!1,issue:"unsupported_glb"};let f=new DataView(o.buffer,o.byteOffset,o.byteLength),b=(w,P,g)=>{if(typeof w!="number"||!Number.isInteger(w)||!re(a[w]))return null;let M=a[w];if(M.type!==P||M.sparse!==void 0||M.normalized===!0||typeof M.count!="number"||!Number.isInteger(M.count)||M.count<1||typeof M.componentType!="number"||!g.includes(M.componentType)||typeof M.bufferView!="number")return null;let R=m[M.bufferView];if(!re(R)||R.buffer!==0||typeof R.byteLength!="number"||!Number.isInteger(R.byteLength)||R.byteLength<0)return null;let k=Ms(M.type),L=xs(M.componentType),U=typeof R.byteStride=="number"?R.byteStride:k*L,v=typeof R.byteOffset=="number"?R.byteOffset:0,S=typeof M.byteOffset=="number"?M.byteOffset:0,T=v+S,N=S+(M.count-1)*U+k*L;if(!Number.isInteger(U)||!Number.isInteger(v)||!Number.isInteger(S)||U<k*L||v<0||S<0||v+R.byteLength>o.byteLength||N>R.byteLength)return null;let E=[];for(let O=0;O<M.count;O++){let A=[];for(let _=0;_<k;_++){let B=Ss(f,T+O*U+_*L,M.componentType);if(!Number.isFinite(B))return null;A.push(B)}E.push(A)}return E},p=[],h=[],y=0,x=new Set,I=(w,P)=>{if(typeof w!="number"||!Number.isInteger(w)||!re(l[w])||x.has(w))return!1;x.add(w);let g=l[w],M=ps(g);if(!M)return!1;let R=bs(P,M),k=ys(R);if(!k)return!1;if(g.mesh!==void 0){if(typeof g.mesh!="number")return!1;let L=u[g.mesh];if(!re(L))return!1;for(let U of oe(L.primitives)){if(!re(U)||U.mode!==void 0&&U.mode!==4||!re(U.attributes))return!1;let v=b(U.attributes.POSITION,"VEC3",[5126]),S=U.attributes.NORMAL===void 0?null:b(U.attributes.NORMAL,"VEC3",[5126]);if(!v||U.attributes.NORMAL!==void 0&&!S)return!1;let T=v.length;if(U.indices!==void 0){let E=typeof U.indices=="number"?a[U.indices]:null;T=re(E)?E.count:void 0}if(typeof T!="number"||!Number.isInteger(T)||T%3!==0||(y+=T/3,y>1e5))return!1;let N=U.indices===void 0?v.map((E,O)=>[O]):b(U.indices,"SCALAR",[5121,5123,5125]);if(!N||N.length%3!==0||N.length!==T)return!1;for(let E=0;E<N.length;E+=3){let O=[N[E][0],N[E+1][0],N[E+2][0]];if(O.some(B=>!Number.isInteger(B)||B<0||B>=v.length))return!1;let A=O.map(B=>hs(R,...v[B])),_=null;if(!S){let B=A[1][0]-A[0][0],D=A[1][1]-A[0][1],F=A[1][2]-A[0][2],j=A[2][0]-A[0][0],Y=A[2][1]-A[0][1],X=A[2][2]-A[0][2];_=Ro([1,0,0,0,1,0,0,0,1],D*X-F*Y,F*j-B*X,B*Y-D*j)}for(let B=0;B<3;B++)p.push(...A[B]),h.push(...S?Ro(k,...S[O[B]]):_)}}}for(let L of oe(g.children))if(!I(L,R))return!1;return x.delete(w),!0};for(let w of oe(d[c].nodes))if(!I(w,ds()))return{ok:!1,issue:y>1e5?"triangle_limit":"unsupported_glb"};return!y||p.length!==y*9||h.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:y,position:new Float32Array(p),normal:new Float32Array(h)}}function Po(e){try{return ws(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function Co(e){let{doc:t}=e,n=pn(t.theme),r=n.structure,o=Hn(t,e.eventConfigurationId??t.eventConfigurationId),i=vo(e.eventConfigurationId,e.eventConfiguration,o),s=e.seats,a=new et,m=null;if(e.registeredShellGlb){let E=Po(e.registeredShellGlb);if(E.ok){let O=E.position.length/3,A=new Float32Array(E.position.length),_=n.materials.shell??r.tierWall;for(let B=0;B<O;B++){let D=E.normal[B*3+1],F=D<-.25?.4:.62+.38*Math.max(0,D);A[B*3]=_[0]*F,A[B*3+1]=_[1]*F,A[B*3+2]=_[2]*F}m={position:E.position,normal:E.normal,color:A,floor:new Float32Array(O).fill(-2),material:new Float32Array(O),count:O}}}let u=new Map;for(let E of o)for(let O of E.objects)u.set(O.id,E.index),O.type==="section"&&u.set(O.logicalSectionId??O.id,E.index);let l=s.map(E=>u.get(E.sectionId??"")??u.get(E.rowId??"")??0),d=Ft(o,s);So(a,o,s,l,d,r);let c=$n(t,s),f=new Map,b=new Map;for(let E of t.categories??[])f.set(E.key,E.color),E.seatGlyph&&b.set(E.key,E.seatGlyph);let p=[],h=Zn(o,s,l),y=new Float32Array(s.length),x=[];for(let E=0;E<o.length;E++){let O=o[E];a.setFloor(E);let A=new at,_=[],B=O.objects.filter(D=>D.type==="section"&&!!D.outline&&D.outline.length>=3);for(let D of O.objects)if(D.type==="section"){let F=a.vertexCount;fo(a,D,O,Qn(D,c),h.bySection.get(D.id),A,B,r);let j=a.vertexCount-F;j>0&&x.push({sectionId:D.id,start:F,count:j})}else if(D.type==="shape"){let F=i.byObjectId.get(D.id);a.setMaterial((F?.kind??D.role)==="screen"?1:0),ro(a,D,O.baseHeightM,Jn(D,_),r,O.focal,p,F),a.setMaterial(0)}else D.type==="gaArea"?so(a,D,O.baseHeightM,W(f.get(D.categoryKey)),r):D.type==="booth"?no(a,D,O.baseHeightM,W(f.get(D.categoryKey)),r):D.type==="table"?oo(a,D,O.baseHeightM,W(D.fill??t.theme?.decorFill??"#232c40"),r):D.type==="decorImage"&&io(a,D,O.baseHeightM,r);mo(a,O,s,h,r,n.materials.shell,!m)}let I=o.length>1?{x:o.reduce((E,O)=>E+O.focal.x,0)/o.length,y:o.reduce((E,O)=>E+O.focal.y,0)/o.length}:t.focalPoint??{x:(d.minX+d.maxX)/2,y:(d.minY+d.maxY)/2},w=Mn(m?[a.build(),m]:[a.build()]),P=An(s,e.initialState,h,y,f,b),g=yo({doc:t,units:o,seats:s,surfaces:h,focal:I}),{labels:M,sections:R,rows:k}=go({doc:t,units:o,seats:s,surfaces:h,seatData:P,hintedSeatFloor:l,zones:g,focal:I}),L=Mo({doc:t,units:o,seats:s,surfaces:h,solids:w,hintedSeatFloor:l,seatFloor:y});xo(M,L),P.iYaw=En(P.iPosition,s.length,E=>s[E].rowId,E=>{let O=o[y[E]]?.focal??I;return[O.x*C,O.y*C]});let U=(d.minX+d.maxX)/2*C,v=(d.minY+d.maxY)/2*C,S=.5*Math.hypot((d.maxX-d.minX)*C,(d.maxY-d.minY)*C)||10,T=wo(w,P,{cx:U,cz:v,radius:S}),N=Io(P,p,d,T.minY,T.maxY,S);return{solids:w,sectionSolidRanges:x,seats:P,bounds:{center:[(N.min[0]+N.max[0])/2,(N.min[1]+N.max[1])/2,(N.min[2]+N.max[2])/2],radius:S,groundY:0,box:N},renderBounds:{center:T.center,radius:T.radius},stateColorLUT:hn(n,Qe),theme:n,seatCount:s.length,focalWorld:[I.x*C,1.5,I.y*C],zones:g,stages:p,productionElements:i.elements,sections:R,rows:k,labels:M,floors:L}}function Is(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(n=>n.buffer)}var Eo=self;Eo.onmessage=e=>{let t=performance.now(),n=!e.data.seats,r=e.data.seats??fn(e.data.doc),o=Co({doc:e.data.doc,seats:r,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb});Eo.postMessage({model:o,buildMs:performance.now()-t,...n?{seats:r}:{}},Is(o))};
1
+ "use strict";var Mi=Object.create;var Ln=Object.defineProperty;var Si=Object.getOwnPropertyDescriptor;var Ii=Object.getOwnPropertyNames;var Pi=Object.getPrototypeOf,Ri=Object.prototype.hasOwnProperty;var wi=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ii(t))!Ri.call(e,r)&&r!==n&&Ln(e,r,{get:()=>t[r],enumerable:!(o=Si(t,r))||o.enumerable});return e};var Fe=(e,t,n)=>(n=e!=null?Mi(Pi(e)):{},wi(t||!e||!e.__esModule?Ln(n,"default",{value:e,enumerable:!0}):n,e));var eu=Math.PI/180;function Wt(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function it(e){return e.length?Wt(e):null}function On(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,s=3*n*t*t,i=t*t*t;return{x:o*e.start.x+r*e.control1.x+s*e.control2.x+i*e.end.x,y:o*e.start.y+r*e.control1.y+s*e.control2.y+i*e.end.y}}function Bn(e,t,n=192){if(!Number.isInteger(t)||t<1)throw new Error("Path point count must be a positive integer");if(t===1)return[On(e,.5)];let o=Array.from({length:n+1},(f,u)=>On(e,u/n)),r=new Float64Array(o.length);for(let f=1;f<o.length;f+=1){let u=o[f].x-o[f-1].x,l=o[f].y-o[f-1].y;r[f]=r[f-1]+Math.hypot(u,l)}let s=r[r.length-1];if(s<=1e-9)return Array.from({length:t},()=>({...e.start}));let i=[],a=1;for(let f=0;f<t;f+=1){let u=s*f/(t-1);for(;a<r.length-1&&r[a]<u;)a+=1;let l=r[a-1],c=r[a],h=c===l?0:(u-l)/(c-l);i.push({x:o[a-1].x+(o[a].x-o[a-1].x)*h,y:o[a-1].y+(o[a].y-o[a-1].y)*h})}return i}function Fn(e,t,n){return Math.max(t,Math.min(n,e))}function Dn(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let s=r.slice().sort((h,m)=>h.segmentedRow.componentIndex-m.segmentedRow.componentIndex),i=s[0]?.segmentedRow?.componentCount??0,a=s[0]?.segmentedRow;if(!a||!(i>=2&&s.length===i&&a?.boundaryBefore==="start"&&s.every((h,m)=>h.segmentedRow?.kind==="segmented-row-v1"&&h.segmentedRow.groupId===o&&h.segmentedRow.componentCount===i&&h.segmentedRow.componentIndex===m&&h.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(m===0?h.segmentedRow.boundaryBefore==="start":h.segmentedRow.boundaryBefore!=="start")&&h.segmentedRow.displayLabel===a.displayLabel)))continue;let u=s.reduce((h,m)=>h+m.seatCount,0),l=0,c=0;for(let h of s)h.segmentedRow.boundaryBefore==="break"&&(l+=1),t.set(h.id,{groupId:o,adjacencyOffset:l,displayOffset:c,displayLabel:a.displayLabel,totalSeats:u,canonical:s[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),l+=h.seatCount,c+=h.seatCount}return t}var vi="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Ei="abcdefghijklmnopqrstuvwxyz";function Ci(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let s=o%n;r=t[s]+r,o=Math.floor(o/n)}return r}function Zt(e,t=!1){let n=t?Ei:vi;return Ci(Math.max(0,Math.floor(e)-1),n)}var Ai=[[1e3,"M"],[900,"CM"],[500,"D"],[400,"CD"],[100,"C"],[90,"XC"],[50,"L"],[40,"XL"],[10,"X"],[9,"IX"],[5,"V"],[4,"IV"],[1,"I"]];function Nn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Ai)for(;t>=o;)n+=r,t-=o;return n}function _i(e){let t=new Array(e);return Array.from({length:e},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(e-1))-Math.abs(2*o-(e-1))||n-o).forEach((n,o)=>t[n]=o),t}function xt(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,s=e.seatNumbering?.scheme??"decimal",i=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,f=e.seatCount;if(s==="updown"||s==="updown-descending"){let m=Math.ceil(f/2),d=s==="updown"?t<m?n+2*t:n-1+2*(f-t):t<m?n+2*(m-1-t):n+1+2*(t-m);return`${i}${d}`}let u=s==="odd"||s==="even"?2:r,l=a!=null&&Number.isFinite(a)?a-(f-1)*u:n,c=o==="center"?_i(f)[t]:o==="rtl"?f-1-t:t,h;switch(s){case"odd":{let m=l%2===1?l:l+1;h=String(m+c*2);break}case"even":{let m=l%2===0?l:l+1;h=String(m+c*2);break}case"roman":h=Nn(l+c*r);break;case"letters-upper":h=Zt(l+c*r,!1);break;case"letters-lower":h=Zt(l+c*r,!0);break;default:h=String(l+c*r);break}return`${i}${h}`}function ki(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function Gn(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${xt(e,t)}`}function $t(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return xt(e,t);if(!n)return`${e.displayLabel||e.label}-${xt(e,t)}`;let r=ki(n),s=n.displayOffset+t;return`${n.displayLabel}-${xt(r,s)}`}var J=.02291666666666667,ge=1/J,Ti=58,Li=Ti*J;var Oi=3,jn=0,Qt=120,Bi=0,Fi=45,Di=7,Ee=1.2;function qt(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function Ni(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=Di?e:Oi}function De(e,t={}){let n=qt(t.floorBaseHeightM,jn,Qt,0),o=Math.min(Qt,n+Ni(e.elevation)*Li),r=e.height===void 0?o:qt(e.height,jn,Qt,o),s=qt(e.rake,Bi,Fi,0);return{height:r,rake:s}}function Hn(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function We(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let s=e[r],i=e[r+1],a=i.x-s.x,f=i.y-s.y,u=a*a+f*f,l=u>1e-12?((t-s.x)*a+(n-s.y)*f)/u:0;l<0?l=0:l>1&&(l=1);let c=t-(s.x+l*a),h=n-(s.y+l*f);if(Math.abs(c)>=o||Math.abs(h)>=o)continue;let m=Math.hypot(c,h);m<o&&(o=m)}return o}function Gi(e){let t=0,n=0;for(let s of e)t+=s.x,n+=s.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let s of e){let i=Math.hypot(s.x-t,s.y-n);i>r&&(r=i)}return{cx:t,cy:n,r}}function Xn(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function Jt(e,t){let n=1/0;for(let o of Hn(e)){let r=We(t,o.x,o.y);r<n&&(n=r)}for(let o of Hn(t)){let r=We(e,o.x,o.y);r<n&&(n=r)}return n}function ji(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let l of e)n+=l.x,o+=l.y;n/=e.length,o/=e.length;let r=-1,s=e[0];for(let l of e){let c=Math.hypot(l.x-n,l.y-o);c>r&&(r=c,s=l)}let i=s.x-n,a=s.y-o,f=Math.hypot(i,a);f>1e-9?(i/=f,a/=f):(i=1,a=0);let u=e.map((l,c)=>({p:l,i:c,t:(l.x-n)*i+(l.y-o)*a})).sort((l,c)=>l.t-c.t);return{pts:u.map(l=>l.p),seatIndices:u.map(l=>t[l.i])}}function en(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let x of e)n+=x.x,o+=x.y;n/=t,o/=t;let r=0,s=0,i=0,a=0,f=0,u=0,l=0;for(let x of e){let M=x.x-n,I=x.y-o;r+=M*M,i+=I*I,s+=M*I,a+=M*M*M,f+=I*I*I,u+=M*I*I,l+=I*M*M}let c=r*i-s*s;if(Math.abs(c)<1e-9)return null;let h=(a+u)/2,m=(f+l)/2,d=(h*i-m*s)/c,p=(m*r-h*s)/c,b=d+n,y=p+o;return!Number.isFinite(b)||!Number.isFinite(y)?null:{cx:b,cy:y}}var Hi=.15;function Xi(e){if(e.length<2)return null;let t=e.map(x=>{let M=0,I=0;for(let w of x.pts)M+=w.x,I+=w.y;return{x:M/x.pts.length,y:I/x.pts.length}}),n=0,o=0;for(let x of t)n+=x.x,o+=x.y;n/=t.length,o/=t.length;let r=0,s=0,i=0;for(let x of t){let M=x.x-n,I=x.y-o;r+=M*M,s+=M*I,i+=I*I}let a=r+i,f=r*i-s*s,u=a/2+Math.sqrt(Math.max(0,a*a/4-f)),l,c;Math.abs(s)>1e-12?(l=u-i,c=s):r>=i?(l=1,c=0):(l=0,c=1);let h=Math.hypot(l,c);if(!(h>1e-12))return null;l/=h,c/=h;let m=1/0,d=-1/0,p=[];for(let x of e){let M=1/0,I=-1/0;for(let w of x.pts){let g=w.x*l+w.y*c;g<M&&(M=g),g>I&&(I=g),g<m&&(m=g),g>d&&(d=g)}p.push(I-M)}let b=d-m;return b>1e-9?(p.sort((x,M)=>x-M),p[Math.min(p.length-1,Math.floor(p.length*.9))]/b<=Ui?{x:l,y:c}:null):null}var Ui=.35;function gt(e,t,n,o){let r=new Map;for(let g of n){let R=t[g],P=R.rowId||`__seat-${g}`,S=r.get(P);S||(S={pts:[],idx:[]},r.set(P,S)),S.pts.push({x:R.x,y:R.y}),S.idx.push(g)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let s=[];for(let[g,R]of r){let P=ji(R.pts,R.idx),S=0;for(let E of P.pts)S+=Math.hypot(E.x-o.x,E.y-o.y);s.push({id:g,pts:P.pts,seatIndices:P.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:S/P.pts.length})}let i=s.map(g=>Gi(g.pts)),a=s.length<=256?s.length*(s.length-1)/2:0,f=a?new Float64Array(a):null;f?.fill(Number.NaN);let u=f?new Map(s.map((g,R)=>[g,R])):null,l=(g,R)=>(g>R&&([g,R]=[R,g]),g*(2*s.length-g-1)/2+(R-g-1)),c=(g,R)=>{if(!f)return Jt(s[g].pts,s[R].pts);let P=l(g,R),S=f[P];if(!Number.isNaN(S))return S;let E=Jt(s[g].pts,s[R].pts);return f[P]=E,E},h=(g,R)=>u?c(u.get(g),u.get(R)):Jt(g.pts,R.pts),m=[];for(let g=0;g<s.length;g++){let R=1/0;for(let P=0;P<s.length;P++){if(g===P||Xn(i[g],i[P])>=R)continue;let S=c(g,P);S<R&&(R=S)}Number.isFinite(R)&&m.push(R)}m.sort((g,R)=>g-R);let d=m.length?m[Math.floor(m.length/2)]:1,p=Math.max(d*1.8,1e-6),b=s.map(()=>[]);for(let g=0;g<s.length;g++)for(let R=g+1;R<s.length;R++)Xn(i[g],i[R])>p||c(g,R)<=p&&(b[g].push(R),b[R].push(g));let y=0;for(let g=0;g<s.length;g++){if(s[g].blockId!==-1)continue;let R=y++,P=[g];for(s[g].blockId=R;P.length;){let S=P.pop();for(let E of b[S])s[E].blockId===-1&&(s[E].blockId=R,P.push(E))}}let x=new Map;for(let g of s){let R=x.get(g.blockId)??[];R.push(g),x.set(g.blockId,R)}let M=[];for(let g of s){if(g.pts.length<4)continue;let R=en(g.pts);R&&(!Number.isFinite(R.cx)||!Number.isFinite(R.cy)||M.push({x:R.cx,y:R.cy}))}let I=M.length>=2?(()=>{let g=M.map(S=>S.x).sort((S,E)=>S-E),R=M.map(S=>S.y).sort((S,E)=>S-E),P=Math.floor(M.length/2);return{cx:g[P],cy:R[P]}})():null;if(I){let g=O=>Math.hypot(O.x-I.cx,O.y-I.cy),R=1/0,P=-1/0,S=[];for(let O of s){let k=1/0,C=-1/0;for(let A of O.pts){let L=g(A);L<k&&(k=L),L>C&&(C=L)}S.push(C-k),k<R&&(R=k),C>P&&(P=C)}let E=P-R;S.sort((O,k)=>O-k);let _=S[Math.min(S.length-1,Math.floor(S.length*.9))];if(E>1e-9&&_/E<=Hi){let O=s.map(D=>{let V=0;for(let U of D.pts)V+=g(U);return{row:D,radius:V/D.pts.length}}),k=0,C=0;for(let D of O)k+=D.radius,C+=D.row.focalDistance;k/=O.length,C/=O.length;let A=0;for(let D of O)A+=(D.radius-k)*(D.row.focalDistance-C);if(A<0)for(let D of O)D.radius=-D.radius;let F=1/0;for(let D of O)D.radius<F&&(F=D.radius);O.sort((D,V)=>D.radius-V.radius);let T=-1,B=-1/0,N=E/Math.max(1,O.length)*.5,H=[];for(let D of O)D.radius-B>N&&(T++,B=D.radius),D.row.ordinal=T,D.row.blockDepth=D.radius-F,H.push(D.row);return{sectionId:e,rows:H,blockCount:y}}}let w=[];for(let[,g]of x){let R=Xi(g);if(R){let P=E=>{let _=0;for(let O of E.pts)_+=O.x*R.x+O.y*R.y;return _/E.pts.length};g.sort((E,_)=>P(E)-P(_)),g.length>=2&&g[0].focalDistance>g[g.length-1].focalDistance&&g.reverse();let S=0;for(let E=0;E<g.length;E++)E>0&&(S+=h(g[E-1],g[E])),g[E].ordinal=E,g[E].blockDepth=S,w.push(g[E])}else{let P=1/0;for(let S of g)S.focalDistance<P&&(P=S.focalDistance);g.sort((S,E)=>S.focalDistance-E.focalDistance);for(let S=0;S<g.length;S++)g[S].ordinal=S,g[S].blockDepth=Math.max(0,g[S].focalDistance-P),w.push(g[S])}}return{sectionId:e,rows:w,blockCount:y}}var Vi=/^\d{4}-\d{2}-\d{2}$/;function Yi(e){let t=Date.parse(e);return Number.isFinite(t)?Vi.test(e)?t+864e5:t:null}function Ki(e,t=Date.now()){if(e.validUntil===void 0){if(e.status!=="approved")return!0;let o=e.assessedAt?Date.parse(e.assessedAt):Number.NaN;return Number.isFinite(o)&&(t instanceof Date?t.getTime():t)<=o+366*864e5}let n=Yi(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function zi(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function Wi(e){return e.status!=="draft"&&e.status!=="retracted"}function Zi(e,t){return e.status===void 0?t===void 0:e.status!=="approved"?!0:typeof t=="string"&&typeof e.basisSha256=="string"&&e.basisSha256===t}function Un(e,t={}){return!!e&&Wi(e)&&zi(e,t.activeConfigurationId,t.activeConfigurationVersion)&&Zi(e,t.activeBasisSha256)&&Ki(e,t.now)}var $i=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),Qi=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function Xe(e){return!!e&&$i.has(e)}function Kn(e){return!!e&&Qi.has(e)}var Mt=1.1,qi={"pitch-football":{width:105,height:68},"rink-hockey":{width:60,height:30},"track-athletics":{width:176.9,height:92.5},"oval-cricket":{width:150,height:140},"pitch-rugby":{width:120,height:70},"diamond-baseball":{width:140,height:140},"court-basketball":{width:32,height:19},"court-tennis":{width:36.57,height:18.29},"ring-boxing":{width:7.8,height:7.8}},Ji={"pitch-football":"#2f7d4f","rink-hockey":"#e8f1f8","track-athletics":"#a4472f","oval-cricket":"#3d8a53","pitch-rugby":"#2f7d4f","diamond-baseball":"#2f7d4f","court-basketball":"#c8894f","court-tennis":"#3f7a5a","ring-boxing":"#2a4d8f"};var es=Math.PI*2;function ts(e,t,n,o,r,s){return{x:r+e*n-t*o,y:s+e*o+t*n}}function Vn(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let s=0;s<=r;s++){let i=-Math.PI/2+s/r*Math.PI;o.push({x:n+t*Math.cos(i),y:t*Math.sin(i)})}for(let s=0;s<=r;s++){let i=Math.PI/2+s/r*Math.PI;o.push({x:-n+t*Math.cos(i),y:t*Math.sin(i)})}return o}var Yn=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),s=r+70,i=[],a=Math.atan2(o.y-r,o.x),f=Math.atan2(o.y-r,-o.x);for(let u=0;u<=24;u++){let l=a+(f-a)*u/24;i.push({x:s*Math.cos(l),y:r+s*Math.sin(l)})}return{half:70,home:t,backstop:n,fence:i}})();var St="#f1f5f9";function st(e){return Xe(e)}function Ne(e,t,n,o,r=32){let s=[];for(let i=0;i<r;i++){let a=i/r*es;s.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return s}function Te(e,t,n,o){return[{x:e-n,y:t-o},{x:e+n,y:t-o},{x:e+n,y:t+o},{x:e-n,y:t+o}]}function ns(e){let{kind:t,cx:n,cy:o,width:r,height:s}=e,i=(e.rotation??0)*Math.PI/180,a=Math.cos(i),f=Math.sin(i),u=r/2,l=s/2,c=[],h=qi[t],m=p=>h?p/h.width*r:0,d=p=>h?p/h.height*s:0;switch(t){case"pitch-football":{c.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1}),c.push({points:Ne(0,0,m(9.15),d(9.15)),closed:!0});for(let p of[-1,1])c.push({points:Te(p*(u-m(16.5)/2),0,m(16.5)/2,d(40.32)/2),closed:!0}),c.push({points:Te(p*(u-m(5.5)/2),0,m(5.5)/2,d(18.32)/2),closed:!0});break}case"rink-hockey":{c.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1,ink:"#d63b3b"});for(let p of[-1,1]){c.push({points:[{x:p*m(7.5),y:-l},{x:p*m(7.5),y:l}],closed:!1,ink:"#2f6ecb"}),c.push({points:[{x:p*(u-m(4)),y:-d(11)},{x:p*(u-m(4)),y:d(11)}],closed:!1,ink:"#d63b3b"});for(let b of[-1,1])c.push({points:Ne(p*m(20.5),b*d(7),m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"})}c.push({points:Ne(0,0,m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"});break}case"track-athletics":{let b=l-d(1.22)*8;b>0&&c.push({points:Vn(u-m(1.22)*8,b),closed:!0,fill:"#2f7d4f"});for(let y=1;y<8;y++){let x=d(1.22)*y,M=l-x;if(M<=0)break;c.push({points:Vn(u-m(1.22)*y,M),closed:!0})}break}case"oval-cricket":{c.push({points:Ne(0,0,m(27.4),d(27.4+20.12/2),40),closed:!0}),c.push({points:Te(0,0,m(3.05)/2,d(20.12)/2),closed:!0,ink:"#d8cfae"});break}case"pitch-rugby":{let p=b=>({points:[{x:m(b),y:-l},{x:m(b),y:l}],closed:!1});c.push(p(0));for(let b of[-1,1]){c.push(p(b*50),p(b*28));for(let y=-35;y<35;y+=4)c.push({points:[{x:m(b*10),y:d(y)},{x:m(b*10),y:d(Math.min(35,y+2))}],closed:!1})}break}case"diamond-baseball":{let p=(L,F)=>({x:m(L),y:d(F)}),{home:b}=Yn,y=27.43,x=y/Math.SQRT2,M={x:b.x+x,y:b.y-x},I={x:b.x,y:b.y-2*x},w={x:b.x-x,y:b.y-x},g={x:b.x,y:b.y-18.44},R="#b98a59",P=Ji["diamond-baseball"],S=38.94,E=[p(b.x,b.y)],_=Math.atan2(b.y-S/Math.SQRT2-g.y,S/Math.SQRT2),O=Math.PI-_;for(let L=0;L<=16;L++){let F=_-(_+Math.PI*2-O)%(Math.PI*2)*(L/16);E.push(p(g.x+29*Math.cos(F),g.y+29*Math.sin(F)))}c.push({points:E,closed:!0,fill:R,ink:R});let k={x:b.x,y:b.y-x},C=[{x:b.x,y:b.y},M,I,w].map(L=>p(k.x+(L.x-k.x)*.84,k.y+(L.y-k.y)*.84));c.push({points:C,closed:!0,fill:P,ink:P}),c.push({points:Ne(m(g.x),d(g.y),m(2.74),d(2.74),20),closed:!0,fill:R,ink:R}),c.push({points:Ne(m(b.x),d(b.y),m(3.96),d(3.96),20),closed:!0,fill:R,ink:R});let A=Yn.fence;c.push({points:[p(b.x,b.y),p(A[0].x,A[0].y)],closed:!1}),c.push({points:[p(b.x,b.y),p(A[A.length-1].x,A[A.length-1].y)],closed:!1});for(let L of[M,I,w])c.push({points:Te(m(L.x),d(L.y),m(.3),d(.3)),closed:!0,fill:St});break}case"court-basketball":{c.push({points:Te(0,0,m(14),d(7.5)),closed:!0}),c.push({points:[{x:0,y:-d(7.5)},{x:0,y:d(7.5)}],closed:!1}),c.push({points:Ne(0,0,m(1.8),d(1.8),24),closed:!0});for(let p of[-1,1]){let b=p*14,y=p*(14-5.8),x=p*(14-1.575);c.push({points:Te(m((b+y)/2),0,m(2.9),d(2.45)),closed:!0,fill:"#2f5d8a"}),c.push({points:Ne(m(y),0,m(1.8),d(1.8),24),closed:!0});let M=Math.sqrt(6.75*6.75-6.6*6.6),I=[{x:m(b),y:-d(6.6)}],w=Math.atan2(-6.6,-p*M),g=2*Math.atan2(6.6,M);for(let R=0;R<=16;R++){let P=w-p*g*(R/16);I.push({x:m(x+6.75*Math.cos(P)),y:d(6.75*Math.sin(P))})}I.push({x:m(b),y:d(6.6)}),c.push({points:I,closed:!1})}break}case"court-tennis":{c.push({points:Te(0,0,m(11.885),d(5.485)),closed:!0,fill:"#2b5f99"});for(let p of[-1,1])c.push({points:[{x:-m(11.885),y:p*d(4.115)},{x:m(11.885),y:p*d(4.115)}],closed:!1}),c.push({points:[{x:p*m(6.4),y:-d(4.115)},{x:p*m(6.4),y:d(4.115)}],closed:!1});c.push({points:[{x:-m(6.4),y:0},{x:m(6.4),y:0}],closed:!1}),c.push({points:[{x:0,y:-d(6.4)},{x:0,y:d(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{c.push({points:Te(0,0,m(3.05),d(3.05)),closed:!0});let y=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[x,M,I]of y)c.push({points:Te(x*m(3.05),M*d(3.05),m(.3),d(.3)),closed:!0,fill:I,ink:I});break}default:return[]}return c.map(p=>({...p,points:p.points.map(b=>ts(b.x,b.y,a,f,n,o))}))}function zn(e){if(e.role!=="stage"||!st(e.stageKind))return[];let t=null;if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null&&e.width>0&&e.height>0&&[e.x,e.y,e.width,e.height].every(Number.isFinite))t={cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height};else if(e.points&&e.points.length>=3&&e.points.every(n=>Number.isFinite(n.x)&&Number.isFinite(n.y))){let n=e.points.map(l=>l.x),o=e.points.map(l=>l.y),r=Math.min(...n),s=Math.max(...n),i=Math.min(...o),a=Math.max(...o),f=Math.max(1,s-r),u=Math.max(1,a-i);t={cx:r+f/2,cy:i+u/2,width:f,height:u}}return t?ns({kind:e.stageKind,...t}):[]}var os=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,rs=/[\s"'<>`\\]/;function is(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return os.test(e);if(rs.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function Wn(e){let t=e.trim();return is(t)?t:null}var tn="seatlayer.event-configuration/1";var Ze=100,ss=120,as=2e5,cs=1e4,ls=/^[a-f0-9]{64}$/,us=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function at(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ue(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function fs(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function Zn(e){return!Array.isArray(e)||e.length>as||!e.every(t=>Ue(t,Ze))?null:[...new Set(e)].sort()}function ms(e){return!at(e)||!Ue(e.chartId,Ze)||!Ue(e.version,Ze)||e.sha256!==void 0&&(typeof e.sha256!="string"||!ls.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function nn(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function hs(e){return at(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&nn(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function ds(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>cs)return null;let n=new Set(t),o=new Set,r=new Set,s=0,i=[];for(let a of e){if(!at(a)||!Ue(a.id,Ze)||!Ue(a.objectId,Ze)||!n.has(a.objectId)||!us.has(String(a.kind))||!nn(a.heightM,.05,50)||a.baseElevationM!==void 0&&!nn(a.baseElevationM,-10,100))return null;let f=hs(a.occlusion);if(!f||o.has(a.id)||r.has(a.objectId))return null;let u=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?Wn(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!u||a.kind!=="screen"||++s>1))return null;o.add(a.id),r.add(a.objectId),i.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:f,...u?{contentImageUrl:u}:{}})}return i.sort((a,f)=>a.id.localeCompare(f.id))}function ps(e){let t=[];if(!at(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==tn&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${tn}`}),Ue(e.id,Ze)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),Ue(e.label,ss)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),fs(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=ms(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let o=at(e.overlay)?e.overlay:null,r=Zn(o?.objectIds),s=Zn(o?.productionKillSeatIds),i=r?ds(o?.productionElements,r):null;return(!o||!r||!s)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),i===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!r||!s||i===null?{issues:t}:{issues:t,value:{schema:tn,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:s,...i!==void 0?{productionElements:i}:{}}}}}function $n(e){let t=ps(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function bs(e){if((e.kind==="polygon"||e.kind==="polyline"||e.kind==="line")&&e.points&&e.points.length>=2)return e.points;if(e.x==null||e.y==null||e.width==null||e.height==null)return null;let t=e.x,n=e.y,o=e.width,r=e.height;return[{x:t,y:n},{x:t+o,y:n},{x:t+o,y:n+r},{x:t,y:n+r}]}function ys(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),s=Math.sin(o),i=e.x-t.x,a=e.y-t.y;return{x:t.x+i*r-a*s,y:t.y+i*s+a*r}}function Qn(e){let t=bs(e);if(!t||t.length<2)return null;let n=e.rotation??0,o=Math.abs(n)<1e-6?t:t.map(f=>ys(f,{x:t.reduce((u,l)=>u+l.x,0)/t.length,y:t.reduce((u,l)=>u+l.y,0)/t.length},n)),r=1/0,s=1/0,i=-1/0,a=-1/0;for(let f of o)r=Math.min(r,f.x),s=Math.min(s,f.y),i=Math.max(i,f.x),a=Math.max(a,f.y);return!Number.isFinite(r)||i-r<1e-6||a-s<1e-6?null:{minX:r,minY:s,maxX:i,maxY:a}}var xs=5,gs=3,Ms=.92,Ss=1.9,Is=2,Ps=.6,Rs=1,ws=.06;function vs(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?Mt:st(e.stageKind)?ws:Rs}function qn(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,s=-1/0;for(let i of to(e)){let a=i.baseHeightM??0;for(let f of i.objects){if(f.type!=="shape"||f.role!=="stage")continue;let u=Qn(f);u&&(t=Math.min(t,u.minX),n=Math.min(n,u.minY),o=Math.max(o,u.maxX),r=Math.max(r,u.maxY),s=Math.max(s,a+vs(f)))}}return!Number.isFinite(t)||!Number.isFinite(s)?null:{minX:t,minY:n,maxX:o,maxY:r,deckTopM:s}}function Es(e,t,n,o){let r=1/0,s=1/0,i=-1/0,a=-1/0;for(let m of e)Number.isFinite(m.eyeHeightM)&&(r=Math.min(r,m.x),i=Math.max(i,m.x),s=Math.min(s,m.y),a=Math.max(a,m.y));if(!Number.isFinite(r))return null;let f=r*t,u=s*t,l=Math.max(1,Math.ceil((i-r)*t/n)+1),c=Math.max(1,Math.ceil((a-s)*t/n)+1),h=new Float64Array(l*c).fill(-1/0);for(let m of e){if(!Number.isFinite(m.eyeHeightM))continue;let d=m.eyeHeightM-Ee,p=Math.min(l-1,Math.max(0,Math.floor((m.x*t-f)/n))),y=Math.min(c-1,Math.max(0,Math.floor((m.y*t-u)/n)))*l+p,x=d+o;x>h[y]&&(h[y]=x)}return{cellM:n,minX:f,minY:u,cols:l,rows:c,top:h}}function Cs(e,t,n){let o=Math.floor((t-e.minX)/e.cellM),r=Math.floor((n-e.minY)/e.cellM);return o<0||r<0||o>=e.cols||r>=e.rows?-1/0:e.top[r*e.cols+o]}function Jn(e,t,n={}){let o=new Map;if(!t||!e.length)return o;let r=n.metresPerChartUnit??J,s=n.cellM??Ps,i=n.chairBackM??Ms,a=n.selfRowSkipM??Is,f=n.clearThreshold??.9,u=n.partialThreshold??.25,l=Math.max(1,n.columns??xs),c=Math.max(1,n.rows??gs),h=Es(e,r,s,i);if(!h)return o;let m=(t.maxX-t.minX)*r,d=(t.maxY-t.minY)*r,p=m>=d,b=(t.minX+t.maxX)/2*r,y=(t.minY+t.maxY)/2*r,x=[];for(let I=0;I<l;I++){let w=(I+.5)/l-.5,g=p?b+w*m:b,R=p?y:y+w*d;for(let P=0;P<c;P++){let S=t.deckTopM+(c===1?0:P/(c-1)*Ss);x.push({x:g,y:R,z:S})}}let M=s/2;for(let I of e){if(!Number.isFinite(I.eyeHeightM))continue;let w=I.x*r,g=I.y*r,R=I.eyeHeightM,P=0,S=1/0;for(let _ of x){let O=_.x-w,k=_.y-g,C=Math.hypot(O,k);if(!(C>a)){P++;continue}let A=O/C,L=k/C,F=0;for(let T=a;T<C;T+=M){let B=Cs(h,w+A*T,g+L*T);if(!(!Number.isFinite(B)||B>=R)&&B>R+(_.z-R)*T/C){F=T;break}}F?S=Math.min(S,F):P++}let E=P/x.length;E>=f||o.set(I.id,{seatId:I.id,mark:E<u?"obstructedView":"restrictedView",visibleFraction:E,totalRays:x.length,atDistanceM:Number.isFinite(S)?S:0})}return o}function eo(e,t){if(!t.size)return 0;let n=0;for(let o of e){let r=t.get(o.id);if(!r)continue;let s=o.commercial;s?.restrictedView!==void 0||s?.obstructedView!==void 0||(o.commercial={...s,[r.mark]:!0},n++)}return n}function on(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Pt=Math.PI/180;var ct=16;function rn(e,t,n,o){let r=n*Pt,s=Math.cos(r),i=Math.sin(r);return{x:o.x+e*s-t*i,y:o.y+e*i+t*s}}function so(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:s}=e,i=[];if(e.path)return Bn(e.path,t);if(t<=1)return t===1&&i.push({x:s.x,y:s.y}),i;if(o===0){for(let u=0;u<t;u++)i.push(rn(u*n,0,r,s));return i}let a=o/(t-1)*Pt,f=n/(2*Math.sin(Math.abs(a)/2));for(let u=0;u<t;u++){let l=u*a,c=f*Math.sin(l),h=-f+f*Math.cos(l);i.push(rn(c,h,r,s))}return i}function ao(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function As(e,t){let n=ao(e);return so(e).map((o,r)=>{let s=n.get(r),i=on(s),a=Gn(e,r,s),f={...e.commercial,...s?.commercial};return{index:r,x:o.x+(s?.dx??0),y:o.y+(s?.dy??0),label:a,displayLabel:$t(e,r,t,s),categoryKey:s?.categoryKey??e.categoryKey,skipped:!!s?.skip,accessible:i.length>0,accessibility:i,wheelchairSpaceType:s?.wheelchairSpaceType,commercial:Object.values(f).some(u=>u!==void 0&&u!==!1&&u!=="")?f:void 0,glyph:s?.glyph,viewUrl:s?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:s?.viewFromSeatUrl?s.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:s?.labelStyle??e.seatLabelStyle}})}function _s(e){let t=[];for(let n of As(e))n.skipped||t.push({id:`${e.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:e.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,glyph:n.glyph,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function ks(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(s=>t.includes(s)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let s=0;s<r;s++)o[n[s%n.length]]+=1;return o}function Ts(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(l=>[l.index,l])),r=(l,c,h,m)=>{let d=o.get(l),p=on(d),b=d?.label??`${e.label}-${l+1}`,y=e.displayLabel??e.label;return{index:l,label:b,displayLabel:d?.displayLabel??`${y}-${l+1}`,x:c+(d?.dx??0),y:h+(d?.dy??0),categoryKey:d?.categoryKey??e.categoryKey,skipped:!!d?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:d?.wheelchairSpaceType,commercial:d?.commercial,glyph:d?.glyph,viewUrl:d?.viewFromSeatUrl,viewMeta:d?.viewFromSeatUrl?d.viewFromSeatMeta:void 0,labelStyle:d?.labelStyle,...m?{side:m}:{}}};if(e.shape==="round"){let l=(e.radius??40)+ct,c=e.rotation*Pt,h=Math.max(0,Math.min(360,e.seatArc??360));if(h>=360||n===1){for(let b=0;b<n;b++){let y=c+b/n*2*Math.PI;t.push(r(b,e.center.x+l*Math.cos(y),e.center.y+l*Math.sin(y)))}return t}let m=h*Pt,d=(2*Math.PI-m)/2,p=c+d;for(let b=0;b<n;b++){let y=p+b/(n-1)*m;t.push(r(b,e.center.x+l*Math.cos(y),e.center.y+l*Math.sin(y)))}return t}let s=e.width??80,i=e.height??50,a=ks(e),f=["top","bottom","left","right"],u=0;for(let l of f){let c=a[l];for(let h=0;h<c;h++){let m,d;l==="top"?(m=-s/2+(h+.5)*s/c,d=-i/2-ct):l==="bottom"?(m=-s/2+(h+.5)*s/c,d=i/2+ct):l==="left"?(m=-s/2-ct,d=-i/2+(h+.5)*i/c):(m=s/2+ct,d=-i/2+(h+.5)*i/c);let p=rn(m,d,e.rotation,e.center);t.push(r(u++,p.x,p.y,l))}}return t}function Ls(e){return Ts(e).filter(t=>!t.skipped).map(t=>({id:`${e.id}:${t.index}`,label:t.label,...t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.x,y:t.y,rowId:e.id,categoryKey:t.categoryKey,...t.accessible?{accessible:!0}:{},...t.accessibility.length?{accessibility:t.accessibility}:{},...t.wheelchairSpaceType?{wheelchairSpaceType:t.wheelchairSpaceType}:{},...t.commercial?{commercial:t.commercial}:{},...t.glyph?{glyph:t.glyph}:{},...t.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function Os(e){return[{id:`${e.id}:0`,label:e.label,...e.displayLabel&&e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.center.x,y:e.center.y,rowId:e.id,categoryKey:e.categoryKey,kind:"booth"}]}function no(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let s=t[o].x,i=t[o].y,a=t[r].x,f=t[r].y;i>e.y!=f>e.y&&e.x<(a-s)*(e.y-i)/(f-i)+s&&(n=!n)}return n}function Bs(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],s=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(s)>1e-7)return!1;let i=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),a=(r.x-n.x)**2+(r.y-n.y)**2;return i>=-1e-7&&i<=a+1e-7})}function sn(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function me(e,t,n){return no(e,t)&&!sn(n).some(o=>no(e,o)||Bs(e,o))}function It(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function co(e){switch(e.type){case"row":{let t=so(e),n=ao(e),o=0,r=0,s=0;for(let i=0;i<t.length;i++){let a=n.get(i);a?.skip||(o+=t[i].x+(a?.dx??0),r+=t[i].y+(a?.dy??0),s++)}return s?{x:o/s,y:r/s}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return It(e.points);case"section":return It(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?It(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function oo(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Fs(e,t){if(e.type!=="gaArea"||!oo(e.points,t.outline))return!1;let n=sn(e.holes),o=sn(t.holes);return n.length===o.length&&n.every((r,s)=>oo(r,o[s]))}function Ds(e,t,n=e.filter(r=>r.type==="section"),o=co(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(i=>(i.logicalSectionId??i.id)===r&&(Fs(t,i)||me(o,i.outline,i.holes))):void 0)??n.find(i=>me(o,i.outline,i.holes))}function to(e){return e.floors&&e.floors.length?e.floors:[{id:"floor-0",name:"Main",objects:e.objects,focalPoint:e.focalPoint,referenceImage:e.referenceImage,backgroundImage:e.backgroundImage}]}function ro(e,t,n,o,r,s,i,a,f){let u=[],l=e.filter(p=>p.type==="section"),c=Dn(e),h=p=>!p?.eventConfigurationId||p.eventConfigurationId===o&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===f),m=p=>Un(p,{activeConfigurationId:o,activeConfigurationVersion:f,activeBasisSha256:r,now:a}),d=(p,b)=>m(p)?{...p,coverage:b}:void 0;for(let p of e){let b=[];if(p.type==="row"?b=_s(p):p.type==="table"?b=Ls(p):p.type==="booth"&&(b=Os(p)),!b.length)continue;for(let w of b)w.viewUrl&&!h(w.viewMeta)&&(w.viewUrl=void 0,w.viewMeta=void 0);if(p.type==="row"){let w=c.get(p.id);if(w){let g=new Map((p.overrides??[]).map(R=>[R.index,R]));for(let R of b){let P=Number(R.id.slice(R.id.lastIndexOf(":")+1));if(!Number.isInteger(P))continue;R.logicalRowId=w.groupId,R.logicalSeatIndex=w.adjacencyOffset+P,g.get(P)?.displayLabel||(R.displayLabel=$t(p,P,w)),!R.viewUrl&&w.viewFromSeatUrl&&h(w.viewFromSeatMeta)&&(R.viewUrl=w.viewFromSeatUrl,R.viewMeta=w.viewFromSeatMeta);let S=g.get(P)?.confidenceEvidence;R.confidenceEvidence=d(S,"exact-seat")??d(p.confidenceEvidence,"row-representative")??d(w.confidenceEvidence,"row-representative")}}}let y=Ds(e,p,l,p.type==="row"?It(b):co(p)),x=y?.viewFromSeatUrl,I=(y?.zone?t?.find(w=>w.id===y.zone):void 0)?.focalPoint??n;for(let w of b){if(!w.confidenceEvidence){let g=Number(w.id.slice(w.id.lastIndexOf(":")+1)),R=(p.type==="row"||p.type==="table")&&Number.isInteger(g)?p.overrides?.find(P=>P.index===g)?.confidenceEvidence:void 0;w.confidenceEvidence=d(R,"exact-seat")??(p.type==="row"?d(p.confidenceEvidence,"row-representative"):void 0)}w.confidenceEvidence??=d(y?.confidenceEvidence,"section-representative")??(i?d(i.evidence,i.coverage):void 0),!w.viewUrl&&x&&h(y?.viewFromSeatMeta)&&(w.viewUrl=x,w.viewMeta=y?.viewFromSeatMeta),!w.viewUrl&&s&&h(s.meta)&&(w.viewUrl=s.url,w.viewMeta=s.meta),y&&(w.sectionId=y.logicalSectionId??y.id),y?.zone&&(w.zoneId=y.zone),I&&(w.focalPoint={...I})}u.push(...b)}return u}function $e(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let s=r.focalPoint??e.focalPoint,i=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,f=ro(r.objects,e.zones,s,e.eventConfigurationId,e.confidenceBasisSha256,i,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&io(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,f);for(let u of f)u.floorId=r.id;for(let u of f)o.push(u)}return o}let n=ro(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.confidenceBasisSha256,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);return t.resolveEyeHeights!==!1&&io(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),Ns(e,n,t)}function Ns(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||eo(t,Jn(t,qn(e))),t}function io(e,t,n,o){let r=e.filter(c=>c.type==="section"),s=n>0||r.some(c=>c.height!==void 0||c.rake!==void 0||(c.elevation??0)>0);if(!r.length||!s||!t){for(let c of o)c.eyeHeightM=n+Ee;return}let i=new Array(o.length),a=new Map;for(let c of r)a.has(c.id)||a.set(c.id,c);let f=new Map,u=new Map;for(let c=0;c<o.length;c++){let h=o[c],d=(h.sectionId?a.get(h.sectionId)??r.find(b=>b.logicalSectionId===h.sectionId&&me({x:h.x,y:h.y},b.outline,b.holes)):void 0)??r.find(b=>me({x:h.x,y:h.y},b.outline,b.holes))??null;if(i[c]=d,!d)continue;f.has(d.id)||f.set(d.id,De(d,{floorBaseHeightM:n}));let p=u.get(d.id);p?p.push(c):u.set(d.id,[c])}let l=new Array(o.length).fill(void 0);for(let[c,h]of u){let m=f.get(c);if(!m)continue;let d=m.rake>0?Math.tan(m.rake*Math.PI/180):0,p=gt(c,o,h,t);for(let b of p.rows){let y=b.blockDepth*J*d,x=m.height+y;for(let M of b.seatIndices)l[M]=x}}for(let c=0;c<o.length;c++){let h=o[c],m=i[c];if(!m){h.eyeHeightM=n+Ee;continue}let d=f.get(m.id);h.eyeHeightM=(l[c]??d.height)+Ee}}var uo=Fe(require("earcut"),1),an=Fe(require("polygon-clipping"),1);function de(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let r=e[n],s=e[(n+1)%o];t+=r.x*s.y-s.x*r.y}return t/2}function pe(e,t,n){let o=!1;for(let r=0,s=e.length-1;r<e.length;s=r++){let i=e[r],a=e[s];i.y>n!=a.y>n&&t<(a.x-i.x)*(n-i.y)/(a.y-i.y)+i.x&&(o=!o)}return o}var v=J,Gs=.002;function js(e,t,n){let o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),s=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),i=Math.max(o,r,s);if(i<1e-9)return!0;let a=(o+r+s)/2;return 2*Math.sqrt(Math.max(0,a*(a-o)*(a-r)*(a-s)))/i<Gs}var Ve=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=o}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let o=new Float32Array(n);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},vt=class{constructor(){this.pos=new Ve;this.nor=new Ve;this.col=new Ve;this.flr=new Ve;this.mat=new Ve;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,o,r,s,i=s,a=s){js(t,n,o)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(a[0],a[1],a[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(t,n,o,r,s,i,a,f=a,u=a){[...t,...n,...o].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(s[0],s[1],s[2]),this.nor.push3(i[0],i[1],i[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(f[0],f[1],f[2]),this.col.push3(u[0],u[1],u[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 Hs(e,t,n){let o=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2],i=n[0]-e[0],a=n[1]-e[1],f=n[2]-e[2],u=r*f-s*a,l=s*i-o*f,c=o*a-r*i,h=Math.hypot(u,l,c)||1;return u/=h,l/=h,c/=h,[u,l,c]}function Xs(e,t){let n=[...e],o=[];for(let i of e)o.push(i.x,i.y);let r=[];if(t){for(let i of t)if(!(i.length<3)){r.push(n.length);for(let a of i)n.push(a),o.push(a.x,a.y)}}let s=(0,uo.default)(o,r.length?r:void 0,2);return{pts:n,tris:s}}function Ce(e){return de(e)<0?[...e].reverse():e}var Us=3;function Vs(e,t,n,o){let r=o(e),s=o(t),i=o(n),a=(m,d,p,b)=>Math.abs(o({x:(m.x+d.x)/2,y:(m.y+d.y)/2})-(p+b)/2),f=(e.x+t.x+n.x)/3,u=(e.y+t.y+n.y)/3,l=(r+s+i)/3,c=Math.max(a(e,t,r,s),a(t,n,s,i),a(n,e,i,r),Math.abs(o({x:f,y:u})-l)),h=(m,d,p)=>{let b=Math.abs(o({x:(m+f)/2,y:(d+u)/2})-(p+l)/2);b>c&&(c=b)};return h((e.x+t.x)/2,(e.y+t.y)/2,(r+s)/2),h((t.x+n.x)/2,(t.y+n.y)/2,(s+i)/2),h((n.x+e.x)/2,(n.y+e.y)/2,(i+r)/2),c}function lt(e,t,n,o,r){if(r<=0)return Vs(e,t,n,o);let s={x:(e.x+t.x)/2,y:(e.y+t.y)/2},i={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(lt(e,s,a,o,r-1),lt(s,t,i,o,r-1),lt(a,i,n,o,r-1),lt(s,i,a,o,r-1))}function ut(e,t,n,o,r,s,i,a){if(i>0){let h={x:(t.x+n.x)/2,y:(t.y+n.y)/2},m={x:(n.x+o.x)/2,y:(n.y+o.y)/2},d={x:(o.x+t.x)/2,y:(o.y+t.y)/2};ut(e,t,h,d,r,s,i-1,a),ut(e,h,n,m,r,s,i-1,a),ut(e,d,m,o,r,s,i-1,a),ut(e,h,m,d,r,s,i-1,a);return}let f=[t.x*v,r(t),t.y*v],u=[n.x*v,r(n),n.y*v],l=[o.x*v,r(o),o.y*v];if(a){e.triN(f,u,l,a(t),a(n),a(o),s);return}let c=Hs(f,u,l);c[1]<0&&(c=[-c[0],-c[1],-c[2]]),e.tri(f,u,l,c,s)}var Ys=8;function lo(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(s,i,a,f,u)=>{if(u>0){let l={x:(s.x+i.x)/2,y:(s.y+i.y)/2},c=t(l);if(Math.abs(c-(a+f)/2)>n){r(s,l,a,c,u-1),r(l,i,c,f,u-1);return}}o.push(s)};for(let s=0;s<e.length;s++){let i=e[s],a=e[(s+1)%e.length];r(i,a,t(i),t(a),Ys)}return o}function Rt(e,t){if(e.length<3)return e;let n=[];for(let r of e){let s=n[n.length-1];s&&Math.hypot(r.x-s.x,r.y-s.y)<t||n.push(r)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let o=[];for(let r=0;r<n.length;r++){let s=o.length?o[o.length-1]:n[(r-1+n.length)%n.length],i=n[r],a=n[(r+1)%n.length],f=a.x-s.x,u=a.y-s.y,l=Math.hypot(f,u);l>t&&Math.abs((i.x-s.x)*u-(i.y-s.y)*f)/l<t||o.push(i)}return o.length>=3?o:n}var wt=.001*ge*.1;function W(e,t,n,o,r,s,i,a,f=1/0,u){if(!t||t.length<3||(f===void 0&&(f=1/0),Math.abs(de(t))<1e-4))return;let l=Rt(lo(Rt(Ce(t),wt),o,f),wt),c=n?.map(g=>Rt(lo(Rt(Ce(g),wt),o,f),wt)).filter(g=>g.length>=3&&Math.abs(de(g))>=1e-4),{pts:h,tris:m}=Xs(l,c),d=[s[0]*a.top,s[1]*a.top,s[2]*a.top],p=[s[0]*a.bottomCap,s[1]*a.bottomCap,s[2]*a.bottomCap],b=[i[0]*a.top,i[1]*a.top,i[2]*a.top],y=[i[0]*a.wallBottom,i[1]*a.wallBottom,i[2]*a.wallBottom],x=0;if(Number.isFinite(f))for(;x<Us;x++){let g=0;for(let R=0;R<m.length;R+=3){let P=lt(h[m[R]],h[m[R+1]],h[m[R+2]],o,x);P>g&&(g=P)}if(g<=f)break}for(let g=0;g<m.length;g+=3){let R=h[m[g]],P=h[m[g+1]],S=h[m[g+2]];ut(e,R,P,S,o,d,x,u);let E=[R.x*v,r,R.y*v],_=[P.x*v,r,P.y*v],O=[S.x*v,r,S.y*v];e.tri(E,O,_,[0,-1,0],p)}let M=g=>{if(x<=0)return g;let R=1<<x,P=[];for(let S=0;S<g.length;S++){let E=g[S],_=g[(S+1)%g.length];for(let O=0;O<R;O++){let k=O/R;P.push({x:E.x+(_.x-E.x)*k,y:E.y+(_.y-E.y)*k})}}return P},I=Wt(l),w=[{ring:M(l),flip:!1}];if(c)for(let g of c)g.length>=3&&w.push({ring:M(g),flip:!0});for(let{ring:g,flip:R}of w)for(let P=0;P<g.length;P++){let S=g[P],E=g[(P+1)%g.length],_=(E.x-S.x)*v,k=(E.y-S.y)*v,C=-_,A=Math.hypot(k,C)||1;k/=A,C/=A;let L=(S.x+E.x)/2-I.x,F=(S.y+E.y)/2-I.y,T=k*L+C*F;R&&(T=-T),T<0&&(k=-k,C=-C);let B=[k,0,C],N=[S.x*v,o(S),S.y*v],H=[E.x*v,o(E),E.y*v],D=[S.x*v,r,S.y*v],V=[E.x*v,r,E.y*v];e.tri(N,H,V,B,b,b,y),e.tri(N,V,D,B,b,y,y)}}function fo(e){let t=0;for(let f of e)t+=f.count;let n=new Float32Array(t*3),o=new Float32Array(t*3),r=new Float32Array(t*3),s=new Float32Array(t),i=new Float32Array(t),a=0;for(let f of e)n.set(f.position,a*3),o.set(f.normal,a*3),r.set(f.color,a*3),s.set(f.floor,a),i.set(f.material,a),a+=f.count;return{position:n,normal:o,color:r,floor:s,material:i,count:t}}function Ie(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=Ce(e),r=o.length,s=[];for(let a=0;a<r;a++){let f=o[a],u=o[(a+1)%r],l=u.x-f.x,c=u.y-f.y,h=Math.hypot(l,c)||1;s.push({x:c/h,y:-l/h})}let i=[];for(let a=0;a<r;a++){let f=o[a],u=s[(a-1+r)%r],l=s[a],c=u.x+l.x,h=u.y+l.y,m=Math.hypot(c,h),d=()=>{i.push([f.x+u.x*t,f.y+u.y*t]),i.push([f.x+l.x*t,f.y+l.y*t])};if(m<1e-9){d();continue}c/=m,h/=m;let p=c*u.x+h*u.y,b=1/Math.max(p,1e-6);if(!Number.isFinite(b)||b>n){d();continue}i.push([f.x+c*t*b,f.y+h*t*b])}if(i.length<3)return e;try{let a=an.default.union([[...i,i[0]]]),f=null,u=-1/0;for(let c of a){let h=Math.abs(de(c[0].map(([m,d])=>({x:m,y:d}))));h>u&&(u=h,f=c[0])}if(!f)return e;let l=f.map(([c,h])=>({x:c,y:h}));if(l.length>1){let c=l[0],h=l[l.length-1];Math.abs(c.x-h.x)<1e-9&&Math.abs(c.y-h.y)<1e-9&&l.pop()}return l.length>=3?l:e}catch{return e}}function Ye(e,t,n=2.5){if(e.length<3)return[];if(t<=0)return e;let o=Ce(e),r=o.length,s=[];for(let f=0;f<r;f++){let u=o[f],l=o[(f+1)%r],c=Math.hypot(l.x-u.x,l.y-u.y)||1;s.push({x:-(l.y-u.y)/c,y:(l.x-u.x)/c})}let i=[],a=[];for(let f=0;f<r;f++){let u=o[f],l=s[(f-1+r)%r],c=s[f],h=l.x+c.x,m=l.y+c.y,d=Math.hypot(h,m),p=d<1e-9?1/0:1/Math.max(h/d*l.x+m/d*l.y,1e-6);if(!Number.isFinite(p)||p>n){i.push({x:u.x+l.x*t,y:u.y+l.y*t},{x:u.x+c.x*t,y:u.y+c.y*t}),a.push(f,f);continue}h/=d,m/=d,i.push({x:u.x+h*t*p,y:u.y+m*t*p}),a.push(f)}for(let f=0;f<i.length;f++){let u=(f+1)%i.length,l=a[f],c=a[u];if(c!==(l+1)%r)continue;let h=o[l],m=o[c];if((i[u].x-i[f].x)*(m.x-h.x)+(i[u].y-i[f].y)*(m.y-h.y)<=0)return[]}try{let f=an.default.intersection([[...i.map(d=>[d.x,d.y]),[i[0].x,i[0].y]]],[[...o.map(d=>[d.x,d.y]),[o[0].x,o[0].y]]]),u=null,l=0;for(let d of f){let p=Math.abs(de(d[0].map(([b,y])=>({x:b,y}))));p>l&&(l=p,u=d[0])}if(!u)return[];let c=u.map(([d,p])=>({x:d,y:p})),h=c[0],m=c[c.length-1];return c.length>1&&Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&c.pop(),c.length>=3?Ce(c):[]}catch{return[]}}function Et(e,t,n,o,r=28){let s=[];for(let i=0;i<r;i++){let a=i/r*Math.PI*2;s.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return s}function ft(e,t,n,o){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+o},{x:e,y:t+o}]}var mt=3,Ke=.38,ht=.24;function Ks(e){if(e.length<3)return null;let t=e[0],n=e[Math.floor(e.length/2)],o=e[e.length-1],r=(n.x-t.x)*v,s=(n.y-t.y)*v,i=(o.x-t.x)*v,a=(o.y-t.y)*v,f=2*(r*a-s*i);if(Math.abs(f)<1e-7)return null;let u=r*r+s*s,l=i*i+a*a,c=(u*a-l*s)/f+t.x*v,h=(r*l-i*u)/f+t.y*v,m=Math.hypot(t.x*v-c,t.y*v-h);return m<1||m>200||!Number.isFinite(m)||e.some(d=>Math.abs(Math.hypot(d.x*v-c,d.y*v-h)-m)>.03)?null:{x:c,z:h,radius:m}}function mo(e){let t=[],n=new Map,o=(f,u)=>`${Math.floor(f/mt)},${Math.floor(u/mt)}`;for(let f of e)for(let u of f.rows){for(let c of u.pts){let h=c.x*v,m=c.y*v,d=o(h,m),p=n.get(d)??[];p.push({x:h,z:m,y:u.y,floor:f.floorIndex}),n.set(d,p)}if(u.patch||u.pts.length<2)continue;let l=Ks(u.pts);for(let c of[0,u.pts.length-1]){let h=u.pts[c],m=u.pts[c===0?1:c-1],d=h.x-m.x,p=h.y-m.y,b=Math.hypot(d,p);b<1e-6||t.push({sectionId:f.sectionId,floorIndex:f.floorIndex,curve:l,row:u,point:h,x:h.x*v,z:h.y*v,dx:d/b,dz:p/b})}}let r=new Map;t.forEach((f,u)=>{let l=o(f.x,f.z),c=r.get(l)??[];c.push(u),r.set(l,c)});let s=(f,u)=>{let l=Math.floor(f/mt),c=Math.floor(u/mt);return[-1,0,1].flatMap(h=>[-1,0,1].map(m=>`${l+h},${c+m}`))},i=new Map;t.forEach((f,u)=>{let l=-1,c=1/0,h=!1;for(let m of s(f.x,f.z))for(let d of r.get(m)??[]){let p=t[d];if(f.sectionId===p.sectionId&&f.row.blockId===p.row.blockId||f.floorIndex!==p.floorIndex||Math.abs(f.row.y-p.row.y)>.05)continue;let b=p.x-f.x,y=p.z-f.z,x=Math.hypot(b,y);if(x<Ke*2+.45||x>mt)continue;let M=f.curve&&p.curve&&Math.hypot(f.curve.x-p.curve.x,f.curve.z-p.curve.z)<=.05&&Math.abs(f.curve.radius-p.curve.radius)<=.05,I=Math.min((b*f.dx+y*f.dz)/x,(-b*p.dx-y*p.dz)/x);(M?I<.8:I<.98)||!M&&(Math.abs(b*f.dz-y*f.dx)>.15||Math.abs(b*p.dz-y*p.dx)>.15)||(x<c-.02?(l=d,c=x,h=!1):Math.abs(x-c)<=.02&&(h=!0))}l>=0&&!h&&i.set(u,l)});let a=[];for(let[f,u]of i){if(f>=u||i.get(u)!==f)continue;let l=t[f],c=t[u],h=Math.hypot(c.x-l.x,c.z-l.z),m=(c.x-l.x)/h,d=(c.z-l.z)/h,p=!1;for(let y of s((l.x+c.x)/2,(l.z+c.z)/2))for(let x of n.get(y)??[]){if(x.floor!==l.floorIndex||Math.abs(x.y-l.row.y)>.75)continue;let M=(x.x-l.x)*m+(x.z-l.z)*d,I=Math.abs((x.x-l.x)*d-(x.z-l.z)*m);M>.01&&M<h-.01&&I<ht+Ke&&(p=!0)}if(p)continue;let b=(y,x)=>({x:(l.x+m*y-d*x)/v,y:(l.z+d*y+m*x)/v});a.push({sections:[l.sectionId,c.sectionId],blocks:[l.row.blockId,c.row.blockId],floorIndex:l.floorIndex,ends:[l.point,c.point],clearWidthM:h-2*Ke,heightM:(l.row.y+c.row.y)/2,outline:[b(Ke,-ht),b(h-Ke,-ht),b(h-Ke,ht),b(Ke,ht)]})}return a}var zs=/^#?([\da-f]{3}|[\da-f]{6})$/i;function ho(e){let t=e.replace("#","");return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}function Ws(e){let t=zs.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function oe(e){let t=Ws(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function Zs(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function re(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function Ae(e,t){let n=Zs(e);return re(e,[n,n,n],t)}function po({r:e,g:t,b:n}){let o=e/255,r=t/255,s=n/255,i=Math.max(o,r,s),a=Math.min(o,r,s),f=(i+a)/2;if(i===a)return{h:0,s:0,l:f};let u=i-a,l=f>.5?u/(2-i-a):u/(i+a),c;return i===o?c=((r-s)/u+(r<s?6:0))/6:i===r?c=((s-o)/u+2)/6:c=((o-r)/u+4)/6,{h:c,s:l,l:f}}var Ct=["available","held","sold","selected","dimmed"];function bo(e){let t=Ct.indexOf(e);return t<0?0:t}var yo={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var cn={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]},ln={top:[.05,.06,.08],bottom:[.1,.12,.15]};function z(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var $s=.15,Qs=1.6;function xo(e){return Fn(e??1,$s,Qs)}var qs=.15,Js=.9,ea=1.76;function ta(){return{background:{top:[...ln.top],bottom:[...ln.bottom]},structure:cn,seatStates:{...yo},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function na(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{deck:"#a8ada9",fascia:"#69777c",shell:"#8d9ca0",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function go(e){let t=ta();e??={};let n=oe(e.background);if(n){t.background={top:z(n,Js),bottom:z(n,ea)};let a={};for(let[u,l]of Object.entries(cn))a[u]=re(l,n,qs);n[0]*.2126+n[1]*.7152+n[2]*.0722>.55&&(a.ground=z(n,.86)),t.structure=a}let o=oe(e.selectionColor)??oe(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=xo(r));let s=Object.fromEntries(Object.entries(e.venue3d??{}).filter(([,a])=>a!=null)),i={...na(n),...s};if(i){let a=oe(i.deck),f=oe(i.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),f&&(t.structure={...t.structure,tierWall:f,gaWall:f}),t.materials.seat=oe(i.seat),t.materials.shell=oe(i.shell),typeof i.roughness=="number"&&Number.isFinite(i.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,i.roughness)))}return t}function Mo(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}var oa=[{key:"wheelchair",label:"Wheelchair space",short:"Wheelchair",icon:"\u267F"},{key:"companion",label:"Companion seat",short:"Companion",icon:"\u{1F9D1}\u200D\u{1F91D}\u200D\u{1F9D1}"},{key:"semi-ambulatory",label:"Semi-ambulatory (limited mobility)",short:"Limited mobility",icon:"\u{1F9AF}"},{key:"designated-aisle",label:"Designated aisle / transfer seat",short:"Aisle transfer",icon:"AS"},{key:"step-free",label:"Step-free accessible seat",short:"Step-free",icon:"SF"},{key:"hearing",label:"Assistive listening",short:"Hearing",icon:"\u{1F9BB}"},{key:"cart",label:"CART live-caption view",short:"CART captions",icon:"CC"},{key:"sign-language",label:"Sign-language view",short:"Sign language",icon:"\u{1F91F}"},{key:"low-vision",label:"Blind / low-vision viewing",short:"Low vision",icon:"LV"},{key:"sensory-friendly",label:"Quiet / sensory-friendly seating",short:"Sensory-friendly",icon:"QS"},{key:"plus-size",label:"Plus-size seat",short:"Plus-size",icon:"\u{1F4BA}"},{key:"lift-armrest",label:"Lift-up armrest",short:"Lift armrest",icon:"\u2195\uFE0F"}],Zu=new Map(oa.map(e=>[e.key,e]));var ra={wheelchair:"#3b82f6",companion:"#8b5cf6","semi-ambulatory":"#0ea5e9","designated-aisle":"#0284c7","step-free":"#16a34a",hearing:"#14b8a6",cart:"#7c3aed","sign-language":"#f59e0b","low-vision":"#d97706","sensory-friendly":"#6366f1","plus-size":"#ec4899","lift-armrest":"#22c55e"};function So(e){let t=e?.[0];return t&&ra[t]||"#3b82f6"}var ia=[{key:"obstructedView",label:"Obstructed view",short:"Obstructed",icon:"\u26D4"},{key:"restrictedView",label:"Restricted view",short:"Restricted",icon:"\u{1F441}"},{key:"premium",label:"Premium seat",short:"Premium",icon:"\u2605"}],$u=new Map(ia.map(e=>[e.key,e]));var sa=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Qu=new Set(sa);var Po=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds:null,mark:null},{key:"theatre",label:"Theatre chair",shortLabel:"Theatre",useCase:"Auditoriums, arenas and stadium stands",group:"fixed",path:"M4.5 3.5 Q4.5 1.5 6.5 1.5 L17.5 1.5 Q19.5 1.5 19.5 3.5 L19.5 13 L4.5 13 Z M3.5 12 L20.5 12 Q22.5 12 22.5 14 L22.5 21 Q22.5 22.5 21 22.5 Q19.5 22.5 19.5 21 L19.5 17.5 L4.5 17.5 L4.5 21 Q4.5 22.5 3 22.5 Q1.5 22.5 1.5 21 L1.5 14 Q1.5 12 3.5 12 Z",bounds:{x:1.5,y:1.5,width:21,height:21},mark:{x:12,y:10,radius:6}},{key:"dining",label:"Dining chair",shortLabel:"Dining",useCase:"Banquets, restaurants and table seating",group:"flexible",path:"M7 1 Q6 1 6 2.5 L6.75 10.5 L5 10.5 Q4 10.5 4 12 L4 14 Q4 15 5.25 15 L6 15 L4 23 L7 23 L9.5 15 L14.5 15 L17 23 L20 23 L18 15 L18.75 15 Q20 15 20 14 L20 12 Q20 10.5 19 10.5 L17.25 10.5 L18 2.5 Q18 1 17 1 Z",bounds:{x:4,y:1,width:16,height:22},mark:{x:12,y:10,radius:4.5}},{key:"folding",label:"Folding chair",shortLabel:"Folding",useCase:"Concert floors, ceremonies and conferences",group:"flexible",path:"M6 2 Q5 2 5 3 L6 8 L18 8 L19 3 Q19 2 18 2 Z M5 9 L19 9 Q20 9 20 10.5 L19 13 L5 13 L4 10.5 Q4 9 5 9 Z M6 12 L9 12 L12 17 L15 12 L18 12 L14 19 L17 23 L14 23 L12 21 L10 23 L7 23 L10 19 Z",bounds:{x:4,y:2,width:16,height:21},mark:{x:12,y:5,radius:3}},{key:"armchair",label:"Premium armchair",shortLabel:"Armchair",useCase:"Boxes, lounges and club seating",group:"premium",path:"M3.5 4 Q3.5 1.5 6 1.5 L18 1.5 Q20.5 1.5 20.5 4 L20.5 13 L3.5 13 Z M1.5 12.5 Q1.5 10 3.25 10 Q5 10 5 12.5 L5 13.5 L19 13.5 L19 12.5 Q19 10 20.75 10 Q22.5 10 22.5 12.5 L22.5 19.5 Q22.5 22 20 22 L4 22 Q1.5 22 1.5 19.5 Z",bounds:{x:1.5,y:1.5,width:21,height:20.5},mark:{x:12,y:7.5,radius:5.5}},{key:"recliner",label:"Recliner",shortLabel:"Recliner",useCase:"Luxury cinemas and premium clubs",group:"premium",path:"M7 2 Q7 1 8.5 1 L15.5 1 Q17 1 17 2 L19 13 L5 13 Z M4 9 Q2 9 2 11.5 L2 16 Q2 18 4 18 L6 18 L6 15 L18 15 L18 18 L20 18 Q22 18 22 16 L22 11.5 Q22 9 20 9 Q18 9 18 11 L18 13 L6 13 L6 11 Q6 9 4 9 Z M7 17 L17 17 Q18 17 18.5 18.5 L19.5 22.5 L4.5 22.5 L5.5 18.5 Q6 17 7 17 Z",bounds:{x:2,y:1,width:20,height:21.5},mark:{x:12,y:8,radius:5}},{key:"stool",label:"Stool",shortLabel:"Stool",useCase:"Bars, high-tops and seating rails",group:"flexible",path:"M6 2.5 L18 2.5 Q22 2.5 22 6.5 L22 12 Q22 16 18 16 L6 16 Q2 16 2 12 L2 6.5 Q2 2.5 6 2.5 Z M6 15.5 L9.5 15.5 L7.5 22.5 L3 22.5 Z M14.5 15.5 L18 15.5 L20.5 22.5 L16 22.5 Z",bounds:{x:2,y:2.5,width:20,height:20},mark:{x:12,y:9.25,radius:6.5}},{key:"bench",label:"Bench place",shortLabel:"Bench",useCase:"Pews, bleachers and terraces",group:"fixed",path:"M2.5 0.5 L21.5 0.5 Q23 0.5 23 2 L23 5 Q23 6.5 21.5 6.5 L2.5 6.5 Q1 6.5 1 5 L1 2 Q1 0.5 2.5 0.5 Z M2 7.5 L22 7.5 Q23.5 7.5 23.5 9 L23.5 15.5 Q23.5 17 22 17 L18 17 L18 21.5 Q18 22.5 16.75 22.5 Q15.5 22.5 15.5 21.5 L15.5 17 L8.5 17 L8.5 21.5 Q8.5 22.5 7.25 22.5 Q6 22.5 6 21.5 L6 17 L2 17 Q0.5 17 0.5 15.5 L0.5 9 Q0.5 7.5 2 7.5 Z",bounds:{x:.5,y:.5,width:23,height:22},mark:{x:12,y:12.25,radius:4.75}}],Ro=Po.map(e=>e.key),aa=new Map(Po.map(e=>[e.key,e]));function Io(e){return typeof e=="string"&&aa.has(e)}function wo(e,t){return Io(e)?e:Io(t?.seatGlyph)?t.seatGlyph:"circle"}var ue={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},ca=.44,la=.15,ua=.3,fa=.24;function vo(e){return e===void 0||!Number.isFinite(e)||e<=0?fa:Math.min(ua,Math.max(la,e*ca))}var ma=.05,Eo=.45,ha=Eo+ma,da=.92;var nf=[{part:ue.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ue.pad,min:[-1,.36,-.95],max:[1,Eo,1]},{part:ue.back,min:[-1,ha,-1],max:[1,da,-.72]},{part:ue.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ue.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ue.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ue.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ue.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ue.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ue.leg,min:[.62,0,.48],max:[.82,.37,.7]}],of=[{part:ue.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ue.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ue.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ue.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ue.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function Co(e,t,n,o){let r=new Float32Array(t),s=u=>e[u*3],i=u=>e[u*3+2],a=0,f=(u,l)=>{let c=l-u;for(let h=u;h<l;h++){let[m,d]=o(h),p=m-s(h),b=d-i(h);if(c>=2){let y=Math.max(u,h-1),x=Math.min(l-1,h+1),M=s(x)-s(y),I=i(x)-i(y),w=Math.hypot(M,I);if(w>1e-6){let g=-I/w,R=M/w;g*p+R*b<0&&(g=-g,R=-R),p=g,b=R}}r[h]=p===0&&b===0?0:Math.atan2(p,b)}};for(let u=1;u<=t;u++)(u===t||n(u)!==n(a))&&(f(a,u),a=u);return r}var At=.22;var pa=.42;function ba(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let o=1/0,r=1/0,s=-1/0,i=-1/0;for(let d of e)d.x<o&&(o=d.x),d.y<r&&(r=d.y),d.x>s&&(s=d.x),d.y>i&&(i=d.y);let a=Math.max(s-o,1e-6),f=Math.max(i-r,1e-6),u=Math.max(Math.sqrt(a*f/t),1e-6),l=Math.max(1,Math.ceil(a/u)+1),c=Math.max(1,Math.ceil(f/u)+1),h=new Map,m=(d,p)=>{let b=Math.min(l-1,Math.max(0,Math.floor((d-o)/u)));return Math.min(c-1,Math.max(0,Math.floor((p-r)/u)))*l+b};for(let d=0;d<t;d++){let p=m(e[d].x,e[d].y),b=h.get(p);b?b.push(d):h.set(p,[d])}for(let d=0;d<t;d++){let p=e[d],b=Math.min(l-1,Math.max(0,Math.floor((p.x-o)/u))),y=Math.min(c-1,Math.max(0,Math.floor((p.y-r)/u))),x=1/0;for(let M=1;M<=4;M++){for(let I=y-M;I<=y+M;I++)if(!(I<0||I>=c))for(let w=b-M;w<=b+M;w++){if(w<0||w>=l||M>1&&Math.abs(I-y)<M&&Math.abs(w-b)<M)continue;let g=h.get(I*l+w);if(g)for(let R of g){if(R===d)continue;let P=Math.hypot(e[R].x-p.x,e[R].y-p.y);P<x&&(x=P)}}if(Number.isFinite(x)&&x<=M*u)break}n[d]=x}return n}function ya(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-Ee):0}function Ao(e,t,n,o,r,s){let i=e.length,a=new Float32Array(i*3),f=new Float32Array(i),u=new Float32Array(i*3),l=new Float32Array(i),c=new Float32Array(i),h=new Float32Array(i),m=new Float32Array(i),d=new Float32Array(i*3),p=new Map,b=ba(e);for(let y=0;y<i;y++){let x=e[y],I=(n?.seatPitchU(y)??b[y])*v;l[y]=Number.isFinite(I)?Math.max(.06,Math.min(At,I*pa)):At,c[y]=vo(Number.isFinite(I)?I:void 0);let w=wo(x.glyph,{seatGlyph:s?.get(x.categoryKey)});h[y]=Ro.indexOf(w),m[y]=x.wheelchairSpaceType==="no-seat"?0:1,a[y*3]=x.x*v,a[y*3+1]=n?n.seatDeckY(y):ya(x),a[y*3+2]=x.y*v,f[y]=bo(t?t(x):"available");let g=oe(r?.get(x.categoryKey)??"#6e7bff")??[.43,.48,1];if(u[y*3]=g[0],u[y*3+1]=g[1],u[y*3+2]=g[2],x.accessibility?.length){let R=oe(So(x.accessibility));R&&(d[y*3]=R[0],d[y*3+1]=R[1],d[y*3+2]=R[2])}p.set(x.id,y)}return{count:i,iPosition:a,iState:f,iCategory:u,iMaxRadius:l,iRing:d,idToIndex:p,iChairWidth:c,iGlyph:h,iPhysicalSeat:m,iFloor:o??new Float32Array(i),iSection:new Float32Array(i).fill(-1),iYaw:new Float32Array(i)}}function xa(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let o=t-e.x,r=n-e.y,s=Math.hypot(o,r);return s<1e-9?[0,0]:[o/s,r/s]}}}function ga(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let m of e)n+=m.x,o+=m.y,r+=Math.hypot(m.x-t.x,m.y-t.y);let s=e.length;n/=s,o/=s,r/=s;let i=e[0],a=-1;for(let m of e){let d=Math.hypot(m.x-n,m.y-o);d>a&&(a=d,i=m)}let f=i.x-n,u=i.y-o,l=Math.hypot(f,u);l>1e-9?(f/=l,u/=l):(f=1,u=0);let c=[...e].sort((m,d)=>(m.x-n)*f+(m.y-o)*u-((d.x-n)*f+(d.y-o)*u)),h=0;for(let m of c){let d=Math.hypot(m.x-n,m.y-o);d>h&&(h=d)}return{pts:c,cx:n,cy:o,radius:h,depth:r}}function _o(e,t,n){let o=e.pts;if(o.length===1)return Math.hypot(t-o[0].x,n-o[0].y);let r=1/0;for(let s=0;s+1<o.length;s++){let i=o[s],a=o[s+1],f=a.x-i.x,u=a.y-i.y,l=f*f+u*u,c=l>1e-12?((t-i.x)*f+(n-i.y)*u)/l:0;c<0?c=0:c>1&&(c=1);let h=Math.hypot(t-(i.x+c*f),n-(i.y+c*u));h<r&&(r=h)}return r}var _t=8;function Ma(e,t,n){let o=new Array(_t).fill(1/0),r=new Array(_t).fill(-1);for(let l=0;l<e.length;l++){let c=e[l],h=Math.hypot(t-c.cx,n-c.cy)-c.radius;for(let m=0;m<_t;m++)if(h<o[m]){for(let d=_t-1;d>m;d--)o[d]=o[d-1],r[d]=r[d-1];o[m]=h,r[m]=l;break}}let s=new Array(3).fill(1/0),i=new Array(3).fill(-1);for(let l of r){if(l<0)continue;let c=_o(e[l],t,n);for(let h=0;h<3;h++)if(c<s[h]){for(let m=2;m>h;m--)s[m]=s[m-1],i[m]=i[m-1];s[h]=c,i[h]=l;break}}if(i[0]<0)return 0;if(s[0]<1e-6)return e[i[0]].depth;let a=s[0]*2.2,f=0,u=0;for(let l=0;l<3;l++){let c=i[l];if(c<0||s[l]>a)continue;let h=1/(s[l]*s[l]);f+=h*e[c].depth,u+=h}return u>0?f/u:e[i[0]].depth}function Sa(e){let t=(o,r)=>Ma(e,o,r),n=(o,r)=>{let s=1/0,i=-1;for(let a=0;a<e.length;a++){let f=e[a];if(Math.hypot(o-f.cx,r-f.cy)-f.radius>=s)continue;let u=_o(f,o,r);u<s&&(s=u,i=a)}return i};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(o,r)=>{let s=(t(o+.5,r)-t(o-.5,r))/1,i=(t(o,r+.5)-t(o,r-.5))/(2*.5),a=Math.hypot(s,i);return a<1e-9?[0,0]:[s/a,i/a]}}}function ko(e,t){let n=[];for(let o of e){let r=ga(o.points,t);r&&n.push(r)}return n.length<2?xa(t):(n.sort((o,r)=>o.depth-r.depth),Sa(n))}var mn=Fe(require("polygon-clipping"),1);var Bo=Fe(require("earcut"),1);var Ia=.58,To=.01,Me=At*1.5*ge,Pa=.5,Ra=.6;function wa(e,t){let n=e.length,o=[];for(let i=0;i<n;i++){let a=e[Math.max(0,i-1)],f=e[Math.min(n-1,i+1)],u=f.x-a.x,l=f.y-a.y,c=Math.hypot(u,l);if(c<1e-9){o.push([0,0]);continue}u/=c,l/=c,o.push([-l,u])}let r=0;for(let i=0;i<n;i++)r+=(e[i].x-t.x)*o[i][0]+(e[i].y-t.y)*o[i][1];return r<0?o.map(([i,a])=>[-i,-a]):o}function va(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(i,a)=>{let f=a.x-i.x,u=a.y-i.y,l=Math.hypot(f,u)||1;return{x:f/l,y:u/l}},r=o(n[1],n[0]),s=o(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+r.x*t,y:n[0].y+r.y*t}),n.push({x:n[n.length-1].x+s.x*t,y:n[n.length-1].y+s.y*t}),n}var Lo=Math.PI/12;function Ea(e){if(e.length<3)return[...e];let t=[...e].sort((s,i)=>s.x-i.x||s.y-i.y),n=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),o=s=>{let i=[];for(let a of s){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),i},r=[...o(t),...o([...t].reverse())];return r.length>=3?r:[...e]}function Fo(e,t){if(!e.length||!(t>0))return[];let n=Ea(e),o=(a,f,u,l)=>{let c=u-f;for(;c<0;)c+=Math.PI*2;for(;c>Math.PI*2;)c-=Math.PI*2;let h=Math.max(1,Math.ceil(c/Lo)),m=t/Math.cos(c/h/2);for(let d=0;d<=h;d++){let p=f+c*d/h;l.push({x:a.x+Math.cos(p)*m,y:a.y+Math.sin(p)*m})}};if(n.length<3){let a=0,f=0;for(let m of n)a+=m.x,f+=m.y;a/=n.length||1,f/=n.length||1;let u=0;for(let m of n)u=Math.max(u,Math.hypot(m.x-a,m.y-f));let l=[],c=Math.max(3,Math.ceil(Math.PI*2/Lo)),h=(u+t)/Math.cos(Math.PI/c);for(let m=0;m<c;m++){let d=m/c*Math.PI*2;l.push({x:a+Math.cos(d)*h,y:f+Math.sin(d)*h})}return l}let r=n.length,s=[];for(let a=0;a<r;a++){let f=n[a],u=n[(a+1)%r];s.push(Math.atan2(-(u.x-f.x),u.y-f.y))}let i=[];for(let a=0;a<r;a++)o(n[a],s[(a+r-1)%r],s[a],i);return Ho(i)}function Ca(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let s=e[r],i=e[r+1],a=i.x-s.x,f=i.y-s.y,u=a*a+f*f,l=u>1e-12?((t-s.x)*a+(n-s.y)*f)/u:0;l<0?l=0:l>1&&(l=1);let c=Math.hypot(t-(s.x+l*a),n-(s.y+l*f));c<o&&(o=c)}return o}function kt(e){let t=e.map(r=>{let s=0,i=0;for(let u of r.pts)s+=u.x,i+=u.y;let a=r.pts.length||1;s/=a,i/=a;let f=0;for(let u of r.pts){let l=Math.hypot(u.x-s,u.y-i);l>f&&(f=l)}return{cx:s,cy:i,rad:f}}),n=r=>{let s=r.length;return s<=2?[...r]:[r[Math.floor(s*.25)],r[Math.floor(s*.5)],r[Math.floor(s*.75)]]},o=[];for(let r=0;r<e.length;r++){let s=n(e[r].pts),i=[],a=1/0,f=null;for(let l of s){let c=1/0;for(let h=0;h<e.length;h++){if(h===r||Math.abs(e[h].y-e[r].y)<.001)continue;let m=t[h],d=Math.hypot(l.x-m.cx,l.y-m.cy)-m.rad;if(d>=c&&d>=a)continue;let p=Ca(e[h].pts,l.x,l.y);p<c&&(c=p),e[h].depth<e[r].depth&&p<a&&(a=p,f=e[h].y)}Number.isFinite(c)&&c>0&&i.push(c)}i.sort((l,c)=>l-c);let u=i.length?i[Math.floor(i.length/2)]:1;o.push({pitch:u,belowY:f})}return o}function Do(e,t,n,o){let r=e[t],s=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let l=r.pts[0],c=l.x-o.x,h=l.y-o.y,m=Math.hypot(c,h)||1;c/=m,h/=m;let d=Math.max(n[t].pitch,.001)*.5;return[{x:l.x+h*d,y:l.y-c*d},{x:l.x-h*d,y:l.y+c*d}]})():[];if(s.length<2)return null;let i=0,a=0;for(let l=1;l<s.length;l++){let c=Math.hypot(s[l].x-s[l-1].x,s[l].y-s[l-1].y);c>1e-6&&(i+=c,a++)}let f=a>0?i/a:0,u=va(s,Math.max(f*Ra,Me));return{pts:u,nrm:wa(u,o),front:Math.max(n[t].pitch*Ia,Me),back:Math.max(n[t].pitch*Pa,Me)}}var Qe=1.5,No=.3;function un(e,t){if(e.length<3)return e;let n=e[0],o=e[e.length-1],r=o.x-n.x,s=o.y-n.y,i=Math.hypot(r,s),a=-1,f=-1;for(let c=1;c<e.length-1;c++){let h=e[c],m=i>1e-12?Math.abs((h.x-n.x)*s-(h.y-n.y)*r)/i:Math.hypot(h.x-n.x,h.y-n.y);m>a&&(a=m,f=c)}if(a<=t||f<0)return[n,o];let u=un(e.slice(0,f+1),t),l=un(e.slice(f),t);return[...u.slice(0,-1),...l]}function Go(e,t){if(e.length<4)return e;let n=un([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function Aa(e){let t=e.map((o,r)=>{let s=e[(r+1)%e.length];return{a:o,b:s,i:r,minX:Math.min(o.x,s.x),maxX:Math.max(o.x,s.x),minY:Math.min(o.y,s.y),maxY:Math.max(o.y,s.y)}}).sort((o,r)=>o.minX-r.minX),n=(o,r,s)=>(r.x-o.x)*(s.y-o.y)-(r.y-o.y)*(s.x-o.x);for(let o=0;o<t.length;o++){let r=t[o];for(let s=o+1;s<t.length&&t[s].minX<=r.maxX;s++){let i=t[s];if(!(Math.abs(r.i-i.i)===1||Math.abs(r.i-i.i)===e.length-1||r.maxY<i.minY||i.maxY<r.minY)&&n(r.a,r.b,i.a)*n(r.a,r.b,i.b)<=0&&n(i.a,i.b,r.a)*n(i.a,i.b,r.b)<=0)return!0}}return!1}function jo(e,t,n){if(e.length<2)return[];let o=n??kt(e),r=new Map;for(let i=0;i<e.length;i++){let a=r.get(e[i].blockId);a?a.push(i):r.set(e[i].blockId,[i])}let s=[];for(let[,i]of r){let a=[];for(let x of i){let M=e[x].patch;M&&M.length>=3?s.push({outline:[...M],holes:[],topY:e[x].y}):a.push(x)}if(!a.length)continue;a.sort((x,M)=>e[x].depth-e[M].depth);let u=a.map(x=>Do(e,x,o,t)).filter(x=>x!==null);if(!u.length)continue;let l=(x,M)=>({x:x.pts[M].x-x.nrm[M][0]*(x.front+Qe),y:x.pts[M].y-x.nrm[M][1]*(x.front+Qe)}),c=(x,M)=>({x:x.pts[M].x+x.nrm[M][0]*(x.back+Qe),y:x.pts[M].y+x.nrm[M][1]*(x.back+Qe)}),h=u[0],m=u[u.length-1],d=[];for(let x=0;x<h.pts.length;x++)d.push(l(h,x));for(let x of u)d.push(c(x,x.pts.length-1));for(let x=m.pts.length-1;x>=0;x--)d.push(c(m,x));for(let x=u.length-1;x>=0;x--)d.push(l(u[x],0));let p=Ho(d),b=1/0;for(let x of a)e[x].y<b&&(b=e[x].y);if(!Number.isFinite(b))continue;if(p.length>=3&&Math.abs(de(p))>1e-6&&u.every(x=>{let M=x.pts[Math.floor(x.pts.length/2)];return pe(p,M.x,M.y)})&&!Aa(p)){s.push({outline:Go(p,No),holes:[],topY:b});continue}for(let x of _a(u))s.push({outline:x,holes:[],topY:b})}return s}function _a(e){let t=[];for(let n of e){let o=[],r=[],s=n.front+Qe,i=n.back+Qe;for(let f=0;f<n.pts.length;f++){let u=n.pts[f],l=n.nrm[f];o.push([u.x-l[0]*s,u.y-l[1]*s]),r.push([u.x+l[0]*i,u.y+l[1]*i])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=mn.default.union(t[0],...t.slice(1)),o=[];for(let r of n){if(!r.length||r[0].length<4)continue;let s=r[0].map(([f,u])=>({x:f,y:u})),i=s[0],a=s[s.length-1];s.length>1&&Math.abs(i.x-a.x)<1e-9&&Math.abs(i.y-a.y)<1e-9&&s.pop(),s.length>=3&&o.push(Go(s,No))}return o}catch{return[]}}function Ho(e){let t=[];for(let n of e){let o=t[t.length-1];o&&Math.hypot(n.x-o.x,n.y-o.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var fn=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let o of n)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let o=!0;for(let r of t)if(!pe(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function Oo(e,t,n,o,r,s){if(o.length<3)return;if(n.containsAll(o)){let u=[0,1,0],l=o[0];for(let c=1;c+1<o.length;c++){let h=o[c],m=o[c+1];e.tri([l.x*v,r,l.y*v],[h.x*v,r,h.y*v],[m.x*v,r,m.y*v],u,s)}return}let i=o.map(u=>[u.x,u.y]);i.push(i[0]);let a;try{a=mn.default.intersection([i],t)}catch{return}let f=[0,1,0];for(let u of a){if(!u.length||u[0].length<4)continue;let l=u[0],c=[],h=[];for(let d=0;d<l.length-1;d++)c.push(l[d][0],l[d][1]),h.push([l[d][0],l[d][1]]);if(h.length<3)continue;let m=(0,Bo.default)(c,void 0,2);for(let d=0;d<m.length;d+=3){let p=h[m[d]],b=h[m[d+1]],y=h[m[d+2]];e.tri([p[0]*v,r,p[1]*v],[b[0]*v,r,b[1]*v],[y[0]*v,r,y[1]*v],f,s)}}}function Xo(e,t,n,o,r,s,i){if(t.length<2)return;let a=i??kt(t),f=[0,1,0],u=s&&s.length>=3?[[...s.map(m=>[m.x,m.y]),[s[0].x,s[0].y]]]:null,l=s&&s.length>=3?new fn([[...s]]):null,c=m=>{e.setMaterial(2),m(),e.setMaterial(0)},h=m=>{e.setMaterial(3),m(),e.setMaterial(0)};for(let m=0;m<t.length;m++){let d=t[m];if(d.patch&&d.patch.length>=3){let w=[...d.patch],g=a[m].belowY??o;if(h(()=>{if(u&&l)Oo(e,u,l,w,d.y,r.tread);else{let R=w[0];for(let P=1;P+1<w.length;P++){let S=w[P],E=w[P+1];e.tri([R.x*v,d.y,R.y*v],[S.x*v,d.y,S.y*v],[E.x*v,d.y,E.y*v],f,r.tread)}}}),d.y>g+To){let R=0,P=0;for(let S of w)R+=S.x,P+=S.y;R/=w.length,P/=w.length,c(()=>{for(let S=0;S<w.length;S++){let E=w[S],_=w[(S+1)%w.length],O=_.x-E.x,k=_.y-E.y,C=Math.hypot(O,k);if(C<1e-6)continue;let A=k/C,L=-O/C;(E.x-R)*A+(E.y-P)*L<0&&(A=-A,L=-L);let F=[A,0,L],T=[E.x*v,d.y,E.y*v],B=[_.x*v,d.y,_.y*v],N=[E.x*v,g,E.y*v],H=[_.x*v,g,_.y*v];e.tri(T,B,H,F,r.riser),e.tri(T,H,N,F,r.riser)}})}continue}let p=Do(t,m,a,n);if(!p)continue;let{pts:b,nrm:y,front:x,back:M}=p,I=a[m].belowY??o;for(let w=0;w+1<b.length;w++){let g=b[w],R=b[w+1],P=y[w],S=y[w+1];if(Math.hypot(R.x-g.x,R.y-g.y)<1e-6||P[0]===0&&P[1]===0||S[0]===0&&S[1]===0)continue;let E=[(g.x-P[0]*x)*v,d.y,(g.y-P[1]*x)*v],_=[(R.x-S[0]*x)*v,d.y,(R.y-S[1]*x)*v],O=[(g.x+P[0]*M)*v,d.y,(g.y+P[1]*M)*v],k=[(R.x+S[0]*M)*v,d.y,(R.y+S[1]*M)*v];if(h(()=>{u&&l?Oo(e,u,l,[{x:g.x-P[0]*x,y:g.y-P[1]*x},{x:R.x-S[0]*x,y:R.y-S[1]*x},{x:R.x+S[0]*M,y:R.y+S[1]*M},{x:g.x+P[0]*M,y:g.y+P[1]*M}],d.y,r.tread):(e.tri(E,_,k,f,r.tread),e.tri(E,k,O,f,r.tread))}),d.y>I+To){let C=[E[0],I,E[2]],A=[_[0],I,_[2]],L=[-P[0],0,-P[1]];c(()=>{e.tri(E,_,A,L,r.riser),e.tri(E,A,C,L,r.riser)})}}}}function Uo(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,s=!1;for(let i of e)!Number.isFinite(i.x)||!Number.isFinite(i.y)||(s=!0,i.x<t&&(t=i.x),i.y<n&&(n=i.y),i.x>o&&(o=i.x),i.y>r&&(r=i.y));return s?{minX:t,minY:n,maxX:o,maxY:r}:null}function qe(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var hn=Fe(require("polygon-clipping"),1);function ka(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function Vo(e,t){return e.filter(n=>n.type!=="shape"||ka(n,t))}function Yo(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:Vo(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:Vo(e.objects,t),focal:n,baseHeightM:0,index:0}]}var Ta={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Le(e){return Uo(e)??Ta}function Ko(e,t){let n=Ie(e.outline,Me),o=Le(n),r=t.filter(i=>i!==e&&i.outline&&i.outline.length>=3&&qe(o,Le(i.outline)));if(!r.length)return[n];let s=i=>{let a=i.map(f=>[f.x,f.y]);return a.push(a[0]),a};try{let i=hn.default.difference([s(n)],...r.map(f=>[s(f.outline)])),a=[];for(let f of i){if(!f.length)continue;let u=f[0].map(([l,c])=>({x:l,y:c}));if(u.length>1){let l=u[0],c=u[u.length-1];Math.abs(l.x-c.x)<1e-9&&Math.abs(l.y-c.y)<1e-9&&u.pop()}u.length>=3&&a.push(u)}return a.length?a:[n]}catch{return[n]}}function zo(e,t){if(!t.length)return e;let n=s=>{let i=s.map(a=>[a.x,a.y]);return i.push(i[0]),i},o=t.map(s=>[n(s)]),r=[];for(let s of e){let i;try{i=hn.default.intersection([n(s.outline)],o.flat())}catch{r.push(s);continue}for(let a of i){if(!a.length)continue;let f=a[0].map(([u,l])=>({x:u,y:l}));if(f.length>1){let u=f[0],l=f[f.length-1];Math.abs(u.x-l.x)<1e-9&&Math.abs(u.y-l.y)<1e-9&&f.pop()}f.length>=3&&r.push({outline:f,holes:[],topY:s.topY})}}return r.length?r:e}var Ge=.06,La=.05,Zo=.05,Wo=.15,dn=25;function $o(e,t,n){let o=new Map,r=new Array(t.length).fill(null),s=new Float64Array(t.length),i=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),f=new Map,u=[],l=new Set;for(let h=0;h<e.length;h+=1){let m=e[h];for(let d of m.objects){if(d.type==="table"&&l.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let p=Ie(d.outline,Me);f.set(d.id,{section:d,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),u.push({id:d.id,floorIndex:h,box:Le(p),section:d,unit:m,outline:p})}}let c=new Map;for(let h of u){let m=c.get(h.floorIndex);m?m.push(h):c.set(h.floorIndex,[h])}for(let h=0;h<t.length;h++){let m=t[h],d=n?c.get(n[h])??[]:u,p=m.sectionId?d.find(y=>y.id===m.sectionId)??d.find(y=>y.section.logicalSectionId===m.sectionId&&me({x:m.x,y:m.y},y.outline,y.section.holes)):void 0,b=p?[p]:d;for(let y of b){if(n&&y.floorIndex!==n[h]||!p&&(m.x<y.box.minX||m.x>y.box.maxX||m.y<y.box.minY||m.y>y.box.maxY||!me({x:m.x,y:m.y},y.outline,y.section.holes)))continue;r[h]=y.id;let x=f.get(y.id);x.hasSeats=!0;let M=m.focalPoint??y.unit.focal,I=Math.hypot(m.x-M.x,m.y-M.y);I<x.frontU&&(x.frontU=I),x.seatIndices.push(h);let w=m.rowId||`__seat-${h}`,g=x.rows.get(w);g?g.push({x:m.x,y:m.y}):x.rows.set(w,[{x:m.x,y:m.y}]);break}}for(let[h,m]of f){let d=De(m.section,{floorBaseHeightM:m.unit.baseHeightM}),p=m.unit.baseHeightM,b=d.rake>0?Math.tan(d.rake*Math.PI/180):0,y=d.rake<=.01&&d.height<=p+.001,x=m.section.surfaceKind,M=x==="flat"?!0:x==="rakedRows"&&d.rake>.01?!1:y,I=m.hasSeats?gt(h,t,m.seatIndices,m.unit.focal):{sectionId:h,rows:[],blockCount:0},g=I.rows.length<2?ko([...m.rows.values()].map(T=>({points:T})),m.unit.focal):null,R=1/0;if(g){if(m.hasSeats)for(let T of m.rows.values())for(let B of T){let N=g.depthAt(B.x,B.y);N<R&&(R=N)}if(!m.hasSeats||!Number.isFinite(R)){R=1/0;for(let T of m.section.outline){let B=g.depthAt(T.x,T.y);B<R&&(R=B)}}}let P=p+La,S=Math.max(P,d.height),E=T=>{let B=Math.max(0,T-R)*J,N=Math.min(B*b,dn);return Math.max(P,d.height+N)},_=T=>{let B=Math.max(0,T)*J,N=Math.min(B*b,dn);return Math.max(P,d.height+N)},O=M?[]:I.rows.map(T=>({pts:T.pts,y:_(T.blockDepth),depth:T.blockDepth,blockId:T.blockId,...l.has(T.id)?{patch:Fo(T.pts,Me)}:{}})),k=O.length?O[0].y:S,C=O.map(T=>{let B=T.patch&&T.patch.length>=3?T.patch:T.pts,N=0,H=0;for(let U of B)N+=U.x,H+=U.y;let D=B.length||1;N/=D,H/=D;let V=0;for(let U of B){let Z=Math.hypot(U.x-N,U.y-H);Z>V&&(V=Z)}return{cx:N,cy:H,rad:V}}),A=M?()=>S:O.length>=2?(T,B)=>{let N=1/0,H=k;for(let D=0;D<O.length;D++){let V=C[D];if(Math.hypot(T-V.cx,B-V.cy)-V.rad>=N)continue;let U=O[D].patch,Z=U&&U.length>=3?pe(U,T,B)?0:We(U,T,B):We(O[D].pts,T,B);Z<N&&(N=Z,H=O[D].y)}return H}:(T,B)=>g?E(g.depthAt(T,B)):S,L=[0,1,0],F=O.length>=2||M?()=>L:(T,B)=>{if(!g)return L;let N=g.depthAt(T,B);if(N<=R)return L;let H=(N-R)*J;if(H*b>=dn||d.height+H*b<=P)return L;let[D,V]=g.gradientAt(T,B);if(D===0&&V===0)return L;let U=1/Math.hypot(b,1);return[-D*b*U,U,-V*b*U]};if(!M)for(let T of I.rows){let B=_(T.blockDepth);for(let N of T.seatIndices)i[N]=B}for(let T of I.rows){let B=[];for(let U=1;U<T.pts.length;U++){let Z=Math.hypot(T.pts[U].x-T.pts[U-1].x,T.pts[U].y-T.pts[U-1].y);Z>1e-6&&B.push(Z)}B.sort((U,Z)=>U-Z);let N=B.length?B[Math.floor(B.length/2)]:1/0,H=1/0,D=T.pts[Math.floor(T.pts.length/2)];if(D)for(let U of I.rows){if(U===T||U.blockId!==T.blockId)continue;let Z=We(U.pts,D.x,D.y);Z>1e-6&&Z<H&&(H=Z)}let V=Math.min(N,Math.max(H,N*.5));if(Number.isFinite(V)&&V>0)for(let U of T.seatIndices)a[U]=V}o.set(h,{sectionId:h,deckAt:A,normalAt:F,flat:M,bottomY:p,rowLevels:O,landingY:k})}for(let h=0;h<t.length;h++){let m=r[h],d=t[h];if(m){let y=i[h];s[h]=(y??o.get(m).deckAt(d.x,d.y))+Wo;continue}let p=d.eyeHeightM,b=Number.isFinite(p)?Math.max(0,p-Ee):0;s[h]=d.kind==="booth"?b+Ge+Wo:b}return{bySection:o,seatOwner:r,seatDeckY:h=>s[h],seatPitchU:h=>a[h]}}var K={top:1,wallBottom:.58,bottomCap:.4};function je(e,t){if(!e)return t;let n=z(Ae(e,.4),.62);return re(t,n,.22)}function Qo(e,t){return e?re(t,z(Ae(e,.08),.9),.82):t}function qo(e,t){let n=new Map;for(let s of e.categories??[])n.set(s.key,s.color);let o=new Map;for(let s of t){if(!s.sectionId)continue;let i=o.get(s.sectionId);i||(i=new Map,o.set(s.sectionId,i)),i.set(s.categoryKey,(i.get(s.categoryKey)??0)+1)}let r=new Map;for(let[s,i]of o){let a=0,f=0,u=0,l=0;for(let[c,h]of i){let m=oe(n.get(c));m&&(a+=m[0]*h,f+=m[1]*h,u+=m[2]*h,l+=h)}l>0&&r.set(s,[a/l,f/l,u/l])}return r}function Jo(e,t){return oe(e.color)??t.get(e.logicalSectionId??e.id)??null}var er=Fe(require("polygon-clipping"),1);function Oa(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var Tt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(f=>[f.x,f.y]);if(o.length<3)return[];o.push(o[0]);let r=Le(t),s=this.rings.filter((f,u)=>qe(r,this.boxes[u])&&Oa(n,this.levels[u])),i=[[o]];if(s.length)try{i=er.default.difference([o],...s).map(u=>u.map(l=>l.map(([c,h])=>[c,h])))}catch{i=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let f of i){if(!f.length)continue;let u=f[0].map(([l,c])=>({x:l,y:c}));if(u.length>1){let l=u[0],c=u[u.length-1];Math.abs(l.x-c.x)<1e-9&&Math.abs(l.y-c.y)<1e-9&&u.pop()}u.length>=3&&a.push(u)}return a}};function Lt(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,s=-1/0;for(let c of e)n=Math.min(n,c.x),o=Math.max(o,c.x),r=Math.min(r,c.y),s=Math.max(s,c.y);let i=(n+o)/2,a=(r+s)/2,f=t*Math.PI/180,u=Math.cos(f),l=Math.sin(f);return e.map(c=>{let h=c.x-i,m=c.y-a;return{x:i+h*u-m*l,y:a+h*l+m*u}})}function ae(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=ft(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,o=(e.y??0)+e.height/2;t=Et(n,o,e.width/2,e.height/2)}return t?Lt(t,e.rotation):null}function Pe(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},o=t==="stage"&&st(e.stageKind)?{kind:"stage",heightM:e.stageKind==="ring-boxing"?Mt:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var Ba=.08,Fa=30,Da=.015;function Na(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let s=t[o],i=t[r];s.y>e.y!=i.y>e.y&&e.x<(i.x-s.x)*(e.y-s.y)/(i.y-s.y)+s.x&&(n=!n)}return n}function tr(e,t){let n=ae(e)??(e.points?.length?Lt(e.points,e.rotation):null),o=Pe(e),s=!e.role&&o.kind==="plate"&&e.heightM===void 0&&!!n&&Math.abs(de(n))*J**2>=Fa?Da:o.heightM;if(!n)return{topOffsetM:s,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:s,supportOffsetM:0};let i=1/0,a=1/0,f=-1/0,u=-1/0;for(let m of n)i=Math.min(i,m.x),a=Math.min(a,m.y),f=Math.max(f,m.x),u=Math.max(u,m.y);let l=s,c=0,h=1e-6*Math.max(1,f-i,u-a);for(let m of t)f>m.minX&&i<m.maxX&&u>m.minY&&a<m.maxY&&l<=m.topOffsetM+1e-6&&(l=m.topOffsetM+Ba),i>=m.minX-h&&f<=m.maxX+h&&a>=m.minY-h&&u<=m.maxY+h&&(!m.poly||n.every(b=>Na(b,m.poly)||Ga(b,m.poly,h)))&&(c=Math.max(c,m.topOffsetM));return e.fill&&e.fill!=="none"&&e.fill!=="transparent"&&t.push({minX:i,minY:a,maxX:f,maxY:u,topOffsetM:l,poly:n}),{topOffsetM:l,supportOffsetM:Math.min(c,l)}}function Ga(e,t,n){for(let o=0,r=t.length-1;o<t.length;r=o++){let s=t[r],i=t[o],a=i.x-s.x,f=i.y-s.y,u=a*a+f*f,l=u?Math.max(0,Math.min(1,((e.x-s.x)*a+(e.y-s.y)*f)/u)):0;if(Math.hypot(e.x-(s.x+l*a),e.y-(s.y+l*f))<=n)return!0}return!1}function He(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function be(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function fe(e,t,n){return[He(e[0],e[1],t),He(e[0],e[1],n),He(e[3],e[2],n),He(e[3],e[2],t)]}function dt(e,t,n){return[He(e[0],e[3],t),He(e[1],e[2],t),He(e[1],e[2],n),He(e[0],e[3],n)]}function ee(e,t,n,o,r,s){W(e,t,void 0,()=>n,o,r,s,K)}function Je(e,t,n){if(e.length!==4||n<=t)return null;let o=be(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*v,s=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*v;if(r<1e-6||s<1e-6)return null;let i=Math.min(.22/r,.16),a=Math.min(.28,(n-t)*.13),f=Math.min(.065/s,.2);return{quad:o,side:i,face:f,opening:fe(o,i,1-i),openingTop:n-a}}function pn(e,t,n){if(e.length!==4||n-t<=.2)return null;let o=be(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*v;if(r<=1e-6)return null;let s=Math.min(.14,(n-t)*.08,r*.08),i=s/r,a=fe(o,i,1-i);return{quad:o,side:i,trim:s,inner:a,panel:dt(a,.15,.85),bottom:t+s,top:n-s}}function nr(e,t,n,o){let r=pn(e,t,n);if(!r)return;let{panel:s}=r,i=(x,M)=>({x:(x.x+M.x)/2,y:(x.y+M.y)/2}),a=i(s[0],s[1]),f=i(s[3],s[2]),u=Math.hypot(a.x-o.x,a.y-o.y)<=Math.hypot(f.x-o.x,f.y-o.y),[l,c]=u?[s[0],s[1]]:[s[3],s[2]],h=u?{x:a.x-f.x,y:a.y-f.y}:{x:f.x-a.x,y:f.y-a.y},m=Math.hypot(h.x,h.y);if(m<1e-6)return;-(c.y-l.y)*h.x+(c.x-l.x)*h.y<0&&([l,c]=[c,l]);let d=Math.min(.006,m*v*.05),p=h.x/m*d,b=h.y/m*d,y=(x,M)=>[x.x*v+p,M,x.y*v+b];return[y(l,r.bottom),y(c,r.bottom),y(l,r.top),y(c,r.top)]}var or=Fe(require("polygon-clipping"),1);function Oe(e,t,n,o,r,s,i,a={}){let f=Le(t),u=a.ao??K,l=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let b=ae(p);if(!b||b.length!==4||!qe(f,Le(b)))return[];let y=a.portalBase??n,x=Je(b,y,y+Pe(p).heightM);if(!x)return[];let M=Math.min(o,x.openingTop);return M<=n?[]:[{poly:x.opening,height:M}]});if(!l.length)return!1;let c=p=>p.map(b=>[b.x,b.y]),h=[c(t),...(a.holes??[]).map(c)],m=[n,...new Set(l.map(p=>p.height)),o].sort((p,b)=>p-b),d=[];try{for(let p=1;p<m.length;p++){let b=m[p-1],y=m[p];if(y-b<1e-6)continue;let x=l.filter(I=>I.height>b+1e-6).map(I=>[c(I.poly)]),M=x.length?or.default.difference(h,...x):[h];d.push({low:b,high:y,polys:M})}}catch{return!1}for(let p of d)for(let b of p.polys){let[y,...x]=b.map(I=>I.map(([w,g])=>({x:w,y:g}))),M=I=>u.wallBottom+(u.top-u.wallBottom)*(I-n)/(o-n);W(e,y,x,()=>p.high,p.low,s,i,{...u,top:M(p.high),wallBottom:M(p.low)})}return!0}function rr(e,t,n,o,r,s,i){let a=o-n;if(a<=0)return;let f=a<1.5?[[n,o,1]]:[[n,n+Math.min(.9,a*.18),.82],[n+Math.min(.9,a*.18),o-.1,1],[o-.1,o,1.1]],u=l=>K.wallBottom+(K.top-K.wallBottom)*(l-n)/a;for(let[l,c,h]of f){let m={...K,top:u(c),wallBottom:u(l)},d=z(s,h),p=z(i,h);Oe(e,t,l,c,r,d,p,{portalBase:n,ao:m})||W(e,t,void 0,()=>c,l,d,p,m)}}function pt(e,t,n){let o=oe(t.stroke?.color),r=t.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let s=t.kind==="line"||t.kind==="polyline",i=s?Lt(t.points??[],t.rotation):ae(t);if(!i||i.length<2)return;let a=s?i.length-1:i.length,f=r*.5;for(let u=0;u<a;u++){let l=i[u],c=i[(u+1)%i.length],h=Math.hypot(c.x-l.x,c.y-l.y);if(h<1e-6)continue;let m=-(c.y-l.y)/h*f,d=(c.x-l.x)/h*f,p=[(l.x+m)*v,n,(l.y+d)*v],b=[(c.x+m)*v,n,(c.y+d)*v],y=[(c.x-m)*v,n,(c.y-d)*v],x=[(l.x-m)*v,n,(l.y-d)*v];e.tri(p,b,y,[0,1,0],o),e.tri(p,y,x,[0,1,0],o)}}function ir(e){return e==="bar"||e==="concession"||e==="coat"||e==="restroom"}var et=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function Ot(e,t,n,o){let[r,s,i,a]=t?e:[e[3],e[2],e[1],e[0]];return[et(r,a,n),et(s,i,n),et(s,i,o),et(r,a,o)]}function sr(e,t,n,o,r,s,i,a,f=!1){if(n.length!==4||r-o<.4)return!1;let u=P=>f?Math.min(P,r):P,l=be(n),c=Math.hypot(l[3].x-l[0].x,l[3].y-l[0].y)*v;if(c<.4)return!1;let h=et(l[0],l[1],.5),m=et(l[3],l[2],.5),d=Math.hypot(h.x-a.x,h.y-a.y)<=Math.hypot(m.x-a.x,m.y-a.y),p=re(i,[.92,.9,.86],.35),b=z(s,.72),y=r-o;if(t==="restroom"){let P=Math.min(.18,y*.08);return ee(e,l,r-P,o,i,s),ee(e,l,r,r-P,p,p),!0}let x=o+Math.min(1.1,y),M=t==="coat"?1:Math.min(.5,.75/c),I=Ot(l,d,0,M);if(ee(e,I,x-.05,o,b,s),ee(e,I,x,x-.05,p,p),t==="coat"||c<1.2)return!0;if(t==="bar"){let P=Ot(l,d,Math.max(M+.2,1-.45/c),1),S=u(o+Math.max(Math.min(2.2,y*2),x-o+.6));return ee(e,P,S,o,i,b),!0}let w=Ot(l,d,Math.max(M+.25,.55),1),g=u(o+Math.max(2.6,x-o+1.4));if(g-.14<=x)return!0;ee(e,w,g-.14,o,i,s),ee(e,l,g,g-.14,p,b);let R=Math.min(.08,.1/Math.max(.1,Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y)*v));for(let[P,S]of[[0,R],[1-R,1]])ee(e,Ot(fe(l,P,S),d,0,Math.min(.08,.1/c)),g-.14,x,b,b);return!0}var ja=[.12,.38,.16],Ha=[.72,.62,.45],Xa=[.88,.93,.96],ar=[.95,.95,.94],Ua=[.66,.29,.22],bn={length:20.12,width:3.05},Va=.14,Ya=9.76,Be=[.93,.94,.95],Bt=[.1,.11,.13],Ka=[.45,.85,1.25],za=1.45,cr=.012,lr=.004,Wa=1.07,Za=.15;function nt(e,t,n,o,r,s){e.setMaterial(s),W(e,t,n?[n.slice().reverse()]:void 0,()=>o,o-.004,r,r,K)}var ur=(e,t)=>Ye(e,t/v);function fr(e,t,n){let o=t.x-e.x,r=t.y-e.y,s=Math.hypot(o,r);if(s<1e-9)return null;let i=-r/s*n,a=o/s*n;return[{x:e.x+i,y:e.y+a},{x:t.x+i,y:t.y+a},{x:t.x-i,y:t.y-a},{x:e.x-i,y:e.y-a}]}function $a(e,t,n,o){let r=t.map(s=>[s.x*v,n,s.y*v]);e.tri(r[0],r[1],r[2],[0,1,0],o),e.tri(r[0],r[2],r[3],[0,1,0],o)}function Ft(e,t,n,o,r,s){let i=n/v,a=[{x:t.x-i,y:t.y-i},{x:t.x+i,y:t.y-i},{x:t.x+i,y:t.y+i},{x:t.x-i,y:t.y+i}];W(e,a,void 0,()=>r,o,s,z(s,.85),K)}function tt(e,t,n,o,r,s,i){let a=fr(t,n,o/v);a&&W(e,a,void 0,()=>s,r,i,z(i,.85),K)}function Dt(e){let t=be(e),n={x:(t[0].x+t[2].x)/2,y:(t[0].y+t[2].y)/2},o=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y)||1,r=Math.hypot(t[3].x-t[0].x,t[3].y-t[0].y)||1,s={x:(t[1].x-t[0].x)/o,y:(t[1].y-t[0].y)/o},i={x:(t[3].x-t[0].x)/r,y:(t[3].y-t[0].y)/r};return{at:(f,u)=>({x:n.x+(s.x*f+i.x*u)/v,y:n.y+(s.y*f+i.y*u)/v}),lengthM:o*v,widthM:r*v}}function mr(e,t,n){let o=zn(t);if(!o.length)return;let r=1/0,s=-1/0,i=1/0,a=-1/0;for(let M of t.points??[])r=Math.min(r,M.x),s=Math.max(s,M.x),i=Math.min(i,M.y),a=Math.max(a,M.y);let f=(t.rotation??0)*Math.PI/180,u=Math.cos(f),l=Math.sin(f),c=(r+s)/2,h=(i+a)/2,m=M=>f?{x:c+(M.x-c)*u-(M.y-h)*l,y:h+(M.x-c)*l+(M.y-h)*u}:M,d=Math.min(s-r,a-i)*v,p=Math.max(.04,Math.min(.3,d*.004))/v,b=0;e.setMaterial(0);for(let M of o){if(!M.fill)continue;let I=M.points.map(m);nt(e,I,null,n+cr+b*lr,oe(M.fill)??Be,0),b++}let y=o.filter(M=>!(M.fill&&M.ink===M.fill)),x=[...new Set(y.map(M=>M.ink??St))];for(let M of x){let I=n+cr+b++*lr,w=oe(M)??Be;for(let g of y){if((g.ink??St)!==M)continue;let R=g.points.map(m),P=g.closed?R.length:R.length-1;for(let S=0;S<P;S++){let E=fr(R[S],R[(S+1)%R.length],p);E&&$a(e,E,I,w)}}}}function hr(e,t,n,o,r){if(t.length<3)return!1;let s=o+.006,i=r??ja;if(n==="oval-cricket"){let a=t.reduce((w,g)=>w+g.x,0)/t.length,f=t.reduce((w,g)=>w+g.y,0)/t.length,u=w=>t.map(g=>({x:a+(g.x-a)*w,y:f+(g.y-f)*w})),l=8;for(let w=0;w<l;w++){let g=u(1-w/l),R=w===l-1?null:u(1-(w+1)/l);nt(e,g,R,s,z(i,w%2?1.04:.96),4)}let c=t[0];for(let w of t)Math.hypot(w.x-a,w.y-f)>Math.hypot(c.x-a,c.y-f)&&(c=w);let h=Math.hypot(c.x-a,c.y-f)||1,m=(c.x-a)/h,d=(c.y-f)/h,p=-d,b=m,y=Math.min(1,2*h*v*Va/bn.length),x=bn.length*y/2/v,M=bn.width*y/2/v,I=[[-x,-M],[x,-M],[x,M],[-x,M]].map(([w,g])=>({x:a+m*w+p*g,y:f+d*w+b*g}));return nt(e,I,null,s+.004,Ha,0),e.setMaterial(0),!0}if(n==="rink-hockey"){let a=ur(t,Za);return nt(e,a,null,s,Xa,0),e.setMaterial(0),W(e,t,[a.slice().reverse()],()=>o+Wa,o,ar,z(ar,.9),K),!0}if(n==="ring-boxing"&&t.length===4){let{at:a}=Dt(t),f=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],u=[[.77,.19,.19],Be,[.17,.42,.69],Be];e.setMaterial(0),f.forEach((l,c)=>Ft(e,l,.07,o,o+za,u[c]));for(let l of Ka)for(let c=0;c<4;c++)tt(e,f[c],f[(c+1)%4],.025,o+l-.025,o+l+.025,Be);return!0}if(n==="court-tennis"&&t.length===4){let{at:a}=Dt(t);e.setMaterial(0),tt(e,a(0,-6.4),a(0,6.4),.015,o,o+.95,Bt),tt(e,a(0,-6.4),a(0,6.4),.03,o+.95,o+1,Be);for(let f of[-1,1])Ft(e,a(0,f*6.4),.05,o,o+1.07,Bt);return!0}if(n==="court-basketball"&&t.length===4){let{at:a,lengthM:f}=Dt(t),u=Math.min(14,f/2-.5);e.setMaterial(0);for(let l of[-1,1]){let c=a(l*(u+1.2),0),h=a(l*(u-1.2),0);Ft(e,c,.12,o,o+3.4,Bt),tt(e,c,h,.06,o+3.25,o+3.4,Bt),tt(e,a(l*(u-1.2),-.9),a(l*(u-1.2),.9),.03,o+2.9,o+3.95,Be)}return!0}if(n==="pitch-rugby"&&t.length===4){let{at:a,lengthM:f}=Dt(t),u=f*(50/120);e.setMaterial(0);for(let l of[-1,1]){for(let c of[-2.8,2.8])Ft(e,a(l*u,c),.07,o,o+12,Be);tt(e,a(l*u,-2.8),a(l*u,2.8),.06,o+2.94,o+3.06,Be)}return!0}if(n==="track-athletics"){let a=ur(t,Ya);return a.length<3?!1:(nt(e,t,a,s,Ua,0),nt(e,a,null,s,i,4),e.setMaterial(0),!0)}return!1}var Qa=.012,jt=2.4,qa=1,Ja=.75,ec=.15;function _e(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:o,rotation:r}=e;if(!n||!o)return null;let s=(r??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),f=n/2,u=o/2;return[[-f,-u],[f,-u],[f,u],[-f,u]].map(([l,c])=>({x:t.x+l*i-c*a,y:t.y+l*a+c*i}))}function gr(e,t,n,o,r,s,i=!1){let a=_e(t);if(a){if(i){let f=je(o,r.boothTop),u=Ce([...a]);W(e,Ie(u,tc/v),[u.slice().reverse()],()=>n+.03,n,f,z(f,.8),K);return}if(!(!t.points&&s&&oc(e,a,n,o,s))){if(!t.points&&s&&a.length===4){nc(e,a,n,o,s);return}W(e,a,void 0,()=>n+jt,n,je(o,r.boothTop),r.boothWall,K)}}}var yn=1.1,dr=[.9,.9,.88],tc=.1,Nt=[.87,.87,.85],pr=.08;function Mr(e,t){let n=f=>({x:(e[f].x+e[(f+1)%4].x)/2,y:(e[f].y+e[(f+1)%4].y)/2}),o=0,r=1/0;for(let f=0;f<4;f++){let u=n(f),l=Math.hypot(u.x-t.x,u.y-t.y);l<r&&(r=l,o=f)}let s=[0,1,2,3].map(f=>e[(o+f)%4]),i=(f,u,l)=>({x:f.x+(u.x-f.x)*l,y:f.y+(u.y-f.y)*l});return{q:s,part:(f,u,l,c)=>{let h=i(s[0],s[1],f),m=i(s[0],s[1],u),d=i(s[3],s[2],f),p=i(s[3],s[2],u);return[i(h,d,l),i(m,p,l),i(m,p,c),i(h,d,c)]},depthM:Math.hypot(s[3].x-s[0].x,s[3].y-s[0].y)*v,widthM:Math.hypot(s[1].x-s[0].x,s[1].y-s[0].y)*v}}function nc(e,t,n,o,r){let{q:s,part:i}=Mr(t,r),a=o??[.35,.42,.55],f=re(a,[.78,.78,.77],.62),u=re(a,[.95,.95,.94],.45);ee(e,s,n+Ge,n,f,z(f,.8)),ee(e,i(.05,.95,.72,.98),n+yn-.05,n+Ge,u,z(u,.8)),ee(e,i(.03,.97,.7,1),n+yn,n+yn-.05,dr,z(dr,.9))}function oc(e,t,n,o,r){if(t.length!==4)return!1;let{q:s,part:i,depthM:a,widthM:f}=Mr(t,r);if(a<1||f<1)return!1;let u=o??[.35,.42,.55],l=re(u,[.78,.78,.77],.62),c=n+jt,h=pr/f,m=pr/a;ee(e,s,n+Ge,n,l,z(l,.8)),ee(e,i(0,1,1-m,1),c,n+Ge,Nt,z(Nt,.9));for(let[b,y]of[[0,h],[1-h,1]])ee(e,i(b,y,0,1-m),c,n+Ge,Nt,z(Nt,.9));ee(e,i(h,1-h,0,Math.min(.5,.06/a)),c,c-.3,u,z(u,.85));let d=Math.min(.4,.6/f),p=Math.min(.12,.3/a);return ee(e,i(.5-d,.5+d,.72-p,.72+p),n+qa,n+Ge,re(u,[.95,.95,.94],.7),z(u,.75)),!0}function Ht(e){if(e.shape==="round"){let l=e.radius;return l?Et(e.center.x,e.center.y,l,l,24):null}let{width:t,height:n,rotation:o,center:r}=e;if(!t||!n)return null;let s=(o??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),f=t/2,u=n/2;return[[-f,-u],[f,-u],[f,u],[-f,u]].map(([l,c])=>({x:r.x+l*i-c*a,y:r.y+l*a+c*i}))}function Sr(e,t,n,o,r,s=!0){let i=Ht(t);if(!i)return;let a=i.reduce((h,m)=>h+m.x,0)/i.length,f=i.reduce((h,m)=>h+m.y,0)/i.length,u=h=>i.map(m=>({x:a+(m.x-a)*h,y:f+(m.y-f)*h})),l=s&&o?je(o,r.tableTop):rc,c=n+Ja;W(e,i,void 0,()=>c,n+ic,l,z(l,.86),K),W(e,u(.12),void 0,()=>c+.12,c,br,z(br,.8),K)}var rc=[.93,.92,.89],br=[.78,.66,.42],ic=.25;function Ir(e,t,n,o,r,s,i,a,f=[]){let u=ae(t);if(!t.role&&(!t.fill||t.fill==="none"||t.fill==="transparent")||!u){pt(e,t,n+o+Qa);return}let c=a?a.kind==="stage":t.role==="stage",h=a?a.kind==="screen":t.role==="screen",m=a?{kind:c?"stage":"solid",heightM:a.topY-a.baseY}:Pe(t),d=a?.baseY??n,p=a?.topY??n+o;if(c&&i){let P=1/0,S=-1/0,E=1/0,_=-1/0;for(let O of u)O.x<P&&(P=O.x),O.x>S&&(S=O.x),O.y<E&&(E=O.y),O.y>_&&(_=O.y);i.push({cx:(P+S)/2*v,cz:(E+_)/2*v,y:p,halfX:Math.max((S-P)/2*v,.5),halfZ:Math.max((_-E)/2*v,.5)})}let b=oe(t.fill),y=t.role==="wall"||t.role==="entrance"||t.role==="exit",x=y?b?z(Ae(b,.12),.95):r.tierTop:c&&b?re(r.stageTop,z(Ae(b,.18),.9),.9):!t.role&&b?b:je(b,c?r.stageTop:r.decorTop),M=h?b:null,I=y?b?z(Ae(b,.12),.85):r.tierWall:c?b?re(r.stageWall,z(b,.58),.82):r.stageWall:h?M?re(z(M,1.42),[.24,.46,.82],.08):[.24,.46,.82]:je(oe(t.fill),r.decorWall);if(t.role==="wall"&&!a){rr(e,u,d,p,f,x,I),pt(e,t,p+.012);return}if(h&&u.length===4&&p-d>.2){let P=pn(u,d,p);if(!P)return;let{quad:S,side:E,trim:_,inner:O,panel:k}=P,C=[.12,.15,.18];for(let[A,L]of[[0,E],[1-E,1]])ee(e,fe(S,A,L),p,d,C,C);ee(e,O,d+_,d,C,C),ee(e,O,p,p-_,C,C),ee(e,k,p-_,d+_,I,I),pt(e,t,p+.012);return}let w=b?z(Ae(b,.15),.82):I,g=b?z(Ae(b,.1),1.02):x;if(ir(t.role)&&!a&&sr(e,t.role,u,d,p,w,g,s,t.heightM!==void 0))return;if((t.role==="sound"||a?.kind==="sound_desk")&&u.length===4&&p-d>.3){let P=be(u),S=Math.hypot(P[1].x-P[0].x,P[1].y-P[0].y)*v,E=Math.min(.12,.09/Math.max(S,.001)),_=[.18,.21,.24],O=p-Math.min(.12,(p-d)*.15);for(let[k,C]of[[0,E],[1-E,1]])ee(e,fe(P,k,C),O,d,_,_);ee(e,P,p,O,x,_);return}if(t.role==="rail"&&u.length===4&&p>d){let P=be(u),S=Math.hypot(P[1].x-P[0].x,P[1].y-P[0].y)*v,E=Math.max(1,Math.min(128,Math.ceil(S/1.4))),_=Math.min(.08,.055/Math.max(.055,S)),O=[.58,.64,.66];for(let k=0;k<=E;k++){let C=k/E,A=Math.min(1-_,Math.max(0,C-_/2));ee(e,fe(P,A,A+_),p,d,O,z(O,.8))}for(let k of[.52,1]){let C=d+(p-d)*k;ee(e,P,C,Math.max(d,C-.055),O,z(O,.8))}return}if(t.role==="goal"&&u.length===4){let P=be(u),S=Math.hypot(P[1].x-P[0].x,P[1].y-P[0].y)*v,E=Math.min(.12,.1/Math.max(.1,S)),_=[.9,.94,.94];for(let[O,k]of[[0,E],[1-E,1]])ee(e,fe(P,O,k),Math.max(d,p-.1),d,_,_);ee(e,P,p,Math.max(d,p-.1),_,_);return}if(m.kind==="portal"&&u.length===4){let P=Je(u,d,p);if(!P)return;let{quad:S,side:E,face:_,openingTop:O}=P;for(let[k,C,A]of[[0,_,1],[_,1-_,.67],[1-_,1,1]]){let L=dt(S,k,C),F=z(x,A),T=z(I,A);for(let[B,N]of[[0,E],[1-E,1]])ee(e,fe(L,B,N),O,d,F,T);ee(e,L,p,O,F,T)}return}if(m.kind==="suite"&&u.length===4){let P=u.map((_,O)=>{let k=u[(O+1)%4],C=(_.x+k.x)/2,A=(_.y+k.y)/2;return Math.hypot(C-s.x,A-s.y)}),S=P.indexOf(Math.min(...P)),E=[0,1,2,3].map(_=>u[(S+_)%4]);ee(e,fe(E,0,.08),p,d,x,I),ee(e,fe(E,.92,1),p,d,x,I),ee(e,dt(E,.88,1),p,d,x,I),ee(e,E,p,Math.max(d,p-.18),x,I);return}if(c&&!t.stageKind?.startsWith("pitch-")&&p-d>.12){let P=p-Math.min(.06,(p-d)*.15);ee(e,u,P,d,x,I),ee(e,u,p,P,x,re(x,I,.2))}else ee(e,u,p,d,x,I);if((t.stageKind==="pitch-football"||t.stageKind==="pitch-rugby")&&u.length===4){e.setMaterial(4);let P=be(u);for(let S=0;S<12;S++){let E=fe(P,S/12,(S+1)/12),_=z(b??[.12,.38,.16],S%2?1.035:.965),O=E.map(k=>[k.x*v,p+.006,k.y*v]);e.tri(O[0],O[1],O[2],[0,1,0],_),e.tri(O[0],O[2],O[3],[0,1,0],_)}}t.stageKind&&t.stageKind!=="pitch-football"&&hr(e,u,t.stageKind,p,b),c&&Xe(t.stageKind)&&mr(e,t,p),e.setMaterial(h?1:0),pt(e,t,p+.012)}function Xt(e){let{x:t,y:n,width:o,height:r}=e;if(!o||!r)return null;let s=t+o/2,i=n+r/2,a=(e.rotation??0)*Math.PI/180,f=Math.cos(a),u=Math.sin(a),l=o/2,c=r/2;return[[-l,-c],[l,-c],[l,c],[-l,c]].map(([h,m])=>({x:s+h*f-m*u,y:i+h*u+m*f}))}function sc(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let o=n[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return oe(o);let s=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!s)return null;let i=[];for(let a of s[1].matchAll(/stop-color="([^"]+)"/gi)){let f=oe(a[1].trim());f&&i.push(f)}return i.length?i.reduce((a,f,u)=>re(a,f,1/(u+1)),i[0]):null}function Pr(e,t,n,o){if(t.layer==="foreground")return;let r=Xt(t);if(!r)return;let s=n+ec,i=je(sc(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(i=re(o.ground,i,a)),W(e,r,void 0,()=>s,n,i,re(i,o.decorWall,.5),K)}function Rr(e,t,n,o,r){if(!t.points||t.points.length<3)return;let s=je(o,r.gaTop);W(e,t.points,t.holes,()=>n+yr,n,s,r.gaWall,K),lc(e,t.points,n+yr)}var yr=.15,Gt=[.72,.74,.76],xn=1.1,xr=.12,gn=.05,ac=.06,cc=2.4;function lc(e,t,n){let o=Ce([...t]),r=Ye(o,xr/v),s=Ye(o,(xr+gn)/v);if(r.length<3||s.length<3)return;for(let a of[n+xn,n+xn*.5])W(e,r,[s.slice().reverse()],()=>a,a-gn,Gt,z(Gt,.85),K);let i=ac/2/v;for(let a=0;a<r.length;a++){let f=r[a],u=r[(a+1)%r.length],l=Math.hypot(u.x-f.x,u.y-f.y)*v,c=Math.max(1,Math.round(l/cc));for(let h=0;h<c;h++){let m=h/c,d=f.x+(u.x-f.x)*m,p=f.y+(u.y-f.y)*m,b=[{x:d-i,y:p-i},{x:d+i,y:p-i},{x:d+i,y:p+i},{x:d-i,y:p+i}];W(e,b,void 0,()=>n+xn-gn,n,Gt,z(Gt,.8),K)}}}var Mn=.6,wr=3,uc=.25;function fc(e,t){if(pe(t,e.x,e.y))return 0;let n=1/0;for(let o=0,r=t.length-1;o<t.length;r=o++){let s=t[r],i=t[o],a=i.x-s.x,f=i.y-s.y,u=a*a+f*f||1,l=Math.max(0,Math.min(1,((e.x-s.x)*a+(e.y-s.y)*f)/u));n=Math.min(n,Math.hypot(e.x-(s.x+l*a),e.y-(s.y+l*f)))}return n}function vr(e,t){let n=e.map(i=>({booth:i,ring:_e(i)})).filter(i=>!!i.ring&&i.ring.length===4&&!i.booth.points),o=n.map(({ring:i})=>({minX:Math.min(...i.map(a=>a.x)),maxX:Math.max(...i.map(a=>a.x)),minY:Math.min(...i.map(a=>a.y)),maxY:Math.max(...i.map(a=>a.y))})),r=(wr+Mn)/v,s=new Map;return n.forEach(({booth:i,ring:a},f)=>{let u={x:a.reduce((m,d)=>m+d.x,0)/4,y:a.reduce((m,d)=>m+d.y,0)/4},l=[0,1,2,3].map(m=>{let d=a[m],p=a[(m+1)%4],b={x:(d.x+p.x)/2,y:(d.y+p.y)/2},y=b.x-u.x,x=b.y-u.y,M=Math.hypot(y,x)||1,I={x:b.x+y/M*Mn/v,y:b.y+x/M*Mn/v},w=wr/v;return o.forEach((g,R)=>{R===f||I.x<g.minX-r||I.x>g.maxX+r||I.y<g.minY-r||I.y>g.maxY+r||(w=Math.min(w,fc(I,n[R].ring)))}),{open:w*v,toward:{x:b.x+y/M*10/v,y:b.y+x/M*10/v},focal:Math.hypot(b.x-t.x,b.y-t.y)}}),c=Math.max(...l.map(m=>m.open)),h=l.filter(m=>m.open>=c-uc).sort((m,d)=>m.focal-d.focal)[0];s.set(i.id,h.toward)}),s}var Er=Fe(require("polygon-clipping"),1);var mc=.45,hc=1500,dc=200;function Cr(e,t){if(e.role!=="stage"||Xe(e.stageKind))return e;let n=ae(e);if(!n||n.length<3||Math.abs(de(n))*v*v>hc)return e;let o=t.filter(i=>pe(n,i.x,i.y));if(!o.length||o.length>dc)return e;let r=mc/v,s=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=Er.default.difference([[...n.map(u=>[u.x,u.y]),[n[0].x,n[0].y]]],...s),a=null,f=0;for(let u of i){let l=u[0].slice(0,-1).map(([h,m])=>({x:h,y:m})),c=Math.abs(de(l));c>f&&(f=c,a=l)}return!a||a.length<3?e:{...e,kind:"polygon",points:a,rotation:0}}catch{return e}}var pc=Math.PI/180,ie=96,bc=6,yc=60,xc=150,Ar=.2,gc=.35;function Mc(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/pc;return n<0?n+360:n}function Ut(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function Vt(e,t,n=2){let o=e.length,r=new Float64Array(o);for(let s=0;s<o;s++){let i=0,a=0;for(let f=-n;f<=n;f++){let u=s+f;if(t)u=(u%o+o)%o;else if(u<0||u>=o)continue;i+=e[u],a++}r[s]=i/a}return r}function _r(e,t){let n=e.filter(h=>h.rows.length>=1);if(n.length<1)return null;let o=[],r=0,s=0,i=0;for(let h of n)for(let m of h.rows){for(let d of m.pts)r+=d.x,s+=d.y,i++;if(m.pts.length>=4){let d=en(m.pts);d&&Number.isFinite(d.cx)&&Number.isFinite(d.cy)&&o.push({x:d.cx,y:d.cy})}}if(!i)return null;let a={x:r/i,y:s/i},f=a;if(o.length>=8){let h=Ut(o.map(y=>y.x)),m=Ut(o.map(y=>y.y)),d=0;for(let y of n)for(let x of y.rows)for(let M of x.pts){let I=Math.hypot(M.x-a.x,M.y-a.y);I>d&&(d=I)}let p=0,b=d*.2;for(let y of n)for(let x of y.rows)for(let M of x.pts)Math.hypot(M.x-h,M.y-m)<b&&p++;Math.hypot(h-a.x,m-a.y)<=d&&p/i<.01&&(f={x:h,y:m})}let u=[];for(let h of n){let m={sectionId:h.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let d of h.rows)for(let p of d.pts){let b=Math.hypot(p.x-f.x,p.y-f.y),y=Math.min(ie-1,Math.floor(Mc(f,p)/(360/ie)));m.samples.push({r:b,bin:y,levelM:d.levelM}),b<m.rMin&&(m.rMin=b),b>m.rMax&&(m.rMax=b)}m.samples.length&&u.push(m)}if(!u.length)return null;u.sort((h,m)=>h.rMin+h.rMax-(m.rMin+m.rMax));let l=[];for(let h of u){let m=!1;for(let d of l){let p=Math.min(h.rMax,d.rMax)-Math.max(h.rMin,d.rMin),b=Math.min(h.rMax-h.rMin,d.rMax-d.rMin);if(b>1e-9&&p>=gc*b){d.members.push(h),d.rMin=Math.min(d.rMin,h.rMin),d.rMax=Math.max(d.rMax,h.rMax),m=!0;break}}m||l.push({members:[h],rMin:h.rMin,rMax:h.rMax})}let c=[];for(let h of l){let m=new Array(ie).fill(null);for(let k of h.members)for(let C of k.samples){let A=m[C.bin];A||(A={samples:[]},m[C.bin]=A),A.samples.push({r:C.r,levelM:C.levelM})}let d=m.map(k=>!!k);if(!d.filter(Boolean).length)continue;let b=[],y=[];for(let k of m){if(!k)continue;let C=1/0,A=-1/0;for(let L of k.samples)L.r<C&&(C=L.r),L.r>A&&(A=L.r);b.push(C),y.push(A)}let x=Ut(b),M=Ut(y);if(!(x>=Ar*M)||!(M>0))continue;let I=[...b].sort((k,C)=>k-C);if(!(I[Math.floor(I.length*.1)]>=Ar*M))continue;let g=m.map(k=>{if(!k)return null;let C=[...k.samples].sort((D,V)=>D.r-V.r),A=C[0].r,L=C[C.length-1].r,F=C[0].levelM,T=-1/0;for(let D of C)D.levelM>T&&(T=D.levelM);let B=[];for(let D of C){let V={r:D.r,l:D.levelM};for(;B.length&&Math.abs(B[B.length-1].r-V.r)<1e-9;){if(B[B.length-1].l<=V.l){V.skip=!0;break}B.pop()}if(!V.skip){for(;B.length>=2;){let U=B[B.length-2],Z=B[B.length-1];if((Z.r-U.r)*(V.l-U.l)-(Z.l-U.l)*(V.r-U.r)<=0)B.pop();else break}B.push(V)}}let N=B.map(D=>D.r),H=B.map(D=>D.l);return{inner:A,outer:L,front:F,top:T,profile:{rs:N,ls:H}}}),R=d.slice();for(let k=0;k<ie;k++){if(R[k])continue;let C=-1,A=-1,L=0;for(let X=1;X<=ie;X++){let q=(k-X+ie*2)%ie;if(R[q]){C=q;break}}for(let X=1;X<=ie;X++){let q=(k+X)%ie;if(R[q]){A=q,L=X;break}}if(C<0||A<0)continue;let F=0;for(let X=1;X<=ie;X++){let q=(k-X+ie*2)%ie;if(d[q]){F=X;break}}if(F-1+L>bc)continue;let B=g[C],N=g[A],H=F/(F+L),D=B.inner+(N.inner-B.inner)*H,V=B.outer+(N.outer-B.outer)*H,U=B.front+(N.front-B.front)*H,Z=B.top+(N.top-B.top)*H;g[k]={inner:D,outer:V,front:U,top:Z,profile:{rs:[D,V],ls:[U,Z]}}}for(let k=0;k<ie;k++)g[k]&&(R[k]=!0);let P=360/ie,S=[],E=R.filter(Boolean).length,_=[];if(E===ie)_.push({start:0,len:ie});else{let k=0;for(;R[k];)k=(k+1)%ie;let C=-1;for(let A=0;A<=ie;A++){let L=(k+A)%ie,F=A<ie&&R[L];if(F&&C<0)C=L;else if(!F&&C>=0){let T=(L-C+ie)%ie||ie;_.push({start:C,len:T}),C=-1}}}for(let k of _){if(k.len*P<yc&&k.len<ie)continue;let C=k.len===ie,A=new Float64Array(k.len),L=new Float64Array(k.len),F=new Float64Array(k.len),T=new Float64Array(k.len),B=[];for(let X=0;X<k.len;X++){let q=g[(k.start+X)%ie];A[X]=q.inner,L[X]=q.outer,F[X]=q.front,T[X]=q.top,B.push(q.profile??{rs:[q.inner,q.outer],ls:[q.front,q.top]})}let N=Vt(A,C),H=Vt(L,C),D=Vt(F,C),V=Vt(T,C);for(let X=0;X<k.len;X++)N[X]>A[X]&&(N[X]=A[X]),H[X]<L[X]&&(H[X]=L[X]),N[X]>H[X]-1e-6&&(N[X]=Math.max(0,H[X]-1e-6)),V[X]<D[X]&&(V[X]=D[X]);let U={startBin:k.start,binCount:k.len,closed:C,innerR:N,outerR:H,frontLevelM:D,topLevelM:V,profiles:B},Z=(X,q,$)=>{let j=B[X],G=j.rs,Q=j.ls;if(q<=G[0]){Q[0]>$&&(Q[0]=$);return}if(q>=G[G.length-1]){Q[Q.length-1]>$&&(Q[Q.length-1]=$);return}for(let te=0;te+1<G.length;te++)if(q<=G[te+1]){Q[te]>$&&(Q[te]=$),Q[te+1]>$&&(Q[te+1]=$);return}};for(let X=0;X<k.len;X++){let q=m[(k.start+X)%ie];if(q)for(let $ of q.samples){Z(X,$.r,$.levelM);let j=C?(X-1+k.len)%k.len:X-1,G=C?(X+1)%k.len:X+1;j>=0&&Z(j,$.r,$.levelM),G<k.len&&Z(G,$.r,$.levelM)}}S.push(U)}S.reduce((k,C)=>k+C.binCount*P,0)<xc||c.push({arcs:S,sectionIds:h.members.map(k=>k.sectionId),innerRMedian:x,outerRMedian:M})}if(!c.length)return null;if(c.sort((h,m)=>h.innerRMedian-m.innerRMedian),t){let h=c[c.length-1].outerRMedian;if(Math.hypot(t.x-f.x,t.y-f.y)>.9*h)return null}return{centre:f,binCount:ie,binStepDeg:360/ie,rings:c}}function kr(e,t,n,o){let r=e.binStepDeg,s=n/r-.5-t.startBin;s=(s%e.binCount+e.binCount)%e.binCount,s>t.binCount-1&&(t.closed?s=s-t.binCount<t.binCount-s?0:t.binCount-1:s=s-(t.binCount-1)<e.binCount-s?t.binCount-1:0);let i=Math.floor(s),a=t.closed?(i+1)%t.binCount:Math.min(t.binCount-1,i+1),f=s-i,u=l=>{let c=t.profiles[l],h=c.rs,m=c.ls;if(o<=h[0])return m[0];if(o>=h[h.length-1])return m[m.length-1];for(let d=0;d+1<h.length;d++)if(o<=h[d+1]){let p=h[d+1]-h[d],b=p>1e-9?(o-h[d])/p:0;return m[d]+(m[d+1]-m[d])*b}return m[m.length-1]};return u(i)*(1-f)+u(a)*f}function Sn(e,t,n,o,r,s,i,a,f,u=[],l=r){if(t.length!==n.length||t.length<2||s-r<1.5)return;let c=(p,b,y)=>{Oe(e,p,b,y,u,i,a,{portalBase:l,ao:f})||W(e,p,void 0,()=>y,b,i,a,f)},h=(p,b,y)=>({x:p.x+(b.x-p.x)*y,y:p.y+(b.y-p.y)*y}),m=o?t.length:t.length-1,d=0;for(let p=0;p<m;p++){let b=(p+1)%t.length,y=Math.hypot(n[b].x-n[p].x,n[b].y-n[p].y)*J;if(y<1e-5)continue;let x=(g,R)=>[h(t[p],t[b],g),h(t[p],t[b],R),h(n[p],n[b],R),h(n[p],n[b],g)];c(x(0,1),r,r+.95),c(x(0,1),s-.22,s);let M=Math.ceil((d-.32)/6)*6,I=!1,w=!1;for(let g=M;g<d+y;g+=6){let R=Math.max(0,(g-d)/y),P=Math.min(1,(g+.32-d)/y);P<=R||(c(x(R,P),r+.95,s-.22),I||=R<1e-6,w||=P>1-1e-6)}if(!o&&(p===0&&!I||p===m-1&&!w)){let g=Math.min(1,.32/y);c(x(p===0?0:1-g,p===0?g:1),r+.95,s-.22)}d+=y}}var bt=.65;function Tr(e,t){let n=1/0;for(let o of t)for(let r=0;r<o.length;r++){let s=o[r],i=o[(r+1)%o.length],a=i.x-s.x,f=i.y-s.y,u=Math.max(0,Math.min(1,((e.x-s.x)*a+(e.y-s.y)*f)/(a*a+f*f||1)));n=Math.min(n,Math.hypot(e.x-s.x-u*a,e.y-s.y-u*f))}return n}var Lr=.01;function Or(e,t,n,o,r,s,i,a=[],f=!0){if(o-r<=1e-5)return;let u=o-r>=3,l=u?o-bt:r;e.setMaterial(5);let c=u?[]:a.filter(I=>{if(I.role!=="entrance"&&I.role!=="exit")return!1;let w=ae(I);if(!w)return!1;let g=Je(w,r,r+Pe(I).heightM);return g!==null&&g.openingTop<=o-.12});if((!c.length||!Oe(e,t,l,o,c,s,i,{holes:n,portalBase:r}))&&W(e,t,n,()=>o,l,s,i,K,void 0,()=>[0,1,0]),!u){e.setMaterial(0);return}let h=6/v,m=.22/v,d=a.flatMap(I=>{if(I.role!=="entrance"&&I.role!=="exit")return[];let w=ae(I);return w?.length?[{minX:Math.min(...w.map(g=>g.x)),maxX:Math.max(...w.map(g=>g.x)),minY:Math.min(...w.map(g=>g.y)),maxY:Math.max(...w.map(g=>g.y))}]:[]}),p=Math.min(...t.map(I=>I.x)),b=Math.max(...t.map(I=>I.x)),y=Math.min(...t.map(I=>I.y)),x=Math.max(...t.map(I=>I.y));for(let I=p+h/2;I<b;I+=h)for(let w=y+h/2;w<x;w+=h){if(d.some(R=>I+m>=R.minX&&I-m<=R.maxX&&w+m>=R.minY&&w-m<=R.maxY))continue;let g=[{x:I-m,y:w-m},{x:I+m,y:w-m},{x:I+m,y:w+m},{x:I-m,y:w+m}];!me({x:I,y:w},t,n)||Tr({x:I,y:w},[t,...n??[]])<m*Math.SQRT2+(f?In/v:0)||W(e,g,void 0,()=>l,r,s,i,K)}let M=Ye(t,In/v);if(f&&M.length>=3){let I=a.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let P=ae(R);return!!P&&P.some(S=>!me(S,t,void 0)||Tr(S,[t])<=In/v)}),w=[M.slice().reverse()],g=r-Lr;(!I.length||!Oe(e,t,g,l,I,s,i,{holes:w,portalBase:r+Lr}))&&W(e,t,w,()=>l,g,s,i,K)}e.setMaterial(0)}var In=.25;var Sc=.02,Ic=.25,Pc=1.2,Rc=.6,wc=.45,vc=2.3,Ec=Math.PI/180,Br=.005;function ke(e,t,n){let o=n*Ec;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Cc(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let o=n.outerRMedian*.85;for(let r of e){if(r.role!=="wall")continue;let s=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(s.length<2)continue;let i=0;for(let a of s)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=o&&i++;if(i>=s.length/2)return!0}return!1}var Ac=24,_c=.01;function kc(e,t,n,o,r,s,i,a,f){let u=n.binCount,l=Ac,c=J,h=s+.02,m=s-_c,d=[];for(let C=0;C<u;C++){let A=(n.startBin+C+.5)*t.binStepDeg,L=new Float64Array(l+1);for(let F=0;F<=l;F++){let T=o[C]+(r[C]-o[C])*F/l;L[F]=Math.max(h,kr(t,n,A,T)-Ic)}d.push(L)}if(f){let C=0;for(let A=0;A+1<u;A++)for(let L=0;L<l;L++){let F=ke(t.centre,o[A]+(r[A]-o[A])*L/l,(n.startBin+A+.5)*t.binStepDeg),T=ke(t.centre,o[A+1]+(r[A+1]-o[A+1])*(L+1)/l,(n.startBin+A+1.5)*t.binStepDeg);C=Math.max(C,Math.hypot(T.x-F.x,T.y-F.y))}for(let A=0;A<u;A++){let L=(n.startBin+A+.5)*t.binStepDeg;for(let F=0;F<=l;F++){let T=ke(t.centre,o[A]+(r[A]-o[A])*F/l,L),B=f(T.x,T.y,C*1.01);B!==null&&(d[A][F]=Math.min(d[A][F],Math.max(m+Br,B-Br)))}}}let p=[i.bandTop[0]*a.top,i.bandTop[1]*a.top,i.bandTop[2]*a.top],b=[i.bandTop[0]*a.bottomCap,i.bandTop[1]*a.bottomCap,i.bandTop[2]*a.bottomCap],y=[i.bandWall[0]*a.top,i.bandWall[1]*a.top,i.bandWall[2]*a.top],x=[i.bandWall[0]*a.wallBottom,i.bandWall[1]*a.wallBottom,i.bandWall[2]*a.wallBottom],M=(C,A)=>{let L=(n.startBin+C+.5)*t.binStepDeg,F=o[C]+(r[C]-o[C])*A/l,T=ke(t.centre,F,L);return[T.x*c,d[C][A],T.y*c]};{let C=Math.tan(12*Math.PI/180);for(let A=0;A<6;A++){let L=!1;for(let T=0;T<u;T++)for(let B=l-1;B>=0;B--)d[T][B]>d[T][B+1]&&(d[T][B]=d[T][B+1],L=!0);let F=n.closed?u:u-1;for(let T=0;T<F;T++){let B=(T+1)%u;for(let N=0;N<=l;N++){let H=d[B][N]-d[T][N];if(Math.abs(H)>1)continue;let D=o[T]+(r[T]-o[T])*N/l,V=o[B]+(r[B]-o[B])*N/l,U=ke(t.centre,D,(n.startBin+T+.5)*t.binStepDeg),Z=ke(t.centre,V,(n.startBin+B+.5)*t.binStepDeg),X=C*Math.hypot(Z.x-U.x,Z.y-U.y)*c;H>X?(d[B][N]=d[T][N]+X,L=!0):-H>X&&(d[T][N]=d[B][N]+X,L=!0)}}if(!L)break}}let I=1,w=(C,A)=>{for(let L=0;L<=l;L+=4)if(Math.abs(d[C][L]-d[A][L])>I)return!0;return Math.abs(d[C][l]-d[A][l])>I},g=Math.tan(38*Math.PI/180),R=C=>(r[C]-o[C])/l*c,P=(C,A)=>d[C][A+1]-d[C][A]>g*Math.max(1e-6,R(C)),S=(C,A)=>{let L=n.closed?(C-1+u)%u:Math.max(0,C-1),F=n.closed?(C+1)%u:Math.min(u-1,C+1);Math.abs(d[L][A]-d[C][A])>I&&(L=C),Math.abs(d[F][A]-d[C][A])>I&&(F=C);let T=Math.max(0,A-1),B=Math.min(l,A+1);T<A&&P(C,T)&&(T=A),B>A&&P(C,A)&&(B=A);let N=M(L,A),H=M(F,A),D=M(C,T),V=M(C,B),U=H[0]-N[0],Z=H[1]-N[1],X=H[2]-N[2],q=V[0]-D[0],$=V[1]-D[1],j=V[2]-D[2],G=Z*j-X*$,Q=X*q-U*j,te=U*$-Z*q,ne=Math.hypot(G,Q,te);return ne>1e-12?(G/=ne,Q/=ne,te/=ne,Q<0&&(G=-G,Q=-Q,te=-te),[G,Q,te]):[0,1,0]},E=(C,A,L=!1)=>{let F=L&&Math.min(C[1],A[1])-s>=3,T=[C[0],F?C[1]-bt:m,C[2]],B=[A[0],F?A[1]-bt:m,A[2]],N=A[0]-C[0],H=A[2]-C[2],D=Math.hypot(N,H);if(!(D>1e-12))return;let V=[H/D,0,-N/D];e.tri(C,A,B,V,y,y,x),e.tri(C,B,T,V,y,x,x)},_=.05*ge,O=C=>r[C]-o[C]<_,k=n.closed?u:u-1;for(let C=0;C<k;C++){let A=(C+1)%u;if(O(C)||O(A))continue;if(w(C,A)){let H=(n.startBin+C+1)*t.binStepDeg,D=($,j)=>{let G=(o[C]+o[A])/2,Q=(r[C]+r[A])/2,te=G+(Q-G)*j/l,ne=ke(t.centre,te,H);return[ne.x*c,d[$][j],ne.y*c]};for(let $=0;$<l;$++){let j=M(C,$),G=M(C,$+1),Q=D(C,$),te=D(C,$+1),ne=S(C,$),ce=S(C,$+1);e.triN(j,Q,te,ne,ne,ce,p),e.triN(j,te,G,ne,ce,ce,p);let se=M(A,$),Y=M(A,$+1),le=D(A,$),Re=D(A,$+1),we=S(A,$),ve=S(A,$+1);e.triN(le,se,Y,we,we,ve,p),e.triN(le,Y,Re,we,ve,ve,p);let Se=D(C,$),he=D(C,$+1),ze=D(A,$+1),Kt=D(A,$),yt=he[0]-Se[0],rt=he[2]-Se[2],zt=Math.hypot(yt,rt);if(zt>1e-12){let Tn=[rt/zt,0,-yt/zt];e.tri(Se,he,ze,Tn,y),e.tri(Se,ze,Kt,Tn,y)}}let V=M(C,0),U=M(A,0),Z=M(A,l),X=M(C,l),q=$=>[$[0],m,$[2]];Math.min(V[1],U[1])-s<3&&(e.tri(q(V),q(Z),q(U),[0,-1,0],b),e.tri(q(V),q(X),q(Z),[0,-1,0],b)),E(V,U,!0),E(X,Z,!0);continue}for(let H=0;H<l;H++){let D=S(C,H),V=S(A,H),U=S(A,H+1),Z=S(C,H+1);if(P(C,H)||P(A,H)){let G=(he,ze)=>{let Kt=(n.startBin+he+.5)*t.binStepDeg,yt=o[he]+(r[he]-o[he])*(H+.5)/l,rt=ke(t.centre,yt,Kt);return[rt.x*c,ze,rt.y*c]},Q=M(C,H),te=M(A,H),ne=G(C,d[C][H]),ce=G(A,d[A][H]);e.triN(Q,te,ce,D,V,V,p),e.triN(Q,ce,ne,D,V,D,p);let se=M(A,H+1),Y=M(C,H+1),le=G(C,d[C][H+1]),Re=G(A,d[A][H+1]);e.triN(le,Re,se,Z,U,U,p),e.triN(le,se,Y,Z,U,Z,p);let we=ce[0]-ne[0],ve=ce[2]-ne[2],Se=Math.hypot(we,ve);if(Se>1e-12){let he=[-ve/Se,0,we/Se];e.tri(ne,ce,Re,he,y),e.tri(ne,Re,le,he,y)}continue}let X=M(C,H),q=M(A,H),$=M(A,H+1),j=M(C,H+1);e.triN(X,q,$,D,V,U,p),e.triN(X,$,j,D,U,Z,p)}let L=M(C,0),F=M(A,0),T=M(A,l),B=M(C,l),N=H=>[H[0],m,H[2]];Math.min(L[1],F[1])-s<3&&(e.tri(N(L),N(T),N(F),[0,-1,0],b),e.tri(N(L),N(B),N(T),[0,-1,0],b)),E(L,F,!0),E(B,T,!0)}if(!n.closed)for(let C of[0,u-1])for(let A=0;A<l;A++)E(M(C,A),M(C,A+1))}function Fr(e,t,n){let{bottomY:o,colors:r,ao:s}=n,i=new Float64Array(t.binCount).fill(-1/0);for(let l of t.rings)for(let c of l.arcs){let h=new Float64Array(c.binCount),m=new Float64Array(c.binCount);for(let p=0;p<c.binCount;p++){let b=(c.startBin+p)%t.binCount,y=Math.max(0,c.innerR[p]-Me);h[p]=Math.max(y,i[b]+.001),m[p]=Math.max(h[p]+.001,c.outerR[p]+Me)}let d=0;for(let p=0;p<c.binCount;p++){let b=c.topLevelM[p]-o;b>d&&(d=b)}d>=Pc&&kc(e,t,c,h,m,o,r,s,n.standTopNear);for(let p=0;p<c.binCount;p++){let b=(c.startBin+p)%t.binCount;m[p]>i[b]&&(i[b]=m[p])}}if(n.deriveShell===!1||Cc(n.shapes,t))return;let a=t.rings[t.rings.length-1],f=Rc*ge,u=wc*ge;for(let l of a.arcs){let c=[],h=[];for(let S=0;S<l.binCount;S++){let E=(l.startBin+S+.5)*t.binStepDeg,_=l.outerR[S]+Me+f;c.push(ke(t.centre,_,E)),h.push(ke(t.centre,_+u,E))}let m=-1/0;for(let S=0;S<l.binCount;S++)l.topLevelM[S]>m&&(m=l.topLevelM[S]);let d=m+vc,p=l.closed?h:[...h,...c.slice().reverse()],b=l.closed?[c.slice().reverse()]:void 0,y=re(r.shellWall,[.66,.71,.72],.62),x=(S,E,_,O,k)=>{let C=Math.abs(O-m)<1e-6?O-Sc:O;Oe(e,S,_,C,n.shapes,r.shellTop,k,{holes:E,portalBase:o,ao:s})||W(e,S,E,()=>C,_,r.shellTop,k,s)},M=Math.max(1,Math.ceil((m-o)/4.5)),I=(m-o)/M,w=new Set,g=n.tierFrontLevels??t.rings.map(S=>{let E=S.arcs.flatMap(_=>Array.from(_.frontLevelM)).filter(Number.isFinite).sort((_,O)=>_-O);return E[Math.floor(E.length/2)]});for(let S of g)Number.isFinite(S)&&S-o>=3&&S<m&&w.add(Math.max(0,Math.min(M-1,Math.floor((S-o)/I))));let R=Math.min(...g.filter(S=>Number.isFinite(S)&&S-o>=3&&S<m));for(let S=0;S<M;S++)o+(S+1)*I<=R-bt&&Number.isFinite(R)&&w.add(S);for(let S=0;S<M;S++){let E=o+(m-o)*S/M,_=o+(m-o)*(S+1)/M;w.has(S)&&_-E>=3.2?(x(p,b,E,E+.45,y),Sn(e,c,h,l.closed,E+.45,_-.16,r.shellTop,y,s,n.shapes,o)):x(p,b,E,_-.16,y),x(p,b,_-.16,_,z(y,.62))}Sn(e,c,h,l.closed,m,d,r.shellTop,y,s,n.shapes,o);let P=8;for(let S=1;S<h.length;S++){if(P+=Math.hypot(h[S].x-h[S-1].x,h[S].y-h[S-1].y)*J,P<8)continue;P=0;let E=h[S],_=h[S-1],O=E.x-_.x,k=E.y-_.y,C=Math.max(1,Math.hypot(O,k)),A=O/C*.16*ge,L=k/C*.16*ge,F=Math.max(1,Math.hypot(E.x-t.centre.x,E.y-t.centre.y)),T=(E.x-t.centre.x)/F*.24*ge,B=(E.y-t.centre.y)/F*.24*ge,N=[{x:E.x-A,y:E.y-L},{x:E.x+A,y:E.y+L},{x:E.x+A+T,y:E.y+L+B},{x:E.x-A+T,y:E.y-L+B}];x(N,void 0,o,m,z(y,1.12))}}}function Dr(e,t,n,o){let r=new Map;for(let a of t){let f=r.get(a.blockId);(!f||a.depth<f.depth)&&r.set(a.blockId,a)}let s=[.68,.72,.72],i=[.48,.55,.57];for(let a of r.values()){if(a.y-o<2.5||a.pts.length<2)continue;let f=a.pts.map(l=>{let c=l.x-n.x,h=l.y-n.y,m=Math.max(1,Math.hypot(c,h));return{x:l.x-c/m*.65/v,y:l.y-h/m*.65/v}}),u=2;for(let l=1;l<f.length;l++){let c=f[l-1],h=f[l],m=h.x-c.x,d=h.y-c.y,p=Math.hypot(m,d);if(p<1e-5||p*v>2)continue;let b=y=>{let x=-d/p*y/v/2,M=m/p*y/v/2;return[{x:c.x+x,y:c.y+M},{x:h.x+x,y:h.y+M},{x:h.x-x,y:h.y-M},{x:c.x-x,y:c.y-M}]};W(e,b(.22),void 0,()=>a.y-.06,a.y-.56,s,s,K);for(let y of[.5,.95])W(e,b(.045),void 0,()=>a.y+y,a.y+y-.045,i,i,K);if(u+=p*v,u>=1.8||l===f.length-1){u=0;let y=.028/v,x=[{x:c.x-y,y:c.y-y},{x:c.x+y,y:c.y-y},{x:c.x+y,y:c.y+y},{x:c.x-y,y:c.y+y}];W(e,x,void 0,()=>a.y+.95-.045,a.y-.06,i,i,K)}}}}function Nr(e,t,n,o,r){let s=[.67,.71,.68];for(let i=0;i<t.length;i++){let a=t[i];if(!(a.pts.length<2))for(let f of[0,a.pts.length-1]){let u=a.pts[f],l=a.pts[f===0?1:f-1],c=u.x-l.x,h=u.y-l.y,m=Math.hypot(c,h);if(m<1e-5)continue;c/=m,h/=m;let d=1/0;for(let P=0;P<n.length;P++){let S=n[P],E=n[(P+1)%n.length],_=E.x-S.x,O=E.y-S.y,k=c*O-h*_;if(Math.abs(k)<1e-8)continue;let C=S.x-u.x,A=S.y-u.y,L=(C*O-A*_)/k,F=(C*h-A*c)/k;L>0&&F>=0&&F<=1&&(d=Math.min(d,L))}let p=.3/v,b=d-.04/v;if(!Number.isFinite(d)||d*v>2||b-p<.12/v)continue;let y=.27/v,x=[{x:u.x+c*p-h*y,y:u.y+h*p+c*y},{x:u.x+c*b-h*y,y:u.y+h*b+c*y},{x:u.x+c*b+h*y,y:u.y+h*b-c*y},{x:u.x+c*p+h*y,y:u.y+h*p-c*y}];if(!x.every(P=>pe(n,P.x,P.y)))continue;let M=r?.[i]?.belowY,I=M==null?0:a.y-M,w=!!o&&I>.03&&I<=.65;if(w&&o){let P=(S,E)=>Math.hypot((S.x+E.x)/2-o.x,(S.y+E.y)/2-o.y);P(x[0],x[1])>P(x[3],x[2])&&(x=[x[3],x[2],x[1],x[0]])}let g=w?Math.ceil((I-1e-8)/.2):1,R=(P,S,E)=>({x:P.x+(S.x-P.x)*E,y:P.y+(S.y-P.y)*E});for(let P=0;P<g;P++){let S=P/g,E=(P+1)/g,_=[R(x[0],x[3],S),R(x[1],x[2],S),R(x[1],x[2],E),R(x[0],x[3],E)],O=a.y+.008-(w?I*(1-E):0);if(W(e,_,void 0,()=>O,O-(w?I/g+.1:.16),s,[.43,.47,.46],K),!w)continue;let k=Math.hypot(_[3].x-_[0].x,_[3].y-_[0].y)*v,C=Math.min(.04/k,.25),A=R(_[0],_[3],C),L=R(_[1],_[2],C),F=B=>[B.x*v,O+.004,B.y*v],T=[.66,.59,.39];e.tri(F(_[0]),F(_[1]),F(L),[0,1,0],T),e.tri(F(_[0]),F(L),F(A),[0,1,0],T)}}}}function Gr(e,t,n,o,r,s,i,a,f=!1){if(!t.outline||t.outline.length<3)return;let u=n.baseHeightM,l=n.objects.filter(x=>x.type==="shape"&&(x.role==="entrance"||x.role==="exit")),c=Qo(o,a.tierTop);if(!r)return;let h=x=>r.deckAt(x.x,x.y),m=Ko(t,i),d=m[0]??t.outline;if(r.rowLevels.length>=2){let x=kt(r.rowLevels),M=zo(jo(r.rowLevels,n.focal,x),m);for(let w of M){let g=Math.max(u,w.topY-jr);for(let R of s.subtract(w.outline,g))Or(e,R,w.holes,g,u,a.tierTop,a.tierWall,l,!f)}M.length||W(e,d,t.holes,()=>r.landingY,u,c,a.tierWall,K);let I={tread:[c[0]*K.top,c[1]*K.top,c[2]*K.top],riser:[c[0]*.72,c[1]*.72,c[2]*.72]};for(let w of m.length?m:[d])Xo(e,r.rowLevels,n.focal,r.landingY,I,w,x);Dr(e,r.rowLevels,n.focal,u),Nr(e,r.rowLevels,t.outline,n.focal,x);return}let p=r.flat?1/0:Zo,b=x=>r.normalAt(x.x,x.y),y=r.flat?r.landingY:void 0;for(let x of s.subtract(d,y))W(e,x,t.holes,h,u,c,a.tierWall,K,p,b)}function Tc(e,t,n){let o=new Set;for(let i of e.objects)i.type==="section"&&o.add(i.id);let r=new Map;for(let i=0;i<t.length;i++){let a=n.seatOwner[i];if(!a||!o.has(a))continue;let f=n.bySection.get(a);if(f&&f.rowLevels.length>=2)continue;let u=t[i];if(u.kind==="booth")continue;let l=r.get(a);l||(l=new Map,r.set(a,l));let c=u.rowId||`__seat-${i}`,h=l.get(c);h||(h={pts:[],levelM:0,n:0},l.set(c,h)),h.pts.push({x:u.x,y:u.y}),h.levelM+=n.seatDeckY(i),h.n++}let s=[];for(let i of e.objects){if(i.type!=="section")continue;let a=n.bySection.get(i.id);if(a&&a.rowLevels.length>=2){let u=a.rowLevels.filter(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));u.length>=2&&s.push({sectionId:i.id,rows:u});continue}let f=r.get(i.id);f&&s.push({sectionId:i.id,rows:[...f.values()].map(u=>({pts:u.pts,levelM:u.levelM/u.n}))})}return s}function Lc(e,t){let n=1/0;for(let o=0;o<t.length;o++){let r=t[o],s=t[(o+1)%t.length],i=s.x-r.x,a=s.y-r.y,f=Math.max(0,Math.min(1,((e.x-r.x)*i+(e.y-r.y)*a)/(i*i+a*a||1)));n=Math.min(n,Math.hypot(e.x-r.x-f*i,e.y-r.y-f*a))}return n}var jr=.02;function Oc(e,t){let n=e.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=t.bySection.get(o.id);if(!r)return[];let s=1/0,i=-1/0,a=1/0,f=-1/0;for(let l of o.outline)l.x<s&&(s=l.x),l.x>i&&(i=l.x),l.y<a&&(a=l.y),l.y>f&&(f=l.y);let u=r.landingY;for(let l of r.rowLevels)u=Math.min(u,l.y-jr);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:u,minX:s,maxX:i,minY:a,maxY:f}]});return(o,r,s)=>{let i=null;for(let a of n){if(o<a.minX-s||o>a.maxX+s||r<a.minY-s||r>a.maxY+s)continue;let f={x:o,y:r};if(!me(f,a.outline,a.holes)&&Lc(f,a.outline)>s)continue;let u=Math.min(a.surface.deckAt(o,r),a.floorTop);(i===null||u<i)&&(i=u)}return i}}var Bc=3,Fc=.4;function Hr(e,t,n,o,r,s,i=!0){let a=Tc(t,n,o);if(a.length<Bc)return;let f=_r(a,t.focal);if(!f)return;let u=Math.max(0,...f.rings.map(l=>l.arcs.reduce((c,h)=>c+h.binCount,0)))/f.binCount;e.setMaterial(5),Fr(e,f,{bottomY:t.baseHeightM,tierFrontLevels:a.map(l=>Math.min(...l.rows.map(c=>c.levelM))),colors:{bandTop:z(r.tierTop,.8),bandWall:r.tierWall,shellTop:s??z(r.tierWall,1.15),shellWall:s??r.tierWall},ao:K,shapes:t.objects.filter(l=>l.type==="shape"),deriveShell:i&&u>=Fc,standTopNear:Oc(t,o)}),e.setMaterial(0)}var Xr=4;var Dc=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"]];function Nc(e){if(!e)return null;for(let[t,n]of Dc)if(t.test(e))return n;return null}var Yr="auto-rows-";function Kr(e){return e.id.startsWith(Yr)&&!e.label}var Gc=1.15,jc=.09,Hc=6,Xc=34,Uc=.35,Vc=6,Yc=.35,Kc=.75,zc=12,Wc=2.5,Zc=40,Ur=[18,24],$c=.8,Qc=.6,qc=5,Jc=.3,zr=.4,el=2,tl=400,nl=2.6,ol=1.6,rl=6e3,il=.6,sl="#c3c7cd",Vr=300,al=240;function cl(e,t,n,o){if(!e.fill||!/^#[0-9a-f]{6}$/i.test(e.fill))return null;let r=Rn([...t]),s=new Set;for(let l of o)s.add(Math.floor(Math.atan2(l.y-r.y,l.x-r.x)*180/Math.PI/10));if(s.size*10<al)return null;let{h:i,s:a,l:f}=po(ho(e.fill));return i<70/360||i>170/360||a<.2||f<.08||f>.75||n.some(l=>l!==e&&l.type==="shape"&&ae(l)?.some(c=>En(c,t)))?null:e.kind==="ellipse"?"oval-cricket":e.kind==="rect"?"pitch-football":null}var ll="Estimated from the drawing; confirm with the venue.",Wr=e=>{if(!e.length)return null;let t=[...e].sort((o,r)=>o-r),n=Math.floor(t.length/2);return t.length%2?t[n]:(t[n-1]+t[n])/2},Rn=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length}),wn=e=>{let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2};function ul(e){return e.height!==void 0||e.rake!==void 0||e.elevation!==void 0||e.surfaceKind!==void 0}function vn(e){let t=new Map;for(let n of e){let o=t.get(n.rowId);o?o.push(n):t.set(n.rowId,[n])}return t}function En(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let s=t[o],i=t[r];s.y>e.y!=i.y>e.y&&e.x<(i.x-s.x)*(e.y-s.y)/(i.y-s.y)+s.x&&(n=!n)}return n}function Cn(e,t){let n=t[0],o=1/0;for(let r=0;r<t.length;r++){let s=t[r],i=t[(r+1)%t.length],a=i.x-s.x,f=i.y-s.y,u=a*a+f*f,l=u>0?Math.max(0,Math.min(1,((e.x-s.x)*a+(e.y-s.y)*f)/u)):0,c={x:s.x+a*l,y:s.y+f*l},h=Math.hypot(e.x-c.x,e.y-c.y);h<o&&(o=h,n=c)}return n}function Zr(e,t){let n=0,o=0;for(let r of e.values()){if(r.length<3)continue;let s=r[0],i=r[r.length-1],a=i.x-s.x,f=i.y-s.y,u=Math.hypot(a,f);if(u<1e-6)continue;let l={x:(s.x+i.x)/2,y:(s.y+i.y)/2},c=Cn(l,t),h=c.x-l.x,m=c.y-l.y,d=Math.hypot(h,m);d<1e-6||(o+=Math.abs((-f*h+a*m)/(u*d))*r.length,n+=r.length)}return n?o/n:0}function fl(e,t,n){let o=e.filter(p=>p.type==="shape"),r=o.find(p=>p.role==="stage");if(r){let p=ae(r);return p?{shape:r,centre:Rn(p),outline:p,inferred:!1}:null}if(!n.length)return null;let s=1/0,i=-1/0,a=1/0,f=-1/0;for(let p of n)s=Math.min(s,p.x),i=Math.max(i,p.x),a=Math.min(a,p.y),f=Math.max(f,p.y);let u=(i-s)*(f-a),l=[];for(let p of o){if(p.role)continue;let b=ae(p);if(!b)continue;let y=wn(b);if(y*J*J<6||y>u)continue;let x=Math.min(...b.map(S=>S.x)),M=Math.max(...b.map(S=>S.x)),I=Math.min(...b.map(S=>S.y)),w=Math.max(...b.map(S=>S.y)),g=0;for(let S of n)S.x>x&&S.x<M&&S.y>I&&S.y<w&&En(S,b)&&g++;if(g>n.length*.05)continue;let R=Rn(b),P=Zr(t,b);P>=$c&&l.push({shape:p,centre:R,outline:b,score:P,area:y,box:[x,I,M,w]})}let c=(p,b)=>b!==p&&b.area>p.area&&p.box[0]>=b.box[0]-1e-6&&p.box[1]>=b.box[1]-1e-6&&p.box[2]<=b.box[2]+1e-6&&p.box[3]<=b.box[3]+1e-6,h=l.filter(p=>!l.some(b=>c(p,b))),m=Math.max(0,...h.map(p=>p.score)),d=h.filter(p=>p.score>=m-.03).sort((p,b)=>b.area-p.area)[0]??null;return d?{shape:d.shape,centre:d.centre,outline:d.outline,inferred:!0}:null}function ml(e,t,n){if(!n||n.length<3)return Math.hypot(e.x-t.x,e.y-t.y);let o=Cn(e,n);return Math.hypot(e.x-o.x,e.y-o.y)}function $r(e){let t=[...e].sort((s,i)=>s.x-i.x||s.y-i.y);if(t.length<3)return t;let n=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),o=[];for(let s of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],s)<=0;)o.pop();o.push(s)}let r=[];for(let s=t.length-1;s>=0;s--){let i=t[s];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],i)<=0;)r.pop();r.push(i)}return[...o.slice(0,-1),...r.slice(0,-1)]}function hl(e){if(!e.length||e.length>rl)return[];let t=[...vn(e).values()],n=t.map((a,f)=>f),o=a=>n[a]===a?a:n[a]=o(n[a]),r=ol/J,s=t.map(a=>({minX:Math.min(...a.map(f=>f.x))-r,maxX:Math.max(...a.map(f=>f.x))+r,minY:Math.min(...a.map(f=>f.y))-r,maxY:Math.max(...a.map(f=>f.y))+r}));for(let a=0;a<t.length;a++)for(let f=a+1;f<t.length;f++){let u=s[a],l=s[f];if(u.maxX<l.minX||l.maxX<u.minX||u.maxY<l.minY||l.maxY<u.minY)continue;t[a].some(h=>t[f].some(m=>Math.hypot(h.x-m.x,h.y-m.y)<=r))&&(n[o(a)]=o(f))}let i=new Map;return t.forEach((a,f)=>{let u=o(f),l=i.get(u);l?l.push(...a):i.set(u,[...a])}),[...i.values()].filter(a=>new Set(a.map(f=>f.rowId)).size>=2)}function dl(e,t,n){if(!t.length)return null;let o=t.filter(P=>n.tableIds.has(P.rowId)||P.kind==="booth").length>t.length/2,r=vn(t),s=!n.outline||Zr(r,n.outline)>=Qc,i=0,a=0;for(let P of r.values()){if(P.length<2)continue;let S=P[0],E=P[P.length-1],_=E.x-S.x,O=E.y-S.y,k=Math.hypot(_,O);if(k<1e-6)continue;let C={x:(S.x+E.x)/2,y:(S.y+E.y)/2},A=s?n.outline?Cn(C,n.outline):n.focal:n.middle,L=-O/k,F=_/k;L*(A.x-C.x)+F*(A.y-C.y)<0&&(L=-L,F=-F),i+=L*P.length,a+=F*P.length}let f={x:t.reduce((P,S)=>P+S.x,0)/t.length,y:t.reduce((P,S)=>P+S.y,0)/t.length};if(Math.hypot(i,a)<1e-9){let P=s?n.focal:n.middle;i=P.x-f.x,a=P.y-f.y}let u=Math.hypot(i,a)||1,l={x:i/u,y:a/u},c=P=>-(P.x*l.x+P.y*l.y),h=P=>-P.x*l.y+P.y*l.x,m=1/0,d=-1/0,p=1/0,b=-1/0,y=1/0,x=new Map;for(let P of t){let S=c(P),E=h(P);m=Math.min(m,S),d=Math.max(d,S),p=Math.min(p,E),b=Math.max(b,E),s&&(y=Math.min(y,ml(P,n.focal,n.outline)));let _=P.logicalRowId??P.rowId,O=x.get(_);O?O.push(S):x.set(_,[S])}s||(y=Math.max(0,m-c(n.middle)));let M=[...x.values()].map(P=>Wr(P)).sort((P,S)=>P-S),I=[];if(!o)for(let P of M)I.length&&P-I[I.length-1]<Yc/J||I.push(P);let w=ul(e),g=De(e,{floorBaseHeightM:n.baseHeightM}),R={id:e.id,section:e,authored:w,plane:n,facing:l,facesAction:s,hull:$r(t),sample:t.filter((P,S)=>S%Math.ceil(t.length/tl)===0),frontD:m,backD:d,latMin:p,latMax:b,frontDistance:y,rowDepths:I,rowCount:I.length,level:0,height:g.height,rake:w?g.rake:0,backHeight:0};return R.backHeight=R.height+(d-m)*J*Math.tan(R.rake*Math.PI/180),R}function pl(e,t,n,o){if(e.length<2)return 0;let r=Math.max(1,t*J),s=n+Gc-o,i=0,a=0;for(let u=1;u<e.length;u++){let l=Math.max(Kc,(e[u]-e[u-1])*J),c=(s+jc)*(r+l)/r;i+=c-s,a+=l,s=c,r+=l}let f=Math.atan(i/a)*180/Math.PI;return Math.round(Math.max(Hc,Math.min(Xc,f))*10)/10}function bl(e,t){if(e.facing.x*t.facing.x+e.facing.y*t.facing.y<Jc)return null;let n=-1/0,o=1/0,r=-1/0;for(let c of t.hull){n=Math.max(n,-(c.x*e.facing.x+c.y*e.facing.y));let h=-c.x*e.facing.y+c.y*e.facing.x;o=Math.min(o,h),r=Math.max(r,h)}if(Math.min(e.latMax,r)-Math.max(e.latMin,o)<zr*(e.latMax-e.latMin))return null;let i=el/J,a=new Map,f=new Map;for(let c of e.sample){let h=Math.floor((-c.x*e.facing.y+c.y*e.facing.x)/i),m=-(c.x*e.facing.x+c.y*e.facing.y);a.set(h,Math.min(a.get(h)??1/0,m))}for(let c of t.sample){let h=Math.floor((-c.x*e.facing.y+c.y*e.facing.x)/i),m=-(c.x*e.facing.x+c.y*e.facing.y);f.set(h,Math.max(f.get(h)??-1/0,m))}let u=[];for(let[c,h]of a){let m=f.get(c);m!==void 0&&u.push(h-m)}let l=u.length?Wr(u):e.frontD-n;return l<-1/J?null:l}function yl(e,t){if(t.plane.floorIndex>=e.plane.floorIndex)return!1;let n=-1/0,o=1/0,r=1/0,s=-1/0;for(let f of t.hull){let u=-(f.x*e.facing.x+f.y*e.facing.y);n=Math.max(n,u),o=Math.min(o,u);let l=-f.x*e.facing.y+f.y*e.facing.x;r=Math.min(r,l),s=Math.max(s,l)}let i=Math.min(e.latMax,s)-Math.max(e.latMin,r),a=Math.min(e.backD,n)-Math.max(e.frontD,o);return i>zr*(e.latMax-e.latMin)&&a>1/J}function xl(e){let t=new Map,n=[...e].sort((i,a)=>i.plane.floorIndex-a.plane.floorIndex||i.frontDistance-a.frontDistance),o=[],r=new Map,s=i=>{if(i.plane.floorIndex===0||i.plane.baseHeightM>0)return i.plane.baseHeightM;let a=r.get(i.plane.floorIndex-1);return a===void 0?i.plane.baseHeightM:a+Xr};for(let i of n){if(!i.authored){let f=s(i),u;for(let c of o){if(c.plane.floorIndex>i.plane.floorIndex)continue;if(yl(i,c)){let d=c.backHeight+nl;d>f&&(f=d,u=c);continue}let h=bl(i,c);if(h==null)continue;let m=c.backHeight+Uc+Math.min(Vc,Math.max(0,h)*J)*Math.tan(c.rake*Math.PI/180);m>f&&(f=m,u=c)}i.height=Math.round(Math.min(f,i.plane.baseHeightM+Zc)*100)/100;let l=!u&&i.height>i.plane.baseHeightM;if(i.level=u?u.level+1:l?1:0,i.rake=pl(i.rowDepths,i.frontDistance,i.height,i.plane.focalHeightM),!i.facesAction&&i.rowCount<qc)i.rake=0;else if(!u&&!l){let c=Math.max(1e-6,(i.backD-i.frontD)*J);i.rake=Math.min(i.rake,zc,Math.round(Math.atan(Wc/c)*1800/Math.PI)/10)}else i.rowCount>=2&&(i.rake=Math.max(i.rake,Ur[Math.min(i.level,Ur.length)-1]));i.backHeight=i.height+(i.backD-i.frontD)*J*Math.tan(i.rake*Math.PI/180),t.set(i.id,u?.id)}let a=i.plane.floorIndex;r.set(a,Math.min(r.get(a)??1/0,i.height)),o.push(i)}return t}var Pn=(e,t)=>!!e&&e.x===t.x&&e.y===t.y;function Qr(e,t={x:0,y:-40}){let n=$e(e),o=new Map;for(let d of n){if(!d.sectionId)continue;let p=o.get(d.sectionId);p?p.push(d):o.set(d.sectionId,[d])}let r={focalInferred:!1,confident:!1,sections:[]},s=e.floors?.length?e.floors.map((d,p)=>({objects:d.objects,floorIndex:p,floorId:d.id,baseHeightM:d.baseHeightM??0,focal:d.focalPoint??e.focalPoint})):[{objects:e.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:e.focalPoint}],i=new Set(s.flatMap(d=>d.objects.filter(p=>p.type==="table").map(p=>p.id))),a=[],f,u=new Set,l=s.map(d=>{let p=E=>!e.floors?.length||E.floorId===d.floorId,b=hl(n.filter(E=>!E.sectionId&&E.kind!=="booth"&&!i.has(E.rowId)&&p(E))),y=[];for(let E of b){let _=Ie(Ce($r(E)),il/J);if(n.some(k=>!p(k)&&En(k,_)))continue;let O=`${Yr}${d.floorIndex}-${y.length}`;u.add(O),o.set(O,E),y.push({type:"section",id:O,label:"",color:sl,outline:_})}let x=y.length?{...d,objects:[...d.objects,...y]}:d,M=new Set(x.objects.filter(E=>E.type==="section").map(E=>E.logicalSectionId??E.id)),I=[...o.entries()].filter(([E])=>M.has(E)).flatMap(([,E])=>E),w=fl(x.objects,vn(I),I),g=x.focal;(w||x.focal&&!Pn(x.focal,t))&&(r.confident=!0),w&&(r.stage??={id:w.shape.id,inferred:w.inferred,...x.floorId?{floorId:x.floorId}:{}},(w.inferred||Pn(x.focal,t))&&(g=w.centre,r.focalInferred=!0));let R=w&&(!w.inferred||wn(w.outline)*J*J<=Vr),P=w?void 0:f,S={tableIds:i,floorIndex:x.floorIndex,floorId:x.floorId,baseHeightM:x.baseHeightM,focal:P?.focal??g,outline:w?.outline??P?.outline,focalHeightM:P?.focalHeightM??x.baseHeightM+(w&&R?Pe({...w.shape,role:"stage"}).heightM:0),middle:I.length?{x:I.reduce((E,_)=>E+_.x,0)/I.length,y:I.reduce((E,_)=>E+_.y,0)/I.length}:g};for(let E of x.objects){if(E.type!=="section")continue;let _=dl(E,o.get(E.logicalSectionId??E.id)??[],S);_&&a.push(_)}return S.outline&&(f=S),Pn(x.focal,S.focal)||(r.focal??=[]).push({...x.floorId?{floorId:x.floorId}:{},point:{...S.focal}}),{unit:x,plane:S,stage:w,planeSeats:I}}),c=xl(a),h=new Map(a.filter(d=>!d.authored).map(d=>[d.id,d])),m=l.map(({unit:d,plane:p,stage:b,planeSeats:y})=>d.objects.map(x=>{let M=x.type==="shape"&&!x.role&&x.id!==b?.shape.id?Nc(x.label):null;if(M&&x.type==="shape")return(r.roles??=[]).push({id:x.id,...p.floorId?{floorId:p.floorId}:{},role:M}),{...x,role:M};let I=b?.inferred&&x.id===b.shape.id&&x.type==="shape"?cl(x,b.outline,d.objects,y):null;if(I&&x.type==="shape")return r.stage?.id===x.id&&(r.stage.field=I),{...x,role:"stage",stageKind:I};if(b?.inferred&&x.id===b.shape.id&&x.type==="shape"&&wn(b.outline)*J*J<=Vr)return r.stage?.id===x.id&&(r.stage.deck=!0),{...x,role:"stage"};let w=x.type==="section"?h.get(x.id):void 0;if(!w||x.type!=="section")return x;let g=w.rowCount>=2&&w.rake>0;u.has(w.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:w.id,floorId:p.floorId,surfaceKind:g?"rakedRows":"flat",height:w.height,rake:w.rake,stackedOn:c.get(w.id)});let R={status:"inferred",source:"public-2d-topology",note:ll};return{...x,height:w.height,rake:w.rake,surfaceKind:g?"rakedRows":"flat",physical3dProvenance:{height:R,rake:R,surfaceKind:R}}}));if(e.floors?.length){let d=e.floors.map((p,b)=>({...p,objects:m[b],focalPoint:l[b].plane.focal}));return{doc:{...e,floors:d,objects:d[0].objects,focalPoint:d[0].focalPoint},report:r}}return{doc:{...e,objects:m[0],focalPoint:l[0].plane.focal},report:r}}var qr=/^[\p{L}\p{N}]{1,4}$/u,gl=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function Jr(e,t){let n=t?.trim();if(!n)return e;let o=e.toLocaleLowerCase("en-US"),r=n.toLocaleLowerCase("en-US");if(o.startsWith(`${r} `)){let i=e.slice(n.length).trim();if(qr.test(i))return i}let s=gl.exec(e);if(s){let i=s[1].toLocaleLowerCase("en-US"),a=s[2].trim();if((r.startsWith(i)||i.startsWith(r))&&qr.test(a))return a}return e}var Ml=6,Sl=2.2,ei=.1,Il=.3,Pl=1.8,Rl=.9,wl=.55,vl=6e3;function ni(e){let{doc:t,units:n,seats:o,surfaces:r,focal:s}=e,i=t.zones??[],a=[];if(i.length){let f=new Map;for(let l of n)for(let c of l.objects)c.type==="section"&&c.zone&&f.set(c.id,c.zone);let u=new Map;for(let l=0;l<o.length;l++){let c=o[l],h=r.seatOwner[l],m=c.zoneId??(h?f.get(h):void 0);if(!m)continue;let d=u.get(m);d||(d={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},u.set(m,d)),d.n++,c.x<d.minX&&(d.minX=c.x),c.y<d.minY&&(d.minY=c.y),c.x>d.maxX&&(d.maxX=c.x),c.y>d.maxY&&(d.maxY=c.y),d.sumY+=r.seatDeckY(l)}for(let l of i){let c=u.get(l.id),h=[];for(let[m,d]of f)d===l.id&&h.push(m);if(!c||c.n===0){a.push({id:l.id,label:l.label,color:oe(l.color),sectionIds:h,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(l.focalPoint??s).x*v,1.5,(l.focalPoint??s).y*v]});continue}a.push({id:l.id,label:l.label,color:oe(l.color),sectionIds:h,seatCount:c.n,center:[(c.minX+c.maxX)/2*v,c.sumY/c.n,(c.minY+c.maxY)/2*v],radius:.5*Math.hypot((c.maxX-c.minX)*v,(c.maxY-c.minY)*v)||1,focalWorld:[(l.focalPoint??s).x*v,1.5,(l.focalPoint??s).y*v]})}}return a}function oi(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:s,hintedSeatFloor:i,zones:a,focal:f}=e,u=[],l=[],c=[];for(let h of a)h.seatCount!==0&&u.push({id:`zone:${h.id}`,kind:"zone",text:h.label,anchor:[h.center[0],h.center[1]+Ml,h.center[2]],color:t.zones?.find(m=>m.id===h.id)?.color});{let h=new Map,m=new Map;for(let d=0;d<o.length;d++){let p=r.seatOwner[d];if(!p)continue;let b=h.get(p);b||(b={n:0,x:0,y:0,deck:0},h.set(p,b)),b.n++,b.x+=o[d].x,b.y+=o[d].y,b.deck+=r.seatDeckY(d);let y=m.get(p);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},m.set(p,y)),y.minDeck=Math.min(y.minDeck,r.seatDeckY(d)),y.maxDeck=Math.max(y.maxDeck,r.seatDeckY(d)),o[d].x<y.minX&&(y.minX=o[d].x),o[d].x>y.maxX&&(y.maxX=o[d].x),o[d].y<y.minY&&(y.minY=o[d].y),o[d].y>y.maxY&&(y.maxY=o[d].y)}for(let d of n)for(let p of d.objects){if(p.type!=="section"||Kr(p))continue;let b=h.get(p.id);if(!b||b.n===0)continue;let y=m.get(p.id),x=[b.x/b.n*v,b.deck/b.n,b.y/b.n*v],M=p.displayLabel||p.label||p.id;l.push({id:p.id,floorIndex:d.index,label:M,seatCount:b.n,center:x,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*v),box:{min:[y.minX*v-.4,y.minDeck,y.minY*v-.4],max:[y.maxX*v+.4,y.maxDeck+1,y.maxY*v+.4]},focalWorld:[d.focal.x*v,d.baseHeightM+1.5,d.focal.y*v]});let I=t.floors?.[d.index]?.name?.trim().toLocaleLowerCase();n.length>1&&I===M.trim().toLocaleLowerCase()||u.push({id:`section:${p.id}`,kind:"section",text:M,anchor:[x[0],x[1]+Sl,x[2]],floorIndex:d.index})}}{for(let b of n)for(let y of b.objects){if(y.type!=="gaArea")continue;let x=it(y.points);if(!x)continue;let M=y.displayLabel||y.label||y.id;u.push({id:`ga:${y.id}`,kind:"ga",text:y.capacity>0?`${M} \xB7 ${y.capacity.toLocaleString()}`:M,anchor:[x.x*v,b.baseHeightM+Pl,x.y*v],floorIndex:b.index})}let h=new Map,m=new Map;for(let b of n)for(let y of b.objects)if(y.type==="section"&&h.set(y.id,y.displayLabel||y.label||y.id),y.type==="row"){let x=y.displayLabel?.trim()||y.segmentedRow?.displayLabel?.trim();x&&m.set(y.id,x)}let d=new Map;for(let b=0;b<o.length;b++){let y=o[b],x=Math.hypot(y.x-f.x,y.y-f.y),M=d.get(y.rowId);(!M||x>M.far)&&d.set(y.rowId,{seat:y,index:b,far:x})}for(let[b,y]of d){let x=r.seatOwner[y.index]??y.seat.sectionId,M=ti(y.seat.label,b,h.get(x??""),m.get(b));M&&u.push({id:`row:${b}`,kind:"row",text:M,anchor:[y.seat.x*v,r.seatDeckY(y.index)+Rl,y.seat.y*v],floorIndex:i[y.index]})}let p=new Map;for(let b=0;b<o.length;b++){let y=o[b],x=p.get(y.rowId);x||(x={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:ti(y.label,y.rowId,h.get(r.seatOwner[b]??y.sectionId??""),m.get(y.rowId)),sectionId:r.seatOwner[b]??y.sectionId},p.set(y.rowId,x));let M=b*3,I=s.iPosition[M],w=s.iPosition[M+1],g=s.iPosition[M+2];x.n++,x.x+=I,x.y+=w,x.z+=g,x.minX=Math.min(x.minX,I),x.maxX=Math.max(x.maxX,I),x.minZ=Math.min(x.minZ,g),x.maxZ=Math.max(x.maxZ,g)}for(let[b,y]of p)c.push({id:b,label:y.label,sectionId:y.sectionId,seatCount:y.n,center:[y.x/y.n,y.y/y.n,y.z/y.n],radius:Math.max(.8,Math.hypot(y.maxX-y.minX,y.maxZ-y.minZ)*.5)});if(o.length<=vl)for(let b=0;b<o.length;b++){let y=o[b],x=El(y.displayLabel||y.label);x&&u.push({id:`seat:${y.id}`,kind:"seat",seatWidthM:s.iChairWidth[b]*2,text:x,anchor:[y.x*v,r.seatDeckY(b)+wl,y.y*v],floorIndex:i[b]})}}for(let h of n)for(let m of h.objects)if(m.type==="shape"&&m.role&&["entrance","exit","screen","suite","obstruction"].includes(m.role)){let d=ae(m),p=d?it(d):null;if(!p||!m.label)continue;u.push({id:`architecture:${m.id}`,kind:"annotation",text:m.label,anchor:[p.x*v,h.baseHeightM+Pe(m).heightM+ei,p.y*v],color:m.fill,floorIndex:h.index})}else if(m.type==="text"){if(!m.text)continue;u.push({id:`text:${m.id}`,kind:"annotation",text:m.text,anchor:[m.position.x*v,h.baseHeightM+ei,m.position.y*v],color:m.color,rotation:m.rotation,floorIndex:h.index})}else if(m.type==="booth"){let d=_e(m);if(!d)continue;let p=it(d);if(!p)continue;u.push({id:`booth:${m.id}`,kind:"booth",text:m.displayLabel||m.label||m.id,anchor:[p.x*v,h.baseHeightM+jt+Il,p.y*v],floorIndex:h.index})}return{labels:u,sections:l,rows:c}}function ri(e,t){if(t.length>1)for(let n of t)e.push({id:`floor:${n.id}`,kind:"floor",text:n.label,anchor:[n.center[0],n.box.max[1]+1.2,n.center[2]],floorIndex:n.index})}function El(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function ti(e,t,n,o){if(o?.trim())return o.trim();let r=e?e.lastIndexOf("-"):-1,s=r>0?e.slice(0,r):t;return s&&Jr(s,n)}function ii(e){let{doc:t,units:n,seats:o,surfaces:r,solids:s,hintedSeatFloor:i,seatFloor:a}=e,f=[];{let u=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let h=0;h<s.floor.length;h+=1){let m=Math.max(0,Math.min(n.length-1,Math.round(s.floor[h]))),d=h*3,p=u[m];p.minX=Math.min(p.minX,s.position[d]),p.minY=Math.min(p.minY,s.position[d+1]),p.minZ=Math.min(p.minZ,s.position[d+2]),p.maxX=Math.max(p.maxX,s.position[d]),p.maxY=Math.max(p.maxY,s.position[d+1]),p.maxZ=Math.max(p.maxZ,s.position[d+2])}let l=new Map;for(let h=0;h<n.length;h++)for(let m of n[h].objects)m.type==="section"&&l.set(m.id,h);let c=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let h=0;h<o.length;h++){let m=r.seatOwner[h],d=(m!==null?l.get(m):void 0)??i[h];if(d===void 0)continue;let p=c[d],b=o[h];p.n++,b.x<p.minX&&(p.minX=b.x),b.y<p.minY&&(p.minY=b.y),b.x>p.maxX&&(p.maxX=b.x),b.y>p.maxY&&(p.maxY=b.y);let y=r.seatDeckY(h);p.sumX+=b.x*v,p.sumDeck+=y,p.sumZ+=b.y*v,p.minDeck=Math.min(p.minDeck,y),p.maxDeck=Math.max(p.maxDeck,y+1.6),a[h]=d}for(let h=0;h<n.length;h++){let m=c[h],d=t.floors?.[h],p=u[h],b=Math.min(m.n?m.minX*v:n[h].focal.x*v-1,Number.isFinite(p.minX)?p.minX:1/0),y=Math.max(m.n?m.maxX*v:n[h].focal.x*v+1,Number.isFinite(p.maxX)?p.maxX:-1/0),x=Math.min(m.n?m.minY*v:n[h].focal.y*v-1,Number.isFinite(p.minZ)?p.minZ:1/0),M=Math.max(m.n?m.maxY*v:n[h].focal.y*v+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),I=Math.min(m.n?Math.min(n[h].baseHeightM,m.minDeck):n[h].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),w=Math.max(m.n?Math.max(m.maxDeck,I+.5):I+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),g=[m.n?m.sumX/m.n:(b+y)/2,m.n?m.sumDeck/m.n:(I+w)/2,m.n?m.sumZ/m.n:(x+M)/2],R=Math.max(1,.5*Math.hypot(y-b,w-I,M-x));f.push({index:h,id:d?.id??`floor-${h}`,label:d?.name??(n.length>1?`Floor ${h+1}`:"Venue"),seatCount:m.n,center:g,radius:R,box:{min:[b,I,x],max:[y,w,M]},focalWorld:[n[h].focal.x*v,n[h].baseHeightM+1.5,n[h].focal.y*v]})}}return f}function An(e){if(e.length<3)return e.map(s=>({...s}));let t=[...e].sort((s,i)=>s.x-i.x||s.y-i.y),n=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),o=s=>{let i=[];for(let a of s){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),i},r=[...o(t),...o([...t].reverse())];return r.length>=3?r.map(s=>({...s})):t.map(s=>({...s}))}function _n(e,t){let n=1/0,o=1/0,r=-1/0,s=-1/0,i=(a,f)=>{a<n&&(n=a),f<o&&(o=f),a>r&&(r=a),f>s&&(s=f)};for(let a of t)i(a.x,a.y);for(let a of e)for(let f of a.objects)if(f.type==="section")for(let u of f.outline)i(u.x,u.y);else if(f.type==="shape"&&f.points)for(let u of f.points)i(u.x,u.y);else if(f.type==="gaArea")for(let u of f.points)i(u.x,u.y);else if(f.type==="booth"){let u=_e(f);if(u)for(let l of u)i(l.x,l.y)}else if(f.type==="table"){let u=Ht(f);if(u)for(let l of u)i(l.x,l.y)}else if(f.type==="decorImage"){let u=Xt(f);if(u)for(let l of u)i(l.x,l.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,s=100),{minX:n,minY:o,maxX:r,maxY:s}}function ui(e,t,n,o,r,s,i){if(t.length===1){let a=n.map(h=>({x:h.x,y:h.y}));for(let h of t[0].objects)h.type==="section"?a.push(...h.outline):h.type==="shape"?a.push(...ae(h)??h.points??[]):h.type==="gaArea"?a.push(...h.points):h.type==="booth"?a.push(..._e(h)??[]):h.type==="table"?a.push(...Ht(h)??[]):h.type==="decorImage"&&a.push(...Xt(h)??[]);if(li(e,t[0],n,a,s))return!1;if(i&&ai(e,t[0].baseHeightM,a,s,i))return!0;let f=An(a),u=(r.minX+r.maxX)/2,l=(r.minY+r.maxY)/2,c=f.length>=3?f.map(h=>{let m=h.x-u,d=h.y-l,p=Math.max(1,Math.hypot(m,d));return{x:h.x+m/p*80,y:h.y+d/p*80}}):ft(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return W(e,c,void 0,()=>-.04,-.22,s.ground,s.ground,K),!1}else{let a=t.reduce((b,y)=>y.baseHeightM<b.baseHeightM?y:b);e.setFloor(a.index);let f={...a,objects:t.flatMap(b=>b.objects)},u=n.map(b=>({x:b.x,y:b.y}));for(let b of f.objects)b.type==="section"&&u.push(...b.outline);if(li(e,f,n,u,s))return!1;if(i&&ai(e,a.baseHeightM,u,s,i))return!0;let l=n.filter((b,y)=>o[y]===a.index),c=_n([a],l),h=Math.hypot(c.maxX-c.minX,c.maxY-c.minY),m=Math.max(28,Math.min(80,h*.04)),d=ft(c.minX-m,c.minY-m,c.maxX-c.minX+m*2,c.maxY-c.minY+m*2),p=a.baseHeightM-.03;return W(e,d,void 0,()=>p,p-.22,s.ground,s.ground,K),!1}}function kn(e,t,n,o){let{cx:r,cz:s,radius:i}=n,a=1/0,f=1/0,u=1/0,l=-1/0,c=-1/0,h=-1/0,m=(b,y,x)=>{a=Math.min(a,b),l=Math.max(l,b),f=Math.min(f,y),c=Math.max(c,y),u=Math.min(u,x),h=Math.max(h,x)};for(let b=0;b<e.position.length;b+=3){let y=b/3;o&&y>=o[0]&&y<o[1]||m(e.position[b],e.position[b+1],e.position[b+2])}for(let b=0;b<t.count;b++){let y=b*3,x=t.iPosition[y],M=t.iPosition[y+1],I=t.iPosition[y+2],w=Math.max(.35,t.iMaxRadius[b]??.35);m(x-w,M,I-w),m(x+w,M+1.6,I+w)}Number.isFinite(a)||(a=r-i,l=r+i,f=0,c=i*.16,u=s-i,h=s+i);let d=[(a+l)/2,(f+c)/2,(u+h)/2],p=Math.max(1,.5*Math.hypot(l-a,c-f,h-u));return{center:d,radius:p,minY:f,maxY:c}}function fi(e,t,n,o,r,s){let i=1/0,a=1/0,f=-1/0,u=-1/0;for(let I=0;I<e.count;I++){let w=I*3,g=e.iPosition[w],R=e.iPosition[w+2];g<i&&(i=g),g>f&&(f=g),R<a&&(a=R),R>u&&(u=R)}for(let I of t)i=Math.min(i,I.cx-I.halfX),f=Math.max(f,I.cx+I.halfX),a=Math.min(a,I.cz-I.halfZ),u=Math.max(u,I.cz+I.halfZ);let l=n.minX*v,c=n.maxX*v,h=n.minY*v,m=n.maxY*v,d=l,p=c,b=h,y=m;if(Number.isFinite(i)){let I=Math.max(2,.06*Math.hypot(f-i,u-a));d=Math.max(l,i-I),p=Math.min(c,f+I),b=Math.max(h,a-I),y=Math.min(m,u+I)}let x=Math.min(0,o),M=Math.max(r,s*.05);return{min:[d,x,b],max:[p,M,y]}}var si=12,Cl=.6,Al=40;function ai(e,t,n,o,r){let s=An([...n]);if(s.length<3)return!1;let i=1/0,a=1/0,f=-1/0,u=-1/0;for(let I of s)i=Math.min(i,I.x),f=Math.max(f,I.x),a=Math.min(a,I.y),u=Math.max(u,I.y);let l=Math.hypot(f-i,u-a)*v,c=Ie(s,si/v,1.2),h=Math.max(Al,l*Cl),m=Ie(s,(si+h)/v,1.2);if(c.length!==m.length)return!1;let d=re(o.ground,[.78,.76,.72],.35),p=re(o.ground,[.56,.62,.52],.3);W(e,c,void 0,()=>t-.04,t-.22,d,d,K);let b=t-.05,y=c.map(I=>[I.x*v,b,I.y*v]),x=m.map(I=>[I.x*v,b,I.y*v]),M=[0,1,0];for(let I=0;I<y.length;I++){let w=(I+1)%y.length;e.tri(y[I],x[w],x[I],M,p,r,r),e.tri(y[I],y[w],x[w],M,p,p,r)}return!0}var _l=3e3,kl=20,ci=1.5,Tl=1.2,Ll=.25;function li(e,t,n,o,r){if(!n.length||n.length>_l||o.length<3)return!1;for(let S of t.objects){if(S.type==="shape"&&Kn(S.stageKind))return!1;if(S.type==="section"){let{height:E}=De(S,{floorBaseHeightM:t.baseHeightM});if(E-t.baseHeightM>kl)return!1}}let s=0,i=0;for(let S of o)s+=S.x,i+=S.y;s/=o.length,i/=o.length;let a=0,f=0,u=0;for(let S of o){let E=S.x-s,_=S.y-i;a+=E*E,f+=_*_,u+=E*_}let l=.5*Math.atan2(2*u,a-f),c=Math.cos(l),h=Math.sin(l),m=-h,d=c,p=1/0,b=-1/0,y=1/0,x=-1/0;for(let S of o){let E=(S.x-s)*c+(S.y-i)*h,_=(S.x-s)*m+(S.y-i)*d;p=Math.min(p,E),b=Math.max(b,E),y=Math.min(y,_),x=Math.max(x,_)}let M=S=>[[p-S,y-S],[b+S,y-S],[b+S,x+S],[p-S,x+S]].map(([E,_])=>({x:s+c*E+m*_,y:i+h*E+d*_})),I=M(ci/v),w=M((ci+Ll)/v),g=t.baseHeightM,R=re(r.ground,[.62,.55,.47],.4),P=re(r.ground,[.86,.86,.84],.55);return W(e,w,void 0,()=>g-.04,g-.22,R,R,K),W(e,w,[I.slice().reverse()],()=>g+Tl,g-.04,re(P,[1,1,1],.2),P,K),!0}function mi(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=$n(t);if(!r.ok||r.value.id!==e)return o();let s=new Map;for(let c of n)for(let h of c.objects)h.type==="shape"&&s.set(h.id,{shape:h,unit:c});let i=new Set,a=new Set,f=new Map((t.overlay.productionElements??[]).map(c=>{let h=c.runtimeContentImageUrl;return[c.id,typeof h=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(h)?h:void 0]})),u=[];for(let c of r.value.overlay.productionElements??[]){let h=s.get(c.objectId),m=h?ae(h.shape):null,d=c.baseElevationM??0;if(!h||!m||m.length<3||!c.id||i.has(c.id)||a.has(c.objectId)||!Number.isFinite(c.heightM)||c.heightM<.05||c.heightM>50||!Number.isFinite(d)||d<-10||d>100)return o();i.add(c.id),a.add(c.objectId);let p=m.map(P=>P.x*v),b=m.map(P=>P.y*v),y=h.unit.baseHeightM+d,x=Math.min(...p),M=Math.max(...p),I=Math.min(...b),w=Math.max(...b),g,R=f.get(c.id)??c.contentImageUrl;if(c.kind==="screen"&&R&&(g=nr(m,y,y+c.heightM,h.unit.focal),!g))if(M-x>=w-I){let P=Math.abs(I-h.unit.focal.y*v)<=Math.abs(w-h.unit.focal.y*v)?I-.006:w+.006;g=[[x,y,P],[M,y,P],[x,y+c.heightM,P],[M,y+c.heightM,P]]}else{let P=Math.abs(x-h.unit.focal.x*v)<=Math.abs(M-h.unit.focal.x*v)?x-.006:M+.006;g=[[P,y,I],[P,y,w],[P,y+c.heightM,I],[P,y+c.heightM,w]]}u.push({id:c.id,objectId:c.objectId,kind:c.kind,floorIndex:h.unit.index,baseY:y,topY:y+c.heightM,bounds:{min:[x,y,I],max:[M,y+c.heightM,w]},occlusion:c.occlusion,...R?{contentImageUrl:R}:{},...g?{contentPlane:g}:{}})}let l=u.sort((c,h)=>c.id.localeCompare(h.id));return{byObjectId:new Map(l.map(c=>[c.objectId,c])),elements:l}}var hi=[.13,.14,.17],ot=[.4,.43,.47],Ol=.18,Bl=.02,Fl=2.4,Dl=1500,Nl=240;function di(e,t,n,o){let r=t.stageKind??"";if(Xe(r)||r==="round"||!o.length)return;let s=ae(t);if(!s||s.length<3)return;let i={x:s.reduce((A,L)=>A+L.x,0)/s.length,y:s.reduce((A,L)=>A+L.y,0)/s.length},a=0,f=0,u=new Set;for(let A of o)a+=A.x,f+=A.y,u.add(Math.floor(Math.atan2(A.y-i.y,A.x-i.x)*180/Math.PI/10));if(u.size*10>Nl)return;let l=i.x-a/o.length,c=i.y-f/o.length,h=Math.hypot(l,c);if(h<1e-6)return;let m=l/h,d=c/h,p=-d,b=m,y=-1/0,x=1/0,M=1/0,I=-1/0;for(let A of s){let L=(A.x-i.x)*m+(A.y-i.y)*d,F=(A.x-i.x)*p+(A.y-i.y)*b;y=Math.max(y,L),x=Math.min(x,L),M=Math.min(M,F),I=Math.max(I,F)}let w=(I-M)*v,g=(y-x)*v;if(w<3||g<1.5||w*g>Dl)return;let R=Ol/v,P=(A,L)=>({x:i.x+m*A+p*L,y:i.y+d*A+b*L}),S=(A,L,F,T)=>[P(A,F),P(A,T),P(L,T),P(L,F)],E=n+Math.max(3.5,Math.min(8,w*.35)),_=n+Math.min(Fl,E-n-1),O=.2/v,k=x+Math.min(g*.25,1.5)/v,C=Bl/v;W(e,S(y-2*R+C,y-R-C,M+R+O,I-R-O),void 0,()=>_,n,hi,hi,K);for(let[A,L]of[[M+R,M+R+O],[I-R-O,I-R]])W(e,S(y-2*R,y-R,A,L),void 0,()=>E+.3,n,ot,ot,K),W(e,S(k+O,y-2*R,A,L),void 0,()=>E+.3,E,ot,ot,K);W(e,S(k,k+O,M+R,I-R),void 0,()=>E+.3,E,ot,ot,K)}function xe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ye(e){return Array.isArray(e)?e:[]}function Gl(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!xe(n))continue;let o=xe(n.extensions)?n.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function Yt(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function jl(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Hl(e,t){let n=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let s=0;s<4;s++)n[o*4+r]+=e[s*4+r]*t[o*4+s];return n}function Xl(e){let t=Yt(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:Yt(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:Yt(e.rotation,4),r=e.scale===void 0?[1,1,1]:Yt(e.scale,3);if(!n||!o||!r)return null;let[s,i,a,f]=o,u=Math.hypot(s,i,a,f);if(!(u>1e-8))return null;let l=s/u,c=i/u,h=a/u,m=f/u,d=l+l,p=c+c,b=h+h,y=l*d,x=l*p,M=l*b,I=c*p,w=c*b,g=h*b,R=m*d,P=m*p,S=m*b;return[(1-(I+g))*r[0],(x+S)*r[0],(M-P)*r[0],0,(x-S)*r[1],(1-(y+g))*r[1],(w+R)*r[1],0,(M+P)*r[2],(w-R)*r[2],(1-(y+I))*r[2],0,n[0],n[1],n[2],1]}function Ul(e,t,n,o){return[e[0]*t+e[4]*n+e[8]*o+e[12],e[1]*t+e[5]*n+e[9]*o+e[13],e[2]*t+e[6]*n+e[10]*o+e[14]]}function Vl(e){let t=e[0],n=e[4],o=e[8],r=e[1],s=e[5],i=e[9],a=e[2],f=e[6],u=e[10],l=s*u-i*f,c=i*a-r*u,h=r*f-s*a,m=t*l+n*c+o*h;if(Math.abs(m)<1e-12)return null;let d=1/m;return[l*d,c*d,h*d,(o*f-n*u)*d,(t*u-o*a)*d,(n*a-t*f)*d,(n*i-o*s)*d,(o*r-t*i)*d,(t*s-n*r)*d]}function pi(e,t,n,o){let r=e[0]*t+e[1]*n+e[2]*o,s=e[3]*t+e[4]*n+e[5]*o,i=e[6]*t+e[7]*n+e[8]*o,a=Math.hypot(r,s,i)||1;return r/=a,s/=a,i/=a,[r,s,i]}function Yl(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,o=null,r=null;for(;n+8<=e.byteLength;){let s=t.getUint32(n,!0),i=t.getUint32(n+4,!0);if(n+=8,s%4!==0||n+s>e.byteLength)return null;let a=e.subarray(n,n+s);if(i===1313821514&&!o)try{let f=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!xe(f))return null;o=f}catch{return null}else if(i===5130562&&!r)r=a;else return null;n+=s}return n===e.byteLength&&o&&r?{json:o,bin:r}:null}function Kl(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function zl(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Wl(e,t,n){return n===5120?e.getInt8(t):n===5121?e.getUint8(t):n===5122?e.getInt16(t,!0):n===5123?e.getUint16(t,!0):n===5125?e.getUint32(t,!0):e.getFloat32(t,!0)}function Zl(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Yl(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!xe(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let s=ye(o.extensionsUsed).filter(I=>typeof I=="string");if(s.includes("KHR_draco_mesh_compression")||Gl(o))return{ok:!1,issue:"draco_not_allowed"};if(s.length||ye(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(ye(o.images).length||ye(o.textures).length)return{ok:!1,issue:"external_resource"};let i=ye(o.buffers);if(i.length!==1||!xe(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 a=ye(o.accessors),f=ye(o.bufferViews),u=ye(o.meshes),l=ye(o.nodes),c=ye(o.scenes),h=typeof o.scene=="number"?o.scene:0;if(!xe(c[h]))return{ok:!1,issue:"unsupported_glb"};let m=new DataView(r.buffer,r.byteOffset,r.byteLength),d=(I,w,g)=>{if(typeof I!="number"||!Number.isInteger(I)||!xe(a[I]))return null;let R=a[I];if(R.type!==w||R.sparse!==void 0||R.normalized===!0||typeof R.count!="number"||!Number.isInteger(R.count)||R.count<1||typeof R.componentType!="number"||!g.includes(R.componentType)||typeof R.bufferView!="number")return null;let P=f[R.bufferView];if(!xe(P)||P.buffer!==0||typeof P.byteLength!="number"||!Number.isInteger(P.byteLength)||P.byteLength<0)return null;let S=zl(R.type),E=Kl(R.componentType),_=typeof P.byteStride=="number"?P.byteStride:S*E,O=typeof P.byteOffset=="number"?P.byteOffset:0,k=typeof R.byteOffset=="number"?R.byteOffset:0,C=O+k,A=k+(R.count-1)*_+S*E;if(!Number.isInteger(_)||!Number.isInteger(O)||!Number.isInteger(k)||_<S*E||O<0||k<0||O+P.byteLength>r.byteLength||A>P.byteLength)return null;let L=[];for(let F=0;F<R.count;F++){let T=[];for(let B=0;B<S;B++){let N=Wl(m,C+F*_+B*E,R.componentType);if(!Number.isFinite(N))return null;T.push(N)}L.push(T)}return L},p=[],b=[],y=0,x=new Set,M=(I,w)=>{if(typeof I!="number"||!Number.isInteger(I)||!xe(l[I])||x.has(I))return!1;x.add(I);let g=l[I],R=Xl(g);if(!R)return!1;let P=Hl(w,R),S=Vl(P);if(!S)return!1;if(g.mesh!==void 0){if(typeof g.mesh!="number")return!1;let E=u[g.mesh];if(!xe(E))return!1;for(let _ of ye(E.primitives)){if(!xe(_)||_.mode!==void 0&&_.mode!==4||!xe(_.attributes))return!1;let O=d(_.attributes.POSITION,"VEC3",[5126]),k=_.attributes.NORMAL===void 0?null:d(_.attributes.NORMAL,"VEC3",[5126]);if(!O||_.attributes.NORMAL!==void 0&&!k)return!1;let C=O.length;if(_.indices!==void 0){let L=typeof _.indices=="number"?a[_.indices]:null;C=xe(L)?L.count:void 0}if(typeof C!="number"||!Number.isInteger(C)||C%3!==0||(y+=C/3,y>1e5))return!1;let A=_.indices===void 0?O.map((L,F)=>[F]):d(_.indices,"SCALAR",[5121,5123,5125]);if(!A||A.length%3!==0||A.length!==C)return!1;for(let L=0;L<A.length;L+=3){let F=[A[L][0],A[L+1][0],A[L+2][0]];if(F.some(N=>!Number.isInteger(N)||N<0||N>=O.length))return!1;let T=F.map(N=>Ul(P,...O[N])),B=null;if(!k){let N=T[1][0]-T[0][0],H=T[1][1]-T[0][1],D=T[1][2]-T[0][2],V=T[2][0]-T[0][0],U=T[2][1]-T[0][1],Z=T[2][2]-T[0][2];B=pi([1,0,0,0,1,0,0,0,1],H*Z-D*U,D*V-N*Z,N*U-H*V)}for(let N=0;N<3;N++)p.push(...T[N]),b.push(...k?pi(S,...k[F[N]]):B)}}}for(let E of ye(g.children))if(!M(E,P))return!1;return x.delete(I),!0};for(let I of ye(c[h].nodes))if(!M(I,jl()))return{ok:!1,issue:y>1e5?"triangle_limit":"unsupported_glb"};return!y||p.length!==y*9||b.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:y,position:new Float32Array(p),normal:new Float32Array(b)}}function bi(e){try{return Zl(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function yi(e){let{doc:t}=e,n=go(t.theme),o=n.structure,r=Yo(t,e.eventConfigurationId??t.eventConfigurationId),s=mi(e.eventConfigurationId,e.eventConfiguration,r),i=e.seats,a=new vt,f=null;if(e.registeredShellGlb){let j=bi(e.registeredShellGlb);if(j.ok){let G=j.position.length/3,Q=new Float32Array(j.position.length),te=n.materials.shell??o.tierWall;for(let ne=0;ne<G;ne++){let ce=j.normal[ne*3+1],se=ce<-.25?.4:.62+.38*Math.max(0,ce);Q[ne*3]=te[0]*se,Q[ne*3+1]=te[1]*se,Q[ne*3+2]=te[2]*se}f={position:j.position,normal:j.normal,color:Q,floor:new Float32Array(G).fill(-2),material:new Float32Array(G),count:G}}}let u=new Map;for(let j of r)for(let G of j.objects)u.set(G.id,j.index),G.type==="section"&&u.set(G.logicalSectionId??G.id,j.index);let l=i.map(j=>u.get(j.sectionId??"")??u.get(j.rowId??"")??0),c=_n(r,i),h=a.vertexCount,d=ui(a,r,i,l,c,o,re(n.background.top,n.background.bottom,.5))?a.vertexCount:h,p=qo(t,i),b=new Map,y=new Map;for(let j of t.categories??[])b.set(j.key,j.color),j.seatGlyph&&y.set(j.key,j.seatGlyph);let x=[],M=$o(r,i,l),I=new Map;i.forEach((j,G)=>{let Q=M.seatDeckY(G);Number.isFinite(Q)&&I.set(j.rowId,Math.min(I.get(j.rowId)??1/0,Q))});let w=new Float32Array(i.length),g=[],R=new Map((t.floors??[]).map((j,G)=>[j.id,G])),P=r.map(()=>[]);for(let j of i){let G=j.floorId?R.get(j.floorId)??0:0;P[Math.min(G,P.length-1)]?.push(j)}let S=(j,G)=>{if(!G||G.length<3)return!1;let Q=Math.min(...G.map(se=>se.x)),te=Math.max(...G.map(se=>se.x)),ne=Math.min(...G.map(se=>se.y)),ce=Math.max(...G.map(se=>se.y));for(let se=0;se<j;se++)for(let Y of P[se])if(!(Y.x<Q||Y.x>te||Y.y<ne||Y.y>ce)&&me(Y,G,void 0))return!0;return!1},E=null,_=j=>r.length===1?i:i.filter((G,Q)=>l[Q]===j),O=(j,G)=>{let Q=_e(j);if(!Q)return!1;let te=1/0,ne=1/0,ce=-1/0,se=-1/0;for(let Y of Q)te=Math.min(te,Y.x),ce=Math.max(ce,Y.x),ne=Math.min(ne,Y.y),se=Math.max(se,Y.y);return i.some((Y,le)=>Y.kind!=="booth"&&(r.length===1||l[le]===G)&&Y.x>te&&Y.x<ce&&Y.y>ne&&Y.y<se&&pe(Q,Y.x,Y.y))};for(let j=0;j<r.length;j++){let G=r[j];a.setFloor(j);let Q=new Tt,te=[],ne=G.objects.filter(Y=>Y.type==="shape"&&(Y.role==="entrance"||Y.role==="exit")),ce=G.objects.filter(Y=>Y.type==="section"&&!!Y.outline&&Y.outline.length>=3),se=vr(G.objects.filter(Y=>Y.type==="booth"),G.focal);for(let Y of G.objects)if(Y.type==="section"){let le=a.vertexCount;Gr(a,Y,G,Jo(Y,p),M.bySection.get(Y.id),Q,ce,o,j>0&&S(j,Y.outline));let Re=a.vertexCount-le;Re>0&&g.push({sectionId:Y.id,start:le,count:Re})}else if(Y.type==="shape"){let le=s.byObjectId.get(Y.id),Re=x.length;a.setMaterial((le?.kind??Y.role)==="screen"?1:0);let we=Y.role==="stage"&&!le?Cr(Y,_(j)):Y,ve=tr(we,te);if(Ir(a,we,G.baseHeightM+ve.supportOffsetM,ve.topOffsetM-ve.supportOffsetM,o,G.focal,x,le,ne),a.setMaterial(0),Y.role==="stage"&&!le&&x.length>Re&&(E??j)===j){E=j;let Se=t.floors?.[j]?.id,he=r.length>1&&Se?i.filter(ze=>ze.floorId===Se):i;di(a,we,x[x.length-1].y,he)}}else Y.type==="gaArea"?Rr(a,Y,G.baseHeightM,oe(b.get(Y.categoryKey)),o):Y.type==="booth"?gr(a,Y,G.baseHeightM,oe(b.get(Y.categoryKey)),o,se.get(Y.id)??G.focal,O(Y,j)):Y.type==="table"?Sr(a,Y,Math.max(G.baseHeightM,I.get(Y.id)??G.baseHeightM),oe(Y.fill??t.theme?.decorFill??"#232c40"),o,!!(Y.fill??t.theme?.decorFill)):Y.type==="decorImage"&&Pr(a,Y,G.baseHeightM,o);Hr(a,G,i,M,o,n.materials.shell,!f)}let k=r.length>1?{x:r.reduce((j,G)=>j+G.focal.x,0)/r.length,y:r.reduce((j,G)=>j+G.focal.y,0)/r.length}:t.focalPoint??{x:(c.minX+c.maxX)/2,y:(c.minY+c.maxY)/2},C=fo(f?[a.build(),f]:[a.build()]),A=Ao(i,e.initialState,M,w,b,y),L=ni({doc:t,units:r,seats:i,surfaces:M,focal:k}),{labels:F,sections:T,rows:B}=oi({doc:t,units:r,seats:i,surfaces:M,seatData:A,hintedSeatFloor:l,zones:L,focal:k}),N=new Map(T.map((j,G)=>[j.id,G]));M.seatOwner.forEach((j,G)=>{A.iSection[G]=j?N.get(j)??-1:-1});let H=ii({doc:t,units:r,seats:i,surfaces:M,solids:C,hintedSeatFloor:l,seatFloor:w});ri(F,H),A.iYaw=Co(A.iPosition,i.length,j=>i[j].rowId,j=>{let G=r[w[j]]?.focal??k;return[G.x*v,G.y*v]});let D=(c.minX+c.maxX)/2*v,V=(c.minY+c.maxY)/2*v,U=.5*Math.hypot((c.maxX-c.minX)*v,(c.maxY-c.minY)*v)||10,Z=kn(C,A,{cx:D,cz:V,radius:U},[h,d]),X=kn(C,A,{cx:D,cz:V,radius:U}),q=fi(A,x,c,Z.minY,Z.maxY,U);return{sharedAisles:mo(r.flatMap(j=>j.objects.flatMap(G=>{if(G.type!=="section")return[];let Q=M.bySection.get(G.id);return Q?[{sectionId:G.id,floorIndex:j.index,rows:Q.rowLevels}]:[]}))),solids:C,sectionSolidRanges:g,seats:A,seatSectionIds:M.seatOwner,bounds:{center:[(q.min[0]+q.max[0])/2,(q.min[1]+q.max[1])/2,(q.min[2]+q.max[2])/2],radius:U,groundY:0,box:q},renderBounds:{center:Z.center,radius:Z.radius},clipBounds:{center:X.center,radius:X.radius},stateColorLUT:Mo(n,Ct),theme:n,seatCount:i.length,focalWorld:[k.x*v,1.5,k.y*v],zones:L,stages:x,productionElements:s.elements,sections:T,rows:B,labels:F,floors:H}}function $l(e,t){let{doc:n,report:o}=Qr(e),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let f=new Map(o.roles.map(m=>[m.id,m.role])),u=m=>m.map(d=>d.type==="shape"&&f.has(d.id)?{...d,role:f.get(d.id)}:d),l=e.floors?.map(m=>({...m,objects:u(m.objects)})),c=new Float64Array(t.length).fill(Number.NaN),h=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((m,d)=>{m.eyeHeightM!==void 0&&(c[d]=m.eyeHeightM),m.focalPoint&&(h[d*2]=m.focalPoint.x,h[d*2+1]=m.focalPoint.y)}),{doc:{...e,objects:l?.[0]?.objects??u(e.objects),...l?{floors:l}:{}},report:o,eyeHeightM:c,focal:h}}let s=new Map($e(n).map(f=>[f.id,f])),i=new Float64Array(t.length).fill(Number.NaN),a=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((f,u)=>{let l=s.get(f.id)??f;l.eyeHeightM!==void 0&&(i[u]=l.eyeHeightM),l.focalPoint&&(a[u*2]=l.focalPoint.x,a[u*2+1]=l.focalPoint.y)}),{doc:n,report:o,eyeHeightM:i,focal:a}}function Ql(e,t){return e.map((n,o)=>{let r=t.eyeHeightM[o],s=t.focal[o*2],i=t.focal[o*2+1],a={...n};return Number.isNaN(r)?delete a.eyeHeightM:a.eyeHeightM=r,Number.isNaN(s)?delete a.focalPoint:a.focalPoint={x:s,y:i},a})}function xi(e){let t=e.estimate===!1?null:$l(e.doc,e.seats);return t?{input:{...e,doc:t.doc,seats:Ql(e.seats,t)},estimate:t}:{input:e}}function ql(e){return[e.solids.position,e.solids.normal,e.solids.color,e.solids.floor,e.solids.material,e.seats.iPosition,e.seats.iState,e.seats.iCategory,e.seats.iMaxRadius,e.seats.iRing,e.seats.iFloor,e.seats.iYaw,e.seats.iChairWidth,e.seats.iGlyph,e.seats.iPhysicalSeat].map(n=>n.buffer)}var gi=self;gi.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??$e(e.data.doc),{input:r,estimate:s}=xi({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),i=yi(r),a=ql(i);s&&a.push(s.eyeHeightM.buffer,s.focal.buffer),gi.postMessage({model:i,buildMs:performance.now()-t,...n?{seats:o}:{},...s?{estimate:s}:{}},a)};