@seatlayer/core 0.99.0 → 0.101.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 (62) hide show
  1. package/dist/{categoryInventory-DdJdJ4Og.d.ts → categoryInventory-DZ5IcDOy.d.ts} +1 -1
  2. package/dist/{categoryInventory-DuOez0-4.d.cts → categoryInventory-H77A_8pF.d.cts} +1 -1
  3. package/dist/{chunk-KFVUBZMK.js → chunk-2RNZOV5I.js} +1 -1
  4. package/dist/{chunk-HYEZPOZU.js → chunk-52XO3LA7.js} +1 -1
  5. package/dist/{chunk-VWT44HBR.js → chunk-5HXTEMRE.js} +1 -1
  6. package/dist/{chunk-UIMDB6GZ.js → chunk-5PFYIYM5.js} +1 -1
  7. package/dist/chunk-FLZKBXHA.js +1 -0
  8. package/dist/{chunk-23OTKCJU.js → chunk-JK3DUFRX.js} +1 -1
  9. package/dist/chunk-NO6OLVTT.js +1 -0
  10. package/dist/core/chart-ops/index.cjs +1 -1
  11. package/dist/core/chart-ops/index.d.cts +4 -4
  12. package/dist/core/chart-ops/index.d.ts +4 -4
  13. package/dist/core/chart-ops/index.js +1 -1
  14. package/dist/core/inventory/index.d.cts +4 -4
  15. package/dist/core/inventory/index.d.ts +4 -4
  16. package/dist/core/inventory/index.js +1 -1
  17. package/dist/core/layout/index.d.cts +5 -5
  18. package/dist/core/layout/index.d.ts +5 -5
  19. package/dist/core/quality/index.d.cts +3 -3
  20. package/dist/core/quality/index.d.ts +3 -3
  21. package/dist/core/quality/index.js +1 -1
  22. package/dist/core/render-assets/index.d.cts +2 -2
  23. package/dist/core/render-assets/index.d.ts +2 -2
  24. package/dist/core/seatConfidence.d.cts +1 -1
  25. package/dist/core/seatConfidence.d.ts +1 -1
  26. package/dist/core/sections/index.d.cts +5 -5
  27. package/dist/core/sections/index.d.ts +5 -5
  28. package/dist/{eventConfigurations-BISNREZL.d.ts → eventConfigurations-B6aS6c-_.d.ts} +1 -1
  29. package/dist/{eventConfigurations-DYn5XP3J.d.cts → eventConfigurations-ClFqXQi9.d.cts} +1 -1
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.cts +18 -13
  32. package/dist/index.d.ts +18 -13
  33. package/dist/index.js +1 -1
  34. package/dist/{labeling-owTTG6e0.d.cts → labeling-ByEZkLee.d.cts} +1 -1
  35. package/dist/{labeling-CzuSxAkr.d.ts → labeling-CP3GhUrf.d.ts} +1 -1
  36. package/dist/{renderedQuality-Bl1Kq_XO.d.cts → renderedQuality--H0toc-2.d.cts} +1 -1
  37. package/dist/{renderedQuality-BMSbVkwu.d.ts → renderedQuality-Bo4k99GE.d.ts} +1 -1
  38. package/dist/{renderer-njHDbIqI.d.ts → renderer-BPhSZUGh.d.cts} +12 -1
  39. package/dist/{renderer-Ccv8ZDZS.d.cts → renderer-CWbam_zr.d.ts} +12 -1
  40. package/dist/{seatTypeIcons-QwEebl3k.d.cts → seatTypeIcons-B2tvcQ0H.d.cts} +1 -1
  41. package/dist/{seatTypeIcons-dy3XQVWN.d.ts → seatTypeIcons-CSt1isBY.d.ts} +1 -1
  42. package/dist/{sections-DSIfnBJY.d.cts → sections-C_AKwOIh.d.cts} +1 -1
  43. package/dist/{sections-C8VTe6BN.d.ts → sections-JHox6Lsw.d.ts} +1 -1
  44. package/dist/{segmentedRowModel-CDvvJJ4-.d.cts → segmentedRowModel-CZ0Ciea-.d.cts} +1 -1
  45. package/dist/{segmentedRowModel-I8eYUQft.d.ts → segmentedRowModel-DQO0vHR1.d.ts} +1 -1
  46. package/dist/{tableSizing-BLtQ-KV0.d.ts → tableSizing-ClgbhNks.d.ts} +3 -3
  47. package/dist/{tableSizing-CB8g2Fs0.d.cts → tableSizing-Cp5T_6Lw.d.cts} +3 -3
  48. package/dist/{ticketRestrictions-BvlWLw10.d.cts → ticketRestrictions-BHNbxzFT.d.cts} +2 -2
  49. package/dist/{ticketRestrictions-DUjN2bZn.d.ts → ticketRestrictions-DUdzkp4F.d.ts} +2 -2
  50. package/dist/{types-DWx32xXH.d.cts → types-5AlKCD4j.d.cts} +17 -0
  51. package/dist/{types-DWx32xXH.d.ts → types-5AlKCD4j.d.ts} +17 -0
  52. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  53. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  54. package/dist/view3d/index.cjs +127 -53
  55. package/dist/view3d/index.d.cts +34 -5
  56. package/dist/view3d/index.d.ts +34 -5
  57. package/dist/view3d/index.js +125 -51
  58. package/dist/view3d/scene/scene.worker.cjs +1 -1
  59. package/dist/view3d/scene/scene.worker.js +1 -1
  60. package/package.json +1 -1
  61. package/dist/chunk-K22SISYC.js +0 -1
  62. package/dist/chunk-QJXSZT3H.js +0 -1
@@ -1 +1 @@
1
- "use strict";var Xi=Object.create;var Vn=Object.defineProperty;var Ui=Object.getOwnPropertyDescriptor;var Vi=Object.getOwnPropertyNames;var Yi=Object.getPrototypeOf,Ki=Object.prototype.hasOwnProperty;var Wi=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Vi(t))!Ki.call(e,r)&&r!==n&&Vn(e,r,{get:()=>t[r],enumerable:!(o=Ui(t,r))||o.enumerable});return e};var Te=(e,t,n)=>(n=e!=null?Xi(Yi(e)):{},Wi(t||!e||!e.__esModule?Vn(n,"default",{value:e,enumerable:!0}):n,e));var Qu=Math.PI/180;function tn(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function ut(e){return e.length?tn(e):null}function Yn(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function Kn(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[Yn(e,.5)];let o=Array.from({length:n+1},(f,c)=>Yn(e,c/n)),r=new Float64Array(o.length);for(let f=1;f<o.length;f+=1){let c=o[f].x-o[f-1].x,l=o[f].y-o[f-1].y;r[f]=r[f-1]+Math.hypot(c,l)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let f=0;f<t;f+=1){let c=i*f/(t-1);for(;a<r.length-1&&r[a]<c;)a+=1;let l=r[a-1],u=r[a],h=u===l?0:(c-l)/(u-l);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*h,y:o[a-1].y+(o[a].y-o[a-1].y)*h})}return s}function Wn(e,t,n){return Math.max(t,Math.min(n,e))}function zn(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((h,m)=>h.segmentedRow.componentIndex-m.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((h,m)=>h.segmentedRow?.kind==="segmented-row-v1"&&h.segmentedRow.groupId===o&&h.segmentedRow.componentCount===s&&h.segmentedRow.componentIndex===m&&h.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(m===0?h.segmentedRow.boundaryBefore==="start":h.segmentedRow.boundaryBefore!=="start")&&h.segmentedRow.displayLabel===a.displayLabel)))continue;let c=i.reduce((h,m)=>h+m.seatCount,0),l=0,u=0;for(let h of i)h.segmentedRow.boundaryBefore==="break"&&(l+=1),t.set(h.id,{groupId:o,adjacencyOffset:l,displayOffset:u,displayLabel:a.displayLabel,totalSeats:c,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),l+=h.seatCount,u+=h.seatCount}return t}var zi="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var Zi="abcdefghijklmnopqrstuvwxyz";function $i(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function nn(e,t=!1){let n=t?Zi:zi;return $i(Math.max(0,Math.floor(e)-1),n)}var Qi=[[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 Zn(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of Qi)for(;t>=o;)n+=r,t-=o;return n}function qi(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 Et(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,f=e.seatCount;if(i==="updown"||i==="updown-descending"){let m=Math.ceil(f/2),d=i==="updown"?t<m?n+2*t:n-1+2*(f-t):t<m?n+2*(m-1-t):n+1+2*(t-m);return`${s}${d}`}let c=i==="odd"||i==="even"?2:r,l=a!=null&&Number.isFinite(a)?a-(f-1)*c:n,u=o==="center"?qi(f)[t]:o==="rtl"?f-1-t:t,h;switch(i){case"odd":{let m=l%2===1?l:l+1;h=String(m+u*2);break}case"even":{let m=l%2===0?l:l+1;h=String(m+u*2);break}case"roman":h=Zn(l+u*r);break;case"letters-upper":h=nn(l+u*r,!1);break;case"letters-lower":h=nn(l+u*r,!0);break;default:h=String(l+u*r);break}return`${s}${h}`}function Ji(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function $n(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${Et(e,t)}`}function on(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return Et(e,t);if(!n)return`${e.displayLabel||e.label}-${Et(e,t)}`;let r=Ji(n),i=n.displayOffset+t;return`${n.displayLabel}-${Et(r,i)}`}var Q=.02291666666666667,Ie=1/Q,es=58,ts=es*Q;var ns=3,Qn=0,rn=120,os=0,rs=45,is=7,Ce=1.2;function sn(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function ss(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=is?e:ns}function Ge(e,t={}){let n=sn(t.floorBaseHeightM,Qn,rn,0),o=Math.min(rn,n+ss(e.elevation)*ts),r=e.height===void 0?o:sn(e.height,Qn,rn,o),i=sn(e.rake,os,rs,0);return{height:r,rake:i}}function qn(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function qe(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,f=s.y-i.y,c=a*a+f*f,l=c>1e-12?((t-i.x)*a+(n-i.y)*f)/c:0;l<0?l=0:l>1&&(l=1);let u=t-(i.x+l*a),h=n-(i.y+l*f);if(Math.abs(u)>=o||Math.abs(h)>=o)continue;let m=Math.hypot(u,h);m<o&&(o=m)}return o}function as(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function Jn(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function an(e,t){let n=1/0;for(let o of qn(e)){let r=qe(t,o.x,o.y);r<n&&(n=r)}for(let o of qn(t)){let r=qe(e,o.x,o.y);r<n&&(n=r)}return n}function cs(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,i=e[0];for(let l of e){let u=Math.hypot(l.x-n,l.y-o);u>r&&(r=u,i=l)}let s=i.x-n,a=i.y-o,f=Math.hypot(s,a);f>1e-9?(s/=f,a/=f):(s=1,a=0);let c=e.map((l,u)=>({p:l,i:u,t:(l.x-n)*s+(l.y-o)*a})).sort((l,u)=>l.t-u.t);return{pts:c.map(l=>l.p),seatIndices:c.map(l=>t[l.i])}}function cn(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let y of e)n+=y.x,o+=y.y;n/=t,o/=t;let r=0,i=0,s=0,a=0,f=0,c=0,l=0;for(let y of e){let I=y.x-n,P=y.y-o;r+=I*I,s+=P*P,i+=I*P,a+=I*I*I,f+=P*P*P,c+=I*P*P,l+=P*I*I}let u=r*s-i*i;if(Math.abs(u)<1e-9)return null;let h=(a+c)/2,m=(f+l)/2,d=(h*s-m*i)/u,p=(m*r-h*i)/u,b=d+n,x=p+o;return!Number.isFinite(b)||!Number.isFinite(x)?null:{cx:b,cy:x}}var ls=.15;function us(e){if(e.length<2)return null;let t=e.map(E=>{let g=0,S=0;for(let M of E.pts)g+=M.x,S+=M.y;return{x:g/E.pts.length,y:S/E.pts.length}}),n=0,o=0;for(let E of t)n+=E.x,o+=E.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let E of t){let g=E.x-n,S=E.y-o;r+=g*g,i+=g*S,s+=S*S}let a=r+s,f=r*s-i*i,c=a/2+Math.sqrt(Math.max(0,a*a/4-f)),l,u;Math.abs(i)>1e-12?(l=c-s,u=i):r>=s?(l=1,u=0):(l=0,u=1);let h=Math.hypot(l,u);if(!(h>1e-12))return null;l/=h,u/=h;let m=0,d=0,p=0;for(let E of e){if(E.pts.length<2)continue;let g=E.pts[0],S=E.pts[E.pts.length-1],M=S.x-g.x,R=S.y-g.y,v=Math.hypot(M,R);if(!(v>1e-9))continue;let T=M/v,k=R/v;m+=(T*T-k*k)*v,d+=2*T*k*v,p+=v}if(p>0&&Math.hypot(m,d)>=ms*p){let E=Math.atan2(d,m)/2,g=Math.cos(E),S=Math.sin(E);Math.abs(l*g+u*S)>hs&&(l=-S,u=g)}let b=1/0,x=-1/0,y=[];for(let E of e){let g=1/0,S=-1/0;for(let M of E.pts){let R=M.x*l+M.y*u;R<g&&(g=R),R>S&&(S=R),R<b&&(b=R),R>x&&(x=R)}y.push(S-g)}let I=x-b;return I>1e-9?(y.sort((E,g)=>E-g),y[Math.min(y.length-1,Math.floor(y.length*.9))]/I<=fs?{x:l,y:u}:null):null}var fs=.35,ms=.8,hs=.7;function At(e,t,n,o){let r=new Map;for(let g of n){let S=t[g],M=S.rowId||`__seat-${g}`,R=r.get(M);R||(R={pts:[],idx:[]},r.set(M,R)),R.pts.push({x:S.x,y:S.y}),R.idx.push(g)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[g,S]of r){let M=cs(S.pts,S.idx),R=0;for(let v of M.pts)R+=Math.hypot(v.x-o.x,v.y-o.y);i.push({id:g,pts:M.pts,seatIndices:M.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:R/M.pts.length})}let s=i.map(g=>as(g.pts)),a=i.length<=256?i.length*(i.length-1)/2:0,f=a?new Float64Array(a):null;f?.fill(Number.NaN);let c=f?new Map(i.map((g,S)=>[g,S])):null,l=(g,S)=>(g>S&&([g,S]=[S,g]),g*(2*i.length-g-1)/2+(S-g-1)),u=(g,S)=>{if(!f)return an(i[g].pts,i[S].pts);let M=l(g,S),R=f[M];if(!Number.isNaN(R))return R;let v=an(i[g].pts,i[S].pts);return f[M]=v,v},h=(g,S)=>c?u(c.get(g),c.get(S)):an(g.pts,S.pts),m=[];for(let g=0;g<i.length;g++){let S=1/0;for(let M=0;M<i.length;M++){if(g===M||Jn(s[g],s[M])>=S)continue;let R=u(g,M);R<S&&(S=R)}Number.isFinite(S)&&m.push(S)}m.sort((g,S)=>g-S);let d=m.length?m[Math.floor(m.length/2)]:1,p=Math.max(d*1.8,1e-6),b=i.map(()=>[]);for(let g=0;g<i.length;g++)for(let S=g+1;S<i.length;S++)Jn(s[g],s[S])>p||u(g,S)<=p&&(b[g].push(S),b[S].push(g));let x=0;for(let g=0;g<i.length;g++){if(i[g].blockId!==-1)continue;let S=x++,M=[g];for(i[g].blockId=S;M.length;){let R=M.pop();for(let v of b[R])i[v].blockId===-1&&(i[v].blockId=S,M.push(v))}}let y=new Map;for(let g of i){let S=y.get(g.blockId)??[];S.push(g),y.set(g.blockId,S)}let I=[];for(let g of i){if(g.pts.length<4)continue;let S=cn(g.pts);S&&(!Number.isFinite(S.cx)||!Number.isFinite(S.cy)||I.push({x:S.cx,y:S.cy}))}let P=I.length>=2?(()=>{let g=I.map(R=>R.x).sort((R,v)=>R-v),S=I.map(R=>R.y).sort((R,v)=>R-v),M=Math.floor(I.length/2);return{cx:g[M],cy:S[M]}})():null;if(P){let g=k=>Math.hypot(k.x-P.cx,k.y-P.cy),S=1/0,M=-1/0,R=[];for(let k of i){let _=1/0,A=-1/0;for(let C of k.pts){let L=g(C);L<_&&(_=L),L>A&&(A=L)}R.push(A-_),_<S&&(S=_),A>M&&(M=A)}let v=M-S;R.sort((k,_)=>k-_);let T=R[Math.min(R.length-1,Math.floor(R.length*.9))];if(v>1e-9&&T/v<=ls){let k=i.map(D=>{let U=0;for(let V of D.pts)U+=g(V);return{row:D,radius:U/D.pts.length}}),_=0,A=0;for(let D of k)_+=D.radius,A+=D.row.focalDistance;_/=k.length,A/=k.length;let C=0;for(let D of k)C+=(D.radius-_)*(D.row.focalDistance-A);if(C<0)for(let D of k)D.radius=-D.radius;let F=1/0;for(let D of k)D.radius<F&&(F=D.radius);k.sort((D,U)=>D.radius-U.radius);let O=-1,B=-1/0,N=v/Math.max(1,k.length)*.5,H=[];for(let D of k)D.radius-B>N&&(O++,B=D.radius),D.row.ordinal=O,D.row.blockDepth=D.radius-F,H.push(D.row);return{sectionId:e,rows:H,blockCount:x}}}let E=[];for(let[,g]of y){let S=us(g);if(S){let M=k=>{let _=0;for(let A of k.pts)_+=A.x*S.x+A.y*S.y;return _/k.pts.length};g.sort((k,_)=>M(k)-M(_)),g.length>=2&&g[0].focalDistance>g[g.length-1].focalDistance&&g.reverse();let R=[],v=d*.5;for(let k of g){let _=R[R.length-1];_&&Math.abs(M(k)-M(_[0]))<v?_.push(k):R.push([k])}let T=0;for(let k=0;k<R.length;k++){if(k>0){let _=1/0;for(let A of R[k-1])for(let C of R[k])_=Math.min(_,h(A,C));T+=_}for(let _ of R[k])_.ordinal=k,_.blockDepth=T,E.push(_)}}else{let M=1/0;for(let R of g)R.focalDistance<M&&(M=R.focalDistance);g.sort((R,v)=>R.focalDistance-v.focalDistance);for(let R=0;R<g.length;R++)g[R].ordinal=R,g[R].blockDepth=Math.max(0,g[R].focalDistance-M),E.push(g[R])}}return{sectionId:e,rows:E,blockCount:x}}var ds=/^\d{4}-\d{2}-\d{2}$/;function ps(e){let t=Date.parse(e);return Number.isFinite(t)?ds.test(e)?t+864e5:t:null}function bs(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=ps(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function ys(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function xs(e){return e.status!=="draft"&&e.status!=="retracted"}function gs(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 eo(e,t={}){return!!e&&xs(e)&&ys(e,t.activeConfigurationId,t.activeConfigurationVersion)&&gs(e,t.activeBasisSha256)&&bs(e,t.now)}var Ms=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),Ss=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function We(e){return!!e&&Ms.has(e)}function vt(e){return!!e&&Ss.has(e)}var Ct=1.1,Is={"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}},Rs={"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 Ps=Math.PI*2;function ws(e,t,n,o,r,i){return{x:r+e*n-t*o,y:i+e*o+t*n}}function to(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let i=0;i<=r;i++){let s=-Math.PI/2+i/r*Math.PI;o.push({x:n+t*Math.cos(s),y:t*Math.sin(s)})}for(let i=0;i<=r;i++){let s=Math.PI/2+i/r*Math.PI;o.push({x:-n+t*Math.cos(s),y:t*Math.sin(s)})}return o}var no=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),i=r+70,s=[],a=Math.atan2(o.y-r,o.x),f=Math.atan2(o.y-r,-o.x);for(let c=0;c<=24;c++){let l=a+(f-a)*c/24;s.push({x:i*Math.cos(l),y:r+i*Math.sin(l)})}return{half:70,home:t,backstop:n,fence:s}})();var _t="#f1f5f9";function ft(e){return We(e)}function je(e,t,n,o,r=32){let i=[];for(let s=0;s<r;s++){let a=s/r*Ps;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Le(e,t,n,o){return[{x:e-n,y:t-o},{x:e+n,y:t-o},{x:e+n,y:t+o},{x:e-n,y:t+o}]}function Es(e){let{kind:t,cx:n,cy:o,width:r,height:i}=e,s=(e.rotation??0)*Math.PI/180,a=Math.cos(s),f=Math.sin(s),c=r/2,l=i/2,u=[],h=Is[t],m=p=>h?p/h.width*r:0,d=p=>h?p/h.height*i:0;switch(t){case"pitch-football":{u.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1}),u.push({points:je(0,0,m(9.15),d(9.15)),closed:!0});for(let p of[-1,1])u.push({points:Le(p*(c-m(16.5)/2),0,m(16.5)/2,d(40.32)/2),closed:!0}),u.push({points:Le(p*(c-m(5.5)/2),0,m(5.5)/2,d(18.32)/2),closed:!0});break}case"rink-hockey":{u.push({points:[{x:0,y:-l},{x:0,y:l}],closed:!1,ink:"#d63b3b"});for(let p of[-1,1]){u.push({points:[{x:p*m(7.5),y:-l},{x:p*m(7.5),y:l}],closed:!1,ink:"#2f6ecb"}),u.push({points:[{x:p*(c-m(4)),y:-d(11)},{x:p*(c-m(4)),y:d(11)}],closed:!1,ink:"#d63b3b"});for(let b of[-1,1])u.push({points:je(p*m(20.5),b*d(7),m(4.5),d(4.5)),closed:!0,ink:"#2f6ecb"})}u.push({points:je(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&&u.push({points:to(c-m(1.22)*8,b),closed:!0,fill:"#2f7d4f"});for(let x=1;x<8;x++){let y=d(1.22)*x,I=l-y;if(I<=0)break;u.push({points:to(c-m(1.22)*x,I),closed:!0})}break}case"oval-cricket":{u.push({points:je(0,0,m(27.4),d(27.4+20.12/2),40),closed:!0}),u.push({points:Le(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});u.push(p(0));for(let b of[-1,1]){u.push(p(b*50),p(b*28));for(let x=-35;x<35;x+=4)u.push({points:[{x:m(b*10),y:d(x)},{x:m(b*10),y:d(Math.min(35,x+2))}],closed:!1})}break}case"diamond-baseball":{let p=(L,F)=>({x:m(L),y:d(F)}),{home:b}=no,x=27.43,y=x/Math.SQRT2,I={x:b.x+y,y:b.y-y},P={x:b.x,y:b.y-2*y},E={x:b.x-y,y:b.y-y},g={x:b.x,y:b.y-18.44},S="#b98a59",M=Rs["diamond-baseball"],R=38.94,v=[p(b.x,b.y)],T=Math.atan2(b.y-R/Math.SQRT2-g.y,R/Math.SQRT2),k=Math.PI-T;for(let L=0;L<=16;L++){let F=T-(T+Math.PI*2-k)%(Math.PI*2)*(L/16);v.push(p(g.x+29*Math.cos(F),g.y+29*Math.sin(F)))}u.push({points:v,closed:!0,fill:S,ink:S});let _={x:b.x,y:b.y-y},A=[{x:b.x,y:b.y},I,P,E].map(L=>p(_.x+(L.x-_.x)*.84,_.y+(L.y-_.y)*.84));u.push({points:A,closed:!0,fill:M,ink:M}),u.push({points:je(m(g.x),d(g.y),m(2.74),d(2.74),20),closed:!0,fill:S,ink:S}),u.push({points:je(m(b.x),d(b.y),m(3.96),d(3.96),20),closed:!0,fill:S,ink:S});let C=no.fence;u.push({points:[p(b.x,b.y),p(C[0].x,C[0].y)],closed:!1}),u.push({points:[p(b.x,b.y),p(C[C.length-1].x,C[C.length-1].y)],closed:!1});for(let L of[I,P,E])u.push({points:Le(m(L.x),d(L.y),m(.3),d(.3)),closed:!0,fill:_t});break}case"court-basketball":{u.push({points:Le(0,0,m(14),d(7.5)),closed:!0}),u.push({points:[{x:0,y:-d(7.5)},{x:0,y:d(7.5)}],closed:!1}),u.push({points:je(0,0,m(1.8),d(1.8),24),closed:!0});for(let p of[-1,1]){let b=p*14,x=p*(14-5.8),y=p*(14-1.575);u.push({points:Le(m((b+x)/2),0,m(2.9),d(2.45)),closed:!0,fill:"#2f5d8a"}),u.push({points:je(m(x),0,m(1.8),d(1.8),24),closed:!0});let I=Math.sqrt(6.75*6.75-6.6*6.6),P=[{x:m(b),y:-d(6.6)}],E=Math.atan2(-6.6,-p*I),g=2*Math.atan2(6.6,I);for(let S=0;S<=16;S++){let M=E-p*g*(S/16);P.push({x:m(y+6.75*Math.cos(M)),y:d(6.75*Math.sin(M))})}P.push({x:m(b),y:d(6.6)}),u.push({points:P,closed:!1})}break}case"court-tennis":{u.push({points:Le(0,0,m(11.885),d(5.485)),closed:!0,fill:"#2b5f99"});for(let p of[-1,1])u.push({points:[{x:-m(11.885),y:p*d(4.115)},{x:m(11.885),y:p*d(4.115)}],closed:!1}),u.push({points:[{x:p*m(6.4),y:-d(4.115)},{x:p*m(6.4),y:d(4.115)}],closed:!1});u.push({points:[{x:-m(6.4),y:0},{x:m(6.4),y:0}],closed:!1}),u.push({points:[{x:0,y:-d(6.4)},{x:0,y:d(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{u.push({points:Le(0,0,m(3.05),d(3.05)),closed:!0});let x=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[y,I,P]of x)u.push({points:Le(y*m(3.05),I*d(3.05),m(.3),d(.3)),closed:!0,fill:P,ink:P});break}default:return[]}return u.map(p=>({...p,points:p.points.map(b=>ws(b.x,b.y,a,f,n,o))}))}function oo(e){if(e.role!=="stage"||!ft(e.stageKind))return[];let t=null;if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null&&e.width>0&&e.height>0&&[e.x,e.y,e.width,e.height].every(Number.isFinite))t={cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height};else if(e.points&&e.points.length>=3&&e.points.every(n=>Number.isFinite(n.x)&&Number.isFinite(n.y))){let n=e.points.map(l=>l.x),o=e.points.map(l=>l.y),r=Math.min(...n),i=Math.max(...n),s=Math.min(...o),a=Math.max(...o),f=Math.max(1,i-r),c=Math.max(1,a-s);t={cx:r+f/2,cy:s+c/2,width:f,height:c}}return t?Es({kind:e.stageKind,...t}):[]}var As=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,vs=/[\s"'<>`\\]/;function Cs(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return As.test(e);if(vs.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function ro(e){let t=e.trim();return Cs(t)?t:null}var ln="seatlayer.event-configuration/1";var Je=100,_s=120,ks=2e5,Ts=1e4,Ls=/^[a-f0-9]{64}$/,Os=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function mt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ze(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Bs(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function io(e){return!Array.isArray(e)||e.length>ks||!e.every(t=>ze(t,Je))?null:[...new Set(e)].sort()}function Fs(e){return!mt(e)||!ze(e.chartId,Je)||!ze(e.version,Je)||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 un(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function Ds(e){return mt(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&un(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Ns(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>Ts)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!mt(a)||!ze(a.id,Je)||!ze(a.objectId,Je)||!n.has(a.objectId)||!Os.has(String(a.kind))||!un(a.heightM,.05,50)||a.baseElevationM!==void 0&&!un(a.baseElevationM,-10,100))return null;let f=Ds(a.occlusion);if(!f||o.has(a.id)||r.has(a.objectId))return null;let c=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?ro(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!c||a.kind!=="screen"||++i>1))return null;o.add(a.id),r.add(a.objectId),s.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:f,...c?{contentImageUrl:c}:{}})}return s.sort((a,f)=>a.id.localeCompare(f.id))}function Gs(e){let t=[];if(!mt(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==ln&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${ln}`}),ze(e.id,Je)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),ze(e.label,_s)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Bs(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=Fs(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let o=mt(e.overlay)?e.overlay:null,r=io(o?.objectIds),i=io(o?.productionKillSeatIds),s=r?Ns(o?.productionElements,r):null;return(!o||!r||!i)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),s===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!r||!i||s===null?{issues:t}:{issues:t,value:{schema:ln,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function so(e){let t=Gs(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function js(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 Hs(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),i=Math.sin(o),s=e.x-t.x,a=e.y-t.y;return{x:t.x+s*r-a*i,y:t.y+s*i+a*r}}function ao(e){let t=js(e);if(!t||t.length<2)return null;let n=e.rotation??0,o=Math.abs(n)<1e-6?t:t.map(f=>Hs(f,{x:t.reduce((c,l)=>c+l.x,0)/t.length,y:t.reduce((c,l)=>c+l.y,0)/t.length},n)),r=1/0,i=1/0,s=-1/0,a=-1/0;for(let f of o)r=Math.min(r,f.x),i=Math.min(i,f.y),s=Math.max(s,f.x),a=Math.max(a,f.y);return!Number.isFinite(r)||s-r<1e-6||a-i<1e-6?null:{minX:r,minY:i,maxX:s,maxY:a}}var Xs=5,Us=3,Vs=.92,Ys=1.9,Ks=2,Ws=.6,zs=1,Zs=.06;function $s(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?Ct:ft(e.stageKind)?Zs:zs}function co(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=-1/0;for(let s of fo(e)){let a=s.baseHeightM??0;for(let f of s.objects){if(f.type!=="shape"||f.role!=="stage")continue;let c=ao(f);c&&(t=Math.min(t,c.minX),n=Math.min(n,c.minY),o=Math.max(o,c.maxX),r=Math.max(r,c.maxY),i=Math.max(i,a+$s(f)))}}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minX:t,minY:n,maxX:o,maxY:r,deckTopM:i}}function Qs(e,t,n,o){let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let m of e)Number.isFinite(m.eyeHeightM)&&(r=Math.min(r,m.x),s=Math.max(s,m.x),i=Math.min(i,m.y),a=Math.max(a,m.y));if(!Number.isFinite(r))return null;let f=r*t,c=i*t,l=Math.max(1,Math.ceil((s-r)*t/n)+1),u=Math.max(1,Math.ceil((a-i)*t/n)+1),h=new Float64Array(l*u).fill(-1/0);for(let m of e){if(!Number.isFinite(m.eyeHeightM))continue;let d=m.eyeHeightM-Ce,p=Math.min(l-1,Math.max(0,Math.floor((m.x*t-f)/n))),x=Math.min(u-1,Math.max(0,Math.floor((m.y*t-c)/n)))*l+p,y=d+o;y>h[x]&&(h[x]=y)}return{cellM:n,minX:f,minY:c,cols:l,rows:u,top:h}}function qs(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 lo(e,t,n={}){let o=new Map;if(!t||!e.length)return o;let r=n.metresPerChartUnit??Q,i=n.cellM??Ws,s=n.chairBackM??Vs,a=n.selfRowSkipM??Ks,f=n.clearThreshold??.9,c=n.partialThreshold??.25,l=Math.max(1,n.columns??Xs),u=Math.max(1,n.rows??Us),h=Qs(e,r,i,s);if(!h)return o;let m=(t.maxX-t.minX)*r,d=(t.maxY-t.minY)*r,p=m>=d,b=(t.minX+t.maxX)/2*r,x=(t.minY+t.maxY)/2*r,y=[];for(let P=0;P<l;P++){let E=(P+.5)/l-.5,g=p?b+E*m:b,S=p?x:x+E*d;for(let M=0;M<u;M++){let R=t.deckTopM+(u===1?0:M/(u-1)*Ys);y.push({x:g,y:S,z:R})}}let I=i/2;for(let P of e){if(!Number.isFinite(P.eyeHeightM))continue;let E=P.x*r,g=P.y*r,S=P.eyeHeightM,M=0,R=1/0;for(let T of y){let k=T.x-E,_=T.y-g,A=Math.hypot(k,_);if(!(A>a)){M++;continue}let C=k/A,L=_/A,F=0;for(let O=a;O<A;O+=I){let B=qs(h,E+C*O,g+L*O);if(!(!Number.isFinite(B)||B>=S)&&B>S+(T.z-S)*O/A){F=O;break}}F?R=Math.min(R,F):M++}let v=M/y.length;v>=f||o.set(P.id,{seatId:P.id,mark:v<c?"obstructedView":"restrictedView",visibleFraction:v,totalRays:y.length,atDistanceM:Number.isFinite(R)?R:0})}return o}function uo(e,t){if(!t.size)return 0;let n=0;for(let o of e){let r=t.get(o.id);if(!r)continue;let i=o.commercial;i?.restrictedView!==void 0||i?.obstructedView!==void 0||(o.commercial={...i,[r.mark]:!0},n++)}return n}function fn(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Tt=Math.PI/180;var ht=16;function mn(e,t,n,o){let r=n*Tt,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function yo(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return Kn(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let c=0;c<t;c++)s.push(mn(c*n,0,r,i));return s}let a=o/(t-1)*Tt,f=n/(2*Math.sin(Math.abs(a)/2));for(let c=0;c<t;c++){let l=c*a,u=f*Math.sin(l),h=-f+f*Math.cos(l);s.push(mn(u,h,r,i))}return s}function xo(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function Js(e,t){let n=xo(e);return yo(e).map((o,r)=>{let i=n.get(r),s=fn(i),a=$n(e,r,i),f={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:on(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(f).some(c=>c!==void 0&&c!==!1&&c!=="")?f:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle??e.seatLabelStyle}})}function ea(e){let t=[];for(let n of Js(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 ta(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function na(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,u,h,m)=>{let d=o.get(l),p=fn(d),b=d?.label??`${e.label}-${l+1}`,x=e.displayLabel??e.label;return{index:l,label:b,displayLabel:d?.displayLabel??`${x}-${l+1}`,x:u+(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)+ht,u=e.rotation*Tt,h=Math.max(0,Math.min(360,e.seatArc??360));if(h>=360||n===1){for(let b=0;b<n;b++){let x=u+b/n*2*Math.PI;t.push(r(b,e.center.x+l*Math.cos(x),e.center.y+l*Math.sin(x)))}return t}let m=h*Tt,d=(2*Math.PI-m)/2,p=u+d;for(let b=0;b<n;b++){let x=p+b/(n-1)*m;t.push(r(b,e.center.x+l*Math.cos(x),e.center.y+l*Math.sin(x)))}return t}let i=e.width??80,s=e.height??50,a=ta(e),f=["top","bottom","left","right"],c=0;for(let l of f){let u=a[l];for(let h=0;h<u;h++){let m,d;l==="top"?(m=-i/2+(h+.5)*i/u,d=-s/2-ht):l==="bottom"?(m=-i/2+(h+.5)*i/u,d=s/2+ht):l==="left"?(m=-i/2-ht,d=-s/2+(h+.5)*s/u):(m=i/2+ht,d=-s/2+(h+.5)*s/u);let p=mn(m,d,e.rotation,e.center);t.push(r(c++,p.x,p.y,l))}}return t}function oa(e){return na(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 ra(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 mo(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,a=t[r].x,f=t[r].y;s>e.y!=f>e.y&&e.x<(a-i)*(e.y-s)/(f-s)+i&&(n=!n)}return n}function ia(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),a=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=a+1e-7})}function hn(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function be(e,t,n){return mo(e,t)&&!hn(n).some(o=>mo(e,o)||ia(e,o))}function kt(e){if(!e.length)return{x:0,y:0};let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;return{x:t/e.length,y:n/e.length}}function go(e){switch(e.type){case"row":{let t=yo(e),n=xo(e),o=0,r=0,i=0;for(let s=0;s<t.length;s++){let a=n.get(s);a?.skip||(o+=t[s].x+(a?.dx??0),r+=t[s].y+(a?.dy??0),i++)}return i?{x:o/i,y:r/i}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return kt(e.points);case"section":return kt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?kt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function ho(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function sa(e,t){if(e.type!=="gaArea"||!ho(e.points,t.outline))return!1;let n=hn(e.holes),o=hn(t.holes);return n.length===o.length&&n.every((r,i)=>ho(r,o[i]))}function aa(e,t,n=e.filter(r=>r.type==="section"),o=go(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(s=>(s.logicalSectionId??s.id)===r&&(sa(t,s)||be(o,s.outline,s.holes))):void 0)??n.find(s=>be(o,s.outline,s.holes))}function fo(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 po(e,t,n,o,r,i,s,a,f){let c=[],l=e.filter(p=>p.type==="section"),u=zn(e),h=p=>!p?.eventConfigurationId||p.eventConfigurationId===o&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===f),m=p=>eo(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=ea(p):p.type==="table"?b=oa(p):p.type==="booth"&&(b=ra(p)),!b.length)continue;for(let E of b)E.viewUrl&&!h(E.viewMeta)&&(E.viewUrl=void 0,E.viewMeta=void 0);if(p.type==="row"){let E=u.get(p.id);if(E){let g=new Map((p.overrides??[]).map(S=>[S.index,S]));for(let S of b){let M=Number(S.id.slice(S.id.lastIndexOf(":")+1));if(!Number.isInteger(M))continue;S.logicalRowId=E.groupId,S.logicalSeatIndex=E.adjacencyOffset+M,g.get(M)?.displayLabel||(S.displayLabel=on(p,M,E)),!S.viewUrl&&E.viewFromSeatUrl&&h(E.viewFromSeatMeta)&&(S.viewUrl=E.viewFromSeatUrl,S.viewMeta=E.viewFromSeatMeta);let R=g.get(M)?.confidenceEvidence;S.confidenceEvidence=d(R,"exact-seat")??d(p.confidenceEvidence,"row-representative")??d(E.confidenceEvidence,"row-representative")}}}let x=aa(e,p,l,p.type==="row"?kt(b):go(p)),y=x?.viewFromSeatUrl,P=(x?.zone?t?.find(E=>E.id===x.zone):void 0)?.focalPoint??n;for(let E of b){if(!E.confidenceEvidence){let g=Number(E.id.slice(E.id.lastIndexOf(":")+1)),S=(p.type==="row"||p.type==="table")&&Number.isInteger(g)?p.overrides?.find(M=>M.index===g)?.confidenceEvidence:void 0;E.confidenceEvidence=d(S,"exact-seat")??(p.type==="row"?d(p.confidenceEvidence,"row-representative"):void 0)}E.confidenceEvidence??=d(x?.confidenceEvidence,"section-representative")??(s?d(s.evidence,s.coverage):void 0),!E.viewUrl&&y&&h(x?.viewFromSeatMeta)&&(E.viewUrl=y,E.viewMeta=x?.viewFromSeatMeta),!E.viewUrl&&i&&h(i.meta)&&(E.viewUrl=i.url,E.viewMeta=i.meta),x&&(E.sectionId=x.logicalSectionId??x.id),x?.zone&&(E.zoneId=x.zone),P&&(E.focalPoint={...P})}c.push(...b)}return c}function et(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,f=po(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&bo(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,f);for(let c of f)c.floorId=r.id;for(let c of f)o.push(c)}return o}let n=po(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&&bo(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),ca(e,n,t)}function ca(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||uo(t,lo(t,co(e))),t}function bo(e,t,n,o){let r=e.filter(u=>u.type==="section"),i=n>0||r.some(u=>u.height!==void 0||u.rake!==void 0||(u.elevation??0)>0);if(!r.length||!i||!t){for(let u of o)u.eyeHeightM=n+Ce;return}let s=new Array(o.length),a=new Map;for(let u of r)a.has(u.id)||a.set(u.id,u);let f=new Map,c=new Map;for(let u=0;u<o.length;u++){let h=o[u],d=(h.sectionId?a.get(h.sectionId)??r.find(b=>b.logicalSectionId===h.sectionId&&be({x:h.x,y:h.y},b.outline,b.holes)):void 0)??r.find(b=>be({x:h.x,y:h.y},b.outline,b.holes))??null;if(s[u]=d,!d)continue;f.has(d.id)||f.set(d.id,Ge(d,{floorBaseHeightM:n}));let p=c.get(d.id);p?p.push(u):c.set(d.id,[u])}let l=new Array(o.length).fill(void 0);for(let[u,h]of c){let m=f.get(u);if(!m)continue;let d=m.rake>0?Math.tan(m.rake*Math.PI/180):0,p=At(u,o,h,t);for(let b of p.rows){let x=b.blockDepth*Q*d,y=m.height+x;for(let I of b.seatIndices)l[I]=y}}for(let u=0;u<o.length;u++){let h=o[u],m=s[u];if(!m){h.eyeHeightM=n+Ce;continue}let d=f.get(m.id);h.eyeHeightM=(l[u]??d.height)+Ce}}var So=Te(require("earcut"),1),dn=Te(require("polygon-clipping"),1);function ye(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let r=e[n],i=e[(n+1)%o];t+=r.x*i.y-i.x*r.y}return t/2}function xe(e,t,n){let o=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let s=e[r],a=e[i];s.y>n!=a.y>n&&t<(a.x-s.x)*(n-s.y)/(a.y-s.y)+s.x&&(o=!o)}return o}var w=Q,la=.002;function ua(e,t,n){let o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.max(o,r,i);if(s<1e-9)return!0;let a=(o+r+i)/2;return 2*Math.sqrt(Math.max(0,a*(a-o)*(a-r)*(a-i)))/s<la}var Ze=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=o}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let o=new Float32Array(n);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Bt=class{constructor(){this.pos=new Ze;this.nor=new Ze;this.col=new Ze;this.flr=new Ze;this.mat=new Ze;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,o,r,i,s=i,a=i){ua(t,n,o)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(t,n,o,r,i,s,a,f=a,c=a){[...t,...n,...o].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(f[0],f[1],f[2]),this.col.push3(c[0],c[1],c[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function fa(e,t,n){let o=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=n[0]-e[0],a=n[1]-e[1],f=n[2]-e[2],c=r*f-i*a,l=i*s-o*f,u=o*a-r*s,h=Math.hypot(c,l,u)||1;return c/=h,l/=h,u/=h,[c,l,u]}function ma(e,t){let n=[...e],o=[];for(let s of e)o.push(s.x,s.y);let r=[];if(t){for(let s of t)if(!(s.length<3)){r.push(n.length);for(let a of s)n.push(a),o.push(a.x,a.y)}}let i=(0,So.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function _e(e){return ye(e)<0?[...e].reverse():e}var ha=3;function da(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(m,d,p,b)=>Math.abs(o({x:(m.x+d.x)/2,y:(m.y+d.y)/2})-(p+b)/2),f=(e.x+t.x+n.x)/3,c=(e.y+t.y+n.y)/3,l=(r+i+s)/3,u=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:f,y:c})-l)),h=(m,d,p)=>{let b=Math.abs(o({x:(m+f)/2,y:(d+c)/2})-(p+l)/2);b>u&&(u=b)};return h((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),h((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),h((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),u}function dt(e,t,n,o,r){if(r<=0)return da(e,t,n,o);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(dt(e,i,a,o,r-1),dt(i,t,s,o,r-1),dt(a,s,n,o,r-1),dt(i,s,a,o,r-1))}function pt(e,t,n,o,r,i,s,a){if(s>0){let h={x:(t.x+n.x)/2,y:(t.y+n.y)/2},m={x:(n.x+o.x)/2,y:(n.y+o.y)/2},d={x:(o.x+t.x)/2,y:(o.y+t.y)/2};pt(e,t,h,d,r,i,s-1,a),pt(e,h,n,m,r,i,s-1,a),pt(e,d,m,o,r,i,s-1,a),pt(e,h,m,d,r,i,s-1,a);return}let f=[t.x*w,r(t),t.y*w],c=[n.x*w,r(n),n.y*w],l=[o.x*w,r(o),o.y*w];if(a){e.triN(f,c,l,a(t),a(n),a(o),i);return}let u=fa(f,c,l);u[1]<0&&(u=[-u[0],-u[1],-u[2]]),e.tri(f,c,l,u,i)}var pa=8;function Mo(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,f,c)=>{if(c>0){let l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},u=t(l);if(Math.abs(u-(a+f)/2)>n){r(i,l,a,u,c-1),r(l,s,u,f,c-1);return}}o.push(i)};for(let i=0;i<e.length;i++){let s=e[i],a=e[(i+1)%e.length];r(s,a,t(s),t(a),pa)}return o}function Lt(e,t){if(e.length<3)return e;let n=[];for(let r of e){let i=n[n.length-1];i&&Math.hypot(r.x-i.x,r.y-i.y)<t||n.push(r)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let o=[];for(let r=0;r<n.length;r++){let i=o.length?o[o.length-1]:n[(r-1+n.length)%n.length],s=n[r],a=n[(r+1)%n.length],f=a.x-i.x,c=a.y-i.y,l=Math.hypot(f,c);l>t&&Math.abs((s.x-i.x)*c-(s.y-i.y)*f)/l<t||o.push(s)}return o.length>=3?o:n}var Ot=.001*Ie*.1;function W(e,t,n,o,r,i,s,a,f=1/0,c){if(!t||t.length<3||(f===void 0&&(f=1/0),Math.abs(ye(t))<1e-4))return;let l=Lt(Mo(Lt(_e(t),Ot),o,f),Ot),u=n?.map(g=>Lt(Mo(Lt(_e(g),Ot),o,f),Ot)).filter(g=>g.length>=3&&Math.abs(ye(g))>=1e-4),{pts:h,tris:m}=ma(l,u),d=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],b=[s[0]*a.top,s[1]*a.top,s[2]*a.top],x=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],y=0;if(Number.isFinite(f))for(;y<ha;y++){let g=0;for(let S=0;S<m.length;S+=3){let M=dt(h[m[S]],h[m[S+1]],h[m[S+2]],o,y);M>g&&(g=M)}if(g<=f)break}for(let g=0;g<m.length;g+=3){let S=h[m[g]],M=h[m[g+1]],R=h[m[g+2]];pt(e,S,M,R,o,d,y,c);let v=[S.x*w,r,S.y*w],T=[M.x*w,r,M.y*w],k=[R.x*w,r,R.y*w];e.tri(v,k,T,[0,-1,0],p)}let I=g=>{if(y<=0)return g;let S=1<<y,M=[];for(let R=0;R<g.length;R++){let v=g[R],T=g[(R+1)%g.length];for(let k=0;k<S;k++){let _=k/S;M.push({x:v.x+(T.x-v.x)*_,y:v.y+(T.y-v.y)*_})}}return M},P=tn(l),E=[{ring:I(l),flip:!1}];if(u)for(let g of u)g.length>=3&&E.push({ring:I(g),flip:!0});for(let{ring:g,flip:S}of E)for(let M=0;M<g.length;M++){let R=g[M],v=g[(M+1)%g.length],T=(v.x-R.x)*w,_=(v.y-R.y)*w,A=-T,C=Math.hypot(_,A)||1;_/=C,A/=C;let L=(R.x+v.x)/2-P.x,F=(R.y+v.y)/2-P.y,O=_*L+A*F;S&&(O=-O),O<0&&(_=-_,A=-A);let B=[_,0,A],N=[R.x*w,o(R),R.y*w],H=[v.x*w,o(v),v.y*w],D=[R.x*w,r,R.y*w],U=[v.x*w,r,v.y*w];e.tri(N,H,U,B,b,b,x),e.tri(N,U,D,B,b,x,x)}}function Io(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),i=new Float32Array(t),s=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),i.set(f.floor,a),s.set(f.material,a),a+=f.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function Pe(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=_e(e),r=o.length,i=[];for(let a=0;a<r;a++){let f=o[a],c=o[(a+1)%r],l=c.x-f.x,u=c.y-f.y,h=Math.hypot(l,u)||1;i.push({x:u/h,y:-l/h})}let s=[];for(let a=0;a<r;a++){let f=o[a],c=i[(a-1+r)%r],l=i[a],u=c.x+l.x,h=c.y+l.y,m=Math.hypot(u,h),d=()=>{s.push([f.x+c.x*t,f.y+c.y*t]),s.push([f.x+l.x*t,f.y+l.y*t])};if(m<1e-9){d();continue}u/=m,h/=m;let p=u*c.x+h*c.y,b=1/Math.max(p,1e-6);if(!Number.isFinite(b)||b>n){d();continue}s.push([f.x+u*t*b,f.y+h*t*b])}if(s.length<3)return e;try{let a=dn.default.union([[...s,s[0]]]),f=null,c=-1/0;for(let u of a){let h=Math.abs(ye(u[0].map(([m,d])=>({x:m,y:d}))));h>c&&(c=h,f=u[0])}if(!f)return e;let l=f.map(([u,h])=>({x:u,y:h}));if(l.length>1){let u=l[0],h=l[l.length-1];Math.abs(u.x-h.x)<1e-9&&Math.abs(u.y-h.y)<1e-9&&l.pop()}return l.length>=3?l:e}catch{return e}}function He(e,t,n=2.5){if(e.length<3)return[];if(t<=0)return e;let o=_e(e),r=o.length,i=[];for(let f=0;f<r;f++){let c=o[f],l=o[(f+1)%r],u=Math.hypot(l.x-c.x,l.y-c.y)||1;i.push({x:-(l.y-c.y)/u,y:(l.x-c.x)/u})}let s=[],a=[];for(let f=0;f<r;f++){let c=o[f],l=i[(f-1+r)%r],u=i[f],h=l.x+u.x,m=l.y+u.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){s.push({x:c.x+l.x*t,y:c.y+l.y*t},{x:c.x+u.x*t,y:c.y+u.y*t}),a.push(f,f);continue}h/=d,m/=d,s.push({x:c.x+h*t*p,y:c.y+m*t*p}),a.push(f)}for(let f=0;f<s.length;f++){let c=(f+1)%s.length,l=a[f],u=a[c];if(u!==(l+1)%r)continue;let h=o[l],m=o[u];if((s[c].x-s[f].x)*(m.x-h.x)+(s[c].y-s[f].y)*(m.y-h.y)<=0)return[]}try{let f=dn.default.intersection([[...s.map(d=>[d.x,d.y]),[s[0].x,s[0].y]]],[[...o.map(d=>[d.x,d.y]),[o[0].x,o[0].y]]]),c=null,l=0;for(let d of f){let p=Math.abs(ye(d[0].map(([b,x])=>({x:b,y:x}))));p>l&&(l=p,c=d[0])}if(!c)return[];let u=c.map(([d,p])=>({x:d,y:p})),h=u[0],m=u[u.length-1];return u.length>1&&Math.abs(h.x-m.x)<1e-9&&Math.abs(h.y-m.y)<1e-9&&u.pop(),u.length>=3?_e(u):[]}catch{return[]}}function Ft(e,t,n,o,r=28){let i=[];for(let s=0;s<r;s++){let a=s/r*Math.PI*2;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function bt(e,t,n,o){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+o},{x:e,y:t+o}]}var yt=3,$e=.38,xt=.24;function ba(e){if(e.length<3)return null;let t=e[0],n=e[Math.floor(e.length/2)],o=e[e.length-1],r=(n.x-t.x)*w,i=(n.y-t.y)*w,s=(o.x-t.x)*w,a=(o.y-t.y)*w,f=2*(r*a-i*s);if(Math.abs(f)<1e-7)return null;let c=r*r+i*i,l=s*s+a*a,u=(c*a-l*i)/f+t.x*w,h=(r*l-s*c)/f+t.y*w,m=Math.hypot(t.x*w-u,t.y*w-h);return m<1||m>200||!Number.isFinite(m)||e.some(d=>Math.abs(Math.hypot(d.x*w-u,d.y*w-h)-m)>.03)?null:{x:u,z:h,radius:m}}function Ro(e){let t=[],n=new Map,o=(f,c)=>`${Math.floor(f/yt)},${Math.floor(c/yt)}`;for(let f of e)for(let c of f.rows){for(let u of c.pts){let h=u.x*w,m=u.y*w,d=o(h,m),p=n.get(d)??[];p.push({x:h,z:m,y:c.y,floor:f.floorIndex}),n.set(d,p)}if(c.patch||c.pts.length<2)continue;let l=ba(c.pts);for(let u of[0,c.pts.length-1]){let h=c.pts[u],m=c.pts[u===0?1:u-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:c,point:h,x:h.x*w,z:h.y*w,dx:d/b,dz:p/b})}}let r=new Map;t.forEach((f,c)=>{let l=o(f.x,f.z),u=r.get(l)??[];u.push(c),r.set(l,u)});let i=(f,c)=>{let l=Math.floor(f/yt),u=Math.floor(c/yt);return[-1,0,1].flatMap(h=>[-1,0,1].map(m=>`${l+h},${u+m}`))},s=new Map;t.forEach((f,c)=>{let l=-1,u=1/0,h=!1;for(let m of i(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,x=p.z-f.z,y=Math.hypot(b,x);if(y<$e*2+.45||y>yt)continue;let I=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,P=Math.min((b*f.dx+x*f.dz)/y,(-b*p.dx-x*p.dz)/y);(I?P<.8:P<.98)||!I&&(Math.abs(b*f.dz-x*f.dx)>.15||Math.abs(b*p.dz-x*p.dx)>.15)||(y<u-.02?(l=d,u=y,h=!1):Math.abs(y-u)<=.02&&(h=!0))}l>=0&&!h&&s.set(c,l)});let a=[];for(let[f,c]of s){if(f>=c||s.get(c)!==f)continue;let l=t[f],u=t[c],h=Math.hypot(u.x-l.x,u.z-l.z),m=(u.x-l.x)/h,d=(u.z-l.z)/h,p=!1;for(let x of i((l.x+u.x)/2,(l.z+u.z)/2))for(let y of n.get(x)??[]){if(y.floor!==l.floorIndex||Math.abs(y.y-l.row.y)>.75)continue;let I=(y.x-l.x)*m+(y.z-l.z)*d,P=Math.abs((y.x-l.x)*d-(y.z-l.z)*m);I>.01&&I<h-.01&&P<xt+$e&&(p=!0)}if(p)continue;let b=(x,y)=>({x:(l.x+m*x-d*y)/w,y:(l.z+d*x+m*y)/w});a.push({sections:[l.sectionId,u.sectionId],blocks:[l.row.blockId,u.row.blockId],floorIndex:l.floorIndex,ends:[l.point,u.point],clearWidthM:h-2*$e,heightM:(l.row.y+u.row.y)/2,outline:[b($e,-xt),b(h-$e,-xt),b(h-$e,xt),b($e,xt)]})}return a}var ya=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Po(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 xa(e){let t=ya.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function ne(e){let t=xa(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function ga(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function te(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function we(e,t){let n=ga(e);return te(e,[n,n,n],t)}function wo({r:e,g:t,b:n}){let o=e/255,r=t/255,i=n/255,s=Math.max(o,r,i),a=Math.min(o,r,i),f=(s+a)/2;if(s===a)return{h:0,s:0,l:f};let c=s-a,l=f>.5?c/(2-s-a):c/(s+a),u;return s===o?u=((r-i)/c+(r<i?6:0))/6:s===r?u=((i-o)/c+2)/6:u=((o-r)/c+4)/6,{h:u,s:l,l:f}}var Dt=["available","held","sold","selected","dimmed"];function Eo(e){let t=Dt.indexOf(e);return t<0?0:t}var Ao={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var pn={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]},bn={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 Ma=.15,Sa=1.6;function vo(e){return Wn(e??1,Ma,Sa)}var Ia=.15,Ra=.9,Pa=1.76;function Co(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function wa(){return{background:{top:[...bn.top],bottom:[...bn.bottom]},sky:Co(null),structure:pn,seatStates:{...Ao},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function Ea(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 _o(e){let t=wa();e??={};let n=ne(e.background);if(n){t.background={top:z(n,Ra),bottom:z(n,Pa)},t.sky=Co(n);let a={};for(let[c,l]of Object.entries(pn))a[c]=te(l,n,Ia);n[0]*.2126+n[1]*.7152+n[2]*.0722>.55&&(a.ground=z(n,.86)),t.structure=a}let o=ne(e.selectionColor)??ne(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=vo(r));let i=Object.fromEntries(Object.entries(e.venue3d??{}).filter(([,a])=>a!=null)),s={...Ea(n),...i};if(s){let a=ne(s.deck),f=ne(s.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),f&&(t.structure={...t.structure,tierWall:f,gaWall:f}),t.materials.seat=ne(s.seat),t.materials.shell=ne(s.shell),typeof s.roughness=="number"&&Number.isFinite(s.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,s.roughness)))}return t}function ko(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}function To(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=!1;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(i=!0,s.x<t&&(t=s.x),s.y<n&&(n=s.y),s.x>o&&(o=s.x),s.y>r&&(r=s.y));return i?{minX:t,minY:n,maxX:o,maxY:r}:null}function tt(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var Aa=[{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"}],zf=new Map(Aa.map(e=>[e.key,e]));var va={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 Lo(e){let t=e?.[0];return t&&va[t]||"#3b82f6"}var Ca=[{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"}],Zf=new Map(Ca.map(e=>[e.key,e]));var _a=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],$f=new Set(_a);function gt(e){if(e.length<3)return e.map(i=>({...i}));let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r.map(i=>({...i})):t.map(i=>({...i}))}var ar=Te(require("polygon-clipping"),1);var Y={top:1,wallBottom:.58,bottomCap:.4};function Qe(e,t){if(!e)return t;let n=z(we(e,.4),.62);return te(t,n,.22)}function Oo(e,t){return e?te(t,z(we(e,.25),.74),.62):t}function Bo(e,t){return e?te(t,z(we(e,.08),.9),.82):t}function Fo(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let o=new Map;for(let i of t){if(!i.sectionId)continue;let s=o.get(i.sectionId);s||(s=new Map,o.set(i.sectionId,s)),s.set(i.categoryKey,(s.get(i.categoryKey)??0)+1)}let r=new Map;for(let[i,s]of o){let a=0,f=0,c=0,l=0;for(let[u,h]of s){let m=ne(n.get(u));m&&(a+=m[0]*h,f+=m[1]*h,c+=m[2]*h,l+=h)}l>0&&r.set(i,[a/l,f/l,c/l])}return r}function Do(e,t){return ne(e.color)??t.get(e.logicalSectionId??e.id)??null}var Mn=Te(require("polygon-clipping"),1);var gn=Te(require("polygon-clipping"),1);var Go=[{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}}],jo=Go.map(e=>e.key),ka=new Map(Go.map(e=>[e.key,e]));function No(e){return typeof e=="string"&&ka.has(e)}function Ho(e,t){return No(e)?e:No(t?.seatGlyph)?t.seatGlyph:"circle"}var de={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Ta=.44,La=.15,Oa=.3,Ba=.24;function Xo(e){return e===void 0||!Number.isFinite(e)||e<=0?Ba:Math.min(Oa,Math.max(La,e*Ta))}var Fa=.05,Uo=.45,Da=Uo+Fa,Na=.92;var rm=[{part:de.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:de.pad,min:[-1,.36,-.95],max:[1,Uo,1]},{part:de.back,min:[-1,Da,-1],max:[1,Na,-.72]},{part:de.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:de.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:de.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:de.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:de.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:de.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:de.leg,min:[.62,0,.48],max:[.82,.37,.7]}],im=[{part:de.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:de.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:de.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:de.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:de.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function Vo(e,t,n,o){let r=new Float32Array(t),i=c=>e[c*3],s=c=>e[c*3+2],a=0,f=(c,l)=>{let u=l-c;for(let h=c;h<l;h++){let[m,d]=o(h),p=m-i(h),b=d-s(h);if(u>=2){let x=Math.max(c,h-1),y=Math.min(l-1,h+1),I=i(y)-i(x),P=s(y)-s(x),E=Math.hypot(I,P);if(E>1e-6){let g=-P/E,S=I/E;g*p+S*b<0&&(g=-g,S=-S),p=g,b=S}}r[h]=p===0&&b===0?0:Math.atan2(p,b)}};for(let c=1;c<=t;c++)(c===t||n(c)!==n(a))&&(f(a,c),a=c);return r}var Nt=.22;var Ga=.42;function ja(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let d of e)d.x<o&&(o=d.x),d.y<r&&(r=d.y),d.x>i&&(i=d.x),d.y>s&&(s=d.y);let a=Math.max(i-o,1e-6),f=Math.max(s-r,1e-6),c=Math.max(Math.sqrt(a*f/t),1e-6),l=Math.max(1,Math.ceil(a/c)+1),u=Math.max(1,Math.ceil(f/c)+1),h=new Map,m=(d,p)=>{let b=Math.min(l-1,Math.max(0,Math.floor((d-o)/c)));return Math.min(u-1,Math.max(0,Math.floor((p-r)/c)))*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)/c))),x=Math.min(u-1,Math.max(0,Math.floor((p.y-r)/c))),y=1/0;for(let I=1;I<=4;I++){for(let P=x-I;P<=x+I;P++)if(!(P<0||P>=u))for(let E=b-I;E<=b+I;E++){if(E<0||E>=l||I>1&&Math.abs(P-x)<I&&Math.abs(E-b)<I)continue;let g=h.get(P*l+E);if(g)for(let S of g){if(S===d)continue;let M=Math.hypot(e[S].x-p.x,e[S].y-p.y);M<y&&(y=M)}}if(Number.isFinite(y)&&y<=I*c)break}n[d]=y}return n}function Ha(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-Ce):0}function Yo(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),f=new Float32Array(s),c=new Float32Array(s*3),l=new Float32Array(s),u=new Float32Array(s),h=new Float32Array(s),m=new Float32Array(s),d=new Float32Array(s*3),p=new Map,b=ja(e);for(let x=0;x<s;x++){let y=e[x],P=(n?.seatPitchU(x)??b[x])*w;l[x]=Number.isFinite(P)?Math.max(.06,Math.min(Nt,P*Ga)):Nt,u[x]=Xo(Number.isFinite(P)?P:void 0);let E=Ho(y.glyph,{seatGlyph:i?.get(y.categoryKey)});h[x]=jo.indexOf(E),m[x]=y.wheelchairSpaceType==="no-seat"?0:1,a[x*3]=y.x*w,a[x*3+1]=n?n.seatDeckY(x):Ha(y),a[x*3+2]=y.y*w,f[x]=Eo(t?t(y):"available");let g=ne(r?.get(y.categoryKey)??"#6e7bff")??[.43,.48,1];if(c[x*3]=g[0],c[x*3+1]=g[1],c[x*3+2]=g[2],y.accessibility?.length){let S=ne(Lo(y.accessibility));S&&(d[x*3]=S[0],d[x*3+1]=S[1],d[x*3+2]=S[2])}p.set(y.id,x)}return{count:s,iPosition:a,iState:f,iCategory:c,iMaxRadius:l,iRing:d,idToIndex:p,iChairWidth:u,iGlyph:h,iPhysicalSeat:m,iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}var Zo=Te(require("earcut"),1);var Xa=.58,Ko=.01,Re=Nt*1.5*Ie,Ua=.5,Va=.6;function Ya(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],f=e[Math.min(n-1,s+1)],c=f.x-a.x,l=f.y-a.y,u=Math.hypot(c,l);if(u<1e-9){o.push([0,0]);continue}c/=u,l/=u,o.push([-l,c])}let r=0;for(let s=0;s<n;s++)r+=(e[s].x-t.x)*o[s][0]+(e[s].y-t.y)*o[s][1];return r<0?o.map(([s,a])=>[-s,-a]):o}function Ka(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let f=a.x-s.x,c=a.y-s.y,l=Math.hypot(f,c)||1;return{x:f/l,y:c/l}},r=o(n[1],n[0]),i=o(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+r.x*t,y:n[0].y+r.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var Wo=Math.PI/12;function Wa(e){if(e.length<3)return[...e];let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r:[...e]}function $o(e,t){if(!e.length||!(t>0))return[];let n=Wa(e),o=(a,f,c,l)=>{let u=c-f;for(;u<0;)u+=Math.PI*2;for(;u>Math.PI*2;)u-=Math.PI*2;let h=Math.max(1,Math.ceil(u/Wo)),m=t/Math.cos(u/h/2);for(let d=0;d<=h;d++){let p=f+u*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 c=0;for(let m of n)c=Math.max(c,Math.hypot(m.x-a,m.y-f));let l=[],u=Math.max(3,Math.ceil(Math.PI*2/Wo)),h=(c+t)/Math.cos(Math.PI/u);for(let m=0;m<u;m++){let d=m/u*Math.PI*2;l.push({x:a+Math.cos(d)*h,y:f+Math.sin(d)*h})}return l}let r=n.length,i=[];for(let a=0;a<r;a++){let f=n[a],c=n[(a+1)%r];i.push(Math.atan2(-(c.x-f.x),c.y-f.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return tr(s)}function za(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,f=s.y-i.y,c=a*a+f*f,l=c>1e-12?((t-i.x)*a+(n-i.y)*f)/c:0;l<0?l=0:l>1&&(l=1);let u=Math.hypot(t-(i.x+l*a),n-(i.y+l*f));u<o&&(o=u)}return o}function Gt(e){let t=e.map(r=>{let i=0,s=0;for(let c of r.pts)i+=c.x,s+=c.y;let a=r.pts.length||1;i/=a,s/=a;let f=0;for(let c of r.pts){let l=Math.hypot(c.x-i,c.y-s);l>f&&(f=l)}return{cx:i,cy:s,rad:f}}),n=r=>{let i=r.length;return i<=2?[...r]:[r[Math.floor(i*.25)],r[Math.floor(i*.5)],r[Math.floor(i*.75)]]},o=[];for(let r=0;r<e.length;r++){let i=n(e[r].pts),s=[],a=1/0,f=null;for(let l of i){let u=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>=u&&d>=a)continue;let p=za(e[h].pts,l.x,l.y);p<u&&(u=p),e[h].depth<e[r].depth&&p<a&&(a=p,f=e[h].y)}Number.isFinite(u)&&u>0&&s.push(u)}s.sort((l,u)=>l-u);let c=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:c,belowY:f})}return o}function Qo(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let l=r.pts[0],u=l.x-o.x,h=l.y-o.y,m=Math.hypot(u,h)||1;u/=m,h/=m;let d=Math.max(n[t].pitch,.001)*.5;return[{x:l.x+h*d,y:l.y-u*d},{x:l.x-h*d,y:l.y+u*d}]})():[];if(i.length<2)return null;let s=0,a=0;for(let l=1;l<i.length;l++){let u=Math.hypot(i[l].x-i[l-1].x,i[l].y-i[l-1].y);u>1e-6&&(s+=u,a++)}let f=a>0?s/a:0,c=Ka(i,Math.max(f*Va,Re));return{pts:c,nrm:Ya(c,o),front:Math.max(n[t].pitch*Xa,Re),back:Math.max(n[t].pitch*Ua,Re)}}var nt=1.5,qo=.3;function yn(e,t){if(e.length<3)return e;let n=e[0],o=e[e.length-1],r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i),a=-1,f=-1;for(let u=1;u<e.length-1;u++){let h=e[u],m=s>1e-12?Math.abs((h.x-n.x)*i-(h.y-n.y)*r)/s:Math.hypot(h.x-n.x,h.y-n.y);m>a&&(a=m,f=u)}if(a<=t||f<0)return[n,o];let c=yn(e.slice(0,f+1),t),l=yn(e.slice(f),t);return[...c.slice(0,-1),...l]}function Jo(e,t){if(e.length<4)return e;let n=yn([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function Za(e){let t=e.map((o,r)=>{let i=e[(r+1)%e.length];return{a:o,b:i,i:r,minX:Math.min(o.x,i.x),maxX:Math.max(o.x,i.x),minY:Math.min(o.y,i.y),maxY:Math.max(o.y,i.y)}}).sort((o,r)=>o.minX-r.minX),n=(o,r,i)=>(r.x-o.x)*(i.y-o.y)-(r.y-o.y)*(i.x-o.x);for(let o=0;o<t.length;o++){let r=t[o];for(let i=o+1;i<t.length&&t[i].minX<=r.maxX;i++){let s=t[i];if(!(Math.abs(r.i-s.i)===1||Math.abs(r.i-s.i)===e.length-1||r.maxY<s.minY||s.maxY<r.minY)&&n(r.a,r.b,s.a)*n(r.a,r.b,s.b)<=0&&n(s.a,s.b,r.a)*n(s.a,s.b,r.b)<=0)return!0}}return!1}function er(e,t,n){if(e.length<2)return[];let o=n??Gt(e),r=new Map;for(let s=0;s<e.length;s++){let a=r.get(e[s].blockId);a?a.push(s):r.set(e[s].blockId,[s])}let i=[];for(let[,s]of r){let a=[];for(let y of s){let I=e[y].patch;I&&I.length>=3?i.push({outline:[...I],holes:[],topY:e[y].y}):a.push(y)}if(!a.length)continue;a.sort((y,I)=>e[y].depth-e[I].depth);let c=a.map(y=>Qo(e,y,o,t)).filter(y=>y!==null);if(!c.length)continue;let l=(y,I)=>({x:y.pts[I].x-y.nrm[I][0]*(y.front+nt),y:y.pts[I].y-y.nrm[I][1]*(y.front+nt)}),u=(y,I)=>({x:y.pts[I].x+y.nrm[I][0]*(y.back+nt),y:y.pts[I].y+y.nrm[I][1]*(y.back+nt)}),h=c[0],m=c[c.length-1],d=[];for(let y=0;y<h.pts.length;y++)d.push(l(h,y));for(let y of c)d.push(u(y,y.pts.length-1));for(let y=m.pts.length-1;y>=0;y--)d.push(u(m,y));for(let y=c.length-1;y>=0;y--)d.push(l(c[y],0));let p=tr(d),b=1/0;for(let y of a)e[y].y<b&&(b=e[y].y);if(!Number.isFinite(b))continue;if(p.length>=3&&Math.abs(ye(p))>1e-6&&c.every(y=>{let I=y.pts[Math.floor(y.pts.length/2)];return xe(p,I.x,I.y)})&&!Za(p)){i.push({outline:Jo(p,qo),holes:[],topY:b});continue}for(let y of $a(c))i.push({outline:y,holes:[],topY:b})}return i}function $a(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+nt,s=n.back+nt;for(let f=0;f<n.pts.length;f++){let c=n.pts[f],l=n.nrm[f];o.push([c.x-l[0]*i,c.y-l[1]*i]),r.push([c.x+l[0]*s,c.y+l[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=gn.default.union(t[0],...t.slice(1)),o=[];for(let r of n){if(!r.length||r[0].length<4)continue;let i=r[0].map(([f,c])=>({x:f,y:c})),s=i[0],a=i[i.length-1];i.length>1&&Math.abs(s.x-a.x)<1e-9&&Math.abs(s.y-a.y)<1e-9&&i.pop(),i.length>=3&&o.push(Jo(i,qo))}return o}catch{return[]}}function tr(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 xn=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let o of n)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let o=!0;for(let r of t)if(!xe(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function zo(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let c=[0,1,0],l=o[0];for(let u=1;u+1<o.length;u++){let h=o[u],m=o[u+1];e.tri([l.x*w,r,l.y*w],[h.x*w,r,h.y*w],[m.x*w,r,m.y*w],c,i)}return}let s=o.map(c=>[c.x,c.y]);s.push(s[0]);let a;try{a=gn.default.intersection([s],t)}catch{return}let f=[0,1,0];for(let c of a){if(!c.length||c[0].length<4)continue;let l=c[0],u=[],h=[];for(let d=0;d<l.length-1;d++)u.push(l[d][0],l[d][1]),h.push([l[d][0],l[d][1]]);if(h.length<3)continue;let m=(0,Zo.default)(u,void 0,2);for(let d=0;d<m.length;d+=3){let p=h[m[d]],b=h[m[d+1]],x=h[m[d+2]];e.tri([p[0]*w,r,p[1]*w],[b[0]*w,r,b[1]*w],[x[0]*w,r,x[1]*w],f,i)}}}function nr(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??Gt(t),f=[0,1,0],c=i&&i.length>=3?[[...i.map(m=>[m.x,m.y]),[i[0].x,i[0].y]]]:null,l=i&&i.length>=3?new xn([[...i]]):null,u=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 E=[...d.patch],g=a[m].belowY??o;if(h(()=>{if(c&&l)zo(e,c,l,E,d.y,r.tread);else{let S=E[0];for(let M=1;M+1<E.length;M++){let R=E[M],v=E[M+1];e.tri([S.x*w,d.y,S.y*w],[R.x*w,d.y,R.y*w],[v.x*w,d.y,v.y*w],f,r.tread)}}}),d.y>g+Ko){let S=0,M=0;for(let R of E)S+=R.x,M+=R.y;S/=E.length,M/=E.length,u(()=>{for(let R=0;R<E.length;R++){let v=E[R],T=E[(R+1)%E.length],k=T.x-v.x,_=T.y-v.y,A=Math.hypot(k,_);if(A<1e-6)continue;let C=_/A,L=-k/A;(v.x-S)*C+(v.y-M)*L<0&&(C=-C,L=-L);let F=[C,0,L],O=[v.x*w,d.y,v.y*w],B=[T.x*w,d.y,T.y*w],N=[v.x*w,g,v.y*w],H=[T.x*w,g,T.y*w];e.tri(O,B,H,F,r.riser),e.tri(O,H,N,F,r.riser)}})}continue}let p=Qo(t,m,a,n);if(!p)continue;let{pts:b,nrm:x,front:y,back:I}=p,P=a[m].belowY??o;for(let E=0;E+1<b.length;E++){let g=b[E],S=b[E+1],M=x[E],R=x[E+1];if(Math.hypot(S.x-g.x,S.y-g.y)<1e-6||M[0]===0&&M[1]===0||R[0]===0&&R[1]===0)continue;let v=[(g.x-M[0]*y)*w,d.y,(g.y-M[1]*y)*w],T=[(S.x-R[0]*y)*w,d.y,(S.y-R[1]*y)*w],k=[(g.x+M[0]*I)*w,d.y,(g.y+M[1]*I)*w],_=[(S.x+R[0]*I)*w,d.y,(S.y+R[1]*I)*w];if(h(()=>{c&&l?zo(e,c,l,[{x:g.x-M[0]*y,y:g.y-M[1]*y},{x:S.x-R[0]*y,y:S.y-R[1]*y},{x:S.x+R[0]*I,y:S.y+R[1]*I},{x:g.x+M[0]*I,y:g.y+M[1]*I}],d.y,r.tread):(e.tri(v,T,_,f,r.tread),e.tri(v,_,k,f,r.tread))}),d.y>P+Ko){let A=[v[0],P,v[2]],C=[T[0],P,T[2]],L=[-M[0],0,-M[1]];u(()=>{e.tri(v,T,C,L,r.riser),e.tri(v,C,A,L,r.riser)})}}}}function Qa(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function or(e,t){return e.filter(n=>n.type!=="shape"||Qa(n,t))}function rr(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:or(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:or(e.objects,t),focal:n,baseHeightM:0,index:0}]}var qa={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Oe(e){return To(e)??qa}function ir(e,t){let n=Pe(e.outline,Re),o=Oe(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&tt(o,Oe(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(f=>[f.x,f.y]);return a.push(a[0]),a};try{let s=Mn.default.difference([i(n)],...r.map(f=>[i(f.outline)])),a=[];for(let f of s){if(!f.length)continue;let c=f[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&a.push(c)}return a.length?a:[n]}catch{return[n]}}function sr(e,t){if(!t.length)return e;let n=i=>{let s=i.map(a=>[a.x,a.y]);return s.push(s[0]),s},o=t.map(i=>[n(i)]),r=[];for(let i of e){let s;try{s=Mn.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let f=a[0].map(([c,l])=>({x:c,y:l}));if(f.length>1){let c=f[0],l=f[f.length-1];Math.abs(c.x-l.x)<1e-9&&Math.abs(c.y-l.y)<1e-9&&f.pop()}f.length>=3&&r.push({outline:f,holes:[],topY:i.topY})}}return r.length?r:e}function Ja(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var jt=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=Oe(t),i=this.rings.filter((f,c)=>tt(r,this.boxes[c])&&Ja(n,this.levels[c])),s=[[o]];if(i.length)try{s=ar.default.difference([o],...i).map(c=>c.map(l=>l.map(([u,h])=>[u,h])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let f of s){if(!f.length)continue;let c=f[0].map(([l,u])=>({x:l,y:u}));if(c.length>1){let l=c[0],u=c[c.length-1];Math.abs(l.x-u.x)<1e-9&&Math.abs(l.y-u.y)<1e-9&&c.pop()}c.length>=3&&a.push(c)}return a}};function Ht(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,i=-1/0;for(let u of e)n=Math.min(n,u.x),o=Math.max(o,u.x),r=Math.min(r,u.y),i=Math.max(i,u.y);let s=(n+o)/2,a=(r+i)/2,f=t*Math.PI/180,c=Math.cos(f),l=Math.sin(f);return e.map(u=>{let h=u.x-s,m=u.y-a;return{x:s+h*c-m*l,y:a+h*l+m*c}})}function ie(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=bt(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,o=(e.y??0)+e.height/2;t=Ft(n,o,e.width/2,e.height/2)}return t?Ht(t,e.rotation):null}function Ee(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},o=t==="stage"&&ft(e.stageKind)?{kind:"stage",heightM:e.stageKind==="ring-boxing"?Ct:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var ec=.08,tc=30,nc=.015;function oc(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function cr(e,t){let n=ie(e)??(e.points?.length?Ht(e.points,e.rotation):null),o=Ee(e),i=!e.role&&o.kind==="plate"&&e.heightM===void 0&&!!n&&Math.abs(ye(n))*Q**2>=tc?nc:o.heightM;if(!n)return{topOffsetM:i,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:i,supportOffsetM:0};let s=1/0,a=1/0,f=-1/0,c=-1/0;for(let m of n)s=Math.min(s,m.x),a=Math.min(a,m.y),f=Math.max(f,m.x),c=Math.max(c,m.y);let l=i,u=0,h=1e-6*Math.max(1,f-s,c-a);for(let m of t)f>m.minX&&s<m.maxX&&c>m.minY&&a<m.maxY&&l<=m.topOffsetM+1e-6&&(l=m.topOffsetM+ec),s>=m.minX-h&&f<=m.maxX+h&&a>=m.minY-h&&c<=m.maxY+h&&(!m.poly||n.every(b=>oc(b,m.poly)||rc(b,m.poly,h)))&&(u=Math.max(u,m.topOffsetM));return e.fill&&e.fill!=="none"&&e.fill!=="transparent"&&t.push({minX:s,minY:a,maxX:f,maxY:c,topOffsetM:l,poly:n}),{topOffsetM:l,supportOffsetM:Math.min(u,l)}}function rc(e,t,n){for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,f=s.y-i.y,c=a*a+f*f,l=c?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*f)/c)):0;if(Math.hypot(e.x-(i.x+l*a),e.y-(i.y+l*f))<=n)return!0}return!1}function Xe(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function ge(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function pe(e,t,n){return[Xe(e[0],e[1],t),Xe(e[0],e[1],n),Xe(e[3],e[2],n),Xe(e[3],e[2],t)]}function Mt(e,t,n){return[Xe(e[0],e[3],t),Xe(e[1],e[2],t),Xe(e[1],e[2],n),Xe(e[0],e[3],n)]}function ee(e,t,n,o,r,i){W(e,t,void 0,()=>n,o,r,i,Y)}var ic=.8,sc=.6,ac=2;function ot(e,t){if(!t.length)return null;let n=[],o=0;for(let s of e.objects){if(s.type!=="shape"||s.role!=="wall")continue;let a=ie(s)??[],f=lr(a)/2;!(f>0)||uc(a)/f*w>ac||(n.push(...a),o+=f)}if(n.length<3)return null;let r=gt(n);if(r.length<3||o<lr(r)*sc)return null;let i=0;for(let s of t)fc(s,r)&&(i+=1);return i>=t.length*ic?r:null}var ur=6,cc=5,lc=8;function fr(e){return Math.max(lc,(Number.isFinite(e)?e:0)+cc)}function mr(e){let t=0,n=0,o=0;for(let r=0;r<e.length;r++){let i=e[r],s=e[(r+1)%e.length],a=i.x*s.y-s.x*i.y;t+=a,n+=(i.x+s.x)*a,o+=(i.y+s.y)*a}if(Math.abs(t)<1e-9){let r=0,i=0;for(let s of e)r+=s.x,i+=s.y;return{x:r/Math.max(1,e.length),y:i/Math.max(1,e.length)}}return{x:n/(3*t),y:o/(3*t)}}function uc(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 lr(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=Math.hypot(r.x-o.x,r.y-o.y)}return t}function fc(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function mc(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let o=t-e.x,r=n-e.y,i=Math.hypot(o,r);return i<1e-9?[0,0]:[o/i,r/i]}}}function hc(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let m of e)n+=m.x,o+=m.y,r+=Math.hypot(m.x-t.x,m.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let m of e){let d=Math.hypot(m.x-n,m.y-o);d>a&&(a=d,s=m)}let f=s.x-n,c=s.y-o,l=Math.hypot(f,c);l>1e-9?(f/=l,c/=l):(f=1,c=0);let u=[...e].sort((m,d)=>(m.x-n)*f+(m.y-o)*c-((d.x-n)*f+(d.y-o)*c)),h=0;for(let m of u){let d=Math.hypot(m.x-n,m.y-o);d>h&&(h=d)}return{pts:u,cx:n,cy:o,radius:h,depth:r}}function hr(e,t,n){let o=e.pts;if(o.length===1)return Math.hypot(t-o[0].x,n-o[0].y);let r=1/0;for(let i=0;i+1<o.length;i++){let s=o[i],a=o[i+1],f=a.x-s.x,c=a.y-s.y,l=f*f+c*c,u=l>1e-12?((t-s.x)*f+(n-s.y)*c)/l:0;u<0?u=0:u>1&&(u=1);let h=Math.hypot(t-(s.x+u*f),n-(s.y+u*c));h<r&&(r=h)}return r}var Xt=8;function dc(e,t,n){let o=new Array(Xt).fill(1/0),r=new Array(Xt).fill(-1);for(let l=0;l<e.length;l++){let u=e[l],h=Math.hypot(t-u.cx,n-u.cy)-u.radius;for(let m=0;m<Xt;m++)if(h<o[m]){for(let d=Xt-1;d>m;d--)o[d]=o[d-1],r[d]=r[d-1];o[m]=h,r[m]=l;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let l of r){if(l<0)continue;let u=hr(e[l],t,n);for(let h=0;h<3;h++)if(u<i[h]){for(let m=2;m>h;m--)i[m]=i[m-1],s[m]=s[m-1];i[h]=u,s[h]=l;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,f=0,c=0;for(let l=0;l<3;l++){let u=s[l];if(u<0||i[l]>a)continue;let h=1/(i[l]*i[l]);f+=h*e[u].depth,c+=h}return c>0?f/c:e[s[0]].depth}function pc(e){let t=(o,r)=>dc(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let f=e[a];if(Math.hypot(o-f.cx,r-f.cy)-f.radius>=i)continue;let c=hr(f,o,r);c<i&&(i=c,s=a)}return s};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(o,r)=>{let i=(t(o+.5,r)-t(o-.5,r))/1,s=(t(o,r+.5)-t(o,r-.5))/(2*.5),a=Math.hypot(i,s);return a<1e-9?[0,0]:[i/a,s/a]}}}function dr(e,t){let n=[];for(let o of e){let r=hc(o.points,t);r&&n.push(r)}return n.length<2?mc(t):(n.sort((o,r)=>o.depth-r.depth),pc(n))}var Ue=.06,bc=.05,br=.05,pr=.15,Sn=25;function yr(e,t,n){let o=new Map,r=new Array(t.length).fill(null),i=new Float64Array(t.length),s=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),f=new Map,c=[],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=Pe(d.outline,Re);f.set(d.id,{section:d,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),c.push({id:d.id,floorIndex:h,box:Oe(p),section:d,unit:m,outline:p})}}let u=new Map;for(let h of c){let m=u.get(h.floorIndex);m?m.push(h):u.set(h.floorIndex,[h])}for(let h=0;h<t.length;h++){let m=t[h],d=n?u.get(n[h])??[]:c,p=m.sectionId?d.find(x=>x.id===m.sectionId)??d.find(x=>x.section.logicalSectionId===m.sectionId&&be({x:m.x,y:m.y},x.outline,x.section.holes)):void 0,b=p?[p]:d;for(let x of b){if(n&&x.floorIndex!==n[h]||!p&&(m.x<x.box.minX||m.x>x.box.maxX||m.y<x.box.minY||m.y>x.box.maxY||!be({x:m.x,y:m.y},x.outline,x.section.holes)))continue;r[h]=x.id;let y=f.get(x.id);y.hasSeats=!0;let I=m.focalPoint??x.unit.focal,P=Math.hypot(m.x-I.x,m.y-I.y);P<y.frontU&&(y.frontU=P),y.seatIndices.push(h);let E=m.rowId||`__seat-${h}`,g=y.rows.get(E);g?g.push({x:m.x,y:m.y}):y.rows.set(E,[{x:m.x,y:m.y}]);break}}for(let[h,m]of f){let d=Ge(m.section,{floorBaseHeightM:m.unit.baseHeightM}),p=m.unit.baseHeightM,b=d.rake>0?Math.tan(d.rake*Math.PI/180):0,x=d.rake<=.01&&d.height<=p+.001,y=m.section.surfaceKind,I=y==="flat"?!0:y==="rakedRows"&&d.rake>.01?!1:x,P=m.hasSeats?At(h,t,m.seatIndices,m.unit.focal):{sectionId:h,rows:[],blockCount:0},g=P.rows.length<2?dr([...m.rows.values()].map(O=>({points:O})),m.unit.focal):null,S=1/0;if(g){if(m.hasSeats)for(let O of m.rows.values())for(let B of O){let N=g.depthAt(B.x,B.y);N<S&&(S=N)}if(!m.hasSeats||!Number.isFinite(S)){S=1/0;for(let O of m.section.outline){let B=g.depthAt(O.x,O.y);B<S&&(S=B)}}}let M=p+bc,R=Math.max(M,d.height),v=O=>{let B=Math.max(0,O-S)*Q,N=Math.min(B*b,Sn);return Math.max(M,d.height+N)},T=O=>{let B=Math.max(0,O)*Q,N=Math.min(B*b,Sn);return Math.max(M,d.height+N)},k=I?[]:P.rows.map(O=>({pts:O.pts,y:T(O.blockDepth),depth:O.blockDepth,blockId:O.blockId,...l.has(O.id)?{patch:$o(O.pts,Re)}:{}})),_=k.length?k[0].y:R,A=k.map(O=>{let B=O.patch&&O.patch.length>=3?O.patch:O.pts,N=0,H=0;for(let V of B)N+=V.x,H+=V.y;let D=B.length||1;N/=D,H/=D;let U=0;for(let V of B){let $=Math.hypot(V.x-N,V.y-H);$>U&&(U=$)}return{cx:N,cy:H,rad:U}}),C=I?()=>R:k.length>=2?(O,B)=>{let N=1/0,H=_;for(let D=0;D<k.length;D++){let U=A[D];if(Math.hypot(O-U.cx,B-U.cy)-U.rad>=N)continue;let V=k[D].patch,$=V&&V.length>=3?xe(V,O,B)?0:qe(V,O,B):qe(k[D].pts,O,B);$<N&&(N=$,H=k[D].y)}return H}:(O,B)=>g?v(g.depthAt(O,B)):R,L=[0,1,0],F=k.length>=2||I?()=>L:(O,B)=>{if(!g)return L;let N=g.depthAt(O,B);if(N<=S)return L;let H=(N-S)*Q;if(H*b>=Sn||d.height+H*b<=M)return L;let[D,U]=g.gradientAt(O,B);if(D===0&&U===0)return L;let V=1/Math.hypot(b,1);return[-D*b*V,V,-U*b*V]};if(!I)for(let O of P.rows){let B=T(O.blockDepth);for(let N of O.seatIndices)s[N]=B}for(let O of P.rows){let B=[];for(let V=1;V<O.pts.length;V++){let $=Math.hypot(O.pts[V].x-O.pts[V-1].x,O.pts[V].y-O.pts[V-1].y);$>1e-6&&B.push($)}B.sort((V,$)=>V-$);let N=B.length?B[Math.floor(B.length/2)]:1/0,H=1/0,D=O.pts[Math.floor(O.pts.length/2)];if(D)for(let V of P.rows){if(V===O||V.blockId!==O.blockId)continue;let $=qe(V.pts,D.x,D.y);$>1e-6&&$<H&&(H=$)}let U=Math.min(N,Math.max(H,N*.5));if(Number.isFinite(U)&&U>0)for(let V of O.seatIndices)a[V]=U}o.set(h,{sectionId:h,deckAt:C,normalAt:F,flat:I,bottomY:p,rowLevels:k,landingY:_})}for(let h=0;h<t.length;h++){let m=r[h],d=t[h];if(m){let x=s[h];i[h]=(x??o.get(m).deckAt(d.x,d.y))+pr;continue}let p=d.eyeHeightM,b=Number.isFinite(p)?Math.max(0,p-Ce):0;i[h]=d.kind==="booth"?b+Ue+pr:b}return{bySection:o,seatOwner:r,seatDeckY:h=>i[h],seatPitchU:h=>a[h]}}function rt(e,t,n){if(e.length!==4||n<=t)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*w,i=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*w;if(r<1e-6||i<1e-6)return null;let s=Math.min(.22/r,.16),a=Math.min(.28,(n-t)*.13),f=Math.min(.065/i,.2);return{quad:o,side:s,face:f,opening:pe(o,s,1-s),openingTop:n-a}}function In(e,t,n){if(e.length!==4||n-t<=.2)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*w;if(r<=1e-6)return null;let i=Math.min(.14,(n-t)*.08,r*.08),s=i/r,a=pe(o,s,1-s);return{quad:o,side:s,trim:i,inner:a,panel:Mt(a,.15,.85),bottom:t+i,top:n-i}}function xr(e,t,n,o){let r=In(e,t,n);if(!r)return;let{panel:i}=r,s=(y,I)=>({x:(y.x+I.x)/2,y:(y.y+I.y)/2}),a=s(i[0],i[1]),f=s(i[3],i[2]),c=Math.hypot(a.x-o.x,a.y-o.y)<=Math.hypot(f.x-o.x,f.y-o.y),[l,u]=c?[i[0],i[1]]:[i[3],i[2]],h=c?{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;-(u.y-l.y)*h.x+(u.x-l.x)*h.y<0&&([l,u]=[u,l]);let d=Math.min(.006,m*w*.05),p=h.x/m*d,b=h.y/m*d,x=(y,I)=>[y.x*w+p,I,y.y*w+b];return[x(l,r.bottom),x(u,r.bottom),x(l,r.top),x(u,r.top)]}var gr=Te(require("polygon-clipping"),1);function Be(e,t,n,o,r,i,s,a={}){let f=Oe(t),c=a.ao??Y,l=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let b=ie(p);if(!b||b.length!==4||!tt(f,Oe(b)))return[];let x=a.portalBase??n,y=rt(b,x,x+Ee(p).heightM);if(!y)return[];let I=Math.min(o,y.openingTop);return I<=n?[]:[{poly:y.opening,height:I}]});if(!l.length)return!1;let u=p=>p.map(b=>[b.x,b.y]),h=[u(t),...(a.holes??[]).map(u)],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],x=m[p];if(x-b<1e-6)continue;let y=l.filter(P=>P.height>b+1e-6).map(P=>[u(P.poly)]),I=y.length?gr.default.difference(h,...y):[h];d.push({low:b,high:x,polys:I})}}catch{return!1}for(let p of d)for(let b of p.polys){let[x,...y]=b.map(P=>P.map(([E,g])=>({x:E,y:g}))),I=P=>c.wallBottom+(c.top-c.wallBottom)*(P-n)/(o-n);W(e,x,y,()=>p.high,p.low,i,s,{...c,top:I(p.high),wallBottom:I(p.low)})}return!0}function Mr(e,t,n,o,r,i,s){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]],c=l=>Y.wallBottom+(Y.top-Y.wallBottom)*(l-n)/a;for(let[l,u,h]of f){let m={...Y,top:c(u),wallBottom:c(l)},d=z(i,h),p=z(s,h);Be(e,t,l,u,r,d,p,{portalBase:n,ao:m})||W(e,t,void 0,()=>u,l,d,p,m)}}function St(e,t,n){let o=ne(t.stroke?.color),r=t.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let i=t.kind==="line"||t.kind==="polyline",s=i?Ht(t.points??[],t.rotation):ie(t);if(!s||s.length<2)return;let a=i?s.length-1:s.length,f=r*.5;for(let c=0;c<a;c++){let l=s[c],u=s[(c+1)%s.length],h=Math.hypot(u.x-l.x,u.y-l.y);if(h<1e-6)continue;let m=-(u.y-l.y)/h*f,d=(u.x-l.x)/h*f,p=[(l.x+m)*w,n,(l.y+d)*w],b=[(u.x+m)*w,n,(u.y+d)*w],x=[(u.x-m)*w,n,(u.y-d)*w],y=[(l.x-m)*w,n,(l.y-d)*w];e.tri(p,b,x,[0,1,0],o),e.tri(p,x,y,[0,1,0],o)}}function Sr(e){return e==="bar"||e==="concession"||e==="coat"||e==="restroom"}var it=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function Ut(e,t,n,o){let[r,i,s,a]=t?e:[e[3],e[2],e[1],e[0]];return[it(r,a,n),it(i,s,n),it(i,s,o),it(r,a,o)]}function Ir(e,t,n,o,r,i,s,a,f=!1){if(n.length!==4||r-o<.4)return!1;let c=M=>f?Math.min(M,r):M,l=ge(n),u=Math.hypot(l[3].x-l[0].x,l[3].y-l[0].y)*w;if(u<.4)return!1;let h=it(l[0],l[1],.5),m=it(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=te(s,[.92,.9,.86],.35),b=z(i,.72),x=r-o;if(t==="restroom"){let M=Math.min(.18,x*.08);return ee(e,l,r-M,o,s,i),ee(e,l,r,r-M,p,p),!0}let y=o+Math.min(1.1,x),I=t==="coat"?1:Math.min(.5,.75/u),P=Ut(l,d,0,I);if(ee(e,P,y-.05,o,b,i),ee(e,P,y,y-.05,p,p),t==="coat"||u<1.2)return!0;if(t==="bar"){let M=Ut(l,d,Math.max(I+.2,1-.45/u),1),R=c(o+Math.max(Math.min(2.2,x*2),y-o+.6));return ee(e,M,R,o,s,b),!0}let E=Ut(l,d,Math.max(I+.25,.55),1),g=c(o+Math.max(2.6,y-o+1.4));if(g-.14<=y)return!0;ee(e,E,g-.14,o,s,i),ee(e,l,g,g-.14,p,b);let S=Math.min(.08,.1/Math.max(.1,Math.hypot(l[1].x-l[0].x,l[1].y-l[0].y)*w));for(let[M,R]of[[0,S],[1-S,1]])ee(e,Ut(pe(l,M,R),d,0,Math.min(.08,.1/u)),g-.14,y,b,b);return!0}var yc=[.12,.38,.16],xc=[.72,.62,.45],gc=[.88,.93,.96],Rr=[.95,.95,.94],Mc=[.66,.29,.22],Rn={length:20.12,width:3.05},Sc=.14,Ic=9.76,Fe=[.93,.94,.95],Vt=[.1,.11,.13],Rc=[.45,.85,1.25],Pc=1.45,Pr=.012,wr=.004,wc=1.07,Ec=.15;function at(e,t,n,o,r,i){e.setMaterial(i),W(e,t,n?[n.slice().reverse()]:void 0,()=>o,o-.004,r,r,Y)}var Er=(e,t)=>He(e,t/w);function Ar(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<1e-9)return null;let s=-r/i*n,a=o/i*n;return[{x:e.x+s,y:e.y+a},{x:t.x+s,y:t.y+a},{x:t.x-s,y:t.y-a},{x:e.x-s,y:e.y-a}]}function Ac(e,t,n,o){let r=t.map(i=>[i.x*w,n,i.y*w]);e.tri(r[0],r[1],r[2],[0,1,0],o),e.tri(r[0],r[2],r[3],[0,1,0],o)}function Yt(e,t,n,o,r,i){let s=n/w,a=[{x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s},{x:t.x-s,y:t.y+s}];W(e,a,void 0,()=>r,o,i,z(i,.85),Y)}function st(e,t,n,o,r,i,s){let a=Ar(t,n,o/w);a&&W(e,a,void 0,()=>i,r,s,z(s,.85),Y)}function Kt(e){let t=ge(e),n={x:(t[0].x+t[2].x)/2,y:(t[0].y+t[2].y)/2},o=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y)||1,r=Math.hypot(t[3].x-t[0].x,t[3].y-t[0].y)||1,i={x:(t[1].x-t[0].x)/o,y:(t[1].y-t[0].y)/o},s={x:(t[3].x-t[0].x)/r,y:(t[3].y-t[0].y)/r};return{at:(f,c)=>({x:n.x+(i.x*f+s.x*c)/w,y:n.y+(i.y*f+s.y*c)/w}),lengthM:o*w,widthM:r*w}}function vr(e,t,n){let o=oo(t);if(!o.length)return;let r=1/0,i=-1/0,s=1/0,a=-1/0;for(let I of t.points??[])r=Math.min(r,I.x),i=Math.max(i,I.x),s=Math.min(s,I.y),a=Math.max(a,I.y);let f=(t.rotation??0)*Math.PI/180,c=Math.cos(f),l=Math.sin(f),u=(r+i)/2,h=(s+a)/2,m=I=>f?{x:u+(I.x-u)*c-(I.y-h)*l,y:h+(I.x-u)*l+(I.y-h)*c}:I,d=Math.min(i-r,a-s)*w,p=Math.max(.04,Math.min(.3,d*.004))/w,b=0;e.setMaterial(0);for(let I of o){if(!I.fill)continue;let P=I.points.map(m);at(e,P,null,n+Pr+b*wr,ne(I.fill)??Fe,0),b++}let x=o.filter(I=>!(I.fill&&I.ink===I.fill)),y=[...new Set(x.map(I=>I.ink??_t))];for(let I of y){let P=n+Pr+b++*wr,E=ne(I)??Fe;for(let g of x){if((g.ink??_t)!==I)continue;let S=g.points.map(m),M=g.closed?S.length:S.length-1;for(let R=0;R<M;R++){let v=Ar(S[R],S[(R+1)%S.length],p);v&&Ac(e,v,P,E)}}}}function Cr(e,t,n,o,r){if(t.length<3)return!1;let i=o+.006,s=r??yc;if(n==="oval-cricket"){let a=t.reduce((E,g)=>E+g.x,0)/t.length,f=t.reduce((E,g)=>E+g.y,0)/t.length,c=E=>t.map(g=>({x:a+(g.x-a)*E,y:f+(g.y-f)*E})),l=8;for(let E=0;E<l;E++){let g=c(1-E/l),S=E===l-1?null:c(1-(E+1)/l);at(e,g,S,i,z(s,E%2?1.04:.96),4)}let u=t[0];for(let E of t)Math.hypot(E.x-a,E.y-f)>Math.hypot(u.x-a,u.y-f)&&(u=E);let h=Math.hypot(u.x-a,u.y-f)||1,m=(u.x-a)/h,d=(u.y-f)/h,p=-d,b=m,x=Math.min(1,2*h*w*Sc/Rn.length),y=Rn.length*x/2/w,I=Rn.width*x/2/w,P=[[-y,-I],[y,-I],[y,I],[-y,I]].map(([E,g])=>({x:a+m*E+p*g,y:f+d*E+b*g}));return at(e,P,null,i+.004,xc,0),e.setMaterial(0),!0}if(n==="rink-hockey"){let a=Er(t,Ec);return at(e,a,null,i,gc,0),e.setMaterial(0),W(e,t,[a.slice().reverse()],()=>o+wc,o,Rr,z(Rr,.9),Y),!0}if(n==="ring-boxing"&&t.length===4){let{at:a}=Kt(t),f=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],c=[[.77,.19,.19],Fe,[.17,.42,.69],Fe];e.setMaterial(0),f.forEach((l,u)=>Yt(e,l,.07,o,o+Pc,c[u]));for(let l of Rc)for(let u=0;u<4;u++)st(e,f[u],f[(u+1)%4],.025,o+l-.025,o+l+.025,Fe);return!0}if(n==="court-tennis"&&t.length===4){let{at:a}=Kt(t);e.setMaterial(0),st(e,a(0,-6.4),a(0,6.4),.015,o,o+.95,Vt),st(e,a(0,-6.4),a(0,6.4),.03,o+.95,o+1,Fe);for(let f of[-1,1])Yt(e,a(0,f*6.4),.05,o,o+1.07,Vt);return!0}if(n==="court-basketball"&&t.length===4){let{at:a,lengthM:f}=Kt(t),c=Math.min(14,f/2-.5);e.setMaterial(0);for(let l of[-1,1]){let u=a(l*(c+1.2),0),h=a(l*(c-1.2),0);Yt(e,u,.12,o,o+3.4,Vt),st(e,u,h,.06,o+3.25,o+3.4,Vt),st(e,a(l*(c-1.2),-.9),a(l*(c-1.2),.9),.03,o+2.9,o+3.95,Fe)}return!0}if(n==="pitch-rugby"&&t.length===4){let{at:a,lengthM:f}=Kt(t),c=f*(50/120);e.setMaterial(0);for(let l of[-1,1]){for(let u of[-2.8,2.8])Yt(e,a(l*c,u),.07,o,o+12,Fe);st(e,a(l*c,-2.8),a(l*c,2.8),.06,o+2.94,o+3.06,Fe)}return!0}if(n==="track-athletics"){let a=Er(t,Ic);return a.length<3?!1:(at(e,t,a,i,Mc,0),at(e,a,null,i,s,4),e.setMaterial(0),!0)}return!1}var _r=[.19,.4,.15],vc=.012,Zt=2.4,Cc=1,_c=.75,kc=.15;function Ae(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:o,rotation:r}=e;if(!n||!o)return null;let i=(r??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),f=n/2,c=o/2;return[[-f,-c],[f,-c],[f,c],[-f,c]].map(([l,u])=>({x:t.x+l*s-u*a,y:t.y+l*a+u*s}))}function Fr(e,t,n,o,r,i,s=!1){let a=Ae(t);if(a){if(s){let f=Qe(o,r.boothTop),c=_e([...a]);W(e,Pe(c,Tc/w),[c.slice().reverse()],()=>n+.03,n,f,z(f,.8),Y);return}if(!(!t.points&&i&&Oc(e,a,n,o,i))){if(!t.points&&i&&a.length===4){Lc(e,a,n,o,i);return}W(e,a,void 0,()=>n+Zt,n,Qe(o,r.boothTop),r.boothWall,Y)}}}var Pn=1.1,kr=[.9,.9,.88],Tc=.1,Wt=[.87,.87,.85],Tr=.08;function Dr(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 c=n(f),l=Math.hypot(c.x-t.x,c.y-t.y);l<r&&(r=l,o=f)}let i=[0,1,2,3].map(f=>e[(o+f)%4]),s=(f,c,l)=>({x:f.x+(c.x-f.x)*l,y:f.y+(c.y-f.y)*l});return{q:i,part:(f,c,l,u)=>{let h=s(i[0],i[1],f),m=s(i[0],i[1],c),d=s(i[3],i[2],f),p=s(i[3],i[2],c);return[s(h,d,l),s(m,p,l),s(m,p,u),s(h,d,u)]},depthM:Math.hypot(i[3].x-i[0].x,i[3].y-i[0].y)*w,widthM:Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*w}}function Lc(e,t,n,o,r){let{q:i,part:s}=Dr(t,r),a=o??[.35,.42,.55],f=te(a,[.78,.78,.77],.62),c=te(a,[.95,.95,.94],.45);ee(e,i,n+Ue,n,f,z(f,.8)),ee(e,s(.05,.95,.72,.98),n+Pn-.05,n+Ue,c,z(c,.8)),ee(e,s(.03,.97,.7,1),n+Pn,n+Pn-.05,kr,z(kr,.9))}function Oc(e,t,n,o,r){if(t.length!==4)return!1;let{q:i,part:s,depthM:a,widthM:f}=Dr(t,r);if(a<1||f<1)return!1;let c=o??[.35,.42,.55],l=te(c,[.78,.78,.77],.62),u=n+Zt,h=Tr/f,m=Tr/a;ee(e,i,n+Ue,n,l,z(l,.8)),ee(e,s(0,1,1-m,1),u,n+Ue,Wt,z(Wt,.9));for(let[b,x]of[[0,h],[1-h,1]])ee(e,s(b,x,0,1-m),u,n+Ue,Wt,z(Wt,.9));ee(e,s(h,1-h,0,Math.min(.5,.06/a)),u,u-.3,c,z(c,.85));let d=Math.min(.4,.6/f),p=Math.min(.12,.3/a);return ee(e,s(.5-d,.5+d,.72-p,.72+p),n+Cc,n+Ue,te(c,[.95,.95,.94],.7),z(c,.75)),!0}function $t(e){if(e.shape==="round"){let l=e.radius;return l?Ft(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 i=(o??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),f=t/2,c=n/2;return[[-f,-c],[f,-c],[f,c],[-f,c]].map(([l,u])=>({x:r.x+l*s-u*a,y:r.y+l*a+u*s}))}function Nr(e,t,n,o,r,i=!0){let s=$t(t);if(!s)return;let a=s.reduce((h,m)=>h+m.x,0)/s.length,f=s.reduce((h,m)=>h+m.y,0)/s.length,c=h=>s.map(m=>({x:a+(m.x-a)*h,y:f+(m.y-f)*h})),l=i&&o?Qe(o,r.tableTop):Bc,u=n+_c;W(e,s,void 0,()=>u,n+Fc,l,z(l,.86),Y),W(e,c(.12),void 0,()=>u+.12,u,Lr,z(Lr,.8),Y)}var Bc=[.93,.92,.89],Lr=[.78,.66,.42],Fc=.25;function Gr(e,t,n,o,r,i,s,a,f=[]){let c=ie(t);if(!t.role&&(!t.fill||t.fill==="none"||t.fill==="transparent")||!c){St(e,t,n+o+vc);return}let u=a?a.kind==="stage":t.role==="stage",h=a?a.kind==="screen":t.role==="screen",m=a?{kind:u?"stage":"solid",heightM:a.topY-a.baseY}:Ee(t),d=a?.baseY??n,p=a?.topY??n+o;if(u&&s){let M=1/0,R=-1/0,v=1/0,T=-1/0;for(let k of c)k.x<M&&(M=k.x),k.x>R&&(R=k.x),k.y<v&&(v=k.y),k.y>T&&(T=k.y);s.push({cx:(M+R)/2*w,cz:(v+T)/2*w,y:p,halfX:Math.max((R-M)/2*w,.5),halfZ:Math.max((T-v)/2*w,.5)})}let b=ne(t.fill),x=t.role==="wall"||t.role==="entrance"||t.role==="exit",y=x?b?z(we(b,.12),.95):r.tierTop:u&&b?te(r.stageTop,z(we(b,.18),.9),.9):!t.role&&b?b:Qe(b,u?r.stageTop:r.decorTop),I=h?b:null,P=x?b?z(we(b,.12),.85):r.tierWall:u?b?te(r.stageWall,z(b,.58),.82):r.stageWall:h?I?te(z(I,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Qe(ne(t.fill),r.decorWall);if(t.role==="wall"&&!a){Mr(e,c,d,p,f,y,P),St(e,t,p+.012);return}if(h&&c.length===4&&p-d>.2){let M=In(c,d,p);if(!M)return;let{quad:R,side:v,trim:T,inner:k,panel:_}=M,A=[.12,.15,.18];for(let[C,L]of[[0,v],[1-v,1]])ee(e,pe(R,C,L),p,d,A,A);ee(e,k,d+T,d,A,A),ee(e,k,p,p-T,A,A),ee(e,_,p-T,d+T,P,P),St(e,t,p+.012);return}let E=b?z(we(b,.15),.82):P,g=b?z(we(b,.1),1.02):y;if(Sr(t.role)&&!a&&Ir(e,t.role,c,d,p,E,g,i,t.heightM!==void 0))return;if((t.role==="sound"||a?.kind==="sound_desk")&&c.length===4&&p-d>.3){let M=ge(c),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*w,v=Math.min(.12,.09/Math.max(R,.001)),T=[.18,.21,.24],k=p-Math.min(.12,(p-d)*.15);for(let[_,A]of[[0,v],[1-v,1]])ee(e,pe(M,_,A),k,d,T,T);ee(e,M,p,k,y,T);return}if(t.role==="rail"&&c.length===4&&p>d){let M=ge(c),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*w,v=Math.max(1,Math.min(128,Math.ceil(R/1.4))),T=Math.min(.08,.055/Math.max(.055,R)),k=[.58,.64,.66];for(let _=0;_<=v;_++){let A=_/v,C=Math.min(1-T,Math.max(0,A-T/2));ee(e,pe(M,C,C+T),p,d,k,z(k,.8))}for(let _ of[.52,1]){let A=d+(p-d)*_;ee(e,M,A,Math.max(d,A-.055),k,z(k,.8))}return}if(t.role==="goal"&&c.length===4){let M=ge(c),R=Math.hypot(M[1].x-M[0].x,M[1].y-M[0].y)*w,v=Math.min(.12,.1/Math.max(.1,R)),T=[.9,.94,.94];for(let[k,_]of[[0,v],[1-v,1]])ee(e,pe(M,k,_),Math.max(d,p-.1),d,T,T);ee(e,M,p,Math.max(d,p-.1),T,T);return}if(m.kind==="portal"&&c.length===4){let M=rt(c,d,p);if(!M)return;let{quad:R,side:v,face:T,openingTop:k}=M;for(let[_,A,C]of[[0,T,1],[T,1-T,.67],[1-T,1,1]]){let L=Mt(R,_,A),F=z(y,C),O=z(P,C);for(let[B,N]of[[0,v],[1-v,1]])ee(e,pe(L,B,N),k,d,F,O);ee(e,L,p,k,F,O)}return}if(m.kind==="suite"&&c.length===4){let M=c.map((T,k)=>{let _=c[(k+1)%4],A=(T.x+_.x)/2,C=(T.y+_.y)/2;return Math.hypot(A-i.x,C-i.y)}),R=M.indexOf(Math.min(...M)),v=[0,1,2,3].map(T=>c[(R+T)%4]);ee(e,pe(v,0,.08),p,d,y,P),ee(e,pe(v,.92,1),p,d,y,P),ee(e,Mt(v,.88,1),p,d,y,P),ee(e,v,p,Math.max(d,p-.18),y,P);return}if(u&&!t.stageKind?.startsWith("pitch-")&&p-d>.12){let M=p-Math.min(.06,(p-d)*.15);ee(e,c,M,d,y,P),ee(e,c,p,M,y,te(y,P,.2))}else ee(e,c,p,d,y,P);if((t.stageKind==="pitch-football"||t.stageKind==="pitch-rugby")&&c.length===4){e.setMaterial(4);let M=ge(c),R=te(b??_r,_r,b?.45:0);for(let v=0;v<12;v++){let T=pe(M,v/12,(v+1)/12),k=z(R,v%2?1.09:.91),_=T.map(A=>[A.x*w,p+.006,A.y*w]);e.tri(_[0],_[1],_[2],[0,1,0],k),e.tri(_[0],_[2],_[3],[0,1,0],k)}}t.stageKind&&t.stageKind!=="pitch-football"&&Cr(e,c,t.stageKind,p,b),u&&We(t.stageKind)&&vr(e,t,p),e.setMaterial(h?1:0),St(e,t,p+.012)}function Qt(e){let{x:t,y:n,width:o,height:r}=e;if(!o||!r)return null;let i=t+o/2,s=n+r/2,a=(e.rotation??0)*Math.PI/180,f=Math.cos(a),c=Math.sin(a),l=o/2,u=r/2;return[[-l,-u],[l,-u],[l,u],[-l,u]].map(([h,m])=>({x:i+h*f-m*c,y:s+h*c+m*f}))}function Dc(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let o=n[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return ne(o);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let s=[];for(let a of i[1].matchAll(/stop-color="([^"]+)"/gi)){let f=ne(a[1].trim());f&&s.push(f)}return s.length?s.reduce((a,f,c)=>te(a,f,1/(c+1)),s[0]):null}function jr(e,t,n,o){if(t.layer==="foreground")return;let r=Qt(t);if(!r)return;let i=n+kc,s=Qe(Dc(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=te(o.ground,s,a)),W(e,r,void 0,()=>i,n,s,te(s,o.decorWall,.5),Y)}function Hr(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=Oo(o,r.gaTop);W(e,t.points,t.holes,()=>n+Or,n,i,r.gaWall,Y),jc(e,t.points,n+Or)}var Or=.15,zt=[.72,.74,.76],wn=1.1,Br=.12,En=.05,Nc=.06,Gc=2.4;function jc(e,t,n){let o=_e([...t]),r=He(o,Br/w),i=He(o,(Br+En)/w);if(r.length<3||i.length<3)return;for(let a of[n+wn,n+wn*.5])W(e,r,[i.slice().reverse()],()=>a,a-En,zt,z(zt,.85),Y);let s=Nc/2/w;for(let a=0;a<r.length;a++){let f=r[a],c=r[(a+1)%r.length],l=Math.hypot(c.x-f.x,c.y-f.y)*w,u=Math.max(1,Math.round(l/Gc));for(let h=0;h<u;h++){let m=h/u,d=f.x+(c.x-f.x)*m,p=f.y+(c.y-f.y)*m,b=[{x:d-s,y:p-s},{x:d+s,y:p-s},{x:d+s,y:p+s},{x:d-s,y:p+s}];W(e,b,void 0,()=>n+wn-En,n,zt,z(zt,.8),Y)}}}var An=.6,Xr=3,Hc=.25;function Xc(e,t){if(xe(t,e.x,e.y))return 0;let n=1/0;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,f=s.y-i.y,c=a*a+f*f||1,l=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*f)/c));n=Math.min(n,Math.hypot(e.x-(i.x+l*a),e.y-(i.y+l*f)))}return n}function Ur(e,t){let n=e.map(s=>({booth:s,ring:Ae(s)})).filter(s=>!!s.ring&&s.ring.length===4&&!s.booth.points),o=n.map(({ring:s})=>({minX:Math.min(...s.map(a=>a.x)),maxX:Math.max(...s.map(a=>a.x)),minY:Math.min(...s.map(a=>a.y)),maxY:Math.max(...s.map(a=>a.y))})),r=(Xr+An)/w,i=new Map;return n.forEach(({booth:s,ring:a},f)=>{let c={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},x=b.x-c.x,y=b.y-c.y,I=Math.hypot(x,y)||1,P={x:b.x+x/I*An/w,y:b.y+y/I*An/w},E=Xr/w;return o.forEach((g,S)=>{S===f||P.x<g.minX-r||P.x>g.maxX+r||P.y<g.minY-r||P.y>g.maxY+r||(E=Math.min(E,Xc(P,n[S].ring)))}),{open:E*w,toward:{x:b.x+x/I*10/w,y:b.y+y/I*10/w},focal:Math.hypot(b.x-t.x,b.y-t.y)}}),u=Math.max(...l.map(m=>m.open)),h=l.filter(m=>m.open>=u-Hc).sort((m,d)=>m.focal-d.focal)[0];i.set(s.id,h.toward)}),i}var Vr=Te(require("polygon-clipping"),1);var Uc=.45,Vc=1500,Yc=200;function Yr(e,t){if(e.role!=="stage"||We(e.stageKind))return e;let n=ie(e);if(!n||n.length<3||Math.abs(ye(n))*w*w>Vc)return e;let o=t.filter(s=>xe(n,s.x,s.y));if(!o.length||o.length>Yc)return e;let r=Uc/w,i=o.map(s=>[[[s.x-r,s.y-r],[s.x+r,s.y-r],[s.x+r,s.y+r],[s.x-r,s.y+r],[s.x-r,s.y-r]]]);try{let s=Vr.default.difference([[...n.map(c=>[c.x,c.y]),[n[0].x,n[0].y]]],...i),a=null,f=0;for(let c of s){let l=c[0].slice(0,-1).map(([h,m])=>({x:h,y:m})),u=Math.abs(ye(l));u>f&&(f=u,a=l)}return!a||a.length<3?e:{...e,kind:"polygon",points:a,rotation:0}}catch{return e}}var Kc=Math.PI/180,oe=96,Wc=6,zc=60,Zc=150,Kr=.2,$c=.35;function Qc(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/Kc;return n<0?n+360:n}function qt(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function Jt(e,t,n=2){let o=e.length,r=new Float64Array(o);for(let i=0;i<o;i++){let s=0,a=0;for(let f=-n;f<=n;f++){let c=i+f;if(t)c=(c%o+o)%o;else if(c<0||c>=o)continue;s+=e[c],a++}r[i]=s/a}return r}function Wr(e,t){let n=e.filter(h=>h.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let h of n)for(let m of h.rows){for(let d of m.pts)r+=d.x,i+=d.y,s++;if(m.pts.length>=4){let d=cn(m.pts);d&&Number.isFinite(d.cx)&&Number.isFinite(d.cy)&&o.push({x:d.cx,y:d.cy})}}if(!s)return null;let a={x:r/s,y:i/s},f=a;if(o.length>=8){let h=qt(o.map(x=>x.x)),m=qt(o.map(x=>x.y)),d=0;for(let x of n)for(let y of x.rows)for(let I of y.pts){let P=Math.hypot(I.x-a.x,I.y-a.y);P>d&&(d=P)}let p=0,b=d*.2;for(let x of n)for(let y of x.rows)for(let I of y.pts)Math.hypot(I.x-h,I.y-m)<b&&p++;Math.hypot(h-a.x,m-a.y)<=d&&p/s<.01&&(f={x:h,y:m})}let c=[];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),x=Math.min(oe-1,Math.floor(Qc(f,p)/(360/oe)));m.samples.push({r:b,bin:x,levelM:d.levelM}),b<m.rMin&&(m.rMin=b),b>m.rMax&&(m.rMax=b)}m.samples.length&&c.push(m)}if(!c.length)return null;c.sort((h,m)=>h.rMin+h.rMax-(m.rMin+m.rMax));let l=[];for(let h of c){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>=$c*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 u=[];for(let h of l){let m=new Array(oe).fill(null);for(let _ of h.members)for(let A of _.samples){let C=m[A.bin];C||(C={samples:[]},m[A.bin]=C),C.samples.push({r:A.r,levelM:A.levelM})}let d=m.map(_=>!!_);if(!d.filter(Boolean).length)continue;let b=[],x=[];for(let _ of m){if(!_)continue;let A=1/0,C=-1/0;for(let L of _.samples)L.r<A&&(A=L.r),L.r>C&&(C=L.r);b.push(A),x.push(C)}let y=qt(b),I=qt(x);if(!(y>=Kr*I)||!(I>0))continue;let P=[...b].sort((_,A)=>_-A);if(!(P[Math.floor(P.length*.1)]>=Kr*I))continue;let g=m.map(_=>{if(!_)return null;let A=[..._.samples].sort((D,U)=>D.r-U.r),C=A[0].r,L=A[A.length-1].r,F=A[0].levelM,O=-1/0;for(let D of A)D.levelM>O&&(O=D.levelM);let B=[];for(let D of A){let U={r:D.r,l:D.levelM};for(;B.length&&Math.abs(B[B.length-1].r-U.r)<1e-9;){if(B[B.length-1].l<=U.l){U.skip=!0;break}B.pop()}if(!U.skip){for(;B.length>=2;){let V=B[B.length-2],$=B[B.length-1];if(($.r-V.r)*(U.l-V.l)-($.l-V.l)*(U.r-V.r)<=0)B.pop();else break}B.push(U)}}let N=B.map(D=>D.r),H=B.map(D=>D.l);return{inner:C,outer:L,front:F,top:O,profile:{rs:N,ls:H}}}),S=d.slice();for(let _=0;_<oe;_++){if(S[_])continue;let A=-1,C=-1,L=0;for(let X=1;X<=oe;X++){let J=(_-X+oe*2)%oe;if(S[J]){A=J;break}}for(let X=1;X<=oe;X++){let J=(_+X)%oe;if(S[J]){C=J,L=X;break}}if(A<0||C<0)continue;let F=0;for(let X=1;X<=oe;X++){let J=(_-X+oe*2)%oe;if(d[J]){F=X;break}}if(F-1+L>Wc)continue;let B=g[A],N=g[C],H=F/(F+L),D=B.inner+(N.inner-B.inner)*H,U=B.outer+(N.outer-B.outer)*H,V=B.front+(N.front-B.front)*H,$=B.top+(N.top-B.top)*H;g[_]={inner:D,outer:U,front:V,top:$,profile:{rs:[D,U],ls:[V,$]}}}for(let _=0;_<oe;_++)g[_]&&(S[_]=!0);let M=360/oe,R=[],v=S.filter(Boolean).length,T=[];if(v===oe)T.push({start:0,len:oe});else{let _=0;for(;S[_];)_=(_+1)%oe;let A=-1;for(let C=0;C<=oe;C++){let L=(_+C)%oe,F=C<oe&&S[L];if(F&&A<0)A=L;else if(!F&&A>=0){let O=(L-A+oe)%oe||oe;T.push({start:A,len:O}),A=-1}}}for(let _ of T){if(_.len*M<zc&&_.len<oe)continue;let A=_.len===oe,C=new Float64Array(_.len),L=new Float64Array(_.len),F=new Float64Array(_.len),O=new Float64Array(_.len),B=[];for(let X=0;X<_.len;X++){let J=g[(_.start+X)%oe];C[X]=J.inner,L[X]=J.outer,F[X]=J.front,O[X]=J.top,B.push(J.profile??{rs:[J.inner,J.outer],ls:[J.front,J.top]})}let N=Jt(C,A),H=Jt(L,A),D=Jt(F,A),U=Jt(O,A);for(let X=0;X<_.len;X++)N[X]>C[X]&&(N[X]=C[X]),H[X]<L[X]&&(H[X]=L[X]),N[X]>H[X]-1e-6&&(N[X]=Math.max(0,H[X]-1e-6)),U[X]<D[X]&&(U[X]=D[X]);let V={startBin:_.start,binCount:_.len,closed:A,innerR:N,outerR:H,frontLevelM:D,topLevelM:U,profiles:B},$=(X,J,Z)=>{let ce=B[X],ae=ce.rs,G=ce.ls;if(J<=ae[0]){G[0]>Z&&(G[0]=Z);return}if(J>=ae[ae.length-1]){G[G.length-1]>Z&&(G[G.length-1]=Z);return}for(let j=0;j+1<ae.length;j++)if(J<=ae[j+1]){G[j]>Z&&(G[j]=Z),G[j+1]>Z&&(G[j+1]=Z);return}};for(let X=0;X<_.len;X++){let J=m[(_.start+X)%oe];if(J)for(let Z of J.samples){$(X,Z.r,Z.levelM);let ce=A?(X-1+_.len)%_.len:X-1,ae=A?(X+1)%_.len:X+1;ce>=0&&$(ce,Z.r,Z.levelM),ae<_.len&&$(ae,Z.r,Z.levelM)}}R.push(V)}R.reduce((_,A)=>_+A.binCount*M,0)<Zc||u.push({arcs:R,sectionIds:h.members.map(_=>_.sectionId),innerRMedian:y,outerRMedian:I})}if(!u.length)return null;if(u.sort((h,m)=>h.innerRMedian-m.innerRMedian),t){let h=u[u.length-1].outerRMedian;if(Math.hypot(t.x-f.x,t.y-f.y)>.9*h)return null}return{centre:f,binCount:oe,binStepDeg:360/oe,rings:u}}function zr(e,t,n,o){let r=e.binStepDeg,i=n/r-.5-t.startBin;i=(i%e.binCount+e.binCount)%e.binCount,i>t.binCount-1&&(t.closed?i=i-t.binCount<t.binCount-i?0:t.binCount-1:i=i-(t.binCount-1)<e.binCount-i?t.binCount-1:0);let s=Math.floor(i),a=t.closed?(s+1)%t.binCount:Math.min(t.binCount-1,s+1),f=i-s,c=l=>{let u=t.profiles[l],h=u.rs,m=u.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 c(s)*(1-f)+c(a)*f}function vn(e,t,n,o,r,i,s,a,f,c=[],l=r){if(t.length!==n.length||t.length<2||i-r<1.5)return;let u=(p,b,x)=>{Be(e,p,b,x,c,s,a,{portalBase:l,ao:f})||W(e,p,void 0,()=>x,b,s,a,f)},h=(p,b,x)=>({x:p.x+(b.x-p.x)*x,y:p.y+(b.y-p.y)*x}),m=o?t.length:t.length-1,d=0;for(let p=0;p<m;p++){let b=(p+1)%t.length,x=Math.hypot(n[b].x-n[p].x,n[b].y-n[p].y)*Q;if(x<1e-5)continue;let y=(g,S)=>[h(t[p],t[b],g),h(t[p],t[b],S),h(n[p],n[b],S),h(n[p],n[b],g)];u(y(0,1),r,r+.95),u(y(0,1),i-.22,i);let I=Math.ceil((d-.32)/6)*6,P=!1,E=!1;for(let g=I;g<d+x;g+=6){let S=Math.max(0,(g-d)/x),M=Math.min(1,(g+.32-d)/x);M<=S||(u(y(S,M),r+.95,i-.22),P||=S<1e-6,E||=M>1-1e-6)}if(!o&&(p===0&&!P||p===m-1&&!E)){let g=Math.min(1,.32/x);u(y(p===0?0:1-g,p===0?g:1),r+.95,i-.22)}d+=x}}var Ve=Te(require("polygon-clipping"),1),Rt=.65;function Cn(e,t){let n=1/0;for(let o of t)for(let r=0;r<o.length;r++){let i=o[r],s=o[(r+1)%o.length],a=s.x-i.x,f=s.y-i.y,c=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*f)/(a*a+f*f||1)));n=Math.min(n,Math.hypot(e.x-i.x-c*a,e.y-i.y-c*f))}return n}var _n=.01;function Zr(e,t,n,o,r,i,s,a=[],f=!0,c={bays:[],walls:[]}){if(o-r<=1e-5)return;let l=o-r>=3,u=l?o-Rt:r;e.setMaterial(5);let h=l?[]:a.filter(g=>{if(g.role!=="entrance"&&g.role!=="exit")return!1;let S=ie(g);if(!S)return!1;let M=rt(S,r,r+Ee(g).heightM);return M!==null&&M.openingTop<=o-.12});if((!h.length||!Be(e,t,u,o,h,i,s,{holes:n,portalBase:r}))&&W(e,t,n,()=>o,u,i,s,Y,void 0,()=>[0,1,0]),!l){e.setMaterial(0);return}let m=f&&c.bays.length?qc(t,n,He(t,It/w),c):null,d=6/w,p=.22/w,b=a.flatMap(g=>{if(g.role!=="entrance"&&g.role!=="exit")return[];let S=ie(g);return S?.length?[{minX:Math.min(...S.map(M=>M.x)),maxX:Math.max(...S.map(M=>M.x)),minY:Math.min(...S.map(M=>M.y)),maxY:Math.max(...S.map(M=>M.y))}]:[]}),x=Math.min(...t.map(g=>g.x)),y=Math.max(...t.map(g=>g.x)),I=Math.min(...t.map(g=>g.y)),P=Math.max(...t.map(g=>g.y));for(let g=x+d/2;g<y;g+=d)for(let S=I+d/2;S<P;S+=d){if(b.some(R=>g+p>=R.minX&&g-p<=R.maxX&&S+p>=R.minY&&S-p<=R.maxY))continue;let M=[{x:g-p,y:S-p},{x:g+p,y:S-p},{x:g+p,y:S+p},{x:g-p,y:S+p}];!be({x:g,y:S},t,n)||Cn({x:g,y:S},[t,...n??[]])<p*Math.SQRT2+(f?It/w:0)||m&&Cn({x:g,y:S},m.flat())<p*Math.SQRT2+It/w||W(e,M,void 0,()=>u,r,i,s,Y)}if(m){for(let[g,...S]of m)W(e,g,S,()=>u,r-_n,i,s,Y);e.setMaterial(0);return}let E=He(t,It/w);if(f&&E.length>=3){let g=a.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let v=ie(R);return!!v&&v.some(T=>!be(T,t,void 0)||Cn(T,[t])<=It/w)}),S=[E.slice().reverse()],M=r-_n;(!g.length||!Be(e,t,M,u,g,i,s,{holes:S,portalBase:r+_n}))&&W(e,t,S,()=>u,M,i,s,Y)}e.setMaterial(0)}var kn=.25,It=kn;function qc(e,t,n,o){if(n.length<3)return null;let r=s=>{let a=s.map(f=>[f.x,f.y]);return a.push(a[0]),a},i=s=>{let[a,...f]=s.map(c=>[r(c)]);return Ve.default.union(a,...f)};try{let s=[r(e),...(t??[]).map(r)],a=Ve.default.difference(s,[r(n)]),f=Ve.default.intersection(s,i(o.bays));if(!f.length)return null;let c=Ve.default.difference(Ve.default.intersection(s,i(o.walls)),f);return Ve.default.union(Ve.default.difference(a,f),c).map(u=>u.map(h=>h.slice(0,-1).map(([m,d])=>({x:m,y:d}))))}catch{return null}}var Jc=.02,el=.25,tl=1.2,nl=.6,ol=.45,rl=2.3,il=Math.PI/180,$r=.005;function ke(e,t,n){let o=n*il;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function sl(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let o=n.outerRMedian*.85;for(let r of e){if(r.role!=="wall")continue;let i=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(i.length<2)continue;let s=0;for(let a of i)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=o&&s++;if(s>=i.length/2)return!0}return!1}var al=24,cl=.01;function ll(e,t,n,o,r,i,s,a,f){let c=n.binCount,l=al,u=Q,h=i+.02,m=i-cl,d=[];for(let A=0;A<c;A++){let C=(n.startBin+A+.5)*t.binStepDeg,L=new Float64Array(l+1);for(let F=0;F<=l;F++){let O=o[A]+(r[A]-o[A])*F/l;L[F]=Math.max(h,zr(t,n,C,O)-el)}d.push(L)}if(f){let A=0;for(let C=0;C+1<c;C++)for(let L=0;L<l;L++){let F=ke(t.centre,o[C]+(r[C]-o[C])*L/l,(n.startBin+C+.5)*t.binStepDeg),O=ke(t.centre,o[C+1]+(r[C+1]-o[C+1])*(L+1)/l,(n.startBin+C+1.5)*t.binStepDeg);A=Math.max(A,Math.hypot(O.x-F.x,O.y-F.y))}for(let C=0;C<c;C++){let L=(n.startBin+C+.5)*t.binStepDeg;for(let F=0;F<=l;F++){let O=ke(t.centre,o[C]+(r[C]-o[C])*F/l,L),B=f(O.x,O.y,A*1.01);B!==null&&(d[C][F]=Math.min(d[C][F],Math.max(m+$r,B-$r)))}}}let p=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],b=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],x=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],y=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],I=(A,C)=>{let L=(n.startBin+A+.5)*t.binStepDeg,F=o[A]+(r[A]-o[A])*C/l,O=ke(t.centre,F,L);return[O.x*u,d[A][C],O.y*u]};{let A=Math.tan(12*Math.PI/180);for(let C=0;C<6;C++){let L=!1;for(let O=0;O<c;O++)for(let B=l-1;B>=0;B--)d[O][B]>d[O][B+1]&&(d[O][B]=d[O][B+1],L=!0);let F=n.closed?c:c-1;for(let O=0;O<F;O++){let B=(O+1)%c;for(let N=0;N<=l;N++){let H=d[B][N]-d[O][N];if(Math.abs(H)>1)continue;let D=o[O]+(r[O]-o[O])*N/l,U=o[B]+(r[B]-o[B])*N/l,V=ke(t.centre,D,(n.startBin+O+.5)*t.binStepDeg),$=ke(t.centre,U,(n.startBin+B+.5)*t.binStepDeg),X=A*Math.hypot($.x-V.x,$.y-V.y)*u;H>X?(d[B][N]=d[O][N]+X,L=!0):-H>X&&(d[O][N]=d[B][N]+X,L=!0)}}if(!L)break}}let P=1,E=(A,C)=>{for(let L=0;L<=l;L+=4)if(Math.abs(d[A][L]-d[C][L])>P)return!0;return Math.abs(d[A][l]-d[C][l])>P},g=Math.tan(38*Math.PI/180),S=A=>(r[A]-o[A])/l*u,M=(A,C)=>d[A][C+1]-d[A][C]>g*Math.max(1e-6,S(A)),R=(A,C)=>{let L=n.closed?(A-1+c)%c:Math.max(0,A-1),F=n.closed?(A+1)%c:Math.min(c-1,A+1);Math.abs(d[L][C]-d[A][C])>P&&(L=A),Math.abs(d[F][C]-d[A][C])>P&&(F=A);let O=Math.max(0,C-1),B=Math.min(l,C+1);O<C&&M(A,O)&&(O=C),B>C&&M(A,C)&&(B=C);let N=I(L,C),H=I(F,C),D=I(A,O),U=I(A,B),V=H[0]-N[0],$=H[1]-N[1],X=H[2]-N[2],J=U[0]-D[0],Z=U[1]-D[1],ce=U[2]-D[2],ae=$*ce-X*Z,G=X*J-V*ce,j=V*Z-$*J,q=Math.hypot(ae,G,j);return q>1e-12?(ae/=q,G/=q,j/=q,G<0&&(ae=-ae,G=-G,j=-j),[ae,G,j]):[0,1,0]},v=(A,C,L=!1)=>{let F=L&&Math.min(A[1],C[1])-i>=3,O=[A[0],F?A[1]-Rt:m,A[2]],B=[C[0],F?C[1]-Rt:m,C[2]],N=C[0]-A[0],H=C[2]-A[2],D=Math.hypot(N,H);if(!(D>1e-12))return;let U=[H/D,0,-N/D];e.tri(A,C,B,U,x,x,y),e.tri(A,B,O,U,x,y,y)},T=.05*Ie,k=A=>r[A]-o[A]<T,_=n.closed?c:c-1;for(let A=0;A<_;A++){let C=(A+1)%c;if(k(A)||k(C))continue;if(E(A,C)){let H=(n.startBin+A+1)*t.binStepDeg,D=(Z,ce)=>{let ae=(o[A]+o[C])/2,G=(r[A]+r[C])/2,j=ae+(G-ae)*ce/l,q=ke(t.centre,j,H);return[q.x*u,d[Z][ce],q.y*u]};for(let Z=0;Z<l;Z++){let ce=I(A,Z),ae=I(A,Z+1),G=D(A,Z),j=D(A,Z+1),q=R(A,Z),ue=R(A,Z+1);e.triN(ce,G,j,q,q,ue,p),e.triN(ce,j,ae,q,ue,ue,p);let fe=I(C,Z),he=I(C,Z+1),re=D(C,Z),se=D(C,Z+1),ve=R(C,Z),K=R(C,Z+1);e.triN(re,fe,he,ve,ve,K,p),e.triN(re,he,se,ve,K,K,p);let le=D(A,Z),me=D(A,Z+1),Ye=D(C,Z+1),Ke=D(C,Z),De=me[0]-le[0],Ne=me[2]-le[2],lt=Math.hypot(De,Ne);if(lt>1e-12){let wt=[Ne/lt,0,-De/lt];e.tri(le,me,Ye,wt,x),e.tri(le,Ye,Ke,wt,x)}}let U=I(A,0),V=I(C,0),$=I(C,l),X=I(A,l),J=Z=>[Z[0],m,Z[2]];Math.min(U[1],V[1])-i<3&&(e.tri(J(U),J($),J(V),[0,-1,0],b),e.tri(J(U),J(X),J($),[0,-1,0],b)),v(U,V,!0),v(X,$,!0);continue}for(let H=0;H<l;H++){let D=R(A,H),U=R(C,H),V=R(C,H+1),$=R(A,H+1);if(M(A,H)||M(C,H)){let ae=(me,Ye)=>{let Ke=(n.startBin+me+.5)*t.binStepDeg,De=o[me]+(r[me]-o[me])*(H+.5)/l,Ne=ke(t.centre,De,Ke);return[Ne.x*u,Ye,Ne.y*u]},G=I(A,H),j=I(C,H),q=ae(A,d[A][H]),ue=ae(C,d[C][H]);e.triN(G,j,ue,D,U,U,p),e.triN(G,ue,q,D,U,D,p);let fe=I(C,H+1),he=I(A,H+1),re=ae(A,d[A][H+1]),se=ae(C,d[C][H+1]);e.triN(re,se,fe,$,V,V,p),e.triN(re,fe,he,$,V,$,p);let ve=ue[0]-q[0],K=ue[2]-q[2],le=Math.hypot(ve,K);if(le>1e-12){let me=[-K/le,0,ve/le];e.tri(q,ue,se,me,x),e.tri(q,se,re,me,x)}continue}let X=I(A,H),J=I(C,H),Z=I(C,H+1),ce=I(A,H+1);e.triN(X,J,Z,D,U,V,p),e.triN(X,Z,ce,D,V,$,p)}let L=I(A,0),F=I(C,0),O=I(C,l),B=I(A,l),N=H=>[H[0],m,H[2]];Math.min(L[1],F[1])-i<3&&(e.tri(N(L),N(O),N(F),[0,-1,0],b),e.tri(N(L),N(B),N(O),[0,-1,0],b)),v(L,F,!0),v(B,O,!0)}if(!n.closed)for(let A of[0,c-1])for(let C=0;C<l;C++)v(I(A,C),I(A,C+1))}function Qr(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let l of t.rings)for(let u of l.arcs){let h=new Float64Array(u.binCount),m=new Float64Array(u.binCount);for(let p=0;p<u.binCount;p++){let b=(u.startBin+p)%t.binCount,x=Math.max(0,u.innerR[p]-Re);h[p]=Math.max(x,s[b]+.001),m[p]=Math.max(h[p]+.001,u.outerR[p]+Re)}let d=0;for(let p=0;p<u.binCount;p++){let b=u.topLevelM[p]-o;b>d&&(d=b)}d>=tl&&ll(e,t,u,h,m,o,r,i,n.standTopNear);for(let p=0;p<u.binCount;p++){let b=(u.startBin+p)%t.binCount;m[p]>s[b]&&(s[b]=m[p])}}if(n.deriveShell===!1||sl(n.shapes,t))return;let a=t.rings[t.rings.length-1],f=nl*Ie,c=ol*Ie;for(let l of a.arcs){let u=[],h=[];for(let R=0;R<l.binCount;R++){let v=(l.startBin+R+.5)*t.binStepDeg,T=l.outerR[R]+Re+f;u.push(ke(t.centre,T,v)),h.push(ke(t.centre,T+c,v))}let m=-1/0;for(let R=0;R<l.binCount;R++)l.topLevelM[R]>m&&(m=l.topLevelM[R]);let d=m+rl,p=l.closed?h:[...h,...u.slice().reverse()],b=l.closed?[u.slice().reverse()]:void 0,x=te(r.shellWall,[.66,.71,.72],.62),y=(R,v,T,k,_)=>{let A=Math.abs(k-m)<1e-6?k-Jc:k;Be(e,R,T,A,n.shapes,r.shellTop,_,{holes:v,portalBase:o,ao:i})||W(e,R,v,()=>A,T,r.shellTop,_,i)},I=Math.max(1,Math.ceil((m-o)/4.5)),P=(m-o)/I,E=new Set,g=n.tierFrontLevels??t.rings.map(R=>{let v=R.arcs.flatMap(T=>Array.from(T.frontLevelM)).filter(Number.isFinite).sort((T,k)=>T-k);return v[Math.floor(v.length/2)]});for(let R of g)Number.isFinite(R)&&R-o>=3&&R<m&&E.add(Math.max(0,Math.min(I-1,Math.floor((R-o)/P))));let S=Math.min(...g.filter(R=>Number.isFinite(R)&&R-o>=3&&R<m));for(let R=0;R<I;R++)o+(R+1)*P<=S-Rt&&Number.isFinite(S)&&E.add(R);for(let R=0;R<I;R++){let v=o+(m-o)*R/I,T=o+(m-o)*(R+1)/I;E.has(R)&&T-v>=3.2?(y(p,b,v,v+.45,x),vn(e,u,h,l.closed,v+.45,T-.16,r.shellTop,x,i,n.shapes,o)):y(p,b,v,T-.16,x),y(p,b,T-.16,T,z(x,.62))}vn(e,u,h,l.closed,m,d,r.shellTop,x,i,n.shapes,o);let M=8;for(let R=1;R<h.length;R++){if(M+=Math.hypot(h[R].x-h[R-1].x,h[R].y-h[R-1].y)*Q,M<8)continue;M=0;let v=h[R],T=h[R-1],k=v.x-T.x,_=v.y-T.y,A=Math.max(1,Math.hypot(k,_)),C=k/A*.16*Ie,L=_/A*.16*Ie,F=Math.max(1,Math.hypot(v.x-t.centre.x,v.y-t.centre.y)),O=(v.x-t.centre.x)/F*.24*Ie,B=(v.y-t.centre.y)/F*.24*Ie,N=[{x:v.x-C,y:v.y-L},{x:v.x+C,y:v.y+L},{x:v.x+C+O,y:v.y+L+B},{x:v.x-C+O,y:v.y-L+B}];y(N,void 0,o,m,z(x,1.12))}}}var ul=2.5,qr=.65,fl=2,ml=.03;function hl(e,t){let n=()=>{let o=t;for(;e.length>2;){let r=e[0],i=e[1],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>o){e[0]={x:r.x+(i.x-r.x)/s*o,y:r.y+(i.y-r.y)/s*o};return}o-=s,e.shift()}};n(),e.reverse(),n(),e.reverse()}function On(e,t,n){let o=new Map;for(let i of e){let s=o.get(i.blockId);(!s||i.depth<s.depth)&&o.set(i.blockId,i)}let r=[];for(let[i,s]of o){if(s.y-n<ul||s.pts.length<2)continue;let a=s.pts.map(l=>{let u=l.x-t.x,h=l.y-t.y,m=Math.max(1,Math.hypot(u,h));return{x:l.x-u/m*qr/w,y:l.y-h/m*qr/w}}),f=[],c=[a[0]];for(let l=1;l<a.length;l++){let u=a[l-1],h=a[l];Math.hypot(h.x-u.x,h.y-u.y)*w>fl?(c.length>=2&&f.push(c),c=[h]):c.push(h)}c.length>=2&&f.push(c);for(let l of f)hl(l,ml/w);f.length&&r.push({blockId:i,y:s.y,runs:f})}return r}var Jr=.1,dl=1.1,pl=.22,Tn=.95,Ln=.05,ei=1.8;function ti(e,t,n,o){let r=[.72,.72,.69],i=[.48,.55,.57];for(let s of On(t,n,o)){let a=s.y;for(let f of s.runs){let c=ei;for(let l=1;l<f.length;l++){let u=f[l-1],h=f[l],m=h.x-u.x,d=h.y-u.y,p=Math.hypot(m,d);if(p<1e-5)continue;let b=x=>{let y=-d/p*x/w/2,I=m/p*x/w/2;return[{x:u.x+y,y:u.y+I},{x:h.x+y,y:h.y+I},{x:h.x-y,y:h.y-I},{x:u.x-y,y:u.y-I}]};if(W(e,b(pl),void 0,()=>a+Jr,a-dl,r,r,Y),W(e,b(Ln),void 0,()=>a+Tn,a+Tn-Ln,i,i,Y),c+=p*w,c>=ei||l===f.length-1){c=0;let x=.028/w,y=[{x:u.x-x,y:u.y-x},{x:u.x+x,y:u.y-x},{x:u.x+x,y:u.y+x},{x:u.x-x,y:u.y+x}];W(e,y,void 0,()=>a+Tn-Ln,a+Jr,i,i,Y)}}}}}var bl=.9,yl=1.5,xl=.3;function ni(e,t,n){let o=[],r=[],i=bl/w,s=yl/w,a=xl/w;for(let f of e)for(let c of f.runs){if(c.length<2)continue;let l=c.slice(),u=(b,x)=>{let y=l[b],I=l[x],P=Math.hypot(y.x-I.x,y.y-I.y)||1;l[b]={x:y.x+(y.x-I.x)/P*a,y:y.y+(y.y-I.y)/P*a}};u(0,1),u(l.length-1,l.length-2);let h=l.map((b,x)=>{let y=l[Math.max(0,x-1)],I=l[Math.min(l.length-1,x+1)],P=I.x-y.x,E=I.y-y.y,g=Math.hypot(P,E)||1,S=-E/g,M=P/g;return S*(b.x-t.x)+M*(b.y-t.y)<0&&(S=-S,M=-M),{nx:S,ny:M}}),m=l.map((b,x)=>({x:b.x-h[x].nx*s,y:b.y-h[x].ny*s})),d=l.map((b,x)=>({x:b.x+h[x].nx*i,y:b.y+h[x].ny*i})),p=l.map((b,x)=>({x:b.x+h[x].nx*(i+n/w),y:b.y+h[x].ny*(i+n/w)}));o.push([...m,...d.slice().reverse()]),r.push([...d,...p.reverse()])}return{bays:o,walls:r}}function oi(e,t,n,o,r){let i=[.67,.71,.68];for(let s=0;s<t.length;s++){let a=t[s];if(!(a.pts.length<2))for(let f of[0,a.pts.length-1]){let c=a.pts[f],l=a.pts[f===0?1:f-1],u=c.x-l.x,h=c.y-l.y,m=Math.hypot(u,h);if(m<1e-5)continue;u/=m,h/=m;let d=1/0;for(let M=0;M<n.length;M++){let R=n[M],v=n[(M+1)%n.length],T=v.x-R.x,k=v.y-R.y,_=u*k-h*T;if(Math.abs(_)<1e-8)continue;let A=R.x-c.x,C=R.y-c.y,L=(A*k-C*T)/_,F=(A*h-C*u)/_;L>0&&F>=0&&F<=1&&(d=Math.min(d,L))}let p=.3/w,b=d-.04/w;if(!Number.isFinite(d)||d*w>2||b-p<.12/w)continue;let x=.27/w,y=[{x:c.x+u*p-h*x,y:c.y+h*p+u*x},{x:c.x+u*b-h*x,y:c.y+h*b+u*x},{x:c.x+u*b+h*x,y:c.y+h*b-u*x},{x:c.x+u*p+h*x,y:c.y+h*p-u*x}];if(!y.every(M=>xe(n,M.x,M.y)))continue;let I=r?.[s]?.belowY,P=I==null?0:a.y-I,E=!!o&&P>.03&&P<=.65;if(E&&o){let M=(R,v)=>Math.hypot((R.x+v.x)/2-o.x,(R.y+v.y)/2-o.y);M(y[0],y[1])>M(y[3],y[2])&&(y=[y[3],y[2],y[1],y[0]])}let g=E?Math.ceil((P-1e-8)/.2):1,S=(M,R,v)=>({x:M.x+(R.x-M.x)*v,y:M.y+(R.y-M.y)*v});for(let M=0;M<g;M++){let R=M/g,v=(M+1)/g,T=[S(y[0],y[3],R),S(y[1],y[2],R),S(y[1],y[2],v),S(y[0],y[3],v)],k=a.y+.008-(E?P*(1-v):0);if(W(e,T,void 0,()=>k,k-(E?P/g+.1:.16),i,[.43,.47,.46],Y),!E)continue;let _=Math.hypot(T[3].x-T[0].x,T[3].y-T[0].y)*w,A=Math.min(.04/_,.25),C=S(T[0],T[3],A),L=S(T[1],T[2],A),F=B=>[B.x*w,k+.004,B.y*w],O=[.66,.59,.39];e.tri(F(T[0]),F(T[1]),F(L),[0,1,0],O),e.tri(F(T[0]),F(L),F(C),[0,1,0],O)}}}}function ri(e,t,n,o,r,i,s,a,f=!1){if(!t.outline||t.outline.length<3)return;let c=n.baseHeightM,l=n.objects.filter(y=>y.type==="shape"&&(y.role==="entrance"||y.role==="exit")),u=Bo(o,a.tierTop);if(!r)return;let h=y=>r.deckAt(y.x,y.y),m=ir(t,s),d=m[0]??t.outline;if(r.rowLevels.length>=2){let y=Gt(r.rowLevels),I=sr(er(r.rowLevels,n.focal,y),m),P=ni(On(r.rowLevels,n.focal,c),n.focal,kn);for(let g of I){let S=Math.max(c,g.topY-ii);for(let M of i.subtract(g.outline,S))Zr(e,M,g.holes,S,c,a.tierTop,a.tierWall,l,!f,P)}I.length||W(e,d,t.holes,()=>r.landingY,c,u,a.tierWall,Y);let E={tread:[u[0]*Y.top,u[1]*Y.top,u[2]*Y.top],riser:[u[0]*.72,u[1]*.72,u[2]*.72]};for(let g of m.length?m:[d])nr(e,r.rowLevels,n.focal,r.landingY,E,g,y);ti(e,r.rowLevels,n.focal,c),oi(e,r.rowLevels,t.outline,n.focal,y);return}let p=r.flat?1/0:br,b=y=>r.normalAt(y.x,y.y),x=r.flat?r.landingY:void 0;for(let y of i.subtract(d,x))W(e,y,t.holes,h,c,u,a.tierWall,Y,p,b)}function gl(e,t,n){let o=new Set;for(let s of e.objects)s.type==="section"&&o.add(s.id);let r=new Map;for(let s=0;s<t.length;s++){let a=n.seatOwner[s];if(!a||!o.has(a))continue;let f=n.bySection.get(a);if(f&&f.rowLevels.length>=2)continue;let c=t[s];if(c.kind==="booth")continue;let l=r.get(a);l||(l=new Map,r.set(a,l));let u=c.rowId||`__seat-${s}`,h=l.get(u);h||(h={pts:[],levelM:0,n:0},l.set(u,h)),h.pts.push({x:c.x,y:c.y}),h.levelM+=n.seatDeckY(s),h.n++}let i=[];for(let s of e.objects){if(s.type!=="section")continue;let a=n.bySection.get(s.id);if(a&&a.rowLevels.length>=2){let c=a.rowLevels.filter(l=>!l.patch).map(l=>({pts:l.pts,levelM:l.y}));c.length>=2&&i.push({sectionId:s.id,rows:c});continue}let f=r.get(s.id);f&&i.push({sectionId:s.id,rows:[...f.values()].map(c=>({pts:c.pts,levelM:c.levelM/c.n}))})}return i}function Ml(e,t){let n=1/0;for(let o=0;o<t.length;o++){let r=t[o],i=t[(o+1)%t.length],s=i.x-r.x,a=i.y-r.y,f=Math.max(0,Math.min(1,((e.x-r.x)*s+(e.y-r.y)*a)/(s*s+a*a||1)));n=Math.min(n,Math.hypot(e.x-r.x-f*s,e.y-r.y-f*a))}return n}var ii=.02;function Sl(e,t){let n=e.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=t.bySection.get(o.id);if(!r)return[];let i=1/0,s=-1/0,a=1/0,f=-1/0;for(let l of o.outline)l.x<i&&(i=l.x),l.x>s&&(s=l.x),l.y<a&&(a=l.y),l.y>f&&(f=l.y);let c=r.landingY;for(let l of r.rowLevels)c=Math.min(c,l.y-ii);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:c,minX:i,maxX:s,minY:a,maxY:f}]});return(o,r,i)=>{let s=null;for(let a of n){if(o<a.minX-i||o>a.maxX+i||r<a.minY-i||r>a.maxY+i)continue;let f={x:o,y:r};if(!be(f,a.outline,a.holes)&&Ml(f,a.outline)>i)continue;let c=Math.min(a.surface.deckAt(o,r),a.floorTop);(s===null||c<s)&&(s=c)}return s}}var Il=3,Rl=.4;function si(e,t,n,o,r,i,s=!0){let a=gl(t,n,o);if(a.length<Il)return;let f=Wr(a,t.focal);if(!f)return;let c=Math.max(0,...f.rings.map(l=>l.arcs.reduce((u,h)=>u+h.binCount,0)))/f.binCount;e.setMaterial(5),Qr(e,f,{bottomY:t.baseHeightM,tierFrontLevels:a.map(l=>Math.min(...l.rows.map(u=>u.levelM))),colors:{bandTop:z(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??z(r.tierWall,1.15),shellWall:i??r.tierWall},ao:Y,shapes:t.objects.filter(l=>l.type==="shape"),deriveShell:s&&c>=Rl,standTopNear:Sl(t,o)}),e.setMaterial(0)}var ai=4;var Pl=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"],[/\b(walls?|outline|boundary|perimeter)\b/i,"wall"]],wl=1.2,El=12;function ci(e){if(e.heightM!==void 0)return!1;let t=ie(e);if(!t||t.length<3)return!1;let n=0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length];n+=Math.hypot(s.x-i.x,s.y-i.y)}return n*Q<El*2?!1:2*Pt(t)/n*Q<=wl}function Bn(e){if(!e)return null;for(let[t,n]of Pl)if(t.test(e))return n;return null}var ui="auto-rows-";function fi(e){return e.id.startsWith(ui)&&!e.label}var Al=1.15,vl=.09,mi=6,Cl=34,_l=.35,kl=6,Tl=.35,Ll=.75,Ol=12,Bl=2.5,Fl=40,Dl=[18,24],Nl=[12,16],li=14,Gl=.8,jl=.6,Hl=5,Xl=.3,hi=.4,Ul=2,Vl=400,Yl=2.6,Kl=.8,Wl=4,zl=26,Zl=1.6,$l=6e3,Ql=.6,ql="#c3c7cd",Fn=300,Jl=240;function eu(e,t,n,o){if(!e.fill||!/^#[0-9a-f]{6}$/i.test(e.fill))return null;let r=Nn([...t]),i=new Set;for(let l of o)i.add(Math.floor(Math.atan2(l.y-r.y,l.x-r.x)*180/Math.PI/10));if(i.size*10<Jl)return null;let{h:s,s:a,l:f}=wo(Po(e.fill));return s<70/360||s>170/360||a<.2||f<.08||f>.75||n.some(l=>l!==e&&l.type==="shape"&&ie(l)?.some(u=>jn(u,t)))?null:e.kind==="ellipse"?"oval-cricket":e.kind==="rect"?"pitch-football":null}var tu="Estimated from the drawing; confirm with the venue.",di=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},Nn=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length}),Pt=e=>{let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2};function nu(e){return e.height!==void 0||e.rake!==void 0||e.elevation!==void 0||e.surfaceKind!==void 0}function Gn(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 jn(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function Hn(e,t){let n=t[0],o=1/0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length],a=s.x-i.x,f=s.y-i.y,c=a*a+f*f,l=c>0?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*f)/c)):0,u={x:i.x+a*l,y:i.y+f*l},h=Math.hypot(e.x-u.x,e.y-u.y);h<o&&(o=h,n=u)}return n}function pi(e,t){let n=0,o=0;for(let r of e.values()){if(r.length<3)continue;let i=r[0],s=r[r.length-1],a=s.x-i.x,f=s.y-i.y,c=Math.hypot(a,f);if(c<1e-6)continue;let l={x:(i.x+s.x)/2,y:(i.y+s.y)/2},u=Hn(l,t),h=u.x-l.x,m=u.y-l.y,d=Math.hypot(h,m);d<1e-6||(o+=Math.abs((-f*h+a*m)/(c*d))*r.length,n+=r.length)}return n?o/n:0}function ou(e,t,n){let o=e.filter(p=>p.type==="shape"),r=o.find(p=>p.role==="stage");if(r){let p=ie(r);return p?{shape:r,centre:Nn(p),outline:p,inferred:!1}:null}if(!n.length)return null;let i=1/0,s=-1/0,a=1/0,f=-1/0;for(let p of n)i=Math.min(i,p.x),s=Math.max(s,p.x),a=Math.min(a,p.y),f=Math.max(f,p.y);let c=(s-i)*(f-a),l=[];for(let p of o){if(p.role)continue;let b=ie(p);if(!b)continue;let x=Pt(b);if(x*Q*Q<6||x>c)continue;let y=Math.min(...b.map(R=>R.x)),I=Math.max(...b.map(R=>R.x)),P=Math.min(...b.map(R=>R.y)),E=Math.max(...b.map(R=>R.y)),g=0;for(let R of n)R.x>y&&R.x<I&&R.y>P&&R.y<E&&jn(R,b)&&g++;if(g>n.length*.05)continue;let S=Nn(b),M=pi(t,b);M>=Gl&&l.push({shape:p,centre:S,outline:b,score:M,area:x,box:[y,P,I,E]})}let u=(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=>u(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 ru(e,t,n){if(!n||n.length<3)return Math.hypot(e.x-t.x,e.y-t.y);let o=Hn(e,n);return Math.hypot(e.x-o.x,e.y-o.y)}function bi(e){let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y);if(t.length<3)return t;let n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=[];for(let i of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}let r=[];for(let i=t.length-1;i>=0;i--){let s=t[i];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return[...o.slice(0,-1),...r.slice(0,-1)]}function iu(e){if(!e.length||e.length>$l)return[];let t=[...Gn(e).values()],n=t.map((a,f)=>f),o=a=>n[a]===a?a:n[a]=o(n[a]),r=Zl/Q,i=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 c=i[a],l=i[f];if(c.maxX<l.minX||l.maxX<c.minX||c.maxY<l.minY||l.maxY<c.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 s=new Map;return t.forEach((a,f)=>{let c=o(f),l=s.get(c);l?l.push(...a):s.set(c,[...a])}),[...s.values()].filter(a=>new Set(a.map(f=>f.rowId)).size>=2)}function su(e,t,n){if(!t.length)return null;let o=t.filter(M=>n.tableIds.has(M.rowId)||M.kind==="booth").length>t.length/2,r=Gn(t),i=!n.outline||pi(r,n.outline)>=jl,s=0,a=0;for(let M of r.values()){if(M.length<2)continue;let R=M[0],v=M[M.length-1],T=v.x-R.x,k=v.y-R.y,_=Math.hypot(T,k);if(_<1e-6)continue;let A={x:(R.x+v.x)/2,y:(R.y+v.y)/2},C=i?n.outline?Hn(A,n.outline):n.focal:n.middle,L=-k/_,F=T/_;L*(C.x-A.x)+F*(C.y-A.y)<0&&(L=-L,F=-F),s+=L*M.length,a+=F*M.length}let f={x:t.reduce((M,R)=>M+R.x,0)/t.length,y:t.reduce((M,R)=>M+R.y,0)/t.length};if(Math.hypot(s,a)<1e-9){let M=i?n.focal:n.middle;s=M.x-f.x,a=M.y-f.y}let c=Math.hypot(s,a)||1,l={x:s/c,y:a/c},u=M=>-(M.x*l.x+M.y*l.y),h=M=>-M.x*l.y+M.y*l.x,m=1/0,d=-1/0,p=1/0,b=-1/0,x=1/0,y=new Map;for(let M of t){let R=u(M),v=h(M);m=Math.min(m,R),d=Math.max(d,R),p=Math.min(p,v),b=Math.max(b,v),i&&(x=Math.min(x,ru(M,n.focal,n.outline)));let T=M.logicalRowId??M.rowId,k=y.get(T);k?k.push(R):y.set(T,[R])}i||(x=Math.max(0,m-u(n.middle)));let I=[...y.values()].map(M=>di(M)).sort((M,R)=>M-R),P=[];if(!o)for(let M of I)P.length&&M-P[P.length-1]<Tl/Q||P.push(M);let E=nu(e),g=Ge(e,{floorBaseHeightM:n.baseHeightM}),S={id:e.id,section:e,authored:E,plane:n,facing:l,facesAction:i,hull:bi(t),sample:t.filter((M,R)=>R%Math.ceil(t.length/Vl)===0),frontD:m,backD:d,latMin:p,latMax:b,frontDistance:x,rowDepths:P,rowCount:P.length,level:0,height:g.height,rake:E?g.rake:0,backHeight:0};return S.backHeight=S.height+(d-m)*Q*Math.tan(S.rake*Math.PI/180),S}function au(e,t,n,o){if(e.length<2)return 0;let r=Math.max(1,t*Q),i=n+Al-o,s=0,a=0;for(let c=1;c<e.length;c++){let l=Math.max(Ll,(e[c]-e[c-1])*Q),u=(i+vl)*(r+l)/r;s+=u-i,a+=l,i=u,r+=l}let f=Math.atan(s/a)*180/Math.PI;return Math.round(Math.max(mi,Math.min(Cl,f))*10)/10}function cu(e,t){if(e.facing.x*t.facing.x+e.facing.y*t.facing.y<Xl)return null;let n=-1/0,o=1/0,r=-1/0;for(let u of t.hull){n=Math.max(n,-(u.x*e.facing.x+u.y*e.facing.y));let h=-u.x*e.facing.y+u.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)<hi*(e.latMax-e.latMin))return null;let s=Ul/Q,a=new Map,f=new Map;for(let u of e.sample){let h=Math.floor((-u.x*e.facing.y+u.y*e.facing.x)/s),m=-(u.x*e.facing.x+u.y*e.facing.y);a.set(h,Math.min(a.get(h)??1/0,m))}for(let u of t.sample){let h=Math.floor((-u.x*e.facing.y+u.y*e.facing.x)/s),m=-(u.x*e.facing.x+u.y*e.facing.y);f.set(h,Math.max(f.get(h)??-1/0,m))}let c=[];for(let[u,h]of a){let m=f.get(u);m!==void 0&&c.push(h-m)}let l=c.length?di(c):e.frontD-n;return l<-1/Q?null:l}function lu(e,t){if(t.plane.floorIndex>=e.plane.floorIndex)return!1;let n=-1/0,o=1/0,r=1/0,i=-1/0;for(let f of t.hull){let c=-(f.x*e.facing.x+f.y*e.facing.y);n=Math.max(n,c),o=Math.min(o,c);let l=-f.x*e.facing.y+f.y*e.facing.x;r=Math.min(r,l),i=Math.max(i,l)}let s=Math.min(e.latMax,i)-Math.max(e.latMin,r),a=Math.min(e.backD,n)-Math.max(e.frontD,o);return s>hi*(e.latMax-e.latMin)&&a>1/Q}function uu(e,t){let n=new Set;for(let o of e){let r=(Math.atan2(o.y-t.y,o.x-t.x)*180/Math.PI+360)%360;n.add(Math.floor(r/10))}return n.size/36}function fu(e,t){let n=1/0,o=-1/0;for(let i of t.hull){let s=-(i.x*e.facing.x+i.y*e.facing.y);n=Math.min(n,s),o=Math.max(o,s)}let r=Math.max(0,Math.min(o-n,e.frontD-n));return t.height+r*Q*Math.tan(t.rake*Math.PI/180)}function mu(e,t=!1,n=!1){let o=t?Nl:Dl,r=new Map,i=[...e].sort((c,l)=>c.plane.floorIndex-l.plane.floorIndex||c.frontDistance-l.frontDistance),s=[],a=new Map,f=c=>{if(c.plane.floorIndex===0||c.plane.baseHeightM>0)return c.plane.baseHeightM;let l=a.get(c.plane.floorIndex-1);return l===void 0?c.plane.baseHeightM:l+ai};for(let c of i){if(!c.authored){let u=f(c),h;for(let p of s){if(p.plane.floorIndex>c.plane.floorIndex)continue;if(lu(c,p)){let I=fu(c,p)+Yl;I>u&&(u=I,h=p);continue}let b=cu(c,p);if(b==null)continue;let y=n&&!!c.plane.stageDeck&&p.level===0&&p.plane.floorIndex===c.plane.floorIndex&&Math.max(0,b)*Q<=Wl?p.backHeight:p.backHeight+_l+Math.min(kl,Math.max(0,b)*Q)*Math.tan(p.rake*Math.PI/180);y>u&&(u=y,h=p)}c.height=Math.round(Math.min(u,c.plane.baseHeightM+Fl)*100)/100;let m=!h&&c.height>c.plane.baseHeightM;if(c.level=h?h.level+1:m?1:0,c.rake=au(c.rowDepths,c.frontDistance,c.height,c.plane.focalHeightM),!c.facesAction&&c.rowCount<Hl)c.rake=0;else if(!h&&!m){let p=Math.max(1e-6,(c.backD-c.frontD)*Q);c.rake=Math.min(c.rake,Ol,Math.round(Math.atan(Bl/p)*1800/Math.PI)/10)}else c.rowCount>=2&&(c.rake=Math.max(c.rake,o[Math.min(c.level,o.length)-1]));let d=(c.backD-c.frontD)*Q;if(t&&d>0&&c.height+d*Math.tan(c.rake*Math.PI/180)>c.plane.baseHeightM+li){let p=Math.max(0,c.plane.baseHeightM+li-c.height);c.rake=Math.max(mi,Math.round(Math.atan(p/d)*1800/Math.PI)/10)}n&&c.plane.stageDeck&&c.level>0&&(c.rake=Math.min(c.rake,zl)),c.backHeight=c.height+d*Math.tan(c.rake*Math.PI/180),r.set(c.id,h?.id)}let l=c.plane.floorIndex;a.set(l,Math.min(a.get(l)??1/0,c.height)),s.push(c)}return r}var Dn=(e,t)=>!!e&&e.x===t.x&&e.y===t.y;function yi(e,t={x:0,y:-40}){let n=et(e),o=new Map;for(let b of n){if(!b.sectionId)continue;let x=o.get(b.sectionId);x?x.push(b):o.set(b.sectionId,[b])}let r={focalInferred:!1,confident:!1,sections:[]},i=e.floors?.length?e.floors.map((b,x)=>({objects:b.objects,floorIndex:x,floorId:b.id,baseHeightM:b.baseHeightM??0,focal:b.focalPoint??e.focalPoint})):[{objects:e.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:e.focalPoint}],s=new Set(i.flatMap(b=>b.objects.filter(x=>x.type==="table").map(x=>x.id))),a=[],f,c=new Set,l=i.map(b=>{let x=k=>!e.floors?.length||k.floorId===b.floorId,y=iu(n.filter(k=>!k.sectionId&&k.kind!=="booth"&&!s.has(k.rowId)&&x(k))),I=[];for(let k of y){let _=Pe(_e(bi(k)),Ql/Q);if(n.some(C=>!x(C)&&jn(C,_)))continue;let A=`${ui}${b.floorIndex}-${I.length}`;c.add(A),o.set(A,k),I.push({type:"section",id:A,label:"",color:ql,outline:_})}let P=I.length?{...b,objects:[...b.objects,...I]}:b,E=new Set(P.objects.filter(k=>k.type==="section").map(k=>k.logicalSectionId??k.id)),g=[...o.entries()].filter(([k])=>E.has(k)).flatMap(([,k])=>k),S=ou(P.objects,Gn(g),g),M=P.focal;(S||P.focal&&!Dn(P.focal,t))&&(r.confident=!0),S&&(r.stage??={id:S.shape.id,inferred:S.inferred,...P.floorId?{floorId:P.floorId}:{}},(S.inferred||Dn(P.focal,t))&&(M=S.centre,r.focalInferred=!0));let R=S&&(!S.inferred||Pt(S.outline)*Q*Q<=Fn),v=S?void 0:f,T={tableIds:s,floorIndex:P.floorIndex,floorId:P.floorId,baseHeightM:P.baseHeightM,focal:v?.focal??M,outline:S?.outline??v?.outline,focalHeightM:v?.focalHeightM??P.baseHeightM+(S&&R?Ee({...S.shape,role:"stage"}).heightM:0),stageDeck:v?.stageDeck??!!(S&&R&&Pt(S.outline)*Q*Q<=Fn),middle:g.length?{x:g.reduce((k,_)=>k+_.x,0)/g.length,y:g.reduce((k,_)=>k+_.y,0)/g.length}:M};for(let k of P.objects){if(k.type!=="section")continue;let _=su(k,o.get(k.logicalSectionId??k.id)??[],T);_&&a.push(_)}return T.outline&&(f=T),Dn(P.focal,T.focal)||(r.focal??=[]).push({...P.floorId?{floorId:P.floorId}:{},point:{...T.focal}}),{unit:P,plane:T,stage:S,planeSeats:g}}),u=i.flatMap(b=>b.objects).map(b=>b.type==="shape"&&!b.role&&(Bn(b.label)==="wall"||!Bn(b.label)&&ci(b))?{...b,role:"wall"}:b),h=ot({objects:u},n)!==null;h&&(r.indoor=!0);let m=mu(a,h,uu(n,l[0]?.plane.focal??t)<Kl),d=new Map(a.filter(b=>!b.authored).map(b=>[b.id,b])),p=l.map(({unit:b,plane:x,stage:y,planeSeats:I})=>b.objects.map(P=>{let E=P.type==="shape"&&!P.role&&P.id!==y?.shape.id?Bn(P.label):null;if(P.type==="shape"&&!P.role&&P.id!==y?.shape.id&&(E==="wall"||!E&&ci(P))&&P.type==="shape"){(r.roles??=[]).push({id:P.id,...x.floorId?{floorId:x.floorId}:{},role:"wall"});let{fill:T,...k}=P;return{...k,role:"wall"}}if(E&&P.type==="shape")return(r.roles??=[]).push({id:P.id,...x.floorId?{floorId:x.floorId}:{},role:E}),{...P,role:E};let S=y?.inferred&&P.id===y.shape.id&&P.type==="shape"?eu(P,y.outline,b.objects,I):null;if(S&&P.type==="shape")return r.stage?.id===P.id&&(r.stage.field=S),{...P,role:"stage",stageKind:S};if(y?.inferred&&P.id===y.shape.id&&P.type==="shape"&&Pt(y.outline)*Q*Q<=Fn)return r.stage?.id===P.id&&(r.stage.deck=!0),{...P,role:"stage"};let M=P.type==="section"?d.get(P.id):void 0;if(!M||P.type!=="section")return P;let R=M.rowCount>=2&&M.rake>0;c.has(M.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:M.id,floorId:x.floorId,surfaceKind:R?"rakedRows":"flat",height:M.height,rake:M.rake,stackedOn:m.get(M.id)});let v={status:"inferred",source:"public-2d-topology",note:tu};return{...P,height:M.height,rake:M.rake,surfaceKind:R?"rakedRows":"flat",physical3dProvenance:{height:v,rake:v,surfaceKind:v}}}));if(e.floors?.length){let b=e.floors.map((x,y)=>({...x,objects:p[y],focalPoint:l[y].plane.focal}));return{doc:{...e,floors:b,objects:b[0].objects,focalPoint:b[0].focalPoint},report:r}}return{doc:{...e,objects:p[0],focalPoint:l[0].plane.focal},report:r}}var xi=/^[\p{L}\p{N}]{1,4}$/u,hu=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function gi(e,t){let n=t?.trim();if(!n)return e;let o=e.toLocaleLowerCase("en-US"),r=n.toLocaleLowerCase("en-US");if(o.startsWith(`${r} `)){let s=e.slice(n.length).trim();if(xi.test(s))return s}let i=hu.exec(e);if(i){let s=i[1].toLocaleLowerCase("en-US"),a=i[2].trim();if((r.startsWith(s)||s.startsWith(r))&&xi.test(a))return a}return e}var du=6,pu=2.2,Mi=.1,bu=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),yu=.3,xu=1.8,gu=.9,Mu=.55,Su=6e3;function Ii(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let f=new Map;for(let l of n)for(let u of l.objects)u.type==="section"&&u.zone&&f.set(u.id,u.zone);let c=new Map;for(let l=0;l<o.length;l++){let u=o[l],h=r.seatOwner[l],m=u.zoneId??(h?f.get(h):void 0);if(!m)continue;let d=c.get(m);d||(d={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},c.set(m,d)),d.n++,u.x<d.minX&&(d.minX=u.x),u.y<d.minY&&(d.minY=u.y),u.x>d.maxX&&(d.maxX=u.x),u.y>d.maxY&&(d.maxY=u.y),d.sumY+=r.seatDeckY(l)}for(let l of s){let u=c.get(l.id),h=[];for(let[m,d]of f)d===l.id&&h.push(m);if(!u||u.n===0){a.push({id:l.id,label:l.label,color:ne(l.color),sectionIds:h,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(l.focalPoint??i).x*w,1.5,(l.focalPoint??i).y*w]});continue}a.push({id:l.id,label:l.label,color:ne(l.color),sectionIds:h,seatCount:u.n,center:[(u.minX+u.maxX)/2*w,u.sumY/u.n,(u.minY+u.maxY)/2*w],radius:.5*Math.hypot((u.maxX-u.minX)*w,(u.maxY-u.minY)*w)||1,focalWorld:[(l.focalPoint??i).x*w,1.5,(l.focalPoint??i).y*w]})}}return a}function Ri(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:f}=e,c=[],l=[],u=[],h=new Map;for(let m of n)for(let d of m.objects){if(d.type!=="section"||!d.zone)continue;let p=(d.displayLabel||d.label||"").trim().toLocaleLowerCase();if(!p)continue;let b=t.floors?.[m.index]?.name?.trim().toLocaleLowerCase();if(n.length>1&&b===p)continue;let x=h.get(d.zone);x||h.set(d.zone,x=new Set),x.add(p)}for(let m of a)m.seatCount!==0&&(h.get(m.id)?.has(m.label.trim().toLocaleLowerCase())||c.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+du,m.center[2]],color:t.zones?.find(d=>d.id===m.id)?.color}));{let m=new Map,d=new Map;for(let p=0;p<o.length;p++){let b=r.seatOwner[p];if(!b)continue;let x=m.get(b);x||(x={n:0,x:0,y:0,deck:0},m.set(b,x)),x.n++,x.x+=o[p].x,x.y+=o[p].y,x.deck+=r.seatDeckY(p);let y=d.get(b);y||(y={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},d.set(b,y)),y.minDeck=Math.min(y.minDeck,r.seatDeckY(p)),y.maxDeck=Math.max(y.maxDeck,r.seatDeckY(p)),o[p].x<y.minX&&(y.minX=o[p].x),o[p].x>y.maxX&&(y.maxX=o[p].x),o[p].y<y.minY&&(y.minY=o[p].y),o[p].y>y.maxY&&(y.maxY=o[p].y)}for(let p of n)for(let b of p.objects){if(b.type!=="section"||fi(b))continue;let x=m.get(b.id);if(!x||x.n===0)continue;let y=d.get(b.id),I=[x.x/x.n*w,x.deck/x.n,x.y/x.n*w],P=b.displayLabel||b.label||b.id;l.push({id:b.id,floorIndex:p.index,label:P,seatCount:x.n,center:I,radius:Math.max(1,Math.hypot(y.maxX-y.minX,y.maxY-y.minY)*.5*w),box:{min:[y.minX*w-.4,y.minDeck,y.minY*w-.4],max:[y.maxX*w+.4,y.maxDeck+1,y.maxY*w+.4]},focalWorld:[p.focal.x*w,p.baseHeightM+1.5,p.focal.y*w]});let E=t.floors?.[p.index]?.name?.trim().toLocaleLowerCase();n.length>1&&E===P.trim().toLocaleLowerCase()||c.push({id:`section:${b.id}`,kind:"section",text:P,anchor:[I[0],I[1]+pu,I[2]],floorIndex:p.index})}}{for(let x of n)for(let y of x.objects){if(y.type!=="gaArea")continue;let I=ut(y.points);if(!I)continue;let P=y.displayLabel||y.label||y.id;c.push({id:`ga:${y.id}`,kind:"ga",text:y.capacity>0?`${P} \xB7 ${y.capacity.toLocaleString()}`:P,anchor:[I.x*w,x.baseHeightM+xu,I.y*w],floorIndex:x.index})}let m=new Map,d=new Map;for(let x of n)for(let y of x.objects)if(y.type==="section"&&m.set(y.id,y.displayLabel||y.label||y.id),y.type==="row"){let I=y.displayLabel?.trim()||y.segmentedRow?.displayLabel?.trim();I&&d.set(y.id,I)}let p=new Map;for(let x=0;x<o.length;x++){let y=o[x],I=Math.hypot(y.x-f.x,y.y-f.y),P=p.get(y.rowId);(!P||I>P.far)&&p.set(y.rowId,{seat:y,index:x,far:I})}for(let[x,y]of p){let I=r.seatOwner[y.index]??y.seat.sectionId,P=Si(y.seat.label,x,m.get(I??""),d.get(x));P&&c.push({id:`row:${x}`,kind:"row",text:P,anchor:[y.seat.x*w,r.seatDeckY(y.index)+gu,y.seat.y*w],floorIndex:s[y.index]})}let b=new Map;for(let x=0;x<o.length;x++){let y=o[x],I=b.get(y.rowId);I||(I={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:Si(y.label,y.rowId,m.get(r.seatOwner[x]??y.sectionId??""),d.get(y.rowId)),sectionId:r.seatOwner[x]??y.sectionId},b.set(y.rowId,I));let P=x*3,E=i.iPosition[P],g=i.iPosition[P+1],S=i.iPosition[P+2];I.n++,I.x+=E,I.y+=g,I.z+=S,I.minX=Math.min(I.minX,E),I.maxX=Math.max(I.maxX,E),I.minZ=Math.min(I.minZ,S),I.maxZ=Math.max(I.maxZ,S)}for(let[x,y]of b)u.push({id:x,label:y.label,sectionId:y.sectionId,seatCount:y.n,center:[y.x/y.n,y.y/y.n,y.z/y.n],radius:Math.max(.8,Math.hypot(y.maxX-y.minX,y.maxZ-y.minZ)*.5)});if(o.length<=Su)for(let x=0;x<o.length;x++){let y=o[x],I=Iu(y.displayLabel||y.label);I&&c.push({id:`seat:${y.id}`,kind:"seat",seatWidthM:i.iChairWidth[x]*2,text:I,anchor:[y.x*w,r.seatDeckY(x)+Mu,y.y*w],floorIndex:s[x],rowId:y.rowId})}}for(let m of n)for(let d of m.objects)if(d.type==="shape"&&d.role&&bu.has(d.role)){let p=ie(d),b=p?ut(p):null;if(!b||!d.label)continue;c.push({id:`architecture:${d.id}`,kind:d.role==="stage"?"stage":"annotation",text:d.label,anchor:[b.x*w,m.baseHeightM+Ee(d).heightM+Mi,b.y*w],color:d.fill,floorIndex:m.index})}else if(d.type==="text"){if(!d.text)continue;c.push({id:`text:${d.id}`,kind:"annotation",text:d.text,anchor:[d.position.x*w,m.baseHeightM+Mi,d.position.y*w],color:d.color,rotation:d.rotation,floorIndex:m.index})}else if(d.type==="booth"){let p=Ae(d);if(!p)continue;let b=ut(p);if(!b)continue;c.push({id:`booth:${d.id}`,kind:"booth",text:d.displayLabel||d.label||d.id,anchor:[b.x*w,m.baseHeightM+Zt+yu,b.y*w],floorIndex:m.index})}return{labels:c,sections:l,rows:u}}function Pi(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 Iu(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function Si(e,t,n,o){if(o?.trim())return o.trim();let r=e?e.lastIndexOf("-"):-1,i=r>0?e.slice(0,r):t;return i&&gi(i,n)}function wi(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,f=[];{let c=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let h=0;h<i.floor.length;h+=1){let m=Math.max(0,Math.min(n.length-1,Math.round(i.floor[h]))),d=h*3,p=c[m];p.minX=Math.min(p.minX,i.position[d]),p.minY=Math.min(p.minY,i.position[d+1]),p.minZ=Math.min(p.minZ,i.position[d+2]),p.maxX=Math.max(p.maxX,i.position[d]),p.maxY=Math.max(p.maxY,i.position[d+1]),p.maxZ=Math.max(p.maxZ,i.position[d+2])}let 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 u=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)??s[h];if(d===void 0)continue;let p=u[d],b=o[h];p.n++,b.x<p.minX&&(p.minX=b.x),b.y<p.minY&&(p.minY=b.y),b.x>p.maxX&&(p.maxX=b.x),b.y>p.maxY&&(p.maxY=b.y);let x=r.seatDeckY(h);p.sumX+=b.x*w,p.sumDeck+=x,p.sumZ+=b.y*w,p.minDeck=Math.min(p.minDeck,x),p.maxDeck=Math.max(p.maxDeck,x+1.6),a[h]=d}for(let h=0;h<n.length;h++){let m=u[h],d=t.floors?.[h],p=c[h],b=Math.min(m.n?m.minX*w:n[h].focal.x*w-1,Number.isFinite(p.minX)?p.minX:1/0),x=Math.max(m.n?m.maxX*w:n[h].focal.x*w+1,Number.isFinite(p.maxX)?p.maxX:-1/0),y=Math.min(m.n?m.minY*w:n[h].focal.y*w-1,Number.isFinite(p.minZ)?p.minZ:1/0),I=Math.max(m.n?m.maxY*w:n[h].focal.y*w+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),P=Math.min(m.n?Math.min(n[h].baseHeightM,m.minDeck):n[h].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),E=Math.max(m.n?Math.max(m.maxDeck,P+.5):P+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),g=[m.n?m.sumX/m.n:(b+x)/2,m.n?m.sumDeck/m.n:(P+E)/2,m.n?m.sumZ/m.n:(y+I)/2],S=Math.max(1,.5*Math.hypot(x-b,E-P,I-y));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:S,box:{min:[b,P,y],max:[x,E,I]},focalWorld:[n[h].focal.x*w,n[h].baseHeightM+1.5,n[h].focal.y*w]})}}return f}function Xn(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,f)=>{a<n&&(n=a),f<o&&(o=f),a>r&&(r=a),f>i&&(i=f)};for(let a of t)s(a.x,a.y);for(let a of e)for(let f of a.objects)if(f.type==="section")for(let c of f.outline)s(c.x,c.y);else if(f.type==="shape"&&f.points)for(let c of f.points)s(c.x,c.y);else if(f.type==="gaArea")for(let c of f.points)s(c.x,c.y);else if(f.type==="booth"){let c=Ae(f);if(c)for(let l of c)s(l.x,l.y)}else if(f.type==="table"){let c=$t(f);if(c)for(let l of c)s(l.x,l.y)}else if(f.type==="decorImage"){let c=Qt(f);if(c)for(let l of c)s(l.x,l.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function ki(e,t,n,o,r,i,s){if(t.length===1){let a=n.map(h=>({x:h.x,y:h.y}));for(let h of t[0].objects)h.type==="section"?a.push(...h.outline):h.type==="shape"?a.push(...ie(h)??h.points??[]):h.type==="gaArea"?a.push(...h.points):h.type==="booth"?a.push(...Ae(h)??[]):h.type==="table"?a.push(...$t(h)??[]):h.type==="decorImage"&&a.push(...Qt(h)??[]);if(vi(e,t[0],n,i)||_i(e,t[0],n,a,i))return!1;if(s&&Ai(e,t[0].baseHeightM,a,i,s))return!0;let f=gt(a),c=(r.minX+r.maxX)/2,l=(r.minY+r.maxY)/2,u=f.length>=3?f.map(h=>{let m=h.x-c,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}}):bt(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return W(e,u,void 0,()=>-.04,-.22,i.ground,i.ground,Y),!1}else{let a=t.reduce((b,x)=>x.baseHeightM<b.baseHeightM?x:b);e.setFloor(a.index);let f={...a,objects:t.flatMap(b=>b.objects)},c=n.map(b=>({x:b.x,y:b.y}));for(let b of f.objects)b.type==="section"&&c.push(...b.outline);if(vi(e,f,n,i)||_i(e,f,n,c,i))return!1;if(s&&Ai(e,a.baseHeightM,c,i,s))return!0;let l=n.filter((b,x)=>o[x]===a.index),u=Xn([a],l),h=Math.hypot(u.maxX-u.minX,u.maxY-u.minY),m=Math.max(28,Math.min(80,h*.04)),d=bt(u.minX-m,u.minY-m,u.maxX-u.minX+m*2,u.maxY-u.minY+m*2),p=a.baseHeightM-.03;return W(e,d,void 0,()=>p,p-.22,i.ground,i.ground,Y),!1}}function Un(e,t,n,o){let{cx:r,cz:i,radius:s}=n,a=1/0,f=1/0,c=1/0,l=-1/0,u=-1/0,h=-1/0,m=(b,x,y)=>{a=Math.min(a,b),l=Math.max(l,b),f=Math.min(f,x),u=Math.max(u,x),c=Math.min(c,y),h=Math.max(h,y)};for(let b=0;b<e.position.length;b+=3){let x=b/3;o&&x>=o[0]&&x<o[1]||m(e.position[b],e.position[b+1],e.position[b+2])}for(let b=0;b<t.count;b++){let x=b*3,y=t.iPosition[x],I=t.iPosition[x+1],P=t.iPosition[x+2],E=Math.max(.35,t.iMaxRadius[b]??.35);m(y-E,I,P-E),m(y+E,I+1.6,P+E)}Number.isFinite(a)||(a=r-s,l=r+s,f=0,u=s*.16,c=i-s,h=i+s);let d=[(a+l)/2,(f+u)/2,(c+h)/2],p=Math.max(1,.5*Math.hypot(l-a,u-f,h-c));return{center:d,radius:p,minY:f,maxY:u}}var Ru=4096;function Ti(e,t,n=[]){let o=Math.max(1,Math.ceil(e.count/Ru)),r=Math.ceil(e.count/o),i=new Float32Array((r*2+t.length*4+n.length)*3),s=0;for(let a=0;a<e.count;a+=o){let f=e.iPosition[a*3],c=e.iPosition[a*3+1],l=e.iPosition[a*3+2];i[s++]=f,i[s++]=c,i[s++]=l,i[s++]=f,i[s++]=0,i[s++]=l}for(let[a,f,c]of n)i[s++]=a,i[s++]=f,i[s++]=c;for(let a of t)for(let[f,c]of[[-1,-1],[1,-1],[1,1],[-1,1]])i[s++]=a.cx+f*a.halfX,i[s++]=a.y,i[s++]=a.cz+c*a.halfZ;return i.subarray(0,s)}function Li(e,t,n,o,r,i,s=[]){let a=1/0,f=1/0,c=-1/0,l=-1/0;for(let E=0;E<e.count;E++){let g=E*3,S=e.iPosition[g],M=e.iPosition[g+2];S<a&&(a=S),S>c&&(c=S),M<f&&(f=M),M>l&&(l=M)}for(let[E,,g]of s)E<a&&(a=E),E>c&&(c=E),g<f&&(f=g),g>l&&(l=g);for(let E of t)a=Math.min(a,E.cx-E.halfX),c=Math.max(c,E.cx+E.halfX),f=Math.min(f,E.cz-E.halfZ),l=Math.max(l,E.cz+E.halfZ);let u=n.minX*w,h=n.maxX*w,m=n.minY*w,d=n.maxY*w,p=u,b=h,x=m,y=d;if(Number.isFinite(a)){let E=Math.max(2,.06*Math.hypot(c-a,l-f));p=Math.max(u,a-E),b=Math.min(h,c+E),x=Math.max(m,f-E),y=Math.min(d,l+E)}let I=Math.min(0,o),P=Math.max(r,i*.05);return{min:[p,I,x],max:[b,P,y]}}var Ei=12,Pu=.6,wu=40;function Ai(e,t,n,o,r){let i=gt([...n]);if(i.length<3)return!1;let s=1/0,a=1/0,f=-1/0,c=-1/0;for(let P of i)s=Math.min(s,P.x),f=Math.max(f,P.x),a=Math.min(a,P.y),c=Math.max(c,P.y);let l=Math.hypot(f-s,c-a)*w,u=Pe(i,Ei/w,1.2),h=Math.max(wu,l*Pu),m=Pe(i,(Ei+h)/w,1.2);if(u.length!==m.length)return!1;let d=te(o.ground,[.78,.76,.72],.35),p=te(o.ground,[.56,.62,.52],.3);W(e,u,void 0,()=>t-.04,t-.22,d,d,Y);let b=t-.05,x=u.map(P=>[P.x*w,b,P.y*w]),y=m.map(P=>[P.x*w,b,P.y*w]),I=[0,1,0];for(let P=0;P<x.length;P++){let E=(P+1)%x.length;e.tri(x[P],y[E],y[P],I,p,r,r),e.tri(x[P],x[E],y[E],I,p,p,r)}return!0}function vi(e,t,n,o){let r=ot(t,n);if(!r)return!1;let i=t.baseHeightM,s=te(o.ground,[.62,.55,.47],.4);return W(e,r,void 0,()=>i-.04,i-.22,s,s,Y),!0}var Eu=3e3,Au=20,Ci=1.5,vu=1.2,Cu=.25;function _i(e,t,n,o,r){if(!n.length||n.length>Eu||o.length<3)return!1;for(let R of t.objects){if(R.type==="shape"&&vt(R.stageKind))return!1;if(R.type==="section"){let{height:v}=Ge(R,{floorBaseHeightM:t.baseHeightM});if(v-t.baseHeightM>Au)return!1}}let i=0,s=0;for(let R of o)i+=R.x,s+=R.y;i/=o.length,s/=o.length;let a=0,f=0,c=0;for(let R of o){let v=R.x-i,T=R.y-s;a+=v*v,f+=T*T,c+=v*T}let l=.5*Math.atan2(2*c,a-f),u=Math.cos(l),h=Math.sin(l),m=-h,d=u,p=1/0,b=-1/0,x=1/0,y=-1/0;for(let R of o){let v=(R.x-i)*u+(R.y-s)*h,T=(R.x-i)*m+(R.y-s)*d;p=Math.min(p,v),b=Math.max(b,v),x=Math.min(x,T),y=Math.max(y,T)}let I=R=>[[p-R,x-R],[b+R,x-R],[b+R,y+R],[p-R,y+R]].map(([v,T])=>({x:i+u*v+m*T,y:s+h*v+d*T})),P=I(Ci/w),E=I((Ci+Cu)/w),g=t.baseHeightM,S=te(r.ground,[.62,.55,.47],.4),M=te(r.ground,[.86,.86,.84],.55);return W(e,E,void 0,()=>g-.04,g-.22,S,S,Y),W(e,E,[P.slice().reverse()],()=>g+vu,g-.04,te(M,[1,1,1],.2),M,Y),!0}function Oi(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=so(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let u of n)for(let h of u.objects)h.type==="shape"&&i.set(h.id,{shape:h,unit:u});let s=new Set,a=new Set,f=new Map((t.overlay.productionElements??[]).map(u=>{let h=u.runtimeContentImageUrl;return[u.id,typeof h=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(h)?h:void 0]})),c=[];for(let u of r.value.overlay.productionElements??[]){let h=i.get(u.objectId),m=h?ie(h.shape):null,d=u.baseElevationM??0;if(!h||!m||m.length<3||!u.id||s.has(u.id)||a.has(u.objectId)||!Number.isFinite(u.heightM)||u.heightM<.05||u.heightM>50||!Number.isFinite(d)||d<-10||d>100)return o();s.add(u.id),a.add(u.objectId);let p=m.map(M=>M.x*w),b=m.map(M=>M.y*w),x=h.unit.baseHeightM+d,y=Math.min(...p),I=Math.max(...p),P=Math.min(...b),E=Math.max(...b),g,S=f.get(u.id)??u.contentImageUrl;if(u.kind==="screen"&&S&&(g=xr(m,x,x+u.heightM,h.unit.focal),!g))if(I-y>=E-P){let M=Math.abs(P-h.unit.focal.y*w)<=Math.abs(E-h.unit.focal.y*w)?P-.006:E+.006;g=[[y,x,M],[I,x,M],[y,x+u.heightM,M],[I,x+u.heightM,M]]}else{let M=Math.abs(y-h.unit.focal.x*w)<=Math.abs(I-h.unit.focal.x*w)?y-.006:I+.006;g=[[M,x,P],[M,x,E],[M,x+u.heightM,P],[M,x+u.heightM,E]]}c.push({id:u.id,objectId:u.objectId,kind:u.kind,floorIndex:h.unit.index,baseY:x,topY:x+u.heightM,bounds:{min:[y,x,P],max:[I,x+u.heightM,E]},occlusion:u.occlusion,...S?{contentImageUrl:S}:{},...g?{contentPlane:g}:{}})}let l=c.sort((u,h)=>u.id.localeCompare(h.id));return{byObjectId:new Map(l.map(u=>[u.objectId,u])),elements:l}}var Bi=[.13,.14,.17],ct=[.4,.43,.47],_u=.18,ku=.02,Tu=2.4,Lu=1500,Ou=240;function Fi(e,t,n,o){let r=t.stageKind??"";if(We(r)||r==="round"||!o.length)return;let i=ie(t);if(!i||i.length<3)return;let s={x:i.reduce((C,L)=>C+L.x,0)/i.length,y:i.reduce((C,L)=>C+L.y,0)/i.length},a=0,f=0,c=new Set;for(let C of o)a+=C.x,f+=C.y,c.add(Math.floor(Math.atan2(C.y-s.y,C.x-s.x)*180/Math.PI/10));if(c.size*10>Ou)return;let l=s.x-a/o.length,u=s.y-f/o.length,h=Math.hypot(l,u);if(h<1e-6)return;let m=l/h,d=u/h,p=-d,b=m,x=-1/0,y=1/0,I=1/0,P=-1/0;for(let C of i){let L=(C.x-s.x)*m+(C.y-s.y)*d,F=(C.x-s.x)*p+(C.y-s.y)*b;x=Math.max(x,L),y=Math.min(y,L),I=Math.min(I,F),P=Math.max(P,F)}let E=(P-I)*w,g=(x-y)*w;if(E<3||g<1.5||E*g>Lu)return;let S=_u/w,M=(C,L)=>({x:s.x+m*C+p*L,y:s.y+d*C+b*L}),R=(C,L,F,O)=>[M(C,F),M(C,O),M(L,O),M(L,F)],v=n+Math.max(3.5,Math.min(8,E*.35)),T=n+Math.min(Tu,v-n-1),k=.2/w,_=y+Math.min(g*.25,1.5)/w,A=ku/w;W(e,R(x-2*S+A,x-S-A,I+S+k,P-S-k),void 0,()=>T,n,Bi,Bi,Y);for(let[C,L]of[[I+S,I+S+k],[P-S-k,P-S]])W(e,R(x-2*S,x-S,C,L),void 0,()=>v+.3,n,ct,ct,Y),W(e,R(_+k,x-2*S,C,L),void 0,()=>v+.3,v,ct,ct,Y);W(e,R(_,_+k,I+S,P-S),void 0,()=>v+.3,v,ct,ct,Y)}function Se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Me(e){return Array.isArray(e)?e:[]}function Bu(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!Se(n))continue;let o=Se(n.extensions)?n.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function en(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function Fu(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Du(e,t){let n=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let i=0;i<4;i++)n[o*4+r]+=e[i*4+r]*t[o*4+i];return n}function Nu(e){let t=en(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:en(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:en(e.rotation,4),r=e.scale===void 0?[1,1,1]:en(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,f]=o,c=Math.hypot(i,s,a,f);if(!(c>1e-8))return null;let l=i/c,u=s/c,h=a/c,m=f/c,d=l+l,p=u+u,b=h+h,x=l*d,y=l*p,I=l*b,P=u*p,E=u*b,g=h*b,S=m*d,M=m*p,R=m*b;return[(1-(P+g))*r[0],(y+R)*r[0],(I-M)*r[0],0,(y-R)*r[1],(1-(x+g))*r[1],(E+S)*r[1],0,(I+M)*r[2],(E-S)*r[2],(1-(x+P))*r[2],0,n[0],n[1],n[2],1]}function Gu(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 ju(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],f=e[6],c=e[10],l=i*c-s*f,u=s*a-r*c,h=r*f-i*a,m=t*l+n*u+o*h;if(Math.abs(m)<1e-12)return null;let d=1/m;return[l*d,u*d,h*d,(o*f-n*c)*d,(t*c-o*a)*d,(n*a-t*f)*d,(n*s-o*i)*d,(o*r-t*s)*d,(t*i-n*r)*d]}function Di(e,t,n,o){let r=e[0]*t+e[1]*n+e[2]*o,i=e[3]*t+e[4]*n+e[5]*o,s=e[6]*t+e[7]*n+e[8]*o,a=Math.hypot(r,i,s)||1;return r/=a,i/=a,s/=a,[r,i,s]}function Hu(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,o=null,r=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),s=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let a=e.subarray(n,n+i);if(s===1313821514&&!o)try{let f=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!Se(f))return null;o=f}catch{return null}else if(s===5130562&&!r)r=a;else return null;n+=i}return n===e.byteLength&&o&&r?{json:o,bin:r}:null}function Xu(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function Uu(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Vu(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 Yu(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Hu(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!Se(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=Me(o.extensionsUsed).filter(P=>typeof P=="string");if(i.includes("KHR_draco_mesh_compression")||Bu(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||Me(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(Me(o.images).length||Me(o.textures).length)return{ok:!1,issue:"external_resource"};let s=Me(o.buffers);if(s.length!==1||!Se(s[0])||s[0].uri!==void 0||typeof s[0].byteLength!="number"||!Number.isInteger(s[0].byteLength)||s[0].byteLength<0||s[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let a=Me(o.accessors),f=Me(o.bufferViews),c=Me(o.meshes),l=Me(o.nodes),u=Me(o.scenes),h=typeof o.scene=="number"?o.scene:0;if(!Se(u[h]))return{ok:!1,issue:"unsupported_glb"};let m=new DataView(r.buffer,r.byteOffset,r.byteLength),d=(P,E,g)=>{if(typeof P!="number"||!Number.isInteger(P)||!Se(a[P]))return null;let S=a[P];if(S.type!==E||S.sparse!==void 0||S.normalized===!0||typeof S.count!="number"||!Number.isInteger(S.count)||S.count<1||typeof S.componentType!="number"||!g.includes(S.componentType)||typeof S.bufferView!="number")return null;let M=f[S.bufferView];if(!Se(M)||M.buffer!==0||typeof M.byteLength!="number"||!Number.isInteger(M.byteLength)||M.byteLength<0)return null;let R=Uu(S.type),v=Xu(S.componentType),T=typeof M.byteStride=="number"?M.byteStride:R*v,k=typeof M.byteOffset=="number"?M.byteOffset:0,_=typeof S.byteOffset=="number"?S.byteOffset:0,A=k+_,C=_+(S.count-1)*T+R*v;if(!Number.isInteger(T)||!Number.isInteger(k)||!Number.isInteger(_)||T<R*v||k<0||_<0||k+M.byteLength>r.byteLength||C>M.byteLength)return null;let L=[];for(let F=0;F<S.count;F++){let O=[];for(let B=0;B<R;B++){let N=Vu(m,A+F*T+B*v,S.componentType);if(!Number.isFinite(N))return null;O.push(N)}L.push(O)}return L},p=[],b=[],x=0,y=new Set,I=(P,E)=>{if(typeof P!="number"||!Number.isInteger(P)||!Se(l[P])||y.has(P))return!1;y.add(P);let g=l[P],S=Nu(g);if(!S)return!1;let M=Du(E,S),R=ju(M);if(!R)return!1;if(g.mesh!==void 0){if(typeof g.mesh!="number")return!1;let v=c[g.mesh];if(!Se(v))return!1;for(let T of Me(v.primitives)){if(!Se(T)||T.mode!==void 0&&T.mode!==4||!Se(T.attributes))return!1;let k=d(T.attributes.POSITION,"VEC3",[5126]),_=T.attributes.NORMAL===void 0?null:d(T.attributes.NORMAL,"VEC3",[5126]);if(!k||T.attributes.NORMAL!==void 0&&!_)return!1;let A=k.length;if(T.indices!==void 0){let L=typeof T.indices=="number"?a[T.indices]:null;A=Se(L)?L.count:void 0}if(typeof A!="number"||!Number.isInteger(A)||A%3!==0||(x+=A/3,x>1e5))return!1;let C=T.indices===void 0?k.map((L,F)=>[F]):d(T.indices,"SCALAR",[5121,5123,5125]);if(!C||C.length%3!==0||C.length!==A)return!1;for(let L=0;L<C.length;L+=3){let F=[C[L][0],C[L+1][0],C[L+2][0]];if(F.some(N=>!Number.isInteger(N)||N<0||N>=k.length))return!1;let O=F.map(N=>Gu(M,...k[N])),B=null;if(!_){let N=O[1][0]-O[0][0],H=O[1][1]-O[0][1],D=O[1][2]-O[0][2],U=O[2][0]-O[0][0],V=O[2][1]-O[0][1],$=O[2][2]-O[0][2];B=Di([1,0,0,0,1,0,0,0,1],H*$-D*V,D*U-N*$,N*V-H*U)}for(let N=0;N<3;N++)p.push(...O[N]),b.push(..._?Di(R,..._[F[N]]):B)}}}for(let v of Me(g.children))if(!I(v,M))return!1;return y.delete(P),!0};for(let P of Me(u[h].nodes))if(!I(P,Fu()))return{ok:!1,issue:x>1e5?"triangle_limit":"unsupported_glb"};return!x||p.length!==x*9||b.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:x,position:new Float32Array(p),normal:new Float32Array(b)}}function Ni(e){try{return Yu(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function Gi(e){let{doc:t}=e,n=_o(t.theme),o=n.structure,r=rr(t,e.eventConfigurationId??t.eventConfigurationId),i=Oi(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new Bt,f=null;if(e.registeredShellGlb){let G=Ni(e.registeredShellGlb);if(G.ok){let j=G.position.length/3,q=new Float32Array(G.position.length),ue=n.materials.shell??o.tierWall;for(let fe=0;fe<j;fe++){let he=G.normal[fe*3+1],re=he<-.25?.4:.62+.38*Math.max(0,he);q[fe*3]=ue[0]*re,q[fe*3+1]=ue[1]*re,q[fe*3+2]=ue[2]*re}f={position:G.position,normal:G.normal,color:q,floor:new Float32Array(j).fill(-2),material:new Float32Array(j),count:j}}}let c=new Map;for(let G of r)for(let j of G.objects)c.set(j.id,G.index),j.type==="section"&&c.set(j.logicalSectionId??j.id,G.index);let l=s.map(G=>c.get(G.sectionId??"")??c.get(G.rowId??"")??0),u=Xn(r,s),h=a.vertexCount,d=ki(a,r,s,l,u,o,te(n.background.top,n.background.bottom,.5))?a.vertexCount:h,p=Fo(t,s),b=new Map,x=new Map;for(let G of t.categories??[])b.set(G.key,G.color),G.seatGlyph&&x.set(G.key,G.seatGlyph);let y=[],I=yr(r,s,l),P=new Map;s.forEach((G,j)=>{let q=I.seatDeckY(j);Number.isFinite(q)&&P.set(G.rowId,Math.min(P.get(G.rowId)??1/0,q))});let E=new Float32Array(s.length),g=[],S=new Map((t.floors??[]).map((G,j)=>[G.id,j])),M=r.map(()=>[]);for(let G of s){let j=G.floorId?S.get(G.floorId)??0:0;M[Math.min(j,M.length-1)]?.push(G)}let R=(G,j)=>{if(!j||j.length<3)return!1;let q=Math.min(...j.map(re=>re.x)),ue=Math.max(...j.map(re=>re.x)),fe=Math.min(...j.map(re=>re.y)),he=Math.max(...j.map(re=>re.y));for(let re=0;re<G;re++)for(let se of M[re])if(!(se.x<q||se.x>ue||se.y<fe||se.y>he)&&be(se,j,void 0))return!0;return!1},v=null,T=G=>r.length===1?s:s.filter((j,q)=>l[q]===G),k=(G,j)=>{let q=Ae(G);if(!q)return!1;let ue=1/0,fe=1/0,he=-1/0,re=-1/0;for(let se of q)ue=Math.min(ue,se.x),he=Math.max(he,se.x),fe=Math.min(fe,se.y),re=Math.max(re,se.y);return s.some((se,ve)=>se.kind!=="booth"&&(r.length===1||l[ve]===j)&&se.x>ue&&se.x<he&&se.y>fe&&se.y<re&&xe(q,se.x,se.y))},_;for(let G=0;G<r.length;G++){let j=r[G];a.setFloor(G);let q=ot(j,T(G)),ue=0;if(q){let K=0;for(let le of j.objects)if(le.type==="section")for(let me of I.bySection.get(le.id)?.rowLevels??[])K=Math.max(K,me.y-j.baseHeightM);if(ue=fr(K),!_){let le=mr(q);_={centre:[le.x*w,le.y*w]}}}let fe=new jt,he=[],re=j.objects.filter(K=>K.type==="shape"&&(K.role==="entrance"||K.role==="exit")),se=j.objects.filter(K=>K.type==="section"&&!!K.outline&&K.outline.length>=3),ve=Ur(j.objects.filter(K=>K.type==="booth"),j.focal);for(let K of j.objects)if(K.type==="section"){let le=a.vertexCount;ri(a,K,j,Do(K,p),I.bySection.get(K.id),fe,se,o,G>0&&R(G,K.outline));let me=a.vertexCount-le;me>0&&g.push({sectionId:K.id,start:le,count:me})}else if(K.type==="shape"){let le=i.byObjectId.get(K.id),me=y.length,Ye=q!==null&&K.role==="wall"&&!le;a.setMaterial(Ye?ur:(le?.kind??K.role)==="screen"?1:0);let Ke=K.role==="stage"&&!le?Yr(K,T(G)):Ye&&K.heightM===void 0?{...K,heightM:ue}:K,De=cr(Ke,he);if(Gr(a,Ke,j.baseHeightM+De.supportOffsetM,De.topOffsetM-De.supportOffsetM,o,j.focal,y,le,re),a.setMaterial(0),K.role==="stage"&&!le&&y.length>me&&(v??G)===G){v=G;let Ne=t.floors?.[G]?.id,lt=r.length>1&&Ne?s.filter(wt=>wt.floorId===Ne):s;Fi(a,Ke,y[y.length-1].y,lt)}}else K.type==="gaArea"?Hr(a,K,j.baseHeightM,ne(b.get(K.categoryKey)),o):K.type==="booth"?Fr(a,K,j.baseHeightM,ne(b.get(K.categoryKey)),o,ve.get(K.id)??j.focal,k(K,G)):K.type==="table"?Nr(a,K,Math.max(j.baseHeightM,P.get(K.id)??j.baseHeightM),ne(K.fill??t.theme?.decorFill??"#232c40"),o,!!(K.fill??t.theme?.decorFill)):K.type==="decorImage"&&jr(a,K,j.baseHeightM,o);si(a,j,s,I,o,n.materials.shell,!f)}let A=r.length>1?{x:r.reduce((G,j)=>G+j.focal.x,0)/r.length,y:r.reduce((G,j)=>G+j.focal.y,0)/r.length}:t.focalPoint??{x:(u.minX+u.maxX)/2,y:(u.minY+u.maxY)/2},C=Io(f?[a.build(),f]:[a.build()]),L=Yo(s,e.initialState,I,E,b,x),F=Ii({doc:t,units:r,seats:s,surfaces:I,focal:A}),{labels:O,sections:B,rows:N}=Ri({doc:t,units:r,seats:s,surfaces:I,seatData:L,hintedSeatFloor:l,zones:F,focal:A}),H=new Map(B.map((G,j)=>[G.id,j]));I.seatOwner.forEach((G,j)=>{L.iSection[j]=G?H.get(G)??-1:-1});let D=wi({doc:t,units:r,seats:s,surfaces:I,solids:C,hintedSeatFloor:l,seatFloor:E});Pi(O,D),L.iYaw=Vo(L.iPosition,s.length,G=>s[G].rowId,G=>{let j=r[E[G]]?.focal??A;return[j.x*w,j.y*w]});let U=(u.minX+u.maxX)/2*w,V=(u.minY+u.maxY)/2*w,$=.5*Math.hypot((u.maxX-u.minX)*w,(u.maxY-u.minY)*w)||10,X=Un(C,L,{cx:U,cz:V,radius:$},[h,d]),J=Un(C,L,{cx:U,cz:V,radius:$}),Z=Ku(r),ce=Li(L,y,u,X.minY,X.maxY,$,Z);return{sharedAisles:Ro(r.flatMap(G=>G.objects.flatMap(j=>{if(j.type!=="section")return[];let q=I.bySection.get(j.id);return q?[{sectionId:j.id,floorIndex:G.index,rows:q.rowLevels}]:[]}))),solids:C,sectionSolidRanges:g,seats:L,seatSectionIds:I.seatOwner,bounds:{center:[(ce.min[0]+ce.max[0])/2,(ce.min[1]+ce.max[1])/2,(ce.min[2]+ce.max[2])/2],radius:$,groundY:0,box:ce,fitPoints:Ti(L,y,Z)},..._?{room:_}:{},...!_&&r.some(G=>G.objects.some(j=>j.type==="shape"&&vt(j.stageKind)))?{outdoor:!0}:{},renderBounds:{center:X.center,radius:X.radius},clipBounds:{center:J.center,radius:J.radius},stateColorLUT:ko(n,Dt),theme:n,seatCount:s.length,focalWorld:[A.x*w,1.5,A.y*w],zones:F,stages:y,productionElements:i.elements,sections:B,rows:N,labels:O,floors:D}}function Ku(e){let t=[];for(let n of e)for(let o of n.objects){let r=o.type==="gaArea"?o.points:o.type==="booth"?Ae(o):null;for(let i of r??[])t.push([i.x*w,n.baseHeightM,i.y*w])}return t}function Wu(e,t){let{doc:n,report:o}=yi(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])),c=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:c(m.objects)})),u=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&&(u[d]=m.eyeHeightM),m.focalPoint&&(h[d*2]=m.focalPoint.x,h[d*2+1]=m.focalPoint.y)}),{doc:{...e,objects:l?.[0]?.objects??c(e.objects),...l?{floors:l}:{}},report:o,eyeHeightM:u,focal:h}}let i=new Map(et(n).map(f=>[f.id,f])),s=new Float64Array(t.length).fill(Number.NaN),a=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((f,c)=>{let l=i.get(f.id)??f;l.eyeHeightM!==void 0&&(s[c]=l.eyeHeightM),l.focalPoint&&(a[c*2]=l.focalPoint.x,a[c*2+1]=l.focalPoint.y)}),{doc:n,report:o,eyeHeightM:s,focal:a}}function zu(e,t){return e.map((n,o)=>{let r=t.eyeHeightM[o],i=t.focal[o*2],s=t.focal[o*2+1],a={...n};return Number.isNaN(r)?delete a.eyeHeightM:a.eyeHeightM=r,Number.isNaN(i)?delete a.focalPoint:a.focalPoint={x:i,y:s},a})}function ji(e){let t=e.estimate===!1?null:Wu(e.doc,e.seats);return t?{input:{...e,doc:t.doc,seats:zu(e.seats,t)},estimate:t}:{input:e}}function Zu(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 Hi=self;Hi.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??et(e.data.doc),{input:r,estimate:i}=ji({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),s=Gi(r),a=Zu(s);i&&a.push(i.eyeHeightM.buffer,i.focal.buffer),Hi.postMessage({model:s,buildMs:performance.now()-t,...n?{seats:o}:{},...i?{estimate:i}:{}},a)};
1
+ "use strict";var es=Object.create;var qn=Object.defineProperty;var ts=Object.getOwnPropertyDescriptor;var ns=Object.getOwnPropertyNames;var os=Object.getPrototypeOf,rs=Object.prototype.hasOwnProperty;var is=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ns(t))!rs.call(e,r)&&r!==n&&qn(e,r,{get:()=>t[r],enumerable:!(o=ts(t,r))||o.enumerable});return e};var Ce=(e,t,n)=>(n=e!=null?es(os(e)):{},is(t||!e||!e.__esModule?qn(n,"default",{value:e,enumerable:!0}):n,e));var Ff=Math.PI/180;function rn(e){let t=0,n=0;for(let r of e)t+=r.x,n+=r.y;let o=e.length||1;return{x:t/o,y:n/o}}function ut(e){return e.length?rn(e):null}function Jn(e,t){let n=1-t,o=n*n*n,r=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:o*e.start.x+r*e.control1.x+i*e.control2.x+s*e.end.x,y:o*e.start.y+r*e.control1.y+i*e.control2.y+s*e.end.y}}function eo(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[Jn(e,.5)];let o=Array.from({length:n+1},(l,f)=>Jn(e,f/n)),r=new Float64Array(o.length);for(let l=1;l<o.length;l+=1){let f=o[l].x-o[l-1].x,c=o[l].y-o[l-1].y;r[l]=r[l-1]+Math.hypot(f,c)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],a=1;for(let l=0;l<t;l+=1){let f=i*l/(t-1);for(;a<r.length-1&&r[a]<f;)a+=1;let c=r[a-1],u=r[a],d=u===c?0:(f-c)/(u-c);s.push({x:o[a-1].x+(o[a].x-o[a-1].x)*d,y:o[a-1].y+(o[a].y-o[a-1].y)*d})}return s}function to(e,t,n){return Math.max(t,Math.min(n,e))}function no(e){let t=new Map,n=new Map;for(let o of e){if(o.type!=="row"||!o.segmentedRow)continue;let r=n.get(o.segmentedRow.groupId)??[];r.push(o),n.set(o.segmentedRow.groupId,r)}for(let[o,r]of n){let i=r.slice().sort((d,m)=>d.segmentedRow.componentIndex-m.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,a=i[0]?.segmentedRow;if(!a||!(s>=2&&i.length===s&&a?.boundaryBefore==="start"&&i.every((d,m)=>d.segmentedRow?.kind==="segmented-row-v1"&&d.segmentedRow.groupId===o&&d.segmentedRow.componentCount===s&&d.segmentedRow.componentIndex===m&&d.segmentedRow.repeatLabelOnComponents===a.repeatLabelOnComponents&&(m===0?d.segmentedRow.boundaryBefore==="start":d.segmentedRow.boundaryBefore!=="start")&&d.segmentedRow.displayLabel===a.displayLabel)))continue;let f=i.reduce((d,m)=>d+m.seatCount,0),c=0,u=0;for(let d of i)d.segmentedRow.boundaryBefore==="break"&&(c+=1),t.set(d.id,{groupId:o,adjacencyOffset:c,displayOffset:u,displayLabel:a.displayLabel,totalSeats:f,canonical:i[0],viewFromSeatUrl:a.viewFromSeatUrl,viewFromSeatMeta:a.viewFromSeatMeta,confidenceEvidence:a.confidenceEvidence}),c+=d.seatCount,u+=d.seatCount}return t}var ss="ABCDEFGHIJKLMNOPQRSTUVWXYZ";var as="abcdefghijklmnopqrstuvwxyz";function cs(e,t){let n=t.length,o=e+1,r="";for(;o>0;){o-=1;let i=o%n;r=t[i]+r,o=Math.floor(o/n)}return r}function sn(e,t=!1){let n=t?as:ss;return cs(Math.max(0,Math.floor(e)-1),n)}var ls=[[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 oo(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of ls)for(;t>=o;)n+=r,t-=o;return n}function us(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 Et(e,t){let n=e.seatLabelStart??1,o=e.seatNumbering?.direction??"ltr",r=e.seatNumbering?.step??1,i=e.seatNumbering?.scheme??"decimal",s=e.seatNumbering?.prefix??"",a=e.seatNumbering?.endAt,l=e.seatCount;if(i==="updown"||i==="updown-descending"){let m=Math.ceil(l/2),h=i==="updown"?t<m?n+2*t:n-1+2*(l-t):t<m?n+2*(m-1-t):n+1+2*(t-m);return`${s}${h}`}let f=i==="odd"||i==="even"?2:r,c=a!=null&&Number.isFinite(a)?a-(l-1)*f:n,u=o==="center"?us(l)[t]:o==="rtl"?l-1-t:t,d;switch(i){case"odd":{let m=c%2===1?c:c+1;d=String(m+u*2);break}case"even":{let m=c%2===0?c:c+1;d=String(m+u*2);break}case"roman":d=oo(c+u*r);break;case"letters-upper":d=sn(c+u*r,!1);break;case"letters-lower":d=sn(c+u*r,!0);break;default:d=String(c+u*r);break}return`${s}${d}`}function fs(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function ro(e,t,n){return n?.label??`${e.seatLabelBase??e.label}-${Et(e,t)}`}function an(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(e.seatDisplayLabelMode==="number")return Et(e,t);if(!n)return`${e.displayLabel||e.label}-${Et(e,t)}`;let r=fs(n),i=n.displayOffset+t;return`${n.displayLabel}-${Et(r,i)}`}var $=.02291666666666667,Ie=1/$,ms=58,hs=ms*$;var ds=3,io=0,cn=120,ps=0,bs=45,ys=7,ve=1.2;function ln(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function xs(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=ys?e:ds}function Ge(e,t={}){let n=ln(t.floorBaseHeightM,io,cn,0),o=Math.min(cn,n+xs(e.elevation)*hs),r=e.height===void 0?o:ln(e.height,io,cn,o),i=ln(e.rake,ps,bs,0);return{height:r,rake:i}}function so(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function qe(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,l=s.y-i.y,f=a*a+l*l,c=f>1e-12?((t-i.x)*a+(n-i.y)*l)/f:0;c<0?c=0:c>1&&(c=1);let u=t-(i.x+c*a),d=n-(i.y+c*l);if(Math.abs(u)>=o||Math.abs(d)>=o)continue;let m=Math.hypot(u,d);m<o&&(o=m)}return o}function gs(e){let t=0,n=0;for(let i of e)t+=i.x,n+=i.y;let o=e.length||1;t/=o,n/=o;let r=0;for(let i of e){let s=Math.hypot(i.x-t,i.y-n);s>r&&(r=s)}return{cx:t,cy:n,r}}function ao(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function un(e,t){let n=1/0;for(let o of so(e)){let r=qe(t,o.x,o.y);r<n&&(n=r)}for(let o of so(t)){let r=qe(e,o.x,o.y);r<n&&(n=r)}return n}function Ms(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let c of e)n+=c.x,o+=c.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let c of e){let u=Math.hypot(c.x-n,c.y-o);u>r&&(r=u,i=c)}let s=i.x-n,a=i.y-o,l=Math.hypot(s,a);l>1e-9?(s/=l,a/=l):(s=1,a=0);let f=e.map((c,u)=>({p:c,i:u,t:(c.x-n)*s+(c.y-o)*a})).sort((c,u)=>c.t-u.t);return{pts:f.map(c=>c.p),seatIndices:f.map(c=>t[c.i])}}function fn(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let g of e)n+=g.x,o+=g.y;n/=t,o/=t;let r=0,i=0,s=0,a=0,l=0,f=0,c=0;for(let g of e){let w=g.x-n,E=g.y-o;r+=w*w,s+=E*E,i+=w*E,a+=w*w*w,l+=E*E*E,f+=w*E*E,c+=E*w*w}let u=r*s-i*i;if(Math.abs(u)<1e-9)return null;let d=(a+f)/2,m=(l+c)/2,h=(d*s-m*i)/u,p=(m*r-d*i)/u,y=h+n,x=p+o;return!Number.isFinite(y)||!Number.isFinite(x)?null:{cx:y,cy:x}}var Ss=.15;function Is(e){if(e.length<2)return null;let t=e.map(M=>{let b=0,I=0;for(let S of M.pts)b+=S.x,I+=S.y;return{x:b/M.pts.length,y:I/M.pts.length}}),n=0,o=0;for(let M of t)n+=M.x,o+=M.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let M of t){let b=M.x-n,I=M.y-o;r+=b*b,i+=b*I,s+=I*I}let a=r+s,l=r*s-i*i,f=a/2+Math.sqrt(Math.max(0,a*a/4-l)),c,u;Math.abs(i)>1e-12?(c=f-s,u=i):r>=s?(c=1,u=0):(c=0,u=1);let d=Math.hypot(c,u);if(!(d>1e-12))return null;c/=d,u/=d;let m=0,h=0,p=0;for(let M of e){if(M.pts.length<2)continue;let b=M.pts[0],I=M.pts[M.pts.length-1],S=I.x-b.x,R=I.y-b.y,_=Math.hypot(S,R);if(!(_>1e-9))continue;let k=S/_,O=R/_;m+=(k*k-O*O)*_,h+=2*k*O*_,p+=_}if(p>0&&Math.hypot(m,h)>=ws*p){let M=Math.atan2(h,m)/2,b=Math.cos(M),I=Math.sin(M);Math.abs(c*b+u*I)>Ps&&(c=-I,u=b)}let y=1/0,x=-1/0,g=[];for(let M of e){let b=1/0,I=-1/0;for(let S of M.pts){let R=S.x*c+S.y*u;R<b&&(b=R),R>I&&(I=R),R<y&&(y=R),R>x&&(x=R)}g.push(I-b)}let w=x-y;return w>1e-9?(g.sort((M,b)=>M-b),g[Math.min(g.length-1,Math.floor(g.length*.9))]/w<=Rs?{x:c,y:u}:null):null}var Rs=.35,ws=.8,Ps=.7;function _t(e,t,n,o){let r=new Map;for(let b of n){let I=t[b],S=I.rowId||`__seat-${b}`,R=r.get(S);R||(R={pts:[],idx:[]},r.set(S,R)),R.pts.push({x:I.x,y:I.y}),R.idx.push(b)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[b,I]of r){let S=Ms(I.pts,I.idx),R=0;for(let _ of S.pts)R+=Math.hypot(_.x-o.x,_.y-o.y);i.push({id:b,pts:S.pts,seatIndices:S.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:R/S.pts.length})}let s=i.map(b=>gs(b.pts)),a=i.length<=256?i.length*(i.length-1)/2:0,l=a?new Float64Array(a):null;l?.fill(Number.NaN);let f=l?new Map(i.map((b,I)=>[b,I])):null,c=(b,I)=>(b>I&&([b,I]=[I,b]),b*(2*i.length-b-1)/2+(I-b-1)),u=(b,I)=>{if(!l)return un(i[b].pts,i[I].pts);let S=c(b,I),R=l[S];if(!Number.isNaN(R))return R;let _=un(i[b].pts,i[I].pts);return l[S]=_,_},d=(b,I)=>f?u(f.get(b),f.get(I)):un(b.pts,I.pts),m=[];for(let b=0;b<i.length;b++){let I=1/0;for(let S=0;S<i.length;S++){if(b===S||ao(s[b],s[S])>=I)continue;let R=u(b,S);R<I&&(I=R)}Number.isFinite(I)&&m.push(I)}m.sort((b,I)=>b-I);let h=m.length?m[Math.floor(m.length/2)]:1,p=Math.max(h*1.8,1e-6),y=i.map(()=>[]);for(let b=0;b<i.length;b++)for(let I=b+1;I<i.length;I++)ao(s[b],s[I])>p||u(b,I)<=p&&(y[b].push(I),y[I].push(b));let x=0;for(let b=0;b<i.length;b++){if(i[b].blockId!==-1)continue;let I=x++,S=[b];for(i[b].blockId=I;S.length;){let R=S.pop();for(let _ of y[R])i[_].blockId===-1&&(i[_].blockId=I,S.push(_))}}let g=new Map;for(let b of i){let I=g.get(b.blockId)??[];I.push(b),g.set(b.blockId,I)}let w=[];for(let b of i){if(b.pts.length<4)continue;let I=fn(b.pts);I&&(!Number.isFinite(I.cx)||!Number.isFinite(I.cy)||w.push({x:I.cx,y:I.cy}))}let E=w.length>=2?(()=>{let b=w.map(R=>R.x).sort((R,_)=>R-_),I=w.map(R=>R.y).sort((R,_)=>R-_),S=Math.floor(w.length/2);return{cx:b[S],cy:I[S]}})():null;if(E){let b=O=>Math.hypot(O.x-E.cx,O.y-E.cy),I=1/0,S=-1/0,R=[];for(let O of i){let v=1/0,A=-1/0;for(let C of O.pts){let T=b(C);T<v&&(v=T),T>A&&(A=T)}R.push(A-v),v<I&&(I=v),A>S&&(S=A)}let _=S-I;R.sort((O,v)=>O-v);let k=R[Math.min(R.length-1,Math.floor(R.length*.9))];if(_>1e-9&&k/_<=Ss){let O=i.map(D=>{let V=0;for(let X of D.pts)V+=b(X);return{row:D,radius:V/D.pts.length}}),v=0,A=0;for(let D of O)v+=D.radius,A+=D.row.focalDistance;v/=O.length,A/=O.length;let C=0;for(let D of O)C+=(D.radius-v)*(D.row.focalDistance-A);if(C<0)for(let D of O)D.radius=-D.radius;let F=1/0;for(let D of O)D.radius<F&&(F=D.radius);O.sort((D,V)=>D.radius-V.radius);let L=-1,B=-1/0,N=_/Math.max(1,O.length)*.5,j=[];for(let D of O)D.radius-B>N&&(L++,B=D.radius),D.row.ordinal=L,D.row.blockDepth=D.radius-F,j.push(D.row);return{sectionId:e,rows:j,blockCount:x}}}let M=[];for(let[,b]of g){let I=Is(b);if(I){let S=O=>{let v=0;for(let A of O.pts)v+=A.x*I.x+A.y*I.y;return v/O.pts.length};b.sort((O,v)=>S(O)-S(v)),b.length>=2&&b[0].focalDistance>b[b.length-1].focalDistance&&b.reverse();let R=[],_=h*.5;for(let O of b){let v=R[R.length-1];v&&Math.abs(S(O)-S(v[0]))<_?v.push(O):R.push([O])}let k=0;for(let O=0;O<R.length;O++){if(O>0){let v=1/0;for(let A of R[O-1])for(let C of R[O])v=Math.min(v,d(A,C));k+=v}for(let v of R[O])v.ordinal=O,v.blockDepth=k,M.push(v)}}else{let S=1/0;for(let R of b)R.focalDistance<S&&(S=R.focalDistance);b.sort((R,_)=>R.focalDistance-_.focalDistance);for(let R=0;R<b.length;R++)b[R].ordinal=R,b[R].blockDepth=Math.max(0,b[R].focalDistance-S),M.push(b[R])}}return{sectionId:e,rows:M,blockCount:x}}var As=/^\d{4}-\d{2}-\d{2}$/;function Es(e){let t=Date.parse(e);return Number.isFinite(t)?As.test(e)?t+864e5:t:null}function _s(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=Es(e.validUntil);return n===null?!1:(t instanceof Date?t.getTime():t)<n}function Cs(e,t,n){return!(e.eventConfigurationId&&e.eventConfigurationId!==t||e.eventConfigurationVersion!==void 0&&e.eventConfigurationVersion!==n)}function vs(e){return e.status!=="draft"&&e.status!=="retracted"}function ks(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 co(e,t={}){return!!e&&vs(e)&&Cs(e,t.activeConfigurationId,t.activeConfigurationVersion)&&ks(e,t.activeBasisSha256)&&_s(e,t.now)}var Ts=new Set(["pitch-football","rink-hockey","track-athletics","oval-cricket","pitch-rugby","diamond-baseball","court-basketball","court-tennis","ring-boxing"]),Ls=new Set(["pitch-football","track-athletics","oval-cricket","pitch-rugby","diamond-baseball"]);function We(e){return!!e&&Ts.has(e)}function Ct(e){return!!e&&Ls.has(e)}var vt=1.1,Os={"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}},Bs={"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 Fs=Math.PI*2;function Ds(e,t,n,o,r,i){return{x:r+e*n-t*o,y:i+e*o+t*n}}function lo(e,t){let n=Math.max(0,e-t),o=[],r=20;for(let i=0;i<=r;i++){let s=-Math.PI/2+i/r*Math.PI;o.push({x:n+t*Math.cos(s),y:t*Math.sin(s)})}for(let i=0;i<=r;i++){let s=Math.PI/2+i/r*Math.PI;o.push({x:-n+t*Math.cos(s),y:t*Math.sin(s)})}return o}var uo=(()=>{let t={x:0,y:52},n=25,o={x:70,y:t.y-70},r=(o.x*o.x+o.y*o.y-4900)/(2*(o.y+70)),i=r+70,s=[],a=Math.atan2(o.y-r,o.x),l=Math.atan2(o.y-r,-o.x);for(let f=0;f<=24;f++){let c=a+(l-a)*f/24;s.push({x:i*Math.cos(c),y:r+i*Math.sin(c)})}return{half:70,home:t,backstop:n,fence:s}})();var kt="#f1f5f9";function ft(e){return We(e)}function je(e,t,n,o,r=32){let i=[];for(let s=0;s<r;s++){let a=s/r*Fs;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function Le(e,t,n,o){return[{x:e-n,y:t-o},{x:e+n,y:t-o},{x:e+n,y:t+o},{x:e-n,y:t+o}]}function Ns(e){let{kind:t,cx:n,cy:o,width:r,height:i}=e,s=(e.rotation??0)*Math.PI/180,a=Math.cos(s),l=Math.sin(s),f=r/2,c=i/2,u=[],d=Os[t],m=p=>d?p/d.width*r:0,h=p=>d?p/d.height*i:0;switch(t){case"pitch-football":{u.push({points:[{x:0,y:-c},{x:0,y:c}],closed:!1}),u.push({points:je(0,0,m(9.15),h(9.15)),closed:!0});for(let p of[-1,1])u.push({points:Le(p*(f-m(16.5)/2),0,m(16.5)/2,h(40.32)/2),closed:!0}),u.push({points:Le(p*(f-m(5.5)/2),0,m(5.5)/2,h(18.32)/2),closed:!0});break}case"rink-hockey":{u.push({points:[{x:0,y:-c},{x:0,y:c}],closed:!1,ink:"#d63b3b"});for(let p of[-1,1]){u.push({points:[{x:p*m(7.5),y:-c},{x:p*m(7.5),y:c}],closed:!1,ink:"#2f6ecb"}),u.push({points:[{x:p*(f-m(4)),y:-h(11)},{x:p*(f-m(4)),y:h(11)}],closed:!1,ink:"#d63b3b"});for(let y of[-1,1])u.push({points:je(p*m(20.5),y*h(7),m(4.5),h(4.5)),closed:!0,ink:"#2f6ecb"})}u.push({points:je(0,0,m(4.5),h(4.5)),closed:!0,ink:"#2f6ecb"});break}case"track-athletics":{let y=c-h(1.22)*8;y>0&&u.push({points:lo(f-m(1.22)*8,y),closed:!0,fill:"#2f7d4f"});for(let x=1;x<8;x++){let g=h(1.22)*x,w=c-g;if(w<=0)break;u.push({points:lo(f-m(1.22)*x,w),closed:!0})}break}case"oval-cricket":{u.push({points:je(0,0,m(27.4),h(27.4+20.12/2),40),closed:!0}),u.push({points:Le(0,0,m(3.05)/2,h(20.12)/2),closed:!0,ink:"#d8cfae"});break}case"pitch-rugby":{let p=y=>({points:[{x:m(y),y:-c},{x:m(y),y:c}],closed:!1});u.push(p(0));for(let y of[-1,1]){u.push(p(y*50),p(y*28));for(let x=-35;x<35;x+=4)u.push({points:[{x:m(y*10),y:h(x)},{x:m(y*10),y:h(Math.min(35,x+2))}],closed:!1})}break}case"diamond-baseball":{let p=(T,F)=>({x:m(T),y:h(F)}),{home:y}=uo,x=27.43,g=x/Math.SQRT2,w={x:y.x+g,y:y.y-g},E={x:y.x,y:y.y-2*g},M={x:y.x-g,y:y.y-g},b={x:y.x,y:y.y-18.44},I="#b98a59",S=Bs["diamond-baseball"],R=38.94,_=[p(y.x,y.y)],k=Math.atan2(y.y-R/Math.SQRT2-b.y,R/Math.SQRT2),O=Math.PI-k;for(let T=0;T<=16;T++){let F=k-(k+Math.PI*2-O)%(Math.PI*2)*(T/16);_.push(p(b.x+29*Math.cos(F),b.y+29*Math.sin(F)))}u.push({points:_,closed:!0,fill:I,ink:I});let v={x:y.x,y:y.y-g},A=[{x:y.x,y:y.y},w,E,M].map(T=>p(v.x+(T.x-v.x)*.84,v.y+(T.y-v.y)*.84));u.push({points:A,closed:!0,fill:S,ink:S}),u.push({points:je(m(b.x),h(b.y),m(2.74),h(2.74),20),closed:!0,fill:I,ink:I}),u.push({points:je(m(y.x),h(y.y),m(3.96),h(3.96),20),closed:!0,fill:I,ink:I});let C=uo.fence;u.push({points:[p(y.x,y.y),p(C[0].x,C[0].y)],closed:!1}),u.push({points:[p(y.x,y.y),p(C[C.length-1].x,C[C.length-1].y)],closed:!1});for(let T of[w,E,M])u.push({points:Le(m(T.x),h(T.y),m(.3),h(.3)),closed:!0,fill:kt});break}case"court-basketball":{u.push({points:Le(0,0,m(14),h(7.5)),closed:!0}),u.push({points:[{x:0,y:-h(7.5)},{x:0,y:h(7.5)}],closed:!1}),u.push({points:je(0,0,m(1.8),h(1.8),24),closed:!0});for(let p of[-1,1]){let y=p*14,x=p*(14-5.8),g=p*(14-1.575);u.push({points:Le(m((y+x)/2),0,m(2.9),h(2.45)),closed:!0,fill:"#2f5d8a"}),u.push({points:je(m(x),0,m(1.8),h(1.8),24),closed:!0});let w=Math.sqrt(6.75*6.75-6.6*6.6),E=[{x:m(y),y:-h(6.6)}],M=Math.atan2(-6.6,-p*w),b=2*Math.atan2(6.6,w);for(let I=0;I<=16;I++){let S=M-p*b*(I/16);E.push({x:m(g+6.75*Math.cos(S)),y:h(6.75*Math.sin(S))})}E.push({x:m(y),y:h(6.6)}),u.push({points:E,closed:!1})}break}case"court-tennis":{u.push({points:Le(0,0,m(11.885),h(5.485)),closed:!0,fill:"#2b5f99"});for(let p of[-1,1])u.push({points:[{x:-m(11.885),y:p*h(4.115)},{x:m(11.885),y:p*h(4.115)}],closed:!1}),u.push({points:[{x:p*m(6.4),y:-h(4.115)},{x:p*m(6.4),y:h(4.115)}],closed:!1});u.push({points:[{x:-m(6.4),y:0},{x:m(6.4),y:0}],closed:!1}),u.push({points:[{x:0,y:-h(6.4)},{x:0,y:h(6.4)}],closed:!1,ink:"#d1d5db"});break}case"ring-boxing":{u.push({points:Le(0,0,m(3.05),h(3.05)),closed:!0});let x=[[-1,-1,"#c53030"],[1,1,"#2b6cb0"],[1,-1,"#e2e8f0"],[-1,1,"#e2e8f0"]];for(let[g,w,E]of x)u.push({points:Le(g*m(3.05),w*h(3.05),m(.3),h(.3)),closed:!0,fill:E,ink:E});break}default:return[]}return u.map(p=>({...p,points:p.points.map(y=>Ds(y.x,y.y,a,l,n,o))}))}function fo(e){if(e.role!=="stage"||!ft(e.stageKind))return[];let t=null;if(e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null&&e.width>0&&e.height>0&&[e.x,e.y,e.width,e.height].every(Number.isFinite))t={cx:e.x+e.width/2,cy:e.y+e.height/2,width:e.width,height:e.height};else if(e.points&&e.points.length>=3&&e.points.every(n=>Number.isFinite(n.x)&&Number.isFinite(n.y))){let n=e.points.map(c=>c.x),o=e.points.map(c=>c.y),r=Math.min(...n),i=Math.max(...n),s=Math.min(...o),a=Math.max(...o),l=Math.max(1,i-r),f=Math.max(1,a-s);t={cx:r+l/2,cy:s+f/2,width:l,height:f}}return t?Ns({kind:e.stageKind,...t}):[]}var Gs=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,js=/[\s"'<>`\\]/;function Hs(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Gs.test(e);if(js.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function mo(e){let t=e.trim();return Hs(t)?t:null}var mn="seatlayer.event-configuration/1";var Je=100,Xs=120,Us=2e5,Vs=1e4,Ys=/^[a-f0-9]{64}$/,Ks=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function mt(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ze(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Ws(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function ho(e){return!Array.isArray(e)||e.length>Us||!e.every(t=>ze(t,Je))?null:[...new Set(e)].sort()}function zs(e){return!mt(e)||!ze(e.chartId,Je)||!ze(e.version,Je)||e.sha256!==void 0&&(typeof e.sha256!="string"||!Ys.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function hn(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function Zs(e){return mt(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&hn(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function $s(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>Vs)return null;let n=new Set(t),o=new Set,r=new Set,i=0,s=[];for(let a of e){if(!mt(a)||!ze(a.id,Je)||!ze(a.objectId,Je)||!n.has(a.objectId)||!Ks.has(String(a.kind))||!hn(a.heightM,.05,50)||a.baseElevationM!==void 0&&!hn(a.baseElevationM,-10,100))return null;let l=Zs(a.occlusion);if(!l||o.has(a.id)||r.has(a.objectId))return null;let f=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?mo(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!f||a.kind!=="screen"||++i>1))return null;o.add(a.id),r.add(a.objectId),s.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:l,...f?{contentImageUrl:f}:{}})}return s.sort((a,l)=>a.id.localeCompare(l.id))}function Qs(e){let t=[];if(!mt(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==mn&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${mn}`}),ze(e.id,Je)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),ze(e.label,Xs)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Ws(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=zs(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let o=mt(e.overlay)?e.overlay:null,r=ho(o?.objectIds),i=ho(o?.productionKillSeatIds),s=r?$s(o?.productionElements,r):null;return(!o||!r||!i)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),s===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!r||!i||s===null?{issues:t}:{issues:t,value:{schema:mn,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:r,productionKillSeatIds:i,...s!==void 0?{productionElements:s}:{}}}}}function po(e){let t=Qs(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function qs(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 Js(e,t,n){let o=n*Math.PI/180,r=Math.cos(o),i=Math.sin(o),s=e.x-t.x,a=e.y-t.y;return{x:t.x+s*r-a*i,y:t.y+s*i+a*r}}function bo(e){let t=qs(e);if(!t||t.length<2)return null;let n=e.rotation??0,o=Math.abs(n)<1e-6?t:t.map(l=>Js(l,{x:t.reduce((f,c)=>f+c.x,0)/t.length,y:t.reduce((f,c)=>f+c.y,0)/t.length},n)),r=1/0,i=1/0,s=-1/0,a=-1/0;for(let l of o)r=Math.min(r,l.x),i=Math.min(i,l.y),s=Math.max(s,l.x),a=Math.max(a,l.y);return!Number.isFinite(r)||s-r<1e-6||a-i<1e-6?null:{minX:r,minY:i,maxX:s,maxY:a}}var ea=5,ta=3,na=.92,oa=1.9,ra=2,ia=.6,sa=1,aa=.06;function ca(e){return e.heightM!==void 0?e.heightM:e.stageKind==="ring-boxing"?vt:ft(e.stageKind)?aa:sa}function yo(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=-1/0;for(let s of Mo(e)){let a=s.baseHeightM??0;for(let l of s.objects){if(l.type!=="shape"||l.role!=="stage")continue;let f=bo(l);f&&(t=Math.min(t,f.minX),n=Math.min(n,f.minY),o=Math.max(o,f.maxX),r=Math.max(r,f.maxY),i=Math.max(i,a+ca(l)))}}return!Number.isFinite(t)||!Number.isFinite(i)?null:{minX:t,minY:n,maxX:o,maxY:r,deckTopM:i}}function la(e,t,n,o){let r=1/0,i=1/0,s=-1/0,a=-1/0;for(let m of e)Number.isFinite(m.eyeHeightM)&&(r=Math.min(r,m.x),s=Math.max(s,m.x),i=Math.min(i,m.y),a=Math.max(a,m.y));if(!Number.isFinite(r))return null;let l=r*t,f=i*t,c=Math.max(1,Math.ceil((s-r)*t/n)+1),u=Math.max(1,Math.ceil((a-i)*t/n)+1),d=new Float64Array(c*u).fill(-1/0);for(let m of e){if(!Number.isFinite(m.eyeHeightM))continue;let h=m.eyeHeightM-ve,p=Math.min(c-1,Math.max(0,Math.floor((m.x*t-l)/n))),x=Math.min(u-1,Math.max(0,Math.floor((m.y*t-f)/n)))*c+p,g=h+o;g>d[x]&&(d[x]=g)}return{cellM:n,minX:l,minY:f,cols:c,rows:u,top:d}}function ua(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 xo(e,t,n={}){let o=new Map;if(!t||!e.length)return o;let r=n.metresPerChartUnit??$,i=n.cellM??ia,s=n.chairBackM??na,a=n.selfRowSkipM??ra,l=n.clearThreshold??.9,f=n.partialThreshold??.25,c=Math.max(1,n.columns??ea),u=Math.max(1,n.rows??ta),d=la(e,r,i,s);if(!d)return o;let m=(t.maxX-t.minX)*r,h=(t.maxY-t.minY)*r,p=m>=h,y=(t.minX+t.maxX)/2*r,x=(t.minY+t.maxY)/2*r,g=[];for(let E=0;E<c;E++){let M=(E+.5)/c-.5,b=p?y+M*m:y,I=p?x:x+M*h;for(let S=0;S<u;S++){let R=t.deckTopM+(u===1?0:S/(u-1)*oa);g.push({x:b,y:I,z:R})}}let w=i/2;for(let E of e){if(!Number.isFinite(E.eyeHeightM))continue;let M=E.x*r,b=E.y*r,I=E.eyeHeightM,S=0,R=1/0;for(let k of g){let O=k.x-M,v=k.y-b,A=Math.hypot(O,v);if(!(A>a)){S++;continue}let C=O/A,T=v/A,F=0;for(let L=a;L<A;L+=w){let B=ua(d,M+C*L,b+T*L);if(!(!Number.isFinite(B)||B>=I)&&B>I+(k.z-I)*L/A){F=L;break}}F?R=Math.min(R,F):S++}let _=S/g.length;_>=l||o.set(E.id,{seatId:E.id,mark:_<f?"obstructedView":"restrictedView",visibleFraction:_,totalRays:g.length,atDistanceM:Number.isFinite(R)?R:0})}return o}function go(e,t){if(!t.size)return 0;let n=0;for(let o of e){let r=t.get(o.id);if(!r)continue;let i=o.commercial;i?.restrictedView!==void 0||i?.obstructedView!==void 0||(o.commercial={...i,[r.mark]:!0},n++)}return n}function dn(e){return e?e.accessibility?.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var Lt=Math.PI/180;var ht=16;function pn(e,t,n,o){let r=n*Lt,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function Po(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return eo(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let f=0;f<t;f++)s.push(pn(f*n,0,r,i));return s}let a=o/(t-1)*Lt,l=n/(2*Math.sin(Math.abs(a)/2));for(let f=0;f<t;f++){let c=f*a,u=l*Math.sin(c),d=-l+l*Math.cos(c);s.push(pn(u,d,r,i))}return s}function Ao(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function fa(e,t){let n=Ao(e);return Po(e).map((o,r)=>{let i=n.get(r),s=dn(i),a=ro(e,r,i),l={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:a,displayLabel:an(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(l).some(f=>f!==void 0&&f!==!1&&f!=="")?l:void 0,glyph:i?.glyph,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle??e.seatLabelStyle}})}function ma(e){let t=[];for(let n of fa(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 ha(e){if(e.seatCountsBySide)return{...e.seatCountsBySide};let t=e.sides&&e.sides.length?e.sides:["top","bottom"],n=["top","bottom","left","right"].filter(i=>t.includes(i)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let r=Math.max(0,Math.round(e.seatCount));for(let i=0;i<r;i++)o[n[i%n.length]]+=1;return o}function da(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(c=>[c.index,c])),r=(c,u,d,m)=>{let h=o.get(c),p=dn(h),y=h?.label??`${e.label}-${c+1}`,x=e.displayLabel??e.label;return{index:c,label:y,displayLabel:h?.displayLabel??`${x}-${c+1}`,x:u+(h?.dx??0),y:d+(h?.dy??0),categoryKey:h?.categoryKey??e.categoryKey,skipped:!!h?.skip,accessible:p.length>0,accessibility:p,wheelchairSpaceType:h?.wheelchairSpaceType,commercial:h?.commercial,glyph:h?.glyph,viewUrl:h?.viewFromSeatUrl,viewMeta:h?.viewFromSeatUrl?h.viewFromSeatMeta:void 0,labelStyle:h?.labelStyle,...m?{side:m}:{}}};if(e.shape==="round"){let c=(e.radius??40)+ht,u=e.rotation*Lt,d=Math.max(0,Math.min(360,e.seatArc??360));if(d>=360||n===1){for(let y=0;y<n;y++){let x=u+y/n*2*Math.PI;t.push(r(y,e.center.x+c*Math.cos(x),e.center.y+c*Math.sin(x)))}return t}let m=d*Lt,h=(2*Math.PI-m)/2,p=u+h;for(let y=0;y<n;y++){let x=p+y/(n-1)*m;t.push(r(y,e.center.x+c*Math.cos(x),e.center.y+c*Math.sin(x)))}return t}let i=e.width??80,s=e.height??50,a=ha(e),l=["top","bottom","left","right"],f=0;for(let c of l){let u=a[c];for(let d=0;d<u;d++){let m,h;c==="top"?(m=-i/2+(d+.5)*i/u,h=-s/2-ht):c==="bottom"?(m=-i/2+(d+.5)*i/u,h=s/2+ht):c==="left"?(m=-i/2-ht,h=-s/2+(d+.5)*s/u):(m=i/2+ht,h=-s/2+(d+.5)*s/u);let p=pn(m,h,e.rotation,e.center);t.push(r(f++,p.x,p.y,c))}}return t}function pa(e){return da(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 ba(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 So(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o].x,s=t[o].y,a=t[r].x,l=t[r].y;s>e.y!=l>e.y&&e.x<(a-i)*(e.y-s)/(l-s)+i&&(n=!n)}return n}function ya(e,t){return t.some((n,o)=>{let r=t[(o+1)%t.length],i=(e.y-n.y)*(r.x-n.x)-(e.x-n.x)*(r.y-n.y);if(Math.abs(i)>1e-7)return!1;let s=(e.x-n.x)*(r.x-n.x)+(e.y-n.y)*(r.y-n.y),a=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=a+1e-7})}function bn(e){return Array.isArray(e)?e.filter(t=>Array.isArray(t)&&t.length>=3):[]}function be(e,t,n){return So(e,t)&&!bn(n).some(o=>So(e,o)||ya(e,o))}function Tt(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 Eo(e){switch(e.type){case"row":{let t=Po(e),n=Ao(e),o=0,r=0,i=0;for(let s=0;s<t.length;s++){let a=n.get(s);a?.skip||(o+=t[s].x+(a?.dx??0),r+=t[s].y+(a?.dy??0),i++)}return i?{x:o/i,y:r/i}:{x:e.origin.x,y:e.origin.y}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Tt(e.points);case"section":return Tt(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Tt(e.points):e.x!=null&&e.y!=null&&e.width!=null&&e.height!=null?{x:e.x+e.width/2,y:e.y+e.height/2}:{x:e.x??0,y:e.y??0};case"decorImage":return{x:e.x+e.width/2,y:e.y+e.height/2}}}function Io(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function xa(e,t){if(e.type!=="gaArea"||!Io(e.points,t.outline))return!1;let n=bn(e.holes),o=bn(t.holes);return n.length===o.length&&n.every((r,i)=>Io(r,o[i]))}function ga(e,t,n=e.filter(r=>r.type==="section"),o=Eo(t)){let r="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0;return(r?n.find(s=>(s.logicalSectionId??s.id)===r&&(xa(t,s)||be(o,s.outline,s.holes))):void 0)??n.find(s=>be(o,s.outline,s.holes))}function Mo(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,i,s,a,l){let f=[],c=e.filter(p=>p.type==="section"),u=no(e),d=p=>!p?.eventConfigurationId||p.eventConfigurationId===o&&(p.eventConfigurationVersion===void 0||p.eventConfigurationVersion===l),m=p=>co(p,{activeConfigurationId:o,activeConfigurationVersion:l,activeBasisSha256:r,now:a}),h=(p,y)=>m(p)?{...p,coverage:y}:void 0;for(let p of e){let y=[];if(p.type==="row"?y=ma(p):p.type==="table"?y=pa(p):p.type==="booth"&&(y=ba(p)),!y.length)continue;for(let M of y)M.viewUrl&&!d(M.viewMeta)&&(M.viewUrl=void 0,M.viewMeta=void 0);if(p.type==="row"){let M=u.get(p.id);if(M){let b=new Map((p.overrides??[]).map(I=>[I.index,I]));for(let I of y){let S=Number(I.id.slice(I.id.lastIndexOf(":")+1));if(!Number.isInteger(S))continue;I.logicalRowId=M.groupId,I.logicalSeatIndex=M.adjacencyOffset+S,b.get(S)?.displayLabel||(I.displayLabel=an(p,S,M)),!I.viewUrl&&M.viewFromSeatUrl&&d(M.viewFromSeatMeta)&&(I.viewUrl=M.viewFromSeatUrl,I.viewMeta=M.viewFromSeatMeta);let R=b.get(S)?.confidenceEvidence;I.confidenceEvidence=h(R,"exact-seat")??h(p.confidenceEvidence,"row-representative")??h(M.confidenceEvidence,"row-representative")}}}let x=ga(e,p,c,p.type==="row"?Tt(y):Eo(p)),g=x?.viewFromSeatUrl,E=(x?.zone?t?.find(M=>M.id===x.zone):void 0)?.focalPoint??n;for(let M of y){if(!M.confidenceEvidence){let b=Number(M.id.slice(M.id.lastIndexOf(":")+1)),I=(p.type==="row"||p.type==="table")&&Number.isInteger(b)?p.overrides?.find(S=>S.index===b)?.confidenceEvidence:void 0;M.confidenceEvidence=h(I,"exact-seat")??(p.type==="row"?h(p.confidenceEvidence,"row-representative"):void 0)}M.confidenceEvidence??=h(x?.confidenceEvidence,"section-representative")??(s?h(s.evidence,s.coverage):void 0),!M.viewUrl&&g&&d(x?.viewFromSeatMeta)&&(M.viewUrl=g,M.viewMeta=x?.viewFromSeatMeta),!M.viewUrl&&i&&d(i.meta)&&(M.viewUrl=i.url,M.viewMeta=i.meta),x&&(M.sectionId=x.logicalSectionId??x.id),x?.zone&&(M.zoneId=x.zone),E&&(M.focalPoint={...E})}f.push(...y)}return f}function et(e,t={}){if(e.floors?.length){let o=[];for(let r of e.floors){let i=r.focalPoint??e.focalPoint,s=r.viewFromSeatUrl?{url:r.viewFromSeatUrl,meta:r.viewFromSeatMeta}:e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,a=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,l=Ro(r.objects,e.zones,i,e.eventConfigurationId,e.confidenceBasisSha256,s,a,t.now,t.eventConfigurationVersion??e.eventConfigurationVersion);t.resolveEyeHeights!==!1&&wo(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,l);for(let f of l)f.floorId=r.id;for(let f of l)o.push(f)}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&&wo(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),Ma(e,n,t)}function Ma(e,t,n){return!n.deriveRestrictedView||e.derivedRestrictedView===!1||n.resolveEyeHeights===!1||go(t,xo(t,yo(e))),t}function wo(e,t,n,o){let r=e.filter(u=>u.type==="section"),i=n>0||r.some(u=>u.height!==void 0||u.rake!==void 0||(u.elevation??0)>0);if(!r.length||!i||!t){for(let u of o)u.eyeHeightM=n+ve;return}let s=new Array(o.length),a=new Map;for(let u of r)a.has(u.id)||a.set(u.id,u);let l=new Map,f=new Map;for(let u=0;u<o.length;u++){let d=o[u],h=(d.sectionId?a.get(d.sectionId)??r.find(y=>y.logicalSectionId===d.sectionId&&be({x:d.x,y:d.y},y.outline,y.holes)):void 0)??r.find(y=>be({x:d.x,y:d.y},y.outline,y.holes))??null;if(s[u]=h,!h)continue;l.has(h.id)||l.set(h.id,Ge(h,{floorBaseHeightM:n}));let p=f.get(h.id);p?p.push(u):f.set(h.id,[u])}let c=new Array(o.length).fill(void 0);for(let[u,d]of f){let m=l.get(u);if(!m)continue;let h=m.rake>0?Math.tan(m.rake*Math.PI/180):0,p=_t(u,o,d,t);for(let y of p.rows){let x=y.blockDepth*$*h,g=m.height+x;for(let w of y.seatIndices)c[w]=g}}for(let u=0;u<o.length;u++){let d=o[u],m=s[u];if(!m){d.eyeHeightM=n+ve;continue}let h=l.get(m.id);d.eyeHeightM=(c[u]??h.height)+ve}}var Co=Ce(require("earcut"),1),yn=Ce(require("polygon-clipping"),1);function ye(e){let t=0;for(let n=0,o=e.length;n<o;n+=1){let r=e[n],i=e[(n+1)%o];t+=r.x*i.y-i.x*r.y}return t/2}function xe(e,t,n){let o=!1;for(let r=0,i=e.length-1;r<e.length;i=r++){let s=e[r],a=e[i];s.y>n!=a.y>n&&t<(a.x-s.x)*(n-s.y)/(a.y-s.y)+s.x&&(o=!o)}return o}var P=$,Sa=.002;function Ia(e,t,n){let o=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),r=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),i=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),s=Math.max(o,r,i);if(s<1e-9)return!0;let a=(o+r+i)/2;return 2*Math.sqrt(Math.max(0,a*(a-o)*(a-r)*(a-i)))/s<Sa}var Ze=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,o){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=o}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let o=new Float32Array(n);o.set(this.buf.subarray(0,this.len)),this.buf=o}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Ft=class{constructor(){this.pos=new Ze;this.nor=new Ze;this.col=new Ze;this.flr=new Ze;this.mat=new Ze;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,o,r,i,s=i,a=i){Ia(t,n,o)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(r[0],r[1],r[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(t,n,o,r,i,s,a,l=a,f=a){[...t,...n,...o].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(o[0],o[1],o[2]),this.nor.push3(r[0],r[1],r[2]),this.nor.push3(i[0],i[1],i[2]),this.nor.push3(s[0],s[1],s[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(l[0],l[1],l[2]),this.col.push3(f[0],f[1],f[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function Ra(e,t,n){let o=t[0]-e[0],r=t[1]-e[1],i=t[2]-e[2],s=n[0]-e[0],a=n[1]-e[1],l=n[2]-e[2],f=r*l-i*a,c=i*s-o*l,u=o*a-r*s,d=Math.hypot(f,c,u)||1;return f/=d,c/=d,u/=d,[f,c,u]}function wa(e,t){let n=[...e],o=[];for(let s of e)o.push(s.x,s.y);let r=[];if(t){for(let s of t)if(!(s.length<3)){r.push(n.length);for(let a of s)n.push(a),o.push(a.x,a.y)}}let i=(0,Co.default)(o,r.length?r:void 0,2);return{pts:n,tris:i}}function ke(e){return ye(e)<0?[...e].reverse():e}var Pa=3;function Aa(e,t,n,o){let r=o(e),i=o(t),s=o(n),a=(m,h,p,y)=>Math.abs(o({x:(m.x+h.x)/2,y:(m.y+h.y)/2})-(p+y)/2),l=(e.x+t.x+n.x)/3,f=(e.y+t.y+n.y)/3,c=(r+i+s)/3,u=Math.max(a(e,t,r,i),a(t,n,i,s),a(n,e,s,r),Math.abs(o({x:l,y:f})-c)),d=(m,h,p)=>{let y=Math.abs(o({x:(m+l)/2,y:(h+f)/2})-(p+c)/2);y>u&&(u=y)};return d((e.x+t.x)/2,(e.y+t.y)/2,(r+i)/2),d((t.x+n.x)/2,(t.y+n.y)/2,(i+s)/2),d((n.x+e.x)/2,(n.y+e.y)/2,(s+r)/2),u}function dt(e,t,n,o,r){if(r<=0)return Aa(e,t,n,o);let i={x:(e.x+t.x)/2,y:(e.y+t.y)/2},s={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(dt(e,i,a,o,r-1),dt(i,t,s,o,r-1),dt(a,s,n,o,r-1),dt(i,s,a,o,r-1))}function pt(e,t,n,o,r,i,s,a){if(s>0){let d={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},h={x:(o.x+t.x)/2,y:(o.y+t.y)/2};pt(e,t,d,h,r,i,s-1,a),pt(e,d,n,m,r,i,s-1,a),pt(e,h,m,o,r,i,s-1,a),pt(e,d,m,h,r,i,s-1,a);return}let l=[t.x*P,r(t),t.y*P],f=[n.x*P,r(n),n.y*P],c=[o.x*P,r(o),o.y*P];if(a){e.triN(l,f,c,a(t),a(n),a(o),i);return}let u=Ra(l,f,c);u[1]<0&&(u=[-u[0],-u[1],-u[2]]),e.tri(l,f,c,u,i)}var Ea=8;function _o(e,t,n){if(!Number.isFinite(n))return e;let o=[],r=(i,s,a,l,f)=>{if(f>0){let c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},u=t(c);if(Math.abs(u-(a+l)/2)>n){r(i,c,a,u,f-1),r(c,s,u,l,f-1);return}}o.push(i)};for(let i=0;i<e.length;i++){let s=e[i],a=e[(i+1)%e.length];r(s,a,t(s),t(a),Ea)}return o}function Ot(e,t){if(e.length<3)return e;let n=[];for(let r of e){let i=n[n.length-1];i&&Math.hypot(r.x-i.x,r.y-i.y)<t||n.push(r)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let o=[];for(let r=0;r<n.length;r++){let i=o.length?o[o.length-1]:n[(r-1+n.length)%n.length],s=n[r],a=n[(r+1)%n.length],l=a.x-i.x,f=a.y-i.y,c=Math.hypot(l,f);c>t&&Math.abs((s.x-i.x)*f-(s.y-i.y)*l)/c<t||o.push(s)}return o.length>=3?o:n}var Bt=.001*Ie*.1;function W(e,t,n,o,r,i,s,a,l=1/0,f){if(!t||t.length<3||(l===void 0&&(l=1/0),Math.abs(ye(t))<1e-4))return;let c=Ot(_o(Ot(ke(t),Bt),o,l),Bt),u=n?.map(b=>Ot(_o(Ot(ke(b),Bt),o,l),Bt)).filter(b=>b.length>=3&&Math.abs(ye(b))>=1e-4),{pts:d,tris:m}=wa(c,u),h=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.bottomCap,i[1]*a.bottomCap,i[2]*a.bottomCap],y=[s[0]*a.top,s[1]*a.top,s[2]*a.top],x=[s[0]*a.wallBottom,s[1]*a.wallBottom,s[2]*a.wallBottom],g=0;if(Number.isFinite(l))for(;g<Pa;g++){let b=0;for(let I=0;I<m.length;I+=3){let S=dt(d[m[I]],d[m[I+1]],d[m[I+2]],o,g);S>b&&(b=S)}if(b<=l)break}for(let b=0;b<m.length;b+=3){let I=d[m[b]],S=d[m[b+1]],R=d[m[b+2]];pt(e,I,S,R,o,h,g,f);let _=[I.x*P,r,I.y*P],k=[S.x*P,r,S.y*P],O=[R.x*P,r,R.y*P];e.tri(_,O,k,[0,-1,0],p)}let w=b=>{if(g<=0)return b;let I=1<<g,S=[];for(let R=0;R<b.length;R++){let _=b[R],k=b[(R+1)%b.length];for(let O=0;O<I;O++){let v=O/I;S.push({x:_.x+(k.x-_.x)*v,y:_.y+(k.y-_.y)*v})}}return S},E=rn(c),M=[{ring:w(c),flip:!1}];if(u)for(let b of u)b.length>=3&&M.push({ring:w(b),flip:!0});for(let{ring:b,flip:I}of M)for(let S=0;S<b.length;S++){let R=b[S],_=b[(S+1)%b.length],k=(_.x-R.x)*P,v=(_.y-R.y)*P,A=-k,C=Math.hypot(v,A)||1;v/=C,A/=C;let T=(R.x+_.x)/2-E.x,F=(R.y+_.y)/2-E.y,L=v*T+A*F;I&&(L=-L),L<0&&(v=-v,A=-A);let B=[v,0,A],N=[R.x*P,o(R),R.y*P],j=[_.x*P,o(_),_.y*P],D=[R.x*P,r,R.y*P],V=[_.x*P,r,_.y*P];e.tri(N,j,V,B,y,y,x),e.tri(N,V,D,B,y,x,x)}}function vo(e){let t=0;for(let l of e)t+=l.count;let n=new Float32Array(t*3),o=new Float32Array(t*3),r=new Float32Array(t*3),i=new Float32Array(t),s=new Float32Array(t),a=0;for(let l of e)n.set(l.position,a*3),o.set(l.normal,a*3),r.set(l.color,a*3),i.set(l.floor,a),s.set(l.material,a),a+=l.count;return{position:n,normal:o,color:r,floor:i,material:s,count:t}}function we(e,t,n=2.5){if(t<=0||e.length<3)return e;let o=ke(e),r=o.length,i=[];for(let a=0;a<r;a++){let l=o[a],f=o[(a+1)%r],c=f.x-l.x,u=f.y-l.y,d=Math.hypot(c,u)||1;i.push({x:u/d,y:-c/d})}let s=[];for(let a=0;a<r;a++){let l=o[a],f=i[(a-1+r)%r],c=i[a],u=f.x+c.x,d=f.y+c.y,m=Math.hypot(u,d),h=()=>{s.push([l.x+f.x*t,l.y+f.y*t]),s.push([l.x+c.x*t,l.y+c.y*t])};if(m<1e-9){h();continue}u/=m,d/=m;let p=u*f.x+d*f.y,y=1/Math.max(p,1e-6);if(!Number.isFinite(y)||y>n){h();continue}s.push([l.x+u*t*y,l.y+d*t*y])}if(s.length<3)return e;try{let a=yn.default.union([[...s,s[0]]]),l=null,f=-1/0;for(let u of a){let d=Math.abs(ye(u[0].map(([m,h])=>({x:m,y:h}))));d>f&&(f=d,l=u[0])}if(!l)return e;let c=l.map(([u,d])=>({x:u,y:d}));if(c.length>1){let u=c[0],d=c[c.length-1];Math.abs(u.x-d.x)<1e-9&&Math.abs(u.y-d.y)<1e-9&&c.pop()}return c.length>=3?c:e}catch{return e}}function He(e,t,n=2.5){if(e.length<3)return[];if(t<=0)return e;let o=ke(e),r=o.length,i=[];for(let l=0;l<r;l++){let f=o[l],c=o[(l+1)%r],u=Math.hypot(c.x-f.x,c.y-f.y)||1;i.push({x:-(c.y-f.y)/u,y:(c.x-f.x)/u})}let s=[],a=[];for(let l=0;l<r;l++){let f=o[l],c=i[(l-1+r)%r],u=i[l],d=c.x+u.x,m=c.y+u.y,h=Math.hypot(d,m),p=h<1e-9?1/0:1/Math.max(d/h*c.x+m/h*c.y,1e-6);if(!Number.isFinite(p)||p>n){s.push({x:f.x+c.x*t,y:f.y+c.y*t},{x:f.x+u.x*t,y:f.y+u.y*t}),a.push(l,l);continue}d/=h,m/=h,s.push({x:f.x+d*t*p,y:f.y+m*t*p}),a.push(l)}for(let l=0;l<s.length;l++){let f=(l+1)%s.length,c=a[l],u=a[f];if(u!==(c+1)%r)continue;let d=o[c],m=o[u];if((s[f].x-s[l].x)*(m.x-d.x)+(s[f].y-s[l].y)*(m.y-d.y)<=0)return[]}try{let l=yn.default.intersection([[...s.map(h=>[h.x,h.y]),[s[0].x,s[0].y]]],[[...o.map(h=>[h.x,h.y]),[o[0].x,o[0].y]]]),f=null,c=0;for(let h of l){let p=Math.abs(ye(h[0].map(([y,x])=>({x:y,y:x}))));p>c&&(c=p,f=h[0])}if(!f)return[];let u=f.map(([h,p])=>({x:h,y:p})),d=u[0],m=u[u.length-1];return u.length>1&&Math.abs(d.x-m.x)<1e-9&&Math.abs(d.y-m.y)<1e-9&&u.pop(),u.length>=3?ke(u):[]}catch{return[]}}function Dt(e,t,n,o,r=28){let i=[];for(let s=0;s<r;s++){let a=s/r*Math.PI*2;i.push({x:e+n*Math.cos(a),y:t+o*Math.sin(a)})}return i}function bt(e,t,n,o){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+o},{x:e,y:t+o}]}var yt=3,$e=.38,xt=.24;function _a(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)*P,i=(n.y-t.y)*P,s=(o.x-t.x)*P,a=(o.y-t.y)*P,l=2*(r*a-i*s);if(Math.abs(l)<1e-7)return null;let f=r*r+i*i,c=s*s+a*a,u=(f*a-c*i)/l+t.x*P,d=(r*c-s*f)/l+t.y*P,m=Math.hypot(t.x*P-u,t.y*P-d);return m<1||m>200||!Number.isFinite(m)||e.some(h=>Math.abs(Math.hypot(h.x*P-u,h.y*P-d)-m)>.03)?null:{x:u,z:d,radius:m}}function ko(e){let t=[],n=new Map,o=(l,f)=>`${Math.floor(l/yt)},${Math.floor(f/yt)}`;for(let l of e)for(let f of l.rows){for(let u of f.pts){let d=u.x*P,m=u.y*P,h=o(d,m),p=n.get(h)??[];p.push({x:d,z:m,y:f.y,floor:l.floorIndex}),n.set(h,p)}if(f.patch||f.pts.length<2)continue;let c=_a(f.pts);for(let u of[0,f.pts.length-1]){let d=f.pts[u],m=f.pts[u===0?1:u-1],h=d.x-m.x,p=d.y-m.y,y=Math.hypot(h,p);y<1e-6||t.push({sectionId:l.sectionId,floorIndex:l.floorIndex,curve:c,row:f,point:d,x:d.x*P,z:d.y*P,dx:h/y,dz:p/y})}}let r=new Map;t.forEach((l,f)=>{let c=o(l.x,l.z),u=r.get(c)??[];u.push(f),r.set(c,u)});let i=(l,f)=>{let c=Math.floor(l/yt),u=Math.floor(f/yt);return[-1,0,1].flatMap(d=>[-1,0,1].map(m=>`${c+d},${u+m}`))},s=new Map;t.forEach((l,f)=>{let c=-1,u=1/0,d=!1;for(let m of i(l.x,l.z))for(let h of r.get(m)??[]){let p=t[h];if(l.sectionId===p.sectionId&&l.row.blockId===p.row.blockId||l.floorIndex!==p.floorIndex||Math.abs(l.row.y-p.row.y)>.05)continue;let y=p.x-l.x,x=p.z-l.z,g=Math.hypot(y,x);if(g<$e*2+.45||g>yt)continue;let w=l.curve&&p.curve&&Math.hypot(l.curve.x-p.curve.x,l.curve.z-p.curve.z)<=.05&&Math.abs(l.curve.radius-p.curve.radius)<=.05,E=Math.min((y*l.dx+x*l.dz)/g,(-y*p.dx-x*p.dz)/g);(w?E<.8:E<.98)||!w&&(Math.abs(y*l.dz-x*l.dx)>.15||Math.abs(y*p.dz-x*p.dx)>.15)||(g<u-.02?(c=h,u=g,d=!1):Math.abs(g-u)<=.02&&(d=!0))}c>=0&&!d&&s.set(f,c)});let a=[];for(let[l,f]of s){if(l>=f||s.get(f)!==l)continue;let c=t[l],u=t[f],d=Math.hypot(u.x-c.x,u.z-c.z),m=(u.x-c.x)/d,h=(u.z-c.z)/d,p=!1;for(let x of i((c.x+u.x)/2,(c.z+u.z)/2))for(let g of n.get(x)??[]){if(g.floor!==c.floorIndex||Math.abs(g.y-c.row.y)>.75)continue;let w=(g.x-c.x)*m+(g.z-c.z)*h,E=Math.abs((g.x-c.x)*h-(g.z-c.z)*m);w>.01&&w<d-.01&&E<xt+$e&&(p=!0)}if(p)continue;let y=(x,g)=>({x:(c.x+m*x-h*g)/P,y:(c.z+h*x+m*g)/P});a.push({sections:[c.sectionId,u.sectionId],blocks:[c.row.blockId,u.row.blockId],floorIndex:c.floorIndex,ends:[c.point,u.point],clearWidthM:d-2*$e,heightM:(c.row.y+u.row.y)/2,outline:[y($e,-xt),y(d-$e,-xt),y(d-$e,xt),y($e,xt)]})}return a}var Ca=/^#?([\da-f]{3}|[\da-f]{6})$/i;function To(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 va(e){let t=Ca.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(r=>r+r).join(""):t[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function ne(e){let t=va(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function ka(e){return .2126*e[0]+.7152*e[1]+.0722*e[2]}function te(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function Pe(e,t){let n=ka(e);return te(e,[n,n,n],t)}function Lo({r:e,g:t,b:n}){let o=e/255,r=t/255,i=n/255,s=Math.max(o,r,i),a=Math.min(o,r,i),l=(s+a)/2;if(s===a)return{h:0,s:0,l};let f=s-a,c=l>.5?f/(2-s-a):f/(s+a),u;return s===o?u=((r-i)/f+(r<i?6:0))/6:s===r?u=((i-o)/f+2)/6:u=((o-r)/f+4)/6,{h:u,s:c,l}}var Nt=["available","held","sold","selected","dimmed"];function Oo(e){let t=Nt.indexOf(e);return t<0?0:t}var Bo={available:[.24,.82,.52],held:[.34,.39,.45],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var xn={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]},gn={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 Ta=.15,La=1.6;function Fo(e){return to(e??1,Ta,La)}var Oa=.15,Ba=.9,Fa=1.76;function Do(e){return!!e&&e[0]*.2126+e[1]*.7152+e[2]*.0722>.55?{zenith:[.36,.58,.84],horizon:[.82,.88,.94]}:{zenith:[.05,.08,.15],horizon:[.3,.38,.5]}}function Da(){return{background:{top:[...gn.top],bottom:[...gn.bottom]},sky:Do(null),structure:xn,seatStates:{...Bo},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:"#c9ccc8",fascia:"#b4bab8",shell:"#c3c9c8",roughness:.87}:{deck:"#69747b",fascia:"#3e4d58",shell:"#526572",roughness:.87}}function No(e){let t=Da();e??={};let n=ne(e.background);if(n){t.background={top:z(n,Ba),bottom:z(n,Fa)},t.sky=Do(n);let a={};for(let[f,c]of Object.entries(xn))a[f]=te(c,n,Oa);n[0]*.2126+n[1]*.7152+n[2]*.0722>.55&&(a.ground=z(n,.86)),t.structure=a}let o=ne(e.selectionColor)??ne(e.accent);o&&(t.seatStates={...t.seatStates,selected:o});let r=e.seatScale;typeof r=="number"&&Number.isFinite(r)&&(t.seatScale=Fo(r));let i=Object.fromEntries(Object.entries(e.venue3d??{}).filter(([,a])=>a!=null)),s={...Na(n),...i};if(s){let a=ne(s.deck),l=ne(s.fascia);a&&(t.structure={...t.structure,tierTop:a,gaTop:a}),l&&(t.structure={...t.structure,tierWall:l,gaWall:l}),t.materials.seat=ne(s.seat),t.materials.shell=ne(s.shell),typeof s.roughness=="number"&&Number.isFinite(s.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,s.roughness)))}return t}function Go(e,t){let n=[];for(let o of t)n.push(...e.seatStates[o]);return n}function jo(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=!1;for(let s of e)!Number.isFinite(s.x)||!Number.isFinite(s.y)||(i=!0,s.x<t&&(t=s.x),s.y<n&&(n=s.y),s.x>o&&(o=s.x),s.y>r&&(r=s.y));return i?{minX:t,minY:n,maxX:o,maxY:r}:null}function tt(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var Mn=[{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"}],Tm=new Map(Mn.map(e=>[e.key,e]));var Ga={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 Gt(e){let t=e?.[0];return t&&Ga[t]||"#3b82f6"}var ja=[{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"}],Lm=new Map(ja.map(e=>[e.key,e]));var Ha=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Om=new Set(Ha);function gt(e){if(e.length<3)return e.map(i=>({...i}));let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r.map(i=>({...i})):t.map(i=>({...i}))}var dr=Ce(require("polygon-clipping"),1);var Y={top:1,wallBottom:.58,bottomCap:.4};function Qe(e,t){if(!e)return t;let n=z(Pe(e,.4),.62);return te(t,n,.22)}function Ho(e,t){return e?te(t,z(Pe(e,.25),.74),.62):t}function Xo(e,t){return e?te(t,z(Pe(e,.08),.9),.82):t}function Uo(e,t){let n=new Map;for(let i of e.categories??[])n.set(i.key,i.color);let o=new Map;for(let i of t){if(!i.sectionId)continue;let s=o.get(i.sectionId);s||(s=new Map,o.set(i.sectionId,s)),s.set(i.categoryKey,(s.get(i.categoryKey)??0)+1)}let r=new Map;for(let[i,s]of o){let a=0,l=0,f=0,c=0;for(let[u,d]of s){let m=ne(n.get(u));m&&(a+=m[0]*d,l+=m[1]*d,f+=m[2]*d,c+=d)}c>0&&r.set(i,[a/c,l/c,f/c])}return r}function Vo(e,t){return ne(e.color)??t.get(e.logicalSectionId??e.id)??null}var wn=Ce(require("polygon-clipping"),1);var Rn=Ce(require("polygon-clipping"),1);var Ko=[{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}}],Wo=Ko.map(e=>e.key),Xa=new Map(Ko.map(e=>[e.key,e]));function Yo(e){return typeof e=="string"&&Xa.has(e)}function zo(e,t){return Yo(e)?e:Yo(t?.seatGlyph)?t.seatGlyph:"circle"}var de={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},Ua=.44,Va=.15,Ya=.3,Ka=.24;function Zo(e){return e===void 0||!Number.isFinite(e)||e<=0?Ka:Math.min(Ya,Math.max(Va,e*Ua))}var Wa=.05,$o=.45,za=$o+Wa,Za=.92;var Xm=[{part:de.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:de.pad,min:[-1,.36,-.95],max:[1,$o,1]},{part:de.back,min:[-1,za,-1],max:[1,Za,-.72]},{part:de.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:de.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:de.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:de.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:de.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:de.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:de.leg,min:[.62,0,.48],max:[.82,.37,.7]}],Um=[{part:de.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:de.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:de.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:de.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:de.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function Qo(e,t,n,o){let r=new Float32Array(t),i=f=>e[f*3],s=f=>e[f*3+2],a=0,l=(f,c)=>{let u=c-f;for(let d=f;d<c;d++){let[m,h]=o(d),p=m-i(d),y=h-s(d);if(u>=2){let x=Math.max(f,d-1),g=Math.min(c-1,d+1),w=i(g)-i(x),E=s(g)-s(x),M=Math.hypot(w,E);if(M>1e-6){let b=-E/M,I=w/M;b*p+I*y<0&&(b=-b,I=-I),p=b,y=I}}r[d]=p===0&&y===0?0:Math.atan2(p,y)}};for(let f=1;f<=t;f++)(f===t||n(f)!==n(a))&&(l(a,f),a=f);return r}var jt=.22;var $a=.42;function Qa(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let h of e)h.x<o&&(o=h.x),h.y<r&&(r=h.y),h.x>i&&(i=h.x),h.y>s&&(s=h.y);let a=Math.max(i-o,1e-6),l=Math.max(s-r,1e-6),f=Math.max(Math.sqrt(a*l/t),1e-6),c=Math.max(1,Math.ceil(a/f)+1),u=Math.max(1,Math.ceil(l/f)+1),d=new Map,m=(h,p)=>{let y=Math.min(c-1,Math.max(0,Math.floor((h-o)/f)));return Math.min(u-1,Math.max(0,Math.floor((p-r)/f)))*c+y};for(let h=0;h<t;h++){let p=m(e[h].x,e[h].y),y=d.get(p);y?y.push(h):d.set(p,[h])}for(let h=0;h<t;h++){let p=e[h],y=Math.min(c-1,Math.max(0,Math.floor((p.x-o)/f))),x=Math.min(u-1,Math.max(0,Math.floor((p.y-r)/f))),g=1/0;for(let w=1;w<=4;w++){for(let E=x-w;E<=x+w;E++)if(!(E<0||E>=u))for(let M=y-w;M<=y+w;M++){if(M<0||M>=c||w>1&&Math.abs(E-x)<w&&Math.abs(M-y)<w)continue;let b=d.get(E*c+M);if(b)for(let I of b){if(I===h)continue;let S=Math.hypot(e[I].x-p.x,e[I].y-p.y);S<g&&(g=S)}}if(Number.isFinite(g)&&g<=w*f)break}n[h]=g}return n}function qa(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-ve):0}function qo(e,t,n,o,r,i){let s=e.length,a=new Float32Array(s*3),l=new Float32Array(s),f=new Float32Array(s*3),c=new Float32Array(s),u=new Float32Array(s),d=new Float32Array(s),m=new Float32Array(s),h=new Float32Array(s*3),p=new Map,y=Qa(e);for(let x=0;x<s;x++){let g=e[x],E=(n?.seatPitchU(x)??y[x])*P;c[x]=Number.isFinite(E)?Math.max(.06,Math.min(jt,E*$a)):jt,u[x]=Zo(Number.isFinite(E)?E:void 0);let M=zo(g.glyph,{seatGlyph:i?.get(g.categoryKey)});d[x]=Wo.indexOf(M),m[x]=g.wheelchairSpaceType==="no-seat"?0:1,a[x*3]=g.x*P,a[x*3+1]=n?n.seatDeckY(x):qa(g),a[x*3+2]=g.y*P,l[x]=Oo(t?t(g):"available");let b=ne(r?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(f[x*3]=b[0],f[x*3+1]=b[1],f[x*3+2]=b[2],g.accessibility?.length){let I=ne(Gt(g.accessibility));I&&(h[x*3]=I[0],h[x*3+1]=I[1],h[x*3+2]=I[2])}p.set(g.id,x)}return{count:s,iPosition:a,iState:l,iCategory:f,iMaxRadius:c,iRing:h,idToIndex:p,iChairWidth:u,iGlyph:d,iPhysicalSeat:m,iFloor:o??new Float32Array(s),iSection:new Float32Array(s).fill(-1),iYaw:new Float32Array(s)}}var nr=Ce(require("earcut"),1);var Ja=.58,Jo=.01,Re=jt*1.5*Ie,ec=.5,tc=.6;function nc(e,t){let n=e.length,o=[];for(let s=0;s<n;s++){let a=e[Math.max(0,s-1)],l=e[Math.min(n-1,s+1)],f=l.x-a.x,c=l.y-a.y,u=Math.hypot(f,c);if(u<1e-9){o.push([0,0]);continue}f/=u,c/=u,o.push([-c,f])}let r=0;for(let s=0;s<n;s++)r+=(e[s].x-t.x)*o[s][0]+(e[s].y-t.y)*o[s][1];return r<0?o.map(([s,a])=>[-s,-a]):o}function oc(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],o=(s,a)=>{let l=a.x-s.x,f=a.y-s.y,c=Math.hypot(l,f)||1;return{x:l/c,y:f/c}},r=o(n[1],n[0]),i=o(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+r.x*t,y:n[0].y+r.y*t}),n.push({x:n[n.length-1].x+i.x*t,y:n[n.length-1].y+i.y*t}),n}var er=Math.PI/12;function rc(e){if(e.length<3)return[...e];let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y),n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=i=>{let s=[];for(let a of i){for(;s.length>=2&&n(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}return s.pop(),s},r=[...o(t),...o([...t].reverse())];return r.length>=3?r:[...e]}function or(e,t){if(!e.length||!(t>0))return[];let n=rc(e),o=(a,l,f,c)=>{let u=f-l;for(;u<0;)u+=Math.PI*2;for(;u>Math.PI*2;)u-=Math.PI*2;let d=Math.max(1,Math.ceil(u/er)),m=t/Math.cos(u/d/2);for(let h=0;h<=d;h++){let p=l+u*h/d;c.push({x:a.x+Math.cos(p)*m,y:a.y+Math.sin(p)*m})}};if(n.length<3){let a=0,l=0;for(let m of n)a+=m.x,l+=m.y;a/=n.length||1,l/=n.length||1;let f=0;for(let m of n)f=Math.max(f,Math.hypot(m.x-a,m.y-l));let c=[],u=Math.max(3,Math.ceil(Math.PI*2/er)),d=(f+t)/Math.cos(Math.PI/u);for(let m=0;m<u;m++){let h=m/u*Math.PI*2;c.push({x:a+Math.cos(h)*d,y:l+Math.sin(h)*d})}return c}let r=n.length,i=[];for(let a=0;a<r;a++){let l=n[a],f=n[(a+1)%r];i.push(Math.atan2(-(f.x-l.x),f.y-l.y))}let s=[];for(let a=0;a<r;a++)o(n[a],i[(a+r-1)%r],i[a],s);return cr(s)}function ic(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let o=1/0;for(let r=0;r+1<e.length;r++){let i=e[r],s=e[r+1],a=s.x-i.x,l=s.y-i.y,f=a*a+l*l,c=f>1e-12?((t-i.x)*a+(n-i.y)*l)/f:0;c<0?c=0:c>1&&(c=1);let u=Math.hypot(t-(i.x+c*a),n-(i.y+c*l));u<o&&(o=u)}return o}function Ht(e){let t=e.map(r=>{let i=0,s=0;for(let f of r.pts)i+=f.x,s+=f.y;let a=r.pts.length||1;i/=a,s/=a;let l=0;for(let f of r.pts){let c=Math.hypot(f.x-i,f.y-s);c>l&&(l=c)}return{cx:i,cy:s,rad:l}}),n=r=>{let i=r.length;return i<=2?[...r]:[r[Math.floor(i*.25)],r[Math.floor(i*.5)],r[Math.floor(i*.75)]]},o=[];for(let r=0;r<e.length;r++){let i=n(e[r].pts),s=[],a=1/0,l=null;for(let c of i){let u=1/0;for(let d=0;d<e.length;d++){if(d===r||Math.abs(e[d].y-e[r].y)<.001)continue;let m=t[d],h=Math.hypot(c.x-m.cx,c.y-m.cy)-m.rad;if(h>=u&&h>=a)continue;let p=ic(e[d].pts,c.x,c.y);p<u&&(u=p),e[d].depth<e[r].depth&&p<a&&(a=p,l=e[d].y)}Number.isFinite(u)&&u>0&&s.push(u)}s.sort((c,u)=>c-u);let f=s.length?s[Math.floor(s.length/2)]:1;o.push({pitch:f,belowY:l})}return o}function rr(e,t,n,o){let r=e[t],i=r.pts.length>=2?[...r.pts]:r.pts.length===1?(()=>{let c=r.pts[0],u=c.x-o.x,d=c.y-o.y,m=Math.hypot(u,d)||1;u/=m,d/=m;let h=Math.max(n[t].pitch,.001)*.5;return[{x:c.x+d*h,y:c.y-u*h},{x:c.x-d*h,y:c.y+u*h}]})():[];if(i.length<2)return null;let s=0,a=0;for(let c=1;c<i.length;c++){let u=Math.hypot(i[c].x-i[c-1].x,i[c].y-i[c-1].y);u>1e-6&&(s+=u,a++)}let l=a>0?s/a:0,f=oc(i,Math.max(l*tc,Re));return{pts:f,nrm:nc(f,o),front:Math.max(n[t].pitch*Ja,Re),back:Math.max(n[t].pitch*ec,Re)}}var nt=1.5,ir=.3;function Sn(e,t){if(e.length<3)return e;let n=e[0],o=e[e.length-1],r=o.x-n.x,i=o.y-n.y,s=Math.hypot(r,i),a=-1,l=-1;for(let u=1;u<e.length-1;u++){let d=e[u],m=s>1e-12?Math.abs((d.x-n.x)*i-(d.y-n.y)*r)/s:Math.hypot(d.x-n.x,d.y-n.y);m>a&&(a=m,l=u)}if(a<=t||l<0)return[n,o];let f=Sn(e.slice(0,l+1),t),c=Sn(e.slice(l),t);return[...f.slice(0,-1),...c]}function sr(e,t){if(e.length<4)return e;let n=Sn([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function sc(e){let t=e.map((o,r)=>{let i=e[(r+1)%e.length];return{a:o,b:i,i:r,minX:Math.min(o.x,i.x),maxX:Math.max(o.x,i.x),minY:Math.min(o.y,i.y),maxY:Math.max(o.y,i.y)}}).sort((o,r)=>o.minX-r.minX),n=(o,r,i)=>(r.x-o.x)*(i.y-o.y)-(r.y-o.y)*(i.x-o.x);for(let o=0;o<t.length;o++){let r=t[o];for(let i=o+1;i<t.length&&t[i].minX<=r.maxX;i++){let s=t[i];if(!(Math.abs(r.i-s.i)===1||Math.abs(r.i-s.i)===e.length-1||r.maxY<s.minY||s.maxY<r.minY)&&n(r.a,r.b,s.a)*n(r.a,r.b,s.b)<=0&&n(s.a,s.b,r.a)*n(s.a,s.b,r.b)<=0)return!0}}return!1}function ar(e,t,n){if(e.length<2)return[];let o=n??Ht(e),r=new Map;for(let s=0;s<e.length;s++){let a=r.get(e[s].blockId);a?a.push(s):r.set(e[s].blockId,[s])}let i=[];for(let[,s]of r){let a=[];for(let g of s){let w=e[g].patch;w&&w.length>=3?i.push({outline:[...w],holes:[],topY:e[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,w)=>e[g].depth-e[w].depth);let f=a.map(g=>rr(e,g,o,t)).filter(g=>g!==null);if(!f.length)continue;let c=(g,w)=>({x:g.pts[w].x-g.nrm[w][0]*(g.front+nt),y:g.pts[w].y-g.nrm[w][1]*(g.front+nt)}),u=(g,w)=>({x:g.pts[w].x+g.nrm[w][0]*(g.back+nt),y:g.pts[w].y+g.nrm[w][1]*(g.back+nt)}),d=f[0],m=f[f.length-1],h=[];for(let g=0;g<d.pts.length;g++)h.push(c(d,g));for(let g of f)h.push(u(g,g.pts.length-1));for(let g=m.pts.length-1;g>=0;g--)h.push(u(m,g));for(let g=f.length-1;g>=0;g--)h.push(c(f[g],0));let p=cr(h),y=1/0;for(let g of a)e[g].y<y&&(y=e[g].y);if(!Number.isFinite(y))continue;if(p.length>=3&&Math.abs(ye(p))>1e-6&&f.every(g=>{let w=g.pts[Math.floor(g.pts.length/2)];return xe(p,w.x,w.y)})&&!sc(p)){i.push({outline:sr(p,ir),holes:[],topY:y});continue}for(let g of ac(f))i.push({outline:g,holes:[],topY:y})}return i}function ac(e){let t=[];for(let n of e){let o=[],r=[],i=n.front+nt,s=n.back+nt;for(let l=0;l<n.pts.length;l++){let f=n.pts[l],c=n.nrm[l];o.push([f.x-c[0]*i,f.y-c[1]*i]),r.push([f.x+c[0]*s,f.y+c[1]*s])}let a=[...o,...r.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=Rn.default.union(t[0],...t.slice(1)),o=[];for(let r of n){if(!r.length||r[0].length<4)continue;let i=r[0].map(([l,f])=>({x:l,y:f})),s=i[0],a=i[i.length-1];i.length>1&&Math.abs(s.x-a.x)<1e-9&&Math.abs(s.y-a.y)<1e-9&&i.pop(),i.length>=3&&o.push(sr(i,ir))}return o}catch{return[]}}function cr(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 In=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let o of n)o.x<this.minX&&(this.minX=o.x),o.y<this.minY&&(this.minY=o.y),o.x>this.maxX&&(this.maxX=o.x),o.y>this.maxY&&(this.maxY=o.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let o=!0;for(let r of t)if(!xe(n,r.x,r.y)){o=!1;break}if(o)return!0}return!1}};function tr(e,t,n,o,r,i){if(o.length<3)return;if(n.containsAll(o)){let f=[0,1,0],c=o[0];for(let u=1;u+1<o.length;u++){let d=o[u],m=o[u+1];e.tri([c.x*P,r,c.y*P],[d.x*P,r,d.y*P],[m.x*P,r,m.y*P],f,i)}return}let s=o.map(f=>[f.x,f.y]);s.push(s[0]);let a;try{a=Rn.default.intersection([s],t)}catch{return}let l=[0,1,0];for(let f of a){if(!f.length||f[0].length<4)continue;let c=f[0],u=[],d=[];for(let h=0;h<c.length-1;h++)u.push(c[h][0],c[h][1]),d.push([c[h][0],c[h][1]]);if(d.length<3)continue;let m=(0,nr.default)(u,void 0,2);for(let h=0;h<m.length;h+=3){let p=d[m[h]],y=d[m[h+1]],x=d[m[h+2]];e.tri([p[0]*P,r,p[1]*P],[y[0]*P,r,y[1]*P],[x[0]*P,r,x[1]*P],l,i)}}}function lr(e,t,n,o,r,i,s){if(t.length<2)return;let a=s??Ht(t),l=[0,1,0],f=i&&i.length>=3?[[...i.map(m=>[m.x,m.y]),[i[0].x,i[0].y]]]:null,c=i&&i.length>=3?new In([[...i]]):null,u=m=>{e.setMaterial(2),m(),e.setMaterial(0)},d=m=>{e.setMaterial(3),m(),e.setMaterial(0)};for(let m=0;m<t.length;m++){let h=t[m];if(h.patch&&h.patch.length>=3){let M=[...h.patch],b=a[m].belowY??o;if(d(()=>{if(f&&c)tr(e,f,c,M,h.y,r.tread);else{let I=M[0];for(let S=1;S+1<M.length;S++){let R=M[S],_=M[S+1];e.tri([I.x*P,h.y,I.y*P],[R.x*P,h.y,R.y*P],[_.x*P,h.y,_.y*P],l,r.tread)}}}),h.y>b+Jo){let I=0,S=0;for(let R of M)I+=R.x,S+=R.y;I/=M.length,S/=M.length,u(()=>{for(let R=0;R<M.length;R++){let _=M[R],k=M[(R+1)%M.length],O=k.x-_.x,v=k.y-_.y,A=Math.hypot(O,v);if(A<1e-6)continue;let C=v/A,T=-O/A;(_.x-I)*C+(_.y-S)*T<0&&(C=-C,T=-T);let F=[C,0,T],L=[_.x*P,h.y,_.y*P],B=[k.x*P,h.y,k.y*P],N=[_.x*P,b,_.y*P],j=[k.x*P,b,k.y*P];e.tri(L,B,j,F,r.riser),e.tri(L,j,N,F,r.riser)}})}continue}let p=rr(t,m,a,n);if(!p)continue;let{pts:y,nrm:x,front:g,back:w}=p,E=a[m].belowY??o;for(let M=0;M+1<y.length;M++){let b=y[M],I=y[M+1],S=x[M],R=x[M+1];if(Math.hypot(I.x-b.x,I.y-b.y)<1e-6||S[0]===0&&S[1]===0||R[0]===0&&R[1]===0)continue;let _=[(b.x-S[0]*g)*P,h.y,(b.y-S[1]*g)*P],k=[(I.x-R[0]*g)*P,h.y,(I.y-R[1]*g)*P],O=[(b.x+S[0]*w)*P,h.y,(b.y+S[1]*w)*P],v=[(I.x+R[0]*w)*P,h.y,(I.y+R[1]*w)*P];if(d(()=>{f&&c?tr(e,f,c,[{x:b.x-S[0]*g,y:b.y-S[1]*g},{x:I.x-R[0]*g,y:I.y-R[1]*g},{x:I.x+R[0]*w,y:I.y+R[1]*w},{x:b.x+S[0]*w,y:b.y+S[1]*w}],h.y,r.tread):(e.tri(_,k,v,l,r.tread),e.tri(_,v,O,l,r.tread))}),h.y>E+Jo){let A=[_[0],E,_[2]],C=[k[0],E,k[2]],T=[-S[0],0,-S[1]];u(()=>{e.tri(_,k,C,T,r.riser),e.tri(_,C,A,T,r.riser)})}}}}function cc(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function ur(e,t){return e.filter(n=>n.type!=="shape"||cc(n,t))}function fr(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((o,r)=>({objects:ur(o.objects,t),focal:{x:(o.focalPoint??n).x,y:(o.focalPoint??n).y},baseHeightM:o.baseHeightM??0,index:r})):[{objects:ur(e.objects,t),focal:n,baseHeightM:0,index:0}]}var lc={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Oe(e){return jo(e)??lc}function mr(e,t){let n=we(e.outline,Re),o=Oe(n),r=t.filter(s=>s!==e&&s.outline&&s.outline.length>=3&&tt(o,Oe(s.outline)));if(!r.length)return[n];let i=s=>{let a=s.map(l=>[l.x,l.y]);return a.push(a[0]),a};try{let s=wn.default.difference([i(n)],...r.map(l=>[i(l.outline)])),a=[];for(let l of s){if(!l.length)continue;let f=l[0].map(([c,u])=>({x:c,y:u}));if(f.length>1){let c=f[0],u=f[f.length-1];Math.abs(c.x-u.x)<1e-9&&Math.abs(c.y-u.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a.length?a:[n]}catch{return[n]}}function hr(e,t){if(!t.length)return e;let n=i=>{let s=i.map(a=>[a.x,a.y]);return s.push(s[0]),s},o=t.map(i=>[n(i)]),r=[];for(let i of e){let s;try{s=wn.default.intersection([n(i.outline)],o.flat())}catch{r.push(i);continue}for(let a of s){if(!a.length)continue;let l=a[0].map(([f,c])=>({x:f,y:c}));if(l.length>1){let f=l[0],c=l[l.length-1];Math.abs(f.x-c.x)<1e-9&&Math.abs(f.y-c.y)<1e-9&&l.pop()}l.length>=3&&r.push({outline:l,holes:[],topY:i.topY})}}return r.length?r:e}function uc(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var Xt=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let o=t.map(l=>[l.x,l.y]);if(o.length<3)return[];o.push(o[0]);let r=Oe(t),i=this.rings.filter((l,f)=>tt(r,this.boxes[f])&&uc(n,this.levels[f])),s=[[o]];if(i.length)try{s=dr.default.difference([o],...i).map(f=>f.map(c=>c.map(([u,d])=>[u,d])))}catch{s=[[o]]}this.rings.push([o]),this.boxes.push(r),this.levels.push(n);let a=[];for(let l of s){if(!l.length)continue;let f=l[0].map(([c,u])=>({x:c,y:u}));if(f.length>1){let c=f[0],u=f[f.length-1];Math.abs(c.x-u.x)<1e-9&&Math.abs(c.y-u.y)<1e-9&&f.pop()}f.length>=3&&a.push(f)}return a}};function Ut(e,t){if(!t)return e;let n=1/0,o=-1/0,r=1/0,i=-1/0;for(let u of e)n=Math.min(n,u.x),o=Math.max(o,u.x),r=Math.min(r,u.y),i=Math.max(i,u.y);let s=(n+o)/2,a=(r+i)/2,l=t*Math.PI/180,f=Math.cos(l),c=Math.sin(l);return e.map(u=>{let d=u.x-s,m=u.y-a;return{x:s+d*f-m*c,y:a+d*c+m*f}})}function ie(e){let t=null;if(e.kind==="polygon"&&e.points&&e.points.length>=3&&(t=e.points),e.kind==="rect"&&e.width&&e.height&&(t=bt(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,o=(e.y??0)+e.height/2;t=Dt(n,o,e.width/2,e.height/2)}return t?Ut(t,e.rotation):null}function Ae(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},o=t==="stage"&&ft(e.stageKind)?{kind:"stage",heightM:e.stageKind==="ring-boxing"?vt:.06}:n[t]??{kind:"plate",heightM:.25};return{...o,heightM:e.heightM??o.heightM}}var fc=.08,mc=30,hc=.015;function dc(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function pr(e,t){let n=ie(e)??(e.points?.length?Ut(e.points,e.rotation):null),o=Ae(e),i=!e.role&&o.kind==="plate"&&e.heightM===void 0&&!!n&&Math.abs(ye(n))*$**2>=mc?hc:o.heightM;if(!n)return{topOffsetM:i,supportOffsetM:0};if(o.kind!=="plate"&&o.kind!=="stage")return{topOffsetM:i,supportOffsetM:0};let s=1/0,a=1/0,l=-1/0,f=-1/0;for(let m of n)s=Math.min(s,m.x),a=Math.min(a,m.y),l=Math.max(l,m.x),f=Math.max(f,m.y);let c=i,u=0,d=1e-6*Math.max(1,l-s,f-a);for(let m of t)l>m.minX&&s<m.maxX&&f>m.minY&&a<m.maxY&&c<=m.topOffsetM+1e-6&&(c=m.topOffsetM+fc),s>=m.minX-d&&l<=m.maxX+d&&a>=m.minY-d&&f<=m.maxY+d&&(!m.poly||n.every(y=>dc(y,m.poly)||pc(y,m.poly,d)))&&(u=Math.max(u,m.topOffsetM));return e.fill&&e.fill!=="none"&&e.fill!=="transparent"&&t.push({minX:s,minY:a,maxX:l,maxY:f,topOffsetM:c,poly:n}),{topOffsetM:c,supportOffsetM:Math.min(u,c)}}function pc(e,t,n){for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,l=s.y-i.y,f=a*a+l*l,c=f?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*l)/f)):0;if(Math.hypot(e.x-(i.x+c*a),e.y-(i.y+c*l))<=n)return!0}return!1}function Xe(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function ge(e){if(e.length!==4)return e;let t=Math.hypot(e[1].x-e[0].x,e[1].y-e[0].y),n=Math.hypot(e[2].x-e[1].x,e[2].y-e[1].y);return t>=n?e:[e[1],e[2],e[3],e[0]]}function pe(e,t,n){return[Xe(e[0],e[1],t),Xe(e[0],e[1],n),Xe(e[3],e[2],n),Xe(e[3],e[2],t)]}function Mt(e,t,n){return[Xe(e[0],e[3],t),Xe(e[1],e[2],t),Xe(e[1],e[2],n),Xe(e[0],e[3],n)]}function ee(e,t,n,o,r,i){W(e,t,void 0,()=>n,o,r,i,Y)}var bc=.8,yc=.6,xc=2;function ot(e,t){if(!t.length)return null;let n=[],o=0;for(let s of e.objects){if(s.type!=="shape"||s.role!=="wall")continue;let a=ie(s)??[],l=br(a)/2;!(l>0)||Sc(a)/l*P>xc||(n.push(...a),o+=l)}if(n.length<3)return null;let r=gt(n);if(r.length<3||o<br(r)*yc)return null;let i=0;for(let s of t)Ic(s,r)&&(i+=1);return i>=t.length*bc?r:null}var yr=6,gc=5,Mc=8;function xr(e){return Math.max(Mc,(Number.isFinite(e)?e:0)+gc)}function gr(e){let t=0,n=0,o=0;for(let r=0;r<e.length;r++){let i=e[r],s=e[(r+1)%e.length],a=i.x*s.y-s.x*i.y;t+=a,n+=(i.x+s.x)*a,o+=(i.y+s.y)*a}if(Math.abs(t)<1e-9){let r=0,i=0;for(let s of e)r+=s.x,i+=s.y;return{x:r/Math.max(1,e.length),y:i/Math.max(1,e.length)}}return{x:n/(3*t),y:o/(3*t)}}function Sc(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 br(e){let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=Math.hypot(r.x-o.x,r.y-o.y)}return t}function Ic(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function Rc(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let o=t-e.x,r=n-e.y,i=Math.hypot(o,r);return i<1e-9?[0,0]:[o/i,r/i]}}}function wc(e,t){if(!e.length)return null;let n=0,o=0,r=0;for(let m of e)n+=m.x,o+=m.y,r+=Math.hypot(m.x-t.x,m.y-t.y);let i=e.length;n/=i,o/=i,r/=i;let s=e[0],a=-1;for(let m of e){let h=Math.hypot(m.x-n,m.y-o);h>a&&(a=h,s=m)}let l=s.x-n,f=s.y-o,c=Math.hypot(l,f);c>1e-9?(l/=c,f/=c):(l=1,f=0);let u=[...e].sort((m,h)=>(m.x-n)*l+(m.y-o)*f-((h.x-n)*l+(h.y-o)*f)),d=0;for(let m of u){let h=Math.hypot(m.x-n,m.y-o);h>d&&(d=h)}return{pts:u,cx:n,cy:o,radius:d,depth:r}}function Mr(e,t,n){let o=e.pts;if(o.length===1)return Math.hypot(t-o[0].x,n-o[0].y);let r=1/0;for(let i=0;i+1<o.length;i++){let s=o[i],a=o[i+1],l=a.x-s.x,f=a.y-s.y,c=l*l+f*f,u=c>1e-12?((t-s.x)*l+(n-s.y)*f)/c:0;u<0?u=0:u>1&&(u=1);let d=Math.hypot(t-(s.x+u*l),n-(s.y+u*f));d<r&&(r=d)}return r}var Vt=8;function Pc(e,t,n){let o=new Array(Vt).fill(1/0),r=new Array(Vt).fill(-1);for(let c=0;c<e.length;c++){let u=e[c],d=Math.hypot(t-u.cx,n-u.cy)-u.radius;for(let m=0;m<Vt;m++)if(d<o[m]){for(let h=Vt-1;h>m;h--)o[h]=o[h-1],r[h]=r[h-1];o[m]=d,r[m]=c;break}}let i=new Array(3).fill(1/0),s=new Array(3).fill(-1);for(let c of r){if(c<0)continue;let u=Mr(e[c],t,n);for(let d=0;d<3;d++)if(u<i[d]){for(let m=2;m>d;m--)i[m]=i[m-1],s[m]=s[m-1];i[d]=u,s[d]=c;break}}if(s[0]<0)return 0;if(i[0]<1e-6)return e[s[0]].depth;let a=i[0]*2.2,l=0,f=0;for(let c=0;c<3;c++){let u=s[c];if(u<0||i[c]>a)continue;let d=1/(i[c]*i[c]);l+=d*e[u].depth,f+=d}return f>0?l/f:e[s[0]].depth}function Ac(e){let t=(o,r)=>Pc(e,o,r),n=(o,r)=>{let i=1/0,s=-1;for(let a=0;a<e.length;a++){let l=e[a];if(Math.hypot(o-l.cx,r-l.cy)-l.radius>=i)continue;let f=Mr(l,o,r);f<i&&(i=f,s=a)}return s};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(o,r)=>{let i=(t(o+.5,r)-t(o-.5,r))/1,s=(t(o,r+.5)-t(o,r-.5))/(2*.5),a=Math.hypot(i,s);return a<1e-9?[0,0]:[i/a,s/a]}}}function Sr(e,t){let n=[];for(let o of e){let r=wc(o.points,t);r&&n.push(r)}return n.length<2?Rc(t):(n.sort((o,r)=>o.depth-r.depth),Ac(n))}var Ue=.06,Ec=.05,Rr=.05,Ir=.15,Pn=25;function wr(e,t,n){let o=new Map,r=new Array(t.length).fill(null),i=new Float64Array(t.length),s=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),l=new Map,f=[],c=new Set;for(let d=0;d<e.length;d+=1){let m=e[d];for(let h of m.objects){if(h.type==="table"&&c.add(h.id),h.type!=="section"||!h.outline||h.outline.length<3)continue;let p=we(h.outline,Re);l.set(h.id,{section:h,unit:m,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),f.push({id:h.id,floorIndex:d,box:Oe(p),section:h,unit:m,outline:p})}}let u=new Map;for(let d of f){let m=u.get(d.floorIndex);m?m.push(d):u.set(d.floorIndex,[d])}for(let d=0;d<t.length;d++){let m=t[d],h=n?u.get(n[d])??[]:f,p=m.sectionId?h.find(x=>x.id===m.sectionId)??h.find(x=>x.section.logicalSectionId===m.sectionId&&be({x:m.x,y:m.y},x.outline,x.section.holes)):void 0,y=p?[p]:h;for(let x of y){if(n&&x.floorIndex!==n[d]||!p&&(m.x<x.box.minX||m.x>x.box.maxX||m.y<x.box.minY||m.y>x.box.maxY||!be({x:m.x,y:m.y},x.outline,x.section.holes)))continue;r[d]=x.id;let g=l.get(x.id);g.hasSeats=!0;let w=m.focalPoint??x.unit.focal,E=Math.hypot(m.x-w.x,m.y-w.y);E<g.frontU&&(g.frontU=E),g.seatIndices.push(d);let M=m.rowId||`__seat-${d}`,b=g.rows.get(M);b?b.push({x:m.x,y:m.y}):g.rows.set(M,[{x:m.x,y:m.y}]);break}}for(let[d,m]of l){let h=Ge(m.section,{floorBaseHeightM:m.unit.baseHeightM}),p=m.unit.baseHeightM,y=h.rake>0?Math.tan(h.rake*Math.PI/180):0,x=h.rake<=.01&&h.height<=p+.001,g=m.section.surfaceKind,w=g==="flat"?!0:g==="rakedRows"&&h.rake>.01?!1:x,E=m.hasSeats?_t(d,t,m.seatIndices,m.unit.focal):{sectionId:d,rows:[],blockCount:0},b=E.rows.length<2?Sr([...m.rows.values()].map(L=>({points:L})),m.unit.focal):null,I=1/0;if(b){if(m.hasSeats)for(let L of m.rows.values())for(let B of L){let N=b.depthAt(B.x,B.y);N<I&&(I=N)}if(!m.hasSeats||!Number.isFinite(I)){I=1/0;for(let L of m.section.outline){let B=b.depthAt(L.x,L.y);B<I&&(I=B)}}}let S=p+Ec,R=Math.max(S,h.height),_=L=>{let B=Math.max(0,L-I)*$,N=Math.min(B*y,Pn);return Math.max(S,h.height+N)},k=L=>{let B=Math.max(0,L)*$,N=Math.min(B*y,Pn);return Math.max(S,h.height+N)},O=w?[]:E.rows.map(L=>({pts:L.pts,y:k(L.blockDepth),depth:L.blockDepth,blockId:L.blockId,...c.has(L.id)?{patch:or(L.pts,Re)}:{}})),v=O.length?O[0].y:R,A=O.map(L=>{let B=L.patch&&L.patch.length>=3?L.patch:L.pts,N=0,j=0;for(let X of B)N+=X.x,j+=X.y;let D=B.length||1;N/=D,j/=D;let V=0;for(let X of B){let Z=Math.hypot(X.x-N,X.y-j);Z>V&&(V=Z)}return{cx:N,cy:j,rad:V}}),C=w?()=>R:O.length>=2?(L,B)=>{let N=1/0,j=v;for(let D=0;D<O.length;D++){let V=A[D];if(Math.hypot(L-V.cx,B-V.cy)-V.rad>=N)continue;let X=O[D].patch,Z=X&&X.length>=3?xe(X,L,B)?0:qe(X,L,B):qe(O[D].pts,L,B);Z<N&&(N=Z,j=O[D].y)}return j}:(L,B)=>b?_(b.depthAt(L,B)):R,T=[0,1,0],F=O.length>=2||w?()=>T:(L,B)=>{if(!b)return T;let N=b.depthAt(L,B);if(N<=I)return T;let j=(N-I)*$;if(j*y>=Pn||h.height+j*y<=S)return T;let[D,V]=b.gradientAt(L,B);if(D===0&&V===0)return T;let X=1/Math.hypot(y,1);return[-D*y*X,X,-V*y*X]};if(!w)for(let L of E.rows){let B=k(L.blockDepth);for(let N of L.seatIndices)s[N]=B}for(let L of E.rows){let B=[];for(let X=1;X<L.pts.length;X++){let Z=Math.hypot(L.pts[X].x-L.pts[X-1].x,L.pts[X].y-L.pts[X-1].y);Z>1e-6&&B.push(Z)}B.sort((X,Z)=>X-Z);let N=B.length?B[Math.floor(B.length/2)]:1/0,j=1/0,D=L.pts[Math.floor(L.pts.length/2)];if(D)for(let X of E.rows){if(X===L||X.blockId!==L.blockId)continue;let Z=qe(X.pts,D.x,D.y);Z>1e-6&&Z<j&&(j=Z)}let V=Math.min(N,Math.max(j,N*.5));if(Number.isFinite(V)&&V>0)for(let X of L.seatIndices)a[X]=V}o.set(d,{sectionId:d,deckAt:C,normalAt:F,flat:w,bottomY:p,rowLevels:O,landingY:v})}for(let d=0;d<t.length;d++){let m=r[d],h=t[d];if(m){let x=s[d];i[d]=(x??o.get(m).deckAt(h.x,h.y))+Ir;continue}let p=h.eyeHeightM,y=Number.isFinite(p)?Math.max(0,p-ve):0;i[d]=h.kind==="booth"?y+Ue+Ir:y}return{bySection:o,seatOwner:r,seatDeckY:d=>i[d],seatPitchU:d=>a[d]}}function rt(e,t,n){if(e.length!==4||n<=t)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*P,i=Math.hypot(o[3].x-o[0].x,o[3].y-o[0].y)*P;if(r<1e-6||i<1e-6)return null;let s=Math.min(.22/r,.16),a=Math.min(.28,(n-t)*.13),l=Math.min(.065/i,.2);return{quad:o,side:s,face:l,opening:pe(o,s,1-s),openingTop:n-a}}function An(e,t,n){if(e.length!==4||n-t<=.2)return null;let o=ge(e),r=Math.hypot(o[1].x-o[0].x,o[1].y-o[0].y)*P;if(r<=1e-6)return null;let i=Math.min(.14,(n-t)*.08,r*.08),s=i/r,a=pe(o,s,1-s);return{quad:o,side:s,trim:i,inner:a,panel:Mt(a,.15,.85),bottom:t+i,top:n-i}}function Pr(e,t,n,o){let r=An(e,t,n);if(!r)return;let{panel:i}=r,s=(g,w)=>({x:(g.x+w.x)/2,y:(g.y+w.y)/2}),a=s(i[0],i[1]),l=s(i[3],i[2]),f=Math.hypot(a.x-o.x,a.y-o.y)<=Math.hypot(l.x-o.x,l.y-o.y),[c,u]=f?[i[0],i[1]]:[i[3],i[2]],d=f?{x:a.x-l.x,y:a.y-l.y}:{x:l.x-a.x,y:l.y-a.y},m=Math.hypot(d.x,d.y);if(m<1e-6)return;-(u.y-c.y)*d.x+(u.x-c.x)*d.y<0&&([c,u]=[u,c]);let h=Math.min(.006,m*P*.05),p=d.x/m*h,y=d.y/m*h,x=(g,w)=>[g.x*P+p,w,g.y*P+y];return[x(c,r.bottom),x(u,r.bottom),x(c,r.top),x(u,r.top)]}var Er=Ce(require("polygon-clipping"),1);var Ar=Ce(require("polygon-clipping"),1);function Be(e,t,n,o,r,i,s,a={}){let l=Oe(t),f=a.ao??Y,c=r.flatMap(p=>{if(p.role!=="entrance"&&p.role!=="exit")return[];let y=ie(p);if(!y||y.length!==4||!tt(l,Oe(y)))return[];let x=a.portalBase??n,g=rt(y,x,x+Ae(p).heightM);if(!g)return[];let w=Math.min(o,g.openingTop);return w<=n?[]:[{poly:g.opening,height:w}]});if(!c.length)return!1;let u=p=>p.map(y=>[y.x,y.y]),d=[u(t),...(a.holes??[]).map(u)],m=[n,...new Set(c.map(p=>p.height)),o].sort((p,y)=>p-y),h=[];try{for(let p=1;p<m.length;p++){let y=m[p-1],x=m[p];if(x-y<1e-6)continue;let g=c.filter(E=>E.height>y+1e-6).map(E=>[u(E.poly)]),w=g.length?Ar.default.difference(d,...g):[d];h.push({low:y,high:x,polys:w})}}catch{return!1}for(let p of h)for(let y of p.polys){let[x,...g]=y.map(E=>E.map(([M,b])=>({x:M,y:b}))),w=E=>f.wallBottom+(f.top-f.wallBottom)*(E-n)/(o-n);W(e,x,g,()=>p.high,p.low,i,s,{...f,top:w(p.high),wallBottom:w(p.low)})}return!0}var En={depthM:1.6,thicknessM:.35,minWallM:6};function _r(e,t,n,o,r,i,s,a){let l=o-n;if(l<=0)return;let f=a&&l>=En.minWallM?_c(t,a):null,c=f?o-En.thicknessM:o,u=c-n,d=u<1.5?[[n,c,1]]:f?[[n,n+Math.min(.9,u*.18),.82],[n+Math.min(.9,u*.18),c,1]]:[[n,n+Math.min(.9,u*.18),.82],[n+Math.min(.9,u*.18),c-.1,1],[c-.1,c,1.1]],m=h=>Y.wallBottom+(Y.top-Y.wallBottom)*(h-n)/l;for(let[h,p,y]of d){let x={...Y,top:m(p),wallBottom:m(h)},g=z(i,y),w=z(s,y);Be(e,t,h,p,r,g,w,{portalBase:n,ao:x})||W(e,t,void 0,()=>p,h,g,w,x)}for(let[h,...p]of f??[])W(e,h,p.length?p:void 0,()=>o,c,z(i,1.12),z(s,.78),Y)}function _c(e,t){let n=En.depthM/P,o=e.map(s=>{let a=t.x-s.x,l=t.y-s.y,f=Math.hypot(a,l)||1;return{x:s.x+a/f*n,y:s.y+l/f*n}}),r=s=>{let a=s.map(l=>[l.x,l.y]);return a.push(a[0]),a},i=[[r(e)],[r(o)]];for(let s=0;s<e.length;s++){let a=(s+1)%e.length;i.push([r([e[s],e[a],o[a],o[s]])])}try{let[s,...a]=i,l=Er.default.union(s,...a);return l.length?l.map(f=>f.map(c=>c.slice(0,-1).map(([u,d])=>({x:u,y:d})))):null}catch{return null}}function St(e,t,n){let o=ne(t.stroke?.color),r=t.stroke?.width??0;if(!o||!Number.isFinite(r)||r<=0)return;let i=t.kind==="line"||t.kind==="polyline",s=i?Ut(t.points??[],t.rotation):ie(t);if(!s||s.length<2)return;let a=i?s.length-1:s.length,l=r*.5;for(let f=0;f<a;f++){let c=s[f],u=s[(f+1)%s.length],d=Math.hypot(u.x-c.x,u.y-c.y);if(d<1e-6)continue;let m=-(u.y-c.y)/d*l,h=(u.x-c.x)/d*l,p=[(c.x+m)*P,n,(c.y+h)*P],y=[(u.x+m)*P,n,(u.y+h)*P],x=[(u.x-m)*P,n,(u.y-h)*P],g=[(c.x-m)*P,n,(c.y-h)*P];e.tri(p,y,x,[0,1,0],o),e.tri(p,x,g,[0,1,0],o)}}function Cr(e){return e==="bar"||e==="concession"||e==="coat"||e==="restroom"}var it=(e,t,n)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function Yt(e,t,n,o){let[r,i,s,a]=t?e:[e[3],e[2],e[1],e[0]];return[it(r,a,n),it(i,s,n),it(i,s,o),it(r,a,o)]}function vr(e,t,n,o,r,i,s,a,l=!1){if(n.length!==4||r-o<.4)return!1;let f=S=>l?Math.min(S,r):S,c=ge(n),u=Math.hypot(c[3].x-c[0].x,c[3].y-c[0].y)*P;if(u<.4)return!1;let d=it(c[0],c[1],.5),m=it(c[3],c[2],.5),h=Math.hypot(d.x-a.x,d.y-a.y)<=Math.hypot(m.x-a.x,m.y-a.y),p=te(s,[.92,.9,.86],.35),y=z(i,.72),x=r-o;if(t==="restroom"){let S=Math.min(.18,x*.08);return ee(e,c,r-S,o,s,i),ee(e,c,r,r-S,p,p),!0}let g=o+Math.min(1.1,x),w=t==="coat"?1:Math.min(.5,.75/u),E=Yt(c,h,0,w);if(ee(e,E,g-.05,o,y,i),ee(e,E,g,g-.05,p,p),t==="coat"||u<1.2)return!0;if(t==="bar"){let S=Yt(c,h,Math.max(w+.2,1-.45/u),1),R=f(o+Math.max(Math.min(2.2,x*2),g-o+.6));return ee(e,S,R,o,s,y),!0}let M=Yt(c,h,Math.max(w+.25,.55),1),b=f(o+Math.max(2.6,g-o+1.4));if(b-.14<=g)return!0;ee(e,M,b-.14,o,s,i),ee(e,c,b,b-.14,p,y);let I=Math.min(.08,.1/Math.max(.1,Math.hypot(c[1].x-c[0].x,c[1].y-c[0].y)*P));for(let[S,R]of[[0,I],[1-I,1]])ee(e,Yt(pe(c,S,R),h,0,Math.min(.08,.1/u)),b-.14,g,y,y);return!0}var Cc=[.12,.38,.16],vc=[.72,.62,.45],kc=[.88,.93,.96],kr=[.95,.95,.94],Tc=[.66,.29,.22],_n={length:20.12,width:3.05},Lc=.14,Oc=9.76,Fe=[.93,.94,.95],Kt=[.1,.11,.13],Bc=[.45,.85,1.25],Fc=1.45,Tr=.012,Lr=.004,Dc=1.07,Nc=.15;function at(e,t,n,o,r,i){e.setMaterial(i),W(e,t,n?[n.slice().reverse()]:void 0,()=>o,o-.004,r,r,Y)}var Or=(e,t)=>He(e,t/P);function Br(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<1e-9)return null;let s=-r/i*n,a=o/i*n;return[{x:e.x+s,y:e.y+a},{x:t.x+s,y:t.y+a},{x:t.x-s,y:t.y-a},{x:e.x-s,y:e.y-a}]}function Gc(e,t,n,o){let r=t.map(i=>[i.x*P,n,i.y*P]);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 Wt(e,t,n,o,r,i){let s=n/P,a=[{x:t.x-s,y:t.y-s},{x:t.x+s,y:t.y-s},{x:t.x+s,y:t.y+s},{x:t.x-s,y:t.y+s}];W(e,a,void 0,()=>r,o,i,z(i,.85),Y)}function st(e,t,n,o,r,i,s){let a=Br(t,n,o/P);a&&W(e,a,void 0,()=>i,r,s,z(s,.85),Y)}function zt(e){let t=ge(e),n={x:(t[0].x+t[2].x)/2,y:(t[0].y+t[2].y)/2},o=Math.hypot(t[1].x-t[0].x,t[1].y-t[0].y)||1,r=Math.hypot(t[3].x-t[0].x,t[3].y-t[0].y)||1,i={x:(t[1].x-t[0].x)/o,y:(t[1].y-t[0].y)/o},s={x:(t[3].x-t[0].x)/r,y:(t[3].y-t[0].y)/r};return{at:(l,f)=>({x:n.x+(i.x*l+s.x*f)/P,y:n.y+(i.y*l+s.y*f)/P}),lengthM:o*P,widthM:r*P}}function Fr(e,t,n){let o=fo(t);if(!o.length)return;let r=1/0,i=-1/0,s=1/0,a=-1/0;for(let w of t.points??[])r=Math.min(r,w.x),i=Math.max(i,w.x),s=Math.min(s,w.y),a=Math.max(a,w.y);let l=(t.rotation??0)*Math.PI/180,f=Math.cos(l),c=Math.sin(l),u=(r+i)/2,d=(s+a)/2,m=w=>l?{x:u+(w.x-u)*f-(w.y-d)*c,y:d+(w.x-u)*c+(w.y-d)*f}:w,h=Math.min(i-r,a-s)*P,p=Math.max(.04,Math.min(.3,h*.004))/P,y=0;e.setMaterial(0);for(let w of o){if(!w.fill)continue;let E=w.points.map(m);at(e,E,null,n+Tr+y*Lr,ne(w.fill)??Fe,0),y++}let x=o.filter(w=>!(w.fill&&w.ink===w.fill)),g=[...new Set(x.map(w=>w.ink??kt))];for(let w of g){let E=n+Tr+y++*Lr,M=ne(w)??Fe;for(let b of x){if((b.ink??kt)!==w)continue;let I=b.points.map(m),S=b.closed?I.length:I.length-1;for(let R=0;R<S;R++){let _=Br(I[R],I[(R+1)%I.length],p);_&&Gc(e,_,E,M)}}}}function Dr(e,t,n,o,r){if(t.length<3)return!1;let i=o+.006,s=r??Cc;if(n==="oval-cricket"){let a=t.reduce((M,b)=>M+b.x,0)/t.length,l=t.reduce((M,b)=>M+b.y,0)/t.length,f=M=>t.map(b=>({x:a+(b.x-a)*M,y:l+(b.y-l)*M})),c=8;for(let M=0;M<c;M++){let b=f(1-M/c),I=M===c-1?null:f(1-(M+1)/c);at(e,b,I,i,z(s,M%2?1.04:.96),4)}let u=t[0];for(let M of t)Math.hypot(M.x-a,M.y-l)>Math.hypot(u.x-a,u.y-l)&&(u=M);let d=Math.hypot(u.x-a,u.y-l)||1,m=(u.x-a)/d,h=(u.y-l)/d,p=-h,y=m,x=Math.min(1,2*d*P*Lc/_n.length),g=_n.length*x/2/P,w=_n.width*x/2/P,E=[[-g,-w],[g,-w],[g,w],[-g,w]].map(([M,b])=>({x:a+m*M+p*b,y:l+h*M+y*b}));return at(e,E,null,i+.004,vc,0),e.setMaterial(0),!0}if(n==="rink-hockey"){let a=Or(t,Nc);return at(e,a,null,i,kc,0),e.setMaterial(0),W(e,t,[a.slice().reverse()],()=>o+Dc,o,kr,z(kr,.9),Y),!0}if(n==="ring-boxing"&&t.length===4){let{at:a}=zt(t),l=[a(-3.05,-3.05),a(3.05,-3.05),a(3.05,3.05),a(-3.05,3.05)],f=[[.77,.19,.19],Fe,[.17,.42,.69],Fe];e.setMaterial(0),l.forEach((c,u)=>Wt(e,c,.07,o,o+Fc,f[u]));for(let c of Bc)for(let u=0;u<4;u++)st(e,l[u],l[(u+1)%4],.025,o+c-.025,o+c+.025,Fe);return!0}if(n==="court-tennis"&&t.length===4){let{at:a}=zt(t);e.setMaterial(0),st(e,a(0,-6.4),a(0,6.4),.015,o,o+.95,Kt),st(e,a(0,-6.4),a(0,6.4),.03,o+.95,o+1,Fe);for(let l of[-1,1])Wt(e,a(0,l*6.4),.05,o,o+1.07,Kt);return!0}if(n==="court-basketball"&&t.length===4){let{at:a,lengthM:l}=zt(t),f=Math.min(14,l/2-.5);e.setMaterial(0);for(let c of[-1,1]){let u=a(c*(f+1.2),0),d=a(c*(f-1.2),0);Wt(e,u,.12,o,o+3.4,Kt),st(e,u,d,.06,o+3.25,o+3.4,Kt),st(e,a(c*(f-1.2),-.9),a(c*(f-1.2),.9),.03,o+2.9,o+3.95,Fe)}return!0}if(n==="pitch-rugby"&&t.length===4){let{at:a,lengthM:l}=zt(t),f=l*(50/120);e.setMaterial(0);for(let c of[-1,1]){for(let u of[-2.8,2.8])Wt(e,a(c*f,u),.07,o,o+12,Fe);st(e,a(c*f,-2.8),a(c*f,2.8),.06,o+2.94,o+3.06,Fe)}return!0}if(n==="track-athletics"){let a=Or(t,Oc);return a.length<3?!1:(at(e,t,a,i,Tc,0),at(e,a,null,i,s,4),e.setMaterial(0),!0)}return!1}var Nr=[.19,.4,.15],jc=.012,Qt=2.4,Hc=1,Xc=.75,Uc=.15;function Ee(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:o,rotation:r}=e;if(!n||!o)return null;let i=(r??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),l=n/2,f=o/2;return[[-l,-f],[l,-f],[l,f],[-l,f]].map(([c,u])=>({x:t.x+c*s-u*a,y:t.y+c*a+u*s}))}function Vr(e,t,n,o,r,i,s=!1){let a=Ee(t);if(a){if(s){let l=Qe(o,r.boothTop),f=ke([...a]);W(e,we(f,Vc/P),[f.slice().reverse()],()=>n+.03,n,l,z(l,.8),Y);return}if(!(!t.points&&i&&Kc(e,a,n,o,i))){if(!t.points&&i&&a.length===4){Yc(e,a,n,o,i);return}W(e,a,void 0,()=>n+Qt,n,Qe(o,r.boothTop),r.boothWall,Y)}}}var Cn=1.1,Gr=[.9,.9,.88],Vc=.1,Zt=[.87,.87,.85],jr=.08;function Yr(e,t){let n=l=>({x:(e[l].x+e[(l+1)%4].x)/2,y:(e[l].y+e[(l+1)%4].y)/2}),o=0,r=1/0;for(let l=0;l<4;l++){let f=n(l),c=Math.hypot(f.x-t.x,f.y-t.y);c<r&&(r=c,o=l)}let i=[0,1,2,3].map(l=>e[(o+l)%4]),s=(l,f,c)=>({x:l.x+(f.x-l.x)*c,y:l.y+(f.y-l.y)*c});return{q:i,part:(l,f,c,u)=>{let d=s(i[0],i[1],l),m=s(i[0],i[1],f),h=s(i[3],i[2],l),p=s(i[3],i[2],f);return[s(d,h,c),s(m,p,c),s(m,p,u),s(d,h,u)]},depthM:Math.hypot(i[3].x-i[0].x,i[3].y-i[0].y)*P,widthM:Math.hypot(i[1].x-i[0].x,i[1].y-i[0].y)*P}}function Yc(e,t,n,o,r){let{q:i,part:s}=Yr(t,r),a=o??[.35,.42,.55],l=te(a,[.78,.78,.77],.62),f=te(a,[.95,.95,.94],.45);ee(e,i,n+Ue,n,l,z(l,.8)),ee(e,s(.05,.95,.72,.98),n+Cn-.05,n+Ue,f,z(f,.8)),ee(e,s(.03,.97,.7,1),n+Cn,n+Cn-.05,Gr,z(Gr,.9))}function Kc(e,t,n,o,r){if(t.length!==4)return!1;let{q:i,part:s,depthM:a,widthM:l}=Yr(t,r);if(a<1||l<1)return!1;let f=o??[.35,.42,.55],c=te(f,[.78,.78,.77],.62),u=n+Qt,d=jr/l,m=jr/a;ee(e,i,n+Ue,n,c,z(c,.8)),ee(e,s(0,1,1-m,1),u,n+Ue,Zt,z(Zt,.9));for(let[y,x]of[[0,d],[1-d,1]])ee(e,s(y,x,0,1-m),u,n+Ue,Zt,z(Zt,.9));ee(e,s(d,1-d,0,Math.min(.5,.06/a)),u,u-.3,f,z(f,.85));let h=Math.min(.4,.6/l),p=Math.min(.12,.3/a);return ee(e,s(.5-h,.5+h,.72-p,.72+p),n+Hc,n+Ue,te(f,[.95,.95,.94],.7),z(f,.75)),!0}function qt(e){if(e.shape==="round"){let c=e.radius;return c?Dt(e.center.x,e.center.y,c,c,24):null}let{width:t,height:n,rotation:o,center:r}=e;if(!t||!n)return null;let i=(o??0)*Math.PI/180,s=Math.cos(i),a=Math.sin(i),l=t/2,f=n/2;return[[-l,-f],[l,-f],[l,f],[-l,f]].map(([c,u])=>({x:r.x+c*s-u*a,y:r.y+c*a+u*s}))}function Kr(e,t,n,o,r,i=!0){let s=qt(t);if(!s)return;let a=s.reduce((d,m)=>d+m.x,0)/s.length,l=s.reduce((d,m)=>d+m.y,0)/s.length,f=d=>s.map(m=>({x:a+(m.x-a)*d,y:l+(m.y-l)*d})),c=i&&o?Qe(o,r.tableTop):Wc,u=n+Xc;W(e,s,void 0,()=>u,n+zc,c,z(c,.86),Y),W(e,f(.12),void 0,()=>u+.12,u,Hr,z(Hr,.8),Y)}var Wc=[.93,.92,.89],Hr=[.78,.66,.42],zc=.25,It={armM:1.1,widthM:.28,insideM:1.4,low:.043,high:.048};function Zc(e,t,n){let o=e.reduce((x,g)=>x+g.x,0)/4,r=e.reduce((x,g)=>x+g.y,0)/4,i=e[3].x-e[0].x,s=e[3].y-e[0].y,a=Math.hypot(i,s)||1;i/=a,s/=a,i*(t.x-o)+s*(t.y-r)<0&&(i=-i,s=-s);let l=-s,f=i,c=It.armM/P,u=It.widthM/P,d=a/2+It.insideM/P,m=n?-1:1,h=o+i*(d+(n?0:c)),p=r+s*(d+(n?0:c)),y=(x,g)=>({x:h+i*x*m+l*g,y:p+s*x*m+f*g});return[y(0,0),y(-c,c),y(-c-u,c),y(-u,0),y(-c-u,-c),y(-c,-c)]}function $c(e,t,n,o,r){let i=[.94,.95,.96];W(e,Zc(t,o,r),void 0,()=>n+It.high,n+It.low,i,i,Y)}function Wr(e,t,n,o,r,i,s,a,l=[]){let f=ie(t);if(!t.role&&(!t.fill||t.fill==="none"||t.fill==="transparent")||!f){St(e,t,n+o+jc);return}let u=a?a.kind==="stage":t.role==="stage",d=a?a.kind==="screen":t.role==="screen",m=a?{kind:u?"stage":"solid",heightM:a.topY-a.baseY}:Ae(t),h=a?.baseY??n,p=a?.topY??n+o;if(u&&s){let S=1/0,R=-1/0,_=1/0,k=-1/0;for(let O of f)O.x<S&&(S=O.x),O.x>R&&(R=O.x),O.y<_&&(_=O.y),O.y>k&&(k=O.y);s.push({cx:(S+R)/2*P,cz:(_+k)/2*P,y:p,halfX:Math.max((R-S)/2*P,.5),halfZ:Math.max((k-_)/2*P,.5)})}let y=ne(t.fill),x=t.role==="wall"||t.role==="entrance"||t.role==="exit",g=x?y?z(Pe(y,.12),.95):r.tierTop:u&&y?te(r.stageTop,z(Pe(y,.18),.9),.9):!t.role&&y?y:Qe(y,u?r.stageTop:r.decorTop),w=d?y:null,E=x?y?z(Pe(y,.12),.85):r.tierWall:u?y?te(r.stageWall,z(y,.58),.82):r.stageWall:d?w?te(z(w,1.42),[.24,.46,.82],.08):[.24,.46,.82]:Qe(ne(t.fill),r.decorWall);if(t.role==="wall"&&!a){_r(e,f,h,p,l,g,E,i),St(e,t,p+.012);return}if(d&&f.length===4&&p-h>.2){let S=An(f,h,p);if(!S)return;let{quad:R,side:_,trim:k,inner:O,panel:v}=S,A=[.12,.15,.18];for(let[C,T]of[[0,_],[1-_,1]])ee(e,pe(R,C,T),p,h,A,A);ee(e,O,h+k,h,A,A),ee(e,O,p,p-k,A,A),ee(e,v,p-k,h+k,E,E),St(e,t,p+.012);return}let M=y?z(Pe(y,.15),.82):E,b=y?z(Pe(y,.1),1.02):g;if(Cr(t.role)&&!a&&vr(e,t.role,f,h,p,M,b,i,t.heightM!==void 0))return;if((t.role==="sound"||a?.kind==="sound_desk")&&f.length===4&&p-h>.3){let S=ge(f),R=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,_=Math.min(.12,.09/Math.max(R,.001)),k=[.18,.21,.24],O=p-Math.min(.12,(p-h)*.15);for(let[v,A]of[[0,_],[1-_,1]])ee(e,pe(S,v,A),O,h,k,k);ee(e,S,p,O,g,k);return}if(t.role==="rail"&&f.length===4&&p>h){let S=ge(f),R=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,_=Math.max(1,Math.min(128,Math.ceil(R/1.4))),k=Math.min(.08,.055/Math.max(.055,R)),O=[.58,.64,.66];for(let v=0;v<=_;v++){let A=v/_,C=Math.min(1-k,Math.max(0,A-k/2));ee(e,pe(S,C,C+k),p,h,O,z(O,.8))}for(let v of[.52,1]){let A=h+(p-h)*v;ee(e,S,A,Math.max(h,A-.055),O,z(O,.8))}return}if(t.role==="goal"&&f.length===4){let S=ge(f),R=Math.hypot(S[1].x-S[0].x,S[1].y-S[0].y)*P,_=Math.min(.12,.1/Math.max(.1,R)),k=[.9,.94,.94];for(let[O,v]of[[0,_],[1-_,1]])ee(e,pe(S,O,v),Math.max(h,p-.1),h,k,k);ee(e,S,p,Math.max(h,p-.1),k,k);return}if(m.kind==="portal"&&f.length===4){let S=rt(f,h,p);if(!S)return;let{quad:R,side:_,face:k,openingTop:O}=S;for(let[v,A,C]of[[0,k,1],[k,1-k,.67],[1-k,1,1]]){let T=Mt(R,v,A),F=z(g,C),L=z(E,C);for(let[B,N]of[[0,_],[1-_,1]])ee(e,pe(T,B,N),O,h,F,L);ee(e,T,p,O,F,L)}(t.role==="entrance"||t.role==="exit")&&$c(e,R,h,i,t.role==="exit");return}if(m.kind==="suite"&&f.length===4){let S=f.map((k,O)=>{let v=f[(O+1)%4],A=(k.x+v.x)/2,C=(k.y+v.y)/2;return Math.hypot(A-i.x,C-i.y)}),R=S.indexOf(Math.min(...S)),_=[0,1,2,3].map(k=>f[(R+k)%4]);ee(e,pe(_,0,.08),p,h,g,E),ee(e,pe(_,.92,1),p,h,g,E),ee(e,Mt(_,.88,1),p,h,g,E),ee(e,_,p,Math.max(h,p-.18),g,E);return}if(u&&!t.stageKind?.startsWith("pitch-")&&p-h>.12){let S=p-Math.min(.06,(p-h)*.15);ee(e,f,S,h,g,E),ee(e,f,p,S,g,te(g,E,.2))}else ee(e,f,p,h,g,E);if((t.stageKind==="pitch-football"||t.stageKind==="pitch-rugby")&&f.length===4){e.setMaterial(4);let S=ge(f),R=te(y??Nr,Nr,y?.45:0);for(let _=0;_<12;_++){let k=pe(S,_/12,(_+1)/12),O=z(R,_%2?1.09:.91),v=k.map(A=>[A.x*P,p+.006,A.y*P]);e.tri(v[0],v[1],v[2],[0,1,0],O),e.tri(v[0],v[2],v[3],[0,1,0],O)}}t.stageKind&&t.stageKind!=="pitch-football"&&Dr(e,f,t.stageKind,p,y),u&&We(t.stageKind)&&Fr(e,t,p),e.setMaterial(d?1:0),St(e,t,p+.012)}function Jt(e){let{x:t,y:n,width:o,height:r}=e;if(!o||!r)return null;let i=t+o/2,s=n+r/2,a=(e.rotation??0)*Math.PI/180,l=Math.cos(a),f=Math.sin(a),c=o/2,u=r/2;return[[-c,-u],[c,-u],[c,u],[-c,u]].map(([d,m])=>({x:i+d*l-m*f,y:s+d*f+m*l}))}function Qc(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let o=n[1].trim();if(o==="none"||o==="transparent")return null;let r=o.match(/^url\(#([^)]+)\)$/);if(!r)return ne(o);let i=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${r[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!i)return null;let s=[];for(let a of i[1].matchAll(/stop-color="([^"]+)"/gi)){let l=ne(a[1].trim());l&&s.push(l)}return s.length?s.reduce((a,l,f)=>te(a,l,1/(f+1)),s[0]):null}function zr(e,t,n,o){if(t.layer==="foreground")return;let r=Jt(t);if(!r)return;let i=n+Uc,s=Qe(Qc(t.href),o.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(s=te(o.ground,s,a)),W(e,r,void 0,()=>i,n,s,te(s,o.decorWall,.5),Y)}function Zr(e,t,n,o,r){if(!t.points||t.points.length<3)return;let i=Ho(o,r.gaTop);W(e,t.points,t.holes,()=>n+Xr,n,i,r.gaWall,Y),el(e,t.points,n+Xr)}var Xr=.15,$t=[.72,.74,.76],vn=1.1,Ur=.12,kn=.05,qc=.06,Jc=2.4;function el(e,t,n){let o=ke([...t]),r=He(o,Ur/P),i=He(o,(Ur+kn)/P);if(r.length<3||i.length<3)return;for(let a of[n+vn,n+vn*.5])W(e,r,[i.slice().reverse()],()=>a,a-kn,$t,z($t,.85),Y);let s=qc/2/P;for(let a=0;a<r.length;a++){let l=r[a],f=r[(a+1)%r.length],c=Math.hypot(f.x-l.x,f.y-l.y)*P,u=Math.max(1,Math.round(c/Jc));for(let d=0;d<u;d++){let m=d/u,h=l.x+(f.x-l.x)*m,p=l.y+(f.y-l.y)*m,y=[{x:h-s,y:p-s},{x:h+s,y:p-s},{x:h+s,y:p+s},{x:h-s,y:p+s}];W(e,y,void 0,()=>n+vn-kn,n,$t,z($t,.8),Y)}}}var Tn=.6,$r=3,tl=.25;function nl(e,t){if(xe(t,e.x,e.y))return 0;let n=1/0;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[r],s=t[o],a=s.x-i.x,l=s.y-i.y,f=a*a+l*l||1,c=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*l)/f));n=Math.min(n,Math.hypot(e.x-(i.x+c*a),e.y-(i.y+c*l)))}return n}function Qr(e,t){let n=e.map(s=>({booth:s,ring:Ee(s)})).filter(s=>!!s.ring&&s.ring.length===4&&!s.booth.points),o=n.map(({ring:s})=>({minX:Math.min(...s.map(a=>a.x)),maxX:Math.max(...s.map(a=>a.x)),minY:Math.min(...s.map(a=>a.y)),maxY:Math.max(...s.map(a=>a.y))})),r=($r+Tn)/P,i=new Map;return n.forEach(({booth:s,ring:a},l)=>{let f={x:a.reduce((m,h)=>m+h.x,0)/4,y:a.reduce((m,h)=>m+h.y,0)/4},c=[0,1,2,3].map(m=>{let h=a[m],p=a[(m+1)%4],y={x:(h.x+p.x)/2,y:(h.y+p.y)/2},x=y.x-f.x,g=y.y-f.y,w=Math.hypot(x,g)||1,E={x:y.x+x/w*Tn/P,y:y.y+g/w*Tn/P},M=$r/P;return o.forEach((b,I)=>{I===l||E.x<b.minX-r||E.x>b.maxX+r||E.y<b.minY-r||E.y>b.maxY+r||(M=Math.min(M,nl(E,n[I].ring)))}),{open:M*P,toward:{x:y.x+x/w*10/P,y:y.y+g/w*10/P},focal:Math.hypot(y.x-t.x,y.y-t.y)}}),u=Math.max(...c.map(m=>m.open)),d=c.filter(m=>m.open>=u-tl).sort((m,h)=>m.focal-h.focal)[0];i.set(s.id,d.toward)}),i}var qr=Ce(require("polygon-clipping"),1);var ol=.45,rl=1500,il=200;function Jr(e,t){if(e.role!=="stage"||We(e.stageKind))return e;let n=ie(e);if(!n||n.length<3||Math.abs(ye(n))*P*P>rl)return e;let o=t.filter(s=>xe(n,s.x,s.y));if(!o.length||o.length>il)return e;let r=ol/P,i=o.map(s=>[[[s.x-r,s.y-r],[s.x+r,s.y-r],[s.x+r,s.y+r],[s.x-r,s.y+r],[s.x-r,s.y-r]]]);try{let s=qr.default.difference([[...n.map(f=>[f.x,f.y]),[n[0].x,n[0].y]]],...i),a=null,l=0;for(let f of s){let c=f[0].slice(0,-1).map(([d,m])=>({x:d,y:m})),u=Math.abs(ye(c));u>l&&(l=u,a=c)}return!a||a.length<3?e:{...e,kind:"polygon",points:a,rotation:0}}catch{return e}}var sl=Math.PI/180,oe=96,al=6,cl=60,ll=150,ei=.2,ul=.35;function fl(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/sl;return n<0?n+360:n}function en(e){if(!e.length)return NaN;let t=[...e].sort((n,o)=>n-o);return t[Math.floor(t.length/2)]}function tn(e,t,n=2){let o=e.length,r=new Float64Array(o);for(let i=0;i<o;i++){let s=0,a=0;for(let l=-n;l<=n;l++){let f=i+l;if(t)f=(f%o+o)%o;else if(f<0||f>=o)continue;s+=e[f],a++}r[i]=s/a}return r}function ti(e,t){let n=e.filter(d=>d.rows.length>=1);if(n.length<1)return null;let o=[],r=0,i=0,s=0;for(let d of n)for(let m of d.rows){for(let h of m.pts)r+=h.x,i+=h.y,s++;if(m.pts.length>=4){let h=fn(m.pts);h&&Number.isFinite(h.cx)&&Number.isFinite(h.cy)&&o.push({x:h.cx,y:h.cy})}}if(!s)return null;let a={x:r/s,y:i/s},l=a;if(o.length>=8){let d=en(o.map(x=>x.x)),m=en(o.map(x=>x.y)),h=0;for(let x of n)for(let g of x.rows)for(let w of g.pts){let E=Math.hypot(w.x-a.x,w.y-a.y);E>h&&(h=E)}let p=0,y=h*.2;for(let x of n)for(let g of x.rows)for(let w of g.pts)Math.hypot(w.x-d,w.y-m)<y&&p++;Math.hypot(d-a.x,m-a.y)<=h&&p/s<.01&&(l={x:d,y:m})}let f=[];for(let d of n){let m={sectionId:d.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let h of d.rows)for(let p of h.pts){let y=Math.hypot(p.x-l.x,p.y-l.y),x=Math.min(oe-1,Math.floor(fl(l,p)/(360/oe)));m.samples.push({r:y,bin:x,levelM:h.levelM}),y<m.rMin&&(m.rMin=y),y>m.rMax&&(m.rMax=y)}m.samples.length&&f.push(m)}if(!f.length)return null;f.sort((d,m)=>d.rMin+d.rMax-(m.rMin+m.rMax));let c=[];for(let d of f){let m=!1;for(let h of c){let p=Math.min(d.rMax,h.rMax)-Math.max(d.rMin,h.rMin),y=Math.min(d.rMax-d.rMin,h.rMax-h.rMin);if(y>1e-9&&p>=ul*y){h.members.push(d),h.rMin=Math.min(h.rMin,d.rMin),h.rMax=Math.max(h.rMax,d.rMax),m=!0;break}}m||c.push({members:[d],rMin:d.rMin,rMax:d.rMax})}let u=[];for(let d of c){let m=new Array(oe).fill(null);for(let v of d.members)for(let A of v.samples){let C=m[A.bin];C||(C={samples:[]},m[A.bin]=C),C.samples.push({r:A.r,levelM:A.levelM})}let h=m.map(v=>!!v);if(!h.filter(Boolean).length)continue;let y=[],x=[];for(let v of m){if(!v)continue;let A=1/0,C=-1/0;for(let T of v.samples)T.r<A&&(A=T.r),T.r>C&&(C=T.r);y.push(A),x.push(C)}let g=en(y),w=en(x);if(!(g>=ei*w)||!(w>0))continue;let E=[...y].sort((v,A)=>v-A);if(!(E[Math.floor(E.length*.1)]>=ei*w))continue;let b=m.map(v=>{if(!v)return null;let A=[...v.samples].sort((D,V)=>D.r-V.r),C=A[0].r,T=A[A.length-1].r,F=A[0].levelM,L=-1/0;for(let D of A)D.levelM>L&&(L=D.levelM);let B=[];for(let D of A){let V={r:D.r,l:D.levelM};for(;B.length&&Math.abs(B[B.length-1].r-V.r)<1e-9;){if(B[B.length-1].l<=V.l){V.skip=!0;break}B.pop()}if(!V.skip){for(;B.length>=2;){let X=B[B.length-2],Z=B[B.length-1];if((Z.r-X.r)*(V.l-X.l)-(Z.l-X.l)*(V.r-X.r)<=0)B.pop();else break}B.push(V)}}let N=B.map(D=>D.r),j=B.map(D=>D.l);return{inner:C,outer:T,front:F,top:L,profile:{rs:N,ls:j}}}),I=h.slice();for(let v=0;v<oe;v++){if(I[v])continue;let A=-1,C=-1,T=0;for(let U=1;U<=oe;U++){let J=(v-U+oe*2)%oe;if(I[J]){A=J;break}}for(let U=1;U<=oe;U++){let J=(v+U)%oe;if(I[J]){C=J,T=U;break}}if(A<0||C<0)continue;let F=0;for(let U=1;U<=oe;U++){let J=(v-U+oe*2)%oe;if(h[J]){F=U;break}}if(F-1+T>al)continue;let B=b[A],N=b[C],j=F/(F+T),D=B.inner+(N.inner-B.inner)*j,V=B.outer+(N.outer-B.outer)*j,X=B.front+(N.front-B.front)*j,Z=B.top+(N.top-B.top)*j;b[v]={inner:D,outer:V,front:X,top:Z,profile:{rs:[D,V],ls:[X,Z]}}}for(let v=0;v<oe;v++)b[v]&&(I[v]=!0);let S=360/oe,R=[],_=I.filter(Boolean).length,k=[];if(_===oe)k.push({start:0,len:oe});else{let v=0;for(;I[v];)v=(v+1)%oe;let A=-1;for(let C=0;C<=oe;C++){let T=(v+C)%oe,F=C<oe&&I[T];if(F&&A<0)A=T;else if(!F&&A>=0){let L=(T-A+oe)%oe||oe;k.push({start:A,len:L}),A=-1}}}for(let v of k){if(v.len*S<cl&&v.len<oe)continue;let A=v.len===oe,C=new Float64Array(v.len),T=new Float64Array(v.len),F=new Float64Array(v.len),L=new Float64Array(v.len),B=[];for(let U=0;U<v.len;U++){let J=b[(v.start+U)%oe];C[U]=J.inner,T[U]=J.outer,F[U]=J.front,L[U]=J.top,B.push(J.profile??{rs:[J.inner,J.outer],ls:[J.front,J.top]})}let N=tn(C,A),j=tn(T,A),D=tn(F,A),V=tn(L,A);for(let U=0;U<v.len;U++)N[U]>C[U]&&(N[U]=C[U]),j[U]<T[U]&&(j[U]=T[U]),N[U]>j[U]-1e-6&&(N[U]=Math.max(0,j[U]-1e-6)),V[U]<D[U]&&(V[U]=D[U]);let X={startBin:v.start,binCount:v.len,closed:A,innerR:N,outerR:j,frontLevelM:D,topLevelM:V,profiles:B},Z=(U,J,Q)=>{let ce=B[U],ae=ce.rs,G=ce.ls;if(J<=ae[0]){G[0]>Q&&(G[0]=Q);return}if(J>=ae[ae.length-1]){G[G.length-1]>Q&&(G[G.length-1]=Q);return}for(let H=0;H+1<ae.length;H++)if(J<=ae[H+1]){G[H]>Q&&(G[H]=Q),G[H+1]>Q&&(G[H+1]=Q);return}};for(let U=0;U<v.len;U++){let J=m[(v.start+U)%oe];if(J)for(let Q of J.samples){Z(U,Q.r,Q.levelM);let ce=A?(U-1+v.len)%v.len:U-1,ae=A?(U+1)%v.len:U+1;ce>=0&&Z(ce,Q.r,Q.levelM),ae<v.len&&Z(ae,Q.r,Q.levelM)}}R.push(X)}R.reduce((v,A)=>v+A.binCount*S,0)<ll||u.push({arcs:R,sectionIds:d.members.map(v=>v.sectionId),innerRMedian:g,outerRMedian:w})}if(!u.length)return null;if(u.sort((d,m)=>d.innerRMedian-m.innerRMedian),t){let d=u[u.length-1].outerRMedian;if(Math.hypot(t.x-l.x,t.y-l.y)>.9*d)return null}return{centre:l,binCount:oe,binStepDeg:360/oe,rings:u}}function ni(e,t,n,o){let r=e.binStepDeg,i=n/r-.5-t.startBin;i=(i%e.binCount+e.binCount)%e.binCount,i>t.binCount-1&&(t.closed?i=i-t.binCount<t.binCount-i?0:t.binCount-1:i=i-(t.binCount-1)<e.binCount-i?t.binCount-1:0);let s=Math.floor(i),a=t.closed?(s+1)%t.binCount:Math.min(t.binCount-1,s+1),l=i-s,f=c=>{let u=t.profiles[c],d=u.rs,m=u.ls;if(o<=d[0])return m[0];if(o>=d[d.length-1])return m[m.length-1];for(let h=0;h+1<d.length;h++)if(o<=d[h+1]){let p=d[h+1]-d[h],y=p>1e-9?(o-d[h])/p:0;return m[h]+(m[h+1]-m[h])*y}return m[m.length-1]};return f(s)*(1-l)+f(a)*l}function Ln(e,t,n,o,r,i,s,a,l,f=[],c=r){if(t.length!==n.length||t.length<2||i-r<1.5)return;let u=(p,y,x)=>{Be(e,p,y,x,f,s,a,{portalBase:c,ao:l})||W(e,p,void 0,()=>x,y,s,a,l)},d=(p,y,x)=>({x:p.x+(y.x-p.x)*x,y:p.y+(y.y-p.y)*x}),m=o?t.length:t.length-1,h=0;for(let p=0;p<m;p++){let y=(p+1)%t.length,x=Math.hypot(n[y].x-n[p].x,n[y].y-n[p].y)*$;if(x<1e-5)continue;let g=(b,I)=>[d(t[p],t[y],b),d(t[p],t[y],I),d(n[p],n[y],I),d(n[p],n[y],b)];u(g(0,1),r,r+.95),u(g(0,1),i-.22,i);let w=Math.ceil((h-.32)/6)*6,E=!1,M=!1;for(let b=w;b<h+x;b+=6){let I=Math.max(0,(b-h)/x),S=Math.min(1,(b+.32-h)/x);S<=I||(u(g(I,S),r+.95,i-.22),E||=I<1e-6,M||=S>1-1e-6)}if(!o&&(p===0&&!E||p===m-1&&!M)){let b=Math.min(1,.32/x);u(g(p===0?0:1-b,p===0?b:1),r+.95,i-.22)}h+=x}}var Ve=Ce(require("polygon-clipping"),1),wt=.65;function On(e,t){let n=1/0;for(let o of t)for(let r=0;r<o.length;r++){let i=o[r],s=o[(r+1)%o.length],a=s.x-i.x,l=s.y-i.y,f=Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*l)/(a*a+l*l||1)));n=Math.min(n,Math.hypot(e.x-i.x-f*a,e.y-i.y-f*l))}return n}var Bn=.01;function oi(e,t,n,o,r,i,s,a=[],l=!0,f={bays:[],walls:[]}){if(o-r<=1e-5)return;let c=o-r>=3,u=c?o-wt:r;e.setMaterial(5);let d=c?[]:a.filter(b=>{if(b.role!=="entrance"&&b.role!=="exit")return!1;let I=ie(b);if(!I)return!1;let S=rt(I,r,r+Ae(b).heightM);return S!==null&&S.openingTop<=o-.12});if((!d.length||!Be(e,t,u,o,d,i,s,{holes:n,portalBase:r}))&&W(e,t,n,()=>o,u,i,s,Y,void 0,()=>[0,1,0]),!c){e.setMaterial(0);return}let m=l&&f.bays.length?ml(t,n,He(t,Rt/P),f):null,h=6/P,p=.22/P,y=a.flatMap(b=>{if(b.role!=="entrance"&&b.role!=="exit")return[];let I=ie(b);return I?.length?[{minX:Math.min(...I.map(S=>S.x)),maxX:Math.max(...I.map(S=>S.x)),minY:Math.min(...I.map(S=>S.y)),maxY:Math.max(...I.map(S=>S.y))}]:[]}),x=Math.min(...t.map(b=>b.x)),g=Math.max(...t.map(b=>b.x)),w=Math.min(...t.map(b=>b.y)),E=Math.max(...t.map(b=>b.y));for(let b=x+h/2;b<g;b+=h)for(let I=w+h/2;I<E;I+=h){if(y.some(R=>b+p>=R.minX&&b-p<=R.maxX&&I+p>=R.minY&&I-p<=R.maxY))continue;let S=[{x:b-p,y:I-p},{x:b+p,y:I-p},{x:b+p,y:I+p},{x:b-p,y:I+p}];!be({x:b,y:I},t,n)||On({x:b,y:I},[t,...n??[]])<p*Math.SQRT2+(l?Rt/P:0)||m&&On({x:b,y:I},m.flat())<p*Math.SQRT2+Rt/P||W(e,S,void 0,()=>u,r,i,s,Y)}if(m){for(let[b,...I]of m)W(e,b,I,()=>u,r-Bn,i,s,Y);e.setMaterial(0);return}let M=He(t,Rt/P);if(l&&M.length>=3){let b=a.filter(R=>{if(R.role!=="entrance"&&R.role!=="exit")return!1;let _=ie(R);return!!_&&_.some(k=>!be(k,t,void 0)||On(k,[t])<=Rt/P)}),I=[M.slice().reverse()],S=r-Bn;(!b.length||!Be(e,t,S,u,b,i,s,{holes:I,portalBase:r+Bn}))&&W(e,t,I,()=>u,S,i,s,Y)}e.setMaterial(0)}var Fn=.25,Rt=Fn;function ml(e,t,n,o){if(n.length<3)return null;let r=s=>{let a=s.map(l=>[l.x,l.y]);return a.push(a[0]),a},i=s=>{let[a,...l]=s.map(f=>[r(f)]);return Ve.default.union(a,...l)};try{let s=[r(e),...(t??[]).map(r)],a=Ve.default.difference(s,[r(n)]),l=Ve.default.intersection(s,i(o.bays));if(!l.length)return null;let f=Ve.default.difference(Ve.default.intersection(s,i(o.walls)),l);return Ve.default.union(Ve.default.difference(a,l),f).map(u=>u.map(d=>d.slice(0,-1).map(([m,h])=>({x:m,y:h}))))}catch{return null}}var hl=.02,dl=.25,pl=1.2,bl=.6,yl=.45,xl=2.3,gl=Math.PI/180,ri=.005;function Te(e,t,n){let o=n*gl;return{x:e.x+t*Math.sin(o),y:e.y+t*Math.cos(o)}}function Ml(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let o=n.outerRMedian*.85;for(let r of e){if(r.role!=="wall")continue;let i=r.points&&r.points.length>=2?r.points:r.x!==void 0&&r.y!==void 0&&r.width!==void 0&&r.height!==void 0?[{x:r.x,y:r.y},{x:r.x+r.width,y:r.y},{x:r.x+r.width,y:r.y+r.height},{x:r.x,y:r.y+r.height}]:[];if(i.length<2)continue;let s=0;for(let a of i)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=o&&s++;if(s>=i.length/2)return!0}return!1}var Sl=24,Il=.01;function Rl(e,t,n,o,r,i,s,a,l){let f=n.binCount,c=Sl,u=$,d=i+.02,m=i-Il,h=[];for(let A=0;A<f;A++){let C=(n.startBin+A+.5)*t.binStepDeg,T=new Float64Array(c+1);for(let F=0;F<=c;F++){let L=o[A]+(r[A]-o[A])*F/c;T[F]=Math.max(d,ni(t,n,C,L)-dl)}h.push(T)}if(l){let A=0;for(let C=0;C+1<f;C++)for(let T=0;T<c;T++){let F=Te(t.centre,o[C]+(r[C]-o[C])*T/c,(n.startBin+C+.5)*t.binStepDeg),L=Te(t.centre,o[C+1]+(r[C+1]-o[C+1])*(T+1)/c,(n.startBin+C+1.5)*t.binStepDeg);A=Math.max(A,Math.hypot(L.x-F.x,L.y-F.y))}for(let C=0;C<f;C++){let T=(n.startBin+C+.5)*t.binStepDeg;for(let F=0;F<=c;F++){let L=Te(t.centre,o[C]+(r[C]-o[C])*F/c,T),B=l(L.x,L.y,A*1.01);B!==null&&(h[C][F]=Math.min(h[C][F],Math.max(m+ri,B-ri)))}}}let p=[s.bandTop[0]*a.top,s.bandTop[1]*a.top,s.bandTop[2]*a.top],y=[s.bandTop[0]*a.bottomCap,s.bandTop[1]*a.bottomCap,s.bandTop[2]*a.bottomCap],x=[s.bandWall[0]*a.top,s.bandWall[1]*a.top,s.bandWall[2]*a.top],g=[s.bandWall[0]*a.wallBottom,s.bandWall[1]*a.wallBottom,s.bandWall[2]*a.wallBottom],w=(A,C)=>{let T=(n.startBin+A+.5)*t.binStepDeg,F=o[A]+(r[A]-o[A])*C/c,L=Te(t.centre,F,T);return[L.x*u,h[A][C],L.y*u]};{let A=Math.tan(12*Math.PI/180);for(let C=0;C<6;C++){let T=!1;for(let L=0;L<f;L++)for(let B=c-1;B>=0;B--)h[L][B]>h[L][B+1]&&(h[L][B]=h[L][B+1],T=!0);let F=n.closed?f:f-1;for(let L=0;L<F;L++){let B=(L+1)%f;for(let N=0;N<=c;N++){let j=h[B][N]-h[L][N];if(Math.abs(j)>1)continue;let D=o[L]+(r[L]-o[L])*N/c,V=o[B]+(r[B]-o[B])*N/c,X=Te(t.centre,D,(n.startBin+L+.5)*t.binStepDeg),Z=Te(t.centre,V,(n.startBin+B+.5)*t.binStepDeg),U=A*Math.hypot(Z.x-X.x,Z.y-X.y)*u;j>U?(h[B][N]=h[L][N]+U,T=!0):-j>U&&(h[L][N]=h[B][N]+U,T=!0)}}if(!T)break}}let E=1,M=(A,C)=>{for(let T=0;T<=c;T+=4)if(Math.abs(h[A][T]-h[C][T])>E)return!0;return Math.abs(h[A][c]-h[C][c])>E},b=Math.tan(38*Math.PI/180),I=A=>(r[A]-o[A])/c*u,S=(A,C)=>h[A][C+1]-h[A][C]>b*Math.max(1e-6,I(A)),R=(A,C)=>{let T=n.closed?(A-1+f)%f:Math.max(0,A-1),F=n.closed?(A+1)%f:Math.min(f-1,A+1);Math.abs(h[T][C]-h[A][C])>E&&(T=A),Math.abs(h[F][C]-h[A][C])>E&&(F=A);let L=Math.max(0,C-1),B=Math.min(c,C+1);L<C&&S(A,L)&&(L=C),B>C&&S(A,C)&&(B=C);let N=w(T,C),j=w(F,C),D=w(A,L),V=w(A,B),X=j[0]-N[0],Z=j[1]-N[1],U=j[2]-N[2],J=V[0]-D[0],Q=V[1]-D[1],ce=V[2]-D[2],ae=Z*ce-U*Q,G=U*J-X*ce,H=X*Q-Z*J,q=Math.hypot(ae,G,H);return q>1e-12?(ae/=q,G/=q,H/=q,G<0&&(ae=-ae,G=-G,H=-H),[ae,G,H]):[0,1,0]},_=(A,C,T=!1)=>{let F=T&&Math.min(A[1],C[1])-i>=3,L=[A[0],F?A[1]-wt:m,A[2]],B=[C[0],F?C[1]-wt:m,C[2]],N=C[0]-A[0],j=C[2]-A[2],D=Math.hypot(N,j);if(!(D>1e-12))return;let V=[j/D,0,-N/D];e.tri(A,C,B,V,x,x,g),e.tri(A,B,L,V,x,g,g)},k=.05*Ie,O=A=>r[A]-o[A]<k,v=n.closed?f:f-1;for(let A=0;A<v;A++){let C=(A+1)%f;if(O(A)||O(C))continue;if(M(A,C)){let j=(n.startBin+A+1)*t.binStepDeg,D=(Q,ce)=>{let ae=(o[A]+o[C])/2,G=(r[A]+r[C])/2,H=ae+(G-ae)*ce/c,q=Te(t.centre,H,j);return[q.x*u,h[Q][ce],q.y*u]};for(let Q=0;Q<c;Q++){let ce=w(A,Q),ae=w(A,Q+1),G=D(A,Q),H=D(A,Q+1),q=R(A,Q),ue=R(A,Q+1);e.triN(ce,G,H,q,q,ue,p),e.triN(ce,H,ae,q,ue,ue,p);let fe=w(C,Q),he=w(C,Q+1),re=D(C,Q),se=D(C,Q+1),_e=R(C,Q),K=R(C,Q+1);e.triN(re,fe,he,_e,_e,K,p),e.triN(re,he,se,_e,K,K,p);let le=D(A,Q),me=D(A,Q+1),Ye=D(C,Q+1),Ke=D(C,Q),De=me[0]-le[0],Ne=me[2]-le[2],lt=Math.hypot(De,Ne);if(lt>1e-12){let At=[Ne/lt,0,-De/lt];e.tri(le,me,Ye,At,x),e.tri(le,Ye,Ke,At,x)}}let V=w(A,0),X=w(C,0),Z=w(C,c),U=w(A,c),J=Q=>[Q[0],m,Q[2]];Math.min(V[1],X[1])-i<3&&(e.tri(J(V),J(Z),J(X),[0,-1,0],y),e.tri(J(V),J(U),J(Z),[0,-1,0],y)),_(V,X,!0),_(U,Z,!0);continue}for(let j=0;j<c;j++){let D=R(A,j),V=R(C,j),X=R(C,j+1),Z=R(A,j+1);if(S(A,j)||S(C,j)){let ae=(me,Ye)=>{let Ke=(n.startBin+me+.5)*t.binStepDeg,De=o[me]+(r[me]-o[me])*(j+.5)/c,Ne=Te(t.centre,De,Ke);return[Ne.x*u,Ye,Ne.y*u]},G=w(A,j),H=w(C,j),q=ae(A,h[A][j]),ue=ae(C,h[C][j]);e.triN(G,H,ue,D,V,V,p),e.triN(G,ue,q,D,V,D,p);let fe=w(C,j+1),he=w(A,j+1),re=ae(A,h[A][j+1]),se=ae(C,h[C][j+1]);e.triN(re,se,fe,Z,X,X,p),e.triN(re,fe,he,Z,X,Z,p);let _e=ue[0]-q[0],K=ue[2]-q[2],le=Math.hypot(_e,K);if(le>1e-12){let me=[-K/le,0,_e/le];e.tri(q,ue,se,me,x),e.tri(q,se,re,me,x)}continue}let U=w(A,j),J=w(C,j),Q=w(C,j+1),ce=w(A,j+1);e.triN(U,J,Q,D,V,X,p),e.triN(U,Q,ce,D,X,Z,p)}let T=w(A,0),F=w(C,0),L=w(C,c),B=w(A,c),N=j=>[j[0],m,j[2]];Math.min(T[1],F[1])-i<3&&(e.tri(N(T),N(L),N(F),[0,-1,0],y),e.tri(N(T),N(B),N(L),[0,-1,0],y)),_(T,F,!0),_(B,L,!0)}if(!n.closed)for(let A of[0,f-1])for(let C=0;C<c;C++)_(w(A,C),w(A,C+1))}function ii(e,t,n){let{bottomY:o,colors:r,ao:i}=n,s=new Float64Array(t.binCount).fill(-1/0);for(let c of t.rings)for(let u of c.arcs){let d=new Float64Array(u.binCount),m=new Float64Array(u.binCount);for(let p=0;p<u.binCount;p++){let y=(u.startBin+p)%t.binCount,x=Math.max(0,u.innerR[p]-Re);d[p]=Math.max(x,s[y]+.001),m[p]=Math.max(d[p]+.001,u.outerR[p]+Re)}let h=0;for(let p=0;p<u.binCount;p++){let y=u.topLevelM[p]-o;y>h&&(h=y)}h>=pl&&Rl(e,t,u,d,m,o,r,i,n.standTopNear);for(let p=0;p<u.binCount;p++){let y=(u.startBin+p)%t.binCount;m[p]>s[y]&&(s[y]=m[p])}}if(n.deriveShell===!1||Ml(n.shapes,t))return;let a=t.rings[t.rings.length-1],l=bl*Ie,f=yl*Ie;for(let c of a.arcs){let u=[],d=[];for(let R=0;R<c.binCount;R++){let _=(c.startBin+R+.5)*t.binStepDeg,k=c.outerR[R]+Re+l;u.push(Te(t.centre,k,_)),d.push(Te(t.centre,k+f,_))}let m=-1/0;for(let R=0;R<c.binCount;R++)c.topLevelM[R]>m&&(m=c.topLevelM[R]);let h=m+xl,p=c.closed?d:[...d,...u.slice().reverse()],y=c.closed?[u.slice().reverse()]:void 0,x=te(r.shellWall,[.66,.71,.72],.62),g=(R,_,k,O,v)=>{let A=Math.abs(O-m)<1e-6?O-hl:O;Be(e,R,k,A,n.shapes,r.shellTop,v,{holes:_,portalBase:o,ao:i})||W(e,R,_,()=>A,k,r.shellTop,v,i)},w=Math.max(1,Math.ceil((m-o)/4.5)),E=(m-o)/w,M=new Set,b=n.tierFrontLevels??t.rings.map(R=>{let _=R.arcs.flatMap(k=>Array.from(k.frontLevelM)).filter(Number.isFinite).sort((k,O)=>k-O);return _[Math.floor(_.length/2)]});for(let R of b)Number.isFinite(R)&&R-o>=3&&R<m&&M.add(Math.max(0,Math.min(w-1,Math.floor((R-o)/E))));let I=Math.min(...b.filter(R=>Number.isFinite(R)&&R-o>=3&&R<m));for(let R=0;R<w;R++)o+(R+1)*E<=I-wt&&Number.isFinite(I)&&M.add(R);for(let R=0;R<w;R++){let _=o+(m-o)*R/w,k=o+(m-o)*(R+1)/w;M.has(R)&&k-_>=3.2?(g(p,y,_,_+.45,x),Ln(e,u,d,c.closed,_+.45,k-.16,r.shellTop,x,i,n.shapes,o)):g(p,y,_,k-.16,x),g(p,y,k-.16,k,z(x,.62))}Ln(e,u,d,c.closed,m,h,r.shellTop,x,i,n.shapes,o);let S=8;for(let R=1;R<d.length;R++){if(S+=Math.hypot(d[R].x-d[R-1].x,d[R].y-d[R-1].y)*$,S<8)continue;S=0;let _=d[R],k=d[R-1],O=_.x-k.x,v=_.y-k.y,A=Math.max(1,Math.hypot(O,v)),C=O/A*.16*Ie,T=v/A*.16*Ie,F=Math.max(1,Math.hypot(_.x-t.centre.x,_.y-t.centre.y)),L=(_.x-t.centre.x)/F*.24*Ie,B=(_.y-t.centre.y)/F*.24*Ie,N=[{x:_.x-C,y:_.y-T},{x:_.x+C,y:_.y+T},{x:_.x+C+L,y:_.y+T+B},{x:_.x-C+L,y:_.y-T+B}];g(N,void 0,o,m,z(x,1.12))}}}var wl=2.5,si=.65,Pl=2,Al=.03;function El(e,t){let n=()=>{let o=t;for(;e.length>2;){let r=e[0],i=e[1],s=Math.hypot(i.x-r.x,i.y-r.y);if(s>o){e[0]={x:r.x+(i.x-r.x)/s*o,y:r.y+(i.y-r.y)/s*o};return}o-=s,e.shift()}};n(),e.reverse(),n(),e.reverse()}function Gn(e,t,n){let o=new Map;for(let i of e){let s=o.get(i.blockId);(!s||i.depth<s.depth)&&o.set(i.blockId,i)}let r=[];for(let[i,s]of o){if(s.y-n<wl||s.pts.length<2)continue;let a=s.pts.map(c=>{let u=c.x-t.x,d=c.y-t.y,m=Math.max(1,Math.hypot(u,d));return{x:c.x-u/m*si/P,y:c.y-d/m*si/P}}),l=[],f=[a[0]];for(let c=1;c<a.length;c++){let u=a[c-1],d=a[c];Math.hypot(d.x-u.x,d.y-u.y)*P>Pl?(f.length>=2&&l.push(f),f=[d]):f.push(d)}f.length>=2&&l.push(f);for(let c of l)El(c,Al/P);l.length&&r.push({blockId:i,y:s.y,runs:l})}return r}var ai=.1,_l=1.1,Cl=.22,Dn=.95,Nn=.05,ci=1.8;function li(e,t,n,o){let r=[.72,.72,.69],i=[.48,.55,.57];for(let s of Gn(t,n,o)){let a=s.y;for(let l of s.runs){let f=ci;for(let c=1;c<l.length;c++){let u=l[c-1],d=l[c],m=d.x-u.x,h=d.y-u.y,p=Math.hypot(m,h);if(p<1e-5)continue;let y=x=>{let g=-h/p*x/P/2,w=m/p*x/P/2;return[{x:u.x+g,y:u.y+w},{x:d.x+g,y:d.y+w},{x:d.x-g,y:d.y-w},{x:u.x-g,y:u.y-w}]};if(W(e,y(Cl),void 0,()=>a+ai,a-_l,r,r,Y),W(e,y(Nn),void 0,()=>a+Dn,a+Dn-Nn,i,i,Y),f+=p*P,f>=ci||c===l.length-1){f=0;let x=.028/P,g=[{x:u.x-x,y:u.y-x},{x:u.x+x,y:u.y-x},{x:u.x+x,y:u.y+x},{x:u.x-x,y:u.y+x}];W(e,g,void 0,()=>a+Dn-Nn,a+ai,i,i,Y)}}}}}var vl=.9,kl=1.5,Tl=.3;function ui(e,t,n){let o=[],r=[],i=vl/P,s=kl/P,a=Tl/P;for(let l of e)for(let f of l.runs){if(f.length<2)continue;let c=f.slice(),u=(y,x)=>{let g=c[y],w=c[x],E=Math.hypot(g.x-w.x,g.y-w.y)||1;c[y]={x:g.x+(g.x-w.x)/E*a,y:g.y+(g.y-w.y)/E*a}};u(0,1),u(c.length-1,c.length-2);let d=c.map((y,x)=>{let g=c[Math.max(0,x-1)],w=c[Math.min(c.length-1,x+1)],E=w.x-g.x,M=w.y-g.y,b=Math.hypot(E,M)||1,I=-M/b,S=E/b;return I*(y.x-t.x)+S*(y.y-t.y)<0&&(I=-I,S=-S),{nx:I,ny:S}}),m=c.map((y,x)=>({x:y.x-d[x].nx*s,y:y.y-d[x].ny*s})),h=c.map((y,x)=>({x:y.x+d[x].nx*i,y:y.y+d[x].ny*i})),p=c.map((y,x)=>({x:y.x+d[x].nx*(i+n/P),y:y.y+d[x].ny*(i+n/P)}));o.push([...m,...h.slice().reverse()]),r.push([...h,...p.reverse()])}return{bays:o,walls:r}}var jn=.88,nn=.27,Ll=1.2,Ol=.01;function fi(e,t,n,o,r){let i=[.67,.71,.68],s=[i[0]*jn,i[1]*jn,i[2]*jn],a=l=>!!r&&r.some((f,c)=>c!==l&&f?.belowY!=null&&Math.abs(f.belowY-t[l].y)<1e-6&&t[c].blockId===t[l].blockId);for(let l=0;l<t.length;l++){let f=t[l];if(!(f.pts.length<2))for(let c of[0,f.pts.length-1]){let u=f.pts[c],d=f.pts[c===0?1:c-1],m=u.x-d.x,h=u.y-d.y,p=Math.hypot(m,h);if(p<1e-5)continue;m/=p,h/=p;let y=1/0;for(let C=0;C<n.length;C++){let T=n[C],F=n[(C+1)%n.length],L=F.x-T.x,B=F.y-T.y,N=m*B-h*L;if(Math.abs(N)<1e-8)continue;let j=T.x-u.x,D=T.y-u.y,V=(j*B-D*L)/N,X=(j*h-D*m)/N;V>0&&X>=0&&X<=1&&(y=Math.min(y,V))}let x=.3/P,g=y-.04/P;if(!Number.isFinite(y)||y*P>2||g-x<.12/P)continue;let w=!!o&&a(l),E=r?.[l]?.pitch,M=w&&E&&Number.isFinite(E)?Math.min(Ll/P,Math.max(nn/P,E-nn/P-Ol/P)):nn/P,b=-h,I=m;o&&b*(o.x-u.x)+I*(o.y-u.y)<0&&(b=-b,I=-I);let S=nn/P,R=[{x:u.x+m*x+b*S,y:u.y+h*x+I*S},{x:u.x+m*g+b*S,y:u.y+h*g+I*S},{x:u.x+m*g-b*M,y:u.y+h*g-I*M},{x:u.x+m*x-b*M,y:u.y+h*x-I*M}];if(!R.every(C=>xe(n,C.x,C.y)))continue;let _=r?.[l]?.belowY,k=_==null?0:f.y-_,O=!!o&&k>.03&&k<=.65;if(O&&o){let C=(T,F)=>Math.hypot((T.x+F.x)/2-o.x,(T.y+F.y)/2-o.y);C(R[0],R[1])>C(R[3],R[2])&&(R=[R[3],R[2],R[1],R[0]])}let v=O?Math.ceil((k-1e-8)/.2):1,A=(C,T,F)=>({x:C.x+(T.x-C.x)*F,y:C.y+(T.y-C.y)*F});for(let C=0;C<v;C++){let T=C/v,F=(C+1)/v,L=[A(R[0],R[3],T),A(R[1],R[2],T),A(R[1],R[2],F),A(R[0],R[3],F)],B=f.y+.008-(O?k*(1-F):0);W(e,L,void 0,()=>B,B-(O?k/v+.1:.16),i,s,Y)}}}}function mi(e,t,n,o,r,i,s,a,l=!1){if(!t.outline||t.outline.length<3)return;let f=n.baseHeightM,c=n.objects.filter(g=>g.type==="shape"&&(g.role==="entrance"||g.role==="exit")),u=Xo(o,a.tierTop);if(!r)return;let d=g=>r.deckAt(g.x,g.y),m=mr(t,s),h=m[0]??t.outline;if(r.rowLevels.length>=2){let g=Ht(r.rowLevels),w=hr(ar(r.rowLevels,n.focal,g),m),E=ui(Gn(r.rowLevels,n.focal,f),n.focal,Fn);for(let b of w){let I=Math.max(f,b.topY-hi);for(let S of i.subtract(b.outline,I))oi(e,S,b.holes,I,f,a.tierTop,a.tierWall,c,!l,E)}w.length||W(e,h,t.holes,()=>r.landingY,f,u,a.tierWall,Y);let M={tread:[u[0]*Y.top,u[1]*Y.top,u[2]*Y.top],riser:[u[0]*.72,u[1]*.72,u[2]*.72]};for(let b of m.length?m:[h])lr(e,r.rowLevels,n.focal,r.landingY,M,b,g);li(e,r.rowLevels,n.focal,f),fi(e,r.rowLevels,t.outline,n.focal,g);return}let p=r.flat?1/0:Rr,y=g=>r.normalAt(g.x,g.y),x=r.flat?r.landingY:void 0;for(let g of i.subtract(h,x))W(e,g,t.holes,d,f,u,a.tierWall,Y,p,y)}function Bl(e,t,n){let o=new Set;for(let s of e.objects)s.type==="section"&&o.add(s.id);let r=new Map;for(let s=0;s<t.length;s++){let a=n.seatOwner[s];if(!a||!o.has(a))continue;let l=n.bySection.get(a);if(l&&l.rowLevels.length>=2)continue;let f=t[s];if(f.kind==="booth")continue;let c=r.get(a);c||(c=new Map,r.set(a,c));let u=f.rowId||`__seat-${s}`,d=c.get(u);d||(d={pts:[],levelM:0,n:0},c.set(u,d)),d.pts.push({x:f.x,y:f.y}),d.levelM+=n.seatDeckY(s),d.n++}let i=[];for(let s of e.objects){if(s.type!=="section")continue;let a=n.bySection.get(s.id);if(a&&a.rowLevels.length>=2){let f=a.rowLevels.filter(c=>!c.patch).map(c=>({pts:c.pts,levelM:c.y}));f.length>=2&&i.push({sectionId:s.id,rows:f});continue}let l=r.get(s.id);l&&i.push({sectionId:s.id,rows:[...l.values()].map(f=>({pts:f.pts,levelM:f.levelM/f.n}))})}return i}function Fl(e,t){let n=1/0;for(let o=0;o<t.length;o++){let r=t[o],i=t[(o+1)%t.length],s=i.x-r.x,a=i.y-r.y,l=Math.max(0,Math.min(1,((e.x-r.x)*s+(e.y-r.y)*a)/(s*s+a*a||1)));n=Math.min(n,Math.hypot(e.x-r.x-l*s,e.y-r.y-l*a))}return n}var hi=.02;function Dl(e,t){let n=e.objects.filter(o=>o.type==="section"&&!!o.outline&&o.outline.length>=3).flatMap(o=>{let r=t.bySection.get(o.id);if(!r)return[];let i=1/0,s=-1/0,a=1/0,l=-1/0;for(let c of o.outline)c.x<i&&(i=c.x),c.x>s&&(s=c.x),c.y<a&&(a=c.y),c.y>l&&(l=c.y);let f=r.landingY;for(let c of r.rowLevels)f=Math.min(f,c.y-hi);return[{outline:o.outline,holes:o.holes,surface:r,floorTop:f,minX:i,maxX:s,minY:a,maxY:l}]});return(o,r,i)=>{let s=null;for(let a of n){if(o<a.minX-i||o>a.maxX+i||r<a.minY-i||r>a.maxY+i)continue;let l={x:o,y:r};if(!be(l,a.outline,a.holes)&&Fl(l,a.outline)>i)continue;let f=Math.min(a.surface.deckAt(o,r),a.floorTop);(s===null||f<s)&&(s=f)}return s}}var Nl=3,Gl=.4;function di(e,t,n,o,r,i,s=!0){let a=Bl(t,n,o);if(a.length<Nl)return;let l=ti(a,t.focal);if(!l)return;let f=Math.max(0,...l.rings.map(c=>c.arcs.reduce((u,d)=>u+d.binCount,0)))/l.binCount;e.setMaterial(5),ii(e,l,{bottomY:t.baseHeightM,tierFrontLevels:a.map(c=>Math.min(...c.rows.map(u=>u.levelM))),colors:{bandTop:z(r.tierTop,.8),bandWall:r.tierWall,shellTop:i??z(r.tierWall,1.15),shellWall:i??r.tierWall},ao:Y,shapes:t.objects.filter(c=>c.type==="shape"),deriveShell:s&&f>=Gl,standTopNear:Dl(t,o)}),e.setMaterial(0)}var pi=4;var jl=[[/\b(wc|toilets?|restrooms?|washrooms?|lavatory|loo)\b/i,"restroom"],[/\b(bar|drinks|pub|cocktails?)\b/i,"bar"],[/\b(food|concessions?|snacks?|kiosk|caf[eé]|kitchen|catering)\b/i,"concession"],[/\b(coat ?check|cloak ?room|cloakroom|coats)\b/i,"coat"],[/\b(screen|led wall|projection|video wall)\b/i,"screen"],[/\b(sound|foh|mixing desk|control booth)\b/i,"sound"],[/\b(entrance|entry|way in|gate)\b/i,"entrance"],[/\b(exit|way out)\b/i,"exit"],[/\b(pillar|column|obstruction)\b/i,"obstruction"],[/\b(walls?|outline|boundary|perimeter)\b/i,"wall"]],Hl=1.2,Xl=12;function bi(e){if(e.heightM!==void 0)return!1;let t=ie(e);if(!t||t.length<3)return!1;let n=0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length];n+=Math.hypot(s.x-i.x,s.y-i.y)}return n*$<Xl*2?!1:2*Pt(t)/n*$<=Hl}function Hn(e){if(!e)return null;for(let[t,n]of jl)if(t.test(e))return n;return null}var xi="auto-rows-";function gi(e){return e.id.startsWith(xi)&&!e.label}var Ul=1.15,Vl=.09,Mi=6,Yl=34,Kl=.35,Wl=6,zl=.35,Zl=.75,$l=12,Ql=2.5,ql=40,Jl=[18,24],eu=[12,16],yi=14,tu=.8,nu=.6,ou=5,ru=.3,Si=.4,Ii=2,iu=400,su=2.6,au=.8,cu=4,lu=26,uu=.7,fu=.5,mu=.985,hu=1.5,du=2.2,pu=3,bu=25,yu=.985,xu=2,gu=6,Mu=3,Su=.1,Iu=1.5,Ru=1.6,wu=6e3,Pu=.6,Au="#c3c7cd",Xn=300,Eu=240;function _u(e,t,n,o){if(!e.fill||!/^#[0-9a-f]{6}$/i.test(e.fill))return null;let r=Vn([...t]),i=new Set;for(let c of o)i.add(Math.floor(Math.atan2(c.y-r.y,c.x-r.x)*180/Math.PI/10));if(i.size*10<Eu)return null;let{h:s,s:a,l}=Lo(To(e.fill));return s<70/360||s>170/360||a<.2||l<.08||l>.75||n.some(c=>c!==e&&c.type==="shape"&&ie(c)?.some(u=>Wn(u,t)))?null:e.kind==="ellipse"?"oval-cricket":e.kind==="rect"?"pitch-football":null}var Cu="Estimated from the drawing; confirm with the venue.",Yn=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},Vn=e=>({x:e.reduce((t,n)=>t+n.x,0)/e.length,y:e.reduce((t,n)=>t+n.y,0)/e.length}),Pt=e=>{let t=0;for(let n=0;n<e.length;n++){let o=e[n],r=e[(n+1)%e.length];t+=o.x*r.y-r.x*o.y}return Math.abs(t)/2};function vu(e){return e.height!==void 0||e.rake!==void 0||e.elevation!==void 0||e.surfaceKind!==void 0}function Kn(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 Wn(e,t){let n=!1;for(let o=0,r=t.length-1;o<t.length;r=o++){let i=t[o],s=t[r];i.y>e.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n)}return n}function zn(e,t){let n=t[0],o=1/0;for(let r=0;r<t.length;r++){let i=t[r],s=t[(r+1)%t.length],a=s.x-i.x,l=s.y-i.y,f=a*a+l*l,c=f>0?Math.max(0,Math.min(1,((e.x-i.x)*a+(e.y-i.y)*l)/f)):0,u={x:i.x+a*c,y:i.y+l*c},d=Math.hypot(e.x-u.x,e.y-u.y);d<o&&(o=d,n=u)}return n}function Ri(e,t){let n=0,o=0;for(let r of e.values()){if(r.length<3)continue;let i=r[0],s=r[r.length-1],a=s.x-i.x,l=s.y-i.y,f=Math.hypot(a,l);if(f<1e-6)continue;let c={x:(i.x+s.x)/2,y:(i.y+s.y)/2},u=zn(c,t),d=u.x-c.x,m=u.y-c.y,h=Math.hypot(d,m);h<1e-6||(o+=Math.abs((-l*d+a*m)/(f*h))*r.length,n+=r.length)}return n?o/n:0}function ku(e,t,n){let o=e.filter(p=>p.type==="shape"),r=o.find(p=>p.role==="stage");if(r){let p=ie(r);return p?{shape:r,centre:Vn(p),outline:p,inferred:!1}:null}if(!n.length)return null;let i=1/0,s=-1/0,a=1/0,l=-1/0;for(let p of n)i=Math.min(i,p.x),s=Math.max(s,p.x),a=Math.min(a,p.y),l=Math.max(l,p.y);let f=(s-i)*(l-a),c=[];for(let p of o){if(p.role)continue;let y=ie(p);if(!y)continue;let x=Pt(y);if(x*$*$<6||x>f)continue;let g=Math.min(...y.map(R=>R.x)),w=Math.max(...y.map(R=>R.x)),E=Math.min(...y.map(R=>R.y)),M=Math.max(...y.map(R=>R.y)),b=0;for(let R of n)R.x>g&&R.x<w&&R.y>E&&R.y<M&&Wn(R,y)&&b++;if(b>n.length*.05)continue;let I=Vn(y),S=Ri(t,y);S>=tu&&c.push({shape:p,centre:I,outline:y,score:S,area:x,box:[g,E,w,M]})}let u=(p,y)=>y!==p&&y.area>p.area&&p.box[0]>=y.box[0]-1e-6&&p.box[1]>=y.box[1]-1e-6&&p.box[2]<=y.box[2]+1e-6&&p.box[3]<=y.box[3]+1e-6,d=c.filter(p=>!c.some(y=>u(p,y))),m=Math.max(0,...d.map(p=>p.score)),h=d.filter(p=>p.score>=m-.03).sort((p,y)=>y.area-p.area)[0]??null;return h?{shape:h.shape,centre:h.centre,outline:h.outline,inferred:!0}:null}function Tu(e,t,n){if(!n||n.length<3)return Math.hypot(e.x-t.x,e.y-t.y);let o=zn(e,n);return Math.hypot(e.x-o.x,e.y-o.y)}function wi(e){let t=[...e].sort((i,s)=>i.x-s.x||i.y-s.y);if(t.length<3)return t;let n=(i,s,a)=>(s.x-i.x)*(a.y-i.y)-(s.y-i.y)*(a.x-i.x),o=[];for(let i of t){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],i)<=0;)o.pop();o.push(i)}let r=[];for(let i=t.length-1;i>=0;i--){let s=t[i];for(;r.length>=2&&n(r[r.length-2],r[r.length-1],s)<=0;)r.pop();r.push(s)}return[...o.slice(0,-1),...r.slice(0,-1)]}function Lu(e){if(!e.length||e.length>wu)return[];let t=[...Kn(e).values()],n=t.map((a,l)=>l),o=a=>n[a]===a?a:n[a]=o(n[a]),r=Ru/$,i=t.map(a=>({minX:Math.min(...a.map(l=>l.x))-r,maxX:Math.max(...a.map(l=>l.x))+r,minY:Math.min(...a.map(l=>l.y))-r,maxY:Math.max(...a.map(l=>l.y))+r}));for(let a=0;a<t.length;a++)for(let l=a+1;l<t.length;l++){let f=i[a],c=i[l];if(f.maxX<c.minX||c.maxX<f.minX||f.maxY<c.minY||c.maxY<f.minY)continue;t[a].some(d=>t[l].some(m=>Math.hypot(d.x-m.x,d.y-m.y)<=r))&&(n[o(a)]=o(l))}let s=new Map;return t.forEach((a,l)=>{let f=o(l),c=s.get(f);c?c.push(...a):s.set(f,[...a])}),[...s.values()].filter(a=>new Set(a.map(l=>l.rowId)).size>=2)}function Ou(e,t,n){if(!t.length)return null;let o=t.filter(S=>n.tableIds.has(S.rowId)||S.kind==="booth").length>t.length/2,r=Kn(t),i=!n.outline||Ri(r,n.outline)>=nu,s=0,a=0;for(let S of r.values()){if(S.length<2)continue;let R=S[0],_=S[S.length-1],k=_.x-R.x,O=_.y-R.y,v=Math.hypot(k,O);if(v<1e-6)continue;let A={x:(R.x+_.x)/2,y:(R.y+_.y)/2},C=i?n.outline?zn(A,n.outline):n.focal:n.middle,T=-O/v,F=k/v;T*(C.x-A.x)+F*(C.y-A.y)<0&&(T=-T,F=-F),s+=T*S.length,a+=F*S.length}let l={x:t.reduce((S,R)=>S+R.x,0)/t.length,y:t.reduce((S,R)=>S+R.y,0)/t.length};if(Math.hypot(s,a)<1e-9){let S=i?n.focal:n.middle;s=S.x-l.x,a=S.y-l.y}let f=Math.hypot(s,a)||1,c={x:s/f,y:a/f},u=S=>-(S.x*c.x+S.y*c.y),d=S=>-S.x*c.y+S.y*c.x,m=1/0,h=-1/0,p=1/0,y=-1/0,x=1/0,g=new Map;for(let S of t){let R=u(S),_=d(S);m=Math.min(m,R),h=Math.max(h,R),p=Math.min(p,_),y=Math.max(y,_),i&&(x=Math.min(x,Tu(S,n.focal,n.outline)));let k=S.logicalRowId??S.rowId,O=g.get(k);O?O.push(R):g.set(k,[R])}i||(x=Math.max(0,m-u(n.middle)));let w=[...g.values()].map(S=>Yn(S)).sort((S,R)=>S-R),E=[];if(!o)for(let S of w)E.length&&S-E[E.length-1]<zl/$||E.push(S);let M=vu(e),b=Ge(e,{floorBaseHeightM:n.baseHeightM}),I={id:e.id,section:e,authored:M,plane:n,facing:c,facesAction:i,hull:wi(t),sample:t.filter((S,R)=>R%Math.ceil(t.length/iu)===0),frontD:m,backD:h,latMin:p,latMax:y,frontDistance:x,rowDepths:E,rowCount:E.length,level:0,height:b.height,rake:M?b.rake:0,backHeight:0};return I.backHeight=I.height+(h-m)*$*Math.tan(I.rake*Math.PI/180),I}function Bu(e,t,n,o){if(e.length<2)return 0;let r=Math.max(1,t*$),i=n+Ul-o,s=0,a=0;for(let f=1;f<e.length;f++){let c=Math.max(Zl,(e[f]-e[f-1])*$),u=(i+Vl)*(r+c)/r;s+=u-i,a+=c,i=u,r+=c}let l=Math.atan(s/a)*180/Math.PI;return Math.round(Math.max(Mi,Math.min(Yl,l))*10)/10}function Fu(e,t,n=!1){if(!n&&e.facing.x*t.facing.x+e.facing.y*t.facing.y<ru)return null;let o=-1/0,r=1/0,i=-1/0;for(let d of t.hull){o=Math.max(o,-(d.x*e.facing.x+d.y*e.facing.y));let m=-d.x*e.facing.y+d.y*e.facing.x;r=Math.min(r,m),i=Math.max(i,m)}if(Math.min(e.latMax,i)-Math.max(e.latMin,r)<(n?1e-6:Si*(e.latMax-e.latMin)))return null;let a=Ii/$,l=new Map,f=new Map;for(let d of e.sample){let m=Math.floor((-d.x*e.facing.y+d.y*e.facing.x)/a),h=-(d.x*e.facing.x+d.y*e.facing.y);l.set(m,Math.min(l.get(m)??1/0,h))}for(let d of t.sample){let m=Math.floor((-d.x*e.facing.y+d.y*e.facing.x)/a),h=-(d.x*e.facing.x+d.y*e.facing.y);f.set(m,Math.max(f.get(m)??-1/0,h))}let c=[];for(let[d,m]of l){let h=f.get(d);h!==void 0&&c.push(m-h)}let u=c.length?Yn(c):e.frontD-o;return u<-1/$?null:u}function Du(e,t){if(t.plane.floorIndex>=e.plane.floorIndex)return!1;let n=-1/0,o=1/0,r=1/0,i=-1/0;for(let l of t.hull){let f=-(l.x*e.facing.x+l.y*e.facing.y);n=Math.max(n,f),o=Math.min(o,f);let c=-l.x*e.facing.y+l.y*e.facing.x;r=Math.min(r,c),i=Math.max(i,c)}let s=Math.min(e.latMax,i)-Math.max(e.latMin,r),a=Math.min(e.backD,n)-Math.max(e.frontD,o);return s>Si*(e.latMax-e.latMin)&&a>1/$}function Nu(e,t){let n=new Set;for(let o of e){let r=(Math.atan2(o.y-t.y,o.x-t.x)*180/Math.PI+360)%360;n.add(Math.floor(r/10))}return n.size/36}function Gu(e,t){let n=1/0,o=-1/0;for(let i of t.hull){let s=-(i.x*e.facing.x+i.y*e.facing.y);n=Math.min(n,s),o=Math.max(o,s)}let r=Math.max(0,Math.min(o-n,e.frontD-n));return t.height+r*$*Math.tan(t.rake*Math.PI/180)}function ju(e,t){if(!e.facesAction)return!1;let n={x:-e.facing.y,y:e.facing.x},o=Ii/$,r=Math.max(1,Math.ceil((e.backD-e.frontD)/o)),i={left:new Map,right:new Map};for(let a of t)if(!(a===e||a.plane.floorIndex!==e.plane.floorIndex)&&!(a.facing.x*e.facing.x+a.facing.y*e.facing.y>=mu))for(let l of a.sample){let f=-(l.x*e.facing.x+l.y*e.facing.y);if(f<e.frontD||f>e.backD)continue;let c=-l.x*e.facing.y+l.y*e.facing.x,u=c<e.latMin?"left":c>e.latMax?"right":null;if(!u)return!1;let d=Math.min(r-1,Math.floor((f-e.frontD)/o)),m=u==="left"?e.latMin-c:c-e.latMax;m<(i[u].get(d)?.gap??1/0)&&i[u].set(d,{gap:m,other:a})}let s=a=>{let l=a==="left"?e.latMin:e.latMax,f=0;for(let[c,{other:u}]of i[a]){if((u.facing.x*n.x+u.facing.y*n.y)*(a==="left"?1:-1)<uu)continue;let m=e.frontD+(c+.5)*o,h={x:-m*e.facing.x+l*n.x,y:-m*e.facing.y+l*n.y},p=-(h.x*u.facing.x+h.y*u.facing.y),y=-h.x*u.facing.y+h.y*u.facing.x;p<u.frontD&&y>=u.latMin&&y<=u.latMax&&f++}return f/r>=fu};return s("left")&&s("right")}function Hu(e,t){if(t.plane.floorIndex!==e.plane.floorIndex||t.facing.x*e.facing.x+t.facing.y*e.facing.y<yu)return!1;let n=1/0,o=-1/0,r=1/0;for(let a of t.hull){let l=-a.x*e.facing.y+a.y*e.facing.x;n=Math.min(n,l),o=Math.max(o,l),r=Math.min(r,-(a.x*e.facing.x+a.y*e.facing.y))}let i=(e.frontD-r)*$;if(i<-xu||i>gu)return!1;let s=Math.max(n-e.latMax,e.latMin-o);return s*$<=Mu&&s*$>=-Su}function Xu(e,t=!1,n=!1,o){let r=t?eu:Jl,i=new Set(n?[]:e.filter(p=>!p.authored&&ju(p,e))),s=[...e].sort((p,y)=>p.plane.floorIndex-y.plane.floorIndex||Number(i.has(y))-Number(i.has(p))||p.frontDistance-y.frontDistance);for(let p of i)o?.add(p.id);let a=(p,y,x)=>{let g=new Map,w=[],E=new Map,M=b=>{if(b.plane.floorIndex===0||b.plane.baseHeightM>0)return b.plane.baseHeightM;let I=E.get(b.plane.floorIndex-1);return I===void 0?b.plane.baseHeightM:I+pi};for(let b of s){if(i.has(b))b.height=M(b),b.level=0,b.rake=0,b.backHeight=b.height,g.set(b.id,void 0);else if(!b.authored){let S=M(b),R;for(let A of w){if(A.plane.floorIndex>b.plane.floorIndex)continue;if(Du(b,A)){let L=Gu(b,A)+su;L>S&&(S=L,R=A);continue}let C=Fu(b,A,i.has(A));if(C==null)continue;let T=n&&!!b.plane.stageDeck&&A.level===0&&A.plane.floorIndex===b.plane.floorIndex&&Math.max(0,C)*$<=cu,F=i.has(A)?A.height+hu:T?A.backHeight:A.backHeight+Kl+Math.min(Wl,Math.max(0,C)*$)*Math.tan(A.rake*Math.PI/180);F>S&&(S=F,R=A)}let _=p.get(b);_&&_.height>S+.01?(S=_.height,R=void 0):_=void 0,b.height=Math.round(Math.min(S,b.plane.baseHeightM+ql)*100)/100;let k=!R&&!_&&b.height>b.plane.baseHeightM;if(b.level=R?R.level+1:_?_.level:k?1:0,b.rake=Bu(b.rowDepths,b.frontDistance,b.height,b.plane.focalHeightM),!b.facesAction&&b.rowCount<ou)b.rake=0;else if(b.level===0){let A=Math.max(1e-6,(b.backD-b.frontD)*$);b.rake=Math.min(b.rake,$l,Math.round(Math.atan(Ql/A)*1800/Math.PI)/10)}else b.rowCount>=2&&(b.rake=Math.max(b.rake,r[Math.min(b.level,r.length)-1]));let O=(b.backD-b.frontD)*$,v=R&&i.has(R)||_&&x?.has(_.id);if(y!==void 0&&v&&b.rowCount>=2&&(b.rake=y),t&&O>0&&b.height+O*Math.tan(b.rake*Math.PI/180)>b.plane.baseHeightM+yi){let A=Math.max(0,b.plane.baseHeightM+yi-b.height);b.rake=Math.max(Mi,Math.round(Math.atan(A/O)*1800/Math.PI)/10)}n&&b.plane.stageDeck&&b.level>0&&(b.rake=Math.min(b.rake,lu)),b.backHeight=b.height+O*Math.tan(b.rake*Math.PI/180),g.set(b.id,R?.id??(_?g.get(_.id):void 0))}let I=b.plane.floorIndex;E.set(I,Math.min(E.get(I)??1/0,b.height)),w.push(b)}return g},l=a(new Map),f=new Map,c=p=>f.get(p)?.height??p.height;for(let p=!0,y=0;p&&y<e.length;y++){p=!1;for(let x of e)if(!(x.authored||i.has(x)))for(let g of e){let w=f.get(g)??g;g===x||w.height-w.plane.baseHeightM<Iu||w.height<=c(x)+.01||Hu(x,g)&&(f.set(x,w),p=!0)}}let u=new Map(e.map(p=>[p.id,p])),d=e.filter(p=>!p.authored&&p.rowCount>=2&&i.has(u.get(l.get(p.id)??""))),m=d.length?Yn(d.map(p=>p.rake)):void 0;if(!f.size&&m===void 0)return l;let h=new Map([...new Set(f.values())].map(p=>[p,{...p}]));return a(new Map([...f].map(([p,y])=>[p,h.get(y)])),m,new Set(d.map(p=>p.id)))}var Un=(e,t)=>!!e&&e.x===t.x&&e.y===t.y;function Pi(e,t={x:0,y:-40}){let n=et(e),o=new Map;for(let x of n){if(!x.sectionId)continue;let g=o.get(x.sectionId);g?g.push(x):o.set(x.sectionId,[x])}let r={focalInferred:!1,confident:!1,sections:[]},i=e.floors?.length?e.floors.map((x,g)=>({objects:x.objects,floorIndex:g,floorId:x.id,baseHeightM:x.baseHeightM??0,focal:x.focalPoint??e.focalPoint})):[{objects:e.objects,floorIndex:0,floorId:void 0,baseHeightM:0,focal:e.focalPoint}],s=new Set(i.flatMap(x=>x.objects.filter(g=>g.type==="table").map(g=>g.id))),a=[],l,f=new Set,c=i.map(x=>{let g=v=>!e.floors?.length||v.floorId===x.floorId,w=Lu(n.filter(v=>!v.sectionId&&v.kind!=="booth"&&!s.has(v.rowId)&&g(v))),E=[];for(let v of w){let A=we(ke(wi(v)),Pu/$);if(n.some(T=>!g(T)&&Wn(T,A)))continue;let C=`${xi}${x.floorIndex}-${E.length}`;f.add(C),o.set(C,v),E.push({type:"section",id:C,label:"",color:Au,outline:A})}let M=E.length?{...x,objects:[...x.objects,...E]}:x,b=new Set(M.objects.filter(v=>v.type==="section").map(v=>v.logicalSectionId??v.id)),I=[...o.entries()].filter(([v])=>b.has(v)).flatMap(([,v])=>v),S=ku(M.objects,Kn(I),I),R=M.focal;(S||M.focal&&!Un(M.focal,t))&&(r.confident=!0),S&&(r.stage??={id:S.shape.id,inferred:S.inferred,...M.floorId?{floorId:M.floorId}:{}},(S.inferred||Un(M.focal,t))&&(R=S.centre,r.focalInferred=!0));let _=S&&(!S.inferred||Pt(S.outline)*$*$<=Xn),k=S?void 0:l,O={tableIds:s,floorIndex:M.floorIndex,floorId:M.floorId,baseHeightM:M.baseHeightM,focal:k?.focal??R,outline:S?.outline??k?.outline,focalHeightM:k?.focalHeightM??M.baseHeightM+(S&&_?Ae({...S.shape,role:"stage"}).heightM:0),stageDeck:k?.stageDeck??!!(S&&_&&Pt(S.outline)*$*$<=Xn),middle:I.length?{x:I.reduce((v,A)=>v+A.x,0)/I.length,y:I.reduce((v,A)=>v+A.y,0)/I.length}:R};for(let v of M.objects){if(v.type!=="section")continue;let A=Ou(v,o.get(v.logicalSectionId??v.id)??[],O);A&&a.push(A)}return O.outline&&(l=O),Un(M.focal,O.focal)||(r.focal??=[]).push({...M.floorId?{floorId:M.floorId}:{},point:{...O.focal}}),{unit:M,plane:O,stage:S,planeSeats:I}}),u=i.flatMap(x=>x.objects).map(x=>x.type==="shape"&&!x.role&&(Hn(x.label)==="wall"||!Hn(x.label)&&bi(x))?{...x,role:"wall"}:x),d=ot({objects:u},n)!==null;d&&(r.indoor=!0);let m=new Set,h=Xu(a,d,Nu(n,c[0]?.plane.focal??t)<au,m),p=new Map(a.filter(x=>!x.authored).map(x=>[x.id,x])),y=c.map(({unit:x,plane:g,stage:w,planeSeats:E})=>x.objects.map(M=>{let b=M.type==="shape"&&!M.role&&M.id!==w?.shape.id?Hn(M.label):null;if(M.type==="shape"&&!M.role&&M.id!==w?.shape.id&&(b==="wall"||!b&&bi(M))&&M.type==="shape"){(r.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:"wall"});let{fill:A,...C}=M;return{...C,role:"wall"}}if(b&&M.type==="shape")return(r.roles??=[]).push({id:M.id,...g.floorId?{floorId:g.floorId}:{},role:b}),{...M,role:b};let S=w?.inferred&&M.id===w.shape.id&&M.type==="shape"?_u(M,w.outline,x.objects,E):null;if(S&&M.type==="shape")return r.stage?.id===M.id&&(r.stage.field=S),{...M,role:"stage",stageKind:S};let R=M.type==="shape"&&M.id===w?.shape.id&&M.heightM===void 0&&!M.stageKind&&a.some(A=>A.plane===g&&(m.has(A.id)||A.level===0&&A.facesAction&&A.rake<=pu&&(A.frontDistance+A.backD-A.frontD)*$>=bu)),_=R?{heightM:du}:{};if(w?.inferred&&M.id===w.shape.id&&M.type==="shape"&&Pt(w.outline)*$*$<=Xn)return r.stage?.id===M.id&&(r.stage.deck=!0),{...M,role:"stage",..._};if(R&&M.type==="shape"&&M.role==="stage")return{...M,..._};let k=M.type==="section"?p.get(M.id):void 0;if(!k||M.type!=="section")return M;let O=k.rowCount>=2&&k.rake>0;f.has(k.id)?r.looseRowBlocks=(r.looseRowBlocks??0)+1:r.sections.push({id:k.id,floorId:g.floorId,surfaceKind:O?"rakedRows":"flat",height:k.height,rake:k.rake,stackedOn:h.get(k.id)});let v={status:"inferred",source:"public-2d-topology",note:Cu};return{...M,height:k.height,rake:k.rake,surfaceKind:O?"rakedRows":"flat",physical3dProvenance:{height:v,rake:v,surfaceKind:v}}}));if(e.floors?.length){let x=e.floors.map((g,w)=>({...g,objects:y[w],focalPoint:c[w].plane.focal}));return{doc:{...e,floors:x,objects:x[0].objects,focalPoint:x[0].focalPoint},report:r}}return{doc:{...e,objects:y[0],focalPoint:c[0].plane.focal},report:r}}var Ai=/^[\p{L}\p{N}]{1,4}$/u,Uu=/^([\p{L}\p{N}]{2,})[\s\-\u2013\u2014\u00b7_./]+(.+)$/u;function Ei(e,t){let n=t?.trim();if(!n)return e;let o=e.toLocaleLowerCase("en-US"),r=n.toLocaleLowerCase("en-US");if(o.startsWith(`${r} `)){let s=e.slice(n.length).trim();if(Ai.test(s))return s}let i=Uu.exec(e);if(i){let s=i[1].toLocaleLowerCase("en-US"),a=i[2].trim();if((r.startsWith(s)||s.startsWith(r))&&Ai.test(a))return a}return e}var Vu=new Map(Mn.map(e=>[e.key,e.label]));function Yu(e){return`picker.access.${e}`}function _i(e){let t=[],n=e.wheelchairSpaceType;for(let i of e.accessibility??[]){if(i==="wheelchair"&&n)continue;let s=Vu.get(i);s&&t.push({key:`access:${i}`,icon:i,titleKey:Yu(i),titleFallback:s,tone:"access"})}n==="no-seat"?t.push({key:"wheelchair:no-seat",icon:"wheelchair",titleKey:"picker.emptyWheelchairSpace",titleFallback:"Empty wheelchair space",tone:"access"}):n==="seat-present"&&t.push({key:"wheelchair:seat-present",icon:"wheelchair",titleKey:"picker.accessiblePhysicalSeat",titleFallback:"Accessible physical seat",tone:"access"});let o=e.commercial;o?.restrictedView&&t.push({key:"mark:restrictedView",icon:"restrictedView",titleKey:"picker.restrictedView",titleFallback:"Restricted view",tone:"warn"}),o?.obstructedView&&t.push({key:"mark:obstructedView",icon:"obstructedView",titleKey:"picker.obstructedView",titleFallback:"Obstructed view",tone:"warn"}),o?.premium&&t.push({key:"mark:premium",icon:"premium",titleKey:"picker.premiumSeat",titleFallback:"Premium seat",tone:"premium"});let r=o?.note?.trim();if(r){let i=t.find(s=>s.tone==="warn"||s.tone==="premium");i?i.note=r:t.push({key:"note",icon:"note",titleKey:"picker.organizerNote",titleFallback:"Organizer note",tone:"note",note:r})}return t}var Ku=6,Wu=2.2,Ci=.1,zu=new Set(["stage","entrance","exit","screen","suite","obstruction","sound","bar","concession","restroom","coat"]),Zu=.3,$u=1.8,Qu=.9,qu=.55,Ju=1,vi=4e3,ef=6,ki="#d8a425",tf="#e8c15a",Zn="#1c1608";function Ti(e){let t=nf(e);if(!t)return null;let n=_i(e).find(o=>o.icon===t.icon);return{...t,name:n?.titleFallback??t.icon}}function nf(e){let t=e.accessibility;if(t?.length)return{icon:t.includes("wheelchair")?"wheelchair":t[0],color:Gt(t)};let n=e.commercial;return n?.obstructedView?{icon:"obstructedView",color:ki,ink:Zn}:n?.restrictedView?{icon:"restrictedView",color:ki,ink:Zn}:n?.premium?{icon:"premium",color:tf,ink:Zn}:null}function of(e,t){if(!e)return;let n,o=0;for(let[i,s]of e)s>o&&(o=s,n=i);let r=t.categories?.find(i=>i.key===n)?.color;return r&&/^#[0-9a-f]{6}$/i.test(r)?r:void 0}var rf=6e3;function Oi(e){let{doc:t,units:n,seats:o,surfaces:r,focal:i}=e,s=t.zones??[],a=[];if(s.length){let l=new Map;for(let c of n)for(let u of c.objects)u.type==="section"&&u.zone&&l.set(u.id,u.zone);let f=new Map;for(let c=0;c<o.length;c++){let u=o[c],d=r.seatOwner[c],m=u.zoneId??(d?l.get(d):void 0);if(!m)continue;let h=f.get(m);h||(h={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},f.set(m,h)),h.n++,u.x<h.minX&&(h.minX=u.x),u.y<h.minY&&(h.minY=u.y),u.x>h.maxX&&(h.maxX=u.x),u.y>h.maxY&&(h.maxY=u.y),h.sumY+=r.seatDeckY(c)}for(let c of s){let u=f.get(c.id),d=[];for(let[m,h]of l)h===c.id&&d.push(m);if(!u||u.n===0){a.push({id:c.id,label:c.label,color:ne(c.color),sectionIds:d,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(c.focalPoint??i).x*P,1.5,(c.focalPoint??i).y*P]});continue}a.push({id:c.id,label:c.label,color:ne(c.color),sectionIds:d,seatCount:u.n,center:[(u.minX+u.maxX)/2*P,u.sumY/u.n,(u.minY+u.maxY)/2*P],radius:.5*Math.hypot((u.maxX-u.minX)*P,(u.maxY-u.minY)*P)||1,focalWorld:[(c.focalPoint??i).x*P,1.5,(c.focalPoint??i).y*P]})}}return a}function Bi(e){let{doc:t,units:n,seats:o,surfaces:r,seatData:i,hintedSeatFloor:s,zones:a,focal:l}=e,f=[],c=[],u=[],d=new Map;for(let m of n)for(let h of m.objects){if(h.type!=="section"||!h.zone)continue;let p=(h.displayLabel||h.label||"").trim().toLocaleLowerCase();if(!p)continue;let y=t.floors?.[m.index]?.name?.trim().toLocaleLowerCase();if(n.length>1&&y===p)continue;let x=d.get(h.zone);x||d.set(h.zone,x=new Set),x.add(p)}for(let m of a)m.seatCount!==0&&(d.get(m.id)?.has(m.label.trim().toLocaleLowerCase())||f.push({id:`zone:${m.id}`,kind:"zone",text:m.label,anchor:[m.center[0],m.center[1]+Ku,m.center[2]],color:t.zones?.find(h=>h.id===m.id)?.color}));{let m=new Map,h=new Map,p=new Map,y=new Map;for(let x=0;x<o.length;x++){let g=r.seatOwner[x];if(!g)continue;let w=m.get(g);w||(w={n:0,x:0,y:0,deck:0},m.set(g,w)),w.n++,w.x+=o[x].x,w.y+=o[x].y,w.deck+=r.seatDeckY(x);let E=o[x].categoryKey;if(E){let b=h.get(g);b||(b=new Map,h.set(g,b)),b.set(E,(b.get(E)??0)+1)}if(o[x].accessibility?.includes("wheelchair")){let b=p.get(g);b?b.push(x):p.set(g,[x])}let M=y.get(g);M||(M={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0,minDeck:1/0,maxDeck:-1/0},y.set(g,M)),M.minDeck=Math.min(M.minDeck,r.seatDeckY(x)),M.maxDeck=Math.max(M.maxDeck,r.seatDeckY(x)),o[x].x<M.minX&&(M.minX=o[x].x),o[x].x>M.maxX&&(M.maxX=o[x].x),o[x].y<M.minY&&(M.minY=o[x].y),o[x].y>M.maxY&&(M.maxY=o[x].y)}for(let x of n)for(let g of x.objects){if(g.type!=="section"||gi(g))continue;let w=m.get(g.id);if(!w||w.n===0)continue;let E=y.get(g.id),M=[w.x/w.n*P,w.deck/w.n,w.y/w.n*P],b=g.displayLabel||g.label||g.id;c.push({id:g.id,floorIndex:x.index,label:b,seatCount:w.n,center:M,radius:Math.max(1,Math.hypot(E.maxX-E.minX,E.maxY-E.minY)*.5*P),box:{min:[E.minX*P-.4,E.minDeck,E.minY*P-.4],max:[E.maxX*P+.4,E.maxDeck+1,E.maxY*P+.4]},focalWorld:[x.focal.x*P,x.baseHeightM+1.5,x.focal.y*P]});let I=t.floors?.[x.index]?.name?.trim().toLocaleLowerCase();if(!(n.length>1&&I===b.trim().toLocaleLowerCase())){let S=of(h.get(g.id),t),R=p.get(g.id);f.push({id:`section:${g.id}`,kind:"section",text:b,anchor:[M[0],M[1]+Wu,M[2]],floorIndex:x.index,...S?{tint:S}:{},...R?{wheelchairSeats:R}:{}})}}}{for(let M of n)for(let b of M.objects){if(b.type!=="gaArea")continue;let I=ut(b.points);if(!I)continue;let S=b.displayLabel||b.label||b.id;f.push({id:`ga:${b.id}`,kind:"ga",text:b.capacity>0?`${S} \xB7 ${b.capacity.toLocaleString()}`:S,anchor:[I.x*P,M.baseHeightM+$u,I.y*P],floorIndex:M.index})}let m=new Map,h=new Map;for(let M of n)for(let b of M.objects)if(b.type==="section"&&m.set(b.id,b.displayLabel||b.label||b.id),b.type==="row"){let I=b.displayLabel?.trim()||b.segmentedRow?.displayLabel?.trim();I&&h.set(b.id,I)}let p=new Map;for(let M=0;M<o.length;M++){let b=o[M],I=Math.hypot(b.x-l.x,b.y-l.y),S=p.get(b.rowId);(!S||I>S.far)&&p.set(b.rowId,{seat:b,index:M,far:I})}for(let[M,b]of p){let I=r.seatOwner[b.index]??b.seat.sectionId,S=Li(b.seat.label,M,m.get(I??""),h.get(M));S&&f.push({id:`row:${M}`,kind:"row",text:S,anchor:[b.seat.x*P,r.seatDeckY(b.index)+Qu,b.seat.y*P],floorIndex:s[b.index]})}let y=new Map;for(let M=0;M<o.length;M++){let b=o[M],I=y.get(b.rowId);I||(I={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:Li(b.label,b.rowId,m.get(r.seatOwner[M]??b.sectionId??""),h.get(b.rowId)),sectionId:r.seatOwner[M]??b.sectionId},y.set(b.rowId,I));let S=M*3,R=i.iPosition[S],_=i.iPosition[S+1],k=i.iPosition[S+2];I.n++,I.x+=R,I.y+=_,I.z+=k,I.minX=Math.min(I.minX,R),I.maxX=Math.max(I.maxX,R),I.minZ=Math.min(I.minZ,k),I.maxZ=Math.max(I.maxZ,k)}for(let[M,b]of y)u.push({id:M,label:b.label,sectionId:b.sectionId,seatCount:b.n,center:[b.x/b.n,b.y/b.n,b.z/b.n],radius:Math.max(.8,Math.hypot(b.maxX-b.minX,b.maxZ-b.minZ)*.5)});let x=0,g=(M,b)=>{x++,f.push({id:`access:${o[M].id}`,kind:"access",text:b.name,icon:b.icon,color:b.color,...b.ink?{ink:b.ink}:{},seatWidthM:i.iChairWidth[M]*2,anchor:[o[M].x*P,r.seatDeckY(M)+Ju,o[M].y*P],floorIndex:s[M],rowId:o[M].rowId})},w=null,E=()=>{if(w){let M=Ti(o[w.seats[0]]),b=w.seats.length,I=Math.max(1,Math.round(b/ef));for(let S=0;S<I&&x<vi;S++)g(w.seats[Math.min(b-1,Math.floor((S+.5)*b/I))],M)}w=null};for(let M=0;M<o.length&&x<vi;M++){let b=Ti(o[M]);if(b&&o[M].accessibility?.length){E(),g(M,b);continue}if(!b){E();continue}w&&w.rowId===o[M].rowId&&w.icon===b.icon?w.seats.push(M):(E(),w={rowId:o[M].rowId,icon:b.icon,seats:[M]})}if(E(),o.length<=rf)for(let M=0;M<o.length;M++){let b=o[M],I=sf(b.displayLabel||b.label);I&&f.push({id:`seat:${b.id}`,kind:"seat",seatWidthM:i.iChairWidth[M]*2,text:I,anchor:[b.x*P,r.seatDeckY(M)+qu,b.y*P],floorIndex:s[M],rowId:b.rowId})}}for(let m of n)for(let h of m.objects)if(h.type==="shape"&&h.role&&zu.has(h.role)){let p=ie(h),y=p?ut(p):null;if(!y||!h.label)continue;f.push({id:`architecture:${h.id}`,kind:h.role==="stage"?"stage":h.role==="entrance"||h.role==="exit"?"gate":"annotation",text:h.label,...h.role==="entrance"||h.role==="exit"?{icon:h.role}:{},anchor:[y.x*P,m.baseHeightM+Ae(h).heightM+Ci,y.y*P],color:h.fill,floorIndex:m.index})}else if(h.type==="text"){if(!h.text)continue;f.push({id:`text:${h.id}`,kind:"annotation",text:h.text,anchor:[h.position.x*P,m.baseHeightM+Ci,h.position.y*P],color:h.color,rotation:h.rotation,floorIndex:m.index})}else if(h.type==="booth"){let p=Ee(h);if(!p)continue;let y=ut(p);if(!y)continue;f.push({id:`booth:${h.id}`,kind:"booth",text:h.displayLabel||h.label||h.id,anchor:[y.x*P,m.baseHeightM+Qt+Zu,y.y*P],floorIndex:m.index})}return{labels:f,sections:c,rows:u}}function Fi(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 sf(e){let t=e.lastIndexOf("-");return t>=0&&t<e.length-1?e.slice(t+1):e}function Li(e,t,n,o){if(o?.trim())return o.trim();let r=e?e.lastIndexOf("-"):-1,i=r>0?e.slice(0,r):t;return i&&Ei(i,n)}function Di(e){let{doc:t,units:n,seats:o,surfaces:r,solids:i,hintedSeatFloor:s,seatFloor:a}=e,l=[];{let f=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let d=0;d<i.floor.length;d+=1){let m=Math.max(0,Math.min(n.length-1,Math.round(i.floor[d]))),h=d*3,p=f[m];p.minX=Math.min(p.minX,i.position[h]),p.minY=Math.min(p.minY,i.position[h+1]),p.minZ=Math.min(p.minZ,i.position[h+2]),p.maxX=Math.max(p.maxX,i.position[h]),p.maxY=Math.max(p.maxY,i.position[h+1]),p.maxZ=Math.max(p.maxZ,i.position[h+2])}let c=new Map;for(let d=0;d<n.length;d++)for(let m of n[d].objects)m.type==="section"&&c.set(m.id,d);let u=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 d=0;d<o.length;d++){let m=r.seatOwner[d],h=(m!==null?c.get(m):void 0)??s[d];if(h===void 0)continue;let p=u[h],y=o[d];p.n++,y.x<p.minX&&(p.minX=y.x),y.y<p.minY&&(p.minY=y.y),y.x>p.maxX&&(p.maxX=y.x),y.y>p.maxY&&(p.maxY=y.y);let x=r.seatDeckY(d);p.sumX+=y.x*P,p.sumDeck+=x,p.sumZ+=y.y*P,p.minDeck=Math.min(p.minDeck,x),p.maxDeck=Math.max(p.maxDeck,x+1.6),a[d]=h}for(let d=0;d<n.length;d++){let m=u[d],h=t.floors?.[d],p=f[d],y=Math.min(m.n?m.minX*P:n[d].focal.x*P-1,Number.isFinite(p.minX)?p.minX:1/0),x=Math.max(m.n?m.maxX*P:n[d].focal.x*P+1,Number.isFinite(p.maxX)?p.maxX:-1/0),g=Math.min(m.n?m.minY*P:n[d].focal.y*P-1,Number.isFinite(p.minZ)?p.minZ:1/0),w=Math.max(m.n?m.maxY*P:n[d].focal.y*P+1,Number.isFinite(p.maxZ)?p.maxZ:-1/0),E=Math.min(m.n?Math.min(n[d].baseHeightM,m.minDeck):n[d].baseHeightM,Number.isFinite(p.minY)?p.minY:1/0),M=Math.max(m.n?Math.max(m.maxDeck,E+.5):E+.5,Number.isFinite(p.maxY)?p.maxY:-1/0),b=[m.n?m.sumX/m.n:(y+x)/2,m.n?m.sumDeck/m.n:(E+M)/2,m.n?m.sumZ/m.n:(g+w)/2],I=Math.max(1,.5*Math.hypot(x-y,M-E,w-g));l.push({index:d,id:h?.id??`floor-${d}`,label:h?.name??(n.length>1?`Floor ${d+1}`:"Venue"),seatCount:m.n,center:b,radius:I,box:{min:[y,E,g],max:[x,M,w]},focalWorld:[n[d].focal.x*P,n[d].baseHeightM+1.5,n[d].focal.y*P]})}}return l}function $n(e,t){let n=1/0,o=1/0,r=-1/0,i=-1/0,s=(a,l)=>{a<n&&(n=a),l<o&&(o=l),a>r&&(r=a),l>i&&(i=l)};for(let a of t)s(a.x,a.y);for(let a of e)for(let l of a.objects)if(l.type==="section")for(let f of l.outline)s(f.x,f.y);else if(l.type==="shape"&&l.points)for(let f of l.points)s(f.x,f.y);else if(l.type==="gaArea")for(let f of l.points)s(f.x,f.y);else if(l.type==="booth"){let f=Ee(l);if(f)for(let c of f)s(c.x,c.y)}else if(l.type==="table"){let f=qt(l);if(f)for(let c of f)s(c.x,c.y)}else if(l.type==="decorImage"){let f=Jt(l);if(f)for(let c of f)s(c.x,c.y)}return Number.isFinite(n)||(n=-100,o=-100,r=100,i=100),{minX:n,minY:o,maxX:r,maxY:i}}function Ui(e,t,n,o,r,i,s){if(t.length===1){let a=n.map(d=>({x:d.x,y:d.y}));for(let d of t[0].objects)d.type==="section"?a.push(...d.outline):d.type==="shape"?a.push(...ie(d)??d.points??[]):d.type==="gaArea"?a.push(...d.points):d.type==="booth"?a.push(...Ee(d)??[]):d.type==="table"?a.push(...qt(d)??[]):d.type==="decorImage"&&a.push(...Jt(d)??[]);if(ji(e,t[0],n,i)||Xi(e,t[0],n,a,i))return!1;if(s&&Gi(e,t[0].baseHeightM,a,i,s))return!0;let l=gt(a),f=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2,u=l.length>=3?l.map(d=>{let m=d.x-f,h=d.y-c,p=Math.max(1,Math.hypot(m,h));return{x:d.x+m/p*80,y:d.y+h/p*80}}):bt(r.minX-28,r.minY-28,r.maxX-r.minX+56,r.maxY-r.minY+56);return W(e,u,void 0,()=>-.04,-.22,i.ground,i.ground,Y),!1}else{let a=t.reduce((y,x)=>x.baseHeightM<y.baseHeightM?x:y);e.setFloor(a.index);let l={...a,objects:t.flatMap(y=>y.objects)},f=n.map(y=>({x:y.x,y:y.y}));for(let y of l.objects)y.type==="section"&&f.push(...y.outline);if(ji(e,l,n,i)||Xi(e,l,n,f,i))return!1;if(s&&Gi(e,a.baseHeightM,f,i,s))return!0;let c=n.filter((y,x)=>o[x]===a.index),u=$n([a],c),d=Math.hypot(u.maxX-u.minX,u.maxY-u.minY),m=Math.max(28,Math.min(80,d*.04)),h=bt(u.minX-m,u.minY-m,u.maxX-u.minX+m*2,u.maxY-u.minY+m*2),p=a.baseHeightM-.03;return W(e,h,void 0,()=>p,p-.22,i.ground,i.ground,Y),!1}}function Qn(e,t,n,o){let{cx:r,cz:i,radius:s}=n,a=1/0,l=1/0,f=1/0,c=-1/0,u=-1/0,d=-1/0,m=(y,x,g)=>{a=Math.min(a,y),c=Math.max(c,y),l=Math.min(l,x),u=Math.max(u,x),f=Math.min(f,g),d=Math.max(d,g)};for(let y=0;y<e.position.length;y+=3){let x=y/3;o&&x>=o[0]&&x<o[1]||m(e.position[y],e.position[y+1],e.position[y+2])}for(let y=0;y<t.count;y++){let x=y*3,g=t.iPosition[x],w=t.iPosition[x+1],E=t.iPosition[x+2],M=Math.max(.35,t.iMaxRadius[y]??.35);m(g-M,w,E-M),m(g+M,w+1.6,E+M)}Number.isFinite(a)||(a=r-s,c=r+s,l=0,u=s*.16,f=i-s,d=i+s);let h=[(a+c)/2,(l+u)/2,(f+d)/2],p=Math.max(1,.5*Math.hypot(c-a,u-l,d-f));return{center:h,radius:p,minY:l,maxY:u}}var af=4096;function Vi(e,t,n=[]){let o=Math.max(1,Math.ceil(e.count/af)),r=Math.ceil(e.count/o),i=new Float32Array((r*2+t.length*4+n.length)*3),s=0;for(let a=0;a<e.count;a+=o){let l=e.iPosition[a*3],f=e.iPosition[a*3+1],c=e.iPosition[a*3+2];i[s++]=l,i[s++]=f,i[s++]=c,i[s++]=l,i[s++]=0,i[s++]=c}for(let[a,l,f]of n)i[s++]=a,i[s++]=l,i[s++]=f;for(let a of t)for(let[l,f]of[[-1,-1],[1,-1],[1,1],[-1,1]])i[s++]=a.cx+l*a.halfX,i[s++]=a.y,i[s++]=a.cz+f*a.halfZ;return i.subarray(0,s)}function Yi(e,t,n,o,r,i,s=[]){let a=1/0,l=1/0,f=-1/0,c=-1/0;for(let M=0;M<e.count;M++){let b=M*3,I=e.iPosition[b],S=e.iPosition[b+2];I<a&&(a=I),I>f&&(f=I),S<l&&(l=S),S>c&&(c=S)}for(let[M,,b]of s)M<a&&(a=M),M>f&&(f=M),b<l&&(l=b),b>c&&(c=b);for(let M of t)a=Math.min(a,M.cx-M.halfX),f=Math.max(f,M.cx+M.halfX),l=Math.min(l,M.cz-M.halfZ),c=Math.max(c,M.cz+M.halfZ);let u=n.minX*P,d=n.maxX*P,m=n.minY*P,h=n.maxY*P,p=u,y=d,x=m,g=h;if(Number.isFinite(a)){let M=Math.max(2,.06*Math.hypot(f-a,c-l));p=Math.max(u,a-M),y=Math.min(d,f+M),x=Math.max(m,l-M),g=Math.min(h,c+M)}let w=Math.min(0,o),E=Math.max(r,i*.05);return{min:[p,w,x],max:[y,E,g]}}var Ni=12,cf=.6,lf=40;function Gi(e,t,n,o,r){let i=gt([...n]);if(i.length<3)return!1;let s=1/0,a=1/0,l=-1/0,f=-1/0;for(let E of i)s=Math.min(s,E.x),l=Math.max(l,E.x),a=Math.min(a,E.y),f=Math.max(f,E.y);let c=Math.hypot(l-s,f-a)*P,u=we(i,Ni/P,1.2),d=Math.max(lf,c*cf),m=we(i,(Ni+d)/P,1.2);if(u.length!==m.length)return!1;let h=te(o.ground,[.78,.76,.72],.35),p=te(o.ground,[.56,.62,.52],.3);W(e,u,void 0,()=>t-.04,t-.22,h,h,Y);let y=t-.05,x=u.map(E=>[E.x*P,y,E.y*P]),g=m.map(E=>[E.x*P,y,E.y*P]),w=[0,1,0];for(let E=0;E<x.length;E++){let M=(E+1)%x.length;e.tri(x[E],g[M],g[E],w,p,r,r),e.tri(x[E],x[M],g[M],w,p,p,r)}return!0}function ji(e,t,n,o){let r=ot(t,n);if(!r)return!1;let i=t.baseHeightM,s=te(o.ground,[.62,.55,.47],.4);return W(e,r,void 0,()=>i-.04,i-.22,s,s,Y),!0}var uf=3e3,ff=20,Hi=1.5,mf=1.2,hf=.25;function Xi(e,t,n,o,r){if(!n.length||n.length>uf||o.length<3)return!1;for(let R of t.objects){if(R.type==="shape"&&Ct(R.stageKind))return!1;if(R.type==="section"){let{height:_}=Ge(R,{floorBaseHeightM:t.baseHeightM});if(_-t.baseHeightM>ff)return!1}}let i=0,s=0;for(let R of o)i+=R.x,s+=R.y;i/=o.length,s/=o.length;let a=0,l=0,f=0;for(let R of o){let _=R.x-i,k=R.y-s;a+=_*_,l+=k*k,f+=_*k}let c=.5*Math.atan2(2*f,a-l),u=Math.cos(c),d=Math.sin(c),m=-d,h=u,p=1/0,y=-1/0,x=1/0,g=-1/0;for(let R of o){let _=(R.x-i)*u+(R.y-s)*d,k=(R.x-i)*m+(R.y-s)*h;p=Math.min(p,_),y=Math.max(y,_),x=Math.min(x,k),g=Math.max(g,k)}let w=R=>[[p-R,x-R],[y+R,x-R],[y+R,g+R],[p-R,g+R]].map(([_,k])=>({x:i+u*_+m*k,y:s+d*_+h*k})),E=w(Hi/P),M=w((Hi+hf)/P),b=t.baseHeightM,I=te(r.ground,[.62,.55,.47],.4),S=te(r.ground,[.86,.86,.84],.55);return W(e,M,void 0,()=>b-.04,b-.22,I,I,Y),W(e,M,[E.slice().reverse()],()=>b+mf,b-.04,te(S,[1,1,1],.2),S,Y),!0}function Ki(e,t,n){let o=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return o();let r=po(t);if(!r.ok||r.value.id!==e)return o();let i=new Map;for(let u of n)for(let d of u.objects)d.type==="shape"&&i.set(d.id,{shape:d,unit:u});let s=new Set,a=new Set,l=new Map((t.overlay.productionElements??[]).map(u=>{let d=u.runtimeContentImageUrl;return[u.id,typeof d=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(d)?d:void 0]})),f=[];for(let u of r.value.overlay.productionElements??[]){let d=i.get(u.objectId),m=d?ie(d.shape):null,h=u.baseElevationM??0;if(!d||!m||m.length<3||!u.id||s.has(u.id)||a.has(u.objectId)||!Number.isFinite(u.heightM)||u.heightM<.05||u.heightM>50||!Number.isFinite(h)||h<-10||h>100)return o();s.add(u.id),a.add(u.objectId);let p=m.map(S=>S.x*P),y=m.map(S=>S.y*P),x=d.unit.baseHeightM+h,g=Math.min(...p),w=Math.max(...p),E=Math.min(...y),M=Math.max(...y),b,I=l.get(u.id)??u.contentImageUrl;if(u.kind==="screen"&&I&&(b=Pr(m,x,x+u.heightM,d.unit.focal),!b))if(w-g>=M-E){let S=Math.abs(E-d.unit.focal.y*P)<=Math.abs(M-d.unit.focal.y*P)?E-.006:M+.006;b=[[g,x,S],[w,x,S],[g,x+u.heightM,S],[w,x+u.heightM,S]]}else{let S=Math.abs(g-d.unit.focal.x*P)<=Math.abs(w-d.unit.focal.x*P)?g-.006:w+.006;b=[[S,x,E],[S,x,M],[S,x+u.heightM,E],[S,x+u.heightM,M]]}f.push({id:u.id,objectId:u.objectId,kind:u.kind,floorIndex:d.unit.index,baseY:x,topY:x+u.heightM,bounds:{min:[g,x,E],max:[w,x+u.heightM,M]},occlusion:u.occlusion,...I?{contentImageUrl:I}:{},...b?{contentPlane:b}:{}})}let c=f.sort((u,d)=>u.id.localeCompare(d.id));return{byObjectId:new Map(c.map(u=>[u.objectId,u])),elements:c}}var Wi=[.13,.14,.17],ct=[.4,.43,.47],df=.18,pf=.02,bf=2.4,yf=1500,xf=240,gf=.25;function zi(e,t,n,o){let r=t.stageKind??"";if(We(r)||r==="round"||!o.length)return;let i=ie(t);if(!i||i.length<3)return;let s={x:i.reduce((T,F)=>T+F.x,0)/i.length,y:i.reduce((T,F)=>T+F.y,0)/i.length},a=0,l=0,f=new Set;for(let T of o)a+=T.x,l+=T.y,f.add(Math.floor(Math.atan2(T.y-s.y,T.x-s.x)*180/Math.PI/10));let c=s.x-a/o.length,u=s.y-l/o.length,d=Math.hypot(c,u);if(d<1e-6)return;let m=o.reduce((T,F)=>T+Math.hypot(F.x-s.x,F.y-s.y),0)/o.length;if(f.size*10>xf&&d<gf*m)return;let h=c/d,p=u/d,y=-p,x=h,g=-1/0,w=1/0,E=1/0,M=-1/0;for(let T of i){let F=(T.x-s.x)*h+(T.y-s.y)*p,L=(T.x-s.x)*y+(T.y-s.y)*x;g=Math.max(g,F),w=Math.min(w,F),E=Math.min(E,L),M=Math.max(M,L)}let b=(M-E)*P,I=(g-w)*P;if(b<3||I<1.5||b*I>yf)return;let S=df/P,R=(T,F)=>({x:s.x+h*T+y*F,y:s.y+p*T+x*F}),_=(T,F,L,B)=>[R(T,L),R(T,B),R(F,B),R(F,L)],k=n+Math.max(3.5,Math.min(8,b*.35)),O=n+Math.min(bf,k-n-1),v=.2/P,A=w+Math.min(I*.25,1.5)/P,C=pf/P;W(e,_(g-2*S+C,g-S-C,E+S+v,M-S-v),void 0,()=>O,n,Wi,Wi,Y);for(let[T,F]of[[E+S,E+S+v],[M-S-v,M-S]])W(e,_(g-2*S,g-S,T,F),void 0,()=>k+.3,n,ct,ct,Y),W(e,_(A+v,g-2*S,T,F),void 0,()=>k+.3,k,ct,ct,Y);W(e,_(A,A+v,E+S,M-S),void 0,()=>k+.3,k,ct,ct,Y)}function Se(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Me(e){return Array.isArray(e)?e:[]}function Mf(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!Se(n))continue;let o=Se(n.extensions)?n.extensions:null;if(o&&Object.prototype.hasOwnProperty.call(o,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function on(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function Sf(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function If(e,t){let n=new Array(16).fill(0);for(let o=0;o<4;o++)for(let r=0;r<4;r++)for(let i=0;i<4;i++)n[o*4+r]+=e[i*4+r]*t[o*4+i];return n}function Rf(e){let t=on(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:on(e.translation,3),o=e.rotation===void 0?[0,0,0,1]:on(e.rotation,4),r=e.scale===void 0?[1,1,1]:on(e.scale,3);if(!n||!o||!r)return null;let[i,s,a,l]=o,f=Math.hypot(i,s,a,l);if(!(f>1e-8))return null;let c=i/f,u=s/f,d=a/f,m=l/f,h=c+c,p=u+u,y=d+d,x=c*h,g=c*p,w=c*y,E=u*p,M=u*y,b=d*y,I=m*h,S=m*p,R=m*y;return[(1-(E+b))*r[0],(g+R)*r[0],(w-S)*r[0],0,(g-R)*r[1],(1-(x+b))*r[1],(M+I)*r[1],0,(w+S)*r[2],(M-I)*r[2],(1-(x+E))*r[2],0,n[0],n[1],n[2],1]}function wf(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 Pf(e){let t=e[0],n=e[4],o=e[8],r=e[1],i=e[5],s=e[9],a=e[2],l=e[6],f=e[10],c=i*f-s*l,u=s*a-r*f,d=r*l-i*a,m=t*c+n*u+o*d;if(Math.abs(m)<1e-12)return null;let h=1/m;return[c*h,u*h,d*h,(o*l-n*f)*h,(t*f-o*a)*h,(n*a-t*l)*h,(n*s-o*i)*h,(o*r-t*s)*h,(t*i-n*r)*h]}function Zi(e,t,n,o){let r=e[0]*t+e[1]*n+e[2]*o,i=e[3]*t+e[4]*n+e[5]*o,s=e[6]*t+e[7]*n+e[8]*o,a=Math.hypot(r,i,s)||1;return r/=a,i/=a,s/=a,[r,i,s]}function Af(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,o=null,r=null;for(;n+8<=e.byteLength;){let i=t.getUint32(n,!0),s=t.getUint32(n+4,!0);if(n+=8,i%4!==0||n+i>e.byteLength)return null;let a=e.subarray(n,n+i);if(s===1313821514&&!o)try{let l=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!Se(l))return null;o=l}catch{return null}else if(s===5130562&&!r)r=a;else return null;n+=i}return n===e.byteLength&&o&&r?{json:o,bin:r}:null}function Ef(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function _f(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function Cf(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 vf(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=Af(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:o,bin:r}=n;if(!Se(o.asset)||o.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let i=Me(o.extensionsUsed).filter(E=>typeof E=="string");if(i.includes("KHR_draco_mesh_compression")||Mf(o))return{ok:!1,issue:"draco_not_allowed"};if(i.length||Me(o.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(Me(o.images).length||Me(o.textures).length)return{ok:!1,issue:"external_resource"};let s=Me(o.buffers);if(s.length!==1||!Se(s[0])||s[0].uri!==void 0||typeof s[0].byteLength!="number"||!Number.isInteger(s[0].byteLength)||s[0].byteLength<0||s[0].byteLength>r.byteLength)return{ok:!1,issue:"external_resource"};let a=Me(o.accessors),l=Me(o.bufferViews),f=Me(o.meshes),c=Me(o.nodes),u=Me(o.scenes),d=typeof o.scene=="number"?o.scene:0;if(!Se(u[d]))return{ok:!1,issue:"unsupported_glb"};let m=new DataView(r.buffer,r.byteOffset,r.byteLength),h=(E,M,b)=>{if(typeof E!="number"||!Number.isInteger(E)||!Se(a[E]))return null;let I=a[E];if(I.type!==M||I.sparse!==void 0||I.normalized===!0||typeof I.count!="number"||!Number.isInteger(I.count)||I.count<1||typeof I.componentType!="number"||!b.includes(I.componentType)||typeof I.bufferView!="number")return null;let S=l[I.bufferView];if(!Se(S)||S.buffer!==0||typeof S.byteLength!="number"||!Number.isInteger(S.byteLength)||S.byteLength<0)return null;let R=_f(I.type),_=Ef(I.componentType),k=typeof S.byteStride=="number"?S.byteStride:R*_,O=typeof S.byteOffset=="number"?S.byteOffset:0,v=typeof I.byteOffset=="number"?I.byteOffset:0,A=O+v,C=v+(I.count-1)*k+R*_;if(!Number.isInteger(k)||!Number.isInteger(O)||!Number.isInteger(v)||k<R*_||O<0||v<0||O+S.byteLength>r.byteLength||C>S.byteLength)return null;let T=[];for(let F=0;F<I.count;F++){let L=[];for(let B=0;B<R;B++){let N=Cf(m,A+F*k+B*_,I.componentType);if(!Number.isFinite(N))return null;L.push(N)}T.push(L)}return T},p=[],y=[],x=0,g=new Set,w=(E,M)=>{if(typeof E!="number"||!Number.isInteger(E)||!Se(c[E])||g.has(E))return!1;g.add(E);let b=c[E],I=Rf(b);if(!I)return!1;let S=If(M,I),R=Pf(S);if(!R)return!1;if(b.mesh!==void 0){if(typeof b.mesh!="number")return!1;let _=f[b.mesh];if(!Se(_))return!1;for(let k of Me(_.primitives)){if(!Se(k)||k.mode!==void 0&&k.mode!==4||!Se(k.attributes))return!1;let O=h(k.attributes.POSITION,"VEC3",[5126]),v=k.attributes.NORMAL===void 0?null:h(k.attributes.NORMAL,"VEC3",[5126]);if(!O||k.attributes.NORMAL!==void 0&&!v)return!1;let A=O.length;if(k.indices!==void 0){let T=typeof k.indices=="number"?a[k.indices]:null;A=Se(T)?T.count:void 0}if(typeof A!="number"||!Number.isInteger(A)||A%3!==0||(x+=A/3,x>1e5))return!1;let C=k.indices===void 0?O.map((T,F)=>[F]):h(k.indices,"SCALAR",[5121,5123,5125]);if(!C||C.length%3!==0||C.length!==A)return!1;for(let T=0;T<C.length;T+=3){let F=[C[T][0],C[T+1][0],C[T+2][0]];if(F.some(N=>!Number.isInteger(N)||N<0||N>=O.length))return!1;let L=F.map(N=>wf(S,...O[N])),B=null;if(!v){let N=L[1][0]-L[0][0],j=L[1][1]-L[0][1],D=L[1][2]-L[0][2],V=L[2][0]-L[0][0],X=L[2][1]-L[0][1],Z=L[2][2]-L[0][2];B=Zi([1,0,0,0,1,0,0,0,1],j*Z-D*X,D*V-N*Z,N*X-j*V)}for(let N=0;N<3;N++)p.push(...L[N]),y.push(...v?Zi(R,...v[F[N]]):B)}}}for(let _ of Me(b.children))if(!w(_,S))return!1;return g.delete(E),!0};for(let E of Me(u[d].nodes))if(!w(E,Sf()))return{ok:!1,issue:x>1e5?"triangle_limit":"unsupported_glb"};return!x||p.length!==x*9||y.length!==p.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:x,position:new Float32Array(p),normal:new Float32Array(y)}}function $i(e){try{return vf(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function Qi(e){let{doc:t}=e,n=No(t.theme),o=n.structure,r=fr(t,e.eventConfigurationId??t.eventConfigurationId),i=Ki(e.eventConfigurationId,e.eventConfiguration,r),s=e.seats,a=new Ft,l=null;if(e.registeredShellGlb){let G=$i(e.registeredShellGlb);if(G.ok){let H=G.position.length/3,q=new Float32Array(G.position.length),ue=n.materials.shell??o.tierWall;for(let fe=0;fe<H;fe++){let he=G.normal[fe*3+1],re=he<-.25?.4:.62+.38*Math.max(0,he);q[fe*3]=ue[0]*re,q[fe*3+1]=ue[1]*re,q[fe*3+2]=ue[2]*re}l={position:G.position,normal:G.normal,color:q,floor:new Float32Array(H).fill(-2),material:new Float32Array(H),count:H}}}let f=new Map;for(let G of r)for(let H of G.objects)f.set(H.id,G.index),H.type==="section"&&f.set(H.logicalSectionId??H.id,G.index);let c=s.map(G=>f.get(G.sectionId??"")??f.get(G.rowId??"")??0),u=$n(r,s),d=a.vertexCount,h=Ui(a,r,s,c,u,o,te(n.background.top,n.background.bottom,.5))?a.vertexCount:d,p=Uo(t,s),y=new Map,x=new Map;for(let G of t.categories??[])y.set(G.key,G.color),G.seatGlyph&&x.set(G.key,G.seatGlyph);let g=[],w=wr(r,s,c),E=new Map;s.forEach((G,H)=>{let q=w.seatDeckY(H);Number.isFinite(q)&&E.set(G.rowId,Math.min(E.get(G.rowId)??1/0,q))});let M=new Float32Array(s.length),b=[],I=new Map((t.floors??[]).map((G,H)=>[G.id,H])),S=r.map(()=>[]);for(let G of s){let H=G.floorId?I.get(G.floorId)??0:0;S[Math.min(H,S.length-1)]?.push(G)}let R=(G,H)=>{if(!H||H.length<3)return!1;let q=Math.min(...H.map(re=>re.x)),ue=Math.max(...H.map(re=>re.x)),fe=Math.min(...H.map(re=>re.y)),he=Math.max(...H.map(re=>re.y));for(let re=0;re<G;re++)for(let se of S[re])if(!(se.x<q||se.x>ue||se.y<fe||se.y>he)&&be(se,H,void 0))return!0;return!1},_=null,k=G=>r.length===1?s:s.filter((H,q)=>c[q]===G),O=(G,H)=>{let q=Ee(G);if(!q)return!1;let ue=1/0,fe=1/0,he=-1/0,re=-1/0;for(let se of q)ue=Math.min(ue,se.x),he=Math.max(he,se.x),fe=Math.min(fe,se.y),re=Math.max(re,se.y);return s.some((se,_e)=>se.kind!=="booth"&&(r.length===1||c[_e]===H)&&se.x>ue&&se.x<he&&se.y>fe&&se.y<re&&xe(q,se.x,se.y))},v;for(let G=0;G<r.length;G++){let H=r[G];a.setFloor(G);let q=ot(H,k(G)),ue=0;if(q){let K=0;for(let le of H.objects)if(le.type==="section")for(let me of w.bySection.get(le.id)?.rowLevels??[])K=Math.max(K,me.y-H.baseHeightM);if(ue=xr(K),!v){let le=gr(q);v={centre:[le.x*P,le.y*P]}}}let fe=new Xt,he=[],re=H.objects.filter(K=>K.type==="shape"&&(K.role==="entrance"||K.role==="exit")),se=H.objects.filter(K=>K.type==="section"&&!!K.outline&&K.outline.length>=3),_e=Qr(H.objects.filter(K=>K.type==="booth"),H.focal);for(let K of H.objects)if(K.type==="section"){let le=a.vertexCount;mi(a,K,H,Vo(K,p),w.bySection.get(K.id),fe,se,o,G>0&&R(G,K.outline));let me=a.vertexCount-le;me>0&&b.push({sectionId:K.id,start:le,count:me})}else if(K.type==="shape"){let le=i.byObjectId.get(K.id),me=g.length,Ye=q!==null&&K.role==="wall"&&!le;a.setMaterial(Ye?yr:(le?.kind??K.role)==="screen"?1:0);let Ke=K.role==="stage"&&!le?Jr(K,k(G)):Ye&&K.heightM===void 0?{...K,heightM:ue}:K,De=pr(Ke,he);if(Wr(a,Ke,H.baseHeightM+De.supportOffsetM,De.topOffsetM-De.supportOffsetM,o,H.focal,g,le,re),a.setMaterial(0),K.role==="stage"&&!le&&g.length>me&&(_??G)===G){_=G;let Ne=t.floors?.[G]?.id,lt=r.length>1&&Ne?s.filter(At=>At.floorId===Ne):s;zi(a,Ke,g[g.length-1].y,lt)}}else K.type==="gaArea"?Zr(a,K,H.baseHeightM,ne(y.get(K.categoryKey)),o):K.type==="booth"?Vr(a,K,H.baseHeightM,ne(y.get(K.categoryKey)),o,_e.get(K.id)??H.focal,O(K,G)):K.type==="table"?Kr(a,K,Math.max(H.baseHeightM,E.get(K.id)??H.baseHeightM),ne(K.fill??t.theme?.decorFill??"#232c40"),o,!!(K.fill??t.theme?.decorFill)):K.type==="decorImage"&&zr(a,K,H.baseHeightM,o);di(a,H,s,w,o,n.materials.shell,!l)}let A=r.length>1?{x:r.reduce((G,H)=>G+H.focal.x,0)/r.length,y:r.reduce((G,H)=>G+H.focal.y,0)/r.length}:t.focalPoint??{x:(u.minX+u.maxX)/2,y:(u.minY+u.maxY)/2},C=vo(l?[a.build(),l]:[a.build()]),T=qo(s,e.initialState,w,M,y,x),F=Oi({doc:t,units:r,seats:s,surfaces:w,focal:A}),{labels:L,sections:B,rows:N}=Bi({doc:t,units:r,seats:s,surfaces:w,seatData:T,hintedSeatFloor:c,zones:F,focal:A}),j=new Map(B.map((G,H)=>[G.id,H]));w.seatOwner.forEach((G,H)=>{T.iSection[H]=G?j.get(G)??-1:-1});let D=Di({doc:t,units:r,seats:s,surfaces:w,solids:C,hintedSeatFloor:c,seatFloor:M});Fi(L,D),T.iYaw=Qo(T.iPosition,s.length,G=>s[G].rowId,G=>{let H=r[M[G]]?.focal??A;return[H.x*P,H.y*P]});let V=(u.minX+u.maxX)/2*P,X=(u.minY+u.maxY)/2*P,Z=.5*Math.hypot((u.maxX-u.minX)*P,(u.maxY-u.minY)*P)||10,U=Qn(C,T,{cx:V,cz:X,radius:Z},[d,h]),J=Qn(C,T,{cx:V,cz:X,radius:Z}),Q=kf(r),ce=Yi(T,g,u,U.minY,U.maxY,Z,Q);return{sharedAisles:ko(r.flatMap(G=>G.objects.flatMap(H=>{if(H.type!=="section")return[];let q=w.bySection.get(H.id);return q?[{sectionId:H.id,floorIndex:G.index,rows:q.rowLevels}]:[]}))),solids:C,sectionSolidRanges:b,seats:T,seatSectionIds:w.seatOwner,bounds:{center:[(ce.min[0]+ce.max[0])/2,(ce.min[1]+ce.max[1])/2,(ce.min[2]+ce.max[2])/2],radius:Z,groundY:0,box:ce,fitPoints:Vi(T,g,Q)},...v?{room:v}:{},...!v&&r.some(G=>G.objects.some(H=>H.type==="shape"&&Ct(H.stageKind)))?{outdoor:!0}:{},renderBounds:{center:U.center,radius:U.radius},clipBounds:{center:J.center,radius:J.radius},stateColorLUT:Go(n,Nt),theme:n,seatCount:s.length,focalWorld:[A.x*P,1.5,A.y*P],zones:F,stages:g,productionElements:i.elements,sections:B,rows:N,labels:L,floors:D}}function kf(e){let t=[];for(let n of e)for(let o of n.objects){let r=o.type==="gaArea"?o.points:o.type==="booth"?Ee(o):null;for(let i of r??[])t.push([i.x*P,n.baseHeightM,i.y*P])}return t}function Tf(e,t){let{doc:n,report:o}=Pi(e),r=o.confident&&(o.sections.length>0||!!o.looseRowBlocks);if(!r&&!o.roles?.length)return null;if(!r){let l=new Map(o.roles.map(m=>[m.id,m.role])),f=m=>m.map(h=>h.type==="shape"&&l.has(h.id)?{...h,role:l.get(h.id)}:h),c=e.floors?.map(m=>({...m,objects:f(m.objects)})),u=new Float64Array(t.length).fill(Number.NaN),d=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((m,h)=>{m.eyeHeightM!==void 0&&(u[h]=m.eyeHeightM),m.focalPoint&&(d[h*2]=m.focalPoint.x,d[h*2+1]=m.focalPoint.y)}),{doc:{...e,objects:c?.[0]?.objects??f(e.objects),...c?{floors:c}:{}},report:o,eyeHeightM:u,focal:d}}let i=new Map(et(n).map(l=>[l.id,l])),s=new Float64Array(t.length).fill(Number.NaN),a=new Float64Array(t.length*2).fill(Number.NaN);return t.forEach((l,f)=>{let c=i.get(l.id)??l;c.eyeHeightM!==void 0&&(s[f]=c.eyeHeightM),c.focalPoint&&(a[f*2]=c.focalPoint.x,a[f*2+1]=c.focalPoint.y)}),{doc:n,report:o,eyeHeightM:s,focal:a}}function Lf(e,t){return e.map((n,o)=>{let r=t.eyeHeightM[o],i=t.focal[o*2],s=t.focal[o*2+1],a={...n};return Number.isNaN(r)?delete a.eyeHeightM:a.eyeHeightM=r,Number.isNaN(i)?delete a.focalPoint:a.focalPoint={x:i,y:s},a})}function qi(e){let t=e.estimate===!1?null:Tf(e.doc,e.seats);return t?{input:{...e,doc:t.doc,seats:Lf(e.seats,t)},estimate:t}:{input:e}}function Of(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 Ji=self;Ji.onmessage=e=>{let t=performance.now(),n=!e.data.seats,o=e.data.seats??et(e.data.doc),{input:r,estimate:i}=qi({doc:e.data.doc,seats:o,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb,estimate:e.data.estimate}),s=Qi(r),a=Of(s);i&&a.push(i.eyeHeightM.buffer,i.focal.buffer),Ji.postMessage({model:s,buildMs:performance.now()-t,...n?{seats:o}:{},...i?{estimate:i}:{}},a)};