@seatlayer/core 0.70.0 → 0.71.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-WYXHD6J2.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/view3d/index.cjs +10 -10
- package/dist/view3d/index.js +29 -29
- package/dist/view3d/scene/scene.worker.cjs +1 -0
- package/dist/view3d/scene/scene.worker.d.cts +2 -0
- package/dist/view3d/scene/scene.worker.d.ts +2 -0
- package/dist/view3d/scene/scene.worker.js +1 -0
- package/package.json +1 -1
- /package/dist/{localeLoaders-2KZHFEV7.js → localeLoaders-EMBA3SWS.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var $n=Object.create;var Pt=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var eo=Object.getPrototypeOf,to=Object.prototype.hasOwnProperty;var no=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Jn(t))!to.call(e,o)&&o!==n&&Pt(e,o,{get:()=>t[o],enumerable:!(r=qn(t,o))||r.enumerable});return e};var Se=(e,t,n)=>(n=e!=null?$n(eo(e)):{},no(t||!e||!e.__esModule?Pt(n,"default",{value:e,enumerable:!0}):n,e));var oo=/^#?([\da-f]{3}|[\da-f]{6})$/i;function ro(e){let t=oo.exec((e??"").trim());if(!t)return null;let n=t[1].length===3?t[1].split("").map(o=>o+o).join(""):t[1],r=parseInt(n,16);return[r>>16&255,r>>8&255,r&255]}function W(e){let t=ro(e);return t?[t[0]/255,t[1]/255,t[2]/255]:null}function io(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 Ee(e,t){let n=io(e);return te(e,[n,n,n],t)}var Xe=["available","held","sold","selected","dimmed"];function Ct(e){let t=Xe.indexOf(e);return t<0?0:t}var Et={available:[.24,.82,.52],held:[.95,.66,.22],sold:[.34,.39,.45],selected:[.24,.74,1],dimmed:[.28,.32,.37]};var it={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]},st={top:[.05,.06,.08],bottom:[.1,.12,.15]};function re(e,t){return[Math.min(1,e[0]*t),Math.min(1,e[1]*t),Math.min(1,e[2]*t)]}var so=.15,ao=.9,co=1.76,lo=.7,uo=1.6;function fo(){return{background:{top:[...st.top],bottom:[...st.bottom]},structure:it,seatStates:{...Et},seatScale:1,materials:{seat:null,shell:null,roughness:.78}}}function At(e){let t=fo();if(!e)return t;let n=W(e.background);if(n){t.background={top:re(n,ao),bottom:re(n,co)};let i={};for(let[a,m]of Object.entries(it))i[a]=te(m,n,so);t.structure=i}let r=W(e.selectionColor)??W(e.accent);r&&(t.seatStates={...t.seatStates,selected:r});let o=e.seatScale;typeof o=="number"&&Number.isFinite(o)&&(t.seatScale=Math.min(uo,Math.max(lo,o)));let s=e.venue3d;if(s){let i=W(s.deck),a=W(s.fascia);i&&(t.structure={...t.structure,tierTop:i,gaTop:i}),a&&(t.structure={...t.structure,tierWall:a,gaWall:a}),t.materials.seat=W(s.seat),t.materials.shell=W(s.shell),typeof s.roughness=="number"&&Number.isFinite(s.roughness)&&(t.materials.roughness=Math.min(1,Math.max(0,s.roughness)))}return t}function _t(e,t){let n=[];for(let r of t)n.push(...e.seatStates[r]);return n}var Ot=Se(require("earcut"),1),Bt=Se(require("polygon-clipping"),1);var bi=Math.PI/180;function at(e){let t=0,n=0;for(let o of e)t+=o.x,n+=o.y;let r=e.length||1;return{x:t/r,y:n/r}}function Ae(e){return e.length?at(e):null}function he(e){let t=0;for(let n=0,r=e.length;n<r;n+=1){let o=e[n],s=e[(n+1)%r];t+=o.x*s.y-s.x*o.y}return t/2}function _e(e,t,n){let r=!1;for(let o=0,s=e.length-1;o<e.length;s=o++){let i=e[o],a=e[s];i.y>n!=a.y>n&&t<(a.x-i.x)*(n-i.y)/(a.y-i.y)+i.x&&(r=!r)}return r}var ae=.02291666666666667,fe=1/ae,mo=58,ho=mo*ae;var bo=3,kt=0,ct=120,po=0,yo=45,go=7,Ye=1.2;function lt(e,t,n,r){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):r}function xo(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=go?e:bo}function Tt(e,t={}){let n=lt(t.floorBaseHeightM,kt,ct,0),r=Math.min(ct,n+xo(e.elevation)*ho),o=e.height===void 0?r:lt(e.height,kt,ct,r),s=lt(e.rake,po,yo,0);return{height:o,rake:s}}var I=ae,Mo=.002;function So(e,t,n){let r=Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2]),o=Math.hypot(n[0]-t[0],n[1]-t[1],n[2]-t[2]),s=Math.hypot(e[0]-n[0],e[1]-n[1],e[2]-n[2]),i=Math.max(r,o,s);if(i<1e-9)return!0;let a=(r+o+s)/2;return 2*Math.sqrt(Math.max(0,a*(a-r)*(a-o)*(a-s)))/i<Mo}var de=class{constructor(t=16384){this.len=0;this.buf=new Float32Array(t)}push3(t,n,r){this.len+3>this.buf.length&&this.grow(this.len+3),this.buf[this.len++]=t,this.buf[this.len++]=n,this.buf[this.len++]=r}push1(t){this.len+1>this.buf.length&&this.grow(this.len+1),this.buf[this.len++]=t}grow(t){let n=this.buf.length*2;for(;n<t;)n*=2;let r=new Float32Array(n);r.set(this.buf.subarray(0,this.len)),this.buf=r}get length(){return this.len}toArray(){return this.buf.slice(0,this.len)}},Ke=class{constructor(){this.pos=new de;this.nor=new de;this.col=new de;this.flr=new de;this.mat=new de;this.currentFloor=0;this.currentMaterial=0}setFloor(t){this.currentFloor=t}setMaterial(t){this.currentMaterial=t}tri(t,n,r,o,s,i=s,a=s){So(t,n,r)||(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(o[0],o[1],o[2]),this.col.push3(s[0],s[1],s[2]),this.col.push3(i[0],i[1],i[2]),this.col.push3(a[0],a[1],a[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}triN(t,n,r,o,s,i,a,m=a,l=a){[...t,...n,...r].every(Number.isFinite)&&(this.pos.push3(t[0],t[1],t[2]),this.pos.push3(n[0],n[1],n[2]),this.pos.push3(r[0],r[1],r[2]),this.nor.push3(o[0],o[1],o[2]),this.nor.push3(s[0],s[1],s[2]),this.nor.push3(i[0],i[1],i[2]),this.col.push3(a[0],a[1],a[2]),this.col.push3(m[0],m[1],m[2]),this.col.push3(l[0],l[1],l[2]),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.flr.push1(this.currentFloor),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial),this.mat.push1(this.currentMaterial))}get vertexCount(){return this.pos.length/3}build(){return{position:this.pos.toArray(),normal:this.nor.toArray(),color:this.col.toArray(),floor:this.flr.toArray(),material:this.mat.toArray(),count:this.pos.length/3}}};function vo(e,t,n){let r=t[0]-e[0],o=t[1]-e[1],s=t[2]-e[2],i=n[0]-e[0],a=n[1]-e[1],m=n[2]-e[2],l=o*m-s*a,f=s*i-r*m,h=r*a-o*i,c=Math.hypot(l,f,h)||1;return l/=c,f/=c,h/=c,[l,f,h]}function wo(e,t){let n=[...e],r=[];for(let i of e)r.push(i.x,i.y);let o=[];if(t){for(let i of t)if(!(i.length<3)){o.push(n.length);for(let a of i)n.push(a),r.push(a.x,a.y)}}let s=(0,Ot.default)(r,o.length?o:void 0,2);return{pts:n,tris:s}}function ut(e){return he(e)<0?[...e].reverse():e}var Io=3;function Ro(e,t,n,r){let o=r(e),s=r(t),i=r(n),a=(u,d,b,y)=>Math.abs(r({x:(u.x+d.x)/2,y:(u.y+d.y)/2})-(b+y)/2),m=(e.x+t.x+n.x)/3,l=(e.y+t.y+n.y)/3,f=(o+s+i)/3,h=Math.max(a(e,t,o,s),a(t,n,s,i),a(n,e,i,o),Math.abs(r({x:m,y:l})-f)),c=(u,d,b)=>{let y=Math.abs(r({x:(u+m)/2,y:(d+l)/2})-(b+f)/2);y>h&&(h=y)};return c((e.x+t.x)/2,(e.y+t.y)/2,(o+s)/2),c((t.x+n.x)/2,(t.y+n.y)/2,(s+i)/2),c((n.x+e.x)/2,(n.y+e.y)/2,(i+o)/2),h}function ke(e,t,n,r,o){if(o<=0)return Ro(e,t,n,r);let s={x:(e.x+t.x)/2,y:(e.y+t.y)/2},i={x:(t.x+n.x)/2,y:(t.y+n.y)/2},a={x:(n.x+e.x)/2,y:(n.y+e.y)/2};return Math.max(ke(e,s,a,r,o-1),ke(s,t,i,r,o-1),ke(a,i,n,r,o-1),ke(s,i,a,r,o-1))}function Te(e,t,n,r,o,s,i,a){if(i>0){let c={x:(t.x+n.x)/2,y:(t.y+n.y)/2},u={x:(n.x+r.x)/2,y:(n.y+r.y)/2},d={x:(r.x+t.x)/2,y:(r.y+t.y)/2};Te(e,t,c,d,o,s,i-1,a),Te(e,c,n,u,o,s,i-1,a),Te(e,d,u,r,o,s,i-1,a),Te(e,c,u,d,o,s,i-1,a);return}let m=[t.x*I,o(t),t.y*I],l=[n.x*I,o(n),n.y*I],f=[r.x*I,o(r),r.y*I];if(a){e.triN(m,l,f,a(t),a(n),a(r),s);return}let h=vo(m,l,f);h[1]<0&&(h=[-h[0],-h[1],-h[2]]),e.tri(m,l,f,h,s)}var Po=8;function Lt(e,t,n){if(!Number.isFinite(n))return e;let r=[],o=(s,i,a,m,l)=>{if(l>0){let f={x:(s.x+i.x)/2,y:(s.y+i.y)/2},h=t(f);if(Math.abs(h-(a+m)/2)>n){o(s,f,a,h,l-1),o(f,i,h,m,l-1);return}}r.push(s)};for(let s=0;s<e.length;s++){let i=e[s],a=e[(s+1)%e.length];o(i,a,t(i),t(a),Po)}return r}function Ve(e,t){if(e.length<3)return e;let n=[];for(let o of e){let s=n[n.length-1];s&&Math.hypot(o.x-s.x,o.y-s.y)<t||n.push(o)}for(;n.length>2&&Math.hypot(n[0].x-n[n.length-1].x,n[0].y-n[n.length-1].y)<t;)n.pop();if(n.length<3)return e;let r=[];for(let o=0;o<n.length;o++){let s=r.length?r[r.length-1]:n[(o-1+n.length)%n.length],i=n[o],a=n[(o+1)%n.length],m=a.x-s.x,l=a.y-s.y,f=Math.hypot(m,l);f>t&&Math.abs((i.x-s.x)*l-(i.y-s.y)*m)/f<t||r.push(i)}return r.length>=3?r:n}var He=.001*fe*.1;function J(e,t,n,r,o,s,i,a,m=1/0,l){if(!t||t.length<3||(m===void 0&&(m=1/0),Math.abs(he(t))<1e-4))return;let f=Ve(Lt(Ve(ut(t),He),r,m),He),h=n?.map(v=>Ve(Lt(Ve(ut(v),He),r,m),He)).filter(v=>v.length>=3&&Math.abs(he(v))>=1e-4),{pts:c,tris:u}=wo(f,h),d=[s[0]*a.top,s[1]*a.top,s[2]*a.top],b=[s[0]*a.bottomCap,s[1]*a.bottomCap,s[2]*a.bottomCap],y=[i[0]*a.top,i[1]*a.top,i[2]*a.top],p=[i[0]*a.wallBottom,i[1]*a.wallBottom,i[2]*a.wallBottom],g=0;if(Number.isFinite(m))for(;g<Io;g++){let v=0;for(let R=0;R<u.length;R+=3){let k=ke(c[u[R]],c[u[R+1]],c[u[R+2]],r,g);k>v&&(v=k)}if(v<=m)break}for(let v=0;v<u.length;v+=3){let R=c[u[v]],k=c[u[v+1]],B=c[u[v+2]];Te(e,R,k,B,r,d,g,l);let D=[R.x*I,o,R.y*I],U=[k.x*I,o,k.y*I],P=[B.x*I,o,B.y*I];e.tri(D,P,U,[0,-1,0],b)}let x=v=>{if(g<=0)return v;let R=1<<g,k=[];for(let B=0;B<v.length;B++){let D=v[B],U=v[(B+1)%v.length];for(let P=0;P<R;P++){let S=P/R;k.push({x:D.x+(U.x-D.x)*S,y:D.y+(U.y-D.y)*S})}}return k},M=at(f),L=[{ring:x(f),flip:!1}];if(h)for(let v of h)v.length>=3&&L.push({ring:x(v),flip:!0});for(let{ring:v,flip:R}of L)for(let k=0;k<v.length;k++){let B=v[k],D=v[(k+1)%v.length],U=(D.x-B.x)*I,S=(D.y-B.y)*I,T=-U,_=Math.hypot(S,T)||1;S/=_,T/=_;let w=(B.x+D.x)/2-M.x,F=(B.y+D.y)/2-M.y,E=S*w+T*F;R&&(E=-E),E<0&&(S=-S,T=-T);let C=[S,0,T],A=[B.x*I,r(B),B.y*I],G=[D.x*I,r(D),D.y*I],j=[B.x*I,o,B.y*I],X=[D.x*I,o,D.y*I];e.tri(A,G,X,C,y,y,p),e.tri(A,X,j,C,y,p,p)}}function Ft(e){let t=0;for(let m of e)t+=m.count;let n=new Float32Array(t*3),r=new Float32Array(t*3),o=new Float32Array(t*3),s=new Float32Array(t),i=new Float32Array(t),a=0;for(let m of e)n.set(m.position,a*3),r.set(m.normal,a*3),o.set(m.color,a*3),s.set(m.floor,a),i.set(m.material,a),a+=m.count;return{position:n,normal:r,color:o,floor:s,material:i,count:t}}function ze(e,t,n=2.5){if(t<=0||e.length<3)return e;let r=ut(e),o=r.length,s=[];for(let a=0;a<o;a++){let m=r[a],l=r[(a+1)%o],f=l.x-m.x,h=l.y-m.y,c=Math.hypot(f,h)||1;s.push({x:h/c,y:-f/c})}let i=[];for(let a=0;a<o;a++){let m=r[a],l=s[(a-1+o)%o],f=s[a],h=l.x+f.x,c=l.y+f.y,u=Math.hypot(h,c),d=()=>{i.push([m.x+l.x*t,m.y+l.y*t]),i.push([m.x+f.x*t,m.y+f.y*t])};if(u<1e-9){d();continue}h/=u,c/=u;let b=h*l.x+c*l.y,y=1/Math.max(b,1e-6);if(!Number.isFinite(y)||y>n){d();continue}i.push([m.x+h*t*y,m.y+c*t*y])}if(i.length<3)return e;try{let a=Bt.default.union([[...i,i[0]]]),m=null,l=-1/0;for(let h of a){let c=Math.abs(he(h[0].map(([u,d])=>({x:u,y:d}))));c>l&&(l=c,m=h[0])}if(!m)return e;let f=m.map(([h,c])=>({x:h,y:c}));if(f.length>1){let h=f[0],c=f[f.length-1];Math.abs(h.x-c.x)<1e-9&&Math.abs(h.y-c.y)<1e-9&&f.pop()}return f.length>=3?f:e}catch{return e}}function We(e,t,n,r,o=28){let s=[];for(let i=0;i<o;i++){let a=i/o*Math.PI*2;s.push({x:e+n*Math.cos(a),y:t+r*Math.sin(a)})}return s}function Le(e,t,n,r){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}]}var Co=[{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"}],wi=new Map(Co.map(e=>[e.key,e]));var Eo={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 Dt(e){let t=e?.[0];return t&&Eo[t]||"#3b82f6"}var Ao=[{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"}],Ii=new Map(Ao.map(e=>[e.key,e]));var _o=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],Ri=new Set(_o);var Nt=[{key:"circle",label:"Standard seat",shortLabel:"Standard",useCase:"General assigned seating",group:"general",path:null,bounds: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}},{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}},{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}},{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}},{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}},{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}},{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}}],jt=Nt.map(e=>e.key),ko=new Map(Nt.map(e=>[e.key,e]));function Gt(e){return typeof e=="string"&&ko.has(e)}function Ut(e,t){return Gt(e)?e:Gt(t?.seatGlyph)?t.seatGlyph:"circle"}var ee={pedestal:0,pad:1,back:2,arm:3,footrest:4,leg:5,body:10,head:11},To=.44,Lo=.15,Oo=.3,Bo=.24;function Xt(e){return e===void 0||!Number.isFinite(e)||e<=0?Bo:Math.min(Oo,Math.max(Lo,e*To))}var Fo=.05,Yt=.45,Do=Yt+Fo,_i=[{part:ee.pedestal,min:[-.3,0,-.3],max:[.3,.36,.3]},{part:ee.pad,min:[-1,.36,-.95],max:[1,Yt,1]},{part:ee.back,min:[-1,Do,-1],max:[1,.92,-.72]},{part:ee.arm,min:[-1,.44,-.82],max:[-.78,.65,.78]},{part:ee.arm,min:[.78,.44,-.82],max:[1,.65,.78]},{part:ee.footrest,min:[-.9,.18,.78],max:[.9,.31,1.34]},{part:ee.leg,min:[-.82,0,-.7],max:[-.62,.37,-.48]},{part:ee.leg,min:[.62,0,-.7],max:[.82,.37,-.48]},{part:ee.leg,min:[-.82,0,.48],max:[-.62,.37,.7]},{part:ee.leg,min:[.62,0,.48],max:[.82,.37,.7]}],ki=[{part:ee.body,min:[-.52,.39,-.08],max:[-.08,.55,.82]},{part:ee.body,min:[.08,.39,-.08],max:[.52,.55,.82]},{part:ee.body,min:[-.47,.05,.58],max:[-.13,.43,.82]},{part:ee.body,min:[.13,.05,.58],max:[.47,.43,.82]},{part:ee.head,min:[-.16,1.04,-.33],max:[.16,1.1,-.13]}];function Vt(e,t,n,r){let o=new Float32Array(t),s=l=>e[l*3],i=l=>e[l*3+2],a=0,m=(l,f)=>{let h=f-l;for(let c=l;c<f;c++){let[u,d]=r(c),b=u-s(c),y=d-i(c);if(h>=2){let p=Math.max(l,c-1),g=Math.min(f-1,c+1),x=s(g)-s(p),M=i(g)-i(p),L=Math.hypot(x,M);if(L>1e-6){let v=-M/L,R=x/L;v*b+R*y<0&&(v=-v,R=-R),b=v,y=R}}o[c]=b===0&&y===0?0:Math.atan2(b,y)}};for(let l=1;l<=t;l++)(l===t||n(l)!==n(a))&&(m(a,l),a=l);return o}var Ze=.22;var Go=.42;function No(e){let t=e.length,n=new Float64Array(t);if(t<2)return n.fill(1/0),n;let r=1/0,o=1/0,s=-1/0,i=-1/0;for(let d of e)d.x<r&&(r=d.x),d.y<o&&(o=d.y),d.x>s&&(s=d.x),d.y>i&&(i=d.y);let a=Math.max(s-r,1e-6),m=Math.max(i-o,1e-6),l=Math.max(Math.sqrt(a*m/t),1e-6),f=Math.max(1,Math.ceil(a/l)+1),h=Math.max(1,Math.ceil(m/l)+1),c=new Map,u=(d,b)=>{let y=Math.min(f-1,Math.max(0,Math.floor((d-r)/l)));return Math.min(h-1,Math.max(0,Math.floor((b-o)/l)))*f+y};for(let d=0;d<t;d++){let b=u(e[d].x,e[d].y),y=c.get(b);y?y.push(d):c.set(b,[d])}for(let d=0;d<t;d++){let b=e[d],y=Math.min(f-1,Math.max(0,Math.floor((b.x-r)/l))),p=Math.min(h-1,Math.max(0,Math.floor((b.y-o)/l))),g=1/0;for(let x=1;x<=4;x++){for(let M=p-x;M<=p+x;M++)if(!(M<0||M>=h))for(let L=y-x;L<=y+x;L++){if(L<0||L>=f||x>1&&Math.abs(M-p)<x&&Math.abs(L-y)<x)continue;let v=c.get(M*f+L);if(v)for(let R of v){if(R===d)continue;let k=Math.hypot(e[R].x-b.x,e[R].y-b.y);k<g&&(g=k)}}if(Number.isFinite(g)&&g<=x*l)break}n[d]=g}return n}function jo(e){let t=e.eyeHeightM;return Number.isFinite(t)?Math.max(0,t-Ye):0}function Ht(e,t,n,r,o,s){let i=e.length,a=new Float32Array(i*3),m=new Float32Array(i),l=new Float32Array(i*3),f=new Float32Array(i),h=new Float32Array(i),c=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i*3),b=new Map,y=No(e);for(let p=0;p<i;p++){let g=e[p],M=(n?.seatPitchU(p)??y[p])*I;f[p]=Number.isFinite(M)?Math.max(.06,Math.min(Ze,M*Go)):Ze,h[p]=Xt(Number.isFinite(M)?M:void 0);let L=Ut(g.glyph,{seatGlyph:s?.get(g.categoryKey)});c[p]=jt.indexOf(L),u[p]=g.wheelchairSpaceType==="no-seat"?0:1,a[p*3]=g.x*I,a[p*3+1]=n?n.seatDeckY(p):jo(g),a[p*3+2]=g.y*I,m[p]=Ct(t?t(g):"available");let v=W(o?.get(g.categoryKey)??"#6e7bff")??[.43,.48,1];if(l[p*3]=v[0],l[p*3+1]=v[1],l[p*3+2]=v[2],g.accessibility?.length){let R=W(Dt(g.accessibility));R&&(d[p*3]=R[0],d[p*3+1]=R[1],d[p*3+2]=R[2])}b.set(g.id,p)}return{count:i,iPosition:a,iState:m,iCategory:l,iMaxRadius:f,iRing:d,idToIndex:b,iChairWidth:h,iGlyph:c,iPhysicalSeat:u,iFloor:r??new Float32Array(i),iYaw:new Float32Array(i)}}function Kt(e){let t=e.length;return t<=3?[...e]:[e[Math.floor(t*.25)],e[Math.floor(t*.5)],e[Math.floor(t*.75)]]}function ve(e,t,n){if(!e.length)return 1/0;if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let r=1/0;for(let o=0;o+1<e.length;o++){let s=e[o],i=e[o+1],a=i.x-s.x,m=i.y-s.y,l=a*a+m*m,f=l>1e-12?((t-s.x)*a+(n-s.y)*m)/l:0;f<0?f=0:f>1&&(f=1);let h=Math.hypot(t-(s.x+f*a),n-(s.y+f*m));h<r&&(r=h)}return r}function Uo(e){let t=0,n=0;for(let s of e)t+=s.x,n+=s.y;let r=e.length||1;t/=r,n/=r;let o=0;for(let s of e){let i=Math.hypot(s.x-t,s.y-n);i>o&&(o=i)}return{cx:t,cy:n,r:o}}function zt(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function ft(e,t){let n=1/0;for(let r of Kt(e)){let o=ve(t,r.x,r.y);o<n&&(n=o)}for(let r of Kt(t)){let o=ve(e,r.x,r.y);o<n&&(n=o)}return n}function Xo(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,r=0;for(let f of e)n+=f.x,r+=f.y;n/=e.length,r/=e.length;let o=-1,s=e[0];for(let f of e){let h=Math.hypot(f.x-n,f.y-r);h>o&&(o=h,s=f)}let i=s.x-n,a=s.y-r,m=Math.hypot(i,a);m>1e-9?(i/=m,a/=m):(i=1,a=0);let l=e.map((f,h)=>({p:f,i:h,t:(f.x-n)*i+(f.y-r)*a})).sort((f,h)=>f.t-h.t);return{pts:l.map(f=>f.p),seatIndices:l.map(f=>t[f.i])}}function mt(e){let t=e.length;if(t<3)return null;let n=0,r=0;for(let g of e)n+=g.x,r+=g.y;n/=t,r/=t;let o=0,s=0,i=0,a=0,m=0,l=0,f=0;for(let g of e){let x=g.x-n,M=g.y-r;o+=x*x,i+=M*M,s+=x*M,a+=x*x*x,m+=M*M*M,l+=x*M*M,f+=M*x*x}let h=o*i-s*s;if(Math.abs(h)<1e-9)return null;let c=(a+l)/2,u=(m+f)/2,d=(c*i-u*s)/h,b=(u*o-c*s)/h,y=d+n,p=b+r;return!Number.isFinite(y)||!Number.isFinite(p)?null:{cx:y,cy:p}}var Yo=.15;function Vo(e){if(e.length<2)return null;let t=e.map(g=>{let x=0,M=0;for(let L of g.pts)x+=L.x,M+=L.y;return{x:x/g.pts.length,y:M/g.pts.length}}),n=0,r=0;for(let g of t)n+=g.x,r+=g.y;n/=t.length,r/=t.length;let o=0,s=0,i=0;for(let g of t){let x=g.x-n,M=g.y-r;o+=x*x,s+=x*M,i+=M*M}let a=o+i,m=o*i-s*s,l=a/2+Math.sqrt(Math.max(0,a*a/4-m)),f,h;Math.abs(s)>1e-12?(f=l-i,h=s):o>=i?(f=1,h=0):(f=0,h=1);let c=Math.hypot(f,h);if(!(c>1e-12))return null;f/=c,h/=c;let u=1/0,d=-1/0,b=[];for(let g of e){let x=1/0,M=-1/0;for(let L of g.pts){let v=L.x*f+L.y*h;v<x&&(x=v),v>M&&(M=v),v<u&&(u=v),v>d&&(d=v)}b.push(M-x)}let y=d-u;return y>1e-9?(b.sort((g,x)=>g-x),b[Math.min(b.length-1,Math.floor(b.length*.9))]/y<=Ho?{x:f,y:h}:null):null}var Ho=.35;function Wt(e,t,n,r){let o=new Map;for(let y of n){let p=t[y],g=p.rowId||`__seat-${y}`,x=o.get(g);x||(x={pts:[],idx:[]},o.set(g,x)),x.pts.push({x:p.x,y:p.y}),x.idx.push(y)}if(!o.size)return{sectionId:e,rows:[],blockCount:0};let s=[];for(let[y,p]of o){let g=Xo(p.pts,p.idx),x=0;for(let M of g.pts)x+=Math.hypot(M.x-r.x,M.y-r.y);s.push({id:y,pts:g.pts,seatIndices:g.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:x/g.pts.length})}let i=s.map(y=>Uo(y.pts)),a=[];for(let y=0;y<s.length;y++){let p=1/0;for(let g=0;g<s.length;g++){if(y===g||zt(i[y],i[g])>=p)continue;let x=ft(s[y].pts,s[g].pts);x<p&&(p=x)}Number.isFinite(p)&&a.push(p)}a.sort((y,p)=>y-p);let m=a.length?a[Math.floor(a.length/2)]:1,l=Math.max(m*1.8,1e-6),f=s.map(()=>[]);for(let y=0;y<s.length;y++)for(let p=y+1;p<s.length;p++)zt(i[y],i[p])>l||ft(s[y].pts,s[p].pts)<=l&&(f[y].push(p),f[p].push(y));let h=0;for(let y=0;y<s.length;y++){if(s[y].blockId!==-1)continue;let p=h++,g=[y];for(s[y].blockId=p;g.length;){let x=g.pop();for(let M of f[x])s[M].blockId===-1&&(s[M].blockId=p,g.push(M))}}let c=new Map;for(let y of s){let p=c.get(y.blockId)??[];p.push(y),c.set(y.blockId,p)}let u=[];for(let y of s){if(y.pts.length<4)continue;let p=mt(y.pts);p&&(!Number.isFinite(p.cx)||!Number.isFinite(p.cy)||u.push({x:p.cx,y:p.cy}))}let d=u.length>=2?(()=>{let y=u.map(x=>x.x).sort((x,M)=>x-M),p=u.map(x=>x.y).sort((x,M)=>x-M),g=Math.floor(u.length/2);return{cx:y[g],cy:p[g]}})():null;if(d){let y=v=>Math.hypot(v.x-d.cx,v.y-d.cy),p=1/0,g=-1/0,x=[];for(let v of s){let R=1/0,k=-1/0;for(let B of v.pts){let D=y(B);D<R&&(R=D),D>k&&(k=D)}x.push(k-R),R<p&&(p=R),k>g&&(g=k)}let M=g-p;x.sort((v,R)=>v-R);let L=x[Math.min(x.length-1,Math.floor(x.length*.9))];if(M>1e-9&&L/M<=Yo){let v=s.map(w=>{let F=0;for(let E of w.pts)F+=y(E);return{row:w,radius:F/w.pts.length}}),R=0,k=0;for(let w of v)R+=w.radius,k+=w.row.focalDistance;R/=v.length,k/=v.length;let B=0;for(let w of v)B+=(w.radius-R)*(w.row.focalDistance-k);if(B<0)for(let w of v)w.radius=-w.radius;let U=1/0;for(let w of v)w.radius<U&&(U=w.radius);v.sort((w,F)=>w.radius-F.radius);let P=-1,S=-1/0,T=M/Math.max(1,v.length)*.5,_=[];for(let w of v)w.radius-S>T&&(P++,S=w.radius),w.row.ordinal=P,w.row.blockDepth=w.radius-U,_.push(w.row);return{sectionId:e,rows:_,blockCount:h}}}let b=[];for(let[,y]of c){let p=Vo(y);if(p){let g=M=>{let L=0;for(let v of M.pts)L+=v.x*p.x+v.y*p.y;return L/M.pts.length};y.sort((M,L)=>g(M)-g(L)),y.length>=2&&y[0].focalDistance>y[y.length-1].focalDistance&&y.reverse();let x=0;for(let M=0;M<y.length;M++)M>0&&(x+=ft(y[M-1].pts,y[M].pts)),y[M].ordinal=M,y[M].blockDepth=x,b.push(y[M])}else{let g=1/0;for(let x of y)x.focalDistance<g&&(g=x.focalDistance);y.sort((x,M)=>x.focalDistance-M.focalDistance);for(let x=0;x<y.length;x++)y[x].ordinal=x,y[x].blockDepth=Math.max(0,y[x].focalDistance-g),b.push(y[x])}}return{sectionId:e,rows:b,blockCount:h}}var Xi=Math.PI/180;function Zt(e,t){let n=!1;for(let r=0,o=t.length-1;r<t.length;o=r++){let s=t[r].x,i=t[r].y,a=t[o].x,m=t[o].y;i>e.y!=m>e.y&&e.x<(a-s)*(e.y-i)/(m-i)+s&&(n=!n)}return n}function Ko(e,t){return t.some((n,r)=>{let o=t[(r+1)%t.length],s=(e.y-n.y)*(o.x-n.x)-(e.x-n.x)*(o.y-n.y);if(Math.abs(s)>1e-7)return!1;let i=(e.x-n.x)*(o.x-n.x)+(e.y-n.y)*(o.y-n.y),a=(o.x-n.x)**2+(o.y-n.y)**2;return i>=-1e-7&&i<=a+1e-7})}function ht(e,t,n){return Zt(e,t)&&!(n??[]).some(r=>Zt(e,r)||Ko(e,r))}function zo(e){return{kind:"radial",rowCount:0,rows:[],nearestRow:()=>-1,depthAt:(t,n)=>Math.hypot(t-e.x,n-e.y),gradientAt:(t,n)=>{let r=t-e.x,o=n-e.y,s=Math.hypot(r,o);return s<1e-9?[0,0]:[r/s,o/s]}}}function Wo(e,t){if(!e.length)return null;let n=0,r=0,o=0;for(let u of e)n+=u.x,r+=u.y,o+=Math.hypot(u.x-t.x,u.y-t.y);let s=e.length;n/=s,r/=s,o/=s;let i=e[0],a=-1;for(let u of e){let d=Math.hypot(u.x-n,u.y-r);d>a&&(a=d,i=u)}let m=i.x-n,l=i.y-r,f=Math.hypot(m,l);f>1e-9?(m/=f,l/=f):(m=1,l=0);let h=[...e].sort((u,d)=>(u.x-n)*m+(u.y-r)*l-((d.x-n)*m+(d.y-r)*l)),c=0;for(let u of h){let d=Math.hypot(u.x-n,u.y-r);d>c&&(c=d)}return{pts:h,cx:n,cy:r,radius:c,depth:o}}function Qt(e,t,n){let r=e.pts;if(r.length===1)return Math.hypot(t-r[0].x,n-r[0].y);let o=1/0;for(let s=0;s+1<r.length;s++){let i=r[s],a=r[s+1],m=a.x-i.x,l=a.y-i.y,f=m*m+l*l,h=f>1e-12?((t-i.x)*m+(n-i.y)*l)/f:0;h<0?h=0:h>1&&(h=1);let c=Math.hypot(t-(i.x+h*m),n-(i.y+h*l));c<o&&(o=c)}return o}var Qe=8;function Zo(e,t,n){let r=new Array(Qe).fill(1/0),o=new Array(Qe).fill(-1);for(let f=0;f<e.length;f++){let h=e[f],c=Math.hypot(t-h.cx,n-h.cy)-h.radius;for(let u=0;u<Qe;u++)if(c<r[u]){for(let d=Qe-1;d>u;d--)r[d]=r[d-1],o[d]=o[d-1];r[u]=c,o[u]=f;break}}let s=new Array(3).fill(1/0),i=new Array(3).fill(-1);for(let f of o){if(f<0)continue;let h=Qt(e[f],t,n);for(let c=0;c<3;c++)if(h<s[c]){for(let u=2;u>c;u--)s[u]=s[u-1],i[u]=i[u-1];s[c]=h,i[c]=f;break}}if(i[0]<0)return 0;if(s[0]<1e-6)return e[i[0]].depth;let a=s[0]*2.2,m=0,l=0;for(let f=0;f<3;f++){let h=i[f];if(h<0||s[f]>a)continue;let c=1/(s[f]*s[f]);m+=c*e[h].depth,l+=c}return l>0?m/l:e[i[0]].depth}function Qo(e){let t=(r,o)=>Zo(e,r,o),n=(r,o)=>{let s=1/0,i=-1;for(let a=0;a<e.length;a++){let m=e[a];if(Math.hypot(r-m.cx,o-m.cy)-m.radius>=s)continue;let l=Qt(m,r,o);l<s&&(s=l,i=a)}return i};return{kind:"rows",rowCount:e.length,rows:e,nearestRow:n,depthAt:t,gradientAt:(r,o)=>{let s=(t(r+.5,o)-t(r-.5,o))/1,i=(t(r,o+.5)-t(r,o-.5))/(2*.5),a=Math.hypot(s,i);return a<1e-9?[0,0]:[s/a,i/a]}}}function $t(e,t){let n=[];for(let r of e){let o=Wo(r.points,t);o&&n.push(o)}return n.length<2?zo(t):(n.sort((r,o)=>r.depth-o.depth),Qo(n))}var pt=Se(require("polygon-clipping"),1);var tn=Se(require("earcut"),1);var $o=.58,qt=.01,ie=Ze*1.5*fe,qo=.5,Jo=.6;function er(e,t){let n=e.length,r=[];for(let i=0;i<n;i++){let a=e[Math.max(0,i-1)],m=e[Math.min(n-1,i+1)],l=m.x-a.x,f=m.y-a.y,h=Math.hypot(l,f);if(h<1e-9){r.push([0,0]);continue}l/=h,f/=h,r.push([-f,l])}let o=0;for(let i=0;i<n;i++)o+=(e[i].x-t.x)*r[i][0]+(e[i].y-t.y)*r[i][1];return o<0?r.map(([i,a])=>[-i,-a]):r}function tr(e,t){if(e.length<2||t<=0)return[...e];let n=[...e],r=(i,a)=>{let m=a.x-i.x,l=a.y-i.y,f=Math.hypot(m,l)||1;return{x:m/f,y:l/f}},o=r(n[1],n[0]),s=r(n[n.length-2],n[n.length-1]);return n.unshift({x:n[0].x+o.x*t,y:n[0].y+o.y*t}),n.push({x:n[n.length-1].x+s.x*t,y:n[n.length-1].y+s.y*t}),n}var Jt=Math.PI/12;function nr(e){if(e.length<3)return[...e];let t=[...e].sort((s,i)=>s.x-i.x||s.y-i.y),n=(s,i,a)=>(i.x-s.x)*(a.y-s.y)-(i.y-s.y)*(a.x-s.x),r=s=>{let i=[];for(let a of s){for(;i.length>=2&&n(i[i.length-2],i[i.length-1],a)<=0;)i.pop();i.push(a)}return i.pop(),i},o=[...r(t),...r([...t].reverse())];return o.length>=3?o:[...e]}function nn(e,t){if(!e.length||!(t>0))return[];let n=nr(e),r=(a,m,l,f)=>{let h=l-m;for(;h<0;)h+=Math.PI*2;for(;h>Math.PI*2;)h-=Math.PI*2;let c=Math.max(1,Math.ceil(h/Jt)),u=t/Math.cos(h/c/2);for(let d=0;d<=c;d++){let b=m+h*d/c;f.push({x:a.x+Math.cos(b)*u,y:a.y+Math.sin(b)*u})}};if(n.length<3){let a=0,m=0;for(let u of n)a+=u.x,m+=u.y;a/=n.length||1,m/=n.length||1;let l=0;for(let u of n)l=Math.max(l,Math.hypot(u.x-a,u.y-m));let f=[],h=Math.max(3,Math.ceil(Math.PI*2/Jt)),c=(l+t)/Math.cos(Math.PI/h);for(let u=0;u<h;u++){let d=u/h*Math.PI*2;f.push({x:a+Math.cos(d)*c,y:m+Math.sin(d)*c})}return f}let o=n.length,s=[];for(let a=0;a<o;a++){let m=n[a],l=n[(a+1)%o];s.push(Math.atan2(-(l.x-m.x),l.y-m.y))}let i=[];for(let a=0;a<o;a++)r(n[a],s[(a+o-1)%o],s[a],i);return cn(i)}function or(e,t,n){if(e.length===1)return Math.hypot(t-e[0].x,n-e[0].y);let r=1/0;for(let o=0;o+1<e.length;o++){let s=e[o],i=e[o+1],a=i.x-s.x,m=i.y-s.y,l=a*a+m*m,f=l>1e-12?((t-s.x)*a+(n-s.y)*m)/l:0;f<0?f=0:f>1&&(f=1);let h=Math.hypot(t-(s.x+f*a),n-(s.y+f*m));h<r&&(r=h)}return r}function $e(e){let t=e.map(o=>{let s=0,i=0;for(let l of o.pts)s+=l.x,i+=l.y;let a=o.pts.length||1;s/=a,i/=a;let m=0;for(let l of o.pts){let f=Math.hypot(l.x-s,l.y-i);f>m&&(m=f)}return{cx:s,cy:i,rad:m}}),n=o=>{let s=o.length;return s<=2?[...o]:[o[Math.floor(s*.25)],o[Math.floor(s*.5)],o[Math.floor(s*.75)]]},r=[];for(let o=0;o<e.length;o++){let s=n(e[o].pts),i=[],a=1/0,m=null;for(let f of s){let h=1/0;for(let c=0;c<e.length;c++){if(c===o||Math.abs(e[c].y-e[o].y)<.001)continue;let u=t[c],d=Math.hypot(f.x-u.cx,f.y-u.cy)-u.rad;if(d>=h&&d>=a)continue;let b=or(e[c].pts,f.x,f.y);b<h&&(h=b),e[c].depth<e[o].depth&&b<a&&(a=b,m=e[c].y)}Number.isFinite(h)&&h>0&&i.push(h)}i.sort((f,h)=>f-h);let l=i.length?i[Math.floor(i.length/2)]:1;r.push({pitch:l,belowY:m})}return r}function on(e,t,n,r){let o=e[t],s=o.pts.length>=2?[...o.pts]:o.pts.length===1?(()=>{let f=o.pts[0],h=f.x-r.x,c=f.y-r.y,u=Math.hypot(h,c)||1;h/=u,c/=u;let d=Math.max(n[t].pitch,.001)*.5;return[{x:f.x+c*d,y:f.y-h*d},{x:f.x-c*d,y:f.y+h*d}]})():[];if(s.length<2)return null;let i=0,a=0;for(let f=1;f<s.length;f++){let h=Math.hypot(s[f].x-s[f-1].x,s[f].y-s[f-1].y);h>1e-6&&(i+=h,a++)}let m=a>0?i/a:0,l=tr(s,Math.max(m*Jo,ie));return{pts:l,nrm:er(l,r),front:Math.max(n[t].pitch*$o,ie),back:Math.max(n[t].pitch*qo,ie)}}var we=1.5,rn=.3;function dt(e,t){if(e.length<3)return e;let n=e[0],r=e[e.length-1],o=r.x-n.x,s=r.y-n.y,i=Math.hypot(o,s),a=-1,m=-1;for(let h=1;h<e.length-1;h++){let c=e[h],u=i>1e-12?Math.abs((c.x-n.x)*s-(c.y-n.y)*o)/i:Math.hypot(c.x-n.x,c.y-n.y);u>a&&(a=u,m=h)}if(a<=t||m<0)return[n,r];let l=dt(e.slice(0,m+1),t),f=dt(e.slice(m),t);return[...l.slice(0,-1),...f]}function sn(e,t){if(e.length<4)return e;let n=dt([...e,e[0]],t);return n.pop(),n.length>=3?n:e}function an(e,t,n){if(e.length<2)return[];let r=n??$e(e),o=new Map;for(let i=0;i<e.length;i++){let a=o.get(e[i].blockId);a?a.push(i):o.set(e[i].blockId,[i])}let s=[];for(let[,i]of o){let a=[];for(let g of i){let x=e[g].patch;x&&x.length>=3?s.push({outline:[...x],holes:[],topY:e[g].y}):a.push(g)}if(!a.length)continue;a.sort((g,x)=>e[g].depth-e[x].depth);let l=a.map(g=>on(e,g,r,t)).filter(g=>g!==null);if(!l.length)continue;let f=(g,x)=>({x:g.pts[x].x-g.nrm[x][0]*(g.front+we),y:g.pts[x].y-g.nrm[x][1]*(g.front+we)}),h=(g,x)=>({x:g.pts[x].x+g.nrm[x][0]*(g.back+we),y:g.pts[x].y+g.nrm[x][1]*(g.back+we)}),c=l[0],u=l[l.length-1],d=[];for(let g=0;g<c.pts.length;g++)d.push(f(c,g));for(let g of l)d.push(h(g,g.pts.length-1));for(let g=u.pts.length-1;g>=0;g--)d.push(h(u,g));for(let g=l.length-1;g>=0;g--)d.push(f(l[g],0));let b=cn(d),y=1/0;for(let g of a)e[g].y<y&&(y=e[g].y);if(!Number.isFinite(y))continue;if(b.length>=3&&Math.abs(he(b))>1e-6&&l.every(g=>{let x=g.pts[Math.floor(g.pts.length/2)];return _e(b,x.x,x.y)})){s.push({outline:sn(b,rn),holes:[],topY:y});continue}for(let g of rr(l))s.push({outline:g,holes:[],topY:y})}return s}function rr(e){let t=[];for(let n of e){let r=[],o=[],s=n.front+we,i=n.back+we;for(let m=0;m<n.pts.length;m++){let l=n.pts[m],f=n.nrm[m];r.push([l.x-f[0]*s,l.y-f[1]*s]),o.push([l.x+f[0]*i,l.y+f[1]*i])}let a=[...r,...o.reverse()];a.length<3||(a.push(a[0]),t.push([a]))}if(!t.length)return[];try{let n=pt.default.union(t[0],...t.slice(1)),r=[];for(let o of n){if(!o.length||o[0].length<4)continue;let s=o[0].map(([m,l])=>({x:m,y:l})),i=s[0],a=s[s.length-1];s.length>1&&Math.abs(i.x-a.x)<1e-9&&Math.abs(i.y-a.y)<1e-9&&s.pop(),s.length>=3&&r.push(sn(s,rn))}return r}catch{return[]}}function cn(e){let t=[];for(let n of e){let r=t[t.length-1];r&&Math.hypot(n.x-r.x,n.y-r.y)<1e-9||t.push(n)}for(;t.length>2&&Math.hypot(t[0].x-t[t.length-1].x,t[0].y-t[t.length-1].y)<1e-9;)t.pop();return t}var bt=class{constructor(t){this.minX=1/0;this.minY=1/0;this.maxX=-1/0;this.maxY=-1/0;this.rings=t;for(let n of t)for(let r of n)r.x<this.minX&&(this.minX=r.x),r.y<this.minY&&(this.minY=r.y),r.x>this.maxX&&(this.maxX=r.x),r.y>this.maxY&&(this.maxY=r.y)}containsAll(t){for(let n of t)if(n.x<this.minX||n.x>this.maxX||n.y<this.minY||n.y>this.maxY)return!1;for(let n of this.rings){let r=!0;for(let o of t)if(!_e(n,o.x,o.y)){r=!1;break}if(r)return!0}return!1}};function en(e,t,n,r,o,s){if(r.length<3)return;if(n.containsAll(r)){let l=[0,1,0],f=r[0];for(let h=1;h+1<r.length;h++){let c=r[h],u=r[h+1];e.tri([f.x*I,o,f.y*I],[c.x*I,o,c.y*I],[u.x*I,o,u.y*I],l,s)}return}let i=r.map(l=>[l.x,l.y]);i.push(i[0]);let a;try{a=pt.default.intersection([i],t)}catch{return}let m=[0,1,0];for(let l of a){if(!l.length||l[0].length<4)continue;let f=l[0],h=[],c=[];for(let d=0;d<f.length-1;d++)h.push(f[d][0],f[d][1]),c.push([f[d][0],f[d][1]]);if(c.length<3)continue;let u=(0,tn.default)(h,void 0,2);for(let d=0;d<u.length;d+=3){let b=c[u[d]],y=c[u[d+1]],p=c[u[d+2]];e.tri([b[0]*I,o,b[1]*I],[y[0]*I,o,y[1]*I],[p[0]*I,o,p[1]*I],m,s)}}}function ln(e,t,n,r,o,s,i){if(t.length<2)return;let a=i??$e(t),m=[0,1,0],l=s&&s.length>=3?[[...s.map(u=>[u.x,u.y]),[s[0].x,s[0].y]]]:null,f=s&&s.length>=3?new bt([[...s]]):null,h=u=>{e.setMaterial(2),u(),e.setMaterial(0)},c=u=>{e.setMaterial(3),u(),e.setMaterial(0)};for(let u=0;u<t.length;u++){let d=t[u];if(d.patch&&d.patch.length>=3){let L=[...d.patch],v=a[u].belowY??r;if(c(()=>{if(l&&f)en(e,l,f,L,d.y,o.tread);else{let R=L[0];for(let k=1;k+1<L.length;k++){let B=L[k],D=L[k+1];e.tri([R.x*I,d.y,R.y*I],[B.x*I,d.y,B.y*I],[D.x*I,d.y,D.y*I],m,o.tread)}}}),d.y>v+qt){let R=0,k=0;for(let B of L)R+=B.x,k+=B.y;R/=L.length,k/=L.length,h(()=>{for(let B=0;B<L.length;B++){let D=L[B],U=L[(B+1)%L.length],P=U.x-D.x,S=U.y-D.y,T=Math.hypot(P,S);if(T<1e-6)continue;let _=S/T,w=-P/T;(D.x-R)*_+(D.y-k)*w<0&&(_=-_,w=-w);let F=[_,0,w],E=[D.x*I,d.y,D.y*I],C=[U.x*I,d.y,U.y*I],A=[D.x*I,v,D.y*I],G=[U.x*I,v,U.y*I];e.tri(E,C,G,F,o.riser),e.tri(E,G,A,F,o.riser)}})}continue}let b=on(t,u,a,n);if(!b)continue;let{pts:y,nrm:p,front:g,back:x}=b,M=a[u].belowY??r;for(let L=0;L+1<y.length;L++){let v=y[L],R=y[L+1],k=p[L],B=p[L+1];if(Math.hypot(R.x-v.x,R.y-v.y)<1e-6||k[0]===0&&k[1]===0||B[0]===0&&B[1]===0)continue;let D=[(v.x-k[0]*g)*I,d.y,(v.y-k[1]*g)*I],U=[(R.x-B[0]*g)*I,d.y,(R.y-B[1]*g)*I],P=[(v.x+k[0]*x)*I,d.y,(v.y+k[1]*x)*I],S=[(R.x+B[0]*x)*I,d.y,(R.y+B[1]*x)*I];if(c(()=>{l&&f?en(e,l,f,[{x:v.x-k[0]*g,y:v.y-k[1]*g},{x:R.x-B[0]*g,y:R.y-B[1]*g},{x:R.x+B[0]*x,y:R.y+B[1]*x},{x:v.x+k[0]*x,y:v.y+k[1]*x}],d.y,o.tread):(e.tri(D,U,S,m,o.tread),e.tri(D,S,P,m,o.tread))}),d.y>M+qt){let T=[D[0],M,D[2]],_=[U[0],M,U[2]],w=[-k[0],0,-k[1]];h(()=>{e.tri(D,U,_,w,o.riser),e.tri(D,_,T,w,o.riser)})}}}}function un(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,s=!1;for(let i of e)!Number.isFinite(i.x)||!Number.isFinite(i.y)||(s=!0,i.x<t&&(t=i.x),i.y<n&&(n=i.y),i.x>r&&(r=i.x),i.y>o&&(o=i.y));return s?{minX:t,minY:n,maxX:r,maxY:o}:null}function qe(e,t){return e.minX<=t.maxX&&t.minX<=e.maxX&&e.minY<=t.maxY&&t.minY<=e.maxY}var yt=Se(require("polygon-clipping"),1);function ir(e,t){let n=e.eventConfigurationIds;return!n?.length||!!t&&n.includes(t)}function fn(e,t){return e.filter(n=>n.type!=="shape"||ir(n,t))}function mn(e,t){let n=e.focalPoint??{x:0,y:0};return e.floors?.length?e.floors.map((r,o)=>({objects:fn(r.objects,t),focal:{x:(r.focalPoint??n).x,y:(r.focalPoint??n).y},baseHeightM:r.baseHeightM??0,index:o})):[{objects:fn(e.objects,t),focal:n,baseHeightM:0,index:0}]}var sr={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};function Ie(e){return un(e)??sr}function hn(e,t){let n=ze(e.outline,ie),r=Ie(n),o=t.filter(i=>i!==e&&i.outline&&i.outline.length>=3&&qe(r,Ie(i.outline)));if(!o.length)return[n];let s=i=>{let a=i.map(m=>[m.x,m.y]);return a.push(a[0]),a};try{let i=yt.default.difference([s(n)],...o.map(m=>[s(m.outline)])),a=[];for(let m of i){if(!m.length)continue;let l=m[0].map(([f,h])=>({x:f,y:h}));if(l.length>1){let f=l[0],h=l[l.length-1];Math.abs(f.x-h.x)<1e-9&&Math.abs(f.y-h.y)<1e-9&&l.pop()}l.length>=3&&a.push(l)}return a.length?a:[n]}catch{return[n]}}function dn(e,t){if(!t.length)return e;let n=s=>{let i=s.map(a=>[a.x,a.y]);return i.push(i[0]),i},r=t.map(s=>[n(s)]),o=[];for(let s of e){let i;try{i=yt.default.intersection([n(s.outline)],r.flat())}catch{o.push(s);continue}for(let a of i){if(!a.length)continue;let m=a[0].map(([l,f])=>({x:l,y:f}));if(m.length>1){let l=m[0],f=m[m.length-1];Math.abs(l.x-f.x)<1e-9&&Math.abs(l.y-f.y)<1e-9&&m.pop()}m.length>=3&&o.push({outline:m,holes:[],topY:s.topY})}}return o.length?o:e}var ar=.05,bn=.05,cr=.15,gt=25;function pn(e,t,n){let r=new Map,o=new Array(t.length).fill(null),s=new Float64Array(t.length),i=new Array(t.length).fill(void 0),a=new Array(t.length).fill(void 0),m=new Map,l=[],f=new Set;for(let c=0;c<e.length;c+=1){let u=e[c];for(let d of u.objects){if(d.type==="table"&&f.add(d.id),d.type!=="section"||!d.outline||d.outline.length<3)continue;let b=ze(d.outline,ie);m.set(d.id,{section:d,unit:u,frontU:1/0,hasSeats:!1,rows:new Map,seatIndices:[]}),l.push({id:d.id,floorIndex:c,box:Ie(b),section:d,unit:u,outline:b})}}let h=new Map;for(let c of l){let u=h.get(c.floorIndex);u?u.push(c):h.set(c.floorIndex,[c])}for(let c=0;c<t.length;c++){let u=t[c],d=n?h.get(n[c])??[]:l,b=u.sectionId?d.find(p=>p.id===u.sectionId)??d.find(p=>p.section.logicalSectionId===u.sectionId&&ht({x:u.x,y:u.y},p.outline,p.section.holes)):void 0,y=b?[b]:d;for(let p of y){if(n&&p.floorIndex!==n[c]||!b&&(u.x<p.box.minX||u.x>p.box.maxX||u.y<p.box.minY||u.y>p.box.maxY||!ht({x:u.x,y:u.y},p.outline,p.section.holes)))continue;o[c]=p.id;let g=m.get(p.id);g.hasSeats=!0;let x=u.focalPoint??p.unit.focal,M=Math.hypot(u.x-x.x,u.y-x.y);M<g.frontU&&(g.frontU=M),g.seatIndices.push(c);let L=u.rowId||`__seat-${c}`,v=g.rows.get(L);v?v.push({x:u.x,y:u.y}):g.rows.set(L,[{x:u.x,y:u.y}]);break}}for(let[c,u]of m){let d=Tt(u.section,{floorBaseHeightM:u.unit.baseHeightM}),b=u.unit.baseHeightM,y=d.rake>0?Math.tan(d.rake*Math.PI/180):0,p=d.rake<=.01&&d.height<=b+.001,g=u.section.surfaceKind,x=g==="flat"?!0:g==="rakedRows"&&d.rake>.01?!1:p,M=u.hasSeats?Wt(c,t,u.seatIndices,u.unit.focal):{sectionId:c,rows:[],blockCount:0},v=M.rows.length<2?$t([...u.rows.values()].map(E=>({points:E})),u.unit.focal):null,R=1/0;if(v){if(u.hasSeats)for(let E of u.rows.values())for(let C of E){let A=v.depthAt(C.x,C.y);A<R&&(R=A)}if(!u.hasSeats||!Number.isFinite(R)){R=1/0;for(let E of u.section.outline){let C=v.depthAt(E.x,E.y);C<R&&(R=C)}}}let k=b+ar,B=Math.max(k,d.height),D=E=>{let C=Math.max(0,E-R)*ae,A=Math.min(C*y,gt);return Math.max(k,d.height+A)},U=E=>{let C=Math.max(0,E)*ae,A=Math.min(C*y,gt);return Math.max(k,d.height+A)},P=x?[]:M.rows.map(E=>({pts:E.pts,y:U(E.blockDepth),depth:E.blockDepth,blockId:E.blockId,...f.has(E.id)?{patch:nn(E.pts,ie)}:{}})),S=P.length?P[0].y:B,T=P.map(E=>{let C=E.patch&&E.patch.length>=3?E.patch:E.pts,A=0,G=0;for(let N of C)A+=N.x,G+=N.y;let j=C.length||1;A/=j,G/=j;let X=0;for(let N of C){let Y=Math.hypot(N.x-A,N.y-G);Y>X&&(X=Y)}return{cx:A,cy:G,rad:X}}),_=x?()=>B:P.length>=2?(E,C)=>{let A=1/0,G=S;for(let j=0;j<P.length;j++){let X=T[j];if(Math.hypot(E-X.cx,C-X.cy)-X.rad>=A)continue;let N=P[j].patch,Y=N&&N.length>=3?_e(N,E,C)?0:ve(N,E,C):ve(P[j].pts,E,C);Y<A&&(A=Y,G=P[j].y)}return G}:(E,C)=>v?D(v.depthAt(E,C)):B,w=[0,1,0],F=P.length>=2||x?()=>w:(E,C)=>{if(!v)return w;let A=v.depthAt(E,C);if(A<=R)return w;let G=(A-R)*ae;if(G*y>=gt||d.height+G*y<=k)return w;let[j,X]=v.gradientAt(E,C);if(j===0&&X===0)return w;let N=1/Math.hypot(y,1);return[-j*y*N,N,-X*y*N]};if(!x)for(let E of M.rows){let C=U(E.blockDepth);for(let A of E.seatIndices)i[A]=C}for(let E of M.rows){let C=[];for(let N=1;N<E.pts.length;N++){let Y=Math.hypot(E.pts[N].x-E.pts[N-1].x,E.pts[N].y-E.pts[N-1].y);Y>1e-6&&C.push(Y)}C.sort((N,Y)=>N-Y);let A=C.length?C[Math.floor(C.length/2)]:1/0,G=1/0,j=E.pts[Math.floor(E.pts.length/2)];if(j)for(let N of M.rows){if(N===E||N.blockId!==E.blockId)continue;let Y=ve(N.pts,j.x,j.y);Y>1e-6&&Y<G&&(G=Y)}let X=Math.min(A,Math.max(G,A*.5));if(Number.isFinite(X)&&X>0)for(let N of E.seatIndices)a[N]=X}r.set(c,{sectionId:c,deckAt:_,normalAt:F,flat:x,bottomY:b,rowLevels:P,landingY:S})}for(let c=0;c<t.length;c++){let u=o[c],d=t[c];if(u){let y=i[c];s[c]=(y??r.get(u).deckAt(d.x,d.y))+cr;continue}let b=d.eyeHeightM;s[c]=Number.isFinite(b)?Math.max(0,b-Ye):0}return{bySection:r,seatOwner:o,seatDeckY:c=>s[c],seatPitchU:c=>a[c]}}var $={top:1,wallBottom:.5,bottomCap:.4};function ce(e,t){if(!e)return t;let n=re(Ee(e,.4),.62);return te(t,n,.72)}function yn(e,t){let n=new Map;for(let s of e.categories??[])n.set(s.key,s.color);let r=new Map;for(let s of t){if(!s.sectionId)continue;let i=r.get(s.sectionId);i||(i=new Map,r.set(s.sectionId,i)),i.set(s.categoryKey,(i.get(s.categoryKey)??0)+1)}let o=new Map;for(let[s,i]of r){let a=0,m=0,l=0,f=0;for(let[h,c]of i){let u=W(n.get(h));u&&(a+=u[0]*c,m+=u[1]*c,l+=u[2]*c,f+=c)}f>0&&o.set(s,[a/f,m/f,l/f])}return o}function gn(e,t){return W(e.color)??t.get(e.logicalSectionId??e.id)??null}var hs=Math.PI*2;function xn(e){return e==="pitch-football"||e==="rink-hockey"||e==="track-athletics"||e==="oval-cricket"}var Mn=Se(require("polygon-clipping"),1);function lr(e,t){return e===void 0||t===void 0?!0:Math.abs(e-t)<.001}var Je=class{constructor(){this.rings=[];this.boxes=[];this.levels=[]}subtract(t,n){let r=t.map(m=>[m.x,m.y]);if(r.length<3)return[];r.push(r[0]);let o=Ie(t),s=this.rings.filter((m,l)=>qe(o,this.boxes[l])&&lr(n,this.levels[l])),i=[[r]];if(s.length)try{i=Mn.default.difference([r],...s).map(l=>l.map(f=>f.map(([h,c])=>[h,c])))}catch{i=[[r]]}this.rings.push([r]),this.boxes.push(o),this.levels.push(n);let a=[];for(let m of i){if(!m.length)continue;let l=m[0].map(([f,h])=>({x:f,y:h}));if(l.length>1){let f=l[0],h=l[l.length-1];Math.abs(f.x-h.x)<1e-9&&Math.abs(f.y-h.y)<1e-9&&l.pop()}l.length>=3&&a.push(l)}return a}};function ur(e,t){if(!t)return e;let n=1/0,r=-1/0,o=1/0,s=-1/0;for(let h of e)n=Math.min(n,h.x),r=Math.max(r,h.x),o=Math.min(o,h.y),s=Math.max(s,h.y);let i=(n+r)/2,a=(o+s)/2,m=t*Math.PI/180,l=Math.cos(m),f=Math.sin(m);return e.map(h=>{let c=h.x-i,u=h.y-a;return{x:i+c*l-u*f,y:a+c*f+u*l}})}function be(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=Le(e.x??0,e.y??0,e.width,e.height)),e.kind==="ellipse"&&e.width&&e.height){let n=(e.x??0)+e.width/2,r=(e.y??0)+e.height/2;t=We(n,r,e.width/2,e.height/2)}return t?ur(t,e.rotation):null}function Oe(e){let t=e.role??"",n={stage:{kind:"stage",heightM:1},entrance:{kind:"portal",heightM:2.7},exit:{kind:"portal",heightM:2.7},screen:{kind:"solid",heightM:6},wall:{kind:"solid",heightM:2.8},rail:{kind:"solid",heightM:1.1},suite:{kind:"suite",heightM:3},obstruction:{kind:"solid",heightM:4.5},sound:{kind:"solid",heightM:1.45},restroom:{kind:"solid",heightM:2.4},bar:{kind:"solid",heightM:1.1},concession:{kind:"solid",heightM:1.1},coat:{kind:"solid",heightM:1.1},goal:{kind:"portal",heightM:1.8}},r=t==="stage"&&xn(e.stageKind)?{kind:"stage",heightM:.06}:n[t]??{kind:"plate",heightM:.25};return{...r,heightM:e.heightM??r.heightM}}var fr=.08;function Sn(e,t){let n=be(e),r=Oe(e),o=r.heightM;if(!n||r.kind!=="plate"&&r.kind!=="stage")return o;let s=1/0,i=1/0,a=-1/0,m=-1/0;for(let f of n)s=Math.min(s,f.x),i=Math.min(i,f.y),a=Math.max(a,f.x),m=Math.max(m,f.y);let l=o;for(let f of t)a>f.minX&&s<f.maxX&&m>f.minY&&i<f.maxY&&l<=f.topOffsetM+1e-6&&(l=f.topOffsetM+fr);return t.push({minX:s,minY:i,maxX:a,maxY:m,topOffsetM:l}),l}function me(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function vn(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 Be(e,t,n){return[me(e[0],e[1],t),me(e[0],e[1],n),me(e[3],e[2],n),me(e[3],e[2],t)]}function wn(e,t,n){return[me(e[0],e[3],t),me(e[1],e[2],t),me(e[1],e[2],n),me(e[0],e[3],n)]}function le(e,t,n,r,o,s){J(e,t,void 0,()=>n,r,o,s,$)}var xt=2.4,mr=.75,hr=.15;function Fe(e){if(e.points&&e.points.length>=3)return e.points;let{center:t,width:n,height:r,rotation:o}=e;if(!n||!r)return null;let s=(o??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),m=n/2,l=r/2;return[[-m,-l],[m,-l],[m,l],[-m,l]].map(([f,h])=>({x:t.x+f*i-h*a,y:t.y+f*a+h*i}))}function In(e,t,n,r,o){let s=Fe(t);s&&J(e,s,void 0,()=>n+xt,n,ce(r,o.boothTop),o.boothWall,$)}function Mt(e){if(e.shape==="round"){let f=e.radius;return f?We(e.center.x,e.center.y,f,f,24):null}let{width:t,height:n,rotation:r,center:o}=e;if(!t||!n)return null;let s=(r??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),m=t/2,l=n/2;return[[-m,-l],[m,-l],[m,l],[-m,l]].map(([f,h])=>({x:o.x+f*i-h*a,y:o.y+f*a+h*i}))}function Rn(e,t,n,r,o){let s=Mt(t);s&&J(e,s,void 0,()=>n+mr,n,ce(r,o.tableTop),o.tableWall,$)}function Pn(e,t,n,r,o,s,i,a){let m=be(t);if(!m)return;let l=a?a.kind==="stage":t.role==="stage",f=a?a.kind==="screen":t.role==="screen",h=a?{kind:l?"stage":"solid",heightM:a.topY-a.baseY}:Oe(t),c=a?.baseY??n,u=a?.topY??n+r;if(l&&i){let g=1/0,x=-1/0,M=1/0,L=-1/0;for(let v of m)v.x<g&&(g=v.x),v.x>x&&(x=v.x),v.y<M&&(M=v.y),v.y>L&&(L=v.y);i.push({cx:(g+x)/2*I,cz:(M+L)/2*I,y:u,halfX:Math.max((x-g)/2*I,.5),halfZ:Math.max((L-M)/2*I,.5)})}let d=W(t.fill),b=l&&d?te(o.stageTop,re(Ee(d,.18),.9),.9):ce(d,l?o.stageTop:o.decorTop),y=f?d:null,p=l?d?te(o.stageWall,re(d,.58),.82):o.stageWall:f?y?te(re(y,1.42),[.24,.46,.82],.08):[.24,.46,.82]:ce(W(t.fill),o.decorWall);if(h.kind==="portal"&&m.length===4){let g=vn(m);le(e,Be(g,0,.16),u,c,b,p),le(e,Be(g,.84,1),u,c,b,p),le(e,g,u,Math.max(c,u-.35),b,p);return}if(h.kind==="suite"&&m.length===4){let g=m.map((L,v)=>{let R=m[(v+1)%4],k=(L.x+R.x)/2,B=(L.y+R.y)/2;return Math.hypot(k-s.x,B-s.y)}),x=g.indexOf(Math.min(...g)),M=[0,1,2,3].map(L=>m[(x+L)%4]);le(e,Be(M,0,.08),u,c,b,p),le(e,Be(M,.92,1),u,c,b,p),le(e,wn(M,.88,1),u,c,b,p),le(e,M,u,Math.max(c,u-.18),b,p);return}le(e,m,u,c,b,p)}function St(e){let{x:t,y:n,width:r,height:o}=e;if(!r||!o)return null;let s=t+r/2,i=n+o/2,a=(e.rotation??0)*Math.PI/180,m=Math.cos(a),l=Math.sin(a),f=r/2,h=o/2;return[[-f,-h],[f,-h],[f,h],[-f,h]].map(([c,u])=>({x:s+c*m-u*l,y:i+c*l+u*m}))}function dr(e){if(!e||!e.startsWith("data:image/svg+xml"))return null;let t=e.slice(e.indexOf(",")+1);if(/;base64/i.test(e.slice(0,e.indexOf(","))))try{t=atob(t)}catch{return null}else try{t=decodeURIComponent(t)}catch{}let n=t.match(/<(?:rect|path)\b[^>]*\bfill="([^"]+)"/i);if(!n)return null;let r=n[1].trim();if(r==="none"||r==="transparent")return null;let o=r.match(/^url\(#([^)]+)\)$/);if(!o)return W(r);let s=t.match(new RegExp(`<(?:linear|radial)Gradient\\b[^>]*\\bid="${o[1]}"[^>]*>([\\s\\S]*?)</(?:linear|radial)Gradient>`,"i"));if(!s)return null;let i=[];for(let a of s[1].matchAll(/stop-color="([^"]+)"/gi)){let m=W(a[1].trim());m&&i.push(m)}return i.length?i.reduce((a,m,l)=>te(a,m,1/(l+1)),i[0]):null}function Cn(e,t,n,r){if(t.layer==="foreground")return;let o=St(t);if(!o)return;let s=n+hr,i=ce(dr(t.href),r.decorTop),a=Math.max(0,Math.min(1,t.opacity??1));a<1&&(i=te(r.ground,i,a)),J(e,o,void 0,()=>s,n,i,te(i,r.decorWall,.5),$)}function En(e,t,n,r,o){if(!t.points||t.points.length<3)return;let s=ce(r,o.gaTop);J(e,t.points,t.holes,()=>n+.15,n,s,o.gaWall,$)}var br=Math.PI/180,K=96,pr=6,yr=60,gr=150,An=.2,xr=.35;function Mr(e,t){let n=Math.atan2(t.x-e.x,t.y-e.y)/br;return n<0?n+360:n}function et(e){if(!e.length)return NaN;let t=[...e].sort((n,r)=>n-r);return t[Math.floor(t.length/2)]}function tt(e,t,n=2){let r=e.length,o=new Float64Array(r);for(let s=0;s<r;s++){let i=0,a=0;for(let m=-n;m<=n;m++){let l=s+m;if(t)l=(l%r+r)%r;else if(l<0||l>=r)continue;i+=e[l],a++}o[s]=i/a}return o}function _n(e,t){let n=e.filter(c=>c.rows.length>=1);if(n.length<1)return null;let r=[],o=0,s=0,i=0;for(let c of n)for(let u of c.rows){for(let d of u.pts)o+=d.x,s+=d.y,i++;if(u.pts.length>=4){let d=mt(u.pts);d&&Number.isFinite(d.cx)&&Number.isFinite(d.cy)&&r.push({x:d.cx,y:d.cy})}}if(!i)return null;let a={x:o/i,y:s/i},m=a;if(r.length>=8){let c=et(r.map(p=>p.x)),u=et(r.map(p=>p.y)),d=0;for(let p of n)for(let g of p.rows)for(let x of g.pts){let M=Math.hypot(x.x-a.x,x.y-a.y);M>d&&(d=M)}let b=0,y=d*.2;for(let p of n)for(let g of p.rows)for(let x of g.pts)Math.hypot(x.x-c,x.y-u)<y&&b++;Math.hypot(c-a.x,u-a.y)<=d&&b/i<.01&&(m={x:c,y:u})}let l=[];for(let c of n){let u={sectionId:c.sectionId,rMin:1/0,rMax:-1/0,samples:[]};for(let d of c.rows)for(let b of d.pts){let y=Math.hypot(b.x-m.x,b.y-m.y),p=Math.min(K-1,Math.floor(Mr(m,b)/(360/K)));u.samples.push({r:y,bin:p,levelM:d.levelM}),y<u.rMin&&(u.rMin=y),y>u.rMax&&(u.rMax=y)}u.samples.length&&l.push(u)}if(!l.length)return null;l.sort((c,u)=>c.rMin+c.rMax-(u.rMin+u.rMax));let f=[];for(let c of l){let u=!1;for(let d of f){let b=Math.min(c.rMax,d.rMax)-Math.max(c.rMin,d.rMin),y=Math.min(c.rMax-c.rMin,d.rMax-d.rMin);if(y>1e-9&&b>=xr*y){d.members.push(c),d.rMin=Math.min(d.rMin,c.rMin),d.rMax=Math.max(d.rMax,c.rMax),u=!0;break}}u||f.push({members:[c],rMin:c.rMin,rMax:c.rMax})}let h=[];for(let c of f){let u=new Array(K).fill(null);for(let S of c.members)for(let T of S.samples){let _=u[T.bin];_||(_={samples:[]},u[T.bin]=_),_.samples.push({r:T.r,levelM:T.levelM})}let d=u.map(S=>!!S);if(!d.filter(Boolean).length)continue;let y=[],p=[];for(let S of u){if(!S)continue;let T=1/0,_=-1/0;for(let w of S.samples)w.r<T&&(T=w.r),w.r>_&&(_=w.r);y.push(T),p.push(_)}let g=et(y),x=et(p);if(!(g>=An*x)||!(x>0))continue;let M=[...y].sort((S,T)=>S-T);if(!(M[Math.floor(M.length*.1)]>=An*x))continue;let v=u.map(S=>{if(!S)return null;let T=[...S.samples].sort((j,X)=>j.r-X.r),_=T[0].r,w=T[T.length-1].r,F=T[0].levelM,E=-1/0;for(let j of T)j.levelM>E&&(E=j.levelM);let C=[];for(let j of T){let X={r:j.r,l:j.levelM};for(;C.length&&Math.abs(C[C.length-1].r-X.r)<1e-9;){if(C[C.length-1].l<=X.l){X.skip=!0;break}C.pop()}if(!X.skip){for(;C.length>=2;){let N=C[C.length-2],Y=C[C.length-1];if((Y.r-N.r)*(X.l-N.l)-(Y.l-N.l)*(X.r-N.r)<=0)C.pop();else break}C.push(X)}}let A=C.map(j=>j.r),G=C.map(j=>j.l);return{inner:_,outer:w,front:F,top:E,profile:{rs:A,ls:G}}}),R=d.slice();for(let S=0;S<K;S++){if(R[S])continue;let T=-1,_=-1,w=0;for(let O=1;O<=K;O++){let V=(S-O+K*2)%K;if(R[V]){T=V;break}}for(let O=1;O<=K;O++){let V=(S+O)%K;if(R[V]){_=V,w=O;break}}if(T<0||_<0)continue;let F=0;for(let O=1;O<=K;O++){let V=(S-O+K*2)%K;if(d[V]){F=O;break}}if(F-1+w>pr)continue;let C=v[T],A=v[_],G=F/(F+w),j=C.inner+(A.inner-C.inner)*G,X=C.outer+(A.outer-C.outer)*G,N=C.front+(A.front-C.front)*G,Y=C.top+(A.top-C.top)*G;v[S]={inner:j,outer:X,front:N,top:Y,profile:{rs:[j,X],ls:[N,Y]}}}for(let S=0;S<K;S++)v[S]&&(R[S]=!0);let k=360/K,B=[],D=R.filter(Boolean).length,U=[];if(D===K)U.push({start:0,len:K});else{let S=0;for(;R[S];)S=(S+1)%K;let T=-1;for(let _=0;_<=K;_++){let w=(S+_)%K,F=_<K&&R[w];if(F&&T<0)T=w;else if(!F&&T>=0){let E=(w-T+K)%K||K;U.push({start:T,len:E}),T=-1}}}for(let S of U){if(S.len*k<yr&&S.len<K)continue;let T=S.len===K,_=new Float64Array(S.len),w=new Float64Array(S.len),F=new Float64Array(S.len),E=new Float64Array(S.len),C=[];for(let O=0;O<S.len;O++){let V=v[(S.start+O)%K];_[O]=V.inner,w[O]=V.outer,F[O]=V.front,E[O]=V.top,C.push(V.profile??{rs:[V.inner,V.outer],ls:[V.front,V.top]})}let A=tt(_,T),G=tt(w,T),j=tt(F,T),X=tt(E,T);for(let O=0;O<S.len;O++)A[O]>_[O]&&(A[O]=_[O]),G[O]<w[O]&&(G[O]=w[O]),A[O]>G[O]-1e-6&&(A[O]=Math.max(0,G[O]-1e-6)),X[O]<j[O]&&(X[O]=j[O]);let N={startBin:S.start,binCount:S.len,closed:T,innerR:A,outerR:G,frontLevelM:j,topLevelM:X,profiles:C},Y=(O,V,H)=>{let Q=C[O],Z=Q.rs,z=Q.ls;if(V<=Z[0]){z[0]>H&&(z[0]=H);return}if(V>=Z[Z.length-1]){z[z.length-1]>H&&(z[z.length-1]=H);return}for(let q=0;q+1<Z.length;q++)if(V<=Z[q+1]){z[q]>H&&(z[q]=H),z[q+1]>H&&(z[q+1]=H);return}};for(let O=0;O<S.len;O++){let V=u[(S.start+O)%K];if(V)for(let H of V.samples){Y(O,H.r,H.levelM);let Q=T?(O-1+S.len)%S.len:O-1,Z=T?(O+1)%S.len:O+1;Q>=0&&Y(Q,H.r,H.levelM),Z<S.len&&Y(Z,H.r,H.levelM)}}B.push(N)}B.reduce((S,T)=>S+T.binCount*k,0)<gr||h.push({arcs:B,sectionIds:c.members.map(S=>S.sectionId),innerRMedian:g,outerRMedian:x})}if(!h.length)return null;if(h.sort((c,u)=>c.innerRMedian-u.innerRMedian),t){let c=h[h.length-1].outerRMedian;if(Math.hypot(t.x-m.x,t.y-m.y)>.9*c)return null}return{centre:m,binCount:K,binStepDeg:360/K,rings:h}}function kn(e,t,n,r){let o=e.binStepDeg,s=n/o-.5-t.startBin;s=(s%e.binCount+e.binCount)%e.binCount,s>t.binCount-1&&(t.closed?s=s-t.binCount<t.binCount-s?0:t.binCount-1:s=s-(t.binCount-1)<e.binCount-s?t.binCount-1:0);let i=Math.floor(s),a=t.closed?(i+1)%t.binCount:Math.min(t.binCount-1,i+1),m=s-i,l=f=>{let h=t.profiles[f],c=h.rs,u=h.ls;if(r<=c[0])return u[0];if(r>=c[c.length-1])return u[u.length-1];for(let d=0;d+1<c.length;d++)if(r<=c[d+1]){let b=c[d+1]-c[d],y=b>1e-9?(r-c[d])/b:0;return u[d]+(u[d+1]-u[d])*y}return u[u.length-1]};return l(i)*(1-m)+l(a)*m}var Sr=.25,vr=1.2,wr=.6,Ir=.45,Rr=2.3,Pr=Math.PI/180;function pe(e,t,n){let r=n*Pr;return{x:e.x+t*Math.sin(r),y:e.y+t*Math.cos(r)}}function Cr(e,t){let n=t.rings[t.rings.length-1];if(!n)return!1;let r=n.outerRMedian*.85;for(let o of e){if(o.role!=="wall")continue;let s=o.points&&o.points.length>=2?o.points:o.x!==void 0&&o.y!==void 0&&o.width!==void 0&&o.height!==void 0?[{x:o.x,y:o.y},{x:o.x+o.width,y:o.y},{x:o.x+o.width,y:o.y+o.height},{x:o.x,y:o.y+o.height}]:[];if(s.length<2)continue;let i=0;for(let a of s)Math.hypot(a.x-t.centre.x,a.y-t.centre.y)>=r&&i++;if(i>=s.length/2)return!0}return!1}var Er=24;function Ar(e,t,n,r,o,s,i,a){let m=n.binCount,l=Er,f=ae,h=s+.02,c=[];for(let P=0;P<m;P++){let S=(n.startBin+P+.5)*t.binStepDeg,T=new Float64Array(l+1);for(let _=0;_<=l;_++){let w=r[P]+(o[P]-r[P])*_/l;T[_]=Math.max(h,kn(t,n,S,w)-Sr)}c.push(T)}let u=[i.bandTop[0]*a.top,i.bandTop[1]*a.top,i.bandTop[2]*a.top],d=[i.bandTop[0]*a.bottomCap,i.bandTop[1]*a.bottomCap,i.bandTop[2]*a.bottomCap],b=[i.bandWall[0]*a.top,i.bandWall[1]*a.top,i.bandWall[2]*a.top],y=[i.bandWall[0]*a.wallBottom,i.bandWall[1]*a.wallBottom,i.bandWall[2]*a.wallBottom],p=(P,S)=>{let T=(n.startBin+P+.5)*t.binStepDeg,_=r[P]+(o[P]-r[P])*S/l,w=pe(t.centre,_,T);return[w.x*f,c[P][S],w.y*f]};{let P=Math.tan(12*Math.PI/180);for(let S=0;S<6;S++){let T=!1;for(let w=0;w<m;w++)for(let F=l-1;F>=0;F--)c[w][F]>c[w][F+1]&&(c[w][F]=c[w][F+1],T=!0);let _=n.closed?m:m-1;for(let w=0;w<_;w++){let F=(w+1)%m;for(let E=0;E<=l;E++){let C=c[F][E]-c[w][E];if(Math.abs(C)>1)continue;let A=r[w]+(o[w]-r[w])*E/l,G=r[F]+(o[F]-r[F])*E/l,j=pe(t.centre,A,(n.startBin+w+.5)*t.binStepDeg),X=pe(t.centre,G,(n.startBin+F+.5)*t.binStepDeg),N=P*Math.hypot(X.x-j.x,X.y-j.y)*f;C>N?(c[F][E]=c[w][E]+N,T=!0):-C>N&&(c[w][E]=c[F][E]+N,T=!0)}}if(!T)break}}let g=1,x=(P,S)=>{for(let T=0;T<=l;T+=4)if(Math.abs(c[P][T]-c[S][T])>g)return!0;return Math.abs(c[P][l]-c[S][l])>g},M=Math.tan(38*Math.PI/180),L=P=>(o[P]-r[P])/l*f,v=(P,S)=>c[P][S+1]-c[P][S]>M*Math.max(1e-6,L(P)),R=(P,S)=>{let T=n.closed?(P-1+m)%m:Math.max(0,P-1),_=n.closed?(P+1)%m:Math.min(m-1,P+1);Math.abs(c[T][S]-c[P][S])>g&&(T=P),Math.abs(c[_][S]-c[P][S])>g&&(_=P);let w=Math.max(0,S-1),F=Math.min(l,S+1);w<S&&v(P,w)&&(w=S),F>S&&v(P,S)&&(F=S);let E=p(T,S),C=p(_,S),A=p(P,w),G=p(P,F),j=C[0]-E[0],X=C[1]-E[1],N=C[2]-E[2],Y=G[0]-A[0],O=G[1]-A[1],V=G[2]-A[2],H=X*V-N*O,Q=N*Y-j*V,Z=j*O-X*Y,z=Math.hypot(H,Q,Z);return z>1e-12?(H/=z,Q/=z,Z/=z,Q<0&&(H=-H,Q=-Q,Z=-Z),[H,Q,Z]):[0,1,0]},k=(P,S)=>{let T=[P[0],s,P[2]],_=[S[0],s,S[2]],w=S[0]-P[0],F=S[2]-P[2],E=Math.hypot(w,F);if(!(E>1e-12))return;let C=[F/E,0,-w/E];e.tri(P,S,_,C,b,b,y),e.tri(P,_,T,C,b,y,y)},B=.05*fe,D=P=>o[P]-r[P]<B,U=n.closed?m:m-1;for(let P=0;P<U;P++){let S=(P+1)%m;if(D(P)||D(S))continue;if(x(P,S)){let C=(n.startBin+P+1)*t.binStepDeg,A=(O,V)=>{let H=(r[P]+r[S])/2,Q=(o[P]+o[S])/2,Z=H+(Q-H)*V/l,z=pe(t.centre,Z,C);return[z.x*f,c[O][V],z.y*f]};for(let O=0;O<l;O++){let V=p(P,O),H=p(P,O+1),Q=A(P,O),Z=A(P,O+1),z=R(P,O),q=R(P,O+1);e.triN(V,Q,Z,z,z,q,u),e.triN(V,Z,H,z,q,q,u);let Ge=p(S,O),Ne=p(S,O+1),ge=A(S,O),Pe=A(S,O+1),xe=R(S,O),Me=R(S,O+1);e.triN(ge,Ge,Ne,xe,xe,Me,u),e.triN(ge,Ne,Pe,xe,Me,Me,u);let ue=A(P,O),se=A(P,O+1),je=A(S,O+1),ot=A(S,O),Ue=se[0]-ue[0],Ce=se[2]-ue[2],rt=Math.hypot(Ue,Ce);if(rt>1e-12){let Rt=[Ce/rt,0,-Ue/rt];e.tri(ue,se,je,Rt,b),e.tri(ue,je,ot,Rt,b)}}let G=p(P,0),j=p(S,0),X=p(S,l),N=p(P,l),Y=O=>[O[0],s,O[2]];e.tri(Y(G),Y(X),Y(j),[0,-1,0],d),e.tri(Y(G),Y(N),Y(X),[0,-1,0],d),k(G,j),k(N,X);continue}for(let C=0;C<l;C++){let A=R(P,C),G=R(S,C),j=R(S,C+1),X=R(P,C+1);if(v(P,C)||v(S,C)){let H=(se,je)=>{let ot=(n.startBin+se+.5)*t.binStepDeg,Ue=r[se]+(o[se]-r[se])*(C+.5)/l,Ce=pe(t.centre,Ue,ot);return[Ce.x*f,je,Ce.y*f]},Q=p(P,C),Z=p(S,C),z=H(P,c[P][C]),q=H(S,c[S][C]);e.triN(Q,Z,q,A,G,G,u),e.triN(Q,q,z,A,G,A,u);let Ge=p(S,C+1),Ne=p(P,C+1),ge=H(P,c[P][C+1]),Pe=H(S,c[S][C+1]);e.triN(ge,Pe,Ge,X,j,j,u),e.triN(ge,Ge,Ne,X,j,X,u);let xe=q[0]-z[0],Me=q[2]-z[2],ue=Math.hypot(xe,Me);if(ue>1e-12){let se=[-Me/ue,0,xe/ue];e.tri(z,q,Pe,se,b),e.tri(z,Pe,ge,se,b)}continue}let N=p(P,C),Y=p(S,C),O=p(S,C+1),V=p(P,C+1);e.triN(N,Y,O,A,G,j,u),e.triN(N,O,V,A,j,X,u)}let T=p(P,0),_=p(S,0),w=p(S,l),F=p(P,l),E=C=>[C[0],s,C[2]];e.tri(E(T),E(w),E(_),[0,-1,0],d),e.tri(E(T),E(F),E(w),[0,-1,0],d),k(T,_),k(F,w)}if(!n.closed)for(let P of[0,m-1])for(let S=0;S<l;S++)k(p(P,S),p(P,S+1))}function Tn(e,t,n){let{bottomY:r,colors:o,ao:s}=n,i=new Float64Array(t.binCount).fill(-1/0);for(let f of t.rings)for(let h of f.arcs){let c=new Float64Array(h.binCount),u=new Float64Array(h.binCount);for(let b=0;b<h.binCount;b++){let y=(h.startBin+b)%t.binCount,p=Math.max(0,h.innerR[b]-ie);c[b]=Math.max(p,i[y]+.001),u[b]=Math.max(c[b]+.001,h.outerR[b]+ie)}let d=0;for(let b=0;b<h.binCount;b++){let y=h.topLevelM[b]-r;y>d&&(d=y)}d>=vr&&Ar(e,t,h,c,u,r,o,s);for(let b=0;b<h.binCount;b++){let y=(h.startBin+b)%t.binCount;u[b]>i[y]&&(i[y]=u[b])}}if(n.deriveShell===!1||Cr(n.shapes,t))return;let a=t.rings[t.rings.length-1],m=wr*fe,l=Ir*fe;for(let f of a.arcs){let h=[],c=[];for(let b=0;b<f.binCount;b++){let y=(f.startBin+b+.5)*t.binStepDeg,p=f.outerR[b]+ie+m;h.push(pe(t.centre,p,y)),c.push(pe(t.centre,p+l,y))}let u=-1/0;for(let b=0;b<f.binCount;b++)f.topLevelM[b]>u&&(u=f.topLevelM[b]);let d=()=>u+Rr;f.closed?J(e,c,[h.slice().reverse()],d,r,o.shellTop,o.shellWall,s):J(e,[...c,...h.slice().reverse()],void 0,d,r,o.shellTop,o.shellWall,s)}}function Ln(e,t,n,r,o,s,i,a){if(!t.outline||t.outline.length<3)return;let m=n.baseHeightM,l=ce(r,a.tierTop);if(!o)return;let f=y=>o.deckAt(y.x,y.y),h=hn(t,i),c=h[0]??t.outline;if(o.rowLevels.length>=2){let y=$e(o.rowLevels),p=dn(an(o.rowLevels,n.focal,y),h),g=()=>[0,1,0];for(let M of p){let L=Math.max(m,M.topY-.02);for(let v of s.subtract(M.outline,L))J(e,v,M.holes,()=>L,m,l,a.tierWall,$,void 0,g)}p.length||J(e,c,t.holes,()=>o.landingY,m,l,a.tierWall,$);let x={tread:[l[0]*$.top,l[1]*$.top,l[2]*$.top],riser:[l[0]*.72,l[1]*.72,l[2]*.72]};for(let M of h.length?h:[c])ln(e,o.rowLevels,n.focal,o.landingY,x,M,y);return}let u=o.flat?1/0:bn,d=y=>o.normalAt(y.x,y.y),b=o.flat?o.landingY:void 0;for(let y of s.subtract(c,b))J(e,y,t.holes,f,m,l,a.tierWall,$,u,d)}function _r(e,t,n){let r=new Set;for(let i of e.objects)i.type==="section"&&r.add(i.id);let o=new Map;for(let i=0;i<t.length;i++){let a=n.seatOwner[i];if(!a||!r.has(a))continue;let m=n.bySection.get(a);if(m&&m.rowLevels.length>=2)continue;let l=t[i],f=o.get(a);f||(f=new Map,o.set(a,f));let h=l.rowId||`__seat-${i}`,c=f.get(h);c||(c={pts:[],levelM:0,n:0},f.set(h,c)),c.pts.push({x:l.x,y:l.y}),c.levelM+=n.seatDeckY(i),c.n++}let s=[];for(let i of e.objects){if(i.type!=="section")continue;let a=n.bySection.get(i.id);if(a&&a.rowLevels.length>=2){let l=a.rowLevels.filter(f=>!f.patch).map(f=>({pts:f.pts,levelM:f.y}));l.length>=2&&s.push({sectionId:i.id,rows:l});continue}let m=o.get(i.id);m&&s.push({sectionId:i.id,rows:[...m.values()].map(l=>({pts:l.pts,levelM:l.levelM/l.n}))})}return s}function On(e,t,n,r,o,s,i=!0){let a=_r(t,n,r);if(!a.length)return;let m=_n(a,t.focal);m&&(e.setMaterial(0),Tn(e,m,{bottomY:t.baseHeightM,colors:{bandTop:re(o.tierTop,.8),bandWall:o.tierWall,shellTop:s??re(o.tierWall,1.15),shellWall:s??o.tierWall},ao:$,shapes:t.objects.filter(l=>l.type==="shape"),deriveShell:i}))}var kr=6,Tr=2.2,Bn=.1,Lr=.3,Or=1.8,Br=.9,Fr=.55,Dr=6e3;function Fn(e){let{doc:t,units:n,seats:r,surfaces:o,focal:s}=e,i=t.zones??[],a=[];if(i.length){let m=new Map;for(let f of n)for(let h of f.objects)h.type==="section"&&h.zone&&m.set(h.id,h.zone);let l=new Map;for(let f=0;f<r.length;f++){let h=r[f],c=o.seatOwner[f],u=h.zoneId??(c?m.get(c):void 0);if(!u)continue;let d=l.get(u);d||(d={n:0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0,sumY:0},l.set(u,d)),d.n++,h.x<d.minX&&(d.minX=h.x),h.y<d.minY&&(d.minY=h.y),h.x>d.maxX&&(d.maxX=h.x),h.y>d.maxY&&(d.maxY=h.y),d.sumY+=o.seatDeckY(f)}for(let f of i){let h=l.get(f.id),c=[];for(let[u,d]of m)d===f.id&&c.push(u);if(!h||h.n===0){a.push({id:f.id,label:f.label,color:W(f.color),sectionIds:c,seatCount:0,center:[0,0,0],radius:0,focalWorld:[(f.focalPoint??s).x*I,1.5,(f.focalPoint??s).y*I]});continue}a.push({id:f.id,label:f.label,color:W(f.color),sectionIds:c,seatCount:h.n,center:[(h.minX+h.maxX)/2*I,h.sumY/h.n,(h.minY+h.maxY)/2*I],radius:.5*Math.hypot((h.maxX-h.minX)*I,(h.maxY-h.minY)*I)||1,focalWorld:[(f.focalPoint??s).x*I,1.5,(f.focalPoint??s).y*I]})}}return a}function Dn(e){let{doc:t,units:n,seats:r,surfaces:o,seatData:s,hintedSeatFloor:i,zones:a,focal:m}=e,l=[],f=[],h=[];for(let c of a)c.seatCount!==0&&l.push({id:`zone:${c.id}`,kind:"zone",text:c.label,anchor:[c.center[0],c.center[1]+kr,c.center[2]],color:t.zones?.find(u=>u.id===c.id)?.color});{let c=new Map,u=new Map;for(let d=0;d<r.length;d++){let b=o.seatOwner[d];if(!b)continue;let y=c.get(b);y||(y={n:0,x:0,y:0,deck:0},c.set(b,y)),y.n++,y.x+=r[d].x,y.y+=r[d].y,y.deck+=o.seatDeckY(d);let p=u.get(b);p||(p={minX:1/0,maxX:-1/0,minY:1/0,maxY:-1/0},u.set(b,p)),r[d].x<p.minX&&(p.minX=r[d].x),r[d].x>p.maxX&&(p.maxX=r[d].x),r[d].y<p.minY&&(p.minY=r[d].y),r[d].y>p.maxY&&(p.maxY=r[d].y)}for(let d of n)for(let b of d.objects){if(b.type!=="section")continue;let y=c.get(b.id);if(!y||y.n===0)continue;let p=u.get(b.id),g=[y.x/y.n*I,y.deck/y.n,y.y/y.n*I],x=b.displayLabel||b.label||b.id;f.push({id:b.id,floorIndex:d.index,label:x,seatCount:y.n,center:g,radius:Math.max(1,Math.hypot(p.maxX-p.minX,p.maxY-p.minY)*.5*I),focalWorld:[d.focal.x*I,d.baseHeightM+1.5,d.focal.y*I]});let M=t.floors?.[d.index]?.name?.trim().toLocaleLowerCase();n.length>1&&M===x.trim().toLocaleLowerCase()||l.push({id:`section:${b.id}`,kind:"section",text:x,anchor:[g[0],g[1]+Tr,g[2]],floorIndex:d.index})}}{for(let d of n)for(let b of d.objects){if(b.type!=="gaArea")continue;let y=Ae(b.points);if(!y)continue;let p=b.displayLabel||b.label||b.id;l.push({id:`ga:${b.id}`,kind:"ga",text:b.capacity>0?`${p} \xB7 ${b.capacity.toLocaleString()}`:p,anchor:[y.x*I,d.baseHeightM+Or,y.y*I],floorIndex:d.index})}let c=new Map;for(let d=0;d<r.length;d++){let b=r[d],y=Math.hypot(b.x-m.x,b.y-m.y),p=c.get(b.rowId);(!p||y>p.far)&&c.set(b.rowId,{seat:b,index:d,far:y})}for(let[d,b]of c){let y=b.seat.label?b.seat.label.lastIndexOf("-"):-1,p=y>0?b.seat.label.slice(0,y):d;p&&l.push({id:`row:${d}`,kind:"row",text:p,anchor:[b.seat.x*I,o.seatDeckY(b.index)+Br,b.seat.y*I],floorIndex:i[b.index]})}let u=new Map;for(let d=0;d<r.length;d++){let b=r[d],y=b.label?b.label.lastIndexOf("-"):-1,p=u.get(b.rowId);p||(p={n:0,x:0,y:0,z:0,minX:1/0,maxX:-1/0,minZ:1/0,maxZ:-1/0,label:y>0?b.label.slice(0,y):b.rowId,sectionId:b.sectionId},u.set(b.rowId,p));let g=d*3,x=s.iPosition[g],M=s.iPosition[g+1],L=s.iPosition[g+2];p.n++,p.x+=x,p.y+=M,p.z+=L,p.minX=Math.min(p.minX,x),p.maxX=Math.max(p.maxX,x),p.minZ=Math.min(p.minZ,L),p.maxZ=Math.max(p.maxZ,L)}for(let[d,b]of u)h.push({id:d,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)});if(r.length<=Dr)for(let d=0;d<r.length;d++){let b=r[d],y=b.displayLabel||b.label;y&&l.push({id:`seat:${b.id}`,kind:"seat",text:y,anchor:[b.x*I,o.seatDeckY(d)+Fr,b.y*I],floorIndex:i[d]})}}for(let c of n)for(let u of c.objects)if(u.type==="shape"&&u.role&&["entrance","exit","screen","suite","obstruction"].includes(u.role)){let d=be(u),b=d?Ae(d):null;if(!b||!u.label)continue;l.push({id:`architecture:${u.id}`,kind:"annotation",text:u.label,anchor:[b.x*I,c.baseHeightM+Oe(u).heightM+Bn,b.y*I],color:u.fill,floorIndex:c.index})}else if(u.type==="text"){if(!u.text)continue;l.push({id:`text:${u.id}`,kind:"annotation",text:u.text,anchor:[u.position.x*I,c.baseHeightM+Bn,u.position.y*I],color:u.color,rotation:u.rotation,floorIndex:c.index})}else if(u.type==="booth"){let d=Fe(u);if(!d)continue;let b=Ae(d);if(!b)continue;l.push({id:`booth:${u.id}`,kind:"booth",text:u.displayLabel||u.label||u.id,anchor:[b.x*I,c.baseHeightM+xt+Lr,b.y*I],floorIndex:c.index})}return{labels:l,sections:f,rows:h}}function Gn(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 Nn(e){let{doc:t,units:n,seats:r,surfaces:o,solids:s,hintedSeatFloor:i,seatFloor:a}=e,m=[];{let l=n.map(()=>({minX:1/0,minY:1/0,minZ:1/0,maxX:-1/0,maxY:-1/0,maxZ:-1/0}));for(let c=0;c<s.floor.length;c+=1){let u=Math.max(0,Math.min(n.length-1,Math.round(s.floor[c]))),d=c*3,b=l[u];b.minX=Math.min(b.minX,s.position[d]),b.minY=Math.min(b.minY,s.position[d+1]),b.minZ=Math.min(b.minZ,s.position[d+2]),b.maxX=Math.max(b.maxX,s.position[d]),b.maxY=Math.max(b.maxY,s.position[d+1]),b.maxZ=Math.max(b.maxZ,s.position[d+2])}let f=new Map;for(let c=0;c<n.length;c++)for(let u of n[c].objects)u.type==="section"&&f.set(u.id,c);let h=n.map(()=>({n:0,minX:1/0,minY:1/0,minDeck:1/0,maxX:-1/0,maxY:-1/0,maxDeck:-1/0,sumX:0,sumDeck:0,sumZ:0}));for(let c=0;c<r.length;c++){let u=o.seatOwner[c],d=(u!==null?f.get(u):void 0)??i[c];if(d===void 0)continue;let b=h[d],y=r[c];b.n++,y.x<b.minX&&(b.minX=y.x),y.y<b.minY&&(b.minY=y.y),y.x>b.maxX&&(b.maxX=y.x),y.y>b.maxY&&(b.maxY=y.y);let p=o.seatDeckY(c);b.sumX+=y.x*I,b.sumDeck+=p,b.sumZ+=y.y*I,b.minDeck=Math.min(b.minDeck,p),b.maxDeck=Math.max(b.maxDeck,p+1.6),a[c]=d}for(let c=0;c<n.length;c++){let u=h[c],d=t.floors?.[c],b=l[c],y=Math.min(u.n?u.minX*I:n[c].focal.x*I-1,Number.isFinite(b.minX)?b.minX:1/0),p=Math.max(u.n?u.maxX*I:n[c].focal.x*I+1,Number.isFinite(b.maxX)?b.maxX:-1/0),g=Math.min(u.n?u.minY*I:n[c].focal.y*I-1,Number.isFinite(b.minZ)?b.minZ:1/0),x=Math.max(u.n?u.maxY*I:n[c].focal.y*I+1,Number.isFinite(b.maxZ)?b.maxZ:-1/0),M=Math.min(u.n?Math.min(n[c].baseHeightM,u.minDeck):n[c].baseHeightM,Number.isFinite(b.minY)?b.minY:1/0),L=Math.max(u.n?Math.max(u.maxDeck,M+.5):M+.5,Number.isFinite(b.maxY)?b.maxY:-1/0),v=[u.n?u.sumX/u.n:(y+p)/2,u.n?u.sumDeck/u.n:(M+L)/2,u.n?u.sumZ/u.n:(g+x)/2],R=Math.max(1,.5*Math.hypot(p-y,L-M,x-g));m.push({index:c,id:d?.id??`floor-${c}`,label:d?.name??(n.length>1?`Floor ${c+1}`:"Venue"),seatCount:u.n,center:v,radius:R,box:{min:[y,M,g],max:[p,L,x]},focalWorld:[n[c].focal.x*I,n[c].baseHeightM+1.5,n[c].focal.y*I]})}}return m}function vt(e,t){let n=1/0,r=1/0,o=-1/0,s=-1/0,i=(a,m)=>{a<n&&(n=a),m<r&&(r=m),a>o&&(o=a),m>s&&(s=m)};for(let a of t)i(a.x,a.y);for(let a of e)for(let m of a.objects)if(m.type==="section")for(let l of m.outline)i(l.x,l.y);else if(m.type==="shape"&&m.points)for(let l of m.points)i(l.x,l.y);else if(m.type==="gaArea")for(let l of m.points)i(l.x,l.y);else if(m.type==="booth"){let l=Fe(m);if(l)for(let f of l)i(f.x,f.y)}else if(m.type==="table"){let l=Mt(m);if(l)for(let f of l)i(f.x,f.y)}else if(m.type==="decorImage"){let l=St(m);if(l)for(let f of l)i(f.x,f.y)}return Number.isFinite(n)||(n=-100,r=-100,o=100,s=100),{minX:n,minY:r,maxX:o,maxY:s}}function jn(e,t,n,r,o,s){if(t.length===1){let i=Math.max(60,(o.maxX-o.minX+o.maxY-o.minY)*.06),a=Le(o.minX-i,o.minY-i,o.maxX-o.minX+i*2,o.maxY-o.minY+i*2);J(e,a,void 0,()=>0,-.4,s.ground,s.ground,$)}else{let i=t.reduce((u,d)=>d.baseHeightM<u.baseHeightM?d:u);e.setFloor(i.index);let a=n.filter((u,d)=>r[d]===i.index),m=vt([i],a),l=Math.hypot(m.maxX-m.minX,m.maxY-m.minY),f=Math.max(28,Math.min(80,l*.04)),h=Le(m.minX-f,m.minY-f,m.maxX-m.minX+f*2,m.maxY-m.minY+f*2),c=i.baseHeightM-.03;J(e,h,void 0,()=>c,c-.22,s.ground,s.ground,$)}}function Un(e,t,n){let{cx:r,cz:o,radius:s}=n,i=1/0,a=1/0,m=1/0,l=-1/0,f=-1/0,h=-1/0,c=(b,y,p)=>{i=Math.min(i,b),l=Math.max(l,b),a=Math.min(a,y),f=Math.max(f,y),m=Math.min(m,p),h=Math.max(h,p)};for(let b=0;b<e.position.length;b+=3)c(e.position[b],e.position[b+1],e.position[b+2]);for(let b=0;b<t.count;b++){let y=b*3,p=t.iPosition[y],g=t.iPosition[y+1],x=t.iPosition[y+2],M=Math.max(.35,t.iMaxRadius[b]??.35);c(p-M,g,x-M),c(p+M,g+1.6,x+M)}Number.isFinite(i)||(i=r-s,l=r+s,a=0,f=s*.16,m=o-s,h=o+s);let u=[(i+l)/2,(a+f)/2,(m+h)/2],d=Math.max(1,.5*Math.hypot(l-i,f-a,h-m));return{center:u,radius:d,minY:a,maxY:f}}function Xn(e,t,n,r,o,s){let i=1/0,a=1/0,m=-1/0,l=-1/0;for(let M=0;M<e.count;M++){let L=M*3,v=e.iPosition[L],R=e.iPosition[L+2];v<i&&(i=v),v>m&&(m=v),R<a&&(a=R),R>l&&(l=R)}for(let M of t)i=Math.min(i,M.cx-M.halfX),m=Math.max(m,M.cx+M.halfX),a=Math.min(a,M.cz-M.halfZ),l=Math.max(l,M.cz+M.halfZ);let f=n.minX*I,h=n.maxX*I,c=n.minY*I,u=n.maxY*I,d=f,b=h,y=c,p=u;if(Number.isFinite(i)){let M=Math.max(2,.06*Math.hypot(m-i,l-a));d=Math.max(f,i-M),b=Math.min(h,m+M),y=Math.max(c,a-M),p=Math.min(u,l+M)}let g=Math.min(0,r),x=Math.max(o,s*.05);return{min:[d,g,y],max:[b,x,p]}}var Gr=/^data:image\/(?:png|jpe?g|webp|gif|avif);base64,[a-z0-9+/]+={0,2}$/i,Nr=/[\s"'<>`\\]/;function jr(e){if(typeof e!="string"||!e||e.length>2e6||e!==e.trim())return!1;if(e.startsWith("data:"))return Gr.test(e);if(Nr.test(e))return!1;try{let t=new URL(e);return t.protocol==="https:"&&!t.username&&!t.password}catch{return!1}}function Yn(e){let t=e.trim();return jr(t)?t:null}var wt="seatlayer.event-configuration/1";var Re=100,Ur=120,Xr=1e5,Yr=1e4,Vr=/^[a-f0-9]{64}$/,Hr=new Set(["stage","screen","barrier","camera_platform","sound_desk","rigging_truss"]);function De(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ye(e,t){return typeof e=="string"&&e.length>=1&&e.length<=t&&e.normalize("NFKC").trim()===e}function Kr(e){return typeof e=="number"&&Number.isInteger(e)&&e>0}function Vn(e){return!Array.isArray(e)||e.length>Xr||!e.every(t=>ye(t,Re))?null:[...new Set(e)].sort()}function zr(e){return!De(e)||!ye(e.chartId,Re)||!ye(e.version,Re)||e.sha256!==void 0&&(typeof e.sha256!="string"||!Vr.test(e.sha256))?null:{chartId:e.chartId,version:e.version,...typeof e.sha256=="string"?{sha256:e.sha256}:{}}}function It(e,t,n){return typeof e=="number"&&Number.isFinite(e)&&e>=t&&e<=n}function Wr(e){return De(e)?e.mode==="none"||e.mode==="opaque"?e.opacity===void 0?{mode:e.mode}:null:e.mode==="partial"&&It(e.opacity,.01,.99)?{mode:"partial",opacity:e.opacity}:null:null}function Zr(e,t){if(e===void 0)return;if(!Array.isArray(e)||e.length>Yr)return null;let n=new Set(t),r=new Set,o=new Set,s=0,i=[];for(let a of e){if(!De(a)||!ye(a.id,Re)||!ye(a.objectId,Re)||!n.has(a.objectId)||!Hr.has(String(a.kind))||!It(a.heightM,.05,50)||a.baseElevationM!==void 0&&!It(a.baseElevationM,-10,100))return null;let m=Wr(a.occlusion);if(!m||r.has(a.id)||o.has(a.objectId))return null;let l=a.contentImageUrl===void 0?void 0:typeof a.contentImageUrl=="string"?Yn(a.contentImageUrl):null;if(a.contentImageUrl!==void 0&&(!l||a.kind!=="screen"||++s>1))return null;r.add(a.id),o.add(a.objectId),i.push({id:a.id,objectId:a.objectId,kind:a.kind,heightM:a.heightM,...a.baseElevationM!==void 0?{baseElevationM:a.baseElevationM}:{},occlusion:m,...l?{contentImageUrl:l}:{}})}return i.sort((a,m)=>a.id.localeCompare(m.id))}function Qr(e){let t=[];if(!De(e))return{issues:[{code:"invalid_export",path:"configuration",message:"Configuration must be an object"}]};e.schema!==wt&&t.push({code:"unsupported_schema",path:"configuration.schema",message:`Configuration schema must be ${wt}`}),ye(e.id,Re)||t.push({code:"invalid_id",path:"configuration.id",message:"Configuration id must contain 1 to 100 normalized characters"}),ye(e.label,Ur)||t.push({code:"invalid_label",path:"configuration.label",message:"Configuration label must contain 1 to 120 normalized characters"}),Kr(e.version)||t.push({code:"invalid_version",path:"configuration.version",message:"Configuration version must be a positive integer"});let n=zr(e.baseVenue);n||t.push({code:"invalid_base_venue",path:"configuration.baseVenue",message:"Base venue must identify one normalized chart id and exact version"});let r=De(e.overlay)?e.overlay:null,o=Vn(r?.objectIds),s=Vn(r?.productionKillSeatIds),i=o?Zr(r?.productionElements,o):null;return(!r||!o||!s)&&t.push({code:"invalid_overlay",path:"configuration.overlay",message:"Overlay ids must be bounded arrays of normalized stable ids"}),i===null&&t.push({code:"invalid_production_element",path:"configuration.overlay.productionElements",message:"Production elements must be unique, bounded semantics over referenced base-venue objects"}),t.length||!n||!o||!s||i===null?{issues:t}:{issues:t,value:{schema:wt,id:e.id,label:e.label,version:e.version,baseVenue:n,overlay:{objectIds:o,productionKillSeatIds:s,...i!==void 0?{productionElements:i}:{}}}}}function Hn(e){let t=Qr(e);return t.value?{ok:!0,value:t.value}:{ok:!1,issues:t.issues}}function Kn(e,t,n){let r=()=>({byObjectId:new Map,elements:[]});if(!t||!e)return r();let o=Hn(t);if(!o.ok||o.value.id!==e)return r();let s=new Map;for(let h of n)for(let c of h.objects)c.type==="shape"&&s.set(c.id,{shape:c,unit:h});let i=new Set,a=new Set,m=new Map((t.overlay.productionElements??[]).map(h=>{let c=h.runtimeContentImageUrl;return[h.id,typeof c=="string"&&/^(?:blob:|data:image\/|https:\/\/)/.test(c)?c:void 0]})),l=[];for(let h of o.value.overlay.productionElements??[]){let c=s.get(h.objectId),u=c?be(c.shape):null,d=h.baseElevationM??0;if(!c||!u||u.length<3||!h.id||i.has(h.id)||a.has(h.objectId)||!Number.isFinite(h.heightM)||h.heightM<.05||h.heightM>50||!Number.isFinite(d)||d<-10||d>100)return r();i.add(h.id),a.add(h.objectId);let b=u.map(k=>k.x*I),y=u.map(k=>k.y*I),p=c.unit.baseHeightM+d,g=Math.min(...b),x=Math.max(...b),M=Math.min(...y),L=Math.max(...y),v,R=m.get(h.id)??h.contentImageUrl;if(h.kind==="screen"&&R)if(x-g>=L-M){let k=Math.abs(M-c.unit.focal.y*I)<=Math.abs(L-c.unit.focal.y*I)?M-.006:L+.006;v=[[g,p,k],[x,p,k],[g,p+h.heightM,k],[x,p+h.heightM,k]]}else{let k=Math.abs(g-c.unit.focal.x*I)<=Math.abs(x-c.unit.focal.x*I)?g-.006:x+.006;v=[[k,p,M],[k,p,L],[k,p+h.heightM,M],[k,p+h.heightM,L]]}l.push({id:h.id,objectId:h.objectId,kind:h.kind,floorIndex:c.unit.index,baseY:p,topY:p+h.heightM,bounds:{min:[g,p,M],max:[x,p+h.heightM,L]},occlusion:h.occlusion,...R?{contentImageUrl:R}:{},...v?{contentPlane:v}:{}})}let f=l.sort((h,c)=>h.id.localeCompare(c.id));return{byObjectId:new Map(f.map(h=>[h.objectId,h])),elements:f}}function oe(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ne(e){return Array.isArray(e)?e:[]}function $r(e){let t=[e];for(;t.length;){let n=t.pop();if(Array.isArray(n)){t.push(...n);continue}if(!oe(n))continue;let r=oe(n.extensions)?n.extensions:null;if(r&&Object.prototype.hasOwnProperty.call(r,"KHR_draco_mesh_compression"))return!0;t.push(...Object.values(n))}return!1}function nt(e,t){return!Array.isArray(e)||e.length!==t||!e.every(n=>typeof n=="number"&&Number.isFinite(n))?null:e}function qr(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function Jr(e,t){let n=new Array(16).fill(0);for(let r=0;r<4;r++)for(let o=0;o<4;o++)for(let s=0;s<4;s++)n[r*4+o]+=e[s*4+o]*t[r*4+s];return n}function ei(e){let t=nt(e.matrix,16);if(t)return t;if(e.matrix!==void 0)return null;let n=e.translation===void 0?[0,0,0]:nt(e.translation,3),r=e.rotation===void 0?[0,0,0,1]:nt(e.rotation,4),o=e.scale===void 0?[1,1,1]:nt(e.scale,3);if(!n||!r||!o)return null;let[s,i,a,m]=r,l=Math.hypot(s,i,a,m);if(!(l>1e-8))return null;let f=s/l,h=i/l,c=a/l,u=m/l,d=f+f,b=h+h,y=c+c,p=f*d,g=f*b,x=f*y,M=h*b,L=h*y,v=c*y,R=u*d,k=u*b,B=u*y;return[(1-(M+v))*o[0],(g+B)*o[0],(x-k)*o[0],0,(g-B)*o[1],(1-(p+v))*o[1],(L+R)*o[1],0,(x+k)*o[2],(L-R)*o[2],(1-(p+M))*o[2],0,n[0],n[1],n[2],1]}function ti(e,t,n,r){return[e[0]*t+e[4]*n+e[8]*r+e[12],e[1]*t+e[5]*n+e[9]*r+e[13],e[2]*t+e[6]*n+e[10]*r+e[14]]}function ni(e){let t=e[0],n=e[4],r=e[8],o=e[1],s=e[5],i=e[9],a=e[2],m=e[6],l=e[10],f=s*l-i*m,h=i*a-o*l,c=o*m-s*a,u=t*f+n*h+r*c;if(Math.abs(u)<1e-12)return null;let d=1/u;return[f*d,h*d,c*d,(r*m-n*l)*d,(t*l-r*a)*d,(n*a-t*m)*d,(n*i-r*s)*d,(r*o-t*i)*d,(t*s-n*o)*d]}function zn(e,t,n,r){let o=e[0]*t+e[1]*n+e[2]*r,s=e[3]*t+e[4]*n+e[5]*r,i=e[6]*t+e[7]*n+e[8]*r,a=Math.hypot(o,s,i)||1;return o/=a,s/=a,i/=a,[o,s,i]}function oi(e){if(e.byteLength<20||e.byteLength>8388608)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength);if(t.getUint32(0,!0)!==1179937895||t.getUint32(4,!0)!==2||t.getUint32(8,!0)!==e.byteLength)return null;let n=12,r=null,o=null;for(;n+8<=e.byteLength;){let s=t.getUint32(n,!0),i=t.getUint32(n+4,!0);if(n+=8,s%4!==0||n+s>e.byteLength)return null;let a=e.subarray(n,n+s);if(i===1313821514&&!r)try{let m=JSON.parse(new TextDecoder().decode(a).replace(/[\u0000 ]+$/g,""));if(!oe(m))return null;r=m}catch{return null}else if(i===5130562&&!o)o=a;else return null;n+=s}return n===e.byteLength&&r&&o?{json:r,bin:o}:null}function ri(e){return e===5120||e===5121?1:e===5122||e===5123?2:e===5125||e===5126?4:0}function ii(e){return e==="SCALAR"?1:e==="VEC2"?2:e==="VEC3"?3:e==="VEC4"?4:0}function si(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 ai(e){let t=e instanceof Uint8Array?e:new Uint8Array(e),n=oi(t);if(!n)return{ok:!1,issue:"invalid_glb"};let{json:r,bin:o}=n;if(!oe(r.asset)||r.asset.version!=="2.0")return{ok:!1,issue:"unsupported_glb"};let s=ne(r.extensionsUsed).filter(M=>typeof M=="string");if(s.includes("KHR_draco_mesh_compression")||$r(r))return{ok:!1,issue:"draco_not_allowed"};if(s.length||ne(r.extensionsRequired).length)return{ok:!1,issue:"unsupported_glb"};if(ne(r.images).length||ne(r.textures).length)return{ok:!1,issue:"external_resource"};let i=ne(r.buffers);if(i.length!==1||!oe(i[0])||i[0].uri!==void 0||typeof i[0].byteLength!="number"||!Number.isInteger(i[0].byteLength)||i[0].byteLength<0||i[0].byteLength>o.byteLength)return{ok:!1,issue:"external_resource"};let a=ne(r.accessors),m=ne(r.bufferViews),l=ne(r.meshes),f=ne(r.nodes),h=ne(r.scenes),c=typeof r.scene=="number"?r.scene:0;if(!oe(h[c]))return{ok:!1,issue:"unsupported_glb"};let u=new DataView(o.buffer,o.byteOffset,o.byteLength),d=(M,L,v)=>{if(typeof M!="number"||!Number.isInteger(M)||!oe(a[M]))return null;let R=a[M];if(R.type!==L||R.sparse!==void 0||R.normalized===!0||typeof R.count!="number"||!Number.isInteger(R.count)||R.count<1||typeof R.componentType!="number"||!v.includes(R.componentType)||typeof R.bufferView!="number")return null;let k=m[R.bufferView];if(!oe(k)||k.buffer!==0||typeof k.byteLength!="number"||!Number.isInteger(k.byteLength)||k.byteLength<0)return null;let B=ii(R.type),D=ri(R.componentType),U=typeof k.byteStride=="number"?k.byteStride:B*D,P=typeof k.byteOffset=="number"?k.byteOffset:0,S=typeof R.byteOffset=="number"?R.byteOffset:0,T=P+S,_=S+(R.count-1)*U+B*D;if(!Number.isInteger(U)||!Number.isInteger(P)||!Number.isInteger(S)||U<B*D||P<0||S<0||P+k.byteLength>o.byteLength||_>k.byteLength)return null;let w=[];for(let F=0;F<R.count;F++){let E=[];for(let C=0;C<B;C++){let A=si(u,T+F*U+C*D,R.componentType);if(!Number.isFinite(A))return null;E.push(A)}w.push(E)}return w},b=[],y=[],p=0,g=new Set,x=(M,L)=>{if(typeof M!="number"||!Number.isInteger(M)||!oe(f[M])||g.has(M))return!1;g.add(M);let v=f[M],R=ei(v);if(!R)return!1;let k=Jr(L,R),B=ni(k);if(!B)return!1;if(v.mesh!==void 0){if(typeof v.mesh!="number")return!1;let D=l[v.mesh];if(!oe(D))return!1;for(let U of ne(D.primitives)){if(!oe(U)||U.mode!==void 0&&U.mode!==4||!oe(U.attributes))return!1;let P=d(U.attributes.POSITION,"VEC3",[5126]),S=U.attributes.NORMAL===void 0?null:d(U.attributes.NORMAL,"VEC3",[5126]);if(!P||U.attributes.NORMAL!==void 0&&!S)return!1;let T=P.length;if(U.indices!==void 0){let w=typeof U.indices=="number"?a[U.indices]:null;T=oe(w)?w.count:void 0}if(typeof T!="number"||!Number.isInteger(T)||T%3!==0||(p+=T/3,p>1e5))return!1;let _=U.indices===void 0?P.map((w,F)=>[F]):d(U.indices,"SCALAR",[5121,5123,5125]);if(!_||_.length%3!==0||_.length!==T)return!1;for(let w=0;w<_.length;w+=3){let F=[_[w][0],_[w+1][0],_[w+2][0]];if(F.some(A=>!Number.isInteger(A)||A<0||A>=P.length))return!1;let E=F.map(A=>ti(k,...P[A])),C=null;if(!S){let A=E[1][0]-E[0][0],G=E[1][1]-E[0][1],j=E[1][2]-E[0][2],X=E[2][0]-E[0][0],N=E[2][1]-E[0][1],Y=E[2][2]-E[0][2];C=zn([1,0,0,0,1,0,0,0,1],G*Y-j*N,j*X-A*Y,A*N-G*X)}for(let A=0;A<3;A++)b.push(...E[A]),y.push(...S?zn(B,...S[F[A]]):C)}}}for(let D of ne(v.children))if(!x(D,k))return!1;return g.delete(M),!0};for(let M of ne(h[c].nodes))if(!x(M,qr()))return{ok:!1,issue:p>1e5?"triangle_limit":"unsupported_glb"};return!p||b.length!==p*9||y.length!==b.length?{ok:!1,issue:"unsupported_glb"}:{ok:!0,triangleCount:p,position:new Float32Array(b),normal:new Float32Array(y)}}function Wn(e){try{return ai(e)}catch{return{ok:!1,issue:"invalid_glb"}}}function Zn(e){let{doc:t}=e,n=At(t.theme),r=n.structure,o=mn(t,e.eventConfigurationId??t.eventConfigurationId),s=Kn(e.eventConfigurationId,e.eventConfiguration,o),i=e.seats,a=new Ke,m=null;if(e.registeredShellGlb){let _=Wn(e.registeredShellGlb);if(_.ok){let w=_.position.length/3,F=new Float32Array(_.position.length),E=n.materials.shell??r.tierWall;for(let C=0;C<w;C++){let A=_.normal[C*3+1],G=A<-.25?.4:.62+.38*Math.max(0,A);F[C*3]=E[0]*G,F[C*3+1]=E[1]*G,F[C*3+2]=E[2]*G}m={position:_.position,normal:_.normal,color:F,floor:new Float32Array(w).fill(-2),material:new Float32Array(w),count:w}}}let l=new Map;for(let _ of o)for(let w of _.objects)l.set(w.id,_.index),w.type==="section"&&l.set(w.logicalSectionId??w.id,_.index);let f=i.map(_=>l.get(_.sectionId??"")??l.get(_.rowId??"")??0),h=vt(o,i);jn(a,o,i,f,h,r);let c=yn(t,i),u=new Map,d=new Map;for(let _ of t.categories??[])u.set(_.key,_.color),_.seatGlyph&&d.set(_.key,_.seatGlyph);let b=[],y=pn(o,i,f),p=new Float32Array(i.length);for(let _=0;_<o.length;_++){let w=o[_];a.setFloor(_);let F=new Je,E=[],C=w.objects.filter(A=>A.type==="section"&&!!A.outline&&A.outline.length>=3);for(let A of w.objects)if(A.type==="section")Ln(a,A,w,gn(A,c),y.bySection.get(A.id),F,C,r);else if(A.type==="shape"){let G=s.byObjectId.get(A.id);a.setMaterial((G?.kind??A.role)==="screen"?1:0),Pn(a,A,w.baseHeightM,Sn(A,E),r,w.focal,b,G),a.setMaterial(0)}else A.type==="gaArea"?En(a,A,w.baseHeightM,W(u.get(A.categoryKey)),r):A.type==="booth"?In(a,A,w.baseHeightM,W(u.get(A.categoryKey)),r):A.type==="table"?Rn(a,A,w.baseHeightM,W(u.get(A.categoryKey)),r):A.type==="decorImage"&&Cn(a,A,w.baseHeightM,r);On(a,w,i,y,r,n.materials.shell,!m)}let g=o.length>1?{x:o.reduce((_,w)=>_+w.focal.x,0)/o.length,y:o.reduce((_,w)=>_+w.focal.y,0)/o.length}:t.focalPoint??{x:(h.minX+h.maxX)/2,y:(h.minY+h.maxY)/2},x=Ft(m?[a.build(),m]:[a.build()]),M=Ht(i,e.initialState,y,p,u,d),L=Fn({doc:t,units:o,seats:i,surfaces:y,focal:g}),{labels:v,sections:R,rows:k}=Dn({doc:t,units:o,seats:i,surfaces:y,seatData:M,hintedSeatFloor:f,zones:L,focal:g}),B=Nn({doc:t,units:o,seats:i,surfaces:y,solids:x,hintedSeatFloor:f,seatFloor:p});Gn(v,B),M.iYaw=Vt(M.iPosition,i.length,_=>i[_].rowId,_=>{let w=o[p[_]]?.focal??g;return[w.x*I,w.y*I]});let D=(h.minX+h.maxX)/2*I,U=(h.minY+h.maxY)/2*I,P=.5*Math.hypot((h.maxX-h.minX)*I,(h.maxY-h.minY)*I)||10,S=Un(x,M,{cx:D,cz:U,radius:P}),T=Xn(M,b,h,S.minY,S.maxY,P);return{solids:x,seats:M,bounds:{center:[(T.min[0]+T.max[0])/2,(T.min[1]+T.max[1])/2,(T.min[2]+T.max[2])/2],radius:P,groundY:0,box:T},renderBounds:{center:S.center,radius:S.radius},stateColorLUT:_t(n,Xe),theme:n,seatCount:i.length,focalWorld:[g.x*I,1.5,g.y*I],zones:L,stages:b,productionElements:s.elements,sections:R,rows:k,labels:v,floors:B}}function ci(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 Qn=self;Qn.onmessage=e=>{let t=performance.now(),n=Zn({doc:e.data.doc,seats:e.data.seats,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb});Qn.postMessage({model:n,buildMs:performance.now()-t},ci(n))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as t}from"../../chunk-WYXHD6J2.js";import"../../chunk-7OJ6SB6V.js";import"../../chunk-UHPX2P7O.js";import"../../chunk-T2LWVOQ3.js";import"../../chunk-AWPHGLTU.js";import"../../chunk-UL5OIGIF.js";import"../../chunk-X3K36XZM.js";import"../../chunk-CXF32VPG.js";import"../../chunk-CRCGO52K.js";function o(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(s=>s.buffer)}var r=self;r.onmessage=e=>{let a=performance.now(),s=t({doc:e.data.doc,seats:e.data.seats,eventConfigurationId:e.data.eventConfigurationId,eventConfiguration:e.data.eventConfiguration,registeredShellGlb:e.data.registeredShellGlb});r.postMessage({model:s,buildMs:performance.now()-a},o(s))};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seatlayer/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.71.2",
|
|
4
4
|
"description": "SeatLayer's seat map rendering engine — the seating chart runtime behind @seatlayer/js and the React, Vue, and Angular SDKs.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"author": {
|
|
File without changes
|