@seatlayer/core 0.53.0 → 0.55.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 (78) hide show
  1. package/README.md +2 -2
  2. package/dist/categoryInventory-BwarniiK.d.ts +109 -0
  3. package/dist/categoryInventory-D3qPwfKz.d.cts +109 -0
  4. package/dist/chunk-55NOSZK5.js +1 -0
  5. package/dist/chunk-6VTTBC5F.js +1 -0
  6. package/dist/chunk-6XJN4REG.js +1 -0
  7. package/dist/chunk-7PT7OQUO.js +1 -0
  8. package/dist/chunk-AQKYUJBX.js +1 -0
  9. package/dist/chunk-CXF32VPG.js +1 -0
  10. package/dist/chunk-DNGP2HDT.js +1 -0
  11. package/dist/chunk-EQM4FFN5.js +1 -0
  12. package/dist/chunk-HHM3PB66.js +1 -0
  13. package/dist/chunk-PXWKSYCK.js +1 -0
  14. package/dist/chunk-VDZ24QVV.js +1 -0
  15. package/dist/chunk-VI2CLV3Y.js +1 -0
  16. package/dist/core/chart-ops/index.cjs +1 -0
  17. package/dist/core/chart-ops/index.d.cts +1235 -0
  18. package/dist/core/chart-ops/index.d.ts +1235 -0
  19. package/dist/core/chart-ops/index.js +1 -0
  20. package/dist/core/color.cjs +1 -0
  21. package/dist/core/color.d.cts +192 -0
  22. package/dist/core/color.d.ts +192 -0
  23. package/dist/core/color.js +1 -0
  24. package/dist/core/inventory/index.cjs +1 -0
  25. package/dist/core/inventory/index.d.cts +209 -0
  26. package/dist/core/inventory/index.d.ts +209 -0
  27. package/dist/core/inventory/index.js +1 -0
  28. package/dist/core/layout/index.cjs +1 -0
  29. package/dist/core/layout/index.d.cts +376 -0
  30. package/dist/core/layout/index.d.ts +376 -0
  31. package/dist/core/layout/index.js +1 -0
  32. package/dist/core/quality/index.cjs +1 -0
  33. package/dist/core/quality/index.d.cts +132 -0
  34. package/dist/core/quality/index.d.ts +132 -0
  35. package/dist/core/quality/index.js +1 -0
  36. package/dist/core/render-assets/index.cjs +1 -0
  37. package/dist/core/render-assets/index.d.cts +99 -0
  38. package/dist/core/render-assets/index.d.ts +99 -0
  39. package/dist/core/render-assets/index.js +1 -0
  40. package/dist/core/seatConfidence.cjs +1 -1
  41. package/dist/core/seatConfidence.d.cts +1 -1
  42. package/dist/core/seatConfidence.d.ts +1 -1
  43. package/dist/core/seatConfidence.js +1 -1
  44. package/dist/core/sections/index.cjs +1 -0
  45. package/dist/core/sections/index.d.cts +346 -0
  46. package/dist/core/sections/index.d.ts +346 -0
  47. package/dist/core/sections/index.js +1 -0
  48. package/dist/{de-75NWRKC5.js → de-WPX4D3SY.js} +1 -1
  49. package/dist/{es-BM7EJ7PW.js → es-6KAJQVVX.js} +1 -1
  50. package/dist/{fr-HPXQHIB4.js → fr-5DTMRBN5.js} +1 -1
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.d.cts +85 -534
  53. package/dist/index.d.ts +85 -534
  54. package/dist/index.js +1 -1
  55. package/dist/labeling-BmCzW50y.d.ts +90 -0
  56. package/dist/labeling-VfJBEOn0.d.cts +90 -0
  57. package/dist/layout-ClQkmixY.d.ts +181 -0
  58. package/dist/layout-Dlv5bIf2.d.cts +181 -0
  59. package/dist/renderedQuality-B3jgdgPO.d.ts +113 -0
  60. package/dist/renderedQuality-bDkUOyBL.d.cts +113 -0
  61. package/dist/renderer-B_g-W_QB.d.ts +534 -0
  62. package/dist/renderer-DySMcKAR.d.cts +534 -0
  63. package/dist/sections-DIzgtDjF.d.ts +123 -0
  64. package/dist/sections-Dna1nZgR.d.cts +123 -0
  65. package/dist/segmentedRowModel-BNXEUeHp.d.cts +75 -0
  66. package/dist/segmentedRowModel-COXw4GCh.d.ts +75 -0
  67. package/dist/ticketRestrictions-CzchbX_o.d.cts +72 -0
  68. package/dist/ticketRestrictions-DaYOCpEw.d.ts +72 -0
  69. package/dist/{types-tLOunI-B.d.cts → types-DTSG6_Hq.d.cts} +238 -761
  70. package/dist/{types-tLOunI-B.d.ts → types-DTSG6_Hq.d.ts} +238 -761
  71. package/dist/view3d/crossfade/panorama.d.cts +1 -1
  72. package/dist/view3d/crossfade/panorama.d.ts +1 -1
  73. package/dist/view3d/index.cjs +27 -27
  74. package/dist/view3d/index.d.cts +109 -2
  75. package/dist/view3d/index.d.ts +109 -2
  76. package/dist/view3d/index.js +26 -26
  77. package/package.json +94 -5
  78. package/dist/chunk-54A7LIL5.js +0 -1
@@ -0,0 +1 @@
1
+ var jt=40,Nt=1200,Ft=.8,Dt=3,Ht=-2,Ut=20,Bt=.1,Gt=40,Xt=40,ne=e=>Math.max(1,e.fontSize*.6+(e.letterSpacing??0));function He(e,t){let n=e.text.split(/\r?\n/);if(!e.width)return Math.max(1,n.length);let o=Math.max(1,Math.floor(t/ne(e))),r=0;for(let i of n){if(!i.length){r+=1;continue}let s=0;for(let c of i.split(/\s+/)){let u=c.length;s&&s+1+u<=o?s+=1+u:(r+=Math.max(1,Math.ceil(u/o)),s=u%o)}}return Math.max(1,r)}function oe(e){let t=e.background?.padding??0,n=e.text.split(/\r?\n/),o=Math.max(1,...n.map(c=>c.length))*ne(e),r=e.width??o+t*2,i=Math.max(1,r-t*2),s=He(e,i);return{width:r,height:s*e.fontSize*(e.lineHeight??1.2)+t*2,lineCount:s,padding:t}}var Ue=Math.PI/180;function v(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Be(e,t,n){let o=Math.cos(n),r=Math.sin(n),i=e.x-t.x,s=e.y-t.y;return{x:t.x+i*o-s*r,y:t.y+i*r+s*o}}function Kt(e,t){return Be(e,{x:0,y:0},t*Ue)}function C(e,t,n){return{x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n}}function Ge(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 $t(e){return e.length?Ge(e):null}function K(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 Yt(e,t,n){let o={x:(e.x+t.x)/2,y:(e.y+t.y)/2},r={x:(n.x-o.x)*4/3,y:(n.y-o.y)*4/3};return{start:{...e},control1:{x:e.x+(t.x-e.x)/3+r.x,y:e.y+(t.y-e.y)/3+r.y},control2:{x:e.x+(t.x-e.x)*2/3+r.x,y:e.y+(t.y-e.y)*2/3+r.y},end:{...t}}}function se(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[K(e,.5)];let o=Array.from({length:n+1},(u,b)=>K(e,b/n)),r=new Float64Array(o.length);for(let u=1;u<o.length;u+=1){let b=o[u].x-o[u-1].x,a=o[u].y-o[u-1].y;r[u]=r[u-1]+Math.hypot(b,a)}let i=r[r.length-1];if(i<=1e-9)return Array.from({length:t},()=>({...e.start}));let s=[],c=1;for(let u=0;u<t;u+=1){let b=i*u/(t-1);for(;c<r.length-1&&r[c]<b;)c+=1;let a=r[c-1],f=r[c],l=f===a?0:(b-a)/(f-a);s.push({x:o[c-1].x+(o[c].x-o[c-1].x)*l,y:o[c-1].y+(o[c].y-o[c-1].y)*l})}return s}function R(e,t){return{x:e.x+t.x,y:e.y+t.y}}function D(e,t){return{x:e.x-t.x,y:e.y-t.y}}function T(e,t){return{x:e.x*t,y:e.y*t}}function H(e,t=13){return Array.from({length:t},(n,o)=>K(e,o/(t-1)))}function re(e,t){let n=Math.max(0,Math.min(1,t))*(e.length-1),o=Math.min(e.length-2,Math.floor(n));return C(e[o],e[o+1],n-o)}function ie(e,t,n){let o=Math.max(0,Math.min(1,t)),r=Math.max(o,Math.min(1,n)),i=[re(e,o)];for(let s=1;s<e.length-1;s+=1){let c=s/(e.length-1);c>o+1e-9&&c<r-1e-9&&i.push(e[s])}return i.push(re(e,r)),i}function ce(e,t){let n=[[0,1],[1,2],[2,3],[3,0]],o=0,r=Number.POSITIVE_INFINITY;n.forEach(([l,p],x)=>{let g=v(C(e[l],e[p],.5),t);g<r&&(r=g,o=x)});let i=e[o],s=e[(o+1)%4],c=e[(o+2)%4],u=e[(o+3)%4],b=C(i,s,.5),a=D(t,b),f=Math.max(1e-9,Math.hypot(a.x,a.y));return{p0:i,p1:s,p2:c,p3:u,normal:T(a,1/f),depth:(v(i,u)+v(s,c))/2}}function ae(e){let{p0:t,p1:n,p2:o,p3:r,normal:i,depth:s}=e,c=D(n,t),u=D(o,r),b=s*.22,a=s*.12;return{nearPath:{start:t,control1:R(R(t,T(c,1/3)),T(i,b)),control2:R(R(t,T(c,2/3)),T(i,b)),end:n},farPath:{start:o,control1:R(R(r,T(u,2/3)),T(i,a)),control2:R(R(r,T(u,1/3)),T(i,a)),end:r}}}function qt(e,t,n){if(e.length!==4)throw new Error("A section shell requires four mapped bounds corners");let o=e.reduce((x,g)=>R(x,g),{x:0,y:0});o.x/=4,o.y/=4;let r=v(e[0],e[1]),i=v(e[0],e[3]),s=n==="auto"?r>i*1.25&&v(o,t)>i?"bezier":"tapered":n;if(s==="rectangle")return{mode:s,outline:e.map(x=>({...x}))};let c=ce(e,t),{p0:u,p1:b,p2:a,p3:f}=c;if(s==="tapered")return{mode:s,outline:[R(u,T(D(b,u),.14)),R(u,T(D(b,u),1-.14)),a,f]};let{nearPath:l,farPath:p}=ae(c);return{mode:s,outline:[...H(l),...H(p).slice(1)]}}function Jt(e,t,n,o){if(e.length!==4)throw new Error("Aisle generation requires four mapped bounds corners");if(!Number.isInteger(n)||n<0||n>3)throw new Error("Aisle count must be an integer from 0 to 3");if(n===0)return[];let r=ce(e,t),{p0:i,p1:s,p2:c,p3:u}=r,b=o==="bezier"?ae(r):null,a=b?H(b.nearPath):null,f=b?H(b.farPath).reverse():null,l=Math.min(.055,.18/(n+1));return Array.from({length:n},(p,x)=>{let g=(x+1)/(n+1),m=g-l/2,h=g+l/2;return a&&f?[...ie(a,m,h),...ie(f,m,h).reverse()]:[C(i,s,m),C(i,s,h),C(u,c,h),C(u,c,m)]})}function Xe(e,t,n){let o=n.x-t.x,r=n.y-t.y,i=o*o+r*r,s=i?Math.max(0,Math.min(1,((e.x-t.x)*o+(e.y-t.y)*r)/i)):0;return Math.hypot(e.x-(t.x+s*o),e.y-(t.y+s*r))}function ze(e,t){let n=1/0;for(let o of t)if(!(o.length<2))for(let r=0,i=o.length-1;r<o.length;i=r++){let s=Xe(e,o[i],o[r]);s<n&&(n=s)}return n}function le(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,c=t[r].x,u=t[r].y;s>e.y!=u>e.y&&e.x<(c-i)*(e.y-s)/(u-s)+i&&(n=!n)}return n}function Ke(e,t,n){let o=le(e,t)&&!n.some(i=>le(e,i)),r=ze(e,[t,...n]);return o?r:-r}function L(e,t,n,o,r){let i=Ke({x:e,y:t},o,r);return{x:e,y:t,h:n,d:i,max:i+n*Math.SQRT2}}var $=class{constructor(){this.items=[]}get size(){return this.items.length}push(t){let n=this.items;n.push(t);let o=n.length-1;for(;o>0;){let r=o-1>>1;if(n[r].max>=n[o].max)break;[n[r],n[o]]=[n[o],n[r]],o=r}}pop(){let t=this.items,n=t[0],o=t.pop();if(t.length&&o){t[0]=o;let r=0;for(;;){let i=r*2+1,s=i+1,c=r;if(i<t.length&&t[i].max>t[c].max&&(c=i),s<t.length&&t[s].max>t[c].max&&(c=s),c===r)break;[t[c],t[r]]=[t[r],t[c]],r=c}}return n}};function ue(e){if(e.length<3)return 0;let t=0;for(let n=0,o=e.length-1;n<e.length;o=n++)t+=(e[o].x+e[n].x)*(e[o].y-e[n].y);return Math.abs(t)/2}function Zt(e,t){return Math.max(0,ue(e)-(t??[]).reduce((n,o)=>n+ue(o),0))}function fe(e,t){let n=t??[];if(!e.length)return{point:{x:0,y:0},radius:0};if(e.length<3){let g=e.reduce((h,S)=>h+S.x,0)/e.length,m=e.reduce((h,S)=>h+S.y,0)/e.length;return{point:{x:g,y:m},radius:0}}let o=1/0,r=1/0,i=-1/0,s=-1/0;for(let g of e)g.x<o&&(o=g.x),g.y<r&&(r=g.y),g.x>i&&(i=g.x),g.y>s&&(s=g.y);let c=i-o,u=s-r,b=Math.min(c,u);if(!(b>0))return{point:{x:(o+i)/2,y:(r+s)/2},radius:0};let a=Math.max(c,u)/150,f=new $,l=b/2;for(let g=o;g<i;g+=b)for(let m=r;m<s;m+=b)f.push(L(g+l,m+l,l,e,n));let p=L(o+c/2,r+u/2,0,e,n),x=0;for(;f.size;){let g=f.pop();if(!g)break;g.d>p.d&&(p=g),!(g.max-p.d<=a)&&(x>=4e3||(x+=1,l=g.h/2,f.push(L(g.x-l,g.y-l,l,e,n)),f.push(L(g.x+l,g.y-l,l,e,n)),f.push(L(g.x-l,g.y+l,l,e,n)),f.push(L(g.x+l,g.y+l,l,e,n))))}return{point:{x:p.x,y:p.y},radius:Math.max(0,p.d)}}function $e(e,t,n){return Math.max(t,Math.min(n,e))}function tn(e,t,n){return e<t?t:e>n?n:e}function We(e){return $e(e,0,1)}function de(e){let t=We(e);return t*t*(3-2*t)}var j=Math.PI*2;function N(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}function Ve(e,t,n){let o=t-e;if(n){for(;o<0;)o+=j;for(;o>=j;)o-=j}else{for(;o>0;)o-=j;for(;o<=-j;)o+=j}return o}function sn(e){return e.end}function pe(e){if(e.version!==1||e.closed!==!0||!N(e.start)||!Array.isArray(e.segments)||e.segments.length<2||e.segments.length>512)return!1;let t=e.start;for(let n of e.segments){if(!n||!N(n.end))return!1;if(n.kind==="line"){if(v(t,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!N(n.control1)||!N(n.control2)||v(t,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!N(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(v(t,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(v(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||v(t,n.end)<=1e-9)return!1}else return!1;t=n.end}return v(t,e.start)<=1e-4}function Ye(e,t,n){let o=1-n;return{x:o**3*e.x+3*o**2*n*t.control1.x+3*o*n**2*t.control2.x+n**3*t.end.x,y:o**3*e.y+3*o**2*n*t.control1.y+3*o*n**2*t.control2.y+n**3*t.end.y}}function cn(e,t=2){if(!pe(e))throw new Error("Section outline path is invalid");let n=Math.max(.25,t),o=[{...e.start}],r=e.start;for(let i of e.segments){if(i.kind==="line")o.push({...i.end});else if(i.kind==="arc"){let s=Math.atan2(r.y-i.center.y,r.x-i.center.x),c=Math.atan2(i.end.y-i.center.y,i.end.x-i.center.x),u=Ve(s,c,i.clockwise),b=Math.max(2,Math.ceil(Math.abs(u)*i.radius/n));for(let a=1;a<=b;a+=1){let f=s+u*a/b;o.push({x:i.center.x+Math.cos(f)*i.radius,y:i.center.y+Math.sin(f)*i.radius})}}else{let s=v(r,i.control1)+v(i.control1,i.control2)+v(i.control2,i.end),c=Math.max(2,Math.ceil(s/n));for(let u=1;u<=c;u+=1)o.push(Ye(r,i,u/c))}r=i.end}return v(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function ye(e,t,n){return qe(e,r=>({x:r.x+t,y:r.y+n}))}function qe(e,t,n=1,o=!1){return{...e,start:t(e.start),segments:e.segments.map(r=>r.kind==="line"?{...r,end:t(r.end)}:r.kind==="arc"?{...r,center:t(r.center),radius:r.radius*Math.abs(n),clockwise:o?!r.clockwise:r.clockwise,end:t(r.end)}:{...r,control1:t(r.control1),control2:t(r.control2),end:t(r.end)})}}var an=45,Je=150,he=.5523;function me(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}function Qe(e){let t=[],n=[];for(e.forEach((o,r)=>{N(o)&&(t.length&&me(t[t.length-1],o)||(t.push({x:o.x,y:o.y}),n.push(r)))});t.length>1&&me(t[0],t[t.length-1]);)t.pop(),n.pop();return{points:t,sourceIndex:n}}function ln(e,t,n){return nt(e,{cornerSmoothing:t,...n})}var Ze=.5,et=4/3;function tt(e,t,n){let o=t.x-e.x,r=t.y-e.y,i=Math.hypot(o,r);if(i<=1e-9)return{kind:"line",end:{...t}};let s=-r/i,c=o/i,u=n*et;return{kind:"bezier",control1:{x:e.x+o/3+s*u,y:e.y+r/3+c*u},control2:{x:e.x+o*2/3+s*u,y:e.y+r*2/3+c*u},end:{...t}}}function nt(e,t){let{points:n,sourceIndex:o}=Qe(e),r=n.length;if(r<3)return null;let i=Math.min(100,Math.max(0,t.cornerSmoothing??0))/100,s=t.edgeCurvature,c=new Array(r).fill(0);if(s?.length)for(let d=0;d<r;d+=1){let P=s[o[d]];c[d]=Number.isFinite(P)?Math.min(100,Math.max(-100,P))/100:0}let u=c.some(d=>Math.abs(d)>1e-6);if(i<=0&&!u)return null;let b=t.wideAngleThresholdDeg??Je,a=[];for(let d=0;d<r;d+=1)a[d]=v(n[d],n[(d+1)%r]);let f=new Array(r).fill(0);for(let d=0;d<r;d+=1){let P=n[(d-1+r)%r],w=n[d],M=n[(d+1)%r],E={x:P.x-w.x,y:P.y-w.y},O={x:M.x-w.x,y:M.y-w.y},A=Math.hypot(E.x,E.y),k=Math.hypot(O.x,O.y);if(A<=1e-9||k<=1e-9)continue;let I=Math.min(1,Math.max(-1,(E.x*O.x+E.y*O.y)/(A*k))),_=Math.acos(I)*180/Math.PI;if(_<b)continue;let z=de((_-b)/(180-b));f[d]=i*z*.5*Math.min(A,k)}for(let d=0;d<r;d+=1){let P=(d+1)%r,w=f[d]+f[P];if(w>a[d]&&w>1e-9){let M=a[d]/w;f[d]*=M,f[P]*=M}}let l=new Array(r),p=new Array(r);for(let d=0;d<r;d+=1){let P=n[(d-1+r)%r],w=n[d],M=n[(d+1)%r];if(f[d]<=1e-6){l[d]={...w},p[d]={...w};continue}let E=v(w,P)||1,O=v(w,M)||1;l[d]={x:w.x+(P.x-w.x)/E*f[d],y:w.y+(P.y-w.y)/E*f[d]},p[d]={x:w.x+(M.x-w.x)/O*f[d],y:w.y+(M.y-w.y)/O*f[d]}}if(f.every(d=>d<=1e-6)&&!u)return null;let x=[],g={...p[0]},m=g,h=(d,P)=>{if(v(m,d)<=1e-9)return;let w=c[P];Math.abs(w)>1e-6?x.push(tt(m,d,w*Ze*a[P])):x.push({kind:"line",end:{...d}}),m=d};for(let d=1;d<=r;d+=1){let P=d%r,w=n[P];h(l[P],(d-1)%r),f[P]>1e-6&&v(l[P],p[P])>1e-9&&(x.push({kind:"bezier",control1:C(l[P],w,he),control2:C(p[P],w,he),end:{...p[P]}}),m=p[P])}if(!x.length)return null;let S=x[x.length-1];v(S.end,g)>1e-9&&(S.kind==="line"?S.end={...g}:x.push({kind:"line",end:{...g}}));let y={version:1,closed:!0,start:g,segments:x};return pe(y)?y:null}function un(e){let t=[],n=e.start;for(let r of e.segments)t.push(n),n=r.end;let o=[];for(let r=e.segments.length-1;r>=0;r-=1){let i=e.segments[r],s=t[r];i.kind==="line"?o.push({kind:"line",end:{...s}}):i.kind==="arc"?o.push({kind:"arc",center:{...i.center},radius:i.radius,clockwise:!i.clockwise,end:{...s}}):o.push({kind:"bezier",control1:{...i.control2},control2:{...i.control1},end:{...s}})}return{version:1,closed:!0,start:{...e.start},segments:o}}function dn(e,t,n){let o=[];for(let r=0;r<e.length-1;r+=1){let i=e[r],s=e[r+1],c=Math.hypot(s.x-i.x,s.y-i.y);if(c<=0)continue;let u=Math.max(1,Math.round(c/n)),b=c/u,a=Math.atan2(s.y-i.y,s.x-i.x),f=r===0,p=(r>0?t[r-1]:void 0)==="break"?2:1,x=f?{...i}:{x:i.x+Math.cos(a)*b*p,y:i.y+Math.sin(a)*b*p},g=f?u+1:Math.max(1,u-(p-1));o.push({origin:x,rotation:a*180/Math.PI,seatCount:g,seatSpacing:b})}return o}function hn(e){let t=e.rotation*Math.PI/180,n={x:Math.cos(t),y:Math.sin(t)};return Array.from({length:e.seatCount},(o,r)=>({x:e.origin.x+n.x*r*e.seatSpacing,y:e.origin.y+n.y*r*e.seatSpacing}))}function mn(e){return e.reduce((t,n)=>t+n.seatCount,0)}function be(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((l,p)=>l.segmentedRow.componentIndex-p.segmentedRow.componentIndex),s=i[0]?.segmentedRow?.componentCount??0,c=i[0]?.segmentedRow;if(!c||!(s>=2&&i.length===s&&c?.boundaryBefore==="start"&&i.every((l,p)=>l.segmentedRow?.kind==="segmented-row-v1"&&l.segmentedRow.groupId===o&&l.segmentedRow.componentCount===s&&l.segmentedRow.componentIndex===p&&l.segmentedRow.repeatLabelOnComponents===c.repeatLabelOnComponents&&(p===0?l.segmentedRow.boundaryBefore==="start":l.segmentedRow.boundaryBefore!=="start")&&l.segmentedRow.displayLabel===c.displayLabel)))continue;let b=i.reduce((l,p)=>l+p.seatCount,0),a=0,f=0;for(let l of i)l.segmentedRow.boundaryBefore==="break"&&(a+=1),t.set(l.id,{groupId:o,adjacencyOffset:a,displayOffset:f,displayLabel:c.displayLabel,totalSeats:b,canonical:i[0],viewFromSeatUrl:c.viewFromSeatUrl,viewFromSeatMeta:c.viewFromSeatMeta,confidenceEvidence:c.confidenceEvidence}),a+=l.seatCount,f+=l.seatCount}return t}var xe="ABCDEFGHIJKLMNOPQRSTUVWXYZ",ot="ABCDEFGHJKLMNPQRSTUVWXYZ",rt="abcdefghijklmnopqrstuvwxyz";function ge(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 it(e,t){let n=t.startAt-1,o=e+n;if(t.scheme==="numbers")return String(o+1);let r=t.skipAmbiguous?ot:xe;return ge(o,r)}function W(e,t=!1){let n=t?rt:xe;return ge(Math.max(0,Math.floor(e)-1),n)}var st=[[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 Se(e){if(!Number.isFinite(e)||e<=0)return String(e);let t=Math.floor(e),n="";for(let[o,r]of st)for(;t>=o;)n+=r,t-=o;return n}function yn(e,t){let n=e.length;return e.map((o,r)=>{let i=t.reverse?n-1-r:r;return{...o,label:it(i,t)}})}function ct(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 V(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??"",c=e.seatNumbering?.endAt,u=e.seatCount;if(i==="updown"||i==="updown-descending"){let p=Math.ceil(u/2),x=i==="updown"?t<p?n+2*t:n-1+2*(u-t):t<p?n+2*(p-1-t):n+1+2*(t-p);return`${s}${x}`}let b=i==="odd"||i==="even"?2:r,a=c!=null&&Number.isFinite(c)?c-(u-1)*b:n,f=o==="center"?ct(u)[t]:o==="rtl"?u-1-t:t,l;switch(i){case"odd":{let p=a%2===1?a:a+1;l=String(p+f*2);break}case"even":{let p=a%2===0?a:a+1;l=String(p+f*2);break}case"roman":l=Se(a+f*r);break;case"letters-upper":l=W(a+f*r,!1);break;case"letters-lower":l=W(a+f*r,!0);break;default:l=String(a+f*r);break}return`${s}${l}`}function at(e){return{...e.canonical,seatCount:e.totalSeats,label:e.displayLabel,displayLabel:e.displayLabel}}function we(e,t,n){return n?.label??`${e.label}-${V(e,t)}`}function Y(e,t,n,o){if(o?.displayLabel)return o.displayLabel;if(!n)return`${e.displayLabel??e.label}-${V(e,t)}`;let r=at(n),i=n.displayOffset+t;return`${n.displayLabel}-${V(r,i)}`}var U=.02291666666666667,Sn=1/U,lt=58,ut=lt*U,Pe=0,ve=3,Me=0,q=120,ft=0,dt=45,ht=7,B=1.2;function J(e,t,n,o){return Number.isFinite(e)?Math.max(t,Math.min(n,e)):o}function wn(e){return Number.isFinite(e)?Math.max(Pe,Math.min(ve,Math.round(e))):Pe}function mt(e){return!Number.isFinite(e)||!Number.isInteger(e)||e<0?0:e<=ht?e:ve}function Ie(e,t={}){let n=J(t.floorBaseHeightM,Me,q,0),o=Math.min(q,n+mt(e.elevation)*ut),r=e.height===void 0?o:J(e.height,Me,q,o),i=J(e.rake,ft,dt,0);return{height:r,rake:i}}function Ee(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 Oe(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],c=s.x-i.x,u=s.y-i.y,b=c*c+u*u,a=b>1e-12?((t-i.x)*c+(n-i.y)*u)/b:0;a<0?a=0:a>1&&(a=1);let f=Math.hypot(t-(i.x+a*c),n-(i.y+a*u));f<o&&(o=f)}return o}function pt(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 Ce(e,t){return Math.hypot(e.cx-t.cx,e.cy-t.cy)-e.r-t.r}function Q(e,t){let n=1/0;for(let o of Ee(e)){let r=Oe(t,o.x,o.y);r<n&&(n=r)}for(let o of Ee(t)){let r=Oe(e,o.x,o.y);r<n&&(n=r)}return n}function yt(e,t){if(e.length<3)return{pts:e,seatIndices:t};let n=0,o=0;for(let a of e)n+=a.x,o+=a.y;n/=e.length,o/=e.length;let r=-1,i=e[0];for(let a of e){let f=Math.hypot(a.x-n,a.y-o);f>r&&(r=f,i=a)}let s=i.x-n,c=i.y-o,u=Math.hypot(s,c);u>1e-9?(s/=u,c/=u):(s=1,c=0);let b=e.map((a,f)=>({p:a,i:f,t:(a.x-n)*s+(a.y-o)*c})).sort((a,f)=>a.t-f.t);return{pts:b.map(a=>a.p),seatIndices:b.map(a=>t[a.i])}}function bt(e){let t=e.length;if(t<3)return null;let n=0,o=0;for(let S of e)n+=S.x,o+=S.y;n/=t,o/=t;let r=0,i=0,s=0,c=0,u=0,b=0,a=0;for(let S of e){let y=S.x-n,d=S.y-o;r+=y*y,s+=d*d,i+=y*d,c+=y*y*y,u+=d*d*d,b+=y*d*d,a+=d*y*y}let f=r*s-i*i;if(Math.abs(f)<1e-9)return null;let l=(c+b)/2,p=(u+a)/2,x=(l*s-p*i)/f,g=(p*r-l*i)/f,m=x+n,h=g+o;return!Number.isFinite(m)||!Number.isFinite(h)?null:{cx:m,cy:h}}var xt=.15;function gt(e){if(e.length<2)return null;let t=e.map(S=>{let y=0,d=0;for(let P of S.pts)y+=P.x,d+=P.y;return{x:y/S.pts.length,y:d/S.pts.length}}),n=0,o=0;for(let S of t)n+=S.x,o+=S.y;n/=t.length,o/=t.length;let r=0,i=0,s=0;for(let S of t){let y=S.x-n,d=S.y-o;r+=y*y,i+=y*d,s+=d*d}let c=r+s,u=r*s-i*i,b=c/2+Math.sqrt(Math.max(0,c*c/4-u)),a,f;Math.abs(i)>1e-12?(a=b-s,f=i):r>=s?(a=1,f=0):(a=0,f=1);let l=Math.hypot(a,f);if(!(l>1e-12))return null;a/=l,f/=l;let p=1/0,x=-1/0,g=[];for(let S of e){let y=1/0,d=-1/0;for(let P of S.pts){let w=P.x*a+P.y*f;w<y&&(y=w),w>d&&(d=w),w<p&&(p=w),w>x&&(x=w)}g.push(d-y)}let m=x-p;return m>1e-9?(g.sort((S,y)=>S-y),g[Math.min(g.length-1,Math.floor(g.length*.9))]/m<=St?{x:a,y:f}:null):null}var St=.35;function Re(e,t,n,o){let r=new Map;for(let m of n){let h=t[m],S=h.rowId||`__seat-${m}`,y=r.get(S);y||(y={pts:[],idx:[]},r.set(S,y)),y.pts.push({x:h.x,y:h.y}),y.idx.push(m)}if(!r.size)return{sectionId:e,rows:[],blockCount:0};let i=[];for(let[m,h]of r){let S=yt(h.pts,h.idx),y=0;for(let d of S.pts)y+=Math.hypot(d.x-o.x,d.y-o.y);i.push({id:m,pts:S.pts,seatIndices:S.seatIndices,blockId:-1,ordinal:0,blockDepth:0,focalDistance:y/S.pts.length})}let s=i.map(m=>pt(m.pts)),c=[];for(let m=0;m<i.length;m++){let h=1/0;for(let S=0;S<i.length;S++){if(m===S||Ce(s[m],s[S])>=h)continue;let y=Q(i[m].pts,i[S].pts);y<h&&(h=y)}Number.isFinite(h)&&c.push(h)}c.sort((m,h)=>m-h);let u=c.length?c[Math.floor(c.length/2)]:1,b=Math.max(u*1.8,1e-6),a=i.map(()=>[]);for(let m=0;m<i.length;m++)for(let h=m+1;h<i.length;h++)Ce(s[m],s[h])>b||Q(i[m].pts,i[h].pts)<=b&&(a[m].push(h),a[h].push(m));let f=0;for(let m=0;m<i.length;m++){if(i[m].blockId!==-1)continue;let h=f++,S=[m];for(i[m].blockId=h;S.length;){let y=S.pop();for(let d of a[y])i[d].blockId===-1&&(i[d].blockId=h,S.push(d))}}let l=new Map;for(let m of i){let h=l.get(m.blockId)??[];h.push(m),l.set(m.blockId,h)}let p=[];for(let m of i){if(m.pts.length<4)continue;let h=bt(m.pts);h&&(!Number.isFinite(h.cx)||!Number.isFinite(h.cy)||p.push({x:h.cx,y:h.cy}))}let x=p.length>=2?(()=>{let m=p.map(y=>y.x).sort((y,d)=>y-d),h=p.map(y=>y.y).sort((y,d)=>y-d),S=Math.floor(p.length/2);return{cx:m[S],cy:h[S]}})():null;if(x){let m=w=>Math.hypot(w.x-x.cx,w.y-x.cy),h=1/0,S=-1/0,y=[];for(let w of i){let M=1/0,E=-1/0;for(let O of w.pts){let A=m(O);A<M&&(M=A),A>E&&(E=A)}y.push(E-M),M<h&&(h=M),E>S&&(S=E)}let d=S-h;y.sort((w,M)=>w-M);let P=y[Math.min(y.length-1,Math.floor(y.length*.9))];if(d>1e-9&&P/d<=xt){let w=i.map(I=>{let _=0;for(let z of I.pts)_+=m(z);return{row:I,radius:_/I.pts.length}}),M=1/0;for(let I of w)I.radius<M&&(M=I.radius);w.sort((I,_)=>I.radius-_.radius);let E=-1,O=-1/0,A=d/Math.max(1,w.length)*.5,k=[];for(let I of w)I.radius-O>A&&(E++,O=I.radius),I.row.ordinal=E,I.row.blockDepth=I.radius-M,k.push(I.row);return{sectionId:e,rows:k,blockCount:f}}}let g=[];for(let[,m]of l){let h=gt(m);if(h){let S=d=>{let P=0;for(let w of d.pts)P+=w.x*h.x+w.y*h.y;return P/d.pts.length};m.sort((d,P)=>S(d)-S(P));let y=0;for(let d=0;d<m.length;d++)d>0&&(y+=Q(m[d-1].pts,m[d].pts)),m[d].ordinal=d,m[d].blockDepth=y,g.push(m[d])}else{let S=1/0;for(let y of m)y.focalDistance<S&&(S=y.focalDistance);m.sort((y,d)=>y.focalDistance-d.focalDistance);for(let y=0;y<m.length;y++)m[y].ordinal=y,m[y].blockDepth=Math.max(0,m[y].focalDistance-S),g.push(m[y])}}return{sectionId:e,rows:g,blockCount:f}}function Le(e){return e?e.accessibility&&e.accessibility.length?e.wheelchairSpaceType&&!e.accessibility.includes("wheelchair")?["wheelchair",...e.accessibility]:e.accessibility:e.wheelchairSpaceType?["wheelchair"]:e.accessible?["wheelchair"]:[]:[]}var X=Math.PI/180,wt=9,F=16;function ee(e,t,n,o){let r=n*X,i=Math.cos(r),s=Math.sin(r);return{x:o.x+e*i-t*s,y:o.y+e*s+t*i}}function je(e){let{seatCount:t,seatSpacing:n,curve:o,rotation:r,origin:i}=e,s=[];if(e.path)return se(e.path,t);if(t<=1)return t===1&&s.push({x:i.x,y:i.y}),s;if(o===0){for(let b=0;b<t;b++)s.push(ee(b*n,0,r,i));return s}let c=o/(t-1)*X,u=n/(2*Math.sin(Math.abs(c)/2));for(let b=0;b<t;b++){let a=b*c,f=u*Math.sin(a),l=-u+u*Math.cos(a);s.push(ee(f,l,r,i))}return s}function Pt(e){let t=new Map;if(e.overrides)for(let n of e.overrides)t.set(n.index,n);return t}function _n(e){let t=new Set((e.overrides??[]).filter(n=>n.skip&&Number.isInteger(n.index)&&n.index>=0&&n.index<e.seatCount).map(n=>n.index));return Math.max(0,e.seatCount-t.size)}function Mt(e,t){let n=Pt(e);return je(e).map((o,r)=>{let i=n.get(r),s=Le(i),c=we(e,r,i),u={...e.commercial,...i?.commercial};return{index:r,x:o.x+(i?.dx??0),y:o.y+(i?.dy??0),label:c,displayLabel:Y(e,r,t,i),categoryKey:i?.categoryKey??e.categoryKey,skipped:!!i?.skip,accessible:s.length>0,accessibility:s,wheelchairSpaceType:i?.wheelchairSpaceType,commercial:Object.values(u).some(b=>b!==void 0&&b!==!1&&b!=="")?u:void 0,viewUrl:i?.viewFromSeatUrl??e.viewFromSeatUrl,viewMeta:i?.viewFromSeatUrl?i.viewFromSeatMeta:e.viewFromSeatMeta,labelStyle:i?.labelStyle}})}function Ne(e){let t=[];for(let n of Mt(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,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return t}function vt(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 Fe(e){let t=[],n=Math.max(0,Math.round(e.seatCount));if(n===0)return t;let o=new Map((e.overrides??[]).map(a=>[a.index,a])),r=(a,f,l,p)=>{let x=o.get(a),g=Le(x),m=x?.label??`${e.label}-${a+1}`,h=e.displayLabel??e.label;return{index:a,label:m,displayLabel:x?.displayLabel??`${h}-${a+1}`,x:f+(x?.dx??0),y:l+(x?.dy??0),categoryKey:x?.categoryKey??e.categoryKey,skipped:!!x?.skip,accessible:g.length>0,accessibility:g,wheelchairSpaceType:x?.wheelchairSpaceType,commercial:x?.commercial,viewUrl:x?.viewFromSeatUrl,viewMeta:x?.viewFromSeatUrl?x.viewFromSeatMeta:void 0,labelStyle:x?.labelStyle,...p?{side:p}:{}}};if(e.shape==="round"){let a=(e.radius??40)+F,f=e.rotation*X,l=Math.max(0,Math.min(360,e.seatArc??360));if(l>=360||n===1){for(let m=0;m<n;m++){let h=f+m/n*2*Math.PI;t.push(r(m,e.center.x+a*Math.cos(h),e.center.y+a*Math.sin(h)))}return t}let p=l*X,x=(2*Math.PI-p)/2,g=f+x;for(let m=0;m<n;m++){let h=g+m/(n-1)*p;t.push(r(m,e.center.x+a*Math.cos(h),e.center.y+a*Math.sin(h)))}return t}let i=e.width??80,s=e.height??50,c=vt(e),u=["top","bottom","left","right"],b=0;for(let a of u){let f=c[a];for(let l=0;l<f;l++){let p,x;a==="top"?(p=-i/2+(l+.5)*i/f,x=-s/2-F):a==="bottom"?(p=-i/2+(l+.5)*i/f,x=s/2+F):a==="left"?(p=-i/2-F,x=-s/2+(l+.5)*s/f):(p=i/2+F,x=-s/2+(l+.5)*s/f);let g=ee(p,x,e.rotation,e.center);t.push(r(b++,g.x,g.y,a))}}return t}function kn(e){return e.bookAsWhole||e.variableOccupancy?Math.max(0,Math.round(e.seatCount)):Fe(e).filter(t=>!t.skipped).length}function It(e){return Fe(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.viewUrl?{viewUrl:t.viewUrl}:{},...t.viewUrl&&t.viewMeta?{viewMeta:t.viewMeta}:{},...t.labelStyle?{labelStyle:t.labelStyle}:{}}))}function Et(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 Te(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,c=t[r].x,u=t[r].y;s>e.y!=u>e.y&&e.x<(c-i)*(e.y-s)/(u-s)+i&&(n=!n)}return n}function Ot(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),c=(r.x-n.x)**2+(r.y-n.y)**2;return s>=-1e-7&&s<=c+1e-7})}function te(e,t,n){return Te(e,t)&&!(n??[]).some(o=>Te(e,o)||Ot(e,o))}function Ln(e,t){return fe(e,t).point}function Z(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 Ct(e){switch(e.type){case"row":{let t=Ne(e);if(!t.length)return{x:e.origin.x,y:e.origin.y};let n=0,o=0;for(let r of t)n+=r.x,o+=r.y;return{x:n/t.length,y:o/t.length}}case"table":case"booth":return{x:e.center.x,y:e.center.y};case"gaArea":return Z(e.points);case"section":return Z(e.outline);case"text":return{x:e.position.x,y:e.position.y};case"shape":return e.points&&e.points.length?Z(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 Ae(e,t){return e.length===t.length&&e.every((n,o)=>n.x===t[o].x&&n.y===t[o].y)}function Rt(e,t){if(e.type!=="gaArea"||!Ae(e.points,t.outline))return!1;let n=e.holes??[],o=t.holes??[];return n.length===o.length&&n.every((r,i)=>Ae(r,o[i]))}function Tt(e,t){let n=e.filter(s=>s.type==="section"),o="referenceInventorySource"in t?t.referenceInventorySource?.logicalSectionId:void 0,r=Ct(t);return(o?n.find(s=>(s.logicalSectionId??s.id)===o&&(Rt(t,s)||te(r,s.outline,s.holes))):void 0)??n.find(s=>te(r,s.outline,s.holes))}function At(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 jn(e,t){let n=At(e);return(t?n.find(o=>o.id===t):n[0])?.objects??[]}function _t(e){return e.floors&&e.floors.length?e.floors.flatMap(t=>t.objects):e.objects}function De(e,t,n){let o=i=>({x:i.x+t,y:i.y+n}),r=i=>i.map(o);switch(e.type){case"row":return{...e,origin:o(e.origin)};case"table":case"booth":return{...e,center:o(e.center)};case"gaArea":return{...e,points:r(e.points),...e.holes?{holes:e.holes.map(r)}:{}};case"section":return{...e,outline:r(e.outline),...e.outlinePath?{outlinePath:ye(e.outlinePath,t,n)}:{},...e.holes?{holes:e.holes.map(r)}:{}};case"text":return{...e,position:o(e.position)};case"shape":return{...e,...e.points?{points:r(e.points)}:{},...e.x!=null?{x:e.x+t}:{},...e.y!=null?{y:e.y+n}:{}};case"decorImage":return{...e,x:e.x+t,y:e.y+n}}}function Nn(e,t=900){if(!e.floors||e.floors.length<2)return e;let n=[];return e.floors.forEach((o,r)=>{let i=-r*t;for(let s of o.objects)n.push(i===0?s:De(s,0,i))}),{...e,objects:n,floors:void 0}}function Fn(e){let t=e.floors;if(!t||t.length<2)return e;let n=kt(e),o=[];return t.forEach((r,i)=>{let{x:s,y:c}=n[i];for(let u of r.objects)o.push(De(u,s,c))}),{...e,objects:o,floors:void 0,referenceImage:void 0,backgroundImage:void 0}}function kt(e){let t=e.floors;if(!t?.length)return[{x:0,y:0}];if(t.length<2)return t.map(()=>({x:0,y:0}));let n=t.map(l=>Lt({...e,objects:l.objects,floors:void 0,focalPoint:l.focalPoint,referenceImage:void 0,backgroundImage:void 0})),o=Math.max(1,...n.map(l=>Math.max(l.width,l.height))),r=Math.max(64,Math.min(240,o*.08)),i=16/10,s=null;for(let l=1;l<=t.length;l+=1){let p=Math.ceil(t.length/l),x=new Array(l).fill(0),g=new Array(p).fill(0);n.forEach((d,P)=>{let w=P%l,M=Math.floor(P/l);x[w]=Math.max(x[w],d.width),g[M]=Math.max(g[M],d.height)});let m=x.reduce((d,P)=>d+P,0)+r*(l-1),h=g.reduce((d,P)=>d+P,0)+r*(p-1),S=l*p-t.length,y=Math.abs(Math.log(m/Math.max(1,h)/i))+S*.04;(!s||y<s.score)&&(s={columns:l,columnWidths:x,rowHeights:g,score:y})}let{columns:c,columnWidths:u,rowHeights:b}=s,a=[],f=[];return u.reduce((l,p,x)=>(a[x]=l,l+p+r),0),b.reduce((l,p,x)=>(f[x]=l,l+p+r),0),t.map((l,p)=>{let x=n[p],g=p%c,m=Math.floor(p/c),h=a[g]+(u[g]-x.width)/2,S=f[m]+(b[m]-x.height)/2;return{x:h-x.x,y:S-x.y}})}function _e(e,t,n,o,r,i){let s=[],c=be(e),u=f=>!f?.eventConfigurationId||f.eventConfigurationId===o,b=f=>!!f&&(!f.eventConfigurationId||f.eventConfigurationId===o),a=(f,l)=>b(f)?{...f,coverage:l}:void 0;for(let f of e){let l=[];if(f.type==="row"?l=Ne(f):f.type==="table"?l=It(f):f.type==="booth"&&(l=Et(f)),!l.length)continue;for(let h of l)h.viewUrl&&!u(h.viewMeta)&&(h.viewUrl=void 0,h.viewMeta=void 0);if(f.type==="row"){let h=c.get(f.id);if(h){let S=new Map((f.overrides??[]).map(y=>[y.index,y]));for(let y of l){let d=Number(y.id.slice(y.id.lastIndexOf(":")+1));if(!Number.isInteger(d))continue;y.logicalRowId=h.groupId,y.logicalSeatIndex=h.adjacencyOffset+d,S.get(d)?.displayLabel||(y.displayLabel=Y(f,d,h)),!y.viewUrl&&h.viewFromSeatUrl&&u(h.viewFromSeatMeta)&&(y.viewUrl=h.viewFromSeatUrl,y.viewMeta=h.viewFromSeatMeta);let P=S.get(d)?.confidenceEvidence;y.confidenceEvidence=a(P,"exact-seat")??a(f.confidenceEvidence,"row-representative")??a(h.confidenceEvidence,"row-representative")}}}let p=Tt(e,f),x=p?.viewFromSeatUrl,m=(p?.zone?t?.find(h=>h.id===p.zone):void 0)?.focalPoint??n;for(let h of l){if(!h.confidenceEvidence){let S=Number(h.id.slice(h.id.lastIndexOf(":")+1)),y=(f.type==="row"||f.type==="table")&&Number.isInteger(S)?f.overrides?.find(d=>d.index===S)?.confidenceEvidence:void 0;h.confidenceEvidence=a(y,"exact-seat")??(f.type==="row"?a(f.confidenceEvidence,"row-representative"):void 0)}h.confidenceEvidence??=a(p?.confidenceEvidence,"section-representative")??(i?a(i.evidence,i.coverage):void 0),!h.viewUrl&&x&&u(p?.viewFromSeatMeta)&&(h.viewUrl=x,h.viewMeta=p?.viewFromSeatMeta),!h.viewUrl&&r&&u(r.meta)&&(h.viewUrl=r.url,h.viewMeta=r.meta),p&&(h.sectionId=p.logicalSectionId??p.id),p?.zone&&(h.zoneId=p.zone),m&&(h.focalPoint={...m})}s.push(...l)}return s}function Dn(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,c=r.confidenceEvidence?{evidence:r.confidenceEvidence,coverage:"floor-representative"}:e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0,u=_e(r.objects,e.zones,i,e.eventConfigurationId,s,c);t.resolveEyeHeights!==!1&&ke(r.objects,r.focalPoint??e.focalPoint,r.baseHeightM??0,u),o.push(...u)}return o}let n=_e(e.objects,e.zones,e.focalPoint,e.eventConfigurationId,e.viewFromSeatUrl?{url:e.viewFromSeatUrl,meta:e.viewFromSeatMeta}:void 0,e.confidenceEvidence?{evidence:e.confidenceEvidence,coverage:"venue-representative"}:void 0);return t.resolveEyeHeights!==!1&&ke(e.objects,e.focalPoint,t.floorBaseHeightM??0,n),n}function ke(e,t,n,o){let r=e.filter(a=>a.type==="section"),i=n>0||r.some(a=>a.height!==void 0||a.rake!==void 0||(a.elevation??0)>0);if(!r.length||!i||!t){for(let a of o)a.eyeHeightM=n+B;return}let s=new Array(o.length),c=new Map,u=new Map;for(let a=0;a<o.length;a++){let f=o[a],l=r.find(x=>te({x:f.x,y:f.y},x.outline,x.holes))??null;if(s[a]=l,!l)continue;c.has(l.id)||c.set(l.id,Ie(l,{floorBaseHeightM:n}));let p=u.get(l.id);p?p.push(a):u.set(l.id,[a])}let b=new Array(o.length).fill(void 0);for(let[a,f]of u){let l=c.get(a);if(!l)continue;let p=l.rake>0?Math.tan(l.rake*Math.PI/180):0,x=Re(a,o,f,t);for(let g of x.rows){let m=g.blockDepth*U*p,h=l.height+m;for(let S of g.seatIndices)b[S]=h}}for(let a=0;a<o.length;a++){let f=o[a],l=s[a];if(!l){f.eyeHeightM=n+B;continue}let p=c.get(l.id);f.eyeHeightM=(b[a]??p.height)+B}}var G=40;function Lt(e){let t=1/0,n=1/0,o=-1/0,r=-1/0,i=(s,c)=>{s<t&&(t=s),c<n&&(n=c),s>o&&(o=s),c>r&&(r=c)};for(let s of _t(e))if(s.type==="row"){let c=new Map((s.overrides??[]).map(u=>[u.index,u]));je(s).forEach((u,b)=>{let a=c.get(b);a?.skip||i(u.x+(a?.dx??0),u.y+(a?.dy??0))})}else if(s.type==="gaArea")for(let c of s.points)i(c.x,c.y);else if(s.type==="section")for(let c of s.outline)i(c.x,c.y);else if(s.type==="decorImage")i(s.x,s.y),i(s.x+s.width,s.y+s.height);else if(s.type==="shape")if(s.points&&s.points.length)for(let c of s.points)i(c.x,c.y);else s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null&&(i(s.x,s.y),i(s.x+s.width,s.y+s.height));else if(s.type==="table"){let c=F+wt,u=s.shape==="round"?(s.radius??40)+c:Math.max((s.width??80)/2,(s.height??50)/2)+c;i(s.center.x-u,s.center.y-u),i(s.center.x+u,s.center.y+u)}else if(s.type==="booth"){let c=Math.max(s.width,s.height)/2;i(s.center.x-c,s.center.y-c),i(s.center.x+c,s.center.y+c)}else if(s.type==="text"){let c=oe(s);i(s.position.x,s.position.y),i(s.position.x+c.width,s.position.y+c.height)}for(let s of[e.referenceImage,e.backgroundImage]){if(!s)continue;let{center:c,width:u}=s,b=u*3/4;i(c.x-u/2,c.y-b/2),i(c.x+u/2,c.y+b/2)}if(!isFinite(t)){let s=e.focalPoint??{x:0,y:0};return{x:s.x-200,y:s.y-200,width:400,height:400}}return{x:t-G,y:n-G,width:o-t+G*2,height:r-n+G*2}}export{jt as a,Nt as b,Ft as c,Dt as d,Ht as e,Ut as f,Bt as g,Gt as h,Xt as i,oe as j,Kt as k,Ge as l,$t as m,K as n,Yt as o,se as p,qt as q,Jt as r,ze as s,ue as t,Zt as u,fe as v,$e as w,tn as x,sn as y,pe as z,cn as A,ye as B,qe as C,an as D,ln as E,Ze as F,nt as G,un as H,dn as I,hn as J,mn as K,be as L,ge as M,it as N,W as O,Se as P,yn as Q,V as R,at as S,we as T,Y as U,U as V,Sn as W,ut as X,Pe as Y,ve as Z,Me as _,q as $,ft as aa,dt as ba,ht as ca,B as da,wn as ea,Ie as fa,Oe as ga,bt as ha,Re as ia,je as ja,_n as ka,Mt as la,Ne as ma,vt as na,Fe as oa,kn as pa,It as qa,Et as ra,Te as sa,te as ta,Ln as ua,Ct as va,Tt as wa,At as xa,jn as ya,_t as za,De as Aa,Nn as Ba,Fn as Ca,kt as Da,Dn as Ea,Lt as Fa};
@@ -0,0 +1 @@
1
+ import{c,j as A,m as T}from"./chunk-CXF32VPG.js";var d=7,B=10,N=15,R=11,k=.85,x=12,M=4.5,E=3,l="#000000",u="#ffffff",g=24,Z=18.67;function y(t,L=400){return t>=g||L>=700&&t>=Z?E:M}function G(t,L){return t*L>=x}var H=24,m={wheelchair:"M7.8 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM8 7L10.5 7L10.5 15L8 15ZM8 12.5L18 12.5L18 15L8 15ZM16 15L18 15L18 18L16 18ZM5.5 16a5.5 5.5 0 1 0 11 0a5.5 5.5 0 1 0 -11 0zM8 16a3 3 0 1 1 6 0a3 3 0 1 1 -6 0z",companion:"M5.5 6.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM4.5 18.5L6 11.5L11 11.5L12.5 18.5ZM12.5 7.5a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM11.5 19L13 12.5L18 12.5L19.5 19Z","semi-ambulatory":"M8.3 3.8a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM9 6.2L12 6.6L11 13.5L8.6 13L9 6.2ZM8.6 13L11 13L9.5 21L7 21ZM10.4 13L12.6 13L13.6 21L11.2 21ZM11.2 7.2L14 8L14.6 9.6L11.9 8.9ZM14.4 6.8L15.9 6.8L16.4 21L14.8 21Z","designated-aisle":"M3 5L6 5L6 14L3 14ZM3 12L13 12L13 15L3 15ZM5 15L7 15L7 20L5 20ZM11 15L13 15L13 20L11 20ZM13 7L20 7L17 4L19 4L23 8.5L19 13L17 13L20 10L13 10Z","step-free":"M4 4.5a2.2 2.2 0 1 0 4.4 0a2.2 2.2 0 1 0 -4.4 0zM4.4 7L7.5 7L7.5 13L11 15L9.5 17L5 14L4.4 7ZM2 19L8 19L17 10L22 10L22 13L18 13L10 21L2 21Z",hearing:"M15.5 3.5C9 2.2 5.5 6 5.5 11.5C5.5 16 8 19.5 10.5 21C13.2 22.6 16.4 20.8 15.4 18C14.8 16.4 12.9 16.1 13 14C13.1 11.9 15.8 11.4 15.8 8.5C15.8 5.4 13 4 15.5 3.5Z",cart:"M5.5 6L18.5 6a2.5 2.5 0 0 1 2.5 2.5L21 15.5a2.5 2.5 0 0 1 -2.5 2.5L11 18L7 20.5L7.5 18L5.5 18a2.5 2.5 0 0 1 -2.5 -2.5L3 8.5a2.5 2.5 0 0 1 2.5 -2.5zM6.5 11L17.5 11L17.5 12.6L6.5 12.6zM6.5 14L17.5 14L17.5 15.6L6.5 15.6z","sign-language":"M7 11L17 11L17 18a2 2 0 0 1 -2 2L9 20a2 2 0 0 1 -2 -2zM7.6 5L9.4 5L9.4 12L7.6 12zM9.9 3.5L11.7 3.5L11.7 12L9.9 12zM12.3 3.5L14.1 3.5L14.1 12L12.3 12zM14.6 5L16.4 5L16.4 12L14.6 12zM7.2 12.5L5 10.2L6.4 8.9L8.6 11.2Z","low-vision":"M2.5 12C6 6 18 6 21.5 12C18 18 6 18 2.5 12ZM9 12a3 3 0 1 0 6 0a3 3 0 1 0 -6 0zM17.5 3L19 3L19 6L17.5 6ZM19 4L22 4L22 5.5L19 5.5Z","sensory-friendly":"M4 11C4 5 7 2.5 12 2.5S20 5 20 11L17 11C17 7 15.5 5.5 12 5.5S7 7 7 11ZM3 10L8 10L8 19L5 19a2 2 0 0 1 -2 -2ZM16 10L21 10L21 17a2 2 0 0 1 -2 2L16 19ZM9 12L15 12L15 14L9 14ZM10 16L14 16L14 18L10 18Z","plus-size":"M9.4 4.3a2.6 2.6 0 1 0 5.2 0a2.6 2.6 0 1 0 -5.2 0zM5 20L4 13C4 10.5 7 9.5 12 9.5C17 9.5 20 10.5 20 13L19 20Z","lift-armrest":"M5 6L8 6L8 19L5 19zM5 16L18 16L18 19L5 19zM8 12L17 12L17 14.5L8 14.5zM14 7L16 7L16 12L14 12zM12 7L18 7L15 3Z"},P=m.wheelchair;function v(t){if(!t?.length)return null;let L=t.includes("wheelchair")?"wheelchair":t[0];return m[L]??null}function w(t){return/-(\d{1,5})$/.exec(t)?.[1]??t}var a=T;function X(t,L,r){let n=c(t),o=c(L);if(!n||!o)return L;let e=Math.max(0,Math.min(1,r));return`#${n.map((s,_)=>Math.round(s*e+o[_]*(1-e))).map(s=>s.toString(16).padStart(2,"0")).join("")}`}var F=3;function I(t,L,r=M){let n=a(L,t);if(n!=null&&n>=r)return L;let o=a(l,t)??0,e=a(u,t)??0;return o===0&&e===0?L:o>=e?l:u}var S=3;function K(t){let L=a("#ffffff",t);if(L!=null&&L>=S)return"#ffffff";let r=a(l,t)??0,n=a(u,t)??0;return r===0&&n===0?"#ffffff":r>=n?l:u}var C=/^#[0-9a-f]{6}$/i;function b(t){let L=c(t);return L!=null&&A(L)>.5}var O="#e5e7eb",h="#273142";function Y(t){return b(t)?O:h}function D(t,L,r=M){let n=C.test(t.trim()),o=t.trim().toLowerCase(),e=0,i=0,s=null;for(let f of L){if(!n||!C.test(f.trim()))continue;e+=1;let p=I(f,t,r);p.toLowerCase()!==o&&(i+=1,s=p)}return{total:e,overridden:i,status:e===0?"none":i===0?"applies":i===e?"overridden":"mixed",overrideInk:s}}export{d as a,B as b,N as c,R as d,k as e,x as f,M as g,E as h,l as i,u as j,y as k,G as l,H as m,m as n,P as o,v as p,w as q,a as r,X as s,F as t,I as u,K as v,b as w,O as x,h as y,Y as z,D as A};
@@ -0,0 +1 @@
1
+ "use strict";var qn=Object.create;var xe=Object.defineProperty;var Xn=Object.getOwnPropertyDescriptor;var Yn=Object.getOwnPropertyNames;var Wn=Object.getPrototypeOf,Zn=Object.prototype.hasOwnProperty;var Qn=(t,e)=>{for(var n in e)xe(t,n,{get:e[n],enumerable:!0})},yt=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Yn(e))!Zn.call(t,i)&&i!==n&&xe(t,i,{get:()=>e[i],enumerable:!(o=Xn(e,i))||o.enumerable});return t};var eo=(t,e,n)=>(n=t!=null?qn(Wn(t)):{},yt(e||!t||!t.__esModule?xe(n,"default",{value:t,enumerable:!0}):n,t)),to=t=>yt(xe({},"__esModule",{value:!0}),t);var Ui={};Qn(Ui,{COLORBLIND_SAFE_PALETTE:()=>ft,ChartOperationError:()=>u,DEFAULT_FLOOR_HEIGHT_STEP_M:()=>it,DEFAULT_SECTION_CORNER_SMOOTHING:()=>Ot,MAX_FLOOR_BASE_HEIGHT_M:()=>Me,addArcFanRows:()=>Xr,addBookableGridArray:()=>gi,addBoothArray:()=>oi,addChartCategory:()=>xn,addChartFloor:()=>ko,addChartZone:()=>Eo,addGAArea:()=>ti,addRowBlock:()=>Zr,addTableArray:()=>ni,applyPolygonHole:()=>mr,applyReferenceScanRows:()=>ui,applySectionCornerSmoothing:()=>Or,applySectionOutlineShaping:()=>ln,applySectionRowFit:()=>hr,arcFanInputForGroup:()=>vn,assignSectionInventoryCategory:()=>xr,automaticPlacementCenter:()=>Hr,confirmReferenceCategoryOutputColor:()=>Fr,convertGeneratedSectionToPolygon:()=>Ir,countCoveredInventory:()=>Te,familyCategoryLabel:()=>gt,gaAreaFootprint:()=>On,groupRowsAsSegmented:()=>ri,insertSeatingBlock:()=>dr,joinGAAreas:()=>Di,mergeRows:()=>Mi,mirrorFirstFloor:()=>fe,parseSeatRefId:()=>pi,pickColorblindSafeCategoryColor:()=>wn,previewArcFanRows:()=>bt,previewBookableGridArray:()=>fi,previewGeneratedSectionPolygonConversion:()=>sn,previewJoinGAAreas:()=>Ni,previewPolygonHole:()=>Ee,previewRemovePolygonHole:()=>on,previewRowCubicPath:()=>en,previewSectionRowFit:()=>tn,reassignColorblindSafeCategoryColors:()=>kr,relabelChartRows:()=>lr,removeChartCategory:()=>Gr,removeChartFloor:()=>Lo,removeChartObjects:()=>sr,removeChartZone:()=>Do,removePolygonHole:()=>yr,renameChartFloor:()=>Fo,reorderChartCategories:()=>Mr,replaceArcFanRows:()=>Yr,replaceRowBlock:()=>si,resetSeatOverrides:()=>xi,resizeShapes:()=>zi,resolveCreationCategory:()=>$r,seatRefId:()=>ye,sectionInventorySelectionSummary:()=>an,setRowBlockSpacing:()=>Ri,splitRow:()=>ji,straightenAndSpaceRows:()=>ki,transformSectionBoundary:()=>vr,transformSectionBoundaryObject:()=>cn,ungroupSegmentedRow:()=>ii,updateBooths:()=>ir,updateCategoryDefinitions:()=>yn,updateChartFloorBaseHeight:()=>To,updateChartTheme:()=>Br,updateChartZones:()=>No,updateGAAreas:()=>ar,updateRowCubicPath:()=>fr,updateRows:()=>Si,updateSeatOverrides:()=>wi,updateSectionExactPath:()=>Cr,updateSectionMetadata:()=>Sr,updateSegmentedRow:()=>ai,updateShapes:()=>Gi,updateStageKinds:()=>Bi,updateTables:()=>rr,updateTextObjects:()=>cr,updateViewFromSeatFallback:()=>Ur});module.exports=to(Ui);var wt=t=>Math.max(1,t.fontSize*.6+(t.letterSpacing??0));function no(t,e){let n=t.text.split(/\r?\n/);if(!t.width)return Math.max(1,n.length);let o=Math.max(1,Math.floor(e/wt(t))),i=0;for(let a of n){if(!a.length){i+=1;continue}let r=0;for(let s of a.split(/\s+/)){let c=s.length;r&&r+1+c<=o?r+=1+c:(i+=Math.max(1,Math.ceil(c/o)),r=c%o)}}return Math.max(1,i)}function xt(t){let e=t.background?.padding??0,n=t.text.split(/\r?\n/),o=Math.max(1,...n.map(s=>s.length))*wt(t),i=t.width??o+e*2,a=Math.max(1,i-e*2),r=no(t,a);return{width:i,height:r*t.fontSize*(t.lineHeight??1.2)+e*2,lineCount:r,padding:e}}var Ji=Math.PI/180;function E(t,e){return Math.hypot(t.x-e.x,t.y-e.y)}function Je(t,e,n){return{x:t.x+(e.x-t.x)*n,y:t.y+(e.y-t.y)*n}}function St(t,e){let n=1-e,o=n*n*n,i=3*n*n*e,a=3*n*e*e,r=e*e*e;return{x:o*t.start.x+i*t.control1.x+a*t.control2.x+r*t.end.x,y:o*t.start.y+i*t.control1.y+a*t.control2.y+r*t.end.y}}function Se(t,e,n=192){if(!Number.isInteger(e)||e<1)throw new Error("Path point count must be a positive integer");if(e===1)return[St(t,.5)];let o=Array.from({length:n+1},(c,l)=>St(t,l/n)),i=new Float64Array(o.length);for(let c=1;c<o.length;c+=1){let l=o[c].x-o[c-1].x,d=o[c].y-o[c-1].y;i[c]=i[c-1]+Math.hypot(l,d)}let a=i[i.length-1];if(a<=1e-9)return Array.from({length:e},()=>({...t.start}));let r=[],s=1;for(let c=0;c<e;c+=1){let l=a*c/(e-1);for(;s<i.length-1&&i[s]<l;)s+=1;let d=i[s-1],g=i[s],b=g===d?0:(l-d)/(g-d);r.push({x:o[s-1].x+(o[s].x-o[s-1].x)*b,y:o[s-1].y+(o[s].y-o[s-1].y)*b})}return r}function le(t){if(t.length<3)return 0;let e=0;for(let n=0,o=t.length-1;n<t.length;o=n++)e+=(t[o].x+t[n].x)*(t[o].y-t[n].y);return Math.abs(e)/2}function oo(t,e,n){return Math.max(e,Math.min(n,t))}function ro(t){return oo(t,0,1)}function It(t){let e=ro(t);return e*e*(3-2*e)}var ne=Math.PI*2;function oe(t){return Number.isFinite(t.x)&&Number.isFinite(t.y)}function io(t,e,n){let o=e-t;if(n){for(;o<0;)o+=ne;for(;o>=ne;)o-=ne}else{for(;o>0;)o-=ne;for(;o<=-ne;)o+=ne}return o}function Ie(t){if(t.version!==1||t.closed!==!0||!oe(t.start)||!Array.isArray(t.segments)||t.segments.length<2||t.segments.length>512)return!1;let e=t.start;for(let n of t.segments){if(!n||!oe(n.end))return!1;if(n.kind==="line"){if(E(e,n.end)<=1e-9)return!1}else if(n.kind==="bezier"){if(!oe(n.control1)||!oe(n.control2)||E(e,n.end)<=1e-9)return!1}else if(n.kind==="arc"){if(!oe(n.center)||!Number.isFinite(n.radius)||n.radius<=1e-6||Math.abs(E(e,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||Math.abs(E(n.end,n.center)-n.radius)>Math.max(1e-4,n.radius*1e-4)||E(e,n.end)<=1e-9)return!1}else return!1;e=n.end}return E(e,t.start)<=1e-4}function ao(t,e,n){let o=1-n;return{x:o**3*t.x+3*o**2*n*e.control1.x+3*o*n**2*e.control2.x+n**3*e.end.x,y:o**3*t.y+3*o**2*n*e.control1.y+3*o*n**2*e.control2.y+n**3*e.end.y}}function qe(t,e=2){if(!Ie(t))throw new Error("Section outline path is invalid");let n=Math.max(.25,e),o=[{...t.start}],i=t.start;for(let a of t.segments){if(a.kind==="line")o.push({...a.end});else if(a.kind==="arc"){let r=Math.atan2(i.y-a.center.y,i.x-a.center.x),s=Math.atan2(a.end.y-a.center.y,a.end.x-a.center.x),c=io(r,s,a.clockwise),l=Math.max(2,Math.ceil(Math.abs(c)*a.radius/n));for(let d=1;d<=l;d+=1){let g=r+c*d/l;o.push({x:a.center.x+Math.cos(g)*a.radius,y:a.center.y+Math.sin(g)*a.radius})}}else{let r=E(i,a.control1)+E(a.control1,a.control2)+E(a.control2,a.end),s=Math.max(2,Math.ceil(r/n));for(let c=1;c<=s;c+=1)o.push(ao(i,a,c/s))}i=a.end}return E(o[o.length-1],o[0])<=1e-4&&o.pop(),o}function Pt(t,e,n){return Xe(t,i=>({x:i.x+e,y:i.y+n}))}function Xe(t,e,n=1,o=!1){return{...t,start:e(t.start),segments:t.segments.map(i=>i.kind==="line"?{...i,end:e(i.end)}:i.kind==="arc"?{...i,center:e(i.center),radius:i.radius*Math.abs(n),clockwise:o?!i.clockwise:i.clockwise,end:e(i.end)}:{...i,control1:e(i.control1),control2:e(i.control2),end:e(i.end)})}}var Ot=45,so=150,vt=.5523;function Ct(t,e){return Math.abs(t.x-e.x)<=1e-6&&Math.abs(t.y-e.y)<=1e-6}function co(t){let e=[],n=[];for(t.forEach((o,i)=>{oe(o)&&(e.length&&Ct(e[e.length-1],o)||(e.push({x:o.x,y:o.y}),n.push(i)))});e.length>1&&Ct(e[0],e[e.length-1]);)e.pop(),n.pop();return{points:e,sourceIndex:n}}var lo=.5,uo=4/3;function fo(t,e,n){let o=e.x-t.x,i=e.y-t.y,a=Math.hypot(o,i);if(a<=1e-9)return{kind:"line",end:{...e}};let r=-i/a,s=o/a,c=n*uo;return{kind:"bezier",control1:{x:t.x+o/3+r*c,y:t.y+i/3+s*c},control2:{x:t.x+o*2/3+r*c,y:t.y+i*2/3+s*c},end:{...e}}}function At(t,e){let{points:n,sourceIndex:o}=co(t),i=n.length;if(i<3)return null;let a=Math.min(100,Math.max(0,e.cornerSmoothing??0))/100,r=e.edgeCurvature,s=new Array(i).fill(0);if(r?.length)for(let w=0;w<i;w+=1){let S=r[o[w]];s[w]=Number.isFinite(S)?Math.min(100,Math.max(-100,S))/100:0}let c=s.some(w=>Math.abs(w)>1e-6);if(a<=0&&!c)return null;let l=e.wideAngleThresholdDeg??so,d=[];for(let w=0;w<i;w+=1)d[w]=E(n[w],n[(w+1)%i]);let g=new Array(i).fill(0);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],I=n[w],A=n[(w+1)%i],D={x:S.x-I.x,y:S.y-I.y},L={x:A.x-I.x,y:A.y-I.y},B=Math.hypot(D.x,D.y),K=Math.hypot(L.x,L.y);if(B<=1e-9||K<=1e-9)continue;let O=Math.min(1,Math.max(-1,(D.x*L.x+D.y*L.y)/(B*K))),G=Math.acos(O)*180/Math.PI;if(G<l)continue;let j=It((G-l)/(180-l));g[w]=a*j*.5*Math.min(B,K)}for(let w=0;w<i;w+=1){let S=(w+1)%i,I=g[w]+g[S];if(I>d[w]&&I>1e-9){let A=d[w]/I;g[w]*=A,g[S]*=A}}let b=new Array(i),f=new Array(i);for(let w=0;w<i;w+=1){let S=n[(w-1+i)%i],I=n[w],A=n[(w+1)%i];if(g[w]<=1e-6){b[w]={...I},f[w]={...I};continue}let D=E(I,S)||1,L=E(I,A)||1;b[w]={x:I.x+(S.x-I.x)/D*g[w],y:I.y+(S.y-I.y)/D*g[w]},f[w]={x:I.x+(A.x-I.x)/L*g[w],y:I.y+(A.y-I.y)/L*g[w]}}if(g.every(w=>w<=1e-6)&&!c)return null;let h=[],y={...f[0]},x=y,v=(w,S)=>{if(E(x,w)<=1e-9)return;let I=s[S];Math.abs(I)>1e-6?h.push(fo(x,w,I*lo*d[S])):h.push({kind:"line",end:{...w}}),x=w};for(let w=1;w<=i;w+=1){let S=w%i,I=n[S];v(b[S],(w-1)%i),g[S]>1e-6&&E(b[S],f[S])>1e-9&&(h.push({kind:"bezier",control1:Je(b[S],I,vt),control2:Je(f[S],I,vt),end:{...f[S]}}),x=f[S])}if(!h.length)return null;let p=h[h.length-1];E(p.end,y)>1e-9&&(p.kind==="line"?p.end={...y}:h.push({kind:"line",end:{...y}}));let m={version:1,closed:!0,start:y,segments:h};return Ie(m)?m:null}var _t="ABCDEFGHIJKLMNOPQRSTUVWXYZ",go="ABCDEFGHJKLMNPQRSTUVWXYZ",bo="abcdefghijklmnopqrstuvwxyz";function Mt(t,e){let n=e.length,o=t+1,i="";for(;o>0;){o-=1;let a=o%n;i=e[a]+i,o=Math.floor(o/n)}return i}function ho(t,e){let n=e.startAt-1,o=t+n;if(e.scheme==="numbers")return String(o+1);let i=e.skipAmbiguous?go:_t;return Mt(o,i)}function Ye(t,e=!1){let n=e?bo:_t;return Mt(Math.max(0,Math.floor(t)-1),n)}var po=[[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 jt(t){if(!Number.isFinite(t)||t<=0)return String(t);let e=Math.floor(t),n="";for(let[o,i]of po)for(;e>=o;)n+=i,e-=o;return n}function Rt(t,e){let n=t.length;return t.map((o,i)=>{let a=e.reverse?n-1-i:i;return{...o,label:ho(a,e)}})}function mo(t){let e=new Array(t);return Array.from({length:t},(n,o)=>o).sort((n,o)=>Math.abs(2*n-(t-1))-Math.abs(2*o-(t-1))||n-o).forEach((n,o)=>e[n]=o),e}function We(t,e){let n=t.seatLabelStart??1,o=t.seatNumbering?.direction??"ltr",i=t.seatNumbering?.step??1,a=t.seatNumbering?.scheme??"decimal",r=t.seatNumbering?.prefix??"",s=t.seatNumbering?.endAt,c=t.seatCount;if(a==="updown"||a==="updown-descending"){let f=Math.ceil(c/2),h=a==="updown"?e<f?n+2*e:n-1+2*(c-e):e<f?n+2*(f-1-e):n+1+2*(e-f);return`${r}${h}`}let l=a==="odd"||a==="even"?2:i,d=s!=null&&Number.isFinite(s)?s-(c-1)*l:n,g=o==="center"?mo(c)[e]:o==="rtl"?c-1-e:e,b;switch(a){case"odd":{let f=d%2===1?d:d+1;b=String(f+g*2);break}case"even":{let f=d%2===0?d:d+1;b=String(f+g*2);break}case"roman":b=jt(d+g*i);break;case"letters-upper":b=Ye(d+g*i,!1);break;case"letters-lower":b=Ye(d+g*i,!0);break;default:b=String(d+g*i);break}return`${r}${b}`}function yo(t){return{...t.canonical,seatCount:t.totalSeats,label:t.displayLabel,displayLabel:t.displayLabel}}function kt(t,e,n){return n?.label??`${t.label}-${We(t,e)}`}function Ft(t,e,n,o){if(o?.displayLabel)return o.displayLabel;if(!n)return`${t.displayLabel??t.label}-${We(t,e)}`;let i=yo(n),a=n.displayOffset+e;return`${n.displayLabel}-${We(i,a)}`}function Et(t){return t?t.accessibility&&t.accessibility.length?t.wheelchairSpaceType&&!t.accessibility.includes("wheelchair")?["wheelchair",...t.accessibility]:t.accessibility:t.wheelchairSpaceType?["wheelchair"]:t.accessible?["wheelchair"]:[]:[]}var Ce=Math.PI/180,wo=9,re=16;function Qe(t,e,n,o){let i=n*Ce,a=Math.cos(i),r=Math.sin(i);return{x:o.x+t*a-e*r,y:o.y+t*r+e*a}}function de(t){let{seatCount:e,seatSpacing:n,curve:o,rotation:i,origin:a}=t,r=[];if(t.path)return Se(t.path,e);if(e<=1)return e===1&&r.push({x:a.x,y:a.y}),r;if(o===0){for(let l=0;l<e;l++)r.push(Qe(l*n,0,i,a));return r}let s=o/(e-1)*Ce,c=n/(2*Math.sin(Math.abs(s)/2));for(let l=0;l<e;l++){let d=l*s,g=c*Math.sin(d),b=-c+c*Math.cos(d);r.push(Qe(g,b,i,a))}return r}function xo(t){let e=new Map;if(t.overrides)for(let n of t.overrides)e.set(n.index,n);return e}function So(t,e){let n=xo(t);return de(t).map((o,i)=>{let a=n.get(i),r=Et(a),s=kt(t,i,a),c={...t.commercial,...a?.commercial};return{index:i,x:o.x+(a?.dx??0),y:o.y+(a?.dy??0),label:s,displayLabel:Ft(t,i,e,a),categoryKey:a?.categoryKey??t.categoryKey,skipped:!!a?.skip,accessible:r.length>0,accessibility:r,wheelchairSpaceType:a?.wheelchairSpaceType,commercial:Object.values(c).some(l=>l!==void 0&&l!==!1&&l!=="")?c:void 0,viewUrl:a?.viewFromSeatUrl??t.viewFromSeatUrl,viewMeta:a?.viewFromSeatUrl?a.viewFromSeatMeta:t.viewFromSeatMeta,labelStyle:a?.labelStyle}})}function z(t){let e=[];for(let n of So(t))n.skipped||e.push({id:`${t.id}:${n.index}`,label:n.label,displayLabel:n.displayLabel===n.label?void 0:n.displayLabel,x:n.x,y:n.y,rowId:t.id,categoryKey:n.categoryKey,accessible:n.accessible||void 0,accessibility:n.accessibility.length?n.accessibility:void 0,wheelchairSpaceType:n.wheelchairSpaceType,commercial:n.commercial,viewUrl:n.viewUrl,viewMeta:n.viewMeta,labelStyle:n.labelStyle});return e}function Io(t){if(t.seatCountsBySide)return{...t.seatCountsBySide};let e=t.sides&&t.sides.length?t.sides:["top","bottom"],n=["top","bottom","left","right"].filter(a=>e.includes(a)),o={top:0,bottom:0,left:0,right:0};if(!n.length)return o;let i=Math.max(0,Math.round(t.seatCount));for(let a=0;a<i;a++)o[n[a%n.length]]+=1;return o}function vo(t){let e=[],n=Math.max(0,Math.round(t.seatCount));if(n===0)return e;let o=new Map((t.overrides??[]).map(d=>[d.index,d])),i=(d,g,b,f)=>{let h=o.get(d),y=Et(h),x=h?.label??`${t.label}-${d+1}`,v=t.displayLabel??t.label;return{index:d,label:x,displayLabel:h?.displayLabel??`${v}-${d+1}`,x:g+(h?.dx??0),y:b+(h?.dy??0),categoryKey:h?.categoryKey??t.categoryKey,skipped:!!h?.skip,accessible:y.length>0,accessibility:y,wheelchairSpaceType:h?.wheelchairSpaceType,commercial:h?.commercial,viewUrl:h?.viewFromSeatUrl,viewMeta:h?.viewFromSeatUrl?h.viewFromSeatMeta:void 0,labelStyle:h?.labelStyle,...f?{side:f}:{}}};if(t.shape==="round"){let d=(t.radius??40)+re,g=t.rotation*Ce,b=Math.max(0,Math.min(360,t.seatArc??360));if(b>=360||n===1){for(let x=0;x<n;x++){let v=g+x/n*2*Math.PI;e.push(i(x,t.center.x+d*Math.cos(v),t.center.y+d*Math.sin(v)))}return e}let f=b*Ce,h=(2*Math.PI-f)/2,y=g+h;for(let x=0;x<n;x++){let v=y+x/(n-1)*f;e.push(i(x,t.center.x+d*Math.cos(v),t.center.y+d*Math.sin(v)))}return e}let a=t.width??80,r=t.height??50,s=Io(t),c=["top","bottom","left","right"],l=0;for(let d of c){let g=s[d];for(let b=0;b<g;b++){let f,h;d==="top"?(f=-a/2+(b+.5)*a/g,h=-r/2-re):d==="bottom"?(f=-a/2+(b+.5)*a/g,h=r/2+re):d==="left"?(f=-a/2-re,h=-r/2+(b+.5)*r/g):(f=a/2+re,h=-r/2+(b+.5)*r/g);let y=Qe(f,h,t.rotation,t.center);e.push(i(l++,y.x,y.y,d))}}return e}function W(t){return vo(t).filter(e=>!e.skipped).map(e=>({id:`${t.id}:${e.index}`,label:e.label,...e.displayLabel!==e.label?{displayLabel:e.displayLabel}:{},x:e.x,y:e.y,rowId:t.id,categoryKey:e.categoryKey,...e.accessible?{accessible:!0}:{},...e.accessibility.length?{accessibility:e.accessibility}:{},...e.wheelchairSpaceType?{wheelchairSpaceType:e.wheelchairSpaceType}:{},...e.commercial?{commercial:e.commercial}:{},...e.viewUrl?{viewUrl:e.viewUrl}:{},...e.viewUrl&&e.viewMeta?{viewMeta:e.viewMeta}:{},...e.labelStyle?{labelStyle:e.labelStyle}:{}}))}function Nt(t){return[{id:`${t.id}:0`,label:t.label,...t.displayLabel&&t.displayLabel!==t.label?{displayLabel:t.displayLabel}:{},x:t.center.x,y:t.center.y,rowId:t.id,categoryKey:t.categoryKey,kind:"booth"}]}function Tt(t,e){let n=!1;for(let o=0,i=e.length-1;o<e.length;i=o++){let a=e[o].x,r=e[o].y,s=e[i].x,c=e[i].y;r>t.y!=c>t.y&&t.x<(s-a)*(t.y-r)/(c-r)+a&&(n=!n)}return n}function Co(t,e){return e.some((n,o)=>{let i=e[(o+1)%e.length],a=(t.y-n.y)*(i.x-n.x)-(t.x-n.x)*(i.y-n.y);if(Math.abs(a)>1e-7)return!1;let r=(t.x-n.x)*(i.x-n.x)+(t.y-n.y)*(i.y-n.y),s=(i.x-n.x)**2+(i.y-n.y)**2;return r>=-1e-7&&r<=s+1e-7})}function N(t,e,n){return Tt(t,e)&&!(n??[]).some(o=>Tt(t,o)||Co(t,o))}function Ze(t){if(!t.length)return{x:0,y:0};let e=0,n=0;for(let o of t)e+=o.x,n+=o.y;return{x:e/t.length,y:n/t.length}}function F(t){switch(t.type){case"row":{let e=z(t);if(!e.length)return{x:t.origin.x,y:t.origin.y};let n=0,o=0;for(let i of e)n+=i.x,o+=i.y;return{x:n/e.length,y:o/e.length}}case"table":case"booth":return{x:t.center.x,y:t.center.y};case"gaArea":return Ze(t.points);case"section":return Ze(t.outline);case"text":return{x:t.position.x,y:t.position.y};case"shape":return t.points&&t.points.length?Ze(t.points):t.x!=null&&t.y!=null&&t.width!=null&&t.height!=null?{x:t.x+t.width/2,y:t.y+t.height/2}:{x:t.x??0,y:t.y??0};case"decorImage":return{x:t.x+t.width/2,y:t.y+t.height/2}}}function Lt(t,e){return t.length===e.length&&t.every((n,o)=>n.x===e[o].x&&n.y===e[o].y)}function Po(t,e){if(t.type!=="gaArea"||!Lt(t.points,e.outline))return!1;let n=t.holes??[],o=e.holes??[];return n.length===o.length&&n.every((i,a)=>Lt(i,o[a]))}function Dt(t,e){let n=t.filter(r=>r.type==="section"),o="referenceInventorySource"in e?e.referenceInventorySource?.logicalSectionId:void 0,i=F(e);return(o?n.find(r=>(r.logicalSectionId??r.id)===o&&(Po(e,r)||N(i,r.outline,r.holes))):void 0)??n.find(r=>N(i,r.outline,r.holes))}function $(t){return t.floors&&t.floors.length?t.floors:[{id:"floor-0",name:"Main",objects:t.objects,focalPoint:t.focalPoint,referenceImage:t.referenceImage,backgroundImage:t.backgroundImage}]}function J(t){return t.floors&&t.floors.length?t.floors.flatMap(e=>e.objects):t.objects}var ve=40;function $t(t){let e=1/0,n=1/0,o=-1/0,i=-1/0,a=(r,s)=>{r<e&&(e=r),s<n&&(n=s),r>o&&(o=r),s>i&&(i=s)};for(let r of J(t))if(r.type==="row"){let s=new Map((r.overrides??[]).map(c=>[c.index,c]));de(r).forEach((c,l)=>{let d=s.get(l);d?.skip||a(c.x+(d?.dx??0),c.y+(d?.dy??0))})}else if(r.type==="gaArea")for(let s of r.points)a(s.x,s.y);else if(r.type==="section")for(let s of r.outline)a(s.x,s.y);else if(r.type==="decorImage")a(r.x,r.y),a(r.x+r.width,r.y+r.height);else if(r.type==="shape")if(r.points&&r.points.length)for(let s of r.points)a(s.x,s.y);else r.x!=null&&r.y!=null&&r.width!=null&&r.height!=null&&(a(r.x,r.y),a(r.x+r.width,r.y+r.height));else if(r.type==="table"){let s=re+wo,c=r.shape==="round"?(r.radius??40)+s:Math.max((r.width??80)/2,(r.height??50)/2)+s;a(r.center.x-c,r.center.y-c),a(r.center.x+c,r.center.y+c)}else if(r.type==="booth"){let s=Math.max(r.width,r.height)/2;a(r.center.x-s,r.center.y-s),a(r.center.x+s,r.center.y+s)}else if(r.type==="text"){let s=xt(r);a(r.position.x,r.position.y),a(r.position.x+s.width,r.position.y+s.height)}for(let r of[t.referenceImage,t.backgroundImage]){if(!r)continue;let{center:s,width:c}=r,l=c*3/4;a(s.x-c/2,s.y-l/2),a(s.x+c/2,s.y+l/2)}if(!isFinite(e)){let r=t.focalPoint??{x:0,y:0};return{x:r.x-200,y:r.y-200,width:400,height:400}}return{x:e-ve,y:n-ve,width:o-e+ve*2,height:i-n+ve*2}}var ue=[{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"}],ca=new Map(ue.map(t=>[t.key,t]));var Oo=[{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"}],la=new Map(Oo.map(t=>[t.key,t]));var et=8,tt=24,Ao=["reference-focal","bar","entrance","exit","restroom","screen","sound","concession","coat","wall","rail","suite","obstruction"],da=new Set(Ao);var u=class extends Error{constructor(n,o,i={}){super(o);this.code=n;this.details=i;this.name="ChartOperationError"}};function C(t,e){let n=$(t),o=e?n.find(i=>i.id===e):n[0];if(!o)throw new u("floor_not_found",`Unknown chart floor: ${e}`,{floorId:e});return{floorId:o.id,objects:o.objects}}function R(t,e){if(!t.categories.some(n=>n.key===e))throw new u("category_not_found",`Unknown chart category: ${e}. Call get_chart to list valid category keys.`,{categoryKey:e})}function M(t,e,n,o){let i=new Set([...o,...t.categories.map(a=>a.key),...t.zones?.map(a=>a.id)??[],...t.floors?.map(a=>a.id)??[],...t.floors?.length?t.floors.flatMap(a=>a.objects.map(r=>r.id)):t.objects.map(a=>a.id)]);for(let a=0;a<100;a++){let r=n(e);if(r&&!i.has(r))return o.add(r),r}throw new u("id_generation_failed",`Unable to allocate a unique ${e} id`)}function _o(t){let e=t.slice().sort((a,r)=>a.x-r.x||a.y-r.y);if(e.length<3)return e;let n=(a,r,s)=>(r.x-a.x)*(s.y-a.y)-(r.y-a.y)*(s.x-a.x),o=[];for(let a of e){for(;o.length>=2&&n(o[o.length-2],o[o.length-1],a)<=0;)o.pop();o.push(a)}let i=[];for(let a=e.length-1;a>=0;a--){let r=e[a];for(;i.length>=2&&n(i[i.length-2],i[i.length-1],r)<=0;)i.pop();i.push(r)}return o.pop(),i.pop(),o.concat(i)}function Mo(t,e){if(!t.length)return t;let n={x:t.reduce((o,i)=>o+i.x,0)/t.length,y:t.reduce((o,i)=>o+i.y,0)/t.length};return t.map(o=>{let i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a)||1;return{x:o.x+i/r*e,y:o.y+a/r*e}})}function Z(t){let e=[];for(let o of t)o.type==="row"?e.push(...z(o).map(i=>({x:i.x,y:i.y}))):o.type==="table"?e.push(...W(o).map(i=>({x:i.x,y:i.y}))):o.type==="gaArea"?e.push(...o.points):o.type==="booth"&&e.push(o.center);if(e.length<3)return null;let n=Mo(_o(e),22);return n.length>=3?n:null}function Pe(t,e){let n=C(t,e),o=$(t).find(i=>i.id===n.floorId);return{...t,objects:n.objects,floors:void 0,focalPoint:o.focalPoint,referenceImage:o.referenceImage,backgroundImage:o.backgroundImage}}var Kt=24,Gt=80;function nt(t,e){let n=t.normalize("NFKC").trim();if(n.length>Kt)throw new u("invalid_operation",`${e} displayed type must be at most ${Kt} characters`);return n}function Oe(t,e){if(t.displayType===void 0)return!1;let n=nt(t.displayType,e);return n?(t.displayType=n,!1):(delete t.displayType,!0)}function ie(t,e){if(t.displayLabel===void 0)return!1;let n=t.displayLabel.normalize("NFKC").trim();if(n.length>Gt)throw new u("invalid_operation",`${e} displayed label must be at most ${Gt} characters`);return n?(t.displayLabel=n,!1):(delete t.displayLabel,!0)}function T(t,e){let n=t.trim().toLowerCase();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation",`${e} must use a six-digit hex color`);return n}function zt(t,e){if(!Number.isFinite(t)||t<et||t>tt)throw new u("invalid_operation",`${e} label size must be from ${et} to ${tt}`)}function ae(t,e){t.size!==void 0&&t.size!==null&&zt(t.size,e),t.color!==void 0&&t.color!==null&&T(t.color,`${e} label color`)}function Ae(t,e){if(t?.positionPreset!==void 0&&!["start","end","both","none"].includes(t.positionPreset))throw new u("invalid_operation",`${e} label positionPreset must be one of start, end, both, none`);let n=t?.labelStyle;n&&(n.size!==void 0&&zt(n.size,e),n.color!==void 0&&T(n.color,`${e} label color`))}function _e(t,e){let n=t?structuredClone(t):{},o=n.labelStyle?{...n.labelStyle}:{};return e.size===null?delete o.size:e.size!==void 0&&(o.size=e.size),e.color===null?delete o.color:e.color!==void 0&&(o.color=T(e.color,"Label color")),o.size===void 0&&o.color===void 0?delete n.labelStyle:n.labelStyle=o,e.visible!==void 0&&(n.visible=e.visible),Object.keys(n).length?n:void 0}function ot(t,e,n){let o=e.normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Zone labels must contain 1 to 80 characters");if((t.zones??[]).some(i=>i.id!==n&&i.label.normalize("NFKC").trim().toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Zone label already exists: ${o}`);return o}function rt(t,e){if(!Number.isFinite(t?.x)||!Number.isFinite(t?.y))throw new u("invalid_operation",`${e} must contain finite x and y values`);return{x:t.x,y:t.y}}function H(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)}var X=Math.PI/180,q=Math.PI/180;function Q(t){return t.type==="row"||t.type==="table"?t.seatCount:t.type==="gaArea"?Math.max(0,Math.floor(t.capacity)):t.type==="booth"?1:0}function fe(t){if(t.floors?.length){let e=t.floors[0];t.objects=e.objects,t.focalPoint=e.focalPoint,t.referenceImage=e.referenceImage,t.backgroundImage=e.backgroundImage}return t}var jo=0,Me=120,it=4;function Ro(t){if(!Number.isFinite(t)||t<jo||t>Me)throw new u("invalid_operation","Floor base height must be a number from 0 to 120 metres")}function ko(t,e){let n=$(t);if(n.length>=5)throw new u("invalid_operation","A chart can contain at most five physical floors");let o=(e.name??String(n.length+1)).normalize("NFKC").trim();if(!o||o.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(c=>c.name.toLocaleLowerCase("en")===o.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${o}`);t.floors?.length||(t.floors=[{id:"floor-0",name:"1",objects:t.objects,baseHeightM:0,focalPoint:t.focalPoint,referenceImage:t.referenceImage,backgroundImage:t.backgroundImage}]);let a=t.floors[t.floors.length-1].baseHeightM??Math.min(Me,(t.floors.length-1)*it),r=Math.min(Me,a+it),s=M(t,"floor",e.idFactory,new Set);return t.floors.push({id:s,name:o,baseHeightM:r,objects:[],focalPoint:{...t.focalPoint}}),fe(t),{changed:!0,floorId:s,floorCount:t.floors.length,baseHeightM:r}}function Fo(t,e){let n=$(t),o=n.find(r=>r.id===e.floorId);if(!o)throw new u("floor_not_found",`Unknown chart floor: ${e.floorId}`,{floorId:e.floorId});let i=e.name.normalize("NFKC").trim();if(!i||i.length>80)throw new u("invalid_operation","Floor names must contain 1 to 80 characters");if(n.some(r=>r.id!==o.id&&r.name.toLocaleLowerCase("en")===i.toLocaleLowerCase("en")))throw new u("invalid_operation",`Floor name already exists: ${i}`);let a=o.name!==i;return a&&(o.name=i),{changed:a,floorId:o.id,floorName:i}}function To(t,e){if(!t.floors?.length)throw new u("invalid_operation","A single-floor chart has an implicit base height of 0 metres");let n=t.floors.find(i=>i.id===e.floorId);if(!n)throw new u("floor_not_found",`Unknown chart floor: ${e.floorId}`,{floorId:e.floorId});Ro(e.baseHeightM);let o=n.baseHeightM!==e.baseHeightM;return o&&(n.baseHeightM=e.baseHeightM,n.physical3dProvenance={...n.physical3dProvenance,baseHeightM:{status:"confirmed",source:"user-review",note:"Physical floor height reviewed through the shared Designer/Copilot operation."}}),{changed:o,floorId:n.id,baseHeightM:e.baseHeightM}}function Lo(t,e){if(!t.floors?.length)throw new u("invalid_operation","A single-floor chart cannot remove its only floor");let n=t.floors.findIndex(i=>i.id===e.floorId);if(n<0)throw new u("floor_not_found",`Unknown chart floor: ${e.floorId}`,{floorId:e.floorId});let[o]=t.floors.splice(n,1);if(t.floors.length===1){let[i]=t.floors;t.objects=i.objects,t.focalPoint=i.focalPoint,t.referenceImage=i.referenceImage,t.backgroundImage=i.backgroundImage,t.floors=void 0}else fe(t);return{changed:!0,floorId:o.id,removedObjects:o.objects.length,floorCount:$(t).length}}function Eo(t,e){if((t.zones?.length??0)>=100)throw new u("invalid_operation","A chart supports at most 100 zones");let n={id:M(t,"zone",e.idFactory,new Set),label:ot(t,e.label),color:T(e.color,"Zone color"),...e.focalPoint?{focalPoint:rt(e.focalPoint,"Zone focal point")}:{}};return(t.zones??=[]).push(n),{changed:!0,zone:structuredClone(n)}}function No(t,e){if(!e.updates.length)throw new u("invalid_operation","At least one zone update is required");let n=e.updates.map(c=>c.zoneId);if(new Set(n).size!==n.length)throw new u("invalid_operation","Zone ids must be unique");let o=new Map((t.zones??[]).map(c=>[c.id,c])),i=n.filter(c=>!o.has(c));if(i.length)throw new u("object_not_found",`Unknown zone id(s): ${i.join(", ")}. Call get_chart to list current zone ids.`,{zoneIds:i});let a=structuredClone(t),r=new Map((a.zones??[]).map(c=>[c.id,c]));for(let c of e.updates){if(!Object.keys(c.patch).length)throw new u("invalid_operation",`Zone ${c.zoneId} has no changes`);let d=r.get(c.zoneId);c.patch.label!==void 0&&(d.label=ot(a,c.patch.label,d.id)),c.patch.color!==void 0&&(d.color=T(c.patch.color,"Zone color")),c.patch.focalPoint!==void 0&&(d.focalPoint=rt(c.patch.focalPoint,"Zone focal point"))}let s=JSON.stringify(a.zones??[])!==JSON.stringify(t.zones??[]);return s&&(t.zones=a.zones),{changed:s,zoneIds:n,zones:n.map(c=>structuredClone(r.get(c)))}}function Do(t,e){let n=(t.zones??[]).findIndex(a=>a.id===e.zoneId);if(n<0)throw new u("object_not_found",`Unknown chart zone: ${e.zoneId}`,{zoneId:e.zoneId});let o=$(t).flatMap(a=>a.objects).filter(a=>a.type==="section"&&a.zone===e.zoneId);if(o.length&&e.clearSectionAssignments!==!0)throw new u("invalid_operation",`Zone ${e.zoneId} is assigned to ${o.length} section(s)`,{zoneId:e.zoneId,sectionIds:o.map(a=>a.id),requiresClearSectionAssignments:!0});let i=o.map(a=>a.id);for(let a of o)delete a.zone;return t.zones.splice(n,1),t.zones.length||delete t.zones,fe(t),{changed:!0,zoneId:e.zoneId,clearedSectionIds:i,zoneCount:t.zones?.length??0}}var je=[{key:"row-seats",label:"row seats",suffix:"rows",labelSuffix:"Rows",creationWord:"Seats",objectType:"row"},{key:"table-chairs",label:"table chairs",suffix:"tables",labelSuffix:"Tables",creationWord:"Tables",objectType:"table"},{key:"booth-units",label:"booth units",suffix:"booths",labelSuffix:"Booths",creationWord:"Booths",objectType:"booth"},{key:"ga-capacity",label:"GA capacity",suffix:"ga",labelSuffix:"GA",creationWord:"Standing",objectType:"gaArea"}];function Re(t){let e=new Map,n=Math.max(0,Math.floor(t.seatCount)),o=new Map((t.overrides??[]).filter(a=>Number.isInteger(a.index)&&a.index>=0&&a.index<t.seatCount).map(a=>[a.index,a])),i=(a,r=1)=>{a&&r>0&&e.set(a,(e.get(a)??0)+r)};i(t.categoryKey,n-o.size);for(let a of o.values())a.skip||i(a.categoryKey??t.categoryKey);return e}var Bt="__sl_ga__",ee=1e5,se=1e5;function $o(t,e){return`${Bt}${encodeURIComponent(t)}__${e+1}`}function at(t){let e=t.inventorySegments;if(e===void 0)return!0;if(!Array.isArray(e)||e.length<1||e.length>256)return!1;let n=0,o=new Map;for(let i of e){if(!i||typeof i.sourceAreaId!="string"||!i.sourceAreaId.trim()||i.sourceAreaId.length>160||!Number.isInteger(i.startIndex)||i.startIndex<0||!Number.isInteger(i.count)||i.count<1||i.startIndex+i.count>ee||(n+=i.count,n>ee))return!1;let a=o.get(i.sourceAreaId)??[],r=i.startIndex+i.count;if(a.some(s=>i.startIndex<s.end&&r>s.start))return!1;a.push({start:i.startIndex,end:r}),o.set(i.sourceAreaId,a)}return n===t.capacity}function ke(t){let e=Math.min(ee,Math.max(0,Math.floor(t.capacity)));return t.inventorySegments===void 0?e?[{sourceAreaId:t.id,startIndex:0,count:e}]:[]:at(t)?t.inventorySegments.map(n=>({...n})):[]}function te(t){return ke(t).flatMap(e=>Array.from({length:e.count},(n,o)=>$o(e.sourceAreaId,e.startIndex+o)))}function st(t,e){if(t.inventorySegments===void 0||e===t.capacity)return t.inventorySegments;if(e<t.capacity)return;let n=ke(t);if(!n.length)return;let o=e-t.capacity;if(!o)return n;let a=n.filter(s=>s.sourceAreaId===t.id).reduce((s,c)=>Math.max(s,c.startIndex+c.count),0),r=n[n.length-1];if(r?.sourceAreaId===t.id&&r.startIndex+r.count===a)r.count+=o;else{if(n.length>=256)return;n.push({sourceAreaId:t.id,startIndex:a,count:o})}return n}function Ut(t){return t.startsWith(Bt)}var Ko="__ungrouped__";function Go(t){return t.type==="row"?z(t).map(e=>e.label):t.type==="table"?W(t).map(e=>e.label):t.type==="booth"?Nt(t).map(e=>e.label):t.type==="gaArea"?te(t):[]}function zo(t){return t.type==="row"||t.type==="table"||t.type==="booth"||t.type==="gaArea"}function ge(t){let e=J(t),n=e.filter(r=>r.type==="section"),o=new Map;for(let r of n){let s=r.logicalSectionId??r.id;o.get(s)||o.set(s,{id:s,label:r.displayLabel||r.label||"Section",zone:r.zone,seatCount:0,objectIds:[],seatLabels:[]})}let i={id:Ko,label:"Other seats",seatCount:0,objectIds:[],seatLabels:[]},a=new Map;for(let r of e){if(!zo(r))continue;let s=Go(r);if(s.length===0)continue;let c=Dt(e,r),l=c?o.get(c.logicalSectionId??c.id):i;l.seatCount+=s.length,l.objectIds.push(r.id),l.seatLabels.push(...s),a.set(r.id,l.id)}return{sections:[...o.values()],ungrouped:i.objectIds.length?i:null,objectToSection:a}}var be={vip:{key:"vip",label:"VIP",color:"#e5484d",price:120},premium:{key:"premium",label:"Premium",color:"#a86b00",price:80},standard:{key:"standard",label:"Standard",color:"#6e7bff",price:45},balcony:{key:"balcony",label:"Balcony",color:"#22a06b",price:30}};function he(t,e,n,o,i,a,r=0){return{type:"row",id:t,label:e,origin:{x:-(o-1)*i/2,y:n},rotation:0,curve:r,seatCount:o,seatSpacing:i,categoryKey:a}}function Bo(t,e,n,o,i,a){return{type:"table",id:t,label:e,center:n,shape:"round",seatCount:o,rotation:0,radius:i,categoryKey:a}}function Uo(t,e,n,o,i,a){let r=n/2,s=o/2;return{type:"gaArea",id:t,label:e,points:[{x:-r,y:-s},{x:r,y:-s},{x:r,y:s},{x:-r,y:s}],capacity:i,categoryKey:a}}var Ht=[{key:"balcony",label:"Balcony",icon:"\u2312",blurb:"Insert four curved rows inside a section.",categories:[be.balcony],sectionLabel:"Balcony",build:()=>[he("blk-b0","A",-45,18,24,"balcony",18),he("blk-b1","B",-15,20,24,"balcony",18),he("blk-b2","C",15,22,24,"balcony",18),he("blk-b3","D",45,24,24,"balcony",18)]},{key:"rows",label:"Row block",icon:"\u2261",blurb:"Insert six straight rows inside a section.",categories:[be.standard],sectionLabel:"Section",build:()=>Array.from({length:6},(t,e)=>he(`blk-r${e}`,"ABCDEF"[e],-80+e*32,12,26,"standard"))},{key:"ga-pen",label:"GA pen",icon:"\u25A8",blurb:"Insert a standing area for 250 people.",categories:[be.standard],build:()=>[Uo("blk-ga","Standing",320,180,250,"standard")]},{key:"tables",label:"Tables",icon:"\u283F",blurb:"Insert six round tables with eight bookable seats each.",categories:[be.premium],build:()=>Array.from({length:6},(t,e)=>Bo(`blk-t${e}`,`T${e+1}`,{x:-150+e%3*150,y:e<3?-70:70},8,34,"premium"))},{key:"boxes",label:"Boxes",icon:"\u25A3",blurb:"Insert two private boxes with four bookable seats each.",categories:[be.vip],build:()=>[{type:"table",id:"blk-x0",label:"Box 1",center:{x:-70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"},{type:"table",id:"blk-x1",label:"Box 2",center:{x:70,y:0},shape:"rect",seatCount:4,rotation:0,width:110,height:56,categoryKey:"vip"}]}];function V(t){let e="",n=t;do e=String.fromCharCode(65+n%26)+e,n=Math.floor(n/26)-1;while(n>=0);return e}function Vt(t){if(!/^[A-Z]+$/.test(t))return null;let e=0;for(let n of t)e=e*26+(n.charCodeAt(0)-64);return e-1}var Jt="M13 4.6a1.6 1.6 0 1 0-3.2 0 1.6 1.6 0 0 0 3.2 0 M11 6.5V13h5l2.4 6 M15 16.4A5 5 0 1 1 9 11.3",qt=[{key:"restroom-men",label:"Men's restroom",group:"facilities",path:"M16 7a4 4 0 1 0-8 0 4 4 0 0 0 8 0 M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"},{key:"restroom-women",label:"Women's restroom",group:"facilities",path:"M15 5a3 3 0 1 0-6 0 3 3 0 0 0 6 0 M12 8l-4 10h8l-4-10 M10 18v4 M14 18v4"},{key:"restroom-accessible",label:"Accessible restroom",group:"facilities",path:Jt},{key:"first-aid",label:"First aid",group:"facilities",path:"M5 4h14a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1Z M12 8v8 M8 12h8"},{key:"coat-check",label:"Coat check",group:"facilities",path:"M12 6a2 2 0 0 1 0-4 2 2 0 0 1 1.6 3.2L21 13H3l8.4-7.8 M3 13h18"},{key:"atm",label:"ATM / cash",group:"facilities",path:"M2 6h20v12H2V6Z M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0 M6 9h.01 M18 15h.01"},{key:"info",label:"Info point",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M12 11v5 M12 8h.01"},{key:"lost-found",label:"Lost & found",group:"facilities",path:"M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14 M16 16l5 5 M9 8.5a2 2 0 1 1 3 1.7c-.8.5-1 .8-1 1.8 M11 15h.01"},{key:"restrooms",label:"Restrooms",group:"facilities",path:"M6 3h12a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M9 18v-3.5a3 3 0 0 1 6 0V18"},{key:"charging",label:"Charging point",group:"facilities",path:"M3 8h13v8H3V8Z M16 10h3v4h-3 M9.6 9l-2 3.5h2.5l-1.5 3"},{key:"smoking",label:"Smoking area",group:"facilities",path:"M2 15h13v3H2v-3Z M18 16h2 M19 8c0 1 1 1.5 1 2.5S19 12 19 13"},{key:"no-smoking",label:"No smoking",group:"facilities",path:"M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18 M5.6 5.6l12.8 12.8 M7 13h6v2H7v-2Z"},{key:"food",label:"Food",group:"food-drink",path:"M7 3v6a2 2 0 0 0 4 0V3 M9 11v10 M17 3c-1.6 1-2.2 3-2.2 6 0 2 .9 3.2 2.2 3.6V21"},{key:"bar",label:"Bar",group:"food-drink",path:"M4 5h16l-8 8-8-8Z M12 13v6 M8 20h8"},{key:"coffee",label:"Caf\xE9 / coffee",group:"food-drink",path:"M4 8h13v4a5 5 0 0 1-5 5H9a5 5 0 0 1-5-5V8Z M17 9h2a2 2 0 0 1 0 4h-2 M8 2v2 M11 2v2 M4 21h14"},{key:"water",label:"Water / drinks",group:"food-drink",path:"M12 22a7 7 0 0 1-7-7c0-5 7-12 7-12s7 7 7 12a7 7 0 0 1-7 7Z"},{key:"merch",label:"Merch / shop",group:"food-drink",path:"M6 8h12l-1 12H7L6 8Z M9 8V6a3 3 0 0 1 6 0v2"},{key:"screen",label:"Screen",group:"facilities",path:"M3 4h18v12H3V4Z M9 20h6 M12 16v4 M10 8l4 2-4 2V8Z"},{key:"sound-booth",label:"Sound booth",group:"facilities",path:"M6 4v16 M6 14a2 2 0 1 0 0-4 2 2 0 0 0 0 4 M12 4v16 M12 8a2 2 0 1 0 0 4 2 2 0 0 0 0-4 M18 4v16 M18 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4"},{key:"entrance",label:"Entrance",group:"navigation",path:"M14 3h5a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1h-5 M3 12h11 M10 8l4 4-4 4"},{key:"exit",label:"Exit",group:"navigation",path:"M10 3H5a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h5 M14 12h7 M17 8l4 4-4 4"},{key:"emergency-exit",label:"Emergency exit",group:"navigation",path:"M14 4.6a1.5 1.5 0 1 0-3 0 1.5 1.5 0 0 0 3 0 M12.5 8l-3.5 2 1.6 3.6-2 4.4 M12.5 10l3.5 1.5 M9 10.5l-3.5 1 M15 12h6 M18 9l3 3-3 3"},{key:"stairs",label:"Stairs",group:"navigation",path:"M3 20v-4h4v-4h4v-4h4V4h5"},{key:"elevator",label:"Elevator",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M8 11l1.5-2 1.5 2 M8 14l1.5 2 1.5-2 M15 8v8"},{key:"parking",label:"Parking",group:"navigation",path:"M5 3h14a1 1 0 0 1 1 1v16a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1Z M9 17V7h4a3 3 0 0 1 0 6H9"},{key:"wheelchair",label:"Wheelchair access",group:"accessibility",path:Jt},{key:"hearing",label:"Hearing assistance",group:"accessibility",path:"M8 20a4 4 0 0 1-2-3c0-1 .5-2 .5-3a4.5 4.5 0 1 1 9 0c0 1.4-1 2-2 2.4-1.2.5-1.5 1-1.5 2.2 M17 6a5 5 0 0 1 1 6 M19.5 4a8 8 0 0 1 1.2 9"}];var Ho=new Map(qt.map(t=>[t.key,t]));function Xt(t){return typeof t=="string"&&Ho.has(t)}var Fa=qt.map(t=>t.key);function ct(t){let e=(t%360+360)%360,n=e>=180?e-360:e;return Object.is(n,-0)||Math.abs(n)<1e-9?0:n}function Yt(t,e,n){let o=i=>({x:i.x+e,y:i.y+n});switch(t.type){case"row":t.origin=o(t.origin),t.path&&(t.path={start:o(t.path.start),control1:o(t.path.control1),control2:o(t.path.control2),end:o(t.path.end)});break;case"table":case"booth":t.center=o(t.center);break;case"text":t.position=o(t.position);break;case"gaArea":t.points=t.points.map(o),t.holes&&(t.holes=t.holes.map(i=>i.map(o)));break;case"section":t.outline=t.outline.map(o),t.sourceOutline&&(t.sourceOutline=t.sourceOutline.map(o)),t.outlinePath&&(t.outlinePath=Pt(t.outlinePath,e,n)),t.holes&&(t.holes=t.holes.map(i=>i.map(o)));break;case"shape":t.points&&(t.points=t.points.map(o)),t.x!=null&&(t.x+=e),t.y!=null&&(t.y+=n);break;case"decorImage":t.x+=e,t.y+=n;break}}function Vo(t,e){return Math.abs(t.x-e.x)<=1e-7&&Math.abs(t.y-e.y)<=1e-7}function pe(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)}function Fe(t,e,n){let o=pe(e,n,t);return Math.abs(o)>1e-7?!1:t.x>=Math.min(e.x,n.x)-1e-7&&t.x<=Math.max(e.x,n.x)+1e-7&&t.y>=Math.min(e.y,n.y)-1e-7&&t.y<=Math.max(e.y,n.y)+1e-7}function Jo(t,e,n,o){let i=pe(t,e,n),a=pe(t,e,o),r=pe(n,o,t),s=pe(n,o,e);return(i>1e-7&&a<-1e-7||i<-1e-7&&a>1e-7)&&(r>1e-7&&s<-1e-7||r<-1e-7&&s>1e-7)?!0:Math.abs(i)<=1e-7&&Fe(n,t,e)||Math.abs(a)<=1e-7&&Fe(o,t,e)||Math.abs(r)<=1e-7&&Fe(t,n,o)||Math.abs(s)<=1e-7&&Fe(e,n,o)}function qo(t){return t.reduce((e,n,o)=>{let i=t[(o+1)%t.length];return e+n.x*i.y-i.x*n.y},0)}function Xo(t){for(let e=0;e<t.length;e+=1){let n=(e+1)%t.length;for(let o=e+1;o<t.length;o+=1){let i=(o+1)%t.length;if(!(e===o||n===o||i===e)&&Jo(t[e],t[n],t[o],t[i]))return!0}}return!1}function Wt(t){return t.length<3?{ok:!1,code:"too_few_vertices",message:"Add at least three vertices to create a polygon."}:t.length>256?{ok:!1,code:"too_many_vertices",message:"A polygon can contain at most 256 vertices."}:t.some(e=>!Number.isFinite(e.x)||!Number.isFinite(e.y)||Math.abs(e.x)>1e7||Math.abs(e.y)>1e7)?{ok:!1,code:"invalid_coordinate",message:"Every polygon vertex must use a finite coordinate inside the safe chart range."}:t.some((e,n)=>Vo(e,t[(n+1)%t.length]))?{ok:!1,code:"duplicate_vertex",message:"Move or remove duplicate neighbouring vertices."}:Math.abs(qo(t))<2?{ok:!1,code:"degenerate_polygon",message:"The polygon needs a visible enclosed area."}:Xo(t)?{ok:!1,code:"self_intersection",message:"Polygon edges cannot cross or touch each other."}:{ok:!0}}function rr(t,e){let n=C(t,e.floorId),o=[...new Set(e.tableIds)];if(!o.length)throw new u("invalid_operation","At least one table id is required");let i=o.map(p=>n.objects.find(m=>m.type==="table"&&m.id===p)),a=o.filter((p,m)=>!i[m]);if(a.length)throw new u("object_not_found",`Unknown table id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current table ids.`,{tableIds:a});let r=structuredClone(e.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one table change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one table at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Table labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&R(t,r.categoryKey);let s=r.seatCount!==void 0,c=r.seatCountsBySide!==void 0;if(c){if(r.sides!==void 0)throw new u("invalid_operation","Use seatCountsBySide for exact rectangular counts; do not also supply legacy sides");if(r.shape==="round")throw new u("invalid_operation","seatCountsBySide can be used only with rectangular tables");let p=["top","bottom","left","right"],m=Object.keys(r.seatCountsBySide);if(m.length!==p.length||m.some(S=>!p.includes(S)))throw new u("invalid_operation","seatCountsBySide must contain exactly top, bottom, left, and right");for(let S of p){let I=r.seatCountsBySide[S];if(!Number.isInteger(I)||I<0||I>40)throw new u("invalid_operation",`seatCountsBySide.${S} must be a whole number from 0 to 40`)}let w=p.reduce((S,I)=>S+r.seatCountsBySide[I],0);if(w<1||w>40)throw new u("invalid_operation","Rectangular table side counts must total from 1 to 40 chairs");if(s&&r.seatCount!==w)throw new u("invalid_operation",`seatCount must equal the ${w}-chair seatCountsBySide total`);r.seatCount=w,r.sides=p.filter(S=>r.seatCountsBySide[S]>0)}if(r.seatCount!==void 0&&(!Number.isInteger(r.seatCount)||r.seatCount<1||r.seatCount>40))throw new u("invalid_operation","seatCount must be an integer from 1 to 40");if(r.shape!==void 0&&r.shape!=="round"&&r.shape!=="rect")throw new u("invalid_operation","Table shape must be round or rect");if(r.bookAsWhole===!0&&r.variableOccupancy===!0)throw new u("invalid_operation","A table cannot use whole-table and variable-occupancy selling at the same time");if(r.variableOccupancy===!1&&(r.minOccupancy!==void 0||r.maxOccupancy!==void 0))throw new u("invalid_operation","Guest bounds can be supplied only with variable-occupancy selling");let l=(p,m,w,S)=>{if(m!==void 0&&(!Number.isFinite(m)||m<w||m>S))throw new u("invalid_operation",`${String(p)} must be from ${w} to ${S}`)};if(l("rotation",r.rotation,0,360),l("radius",r.radius,24,160),l("seatArc",r.seatArc,120,360),l("width",r.width,40,320),l("height",r.height,30,240),r.minOccupancy!==void 0&&(!Number.isInteger(r.minOccupancy)||r.minOccupancy<1||r.minOccupancy>40))throw new u("invalid_operation","minOccupancy must be a whole number from 1 to 40");if(r.maxOccupancy!==void 0&&(!Number.isInteger(r.maxOccupancy)||r.maxOccupancy<1||r.maxOccupancy>40))throw new u("invalid_operation","maxOccupancy must be a whole number from 1 to 40");if(r.sides!==void 0){let p=new Set(["top","bottom","left","right"]);if(!r.sides.length||r.sides.length>4||new Set(r.sides).size!==r.sides.length||r.sides.some(m=>!p.has(m)))throw new u("invalid_operation","Table sides must contain one to four unique perimeter sides")}let d=ie(r,"Table"),g=Oe(r,"Table"),b=i.map(p=>{if(p.seatCountsBySide&&!c&&(s||e.patch.sides!==void 0))throw new u("invalid_operation",`Table "${p.label}" has exact per-side counts; update seatCountsBySide instead of aggregate seatCount or legacy sides`,{tableId:p.id});let m=structuredClone(p);if(Object.assign(m,r),m.shape==="round"&&delete m.seatCountsBySide,m.overrides&&r.seatCount!==void 0&&(m.overrides=m.overrides.filter(w=>w.index<m.seatCount),m.overrides.length||delete m.overrides),r.bookAsWhole===!1&&delete m.bookAsWhole,r.variableOccupancy===!1&&(delete m.variableOccupancy,delete m.minOccupancy,delete m.maxOccupancy),m.bookAsWhole||delete m.bookAsWhole,m.variableOccupancy||delete m.variableOccupancy,m.bookAsWhole&&m.variableOccupancy)throw new u("invalid_operation",`Table "${m.label}" cannot use whole-table and variable-occupancy selling at the same time`,{tableId:m.id});if((m.bookAsWhole||m.variableOccupancy)&&m.overrides?.length)throw new u("invalid_operation",`Table "${m.label}" has individual-chair overrides; reset them before choosing grouped table selling`,{tableId:m.id,overriddenChairIndices:m.overrides.map(w=>w.index)});if(m.bookAsWhole)delete m.minOccupancy,delete m.maxOccupancy;else if(m.variableOccupancy){if(!Number.isInteger(m.minOccupancy)||!Number.isInteger(m.maxOccupancy)||m.minOccupancy<1||m.maxOccupancy<m.minOccupancy||m.maxOccupancy>m.seatCount)throw new u("invalid_operation",`Table "${m.label}" needs whole-number minimum and maximum guests from 1 to its ${m.seatCount}-chair capacity`,{tableId:m.id,seatCount:m.seatCount})}else{if(r.minOccupancy!==void 0||r.maxOccupancy!==void 0)throw new u("invalid_operation","Guest bounds can be changed only on a variable-occupancy table",{tableId:m.id});delete m.minOccupancy,delete m.maxOccupancy}if(g&&delete m.displayType,d&&delete m.displayLabel,m.shape==="rect"){if(m.width??=80,m.height??=50,m.seatCountsBySide){let w=["top","bottom","left","right"],S=w.reduce((I,A)=>I+m.seatCountsBySide[A],0);if(S!==m.seatCount)throw new u("invalid_operation",`Table "${m.label}" side counts total ${S}, but seatCount is ${m.seatCount}`,{tableId:m.id,seatCount:m.seatCount,seatCountsBySide:m.seatCountsBySide});m.sides=w.filter(I=>m.seatCountsBySide[I]>0)}}else m.radius??=40;if((m.bookAsWhole||m.variableOccupancy)&&Ut(m.label))throw new u("invalid_operation",`Grouped table label "${m.label}" uses SeatLayer's reserved GA namespace`,{tableId:m.id});return m}),f=new Map(b.map(p=>[p.id,p])),h=new Set(o),y=new Map;for(let p of $(t))for(let m of p.objects){let w=m.type==="table"?f.get(m.id)??m:m,S=[];w.type==="row"?S=z(w).map(I=>I.label):w.type==="table"?S=w.bookAsWhole||w.variableOccupancy?[w.label]:W(w).map(I=>I.label):w.type==="booth"?S=[w.label]:w.type==="gaArea"&&(S=te(w));for(let I of S){let A=y.get(I);if(A&&(h.has(A)||h.has(w.id)))throw new u("invalid_operation",`Inventory label "${I}" is already in use; grouped table labels must be unique`,{tableIds:o,inventoryLabel:I,conflictingObjectIds:[A,w.id]});y.set(I,A??w.id)}}let x=!1,v=["bookAsWhole","variableOccupancy","minOccupancy","maxOccupancy","displayLabel","displayType","seatCountsBySide","overrides"];for(let[p,m]of i.entries()){let w=b[p],S=JSON.stringify(m);for(let I of v)I in w||delete m[I];Object.assign(m,w),JSON.stringify(m)!==S&&(x=!0)}return{floorId:n.floorId,changed:x,tableIds:o}}function ir(t,e){let n=C(t,e.floorId),o=[...new Set(e.boothIds)];if(!o.length)throw new u("invalid_operation","At least one booth id is required");let i=o.map(f=>n.objects.find(h=>h.type==="booth"&&h.id===f)),a=o.filter((f,h)=>!i[h]);if(a.length)throw new u("object_not_found",`Unknown booth id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current booth ids.`,{boothIds:a});let r=structuredClone(e.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one booth change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one booth at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","Booth labels must contain 1 to 80 characters")}r.categoryKey!==void 0&&R(t,r.categoryKey);let s=(f,h,y,x)=>{if(h!==void 0&&(!Number.isFinite(h)||h<y||h>x))throw new u("invalid_operation",`${f} must be from ${y} to ${x}`)};s("width",r.width,30,400),s("height",r.height,30,400),s("rotation",r.rotation,0,360);let c=r.points===null;if(r.points!=null){if(o.length!==1)throw new u("invalid_operation","points can be changed only for one booth at a time");let f=Wt(r.points);if(!f.ok)throw new u("invalid_operation",f.message??"The booth outline is not a valid simple polygon")}let l=r.points!=null?r.points.map(f=>({x:f.x,y:f.y})):void 0;delete r.points;let d=ie(r,"Booth"),g=Oe(r,"Booth"),b=!1;for(let f of i){let h=JSON.stringify(f);Object.assign(f,r),d&&delete f.displayLabel,g&&delete f.displayType,c?delete f.points:l&&(f.points=l),JSON.stringify(f)!==h&&(b=!0)}return{floorId:n.floorId,changed:b,boothIds:o}}function ar(t,e){let n=C(t,e.floorId),o=[...new Set(e.gaAreaIds)];if(!o.length)throw new u("invalid_operation","At least one GA area id is required");let i=o.map(d=>n.objects.find(g=>g.type==="gaArea"&&g.id===d)),a=o.filter((d,g)=>!i[g]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=structuredClone(e.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one GA area change is required");if(r.label!==void 0){if(r.label=r.label.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","label can be changed only for one GA area at a time");if(!r.label||r.label.length>80)throw new u("invalid_operation","GA area labels must contain 1 to 80 characters")}if(r.categoryKey!==void 0&&R(t,r.categoryKey),r.capacity!==void 0&&(!Number.isInteger(r.capacity)||r.capacity<1||r.capacity>1e5))throw new u("invalid_operation","capacity must be an integer from 1 to 100000");if(r.cornerRadius!==void 0&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>2e3))throw new u("invalid_operation","cornerRadius must be from 0 to 2000");let s=ie(r,"GA area"),c=Oe(r,"GA area");if(r.capacity!==void 0)for(let d of i){if(d.inventorySegments!==void 0&&r.capacity<d.capacity)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot be reduced below ${d.capacity}; shrinking would delete stable inventory identities. Create or split a new surface instead.`,{gaAreaId:d.id,currentCapacity:d.capacity,requestedCapacity:r.capacity});if(d.inventorySegments!==void 0&&r.capacity>d.capacity&&st(d,r.capacity)===void 0)throw new u("invalid_operation",`Joined GA area "${d.label}" cannot append that capacity safely`,{gaAreaId:d.id})}let l=!1;for(let d of i){let g=JSON.stringify(d),b=r.capacity===void 0?d.inventorySegments:st(d,r.capacity);Object.assign(d,r),b!==void 0&&(d.inventorySegments=b),s&&delete d.displayLabel,c&&delete d.displayType,JSON.stringify(d)!==g&&(l=!0)}return{floorId:n.floorId,changed:l,gaAreaIds:o}}function Te(t,e){if(e.length<3)return 0;let n=i=>N(i,e,void 0),o=0;for(let i of t)n(F(i))&&(i.type==="row"?o+=z(i).length:i.type==="table"?o+=W(i).length:(i.type==="gaArea"||i.type==="booth")&&(o+=Q(i)));return o}function sr(t,e){let n=C(t,e.floorId);if(!e.objectIds.length)throw new u("invalid_operation","At least one chart object id is required");if(new Set(e.objectIds).size!==e.objectIds.length)throw new u("invalid_operation","Chart object ids must be unique");let o=e.objectIds.map(s=>n.objects.find(c=>c.id===s)),i=e.objectIds.filter((s,c)=>!o[c]);if(i.length)throw new u("object_not_found","One or more chart object ids do not exist on the selected floor",{objectIds:i});let a=o,r=new Set(e.objectIds);for(let s=n.objects.length-1;s>=0;s--)r.has(n.objects[s].id)&&n.objects.splice(s,1);return{floorId:n.floorId,changed:!0,removedObjects:a.map(s=>({id:s.id,type:s.type})),removedInventory:a.reduce((s,c)=>s+Q(c),0),remainingObjectCount:n.objects.length}}function cr(t,e){let n=C(t,e.floorId),o=[...new Set(e.textIds)];if(!o.length)throw new u("invalid_operation","At least one text id is required");let i=o.map(l=>n.objects.find(d=>d.type==="text"&&d.id===l)),a=o.filter((l,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown text id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current text ids.`,{textIds:a});let r=structuredClone(e.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one text change is required");if(r.text!==void 0){if(r.text=r.text.normalize("NFKC").trim(),o.length!==1)throw new u("invalid_operation","content can be changed only for one text object at a time");if(!r.text||r.text.length>240)throw new u("invalid_operation","Text content must contain 1 to 240 characters")}if(r.fontSize!==void 0&&(!Number.isFinite(r.fontSize)||r.fontSize<8||r.fontSize>72))throw new u("invalid_operation","Text fontSize must be from 8 to 72");if(r.fontFamily!==void 0&&r.fontFamily!==null&&(r.fontFamily=r.fontFamily.normalize("NFKC").trim(),!r.fontFamily||r.fontFamily.length>120))throw new u("invalid_operation","Text fontFamily must contain 1 to 120 characters");if(r.rotation!==void 0&&(!Number.isFinite(r.rotation)||r.rotation<0||r.rotation>360))throw new u("invalid_operation","Text rotation must be from 0 to 360");if(r.color!==void 0&&r.color!==null&&(r.color=T(r.color,"Text color")),r.bold!==void 0&&typeof r.bold!="boolean")throw new u("invalid_operation","Text bold must be a boolean");if(r.italic!==void 0&&typeof r.italic!="boolean")throw new u("invalid_operation","Text italic must be a boolean");if(r.width!==void 0&&r.width!==null&&(!Number.isFinite(r.width)||r.width<40||r.width>1200))throw new u("invalid_operation",`Text width must be from ${40} to ${1200}`);if(r.align!==void 0&&!["left","center","right"].includes(r.align))throw new u("invalid_operation","Text align must be left, center, or right");if(r.lineHeight!==void 0&&(!Number.isFinite(r.lineHeight)||r.lineHeight<.8||r.lineHeight>3))throw new u("invalid_operation",`Text lineHeight must be from ${.8} to ${3}`);if(r.letterSpacing!==void 0&&(!Number.isFinite(r.letterSpacing)||r.letterSpacing<-2||r.letterSpacing>20))throw new u("invalid_operation",`Text letterSpacing must be from ${-2} to ${20}`);if(r.underline!==void 0&&typeof r.underline!="boolean")throw new u("invalid_operation","Text underline must be a boolean");if(r.opacity!==void 0&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation",`Text opacity must be from ${.1} to 1`);if(r.background!==void 0&&r.background!==null){r.background.color=T(r.background.color,"Text background color");let{padding:l=6,cornerRadius:d=4,opacity:g=.9}=r.background;if(!Number.isFinite(l)||l<0||l>40)throw new u("invalid_operation",`Text background padding must be from 0 to ${40}`);if(!Number.isFinite(d)||d<0||d>40)throw new u("invalid_operation",`Text background cornerRadius must be from 0 to ${40}`);if(!Number.isFinite(g)||g<.1||g>1)throw new u("invalid_operation",`Text background opacity must be from ${.1} to 1`)}if(["width","align","lineHeight","letterSpacing","underline","opacity","background"].some(l=>Object.prototype.hasOwnProperty.call(r,l))&&i.some(l=>l.semanticKind==="icon"))throw new u("invalid_operation","Text layout fields cannot be applied to venue icons");if(r.iconKey!==void 0){if(!Xt(r.iconKey))throw new u("invalid_operation","iconKey must be a known venue-icon registry key");if(i.some(l=>l.semanticKind!=="icon"))throw new u("invalid_operation",'iconKey can be set only on venue-icon objects (semanticKind "icon")')}let c=!1;for(let l of i){let d=JSON.stringify(l);r.iconKey!==void 0&&(l.iconKey=r.iconKey),r.text!==void 0&&(l.text=r.text),r.fontSize!==void 0&&(l.fontSize=r.fontSize),r.fontFamily===null?delete l.fontFamily:r.fontFamily!==void 0&&(l.fontFamily=r.fontFamily),r.rotation!==void 0&&(l.rotation=r.rotation),r.color===null?delete l.color:r.color!==void 0&&(l.color=r.color),r.bold!==void 0&&(r.bold?l.bold=!0:delete l.bold),r.italic!==void 0&&(r.italic?l.italic=!0:delete l.italic),r.width===null?delete l.width:r.width!==void 0&&(l.width=r.width),r.align!==void 0&&(r.align==="left"?delete l.align:l.align=r.align),r.lineHeight!==void 0&&(r.lineHeight===1.2?delete l.lineHeight:l.lineHeight=r.lineHeight),r.letterSpacing!==void 0&&(r.letterSpacing===0?delete l.letterSpacing:l.letterSpacing=r.letterSpacing),r.underline!==void 0&&(r.underline?l.underline=!0:delete l.underline),r.opacity!==void 0&&(r.opacity===1?delete l.opacity:l.opacity=r.opacity),r.background===null?delete l.background:r.background!==void 0&&(l.background=r.background),JSON.stringify(l)!==d&&(c=!0)}return{floorId:n.floorId,changed:c,textIds:o}}function lr(t,e){let n=C(t,e.floorId),o=[...new Set(e.rowIds)],i=o.map(l=>n.objects.find(d=>d.type==="row"&&d.id===l)),a=o.filter((l,d)=>!i[d]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i.slice().sort((l,d)=>l.origin.y-d.origin.y||l.origin.x-d.origin.x),s=Rt(r.map(l=>({label:l.label})),e.options),c=!1;return r.forEach((l,d)=>{l.label!==s[d].label&&(c=!0),l.label=s[d].label}),{floorId:n.floorId,changed:c,rows:r.map(l=>({id:l.id,label:l.label}))}}function dr(t,e){let n=Ht.find(l=>l.key===e.blockKey);if(!n)throw new u("invalid_operation",`Unknown seating block: ${e.blockKey}`,{blockKey:e.blockKey});let o=C(t,e.floorId),i=new Set,a=n.build().map(l=>structuredClone(l));for(let l of a)l.id=M(t,l.type,e.idFactory,i),Yt(l,e.center.x,e.center.y);for(let l of n.categories)t.categories.some(d=>d.key===l.key)||t.categories.push({...l});let r=a.filter(l=>l.type==="row");if(r.length){let l=0;for(let d of o.objects){if(d.type!=="row")continue;let g=Vt(d.label);g!=null&&(l=Math.max(l,g+1))}for(let d of r)d.label=V(l++)}let s=new Set(o.objects.flatMap(l=>"label"in l&&l.label?[l.label]:[]));for(let l of a){if((l.type==="table"||l.type==="booth")&&s.has(l.label)){let d=/^(.*?)(\d+)$/.exec(l.label),g=d?d[1]:`${l.label} `,b=d?Number.parseInt(d[2],10):1;do b++;while(s.has(`${g}${b}`));l.label=`${g}${b}`}"label"in l&&l.label&&s.add(l.label)}o.objects.push(...a);let c=null;if(n.sectionLabel){let l=Z(a);if(l){let d={type:"section",id:M(t,"sec",e.idFactory,i),label:n.sectionLabel,outline:l};o.objects.push(d),c=d.id}}return{floorId:o.floorId,blockKey:n.key,createdIds:[...a.map(l=>l.id),...c?[c]:[]],sectionId:c}}function ur(t){let e=structuredClone(t);if([e.start,e.control1,e.control2,e.end].some(a=>!Number.isFinite(a.x)||!Number.isFinite(a.y)))throw new u("invalid_operation","Exact row path points must be finite");let o=Se(e,97),i=o.slice(1).reduce((a,r,s)=>a+Math.hypot(r.x-o[s].x,r.y-o[s].y),0);if(!Number.isFinite(i)||i<1)throw new u("invalid_operation","Exact row path must have at least one chart unit of usable length");return{path:e,length:i}}function en(t,e){let n=C(t,e.floorId),o=n.objects.find(d=>d.type==="row"&&d.id===e.rowId);if(!o)throw new u("object_not_found",`Unknown row id: ${e.rowId}`,{rowId:e.rowId});let i=ur(e.path),a=z(o),r=structuredClone(o);r.path=i.path,r.origin={...i.path.start};let s=z(r),c=a.map((d,g)=>Math.hypot(d.x-s[g].x,d.y-s[g].y)),l=JSON.stringify(o.path)!==JSON.stringify(i.path)||o.origin.x!==i.path.start.x||o.origin.y!==i.path.start.y;return{floorId:n.floorId,rowId:o.id,seatCount:o.seatCount,pathLength:i.length,averageSeatMovement:c.length?c.reduce((d,g)=>d+g,0)/c.length:0,maxSeatMovement:c.length?Math.max(...c):0,convertingFromParametric:!o.path,changed:l,preservesStableId:!0,preservesSeatMetadata:!0,preservesInventoryUnits:o.seatCount}}function fr(t,e){let n=en(t,e);if(!n.changed)return n;let i=C(t,n.floorId).objects.find(a=>a.type==="row"&&a.id===n.rowId);return i.path=structuredClone(e.path),i.origin={...e.path.start},delete i.arcFanGeneration,delete i.rowBlockGeneration,n}function gr(t,e){let n=t.map((o,i)=>[...o,e[i]]);for(let o=0;o<3;o++){let i=o;for(let r=o+1;r<3;r++)Math.abs(n[r][o])>Math.abs(n[i][o])&&(i=r);if(Math.abs(n[i][o])<1e-9)return null;[n[o],n[i]]=[n[i],n[o]];let a=n[o][o];for(let r=o;r<4;r++)n[o][r]/=a;for(let r=0;r<3;r++){if(r===o)continue;let s=n[r][o];for(let c=o;c<4;c++)n[r][c]-=s*n[o][c]}}return[n[0][3],n[1][3],n[2][3]]}function br(t){if(t.length<3)return null;let e=[[0,0,0],[0,0,0],[0,0,0]],n=[0,0,0];for(let i of t){if(!Number.isFinite(i.x)||!Number.isFinite(i.y))return null;let a=[2*i.x,2*i.y,1],r=i.x**2+i.y**2;for(let s=0;s<3;s++){n[s]+=a[s]*r;for(let c=0;c<3;c++)e[s][c]+=a[s]*a[c]}}let o=gr(e,n);return o?{x:o[0],y:o[1]}:null}function Zt(t){let e=((t+180)%360+360)%360-180;return e===-180&&(e=180),e}function tn(t,e){let n=C(t,e.floorId),o=n.objects.find(f=>f.type==="section"&&f.id===e.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${e.sectionId}`,{sectionId:e.sectionId});let i=e.strength??100;if(!Number.isFinite(i)||i<0||i>100)throw new u("invalid_operation","Section row-fit strength must be from 0 to 100");let a=$(t).find(f=>f.id===n.floorId),r=e.mode==="outline"?br(o.outline):e.focalPoint??a.focalPoint??t.focalPoint;if(!r||!Number.isFinite(r.x)||!Number.isFinite(r.y))throw new u("invalid_operation",`Section ${e.mode} fit has no finite center`);let s=n.objects.filter(f=>f.type==="row"&&N(F(f),o.outline,o.holes)),c=s.filter(f=>!!f.path).map(f=>f.id),l=[],d=[],g=i/100;for(let f of s){if(f.path)continue;if(f.seatCount<2){l.push(f.id);continue}let h=Math.hypot(f.origin.x-r.x,f.origin.y-r.y);if(h<=f.seatSpacing/2+1e-6){l.push(f.id);continue}let y=2*Math.asin(f.seatSpacing/(2*h))/X,x=z(f),v=Math.atan2(f.origin.x-r.x,f.origin.y-r.y)/X,m=(f.curve!==0?Math.sign(f.curve):x.length>1&&Math.sign(Zt(Math.atan2(x[1].x-r.x,x[1].y-r.y)/X-v))||1)*y*(f.seatCount-1);if(Math.abs(m)>320){l.push(f.id);continue}let w=-v,S=f.curve+(m-f.curve)*g,I=f.rotation+Zt(w-f.rotation)*g,A={...f,curve:S,rotation:I},L=z(A).map((B,K)=>Math.hypot(B.x-x[K].x,B.y-x[K].y));d.push({rowId:f.id,fromCurve:f.curve,targetCurve:m,resultCurve:S,fromRotation:f.rotation,resultRotation:I,rmsMovement:Math.sqrt(L.reduce((B,K)=>B+K**2,0)/L.length),maxMovement:Math.max(...L)})}let b=d.map(f=>f.rmsMovement);return{floorId:n.floorId,sectionId:o.id,mode:e.mode,fitCenter:{...r},strength:i,rows:d,skippedPathRowIds:c,skippedInvalidRowIds:l,averageMovement:b.length?b.reduce((f,h)=>f+h,0)/b.length:0,maxMovement:d.length?Math.max(...d.map(f=>f.maxMovement)):0}}function hr(t,e){let n=tn(t,e),o=C(t,n.floorId),i=o.objects.find(r=>r.type==="section"&&r.id===n.sectionId),a=!1;for(let r of n.rows){let s=o.objects.find(c=>c.type==="row"&&c.id===r.rowId);(s.curve!==r.resultCurve||s.rotation!==r.resultRotation)&&(s.curve=r.resultCurve,s.rotation=r.resultRotation,delete s.arcFanGeneration,delete s.rowBlockGeneration,a=!0)}return(i.smoothing??0)!==n.strength&&(i.smoothing=n.strength,a=!0),{...n,changed:a}}function nn(t,e,n,o){let i=H(t,e,n),a=H(t,e,o),r=H(n,o,t),s=H(n,o,e);return i*a<-1e-9&&r*s<-1e-9}function Qt(t,e){return t.some((n,o)=>{let i=t[(o+1)%t.length];return e.some((a,r)=>nn(n,i,a,e[(r+1)%e.length]))})}function pr(t){if(t.length<3||t.length>256||Math.abs(le(t))<1||t.some(e=>!Number.isFinite(e.x)||!Number.isFinite(e.y)))return!1;for(let e=0;e<t.length;e++)for(let n=e+1;n<t.length;n++)if(!(n===e+1||e===0&&n===t.length-1)&&nn(t[e],t[(e+1)%t.length],t[n],t[(n+1)%t.length]))return!1;return!0}function Le(t,e,n){let o=C(t,e),i=o.objects.find(a=>(a.type==="section"||a.type==="gaArea")&&a.id===n);if(!i)throw new u("object_not_found",`Unknown polygon object id: ${n}`,{objectId:n});return{target:o,object:i,outer:i.type==="section"?i.outline:i.points}}function Ee(t,e){let{target:n,object:o,outer:i}=Le(t,e.floorId,e.objectId),a=structuredClone(e.points);if(!pr(a))throw new u("invalid_operation","Opening must be a finite, non-self-intersecting shape with 3\u2013256 corners");if(a.some(l=>!N(l,i,void 0)))throw new u("invalid_operation","Every opening corner must stay inside the outer boundary");if(Qt(a,i))throw new u("invalid_operation","Opening edges cannot cross the outer boundary");let r=o.holes??[],s=e.holeIndex??r.length;if(!Number.isInteger(s)||s<0||s>r.length||e.holeIndex!=null&&s>=r.length)throw new u("invalid_operation","Opening not found");for(let l=0;l<r.length;l++){if(l===e.holeIndex)continue;let d=r[l];if(Qt(a,d)||N(a[0],d,void 0)||N(d[0],a,void 0))throw new u("invalid_operation","Openings cannot overlap or contain one another")}let c=n.objects.filter(l=>l.id!==o.id&&l.type!=="section"&&N(F(l),a,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:s,vertexCount:a.length,excludedObjectIds:c.map(l=>l.id),excludedInventoryUnits:Te(n.objects.filter(l=>l.id!==o.id),a),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function mr(t,e){let n=Ee(t,e),{object:o}=Le(t,n.floorId,n.objectId);return o.holes??=[],e.holeIndex==null?o.holes.push(structuredClone(e.points)):o.holes[e.holeIndex]=structuredClone(e.points),{...n,changed:!0}}function on(t,e){let{target:n,object:o}=Le(t,e.floorId,e.objectId);if(!Number.isInteger(e.holeIndex)||e.holeIndex<0||e.holeIndex>=(o.holes?.length??0))throw new u("invalid_operation","Opening not found");let i=o.holes[e.holeIndex],a=n.objects.filter(r=>r.id!==o.id&&r.type!=="section"&&N(F(r),i,void 0));return{floorId:n.floorId,objectId:o.id,objectType:o.type,holeIndex:e.holeIndex,vertexCount:i.length,excludedObjectIds:a.map(r=>r.id),excludedInventoryUnits:Te(n.objects.filter(r=>r.id!==o.id),i),preservesExactOuterPath:o.type==="section"&&!!o.outlinePath}}function yr(t,e){let n=on(t,e),{object:o}=Le(t,n.floorId,n.objectId);return o.holes.splice(e.holeIndex,1),o.holes.length||delete o.holes,{...n,changed:!0}}function wr(t){let e=t.trim();if(!e||e.length>2e6||!/^(https:\/\/|data:image\/)/.test(e))throw new u("invalid_operation","Section view photo must be an HTTPS or data:image URL no larger than 2 MB");return e}function rn(t,e){let n=[...new Set(e)];if(!n.length)throw new u("invalid_operation","At least one section id is required");let o=n.map(r=>t.find(s=>s.type==="section"&&s.id===r)),i=n.filter((r,s)=>!o[s]);if(i.length)throw new u("object_not_found",`Unknown section id(s): ${i.join(", ")} on the selected floor. Call get_chart to list current section ids.`,{sectionIds:i});let a=o;return{requested:n,sections:a,logicalSectionIds:[...new Set(a.map(r=>r.logicalSectionId??r.id))]}}function an(t,e){let n=C(t,e.floorId),o=rn(n.objects,e.sectionIds),i=ge(Pe(t,n.floorId)),a=new Map(i.sections.map(g=>[g.id,g])),r=new Map(n.objects.map(g=>[g.id,g])),s=o.logicalSectionIds.flatMap(g=>a.get(g)?.objectIds??[]),c=new Set;for(let g of s){let b=r.get(g);if(b)if(b.type==="row"||b.type==="table")for(let f of Re(b).keys())c.add(f);else(b.type==="booth"||b.type==="gaArea")&&c.add(b.categoryKey)}let l=o.logicalSectionIds.every(g=>(a.get(g)?.seatCount??0)>0),d=o.logicalSectionIds.every(g=>a.get(g)?.objectIds.some(b=>{let f=r.get(b);return f?.type==="row"||f?.type==="table"||f?.type==="booth"})===!0);return{floorId:n.floorId,sectionIds:o.requested,logicalSectionIds:o.logicalSectionIds,objectIds:s,categoryApplicable:l,...l&&c.size===1?{categoryKey:[...c][0]}:{},categoryMixed:l&&c.size!==1,viewApplicable:d}}function xr(t,e){R(t,e.categoryKey);let n=an(t,e);if(!n.categoryApplicable)throw new u("invalid_operation","Every selected logical section must contain buyer inventory before a section category can be assigned",{logicalSectionIds:n.logicalSectionIds});let o=C(t,n.floorId),i=new Set(n.objectIds),a=!1,r=0;for(let s of o.objects){if(!i.has(s.id)||s.type!=="row"&&s.type!=="table"&&s.type!=="booth"&&s.type!=="gaArea"||(s.categoryKey!==e.categoryKey&&(s.categoryKey=e.categoryKey,a=!0),s.type!=="row"&&s.type!=="table"||!s.overrides?.length))continue;let c=s.overrides.flatMap(l=>{if(l.categoryKey===void 0)return[l];let d={...l};return delete d.categoryKey,r++,a=!0,Object.keys(d).some(g=>g!=="index")?[d]:[]});c.length?s.overrides=c:delete s.overrides}return{...n,changed:a,categoryKey:e.categoryKey,categoryMixed:!1,clearedSeatOverrideCount:r}}function Sr(t,e){let n=C(t,e.floorId),o=rn(n.objects,e.sectionIds),{requested:i}=o,a=structuredClone(e.patch),r=new Set(["label","displayLabel","entrance","viewFromSeatUrl","viewFromSeatMeta","labelPresentation","labelStyle","zone","elevation","height","rake","surfaceKind","color"]),s=Object.keys(a).filter(f=>!r.has(f));if(s.length)throw new u("invalid_operation",`Unsupported section metadata field(s): ${s.join(", ")}`);if(!Object.keys(a).length)throw new u("invalid_operation","At least one section metadata change is required");if(a.label!==void 0){if(a.label=a.label.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","label can be changed only for one section at a time");if(!a.label||a.label.length>80)throw new u("invalid_operation","Section labels must contain 1 to 80 characters")}if(a.displayLabel!==void 0&&a.displayLabel!==null){if(a.displayLabel=a.displayLabel.normalize("NFKC").trim(),i.length!==1)throw new u("invalid_operation","displayLabel can be changed only for one section at a time");if(!a.displayLabel||a.displayLabel.length>80)throw new u("invalid_operation","Section display labels must contain 1 to 80 characters")}if(a.entrance!==void 0&&a.entrance!==null&&(a.entrance=a.entrance.normalize("NFKC").trim(),a.entrance.length>40))throw new u("invalid_operation","Section entrance must be at most 40 characters");if(a.viewFromSeatUrl!==void 0&&a.viewFromSeatUrl!==null&&(a.viewFromSeatUrl=wr(a.viewFromSeatUrl)),a.labelPresentation?.position&&(!Number.isFinite(a.labelPresentation.position.x)||!Number.isFinite(a.labelPresentation.position.y)))throw new u("invalid_operation","Section label position must be finite");if(a.labelPresentation?.rotation!=null&&!Number.isFinite(a.labelPresentation.rotation))throw new u("invalid_operation","Section label rotation must be finite");if(a.labelPresentation!==void 0&&Ae(a.labelPresentation,"Section"),a.labelStyle!==void 0&&ae(a.labelStyle,"Section"),a.zone!==void 0&&a.zone!==null&&!(t.zones??[]).some(f=>f.id===a.zone))throw new u("object_not_found",`Unknown chart zone: ${a.zone}`,{zoneId:a.zone});if(a.elevation!==void 0&&(!Number.isInteger(a.elevation)||a.elevation<0||a.elevation>3))throw new u("invalid_operation","Section elevation must be an integer from 0 to 3");if(a.height!==void 0&&a.height!==null&&(!Number.isFinite(a.height)||a.height<0||a.height>120))throw new u("invalid_operation","Section height must be a number from 0 to 120 metres");if(a.rake!==void 0&&a.rake!==null&&(!Number.isFinite(a.rake)||a.rake<0||a.rake>45))throw new u("invalid_operation","Section rake must be a number from 0 to 45 degrees");if(a.surfaceKind!==void 0&&a.surfaceKind!==null&&a.surfaceKind!=="flat"&&a.surfaceKind!=="rakedRows")throw new u("invalid_operation","Section surfaceKind must be 'flat' or 'rakedRows'");a.color!==void 0&&a.color!==null&&(a.color=T(a.color,"Section color"));let c=a.displayLabel!==void 0||a.entrance!==void 0||a.viewFromSeatUrl!==void 0||a.viewFromSeatMeta!==void 0||a.labelStyle!==void 0||a.zone!==void 0,l=new Set(o.logicalSectionIds),d=c?n.objects.filter(f=>f.type==="section"&&l.has(f.logicalSectionId??f.id)):[],g=new Set,b=!1;for(let f of o.sections){let h=JSON.stringify(f);a.label!==void 0&&(f.label=a.label),a.labelPresentation===null?delete f.labelPresentation:a.labelPresentation!==void 0&&(f.labelPresentation=a.labelPresentation),a.elevation!==void 0&&(f.elevation=a.elevation);let y=x=>{f.physical3dProvenance&&(delete f.physical3dProvenance[x],Object.keys(f.physical3dProvenance).length===0&&delete f.physical3dProvenance)};a.height===null?(delete f.height,y("height")):a.height!==void 0&&(f.height=a.height,f.physical3dProvenance={...f.physical3dProvenance,height:{status:"confirmed",source:"user-review",note:"Section front-edge height reviewed through the shared Designer/Copilot operation."}}),a.rake===null?(delete f.rake,y("rake")):a.rake!==void 0&&(f.rake=a.rake,f.physical3dProvenance={...f.physical3dProvenance,rake:{status:"confirmed",source:"user-review",note:"Section rake reviewed through the shared Designer/Copilot operation."}}),a.surfaceKind===null?(delete f.surfaceKind,y("surfaceKind")):a.surfaceKind!==void 0&&(f.surfaceKind=a.surfaceKind,f.physical3dProvenance={...f.physical3dProvenance,surfaceKind:{status:"confirmed",source:"user-review",note:"Section surface behavior reviewed through the shared Designer/Copilot operation."}}),a.color===null?delete f.color:a.color!==void 0&&(f.color=a.color),JSON.stringify(f)!==h&&(b=!0,g.add(f.id))}for(let f of d){let h=JSON.stringify(f),y=f.viewFromSeatUrl;if(a.displayLabel===null?delete f.displayLabel:a.displayLabel!==void 0&&(f.displayLabel=a.displayLabel),a.entrance===null||a.entrance===""?delete f.entrance:a.entrance!==void 0&&(f.entrance=a.entrance),a.viewFromSeatUrl===null||a.viewFromSeatUrl===""?delete f.viewFromSeatUrl:a.viewFromSeatUrl!==void 0&&(f.viewFromSeatUrl=a.viewFromSeatUrl),!f.viewFromSeatUrl||a.viewFromSeatMeta===null?delete f.viewFromSeatMeta:a.viewFromSeatMeta!==void 0?f.viewFromSeatMeta=structuredClone(a.viewFromSeatMeta):a.viewFromSeatUrl!==void 0&&f.viewFromSeatUrl!==y&&delete f.viewFromSeatMeta,a.labelStyle!==void 0){let x=_e(f.labelPresentation,a.labelStyle);x?f.labelPresentation=x:delete f.labelPresentation}a.zone===null?delete f.zone:a.zone!==void 0&&(f.zone=a.zone),JSON.stringify(f)!==h&&(b=!0,g.add(f.id))}return{floorId:n.floorId,changed:b,sectionIds:i,affectedSectionIds:[...g]}}function sn(t,e){let n=C(t,e.floorId),o=n.objects.find(a=>a.type==="section"&&a.id===e.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${e.sectionId}`,{sectionId:e.sectionId});if(o.outlinePath)throw new u("invalid_operation",`Section ${o.id} has an exact path; polygon conversion requires a separate loss review`,{sectionId:o.id,representation:"exact-path"});if(!o.geometry)throw new u("invalid_operation",`Section ${o.id} is already a manual polygon`,{sectionId:o.id,representation:"manual-polygon"});let i=n.objects.filter(a=>a.id!==o.id&&a.type!=="section"&&N(F(a),o.outline,o.holes));return{floorId:n.floorId,sectionId:o.id,sectionLabel:o.label,source:{representation:"generated-polygon",generator:structuredClone(o.geometry)},target:{representation:"manual-polygon"},geometryChanged:!1,preserved:{stableId:!0,outlineVertexCount:o.outline.length,holeCount:o.holes?.length??0,memberObjectIds:i.map(a=>a.id),inventoryUnits:i.reduce((a,r)=>a+Q(r),0),durableReferenceSource:!!o.referenceSource,inventoryExclusionEvidence:!!o.referenceInventoryExclusion},removedFields:["geometry"]}}function Ir(t,e){let n=sn(t,e),i=C(t,n.floorId).objects.find(a=>a.type==="section"&&a.id===n.sectionId);return delete i.geometry,{...n,changed:!0}}function cn(t,e){let n=(...s)=>s.every(Number.isFinite),o,i=1,a=!1,r=!0;if(e.kind==="translate"){if(!n(e.dx,e.dy))throw new u("invalid_operation","Section translation must be finite");r=e.dx!==0||e.dy!==0,o=s=>({x:s.x+e.dx,y:s.y+e.dy})}else if(e.kind==="scale"){if(!n(e.factor)||e.factor<=0||e.factor>100)throw new u("invalid_operation","Section scale factor must be finite and greater than 0");r=e.factor!==1,i=e.factor;let s=F(t);o=c=>({x:s.x+(c.x-s.x)*e.factor,y:s.y+(c.y-s.y)*e.factor})}else if(e.kind==="rotate"){if(!n(e.degrees))throw new u("invalid_operation","Section rotation must be finite");r=(e.degrees%360+360)%360!==0;let c=e.degrees*Math.PI/180,l=Math.cos(c),d=Math.sin(c),g=F(t);o=b=>{let f=b.x-g.x,h=b.y-g.y;return{x:g.x+f*l-h*d,y:g.y+f*d+h*l}}}else{if(!n(e.coordinate))throw new u("invalid_operation","Section reflection coordinate must be finite");a=!0,o=e.axis==="h"?s=>({x:2*e.coordinate-s.x,y:s.y}):s=>({x:s.x,y:2*e.coordinate-s.y})}return r&&(t.outline=t.outline.map(o),t.sourceOutline&&(t.sourceOutline=t.sourceOutline.map(o)),t.outlinePath&&(t.outlinePath=Xe(t.outlinePath,o,i,a)),t.holes&&(t.holes=t.holes.map(s=>s.map(o)))),{changed:r,sectionId:t.id,representation:t.outlinePath?"exact-path":"polygon",outlineVertexCount:t.outline.length,holeCount:t.holes?.length??0,pathSegmentKinds:t.outlinePath?.segments.map(s=>s.kind)??[]}}function vr(t,e){let n=C(t,e.floorId),o=n.objects.find(i=>i.type==="section"&&i.id===e.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${e.sectionId}`,{sectionId:e.sectionId});return{floorId:n.floorId,...cn(o,e.transform)}}function Cr(t,e){let n=C(t,e.floorId),o=n.objects.find(s=>s.type==="section"&&s.id===e.sectionId);if(!o)throw new u("object_not_found",`Unknown section id: ${e.sectionId}`,{sectionId:e.sectionId});let i=structuredClone(e.path);if(!Ie(i))throw new u("invalid_operation","Exact section path is not finite, continuous, closed, or radius-correct");let a=qe(i),r=JSON.stringify(o.outlinePath)!==JSON.stringify(i)||JSON.stringify(o.outline)!==JSON.stringify(a)||o.sourceOutline!==void 0||o.cornerSmoothing!==void 0;return r&&(o.outlinePath=i,o.outline=a,delete o.geometry,delete o.sourceOutline,delete o.cornerSmoothing),{floorId:n.floorId,sectionId:o.id,changed:r,segmentKinds:i.segments.map(s=>s.kind),sampledVertexCount:a.length,holeCount:o.holes?.length??0}}function Pr(t){return t.geometry?null:t.sourceOutline?.length?t.sourceOutline:t.outlinePath?null:t.outline?.length?t.outline:null}function Or(t,e){return ln(t,{floorId:e.floorId,sectionIds:e.sectionIds,cornerSmoothing:e.strength})}function ln(t,e){let n=C(t,e.floorId);if(e.cornerSmoothing!==void 0&&!Number.isFinite(e.cornerSmoothing))throw new u("invalid_operation","Corner smoothing must be a number from 0 to 100");if(e.edgeCurvature!=null&&e.edgeCurvature.some(s=>!Number.isFinite(s)))throw new u("invalid_operation","Edge curvature values must be numbers from -100 to 100");let o=[...new Set(e.sectionIds)],i=new Set,a=new Map,r=!1;try{for(let s of o){let c=n.objects.find(p=>p.type==="section"&&p.id===s);if(!c||!Pr(c))continue;let d=structuredClone(c);a.set(c.id,{section:c,snapshot:d});let g=JSON.stringify(c),b=(c.sourceOutline??c.outline).map(p=>({...p})),f=Math.min(100,Math.max(0,e.cornerSmoothing??c.cornerSmoothing??0)),y=(e.edgeCurvature===void 0?c.edgeCurvature:e.edgeCurvature??void 0)?.map(p=>Math.min(100,Math.max(-100,p))),x=y?.some(p=>Math.abs(p)>.5)===!0,v=f>.5||x?At(b,{cornerSmoothing:f,...x?{edgeCurvature:y}:{}}):null;v?(c.sourceOutline=b,c.outlinePath=v,c.outline=qe(v),f>.5?c.cornerSmoothing=f:delete c.cornerSmoothing,x?c.edgeCurvature=[...y]:delete c.edgeCurvature):(c.outline=b,delete c.outlinePath,delete c.sourceOutline,delete c.cornerSmoothing,delete c.edgeCurvature);for(let p=0;p<(c.holes?.length??0);p+=1)Ee(t,{floorId:n.floorId,objectId:c.id,points:c.holes[p],holeIndex:p});JSON.stringify(c)!==g&&(r=!0,i.add(c.id))}}catch(s){for(let{section:c,snapshot:l}of a.values()){let d=c;for(let g of Object.keys(d))delete d[g];Object.assign(c,structuredClone(l))}throw s}return{floorId:n.floorId,changed:r,sectionIds:o,affectedSectionIds:[...i]}}var Ar=/^#?([\da-f]{3}|[\da-f]{6})$/i;function Ne(t){let e=Ar.exec((t??"").trim());if(!e)return null;let n=e[1].length===3?e[1].split("").map(i=>i+i).join(""):e[1],o=parseInt(n,16);return[o>>16&255,o>>8&255,o&255]}function dt(t){let e=t/255;return e<=.04045?e/12.92:((e+.055)/1.055)**2.4}function dn(t){return .2126*dt(t[0])+.7152*dt(t[1])+.0722*dt(t[2])}function De(t,e){let n=Ne(t),o=Ne(e);if(!n||!o)return null;let i=dn(n),a=dn(o);return(Math.max(i,a)+.05)/(Math.min(i,a)+.05)}var un=["butt","round","square"],fn=["miter","round","bevel"],gn=["none","arrow"];function ut(t){return t==="line"||t==="polyline"}function bn(t){let e=Ne(t);if(!e)return null;let n=f=>{let h=f/255;return h<=.04045?h/12.92:((h+.055)/1.055)**2.4},o=n(e[0]),i=n(e[1]),a=n(e[2]),r=(.4124*o+.3576*i+.1805*a)/.95047,s=(.2126*o+.7152*i+.0722*a)/1,c=(.0193*o+.1192*i+.9505*a)/1.08883,l=f=>f>.008856?Math.cbrt(f):7.787*f+16/116,d=l(r),g=l(s),b=l(c);return[116*g-16,500*(d-g),200*(g-b)]}function hn(t,e){let n=bn(t),o=bn(e);return!n||!o?null:Math.hypot(n[0]-o[0],n[1]-o[1],n[2]-o[2])}var _r=new Set(["companion","child","senior","student","membership","custom"]);function me(t){if(!t.length)throw new u("invalid_operation","A chart must have at least one category");let e=new Set,n=new Map,o=structuredClone(t);for(let i of o){let a=i.key.trim(),r=i.label.normalize("NFKC").trim();if(!a||a.length>160||e.has(a))throw new u("invalid_operation",`Category keys must be non-empty and unique: ${a}`,{categoryKey:a});if(e.add(a),!r||r.length>80)throw new u("invalid_operation",`Category labels must contain 1 to 80 characters: ${a}`,{categoryKey:a});let s=r.toLocaleLowerCase("en"),c=n.get(s);if(c)throw new u("duplicate_category_label",`Categories ${c} and ${a} share the same label`,{categoryKeys:[c,a],label:r});if(n.set(s,a),!/^#[0-9a-fA-F]{6}$/.test(i.color))throw new u("invalid_operation",`Category ${a} must use a six-digit hex color`,{categoryKey:a});if(i.price!=null&&(!Number.isFinite(i.price)||i.price<0||i.price>1e6))throw new u("invalid_operation",`Category ${a} price must be from 0 to 1000000`,{categoryKey:a});if(i.tiers!=null)if(!i.tiers.length)delete i.tiers;else{if(i.tiers.length>20)throw new u("invalid_operation",`Category ${a} supports at most 20 ticket tiers`);let l=new Set,d=new Set;for(let g of i.tiers){let b=g.id.trim(),f=g.name.normalize("NFKC").trim(),h=f.toLocaleLowerCase("en");if(!b||b.length>160||l.has(b))throw new u("invalid_operation",`Ticket tier ids must be non-empty and unique in category ${a}`,{categoryKey:a,tierId:b});if(!f||f.length>80||d.has(h))throw new u("invalid_operation",`Ticket tier names must be non-empty and unique in category ${a}`,{categoryKey:a,tierName:f});if(!Number.isFinite(g.price)||g.price<0||g.price>1e6)throw new u("invalid_operation",`Ticket tier ${b} price must be from 0 to 1000000`,{categoryKey:a,tierId:b});if(g.restriction!=null&&!_r.has(g.restriction))throw new u("invalid_operation",`Ticket tier ${b} has an unknown restriction`,{categoryKey:a,tierId:b});if(g.buyerMessage!=null){if(g.buyerMessage=g.buyerMessage.normalize("NFKC").trim(),!g.buyerMessage)delete g.buyerMessage;else if(g.buyerMessage.length>240)throw new u("invalid_operation",`Ticket tier ${b} buyer guidance must be at most 240 characters`,{categoryKey:a,tierId:b})}if(g.currency!=null&&(g.currency=g.currency.trim().toUpperCase(),!/^[A-Z]{3}$/.test(g.currency)))throw new u("invalid_operation",`Ticket tier ${b} must use a three-letter ISO currency`,{categoryKey:a,tierId:b});if(g.applicability!=null){let y=g.applicability.seatLabels?.map(v=>v.normalize("NFKC").trim()),x=g.applicability.accessibility;if(y&&(!y.length||y.length>1e4||y.some(v=>!v||v.length>160)||new Set(y).size!==y.length)||x&&(!x.length||x.some(v=>!ue.some(p=>p.key===v))||new Set(x).size!==x.length))throw new u("invalid_operation",`Ticket tier ${b} has invalid seat applicability`,{categoryKey:a,tierId:b});g.applicability={...y?{seatLabels:y}:{},...x?{accessibility:[...x]}:{}},!g.applicability.seatLabels&&!g.applicability.accessibility&&delete g.applicability}if(g.evidence!=null){if(!["public-host","public-event","user-confirmed"].includes(g.evidence.provenance)||typeof g.evidence.sourceDescription!="string")throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b});if(g.evidence.sourceDescription=g.evidence.sourceDescription.normalize("NFKC").trim(),!g.evidence.sourceDescription||g.evidence.sourceDescription.length>240||g.evidence.capturedAt!==void 0&&(g.evidence.capturedAt.length>40||!Number.isFinite(Date.parse(g.evidence.capturedAt))))throw new u("invalid_operation",`Ticket tier ${b} has invalid evidence provenance`,{categoryKey:a,tierId:b})}l.add(b),d.add(h)}}}return o}function yn(t,e){let n=new Set,o=structuredClone(t.categories);for(let r of e.updates){if(n.has(r.categoryKey))throw new u("invalid_operation",`Category ${r.categoryKey} may be updated only once`);n.add(r.categoryKey);let s=o.find(g=>g.key===r.categoryKey);if(!s)throw new u("category_not_found",`Unknown chart category: ${r.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:r.categoryKey});let c=structuredClone(r.patch),{tiers:l,...d}=c;typeof d.label=="string"&&(d.label=d.label.normalize("NFKC").trim()),typeof d.color=="string"&&(d.color=d.color.toLowerCase()),Object.assign(s,d),s.notForSale===!1&&delete s.notForSale,Object.prototype.hasOwnProperty.call(c,"tiers")&&(l==null?delete s.tiers:s.tiers=l?.map(g=>{let b={...g,id:g.id.trim(),name:g.name.normalize("NFKC").trim()};return g.buyerMessage?.trim()?b.buyerMessage=g.buyerMessage.normalize("NFKC").trim():delete b.buyerMessage,b}))}let i=me(o),a=JSON.stringify(i)!==JSON.stringify(t.categories);return a&&(t.categories=i),{changed:a,categoryKeys:[...n],categories:t.categories}}function Mr(t,e){let n=e.categoryKeys.map(c=>c.trim()),o=t.categories.map(c=>c.key);if(n.length!==o.length||new Set(n).size!==n.length)throw new u("invalid_operation","Category order must contain every stable category key exactly once",{categoryKeys:n,expectedCategoryKeys:o});let i=new Set(o),a=o.filter(c=>!n.includes(c)),r=n.filter(c=>!i.has(c));if(a.length||r.length)throw new u(r.length?"category_not_found":"invalid_operation","Category order must be an exact permutation of the current stable keys",{categoryKeys:n,missingCategoryKeys:a,unknownCategoryKeys:r});if(n.every((c,l)=>c===o[l]))return{changed:!1,categoryKeys:o,categories:t.categories};let s=new Map(t.categories.map(c=>[c.key,c]));return t.categories=me(n.map(c=>structuredClone(s.get(c)))),{changed:!0,categoryKeys:n,categories:t.categories}}var ft=["#e69f00","#56b4e9","#009e73","#f0e442","#0072b2","#d55e00","#cc79a7"];function pn(t){let e=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i.exec(t.trim());if(!e)return null;let n=e[1];return n.length===3&&(n=n.split("").map(o=>o+o).join("")),[parseInt(n.slice(0,2),16),parseInt(n.slice(2,4),16),parseInt(n.slice(4,6),16)]}function jr(t,e){let n=pn(t),o=pn(e);return!n||!o?1/0:(n[0]-o[0])**2+(n[1]-o[1])**2+(n[2]-o[2])**2}var Rr=3600;function wn(t,e,n=ft){return n.find(i=>t.every(a=>jr(i,a)>=Rr))??n[e%n.length]}function kr(t,e){let n=e?.palette??ft;if(!t.categories.length)return{changed:[],categories:t.categories};let o=new Map(t.categories.map(r=>[r.key,r.color.toLowerCase()])),i=t.categories.map((r,s)=>({categoryKey:r.key,patch:{color:n[s%n.length]}}));return yn(t,{updates:i}),{changed:t.categories.map(r=>({key:r.key,from:o.get(r.key),to:r.color})).filter(r=>r.from!==r.to),categories:t.categories}}function Fr(t,e){let n=e.color.trim().toLowerCase(),o=e.sourceDescription.normalize("NFKC").trim();if(!/^#[0-9a-f]{6}$/.test(n))throw new u("invalid_operation","Sampled category color must be a six-digit hex color");if(!o||o.length>240)throw new u("invalid_operation","Color confirmation evidence must contain 1 to 240 characters");let i=structuredClone(t.categories),a=i.find(c=>c.key===e.categoryKey);if(!a)throw new u("category_not_found",`Unknown chart category: ${e.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:e.categoryKey});a.color=n,a.referenceCategorySource&&(a.referenceCategorySource.outputColorEvidence="user-confirmed",a.referenceCategorySource.outputColorSourceDescription=o);let r=me(i),s=JSON.stringify(r)!==JSON.stringify(t.categories);return s&&(t.categories=r),{changed:s,category:t.categories.find(c=>c.key===e.categoryKey),categories:t.categories}}function xn(t,e){let n=new Set(t.categories.map(r=>r.key)),o="";for(let r=0;r<100;r++){let c=e.idFactory("cat").trim();if(c&&!n.has(c)){o=c;break}}if(!o)throw new u("id_generation_failed","Unable to allocate a unique category id");let i={key:o,label:e.label.normalize("NFKC").trim(),color:e.color.toLowerCase(),price:e.price,tiers:e.tiers?.map(r=>({...r,id:r.id.trim(),name:r.name.normalize("NFKC").trim()}))},a=me([...t.categories,i]);return t.categories=a,{changed:!0,category:a.find(r=>r.key===o),categories:a}}var Tr=["#e5484d","#a86b00","#8b5cf6","#d6336c","#4d7c0f","#dc2626","#c026d3"],Lr=26;function Er(t,e,n){let o=(1-Math.abs(2*n-1))*e,i=(t%360+360)%360/60,a=o*(1-Math.abs(i%2-1)),[r,s,c]=i<1?[o,a,0]:i<2?[a,o,0]:i<3?[0,o,a]:i<4?[0,a,o]:i<5?[a,0,o]:[o,0,a],l=n-o/2,d=g=>Math.round((g+l)*255).toString(16).padStart(2,"0");return`#${d(r)}${d(s)}${d(c)}`}function Nr(t,e,n){let o=r=>t.every(s=>{let c=hn(r,s);return c==null||c>=Lr}),i=r=>{let s=De(r,"#12151d"),c=De(r,"#ffffff");return(s??0)>=3||(c??0)>=3},a=e.find(r=>o(r)&&i(r));if(a)return a;for(let r=0;r<360;r+=12)for(let s of[.52,.44,.6]){let c=Er(r,.62,s);if(o(c)&&i(c))return c}return n}function gt(t,e){let n=je.find(i=>i.objectType===e).creationWord;return`${t.replace(/\s*[–-]\s*(Tables|Booths|Standing|Seats)$/i,"").trim()||t.trim()} \u2013 ${n}`}function Dr(t){let e=new Map;for(let n of $(t))for(let o of n.objects){let i=je.find(r=>r.objectType===o.type);if(!i)continue;let a=new Set;if(o.type==="row"||o.type==="table")for(let r of Re(o).keys())a.add(r);else"categoryKey"in o&&o.categoryKey&&a.add(o.categoryKey);for(let r of a){let s=e.get(r)??new Set;s.add(i.objectType),e.set(r,s)}}return e}function $r(t,e,n,o){let i=n,a=Dr(t),r=g=>{let b=a.get(g);return!b||b.size===0||b.size===1&&b.has(i)},s=t.categories.find(g=>g.key===e);if(s&&r(s.key))return s.key;if(!s){let g=t.categories.find(b=>{let f=a.get(b.key);return f?.size===1&&f.has(i)});if(g)return g.key}let c=s;if(!c)return mn(t,n,void 0,o);let l=gt(c.label,n),d=t.categories.find(g=>g.label.toLowerCase()===l.toLowerCase()&&r(g.key));return d?d.key:mn(t,n,c,o)}function mn(t,e,n,o){let i=je.find(h=>h.objectType===e),a=e==="gaArea"?"General Admission":i.creationWord,r=n?gt(n.label,e):a,s=o.palette??Tr,c=t.categories.map(h=>h.color),l=o.suggestColor?.(c.map(h=>h.toLowerCase()))??wn(c,t.categories.length),d=Nr(c,s,l),g=new Set(t.categories.map(h=>h.label.toLowerCase())),b=r;for(let h=2;g.has(b.toLowerCase());h+=1)b=`${r} ${h}`;let f=xn(t,{label:b,color:d,...n?.price!==void 0?{price:n.price}:{},...n?.tiers?.length?{tiers:n.tiers}:{},idFactory:o.idFactory});return t.categories=f.categories,f.category.key}function Kr(t,e){let n=new Set;for(let o of $(t))for(let i of o.objects)"categoryKey"in i&&i.categoryKey===e&&n.add(i.id),(i.type==="row"||i.type==="table")&&i.overrides?.some(a=>a.categoryKey===e)&&n.add(i.id);return[...n]}function Gr(t,e){let n=t.categories.find(a=>a.key===e.categoryKey);if(!n)throw new u("category_not_found",`Unknown chart category: ${e.categoryKey}. Call get_chart to list valid category keys.`,{categoryKey:e.categoryKey});if(t.categories.length<=1)throw new u("invalid_operation","A chart must retain at least one category");let o=Kr(t,e.categoryKey);if(o.length)throw new u("category_in_use",`Category ${e.categoryKey} is still assigned to chart inventory`,{categoryKey:e.categoryKey,objectIds:o});if(n.referenceCategorySource)throw new u("reference_category_protected",`Reference-backed category ${e.categoryKey} cannot be deleted through a generic catalog operation`,{categoryKey:e.categoryKey});let i=me(t.categories.filter(a=>a.key!==e.categoryKey));return t.categories=i,{changed:!0,categoryKey:e.categoryKey,categories:i}}var zr=["background","seatLabelColor","rowLabelColor","selectionColor","decorFill","textColor","accent","accentInk"],Sn=.7,In=1.6;function Br(t,e){let n=e.patch;if(!Object.keys(n).length)throw new u("invalid_operation","At least one theme field is required");let o=JSON.stringify(t.theme??null),i={...t.theme??{}};for(let a of zr){let r=n[a];r===null?delete i[a]:r!==void 0&&(i[a]=T(r,`Theme ${a}`))}if(n.fontFamily===null)delete i.fontFamily;else if(n.fontFamily!==void 0){let a=n.fontFamily.normalize("NFKC").trim();if(!a||a.length>120)throw new u("invalid_operation","Theme fontFamily must contain 1 to 120 characters");i.fontFamily=a}if(n.seatScale===null)delete i.seatScale;else if(n.seatScale!==void 0){if(!Number.isFinite(n.seatScale)||n.seatScale<Sn||n.seatScale>In)throw new u("invalid_operation",`Theme seatScale must be from ${Sn} to ${In}`);i.seatScale=n.seatScale}if(n.logoUrl===null)delete i.logoUrl;else if(n.logoUrl!==void 0){let a=n.logoUrl.trim();if(!/^(https:\/\/|data:image\/)/.test(a)||a.length>2e6)throw new u("invalid_operation","Theme logoUrl must be an https or data:image reference");i.logoUrl=a}if(n.brandName===null)delete i.brandName;else if(n.brandName!==void 0){let a=n.brandName.normalize("NFKC").trim();if(!a||a.length>80)throw new u("invalid_operation","Theme brandName must contain 1 to 80 characters");i.brandName=a}return n.hideBadge===null||n.hideBadge===!1?delete i.hideBadge:n.hideBadge===!0&&(i.hideBadge=!0),t.theme=Object.keys(i).length?i:void 0,{changed:JSON.stringify(t.theme??null)!==o,theme:t.theme??null}}function Ur(t,e){let n=e.url===null?null:e.url.trim();if(n!==null&&(!/^(https:\/\/|data:image\/)/.test(n)||n.length>2e6))throw new u("invalid_operation","View-from-seat photo must be an https or data:image reference");let o=n??void 0;if(e.floorId!==void 0){let s=t.floors?.find(g=>g.id===e.floorId);if(!s)throw new u("invalid_operation",`Unknown floor: ${e.floorId}`);let c=(s.viewFromSeatUrl??void 0)===o,l=o?e.metadata===null?void 0:e.metadata??(c?s.viewFromSeatMeta:void 0):void 0,d=!c||JSON.stringify(s.viewFromSeatMeta??null)!==JSON.stringify(l??null);return s.viewFromSeatUrl=o,s.viewFromSeatMeta=l,{changed:d,scope:"floor",floorId:e.floorId,url:s.viewFromSeatUrl??null}}let i=(t.viewFromSeatUrl??void 0)===o,a=o?e.metadata===null?void 0:e.metadata??(i?t.viewFromSeatMeta:void 0):void 0,r=!i||JSON.stringify(t.viewFromSeatMeta??null)!==JSON.stringify(a??null);return t.viewFromSeatUrl=o,t.viewFromSeatMeta=a,{changed:r,scope:"venue",url:t.viewFromSeatUrl??null}}function Hr(t,e){let n=Pe(t,e.floorId),o=$t(n),i=e.placement==="auto"||e.placement==null?"rear":e.placement,a=96;return i==="front"?{x:o.x+o.width/2,y:o.y-a-e.height/2}:i==="left"?{x:o.x-a-e.width/2,y:o.y+o.height/2}:i==="right"?{x:o.x+o.width+a+e.width/2,y:o.y+o.height/2}:{x:o.x+o.width/2,y:o.y+o.height+a+e.height/2}}function $e(t,e){R(t,e.categoryKey);let n=(...d)=>d.every(Number.isFinite);if(!n(e.center.x,e.center.y,e.innerRadius,e.rowGap,e.startAngle,e.endAngle,e.seatPitch))throw new u("invalid_operation","Arc/Fan geometry values must be finite");if(!Number.isInteger(e.rowCount)||e.rowCount<1||e.rowCount>100)throw new u("invalid_operation","Arc/Fan rowCount must be an integer from 1 to 100");if(e.innerRadius<40||e.innerRadius>2e4||e.rowGap<12||e.rowGap>500)throw new u("invalid_operation","Arc/Fan radius must be 40\u201320000 and row gap 12\u2013500");let o=e.endAngle-e.startAngle;if(Math.abs(o)<5||Math.abs(o)>320)throw new u("invalid_operation","Arc/Fan sweep must be from 5\xB0 to 320\xB0");if(e.seatPitch<14||e.seatPitch>80)throw new u("invalid_operation","Arc/Fan seat pitch must be from 14 to 80 chart units");let i=e.fit??"seat-pitch";if(i==="fixed-count"&&(!Number.isInteger(e.seatsPerRow)||e.seatsPerRow<2||e.seatsPerRow>300))throw new u("invalid_operation","Fixed Arc/Fan rows require seatsPerRow from 2 to 300");let a=e.taperDegrees??0,r=e.skewDegrees??0;if(!n(a,r)||Math.abs(a)>120||Math.abs(r)>180)throw new u("invalid_operation","Arc/Fan taper must be within \xB1120\xB0 and skew within \xB1180\xB0");let s={left:e.aisleGaps?.left??0,center:e.aisleGaps?.center??0,right:e.aisleGaps?.right??0};if(!n(s.left,s.center,s.right)||Object.values(s).some(d=>d<0||d>200))throw new u("invalid_operation","Arc/Fan aisle widths must be from 0 to 200 chart units");let l=C(t,e.floorId).objects.filter(d=>d.type==="row").length;return{...e,fit:i,facing:e.facing??"inward",taperDegrees:a,skewDegrees:r,aisleGaps:s,rowLabelStart:e.rowLabelStart??l,seatLabelStart:e.seatLabelStart??1}}function Vr(t,e,n){let o=n*X;return{x:t.x+e*Math.sin(o),y:t.y+e*Math.cos(o)}}function Jr(t,e,n,o){let i=Math.abs(o-n)*X,a=[["left",.25],["center",.5],["right",.75]].flatMap(([l,d])=>{let g=t.aisleGaps[l];if(!g)return[];let b=g/e/i/2;return[[Math.max(0,d-b),Math.min(1,d+b)]]}).sort((l,d)=>l[0]-d[0]),r=[];for(let l of a){let d=r[r.length-1];d&&l[0]<=d[1]?d[1]=Math.max(d[1],l[1]):r.push([...l])}let s=[],c=0;for(let l of r)l[0]-c>1e-6&&s.push([c,l[0]]),c=Math.max(c,l[1]);return 1-c>1e-6&&s.push([c,1]),s.filter(([l,d])=>e*i*(d-l)>=t.seatPitch*.75)}function qr(t,e){let n=t.length*2;if(e<n)throw new u("invalid_operation",`Fixed seat count must be at least ${n} for ${t.length} aisle-separated row segments`);let o=e-n,i=t.reduce((c,l)=>c+l,0),a=t.map(c=>o*c/i),r=a.map(c=>2+Math.floor(c)),s=e-r.reduce((c,l)=>c+l,0);return a.map((c,l)=>({index:l,fraction:c-Math.floor(c)})).sort((c,l)=>l.fraction-c.fraction||c.index-l.index).forEach(({index:c})=>{s-- >0&&r[c]++}),r}function Ke(t,e,n){let o=[];for(let i=0;i<t.rowCount;i++){let a=t.rowCount===1?0:i/(t.rowCount-1),r=t.innerRadius+i*t.rowGap,s=Math.sign(t.endAngle-t.startAngle)||1,c=t.startAngle+s*t.taperDegrees*a+t.skewDegrees*a,l=t.endAngle-s*t.taperDegrees*a+t.skewDegrees*a;if(Math.sign(l-c)!==Math.sign(t.endAngle-t.startAngle)||Math.abs(l-c)<5)throw new u("invalid_operation",`Arc/Fan taper collapses row ${i+1} below a 5\xB0 sweep`);let d=Jr(t,r,c,l);if(!d.length)throw new u("invalid_operation",`Arc/Fan aisles leave no usable span in row ${i+1}`);t.facing==="outward"&&(d=d.slice().reverse());let g=d.map(([h,y])=>r*Math.abs(l-c)*X*(y-h)),b=t.fit==="fixed-count"?qr(g,t.seatsPerRow):g.map(h=>Math.max(2,Math.round(h/t.seatPitch)+1)),f=t.seatLabelStart;d.forEach(([h,y],x)=>{let v=c+(l-c)*h,p=c+(l-c)*y;t.facing==="outward"&&([v,p]=[p,v]);let m=b[x];if(m>300)throw new u("invalid_operation","An Arc/Fan row segment cannot exceed 300 seats");let w=Math.abs(p-v)*X/(m-1),S=2*r*Math.sin(w/2),I={type:"row",id:n(i,x),label:V(t.rowLabelStart+i),origin:Vr(t.center,r,v),rotation:-v,curve:p-v,seatCount:m,seatSpacing:S,categoryKey:t.categoryKey,seatLabelStart:f,arcFanGeneration:{kind:"arc-fan-v1",groupId:e,center:{...t.center},innerRadius:t.innerRadius,rowCount:t.rowCount,rowGap:t.rowGap,startAngle:t.startAngle,endAngle:t.endAngle,seatPitch:t.seatPitch,fit:t.fit,...t.seatsPerRow!=null?{seatsPerRow:t.seatsPerRow}:{},facing:t.facing,taperDegrees:t.taperDegrees,skewDegrees:t.skewDegrees,aisleGaps:{...t.aisleGaps},rowLabelStart:t.rowLabelStart,seatLabelStart:t.seatLabelStart,rowIndex:i,segmentIndex:x}};o.push(I),f+=m})}return o}function bt(t,e){let n=$e(t,e),o=C(t,e.floorId),i=Ke(n,"preview-arc-fan",(c,l)=>`preview-fan-${c}-${l}`),a=i.map(c=>c.seatSpacing),r=Math.max(...a.map(c=>Math.abs(c-n.seatPitch))),s=[];return r>n.seatPitch*.12&&s.push(`Seat fitting deviates from the requested pitch by up to ${r.toFixed(1)} chart units`),i.length>n.rowCount*3&&s.push("Three aisles split each logical row into four separately editable segments"),{floorId:o.floorId,rows:i,logicalRowCount:n.rowCount,rowSegmentCount:i.length,totalSeats:i.reduce((c,l)=>c+l.seatCount,0),innerRadius:n.innerRadius,outerRadius:n.innerRadius+(n.rowCount-1)*n.rowGap,minSeatSpacing:Math.min(...a),maxSeatSpacing:Math.max(...a),maxPitchDeviation:r,aisleCount:Object.values(n.aisleGaps).filter(c=>c>0).length,warnings:s}}function Xr(t,e){let n=$e(t,e),o=C(t,e.floorId),i=new Set,a=M(t,"fan",e.idFactory,i),r=Ke(n,a,()=>M(t,"r",e.idFactory,i)),s=bt(t,e),c=null,l=e.sectionLabel?.normalize("NFKC").trim(),d=null;if(l){if(l.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let g=Z(r);g&&(c=M(t,"sec",e.idFactory,i),d={type:"section",id:c,label:l,outline:g,arcFanGroupId:a})}return o.objects.push(...r,...d?[d]:[]),{floorId:o.floorId,rowIds:r.map(g=>g.id),sectionId:c,groupId:a,logicalRowCount:s.logicalRowCount,rowSegmentCount:s.rowSegmentCount,totalSeats:s.totalSeats,innerRadius:s.innerRadius,outerRadius:s.outerRadius,minSeatSpacing:s.minSeatSpacing,maxSeatSpacing:s.maxSeatSpacing,maxPitchDeviation:s.maxPitchDeviation,aisleCount:s.aisleCount,warnings:s.warnings}}function vn(t,e){let n=C(t,e.floorId),o=n.objects.filter(g=>g.type==="row"&&g.arcFanGeneration?.groupId===e.groupId);if(!o.length)throw new u("object_not_found",`Unknown Arc/Fan group: ${e.groupId}`,{groupId:e.groupId});let i=o[0].arcFanGeneration,a=g=>{let b=g.arcFanGeneration;return JSON.stringify({center:b.center,innerRadius:b.innerRadius,rowCount:b.rowCount,rowGap:b.rowGap,startAngle:b.startAngle,endAngle:b.endAngle,seatPitch:b.seatPitch,fit:b.fit,seatsPerRow:b.seatsPerRow,facing:b.facing,taperDegrees:b.taperDegrees,skewDegrees:b.skewDegrees,aisleGaps:b.aisleGaps,rowLabelStart:b.rowLabelStart,seatLabelStart:b.seatLabelStart})};if(o.some(g=>a(g)!==a(o[0])))throw new u("invalid_operation","Arc/Fan group provenance no longer agrees across all row segments",{groupId:e.groupId});let r=n.objects.find(g=>g.type==="section"&&g.arcFanGroupId===e.groupId),s={floorId:n.floorId,center:{...i.center},innerRadius:i.innerRadius,rowCount:i.rowCount,rowGap:i.rowGap,startAngle:i.startAngle,endAngle:i.endAngle,seatPitch:i.seatPitch,fit:i.fit,seatsPerRow:i.seatsPerRow,facing:i.facing,taperDegrees:i.taperDegrees,skewDegrees:i.skewDegrees,aisleGaps:{...i.aisleGaps},categoryKey:o[0].categoryKey,rowLabelStart:i.rowLabelStart,seatLabelStart:i.seatLabelStart,sectionLabel:r?.label},c=$e(t,s),l=new Set(Ke(c,e.groupId,(g,b)=>`${g}:${b}`).map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`)),d=new Set(o.map(g=>`${g.arcFanGeneration.rowIndex}:${g.arcFanGeneration.segmentIndex}`));if(l.size!==d.size||[...l].some(g=>!d.has(g)))throw new u("invalid_operation","Arc/Fan group is incomplete and cannot be regenerated safely",{groupId:e.groupId});return s}function Yr(t,e){vn(t,{floorId:e.floorId,groupId:e.groupId});let n=$e(t,e),o=C(t,e.floorId),i=o.objects.filter(y=>y.type==="row"&&y.arcFanGeneration?.groupId===e.groupId),a=o.objects.find(y=>y.type==="section"&&y.arcFanGroupId===e.groupId),r=new Map(i.map(y=>[`${y.arcFanGeneration.rowIndex}:${y.arcFanGeneration.segmentIndex}`,y.id])),s=new Set,c=Ke(n,e.groupId,(y,x)=>r.get(`${y}:${x}`)??M(t,"r",e.idFactory,s)),l=bt(t,e),d=e.sectionLabel?.normalize("NFKC").trim(),g=null;if(d){if(d.length>80)throw new u("invalid_operation","Arc/Fan section label must contain at most 80 characters");let y=Z(c);y&&(g={type:"section",id:a?.id??M(t,"sec",e.idFactory,s),label:d,outline:y,arcFanGroupId:e.groupId})}let b=new Set([...i.map(y=>y.id),...a?[a.id]:[]]),f=Math.min(...o.objects.map((y,x)=>b.has(y.id)?x:1/0)),h=o.objects.filter(y=>!b.has(y.id));return h.splice(Number.isFinite(f)?f:h.length,0,...c,...g?[g]:[]),o.objects.splice(0,o.objects.length,...h),{floorId:o.floorId,rowIds:c.map(y=>y.id),sectionId:g?.id??null,groupId:e.groupId,logicalRowCount:l.logicalRowCount,rowSegmentCount:l.rowSegmentCount,totalSeats:l.totalSeats,innerRadius:l.innerRadius,outerRadius:l.outerRadius,minSeatSpacing:l.minSeatSpacing,maxSeatSpacing:l.maxSeatSpacing,maxPitchDeviation:l.maxPitchDeviation,aisleCount:l.aisleCount,warnings:l.warnings}}function Wr(t){let e=new Set(J(t).filter(o=>o.type==="row"||o.type==="table"||o.type==="booth").map(o=>o.label).filter(o=>typeof o=="string")),n=0;return()=>{for(;e.has(V(n));)n+=1;let o=V(n);return e.add(o),n+=1,o}}function Cn(t){return JSON.stringify(["row-block-v1",t.style,t.origin.x,t.origin.y,t.rotation,t.rowCount,t.seatsPerRow,t.rowGap,t.seatSpacing,t.curve])}function Zr(t,e){if(R(t,e.categoryKey),!Number.isInteger(e.rowCount)||e.rowCount<1||e.rowCount>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(e.seatsPerRow)||e.seatsPerRow<1||e.seatsPerRow>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");let n=e.rowGap??28,o=e.seatSpacing??24;if(!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<=0)throw new u("invalid_operation","Row and seat spacing must be positive finite values");if(e.rotation!==void 0&&!Number.isFinite(e.rotation))throw new u("invalid_operation","rotation must be a finite number of degrees");let i=C(t,e.floorId),a=new Set,r=Wr(t),s=ct(e.rotation??0),c=e.curve??0,l=e.style,d=l?M(t,"rowblock",e.idFactory,a):void 0,g=l?Cn({style:l,origin:e.origin,rotation:s,rowCount:e.rowCount,seatsPerRow:e.seatsPerRow,rowGap:n,seatSpacing:o,curve:c}):void 0,b={x:Math.cos(s*q),y:Math.sin(s*q)},f={x:-b.y,y:b.x},h=Array.from({length:e.rowCount},(v,p)=>{let m=l==="intertwined"&&p%2===1?o/2:0,w={type:"row",id:M(t,"r",e.idFactory,a),label:r(),origin:{x:e.origin.x+f.x*p*n+b.x*m,y:e.origin.y+f.y*p*n+b.y*m},rotation:s,curve:c,seatCount:e.seatsPerRow,seatSpacing:o,categoryKey:e.categoryKey};return l&&d&&g&&(w.rowBlockGeneration={kind:"row-block-v1",groupId:d,style:l,rowIndex:p,rowCount:e.rowCount,seatsPerRow:e.seatsPerRow,origin:{...e.origin},rotation:s,rowGap:n,seatSpacing:o,curve:c,signature:g}),w});i.objects.push(...h);let y=null,x=e.sectionLabel?.trim();if(x){let v=Z(h);if(v){let p={type:"section",id:M(t,"sec",e.idFactory,a),label:x,outline:v};i.objects.push(p),y=p.id}}return{floorId:i.floorId,rowIds:h.map(v=>v.id),sectionId:y,createdIds:[...h.map(v=>v.id),...y?[y]:[]]}}function Pn(t,e){let n=new Set(J(t).filter(i=>i.type==="row"||i.type==="table"||i.type==="booth").map(i=>i.label).filter(i=>typeof i=="string")),o=1;return()=>{for(;n.has(`${e}${o}`);)o+=1;let i=`${e}${o}`;return n.add(i),o+=1,i}}function Qr(t,e){let n=new Set(J(t).filter(i=>i.type==="gaArea").map(i=>i.label));if(!n.has(e))return e;let o=2;for(;n.has(`${e} ${o}`);)o+=1;return`${e} ${o}`}var ei=456;function On(t){let e=Math.sqrt(Math.max(1,t)*ei);return{width:Math.round(e*1.027),height:Math.round(e/1.027)}}function ti(t,e){if(R(t,e.categoryKey),!Number.isInteger(e.capacity)||e.capacity<1)throw new u("invalid_operation","capacity must be a positive integer");if(!Number.isFinite(e.center.x)||!Number.isFinite(e.center.y))throw new u("invalid_operation","GA area center must be finite");let n=C(t,e.floorId),o=new Set,{width:i,height:a}=On(e.capacity),r=Qr(t,(e.label??"General Admission").trim()||"General Admission"),s={type:"gaArea",id:M(t,"ga",e.idFactory,o),label:r,...e.displayLabel?.trim()?{displayLabel:e.displayLabel.trim()}:{},points:[{x:e.center.x-i/2,y:e.center.y-a/2},{x:e.center.x+i/2,y:e.center.y-a/2},{x:e.center.x+i/2,y:e.center.y+a/2},{x:e.center.x-i/2,y:e.center.y+a/2}],capacity:e.capacity,categoryKey:e.categoryKey};return n.objects.push(s),{floorId:n.floorId,gaAreaId:s.id,label:r,createdIds:[s.id]}}function ni(t,e){if(R(t,e.categoryKey),!Number.isInteger(e.tableRows)||e.tableRows<1||e.tableRows>20||!Number.isInteger(e.tableColumns)||e.tableColumns<1||e.tableColumns>20)throw new u("invalid_operation","tableRows and tableColumns must be integers from 1 to 20");if(!Number.isInteger(e.seatsPerTable)||e.seatsPerTable<1||e.seatsPerTable>20)throw new u("invalid_operation","seatsPerTable must be an integer from 1 to 20");let n=e.gapX??155,o=e.gapY??150;if(!Number.isFinite(n)||n<80||!Number.isFinite(o)||o<80)throw new u("invalid_operation","Table spacing must be at least 80 chart units");if(!Number.isFinite(e.center.x)||!Number.isFinite(e.center.y))throw new u("invalid_operation","Table array center must be finite");let i=C(t,e.floorId),a=new Set,r=Pn(t,"T"),s=[];for(let c=0;c<e.tableRows;c+=1)for(let l=0;l<e.tableColumns;l+=1)s.push({type:"table",id:M(t,"t",e.idFactory,a),label:r(),center:{x:e.center.x+(l-(e.tableColumns-1)/2)*n,y:e.center.y+(c-(e.tableRows-1)/2)*o},rotation:0,categoryKey:e.categoryKey,seatCount:e.seatsPerTable,...e.shape==="round"?{shape:"round",radius:46}:{shape:"rect",sides:["top","bottom"],width:120,height:58}});return i.objects.push(...s),{floorId:i.floorId,tableIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function oi(t,e){if(R(t,e.categoryKey),!Number.isInteger(e.boothRows)||e.boothRows<1||e.boothRows>30||!Number.isInteger(e.boothColumns)||e.boothColumns<1||e.boothColumns>30)throw new u("invalid_operation","boothRows and boothColumns must be integers from 1 to 30");let n=e.gapX??88,o=e.gapY??82;if(!Number.isFinite(n)||n<62||!Number.isFinite(o)||o<52)throw new u("invalid_operation","Booth spacing must clear the 62\xD752 booth footprint");if(!Number.isFinite(e.center.x)||!Number.isFinite(e.center.y))throw new u("invalid_operation","Booth array center must be finite");let i=C(t,e.floorId),a=new Set,r=Pn(t,"B"),s=[];for(let c=0;c<e.boothRows;c+=1)for(let l=0;l<e.boothColumns;l+=1)s.push({type:"booth",id:M(t,"booth",e.idFactory,a),label:r(),center:{x:e.center.x+(l-(e.boothColumns-1)/2)*n,y:e.center.y+(c-(e.boothRows-1)/2)*o},width:62,height:52,rotation:0,categoryKey:e.categoryKey});return i.objects.push(...s),{floorId:i.floorId,boothIds:s.map(c=>c.id),createdIds:s.map(c=>c.id)}}function ri(t,e){let n=C(t,e.floorId),o=[...new Set(e.rowIds)];if(o.length<2||o.length>64)throw new u("invalid_operation","A segmented row requires 2 to 64 ordered component rows");if(e.boundaries.length!==o.length-1||e.boundaries.some(b=>b!=="continuous"&&b!=="break"))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more segmented-row components do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(b=>b.segmentedRow);if(s.length)throw new u("invalid_operation","Ungroup existing segmented rows before combining their components again",{rowIds:s.map(b=>b.id)});let c=(e.displayLabel??r[0].displayLabel??r[0].label).normalize("NFKC").trim();if(!c||c.length>80)throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let l=new Set(n.objects.flatMap(b=>b.type==="row"?[b.segmentedRow?.groupId,b.rowBlockGeneration?.groupId].filter(f=>!!f):[])),d="";for(let b=0;b<100;b+=1){let f=e.idFactory("rowgroup");if(f&&!l.has(f)){d=f;break}}if(!d)throw new u("id_generation_failed","Unable to allocate a segmented-row group id");let g=r[0];return r.forEach((b,f)=>{b.segmentedRow={kind:"segmented-row-v1",groupId:d,componentIndex:f,componentCount:r.length,boundaryBefore:f===0?"start":e.boundaries[f-1],displayLabel:c,...g.displayType?{displayType:g.displayType}:{},...g.labelPresentation?{labelPresentation:structuredClone(g.labelPresentation)}:{},...g.viewFromSeatUrl?{viewFromSeatUrl:g.viewFromSeatUrl}:{},...g.viewFromSeatMeta?{viewFromSeatMeta:structuredClone(g.viewFromSeatMeta)}:{},...g.confidenceEvidence?{confidenceEvidence:structuredClone(g.confidenceEvidence)}:{}}}),{floorId:n.floorId,groupId:d,rowIds:o,changed:!0}}function ii(t,e){let n=C(t,e.floorId),o=e.groupId?n.objects.find(s=>s.type==="row"&&s.segmentedRow?.groupId===e.groupId):n.objects.find(s=>s.type==="row"&&s.id===e.rowId),i=e.groupId??o?.segmentedRow?.groupId;if(!i)throw new u("object_not_found","The segmented row does not exist on the selected floor");let a=n.objects.filter(s=>s.type==="row"&&s.segmentedRow?.groupId===i);if(!a.length)throw new u("object_not_found","The segmented row does not exist on the selected floor");let r=a.sort((s,c)=>s.segmentedRow.componentIndex-c.segmentedRow.componentIndex).map(s=>s.id);for(let s of a)delete s.segmentedRow;return{floorId:n.floorId,groupId:i,rowIds:r,changed:!0}}function ai(t,e){let n=C(t,e.floorId),o=n.objects.filter(r=>r.type==="row"&&r.segmentedRow?.groupId===e.groupId).sort((r,s)=>r.segmentedRow.componentIndex-s.segmentedRow.componentIndex);if(o.length<2)throw new u("object_not_found","The segmented row is incomplete or missing on the selected floor");if(e.boundaries&&(e.boundaries.length!==o.length-1||e.boundaries.some(r=>r!=="continuous"&&r!=="break")))throw new u("invalid_operation","Declare one continuous or break boundary between every pair of row components");let i=e.displayLabel?.normalize("NFKC").trim();if(i!==void 0&&(!i||i.length>80))throw new u("invalid_operation","Segmented-row display label must contain 1 to 80 characters");let a=JSON.stringify(o.map(r=>r.segmentedRow));return o.forEach((r,s)=>{let c=r.segmentedRow,l=c.viewFromSeatUrl;i!==void 0&&(c.displayLabel=i),e.boundaries&&s>0&&(c.boundaryBefore=e.boundaries[s-1]),e.smoothing!==void 0&&(c.smoothing=e.smoothing||void 0),e.viewFromSeatUrl===null?delete c.viewFromSeatUrl:e.viewFromSeatUrl!==void 0&&(c.viewFromSeatUrl=e.viewFromSeatUrl),!c.viewFromSeatUrl||e.viewFromSeatMeta===null?delete c.viewFromSeatMeta:e.viewFromSeatMeta!==void 0?c.viewFromSeatMeta=structuredClone(e.viewFromSeatMeta):e.viewFromSeatUrl!==void 0&&c.viewFromSeatUrl!==l&&delete c.viewFromSeatMeta}),{floorId:n.floorId,groupId:e.groupId,rowIds:o.map(r=>r.id),changed:JSON.stringify(o.map(r=>r.segmentedRow))!==a}}function si(t,e){let n=C(t,e.floorId),o=n.objects.filter(O=>O.type==="row"&&O.rowBlockGeneration?.groupId===e.groupId).sort((O,G)=>O.rowBlockGeneration.rowIndex-G.rowBlockGeneration.rowIndex),i=o[0]?.rowBlockGeneration;if(!i||o.length!==i.rowCount||o.some((O,G)=>{let j=O.rowBlockGeneration;return j.kind!=="row-block-v1"||j.rowIndex!==G||j.signature!==i.signature||JSON.stringify(j)!==JSON.stringify({...i,rowIndex:G})}))throw new u("invalid_operation","This row block was edited manually or is incomplete; repair or recreate it before regeneration",{groupId:e.groupId});let a=JSON.stringify(o),r=e.style??i.style,s=e.rowCount??i.rowCount,c=e.seatsPerRow??i.seatsPerRow,l=e.rowGap??i.rowGap,d=e.seatSpacing??i.seatSpacing,g=e.curve??i.curve,b=Number.isFinite(e.rotation??i.rotation)?ct(e.rotation??i.rotation):e.rotation??i.rotation,f=e.origin?{...e.origin}:{...i.origin};if(!Number.isInteger(s)||s<1||s>100)throw new u("invalid_operation","rowCount must be an integer from 1 to 100");if(!Number.isInteger(c)||c<1||c>300)throw new u("invalid_operation","seatsPerRow must be an integer from 1 to 300");if(![l,d].every(O=>Number.isFinite(O)&&O>0)||!Number.isFinite(g)||!Number.isFinite(b)||!Number.isFinite(f.x)||!Number.isFinite(f.y))throw new u("invalid_operation","Row-block geometry must use positive spacing and finite origin, rotation, and curve values");let h=Cn({style:r,origin:f,rotation:b,rowCount:s,seatsPerRow:c,rowGap:l,seatSpacing:d,curve:g}),y={x:Math.cos(b*q),y:Math.sin(b*q)},x={x:-y.y,y:y.x},v=new Map(o.map(O=>[O.rowBlockGeneration.rowIndex,O])),p=new Set,m=new Set(n.objects.filter(O=>O.type==="row").filter(O=>!o.includes(O)).map(O=>O.label)),w=n.objects.filter(O=>O.type==="row").length,S=()=>{for(;m.has(V(w));)w+=1;let O=V(w);return m.add(O),w+=1,O},I=[],A=[];for(let O=0;O<s;O+=1){let G=r==="intertwined"&&O%2===1?d/2:0,j=v.get(O);j||(j={type:"row",id:M(t,"r",e.idFactory,p),label:S(),origin:{...f},rotation:b,curve:g,seatCount:c,seatSpacing:d,categoryKey:o[0].categoryKey},A.push(j.id)),j.origin={x:f.x+x.x*O*l+y.x*G,y:f.y+x.y*O*l+y.y*G},j.rotation=b,j.curve=g,j.seatCount=c,j.seatSpacing=d,delete j.path,delete j.arcFanGeneration,j.overrides&&(j.overrides=j.overrides.filter(He=>He.index<c),j.overrides.length||delete j.overrides),j.rowBlockGeneration={kind:"row-block-v1",groupId:e.groupId,style:r,rowIndex:O,rowCount:s,seatsPerRow:c,origin:{...f},rotation:b,rowGap:l,seatSpacing:d,curve:g,signature:h},I.push(j)}let D=o.slice(s).map(O=>O.id),L=Math.min(...o.map(O=>n.objects.indexOf(O))),B=new Set(o.map(O=>O.id)),K=n.objects.filter(O=>!B.has(O.id));return K.splice(L,0,...I),n.objects.splice(0,n.objects.length,...K),{floorId:n.floorId,groupId:e.groupId,rowIds:I.map(O=>O.id),createdRowIds:A,removedRowIds:D,changed:a!==JSON.stringify(I)||A.length>0||D.length>0}}var ci=300;function li(t,e){return t.filter(n=>(n.type==="row"||n.type==="table"||n.type==="booth"||n.type==="gaArea")&&!(n.type==="row"&&n.referenceScan?.assetId===e))}function di(t,e,n,o){let i=t.sectionId?e.find(s=>s.type==="section"&&s.id===t.sectionId):void 0;if(i){let s=li(e,n).filter(c=>N(F(c),i.outline,i.holes));if(s.length)return{skip:{sectionId:i.id,name:t.name,reason:"section_not_empty",objectIds:s.map(c=>c.id)},rows:[],seats:0}}let a=[],r=0;for(let s of t.rows){let c=Math.min(ci,Math.max(1,Math.round(s.seatCount)));if(!Number.isFinite(c)||c<1)continue;let l=s.end.x-s.start.x,d=s.end.y-s.start.y,g=Math.hypot(l,d),b=c>1&&g>0?g/(c-1):o>0?o:24;if(!Number.isFinite(b)||b<=0)continue;let f=g>0?Math.atan2(d,l)*180/Math.PI:0;a.push({label:V(a.length),origin:{x:s.start.x,y:s.start.y},rotation:f,seatCount:c,seatSpacing:b}),r+=c}return{skip:null,rows:a,seats:r}}function ui(t,e,n){R(t,n.categoryKey);let o=C(t,n.floorId),i=e.assetId,a=[],r=o.objects.filter(b=>b.type==="row"&&b.referenceScan?.assetId===i?(a.push(b.id),!1):!0);o.objects.splice(0,o.objects.length,...r);let s=[],c=[],l=[],d=new Set,g=0;for(let b of e.sections){let f=di(b,o.objects,i,e.seatPitch);if(f.skip){c.push(f.skip);continue}let h=f.rows.map(y=>({type:"row",id:M(t,"r",n.idFactory,d),referenceScan:{assetId:i},label:y.label,origin:y.origin,rotation:y.rotation,curve:0,seatCount:y.seatCount,seatSpacing:y.seatSpacing,categoryKey:n.categoryKey}));o.objects.push(...h);for(let y of h)l.push(y.id);s.push({sectionId:b.sectionId,name:b.name,seats:f.seats,rows:h.length}),g+=f.seats}return{floorId:o.floorId,assetId:i,createdRowIds:l,removedRowIds:a,totalSeats:g,perSection:s,skipped:c}}function An(t,e){let n=C(t,e.floorId),o=[...new Set(e.objectIds)];if(!o.length)throw new u("invalid_operation","Select at least one table or booth to repeat");let i=o.map(f=>n.objects.find(h=>(h.type==="table"||h.type==="booth")&&h.id===f)),a=o.filter((f,h)=>!i[h]);if(a.length)throw new u("object_not_found","One or more grid sources do not exist on the selected floor",{objectIds:a});let r=i[0].type;if(i.some(f=>f.type!==r))throw new u("invalid_operation","A grid array must contain only tables or only booths");for(let[f,h,y]of[["rows",e.rows,30],["columns",e.columns,30]])if(!Number.isInteger(h)||h<1||h>y)throw new u("invalid_operation",`${f} must be a whole number from 1 to ${y}`);for(let[f,h]of[["stepX",e.stepX],["stepY",e.stepY]])if(!Number.isFinite(h)||h<30||h>2e3)throw new u("invalid_operation",`${f} must be from 30 to 2000 chart units`);let s=e.rows*e.columns;if(s<2)throw new u("invalid_operation","Choose at least two grid cells");let c=o.length*(s-1);if(c>5e3)throw new u("invalid_operation","A grid array can add at most 5000 objects");let l=i.reduce((f,h)=>f+(h.type==="table"?h.seatCount:1),0),g=(t.floors?.length?t.floors.flatMap(f=>f.objects):t.objects).reduce((f,h)=>f+(h.type==="row"||h.type==="table"?h.seatCount:h.type==="gaArea"?Math.max(0,Math.floor(h.capacity)):h.type==="booth"?1:0),0),b=l*(s-1);if(g+b>se)throw new u("invalid_operation",`Grid inventory would exceed the ${se} unit event limit`);return{target:n,sources:i,preview:{floorId:n.floorId,kind:r,sourceIds:o,sourceCount:o.length,cells:s,createdCount:c,addedInventory:b,resultingInventory:g+b,provenanceRemovedCount:i.filter(f=>!!f.referenceInventorySource).length*(s-1)}}}function fi(t,e){return An(t,e).preview}function gi(t,e){let{target:n,sources:o,preview:i}=An(t,e),a=new Set,r=new Set((t.floors?.length?t.floors.flatMap(d=>d.objects):t.objects).flatMap(d=>"label"in d&&d.label?[d.label]:[])),s=[],c=(d,g)=>{let b=Math.max(2,g),f=y=>{let x=`-${y}`;return`${d.slice(0,Math.max(1,80-x.length))}${x}`},h=f(b);for(;r.has(h);)h=f(++b);return r.add(h),h},l=1;for(let d=0;d<e.rows;d++)for(let g=0;g<e.columns;g++)if(!(d===0&&g===0)){l+=1;for(let b of o){let f=structuredClone(b);f.id=M(t,f.type,e.idFactory,a),f.label=c(b.label,l),f.center={x:b.center.x+g*e.stepX,y:b.center.y+d*e.stepY},delete f.referenceInventorySource,s.push(f)}}return n.objects.push(...s),{...i,createdIds:s.map(d=>d.id)}}function bi(t,e){let n=t?{...t}:{};return e.size===null?delete n.size:e.size!==void 0&&(n.size=e.size),e.color===null?delete n.color:e.color!==void 0&&(n.color=T(e.color,"Seat label color")),n.size===void 0&&n.color===void 0?void 0:n}var hi=new Set(ue.map(t=>t.key));function ye(t){return`${t.rowId}:${t.index}`}function pi(t){let e=t.lastIndexOf(":"),n=e>0?t.slice(0,e):"",o=e>0?Number(t.slice(e+1)):Number.NaN;if(!n||!Number.isInteger(o)||o<0)throw new u("invalid_operation",`Invalid stable seat id: ${t}`,{seatId:t});return{rowId:n,index:o}}function mi(t){if(t.label||delete t.label,t.displayLabel||delete t.displayLabel,t.dx||delete t.dx,t.dy||delete t.dy,t.skip||delete t.skip,t.categoryKey||delete t.categoryKey,t.accessible&&!t.accessibility?.length&&(t.accessibility=["wheelchair"]),delete t.accessible,t.wheelchairSpaceType&&!t.accessibility?.includes("wheelchair")&&(t.accessibility=["wheelchair",...t.accessibility??[]]),t.accessibility?.length||delete t.accessibility,t.commercial){let e=t.commercial.note?.normalize("NFKC").trim(),n={};typeof t.commercial.restrictedView=="boolean"&&(n.restrictedView=t.commercial.restrictedView),typeof t.commercial.obstructedView=="boolean"&&(n.obstructedView=t.commercial.obstructedView),typeof t.commercial.premium=="boolean"&&(n.premium=t.commercial.premium),e&&(n.note=e),Object.keys(n).length?t.commercial=n:delete t.commercial}t.viewFromSeatUrl||(delete t.viewFromSeatUrl,delete t.viewFromSeatMeta),t.labelStyle&&t.labelStyle.size===void 0&&t.labelStyle.color===void 0&&delete t.labelStyle}function yi(t){return Object.keys(t).every(e=>e==="index")}function _n(t,e,n){if(!n.length)throw new u("invalid_operation","At least one seat is required");let o=C(t,e),i=[],a=new Set,r=new Map;for(let s of n){let c=ye(s);if(a.has(c))continue;a.add(c);let l=o.objects.find(d=>(d.type==="row"||d.type==="table")&&d.id===s.rowId);if(!l)throw new u("object_not_found",`Unknown row or table for seat: ${c}`,{seatId:c,objectId:s.rowId});if(l.type==="table"&&(l.bookAsWhole||l.variableOccupancy))throw new u("invalid_operation",`Table "${l.label}" is sold as one grouped unit; switch it to individual-chair selling before editing chairs`,{seatId:c,tableId:l.id});if(!Number.isInteger(s.index)||s.index<0||s.index>=l.seatCount)throw new u("invalid_operation",l.type==="row"?`Seat index is outside row bounds: ${c}`:`Chair index is outside table bounds: ${c}`,{seatId:c,objectId:s.rowId,index:s.index,seatCount:l.seatCount});i.push({rowId:s.rowId,index:s.index}),r.set(l.id,l)}return{floorId:o.floorId,refs:i,owners:r}}function wi(t,e){let n=_n(t,e.floorId,e.seats),o=Object.keys(e.patch);if(!o.length&&e.labelPrefix===void 0&&e.displayLabelPrefix===void 0)throw new u("invalid_operation","At least one seat override field is required");if(e.labelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(e.patch,"label"))throw new u("invalid_operation","Use either label or labelPrefix, not both");if(e.displayLabelPrefix!==void 0&&Object.prototype.hasOwnProperty.call(e.patch,"displayLabel"))throw new u("invalid_operation","Use either displayLabel or displayLabelPrefix, not both");if(n.refs.length>1&&e.patch.label!=null)throw new u("invalid_operation","A literal label can only be assigned to one seat; use labelPrefix for a bulk sequence");if(n.refs.length>1&&e.patch.displayLabel!=null)throw new u("invalid_operation","A literal display label can only be assigned to one seat; use displayLabelPrefix for a bulk sequence");if(e.patch.categoryKey&&R(t,e.patch.categoryKey),e.patch.accessibility){let a=e.patch.accessibility.filter(r=>!hi.has(r));if(a.length)throw new u("invalid_operation","Unknown accessibility type",{accessibility:a})}if(e.patch.wheelchairSpaceType!==void 0&&e.patch.wheelchairSpaceType!==null&&e.patch.wheelchairSpaceType!=="seat-present"&&e.patch.wheelchairSpaceType!=="no-seat")throw new u("invalid_operation","wheelchairSpaceType must be seat-present, no-seat, or null");if(e.patch.wheelchairSpaceType&&e.patch.skip===!0)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory");for(let a of n.refs){let r=n.owners.get(a.rowId)?.overrides?.find(l=>l.index===a.index),s=e.patch.wheelchairSpaceType===null?void 0:e.patch.wheelchairSpaceType??r?.wheelchairSpaceType,c=e.patch.skip===null?!1:e.patch.skip??r?.skip??!1;if(s&&c)throw new u("invalid_operation","A wheelchair-space physical type cannot also be skipped inventory",{seatId:ye(a)})}if(e.patch.commercial?.note&&e.patch.commercial.note.normalize("NFKC").trim().length>160)throw new u("invalid_operation","Commercial note supports at most 160 characters");for(let a of["dx","dy"]){let r=e.patch[a];if(r!=null&&!Number.isFinite(r))throw new u("invalid_operation",`${a} must be finite`,{[a]:r})}e.patch.labelStyle!=null&&ae(e.patch.labelStyle,"Seat");let i=!1;return n.refs.forEach((a,r)=>{let s=n.owners.get(a.rowId),c=JSON.stringify(s.overrides??[]),l=s.overrides??(s.overrides=[]),d=l.find(b=>b.index===a.index);d||(d={index:a.index},l.push(d));let g=d.viewFromSeatUrl;for(let b of o){let f=e.patch[b];if(b==="wheelchairSpaceType"&&f==null)delete d.wheelchairSpaceType,d.accessibility&&(d.accessibility=d.accessibility.filter(h=>h!=="wheelchair"),d.accessibility.length||delete d.accessibility),delete d.accessible;else if(f==null)delete d[b];else if(b==="accessibility")d.accessibility=[...new Set(f)],delete d.accessible;else if(b==="commercial")d.commercial={...d.commercial,...f};else if(b==="labelStyle"){let h=bi(d.labelStyle,f);h?d.labelStyle=h:delete d.labelStyle}else Object.assign(d,{[b]:f})}e.patch.viewFromSeatMeta===void 0&&e.patch.viewFromSeatUrl!==void 0&&d.viewFromSeatUrl!==g&&delete d.viewFromSeatMeta,e.labelPrefix!==void 0&&(d.label=`${e.labelPrefix}${r+1}`),e.displayLabelPrefix!==void 0&&(d.displayLabel=`${e.displayLabelPrefix}${r+1}`),mi(d),yi(d)&&(s.overrides=l.filter(b=>b!==d)),s.overrides?.length||delete s.overrides,JSON.stringify(s.overrides??[])!==c&&(i=!0)}),{floorId:n.floorId,changed:i,seatIds:n.refs.map(ye)}}function xi(t,e){let n=_n(t,e.floorId,e.seats),o=!1;for(let[i,a]of n.owners){if(!a.overrides?.length)continue;let r=new Set(n.refs.filter(c=>c.rowId===i).map(c=>c.index)),s=a.overrides.filter(c=>!r.has(c.index));s.length!==a.overrides.length&&(o=!0),a.overrides=s,a.overrides.length||delete a.overrides}return{floorId:n.floorId,changed:o,seatIds:n.refs.map(ye)}}function Si(t,e){let n=C(t,e.floorId),o=[...new Set(e.rowIds)],i=o.map(p=>n.objects.find(m=>m.type==="row"&&m.id===p)),a=o.filter((p,m)=>!i[m]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});if(e.patch.categoryKey!==void 0&&R(t,e.patch.categoryKey),e.patch.seatCount!==void 0&&(!Number.isInteger(e.patch.seatCount)||e.patch.seatCount<1||e.patch.seatCount>300))throw new u("invalid_operation","seatCount must be an integer from 1 to 300");if(e.patch.seatNumbering!==void 0){let p=e.patch.seatNumbering,m=["decimal","odd","even","updown","updown-descending","roman","letters-upper","letters-lower"];if(p.scheme!==void 0&&!m.includes(p.scheme))throw new u("invalid_operation",`Unknown seat numbering scheme: ${p.scheme}. Expected one of ${m.join(", ")}.`);if(p.prefix!==void 0&&(typeof p.prefix!="string"||p.prefix.length>8))throw new u("invalid_operation","Seat label prefix must be a string of at most 8 characters");if(p.endAt!==void 0&&p.endAt!==null&&(!Number.isInteger(p.endAt)||p.endAt<0||p.endAt>9999))throw new u("invalid_operation","Seat numbering endAt must be an integer from 0 to 9999")}let{labelStyle:r,labelPosition:s,labelRotation:c,labelStyleShape:l,displayLabel:d,displayType:g,...b}=e.patch,f=d===void 0?{}:{displayLabel:d},h=ie(f,"Row"),y=g===void 0?void 0:nt(g,"Row");if(r!==void 0&&ae(r,"Row"),s!==void 0&&!["start","end","both","none"].includes(s))throw new u("invalid_operation","Row labelPosition must be one of start, end, both, none");if(c!=null&&(!Number.isFinite(c)||c<-180||c>180))throw new u("invalid_operation","Row labelRotation must be a number from -180 to 180");if(l!==void 0&&l!=="plain"&&l!=="pill")throw new u("invalid_operation","Row labelStyleShape must be plain or pill");b.labelPresentation!==void 0&&Ae(b.labelPresentation,"Row");let x=p=>JSON.stringify({origin:p.origin,rotation:p.rotation,curve:p.curve,seatCount:p.seatCount,seatSpacing:p.seatSpacing,path:p.path??null}),v=!1;for(let p of i){let m=JSON.stringify(p),w=x(p),S=e.preserveCenterOnSeatCountChange&&e.patch.seatCount!==void 0?F(p):null;if(Object.assign(p,structuredClone(b)),p.overrides&&e.patch.seatCount!==void 0&&(p.overrides=p.overrides.filter(I=>I.index<p.seatCount),p.overrides.length||(p.overrides=void 0)),S){let I=F(p);p.origin={x:p.origin.x+S.x-I.x,y:p.origin.y+S.y-I.y}}if(JSON.stringify(p)!==m&&(v=!0),x(p)!==w&&(delete p.arcFanGeneration,delete p.rowBlockGeneration),r!==void 0){let I=JSON.stringify(p.labelPresentation??null),A=_e(p.labelPresentation,r);A?p.labelPresentation=A:delete p.labelPresentation,JSON.stringify(p.labelPresentation??null)!==I&&(v=!0)}if(s!==void 0){let I=JSON.stringify(p.labelPresentation??null),A=p.labelPresentation?structuredClone(p.labelPresentation):{};A.positionPreset=s,A.visible=s!=="none",delete A.position,p.labelPresentation=A,JSON.stringify(p.labelPresentation??null)!==I&&(v=!0)}if(c!==void 0||l!==void 0){let I=JSON.stringify(p.labelPresentation??null),A=p.labelPresentation?structuredClone(p.labelPresentation):{};c===null?delete A.rotation:c!==void 0&&(A.rotation=c),l!==void 0&&(A.style=l),p.labelPresentation=A,JSON.stringify(p.labelPresentation??null)!==I&&(v=!0)}if(y!==void 0){let I=p.displayType;y?p.displayType=y:delete p.displayType,p.displayType!==I&&(v=!0)}if(d!==void 0){let I=p.displayLabel;h?delete p.displayLabel:p.displayLabel=f.displayLabel,p.displayLabel!==I&&(v=!0)}}return{floorId:n.floorId,changed:v,rowIds:o}}var Ii=3;function Ge(t){return(t%360+360)%360}function vi(t){let e=t.rotation*q;return{x:Math.cos(e),y:Math.sin(e)}}function Ci(t,e){let n=Math.abs(Ge(t-e));return n>180&&(n=360-n),n}function ce(t,e,n){return(t.x-e.x)*n.x+(t.y-e.y)*n.y}function Mn(t){let e=0,n=0;for(let i of t){let a=2*i.rotation*q;e+=Math.cos(a),n+=Math.sin(a)}let o=(e===0&&n===0?0:Math.atan2(n,e))/2;return{x:Math.cos(o),y:Math.sin(o)}}function Pi(t,e,n){if(t.origin={x:t.origin.x+e,y:t.origin.y+n},t.path){let o=i=>({x:i.x+e,y:i.y+n});t.path={start:o(t.path.start),control1:o(t.path.control1),control2:o(t.path.control2),end:o(t.path.end)}}}function jn(t,e){let n=Mn(t),o={x:-n.y,y:n.x},i=F(t[0]),a=t.map(c=>({row:c,coord:ce(F(c),i,o)})).sort((c,l)=>c.coord-l.coord),r=a[0].coord,s=!1;return a.forEach((c,l)=>{let d=r+l*e-c.coord;Math.abs(d)>1e-6&&(Pi(c.row,o.x*d,o.y*d),delete c.row.arcFanGeneration,delete c.row.rowBlockGeneration,s=!0)}),s}function Oi(t,e){let n={x:-e.y,y:e.x},o=F(t[0]),i=t.map(r=>ce(F(r),o,n)).sort((r,s)=>r-s);if(i.length<2)return 28;let a=(i[i.length-1]-i[0])/(i.length-1);return a>.5?a:28}function Ai(t){if(t.seatCount<2){t.curve=0,delete t.path,delete t.arcFanGeneration,delete t.rowBlockGeneration;return}let e=de(t),n=e[0],o=e[e.length-1],i=o.x-n.x,a=o.y-n.y,r=Math.hypot(i,a);t.path&&(t.origin={...n},t.seatSpacing=Math.max(1,r/(t.seatCount-1))),r>1e-6&&(t.rotation=Ge(Math.atan2(a,i)/q)),t.curve=0,delete t.path,delete t.arcFanGeneration,delete t.rowBlockGeneration}function _i(t,e){let n=new Set(t.filter(o=>o.type==="row").map(o=>o.label));for(let o=2;o<1e4;o++){let i=`${e}${o}`.slice(0,80);if(!n.has(i))return i}return`${e}-${Date.now().toString(36)}`}function Mi(t,e){let n=C(t,e.floorId),o=[...new Set(e.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to merge");let i=o.map(S=>n.objects.find(I=>I.type==="row"&&I.id===S)),a=o.filter((S,I)=>!i[I]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=r.filter(S=>S.path||S.curve!==0);if(s.length)throw new u("invalid_operation","Only straight rows can be merged \u2014 straighten the rows first, then merge.",{rowIds:s.map(S=>S.id)});let c=r[0],l=r.find(S=>Ci(S.rotation,c.rotation)>Ii);if(l)throw new u("invalid_operation","Rows must be parallel to merge \u2014 they point in different directions.",{rowIds:[c.id,l.id]});let d=vi(c),g={x:-d.y,y:d.x},b=Math.max(8,c.seatSpacing*.6),f=r.find(S=>Math.abs(ce(S.origin,c.origin,g))>b);if(f){let S=Math.round(Math.abs(ce(f.origin,c.origin,g)));throw new u("invalid_operation",`Rows must lie on the same line to merge \u2014 a selected row is offset ${S} units from the first.`,{rowIds:[c.id,f.id]})}let h=r.slice().sort((S,I)=>ce(S.origin,c.origin,d)-ce(I.origin,c.origin,d)),y=h.reduce((S,I)=>S+I.seatCount,0);if(y>300)throw new u("invalid_operation",`A merged row would have ${y} seats, over the 300-seat row limit. Merge fewer rows.`);let x=h[0],v=[],p=0;for(let S of h){if(S.overrides)for(let I of S.overrides)v.push({...structuredClone(I),index:I.index+p});p+=S.seatCount}x.seatCount=y,x.curve=0,delete x.path,v.length?x.overrides=v:delete x.overrides,delete x.arcFanGeneration,delete x.rowBlockGeneration;let m=h.slice(1).map(S=>S.id),w=new Set(m);for(let S=n.objects.length-1;S>=0;S--)w.has(n.objects[S].id)&&n.objects.splice(S,1);return{floorId:n.floorId,changed:!0,rowId:x.id,removedRowIds:m,seatCount:y}}function ji(t,e){let n=C(t,e.floorId),o=n.objects.find(f=>f.type==="row"&&f.id===e.rowId);if(!o)throw new u("object_not_found","The row id does not exist on the selected floor",{rowIds:[e.rowId]});if(o.path)throw new u("invalid_operation","Cannot split a free-form curved row \u2014 straighten it first, then split.",{rowIds:[o.id]});let i=o.seatCount,a=e.index;if(!Number.isInteger(a)||a<1||a>i-1)throw new u("invalid_operation",`Split position must be a whole number from 1 to ${i-1} (the seat where the second row begins)`);let r=de(o),s=i>1?o.curve/(i-1):0,c=i-a,l={type:"row",id:M(t,"r",e.idFactory,new Set),label:_i(n.objects,o.label),origin:{...r[a]},rotation:Ge(o.rotation-s*a),curve:s*(c-1),seatCount:c,seatSpacing:o.seatSpacing,categoryKey:o.categoryKey};if(o.seatNumbering&&(l.seatNumbering=structuredClone(o.seatNumbering)),o.seatLabelStart!=null&&(l.seatLabelStart=o.seatLabelStart),o.commercial&&(l.commercial=structuredClone(o.commercial)),o.viewFromSeatUrl&&(l.viewFromSeatUrl=o.viewFromSeatUrl),o.viewFromSeatMeta&&(l.viewFromSeatMeta=structuredClone(o.viewFromSeatMeta)),o.confidenceEvidence&&(l.confidenceEvidence=structuredClone(o.confidenceEvidence)),o.labelPresentation){let f=structuredClone(o.labelPresentation);delete f.position,l.labelPresentation=f}let d=[],g=[];if(o.overrides)for(let f of o.overrides)f.index<a?d.push(structuredClone(f)):g.push({...structuredClone(f),index:f.index-a});o.seatCount=a,o.curve=s*(a-1),d.length?o.overrides=d:delete o.overrides,delete o.arcFanGeneration,delete o.rowBlockGeneration,g.length&&(l.overrides=g);let b=n.objects.indexOf(o);return n.objects.splice(b+1,0,l),{floorId:n.floorId,changed:!0,rowId:o.id,newRowId:l.id,firstSeatCount:a,secondSeatCount:c,newLabel:l.label}}function Ri(t,e){let n=C(t,e.floorId),o=[...new Set(e.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to set row spacing");if(!Number.isFinite(e.gap)||e.gap<=0||e.gap>4e3)throw new u("invalid_operation","Row spacing must be a positive value up to 4000 chart units");let i=o.map(s=>n.objects.find(c=>c.type==="row"&&c.id===s)),a=o.filter((s,c)=>!i[c]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=jn(i,e.gap);return{floorId:n.floorId,changed:r,rowIds:o,gap:e.gap}}function ki(t,e){let n=C(t,e.floorId),o=[...new Set(e.rowIds)];if(o.length<2)throw new u("invalid_operation","Select at least two rows to straighten and space evenly");let i=o.map(b=>n.objects.find(f=>f.type==="row"&&f.id===b)),a=o.filter((b,f)=>!i[f]);if(a.length)throw new u("object_not_found","One or more row ids do not exist on the selected floor",{rowIds:a});let r=i,s=()=>JSON.stringify(r.map(b=>[b.origin,b.rotation,b.curve,b.path??null,b.seatSpacing])),c=s();for(let b of r)Ai(b);let l=Mn(r),d=Ge(Math.atan2(l.y,l.x)/q);for(let b of r)b.rotation=d;let g=Oi(r,l);return jn(r,g),{floorId:n.floorId,changed:s()!==c,rowIds:o,gap:g}}var Be=eo(require("polygon-clipping"),1),Rn=100,kn=512,ht=8192,Kn=64,Fn=1e7,k=1e-7;function Gn(t,e){return Math.abs(t.x-e.x)<=k&&Math.abs(t.y-e.y)<=k}function zn(t){let e=t.map(n=>({x:n.x,y:n.y}));for(;e.length>1&&Gn(e[0],e[e.length-1]);)e.pop();return e}function we(t,e,n){let o=H(e,n,t);return Math.abs(o)>k?!1:t.x>=Math.min(e.x,n.x)-k&&t.x<=Math.max(e.x,n.x)+k&&t.y>=Math.min(e.y,n.y)-k&&t.y<=Math.max(e.y,n.y)+k}function Bn(t,e,n,o){let i=H(t,e,n),a=H(t,e,o),r=H(n,o,t),s=H(n,o,e);return(i>k&&a<-k||i<-k&&a>k)&&(r>k&&s<-k||r<-k&&s>k)?!0:Math.abs(i)<=k&&we(n,t,e)||Math.abs(a)<=k&&we(o,t,e)||Math.abs(r)<=k&&we(t,n,o)||Math.abs(s)<=k&&we(e,n,o)}function Fi(t){for(let e=0;e<t.length;e+=1){let n=(e+1)%t.length;for(let o=e+1;o<t.length;o+=1){let i=(o+1)%t.length;if(!(e===o||n===o||i===e)&&Bn(t[e],t[n],t[o],t[i]))return!0}}return!1}function Tn(t,e){return t.some((n,o)=>e.some((i,a)=>Bn(n,t[(o+1)%t.length],i,e[(a+1)%e.length])))}function pt(t,e){return!e.some((n,o)=>we(t,n,e[(o+1)%e.length]))&&N(t,e,void 0)}function Ue(t,e,n){let o=zn(t);if(o.length<3||o.length>kn||o.some((i,a)=>!Number.isFinite(i.x)||!Number.isFinite(i.y)||Math.abs(i.x)>Fn||Math.abs(i.y)>Fn||Gn(i,o[(a+1)%o.length]))||Math.abs(le(o))<=k||Fi(o))throw new u("invalid_operation",`GA area ${n} has an invalid or self-intersecting ${e}; Join Areas accepts 3\u2013${kn} finite vertices per ring.`,{gaAreaId:n,ring:e});return o}function Ti(t){let e=Ue(t.points,"outline",t.id),n=t.holes??[];if(!Array.isArray(n)||n.length>Kn)throw new u("invalid_operation",`GA area ${t.id} has too many cutouts to join`,{gaAreaId:t.id});let o=n.map(i=>Ue(i,"cutout",t.id));for(let i=0;i<o.length;i+=1){let a=o[i];if(!a.flatMap((s,c)=>{let l=a[(c+1)%a.length];return[s,{x:(s.x+l.x)/2,y:(s.y+l.y)/2}]}).every(s=>pt(s,e))||Tn(a,e))throw new u("invalid_operation",`GA area ${t.id} has a cutout outside its outline`,{gaAreaId:t.id,holeIndex:i});for(let s=i+1;s<o.length;s+=1)if(Tn(a,o[s])||pt(a[0],o[s])||pt(o[s][0],a))throw new u("invalid_operation",`GA area ${t.id} has overlapping cutouts`,{gaAreaId:t.id,holeIndex:i})}return{outer:e,holes:o}}function ze(t){return t.map(e=>[e.x,e.y])}function Ln(t){return zn(t.map(([e,n])=>({x:e,y:n})))}function En(t){return Math.abs(t.reduce((e,n,o)=>{let i=t[(o+1)%t.length];return e+n[0]*i[1]-i[0]*n[1]},0))/2}function Li(t){return t.reduce((e,n)=>e+(En(n[0]??[])-n.slice(1).reduce((o,i)=>o+En(i),0)),0)}function mt(t){if(t===void 0)return"undefined";if(t===null||typeof t!="object")return JSON.stringify(t);if(Array.isArray(t))return`[${t.map(mt).join(",")}]`;let e=t;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${mt(e[n])}`).join(",")}}`}function Nn(t,e,n){let o=t[e];if(o===void 0)return null;let i=o.normalize("NFKC").trim();if(!i||i!==o||i.length>n)throw new u("invalid_operation",`GA area ${t.id} has an invalid ${e}; normalize it to 1\u2013${n} characters before joining.`,{gaAreaId:t.id,field:e});return i}function Dn(t){return mt({categoryKey:t.categoryKey,displayLabel:Nn(t,"displayLabel",80),displayType:Nn(t,"displayType",24),referenceInventorySource:t.referenceInventorySource??null})}function $n(t,e){let n=Math.min(...t.points.map(i=>i.y)),o=Math.min(...t.points.map(i=>i.x));return[n,o,e]}function Ei(t,e){return t[0]-e[0]||t[1]-e[1]||t[2]-e[2]}function Un(t,e){let n=C(t,e.floorId),o=[...new Set(e.gaAreaIds)];if(o.length<2)throw new u("invalid_operation","Select at least two GA areas to join");if(o.length>Rn)throw new u("invalid_operation",`Join Areas supports at most ${Rn} areas at once`);let i=o.map(P=>n.objects.find(_=>_.type==="gaArea"&&_.id===P)),a=o.filter((P,_)=>!i[_]);if(a.length)throw new u("object_not_found","One or more GA area ids do not exist on the selected floor",{gaAreaIds:a});let r=i;R(t,r[0].categoryKey);let s=Dn(r[0]),c=r.find(P=>Dn(P)!==s);if(c)throw new u("invalid_operation","GA areas must use the same category, displayed label, displayed type, and reference-inventory provenance before they can be joined.",{gaAreaIds:[r[0].id,c.id]});let l=ge(t).objectToSection,d=l.get(r[0].id)??"__ungrouped__",g=r.find(P=>(l.get(P.id)??"__ungrouped__")!==d);if(g)throw new u("invalid_operation","GA areas must belong to the same buyer section before they can be joined.",{gaAreaIds:[r[0].id,g.id],sectionIds:[d,l.get(g.id)??"__ungrouped__"]});let b=r.reduce((P,_)=>{if(!Number.isInteger(_.capacity)||_.capacity<1||_.capacity>ee)throw new u("invalid_operation",`GA area ${_.id} has invalid capacity`,{gaAreaId:_.id});return P+_.capacity},0);if(b>ee)throw new u("invalid_operation",`Joined GA capacity would be ${b}, over the ${ee}-unit area limit`,{capacity:b});let f=J(t).reduce((P,_)=>P+Q(_),0);if(f>se)throw new u("invalid_operation",`Chart inventory exceeds the ${se}-unit publication limit`,{inventory:f});let h=r.map(Ti),y=h.reduce((P,_)=>P+_.outer.length+_.holes.reduce((U,Y)=>U+Y.length,0),0);if(y>ht)throw new u("invalid_operation",`Join Areas supports at most ${ht} source vertices`,{vertexCount:y});let x;try{let P=h.map(Y=>[ze(Y.outer)]);if(x=Be.default.union(P[0],...P.slice(1)),x.length!==1)throw new u("invalid_operation","Selected GA areas must overlap or share an edge. Disconnected or point-only contact cannot produce one sellable surface.",{surfaceCount:x.length});let _=h.flatMap(Y=>Y.holes.map(Ve=>[ze(Ve)]));_.length&&(x=Be.default.difference(x,..._));let U=h.findIndex(Y=>{let Ve=[ze(Y.outer),...Y.holes.map(ze)];return Li(Be.default.intersection(Ve,x))<=k});if(U>=0)throw new u("invalid_operation",`GA area ${r[U].id} contributes no sellable surface after preserving every source cutout.`,{gaAreaId:r[U].id})}catch(P){throw P instanceof u?P:new u("invalid_operation","The selected GA boundaries could not be joined safely",{reason:P instanceof Error?P.message:"polygon_union_failed"})}if(x.length!==1||!x[0]?.length)throw new u("invalid_operation","Joining these boundaries would create disconnected sellable surfaces; adjust the outlines or cutouts first.",{surfaceCount:x.length});let v=Ln(x[0][0]),p=x[0].slice(1).map(Ln),m=v.length+p.reduce((P,_)=>P+_.length,0);if(p.length>Kn||m>ht)throw new u("invalid_operation","The joined boundary is too complex to store safely",{holeCount:p.length,vertexCount:m});Ue(v,"outline",r[0].id),p.forEach(P=>Ue(P,"cutout",r[0].id));let w=new Map(n.objects.map((P,_)=>[P.id,_])),S=r.slice().sort((P,_)=>Ei($n(P,w.get(P.id)??Number.MAX_SAFE_INTEGER),$n(_,w.get(_.id)??Number.MAX_SAFE_INTEGER))),I=S[0],A=structuredClone(t),D=C(A,n.floorId),L=D.objects.find(P=>P.type==="gaArea"&&P.id===I.id);L.points=structuredClone(v),p.length?L.holes=structuredClone(p):delete L.holes;let B=new Set(S.slice(1).map(P=>P.id));for(let P=D.objects.length-1;P>=0;P-=1)B.has(D.objects[P].id)&&D.objects.splice(P,1);let K=ge(A).objectToSection.get(I.id)??"__ungrouped__";if(K!==d)throw new u("invalid_operation","The joined surface would change buyer-section ownership; adjust the GA or section boundaries first.",{gaAreaId:I.id,beforeSectionId:d,afterSectionId:K});let O=[],G=new Set;for(let P of S){if(!at(P))throw new u("invalid_operation",`GA area ${P.id} has invalid inventory provenance and cannot be joined`,{gaAreaId:P.id});let _=te(P);if(_.length!==P.capacity||_.some(U=>G.has(U)))throw new u("invalid_operation","Selected GA areas contain duplicated or incomplete stable inventory identities",{gaAreaId:P.id});_.forEach(U=>G.add(U)),O.push(...ke(P))}if(O.length>256)throw new u("invalid_operation","Joined inventory provenance would exceed 256 durable source ranges");let j=new Set(r.map(P=>P.id));for(let P of J(t).filter(_=>_.type==="gaArea"&&!j.has(_.id))){let _=te(P).find(U=>G.has(U));if(_)throw new u("invalid_operation","A stable GA inventory identity is already owned by another area",{label:_,gaAreaId:P.id})}let He=S.slice(1).map(P=>P.id);return{floorId:n.floorId,areaId:I.id,survivorLabel:I.label,removedAreaIds:He,sourceAreaCount:S.length,capacity:b,inventorySegmentCount:O.length,outerVertexCount:v.length,holeCount:p.length,sectionId:d,points:v,...p.length?{holes:p}:{},segments:O}}function Ni(t,e){let{segments:n,...o}=Un(t,e);return o}function Di(t,e){let n=Un(t,e),o=C(t,n.floorId),i=o.objects.find(c=>c.type==="gaArea"&&c.id===n.areaId);i.points=structuredClone(n.points),n.holes?.length?i.holes=structuredClone(n.holes):delete i.holes,i.capacity=n.capacity,i.inventorySegments=structuredClone(n.segments);let a=new Set(n.removedAreaIds);for(let c=o.objects.length-1;c>=0;c-=1)a.has(o.objects[c].id)&&o.objects.splice(c,1);let{segments:r,...s}=n;return{...s,changed:!0}}var Hn=[{key:"rect",label:"Flat stage",icon:"\u25AD",blurb:"Classic proscenium box."},{key:"rounded",label:"Rounded",icon:"\u25A2",blurb:"Softened corners."},{key:"arc",label:"Curved front",icon:"\u25D7",blurb:"Front edge bows toward the audience."},{key:"thrust",label:"Thrust (T)",icon:"\u22A4",blurb:"Central tongue projects into the crowd."},{key:"runway",label:"Runway",icon:"\u2337",blurb:"Long catwalk into the audience."},{key:"round",label:"In the round",icon:"\u25EF",blurb:"Central platform, audience all around."}];var $i=Math.PI*2;function Ki(t,e,n,o,i,a){return{x:i+t*n-e*o,y:a+t*o+e*n}}function Vn(t){let{kind:e,cx:n,cy:o,width:i,height:a}=t,r=(t.rotation??0)*Math.PI/180,s=Math.cos(r),c=Math.sin(r),l=i/2,d=a/2,g=[],b=(f,h)=>{g.push({x:f,y:h})};switch(e){case"rect":{b(-l,-d),b(l,-d),b(l,d),b(-l,d);break}case"rounded":{let f=Math.min(i,a)*.18,h=5,y=(x,v,p)=>{for(let m=0;m<=h;m++){let w=p+m/h*(Math.PI/2);b(x+f*Math.cos(w),v+f*Math.sin(w))}};y(l-f,-d+f,-Math.PI/2),y(l-f,d-f,0),y(-l+f,d-f,Math.PI/2),y(-l+f,-d+f,Math.PI);break}case"arc":{let f=a*.45;b(-l,-d),b(l,-d);let h=24;for(let y=0;y<=h;y++){let x=y/h,v=l-x*i,p=d+f*(1-Math.pow(2*v/i,2));b(v,p)}break}case"thrust":{let f=i*.18,h=a*1.1;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+h),b(-f,d+h),b(-f,d),b(-l,d);break}case"runway":{let f=i*.1,h=a*3;b(-l,-d),b(l,-d),b(l,d),b(f,d),b(f,d+h),b(-f,d+h),b(-f,d),b(-l,d);break}case"round":{for(let h=0;h<40;h++){let y=h/40*$i;b(l*Math.cos(y),d*Math.sin(y))}break}}return g.map(f=>Ki(f.x,f.y,s,c,n,o))}function Gi(t,e){let n=C(t,e.floorId),o=[...new Set(e.shapeIds)];if(!o.length)throw new u("invalid_operation","At least one shape id is required");let i=o.map(l=>n.objects.find(d=>d.type==="shape"&&d.id===l)),a=o.filter((l,d)=>!i[d]);if(a.length)throw new u("object_not_found",`Unknown shape id(s): ${a.join(", ")} on the selected floor. Call get_chart to list current shape ids.`,{shapeIds:a});let r=structuredClone(e.patch);if(!Object.keys(r).length)throw new u("invalid_operation","At least one shape change is required");if(r.label!==void 0){if(o.length!==1)throw new u("invalid_operation","label can be changed only for one shape at a time");if(r.label!==null){if(r.label=r.label.normalize("NFKC").trim(),!r.label)r.label=null;else if(r.label.length>80)throw new u("invalid_operation","Shape labels support at most 80 characters")}}if(r.fill!==void 0&&r.fill!==null&&(r.fill=T(r.fill,"Shape fill")),r.kind!==void 0&&!["rect","ellipse","polygon","line","polyline"].includes(r.kind))throw new u("invalid_operation","Shape kind must be rect, ellipse, polygon, line, or polyline");if(r.stroke!==void 0&&r.stroke!==null){if(!Number.isFinite(r.stroke.width)||r.stroke.width<.5||r.stroke.width>40)throw new u("invalid_operation","Shape stroke width must be from 0.5 to 40 chart units");r.stroke={color:T(r.stroke.color,"Shape stroke"),width:r.stroke.width}}if(r.cornerRadius!==void 0&&r.cornerRadius!==null&&(!Number.isFinite(r.cornerRadius)||r.cornerRadius<0||r.cornerRadius>5e3))throw new u("invalid_operation","Shape cornerRadius must be from 0 to 5000 chart units");if(r.opacity!==void 0&&r.opacity!==null&&(!Number.isFinite(r.opacity)||r.opacity<.1||r.opacity>1))throw new u("invalid_operation","Shape opacity must be from 0.1 to 1");if(r.heightM!==void 0&&r.heightM!==null&&(!Number.isFinite(r.heightM)||r.heightM<.05||r.heightM>50))throw new u("invalid_operation","Shape heightM must be from 0.05 to 50 metres");if(r.eventConfigurationIds!==void 0&&r.eventConfigurationIds!==null){let l=r.eventConfigurationIds.map(d=>d.normalize("NFKC").trim());if(!l.length||l.length>20||l.some(d=>!d||d.length>100)||new Set(l).size!==l.length)throw new u("invalid_operation","Shape event configurations must contain 1 to 20 unique ids");r.eventConfigurationIds=l}if(r.lineCap!==void 0&&r.lineCap!==null&&!un.includes(r.lineCap))throw new u("invalid_operation","Shape lineCap must be butt, round, or square");if(r.lineJoin!==void 0&&r.lineJoin!==null&&!fn.includes(r.lineJoin))throw new u("invalid_operation","Shape lineJoin must be miter, round, or bevel");for(let[l,d]of[["startEnding",r.startEnding],["endEnding",r.endEnding]])if(d!=null&&!gn.includes(d))throw new u("invalid_operation",`Shape ${l} must be none or arrow`);if(r.lineCap!=null||r.lineJoin!=null||r.startEnding!=null||r.endEnding!=null){let l=i.filter(d=>!ut(r.kind??d.kind));if(l.length)throw new u("invalid_operation","Line caps, joins, and start/end decorations apply only to open line or polyline shapes",{shapeIds:l.map(d=>d.id)})}let c=!1;for(let l of i){let d=JSON.stringify(l);if(r.label===null?delete l.label:r.label!==void 0&&(l.label=r.label),r.fill===null?delete l.fill:r.fill!==void 0&&(l.fill=r.fill),r.kind!==void 0&&(l.kind=r.kind,ut(l.kind)||(delete l.lineCap,delete l.lineJoin,delete l.startEnding,delete l.endEnding)),r.stroke===null?delete l.stroke:r.stroke!==void 0&&(l.stroke={...r.stroke}),r.opacity===null?delete l.opacity:r.opacity!==void 0&&(l.opacity=r.opacity),r.heightM===null?delete l.heightM:r.heightM!==void 0&&(l.heightM=r.heightM),r.eventConfigurationIds===null?delete l.eventConfigurationIds:r.eventConfigurationIds!==void 0&&(l.eventConfigurationIds=[...r.eventConfigurationIds]),r.lineCap===null?delete l.lineCap:r.lineCap!==void 0&&(l.lineCap=r.lineCap),r.lineJoin===null?delete l.lineJoin:r.lineJoin!==void 0&&(l.lineJoin=r.lineJoin),r.startEnding===null?delete l.startEnding:r.startEnding!==void 0&&(l.startEnding=r.startEnding),r.endEnding===null?delete l.endEnding:r.endEnding!==void 0&&(l.endEnding=r.endEnding),r.cornerRadius===null)delete l.cornerRadius;else if(r.cornerRadius!==void 0){let g=Math.min(l.width??1/0,l.height??1/0),b=Number.isFinite(g)?g/2:r.cornerRadius;l.cornerRadius=l.kind==="rect"?Math.max(0,Math.min(r.cornerRadius,b)):r.cornerRadius}JSON.stringify(l)!==d&&(c=!0)}return{floorId:n.floorId,changed:c,shapeIds:o}}function Jn(t){if(t.x!=null&&t.y!=null&&t.width!=null&&t.height!=null){if(![t.x,t.y,t.width,t.height].every(Number.isFinite)||t.width<=0||t.height<=0)throw new u("invalid_operation",`Stage ${t.id} has an invalid stored base box`,{stageId:t.id});return{cx:t.x+t.width/2,cy:t.y+t.height/2,width:t.width,height:t.height}}let e=t.points??[];if(e.length<3||e.some(d=>!Number.isFinite(d.x)||!Number.isFinite(d.y)))throw new u("invalid_operation",`Stage ${t.id} has no valid geometry from which to derive its base box`,{stageId:t.id});let n=e.map(d=>d.x),o=e.map(d=>d.y),i=Math.min(...n),a=Math.max(...n),r=Math.min(...o),s=Math.max(...o),c=Math.max(1,a-i),l=Math.max(1,s-r);return{cx:i+c/2,cy:r+l/2,width:c,height:l}}function zi(t,e){let n=C(t,e.floorId);if(!e.updates.length)throw new u("invalid_operation","At least one shape resize is required");let o=e.updates.map(r=>r.shapeId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Shape ids must be unique");let i=e.updates.map(r=>{if(![r.width,r.height].every(Number.isFinite)||r.width<8||r.height<8||r.width>1e4||r.height>1e4)throw new u("invalid_operation","Shape width and height must be between 8 and 10000 chart units",{shapeId:r.shapeId});let s=n.objects.find(l=>l.type==="shape"&&l.id===r.shapeId);if(!s)throw new u("object_not_found",`Unknown shape id: ${r.shapeId}`,{shapeId:r.shapeId});let c=s.role==="stage"?Jn(s):(s.kind==="rect"||s.kind==="ellipse")&&s.x!=null&&s.y!=null&&s.width!=null&&s.height!=null?{cx:s.x+s.width/2,cy:s.y+s.height/2,width:s.width,height:s.height}:(()=>{let l=s.points??[];if(l.length<3||l.some(x=>!Number.isFinite(x.x)||!Number.isFinite(x.y)))throw new u("invalid_operation",`Shape ${s.id} has no resizable geometry`,{shapeId:s.id});let d=l.map(x=>x.x),g=l.map(x=>x.y),b=Math.min(...d),f=Math.max(...d),h=Math.min(...g),y=Math.max(...g);return{cx:(b+f)/2,cy:(h+y)/2,width:Math.max(1,f-b),height:Math.max(1,y-h)}})();return{shape:s,update:r,box:c}}),a=!1;for(let{shape:r,update:s,box:c}of i)if(!(Math.abs(c.width-s.width)<1e-9&&Math.abs(c.height-s.height)<1e-9)){if(r.kind==="rect"||r.kind==="ellipse")r.x=c.cx-s.width/2,r.y=c.cy-s.height/2,r.width=s.width,r.height=s.height;else{let l=s.width/c.width,d=s.height/c.height;r.points=(r.points??[]).map(g=>({x:c.cx+(g.x-c.cx)*l,y:c.cy+(g.y-c.cy)*d})),(r.x!=null||r.y!=null||r.width!=null||r.height!=null||r.role==="stage")&&(r.x=c.cx-s.width/2,r.y=c.cy-s.height/2,r.width=s.width,r.height=s.height)}a=!0}return{floorId:n.floorId,changed:a,shapes:i.map(({shape:r,update:s})=>({id:r.id,width:s.width,height:s.height}))}}function Bi(t,e){let n=C(t,e.floorId);if(!e.updates.length)throw new u("invalid_operation","At least one stage update is required");let o=e.updates.map(s=>s.stageId);if(new Set(o).size!==o.length)throw new u("invalid_operation","Stage ids must be unique");let i=new Set(Hn.map(s=>s.key)),a=e.updates.map(s=>{if(!i.has(s.stageKind))throw new u("invalid_operation",`Unknown stage kind: ${s.stageKind}`,{stageKind:s.stageKind});let c=n.objects.find(l=>l.type==="shape"&&l.id===s.stageId);if(!c)throw new u("object_not_found",`Unknown stage id: ${s.stageId}. Call get_chart to list current stage ids.`,{stageId:s.stageId});if(c.role!=="stage")throw new u("invalid_operation",`Shape ${s.stageId} is not tagged as a stage`,{stageId:s.stageId});return{shape:c,stageKind:s.stageKind,box:c.stageKind===s.stageKind?null:Jn(c)}}),r=!1;for(let s of a)s.box&&(s.shape.points=Vn({kind:s.stageKind,...s.box}),s.shape.kind="polygon",s.shape.stageKind=s.stageKind,r=!0);return{floorId:n.floorId,changed:r,stages:a.map(s=>({id:s.shape.id,stageKind:s.stageKind}))}}0&&(module.exports={COLORBLIND_SAFE_PALETTE,ChartOperationError,DEFAULT_FLOOR_HEIGHT_STEP_M,DEFAULT_SECTION_CORNER_SMOOTHING,MAX_FLOOR_BASE_HEIGHT_M,addArcFanRows,addBookableGridArray,addBoothArray,addChartCategory,addChartFloor,addChartZone,addGAArea,addRowBlock,addTableArray,applyPolygonHole,applyReferenceScanRows,applySectionCornerSmoothing,applySectionOutlineShaping,applySectionRowFit,arcFanInputForGroup,assignSectionInventoryCategory,automaticPlacementCenter,confirmReferenceCategoryOutputColor,convertGeneratedSectionToPolygon,countCoveredInventory,familyCategoryLabel,gaAreaFootprint,groupRowsAsSegmented,insertSeatingBlock,joinGAAreas,mergeRows,mirrorFirstFloor,parseSeatRefId,pickColorblindSafeCategoryColor,previewArcFanRows,previewBookableGridArray,previewGeneratedSectionPolygonConversion,previewJoinGAAreas,previewPolygonHole,previewRemovePolygonHole,previewRowCubicPath,previewSectionRowFit,reassignColorblindSafeCategoryColors,relabelChartRows,removeChartCategory,removeChartFloor,removeChartObjects,removeChartZone,removePolygonHole,renameChartFloor,reorderChartCategories,replaceArcFanRows,replaceRowBlock,resetSeatOverrides,resizeShapes,resolveCreationCategory,seatRefId,sectionInventorySelectionSummary,setRowBlockSpacing,splitRow,straightenAndSpaceRows,transformSectionBoundary,transformSectionBoundaryObject,ungroupSegmentedRow,updateBooths,updateCategoryDefinitions,updateChartFloorBaseHeight,updateChartTheme,updateChartZones,updateGAAreas,updateRowCubicPath,updateRows,updateSeatOverrides,updateSectionExactPath,updateSectionMetadata,updateSegmentedRow,updateShapes,updateStageKinds,updateTables,updateTextObjects,updateViewFromSeatFallback});